import { IJsonSchemaAny, IJsonSchemaObject } from '../../types'; export interface IPrivateForWeDa { displayType: string; displayName: string; dataFieldInfo?: { type?: string; format?: string; 'x-system': boolean; }; insertText: string; group?: string; subGroup?: string; doc?: string; description?: string; definition?: string; schema?: IJsonSchemaAny; baseClass?: string; datasource?: string; } export interface IDTSCodeItem { name: string; code: string; } export interface IInputDataUsedComponents { module: string; component: string; exportProperties?: IJsonSchemaObject; exportMethods?: { name: string; input?: IJsonSchemaObject; output?: IJsonSchemaAny; }[]; } export interface IInputDataWidgetItem { module: string; component: string; idList: string[]; extraMap?: Record; } export interface IInputDataRepeaterItem { widgetId: string; currentItemAlias: string; currentIndexAlias: string; itemData: IJsonSchemaAny; } export interface IInputDataRedefineAnyType { module: string; component: string; widgetId: string; updateProps: { widgetPropName: string; widgetPropTitle: string; widgetPropTypeSchema: IJsonSchemaAny; datasource: { id: string; name: string; title: string; type: 'ds' | 'apis'; }; }[]; } export interface IOptions { isCompMode?: boolean; needGlobalFormula?: boolean; needGlobalFor?: boolean; scope?: 'component' | 'page' | 'global'; } export declare enum IInputDataType { globalState = "globalState", globalQuery = "globalQuery", pageState = "pageState", pageQuery = "pageQuery", compState = "compState", pageParams = "pageParams", pageEventFlow = "pageEventFlow", forState = "forState", globalCommonCodes = "globalCommonCodes", pageHandlerCodes = "pageHandlerCodes", compHandlerCodes = "compHandlerCodes", compPropData = "compPropData", compPropEvents = "compPropEvents", usedComponents = "usedComponents", usedWidgets = "usedWidgets", repeaterScope = "repeaterScope", redefineAnyType = "redefineAnyType", serverSideSate = "serverSideSate", dtsString = "dtsString" } export interface IInputData { [IInputDataType.globalState]?: IJsonSchemaObject; [IInputDataType.globalQuery]?: IJsonSchemaObject; [IInputDataType.pageState]?: IJsonSchemaObject; [IInputDataType.pageQuery]?: IJsonSchemaObject; [IInputDataType.pageEventFlow]?: IJsonSchemaObject; [IInputDataType.compState]?: IJsonSchemaObject; [IInputDataType.pageParams]?: IJsonSchemaObject; [IInputDataType.forState]?: IJsonSchemaObject; [IInputDataType.globalCommonCodes]?: IDTSCodeItem[]; [IInputDataType.pageHandlerCodes]?: IDTSCodeItem[]; [IInputDataType.compHandlerCodes]?: IDTSCodeItem[]; [IInputDataType.compPropData]?: IJsonSchemaObject; [IInputDataType.compPropEvents]?: string[]; [IInputDataType.usedComponents]?: IInputDataUsedComponents[]; [IInputDataType.usedWidgets]?: IInputDataWidgetItem[]; [IInputDataType.repeaterScope]?: IInputDataRepeaterItem[]; [IInputDataType.redefineAnyType]?: IInputDataRedefineAnyType[]; [IInputDataType.serverSideSate]?: boolean; [IInputDataType.dtsString]?: string; } /** * 通过该类可以共享同个dts。 * 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析 */ export declare class WeDaDTS { private static _dts; /** * 全部更新 */ static updateDTS(inputData?: IInputData, options?: Pick): Promise; /** * 部分更新 - 只更新一种类型 */ static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[] | IInputDataRedefineAnyType[] | string, itemType: IInputDataType, options?: { setEmptyIfError: boolean; }): Promise; static getDTS(options?: Omit): string; } /** * 生成 WeDa 应用的低码代码提示的 dts 类型声明内容 */ export declare function generateWeDaAppDTS(inputData?: IInputData, options?: IOptions): Promise; export declare const workerCode = "\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/typescriptServices.min.js');\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/ts-lib.min.js');\n\nconst files = {\n \"foo.ts\": '',\n \"lib.d.ts\": libFileMap['lib.es5.d.ts']\n};\n\nfunction createLanguageService() {\n return ts.createLanguageService({\n getCompilationSettings() {\n return {};\n },\n getScriptFileNames() {\n return [\"foo.ts\", \"lib.d.ts\"];\n },\n getScriptVersion(_fileName) {\n // \u8FD9\u6837\u53EF\u907F\u514D\u4F7F\u7528\u7F13\u5B58\n if (_fileName === 'foo.ts')\n return 'v_' + Math.random();\n return ''\n },\n getScriptSnapshot(fileName) {\n if (fileName === \".ts\") {\n return ts.ScriptSnapshot.fromString(\"\");\n }\n return ts.ScriptSnapshot.fromString(files[fileName] || \"\");\n },\n getCurrentDirectory: () => \".\",\n getDefaultLibFileName(options) {\n return 'lib.d.ts'\n },\n fileExists: name => !!files[name],\n readFile: name => {\n return files[name]\n }\n });\n}\nconst languageService = createLanguageService();\n\nfunction transpile(code) {\n files[\"foo.ts\"] = code\n const result = languageService.getEmitOutput(\n \"foo.ts\",\n /*emitOnlyDtsFiles*/ true,\n /*forceDtsEmit*/ true\n )\n return result.outputFiles[0].text.trim()\n}\n\naddEventListener('message', (message) => {\n const {action, data: {id, code}} = message.data\n switch(action) {\n case 'dts':\n const dts = transpile(code)\n postMessage({action: 'dts_back', data: {id, dts}})\n break\n default:\n break\n }\n})\n"; /** * 通过 js/ts 代码生成 dts */ export declare function transpileToDTS(code: string): Promise; export declare const jsonToDTSWorkerCode = "\nimportScripts('https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_url/devtools/json-schema-to-typescript-for-browser.min-11.0.5.js');\n\nfunction transpile(jsonschema) {\n return jstt.compile(jsonschema, 'IWeDa', { additionalProperties: true, bannerComment: '', format: false, unknownAny: false })\n}\n\naddEventListener('message', (message) => {\n const {action, data: {id, jsonschema}} = message.data\n switch(action) {\n case 'dts':\n transpile(jsonschema).then(dts => {\n postMessage({action: 'dts_back', data: {id, dts}})\n }).catch(err => postMessage({action: 'dts_back', data: {id, dts: 'Parse error:' + err.message}}))\n break\n default:\n break\n }\n})\n"; /** * Webworker 版本的 JSON to DTS */ export declare function compileJSONToDTS(jsonschema: any): Promise; //# sourceMappingURL=index.d.ts.map