@cloudbase/cals 1.0.72-alpha.3 → 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.
- package/lib/parser/cals/index.d.ts +7 -0
- package/lib/parser/cals/index.d.ts.map +1 -1
- package/lib/parser/cals/index.js +2 -74
- package/lib/parser/cals/utils/block/index.d.ts +10 -3
- package/lib/parser/cals/utils/block/index.d.ts.map +1 -1
- package/lib/parser/cals/utils/block/index.js +86 -6
- 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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parser/cals/index.ts"],"names":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C;CAC1B,CA4DA;AAED,wBAAgB,6BAA6B,CAAC,YAAY,GAAE,aAAkB,MAQ7E;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,UAWvD;AAED,wBAAgB,+BAA+B,CAAC,SAAS,QAAK;;;;;;;;;;;;;;;;;QA4BtD;;;WAGG;;;;;;;EAcV;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,QAAQ,OAchE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,KAAA,GAAG,eAAe,CAiBtD;AAED,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,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,CAAA;CAAE,GAC9D,YAAY,GAAG,eAAe,CAehC;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,CA8ChC"}
|
package/lib/parser/cals/index.js
CHANGED
|
@@ -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
|
-
}
|
|
@@ -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:
|
|
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(
|
|
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;
|
|
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;AAKxG,OAAO,EAAE,eAAe,EAAsD,MAAM,+BAA+B,CAAC;AAOpH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,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,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,kBAAkB,GAAG,aAAa,CAyD9F;AA+GD,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,qBAAqB,GAAG;IAAE,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAClH,UAAU,EAAE,kBAAkB,EAAE,GAC/B,kBAAkB,EAAE,CAmBtB;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,aAAa,CAAC,EAAE;QACd,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;KAC5C,CAAC;CACH;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,EAAE,IAAI,EAAE,cAAc,EAAE,gBA+E/F;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,qBAAqB,GAAG;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,EAC1D,SAAS,EAAE,kBAAkB,OA8C9B;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,qBAAqB,EAAE,SAAS,KAAA,OA2B/E"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
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(),
|
|
@@ -197,7 +209,7 @@ function mergeCals(list) {
|
|
|
197
209
|
return;
|
|
198
210
|
}
|
|
199
211
|
const namespace = (0, get_component_namespace_1.getComponentNamespace)(item.component);
|
|
200
|
-
visitedContext.existing.
|
|
212
|
+
visitedContext.existing.add(namespace, item.id);
|
|
201
213
|
return item;
|
|
202
214
|
});
|
|
203
215
|
}
|
|
@@ -208,7 +220,7 @@ function mergeCals(list) {
|
|
|
208
220
|
for (const { cals } of clonedCalsList) {
|
|
209
221
|
const page = cals.items[0];
|
|
210
222
|
const { componentIdMap } = (0, remap_component_ids_1.remapComponentIds)(page.items, visitedContext);
|
|
211
|
-
page.items = regenBlockTemplateComponents({ visiting: visitedContext, componentIdMap }, page.items);
|
|
223
|
+
page.items = regenBlockTemplateComponents({ visiting: visitedContext, componentIdMap, blockTemplateMap: ctx.blockTemplateMap }, page.items);
|
|
212
224
|
// 应用资源更新 ID
|
|
213
225
|
cals.resources = (_a = cals.resources) === null || _a === void 0 ? void 0 : _a.map((resource) => (0, renew_id_in_resource_1.renewIdInResource)(resource, componentIdMap));
|
|
214
226
|
// 页面资源更新 ID
|
|
@@ -228,3 +240,71 @@ function mergeCals(list) {
|
|
|
228
240
|
return mergedCals;
|
|
229
241
|
}
|
|
230
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
|
+
}
|