@cloudbase/cals 1.0.72-alpha.1 → 1.0.72-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser/cals/index.d.ts +10 -8
- package/lib/parser/cals/index.d.ts.map +1 -1
- package/lib/parser/cals/index.js +9 -81
- package/lib/parser/cals/utils/block/helpers/merge-dataset.d.ts +6 -0
- package/lib/parser/cals/utils/block/helpers/merge-dataset.d.ts.map +1 -0
- package/lib/parser/cals/utils/block/helpers/merge-dataset.js +17 -0
- package/lib/parser/cals/utils/block/helpers/merge-listeners.d.ts +6 -0
- package/lib/parser/cals/utils/block/helpers/merge-listeners.d.ts.map +1 -0
- package/lib/parser/cals/utils/block/helpers/merge-listeners.js +14 -0
- package/lib/parser/cals/utils/block/helpers/merge-resources.d.ts +6 -0
- package/lib/parser/cals/utils/block/helpers/merge-resources.d.ts.map +1 -0
- package/lib/parser/cals/utils/block/helpers/merge-resources.js +29 -0
- package/lib/parser/cals/utils/block/helpers/remap-component-ids.d.ts.map +1 -1
- package/lib/parser/cals/utils/block/helpers/remap-component-ids.js +5 -4
- package/lib/parser/cals/utils/block/helpers/renew-id-in-code.d.ts.map +1 -1
- package/lib/parser/cals/utils/block/helpers/renew-id-in-code.js +2 -8
- package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts +2 -1
- package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts.map +1 -1
- package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.js +49 -55
- package/lib/parser/cals/utils/block/index.d.ts +27 -3
- package/lib/parser/cals/utils/block/index.d.ts.map +1 -1
- package/lib/parser/cals/utils/block/index.js +163 -7
- package/lib/parser/cals/utils/common.d.ts +1 -1
- package/lib/parser/cals/utils/common.d.ts.map +1 -1
- package/lib/parser/cals/utils/common.js +4 -9
- package/lib/parser/cals/utils/getUsedReference.d.ts +3 -2
- package/lib/parser/cals/utils/getUsedReference.d.ts.map +1 -1
- package/lib/parser/cals/utils/getUsedReference.js +8 -5
- package/lib/parser/index.d.ts +1 -1
- package/lib/parser/index.d.ts.map +1 -1
- package/lib/parser/index.js +4 -1
- package/lib/types/platform/datasource.d.ts +6 -0
- package/lib/types/platform/datasource.d.ts.map +1 -1
- package/lib/types/platform/datasource.js +7 -0
- package/lib/utils/dts/auto-generated.d.ts +1 -1
- package/lib/utils/dts/auto-generated.d.ts.map +1 -1
- package/lib/utils/dts/auto-generated.js +5 -0
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ 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';
|
|
8
|
+
import { IBlockTemplate } from './utils/block/index';
|
|
7
9
|
export { getUsedComps, generateCustomLoginConfigPathname } from './utils/common';
|
|
8
10
|
export { generateDefaultCode } from './utils/template';
|
|
9
11
|
interface IDeserializeContext {
|
|
@@ -508,23 +510,23 @@ export declare function generateHandlerParamsDynamicMap(handler: IHandler): any;
|
|
|
508
510
|
* 仅保留子包自身数据
|
|
509
511
|
*/
|
|
510
512
|
export declare function streamlineSubApp(cals: any): IPlatformSubApp;
|
|
513
|
+
export interface ICalsReferenceContext {
|
|
514
|
+
blockTemplateMap: Record<string, IBlockTemplate>;
|
|
515
|
+
referenceMap?: Record<string, boolean>;
|
|
516
|
+
strict?: boolean;
|
|
517
|
+
visiting?: IVisitedContext;
|
|
518
|
+
}
|
|
511
519
|
/**
|
|
512
520
|
* 还原引用
|
|
513
521
|
*/
|
|
514
522
|
export declare function collapseCalsReference(cals: IPlatformApp | IPlatformSubApp, options: {
|
|
515
|
-
blockTemplates:
|
|
516
|
-
name?: string;
|
|
517
|
-
path?: string;
|
|
518
|
-
}[];
|
|
523
|
+
blockTemplates: IBlockTemplate[];
|
|
519
524
|
}): IPlatformApp | IPlatformSubApp;
|
|
520
525
|
/**
|
|
521
526
|
* 展开引用
|
|
522
527
|
*/
|
|
523
528
|
export declare function expandCalsReference(cals: IPlatformApp | IPlatformSubApp, options: {
|
|
524
|
-
blockTemplates:
|
|
525
|
-
name?: string;
|
|
526
|
-
path?: string;
|
|
527
|
-
}[];
|
|
529
|
+
blockTemplates: IBlockTemplate[];
|
|
528
530
|
strict?: boolean;
|
|
529
531
|
}): IPlatformApp | IPlatformSubApp;
|
|
530
532
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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":[],"mappings":"AAOA,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;AAErB,OAAO,EAAE,eAAe,EAAc,MAAM,2CAA2C,CAAC;AAExF,OAAO,EAAwD,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE3G,OAAO,EAAE,YAAY,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,UAAU,mBAAmB;IAC3B,GAAG,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GAAG,eAAe,EACpC,OAAO,EAAE;IAAE,cAAc,EAAE,cAAc,EAAE,CAAA;CAAE,GAC5C,YAAY,GAAG,eAAe,CAehC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,YAAY,GAAG,eAAe,EACpC,OAAO,EAAE;IAAE,cAAc,EAAE,cAAc,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,YAAY,GAAG,eAAe,CA6ChC"}
|
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");
|
|
@@ -569,6 +568,7 @@ function deserializeDirecties(ctx, directives) {
|
|
|
569
568
|
* heander 更新为表达式
|
|
570
569
|
*/
|
|
571
570
|
function serializeListener(ctx, listener) {
|
|
571
|
+
var _a;
|
|
572
572
|
const { data, extra = {} } = serializeDynamicMapWithExtra({
|
|
573
573
|
ctx,
|
|
574
574
|
map: listener.data,
|
|
@@ -585,7 +585,7 @@ function serializeListener(ctx, listener) {
|
|
|
585
585
|
name: listener.handler.name,
|
|
586
586
|
module: /^comp-\w+$/.test(listener.handler.moduleName)
|
|
587
587
|
? '$comp'
|
|
588
|
-
: listener.type === expression_1.ActionType.Rematch && ctx.page.id
|
|
588
|
+
: listener.type === expression_1.ActionType.Rematch && ((_a = ctx.page) === null || _a === void 0 ? void 0 : _a.id)
|
|
589
589
|
? ctx.page.id
|
|
590
590
|
: listener.handler.moduleName,
|
|
591
591
|
[':code']: listener.handler.code,
|
|
@@ -612,7 +612,7 @@ function serializeListener(ctx, listener) {
|
|
|
612
612
|
return platfromListener;
|
|
613
613
|
}
|
|
614
614
|
function deserializeListener(ctx, listener) {
|
|
615
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
615
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
616
616
|
let paramsDynamicMap = generateHandlerParamsDynamicMap(listener.handler);
|
|
617
617
|
let argsExtra = (_a = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _a === void 0 ? void 0 : _a.handlerAragsExtraData;
|
|
618
618
|
if (!argsExtra && ((_b = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _b === void 0 ? void 0 : _b.handlerAragsExtraData)) {
|
|
@@ -626,7 +626,7 @@ function deserializeListener(ctx, listener) {
|
|
|
626
626
|
moduleName: (_e = listener.handler) === null || _e === void 0 ? void 0 : _e.module,
|
|
627
627
|
code: ((_f = listener.handler) === null || _f === void 0 ? void 0 : _f[':code']) || ((_g = listener.handler) === null || _g === void 0 ? void 0 : _g.code),
|
|
628
628
|
};
|
|
629
|
-
if (listener.type === expression_1.ActionType.Rematch && ctx.page.id) {
|
|
629
|
+
if (listener.type === expression_1.ActionType.Rematch && ((_h = ctx.page) === null || _h === void 0 ? void 0 : _h.id)) {
|
|
630
630
|
handler.moduleName = ctx.page.id;
|
|
631
631
|
}
|
|
632
632
|
let processed = {
|
|
@@ -634,7 +634,7 @@ function deserializeListener(ctx, listener) {
|
|
|
634
634
|
trigger: listener.eventName,
|
|
635
635
|
type: listener.type,
|
|
636
636
|
handler,
|
|
637
|
-
data: deserializeDynamicMap(ctx, ((
|
|
637
|
+
data: deserializeDynamicMap(ctx, ((_j = paramsDynamicMap.params) === null || _j === void 0 ? void 0 : _j[0]) || {}, ((_k = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _k === void 0 ? void 0 : _k.handlerParamExtraData) || {}),
|
|
638
638
|
args: deserializeDynamicMap(ctx, paramsDynamicMap, argsExtra),
|
|
639
639
|
isCapturePhase: !!listener.isCapturePhase,
|
|
640
640
|
// TODO
|
|
@@ -1520,45 +1520,11 @@ function collapseCalsReference(cals, options) {
|
|
|
1520
1520
|
};
|
|
1521
1521
|
const res = Object.assign(Object.assign({}, cals), { items: (_a = cals.items) === null || _a === void 0 ? void 0 : _a.map((page) => {
|
|
1522
1522
|
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)) });
|
|
1523
|
+
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
1524
|
}) });
|
|
1525
1525
|
return res;
|
|
1526
1526
|
}
|
|
1527
1527
|
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
1528
|
/**
|
|
1563
1529
|
* 展开引用
|
|
1564
1530
|
*/
|
|
@@ -1577,7 +1543,7 @@ function expandCalsReference(cals, options) {
|
|
|
1577
1543
|
const { refs } = (0, utils_1.getUsedReference)([cals], blockTemplates);
|
|
1578
1544
|
[cals]
|
|
1579
1545
|
.concat(Array.from(refs)
|
|
1580
|
-
.map((key) => blockTemplateMap[key])
|
|
1546
|
+
.map((key) => { var _a; return (_a = blockTemplateMap[key]) === null || _a === void 0 ? void 0 : _a.content; })
|
|
1581
1547
|
.filter((item) => !!item))
|
|
1582
1548
|
.forEach((cals, index) => {
|
|
1583
1549
|
var _a, _b;
|
|
@@ -1588,54 +1554,16 @@ function expandCalsReference(cals, options) {
|
|
|
1588
1554
|
const { untilNow, existing } = ctx.visiting;
|
|
1589
1555
|
const namespace = (0, get_component_namespace_1.getComponentNamespace)(componentName);
|
|
1590
1556
|
if (index === 0) {
|
|
1591
|
-
untilNow.add(namespace, id);
|
|
1557
|
+
untilNow.add(namespace, component.id);
|
|
1592
1558
|
}
|
|
1593
1559
|
existing.add(namespace, component.id);
|
|
1594
1560
|
}
|
|
1595
|
-
return component;
|
|
1596
1561
|
});
|
|
1597
1562
|
});
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;;
|
|
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,OAuD9G"}
|
|
@@ -53,10 +53,9 @@ 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
|
|
56
|
+
return;
|
|
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;
|
|
@@ -71,7 +70,6 @@ function remapComponentIds(components, visitedContext) {
|
|
|
71
70
|
for (const target of [existing, untilNow]) {
|
|
72
71
|
target.add(namespace, item.id);
|
|
73
72
|
}
|
|
74
|
-
return item;
|
|
75
73
|
});
|
|
76
74
|
return { componentIdMap };
|
|
77
75
|
}
|
|
@@ -99,6 +97,7 @@ function refreshComponentIds(ctx, component) {
|
|
|
99
97
|
}
|
|
100
98
|
case 'Repeater': {
|
|
101
99
|
const oldId = (_c = processed.attributes) === null || _c === void 0 ? void 0 : _c.suffix;
|
|
100
|
+
console.log('>>>>>>>>>>>>', processed.id, oldId, componentIdMap.has(oldId));
|
|
102
101
|
if (oldId && componentIdMap.has(oldId)) {
|
|
103
102
|
for (const key of ['forIndex', 'forItem', 'suffix']) {
|
|
104
103
|
const value = processed.attributes[key];
|
|
@@ -122,7 +121,9 @@ function refreshComponentIds(ctx, component) {
|
|
|
122
121
|
if (processed === null || processed === void 0 ? void 0 : processed.resources) {
|
|
123
122
|
processed.resources = processed.resources.map((item) => (0, renew_id_in_resource_1.renewIdInResource)(item, componentIdMap));
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
if (processed === null || processed === void 0 ? void 0 : processed.items) {
|
|
125
|
+
processed.items = (_g = (_f = processed.items) === null || _f === void 0 ? void 0 : _f.map) === null || _g === void 0 ? void 0 : _g.call(_f, (i) => refreshComponentIds(ctx, i));
|
|
126
|
+
}
|
|
126
127
|
return processed;
|
|
127
128
|
}
|
|
128
129
|
exports.refreshComponentIds = refreshComponentIds;
|
|
@@ -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":"
|
|
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
|
|
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
|
|
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>):
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// code
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
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,30 @@ 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'];
|
|
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
|
+
/**
|
|
30
|
+
* todo: dataForm 追加
|
|
31
|
+
*/
|
|
32
|
+
export declare function mergeCals(ctx: {
|
|
33
|
+
blockTemplateMap: Record<string, IBlockTemplate>;
|
|
34
|
+
}, list: IMergeCalsMeta[]): IPlatformApp;
|
|
35
|
+
export declare function expandComponentReference(ctx: ICalsReferenceContext & {
|
|
36
|
+
visiting: IVisitedContext;
|
|
37
|
+
}, component: IPlatformComponent): any;
|
|
38
|
+
export declare function collapseComponentReference(ctx: ICalsReferenceContext, component: any): any;
|
|
39
|
+
export interface IBlockTemplate {
|
|
40
|
+
name: string;
|
|
41
|
+
path?: string;
|
|
42
|
+
dynamicConfig?: any;
|
|
43
|
+
content: IPlatformApp;
|
|
44
|
+
}
|
|
21
45
|
//# 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,
|
|
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;AAG1D,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,C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