@cloudbase/cals 0.5.13-alpha.4 → 0.5.14
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 +3 -1
- package/lib/parser/cals/index.d.ts.map +1 -1
- package/lib/parser/cals/index.js +13 -1
- package/lib/parser/cals/utils/common.d.ts +1 -1
- package/lib/parser/cals/utils/common.d.ts.map +1 -1
- package/lib/parser/cals/utils/version/common.d.ts.map +1 -1
- package/lib/parser/cals/utils/version/common.js +17 -16
- package/lib/parser/cals/utils/version/parses.d.ts.map +1 -1
- package/lib/parser/cals/utils/version/parses.js +4 -3
- 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/types/platform/app.d.ts +1 -1
- package/lib/types/platform/app.d.ts.map +1 -1
- package/lib/types/platform/component.d.ts +1 -1
- package/lib/types/platform/component.d.ts.map +1 -1
- package/lib/types/platform/datasource.d.ts +4 -4
- package/lib/types/platform/datasource.d.ts.map +1 -1
- package/lib/utils/constant.d.ts +8 -0
- package/lib/utils/constant.d.ts.map +1 -1
- package/lib/utils/constant.js +9 -1
- 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 +20 -1159
- package/lib/utils/dts/build.js +1 -1
- package/lib/utils/dts/index.d.ts +2 -13
- package/lib/utils/dts/index.d.ts.map +1 -1
- package/lib/utils/dts/index.js +32 -196
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +4 -2
- package/lib/utils/version/common.d.ts +3 -0
- package/lib/utils/version/common.d.ts.map +1 -0
- package/lib/utils/version/common.js +27 -0
- package/lib/utils/version/featureChecker.d.ts +3 -0
- package/lib/utils/version/featureChecker.d.ts.map +1 -0
- package/lib/utils/version/featureChecker.js +31 -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 +2 -2
package/lib/utils/dts/build.js
CHANGED
|
@@ -44,7 +44,7 @@ function buildFormulaDTS() {
|
|
|
44
44
|
const dts = yield fs_extra_1.default.readFile(tempDtsPath, 'utf8');
|
|
45
45
|
yield fs_extra_1.default.remove(tempDtsPath);
|
|
46
46
|
// 去掉最外层的模块声明
|
|
47
|
-
return dts.replace(/^declare module.*$/m, '').replace(
|
|
47
|
+
return dts.replace(/^declare module.*$/m, '').replace(/\}$/m, '').replace(/^\s+/mg, '');
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
});
|
package/lib/utils/dts/index.d.ts
CHANGED
|
@@ -23,15 +23,6 @@ export interface IInputDataRepeaterItem {
|
|
|
23
23
|
currentIndexAlias: string;
|
|
24
24
|
itemData: IJsonSchemaAny;
|
|
25
25
|
}
|
|
26
|
-
export interface IInputDataRedefineAnyType {
|
|
27
|
-
module: string;
|
|
28
|
-
component: string;
|
|
29
|
-
widgetId: string;
|
|
30
|
-
updateProps: {
|
|
31
|
-
widgetPropName: string;
|
|
32
|
-
widgetPropTypeSchema: IJsonSchemaAny;
|
|
33
|
-
}[];
|
|
34
|
-
}
|
|
35
26
|
export interface IOptions {
|
|
36
27
|
isCompMode?: boolean;
|
|
37
28
|
needGlobalFormula?: boolean;
|
|
@@ -51,8 +42,7 @@ export declare enum IInputDataType {
|
|
|
51
42
|
compPropEvents = "compPropEvents",
|
|
52
43
|
usedComponents = "usedComponents",
|
|
53
44
|
usedWidgets = "usedWidgets",
|
|
54
|
-
repeaterScope = "repeaterScope"
|
|
55
|
-
redefineAnyType = "redefineAnyType"
|
|
45
|
+
repeaterScope = "repeaterScope"
|
|
56
46
|
}
|
|
57
47
|
export interface IInputData {
|
|
58
48
|
[IInputDataType.globalState]?: IJsonSchemaObject;
|
|
@@ -68,7 +58,6 @@ export interface IInputData {
|
|
|
68
58
|
[IInputDataType.usedComponents]?: IInputDataUsedComponents[];
|
|
69
59
|
[IInputDataType.usedWidgets]?: IInputDataWidgetItem[];
|
|
70
60
|
[IInputDataType.repeaterScope]?: IInputDataRepeaterItem[];
|
|
71
|
-
[IInputDataType.redefineAnyType]?: IInputDataRedefineAnyType[];
|
|
72
61
|
}
|
|
73
62
|
/**
|
|
74
63
|
* 通过该类可以共享同个dts。
|
|
@@ -83,7 +72,7 @@ export declare class WeDaDTS {
|
|
|
83
72
|
/**
|
|
84
73
|
* 部分更新 - 只更新一种类型
|
|
85
74
|
*/
|
|
86
|
-
static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[]
|
|
75
|
+
static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[], itemType: IInputDataType, options?: {
|
|
87
76
|
setEmptyIfError: boolean;
|
|
88
77
|
}): Promise<void>;
|
|
89
78
|
static getDTS(options?: Omit<IOptions, "isCompMode">): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG/D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,iBAAiB,CAAA;IACpC,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAA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5D;AAID,eAAO,MAAM,mBAAmB,+tBAmB/B,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,KAAA,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5D"}
|
package/lib/utils/dts/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.compileJSONToDTS = exports.jsonToDTSWorkerCode = exports.transpileToDTS = exports.workerCode = exports.generateWeDaAppDTS = exports.WeDaDTS = exports.IInputDataType = void 0;
|
|
13
|
-
const lodash_1 = require("lodash");
|
|
14
13
|
const auto_generated_1 = require("./auto-generated");
|
|
15
14
|
var IInputDataType;
|
|
16
15
|
(function (IInputDataType) {
|
|
@@ -27,7 +26,6 @@ var IInputDataType;
|
|
|
27
26
|
IInputDataType["usedComponents"] = "usedComponents";
|
|
28
27
|
IInputDataType["usedWidgets"] = "usedWidgets";
|
|
29
28
|
IInputDataType["repeaterScope"] = "repeaterScope";
|
|
30
|
-
IInputDataType["redefineAnyType"] = "redefineAnyType";
|
|
31
29
|
})(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
|
|
32
30
|
const DtsPlaceholder = {
|
|
33
31
|
[IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
|
|
@@ -42,8 +40,7 @@ const DtsPlaceholder = {
|
|
|
42
40
|
[IInputDataType.compPropEvents]: "// Comp Prop Events 组件事件 - Don't touch me",
|
|
43
41
|
[IInputDataType.usedComponents]: "// Used Components - Don't touch me",
|
|
44
42
|
[IInputDataType.usedWidgets]: "// used widgets - Don't touch me",
|
|
45
|
-
[IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
|
|
46
|
-
[IInputDataType.redefineAnyType]: "// Redefine Any Type - Don't touch me",
|
|
43
|
+
[IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
|
|
47
44
|
};
|
|
48
45
|
const DtsInnerSign = {
|
|
49
46
|
[IInputDataType.globalState]: "Global State Inner",
|
|
@@ -58,18 +55,8 @@ const DtsInnerSign = {
|
|
|
58
55
|
[IInputDataType.compPropEvents]: "Comp Prop Events Inner",
|
|
59
56
|
[IInputDataType.usedComponents]: "Used Components Inner",
|
|
60
57
|
[IInputDataType.usedWidgets]: "used widgets Inner",
|
|
61
|
-
[IInputDataType.repeaterScope]: "repeater scope Inner"
|
|
62
|
-
[IInputDataType.redefineAnyType]: "Redefine Any Type Inner",
|
|
58
|
+
[IInputDataType.repeaterScope]: "repeater scope Inner"
|
|
63
59
|
};
|
|
64
|
-
var GroupEnum;
|
|
65
|
-
(function (GroupEnum) {
|
|
66
|
-
GroupEnum["GLOBAL_VAR"] = "globalVar";
|
|
67
|
-
GroupEnum["PAGE_VAR"] = "pageVar";
|
|
68
|
-
GroupEnum["PAGE_PARAM"] = "pageParam";
|
|
69
|
-
GroupEnum["COMPONENT"] = "component";
|
|
70
|
-
GroupEnum["REPEATER"] = "repeater";
|
|
71
|
-
GroupEnum["DATA_FIELD"] = "dataField";
|
|
72
|
-
})(GroupEnum || (GroupEnum = {}));
|
|
73
60
|
/**
|
|
74
61
|
* 通过该类可以共享同个dts。
|
|
75
62
|
* 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析
|
|
@@ -88,16 +75,14 @@ class WeDaDTS {
|
|
|
88
75
|
*/
|
|
89
76
|
static updateDTSPartial(inputData, itemType, options = { setEmptyIfError: false }) {
|
|
90
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
let dts = '';
|
|
91
79
|
try {
|
|
92
|
-
|
|
93
|
-
replaceRules.forEach(rule => {
|
|
94
|
-
WeDaDTS._dts = WeDaDTS._dts.replace(rule.from, rule.to);
|
|
95
|
-
});
|
|
80
|
+
dts = yield _generateOneItemDTS(inputData, itemType);
|
|
96
81
|
WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
|
|
97
82
|
}
|
|
98
83
|
catch (e) {
|
|
99
84
|
if (options.setEmptyIfError) {
|
|
100
|
-
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`);
|
|
101
86
|
}
|
|
102
87
|
}
|
|
103
88
|
});
|
|
@@ -116,8 +101,8 @@ class WeDaDTS {
|
|
|
116
101
|
return resultDts;
|
|
117
102
|
}
|
|
118
103
|
}
|
|
119
|
-
exports.WeDaDTS = WeDaDTS;
|
|
120
104
|
WeDaDTS._dts = '';
|
|
105
|
+
exports.WeDaDTS = WeDaDTS;
|
|
121
106
|
/**
|
|
122
107
|
* 生成 WeDa 应用的低码代码提示的 dts 类型声明内容
|
|
123
108
|
*/
|
|
@@ -129,8 +114,8 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
129
114
|
if (placeholder) {
|
|
130
115
|
// 防止某项错误导致全部都错误
|
|
131
116
|
try {
|
|
132
|
-
const
|
|
133
|
-
resultDts = resultDts.replace(placeholder, dts +
|
|
117
|
+
const dts = yield _generateOneItemDTS(inputData[key], key);
|
|
118
|
+
resultDts = resultDts.replace(placeholder, dts + placeholder);
|
|
134
119
|
}
|
|
135
120
|
catch (e) {
|
|
136
121
|
console.error(e);
|
|
@@ -156,102 +141,17 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
156
141
|
if (!(options === null || options === void 0 ? void 0 : options.needRepeaterScope)) {
|
|
157
142
|
resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
|
|
158
143
|
}
|
|
144
|
+
// console.log(resultDts)
|
|
159
145
|
return resultDts;
|
|
160
146
|
});
|
|
161
147
|
}
|
|
162
148
|
exports.generateWeDaAppDTS = generateWeDaAppDTS;
|
|
163
|
-
/**
|
|
164
|
-
* 生成 weda 专有的注释信息
|
|
165
|
-
*/
|
|
166
|
-
function genWeDaCodeComment({ fieldName, title, description, type, group }) {
|
|
167
|
-
const desc = `${title || fieldName}\n${description || ''}`;
|
|
168
|
-
return desc + `\n@privateForWeDa\n${JSON.stringify({ group, displayType: type, displayName: title || '' })}`;
|
|
169
|
-
}
|
|
170
149
|
/**
|
|
171
150
|
* 生成指定类型的 DTS
|
|
172
151
|
*/
|
|
173
152
|
function _generateOneItemDTS(inputData, itemType) {
|
|
174
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const replaceRules = [];
|
|
176
|
-
/**
|
|
177
|
-
* 处理注释信息
|
|
178
|
-
*/
|
|
179
|
-
function _handleComment(inputData, group) {
|
|
180
|
-
const _inputData = (0, lodash_1.cloneDeep)(inputData);
|
|
181
|
-
const schema = JSON.parse(JSON.stringify(_inputData, (key, value) => {
|
|
182
|
-
var _a;
|
|
183
|
-
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)) {
|
|
184
|
-
// value?.type?.type 有值,则证明 type 是自定义的字段,而非 JSONSchema 中的 type
|
|
185
|
-
value.description = genWeDaCodeComment({
|
|
186
|
-
fieldName: key,
|
|
187
|
-
title: value.title,
|
|
188
|
-
description: value.description,
|
|
189
|
-
group: group,
|
|
190
|
-
type: value.type
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return value;
|
|
194
|
-
}));
|
|
195
|
-
schema.description = ''; // 避免第一层出现注释
|
|
196
|
-
return schema;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* 获取用于显示的数据类型(仅有 number, string , boolean, array, object 等内置基础类型)
|
|
200
|
-
*/
|
|
201
|
-
function getDisplayReturnType(typeStr) {
|
|
202
|
-
let displayType = typeStr.trim();
|
|
203
|
-
if (displayType.endsWith('[]')) {
|
|
204
|
-
displayType = 'array';
|
|
205
|
-
}
|
|
206
|
-
else if (displayType.endsWith('}')) {
|
|
207
|
-
displayType = 'object';
|
|
208
|
-
}
|
|
209
|
-
return displayType;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* 获取组件接口定义名称
|
|
213
|
-
*/
|
|
214
|
-
function _genCompInterfaceName(module, component) {
|
|
215
|
-
return `${module.replace(/-/g, '_')}_${component}`;
|
|
216
|
-
}
|
|
217
|
-
function _compile(jsonschema, isObjNeedWrapper = false) {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
-
let dts = yield compileJSONToDTS(jsonschema);
|
|
220
|
-
if (dts.search(/^export interface IWeDa/) >= 0) {
|
|
221
|
-
dts = dts.replace(/^export interface.*$/m, '');
|
|
222
|
-
dts = dts.substring(0, dts.length - 2);
|
|
223
|
-
if (isObjNeedWrapper) {
|
|
224
|
-
dts = `{${dts}}`;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
dts = dts.replace(/^export type IWeDa =/m, '');
|
|
229
|
-
}
|
|
230
|
-
return dts;
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
154
|
const hanlderMap = {
|
|
234
|
-
[IInputDataType.globalState]: function (inputData) {
|
|
235
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
-
// 完善注释信息
|
|
237
|
-
const handledInputData = _handleComment(inputData, GroupEnum.GLOBAL_VAR);
|
|
238
|
-
return yield _compile(handledInputData);
|
|
239
|
-
});
|
|
240
|
-
},
|
|
241
|
-
[IInputDataType.pageState]: function (inputData) {
|
|
242
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
// 完善注释信息
|
|
244
|
-
const handledInputData = _handleComment(inputData, GroupEnum.PAGE_VAR);
|
|
245
|
-
return yield _compile(handledInputData);
|
|
246
|
-
});
|
|
247
|
-
},
|
|
248
|
-
[IInputDataType.pageParams]: function (inputData) {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
// 完善注释信息
|
|
251
|
-
const handledInputData = _handleComment(inputData, GroupEnum.PAGE_PARAM);
|
|
252
|
-
return yield _compile(handledInputData);
|
|
253
|
-
});
|
|
254
|
-
},
|
|
255
155
|
[IInputDataType.globalCommonCodes]: function (inputData) {
|
|
256
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
157
|
const dts = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -305,8 +205,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
305
205
|
// 属性
|
|
306
206
|
let exportPropertiesDTS = '';
|
|
307
207
|
if (item.exportProperties) {
|
|
308
|
-
|
|
309
|
-
exportPropertiesDTS = yield _compile(handledProperties);
|
|
208
|
+
exportPropertiesDTS = yield _compile(item.exportProperties);
|
|
310
209
|
}
|
|
311
210
|
// 方法
|
|
312
211
|
let exportMethodsDTS = '';
|
|
@@ -355,17 +254,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
355
254
|
return inputData.map(item => {
|
|
356
255
|
if (item.idList && item.idList.length > 0) {
|
|
357
256
|
const interfaceName = _genCompInterfaceName(item.module, item.component);
|
|
358
|
-
return item.idList.map(id => `
|
|
359
|
-
/**
|
|
360
|
-
${genWeDaCodeComment({
|
|
361
|
-
fieldName: id,
|
|
362
|
-
title: '',
|
|
363
|
-
description: '',
|
|
364
|
-
group: GroupEnum.COMPONENT,
|
|
365
|
-
type: 'component' // 组件显示的类型为 component
|
|
366
|
-
}).split('\n').map(item => `* ${item}`).join('\n')}
|
|
367
|
-
*/
|
|
368
|
-
const ${id}: ${interfaceName}`).join('\n');
|
|
257
|
+
return item.idList.map(id => `const ${id}: ${interfaceName}`).join('\n');
|
|
369
258
|
}
|
|
370
259
|
return '';
|
|
371
260
|
}).join('\n');
|
|
@@ -375,96 +264,43 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
375
264
|
const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
376
265
|
let itemDataDTS = yield _compile(item.itemData, true);
|
|
377
266
|
return `
|
|
378
|
-
/**
|
|
379
|
-
${genWeDaCodeComment({
|
|
380
|
-
fieldName: item.currentItemAlias,
|
|
381
|
-
title: '',
|
|
382
|
-
description: '',
|
|
383
|
-
group: GroupEnum.REPEATER,
|
|
384
|
-
type: getDisplayReturnType(itemDataDTS)
|
|
385
|
-
}).split('\n').map(item => `* ${item}`).join('\n')}
|
|
386
|
-
*/
|
|
387
267
|
const ${item.currentItemAlias}: ${itemDataDTS}
|
|
388
|
-
/**
|
|
389
|
-
${genWeDaCodeComment({
|
|
390
|
-
fieldName: item.currentIndexAlias,
|
|
391
|
-
title: '',
|
|
392
|
-
description: '',
|
|
393
|
-
group: GroupEnum.REPEATER,
|
|
394
|
-
type: 'number'
|
|
395
|
-
}).split('\n').map(item => `* ${item}`).join('\n')}
|
|
396
|
-
*/
|
|
397
268
|
const ${item.currentIndexAlias}: number
|
|
398
269
|
`;
|
|
399
270
|
})));
|
|
400
271
|
return results.join('\n');
|
|
401
272
|
});
|
|
402
273
|
},
|
|
403
|
-
[IInputDataType.redefineAnyType]: function (inputData) {
|
|
404
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
-
const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
406
|
-
const compInterfaceName = _genCompInterfaceName(item.module, item.component);
|
|
407
|
-
const widgetInterfaceName = `${item.widgetId}_${compInterfaceName}`;
|
|
408
|
-
/**
|
|
409
|
-
* 更新
|
|
410
|
-
*/
|
|
411
|
-
replaceRules.push({
|
|
412
|
-
from: new RegExp(`(const ${item.widgetId}): .*`),
|
|
413
|
-
to: `$1: ${widgetInterfaceName}`
|
|
414
|
-
});
|
|
415
|
-
/**
|
|
416
|
-
* 增加类
|
|
417
|
-
*/
|
|
418
|
-
const propDefinitions = yield Promise.all(item.updateProps.map((prop) => __awaiter(this, void 0, void 0, function* () {
|
|
419
|
-
const properties = _handleComment(prop.widgetPropTypeSchema, GroupEnum.DATA_FIELD);
|
|
420
|
-
const widgetPropTypeDTS = yield _compile(Object.assign(Object.assign({}, prop.widgetPropTypeSchema), properties), true);
|
|
421
|
-
// 是否是多层级字段,如 "a.b"
|
|
422
|
-
// FIXME: 当前只支持 a.b 这种形式,不支持 a[].b
|
|
423
|
-
const multiLevelField = prop.widgetPropName.includes('.');
|
|
424
|
-
let multiLevelFields = [];
|
|
425
|
-
let multiLevelFieldObj = {};
|
|
426
|
-
let firstField = '';
|
|
427
|
-
let othersFields = [];
|
|
428
|
-
if (multiLevelField) {
|
|
429
|
-
multiLevelFields = prop.widgetPropName.split('.');
|
|
430
|
-
(0, lodash_1.set)(multiLevelFieldObj, prop.widgetPropName, "$$schema$$");
|
|
431
|
-
const [_firstField, ..._othersFields] = multiLevelFields;
|
|
432
|
-
firstField = _firstField;
|
|
433
|
-
othersFields = _othersFields;
|
|
434
|
-
}
|
|
435
|
-
return `
|
|
436
|
-
/**
|
|
437
|
-
${genWeDaCodeComment({
|
|
438
|
-
fieldName: prop.widgetPropName,
|
|
439
|
-
title: prop.widgetPropTypeSchema.title,
|
|
440
|
-
description: prop.widgetPropTypeSchema.description,
|
|
441
|
-
group: undefined,
|
|
442
|
-
type: getDisplayReturnType(widgetPropTypeDTS)
|
|
443
|
-
}).split('\n').map(item => `* ${item}`).join('\n')}
|
|
444
|
-
*/
|
|
445
|
-
${multiLevelField ? `${firstField}: Omit<${compInterfaceName}['${firstField}'], '${othersFields.join(".")}'> & ${JSON.stringify(multiLevelFieldObj[firstField]).replace('"$$schema$$"', widgetPropTypeDTS)}` : `${prop.widgetPropName}: ${widgetPropTypeDTS}`}
|
|
446
|
-
`;
|
|
447
|
-
})));
|
|
448
|
-
return `
|
|
449
|
-
declare class ${widgetInterfaceName} extends ${compInterfaceName} {
|
|
450
|
-
${propDefinitions.join('\n')}
|
|
451
|
-
}
|
|
452
|
-
`;
|
|
453
|
-
})));
|
|
454
|
-
return results.join('\n');
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
274
|
};
|
|
458
275
|
let dts = '';
|
|
459
276
|
if (!inputData)
|
|
460
|
-
return
|
|
277
|
+
return dts;
|
|
461
278
|
const handler = hanlderMap[itemType];
|
|
462
279
|
// 优先判断是否有独立的处理逻辑
|
|
463
280
|
if (handler) {
|
|
464
281
|
dts = yield handler.call(hanlderMap, inputData);
|
|
465
282
|
}
|
|
466
283
|
dts = dts || (yield _compile(inputData));
|
|
467
|
-
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
|
+
}
|
|
468
304
|
});
|
|
469
305
|
}
|
|
470
306
|
// 仅仅为了与 unittest 共享,外部请不要使用
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from '../parser';
|
|
|
2
2
|
export * from '../types/index';
|
|
3
3
|
export * from './constant';
|
|
4
4
|
export * from './dts/index';
|
|
5
|
-
export { version4 } from './version
|
|
5
|
+
export { version4 } from './version/migrations/version4';
|
|
6
|
+
export { semverComp } from './version/common';
|
|
6
7
|
export { isUnitlessNumber } from './CSSProperty';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/utils/index.js
CHANGED
|
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isUnitlessNumber = exports.version4 = void 0;
|
|
17
|
+
exports.isUnitlessNumber = exports.semverComp = exports.version4 = void 0;
|
|
18
18
|
__exportStar(require("../parser"), exports);
|
|
19
19
|
__exportStar(require("../types/index"), exports);
|
|
20
20
|
__exportStar(require("./constant"), exports);
|
|
21
21
|
__exportStar(require("./dts/index"), exports);
|
|
22
|
-
var version4_1 = require("./version
|
|
22
|
+
var version4_1 = require("./version/migrations/version4");
|
|
23
23
|
Object.defineProperty(exports, "version4", { enumerable: true, get: function () { return version4_1.version4; } });
|
|
24
|
+
var common_1 = require("./version/common");
|
|
25
|
+
Object.defineProperty(exports, "semverComp", { enumerable: true, get: function () { return common_1.semverComp; } });
|
|
24
26
|
var CSSProperty_1 = require("./CSSProperty");
|
|
25
27
|
Object.defineProperty(exports, "isUnitlessNumber", { enumerable: true, get: function () { return CSSProperty_1.isUnitlessNumber; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/version/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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toFixed = exports.semverComp = void 0;
|
|
4
|
+
function semverComp(a, b) {
|
|
5
|
+
const pa = a.split('.');
|
|
6
|
+
const pb = b.split('.');
|
|
7
|
+
for (let i = 0; i < 3; i++) {
|
|
8
|
+
const na = Number(pa[i]);
|
|
9
|
+
const nb = Number(pb[i]);
|
|
10
|
+
if (na > nb)
|
|
11
|
+
return 1;
|
|
12
|
+
if (nb > na)
|
|
13
|
+
return -1;
|
|
14
|
+
if (!isNaN(na) && isNaN(nb))
|
|
15
|
+
return 1;
|
|
16
|
+
if (isNaN(na) && !isNaN(nb))
|
|
17
|
+
return -1;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
exports.semverComp = semverComp;
|
|
22
|
+
function toFixed(num, precision) {
|
|
23
|
+
const multiplier = Math.pow(10, (precision + 1));
|
|
24
|
+
const wholeNumber = Math.floor(num * multiplier);
|
|
25
|
+
return (Math.round(wholeNumber / 10) * 10) / multiplier;
|
|
26
|
+
}
|
|
27
|
+
exports.toFixed = toFixed;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEnablePageRoot = exports.isEnbaleObserverVersion = void 0;
|
|
4
|
+
const constant_1 = require("../constant");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
function compareOfficialLibVersionWithVersion(dependencies, version, timesnap) {
|
|
7
|
+
const officialLib = dependencies.find((item) => item.name === constant_1.OFFICIAL_LIB_KEY);
|
|
8
|
+
if (officialLib) {
|
|
9
|
+
const { version } = officialLib;
|
|
10
|
+
if (version.includes('.')) {
|
|
11
|
+
return (0, common_1.semverComp)('2.21.3', version) <= 0;
|
|
12
|
+
// 正式版本的版本号
|
|
13
|
+
}
|
|
14
|
+
else if (Number(version) >= 1678760239346) {
|
|
15
|
+
// 测试版本的版本号
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function isEnbaleObserverVersion(dependencies = []) {
|
|
25
|
+
return compareOfficialLibVersionWithVersion(dependencies, '2.21.3', 1678760239346);
|
|
26
|
+
}
|
|
27
|
+
exports.isEnbaleObserverVersion = isEnbaleObserverVersion;
|
|
28
|
+
function isEnablePageRoot(dependencies) {
|
|
29
|
+
return compareOfficialLibVersionWithVersion(dependencies, '20000.21.3', 1679640531142);
|
|
30
|
+
}
|
|
31
|
+
exports.isEnablePageRoot = isEnablePageRoot;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version4.d.ts","sourceRoot":"","sources":["../../../../src/utils/version/migrations/version4.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAGnE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,OAAO,EAClB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,GAC/D,YAAY,CAEd"}
|