@cloudbase/cals 0.3.5 → 0.3.9

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.
@@ -156,9 +156,9 @@ function serializeDynamicMap({ ctx, map = {}, scope = 'page', streamlineDefaultV
156
156
  let matched = processedKey.match(/^:(.*)$/);
157
157
  if (matched) {
158
158
  const originValue = matched[1];
159
- lodash_1.unset(data, originValue);
159
+ (0, lodash_1.unset)(data, originValue);
160
160
  }
161
- if (lodash_1.get(data, processedKey) == undefined) {
161
+ if ((0, lodash_1.get)(data, processedKey) == undefined) {
162
162
  data[processedKey] = processedValue;
163
163
  }
164
164
  });
@@ -297,7 +297,8 @@ function deserializeDirecties(ctx, directives) {
297
297
  let waIf = (directives === null || directives === void 0 ? void 0 : directives[':if']) != undefined
298
298
  ? deserializeValue(ctx, ':if', directives[':if']).value
299
299
  : { value: true };
300
- let waFor = (directives === null || directives === void 0 ? void 0 : directives[':for']) ? deserializeValue(ctx, ':for', directives[':for']).value
300
+ let waFor = (directives === null || directives === void 0 ? void 0 : directives[':for'])
301
+ ? deserializeValue(ctx, ':for', directives[':for']).value
301
302
  : undefined;
302
303
  if (waFor) {
303
304
  let { type, value } = waFor;
@@ -451,7 +452,7 @@ function serializeComponent(ctx, component, scope = 'page') {
451
452
  type: undefined,
452
453
  module: serializeModuleName(componentCtx, moduleName, componentName),
453
454
  component: componentName,
454
- attributes: runtime_1.getValidValue(component.xProps
455
+ attributes: (0, runtime_1.getValidValue)(component.xProps
455
456
  ? 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
457
  items: component.properties
457
458
  ? Object.keys(component.properties).map((key) => {
@@ -459,24 +460,26 @@ function serializeComponent(ctx, component, scope = 'page') {
459
460
  return serializeComponent(componentCtx, Object.assign({ id: key }, (_a = component.properties) === null || _a === void 0 ? void 0 : _a[key]), scope);
460
461
  })
461
462
  : 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) => {
463
+ 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
464
  return serializeListener(componentCtx, listener);
464
465
  })),
465
466
  directives: serializeDirecties(componentCtx, (((_j = component.xProps) === null || _j === void 0 ? void 0 : _j.directives) || {}), scope) || {
466
467
  ':if': true,
467
468
  },
468
- ':class': ((_k = component === null || component === void 0 ? void 0 : component.xProps) === null || _k === void 0 ? void 0 : _k.classListBind) ? serializeValue({
469
- ctx: componentCtx,
470
- key: 'classListBind',
471
- dynamicValue: (_l = component === null || component === void 0 ? void 0 : component.xProps) === null || _l === void 0 ? void 0 : _l.classListBind,
472
- scope,
473
- }).value
469
+ ':class': ((_k = component === null || component === void 0 ? void 0 : component.xProps) === null || _k === void 0 ? void 0 : _k.classListBind)
470
+ ? serializeValue({
471
+ ctx: componentCtx,
472
+ key: 'classListBind',
473
+ dynamicValue: (_l = component === null || component === void 0 ? void 0 : component.xProps) === null || _l === void 0 ? void 0 : _l.classListBind,
474
+ scope,
475
+ }).value
474
476
  : undefined,
475
- ':style': ((_m = component === null || component === void 0 ? void 0 : component.xProps) === null || _m === void 0 ? void 0 : _m.styleBind) ? serializeValue({
476
- ctx: componentCtx,
477
- key: 'styleBind',
478
- dynamicValue: (_o = component === null || component === void 0 ? void 0 : component.xProps) === null || _o === void 0 ? void 0 : _o.styleBind,
479
- }).value
477
+ ':style': ((_m = component === null || component === void 0 ? void 0 : component.xProps) === null || _m === void 0 ? void 0 : _m.styleBind)
478
+ ? serializeValue({
479
+ ctx: componentCtx,
480
+ key: 'styleBind',
481
+ dynamicValue: (_o = component === null || component === void 0 ? void 0 : component.xProps) === null || _o === void 0 ? void 0 : _o.styleBind,
482
+ }).value
480
483
  : undefined,
481
484
  extra: {
482
485
  commonStyle: (_p = component.xProps) === null || _p === void 0 ? void 0 : _p.commonStyle,
@@ -539,7 +542,7 @@ function deserializeComponent(ctx, components) {
539
542
  if (Array.isArray(item)) {
540
543
  return !!item.length;
541
544
  }
542
- return item != undefined && !common_2.isEmptyObj(item);
545
+ return item != undefined && !(0, common_2.isEmptyObj)(item);
543
546
  })
544
547
  ? xProps
545
548
  : undefined,
@@ -547,7 +550,8 @@ function deserializeComponent(ctx, components) {
547
550
  * TODO
548
551
  */
549
552
  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 : undefined /*0*/,
553
+ ? (_j = item.extra) === null || _j === void 0 ? void 0 : _j.xIndex
554
+ : undefined /*0*/,
551
555
  properties: item.items
552
556
  ? deserializeComponent(ctx, item.items)
553
557
  : undefined,
@@ -568,7 +572,7 @@ function serializePage(ctx, page) {
568
572
  id: page.id,
569
573
  type: types_1.EComponentType.PAGE,
570
574
  component: 'Page',
571
- attributes: runtime_1.getValidValue(serializeAttributes(pageCtx, 'page', page.data)),
575
+ attributes: (0, runtime_1.getValidValue)(serializeAttributes(pageCtx, 'page', page.data)),
572
576
  items: Object.keys(page.componentInstances || {}).map((id) => {
573
577
  return serializeComponent(pageCtx, Object.assign({ id }, page.componentInstances[id]));
574
578
  }),
@@ -577,8 +581,8 @@ function serializePage(ctx, page) {
577
581
  },
578
582
  resources: (_a = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _a === void 0 ? void 0 : _a.map((item) => serializeCodeSource(pageCtx, item)),
579
583
  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) => {
584
+ 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))),
585
+ 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
586
  return serializeListener(pageCtx, item);
583
587
  })),
584
588
  extra: {
@@ -628,6 +632,9 @@ function deserializePage(ctx, page) {
628
632
  listeners: ((_g = page === null || page === void 0 ? void 0 : page.listeners) === null || _g === void 0 ? void 0 : _g.map((item) => {
629
633
  return deserializeListener(pageCtx, item);
630
634
  })) || [],
635
+ // TODO
636
+ // children: [],
637
+ // styleBindPath: item.styleBindPath,
631
638
  };
632
639
  }
633
640
  exports.deserializePage = deserializePage;
@@ -658,7 +665,7 @@ function serializePlatformApp(data, optsions) {
658
665
  resources: lowCodes === null || lowCodes === void 0 ? void 0 : lowCodes.map((item) => serializeCodeSource(ctx, item)),
659
666
  dataSources: datasources,
660
667
  dataset: serializeDataset(ctx, dataset),
661
- dataVariables: runtime_1.getValidValue(vars === null || vars === void 0 ? void 0 : vars.data.map((item) => serializeDataVariables(ctx, item))),
668
+ dataVariables: (0, runtime_1.getValidValue)(vars === null || vars === void 0 ? void 0 : vars.data.map((item) => serializeDataVariables(ctx, item))),
662
669
  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
670
  };
664
671
  return processed;
@@ -710,6 +717,8 @@ function deserializePlatformApp(data, optsions) {
710
717
  appConfig: appConfig,
711
718
  miniprogramPlugins,
712
719
  extra: Object.assign(Object.assign({}, restExtra), { name: data.name, author: data.author, description: data.description }),
720
+ // TODO
721
+ // emitEvents: [], { "name": "自定义校验规则", "eventName": "validator" }
713
722
  };
714
723
  return processed;
715
724
  }
