@cloudbase/cals 1.0.72-alpha.2 → 1.0.72-alpha.4

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.
Files changed (26) hide show
  1. package/lib/parser/cals/index.d.ts +7 -0
  2. package/lib/parser/cals/index.d.ts.map +1 -1
  3. package/lib/parser/cals/index.js +2 -74
  4. package/lib/parser/cals/utils/block/helpers/merge-dataset.d.ts +6 -0
  5. package/lib/parser/cals/utils/block/helpers/merge-dataset.d.ts.map +1 -0
  6. package/lib/parser/cals/utils/block/helpers/merge-dataset.js +17 -0
  7. package/lib/parser/cals/utils/block/helpers/merge-listeners.d.ts +6 -0
  8. package/lib/parser/cals/utils/block/helpers/merge-listeners.d.ts.map +1 -0
  9. package/lib/parser/cals/utils/block/helpers/merge-listeners.js +14 -0
  10. package/lib/parser/cals/utils/block/helpers/merge-resources.d.ts +6 -0
  11. package/lib/parser/cals/utils/block/helpers/merge-resources.d.ts.map +1 -0
  12. package/lib/parser/cals/utils/block/helpers/merge-resources.js +29 -0
  13. package/lib/parser/cals/utils/block/helpers/remap-component-ids.d.ts.map +1 -1
  14. package/lib/parser/cals/utils/block/helpers/remap-component-ids.js +0 -1
  15. package/lib/parser/cals/utils/block/helpers/renew-id-in-code.d.ts.map +1 -1
  16. package/lib/parser/cals/utils/block/helpers/renew-id-in-code.js +2 -8
  17. package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts +2 -1
  18. package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts.map +1 -1
  19. package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.js +49 -55
  20. package/lib/parser/cals/utils/block/index.d.ts +18 -3
  21. package/lib/parser/cals/utils/block/index.d.ts.map +1 -1
  22. package/lib/parser/cals/utils/block/index.js +147 -5
  23. package/lib/parser/index.d.ts +1 -1
  24. package/lib/parser/index.d.ts.map +1 -1
  25. package/lib/parser/index.js +2 -1
  26. package/package.json +1 -1
@@ -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,OAAO,EAAE,YAAY,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,UAAU,mBAAmB;IAC3B,GA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AC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAChF,YAAY,GAAG,eAAe,CA8ChC"}
@@ -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
  */
@@ -1598,44 +1563,7 @@ function expandCalsReference(cals, options) {
1598
1563
  });
1599
1564
  return Object.assign(Object.assign({}, cals), { items: (_a = cals.items) === null || _a === void 0 ? void 0 : _a.map((page) => {
1600
1565
  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)) });
1566
+ 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
1567
  }) });
1603
1568
  }
1604
1569
  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
