@cloudbase/cals 0.5.11-alpha.0 → 0.5.11-beta1
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.js +1344 -905
- package/lib/utils/dts/index.d.ts +0 -5
- package/lib/utils/dts/index.d.ts.map +1 -1
- package/lib/utils/dts/index.js +33 -51
- package/package.json +1 -1
package/lib/parser/cals/index.js
CHANGED
|
@@ -1,211 +1,272 @@
|
|
|
1
|
-
|
|
2
|
-
var __rest =
|
|
1
|
+
'use strict';
|
|
2
|
+
var __rest =
|
|
3
|
+
(this && this.__rest) ||
|
|
4
|
+
function (s, e) {
|
|
3
5
|
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
7
|
+
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
|
|
8
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
11
|
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports,
|
|
14
|
-
exports.parseVersion =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
exports.parseVersion =
|
|
15
|
+
exports.processRuntimeCodeResources =
|
|
16
|
+
exports.deserializeComponentLibraryMeta =
|
|
17
|
+
exports.deserializeRuntimeComponent =
|
|
18
|
+
exports.serializeRuntimeComponent =
|
|
19
|
+
exports.serializeRuntimePage =
|
|
20
|
+
exports.deserializePlatformApp =
|
|
21
|
+
exports.serializePlatformApp =
|
|
22
|
+
exports.deserializePage =
|
|
23
|
+
exports.serializePage =
|
|
24
|
+
exports.deserializeComponent =
|
|
25
|
+
exports.serializeComponent =
|
|
26
|
+
exports.deserializeDataVariables =
|
|
27
|
+
exports.deserializeAttributes =
|
|
28
|
+
exports.serializeAttributes =
|
|
29
|
+
exports.deserializeDynamicMap =
|
|
30
|
+
exports.serializeDynamicMap =
|
|
31
|
+
exports.deserializeValue =
|
|
32
|
+
exports.serializeValue =
|
|
33
|
+
exports.generateDefaultCode =
|
|
34
|
+
exports.getUsedComps =
|
|
35
|
+
void 0;
|
|
36
|
+
const lodash_1 = require('lodash');
|
|
37
|
+
const common_1 = require('../../types/platform/common');
|
|
38
|
+
const expression_1 = require('../expression');
|
|
39
|
+
const common_2 = require('./utils/common');
|
|
40
|
+
const style_1 = require('./utils/style');
|
|
41
|
+
const runtime_1 = require('./utils/runtime');
|
|
42
|
+
const config_1 = require('./utils/version/config');
|
|
43
|
+
const template_1 = require('./utils/template');
|
|
44
|
+
var common_3 = require('./utils/common');
|
|
45
|
+
Object.defineProperty(exports, 'getUsedComps', {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return common_3.getUsedComps;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
var template_2 = require('./utils/template');
|
|
52
|
+
Object.defineProperty(exports, 'generateDefaultCode', {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return template_2.generateDefaultCode;
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
function serializeValue({ ctx, key, dynamicValue, scope = 'page', streamlineDefaultValue }) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
let { value } = dynamicValue;
|
|
61
|
+
let { dependenciesMap = {} } = ctx;
|
|
62
|
+
if (dynamicValue.type && dynamicValue.type !== 'static') {
|
|
63
|
+
key = `:${key}`;
|
|
64
|
+
switch (dynamicValue.type) {
|
|
65
|
+
case expression_1.PropBindType.state:
|
|
66
|
+
case expression_1.PropBindType.computed:
|
|
67
|
+
case expression_1.PropBindType.dataVar:
|
|
68
|
+
case expression_1.PropBindType.stateData:
|
|
69
|
+
case expression_1.PropBindType.params: {
|
|
70
|
+
const TYPE_MAP = {
|
|
71
|
+
[expression_1.PropBindType.prop]: 'props',
|
|
72
|
+
[expression_1.PropBindType.state]: 'state',
|
|
73
|
+
[expression_1.PropBindType.computed]: 'computed',
|
|
74
|
+
[expression_1.PropBindType.dataVar]: 'dataVar',
|
|
75
|
+
[expression_1.PropBindType.stateData]: 'dataset.state',
|
|
76
|
+
[expression_1.PropBindType.params]: 'dataset.params',
|
|
77
|
+
};
|
|
78
|
+
let exp = dynamicValue.value;
|
|
79
|
+
let reg = /^(.*?)\./;
|
|
80
|
+
let prefix = exp;
|
|
81
|
+
let matched = exp.match(reg);
|
|
82
|
+
if (matched) {
|
|
83
|
+
prefix = matched[1];
|
|
86
84
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if ((config === null || config === void 0 ? void 0 : config.default) === value || (config && config.default === undefined && value === '')) {
|
|
93
|
-
value = undefined;
|
|
85
|
+
let replacer = scope === 'component' ? '$comp' : '$page';
|
|
86
|
+
if (prefix === 'global') {
|
|
87
|
+
replacer = '$app';
|
|
88
|
+
} else if (/^comp-\w+/.test(prefix) || /^\$comp_\w+/.test(prefix)) {
|
|
89
|
+
replacer = '$comp';
|
|
94
90
|
}
|
|
91
|
+
replacer += `.${TYPE_MAP[dynamicValue.type]}.`;
|
|
92
|
+
value = exp.replace(reg, replacer);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case expression_1.PropBindType.prop: {
|
|
96
|
+
const isNeg = dynamicValue.value.startsWith('!');
|
|
97
|
+
value = isNeg
|
|
98
|
+
? dynamicValue.value.replace('!', '!$comp.props.data.')
|
|
99
|
+
: `$comp.props.data.${dynamicValue.value}`;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case expression_1.PropBindType.forItem: {
|
|
103
|
+
value = `$for.${dynamicValue.value}`;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case expression_1.PropBindType.slot: {
|
|
107
|
+
value = '$slot';
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case expression_1.PropBindType.expression: {
|
|
111
|
+
// Todo: 表达式转义
|
|
112
|
+
// app.state => $app.state
|
|
113
|
+
// forItems.state => $for.state
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} else if (streamlineDefaultValue) {
|
|
118
|
+
let { module = '', component = '' } = ctx.component || {};
|
|
119
|
+
let sourceKey = `${module}:${component}`;
|
|
120
|
+
let config =
|
|
121
|
+
(_b =
|
|
122
|
+
(_a = dependenciesMap === null || dependenciesMap === void 0 ? void 0 : dependenciesMap[sourceKey]) === null ||
|
|
123
|
+
_a === void 0
|
|
124
|
+
? void 0
|
|
125
|
+
: _a.dataForm) === null || _b === void 0
|
|
126
|
+
? void 0
|
|
127
|
+
: _b[key];
|
|
128
|
+
if (
|
|
129
|
+
(config === null || config === void 0 ? void 0 : config.default) === value ||
|
|
130
|
+
(config && config.default === undefined && value === '')
|
|
131
|
+
) {
|
|
132
|
+
value = undefined;
|
|
95
133
|
}
|
|
96
|
-
|
|
134
|
+
}
|
|
135
|
+
return { key, value, extra: dynamicValue.extra };
|
|
97
136
|
}
|
|
98
137
|
exports.serializeValue = serializeValue;
|
|
99
138
|
const DYNAMIC_KEY_REG = /^:(.*)$/;
|
|
100
139
|
function deserializeValue(ctx, key, value, extra) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
140
|
+
var _a;
|
|
141
|
+
let matched = key.match(DYNAMIC_KEY_REG);
|
|
142
|
+
if (matched) {
|
|
143
|
+
let key = matched[1];
|
|
144
|
+
let type = expression_1.PropBindType.expression;
|
|
145
|
+
try {
|
|
146
|
+
let parser = new expression_1.DynamicValueParser(value, {
|
|
147
|
+
pageId: (_a = ctx.page) === null || _a === void 0 ? void 0 : _a.id,
|
|
148
|
+
});
|
|
149
|
+
let res = parser.parse();
|
|
150
|
+
type = res.type;
|
|
151
|
+
if ((res === null || res === void 0 ? void 0 : res.value) != undefined) {
|
|
152
|
+
value = res.value;
|
|
153
|
+
}
|
|
154
|
+
} catch (e) {
|
|
155
|
+
if (typeof value === 'boolean') {
|
|
156
|
+
type = expression_1.PropBindType.static;
|
|
157
|
+
} else {
|
|
158
|
+
type = expression_1.PropBindType.expression;
|
|
106
159
|
try {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if ((res === null || res === void 0 ? void 0 : res.value) != undefined) {
|
|
111
|
-
value = res.value;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
if (typeof value === 'boolean') {
|
|
116
|
-
type = expression_1.PropBindType.static;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
type = expression_1.PropBindType.expression;
|
|
120
|
-
try {
|
|
121
|
-
value = value.replace(/\$app\./g, 'app.').replace(/\$for./g, 'forItems.');
|
|
122
|
-
}
|
|
123
|
-
catch (e) { }
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
key,
|
|
128
|
-
value: { type, value, extra },
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return {
|
|
133
|
-
key,
|
|
134
|
-
value: value === undefined
|
|
135
|
-
? undefined
|
|
136
|
-
: {
|
|
137
|
-
type: undefined /* 'static'*/,
|
|
138
|
-
value,
|
|
139
|
-
extra,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
160
|
+
value = value.replace(/\$app\./g, 'app.').replace(/\$for./g, 'forItems.');
|
|
161
|
+
} catch (e) {}
|
|
162
|
+
}
|
|
142
163
|
}
|
|
164
|
+
return {
|
|
165
|
+
key,
|
|
166
|
+
value: { type, value, extra },
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
return {
|
|
170
|
+
key,
|
|
171
|
+
value:
|
|
172
|
+
value === undefined
|
|
173
|
+
? undefined
|
|
174
|
+
: {
|
|
175
|
+
type: undefined /* 'static'*/,
|
|
176
|
+
value,
|
|
177
|
+
extra,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
143
181
|
}
|
|
144
182
|
exports.deserializeValue = deserializeValue;
|
|
145
183
|
function serializeDynamicMap(props) {
|
|
146
|
-
|
|
184
|
+
return serializeDynamicMapWithExtra(props).data;
|
|
147
185
|
}
|
|
148
186
|
exports.serializeDynamicMap = serializeDynamicMap;
|
|
149
|
-
function serializeDynamicMapWithExtra({ ctx, map = {}, scope = 'page', streamlineDefaultValue
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
187
|
+
function serializeDynamicMapWithExtra({ ctx, map = {}, scope = 'page', streamlineDefaultValue }) {
|
|
188
|
+
let data = {};
|
|
189
|
+
let extra = {};
|
|
190
|
+
Object.keys(map)
|
|
191
|
+
.sort((a, b) => {
|
|
192
|
+
const aPath = a.split('.');
|
|
193
|
+
const bPath = b.split('.');
|
|
194
|
+
const isADynamic = aPath[0].startsWith(':');
|
|
195
|
+
const isBDynamic = bPath[0].startsWith(':');
|
|
196
|
+
if (isADynamic !== isBDynamic) {
|
|
197
|
+
return isADynamic ? -1 : 1;
|
|
198
|
+
} else {
|
|
199
|
+
return aPath > bPath ? 1 : -1;
|
|
200
|
+
}
|
|
164
201
|
})
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
.forEach((key) => {
|
|
203
|
+
let {
|
|
204
|
+
key: processedKey,
|
|
205
|
+
value: processedValue,
|
|
206
|
+
extra: processedExtra,
|
|
207
|
+
} = serializeValue({
|
|
208
|
+
ctx,
|
|
209
|
+
key,
|
|
210
|
+
dynamicValue: map[key],
|
|
211
|
+
scope,
|
|
212
|
+
streamlineDefaultValue,
|
|
213
|
+
});
|
|
214
|
+
let matched = processedKey.match(/^:(.*)$/);
|
|
215
|
+
let originKey = processedKey;
|
|
216
|
+
if (matched) {
|
|
217
|
+
originKey = matched[1];
|
|
218
|
+
(0, lodash_1.unset)(data, originKey);
|
|
219
|
+
}
|
|
220
|
+
const originKeyArr = originKey.split('.');
|
|
221
|
+
if ((0, lodash_1.get)(data, processedKey) == undefined) {
|
|
222
|
+
/* 选区结构处理 [formily] to [CALS] */
|
|
223
|
+
if (
|
|
224
|
+
Array.isArray(processedValue) &&
|
|
225
|
+
(processedValue === null || processedValue === void 0
|
|
226
|
+
? void 0
|
|
227
|
+
: processedValue.some((item) => !!(item === null || item === void 0 ? void 0 : item.selectableBlock)))
|
|
228
|
+
) {
|
|
229
|
+
let valueTmp = (0, lodash_1.cloneDeep)(processedValue);
|
|
230
|
+
processedValue =
|
|
231
|
+
valueTmp === null || valueTmp === void 0
|
|
232
|
+
? void 0
|
|
233
|
+
: valueTmp.map((_value) => {
|
|
234
|
+
var _a, _b, _c;
|
|
235
|
+
const xProp =
|
|
236
|
+
(_a = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null ||
|
|
237
|
+
_a === void 0
|
|
238
|
+
? void 0
|
|
239
|
+
: _a['x-props'];
|
|
240
|
+
const xComponent =
|
|
241
|
+
(_c =
|
|
242
|
+
(_b = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null ||
|
|
243
|
+
_b === void 0
|
|
244
|
+
? void 0
|
|
245
|
+
: _b['x-component']) === null || _c === void 0
|
|
246
|
+
? void 0
|
|
247
|
+
: _c.toLowerCase();
|
|
248
|
+
const module = xComponent === null || xComponent === void 0 ? void 0 : xComponent.split(':')[0];
|
|
249
|
+
const component = xComponent === null || xComponent === void 0 ? void 0 : xComponent.split(':')[1];
|
|
250
|
+
if (
|
|
251
|
+
xProp &&
|
|
252
|
+
config_1.MODULE_SELECTABLEBLOCK_REGEX.test(module) &&
|
|
253
|
+
config_1.COMPONENT_SELECTABLEBLOCK_WHITELIST.includes(component)
|
|
254
|
+
) {
|
|
255
|
+
_value.selectableBlock = serializeRuntimeComponent(ctx, _value.selectableBlock);
|
|
256
|
+
}
|
|
257
|
+
return _value;
|
|
196
258
|
});
|
|
197
|
-
}
|
|
198
|
-
// 为动态数据且有多级,将{":range.0.label": "$page.dataset.state.test1"}转为{ range: [{ label: "$page.dataset.state.test1"}] }
|
|
199
|
-
if (matched && originKeyArr.length >= 2) {
|
|
200
|
-
(0, lodash_1.set)(data, replaceWithColon(originKey), (0, lodash_1.cloneDeep)(processedValue));
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
data[processedKey] = (0, lodash_1.cloneDeep)(processedValue);
|
|
204
|
-
}
|
|
205
259
|
}
|
|
206
|
-
|
|
260
|
+
// 为动态数据且有多级,将{":range.0.label": "$page.dataset.state.test1"}转为{ range: [{ label: "$page.dataset.state.test1"}] }
|
|
261
|
+
if (matched && originKeyArr.length >= 2) {
|
|
262
|
+
(0, lodash_1.set)(data, replaceWithColon(originKey), (0, lodash_1.cloneDeep)(processedValue));
|
|
263
|
+
} else {
|
|
264
|
+
data[processedKey] = (0, lodash_1.cloneDeep)(processedValue);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
extra[originKey] = processedExtra;
|
|
207
268
|
});
|
|
208
|
-
|
|
269
|
+
return { data, extra };
|
|
209
270
|
}
|
|
210
271
|
/**
|
|
211
272
|
* 将{ range: [{ label: "$page.dataset.state.test1"}] }的path range.0.label 转为range.0.:label
|
|
@@ -213,10 +274,10 @@ function serializeDynamicMapWithExtra({ ctx, map = {}, scope = 'page', streamlin
|
|
|
213
274
|
* @returns
|
|
214
275
|
*/
|
|
215
276
|
function replaceWithColon(key) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
277
|
+
const keyArr = key.split('.');
|
|
278
|
+
// 最深一层前面加上":"
|
|
279
|
+
keyArr[keyArr.length - 1] = `:${keyArr[keyArr.length - 1]}`;
|
|
280
|
+
return keyArr.join('.');
|
|
220
281
|
}
|
|
221
282
|
/**
|
|
222
283
|
* 预处理,先还原数据。
|
|
@@ -228,97 +289,126 @@ function replaceWithColon(key) {
|
|
|
228
289
|
* @returns
|
|
229
290
|
*/
|
|
230
291
|
function recoverSynamicMap(parent, current, path = '') {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
292
|
+
Object.keys(current).forEach((key) => {
|
|
293
|
+
let value = current[key];
|
|
294
|
+
if ((0, lodash_1.isArray)(value)) {
|
|
295
|
+
// 注意如果是 selectableBlock 独立处理
|
|
296
|
+
if (
|
|
297
|
+
value === null || value === void 0
|
|
298
|
+
? void 0
|
|
299
|
+
: value.some((item) => !!(item === null || item === void 0 ? void 0 : item.selectableBlock))
|
|
300
|
+
) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
// 数组必须在前面
|
|
304
|
+
value.forEach((valueItem, valueIndex) => {
|
|
305
|
+
if ((0, lodash_1.isObject)(valueItem)) {
|
|
306
|
+
valueItem = recoverSynamicMap(parent, valueItem, `${path === '' ? '' : `${path}.`}${key}.${valueIndex}`);
|
|
244
307
|
}
|
|
245
|
-
|
|
246
|
-
|
|
308
|
+
});
|
|
309
|
+
} else if ((0, lodash_1.isObject)(value)) {
|
|
310
|
+
value = recoverSynamicMap(parent, value, `${path === '' ? '' : `${path}.`}${key}`);
|
|
311
|
+
} else {
|
|
312
|
+
const matched = key.match(DYNAMIC_KEY_REG);
|
|
313
|
+
if (matched) {
|
|
314
|
+
parent[`:${path === '' ? '' : `${path}.`}${matched[1]}`] = current[key];
|
|
315
|
+
if (current !== parent) {
|
|
316
|
+
// 如果是第一层级,说明current和parent相等,不unset
|
|
317
|
+
(0, lodash_1.unset)(current, key);
|
|
247
318
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (current !== parent) {
|
|
253
|
-
// 如果是第一层级,说明current和parent相等,不unset
|
|
254
|
-
(0, lodash_1.unset)(current, key);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
return current;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
return current;
|
|
260
323
|
}
|
|
261
324
|
function deserializeDynamicMap(ctx, map, extraMap) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
325
|
+
var _a, _b;
|
|
326
|
+
let data = {};
|
|
327
|
+
const clonedMap = (0, lodash_1.cloneDeep)(map);
|
|
328
|
+
// 还原flatten path
|
|
329
|
+
map = recoverSynamicMap(clonedMap, clonedMap, '');
|
|
330
|
+
for (let key in map || {}) {
|
|
331
|
+
let value = map === null || map === void 0 ? void 0 : map[key];
|
|
332
|
+
let matched = key.match(DYNAMIC_KEY_REG);
|
|
333
|
+
let { key: processedKey, value: processedValue } = deserializeValue(
|
|
334
|
+
ctx,
|
|
335
|
+
key,
|
|
336
|
+
value,
|
|
337
|
+
extraMap === null || extraMap === void 0 ? void 0 : extraMap[matched ? matched[1] : key],
|
|
338
|
+
);
|
|
339
|
+
/* 选区结构处理 [CALS] to [formily] */
|
|
340
|
+
if (
|
|
341
|
+
Array.isArray(processedValue === null || processedValue === void 0 ? void 0 : processedValue.value) &&
|
|
342
|
+
((_a = processedValue === null || processedValue === void 0 ? void 0 : processedValue.value) === null ||
|
|
343
|
+
_a === void 0
|
|
344
|
+
? void 0
|
|
345
|
+
: _a.some((item) => !!(item === null || item === void 0 ? void 0 : item.selectableBlock)))
|
|
346
|
+
) {
|
|
347
|
+
(_b = processedValue === null || processedValue === void 0 ? void 0 : processedValue.value) === null ||
|
|
348
|
+
_b === void 0
|
|
349
|
+
? void 0
|
|
350
|
+
: _b.forEach((_value) => {
|
|
351
|
+
var _a, _b, _c, _d;
|
|
352
|
+
const module =
|
|
353
|
+
(_b =
|
|
354
|
+
(_a = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null || _a === void 0
|
|
355
|
+
? void 0
|
|
356
|
+
: _a.module) === null || _b === void 0
|
|
357
|
+
? void 0
|
|
358
|
+
: _b.toLowerCase();
|
|
359
|
+
const component =
|
|
360
|
+
(_d =
|
|
361
|
+
(_c = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null || _c === void 0
|
|
362
|
+
? void 0
|
|
363
|
+
: _c.component) === null || _d === void 0
|
|
364
|
+
? void 0
|
|
365
|
+
: _d.toLowerCase();
|
|
366
|
+
if (
|
|
367
|
+
_value.selectableBlock &&
|
|
368
|
+
config_1.MODULE_SELECTABLEBLOCK_REGEX.test(module) &&
|
|
369
|
+
config_1.COMPONENT_SELECTABLEBLOCK_WHITELIST.includes(component)
|
|
370
|
+
) {
|
|
371
|
+
_value.selectableBlock = deserializeRuntimeComponent(ctx, _value.selectableBlock);
|
|
372
|
+
}
|
|
373
|
+
return _value;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
if (processedValue !== undefined) {
|
|
377
|
+
data[processedKey] = processedValue;
|
|
288
378
|
}
|
|
289
|
-
|
|
379
|
+
}
|
|
380
|
+
return data;
|
|
290
381
|
}
|
|
291
382
|
exports.deserializeDynamicMap = deserializeDynamicMap;
|
|
292
383
|
function serializeAttributes(ctx, scope, attributes = {}) {
|
|
293
|
-
|
|
294
|
-
|
|
384
|
+
var _a;
|
|
385
|
+
return (_a = serializeAttributesWithExtra(ctx, scope, attributes)) === null || _a === void 0 ? void 0 : _a.data;
|
|
295
386
|
}
|
|
296
387
|
exports.serializeAttributes = serializeAttributes;
|
|
297
388
|
function serializeAttributesWithExtra(ctx, scope, attributes = {}) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
389
|
+
return serializeDynamicMapWithExtra({
|
|
390
|
+
ctx,
|
|
391
|
+
scope,
|
|
392
|
+
map: attributes,
|
|
393
|
+
streamlineDefaultValue: ctx.streamlineDefaultValue,
|
|
394
|
+
});
|
|
304
395
|
}
|
|
305
396
|
function deserializeAttributes(ctx, attributes = {}, attributesExtraData = {}) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
restAttributes[key] = attributes[key];
|
|
319
|
-
}
|
|
397
|
+
const reservedAttributes = ['style', 'commonStyle', 'class'];
|
|
398
|
+
const reservedAttributesMap = reservedAttributes.reduce((map, key) => {
|
|
399
|
+
map[key] = true;
|
|
400
|
+
map[`:${key}`] = true;
|
|
401
|
+
return map;
|
|
402
|
+
}, {});
|
|
403
|
+
let restAttributes = {};
|
|
404
|
+
for (let key in attributes) {
|
|
405
|
+
if (reservedAttributesMap[key]) {
|
|
406
|
+
continue;
|
|
407
|
+
} else {
|
|
408
|
+
restAttributes[key] = attributes[key];
|
|
320
409
|
}
|
|
321
|
-
|
|
410
|
+
}
|
|
411
|
+
return deserializeDynamicMap(ctx, restAttributes, attributesExtraData);
|
|
322
412
|
}
|
|
323
413
|
exports.deserializeAttributes = deserializeAttributes;
|
|
324
414
|
/**
|
|
@@ -326,452 +416,607 @@ exports.deserializeAttributes = deserializeAttributes;
|
|
|
326
416
|
* 目前仅转换 state 中的 initMethod.params 和 updateMethod.params
|
|
327
417
|
*/
|
|
328
418
|
function serializeDataset(ctx, dataset) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
419
|
+
if (!isDatasetNeedToProcess(dataset)) return dataset;
|
|
420
|
+
const result = JSON.parse(JSON.stringify(dataset));
|
|
421
|
+
Object.values(result.state).forEach((state) => {
|
|
422
|
+
var _a, _b, _c, _d;
|
|
423
|
+
if (state.varType !== 'datasource') return;
|
|
424
|
+
if ((_a = state.initMethod) === null || _a === void 0 ? void 0 : _a.params) {
|
|
425
|
+
state.initMethod.params =
|
|
426
|
+
(_b = serializeDynamicMapWithExtra({
|
|
427
|
+
ctx,
|
|
428
|
+
map: state.initMethod.params,
|
|
429
|
+
})) === null || _b === void 0
|
|
430
|
+
? void 0
|
|
431
|
+
: _b.data;
|
|
432
|
+
}
|
|
433
|
+
if ((_c = state.updateMethod) === null || _c === void 0 ? void 0 : _c.params) {
|
|
434
|
+
state.updateMethod.params =
|
|
435
|
+
(_d = serializeDynamicMapWithExtra({
|
|
436
|
+
ctx,
|
|
437
|
+
map: state.updateMethod.params,
|
|
438
|
+
})) === null || _d === void 0
|
|
439
|
+
? void 0
|
|
440
|
+
: _d.data;
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
return result;
|
|
350
444
|
}
|
|
351
445
|
/**
|
|
352
446
|
* 将dataset({state: {}, params: {}})从 cals 结构转换为weapp结构
|
|
353
447
|
* 目前仅转换 state 中的 initMethod.params 和 updateMethod.params
|
|
354
448
|
*/
|
|
355
449
|
function deserializeDataset(ctx, dataset) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
371
|
-
return result;
|
|
450
|
+
if (!isDatasetNeedToProcess(dataset)) return dataset;
|
|
451
|
+
// 克隆, 避免引用问题
|
|
452
|
+
const result = JSON.parse(JSON.stringify(dataset));
|
|
453
|
+
Object.values(result.state).forEach((state) => {
|
|
454
|
+
var _a, _b;
|
|
455
|
+
if (state.varType !== 'datasource') return;
|
|
456
|
+
if ((_a = state.initMethod) === null || _a === void 0 ? void 0 : _a.params) {
|
|
457
|
+
state.initMethod.params = deserializeDynamicMap(ctx, state.initMethod.params);
|
|
458
|
+
}
|
|
459
|
+
if ((_b = state.updateMethod) === null || _b === void 0 ? void 0 : _b.params) {
|
|
460
|
+
state.updateMethod.params = deserializeDynamicMap(ctx, state.updateMethod.params);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
return result;
|
|
372
464
|
}
|
|
373
465
|
/**
|
|
374
466
|
* dataset 是否需要转换处理
|
|
375
467
|
* dataset 为空, 或者无数据源变量, 或者变量中未使用入参, 则不需要进行转换
|
|
376
468
|
*/
|
|
377
469
|
function isDatasetNeedToProcess(dataset) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
470
|
+
if (!dataset || !dataset.state) return false;
|
|
471
|
+
const hasNoParams = Object.values(dataset.state).every((item) => {
|
|
472
|
+
var _a, _b;
|
|
473
|
+
return (
|
|
474
|
+
item.varType !== 'datasource' ||
|
|
475
|
+
!(
|
|
476
|
+
((_a = item.initMethod) === null || _a === void 0 ? void 0 : _a.params) ||
|
|
477
|
+
((_b = item.updateMethod) === null || _b === void 0 ? void 0 : _b.params)
|
|
478
|
+
)
|
|
479
|
+
);
|
|
480
|
+
});
|
|
481
|
+
if (hasNoParams) return false;
|
|
482
|
+
return true;
|
|
387
483
|
}
|
|
388
484
|
function serializeDirecties(ctx, directives, scope = 'page') {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
485
|
+
var _a;
|
|
486
|
+
let processed = {
|
|
487
|
+
':if': directives.waIf
|
|
488
|
+
? serializeValue({
|
|
489
|
+
ctx,
|
|
490
|
+
key: 'waIf',
|
|
491
|
+
dynamicValue: directives.waIf,
|
|
492
|
+
scope,
|
|
493
|
+
}).value
|
|
494
|
+
: undefined,
|
|
495
|
+
':for': directives.waFor
|
|
496
|
+
? `${(_a = ctx.component) === null || _a === void 0 ? void 0 : _a.id} in ${
|
|
497
|
+
serializeValue({
|
|
498
|
+
ctx,
|
|
499
|
+
key: 'waFor',
|
|
500
|
+
dynamicValue: directives.waFor,
|
|
501
|
+
scope,
|
|
502
|
+
}).value
|
|
503
|
+
}`
|
|
504
|
+
: undefined,
|
|
505
|
+
key: directives.waForKey
|
|
506
|
+
? serializeValue({
|
|
507
|
+
ctx,
|
|
508
|
+
key: 'waForKey',
|
|
509
|
+
dynamicValue: directives.waForKey,
|
|
510
|
+
scope,
|
|
511
|
+
}).value
|
|
512
|
+
: undefined,
|
|
513
|
+
};
|
|
514
|
+
for (let key in processed) {
|
|
515
|
+
let map = processed;
|
|
516
|
+
if (map[key] !== undefined) {
|
|
517
|
+
return processed;
|
|
421
518
|
}
|
|
422
|
-
|
|
519
|
+
}
|
|
520
|
+
return undefined;
|
|
423
521
|
}
|
|
424
522
|
function deserializeDirecties(ctx, directives) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
523
|
+
let waIf =
|
|
524
|
+
(directives === null || directives === void 0 ? void 0 : directives[':if']) !== undefined
|
|
525
|
+
? deserializeValue(ctx, ':if', directives[':if']).value
|
|
526
|
+
: { value: true };
|
|
527
|
+
let waFor = (directives === null || directives === void 0 ? void 0 : directives[':for'])
|
|
528
|
+
? deserializeValue(ctx, ':for', directives[':for']).value
|
|
529
|
+
: undefined;
|
|
530
|
+
const waForKey = (directives === null || directives === void 0 ? void 0 : directives.key)
|
|
531
|
+
? deserializeValue(ctx, 'key', directives.key).value
|
|
532
|
+
: undefined;
|
|
533
|
+
if (waFor) {
|
|
534
|
+
let { type, value } = waFor;
|
|
535
|
+
if (type === expression_1.PropBindType.expression) {
|
|
536
|
+
waFor.value = value.replace(/^(.*?in\s)/, '');
|
|
433
537
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
538
|
+
}
|
|
539
|
+
let processed = {
|
|
540
|
+
waIf: (waIf === null || waIf === void 0 ? void 0 : waIf.value) === true ? undefined : waIf,
|
|
541
|
+
waFor,
|
|
542
|
+
waForKey,
|
|
543
|
+
};
|
|
544
|
+
for (let key in processed) {
|
|
545
|
+
let map = processed;
|
|
546
|
+
if (map[key] !== undefined) {
|
|
547
|
+
return processed;
|
|
444
548
|
}
|
|
445
|
-
|
|
549
|
+
}
|
|
550
|
+
return undefined;
|
|
446
551
|
}
|
|
447
552
|
/**
|
|
448
553
|
* TODO
|
|
449
554
|
* heander 更新为表达式
|
|
450
555
|
*/
|
|
451
556
|
function serializeListener(ctx, listener) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
557
|
+
const { data, extra = {} } =
|
|
558
|
+
serializeDynamicMapWithExtra({
|
|
559
|
+
ctx,
|
|
560
|
+
map: listener.data,
|
|
455
561
|
}) || {};
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
562
|
+
let platfromListener = {};
|
|
563
|
+
if (listener.handler) {
|
|
564
|
+
platfromListener = {
|
|
565
|
+
id: listener.key,
|
|
566
|
+
eventName: listener.trigger,
|
|
567
|
+
type: listener.type,
|
|
568
|
+
handler: {
|
|
569
|
+
name: listener.handler.name,
|
|
570
|
+
module: /^comp-\w+$/.test(listener.handler.moduleName) ? '$comp' : listener.handler.moduleName,
|
|
571
|
+
params: data,
|
|
572
|
+
},
|
|
573
|
+
isCapturePhase: listener.isCapturePhase,
|
|
466
574
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
575
|
+
} else {
|
|
576
|
+
platfromListener = {
|
|
577
|
+
id: listener.key,
|
|
578
|
+
eventName: listener.trigger,
|
|
579
|
+
type: listener.type,
|
|
580
|
+
handler: {},
|
|
581
|
+
jsCode: listener.jsCode,
|
|
582
|
+
isCapturePhase: listener.isCapturePhase,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
if (Object.keys(extra).some((key) => extra[key] !== undefined)) {
|
|
586
|
+
if (!platfromListener.extra) {
|
|
587
|
+
platfromListener.extra = {};
|
|
472
588
|
}
|
|
473
|
-
|
|
589
|
+
platfromListener.extra.handlerParamExtraData = extra;
|
|
590
|
+
}
|
|
591
|
+
return platfromListener;
|
|
474
592
|
}
|
|
475
593
|
function deserializeListener(ctx, listener) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
594
|
+
var _a, _b, _c, _d;
|
|
595
|
+
let processed = {
|
|
596
|
+
key: listener.id,
|
|
597
|
+
trigger: listener.eventName,
|
|
598
|
+
type: listener.type,
|
|
599
|
+
handler: {
|
|
600
|
+
name: (_a = listener.handler) === null || _a === void 0 ? void 0 : _a.name,
|
|
601
|
+
moduleName: (_b = listener.handler) === null || _b === void 0 ? void 0 : _b.module,
|
|
602
|
+
},
|
|
603
|
+
data: deserializeDynamicMap(
|
|
604
|
+
ctx,
|
|
605
|
+
((_c = listener.handler) === null || _c === void 0 ? void 0 : _c.params) || {},
|
|
606
|
+
((_d = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _d === void 0
|
|
607
|
+
? void 0
|
|
608
|
+
: _d.handlerParamExtraData) || {},
|
|
609
|
+
),
|
|
610
|
+
isCapturePhase: !!listener.isCapturePhase,
|
|
611
|
+
// TODO
|
|
612
|
+
noPropagation: !!listener.noPropagation,
|
|
613
|
+
};
|
|
614
|
+
if (listener.jsCode) {
|
|
615
|
+
processed.jsCode = listener.jsCode;
|
|
616
|
+
}
|
|
617
|
+
return processed;
|
|
491
618
|
}
|
|
492
619
|
function serializeDataVariables(ctx, data) {
|
|
493
|
-
|
|
494
|
-
|
|
620
|
+
let { title } = data,
|
|
621
|
+
restData = __rest(data, ['title']);
|
|
622
|
+
return Object.assign(Object.assign({ varType: 'datasource' }, restData), { label: title });
|
|
495
623
|
}
|
|
496
624
|
function deserializeDataVariables(ctx, data) {
|
|
497
|
-
|
|
498
|
-
|
|
625
|
+
let { label } = data,
|
|
626
|
+
restData = __rest(data, ['label']);
|
|
627
|
+
return Object.assign(Object.assign({}, restData), { title: label });
|
|
499
628
|
}
|
|
500
629
|
exports.deserializeDataVariables = deserializeDataVariables;
|
|
501
630
|
function serializeCodeSource(ctx, data) {
|
|
502
|
-
|
|
503
|
-
|
|
631
|
+
const { type } = data;
|
|
632
|
+
return Object.assign(Object.assign({}, data), { type: common_1.EResourceType.CODE, codeType: type });
|
|
504
633
|
}
|
|
505
634
|
function deserializeCodeResource(ctx, data) {
|
|
506
|
-
|
|
507
|
-
|
|
635
|
+
const { type, codeType } = data,
|
|
636
|
+
resData = __rest(data, ['type', 'codeType']);
|
|
637
|
+
return Object.assign(Object.assign({}, resData), { type: codeType });
|
|
508
638
|
}
|
|
509
639
|
function serializeModuleName(ctx, moduleName, componentName) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
let find = undefined;
|
|
517
|
-
for (let i = dependencies.length - 1; i > 0; i--) {
|
|
518
|
-
let lib = dependencies[i];
|
|
519
|
-
let currentModuleName = lib.name;
|
|
520
|
-
let key = `${currentModuleName}:${componentName}`;
|
|
521
|
-
if (!!dependenciesMap[key]) {
|
|
522
|
-
find = lib;
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
if (find) {
|
|
527
|
-
if ((find === null || find === void 0 ? void 0 : find.name) === moduleName) {
|
|
528
|
-
return undefined;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
else if (((_b = dependencies[0]) === null || _b === void 0 ? void 0 : _b.name) === moduleName) {
|
|
532
|
-
return undefined;
|
|
533
|
-
}
|
|
640
|
+
var _a, _b;
|
|
641
|
+
let { dependencies = [], dependenciesMap = {} } = ctx;
|
|
642
|
+
if (ctx.streamlineModuleName) {
|
|
643
|
+
if (moduleName === ((_a = dependencies[0]) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
644
|
+
moduleName = undefined;
|
|
534
645
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
646
|
+
let find = undefined;
|
|
647
|
+
for (let i = dependencies.length - 1; i > 0; i--) {
|
|
648
|
+
let lib = dependencies[i];
|
|
649
|
+
let currentModuleName = lib.name;
|
|
650
|
+
let key = `${currentModuleName}:${componentName}`;
|
|
651
|
+
if (!!dependenciesMap[key]) {
|
|
652
|
+
find = lib;
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
540
655
|
}
|
|
541
|
-
|
|
656
|
+
if (find) {
|
|
657
|
+
if ((find === null || find === void 0 ? void 0 : find.name) === moduleName) {
|
|
658
|
+
return undefined;
|
|
659
|
+
}
|
|
660
|
+
} else if (((_b = dependencies[0]) === null || _b === void 0 ? void 0 : _b.name) === moduleName) {
|
|
661
|
+
return undefined;
|
|
662
|
+
}
|
|
663
|
+
} else if (
|
|
664
|
+
moduleName &&
|
|
665
|
+
!/-lcap-spinoff$/.test(moduleName) &&
|
|
666
|
+
!dependenciesMap[`${moduleName}:${componentName}`] &&
|
|
667
|
+
dependenciesMap[`${moduleName}-lcap-spinoff:${componentName}`]
|
|
668
|
+
) {
|
|
669
|
+
return `${moduleName}-lcap-spinoff`;
|
|
670
|
+
}
|
|
671
|
+
return moduleName;
|
|
542
672
|
}
|
|
543
673
|
function deserializeModuleName(ctx, componentName, moduleName) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
return find ? find === null || find === void 0 ? void 0 : find.name : defaultModuleName;
|
|
674
|
+
var _a;
|
|
675
|
+
let { dependencies = [], dependenciesMap = {} } = ctx;
|
|
676
|
+
let defaultModuleName = (_a = dependencies[0]) === null || _a === void 0 ? void 0 : _a.name;
|
|
677
|
+
// 补充默认的 moduleName 按照依赖反序查找
|
|
678
|
+
if (!moduleName) {
|
|
679
|
+
let find = undefined;
|
|
680
|
+
for (let i = dependencies.length - 1; i > 0; i--) {
|
|
681
|
+
let lib = dependencies[i];
|
|
682
|
+
let { name } = lib;
|
|
683
|
+
let key = `${name}:${componentName}`;
|
|
684
|
+
if (!!dependenciesMap[key]) {
|
|
685
|
+
find = lib;
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
560
688
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
689
|
+
return find ? (find === null || find === void 0 ? void 0 : find.name) : defaultModuleName;
|
|
690
|
+
} else if (
|
|
691
|
+
moduleName &&
|
|
692
|
+
!/-lcap-spinoff$/.test(moduleName) &&
|
|
693
|
+
!dependenciesMap[`${moduleName}:${componentName}`] &&
|
|
694
|
+
dependenciesMap[`${moduleName}-lcap-spinoff:${componentName}`]
|
|
695
|
+
) {
|
|
696
|
+
return `${moduleName}-lcap-spinoff`;
|
|
697
|
+
}
|
|
698
|
+
return moduleName;
|
|
568
699
|
}
|
|
569
700
|
function serializeComponent(ctx, component, scope = 'page') {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
701
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
702
|
+
// const scope = ctx.component?.id ? 'component' : 'page'
|
|
703
|
+
const moduleName = (_a = component.xComponent) === null || _a === void 0 ? void 0 : _a.moduleName;
|
|
704
|
+
const componentName = ((_b = component.xComponent) === null || _b === void 0 ? void 0 : _b.name) || '';
|
|
705
|
+
const componentCtx = Object.assign(Object.assign({}, ctx), {
|
|
706
|
+
component: {
|
|
707
|
+
id: component.id,
|
|
708
|
+
module: moduleName,
|
|
709
|
+
component: (_c = component.xComponent) === null || _c === void 0 ? void 0 : _c.name,
|
|
710
|
+
},
|
|
711
|
+
});
|
|
712
|
+
if (componentCtx.dependencies && !componentCtx.dependenciesMap) {
|
|
713
|
+
componentCtx.dependenciesMap = processDependenciesMap(componentCtx.dependencies || []);
|
|
714
|
+
}
|
|
715
|
+
let attributeMeta =
|
|
716
|
+
serializeAttributesWithExtra(
|
|
717
|
+
componentCtx,
|
|
718
|
+
scope,
|
|
719
|
+
((_d = component === null || component === void 0 ? void 0 : component.xProps) === null || _d === void 0
|
|
720
|
+
? void 0
|
|
721
|
+
: _d.data) || {},
|
|
722
|
+
) || {};
|
|
723
|
+
const { data: attributes = {}, extra: attributeExtraData = {} } = attributeMeta;
|
|
724
|
+
let classListBindData = null;
|
|
725
|
+
let styleBindData = null;
|
|
726
|
+
if (
|
|
727
|
+
(_e = component === null || component === void 0 ? void 0 : component.xProps) === null || _e === void 0
|
|
728
|
+
? void 0
|
|
729
|
+
: _e.classListBind
|
|
730
|
+
) {
|
|
731
|
+
classListBindData = serializeValue({
|
|
732
|
+
ctx: componentCtx,
|
|
733
|
+
key: 'classListBind',
|
|
734
|
+
dynamicValue:
|
|
735
|
+
(_f = component === null || component === void 0 ? void 0 : component.xProps) === null || _f === void 0
|
|
736
|
+
? void 0
|
|
737
|
+
: _f.classListBind,
|
|
738
|
+
scope,
|
|
739
|
+
});
|
|
740
|
+
if (classListBindData.extra) {
|
|
741
|
+
attributeExtraData.class = classListBindData.extra;
|
|
596
742
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
743
|
+
}
|
|
744
|
+
if (
|
|
745
|
+
(_g = component === null || component === void 0 ? void 0 : component.xProps) === null || _g === void 0
|
|
746
|
+
? void 0
|
|
747
|
+
: _g.styleBind
|
|
748
|
+
) {
|
|
749
|
+
styleBindData = serializeValue({
|
|
750
|
+
ctx: componentCtx,
|
|
751
|
+
key: 'styleBind',
|
|
752
|
+
dynamicValue:
|
|
753
|
+
(_h = component === null || component === void 0 ? void 0 : component.xProps) === null || _h === void 0
|
|
754
|
+
? void 0
|
|
755
|
+
: _h.styleBind,
|
|
756
|
+
});
|
|
757
|
+
if (styleBindData.extra) {
|
|
758
|
+
attributeExtraData.style = styleBindData.extra;
|
|
606
759
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
760
|
+
}
|
|
761
|
+
return {
|
|
762
|
+
id: component.id,
|
|
763
|
+
label: (0, runtime_1.getValidValue)(component.label),
|
|
764
|
+
type: undefined,
|
|
765
|
+
module: serializeModuleName(componentCtx, moduleName, componentName),
|
|
766
|
+
component: componentName,
|
|
767
|
+
attributes: (0, runtime_1.getValidValue)(
|
|
768
|
+
component.xProps
|
|
769
|
+
? Object.assign(Object.assign({}, attributes), {
|
|
770
|
+
style: (_j = component.xProps) === null || _j === void 0 ? void 0 : _j.style,
|
|
771
|
+
class:
|
|
772
|
+
(_l = (_k = component.xProps) === null || _k === void 0 ? void 0 : _k.classList) === null || _l === void 0
|
|
773
|
+
? void 0
|
|
774
|
+
: _l.join(' '),
|
|
775
|
+
})
|
|
776
|
+
: undefined,
|
|
777
|
+
),
|
|
778
|
+
items: component.properties
|
|
779
|
+
? Object.keys(component.properties).map((key) => {
|
|
780
|
+
var _a;
|
|
781
|
+
return serializeComponent(
|
|
782
|
+
componentCtx,
|
|
783
|
+
Object.assign({ id: key }, (_a = component.properties) === null || _a === void 0 ? void 0 : _a[key]),
|
|
784
|
+
scope,
|
|
785
|
+
);
|
|
786
|
+
})
|
|
787
|
+
: undefined,
|
|
788
|
+
listeners: (0, runtime_1.getValidValue)(
|
|
789
|
+
(_o = (_m = component.xProps) === null || _m === void 0 ? void 0 : _m.listeners) === null || _o === void 0
|
|
790
|
+
? void 0
|
|
791
|
+
: _o.map((listener) => {
|
|
622
792
|
return serializeListener(componentCtx, listener);
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
793
|
+
}),
|
|
794
|
+
),
|
|
795
|
+
directives: serializeDirecties(
|
|
796
|
+
componentCtx,
|
|
797
|
+
((_p = component.xProps) === null || _p === void 0 ? void 0 : _p.directives) || {},
|
|
798
|
+
scope,
|
|
799
|
+
) || {
|
|
800
|
+
':if': true,
|
|
801
|
+
},
|
|
802
|
+
':class': classListBindData ? classListBindData.value : undefined,
|
|
803
|
+
':style': styleBindData ? styleBindData.value : undefined,
|
|
804
|
+
extra: {
|
|
805
|
+
commonStyle: (_q = component.xProps) === null || _q === void 0 ? void 0 : _q.commonStyle,
|
|
806
|
+
xIndex: component.xIndex,
|
|
807
|
+
styleBindPath:
|
|
808
|
+
(_r = component === null || component === void 0 ? void 0 : component.xProps) === null || _r === void 0
|
|
809
|
+
? void 0
|
|
810
|
+
: _r.styleBindPath,
|
|
811
|
+
staticResourceAttribute:
|
|
812
|
+
(_s = component === null || component === void 0 ? void 0 : component.xProps) === null || _s === void 0
|
|
813
|
+
? void 0
|
|
814
|
+
: _s.staticResourceAttribute,
|
|
815
|
+
attributeExtraData: (0, common_2.isEmptyObj)(attributeExtraData) ? undefined : attributeExtraData,
|
|
816
|
+
},
|
|
817
|
+
};
|
|
637
818
|
}
|
|
638
819
|
exports.serializeComponent = serializeComponent;
|
|
639
820
|
function deserializeComponent(ctx, components) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
821
|
+
let componentMap = components.reduce((map, item) => {
|
|
822
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
823
|
+
const { attributeExtraData = {} } = item.extra || {};
|
|
824
|
+
let dynamicStyle = item[':style']
|
|
825
|
+
? deserializeValue(ctx, ':style', item[':style'], attributeExtraData.style).value
|
|
826
|
+
: undefined;
|
|
827
|
+
let dynamicClassList = item[':class']
|
|
828
|
+
? deserializeValue(ctx, ':class', item[':class'], attributeExtraData.class).value
|
|
829
|
+
: undefined;
|
|
830
|
+
const xComponent = {
|
|
831
|
+
moduleName: item.module,
|
|
832
|
+
name: item.component || undefined,
|
|
833
|
+
};
|
|
834
|
+
if (xComponent.name) {
|
|
835
|
+
xComponent.moduleName =
|
|
836
|
+
deserializeModuleName(ctx, xComponent.name, xComponent.moduleName) || xComponent.moduleName;
|
|
837
|
+
}
|
|
838
|
+
const xProps = {
|
|
839
|
+
data: deserializeAttributes(ctx, item.attributes, attributeExtraData),
|
|
840
|
+
directives: deserializeDirecties(ctx, item.directives || {}),
|
|
841
|
+
style: (_a = item.attributes) === null || _a === void 0 ? void 0 : _a.style,
|
|
842
|
+
styleBind: dynamicStyle
|
|
843
|
+
? {
|
|
844
|
+
type: dynamicStyle.type,
|
|
845
|
+
value: dynamicStyle.value,
|
|
846
|
+
}
|
|
847
|
+
: undefined,
|
|
848
|
+
commonStyle:
|
|
849
|
+
(_b = item === null || item === void 0 ? void 0 : item.extra) === null || _b === void 0
|
|
850
|
+
? void 0
|
|
851
|
+
: _b.commonStyle,
|
|
852
|
+
staticResourceAttribute:
|
|
853
|
+
(_c = item === null || item === void 0 ? void 0 : item.extra) === null || _c === void 0
|
|
854
|
+
? void 0
|
|
855
|
+
: _c.staticResourceAttribute,
|
|
856
|
+
classList:
|
|
857
|
+
(_f =
|
|
858
|
+
(_e = (_d = item.attributes) === null || _d === void 0 ? void 0 : _d.class) === null || _e === void 0
|
|
859
|
+
? void 0
|
|
860
|
+
: _e.split(/\s/g)) === null || _f === void 0
|
|
861
|
+
? void 0
|
|
862
|
+
: _f.filter((className) => !!className),
|
|
863
|
+
classListBind: item[':class']
|
|
864
|
+
? {
|
|
865
|
+
value: dynamicClassList === null || dynamicClassList === void 0 ? void 0 : dynamicClassList.value,
|
|
866
|
+
type: dynamicClassList === null || dynamicClassList === void 0 ? void 0 : dynamicClassList.type,
|
|
867
|
+
}
|
|
868
|
+
: undefined,
|
|
869
|
+
listeners:
|
|
870
|
+
((_g = item === null || item === void 0 ? void 0 : item.listeners) === null || _g === void 0
|
|
871
|
+
? void 0
|
|
872
|
+
: _g.map((item) => {
|
|
873
|
+
return deserializeListener(ctx, item);
|
|
678
874
|
})) || [],
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
875
|
+
};
|
|
876
|
+
let processed = {
|
|
877
|
+
xComponent: Object.values(xComponent).find((item) => item != undefined) ? xComponent : undefined,
|
|
878
|
+
xProps: Object.values(xProps).find((item) => {
|
|
879
|
+
if (Array.isArray(item)) {
|
|
880
|
+
return !!item.length;
|
|
881
|
+
}
|
|
882
|
+
return item != undefined && !(0, common_2.isEmptyObj)(item);
|
|
883
|
+
})
|
|
884
|
+
? xProps
|
|
885
|
+
: undefined,
|
|
886
|
+
/**
|
|
887
|
+
* TODO
|
|
888
|
+
*/
|
|
889
|
+
xIndex:
|
|
890
|
+
((_h = item.extra) === null || _h === void 0 ? void 0 : _h.xIndex) !== undefined
|
|
891
|
+
? (_j = item.extra) === null || _j === void 0
|
|
892
|
+
? void 0
|
|
893
|
+
: _j.xIndex
|
|
894
|
+
: undefined /* 0*/,
|
|
895
|
+
label:
|
|
896
|
+
(item === null || item === void 0 ? void 0 : item.label) !== undefined
|
|
897
|
+
? item === null || item === void 0
|
|
898
|
+
? void 0
|
|
899
|
+
: item.label
|
|
900
|
+
: undefined /* 0*/,
|
|
901
|
+
properties: item.items ? deserializeComponent(ctx, item.items) : undefined,
|
|
902
|
+
};
|
|
903
|
+
map[item.id] = processed;
|
|
904
|
+
return map;
|
|
905
|
+
}, {});
|
|
906
|
+
return componentMap;
|
|
701
907
|
}
|
|
702
908
|
exports.deserializeComponent = deserializeComponent;
|
|
703
909
|
function serializePage(ctx, page) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
910
|
+
var _a, _b, _c, _d, _e;
|
|
911
|
+
const pageCtx = Object.assign(Object.assign({}, ctx), { page });
|
|
912
|
+
if (pageCtx.dependencies && !pageCtx.dependenciesMap) {
|
|
913
|
+
pageCtx.dependenciesMap = processDependenciesMap(pageCtx.dependencies || []);
|
|
914
|
+
}
|
|
915
|
+
let processedPage = {
|
|
916
|
+
id: page.id,
|
|
917
|
+
type: 'PAGE',
|
|
918
|
+
component: 'Page',
|
|
919
|
+
attributes: (0, runtime_1.getValidValue)(
|
|
920
|
+
(_a = serializeAttributesWithExtra(pageCtx, 'page', page.data)) === null || _a === void 0 ? void 0 : _a.data,
|
|
921
|
+
),
|
|
922
|
+
items: Object.keys(page.componentInstances || {}).map((id) => {
|
|
923
|
+
return serializeComponent(pageCtx, Object.assign({ id }, page.componentInstances[id]));
|
|
924
|
+
}),
|
|
925
|
+
directives: {
|
|
926
|
+
':if': true,
|
|
927
|
+
},
|
|
928
|
+
resources:
|
|
929
|
+
(_b = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _b === void 0
|
|
930
|
+
? void 0
|
|
931
|
+
: _b.map((item) => serializeCodeSource(pageCtx, item)),
|
|
932
|
+
dataset: serializeDataset(ctx, page === null || page === void 0 ? void 0 : page.dataset),
|
|
933
|
+
dataVariables: (0, runtime_1.getValidValue)(
|
|
934
|
+
(_d =
|
|
935
|
+
(_c = page === null || page === void 0 ? void 0 : page.vars) === null || _c === void 0 ? void 0 : _c.data) ===
|
|
936
|
+
null || _d === void 0
|
|
937
|
+
? void 0
|
|
938
|
+
: _d.map((item) => serializeDataVariables(pageCtx, item)),
|
|
939
|
+
),
|
|
940
|
+
listeners: (0, runtime_1.getValidValue)(
|
|
941
|
+
(_e = page === null || page === void 0 ? void 0 : page.listeners) === null || _e === void 0
|
|
942
|
+
? void 0
|
|
943
|
+
: _e.map((item) => {
|
|
724
944
|
return serializeListener(pageCtx, item);
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
|
|
945
|
+
}),
|
|
946
|
+
),
|
|
947
|
+
extra: {
|
|
948
|
+
commonStyle: page === null || page === void 0 ? void 0 : page.commonStyle,
|
|
949
|
+
xIndex: page.xIndex,
|
|
950
|
+
staticResourceAttribute: page === null || page === void 0 ? void 0 : page.staticResourceAttribute,
|
|
951
|
+
hideAdminPortalMenu: page === null || page === void 0 ? void 0 : page.hideAdminPortalMenu,
|
|
952
|
+
},
|
|
953
|
+
};
|
|
954
|
+
if (page.styleBind) {
|
|
955
|
+
page[':style'] = serializeValue({
|
|
956
|
+
ctx: pageCtx,
|
|
957
|
+
key: 'styleBind',
|
|
958
|
+
dynamicValue: page.styleBind,
|
|
959
|
+
}).value;
|
|
960
|
+
}
|
|
961
|
+
if (page.classListBind) {
|
|
962
|
+
page[':class'] = serializeValue({
|
|
963
|
+
ctx: pageCtx,
|
|
964
|
+
key: 'classListBind',
|
|
965
|
+
dynamicValue: page.classListBind,
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
return processedPage;
|
|
748
969
|
}
|
|
749
970
|
exports.serializePage = serializePage;
|
|
750
971
|
function deserializePage(ctx, page) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
972
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
973
|
+
let pageCtx = Object.assign(Object.assign({}, ctx), { page });
|
|
974
|
+
return {
|
|
975
|
+
id: page.id,
|
|
976
|
+
isHome: page.id === ctx.homePageId,
|
|
977
|
+
dataset: deserializeDataset(ctx, page.dataset),
|
|
978
|
+
vars: {
|
|
979
|
+
data:
|
|
980
|
+
((_a = page.dataVariables) === null || _a === void 0
|
|
981
|
+
? void 0
|
|
982
|
+
: _a.map((item) => {
|
|
983
|
+
return deserializeDataVariables(pageCtx, item);
|
|
760
984
|
})) || [],
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
985
|
+
},
|
|
986
|
+
data: deserializeAttributes(
|
|
987
|
+
pageCtx,
|
|
988
|
+
page.attributes,
|
|
989
|
+
(_b = page === null || page === void 0 ? void 0 : page.extra) === null || _b === void 0
|
|
990
|
+
? void 0
|
|
991
|
+
: _b.attributeExtraData,
|
|
992
|
+
),
|
|
993
|
+
componentInstances: deserializeComponent(pageCtx, page.items || []),
|
|
994
|
+
commonStyle:
|
|
995
|
+
(_c = page === null || page === void 0 ? void 0 : page.extra) === null || _c === void 0 ? void 0 : _c.commonStyle,
|
|
996
|
+
staticResourceAttribute:
|
|
997
|
+
(_d = page === null || page === void 0 ? void 0 : page.extra) === null || _d === void 0
|
|
998
|
+
? void 0
|
|
999
|
+
: _d.staticResourceAttribute,
|
|
1000
|
+
hideAdminPortalMenu:
|
|
1001
|
+
(_e = page === null || page === void 0 ? void 0 : page.extra) === null || _e === void 0
|
|
1002
|
+
? void 0
|
|
1003
|
+
: _e.hideAdminPortalMenu,
|
|
1004
|
+
lowCodes:
|
|
1005
|
+
(_f = page === null || page === void 0 ? void 0 : page.resources) === null || _f === void 0
|
|
1006
|
+
? void 0
|
|
1007
|
+
: _f
|
|
1008
|
+
.filter((item) => item.type === common_1.EResourceType.CODE)
|
|
1009
|
+
.map((item) => deserializeCodeResource(pageCtx, item)),
|
|
1010
|
+
listeners:
|
|
1011
|
+
((_g = page === null || page === void 0 ? void 0 : page.listeners) === null || _g === void 0
|
|
1012
|
+
? void 0
|
|
1013
|
+
: _g.map((item) => {
|
|
769
1014
|
return deserializeListener(pageCtx, item);
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1015
|
+
})) || [],
|
|
1016
|
+
// TODO
|
|
1017
|
+
// children: [],
|
|
1018
|
+
// styleBindPath: item.styleBindPath,
|
|
1019
|
+
};
|
|
775
1020
|
}
|
|
776
1021
|
exports.deserializePage = deserializePage;
|
|
777
1022
|
/**
|
|
@@ -780,34 +1025,96 @@ exports.deserializePage = deserializePage;
|
|
|
780
1025
|
* @param data
|
|
781
1026
|
*/
|
|
782
1027
|
function serializePlatformApp(data, optsions) {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
1028
|
+
var _a;
|
|
1029
|
+
let {
|
|
1030
|
+
version,
|
|
1031
|
+
author,
|
|
1032
|
+
name,
|
|
1033
|
+
label,
|
|
1034
|
+
description,
|
|
1035
|
+
selectedPageId,
|
|
1036
|
+
pageInstanceList,
|
|
1037
|
+
lowCodes = [],
|
|
1038
|
+
datasources,
|
|
1039
|
+
vars,
|
|
1040
|
+
dataset,
|
|
1041
|
+
extra,
|
|
1042
|
+
dependencies: calsDependencies,
|
|
1043
|
+
miniprogramPlugins,
|
|
1044
|
+
lastDependencies,
|
|
1045
|
+
externalResources,
|
|
1046
|
+
schemaVersion,
|
|
1047
|
+
} = data,
|
|
1048
|
+
restData = __rest(data, [
|
|
1049
|
+
'version',
|
|
1050
|
+
'author',
|
|
1051
|
+
'name',
|
|
1052
|
+
'label',
|
|
1053
|
+
'description',
|
|
1054
|
+
'selectedPageId',
|
|
1055
|
+
'pageInstanceList',
|
|
1056
|
+
'lowCodes',
|
|
1057
|
+
'datasources',
|
|
1058
|
+
'vars',
|
|
1059
|
+
'dataset',
|
|
1060
|
+
'extra',
|
|
1061
|
+
'dependencies',
|
|
1062
|
+
'miniprogramPlugins',
|
|
1063
|
+
'lastDependencies',
|
|
1064
|
+
'externalResources',
|
|
1065
|
+
'schemaVersion',
|
|
1066
|
+
]);
|
|
1067
|
+
let { dependencies = [] } = optsions || {};
|
|
1068
|
+
const _b = extra || {},
|
|
1069
|
+
{ name: extraName, label: extraLabel, author: extraAuthor, description: extraDescription } = _b,
|
|
1070
|
+
restExtra = __rest(_b, ['name', 'label', 'author', 'description']);
|
|
1071
|
+
const ctx = {
|
|
1072
|
+
app: data,
|
|
1073
|
+
dependencies,
|
|
1074
|
+
dependenciesMap: processDependenciesMap(dependencies),
|
|
1075
|
+
};
|
|
1076
|
+
const homePage =
|
|
1077
|
+
pageInstanceList === null || pageInstanceList === void 0 ? void 0 : pageInstanceList.find((page) => page.isHome);
|
|
1078
|
+
let processed = {
|
|
1079
|
+
label: label || extraLabel,
|
|
1080
|
+
name: name || extraName,
|
|
1081
|
+
author: author || extraAuthor,
|
|
1082
|
+
version,
|
|
1083
|
+
schemaVersion,
|
|
1084
|
+
description: description || extraDescription,
|
|
1085
|
+
externalResources,
|
|
1086
|
+
main: homePage
|
|
1087
|
+
? homePage.id
|
|
1088
|
+
: ((_a = pageInstanceList === null || pageInstanceList === void 0 ? void 0 : pageInstanceList[0]) === null ||
|
|
1089
|
+
_a === void 0
|
|
1090
|
+
? void 0
|
|
1091
|
+
: _a.id) || selectedPageId,
|
|
1092
|
+
items:
|
|
1093
|
+
pageInstanceList === null || pageInstanceList === void 0
|
|
1094
|
+
? void 0
|
|
1095
|
+
: pageInstanceList.map((page) => serializePage(ctx, page)),
|
|
1096
|
+
resources:
|
|
1097
|
+
lowCodes === null || lowCodes === void 0 ? void 0 : lowCodes.map((item) => serializeCodeSource(ctx, item)),
|
|
1098
|
+
dataSources: datasources,
|
|
1099
|
+
dataset: serializeDataset(ctx, dataset),
|
|
1100
|
+
dataVariables: (0, runtime_1.getValidValue)(
|
|
1101
|
+
vars === null || vars === void 0 ? void 0 : vars.data.map((item) => serializeDataVariables(ctx, item)),
|
|
1102
|
+
),
|
|
1103
|
+
dependencies: calsDependencies,
|
|
1104
|
+
extra: Object.assign(Object.assign(Object.assign({}, restExtra), restData), {
|
|
1105
|
+
miniprogramPlugins,
|
|
1106
|
+
historyType: data.historyType,
|
|
1107
|
+
npmDependencies: data.npmDependencies || {},
|
|
1108
|
+
plugins: data.plugins,
|
|
1109
|
+
maxID: data.maxID,
|
|
1110
|
+
rootPath: data.rootPath,
|
|
1111
|
+
themeVars: data.themeVars,
|
|
1112
|
+
presetColors: data.presetColors,
|
|
1113
|
+
appConfig: data.appConfig,
|
|
1114
|
+
lastDependencies,
|
|
1115
|
+
}),
|
|
1116
|
+
};
|
|
1117
|
+
return processed;
|
|
811
1118
|
}
|
|
812
1119
|
exports.serializePlatformApp = serializePlatformApp;
|
|
813
1120
|
/**
|
|
@@ -816,54 +1123,89 @@ exports.serializePlatformApp = serializePlatformApp;
|
|
|
816
1123
|
* @param data
|
|
817
1124
|
*/
|
|
818
1125
|
function deserializePlatformApp(data, optsions) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
1126
|
+
var _a, _b;
|
|
1127
|
+
let homePageId = data.main || ((_a = data.items[0]) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
1128
|
+
let extra = data.extra || {};
|
|
1129
|
+
const {
|
|
1130
|
+
historyType,
|
|
1131
|
+
npmDependencies,
|
|
1132
|
+
plugins,
|
|
1133
|
+
maxID,
|
|
1134
|
+
rootPath,
|
|
1135
|
+
themeVars,
|
|
1136
|
+
presetColors,
|
|
1137
|
+
appConfig,
|
|
1138
|
+
miniprogramPlugins,
|
|
1139
|
+
compHiddenConfig,
|
|
1140
|
+
lastDependencies,
|
|
1141
|
+
} = extra,
|
|
1142
|
+
restExtra = __rest(extra, [
|
|
1143
|
+
'historyType',
|
|
1144
|
+
'npmDependencies',
|
|
1145
|
+
'plugins',
|
|
1146
|
+
'maxID',
|
|
1147
|
+
'rootPath',
|
|
1148
|
+
'themeVars',
|
|
1149
|
+
'presetColors',
|
|
1150
|
+
'appConfig',
|
|
1151
|
+
'miniprogramPlugins',
|
|
1152
|
+
'compHiddenConfig',
|
|
1153
|
+
'lastDependencies',
|
|
1154
|
+
]);
|
|
1155
|
+
const ctx = {
|
|
1156
|
+
app: data,
|
|
1157
|
+
dependencies: (optsions === null || optsions === void 0 ? void 0 : optsions.dependencies) || [],
|
|
1158
|
+
homePageId,
|
|
1159
|
+
dependenciesMap: processDependenciesMap(
|
|
1160
|
+
(optsions === null || optsions === void 0 ? void 0 : optsions.dependencies) || [],
|
|
1161
|
+
),
|
|
1162
|
+
};
|
|
1163
|
+
let processed = {
|
|
1164
|
+
id: data.id,
|
|
1165
|
+
version: data.version,
|
|
1166
|
+
author: data.author,
|
|
1167
|
+
name: data.name,
|
|
1168
|
+
label: data.label,
|
|
1169
|
+
description: data.description,
|
|
1170
|
+
selectedPageId: homePageId,
|
|
1171
|
+
historyType,
|
|
1172
|
+
pageInstanceList: (data.items || []).map((page) => deserializePage(ctx, page)),
|
|
1173
|
+
// lowCodes: data.resources || [],
|
|
1174
|
+
lowCodes: (data.resources || [])
|
|
1175
|
+
.filter((item) => item.type === common_1.EResourceType.CODE)
|
|
1176
|
+
.map((item) => deserializeCodeResource(ctx, item)),
|
|
1177
|
+
datasources: data.dataSources,
|
|
1178
|
+
dataset: deserializeDataset(ctx, data.dataset),
|
|
1179
|
+
vars: {
|
|
1180
|
+
data:
|
|
1181
|
+
((_b = data.dataVariables) === null || _b === void 0
|
|
1182
|
+
? void 0
|
|
1183
|
+
: _b.map((item) => {
|
|
1184
|
+
return deserializeDataVariables(ctx, item);
|
|
848
1185
|
})) || [],
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
|
|
1186
|
+
},
|
|
1187
|
+
compHiddenConfig: compHiddenConfig || {},
|
|
1188
|
+
npmDependencies: npmDependencies || {},
|
|
1189
|
+
plugins: plugins || [],
|
|
1190
|
+
maxID,
|
|
1191
|
+
rootPath,
|
|
1192
|
+
themeVars,
|
|
1193
|
+
presetColors: presetColors || [],
|
|
1194
|
+
appConfig,
|
|
1195
|
+
miniprogramPlugins,
|
|
1196
|
+
externalResources: data.externalResources,
|
|
1197
|
+
extra: Object.assign(Object.assign({}, restExtra), {
|
|
1198
|
+
name: data.name,
|
|
1199
|
+
author: data.author,
|
|
1200
|
+
description: data.description,
|
|
1201
|
+
lastDependencies,
|
|
1202
|
+
}),
|
|
1203
|
+
dependencies: data.dependencies,
|
|
1204
|
+
// TODO
|
|
1205
|
+
// emitEvents: [], { "name": "自定义校验规则", "eventName": "validator" }
|
|
1206
|
+
schemaVersion: data.schemaVersion,
|
|
1207
|
+
};
|
|
1208
|
+
return processed;
|
|
867
1209
|
}
|
|
868
1210
|
exports.deserializePlatformApp = deserializePlatformApp;
|
|
869
1211
|
/**
|
|
@@ -871,45 +1213,75 @@ exports.deserializePlatformApp = deserializePlatformApp;
|
|
|
871
1213
|
* [formily] to [CALS]
|
|
872
1214
|
*/
|
|
873
1215
|
function serializeRuntimePage(ctx, page) {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1216
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1217
|
+
const pageCtx = Object.assign(Object.assign({}, ctx), {
|
|
1218
|
+
dependenciesMap: processDependenciesMap(ctx.dependencies || []),
|
|
1219
|
+
page: { id: page.id },
|
|
1220
|
+
});
|
|
1221
|
+
let processedPage = {
|
|
1222
|
+
id: page.id,
|
|
1223
|
+
type: 'PAGE',
|
|
1224
|
+
component: 'Page',
|
|
1225
|
+
attributes:
|
|
1226
|
+
(_a = serializeAttributesWithExtra(pageCtx, 'page', (0, runtime_1.readDynamicData)(page))) === null ||
|
|
1227
|
+
_a === void 0
|
|
1228
|
+
? void 0
|
|
1229
|
+
: _a.data,
|
|
1230
|
+
items: (0, runtime_1.getValidValue)(
|
|
1231
|
+
Object.keys(((_b = page.componentSchemaJson) === null || _b === void 0 ? void 0 : _b.properties) || {}).map(
|
|
1232
|
+
(id) => {
|
|
1233
|
+
var _a;
|
|
1234
|
+
return serializeRuntimeComponent(
|
|
1235
|
+
pageCtx,
|
|
1236
|
+
Object.assign(
|
|
1237
|
+
{ id },
|
|
1238
|
+
(_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties[id],
|
|
1239
|
+
),
|
|
1240
|
+
);
|
|
896
1241
|
},
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
page
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1242
|
+
),
|
|
1243
|
+
),
|
|
1244
|
+
resources:
|
|
1245
|
+
(_c = page === null || page === void 0 ? void 0 : page.codeModules) === null || _c === void 0
|
|
1246
|
+
? void 0
|
|
1247
|
+
: _c.map((item) => serializeCodeSource(pageCtx, item)),
|
|
1248
|
+
dataset: page === null || page === void 0 ? void 0 : page.dataset,
|
|
1249
|
+
dataVariables: (0, runtime_1.getValidValue)(
|
|
1250
|
+
(_e =
|
|
1251
|
+
(_d = page === null || page === void 0 ? void 0 : page.vars) === null || _d === void 0 ? void 0 : _d.data) ===
|
|
1252
|
+
null || _e === void 0
|
|
1253
|
+
? void 0
|
|
1254
|
+
: _e.map((item) => serializeDataVariables(pageCtx, item)),
|
|
1255
|
+
),
|
|
1256
|
+
listeners: (0, runtime_1.getValidValue)(
|
|
1257
|
+
(0, runtime_1.readListeners)(page.listenerInstances || []).map((item) => {
|
|
1258
|
+
return serializeListener(pageCtx, item);
|
|
1259
|
+
}),
|
|
1260
|
+
),
|
|
1261
|
+
extra: {
|
|
1262
|
+
commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(page.style)),
|
|
1263
|
+
styleBindPath: (0, runtime_1.getValidValue)(page.styleBindPath),
|
|
1264
|
+
xIndex: page.xIndex,
|
|
1265
|
+
children: (0, runtime_1.getValidValue)(
|
|
1266
|
+
(_f = page.children) === null || _f === void 0 ? void 0 : _f.map((child) => serializeRuntimePage(ctx, child)),
|
|
1267
|
+
),
|
|
1268
|
+
},
|
|
1269
|
+
};
|
|
1270
|
+
if ((0, common_2.isValidStyleBind)(page.styleBind) && (0, runtime_1.getValidValue)(page.styleBind)) {
|
|
1271
|
+
page[':style'] = serializeValue({
|
|
1272
|
+
ctx: pageCtx,
|
|
1273
|
+
key: 'styleBind',
|
|
1274
|
+
dynamicValue: page.styleBind,
|
|
1275
|
+
}).value;
|
|
1276
|
+
}
|
|
1277
|
+
if ((0, common_2.isValidClassNameListBind)(page.classListBind) && (0, runtime_1.getValidValue)(page.classListBind)) {
|
|
1278
|
+
page[':class'] = serializeValue({
|
|
1279
|
+
ctx: pageCtx,
|
|
1280
|
+
key: 'classListBind',
|
|
1281
|
+
dynamicValue: page.classListBind,
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
return processedPage;
|
|
913
1285
|
}
|
|
914
1286
|
exports.serializeRuntimePage = serializeRuntimePage;
|
|
915
1287
|
// /**
|
|
@@ -925,78 +1297,112 @@ exports.serializeRuntimePage = serializeRuntimePage;
|
|
|
925
1297
|
* [formily] to [CALS]
|
|
926
1298
|
*/
|
|
927
1299
|
function serializeRuntimeComponent(ctx, component) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1300
|
+
var _a, _b, _c;
|
|
1301
|
+
if (!component.id) {
|
|
1302
|
+
component.id = component.key;
|
|
1303
|
+
}
|
|
1304
|
+
let processed = {
|
|
1305
|
+
id: component.id,
|
|
1306
|
+
type: undefined,
|
|
1307
|
+
component: '',
|
|
1308
|
+
label: (0, runtime_1.getValidValue)(component.label),
|
|
1309
|
+
};
|
|
1310
|
+
let props = component['x-props'];
|
|
1311
|
+
const { dependencies = [] } = ctx;
|
|
1312
|
+
if (props) {
|
|
1313
|
+
const [moduleName, name = ''] = props.sourceKey.split(':');
|
|
1314
|
+
const componentCtx = Object.assign(Object.assign({}, ctx), {
|
|
1315
|
+
component: { id: component.id, module: moduleName, component: name },
|
|
1316
|
+
});
|
|
1317
|
+
if (componentCtx.dependencies && !componentCtx.dependenciesMap) {
|
|
1318
|
+
componentCtx.dependenciesMap = processDependenciesMap(componentCtx.dependencies || []);
|
|
931
1319
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
},
|
|
962
|
-
});
|
|
963
|
-
if (styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.extra) {
|
|
964
|
-
attributeExtraData.style = styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.extra;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
if ((0, common_2.isValidClassNameListBind)(props.classNameListBind)) {
|
|
968
|
-
classListBindData = serializeValue({
|
|
969
|
-
ctx: componentCtx,
|
|
970
|
-
key: 'classListBind',
|
|
971
|
-
dynamicValue: (0, runtime_1.getValidValue)({
|
|
972
|
-
type: props.classNameListBind.type,
|
|
973
|
-
value: props.classNameListBind.bindDataPath,
|
|
974
|
-
}),
|
|
975
|
-
});
|
|
976
|
-
if (classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.extra) {
|
|
977
|
-
attributeExtraData.class = classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.extra;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
processed = Object.assign(Object.assign({}, processed), { module: serializeModuleName(componentCtx, moduleName, name), component: name, attributes: Object.assign(Object.assign({}, attributes), { style: (0, runtime_1.getValidValue)(props.style), class: (_b = (0, runtime_1.getValidValue)(props.classNameList)) === null || _b === void 0 ? void 0 : _b.join(' ') }), items: (0, runtime_1.getValidValue)(Object.keys(properties)
|
|
981
|
-
.filter((key) => !excludeKeys.includes(key))
|
|
982
|
-
.sort((a, b) => properties[a]['x-index'] - properties[b]['x-index'])
|
|
983
|
-
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, properties[key])))), listeners: (_c = (0, runtime_1.getValidValue)((0, runtime_1.readListeners)(props.listenerInstances))) === null || _c === void 0 ? void 0 : _c.map((listener /* IEventListener */) => {
|
|
984
|
-
return serializeListener(componentCtx, listener);
|
|
985
|
-
}), directives: serializeDirecties(componentCtx, ((0, runtime_1.getValidValue)((0, runtime_1.readDirectives)(props)) || {})) || undefined, ':class': (classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.value) || undefined, ':style': (styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.value) || undefined, extra: {
|
|
986
|
-
commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(props.commonStyle)),
|
|
987
|
-
xIndex: (0, runtime_1.getValidValue)(component['x-index']),
|
|
988
|
-
styleBindPath: (0, runtime_1.getValidValue)(props.styleBindPath),
|
|
989
|
-
staticResourceAttribute: (0, runtime_1.getValidValue)(props.staticResourceAttribute),
|
|
990
|
-
attributeExtraData: (0, common_2.isEmptyObj)(attributeExtraData) ? undefined : attributeExtraData,
|
|
991
|
-
} });
|
|
1320
|
+
const excludeKeys = (props.dataTypes || [])
|
|
1321
|
+
.filter((dataType) => dataType.type !== 'slot')
|
|
1322
|
+
.map((dataType) => dataType.propertyPath);
|
|
1323
|
+
let properties = component.properties || {};
|
|
1324
|
+
const { data: attributes = {}, extra: attributeExtraData = {} } =
|
|
1325
|
+
serializeAttributesWithExtra(
|
|
1326
|
+
componentCtx,
|
|
1327
|
+
'page',
|
|
1328
|
+
(0, runtime_1.getValidValue)((0, runtime_1.readDynamicData)(props)) || {},
|
|
1329
|
+
) || {};
|
|
1330
|
+
let styleBindData = null;
|
|
1331
|
+
let classListBindData = null;
|
|
1332
|
+
if (
|
|
1333
|
+
(_a = props === null || props === void 0 ? void 0 : props.styleBind) === null || _a === void 0
|
|
1334
|
+
? void 0
|
|
1335
|
+
: _a.bindDataPath
|
|
1336
|
+
) {
|
|
1337
|
+
styleBindData = serializeValue({
|
|
1338
|
+
ctx: componentCtx,
|
|
1339
|
+
key: 'styleBind',
|
|
1340
|
+
dynamicValue: {
|
|
1341
|
+
type: props.styleBind.type,
|
|
1342
|
+
value: props.styleBind.bindDataPath,
|
|
1343
|
+
extra: props.styleBind.extra,
|
|
1344
|
+
},
|
|
1345
|
+
});
|
|
1346
|
+
if (styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.extra) {
|
|
1347
|
+
attributeExtraData.style = styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.extra;
|
|
1348
|
+
}
|
|
992
1349
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1350
|
+
if ((0, common_2.isValidClassNameListBind)(props.classNameListBind)) {
|
|
1351
|
+
classListBindData = serializeValue({
|
|
1352
|
+
ctx: componentCtx,
|
|
1353
|
+
key: 'classListBind',
|
|
1354
|
+
dynamicValue: (0, runtime_1.getValidValue)({
|
|
1355
|
+
type: props.classNameListBind.type,
|
|
1356
|
+
value: props.classNameListBind.bindDataPath,
|
|
1357
|
+
}),
|
|
1358
|
+
});
|
|
1359
|
+
if (classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.extra) {
|
|
1360
|
+
attributeExtraData.class =
|
|
1361
|
+
classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.extra;
|
|
1362
|
+
}
|
|
998
1363
|
}
|
|
999
|
-
|
|
1364
|
+
processed = Object.assign(Object.assign({}, processed), {
|
|
1365
|
+
module: serializeModuleName(componentCtx, moduleName, name),
|
|
1366
|
+
component: name,
|
|
1367
|
+
attributes: Object.assign(Object.assign({}, attributes), {
|
|
1368
|
+
style: (0, runtime_1.getValidValue)(props.style),
|
|
1369
|
+
class:
|
|
1370
|
+
(_b = (0, runtime_1.getValidValue)(props.classNameList)) === null || _b === void 0 ? void 0 : _b.join(' '),
|
|
1371
|
+
}),
|
|
1372
|
+
items: (0, runtime_1.getValidValue)(
|
|
1373
|
+
Object.keys(properties)
|
|
1374
|
+
.filter((key) => !excludeKeys.includes(key))
|
|
1375
|
+
.sort((a, b) => properties[a]['x-index'] - properties[b]['x-index'])
|
|
1376
|
+
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, properties[key]))),
|
|
1377
|
+
),
|
|
1378
|
+
listeners:
|
|
1379
|
+
(_c = (0, runtime_1.getValidValue)((0, runtime_1.readListeners)(props.listenerInstances))) === null ||
|
|
1380
|
+
_c === void 0
|
|
1381
|
+
? void 0
|
|
1382
|
+
: _c.map((listener /* IEventListener */) => {
|
|
1383
|
+
return serializeListener(componentCtx, listener);
|
|
1384
|
+
}),
|
|
1385
|
+
directives:
|
|
1386
|
+
serializeDirecties(componentCtx, (0, runtime_1.getValidValue)((0, runtime_1.readDirectives)(props)) || {}) ||
|
|
1387
|
+
undefined,
|
|
1388
|
+
':class':
|
|
1389
|
+
(classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.value) || undefined,
|
|
1390
|
+
':style': (styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.value) || undefined,
|
|
1391
|
+
extra: {
|
|
1392
|
+
commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(props.commonStyle)),
|
|
1393
|
+
xIndex: (0, runtime_1.getValidValue)(component['x-index']),
|
|
1394
|
+
styleBindPath: (0, runtime_1.getValidValue)(props.styleBindPath),
|
|
1395
|
+
staticResourceAttribute: (0, runtime_1.getValidValue)(props.staticResourceAttribute),
|
|
1396
|
+
attributeExtraData: (0, common_2.isEmptyObj)(attributeExtraData) ? undefined : attributeExtraData,
|
|
1397
|
+
},
|
|
1398
|
+
});
|
|
1399
|
+
} else {
|
|
1400
|
+
let items = Object.keys(component.properties || {})
|
|
1401
|
+
.sort((a, b) => component.properties[a]['x-index'] - component.properties[b]['x-index'])
|
|
1402
|
+
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, component.properties[key])));
|
|
1403
|
+
processed = Object.assign(Object.assign({}, processed), { items: (0, runtime_1.getValidValue)(items) });
|
|
1404
|
+
}
|
|
1405
|
+
return processed;
|
|
1000
1406
|
}
|
|
1001
1407
|
exports.serializeRuntimeComponent = serializeRuntimeComponent;
|
|
1002
1408
|
/**
|
|
@@ -1005,93 +1411,126 @@ exports.serializeRuntimeComponent = serializeRuntimeComponent;
|
|
|
1005
1411
|
* To be continue, currently support listener
|
|
1006
1412
|
*/
|
|
1007
1413
|
function deserializeRuntimeComponent(ctx, component) {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1414
|
+
const { id, module, component: runtimeComponent, listeners = [] } = component;
|
|
1415
|
+
let listenerInstances = (0, runtime_1.getValidValue)(
|
|
1416
|
+
(0, runtime_1.writeListeners)(
|
|
1417
|
+
(listeners === null || listeners === void 0
|
|
1418
|
+
? void 0
|
|
1419
|
+
: listeners.map((item) => {
|
|
1420
|
+
return Object.assign({ sourceKey: `${module}:${runtimeComponent}` }, deserializeListener(ctx, item));
|
|
1421
|
+
})) || [],
|
|
1422
|
+
),
|
|
1423
|
+
);
|
|
1424
|
+
const target = {
|
|
1425
|
+
key: id,
|
|
1426
|
+
type: 'object',
|
|
1427
|
+
properties: {},
|
|
1428
|
+
'x-component': `${module}:${runtimeComponent}`,
|
|
1429
|
+
'x-props': {
|
|
1430
|
+
sourceKey: `${module}:${runtimeComponent}`,
|
|
1431
|
+
listenerInstances: listenerInstances || [],
|
|
1432
|
+
},
|
|
1433
|
+
};
|
|
1434
|
+
return target;
|
|
1023
1435
|
}
|
|
1024
1436
|
exports.deserializeRuntimeComponent = deserializeRuntimeComponent;
|
|
1025
1437
|
function processDependenciesMap(dependencies = []) {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
return map;
|
|
1032
|
-
}, {});
|
|
1438
|
+
let map = dependencies.reduce((map, componentLib) => {
|
|
1439
|
+
let { components = [] } = componentLib;
|
|
1440
|
+
for (let item of components) {
|
|
1441
|
+
map[item.sourceKey] = item;
|
|
1442
|
+
}
|
|
1033
1443
|
return map;
|
|
1444
|
+
}, {});
|
|
1445
|
+
return map;
|
|
1034
1446
|
}
|
|
1035
1447
|
function deserializeComponentLibraryMeta(meta) {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1448
|
+
let { components = {}, actions = {}, styles = [], dependencies = {} } = meta,
|
|
1449
|
+
restLibraryMeta = __rest(meta, ['components', 'actions', 'styles', 'dependencies']);
|
|
1450
|
+
let processedComponents = {};
|
|
1451
|
+
for (const componentName in components) {
|
|
1452
|
+
let component = components[componentName];
|
|
1453
|
+
let _a = component.meta || {},
|
|
1454
|
+
{ title, description, category, icon, extra = {} } = _a,
|
|
1455
|
+
restComponentMeta = __rest(_a, ['title', 'description', 'category', 'icon', 'extra']);
|
|
1456
|
+
processedComponents[componentName] = Object.assign(
|
|
1457
|
+
Object.assign(
|
|
1458
|
+
{
|
|
1459
|
+
title: title || component.name || componentName,
|
|
1460
|
+
desc: description || '',
|
|
1461
|
+
category: category || '',
|
|
1462
|
+
thumbnail: icon,
|
|
1463
|
+
},
|
|
1464
|
+
extra,
|
|
1465
|
+
),
|
|
1466
|
+
restComponentMeta,
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
return Object.assign(Object.assign({}, restLibraryMeta), {
|
|
1470
|
+
styles,
|
|
1471
|
+
dependencies,
|
|
1472
|
+
components: processedComponents,
|
|
1473
|
+
actions,
|
|
1474
|
+
});
|
|
1045
1475
|
}
|
|
1046
1476
|
exports.deserializeComponentLibraryMeta = deserializeComponentLibraryMeta;
|
|
1047
1477
|
function processRuntimeCodeResources(ctx, resources /* : IWeappCode[]*/ = [], scope) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1478
|
+
const { id } = ctx;
|
|
1479
|
+
const fileTypes = [
|
|
1480
|
+
common_1.ECodeType.STYLE,
|
|
1481
|
+
common_1.ECodeType.STATE,
|
|
1482
|
+
common_1.ECodeType.LIFECYCLE,
|
|
1483
|
+
common_1.ECodeType.COMPUTEDN,
|
|
1484
|
+
];
|
|
1485
|
+
const CODE_TYPE_NAME_MAP = {
|
|
1486
|
+
[common_1.ECodeType.STATE]: common_1.ECodeName.STATE,
|
|
1487
|
+
[common_1.ECodeType.COMPUTEDN]: common_1.ECodeName.COMPUTEDN,
|
|
1488
|
+
[common_1.ECodeType.STYLE]: common_1.ECodeName.STYLE,
|
|
1489
|
+
[common_1.ECodeType.LIFECYCLE]: common_1.ECodeName.LIFECYCLE,
|
|
1490
|
+
};
|
|
1491
|
+
const isComponent = id === '$comp' || scope === 'component';
|
|
1492
|
+
if (id === 'global' || scope === 'app') {
|
|
1493
|
+
fileTypes.push(common_1.ECodeType.THEME);
|
|
1494
|
+
}
|
|
1495
|
+
const EXIST_FILE_TYPE_MAP = {};
|
|
1496
|
+
resources.forEach((mod) => {
|
|
1497
|
+
EXIST_FILE_TYPE_MAP[mod.type] = true;
|
|
1498
|
+
});
|
|
1499
|
+
fileTypes.forEach((type) => {
|
|
1500
|
+
const isHasLowcodeIndex = EXIST_FILE_TYPE_MAP[type];
|
|
1501
|
+
if (!isHasLowcodeIndex) {
|
|
1502
|
+
const name = CODE_TYPE_NAME_MAP[type] || type;
|
|
1503
|
+
resources.unshift({
|
|
1504
|
+
name,
|
|
1505
|
+
type,
|
|
1506
|
+
code: (0, template_1.generateDefaultCode)(
|
|
1507
|
+
ctx,
|
|
1508
|
+
type,
|
|
1509
|
+
isComponent ? 'component' : id === 'global' ? 'app' : 'page',
|
|
1510
|
+
),
|
|
1511
|
+
path: `${id}/${name}`,
|
|
1512
|
+
system: true,
|
|
1513
|
+
});
|
|
1059
1514
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
EXIST_FILE_TYPE_MAP[mod.type] = true;
|
|
1063
|
-
});
|
|
1064
|
-
fileTypes.forEach((type) => {
|
|
1065
|
-
const isHasLowcodeIndex = EXIST_FILE_TYPE_MAP[type];
|
|
1066
|
-
if (!isHasLowcodeIndex) {
|
|
1067
|
-
const name = CODE_TYPE_NAME_MAP[type] || type;
|
|
1068
|
-
resources.unshift({
|
|
1069
|
-
name,
|
|
1070
|
-
type,
|
|
1071
|
-
code: (0, template_1.generateDefaultCode)(ctx, type, isComponent ? 'component' : id === 'global' ? 'app' : 'page'),
|
|
1072
|
-
path: `${id}/${name}`,
|
|
1073
|
-
system: true,
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
return resources.filter((m) => m.name !== common_1.ECodeName.PLACEHOLDER);
|
|
1515
|
+
});
|
|
1516
|
+
return resources.filter((m) => m.name !== common_1.ECodeName.PLACEHOLDER);
|
|
1078
1517
|
}
|
|
1079
1518
|
exports.processRuntimeCodeResources = processRuntimeCodeResources;
|
|
1080
1519
|
/**
|
|
1081
1520
|
* 解析 cals version 来生成 feature map
|
|
1082
1521
|
*/
|
|
1083
1522
|
function parseVersion(version = '') {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1523
|
+
const list = version.split('.');
|
|
1524
|
+
const FEATURE_MAP = {
|
|
1525
|
+
/**
|
|
1526
|
+
* 默认单位为 px,
|
|
1527
|
+
* 然后进行动态转换 为 rem及rpx
|
|
1528
|
+
*/
|
|
1529
|
+
defaultDynamicCssUnit: true,
|
|
1530
|
+
};
|
|
1531
|
+
if (list[0] === '4' || version === 'latest') {
|
|
1532
|
+
FEATURE_MAP.defaultDynamicCssUnit = false;
|
|
1533
|
+
}
|
|
1534
|
+
return FEATURE_MAP;
|
|
1096
1535
|
}
|
|
1097
1536
|
exports.parseVersion = parseVersion;
|