@cloudbase/cals 1.0.3-alpha.7 → 1.0.3-alpha.8
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/cloudbase.cals.umd.min.js +5 -0
- package/lib/parser/cals/index.d.ts +366 -371
- package/lib/parser/cals/index.d.ts.map +1 -1
- package/lib/parser/cals/index.js +12 -12
- package/lib/parser/cals/utils/block/index.d.ts +14 -14
- 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.js +13 -12
- package/lib/parser/cals/utils/common.d.ts +11 -11
- 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/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.js +3 -6
- package/lib/parser/cals/utils/version/common.d.ts +4 -4
- package/lib/parser/cals/utils/version/common.js +11 -34
- package/lib/parser/cals/utils/version/config.d.ts +13 -13
- package/lib/parser/cals/utils/version/index.d.ts +2 -2
- package/lib/parser/cals/utils/version/parses.d.ts +15 -15
- package/lib/parser/cals/utils/version/parses.js +14 -37
- 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/expression/index.d.ts +122 -122
- package/lib/parser/index.d.ts +8 -8
- 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/common.d.ts +88 -88
- package/lib/types/basic/component.d.ts +208 -208
- package/lib/types/basic/datasource.d.ts +49 -49
- package/lib/types/index.d.ts +9 -9
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +14 -1
- package/lib/types/lcds.d.ts +447 -197
- package/lib/types/lcds.d.ts.map +1 -1
- package/lib/types/platform/app.d.ts +176 -176
- package/lib/types/platform/common.d.ts +137 -137
- package/lib/types/platform/component.d.ts +140 -140
- package/lib/types/platform/datasource.d.ts +466 -466
- package/lib/types/platform/widget/form.d.ts +89 -89
- package/lib/types/platform/widget/meta.d.ts +59 -59
- package/lib/utils/CSSProperty.d.ts +63 -63
- package/lib/utils/build.d.ts +1 -1
- package/lib/utils/build.js +3 -6
- package/lib/utils/constant.d.ts +40 -40
- package/lib/utils/dts/auto-generated.d.ts +1 -1
- package/lib/utils/dts/build.d.ts +1 -1
- package/lib/utils/dts/index.d.ts +130 -130
- package/lib/utils/dts/index.d.ts.map +1 -1
- package/lib/utils/dts/index.js +116 -78
- package/lib/utils/index.d.ts +7 -7
- 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/package.json +12 -3
- package/lib/utils/version-migrations/common.d.ts +0 -5
- package/lib/utils/version-migrations/common.d.ts.map +0 -1
- package/lib/utils/version-migrations/common.js +0 -29
- package/lib/utils/version-migrations/version4.d.ts +0 -3
- package/lib/utils/version-migrations/version4.d.ts.map +0 -1
- package/lib/utils/version-migrations/version4.js +0 -199
package/lib/utils/dts/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.compileJSONToDTS = exports.jsonToDTSWorkerCode = exports.transpileToDTS = exports.workerCode = exports.generateWeDaAppDTS = exports.WeDaDTS = exports.IInputDataType = void 0;
|
|
16
|
-
const
|
|
16
|
+
const lodash_es_1 = require("lodash-es");
|
|
17
17
|
const json_easy_filter_1 = __importDefault(require("json-easy-filter"));
|
|
18
18
|
const auto_generated_1 = require("./auto-generated");
|
|
19
19
|
var IInputDataType;
|
|
@@ -50,20 +50,20 @@ const DtsPlaceholder = {
|
|
|
50
50
|
[IInputDataType.redefineAnyType]: "// Redefine Any Type - Don't touch me",
|
|
51
51
|
};
|
|
52
52
|
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]:
|
|
53
|
+
[IInputDataType.globalState]: 'Global State Inner',
|
|
54
|
+
[IInputDataType.pageState]: 'Page State Inner',
|
|
55
|
+
[IInputDataType.compState]: 'Comp State Inner',
|
|
56
|
+
[IInputDataType.pageParams]: 'Page Param Inner',
|
|
57
|
+
[IInputDataType.forState]: 'Global For Inner',
|
|
58
|
+
[IInputDataType.globalCommonCodes]: 'Global Common Inner',
|
|
59
|
+
[IInputDataType.pageHandlerCodes]: 'Page Handler Inner',
|
|
60
|
+
[IInputDataType.compHandlerCodes]: 'Comp Handler Inner',
|
|
61
|
+
[IInputDataType.compPropData]: 'Comp Prop Data Inner',
|
|
62
|
+
[IInputDataType.compPropEvents]: 'Comp Prop Events Inner',
|
|
63
|
+
[IInputDataType.usedComponents]: 'Used Components Inner',
|
|
64
|
+
[IInputDataType.usedWidgets]: 'used widgets Inner',
|
|
65
|
+
[IInputDataType.repeaterScope]: 'repeater scope Inner',
|
|
66
|
+
[IInputDataType.redefineAnyType]: 'Redefine Any Type Inner',
|
|
67
67
|
};
|
|
68
68
|
var GroupEnum;
|
|
69
69
|
(function (GroupEnum) {
|
|
@@ -94,7 +94,7 @@ class WeDaDTS {
|
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
try {
|
|
96
96
|
const [dts, replaceRules] = yield _generateOneItemDTS(inputData, itemType);
|
|
97
|
-
replaceRules.forEach(rule => {
|
|
97
|
+
replaceRules.forEach((rule) => {
|
|
98
98
|
WeDaDTS._dts = WeDaDTS._dts.replace(rule.from, rule.to);
|
|
99
99
|
});
|
|
100
100
|
WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
|
|
@@ -106,7 +106,11 @@ class WeDaDTS {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
static getDTS(options = {
|
|
109
|
+
static getDTS(options = {
|
|
110
|
+
needGlobalFormula: false,
|
|
111
|
+
needGlobalFor: false,
|
|
112
|
+
needRepeaterScope: false,
|
|
113
|
+
}) {
|
|
110
114
|
let resultDts = WeDaDTS._dts;
|
|
111
115
|
if (!options.needGlobalFormula) {
|
|
112
116
|
resultDts = resultDts.replace(/^\/\/ Global Formula Begin[\s\S]*^\/\/ Global Formula End$/m, '');
|
|
@@ -134,7 +138,7 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
|
|
|
134
138
|
// 防止某项错误导致全部都错误
|
|
135
139
|
try {
|
|
136
140
|
const [dts, replaceRules] = yield _generateOneItemDTS(inputData[key], key);
|
|
137
|
-
replaceRules.forEach(rule => {
|
|
141
|
+
replaceRules.forEach((rule) => {
|
|
138
142
|
resultDts = resultDts.replace(rule.from, rule.to);
|
|
139
143
|
});
|
|
140
144
|
resultDts = resultDts.replace(placeholder, dts + '\n' + placeholder);
|
|
@@ -171,8 +175,18 @@ exports.generateWeDaAppDTS = generateWeDaAppDTS;
|
|
|
171
175
|
* 生成 weda 专有的注释信息
|
|
172
176
|
*/
|
|
173
177
|
function genWeDaCodeComment({ fieldName, title, description, type, dataFieldInfo, group, schema, subGroup, baseClass, datasource, }) {
|
|
174
|
-
const desc =
|
|
175
|
-
return desc +
|
|
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
|
+
})}`);
|
|
176
190
|
}
|
|
177
191
|
/**
|
|
178
192
|
* 生成指定类型的 DTS
|
|
@@ -185,23 +199,23 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
185
199
|
*/
|
|
186
200
|
function getDataFieldDisplayType(format) {
|
|
187
201
|
const nameMap = {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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',
|
|
205
219
|
};
|
|
206
220
|
return nameMap[format];
|
|
207
221
|
}
|
|
@@ -209,7 +223,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
209
223
|
* 处理注释信息
|
|
210
224
|
*/
|
|
211
225
|
function _handleComment(inputData, group, needKeepSchema) {
|
|
212
|
-
const _inputData = (0,
|
|
226
|
+
const _inputData = (0, lodash_es_1.cloneDeep)(inputData);
|
|
213
227
|
json_easy_filter_1.default.traverse(_inputData, function (key, value, path) {
|
|
214
228
|
var _a;
|
|
215
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)) {
|
|
@@ -219,7 +233,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
219
233
|
const isFirstLevel = path.length === 2 && (path === null || path === void 0 ? void 0 : path[0]) === 'properties';
|
|
220
234
|
if (isFirstLevel) {
|
|
221
235
|
// 只需要第一级属性需要保存,且只保存子信息(对象或数组的子项)
|
|
222
|
-
schema =
|
|
236
|
+
schema = value.properties || value.items ? value : null;
|
|
223
237
|
}
|
|
224
238
|
}
|
|
225
239
|
// 特殊处理数据字段的类型
|
|
@@ -233,8 +247,8 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
233
247
|
description: value.description,
|
|
234
248
|
group,
|
|
235
249
|
type,
|
|
236
|
-
dataFieldInfo: (0,
|
|
237
|
-
schema
|
|
250
|
+
dataFieldInfo: (0, lodash_es_1.pick)(value, ['type', 'format', 'x-system']),
|
|
251
|
+
schema,
|
|
238
252
|
});
|
|
239
253
|
}
|
|
240
254
|
});
|
|
@@ -341,9 +355,11 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
341
355
|
},
|
|
342
356
|
[IInputDataType.compPropEvents]: function (inputData) {
|
|
343
357
|
const IData = `any`;
|
|
344
|
-
return inputData
|
|
358
|
+
return inputData
|
|
359
|
+
.map((eventName) => {
|
|
345
360
|
return `function ${eventName}(data?: ${IData}): void`;
|
|
346
|
-
})
|
|
361
|
+
})
|
|
362
|
+
.join('\n');
|
|
347
363
|
},
|
|
348
364
|
[IInputDataType.usedComponents]: function (inputData) {
|
|
349
365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -391,7 +407,10 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
391
407
|
${genWeDaCodeComment({
|
|
392
408
|
fieldName: interfaceName,
|
|
393
409
|
schema: item.exportProperties,
|
|
394
|
-
})
|
|
410
|
+
})
|
|
411
|
+
.split('\n')
|
|
412
|
+
.map((item) => `* ${item}`)
|
|
413
|
+
.join('\n')}
|
|
395
414
|
*/
|
|
396
415
|
declare class ${interfaceName} extends UserWidget {
|
|
397
416
|
|
|
@@ -405,10 +424,12 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
405
424
|
});
|
|
406
425
|
},
|
|
407
426
|
[IInputDataType.usedWidgets]: function (inputData) {
|
|
408
|
-
return inputData
|
|
427
|
+
return inputData
|
|
428
|
+
.map((item) => {
|
|
409
429
|
if (item.idList && item.idList.length > 0) {
|
|
410
430
|
const interfaceName = _genCompInterfaceName(item.module, item.component);
|
|
411
|
-
return item.idList
|
|
431
|
+
return item.idList
|
|
432
|
+
.map((id) => `
|
|
412
433
|
/**
|
|
413
434
|
${genWeDaCodeComment({
|
|
414
435
|
fieldName: id,
|
|
@@ -417,13 +438,18 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
417
438
|
group: GroupEnum.COMPONENT,
|
|
418
439
|
type: 'component',
|
|
419
440
|
baseClass: interfaceName,
|
|
420
|
-
datasource: `$${id}_start$ $${id}_end
|
|
421
|
-
})
|
|
441
|
+
datasource: `$${id}_start$ $${id}_end$`,
|
|
442
|
+
})
|
|
443
|
+
.split('\n')
|
|
444
|
+
.map((item) => `* ${item}`)
|
|
445
|
+
.join('\n')}
|
|
422
446
|
*/
|
|
423
|
-
const ${id}: ${interfaceName}`)
|
|
447
|
+
const ${id}: ${interfaceName}`)
|
|
448
|
+
.join('\n');
|
|
424
449
|
}
|
|
425
450
|
return '';
|
|
426
|
-
})
|
|
451
|
+
})
|
|
452
|
+
.join('\n');
|
|
427
453
|
},
|
|
428
454
|
[IInputDataType.repeaterScope]: function (inputData) {
|
|
429
455
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -447,8 +473,11 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
447
473
|
group: GroupEnum.REPEATER,
|
|
448
474
|
type: getDisplayReturnType(itemDataDTS),
|
|
449
475
|
schema: item.itemData,
|
|
450
|
-
subGroup: item.widgetId
|
|
451
|
-
})
|
|
476
|
+
subGroup: item.widgetId,
|
|
477
|
+
})
|
|
478
|
+
.split('\n')
|
|
479
|
+
.map((item) => `* ${item}`)
|
|
480
|
+
.join('\n')}
|
|
452
481
|
*/
|
|
453
482
|
const ${item.currentItemAlias}: ${itemDataDTS}
|
|
454
483
|
/**
|
|
@@ -458,8 +487,11 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
458
487
|
description: '',
|
|
459
488
|
group: GroupEnum.REPEATER,
|
|
460
489
|
type: 'number',
|
|
461
|
-
subGroup: item.widgetId
|
|
462
|
-
})
|
|
490
|
+
subGroup: item.widgetId,
|
|
491
|
+
})
|
|
492
|
+
.split('\n')
|
|
493
|
+
.map((item) => `* ${item}`)
|
|
494
|
+
.join('\n')}
|
|
463
495
|
*/
|
|
464
496
|
const ${item.currentIndexAlias}: number
|
|
465
497
|
`;
|
|
@@ -477,7 +509,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
477
509
|
*/
|
|
478
510
|
replaceRules.push({
|
|
479
511
|
from: new RegExp(`(const ${item.widgetId}): .*`),
|
|
480
|
-
to: `$1: ${widgetInterfaceName}
|
|
512
|
+
to: `$1: ${widgetInterfaceName}`,
|
|
481
513
|
});
|
|
482
514
|
/**
|
|
483
515
|
* 增加类
|
|
@@ -492,7 +524,10 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
492
524
|
datasources[id] = {
|
|
493
525
|
fields: [{ name: prop.widgetPropName, title: prop.widgetPropTitle }],
|
|
494
526
|
schema: prop.widgetPropTypeSchema,
|
|
495
|
-
name: prop.datasource.name,
|
|
527
|
+
name: prop.datasource.name,
|
|
528
|
+
title: prop.datasource.title,
|
|
529
|
+
id: prop.datasource.id,
|
|
530
|
+
type: prop.datasource.type,
|
|
496
531
|
};
|
|
497
532
|
}
|
|
498
533
|
else {
|
|
@@ -507,7 +542,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
507
542
|
let othersFields = [];
|
|
508
543
|
if (multiLevelField) {
|
|
509
544
|
multiLevelFields = prop.widgetPropName.split('.');
|
|
510
|
-
(0,
|
|
545
|
+
(0, lodash_es_1.set)(multiLevelFieldObj, prop.widgetPropName, '$$schema$$');
|
|
511
546
|
const [_firstField, ..._othersFields] = multiLevelFields;
|
|
512
547
|
firstField = _firstField;
|
|
513
548
|
othersFields = _othersFields;
|
|
@@ -519,10 +554,15 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
519
554
|
title: prop.widgetPropTypeSchema.title,
|
|
520
555
|
description: prop.widgetPropTypeSchema.description,
|
|
521
556
|
group: undefined,
|
|
522
|
-
type: getDisplayReturnType(widgetPropTypeDTS)
|
|
523
|
-
})
|
|
557
|
+
type: getDisplayReturnType(widgetPropTypeDTS),
|
|
558
|
+
})
|
|
559
|
+
.split('\n')
|
|
560
|
+
.map((item) => `* ${item}`)
|
|
561
|
+
.join('\n')}
|
|
524
562
|
*/
|
|
525
|
-
${multiLevelField
|
|
563
|
+
${multiLevelField
|
|
564
|
+
? `${firstField}: Omit<${compInterfaceName}['${firstField}'], '${othersFields.join('.')}'> & ${JSON.stringify(multiLevelFieldObj[firstField]).replace('"$$schema$$"', widgetPropTypeDTS)}`
|
|
565
|
+
: `${prop.widgetPropName}: ${widgetPropTypeDTS}`}
|
|
526
566
|
`;
|
|
527
567
|
})));
|
|
528
568
|
/**
|
|
@@ -533,7 +573,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
533
573
|
replaceRules.push({
|
|
534
574
|
from: new RegExp(`(\\$${item.widgetId}_start\\$).*(\\$${item.widgetId}_end\\$)`),
|
|
535
575
|
// encodeURIComponent 是为了能正常 parse 成 JSON
|
|
536
|
-
to: `$1${encodeURIComponent(JSON.stringify(datasourceInfoList))}$2
|
|
576
|
+
to: `$1${encodeURIComponent(JSON.stringify(datasourceInfoList))}$2`,
|
|
537
577
|
});
|
|
538
578
|
}
|
|
539
579
|
return `
|
|
@@ -544,7 +584,7 @@ function _generateOneItemDTS(inputData, itemType) {
|
|
|
544
584
|
})));
|
|
545
585
|
return results.join('\n');
|
|
546
586
|
});
|
|
547
|
-
}
|
|
587
|
+
},
|
|
548
588
|
};
|
|
549
589
|
let dts = '';
|
|
550
590
|
if (!inputData)
|
|
@@ -635,20 +675,18 @@ function TypescriptWorker(workerId, workerCode) {
|
|
|
635
675
|
typescriptWorker.onmessage = function (event) {
|
|
636
676
|
const { action } = event.data;
|
|
637
677
|
if (action === 'dts_back') {
|
|
638
|
-
const { data: { id, dts } } = event.data;
|
|
678
|
+
const { data: { id, dts }, } = event.data;
|
|
639
679
|
sendMessageCallbackFn[id] && sendMessageCallbackFn[id](dts);
|
|
640
680
|
}
|
|
641
681
|
};
|
|
642
682
|
typescriptWorkerMap[workerId] = {
|
|
643
683
|
typescriptWorker,
|
|
644
|
-
sendMessageCallbackFn
|
|
684
|
+
sendMessageCallbackFn,
|
|
645
685
|
};
|
|
646
686
|
}
|
|
647
687
|
function sendMessage(msgData, callbackFn) {
|
|
648
688
|
const { typescriptWorker, sendMessageCallbackFn } = typescriptWorkerMap[workerId];
|
|
649
|
-
const id = Math.random()
|
|
650
|
-
.toString(36)
|
|
651
|
-
.substring(2, 5);
|
|
689
|
+
const id = Math.random().toString(36).substring(2, 5);
|
|
652
690
|
msgData.data.id = id;
|
|
653
691
|
sendMessageCallbackFn[id] = callbackFn;
|
|
654
692
|
typescriptWorker.postMessage(msgData);
|
|
@@ -657,22 +695,22 @@ function TypescriptWorker(workerId, workerCode) {
|
|
|
657
695
|
};
|
|
658
696
|
}
|
|
659
697
|
/**
|
|
660
|
-
* 使用:
|
|
661
|
-
* const typescriptWorker = getTypescriptWorker();
|
|
662
|
-
* typescriptWorker.sendMessage({ action: 'dts', data: { code } }, dts => {
|
|
663
|
-
*
|
|
664
|
-
* })
|
|
665
|
-
* // 以下暂未实现
|
|
666
|
-
* typescriptWorker.sendMessage({ action: 'ts', data: { code } }, ts => {
|
|
667
|
-
*
|
|
668
|
-
* })
|
|
669
|
-
*/
|
|
698
|
+
* 使用:
|
|
699
|
+
* const typescriptWorker = getTypescriptWorker();
|
|
700
|
+
* typescriptWorker.sendMessage({ action: 'dts', data: { code } }, dts => {
|
|
701
|
+
*
|
|
702
|
+
* })
|
|
703
|
+
* // 以下暂未实现
|
|
704
|
+
* typescriptWorker.sendMessage({ action: 'ts', data: { code } }, ts => {
|
|
705
|
+
*
|
|
706
|
+
* })
|
|
707
|
+
*/
|
|
670
708
|
const getTypescriptWorker = TypescriptWorker('transpileToDTS', exports.workerCode);
|
|
671
709
|
/**
|
|
672
710
|
* 通过 js/ts 代码生成 dts
|
|
673
711
|
*/
|
|
674
712
|
function transpileToDTS(code) {
|
|
675
|
-
return new Promise(resolve => {
|
|
713
|
+
return new Promise((resolve) => {
|
|
676
714
|
const typescriptWorker = getTypescriptWorker();
|
|
677
715
|
typescriptWorker.sendMessage({ action: 'dts', data: { code } }, (dts) => {
|
|
678
716
|
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
|
|
@@ -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?: never[]): 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,UAAK,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
|
+
const 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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cals",
|
|
3
|
-
"version": "1.0.3-alpha.
|
|
3
|
+
"version": "1.0.3-alpha.8",
|
|
4
4
|
"description": "Common application specifications",
|
|
5
5
|
"main": "lib/utils/index.js",
|
|
6
6
|
"source": "src/utils/index.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"build:schema": "ts-node src/utils/build.ts",
|
|
17
17
|
"build:dts": "ts-node src/utils/dts/build.ts",
|
|
18
|
+
"build:umd": "tsc && rollup -c rollup.config.js --bundleConfigAsCjs",
|
|
18
19
|
"build:dts:watch": "ts-node src/utils/dts/build.ts --watch",
|
|
19
20
|
"develop": "tsc --watch",
|
|
20
21
|
"docs": "typedoc --options typedoc.json types",
|
|
@@ -32,14 +33,16 @@
|
|
|
32
33
|
"acorn": "^8.0.4",
|
|
33
34
|
"json-easy-filter": "^0.3.1",
|
|
34
35
|
"json-schema-to-typescript-for-browser": "^11.0.3",
|
|
35
|
-
"lodash": "^4.17.
|
|
36
|
+
"lodash-es": "^4.17.19",
|
|
36
37
|
"postcss": "^8.4.20",
|
|
37
38
|
"postcss-less": "^6.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
41
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
42
|
+
"@rollup/plugin-typescript": "^11.1.0",
|
|
40
43
|
"@types/acorn": "^4.0.5",
|
|
41
44
|
"@types/jest": "^27.4.0",
|
|
42
|
-
"@types/lodash": "^4.
|
|
45
|
+
"@types/lodash-es": "^4.17.6",
|
|
43
46
|
"@types/node": "^14.14.6",
|
|
44
47
|
"@types/react": "^18.0.17",
|
|
45
48
|
"@types/web": "^0.0.78",
|
|
@@ -49,6 +52,12 @@
|
|
|
49
52
|
"jest-fetch-mock": "^3.0.3",
|
|
50
53
|
"jsdom-worker": "^0.3.0",
|
|
51
54
|
"node-watch": "^0.7.3",
|
|
55
|
+
"rollup": "^3.21.6",
|
|
56
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
57
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
58
|
+
"rollup-plugin-size-snapshot": "^0.12.0",
|
|
59
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
60
|
+
"rollup-plugin-typescript2": "0.31.2",
|
|
52
61
|
"ts-jest": "^27.1.5",
|
|
53
62
|
"ts-node": "^10.4.0",
|
|
54
63
|
"typescript": "^4.7.4",
|
|
@@ -1,5 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OFFICIAL_MATERIAL_LIB_NAME = exports.OFFICIAL_COMPONENT_LIB_NAME = 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;
|
|
28
|
-
exports.OFFICIAL_COMPONENT_LIB_NAME = 'CLOUDBASE_STANDARD';
|
|
29
|
-
exports.OFFICIAL_MATERIAL_LIB_NAME = 'gsd-h5-react';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version4.d.ts","sourceRoot":"","sources":["../../../src/utils/version-migrations/version4.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAGhE,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"}
|