@cloudbase/cals 1.0.72-alpha.3 → 1.0.72-alpha.5

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.
@@ -4,6 +4,7 @@ IPlatformDataSource, IDependencies, LCDS } from '../../types';
4
4
  import { IDynamicValue, PropBindType } from '../expression';
5
5
  import { IEventFlow } from '../../types/platform/eventFlow';
6
6
  import { IHandler, IPlatformSubApp, IPlatformComponentExtra } from '../../utils';
7
+ import { IVisitedContext } from './utils/block/helpers/remap-component-ids';
7
8
  export { getUsedComps, generateCustomLoginConfigPathname } from './utils/common';
8
9
  export { generateDefaultCode } from './utils/template';
9
10
  interface IDeserializeContext {
@@ -508,6 +509,12 @@ export declare function generateHandlerParamsDynamicMap(handler: IHandler): any;
508
509
  * 仅保留子包自身数据
509
510
  */
510
511
  export declare function streamlineSubApp(cals: any): IPlatformSubApp;
512
+ export interface ICalsReferenceContext {
513
+ blockTemplateMap: Record<string, any>;
514
+ referenceMap?: Record<string, boolean>;
515
+ strict?: boolean;
516
+ visiting?: IVisitedContext;
517
+ }
511
518
  /**
512
519
  * 还原引用
513
520
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parser/cals/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAuC,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEvH,OAAO,EACL,WAAW,EACX,YAAY,EAGZ,cAAc,EACd,kBAAkB,EAElB,mBAAmB,EACnB,cAAc,EAAE,cAAc;AAC9B,mBAAmB,EACnB,aAAa,EACb,IAAI,EAEL,MAAM,aAAa,CAAC;AAErB,OAAO,EAAkC,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAe5F,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,eAAe,EACf,uBAAuB,EAIxB,MAAM,aAAa,CAAC;AAMrB,OAA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;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,YAAY,GAAG,eAAe,EACpC,OAAO,EAAE;IAAE,cAAc,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAChF,YAAY,GAAG,eAAe,CA6ChC"}
@@ -21,7 +21,6 @@ const unset_1 = __importDefault(require("lodash/unset"));
21
21
  const set_1 = __importDefault(require("lodash/set"));
22
22
  const isArray_1 = __importDefault(require("lodash/isArray"));
23
23
  const isObject_1 = __importDefault(require("lodash/isObject"));
24
- const isEqual_1 = __importDefault(require("lodash/isEqual"));
25
24
  const common_1 = require("../../types/platform/common");
26
25
  const expression_1 = require("../expression");
27
26
  const common_2 = require("./utils/common");
@@ -1520,45 +1519,11 @@ function collapseCalsReference(cals, options) {
1520
1519
  };
1521
1520
  const res = Object.assign(Object.assign({}, cals), { items: (_a = cals.items) === null || _a === void 0 ? void 0 : _a.map((page) => {
1522
1521
  var _a;
1523
- return Object.assign(Object.assign({}, page), { items: (_a = page.items) === null || _a === void 0 ? void 0 : _a.map((component) => collapseComponentReference(ctx, component)) });
1522
+ return Object.assign(Object.assign({}, page), { items: (_a = page.items) === null || _a === void 0 ? void 0 : _a.map((component) => (0, index_1.collapseComponentReference)(ctx, component)) });
1524
1523
  }) });
1525
1524
  return res;
1526
1525
  }
1527
1526
  exports.collapseCalsReference = collapseCalsReference;
1528
- function collapseComponentReference(ctx, component) {
1529
- var _a, _b, _c;
1530
- const { extra, attributes = {}, ':style': styleBind, ':class': classBind } = component;
1531
- const { blockTemplateMap } = ctx;
1532
- const _d = extra || {}, { ref, anchored, refAttributes } = _d, restExtra = __rest(_d, ["ref", "anchored", "refAttributes"]);
1533
- if (ref && blockTemplateMap[ref]) {
1534
- const processed = {};
1535
- const blockContent = (_c = (_b = (_a = blockTemplateMap[ref].items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c[0];
1536
- restExtra.ref = ref;
1537
- processed.attributes = filterMap(attributes, refAttributes);
1538
- if (styleBind !== blockContent[':style']) {
1539
- processed[':style'] = styleBind;
1540
- }
1541
- if (classBind !== blockContent[':class']) {
1542
- processed[':class'] = classBind;
1543
- }
1544
- processed.extra = filterMap(restExtra, blockContent === null || blockContent === void 0 ? void 0 : blockContent.extra);
1545
- return processed;
1546
- }
1547
- else {
1548
- const _e = (component === null || component === void 0 ? void 0 : component.extra) || {}, { ref, refAttributes } = _e, rest = __rest(_e, ["ref", "refAttributes"]);
1549
- return Object.assign(Object.assign({}, component), { extra: (component === null || component === void 0 ? void 0 : component.extra) ? rest : component === null || component === void 0 ? void 0 : component.extra });
1550
- }
1551
- }
1552
- function filterMap(current = {}, base = {}) {
1553
- const filtered = {};
1554
- Object.entries(current).forEach(([key, value]) => {
1555
- // todo: 变量绑定key与非绑定key应为相同key
1556
- if (!(0, isEqual_1.default)(base[key], value)) {
1557
- filtered[key] = value;
1558
- }
1559
- });
1560
- return filtered;
1561
- }
1562
1527
  /**
1563
1528
  * 展开引用
1564
1529
  */
@@ -1588,54 +1553,16 @@ function expandCalsReference(cals, options) {
1588
1553
  const { untilNow, existing } = ctx.visiting;
1589
1554
  const namespace = (0, get_component_namespace_1.getComponentNamespace)(componentName);
1590
1555
  if (index === 0) {
1591
- untilNow.add(namespace, id);
1556
+ untilNow.add(namespace, component.id);
1592
1557
  }
1593
1558
  existing.add(namespace, component.id);
1594
1559
  }
1595
- return component;
1596
1560
  });
