@cloudbase/cals 1.0.3-alpha.8 → 1.0.3-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser/cals/index.d.ts +379 -366
- package/lib/parser/cals/index.d.ts.map +1 -1
- package/lib/parser/cals/index.js +75 -13
- package/lib/parser/cals/utils/block/index.d.ts +14 -14
- package/lib/parser/cals/utils/block/index.d.ts.map +0 -0
- package/lib/parser/cals/utils/block/index.js +3 -3
- package/lib/parser/cals/utils/code/index.d.ts +30 -30
- package/lib/parser/cals/utils/code/index.d.ts.map +0 -0
- package/lib/parser/cals/utils/code/index.js +12 -13
- package/lib/parser/cals/utils/common.d.ts +11 -11
- package/lib/parser/cals/utils/common.d.ts.map +0 -0
- package/lib/parser/cals/utils/common.js +0 -0
- package/lib/parser/cals/utils/runtime.d.ts +13 -13
- package/lib/parser/cals/utils/runtime.d.ts.map +1 -1
- package/lib/parser/cals/utils/runtime.js +2 -2
- package/lib/parser/cals/utils/spinoff/index.d.ts +9 -9
- package/lib/parser/cals/utils/spinoff/index.d.ts.map +0 -0
- package/lib/parser/cals/utils/spinoff/index.js +0 -0
- package/lib/parser/cals/utils/style.d.ts +42 -42
- package/lib/parser/cals/utils/style.d.ts.map +1 -1
- package/lib/parser/cals/utils/style.js +3 -3
- package/lib/parser/cals/utils/template.d.ts +5 -5
- package/lib/parser/cals/utils/template.d.ts.map +0 -0
- package/lib/parser/cals/utils/template.js +6 -3
- package/lib/parser/cals/utils/version/common.d.ts +4 -4
- package/lib/parser/cals/utils/version/common.d.ts.map +0 -0
- package/lib/parser/cals/utils/version/common.js +34 -11
- package/lib/parser/cals/utils/version/config.d.ts +13 -13
- package/lib/parser/cals/utils/version/config.d.ts.map +0 -0
- package/lib/parser/cals/utils/version/config.js +0 -0
- package/lib/parser/cals/utils/version/index.d.ts +2 -2
- package/lib/parser/cals/utils/version/index.d.ts.map +0 -0
- package/lib/parser/cals/utils/version/index.js +0 -0
- package/lib/parser/cals/utils/version/parses.d.ts +15 -15
- package/lib/parser/cals/utils/version/parses.d.ts.map +0 -0
- package/lib/parser/cals/utils/version/parses.js +37 -14
- package/lib/parser/cals/utils/version/utils.d.ts +13 -13
- package/lib/parser/cals/utils/version/utils.d.ts.map +1 -1
- package/lib/parser/cals/utils/version/utils.js +2 -2
- package/lib/parser/constants.d.ts +2 -0
- package/lib/parser/constants.d.ts.map +1 -0
- package/lib/parser/constants.js +4 -0
- package/lib/parser/expression/index.d.ts +122 -122
- package/lib/parser/expression/index.d.ts.map +0 -0
- package/lib/parser/expression/index.js +0 -0
- package/lib/parser/index.d.ts +8 -8
- package/lib/parser/index.d.ts.map +0 -0
- package/lib/parser/index.js +0 -0
- package/lib/parser/plugins/postcss-rpx2clac.d.ts +17 -17
- package/lib/parser/plugins/postcss-rpx2clac.js +2 -2
- package/lib/types/basic/app.d.ts +72 -72
- package/lib/types/basic/app.d.ts.map +0 -0
- package/lib/types/basic/app.js +0 -0
- package/lib/types/basic/common.d.ts +88 -88
- package/lib/types/basic/common.d.ts.map +1 -1
- package/lib/types/basic/common.js +0 -0
- package/lib/types/basic/component.d.ts +213 -208
- package/lib/types/basic/component.d.ts.map +1 -1
- package/lib/types/basic/component.js +0 -0
- package/lib/types/basic/datasource.d.ts +49 -49
- package/lib/types/basic/datasource.d.ts.map +0 -0
- package/lib/types/basic/datasource.js +0 -0
- package/lib/types/index.d.ts +10 -9
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -14
- package/lib/types/lcds.d.ts +334 -447
- package/lib/types/lcds.d.ts.map +1 -1
- package/lib/types/lcds.js +0 -0
- package/lib/types/platform/app.d.ts +176 -176
- package/lib/types/platform/app.d.ts.map +0 -0
- package/lib/types/platform/app.js +0 -0
- package/lib/types/platform/common.d.ts +147 -137
- package/lib/types/platform/common.d.ts.map +1 -1
- package/lib/types/platform/common.js +0 -0
- package/lib/types/platform/component.d.ts +145 -140
- package/lib/types/platform/component.d.ts.map +1 -1
- package/lib/types/platform/component.js +0 -0
- package/lib/types/platform/datasource.d.ts +466 -466
- package/lib/types/platform/datasource.d.ts.map +0 -0
- package/lib/types/platform/datasource.js +0 -0
- package/lib/types/platform/eventFlow.d.ts +20 -0
- package/lib/types/platform/eventFlow.d.ts.map +1 -0
- package/lib/types/platform/eventFlow.js +2 -0
- package/lib/types/platform/query.d.ts +58 -0
- package/lib/types/platform/query.d.ts.map +1 -0
- package/lib/types/platform/query.js +2 -0
- package/lib/types/platform/widget/form.d.ts +89 -89
- package/lib/types/platform/widget/form.d.ts.map +0 -0
- package/lib/types/platform/widget/form.js +0 -0
- package/lib/types/platform/widget/meta.d.ts +59 -59
- package/lib/types/platform/widget/meta.d.ts.map +0 -0
- package/lib/types/platform/widget/meta.js +0 -0
- package/lib/utils/CSSProperty.d.ts +63 -63
- package/lib/utils/CSSProperty.d.ts.map +0 -0
- package/lib/utils/CSSProperty.js +0 -0
- package/lib/utils/build.d.ts +1 -1
- package/lib/utils/build.d.ts.map +0 -0
- package/lib/utils/build.js +6 -3
- package/lib/utils/constant.d.ts +40 -40
- package/lib/utils/constant.d.ts.map +0 -0
- package/lib/utils/constant.js +0 -0
- package/lib/utils/dts/auto-generated.d.ts +1 -1
- package/lib/utils/dts/auto-generated.d.ts.map +1 -1
- package/lib/utils/dts/auto-generated.js +35 -1227
- package/lib/utils/dts/build.d.ts +1 -1
- package/lib/utils/dts/build.js +4 -1
- package/lib/utils/dts/index.d.ts +93 -130
- package/lib/utils/dts/index.d.ts.map +1 -1
- package/lib/utils/dts/index.js +66 -359
- package/lib/utils/index.d.ts +7 -7
- package/lib/utils/index.d.ts.map +0 -0
- package/lib/utils/index.js +0 -0
- package/lib/utils/version/common.d.ts +2 -2
- package/lib/utils/version/featureChecker.d.ts +2 -2
- package/lib/utils/version/featureChecker.d.ts.map +1 -1
- package/lib/utils/version/migrations/version4.d.ts +2 -2
- package/lib/utils/version/migrations/version4.js +2 -2
- package/lib/utils/version-migrations/common.d.ts +5 -0
- package/lib/utils/version-migrations/common.d.ts.map +1 -0
- package/lib/utils/version-migrations/common.js +29 -0
- package/lib/utils/version-migrations/version4.d.ts +3 -0
- package/lib/utils/version-migrations/version4.d.ts.map +1 -0
- package/lib/utils/version-migrations/version4.js +199 -0
- package/package.json +3 -13
- package/lib/cloudbase.cals.umd.min.js +0 -5
package/lib/utils/dts/index.js
CHANGED
|
@@ -8,13 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.compileJSONToDTS = exports.jsonToDTSWorkerCode = exports.transpileToDTS = exports.workerCode = exports.generateWeDaAppDTS = exports.WeDaDTS = exports.IInputDataType = void 0;
|
|
16
|
-
const lodash_es_1 = require("lodash-es");
|
|
17
|
-
const json_easy_filter_1 = __importDefault(require("json-easy-filter"));
|
|
18
13
|
const auto_generated_1 = require("./auto-generated");
|
|
19
14
|
var IInputDataType;
|
|
20
15
|
(function (IInputDataType) {
|
|
@@ -31,7 +26,6 @@ var IInputDataType;
|
|
|
31
26
|
IInputDataType["usedComponents"] = "usedComponents";
|
|
32
27
|
IInputDataType["usedWidgets"] = "usedWidgets";
|
|
33
28
|
IInputDataType["repeaterScope"] = "repeaterScope";
|
|
34
|
-
IInputDataType["redefineAnyType"] = "redefineAnyType";
|
|
35
29
|
})(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
|
|
36
30
|
const DtsPlaceholder = {
|
|
37
31
|
[IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
|
|
@@ -46,34 +40,23 @@ const DtsPlaceholder = {
|
|
|
46
40
|
[IInputDataType.compPropEvents]: "// Comp Prop Events 组件事件 - Don't touch me",
|
|
47
41
|
[IInputDataType.usedComponents]: "// Used Components - Don't touch me",
|
|
48
42
|
[IInputDataType.usedWidgets]: "// used widgets - Don't touch me",
|
|
49
|
-
[IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
|
|
50
|
-
[IInputDataType.redefineAnyType]: "// Redefine Any Type - Don't touch me",
|
|
43
|
+
[IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
|
|
51
44
|
};
|
|
52
45
|
const DtsInnerSign = {
|
|
53
|
-
[IInputDataType.globalState]:
|
|
54
|
-
[IInputDataType.pageState]:
|
|
55
|
-
[IInputDataType.compState]:
|
|
56
|
-
[IInputDataType.pageParams]:
|
|
57
|
-
[IInputDataType.forState]:
|
|
58
|
-
[IInputDataType.globalCommonCodes]:
|
|
59
|
-
[IInputDataType.pageHandlerCodes]:
|
|
60
|
-
[IInputDataType.compHandlerCodes]:
|
|
61
|
-
[IInputDataType.compPropData]:
|
|
62
|
-
[IInputDataType.compPropEvents]:
|
|
63
|
-
[IInputDataType.usedComponents]:
|
|
64
|
-
[IInputDataType.usedWidgets]:
|
|
65
|
-
[IInputDataType.repeaterScope]:
|
|
66
|
-
[IInputDataType.redefineAnyType]: 'Redefine Any Type Inner',
|
|
46
|
+
[IInputDataType.globalState]: "Global State Inner",
|
|
47
|
+
[IInputDataType.pageState]: "Page State Inner",
|
|
48
|
+
[IInputDataType.compState]: "Comp State Inner",
|
|
49
|
+
[IInputDataType.pageParams]: "Page Param Inner",
|
|
50
|
+
[IInputDataType.forState]: "Global For Inner",
|
|
51
|
+
[IInputDataType.globalCommonCodes]: "Global Common Inner",
|
|
52
|
+
[IInputDataType.pageHandlerCodes]: "Page Handler Inner",
|
|
53
|
+
[IInputDataType.compHandlerCodes]: "Comp Handler Inner",
|
|
54
|
+
[IInputDataType.compPropData]: "Comp Prop Data Inner",
|
|
55
|
+
[IInputDataType.compPropEvents]: "Comp Prop Events Inner",
|
|
56
|
+
[IInputDataType.usedComponents]: "Used Components Inner",
|
|
57
|
+
[IInputDataType.usedWidgets]: "used widgets Inner",
|
|
58
|
+
[IInputDataType.repeaterScope]: "repeater scope Inner"
|
|
67
59
|
};
|
|
68
|
-
var GroupEnum;
|
|
69
|
-
(function (GroupEnum) {
|
|
70
|
-
GroupEnum["GLOBAL_VAR"] = "globalVar";
|
|
71
|
-
GroupEnum["PAGE_VAR"] = "pageVar";
|
|
72
|
-
GroupEnum["PAGE_PARAM"] = "pageParam";
|
|
73
|
-
GroupEnum["COMPONENT"] = "component";
|
|
74
|
-
GroupEnum["REPEATER"] = "repeater";
|
|
75
|
-
GroupEnum["DATA_FIELD"] = "dataField";
|
|
76
|
-
})(GroupEnum || (GroupEnum = {}));
|
|
77
60
|
/**
|
|
78
61
|
* 通过该类可以共享同个dts。
|
|
79
62
|
* 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析
|
|
@@ -92,25 +75,19 @@ class WeDaDTS {
|
|
|
92
75
|
*/
|
|
93
76
|
static updateDTSPartial(inputData, itemType, options = { setEmptyIfError: false }) {
|
|
94
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
let dts = '';
|
|
95
79
|
try {
|
|
96
|
-
|
|
97
|
-
replaceRules.forEach((rule) => {
|
|
98
|
-
WeDaDTS._dts = WeDaDTS._dts.replace(rule.from, rule.to);
|
|
99
|
-
});
|
|
80
|
+
dts = yield _generateOneItemDTS(inputData, itemType);
|
|
100
81
|
WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
|
|
101
82
|
}
|
|
102
83
|
catch (e) {
|
|
103
84
|
if (options.setEmptyIfError) {
|
|
104
|
-
WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${
|
|
85
|
+
WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
|
|
105
86
|
}
|
|
106
87
|
}
|
|
107
88
|
});
|
|
108
89
|
}
|
|
109
|
-
static getDTS(options = {
|
|
110
|
-
needGlobalFormula: false,
|
|
111
|
-
needGlobalFor: false,
|
|
112
|
-
needRepeaterScope: false,
|
|
113
|
-
}) {
|
|
90
|
+
static getDTS(options = { needGlobalFormula: false, needGlobalFor: false, needRepeaterScope: false }) {
|
|
114
91
|
let resultDts = WeDaDTS._dts;
|
|
115
92
|
if (!options.needGlobalFormula) {
|
|
116
93
|
resultDts = resultDts.replace(/^\/\/ Global Formula Begin[\s\S]*^\/\/ Global Formula End$/m, '');
|
|
@@ -137,11 +114,8 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
137
114
|
if (placeholder) {
|
|
138
115
|
// 防止某项错误导致全部都错误
|
|
139
116
|
try {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
resultDts = resultDts.replace(rule.from, rule.to);
|
|
143
|
-
});
|
|
144
|
-
resultDts = resultDts.replace(placeholder, dts + '\n' + placeholder);
|
|
117
|
+
const dts = yield _generateOneItemDTS(inputData[key], key);
|
|
118
|
+
resultDts = resultDts.replace(placeholder, dts + placeholder);
|
|
145
119
|
}
|
|
146
120
|
catch (e) {
|
|
147
121
|
console.error(e);
|
|
@@ -167,151 +141,17 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
167
141
|
if (!(options === null || options === void 0 ? void 0 : options.needRepeaterScope)) {
|
|
168
142
|
resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
|
|
169
143
|
}
|
|
144
|
+
// console.log(resultDts)
|
|
170
145
|
return resultDts;
|
|
171
146
|
});
|
|
172
147
|
}
|
|
173
148
|
exports.generateWeDaAppDTS = generateWeDaAppDTS;
|
|
174
|
-
/**
|
|
175
|
-
* 生成 weda 专有的注释信息
|
|
176
|
-
*/
|
|
177
|
-
function genWeDaCodeComment({ fieldName, title, description, type, dataFieldInfo, group, schema, subGroup, baseClass, datasource, }) {
|
|
178
|
-
const desc = title || fieldName ? `${title || fieldName}\n${description || ''}` : '';
|
|
179
|
-
return (desc +
|
|
180
|
-
`\n@privateForWeDa\n${JSON.stringify({
|
|
181
|
-
group,
|
|
182
|
-
displayType: type,
|
|
183
|
-
displayName: title || '',
|
|
184
|
-
schema,
|
|
185
|
-
subGroup,
|
|
186
|
-
baseClass,
|
|
187
|
-
datasource,
|
|
188
|
-
dataFieldInfo,
|
|
189
|
-
})}`);
|
|
190
|
-
}
|
|
191
149
|
/**
|
|
192
150
|
* 生成指定类型的 DTS
|
|
193
151
|
*/
|
|
194
152
|
function _generateOneItemDTS(inputData, itemType) {
|
|
195
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
const replaceRules = [];
|
|
197
|
-
/**
|
|
198
|
-
* 获取数据字段的类型
|
|
199
|
-
*/
|
|
200
|
-
function getDataFieldDisplayType(format) {
|
|
201
|
-
const nameMap = {
|
|
202
|
-
email: 'email',
|
|
203
|
-
url: 'url',
|
|
204
|
-
tel: 'tel',
|
|
205
|
-
phone: 'phone',
|
|
206
|
-
'x-image': 'image',
|
|
207
|
-
'x-rtf': 'rtf',
|
|
208
|
-
datetime: 'datetime',
|
|
209
|
-
date: 'date',
|
|
210
|
-
time: 'time',
|
|
211
|
-
'x-enum': 'enum',
|
|
212
|
-
'x-location': 'location',
|
|
213
|
-
'x-file': 'file',
|
|
214
|
-
related: 'related',
|
|
215
|
-
'father-son': 'father-son',
|
|
216
|
-
'x-autonumber': 'autonumber',
|
|
217
|
-
'x-area-code': 'area-code',
|
|
218
|
-
function: 'function',
|
|
219
|
-
};
|
|
220
|
-
return nameMap[format];
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* 处理注释信息
|
|
224
|
-
*/
|
|
225
|
-
function _handleComment(inputData, group, needKeepSchema) {
|
|
226
|
-
const _inputData = (0, lodash_es_1.cloneDeep)(inputData);
|
|
227
|
-
json_easy_filter_1.default.traverse(_inputData, function (key, value, path) {
|
|
228
|
-
var _a;
|
|
229
|
-
if ((value === null || value === void 0 ? void 0 : value.type) && !((_a = value === null || value === void 0 ? void 0 : value.type) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
230
|
-
// value?.type?.type 有值,则证明 type 是自定义的字段,而非 JSONSchema 中的 type
|
|
231
|
-
let schema = null;
|
|
232
|
-
if (needKeepSchema) {
|
|
233
|
-
const isFirstLevel = path.length === 2 && (path === null || path === void 0 ? void 0 : path[0]) === 'properties';
|
|
234
|
-
if (isFirstLevel) {
|
|
235
|
-
// 只需要第一级属性需要保存,且只保存子信息(对象或数组的子项)
|
|
236
|
-
schema = value.properties || value.items ? value : null;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
// 特殊处理数据字段的类型
|
|
240
|
-
let type = value.type;
|
|
241
|
-
if (group === GroupEnum.DATA_FIELD) {
|
|
242
|
-
type = getDataFieldDisplayType(value.format) || type;
|
|
243
|
-
}
|
|
244
|
-
value.description = genWeDaCodeComment({
|
|
245
|
-
fieldName: key,
|
|
246
|
-
title: value.title,
|
|
247
|
-
description: value.description,
|
|
248
|
-
group,
|
|
249
|
-
type,
|
|
250
|
-
dataFieldInfo: (0, lodash_es_1.pick)(value, ['type', 'format', 'x-system']),
|
|
251
|
-
schema,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
_inputData.description = ''; // 避免第一层出现注释
|
|
256
|
-
return _inputData;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* 获取用于显示的数据类型(仅有 number, string , boolean, array, object 等内置基础类型)
|
|
260
|
-
*/
|
|
261
|
-
function getDisplayReturnType(typeStr) {
|
|
262
|
-
let displayType = typeStr.trim();
|
|
263
|
-
if (displayType.endsWith('[]')) {
|
|
264
|
-
displayType = 'array';
|
|
265
|
-
}
|
|
266
|
-
else if (displayType.endsWith('}')) {
|
|
267
|
-
displayType = 'object';
|
|
268
|
-
}
|
|
269
|
-
return displayType;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* 获取组件接口定义名称
|
|
273
|
-
*/
|
|
274
|
-
function _genCompInterfaceName(module, component) {
|
|
275
|
-
return `${module.replace(/-/g, '_')}_${component}`;
|
|
276
|
-
}
|
|
277
|
-
function _compile(jsonschema, isObjNeedWrapper = false) {
|
|
278
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
let dts = yield compileJSONToDTS(jsonschema);
|
|
280
|
-
if (dts.search(/^export interface IWeDa/) >= 0) {
|
|
281
|
-
dts = dts.replace(/^export interface.*$/m, '');
|
|
282
|
-
dts = dts.substring(0, dts.length - 2);
|
|
283
|
-
if (isObjNeedWrapper) {
|
|
284
|
-
dts = `{${dts}}`;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
dts = dts.replace(/^export type IWeDa =/m, '');
|
|
289
|
-
}
|
|
290
|
-
return dts;
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
154
|
const hanlderMap = {
|
|
294
|
-
[IInputDataType.globalState]: function (inputData) {
|
|
295
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
296
|
-
// 完善注释信息
|
|
297
|
-
const handledInputData = _handleComment(inputData, GroupEnum.GLOBAL_VAR, true);
|
|
298
|
-
return yield _compile(handledInputData);
|
|
299
|
-
});
|
|
300
|
-
},
|
|
301
|
-
[IInputDataType.pageState]: function (inputData) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
// 完善注释信息
|
|
304
|
-
const handledInputData = _handleComment(inputData, GroupEnum.PAGE_VAR, true);
|
|
305
|
-
return yield _compile(handledInputData);
|
|
306
|
-
});
|
|
307
|
-
},
|
|
308
|
-
[IInputDataType.pageParams]: function (inputData) {
|
|
309
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
-
// 完善注释信息
|
|
311
|
-
const handledInputData = _handleComment(inputData, GroupEnum.PAGE_PARAM);
|
|
312
|
-
return yield _compile(handledInputData);
|
|
313
|
-
});
|
|
314
|
-
},
|
|
315
155
|
[IInputDataType.globalCommonCodes]: function (inputData) {
|
|
316
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
317
157
|
const dts = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -355,11 +195,9 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
355
195
|
},
|
|
356
196
|
[IInputDataType.compPropEvents]: function (inputData) {
|
|
357
197
|
const IData = `any`;
|
|
358
|
-
return inputData
|
|
359
|
-
.map((eventName) => {
|
|
198
|
+
return inputData.map(eventName => {
|
|
360
199
|
return `function ${eventName}(data?: ${IData}): void`;
|
|
361
|
-
})
|
|
362
|
-
.join('\n');
|
|
200
|
+
}).join('\n');
|
|
363
201
|
},
|
|
364
202
|
[IInputDataType.usedComponents]: function (inputData) {
|
|
365
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -367,8 +205,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
367
205
|
// 属性
|
|
368
206
|
let exportPropertiesDTS = '';
|
|
369
207
|
if (item.exportProperties) {
|
|
370
|
-
|
|
371
|
-
exportPropertiesDTS = yield _compile(handledProperties);
|
|
208
|
+
exportPropertiesDTS = yield _compile(item.exportProperties);
|
|
372
209
|
}
|
|
373
210
|
// 方法
|
|
374
211
|
let exportMethodsDTS = '';
|
|
@@ -401,18 +238,8 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
401
238
|
// ${exportMethodsDTS}
|
|
402
239
|
// }
|
|
403
240
|
// `
|
|
404
|
-
const interfaceName = _genCompInterfaceName(item.module, item.component);
|
|
405
241
|
return `
|
|
406
|
-
|
|
407
|
-
${genWeDaCodeComment({
|
|
408
|
-
fieldName: interfaceName,
|
|
409
|
-
schema: item.exportProperties,
|
|
410
|
-
})
|
|
411
|
-
.split('\n')
|
|
412
|
-
.map((item) => `* ${item}`)
|
|
413
|
-
.join('\n')}
|
|
414
|
-
*/
|
|
415
|
-
declare class ${interfaceName} extends UserWidget {
|
|
242
|
+
declare class ${_genCompInterfaceName(item.module, item.component)} extends UserWidget {
|
|
416
243
|
|
|
417
244
|
${exportPropertiesDTS}
|
|
418
245
|
|
|
@@ -424,162 +251,21 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
424
251
|
});
|
|
425
252
|
},
|
|
426
253
|
[IInputDataType.usedWidgets]: function (inputData) {
|
|
427
|
-
return inputData
|
|
428
|
-
.map((item) => {
|
|
254
|
+
return inputData.map(item => {
|
|
429
255
|
if (item.idList && item.idList.length > 0) {
|
|
430
256
|
const interfaceName = _genCompInterfaceName(item.module, item.component);
|
|
431
|
-
return item.idList
|
|
432
|
-
.map((id) => `
|
|
433
|
-
/**
|
|
434
|
-
${genWeDaCodeComment({
|
|
435
|
-
fieldName: id,
|
|
436
|
-
title: '',
|
|
437
|
-
description: '',
|
|
438
|
-
group: GroupEnum.COMPONENT,
|
|
439
|
-
type: 'component',
|
|
440
|
-
baseClass: interfaceName,
|
|
441
|
-
datasource: `$${id}_start$ $${id}_end$`,
|
|
442
|
-
})
|
|
443
|
-
.split('\n')
|
|
444
|
-
.map((item) => `* ${item}`)
|
|
445
|
-
.join('\n')}
|
|
446
|
-
*/
|
|
447
|
-
const ${id}: ${interfaceName}`)
|
|
448
|
-
.join('\n');
|
|
257
|
+
return item.idList.map(id => `const ${id}: ${interfaceName}`).join('\n');
|
|
449
258
|
}
|
|
450
259
|
return '';
|
|
451
|
-
})
|
|
452
|
-
.join('\n');
|
|
260
|
+
}).join('\n');
|
|
453
261
|
},
|
|
454
262
|
[IInputDataType.repeaterScope]: function (inputData) {
|
|
455
263
|
return __awaiter(this, void 0, void 0, function* () {
|
|
456
264
|
const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
457
|
-
let itemDataDTS =
|
|
458
|
-
if (item.itemData.title) {
|
|
459
|
-
// 特殊场景:数据字段
|
|
460
|
-
const handledInputData = _handleComment(item.itemData, GroupEnum.DATA_FIELD);
|
|
461
|
-
itemDataDTS = yield _compile(handledInputData, true);
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
// 普通的循环项数据
|
|
465
|
-
itemDataDTS = yield _compile(item.itemData, true);
|
|
466
|
-
}
|
|
265
|
+
let itemDataDTS = yield _compile(item.itemData, true);
|
|
467
266
|
return `
|
|
468
|
-
/**
|
|
469
|
-
${genWeDaCodeComment({
|
|
470
|
-
fieldName: item.currentItemAlias,
|
|
471
|
-
title: '当前项值',
|
|
472
|
-
description: '',
|
|
473
|
-
group: GroupEnum.REPEATER,
|
|
474
|
-
type: getDisplayReturnType(itemDataDTS),
|
|
475
|
-
schema: item.itemData,
|
|
476
|
-
subGroup: item.widgetId,
|
|
477
|
-
})
|
|
478
|
-
.split('\n')
|
|
479
|
-
.map((item) => `* ${item}`)
|
|
480
|
-
.join('\n')}
|
|
481
|
-
*/
|
|
482
267
|
const ${item.currentItemAlias}: ${itemDataDTS}
|
|
483
|
-
/**
|
|
484
|
-
${genWeDaCodeComment({
|
|
485
|
-
fieldName: item.currentIndexAlias,
|
|
486
|
-
title: '当前下标',
|
|
487
|
-
description: '',
|
|
488
|
-
group: GroupEnum.REPEATER,
|
|
489
|
-
type: 'number',
|
|
490
|
-
subGroup: item.widgetId,
|
|
491
|
-
})
|
|
492
|
-
.split('\n')
|
|
493
|
-
.map((item) => `* ${item}`)
|
|
494
|
-
.join('\n')}
|
|
495
|
-
*/
|
|
496
268
|
const ${item.currentIndexAlias}: number
|
|
497
|
-
`;
|
|
498
|
-
})));
|
|
499
|
-
return results.join('\n');
|
|
500
|
-
});
|
|
501
|
-
},
|
|
502
|
-
[IInputDataType.redefineAnyType]: function (inputData) {
|
|
503
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
504
|
-
const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
505
|
-
const compInterfaceName = _genCompInterfaceName(item.module, item.component);
|
|
506
|
-
const widgetInterfaceName = `${item.widgetId}_${compInterfaceName}`;
|
|
507
|
-
/**
|
|
508
|
-
* 更新 widget 的类型名
|
|
509
|
-
*/
|
|
510
|
-
replaceRules.push({
|
|
511
|
-
from: new RegExp(`(const ${item.widgetId}): .*`),
|
|
512
|
-
to: `$1: ${widgetInterfaceName}`,
|
|
513
|
-
});
|
|
514
|
-
/**
|
|
515
|
-
* 增加类
|
|
516
|
-
*/
|
|
517
|
-
const datasources = {};
|
|
518
|
-
const propDefinitions = yield Promise.all(item.updateProps.map((prop) => __awaiter(this, void 0, void 0, function* () {
|
|
519
|
-
const properties = _handleComment(prop.widgetPropTypeSchema, GroupEnum.DATA_FIELD);
|
|
520
|
-
const widgetPropTypeDTS = yield _compile(Object.assign(Object.assign({}, prop.widgetPropTypeSchema), properties), true);
|
|
521
|
-
// 同个数据源,有可能是数组类型,所以需要区分开
|
|
522
|
-
const id = `${prop.datasource.name}_${prop.widgetPropTypeSchema.type}`;
|
|
523
|
-
if (!datasources[id]) {
|
|
524
|
-
datasources[id] = {
|
|
525
|
-
fields: [{ name: prop.widgetPropName, title: prop.widgetPropTitle }],
|
|
526
|
-
schema: prop.widgetPropTypeSchema,
|
|
527
|
-
name: prop.datasource.name,
|
|
528
|
-
title: prop.datasource.title,
|
|
529
|
-
id: prop.datasource.id,
|
|
530
|
-
type: prop.datasource.type,
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
datasources[id].fields.push({ name: prop.widgetPropName, title: prop.widgetPropTitle });
|
|
535
|
-
}
|
|
536
|
-
// 是否是多层级字段,如 "a.b"
|
|
537
|
-
// FIXME: 当前只支持 a.b 这种形式,不支持 a[].b
|
|
538
|
-
const multiLevelField = prop.widgetPropName.includes('.');
|
|
539
|
-
let multiLevelFields = [];
|
|
540
|
-
let multiLevelFieldObj = {};
|
|
541
|
-
let firstField = '';
|
|
542
|
-
let othersFields = [];
|
|
543
|
-
if (multiLevelField) {
|
|
544
|
-
multiLevelFields = prop.widgetPropName.split('.');
|
|
545
|
-
(0, lodash_es_1.set)(multiLevelFieldObj, prop.widgetPropName, '$$schema$$');
|
|
546
|
-
const [_firstField, ..._othersFields] = multiLevelFields;
|
|
547
|
-
firstField = _firstField;
|
|
548
|
-
othersFields = _othersFields;
|
|
549
|
-
}
|
|
550
|
-
return `
|
|
551
|
-
/**
|
|
552
|
-
${genWeDaCodeComment({
|
|
553
|
-
fieldName: prop.widgetPropName,
|
|
554
|
-
title: prop.widgetPropTypeSchema.title,
|
|
555
|
-
description: prop.widgetPropTypeSchema.description,
|
|
556
|
-
group: undefined,
|
|
557
|
-
type: getDisplayReturnType(widgetPropTypeDTS),
|
|
558
|
-
})
|
|
559
|
-
.split('\n')
|
|
560
|
-
.map((item) => `* ${item}`)
|
|
561
|
-
.join('\n')}
|
|
562
|
-
*/
|
|
563
|
-
${multiLevelField
|
|
564
|
-
? `${firstField}: Omit<${compInterfaceName}['${firstField}'], '${othersFields.join('.')}'> & ${JSON.stringify(multiLevelFieldObj[firstField]).replace('"$$schema$$"', widgetPropTypeDTS)}`
|
|
565
|
-
: `${prop.widgetPropName}: ${widgetPropTypeDTS}`}
|
|
566
|
-
`;
|
|
567
|
-
})));
|
|
568
|
-
/**
|
|
569
|
-
* 更新数据源信息
|
|
570
|
-
*/
|
|
571
|
-
const datasourceInfoList = Object.values(datasources);
|
|
572
|
-
if (datasourceInfoList.length > 0) {
|
|
573
|
-
replaceRules.push({
|
|
574
|
-
from: new RegExp(`(\\$${item.widgetId}_start\\$).*(\\$${item.widgetId}_end\\$)`),
|
|
575
|
-
// encodeURIComponent 是为了能正常 parse 成 JSON
|
|
576
|
-
to: `$1${encodeURIComponent(JSON.stringify(datasourceInfoList))}$2`,
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
return `
|
|
580
|
-
declare class ${widgetInterfaceName} extends ${compInterfaceName} {
|
|
581
|
-
${propDefinitions.join('\n')}
|
|
582
|
-
}
|
|
583
269
|
`;
|
|
584
270
|
})));
|
|
585
271
|
return results.join('\n');
|
|
@@ -588,14 +274,33 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
588
274
|
};
|
|
589
275
|
let dts = '';
|
|
590
276
|
if (!inputData)
|
|
591
|
-
return
|
|
277
|
+
return dts;
|
|
592
278
|
const handler = hanlderMap[itemType];
|
|
593
279
|
// 优先判断是否有独立的处理逻辑
|
|
594
280
|
if (handler) {
|
|
595
281
|
dts = yield handler.call(hanlderMap, inputData);
|
|
596
282
|
}
|
|
597
283
|
dts = dts || (yield _compile(inputData));
|
|
598
|
-
return
|
|
284
|
+
return dts;
|
|
285
|
+
function _genCompInterfaceName(module, component) {
|
|
286
|
+
return `${module.replace(/-/g, '_')}_${component}`;
|
|
287
|
+
}
|
|
288
|
+
function _compile(jsonschema, isObjNeedWrapper = false) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
let dts = yield compileJSONToDTS(jsonschema);
|
|
291
|
+
if (dts.search(/^export interface IWeDa/) >= 0) {
|
|
292
|
+
dts = dts.replace(/^export interface.*$/m, '');
|
|
293
|
+
dts = dts.substring(0, dts.length - 2);
|
|
294
|
+
if (isObjNeedWrapper) {
|
|
295
|
+
dts = `{${dts}}`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
dts = dts.replace(/^export type IWeDa =/m, '');
|
|
300
|
+
}
|
|
301
|
+
return dts;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
599
304
|
});
|
|
600
305
|
}
|
|
601
306
|
// 仅仅为了与 unittest 共享,外部请不要使用
|
|
@@ -675,18 +380,20 @@ function TypescriptWorker(workerId, workerCode) {
|
|
|
675
380
|
typescriptWorker.onmessage = function (event) {
|
|
676
381
|
const { action } = event.data;
|
|
677
382
|
if (action === 'dts_back') {
|
|
678
|
-
const { data: { id, dts }
|
|
383
|
+
const { data: { id, dts } } = event.data;
|
|
679
384
|
sendMessageCallbackFn[id] && sendMessageCallbackFn[id](dts);
|
|
680
385
|
}
|
|
681
386
|
};
|
|
682
387
|
typescriptWorkerMap[workerId] = {
|
|
683
388
|
typescriptWorker,
|
|
684
|
-
sendMessageCallbackFn
|
|
389
|
+
sendMessageCallbackFn
|
|
685
390
|
};
|
|
686
391
|
}
|
|
687
392
|
function sendMessage(msgData, callbackFn) {
|
|
688
393
|
const { typescriptWorker, sendMessageCallbackFn } = typescriptWorkerMap[workerId];
|
|
689
|
-
const id = Math.random()
|
|
394
|
+
const id = Math.random()
|
|
395
|
+
.toString(36)
|
|
396
|
+
.substring(2, 5);
|
|
690
397
|
msgData.data.id = id;
|
|
691
398
|
sendMessageCallbackFn[id] = callbackFn;
|
|
692
399
|
typescriptWorker.postMessage(msgData);
|
|
@@ -695,22 +402,22 @@ function TypescriptWorker(workerId, workerCode) {
|
|
|
695
402
|
};
|
|
696
403
|
}
|
|
697
404
|
/**
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
405
|
+
* 使用:
|
|
406
|
+
* const typescriptWorker = getTypescriptWorker();
|
|
407
|
+
* typescriptWorker.sendMessage({ action: 'dts', data: { code } }, dts => {
|
|
408
|
+
*
|
|
409
|
+
* })
|
|
410
|
+
* // 以下暂未实现
|
|
411
|
+
* typescriptWorker.sendMessage({ action: 'ts', data: { code } }, ts => {
|
|
412
|
+
*
|
|
413
|
+
* })
|
|
414
|
+
*/
|
|
708
415
|
const getTypescriptWorker = TypescriptWorker('transpileToDTS', exports.workerCode);
|
|
709
416
|
/**
|
|
710
417
|
* 通过 js/ts 代码生成 dts
|
|
711
418
|
*/
|
|
712
419
|
function transpileToDTS(code) {
|
|
713
|
-
return new Promise(
|
|
420
|
+
return new Promise(resolve => {
|
|
714
421
|
const typescriptWorker = getTypescriptWorker();
|
|
715
422
|
typescriptWorker.sendMessage({ action: 'dts', data: { code } }, (dts) => {
|
|
716
423
|
resolve(dts);
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from '../parser';
|
|
2
|
-
export * from '../types/index';
|
|
3
|
-
export * from './constant';
|
|
4
|
-
export * from './dts/index';
|
|
5
|
-
export { version4 } from './version/migrations/version4';
|
|
6
|
-
export { semverComp } from './version/common';
|
|
7
|
-
export { isUnitlessNumber } from './CSSProperty';
|
|
1
|
+
export * from '../parser';
|
|
2
|
+
export * from '../types/index';
|
|
3
|
+
export * from './constant';
|
|
4
|
+
export * from './dts/index';
|
|
5
|
+
export { version4 } from './version/migrations/version4';
|
|
6
|
+
export { semverComp } from './version/common';
|
|
7
|
+
export { isUnitlessNumber } from './CSSProperty';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/utils/index.d.ts.map
CHANGED
|
File without changes
|
package/lib/utils/index.js
CHANGED
|
File without changes
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function semverComp(a: string, b: string): number;
|
|
2
|
-
export declare function toFixed(num: number, precision: number): number;
|
|
1
|
+
export declare function semverComp(a: string, b: string): number;
|
|
2
|
+
export declare function toFixed(num: number, precision: number): number;
|
|
3
3
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function isEnbaleObserverVersion(dependencies?:
|
|
2
|
-
export declare function isEnablePageRoot(dependencies: any): boolean;
|
|
1
|
+
export declare function isEnbaleObserverVersion(dependencies?: any[]): boolean;
|
|
2
|
+
export declare function isEnablePageRoot(dependencies: any): boolean;
|
|
3
3
|
//# sourceMappingURL=featureChecker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featureChecker.d.ts","sourceRoot":"","sources":["../../../src/utils/version/featureChecker.ts"],"names":[],"mappings":"AAqBA,wBAAgB,uBAAuB,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"featureChecker.d.ts","sourceRoot":"","sources":["../../../src/utils/version/featureChecker.ts"],"names":[],"mappings":"AAqBA,wBAAgB,uBAAuB,CAAC,YAAY,QAAK,WAExD;AAED,wBAAgB,gBAAgB,CAAC,YAAY,KAAA,WAE5C"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { IPlatformApp } from '../../../types';
|
|
2
|
-
export declare function version4(cals: IPlatformApp, isUpgrade: boolean, setSchemaVersionCallback?: (version: string | undefined) => void): IPlatformApp;
|
|
1
|
+
import type { IPlatformApp } from '../../../types';
|
|
2
|
+
export declare function version4(cals: IPlatformApp, isUpgrade: boolean, setSchemaVersionCallback?: (version: string | undefined) => void): IPlatformApp;
|
|
3
3
|
//# sourceMappingURL=version4.d.ts.map
|
|
@@ -15,7 +15,7 @@ exports.version4 = version4;
|
|
|
15
15
|
const transformPxLowcodeCompAndSourceComp = (cals, isUpgrade, setSchemaVersionCallback) => {
|
|
16
16
|
var _a, _b, _c, _d;
|
|
17
17
|
{
|
|
18
|
-
|
|
18
|
+
function transformCals(items, isUpgradeToPx) {
|
|
19
19
|
return items.map((item) => {
|
|
20
20
|
var _a;
|
|
21
21
|
// 对于表单操作区的按钮组件的父容器添加.wd-form__action, 兼容组件规范化按钮升级样式
|
|
@@ -52,7 +52,7 @@ const transformPxLowcodeCompAndSourceComp = (cals, isUpgrade, setSchemaVersionCa
|
|
|
52
52
|
}
|
|
53
53
|
return item;
|
|
54
54
|
});
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
56
|
let pages = cals['items'];
|
|
57
57
|
let isDivision;
|
|
58
58
|
if (isUpgrade && (0, common_1.semverComp)((_a = cals['schemaVersion']) !== null && _a !== void 0 ? _a : '3.0.0', '4.0.0') < 0) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function semverComp(a: string, b: string): number;
|
|
2
|
+
export declare function toFixed(num: number, precision: number): number;
|
|
3
|
+
export declare const OFFICIAL_COMPONENT_LIB_NAME = "CLOUDBASE_STANDARD";
|
|
4
|
+
export declare const OFFICIAL_MATERIAL_LIB_NAME = "gsd-h5-react";
|
|
5
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/version-migrations/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAChE,eAAO,MAAM,0BAA0B,iBAAiB,CAAC"}
|