@cloudbase/cals 0.3.6 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser/cals/index.d.ts +57 -2
- package/lib/parser/cals/index.d.ts.map +1 -1
- package/lib/parser/cals/index.js +68 -52
- package/lib/parser/cals/utils/block/index.d.ts +15 -0
- package/lib/parser/cals/utils/block/index.d.ts.map +1 -0
- package/lib/parser/cals/utils/block/index.js +148 -0
- package/lib/parser/cals/utils/runtime.js +3 -3
- package/lib/parser/cals/utils/style.js +3 -3
- package/lib/parser/cals/utils/version/common.js +14 -14
- package/lib/parser/cals/utils/version/index.js +6 -6
- package/lib/parser/cals/utils/version/parses.js +24 -24
- package/lib/parser/cals/utils/version/utils.js +1 -1
- package/lib/parser/expression/index.d.ts +3 -1
- package/lib/parser/expression/index.d.ts.map +1 -1
- package/lib/parser/expression/index.js +14 -5
- package/lib/parser/index.d.ts +3 -2
- package/lib/parser/index.d.ts.map +1 -1
- package/lib/parser/index.js +17 -12
- package/lib/tsconfig.tsbuildinfo +1 -1636
- package/lib/types/platform/common.d.ts +40 -0
- package/lib/types/platform/common.d.ts.map +1 -1
- package/lib/types/platform/common.js +42 -1
- package/lib/types/platform/datasource.d.ts +1 -1
- package/lib/types/platform/datasource.d.ts.map +1 -1
- package/lib/utils/build.js +7 -7
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IPlatformApp, IComplexComponent, IBasicComponent, IPageComponent, IDataSourceVariable, IDataVarMethod, // 勿删,为了生成d.ts
|
|
1
|
+
import { IAttributes, IPlatformApp, IComplexComponent, IBasicComponent, IPageComponent, IDataSourceVariable, IDataVarMethod, // 勿删,为了生成d.ts
|
|
2
2
|
IPlatformDataSource, LCDS } from '../../types';
|
|
3
|
-
import { IDynamicValue } from '../expression';
|
|
3
|
+
import { IDynamicValue, PropBindType } from '../expression';
|
|
4
4
|
interface IDeserializeContext {
|
|
5
5
|
app?: IPlatformApp;
|
|
6
6
|
dependencies?: any[];
|
|
@@ -26,6 +26,61 @@ interface ISerializeContext {
|
|
|
26
26
|
streamlineDefaultValue?: boolean;
|
|
27
27
|
streamlineModuleName?: boolean;
|
|
28
28
|
}
|
|
29
|
+
export declare function serializeValue({ ctx, key, dynamicValue, scope, streamlineDefaultValue, }: {
|
|
30
|
+
ctx: ISerializeContext;
|
|
31
|
+
key: string;
|
|
32
|
+
dynamicValue: {
|
|
33
|
+
type?: PropBindType | 'static';
|
|
34
|
+
value: any;
|
|
35
|
+
};
|
|
36
|
+
scope?: 'page' | 'component';
|
|
37
|
+
streamlineDefaultValue?: boolean;
|
|
38
|
+
}): {
|
|
39
|
+
key: string;
|
|
40
|
+
value: any;
|
|
41
|
+
};
|
|
42
|
+
export declare function deserializeValue(ctx: IDeserializeContext, key: string, value: any): {
|
|
43
|
+
key: string;
|
|
44
|
+
value: {
|
|
45
|
+
type: PropBindType;
|
|
46
|
+
value: any;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
key: string;
|
|
50
|
+
value: {
|
|
51
|
+
type: undefined;
|
|
52
|
+
value: any;
|
|
53
|
+
} | undefined;
|
|
54
|
+
};
|
|
55
|
+
export declare function serializeDynamicMap({ ctx, map, scope, streamlineDefaultValue, }: {
|
|
56
|
+
ctx: ISerializeContext;
|
|
57
|
+
map: {
|
|
58
|
+
[key: string]: string | any;
|
|
59
|
+
};
|
|
60
|
+
scope?: 'page' | 'component';
|
|
61
|
+
streamlineDefaultValue?: boolean;
|
|
62
|
+
}): {
|
|
63
|
+
[key: string]: string;
|
|
64
|
+
};
|
|
65
|
+
export declare function deserializeDynamicMap(ctx: IDeserializeContext, map: {
|
|
66
|
+
[key: string]: string | any;
|
|
67
|
+
}): {
|
|
68
|
+
[key: string]: {
|
|
69
|
+
type?: string | undefined;
|
|
70
|
+
value: any;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare function serializeAttributes(ctx: ISerializeContext, scope: 'page' | 'component', attributes?: {
|
|
74
|
+
[key: string]: IDynamicValue;
|
|
75
|
+
}): {
|
|
76
|
+
[key: string]: string;
|
|
77
|
+
};
|
|
78
|
+
export declare function deserializeAttributes(ctx: IDeserializeContext, attributes?: IAttributes): {
|
|
79
|
+
[key: string]: {
|
|
80
|
+
type?: string | undefined;
|
|
81
|
+
value: any;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
29
84
|
export declare function deserializeDataVariables(ctx: IDeserializeContext, data: IDataSourceVariable): {
|
|
30
85
|
title: string | undefined;
|
|
31
86
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../parser/cals/index.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../parser/cals/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EACX,YAAY,EAEZ,iBAAiB,EACjB,eAAe,EACf,cAAc,EAGd,mBAAmB,EACnB,cAAc,EAAE,cAAc;AAC9B,mBAAmB,EACnB,IAAI,EACL,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGL,aAAa,EACb,YAAY,EACb,MAAM,eAAe,CAAA;AAgBtB,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,YAAY,CAAA;IAClB,YAAY,CAAC,EAAE,GAAG,EAAE,CAAA;IACpB,eAAe,CAAC,EAAE,GAAG,CAAA;IACrB,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB;AAED,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACrB,SAAS,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/D;;;OAGG;IACH,YAAY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AAE,GAAG,GACR,cAAc,CAiEhB;AAWD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,iBAAiB,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;CAC1C,EACD,SAAS,EAAE,GAAG,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAC9B,eAAe,GAAG,iBAAiB,CA0GrC;AAsBD,wBAAgB,+BAA+B,CAAC,IAAI,EAAE;IACpD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACxC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAAA;KAAE,CAAA;IAC9C,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,OAAO,CAAA;KAAE,CAAA;CACzC;;;;;;;mBAUY,MAAM;;sBAEH,MAAM;;;6BACwB,OAAO;;;;;;EA+BpD"}
|
package/lib/parser/cals/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.deserializeComponentLibraryMeta = exports.serializeRuntimeComponent = exports.serializeRuntimePage = exports.deserializePlatformApp = exports.serializePlatformApp = exports.deserializePage = exports.serializePage = exports.deserializeComponent = exports.serializeComponent = exports.deserializeDataVariables = void 0;
|
|
14
|
+
exports.deserializeComponentLibraryMeta = exports.serializeRuntimeComponent = exports.serializeRuntimePage = exports.deserializePlatformApp = exports.serializePlatformApp = exports.deserializePage = exports.serializePage = exports.deserializeComponent = exports.serializeComponent = exports.deserializeDataVariables = exports.deserializeAttributes = exports.serializeAttributes = exports.deserializeDynamicMap = exports.serializeDynamicMap = exports.deserializeValue = exports.serializeValue = void 0;
|
|
15
15
|
const lodash_1 = require("lodash");
|
|
16
16
|
const common_1 = require("../../types/platform/common");
|
|
17
17
|
const types_1 = require("../../types");
|
|
@@ -85,6 +85,7 @@ function serializeValue({ ctx, key, dynamicValue, scope = 'page', streamlineDefa
|
|
|
85
85
|
}
|
|
86
86
|
return { key, value };
|
|
87
87
|
}
|
|
88
|
+
exports.serializeValue = serializeValue;
|
|
88
89
|
function deserializeValue(ctx, key, value) {
|
|
89
90
|
var _a;
|
|
90
91
|
let matched = key.match(/^:(.*)$/);
|
|
@@ -130,6 +131,7 @@ function deserializeValue(ctx, key, value) {
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
}
|
|
134
|
+
exports.deserializeValue = deserializeValue;
|
|
133
135
|
function serializeDynamicMap({ ctx, map = {}, scope = 'page', streamlineDefaultValue, }) {
|
|
134
136
|
let data = {};
|
|
135
137
|
Object.keys(map)
|
|
@@ -156,14 +158,15 @@ function serializeDynamicMap({ ctx, map = {}, scope = 'page', streamlineDefaultV
|
|
|
156
158
|
let matched = processedKey.match(/^:(.*)$/);
|
|
157
159
|
if (matched) {
|
|
158
160
|
const originValue = matched[1];
|
|
159
|
-
lodash_1.unset(data, originValue);
|
|
161
|
+
(0, lodash_1.unset)(data, originValue);
|
|
160
162
|
}
|
|
161
|
-
if (lodash_1.get(data, processedKey) == undefined) {
|
|
163
|
+
if ((0, lodash_1.get)(data, processedKey) == undefined) {
|
|
162
164
|
data[processedKey] = processedValue;
|
|
163
165
|
}
|
|
164
166
|
});
|
|
165
167
|
return data;
|
|
166
168
|
}
|
|
169
|
+
exports.serializeDynamicMap = serializeDynamicMap;
|
|
167
170
|
function deserializeDynamicMap(ctx, map) {
|
|
168
171
|
var _a;
|
|
169
172
|
let data = {};
|
|
@@ -174,6 +177,7 @@ function deserializeDynamicMap(ctx, map) {
|
|
|
174
177
|
}
|
|
175
178
|
return data;
|
|
176
179
|
}
|
|
180
|
+
exports.deserializeDynamicMap = deserializeDynamicMap;
|
|
177
181
|
function serializeAttributes(ctx, scope, attributes = {}) {
|
|
178
182
|
return serializeDynamicMap({
|
|
179
183
|
ctx,
|
|
@@ -182,6 +186,7 @@ function serializeAttributes(ctx, scope, attributes = {}) {
|
|
|
182
186
|
streamlineDefaultValue: ctx.streamlineDefaultValue,
|
|
183
187
|
});
|
|
184
188
|
}
|
|
189
|
+
exports.serializeAttributes = serializeAttributes;
|
|
185
190
|
function deserializeAttributes(ctx, attributes = {}) {
|
|
186
191
|
const reservedAttributes = ['style', 'commonStyle', 'class'];
|
|
187
192
|
const reservedAttributesMap = reservedAttributes.reduce((map, key) => {
|
|
@@ -200,6 +205,7 @@ function deserializeAttributes(ctx, attributes = {}) {
|
|
|
200
205
|
}
|
|
201
206
|
return deserializeDynamicMap(ctx, restAttributes);
|
|
202
207
|
}
|
|
208
|
+
exports.deserializeAttributes = deserializeAttributes;
|
|
203
209
|
/**
|
|
204
210
|
* 将dataset({state: {}, params: {}})从 weapp 结构转换为cals结构
|
|
205
211
|
* 目前仅转换 state 中的 initMethod.params 和 updateMethod.params
|
|
@@ -297,7 +303,8 @@ function deserializeDirecties(ctx, directives) {
|
|
|
297
303
|
let waIf = (directives === null || directives === void 0 ? void 0 : directives[':if']) != undefined
|
|
298
304
|
? deserializeValue(ctx, ':if', directives[':if']).value
|
|
299
305
|
: { value: true };
|
|
300
|
-
let waFor = (directives === null || directives === void 0 ? void 0 : directives[':for'])
|
|
306
|
+
let waFor = (directives === null || directives === void 0 ? void 0 : directives[':for'])
|
|
307
|
+
? deserializeValue(ctx, ':for', directives[':for']).value
|
|
301
308
|
: undefined;
|
|
302
309
|
if (waFor) {
|
|
303
310
|
let { type, value } = waFor;
|
|
@@ -451,7 +458,7 @@ function serializeComponent(ctx, component, scope = 'page') {
|
|
|
451
458
|
type: undefined,
|
|
452
459
|
module: serializeModuleName(componentCtx, moduleName, componentName),
|
|
453
460
|
component: componentName,
|
|
454
|
-
attributes: runtime_1.getValidValue(component.xProps
|
|
461
|
+
attributes: (0, runtime_1.getValidValue)(component.xProps
|
|
455
462
|
? Object.assign(Object.assign({}, serializeAttributes(componentCtx, scope, (component.xProps.data || {}))), { style: (_d = component.xProps) === null || _d === void 0 ? void 0 : _d.style, class: (_f = (_e = component.xProps) === null || _e === void 0 ? void 0 : _e.classList) === null || _f === void 0 ? void 0 : _f.join(' ') }) : undefined),
|
|
456
463
|
items: component.properties
|
|
457
464
|
? Object.keys(component.properties).map((key) => {
|
|
@@ -459,30 +466,32 @@ function serializeComponent(ctx, component, scope = 'page') {
|
|
|
459
466
|
return serializeComponent(componentCtx, Object.assign({ id: key }, (_a = component.properties) === null || _a === void 0 ? void 0 : _a[key]), scope);
|
|
460
467
|
})
|
|
461
468
|
: undefined,
|
|
462
|
-
listeners: runtime_1.getValidValue((_h = (_g = component.xProps) === null || _g === void 0 ? void 0 : _g.listeners) === null || _h === void 0 ? void 0 : _h.map((listener) => {
|
|
469
|
+
listeners: (0, runtime_1.getValidValue)((_h = (_g = component.xProps) === null || _g === void 0 ? void 0 : _g.listeners) === null || _h === void 0 ? void 0 : _h.map((listener) => {
|
|
463
470
|
return serializeListener(componentCtx, listener);
|
|
464
471
|
})),
|
|
465
472
|
directives: serializeDirecties(componentCtx, (((_j = component.xProps) === null || _j === void 0 ? void 0 : _j.directives) || {}), scope) || {
|
|
466
473
|
':if': true,
|
|
467
474
|
},
|
|
468
|
-
':class': ((_k = component === null || component === void 0 ? void 0 : component.xProps) === null || _k === void 0 ? void 0 : _k.classListBind)
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
475
|
+
':class': ((_k = component === null || component === void 0 ? void 0 : component.xProps) === null || _k === void 0 ? void 0 : _k.classListBind)
|
|
476
|
+
? serializeValue({
|
|
477
|
+
ctx: componentCtx,
|
|
478
|
+
key: 'classListBind',
|
|
479
|
+
dynamicValue: (_l = component === null || component === void 0 ? void 0 : component.xProps) === null || _l === void 0 ? void 0 : _l.classListBind,
|
|
480
|
+
scope,
|
|
481
|
+
}).value
|
|
474
482
|
: undefined,
|
|
475
|
-
':style': ((_m = component === null || component === void 0 ? void 0 : component.xProps) === null || _m === void 0 ? void 0 : _m.styleBind)
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
483
|
+
':style': ((_m = component === null || component === void 0 ? void 0 : component.xProps) === null || _m === void 0 ? void 0 : _m.styleBind)
|
|
484
|
+
? serializeValue({
|
|
485
|
+
ctx: componentCtx,
|
|
486
|
+
key: 'styleBind',
|
|
487
|
+
dynamicValue: (_o = component === null || component === void 0 ? void 0 : component.xProps) === null || _o === void 0 ? void 0 : _o.styleBind,
|
|
488
|
+
}).value
|
|
480
489
|
: undefined,
|
|
481
490
|
extra: {
|
|
482
491
|
commonStyle: (_p = component.xProps) === null || _p === void 0 ? void 0 : _p.commonStyle,
|
|
483
492
|
xIndex: component.xIndex,
|
|
484
493
|
styleBindPath: (_q = component === null || component === void 0 ? void 0 : component.xProps) === null || _q === void 0 ? void 0 : _q.styleBindPath,
|
|
485
|
-
staticResourceAttribute: (_r = component === null || component === void 0 ? void 0 : component.xProps) === null || _r === void 0 ? void 0 : _r.staticResourceAttribute
|
|
494
|
+
staticResourceAttribute: (_r = component === null || component === void 0 ? void 0 : component.xProps) === null || _r === void 0 ? void 0 : _r.staticResourceAttribute,
|
|
486
495
|
},
|
|
487
496
|
};
|
|
488
497
|
}
|
|
@@ -539,7 +548,7 @@ function deserializeComponent(ctx, components) {
|
|
|
539
548
|
if (Array.isArray(item)) {
|
|
540
549
|
return !!item.length;
|
|
541
550
|
}
|
|
542
|
-
return item != undefined && !common_2.isEmptyObj(item);
|
|
551
|
+
return item != undefined && !(0, common_2.isEmptyObj)(item);
|
|
543
552
|
})
|
|
544
553
|
? xProps
|
|
545
554
|
: undefined,
|
|
@@ -547,7 +556,8 @@ function deserializeComponent(ctx, components) {
|
|
|
547
556
|
* TODO
|
|
548
557
|
*/
|
|
549
558
|
xIndex: ((_h = item.extra) === null || _h === void 0 ? void 0 : _h.xIndex) !== undefined
|
|
550
|
-
? (_j = item.extra) === null || _j === void 0 ? void 0 : _j.xIndex
|
|
559
|
+
? (_j = item.extra) === null || _j === void 0 ? void 0 : _j.xIndex
|
|
560
|
+
: undefined /*0*/,
|
|
551
561
|
properties: item.items
|
|
552
562
|
? deserializeComponent(ctx, item.items)
|
|
553
563
|
: undefined,
|
|
@@ -568,7 +578,7 @@ function serializePage(ctx, page) {
|
|
|
568
578
|
id: page.id,
|
|
569
579
|
type: types_1.EComponentType.PAGE,
|
|
570
580
|
component: 'Page',
|
|
571
|
-
attributes: runtime_1.getValidValue(serializeAttributes(pageCtx, 'page', page.data)),
|
|
581
|
+
attributes: (0, runtime_1.getValidValue)(serializeAttributes(pageCtx, 'page', page.data)),
|
|
572
582
|
items: Object.keys(page.componentInstances || {}).map((id) => {
|
|
573
583
|
return serializeComponent(pageCtx, Object.assign({ id }, page.componentInstances[id]));
|
|
574
584
|
}),
|
|
@@ -577,8 +587,8 @@ function serializePage(ctx, page) {
|
|
|
577
587
|
},
|
|
578
588
|
resources: (_a = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _a === void 0 ? void 0 : _a.map((item) => serializeCodeSource(pageCtx, item)),
|
|
579
589
|
dataset: serializeDataset(ctx, page === null || page === void 0 ? void 0 : page.dataset),
|
|
580
|
-
dataVariables: runtime_1.getValidValue((_c = (_b = page === null || page === void 0 ? void 0 : page.vars) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.map((item) => serializeDataVariables(pageCtx, item))),
|
|
581
|
-
listeners: runtime_1.getValidValue((_d = page === null || page === void 0 ? void 0 : page.listeners) === null || _d === void 0 ? void 0 : _d.map((item) => {
|
|
590
|
+
dataVariables: (0, runtime_1.getValidValue)((_c = (_b = page === null || page === void 0 ? void 0 : page.vars) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.map((item) => serializeDataVariables(pageCtx, item))),
|
|
591
|
+
listeners: (0, runtime_1.getValidValue)((_d = page === null || page === void 0 ? void 0 : page.listeners) === null || _d === void 0 ? void 0 : _d.map((item) => {
|
|
582
592
|
return serializeListener(pageCtx, item);
|
|
583
593
|
})),
|
|
584
594
|
extra: {
|
|
@@ -628,6 +638,9 @@ function deserializePage(ctx, page) {
|
|
|
628
638
|
listeners: ((_g = page === null || page === void 0 ? void 0 : page.listeners) === null || _g === void 0 ? void 0 : _g.map((item) => {
|
|
629
639
|
return deserializeListener(pageCtx, item);
|
|
630
640
|
})) || [],
|
|
641
|
+
// TODO
|
|
642
|
+
// children: [],
|
|
643
|
+
// styleBindPath: item.styleBindPath,
|
|
631
644
|
};
|
|
632
645
|
}
|
|
633
646
|
exports.deserializePage = deserializePage;
|
|
@@ -658,7 +671,7 @@ function serializePlatformApp(data, optsions) {
|
|
|
658
671
|
resources: lowCodes === null || lowCodes === void 0 ? void 0 : lowCodes.map((item) => serializeCodeSource(ctx, item)),
|
|
659
672
|
dataSources: datasources,
|
|
660
673
|
dataset: serializeDataset(ctx, dataset),
|
|
661
|
-
dataVariables: runtime_1.getValidValue(vars === null || vars === void 0 ? void 0 : vars.data.map((item) => serializeDataVariables(ctx, item))),
|
|
674
|
+
dataVariables: (0, runtime_1.getValidValue)(vars === null || vars === void 0 ? void 0 : vars.data.map((item) => serializeDataVariables(ctx, item))),
|
|
662
675
|
extra: Object.assign(Object.assign(Object.assign({}, restExtra), restData), { miniprogramPlugins, historyType: data.historyType, npmDependencies: data.npmDependencies || {}, plugins: data.plugins, maxID: data.maxID, rootPath: data.rootPath, themeVars: data.themeVars, presetColors: data.presetColors, appConfig: data.appConfig }),
|
|
663
676
|
};
|
|
664
677
|
return processed;
|
|
@@ -710,6 +723,8 @@ function deserializePlatformApp(data, optsions) {
|
|
|
710
723
|
appConfig: appConfig,
|
|
711
724
|
miniprogramPlugins,
|
|
712
725
|
extra: Object.assign(Object.assign({}, restExtra), { name: data.name, author: data.author, description: data.description }),
|
|
726
|
+
// TODO
|
|
727
|
+
// emitEvents: [], { "name": "自定义校验规则", "eventName": "validator" }
|
|
713
728
|
};
|
|
714
729
|
return processed;
|
|
715
730
|
}
|
|
@@ -726,34 +741,34 @@ function serializeRuntimePage(ctx, page //IPageInstance
|
|
|
726
741
|
id: page.id,
|
|
727
742
|
type: types_1.EComponentType.PAGE,
|
|
728
743
|
component: 'Page',
|
|
729
|
-
attributes: serializeAttributes(pageCtx, 'page', runtime_1.readDynamicData(page)),
|
|
730
|
-
items: runtime_1.getValidValue(Object.keys(((_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties) || {}).map((id) => {
|
|
744
|
+
attributes: serializeAttributes(pageCtx, 'page', (0, runtime_1.readDynamicData)(page)),
|
|
745
|
+
items: (0, runtime_1.getValidValue)(Object.keys(((_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties) || {}).map((id) => {
|
|
731
746
|
var _a;
|
|
732
747
|
return serializeRuntimeComponent(pageCtx, Object.assign({ id }, (_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties[id]));
|
|
733
748
|
})),
|
|
734
749
|
resources: (_b = page === null || page === void 0 ? void 0 : page.codeModules) === null || _b === void 0 ? void 0 : _b.map((item) => serializeCodeSource(pageCtx, item)),
|
|
735
750
|
dataset: page === null || page === void 0 ? void 0 : page.dataset,
|
|
736
|
-
dataVariables: runtime_1.getValidValue((_d = (_c = page === null || page === void 0 ? void 0 : page.vars) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.map((item) => serializeDataVariables(pageCtx, item))),
|
|
737
|
-
listeners: runtime_1.getValidValue(runtime_1.readListeners(page.listenerInstances || []).map((item) => {
|
|
751
|
+
dataVariables: (0, runtime_1.getValidValue)((_d = (_c = page === null || page === void 0 ? void 0 : page.vars) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.map((item) => serializeDataVariables(pageCtx, item))),
|
|
752
|
+
listeners: (0, runtime_1.getValidValue)((0, runtime_1.readListeners)(page.listenerInstances || []).map((item) => {
|
|
738
753
|
return serializeListener(pageCtx, item);
|
|
739
754
|
})),
|
|
740
755
|
extra: {
|
|
741
|
-
pluginInstances: runtime_1.getValidValue(page === null || page === void 0 ? void 0 : page.pluginInstances),
|
|
742
|
-
commonStyle: runtime_1.getValidValue(style_1.removeInvalidStyleFormValue(page.style)),
|
|
743
|
-
styleBindPath: runtime_1.getValidValue(page.styleBindPath),
|
|
756
|
+
pluginInstances: (0, runtime_1.getValidValue)(page === null || page === void 0 ? void 0 : page.pluginInstances),
|
|
757
|
+
commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(page.style)),
|
|
758
|
+
styleBindPath: (0, runtime_1.getValidValue)(page.styleBindPath),
|
|
744
759
|
xIndex: page.xIndex,
|
|
745
|
-
children: runtime_1.getValidValue((_e = page.children) === null || _e === void 0 ? void 0 : _e.map((child) => serializeRuntimePage(ctx, child))),
|
|
760
|
+
children: (0, runtime_1.getValidValue)((_e = page.children) === null || _e === void 0 ? void 0 : _e.map((child) => serializeRuntimePage(ctx, child))),
|
|
746
761
|
},
|
|
747
762
|
};
|
|
748
|
-
if (common_2.isValidStyleBind(page.styleBind) && runtime_1.getValidValue(page.styleBind)) {
|
|
763
|
+
if ((0, common_2.isValidStyleBind)(page.styleBind) && (0, runtime_1.getValidValue)(page.styleBind)) {
|
|
749
764
|
page[':style'] = serializeValue({
|
|
750
765
|
ctx: pageCtx,
|
|
751
766
|
key: 'styleBind',
|
|
752
767
|
dynamicValue: page.styleBind,
|
|
753
768
|
}).value;
|
|
754
769
|
}
|
|
755
|
-
if (common_2.isValidClassNameListBind(page.classListBind) &&
|
|
756
|
-
runtime_1.getValidValue(page.classListBind)) {
|
|
770
|
+
if ((0, common_2.isValidClassNameListBind)(page.classListBind) &&
|
|
771
|
+
(0, runtime_1.getValidValue)(page.classListBind)) {
|
|
757
772
|
page[':class'] = serializeValue({
|
|
758
773
|
ctx: pageCtx,
|
|
759
774
|
key: 'classListBind',
|
|
@@ -798,37 +813,38 @@ function serializeRuntimeComponent(ctx, component //IComponentSchemaJson
|
|
|
798
813
|
.filter((dataType) => dataType.type !== 'slot')
|
|
799
814
|
.map((dataType) => dataType.propertyPath);
|
|
800
815
|
let properties = component.properties || {};
|
|
801
|
-
processed = Object.assign(Object.assign({}, processed), { module: serializeModuleName(componentCtx, moduleName, name), component: name, attributes: Object.assign(Object.assign({}, serializeAttributes(componentCtx, 'page', (runtime_1.getValidValue(runtime_1.readDynamicData(props)) || {}))), { style: runtime_1.getValidValue(props.style), class: (_a = runtime_1.getValidValue(props.classNameList)) === null || _a === void 0 ? void 0 : _a.join(' ') }), items: runtime_1.getValidValue(Object.keys(properties)
|
|
816
|
+
processed = Object.assign(Object.assign({}, processed), { module: serializeModuleName(componentCtx, moduleName, name), component: name, attributes: Object.assign(Object.assign({}, serializeAttributes(componentCtx, 'page', ((0, runtime_1.getValidValue)((0, runtime_1.readDynamicData)(props)) || {}))), { style: (0, runtime_1.getValidValue)(props.style), class: (_a = (0, runtime_1.getValidValue)(props.classNameList)) === null || _a === void 0 ? void 0 : _a.join(' ') }), items: (0, runtime_1.getValidValue)(Object.keys(properties)
|
|
802
817
|
.filter((key) => !excludeKeys.includes(key))
|
|
803
|
-
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, properties[key])))), listeners: (_b = runtime_1.getValidValue(runtime_1.readListeners(props.listenerInstances))) === null || _b === void 0 ? void 0 : _b.map((listener /* IEventListener */) => {
|
|
818
|
+
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, properties[key])))), listeners: (_b = (0, runtime_1.getValidValue)((0, runtime_1.readListeners)(props.listenerInstances))) === null || _b === void 0 ? void 0 : _b.map((listener /* IEventListener */) => {
|
|
804
819
|
return serializeListener(componentCtx, listener);
|
|
805
|
-
}), directives: serializeDirecties(componentCtx, (runtime_1.getValidValue(runtime_1.readDirectives(props)) || {})) || undefined, ':class': common_2.isValidClassNameListBind(props.classNameListBind)
|
|
820
|
+
}), directives: serializeDirecties(componentCtx, ((0, runtime_1.getValidValue)((0, runtime_1.readDirectives)(props)) || {})) || undefined, ':class': (0, common_2.isValidClassNameListBind)(props.classNameListBind)
|
|
806
821
|
? serializeValue({
|
|
807
822
|
ctx: componentCtx,
|
|
808
823
|
key: 'classListBind',
|
|
809
|
-
dynamicValue: runtime_1.getValidValue({
|
|
824
|
+
dynamicValue: (0, runtime_1.getValidValue)({
|
|
810
825
|
type: props.classNameListBind.type,
|
|
811
826
|
value: props.classNameListBind.bindDataPath,
|
|
812
827
|
}),
|
|
813
828
|
}).value
|
|
814
|
-
: undefined, ':style': ((_c = props === null || props === void 0 ? void 0 : props.styleBind) === null || _c === void 0 ? void 0 : _c.bindDataPath)
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
829
|
+
: undefined, ':style': ((_c = props === null || props === void 0 ? void 0 : props.styleBind) === null || _c === void 0 ? void 0 : _c.bindDataPath)
|
|
830
|
+
? serializeValue({
|
|
831
|
+
ctx: componentCtx,
|
|
832
|
+
key: 'styleBind',
|
|
833
|
+
dynamicValue: {
|
|
834
|
+
type: props.styleBind.type,
|
|
835
|
+
value: props.styleBind.bindDataPath,
|
|
836
|
+
},
|
|
837
|
+
}).value
|
|
822
838
|
: undefined, extra: {
|
|
823
|
-
commonStyle: runtime_1.getValidValue(style_1.removeInvalidStyleFormValue(props.commonStyle)),
|
|
824
|
-
xIndex: runtime_1.getValidValue(component['x-index']),
|
|
825
|
-
styleBindPath: runtime_1.getValidValue(props.styleBindPath),
|
|
826
|
-
staticResourceAttribute: runtime_1.getValidValue(props.staticResourceAttribute)
|
|
839
|
+
commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(props.commonStyle)),
|
|
840
|
+
xIndex: (0, runtime_1.getValidValue)(component['x-index']),
|
|
841
|
+
styleBindPath: (0, runtime_1.getValidValue)(props.styleBindPath),
|
|
842
|
+
staticResourceAttribute: (0, runtime_1.getValidValue)(props.staticResourceAttribute),
|
|
827
843
|
} });
|
|
828
844
|
}
|
|
829
845
|
else {
|
|
830
846
|
let items = Object.keys(component.properties || {}).map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, component.properties[key])));
|
|
831
|
-
processed = Object.assign(Object.assign({}, processed), { items: runtime_1.getValidValue(items) });
|
|
847
|
+
processed = Object.assign(Object.assign({}, processed), { items: (0, runtime_1.getValidValue)(items) });
|
|
832
848
|
}
|
|
833
849
|
return processed;
|
|
834
850
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IComplexComponent, IBasicComponent } from '../../../../types';
|
|
2
|
+
interface IParseContext {
|
|
3
|
+
component?: {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
forContext: Record<string, boolean>;
|
|
7
|
+
datasetMap: Record<string, any>;
|
|
8
|
+
dataSourceMap: Record<string, any>;
|
|
9
|
+
componentMap: Record<string, any>;
|
|
10
|
+
lowcodeMap: Record<string, any>;
|
|
11
|
+
componentLibMap: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseComponentCals(ctx: IParseContext, cals: IBasicComponent | IComplexComponent): IParseContext;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../parser/cals/utils/block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EAEhB,MAAM,mBAAmB,CAAA;AAQ1B,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE;QACV,EAAE,EAAE,MAAM,CAAA;KACX,CAAA;IACD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACrC;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,eAAe,GAAG,iBAAiB,GACxC,aAAa,CAyDf"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseComponentCals = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const expression_1 = require("../../../expression");
|
|
6
|
+
function parseComponentCals(ctx, cals) {
|
|
7
|
+
if (!ctx.datasetMap) {
|
|
8
|
+
ctx.datasetMap = {};
|
|
9
|
+
}
|
|
10
|
+
if (!ctx.dataSourceMap) {
|
|
11
|
+
ctx.dataSourceMap = {};
|
|
12
|
+
}
|
|
13
|
+
if (!ctx.componentMap) {
|
|
14
|
+
ctx.componentMap = {};
|
|
15
|
+
}
|
|
16
|
+
if (!ctx.lowcodeMap) {
|
|
17
|
+
ctx.lowcodeMap = {};
|
|
18
|
+
}
|
|
19
|
+
if (!ctx.componentLibMap) {
|
|
20
|
+
ctx.componentLibMap = {};
|
|
21
|
+
}
|
|
22
|
+
ctx.component = {
|
|
23
|
+
id: cals.id || '',
|
|
24
|
+
};
|
|
25
|
+
const { component, module, attributes = {}, items = [], listeners = [], directives = {}, [':class']: dynamicClassList, [':style']: dynamicStyle, } = cals;
|
|
26
|
+
if (module && component && !(0, lodash_1.get)(ctx.componentMap, `${module}.${component}`)) {
|
|
27
|
+
(0, lodash_1.set)(ctx.componentMap, `${module}.${component}`, true);
|
|
28
|
+
ctx.componentLibMap[module] = true;
|
|
29
|
+
}
|
|
30
|
+
// 优先处理 directives 因为其他绑定会用到for
|
|
31
|
+
parseDirectivesCals(ctx, directives);
|
|
32
|
+
pasrseDynamicMapCals(ctx, attributes);
|
|
33
|
+
for (let item of listeners) {
|
|
34
|
+
parseListenertCals(ctx, item);
|
|
35
|
+
}
|
|
36
|
+
if (dynamicClassList) {
|
|
37
|
+
parseValueCals(ctx, dynamicClassList);
|
|
38
|
+
}
|
|
39
|
+
if (dynamicStyle) {
|
|
40
|
+
parseValueCals(ctx, dynamicStyle);
|
|
41
|
+
}
|
|
42
|
+
for (let item of items) {
|
|
43
|
+
parseComponentCals(ctx, item);
|
|
44
|
+
}
|
|
45
|
+
return ctx;
|
|
46
|
+
}
|
|
47
|
+
exports.parseComponentCals = parseComponentCals;
|
|
48
|
+
function parseListenertCals(ctx, listener) {
|
|
49
|
+
let { type, handler } = listener;
|
|
50
|
+
switch (type) {
|
|
51
|
+
case expression_1.ActionType.Rematch: {
|
|
52
|
+
if (handler === null || handler === void 0 ? void 0 : handler.name) {
|
|
53
|
+
ctx.lowcodeMap[handler === null || handler === void 0 ? void 0 : handler.name] = true;
|
|
54
|
+
}
|
|
55
|
+
pasrseDynamicMapCals(ctx, handler === null || handler === void 0 ? void 0 : handler.params);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case expression_1.ActionType.DataSource: {
|
|
59
|
+
let params = handler === null || handler === void 0 ? void 0 : handler.params;
|
|
60
|
+
pasrseDynamicMapCals(params);
|
|
61
|
+
if (params === null || params === void 0 ? void 0 : params.dataSourceName) {
|
|
62
|
+
ctx.dataSourceMap[params === null || params === void 0 ? void 0 : params.dataSourceName] = true;
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case expression_1.ActionType.Material: {
|
|
67
|
+
if (handler === null || handler === void 0 ? void 0 : handler.module) {
|
|
68
|
+
ctx.componentLibMap[handler === null || handler === void 0 ? void 0 : handler.module] = true;
|
|
69
|
+
}
|
|
70
|
+
pasrseDynamicMapCals(ctx, handler === null || handler === void 0 ? void 0 : handler.params);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case expression_1.ActionType.Platform: {
|
|
74
|
+
console.log(handler === null || handler === void 0 ? void 0 : handler.params);
|
|
75
|
+
pasrseDynamicMapCals(ctx, handler === null || handler === void 0 ? void 0 : handler.params);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function pasrseDynamicMapCals(ctx, map = {}) {
|
|
81
|
+
for (let key in map) {
|
|
82
|
+
if (/^:/.test(key) && typeof map[key] === 'string') {
|
|
83
|
+
parseValueCals(ctx, map[key]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function parseDirectivesCals(ctx, directives) {
|
|
88
|
+
var _a;
|
|
89
|
+
// 优先处理for,因为其他的可能会用到 foritem
|
|
90
|
+
let forValue = directives[':for'];
|
|
91
|
+
if (typeof forValue === 'string') {
|
|
92
|
+
parseValueCals(ctx, forValue);
|
|
93
|
+
if (!ctx.forContext) {
|
|
94
|
+
ctx.forContext = {};
|
|
95
|
+
}
|
|
96
|
+
if ((_a = ctx.component) === null || _a === void 0 ? void 0 : _a.id) {
|
|
97
|
+
ctx.forContext[ctx.component.id] = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
let visibleValue = directives[':if'];
|
|
101
|
+
if (typeof visibleValue === 'string') {
|
|
102
|
+
parseValueCals(ctx, visibleValue);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function parseValueCals(ctx, value) {
|
|
106
|
+
var _a, _b;
|
|
107
|
+
try {
|
|
108
|
+
let parser = new expression_1.DynamicValueParser(value, { pageId: '$page' });
|
|
109
|
+
let res = parser.parse();
|
|
110
|
+
switch (res.type) {
|
|
111
|
+
case expression_1.PropBindType.paramData:
|
|
112
|
+
case expression_1.PropBindType.stateData: {
|
|
113
|
+
const TYPE_MAP = {
|
|
114
|
+
[expression_1.PropBindType.paramData]: 'params',
|
|
115
|
+
[expression_1.PropBindType.stateData]: 'state',
|
|
116
|
+
};
|
|
117
|
+
const type = TYPE_MAP[res.type];
|
|
118
|
+
const path = ((_a = res.value) === null || _a === void 0 ? void 0 : _a.split('.')) || [];
|
|
119
|
+
let key = path[0];
|
|
120
|
+
if (!ctx.datasetMap[key]) {
|
|
121
|
+
ctx.datasetMap[key] = {};
|
|
122
|
+
}
|
|
123
|
+
if (path.length === 1) {
|
|
124
|
+
ctx.datasetMap[key][type] = true;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
ctx.datasetMap[key][`${type}.${path[1].replace(/\[.*/, '')}`] = true;
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case expression_1.PropBindType.forItem: {
|
|
132
|
+
const [id] = ((_b = res.value) === null || _b === void 0 ? void 0 : _b.split('.')) || [];
|
|
133
|
+
if (!ctx.forContext[id]) {
|
|
134
|
+
throw {
|
|
135
|
+
code: 'INVALID_FOR_CONTEXT',
|
|
136
|
+
message: '缺少循环上下文,无法保存为区块',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
if ((e === null || e === void 0 ? void 0 : e.code) === 'INVALID_FOR_CONTEXT') {
|
|
145
|
+
throw e;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -24,7 +24,7 @@ function readComponents(properties = {}, excludeKeys = []) {
|
|
|
24
24
|
setValidValue(componentXProps, 'listeners', readListeners(srcProps.listenerInstances));
|
|
25
25
|
setValidValue(componentXProps, 'directives', readDirectives(srcProps));
|
|
26
26
|
setValidValue(componentXProps, 'style', srcProps.style);
|
|
27
|
-
setValidValue(componentXProps, 'commonStyle', style_1.removeInvalidStyleFormValue(srcProps.commonStyle));
|
|
27
|
+
setValidValue(componentXProps, 'commonStyle', (0, style_1.removeInvalidStyleFormValue)(srcProps.commonStyle));
|
|
28
28
|
setValidValue(componentXProps, 'styleBindPath', srcProps.styleBindPath);
|
|
29
29
|
if (srcProps.styleBind && srcProps.styleBind.bindDataPath) {
|
|
30
30
|
componentXProps.styleBind = {
|
|
@@ -32,7 +32,7 @@ function readComponents(properties = {}, excludeKeys = []) {
|
|
|
32
32
|
value: srcProps.styleBind.bindDataPath,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
if (common_1.isValidClassNameListBind(srcProps.classNameListBind)) {
|
|
35
|
+
if ((0, common_1.isValidClassNameListBind)(srcProps.classNameListBind)) {
|
|
36
36
|
const classList = srcProps.classNameListBind;
|
|
37
37
|
setValidValue(componentXProps, 'classListBind', {
|
|
38
38
|
type: classList.type,
|
|
@@ -147,7 +147,7 @@ function getValidValue(value) {
|
|
|
147
147
|
if (Array.isArray(value) && value.length === 0) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
if (common_1.isPlainObject(value) && common_1.isEmptyObj(value)) {
|
|
150
|
+
if ((0, common_1.isPlainObject)(value) && (0, common_1.isEmptyObj)(value)) {
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
return value;
|
|
@@ -5,7 +5,7 @@ const common_1 = require("./common");
|
|
|
5
5
|
function removeInvalidStyleFormValue(styleForm = {}) {
|
|
6
6
|
return Object.keys(styleForm).reduce((result, key) => {
|
|
7
7
|
const propStyleFormData = styleForm[key];
|
|
8
|
-
if (common_1.isPlainObject(propStyleFormData)) {
|
|
8
|
+
if ((0, common_1.isPlainObject)(propStyleFormData)) {
|
|
9
9
|
setStyleValue(result, key, removeInvalidStyleFormValue(propStyleFormData));
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
@@ -23,8 +23,8 @@ function setStyleValue(object, key, value) {
|
|
|
23
23
|
if (key === 'open') {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
if (common_1.isEmptyObj(value)) {
|
|
26
|
+
if ((0, common_1.isEmptyObj)(value)) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
object[common_1.camelcase(key)] = value;
|
|
29
|
+
object[(0, common_1.camelcase)(key)] = value;
|
|
30
30
|
}
|