- }
@@ -0,0 +1,6 @@
1
+ import { type IPlatformDataset } from '../../../../../types';
2
+ /**
3
+ * 合并 dataset (如遇同名,保留前者)
4
+ */
5
+ export declare function mergeDataset(first?: IPlatformDataset, second?: IPlatformDataset): IPlatformDataset;
6
+ //# sourceMappingURL=merge-dataset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-dataset.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/merge-dataset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,GAAE,gBAAqB,EAAE,MAAM,GAAE,gBAAqB,oBAYvF"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeDataset = void 0;
4
+ /**
5
+ * 合并 dataset (如遇同名,保留前者)
6
+ */
7
+ function mergeDataset(first = {}, second = {}) {
8
+ const dataset = {};
9
+ for (const key of ['state', 'params', 'query']) {
10
+ const value = Object.assign(Object.assign({}, second[key]), first[key]);
11
+ if (Object.keys(value).length) {
12
+ dataset[key] = value;
13
+ }
14
+ }
15
+ return Object.keys(dataset).length ? dataset : undefined;
16
+ }
17
+ exports.mergeDataset = mergeDataset;
@@ -0,0 +1,6 @@
1
+ import { type IPlatformListener } from '../../../../../types';
2
+ /**
3
+ * 合并监听器 (如遇同名,保留前者)
4
+ */
5
+ export declare function mergeListeners(first?: IPlatformListener[], second?: IPlatformListener[]): IPlatformListener[];
6
+ //# sourceMappingURL=merge-listeners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-listeners.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/merge-listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,GAAE,iBAAiB,EAAO,EAAE,MAAM,GAAE,iBAAiB,EAAO,uBAQ/F"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeListeners = void 0;
4
+ /**
5
+ * 合并监听器 (如遇同名,保留前者)
6
+ */
7
+ function mergeListeners(first = [], second = []) {
8
+ const listenerMap = new Map();
9
+ for (const listener of [...second, ...first]) {
10
+ listenerMap.set(listener.id, listener);
11
+ }
12
+ return listenerMap.size > 0 ? [...listenerMap.values()] : undefined;
13
+ }
14
+ exports.mergeListeners = mergeListeners;
@@ -0,0 +1,6 @@
1
+ import { type ICodeResource } from '../../../../../types';
2
+ /**
3
+ * 合并代码资源 (如遇同名,保留前者)
4
+ */
5
+ export declare function mergeResources(first?: ICodeResource[], second?: ICodeResource[]): ICodeResource[];
6
+ //# sourceMappingURL=merge-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-resources.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/merge-resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,GAAE,aAAa,EAAO,EAAE,MAAM,GAAE,aAAa,EAAO,mBAwBvF"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeResources = void 0;
4
+ const types_1 = require("../../../../../types");
5
+ /**
6
+ * 合并代码资源 (如遇同名,保留前者)
7
+ */
8
+ function mergeResources(first = [], second = []) {
9
+ const resourceMap = new Map();
10
+ for (const resource of first) {
11
+ const { codeType, name } = resource;
12
+ const key = `${codeType}/${name}`;
13
+ resourceMap.set(key, resource);
14
+ }
15
+ for (const resource of second) {
16
+ const { codeType, name } = resource;
17
+ const key = `${codeType}/${name}`;
18
+ if (!resourceMap.has(key)) {
19
+ resourceMap.set(key, resource);
20
+ }
21
+ else if (codeType === types_1.ECodeType.STYLE) {
22
+ // 合并样式内容
23
+ const existResource = resourceMap.get(key);
24
+ existResource.code = [existResource.code, resource.code].join('\n');
25
+ }
26
+ }
27
+ return resourceMap.size > 0 ? [...resourceMap.values()] : undefined;
28
+ }
29
+ exports.mergeResources = mergeResources;
@@ -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;;EAmClG;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;;EAkClG;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE;IAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,SAAS,EAAE,kBAAkB,OAoD9G"}
@@ -56,7 +56,6 @@ function remapComponentIds(components, visitedContext) {
56
56
  return item;
57
57
  }
58
58
  const namespace = (0, get_component_namespace_1.getComponentNamespace)(item.component);
59
- console.log('>>>>>untilNow', item.id);
60
59
  if (untilNow.has(item.id)) {
61
60
  let nextCodeId = `${namespace}1`;
62
61
  let seq = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"renew-id-in-code.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/renew-id-in-code.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAS9E"}
1
+ {"version":3,"file":"renew-id-in-code.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/renew-id-in-code.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAE9E"}
@@ -1,19 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renewIdInCode = void 0;
4
- const resolve_new_id_1 = require("./resolve-new-id");
4
+ const renew_id_in_expr_1 = require("./renew-id-in-expr");
5
5
  /**
6
6
  * 按需将代码中引用的组件旧 ID 更新为新 ID
7
7
  * @param expr 表达式
8
8
  * @param componentIdMap 映射: 组件原始 ID => 新生成 ID
9
9
  */
10
10
  function renewIdInCode(code, componentIdMap) {
11
- return code.replace(/(\$w\.)(\w+)/g, (match, p1, p2) => {
12
- const newId = (0, resolve_new_id_1.resolveNewId)(p2, componentIdMap);
13
- if (newId) {
14
- return `${p1}${newId}`;
15
- }
16
- return match;
17
- });
11
+ return (0, renew_id_in_expr_1.renewIdWithRegexp)(code, componentIdMap);
18
12
  }
19
13
  exports.renewIdInCode = renewIdInCode;
@@ -3,5 +3,6 @@
3
3
  * @param expr 表达式
4
4
  * @param componentIdMap 映射: 组件原始 ID => 新生成 ID
5
5
  */