@@ -726,34 +735,34 @@ function serializeRuntimePage(ctx, page //IPageInstance
726
735
  id: page.id,
727
736
  type: types_1.EComponentType.PAGE,
728
737
  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) => {
738
+ attributes: serializeAttributes(pageCtx, 'page', (0, runtime_1.readDynamicData)(page)),
739
+ items: (0, runtime_1.getValidValue)(Object.keys(((_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties) || {}).map((id) => {
731
740
  var _a;
732
741
  return serializeRuntimeComponent(pageCtx, Object.assign({ id }, (_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties[id]));
733
742
  })),
734
743
  resources: (_b = page === null || page === void 0 ? void 0 : page.codeModules) === null || _b === void 0 ? void 0 : _b.map((item) => serializeCodeSource(pageCtx, item)),
735
744
  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) => {
745
+ 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))),
746
+ listeners: (0, runtime_1.getValidValue)((0, runtime_1.readListeners)(page.listenerInstances || []).map((item) => {
738
747
  return serializeListener(pageCtx, item);
739
748
  })),
740
749
  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),
750
+ pluginInstances: (0, runtime_1.getValidValue)(page === null || page === void 0 ? void 0 : page.pluginInstances),
751
+ commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(page.style)),
752
+ styleBindPath: (0, runtime_1.getValidValue)(page.styleBindPath),
744
753
  xIndex: page.xIndex,