1597
1561
  });
1598
1562
  });
1599
1563
  return Object.assign(Object.assign({}, cals), { items: (_a = cals.items) === null || _a === void 0 ? void 0 : _a.map((page) => {
1600
1564
  var _a, _b;
1601
- return Object.assign(Object.assign({}, page), { items: (_b = (_a = page.items) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (component) => expandComponentReference(ctx, component)) });
1565
+ return Object.assign(Object.assign({}, page), { items: (_b = (_a = page.items) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (component) => (0, index_1.expandComponentReference)(ctx, component)) });
1602
1566
  }) });
1603
1567
  }
1604
1568
  exports.expandCalsReference = expandCalsReference;
1605
- function expandComponentReference(ctx, component) {
1606
- var _a, _b, _c, _d, _e, _f;
1607
- const { blockTemplateMap, strict } = ctx;
1608
- const { extra = {}, id, component: componentName } = component;
1609
- const { ref } = extra;
1610
- if (ref) {
1611
- if (blockTemplateMap[ref]) {
1612
- if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.referenceMap) === null || _a === void 0 ? void 0 : _a[ref]) {
1613
- if (strict) {
1614
- throw new Error(`存在循环引用:${ref}`);
1615
- }
1616
- else {
1617
- return undefined;
1618
- }
1619
- }
1620
- const blockContent = expandComponentReference(Object.assign(Object.assign({}, ctx), { referenceMap: Object.assign(Object.assign({}, ctx.referenceMap), { [ref]: true }) }),
1621
- /**
1622
- * 先根遍历
1623
- * 先安装当前的区块,不展开,接着展开安装子级别区块
1624
- */
1625
- (_d = (0, index_1.regenBlockTemplateComponents)(ctx, (_c = (_b = blockTemplateMap[ref].items) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.items)) === null || _d === void 0 ? void 0 : _d[0]);
1626
- const { attributes: blockAttributes = {} } = blockContent;
1627
- return Object.assign(Object.assign({}, blockContent), {
1628
- // todo: 这里合并有问题,无法简单的合并
1629
- attributes: Object.assign(Object.assign({}, blockAttributes), component.attributes), ':style': component[':style'] || blockContent[':style'], ':class': component[':class'] || blockContent[':class'], extra: Object.assign(Object.assign({}, blockContent.extra), { refAttributes: Object.keys(blockAttributes) ? blockAttributes : undefined, ref }) });
1630
- }
1631
- else {
1632
- if (strict) {
1633
- throw new Error(`未找到引用:${ref}`);
1634
- }
1635
- else {
1636
- return undefined;
1637
- }
1638
- }
1639
- }
1640
- return Object.assign(Object.assign({}, component), { items: (_f = (_e = component.items) === null || _e === void 0 ? void 0 : _e.map) === null || _f === void 0 ? void 0 : _f.call(_e, (item) => expandComponentReference(ctx, item)) });
1641
- }
@@ -1 +1 @@
1
- {"version":3,"file":"remap-component-ids.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/remap-component-ids.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,aAAK,kBAAkB,GAAG,MAAM,CAAC;AACjC,aAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,EAAE,UAAU,CAAC;IAErB,wCAAwC;IACxC,QAAQ,EAAE,UAAU,CAAC;CACtB;AAED,qBAAa,UAAU;;;IAMrB,GAAG,CAAC,GAAG,IAAI,OAAA;IAIX,GAAG,CAAC,SAAS,EAAE,kBAAkB;IAGjC,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,EAAE,EAAE,WAAW;IAOlD,IAAI,IAAI,WAEP;CACF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAAE,cAAc,EAAE,eAAe;;EAkClG;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE;IAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,SAAS,EAAE,kBAAkB,OAoD9G"}
1
+ {"version":3,"file":"remap-component-ids.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/remap-component-ids.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,aAAK,kBAAkB,GAAG,MAAM,CAAC;AACjC,aAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,EAAE,UAAU,CAAC;IAErB,wCAAwC;IACxC,QAAQ,EAAE,UAAU,CAAC;CACtB;AAED,qBAAa,UAAU;;;IAMrB,GAAG,CAAC,GAAG,IAAI,OAAA;IAIX,GAAG,CAAC,SAAS,EAAE,kBAAkB;IAGjC,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,EAAE,EAAE,WAAW;IAOlD,IAAI,IAAI,WAEP;CACF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAAE,cAAc,EAAE,eAAe;;EAiClG;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE;IAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,SAAS,EAAE,kBAAkB,OAoD9G"}
@@ -53,7 +53,7 @@ function remapComponentIds(components, visitedContext) {
53
53
  const componentIdMap = new Map();
54
54
  (0, common_1.walkThroughComponents)(components, (item) => {
55
55
  if (!item.component || typeof item.component !== 'string') {
56
- return item;
56
+ return;
57
57
  }
58
58
  const namespace = (0, get_component_namespace_1.getComponentNamespace)(item.component);
59
59
  if (untilNow.has(item.id)) {
@@ -70,7 +70,6 @@ function remapComponentIds(components, visitedContext) {
70
70
  for (const target of [existing, untilNow]) {
71
71
  target.add(namespace, item.id);
72
72
  }
73
- return item;
74
73
  });
75
74
  return { componentIdMap };
76
75
  }
@@ -1,5 +1,6 @@
1
1
  import { IPlatformApp, IPlatformComponent } from '../../../../types';
2
2
  import { IVisitedContext } from './helpers/remap-component-ids';
3
+ import { ICalsReferenceContext } from '../../../../utils';
3
4
  export { renewIdInResource } from './helpers/renew-id-in-resource';
4
5
  export { remapComponentIds, refreshComponentIds } from './helpers/remap-component-ids';
5
6
  export { VisitedMap } from './helpers/remap-component-ids';
@@ -15,8 +16,8 @@ interface IParseContext {
15
16
  componentLibMap: Record<string, any>;
16
17
  }
17
18
  export declare function parseComponentCals(ctx: IParseContext, cals: IPlatformComponent): IParseContext;
18
- export declare function regenBlockTemplateComponents(ctx: {
19
- visiting: IVisitedContext;
19
+ export declare function regenBlockTemplateComponents(ctx: ICalsReferenceContext & {
20
+ visiting: ICalsReferenceContext['visiting'];
20
21
  componentIdMap?: Map<string, string>;
21
22
  }, components: IPlatformComponent[]): IPlatformComponent[];
22
23
  interface IMergeCalsMeta {
@@ -25,5 +26,11 @@ interface IMergeCalsMeta {
25
26
  mode: 'before' | 'after' | 'head' | 'tail';
26
27
  };
27
28
  }
28
- export declare function mergeCals(list: IMergeCalsMeta[]): IPlatformApp;
29
+ export declare function mergeCals(ctx: {
30
+ blockTemplateMap: Record<string, any>;
31
+ }, list: IMergeCalsMeta[]): IPlatformApp;
32
+ export declare function expandComponentReference(ctx: ICalsReferenceContext & {
33
+ visiting: IVisitedContext;
34
+ }, component: IPlatformComponent): any;
35
+ export declare function collapseComponentReference(ctx: ICalsReferenceContext, component: any): any;
29
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/parser/cals/utils/block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAqC,MAAM,mBAAmB,CAAC;AAIxG,OAAO,EAAE,eAAe,EAAsD,MAAM,+BAA+B,CAAC;AAQpH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE;QACV,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA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+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mergeCals = exports.regenBlockTemplateComponents = exports.parseComponentCals = exports.VisitedMap = exports.refreshComponentIds = exports.remapComponentIds = exports.renewIdInResource = void 0;
17
+ exports.collapseComponentReference = exports.expandComponentReference = exports.mergeCals = exports.regenBlockTemplateComponents = exports.parseComponentCals = exports.VisitedMap = exports.refreshComponentIds = exports.remapComponentIds = exports.renewIdInResource = void 0;
7
18
  const get_1 = __importDefault(require("lodash/get"));
8
19
  const set_1 = __importDefault(require("lodash/set"));
20
+ const isEqual_1 = __importDefault(require("lodash/isEqual"));
9
21
  const expression_1 = require("../../../expression");
10
22
  const remap_component_ids_1 = require("./helpers/remap-component-ids");
11
23
  const common_1 = require("../common");
@@ -164,18 +176,18 @@ function parseValueCals(ctx, value) {
164
176
  }
165
177
  }
166
178
  function regenBlockTemplateComponents(ctx, components) {
167
- let { componentIdMap } = ctx;
179
+ let { componentIdMap } = ctx, restContext = __rest(ctx, ["componentIdMap"]);
168
180
  if (!componentIdMap) {
169
181
  componentIdMap = (0, remap_component_ids_1.remapComponentIds)(components, ctx.visiting).componentIdMap;
170
182
  }
171
183
  return components.map((component) => {
172
184
  const processed = (0, remap_component_ids_1.refreshComponentIds)({ componentIdMap }, component);
173
185
  // todo: 需要处理extra.dataForm
174
- return Object.assign(Object.assign({}, processed), { extra: Object.assign(Object.assign({}, processed.extra), { xIndex: undefined, anchored: true }) });
186
+ return expandComponentReference(restContext, Object.assign(Object.assign({}, processed), { extra: Object.assign(Object.assign({}, processed.extra), { xIndex: undefined, anchored: true }) }));
175
187
  });
176
188
  }
177
189
  exports.regenBlockTemplateComponents = regenBlockTemplateComponents;
178
- function mergeCals(list) {
190
+ function mergeCals(ctx, list) {
179
191
  var _a, _b;
180
192
  const visitedContext = {
181
193
  existing: new remap_component_ids_1.VisitedMap(),
@@ -190,15 +202,14 @@ function mergeCals(list) {
190
202
  }
191
203
  // 区块只有一个页面
192
204
  const page = cals.items[0];
193
- page.items = (0, common_1.walkThroughComponents)(page.items, (item) => {
205
+ (0, common_1.walkThroughComponents)(page.items, (item) => {
194
206
  var _a;
195
207
  (_a = item.extra) === null || _a === void 0 ? true : delete _a.xIndex;
196
208
  if (!item.component || typeof item.component !== 'string') {
197
209
  return;
198
210
  }
199
211
  const namespace = (0, get_component_namespace_1.getComponentNamespace)(item.component);
200
- visitedContext.existing.get(namespace).add(namespace, item.id);
201
- return item;
212
+ visitedContext.existing.add(namespace, item.id);
202
213
  });
203
214
  }
204
215
  /**
@@ -208,7 +219,7 @@ function mergeCals(list) {
208
219
  for (const { cals } of clonedCalsList) {
209
220
  const page = cals.items[0];
210
221
  const { componentIdMap } = (0, remap_component_ids_1.remapComponentIds)(page.items, visitedContext);
211
- page.items = regenBlockTemplateComponents({ visiting: visitedContext, componentIdMap }, page.items);
222
+ page.items = regenBlockTemplateComponents({ visiting: visitedContext, componentIdMap, blockTemplateMap: ctx.blockTemplateMap }, page.items);
212
223
  // 应用资源更新 ID
213
224
  cals.resources = (_a = cals.resources) === null || _a === void 0 ? void 0 : _a.map((resource) => (0, renew_id_in_resource_1.renewIdInResource)(resource, componentIdMap));
214
225
  // 页面资源更新 ID
@@ -228,3 +239,71 @@ function mergeCals(list) {
228
239
  return mergedCals;
229
240
  }
230
241
  exports.mergeCals = mergeCals;
242
+ function expandComponentReference(ctx, component) {
243
+ var _a, _b, _c, _d, _e, _f;
244
+ const { blockTemplateMap, strict } = ctx;
245
+ const { extra = {}, id, component: componentName } = component;
246
+ const { ref } = extra;
247
+ if (ref) {
248
+ if (blockTemplateMap[ref]) {
249
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.referenceMap) === null || _a === void 0 ? void 0 : _a[ref]) {
250
+ if (strict) {
251
+ throw new Error(`存在循环引用:${ref}`);
252
+ }
253
+ else {
254
+ return undefined;
255
+ }
256
+ }
257
+ const blockContent = (_d = regenBlockTemplateComponents(Object.assign(Object.assign({}, ctx), { referenceMap: Object.assign(Object.assign({}, ctx.referenceMap), { [ref]: true }) }), (_c = (_b = blockTemplateMap[ref].items) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.items)) === null || _d === void 0 ? void 0 : _d[0];
258
+ const { attributes: blockAttributes = {} } = blockContent;
259
+ return Object.assign(Object.assign({}, blockContent), {
260
+ // todo: 这里合并有问题,无法简单的合并
261
+ attributes: Object.assign(Object.assign({}, blockAttributes), component.attributes), ':style': component[':style'] || blockContent[':style'], ':class': component[':class'] || blockContent[':class'], extra: Object.assign(Object.assign({}, blockContent.extra), { refAttributes: Object.keys(blockAttributes) ? blockAttributes : undefined, ref }) });
262
+ }
263
+ else {
264
+ if (strict) {
265
+ throw new Error(`未找到引用:${ref}`);
266
+ }
267
+ else {
268
+ return undefined;
269
+ }
270
+ }
271
+ }
272
+ return Object.assign(Object.assign({}, component), { items: (_f = (_e = component.items) === null || _e === void 0 ? void 0 : _e.map) === null || _f === void 0 ? void 0 : _f.call(_e, (item) => expandComponentReference(ctx, item)) });
273
+ }
274
+ exports.expandComponentReference = expandComponentReference;
275
+ function collapseComponentReference(ctx, component) {
276
+ var _a, _b, _c;
277
+ const { extra, attributes = {}, ':style': styleBind, ':class': classBind } = component;
278
+ const { blockTemplateMap } = ctx;
279
+ const _d = extra || {}, { ref, anchored, refAttributes } = _d, restExtra = __rest(_d, ["ref", "anchored", "refAttributes"]);
280
+ if (ref && blockTemplateMap[ref]) {
281
+ const processed = {};
282
+ const blockContent = (_c = (_b = (_a = blockTemplateMap[ref].items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c[0];
283
+ restExtra.ref = ref;
284
+ processed.attributes = filterMap(attributes, refAttributes);
285
+ if (styleBind !== blockContent[':style']) {
286
+ processed[':style'] = styleBind;
287
+ }
288
+ if (classBind !== blockContent[':class']) {
289
+ processed[':class'] = classBind;
290
+ }
291
+ processed.extra = filterMap(restExtra, blockContent === null || blockContent === void 0 ? void 0 : blockContent.extra);
292
+ return processed;
293
+ }
294
+ else {
295
+ const _e = (component === null || component === void 0 ? void 0 : component.extra) || {}, { ref, refAttributes } = _e, rest = __rest(_e, ["ref", "refAttributes"]);
296
+ return Object.assign(Object.assign({}, component), { extra: (component === null || component === void 0 ? void 0 : component.extra) ? rest : component === null || component === void 0 ? void 0 : component.extra });
297
+ }
298
+ }
299
+ exports.collapseComponentReference = collapseComponentReference;
300
+ function filterMap(current = {}, base = {}) {
301
+ const filtered = {};
302
+ Object.entries(current).forEach(([key, value]) => {
303
+ // todo: 变量绑定key与非绑定key应为相同key
304
+ if (!(0, isEqual_1.default)(base[key], value)) {
305
+ filtered[key] = value;
306
+ }
307
+ });
308
+ return filtered;
309
+ }
@@ -22,7 +22,7 @@ export declare function generateCustomLoginConfigPathname({ appId, version }: {
22
22
  appId: string;
23
23
  version: string;
24
24
  }): string;
25
- export declare function walkThroughComponents(components: IPlatformComponent[], visit: any): any[];
25
+ export declare function walkThroughComponents(components: IPlatformComponent[], visit: any): void;
26
26
  export declare const DYNAMIC_KEY_REG: RegExp;
27
27
  export {};
28
28
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/parser/cals/utils/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,E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EAAE,MAAM,gBAAgB,CAAC;AAEnG,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAsBnD,aAAK,uBAAuB,GAAG;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AAOlE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,UAAQ,UAQ5D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,WAErC;AAED,eAAO,MAAM,UAAU,QAAS,MAAM,YAUrC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,WAQpD;AAED,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,SAAS,WAQpE;AAyJD,wBAAgB,YAAY,CAE1B,IAAI,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAExC,YAAY,EAAE,GAAG,EAAE,EACnB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB,GACA,uBAAuB,GAAG;IAAE,SAAS,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,CA+EvG;AAED,wBAAgB,iCAAiC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,UASvG;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,kBAAkB,EAAO,EAAE,KAAK,KAAA,QAKjF;AAED,eAAO,MAAM,eAAe,QAAY,CAAC"}
@@ -276,15 +276,10 @@ function generateCustomLoginConfigPathname({ appId, version }) {
276
276
  }
277
277
  exports.generateCustomLoginConfigPathname = generateCustomLoginConfigPathname;
278
278
  function walkThroughComponents(components = [], visit) {
279
- return components
280
- .map((component) => {
281
- const visiteComponent = visit(component);
282
- if (visiteComponent.items) {
283
- visiteComponent.items = walkThroughComponents(visiteComponent.items || [], visit);
284
- }
285
- return visiteComponent;
286
- })
287
- .filter((item) => !!item);
279
+ components.forEach((component) => {
280
+ visit(component);
281
+ walkThroughComponents(component.items || [], visit);
282
+ });
288
283
  }
289
284
  exports.walkThroughComponents = walkThroughComponents;
290
285
  exports.DYNAMIC_KEY_REG = /^:(.*)$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cals",
3
- "version": "1.0.72-alpha.3",
3
+ "version": "1.0.72-alpha.5",
4
4
  "description": "Common application specifications",
5
5
  "main": "lib/utils/index.js",
6
6
  "source": "src/utils/index.ts",