6
- export declare function renewIdInExpr(expr: string, componentIdMap: Map<string, string>): any;
6
+ export declare function renewIdInExpr(expr: string, componentIdMap: Map<string, string>): string;
7
+ export declare function renewIdWithRegexp(str: string, componentIdMap: Map<string, string>): string;
7
8
  //# sourceMappingURL=renew-id-in-expr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renew-id-in-expr.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/renew-id-in-expr.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OAwC9E"}
1
+ {"version":3,"file":"renew-id-in-expr.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/cals/utils/block/helpers/renew-id-in-expr.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UA0C9E;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAejF"}
@@ -1,30 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.renewIdInExpr = void 0;
27
- const Babel = __importStar(require("@babel/standalone"));
3
+ exports.renewIdWithRegexp = exports.renewIdInExpr = void 0;
4
+ // import * as Babel from '@babel/standalone';
28
5
  const resolve_new_id_1 = require("./resolve-new-id");
29
6
  /**
30
7
  * 按需将表达式中引用的组件旧 ID 更新为新 ID
@@ -35,35 +12,52 @@ function renewIdInExpr(expr, componentIdMap) {
35
12
  if (typeof expr !== 'string' || expr.length === 0 || !expr.includes('$w')) {
36
13
  return expr;
37
14
  }
38
- const output = Babel.transform(expr, {
39
- plugins: [
40
- ({ types: t }) => {
41
- return {
42
- visitor: {
43
- MemberExpression({ node }) {
44
- const { object, property } = node;
45
- if (object.name === '$w') {
46
- const newId = (0, resolve_new_id_1.resolveNewId)(property.name || '', componentIdMap);
47
- if (newId) {
48
- node.property = t.identifier(newId);
49
- }
50
- }
51
- },
52
- },
53
- };
54
- },
55
- ],
56
- });
57
- let code = output.code.replace(/;\s$/, '');
58
- // code wrapped in `()`
59
- // TODO: 是否有必要?
60
- {
61
- const match = code.match(/^\((.*?)\)$/);
62
- if (match === null || match === void 0 ? void 0 : match[1]) {
63
- // eslint-disable-next-line prefer-destructuring
64
- code = match[1];
65
- }
66
- }
67
- return code;
15
+ return renewIdWithRegexp(expr, componentIdMap);
16
+ // const output = Babel.transform(expr, {
17
+ // plugins: [
18
+ // ({ types: t }) => {
19
+ // return {
20
+ // visitor: {
21
+ // MemberExpression({ node }) {
22
+ // const { object, property } = node;
23
+ // if (object.name === '$w') {
24
+ // const newId = resolveNewId(property.name || '', componentIdMap);
25
+ // if (newId) {
26
+ // node.property = t.identifier(newId);
27
+ // }
28
+ // }
29
+ // },
30
+ // },
31
+ // };
32
+ // },
33
+ // ],
34
+ // });
35
+ // let code = output.code.replace(/;\s$/, '');
36
+ // // code wrapped in `()`
37
+ // // TODO: 是否有必要?
38
+ // {
39
+ // const match = code.match(/^\((.*?)\)$/);
40
+ // if (match?.[1]) {
41
+ // // eslint-disable-next-line prefer-destructuring
42
+ // code = match[1];
43
+ // }
44
+ // }
45
+ // return code;
68
46
  }
69
47
  exports.renewIdInExpr = renewIdInExpr;
48
+ function renewIdWithRegexp(str, componentIdMap) {
49
+ return str.replace(/(\$w\.)(\w+)/g, (match, p1, p2, offset) => {
50
+ const before = str[offset - 1];
51
+ const newId = (0, resolve_new_id_1.resolveNewId)(p2, componentIdMap);
52
+ /**
53
+ * 前向匹配
54
+ * 前一个字符存在,且前一个字符费变量安全字 a-z、A-Z、0-9、_、$起始
55
+ * 且前一字符非 . 表示成员访问
56
+ */
57
+ if (newId && !(before && /[a-zA-Z0-9_$.]/.test(before))) {
58
+ return `${p1}${newId}`;
59
+ }
60
+ return match;
61
+ });
62
+ }
63
+ exports.renewIdWithRegexp = renewIdWithRegexp;
@@ -1,5 +1,6 @@
1
- import { IPlatformComponent } from '../../../../types';
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,7 +16,21 @@ 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'];
21
+ componentIdMap?: Map<string, string>;
20
22
  }, components: IPlatformComponent[]): IPlatformComponent[];