745
- children: runtime_1.getValidValue((_e = page.children) === null || _e === void 0 ? void 0 : _e.map((child) => serializeRuntimePage(ctx, child))),
754
+ children: (0, runtime_1.getValidValue)((_e = page.children) === null || _e === void 0 ? void 0 : _e.map((child) => serializeRuntimePage(ctx, child))),
746
755
  },
747
756
  };
748
- if (common_2.isValidStyleBind(page.styleBind) && runtime_1.getValidValue(page.styleBind)) {
757
+ if ((0, common_2.isValidStyleBind)(page.styleBind) && (0, runtime_1.getValidValue)(page.styleBind)) {
749
758
  page[':style'] = serializeValue({
750
759
  ctx: pageCtx,
751
760
  key: 'styleBind',
752
761
  dynamicValue: page.styleBind,
753
762
  }).value;
754
763
  }
755
- if (common_2.isValidClassNameListBind(page.classListBind) &&
756
- runtime_1.getValidValue(page.classListBind)) {
764
+ if ((0, common_2.isValidClassNameListBind)(page.classListBind) &&
765
+ (0, runtime_1.getValidValue)(page.classListBind)) {
757
766
  page[':class'] = serializeValue({
758
767
  ctx: pageCtx,
759
768
  key: 'classListBind',
@@ -798,37 +807,38 @@ function serializeRuntimeComponent(ctx, component //IComponentSchemaJson
798
807
  .filter((dataType) => dataType.type !== 'slot')
799
808
  .map((dataType) => dataType.propertyPath);
800
809
  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)
810
+ 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
811
  .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 */) => {
812
+ .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
813
  return serializeListener(componentCtx, listener);
805
- }), directives: serializeDirecties(componentCtx, (runtime_1.getValidValue(runtime_1.readDirectives(props)) || {})) || undefined, ':class': common_2.isValidClassNameListBind(props.classNameListBind)
814
+ }), directives: serializeDirecties(componentCtx, ((0, runtime_1.getValidValue)((0, runtime_1.readDirectives)(props)) || {})) || undefined, ':class': (0, common_2.isValidClassNameListBind)(props.classNameListBind)
806
815
  ? serializeValue({
807
816
  ctx: componentCtx,
808
817
  key: 'classListBind',
809
- dynamicValue: runtime_1.getValidValue({
818
+ dynamicValue: (0, runtime_1.getValidValue)({
810
819
  type: props.classNameListBind.type,
811
820
  value: props.classNameListBind.bindDataPath,
812
821
  }),
813
822
  }).value
814
- : undefined, ':style': ((_c = props === null || props === void 0 ? void 0 : props.styleBind) === null || _c === void 0 ? void 0 : _c.bindDataPath) ? serializeValue({
815
- ctx: componentCtx,
816
- key: 'styleBind',
817
- dynamicValue: {
818
- type: props.styleBind.type,
819
- value: props.styleBind.bindDataPath,
820
- },
821
- }).value
823
+ : undefined, ':style': ((_c = props === null || props === void 0 ? void 0 : props.styleBind) === null || _c === void 0 ? void 0 : _c.bindDataPath)
824
+ ? serializeValue({
825
+ ctx: componentCtx,
826
+ key: 'styleBind',
827
+ dynamicValue: {
828
+ type: props.styleBind.type,
829
+ value: props.styleBind.bindDataPath,
830
+ },
831
+ }).value
822
832
  : 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)
833
+ commonStyle: (0, runtime_1.getValidValue)((0, style_1.removeInvalidStyleFormValue)(props.commonStyle)),
834
+ xIndex: (0, runtime_1.getValidValue)(component['x-index']),
835
+ styleBindPath: (0, runtime_1.getValidValue)(props.styleBindPath),
836
+ staticResourceAttribute: (0, runtime_1.getValidValue)(props.staticResourceAttribute)
827
837
  } });
