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