23
+ interface IMergeCalsMeta {
24
+ cals: IPlatformApp;
25
+ targetOptions?: {
26
+ mode: 'before' | 'after' | 'head' | 'tail';
27
+ };
28
+ }
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;
21
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,kBAAkB,EAAqB,MAAM,mBAAmB,CAAC;AAI1E,OAAO,EAAE,eAAe,EAA0C,MAAM,+BAA+B,CAAC;AAExG,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;QAC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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.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
- var renew_id_in_resource_1 = require("./helpers/renew-id-in-resource");
12
- Object.defineProperty(exports, "renewIdInResource", { enumerable: true, get: function () { return renew_id_in_resource_1.renewIdInResource; } });
23
+ const common_1 = require("../common");
24
+ const get_component_namespace_1 = require("./helpers/get-component-namespace");
25
+ const renew_id_in_resource_1 = require("./helpers/renew-id-in-resource");
26
+ const merge_resources_1 = require("./helpers/merge-resources");
27
+ const merge_dataset_1 = require("./helpers/merge-dataset");
28
+ const merge_listeners_1 = require("./helpers/merge-listeners");
29
+ var renew_id_in_resource_2 = require("./helpers/renew-id-in-resource");
30
+ Object.defineProperty(exports, "renewIdInResource", { enumerable: true, get: function () { return renew_id_in_resource_2.renewIdInResource; } });
13
31
  var remap_component_ids_2 = require("./helpers/remap-component-ids");
14
32
  Object.defineProperty(exports, "remapComponentIds", { enumerable: true, get: function () { return remap_component_ids_2.remapComponentIds; } });
15
33
  Object.defineProperty(exports, "refreshComponentIds", { enumerable: true, get: function () { return remap_component_ids_2.refreshComponentIds; } });
@@ -158,11 +176,135 @@ function parseValueCals(ctx, value) {
158
176
  }
159
177
  }
160
178
  function regenBlockTemplateComponents(ctx, components) {
161
- const { componentIdMap } = (0, remap_component_ids_1.remapComponentIds)(components, ctx.visiting);
179
+ let { componentIdMap } = ctx, restContext = __rest(ctx, ["componentIdMap"]);
180
+ if (!componentIdMap) {
181
+ componentIdMap = (0, remap_component_ids_1.remapComponentIds)(components, ctx.visiting).componentIdMap;
182
+ }
162
183
  return components.map((component) => {
163
184
  const processed = (0, remap_component_ids_1.refreshComponentIds)({ componentIdMap }, component);
164
185
  // todo: 需要处理extra.dataForm
165
- 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 }) }));
166
187
  });
167
188
  }
168
189
  exports.regenBlockTemplateComponents = regenBlockTemplateComponents;