828
838
  }
829
839
  else {
830
840
  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) });
841
+ processed = Object.assign(Object.assign({}, processed), { items: (0, runtime_1.getValidValue)(items) });
832
842
  }
833
843
  return processed;
834
844
  }
@@ -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
  }
@@ -70,8 +70,8 @@ function translateComponentModuleName(comp) {
70
70
  const { xComponent } = comp;
71
71
  if (xComponent) {
72
72
  const { name } = xComponent;
73
- const complexName = utils_1.isComplexComponent(name);
74
- const gsdH5ReactName = utils_1.isGsdH5ReactComponent(name);
73
+ const complexName = (0, utils_1.isComplexComponent)(name);
74
+ const gsdH5ReactName = (0, utils_1.isGsdH5ReactComponent)(name);
75
75
  if (complexName) {
76
76
  xComponent.moduleName = 'CLOUDBASE_STANDARD';
77
77
  xComponent.name = complexName;
@@ -167,7 +167,7 @@ function translateComponent(comp) {
167
167
  comp.properties = {
168
168
  contentSlot: {
169
169
  properties: {
170
- [utils_1.getId()]: {
170
+ [(0, utils_1.getId)()]: {
171
171
  xComponent: {
172
172
  moduleName: 'gsd-h5-react',
173
173
  name: 'Text',
@@ -246,7 +246,7 @@ function translateStyleToCommonStyle(comp) {
246
246
  if (xProps && xProps.style) {
247
247
  xProps.commonStyle = xProps.commonStyle || {};
248
248
  xProps.commonStyle.self = xProps.commonStyle.self || {};
249
- xProps.commonStyle.self = lodash_1.merge(xProps.style, xProps.commonStyle.self);
249
+ xProps.commonStyle.self = (0, lodash_1.merge)(xProps.style, xProps.commonStyle.self);
250
250
  delete xProps.style;
251
251
  }
252
252
  }
@@ -280,11 +280,11 @@ function addFormItem(comp, key, parent, isOnlySlot = false) {
280
280
  };
281
281
  if (!rulesValue.type || rulesValue.type === 'static') {
282
282
  rulesValue.value = (rulesValue.value || []).filter((meta) => {
283
- return meta && !common_1.isEmptyObj(meta);
283
+ return meta && !(0, common_1.isEmptyObj)(meta);
284
284
  });
285
285
  }
286
- if (utils_1.isPlainObject(rulesValue.value)) {
287
- if (utils_1.isEmptyObject(rulesValue.value)) {
286
+ if ((0, utils_1.isPlainObject)(rulesValue.value)) {
287
+ if ((0, utils_1.isEmptyObject)(rulesValue.value)) {
288
288
  rulesValue.value = [];
289
289
  }
290
290
  else {
@@ -307,15 +307,15 @@ function addFormItem(comp, key, parent, isOnlySlot = false) {
307
307
  let isShowTitleSlot = false;
308
308
  if (properties) {
309
309
  Object.keys(properties).map((subKey) => {
310
- if (utils_1.isWeAppId(subKey)) {
310
+ if ((0, utils_1.isWeAppId)(subKey)) {
311
311
  delete properties[subKey];
312
312
  }
313
313
  if (subKey === 'label') {
314
314
  const targetLabelSlot = properties[subKey];
315
- utils_1.getComponentChildren(targetLabelSlot).map(([key, item]) => {
315
+ (0, utils_1.getComponentChildren)(targetLabelSlot).map(([key, item]) => {
316
316
  labelText = lodash_1.default.get(item, 'xProps.data.text.value');
317
317
  const cloneItem = lodash_1.default.cloneDeep(item);
318
- index_1.deepParse(cloneItem, key, comp);
318
+ (0, index_1.deepParse)(cloneItem, key, comp);
319
319
  isShowTitleSlot = true;
320
320
  });
321
321
  delete comp.properties.label;
@@ -323,7 +323,7 @@ function addFormItem(comp, key, parent, isOnlySlot = false) {
323
323
  });
324
324
  }
325
325
  const titleSlot = {
326
- [utils_1.getId()]: {
326
+ [(0, utils_1.getId)()]: {
327
327
  xComponent: {
328
328
  moduleName: 'gsd-h5-react',
329
329
  name: 'Text',
@@ -358,7 +358,7 @@ function addFormItem(comp, key, parent, isOnlySlot = false) {
358
358
  if (!parent.xComponent ||
359
359
  (parent.xComponent && parent.xComponent.name !== 'FormItem')) {
360
360
  // add FormItem
361
- const newFormItemId = utils_1.getId();
361
+ const newFormItemId = (0, utils_1.getId)();
362
362
  // @ts-ignore
363
363
  parent.properties[newFormItemId] = {
364
364
  xComponent: {
@@ -420,7 +420,7 @@ function renameRepeatId(json) {
420
420
  for (const i in componentInstances) {
421
421
  const comp = componentInstances[i];
422
422
  if (_compIds[i] && i.startsWith('id')) {
423
- const newId = utils_1.getId();
423
+ const newId = (0, utils_1.getId)();
424
424
  componentInstances[newId] = comp;
425
425
  delete componentInstances[i];
426
426
  }
@@ -439,7 +439,7 @@ function renameRepeatId(json) {
439
439
  keys.forEach((key) => {
440
440
  const _comp = topComp['properties'][key];
441
441
  if (_compIds[key] && key.startsWith('id')) {
442
- const newId = utils_1.getId();
442
+ const newId = (0, utils_1.getId)();
443
443
  topComp['properties'][newId] = _comp;
444
444
  delete topComp['properties'][key];
445
445
  }
@@ -26,12 +26,12 @@ const CompParse = __importStar(require("./parses"));
26
26
  const index_1 = require("../../index");
27
27
  function upgrageToVersion2(app) {
28
28
  if (app.selectedPageId) {
29
- utils_1.init(app);
30
- common_1.renameRepeatId(app);
29
+ (0, utils_1.init)(app);
30
+ (0, common_1.renameRepeatId)(app);
31
31
  parse2V2(app);
32
32
  let str = JSON.stringify(app);
33
33
  let obj = JSON.parse(str.replace(/app\.getPageOptions/g, '(()=>{})').replace(/\\\\n/g, '\\n'));
34
- return index_1.serializePlatformApp(obj, { dependencies: [] });
34
+ return (0, index_1.serializePlatformApp)(obj, { dependencies: [] });
35
35
  }
36
36
  else {
37
37
  return app;
@@ -46,7 +46,7 @@ function parse2V2(json) {
46
46
  findSelectedPage = true;
47
47
  }
48
48
  CompParse.addFormWrapperComp(pageInstance);
49
- if (utils_1.isComplexJSON(json)) {
49
+ if ((0, utils_1.isComplexJSON)(json)) {
50
50
  CompParse.parseComplexComponentInstance(pageInstance);
51
51
  }
52
52
  const { componentInstances } = pageInstance;
@@ -71,10 +71,10 @@ function deepParse(comp, key, parent) {
71
71
  const { xComponent } = comp;
72
72
  if (xComponent) {
73
73
  const { name } = xComponent;
74
- common_1.beforeCommonParse(comp);
74
+ (0, common_1.beforeCommonParse)(comp);
75
75
  const parseFunction = CompParse[`parseGsdKbone${name}`];
76
76
  parseFunction && parseFunction(comp, key, parent);
77
- common_1.afterCommonParse(comp);
77
+ (0, common_1.afterCommonParse)(comp);
78
78
  }
79
79
  else {
80
80
  // 当前为 slot