190
+ function mergeCals(ctx, list) {
191
+ var _a, _b;
192
+ const visitedContext = {
193
+ existing: new remap_component_ids_1.VisitedMap(),
194
+ untilNow: new remap_component_ids_1.VisitedMap(),
195
+ };
196
+ // 不修改原始数据
197
+ const clonedCalsList = JSON.parse(JSON.stringify(list));
198
+ // 初始化 `visitedContext.existing` 数据
199
+ for (const { cals } of clonedCalsList) {
200
+ if (cals.items.length > 1) {
201
+ throw new Error('不支持对多页面的 CALS 进行合并');
202
+ }
203
+ // 区块只有一个页面
204
+ const page = cals.items[0];
205
+ page.items = (0, common_1.walkThroughComponents)(page.items, (item) => {
206
+ var _a;
207
+ (_a = item.extra) === null || _a === void 0 ? true : delete _a.xIndex;
208
+ if (!item.component || typeof item.component !== 'string') {
209
+ return;
210
+ }
211
+ const namespace = (0, get_component_namespace_1.getComponentNamespace)(item.component);
212
+ visitedContext.existing.add(namespace, item.id);
213
+ return item;
214
+ });
215
+ }
216
+ /**
217
+ * 根据 `visitedContext` 收集的信息,按需更新组件 ID
218
+ * 组件id是页面隔离的,因此限制约定,只处理 0 号页面
219
+ */
220
+ for (const { cals } of clonedCalsList) {
221
+ const page = cals.items[0];
222
+ const { componentIdMap } = (0, remap_component_ids_1.remapComponentIds)(page.items, visitedContext);
223
+ page.items = regenBlockTemplateComponents({ visiting: visitedContext, componentIdMap, blockTemplateMap: ctx.blockTemplateMap }, page.items);
224
+ // 应用资源更新 ID
225
+ cals.resources = (_a = cals.resources) === null || _a === void 0 ? void 0 : _a.map((resource) => (0, renew_id_in_resource_1.renewIdInResource)(resource, componentIdMap));
226
+ // 页面资源更新 ID
227
+ page.resources = (_b = page.resources) === null || _b === void 0 ? void 0 : _b.map((resource) => (0, renew_id_in_resource_1.renewIdInResource)(resource, componentIdMap));
228
+ }
229
+ const mergedCals = clonedCalsList
230
+ .map((meta) => meta.cals)
231
+ .reduce((first, second) => {
232
+ const firstPage = first.items[0];
233
+ const secondPage = second.items[0];
234
+ const mergedPage = Object.assign(Object.assign(Object.assign({}, secondPage), firstPage), { items: [...firstPage.items, ...secondPage.items], resources: (0, merge_resources_1.mergeResources)(firstPage.resources, secondPage.resources) || [], dataset: (0, merge_dataset_1.mergeDataset)(firstPage.dataset, secondPage.dataset) || {}, listeners: (0, merge_listeners_1.mergeListeners)(firstPage.listeners, secondPage.listeners) });
235
+ if (!mergedPage.listeners) {
236
+ delete mergedPage.listeners;
237
+ }
238
+ return Object.assign(Object.assign(Object.assign({}, second), first), { items: [mergedPage], resources: (0, merge_resources_1.mergeResources)(first.resources, second.resources) || [], dataset: (0, merge_dataset_1.mergeDataset)(first.dataset, second.dataset) || {} });
239
+ });
240
+ return mergedCals;
241
+ }
242
+ exports.mergeCals = mergeCals;
243
+ function expandComponentReference(ctx, component) {
244
+ var _a, _b, _c, _d, _e, _f;
245
+ const { blockTemplateMap, strict } = ctx;
246
+ const { extra = {}, id, component: componentName } = component;
247
+ const { ref } = extra;
248
+ if (ref) {
249
+ if (blockTemplateMap[ref]) {
250
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.referenceMap) === null || _a === void 0 ? void 0 : _a[ref]) {
251
+ if (strict) {
252
+ throw new Error(`存在循环引用:${ref}`);
253
+ }
254
+ else {
255
+ return undefined;
256
+ }
257
+ }
258
+ 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];
259
+ const { attributes: blockAttributes = {} } = blockContent;
260
+ return Object.assign(Object.assign({}, blockContent), {
261
+ // todo: 这里合并有问题,无法简单的合并
262
+ 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 }) });
263
+ }
264
+ else {
265
+ if (strict) {
266
+ throw new Error(`未找到引用:${ref}`);
267
+ }
268
+ else {
269
+ return undefined;
270
+ }
271
+ }
272
+ }
273
+ 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)) });
274
+ }
275
+ exports.expandComponentReference = expandComponentReference;
276
+ function collapseComponentReference(ctx, component) {
277
+ var _a, _b, _c;
278
+ const { extra, attributes = {}, ':style': styleBind, ':class': classBind } = component;
279
+ const { blockTemplateMap } = ctx;
280
+ const _d = extra || {}, { ref, anchored, refAttributes } = _d, restExtra = __rest(_d, ["ref", "anchored", "refAttributes"]);
281
+ if (ref && blockTemplateMap[ref]) {
282
+ const processed = {};
283
+ 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];
284
+ restExtra.ref = ref;
285
+ processed.attributes = filterMap(attributes, refAttributes);
286
+ if (styleBind !== blockContent[':style']) {
287
+ processed[':style'] = styleBind;
288
+ }
289
+ if (classBind !== blockContent[':class']) {
290
+ processed[':class'] = classBind;
291
+ }
292
+ processed.extra = filterMap(restExtra, blockContent === null || blockContent === void 0 ? void 0 : blockContent.extra);
293
+ return processed;
294
+ }
295
+ else {
296
+ const _e = (component === null || component === void 0 ? void 0 : component.extra) || {}, { ref, refAttributes } = _e, rest = __rest(_e, ["ref", "refAttributes"]);
297
+ 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 });
298
+ }
299
+ }
300
+ exports.collapseComponentReference = collapseComponentReference;
301
+ function filterMap(current = {}, base = {}) {
302
+ const filtered = {};
303
+ Object.entries(current).forEach(([key, value]) => {
304
+ // todo: 变量绑定key与非绑定key应为相同key
305
+ if (!(0, isEqual_1.default)(base[key], value)) {
306
+ filtered[key] = value;
307
+ }
308
+ });
309
+ return filtered;
310
+ }
@@ -2,7 +2,7 @@ export * from './cals/index';
2
2
  export { upgrageToVersion2 } from './cals/utils/version';
3
3
  export { processComponentModule } from './cals/utils/spinoff';
4
4
  export { calsToCode, codeToCals, type ICodeItem, checkForConflicts, autoResolveConflicts, findAllConflicts, } from './cals/utils/code';
5
- export { parseComponentCals, regenBlockTemplateComponents, renewIdInResource, VisitedMap, remapComponentIds, refreshComponentIds, } from './cals/utils/block';
5
+ export { parseComponentCals, regenBlockTemplateComponents, renewIdInResource, VisitedMap, remapComponentIds, refreshComponentIds, mergeCals, } from './cals/utils/block';
6
6
  export { ActionType, type IDataBind, PropBindType } from './expression/index';
7
7
  export { processCommonStyle2CSSProperties, processCSSProperties2Rem, processCSSPropertiesUnit, } from './cals/utils/style';
8
8
  export { getUsedResources, getNavUsedStaticResource, _simpleGetUsedResourceOfComponent, } from './cals/utils/getUsedResources';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.DYNAMIC_KEY_REG = exports.walkThroughComponents = exports.Dependencies = exports.PostcssRpx2Calc = exports.getUsedReference = exports._simpleGetUsedResourceOfComponent = exports.getNavUsedStaticResource = exports.getUsedResources = exports.processCSSPropertiesUnit = exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.PropBindType = exports.ActionType = exports.refreshComponentIds = exports.remapComponentIds = exports.VisitedMap = exports.renewIdInResource = exports.regenBlockTemplateComponents = exports.parseComponentCals = exports.findAllConflicts = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
20
+ exports.DYNAMIC_KEY_REG = exports.walkThroughComponents = exports.Dependencies = exports.PostcssRpx2Calc = exports.getUsedReference = exports._simpleGetUsedResourceOfComponent = exports.getNavUsedStaticResource = exports.getUsedResources = exports.processCSSPropertiesUnit = exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.PropBindType = exports.ActionType = exports.mergeCals = exports.refreshComponentIds = exports.remapComponentIds = exports.VisitedMap = exports.renewIdInResource = exports.regenBlockTemplateComponents = exports.parseComponentCals = exports.findAllConflicts = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
21
21
  __exportStar(require("./cals/index"), exports);
22
22
  var version_1 = require("./cals/utils/version");
23
23
  Object.defineProperty(exports, "upgrageToVersion2", { enumerable: true, get: function () { return version_1.upgrageToVersion2; } });
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "renewIdInResource", { enumerable: true, get: fun
36
36
  Object.defineProperty(exports, "VisitedMap", { enumerable: true, get: function () { return block_1.VisitedMap; } });
37
37
  Object.defineProperty(exports, "remapComponentIds", { enumerable: true, get: function () { return block_1.remapComponentIds; } });
38
38
  Object.defineProperty(exports, "refreshComponentIds", { enumerable: true, get: function () { return block_1.refreshComponentIds; } });
39
+ Object.defineProperty(exports, "mergeCals", { enumerable: true, get: function () { return block_1.mergeCals; } });
39
40
  var index_1 = require("./expression/index");
40
41
  Object.defineProperty(exports, "ActionType", { enumerable: true, get: function () { return index_1.ActionType; } });
41
42
  Object.defineProperty(exports, "PropBindType", { enumerable: true, get: function () { return index_1.PropBindType; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cals",
3
- "version": "1.0.72-alpha.2",
3
+ "version": "1.0.72-alpha.4",
4
4
  "description": "Common application specifications",
5
5
  "main": "lib/utils/index.js",
6
6
  "source": "src/utils/index.ts",