bobe 0.0.60 → 0.0.62
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/dist/bobe.cjs.js +160 -35
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +160 -35
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +162 -37
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +162 -37
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +18 -5
- package/dist/index.umd.js +160 -35
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -16,11 +16,10 @@ declare class Interpreter {
|
|
|
16
16
|
private tokenizer;
|
|
17
17
|
opt: TerpConf;
|
|
18
18
|
constructor(tokenizer: Tokenizer);
|
|
19
|
-
isLogicNode(node: any): number;
|
|
20
19
|
ctx: ProgramCtx;
|
|
21
20
|
rootComponent: ComponentNode$1 | null;
|
|
22
21
|
program(root: any, componentNode?: ComponentNode$1, before?: any, ctxProvider?: any): ComponentNode$1;
|
|
23
|
-
insertAnchor(name?: string, isBefore?: boolean): any;
|
|
22
|
+
insertAnchor(node: any, name?: string, isBefore?: boolean): any;
|
|
24
23
|
/** 处理
|
|
25
24
|
* 是逻辑 是普通
|
|
26
25
|
* 父节点 将子节点加入 directList 调用 insert 方法挨个插入子节点
|
|
@@ -37,12 +36,17 @@ declare class Interpreter {
|
|
|
37
36
|
* */
|
|
38
37
|
declaration(ctx: ProgramCtx): any;
|
|
39
38
|
dynamicDeclaration(pData: any, value: string, ctx: ProgramCtx): DynamicNode;
|
|
39
|
+
createTpNode(): TpNode;
|
|
40
40
|
createContextNode(): ContextNode;
|
|
41
41
|
formatForCollection(collection: any): {
|
|
42
42
|
arr: any[];
|
|
43
43
|
keys: string[] | null;
|
|
44
44
|
};
|
|
45
45
|
forDeclaration(): ForNode | ForItemNode;
|
|
46
|
+
/** after 锚点,对 fake 节点反引用
|
|
47
|
+
* 用于 tp 节点 移动时,可以通过 after 锚点找到 fake 节点并做 realParent 的修正
|
|
48
|
+
*/
|
|
49
|
+
anchorRefBack(anchor: any, node: LogicNode): void;
|
|
46
50
|
insertForItem(forNode: ForNode, i: number, parentData: any, newChildren: ForItemNode[], before: any, snapshotForUpdate: any): void;
|
|
47
51
|
removeForItem(children: ForItemNode[], i: number): void;
|
|
48
52
|
reuseForItem(child: ForItemNode, data: any, itemExp: string | ((value: any) => any), i: number, indexName?: string,
|
|
@@ -169,7 +173,8 @@ declare enum FakeType {
|
|
|
169
173
|
Fragment = 32,
|
|
170
174
|
ForItem = 64,
|
|
171
175
|
Context = 128,
|
|
172
|
-
DynamicText = 256
|
|
176
|
+
DynamicText = 256,
|
|
177
|
+
Tp = 512
|
|
173
178
|
}
|
|
174
179
|
type NodeSortBit = number;
|
|
175
180
|
type BaseType = string | number | boolean | undefined | null;
|
|
@@ -296,6 +301,14 @@ type IfNode = LogicNode & {
|
|
|
296
301
|
type ContextNode = Omit<LogicNode, 'data'> & {
|
|
297
302
|
context: any;
|
|
298
303
|
};
|
|
304
|
+
type TpNode = LogicNode & {
|
|
305
|
+
tpData: any;
|
|
306
|
+
effect: Scope;
|
|
307
|
+
contentBefore: any;
|
|
308
|
+
contentAfter: any;
|
|
309
|
+
owner: ComponentNode$1 | FragmentNode$1;
|
|
310
|
+
snapshot: ReturnType<Tokenizer['snapshot']>;
|
|
311
|
+
};
|
|
299
312
|
type DynamicNode = Omit<LogicNode, 'data'> & {
|
|
300
313
|
tokenizer: Tokenizer;
|
|
301
314
|
/** 模版片段快照 */
|
|
@@ -584,7 +597,7 @@ type ParseHooks = Partial<{
|
|
|
584
597
|
}>;
|
|
585
598
|
|
|
586
599
|
declare function bobe<T extends Record<any, any> = any>(fragments: TemplateStringsArray, ...values: any[]): UI<T>;
|
|
587
|
-
declare function customRender(option: CustomRenderConf): <T>(Ctor:
|
|
600
|
+
declare function customRender(option: CustomRenderConf): <T extends typeof Store>(Ctor: T, root: any) => readonly [ComponentNode$1, InstanceType<T>];
|
|
588
601
|
|
|
589
602
|
type IContext = {
|
|
590
603
|
<T = any>(name: string): T;
|
|
@@ -595,4 +608,4 @@ declare const context: IContext;
|
|
|
595
608
|
declare const effect: (callback: (...args: ValueDiff[]) => void, depOrOpt?: Dep[] | Dep | CustomEffectOpt, opt?: CustomEffectOpt) => aoye.Effect;
|
|
596
609
|
|
|
597
610
|
export { Compiler, FakeType, NodeType, ParseErrorCode, ParseSyntaxError, Tokenizer, bobe, context, customRender, effect };
|
|
598
|
-
export type { ASTNodeType, BaseNode, CommentNode, ComponentNode, ConditionalNode, DynamicValue, ElementNode, FragmentNode, IContext, InterpolationNode, LogicNode, LoopNode, ParseError, Program, Property, PropertyKeyNode, PropertyValue, SourceLocation, StaticValue, TemplateNode, TextNode };
|
|
611
|
+
export type { ASTNodeType, BaseNode, CommentNode, ComponentNode, ConditionalNode, DynamicValue, ElementNode, FragmentNode, IContext, InterpolationNode, LogicNode, LoopNode, ParseError, Program, Property, PropertyKeyNode, PropertyValue, SourceLocation, StaticValue, TemplateNode, TextNode, UI };
|
package/dist/index.umd.js
CHANGED
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
FakeType[FakeType["ForItem"] = 64] = "ForItem";
|
|
36
36
|
FakeType[FakeType["Context"] = 128] = "Context";
|
|
37
37
|
FakeType[FakeType["DynamicText"] = 256] = "DynamicText";
|
|
38
|
+
FakeType[FakeType["Tp"] = 512] = "Tp";
|
|
38
39
|
return FakeType;
|
|
39
40
|
}({});
|
|
40
41
|
const CondBit = FakeType.If | FakeType.Fail | FakeType.Else;
|
|
41
|
-
const LogicalBit = FakeType.If | FakeType.Fail | FakeType.Else | FakeType.For | FakeType.ForItem;
|
|
42
42
|
const CtxProviderBit = FakeType.If | FakeType.Fail | FakeType.Else | FakeType.For | FakeType.ForItem | FakeType.Component | FakeType.Fragment | FakeType.DynamicText;
|
|
43
|
-
const ContextBit = FakeType.If | FakeType.Fail | FakeType.Else | FakeType.ForItem | FakeType.Context;
|
|
43
|
+
const ContextBit = FakeType.If | FakeType.Fail | FakeType.Else | FakeType.ForItem | FakeType.Context | FakeType.Tp;
|
|
44
44
|
const TokenizerSwitcherBit = FakeType.Component | FakeType.Fragment;
|
|
45
45
|
let NodeSort = function (NodeSort) {
|
|
46
|
-
NodeSort[NodeSort["
|
|
46
|
+
NodeSort[NodeSort["EffectNode"] = 1] = "EffectNode";
|
|
47
47
|
NodeSort[NodeSort["Real"] = 2] = "Real";
|
|
48
48
|
NodeSort[NodeSort["Component"] = 4] = "Component";
|
|
49
49
|
NodeSort[NodeSort["CtxProvider"] = 8] = "CtxProvider";
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
TerpEvt["HandledComponentNode"] = "handled-component-node";
|
|
57
57
|
return TerpEvt;
|
|
58
58
|
})({});
|
|
59
|
+
const FakeNode = Symbol('fake-node');
|
|
59
60
|
let ParseErrorCode = function (ParseErrorCode) {
|
|
60
61
|
ParseErrorCode[ParseErrorCode["UNCLOSED_BRACE"] = 9001] = "UNCLOSED_BRACE";
|
|
61
62
|
ParseErrorCode[ParseErrorCode["UNCLOSED_STRING"] = 9002] = "UNCLOSED_STRING";
|
|
@@ -1435,7 +1436,7 @@
|
|
|
1435
1436
|
has: () => true,
|
|
1436
1437
|
get: (t, k) => {
|
|
1437
1438
|
if (typeof k === 'symbol') return t[k];
|
|
1438
|
-
return
|
|
1439
|
+
return t[k];
|
|
1439
1440
|
}
|
|
1440
1441
|
};
|
|
1441
1442
|
const safe = data => new Proxy(data, SAFE_HANDLER);
|
|
@@ -1450,9 +1451,6 @@
|
|
|
1450
1451
|
constructor(tokenizer) {
|
|
1451
1452
|
this.tokenizer = tokenizer;
|
|
1452
1453
|
}
|
|
1453
|
-
isLogicNode(node) {
|
|
1454
|
-
return node && node.__logicType & LogicalBit;
|
|
1455
|
-
}
|
|
1456
1454
|
rootComponent = null;
|
|
1457
1455
|
program(root, componentNode, before, ctxProvider) {
|
|
1458
1456
|
this.rootComponent = componentNode;
|
|
@@ -1471,7 +1469,7 @@
|
|
|
1471
1469
|
stack.push({
|
|
1472
1470
|
node: ctxProvider,
|
|
1473
1471
|
prev: null
|
|
1474
|
-
}, (ctxProvider.__logicType
|
|
1472
|
+
}, (ctxProvider.__logicType && ctxProvider.effect ? NodeSort.EffectNode : 0) | NodeSort.CtxProvider);
|
|
1475
1473
|
}
|
|
1476
1474
|
const rootLen = stack.length;
|
|
1477
1475
|
const ctx = this.ctx = {
|
|
@@ -1494,18 +1492,24 @@
|
|
|
1494
1492
|
const token = this.tokenizer.token;
|
|
1495
1493
|
if (token.type & TokenType.Indent) {
|
|
1496
1494
|
this.tokenizer.nextToken();
|
|
1497
|
-
const
|
|
1495
|
+
const isEffectNode = ctx.current && ctx.current.__logicType && ctx.current.effect;
|
|
1498
1496
|
stack.push({
|
|
1499
1497
|
node: ctx.current,
|
|
1500
1498
|
prev: ctx.prevSibling
|
|
1501
|
-
}, !ctx.current.__logicType ? NodeSort.Real : (ctx.current.__logicType &
|
|
1499
|
+
}, !ctx.current.__logicType ? NodeSort.Real : (isEffectNode ? NodeSort.EffectNode : 0) | (ctx.current.__logicType & TokenizerSwitcherBit ? NodeSort.TokenizerSwitcher : 0) | (ctx.current.__logicType & ContextBit ? NodeSort.Context : 0) | (ctx.current.__logicType === FakeType.Component ? NodeSort.Component : 0) | (ctx.current.__logicType === FakeType.Tp ? NodeSort.Real : 0) | (ctx.current.__logicType & CtxProviderBit ? NodeSort.CtxProvider : 0));
|
|
1502
1500
|
if (ctx.current.__logicType) {
|
|
1503
1501
|
this.beforeLogicIndent?.(ctx.current);
|
|
1504
|
-
if (
|
|
1502
|
+
if (isEffectNode) {
|
|
1505
1503
|
aoye.setPulling(ctx.current.effect);
|
|
1506
1504
|
if (ctx.current.__logicType & FakeType.ForItem) {
|
|
1507
1505
|
ctx.prevSibling = ctx.current.realBefore;
|
|
1508
1506
|
}
|
|
1507
|
+
if (ctx.current.__logicType & FakeType.Tp) {
|
|
1508
|
+
aoye.runWithPulling(() => {
|
|
1509
|
+
ctx.realParent = ctx.current.tpData.node;
|
|
1510
|
+
}, null);
|
|
1511
|
+
ctx.prevSibling = ctx.current.contentBefore;
|
|
1512
|
+
}
|
|
1509
1513
|
}
|
|
1510
1514
|
} else {
|
|
1511
1515
|
if (ctx.current) {
|
|
@@ -1539,16 +1543,24 @@
|
|
|
1539
1543
|
sort = _stack$pop2[1];
|
|
1540
1544
|
if (!parent.__logicType) {
|
|
1541
1545
|
const prevSameType = stack.peekByType(NodeSort.Real);
|
|
1542
|
-
|
|
1546
|
+
const sameNode = prevSameType?.node;
|
|
1547
|
+
if (sameNode) {
|
|
1548
|
+
ctx.realParent = sameNode.__logicType === FakeType.Tp ? aoye.runWithPulling(() => sameNode.tpData.node, null) : sameNode;
|
|
1549
|
+
} else {
|
|
1550
|
+
ctx.realParent = root;
|
|
1551
|
+
}
|
|
1543
1552
|
} else {
|
|
1544
|
-
if (sort & NodeSort.
|
|
1545
|
-
const parentLogic = stack.peekByType(NodeSort.
|
|
1553
|
+
if (sort & NodeSort.EffectNode) {
|
|
1554
|
+
const parentLogic = stack.peekByType(NodeSort.EffectNode)?.node;
|
|
1546
1555
|
if (parentLogic) {
|
|
1547
1556
|
aoye.setPulling(parentLogic.effect);
|
|
1548
1557
|
} else {
|
|
1549
1558
|
aoye.setPulling(rootPulling);
|
|
1550
1559
|
}
|
|
1551
1560
|
}
|
|
1561
|
+
if (parent.__logicType === FakeType.Tp) {
|
|
1562
|
+
ctx.realParent = parent.realParent;
|
|
1563
|
+
}
|
|
1552
1564
|
if (sort & NodeSort.TokenizerSwitcher) {
|
|
1553
1565
|
const switcher = stack.peekByType(NodeSort.TokenizerSwitcher)?.node;
|
|
1554
1566
|
if (parent.resumeSnapshot) {
|
|
@@ -1585,13 +1597,17 @@
|
|
|
1585
1597
|
}
|
|
1586
1598
|
return componentNode;
|
|
1587
1599
|
}
|
|
1588
|
-
insertAnchor(name = 'anchor', isBefore = false) {
|
|
1600
|
+
insertAnchor(node, name = 'anchor', isBefore = false) {
|
|
1589
1601
|
const _this$ctx = this.ctx,
|
|
1590
1602
|
realParent = _this$ctx.realParent,
|
|
1591
1603
|
prevSibling = _this$ctx.prevSibling,
|
|
1592
1604
|
stack = _this$ctx.stack,
|
|
1593
1605
|
before = _this$ctx.before;
|
|
1606
|
+
_this$ctx.current;
|
|
1594
1607
|
const afterAnchor = this.createAnchor(name, isBefore);
|
|
1608
|
+
if (!isBefore) {
|
|
1609
|
+
this.anchorRefBack(afterAnchor, node);
|
|
1610
|
+
}
|
|
1595
1611
|
this.ctx.prevSibling = stack.length === 2 && !prevSibling ? before : prevSibling;
|
|
1596
1612
|
this.handleInsert(realParent, afterAnchor, prevSibling);
|
|
1597
1613
|
return afterAnchor;
|
|
@@ -1636,6 +1652,8 @@
|
|
|
1636
1652
|
return this.condDeclaration(ctx);
|
|
1637
1653
|
} else if (value === 'context') {
|
|
1638
1654
|
_node = this.createContextNode();
|
|
1655
|
+
} else if (value === 'tp') {
|
|
1656
|
+
return this.createTpNode();
|
|
1639
1657
|
} else if (value === 'for') {
|
|
1640
1658
|
return this.forDeclaration();
|
|
1641
1659
|
} else if (hookType) {
|
|
@@ -1667,7 +1685,7 @@
|
|
|
1667
1685
|
return _node;
|
|
1668
1686
|
}
|
|
1669
1687
|
dynamicDeclaration(pData, value, ctx) {
|
|
1670
|
-
const valueIsMapKey =
|
|
1688
|
+
const valueIsMapKey = Boolean(aoye.getProxyHasKey(pData, value));
|
|
1671
1689
|
let node = {
|
|
1672
1690
|
__logicType: null,
|
|
1673
1691
|
realParent: null,
|
|
@@ -1679,7 +1697,7 @@
|
|
|
1679
1697
|
parentDataProvider: ctx.stack.peekByType(NodeSort.CtxProvider)?.node
|
|
1680
1698
|
};
|
|
1681
1699
|
let isUpdate = false;
|
|
1682
|
-
node.realAfter = this.insertAnchor(`dynamic-after`);
|
|
1700
|
+
node.realAfter = this.insertAnchor(node, `dynamic-after`);
|
|
1683
1701
|
node.effect = this.effect(({
|
|
1684
1702
|
old,
|
|
1685
1703
|
val
|
|
@@ -1751,10 +1769,110 @@
|
|
|
1751
1769
|
this.removeLogicNode(node);
|
|
1752
1770
|
}
|
|
1753
1771
|
};
|
|
1754
|
-
}, [() => {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1772
|
+
}, [valueIsMapKey ? () => pData[value] : this.getFn(pData, value)], {
|
|
1773
|
+
type: 'render'
|
|
1774
|
+
});
|
|
1775
|
+
return node;
|
|
1776
|
+
}
|
|
1777
|
+
createTpNode() {
|
|
1778
|
+
const child = aoye.deepSignal({}, aoye.getPulling());
|
|
1779
|
+
const node = {
|
|
1780
|
+
__logicType: FakeType.Tp,
|
|
1781
|
+
data: this.getData(),
|
|
1782
|
+
realParent: null,
|
|
1783
|
+
realBefore: null,
|
|
1784
|
+
realAfter: null,
|
|
1785
|
+
contentBefore: null,
|
|
1786
|
+
contentAfter: null,
|
|
1787
|
+
effect: null,
|
|
1788
|
+
snapshot: null,
|
|
1789
|
+
tpData: child,
|
|
1790
|
+
owner: this.ctx.stack.peekByType(NodeSort.TokenizerSwitcher)?.node
|
|
1791
|
+
};
|
|
1792
|
+
this.onePropParsed = createStoreOnePropParsed(child);
|
|
1793
|
+
this.tokenizer.nextToken();
|
|
1794
|
+
this.headerLineAndExtensions(node);
|
|
1795
|
+
this.onePropParsed = this.oneRealPropParsed;
|
|
1796
|
+
node.realAfter = this.insertAnchor(node, 'tp-after');
|
|
1797
|
+
const before = node.contentBefore = this.createAnchor('tp-content-before', true);
|
|
1798
|
+
const after = node.contentAfter = this.createAnchor('tp-content-after', true);
|
|
1799
|
+
let firstRender = true;
|
|
1800
|
+
let scope = new aoye.Scope(() => {});
|
|
1801
|
+
scope.scope = null;
|
|
1802
|
+
aoye.runWithPulling(() => {
|
|
1803
|
+
scope.get();
|
|
1804
|
+
}, null);
|
|
1805
|
+
node.effect = scope;
|
|
1806
|
+
this.effect(({
|
|
1807
|
+
old: oldDom,
|
|
1808
|
+
val: dom
|
|
1809
|
+
}) => {
|
|
1810
|
+
const removeTpChild = () => {
|
|
1811
|
+
if (oldDom) {
|
|
1812
|
+
let point = before;
|
|
1813
|
+
do {
|
|
1814
|
+
const next = this.nextSib(point);
|
|
1815
|
+
this.remove(point, oldDom, null);
|
|
1816
|
+
if (point === after) break;
|
|
1817
|
+
point = next;
|
|
1818
|
+
} while (true);
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
if (firstRender) {
|
|
1822
|
+
if (dom) {
|
|
1823
|
+
this.handleInsert(dom, after, null);
|
|
1824
|
+
this.handleInsert(dom, before, null);
|
|
1825
|
+
} else {
|
|
1826
|
+
if (this.tokenizer.token.type === TokenType.Indent) {
|
|
1827
|
+
const dentLen = this.tokenizer.dentStack[this.tokenizer.dentStack.length - 2] ?? 0;
|
|
1828
|
+
this.tokenizer.skip(dentLen);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
} else {
|
|
1832
|
+
if (dom) {
|
|
1833
|
+
if (oldDom) {
|
|
1834
|
+
let point = before,
|
|
1835
|
+
lastInsert = null;
|
|
1836
|
+
do {
|
|
1837
|
+
const next = this.nextSib(point);
|
|
1838
|
+
const fakeNode = point[FakeNode];
|
|
1839
|
+
if (fakeNode) {
|
|
1840
|
+
fakeNode.realParent = dom;
|
|
1841
|
+
}
|
|
1842
|
+
this.handleInsert(dom, point, lastInsert);
|
|
1843
|
+
if (point === after) break;
|
|
1844
|
+
lastInsert = point;
|
|
1845
|
+
point = next;
|
|
1846
|
+
} while (true);
|
|
1847
|
+
} else {
|
|
1848
|
+
this.handleInsert(dom, after, null);
|
|
1849
|
+
this.handleInsert(dom, before, null);
|
|
1850
|
+
aoye.runWithPulling(() => {
|
|
1851
|
+
this.tokenizer = node.owner.tokenizer;
|
|
1852
|
+
this.tokenizer.resume(node.snapshot);
|
|
1853
|
+
this.tokenizer.useDedentAsEof = false;
|
|
1854
|
+
this.program(dom, node.owner, before, node);
|
|
1855
|
+
}, scope);
|
|
1856
|
+
}
|
|
1857
|
+
} else {
|
|
1858
|
+
removeTpChild();
|
|
1859
|
+
scope.dispose();
|
|
1860
|
+
scope = new aoye.Scope(() => {});
|
|
1861
|
+
scope.scope = null;
|
|
1862
|
+
aoye.runWithPulling(() => {
|
|
1863
|
+
scope.get();
|
|
1864
|
+
}, null);
|
|
1865
|
+
node.effect = scope;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
firstRender = false;
|
|
1869
|
+
return isDestroy => {
|
|
1870
|
+
if (isDestroy) {
|
|
1871
|
+
removeTpChild();
|
|
1872
|
+
scope.dispose();
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
}, [() => child.node], {
|
|
1758
1876
|
type: 'render'
|
|
1759
1877
|
});
|
|
1760
1878
|
return node;
|
|
@@ -1763,7 +1881,7 @@
|
|
|
1763
1881
|
const child = aoye.deepSignal({}, aoye.getPulling());
|
|
1764
1882
|
const parentContext = this.ctx.stack.peekByType(NodeSort.Context)?.node?.context;
|
|
1765
1883
|
if (parentContext) {
|
|
1766
|
-
|
|
1884
|
+
aoye.backupSignal(child, parentContext);
|
|
1767
1885
|
}
|
|
1768
1886
|
this.onePropParsed = createStoreOnePropParsed(child);
|
|
1769
1887
|
const node = {
|
|
@@ -1773,7 +1891,7 @@
|
|
|
1773
1891
|
realBefore: null,
|
|
1774
1892
|
realAfter: null
|
|
1775
1893
|
};
|
|
1776
|
-
node.realAfter = this.insertAnchor('context-after');
|
|
1894
|
+
node.realAfter = this.insertAnchor(node, 'context-after');
|
|
1777
1895
|
return node;
|
|
1778
1896
|
}
|
|
1779
1897
|
formatForCollection(collection) {
|
|
@@ -1866,13 +1984,12 @@
|
|
|
1866
1984
|
const rawGetKey = new Function('data', `with(data){return (${keyExp})}`);
|
|
1867
1985
|
forNode.getKey = data => rawGetKey(safe(data));
|
|
1868
1986
|
}
|
|
1869
|
-
window['for1'] = forNode;
|
|
1870
1987
|
const data = this.getData();
|
|
1871
1988
|
const cells = data[aoye.Keys.Meta].cells;
|
|
1872
1989
|
const hasArrExpKey = Reflect.has(data[aoye.Keys.Raw], arrExp);
|
|
1873
1990
|
const arrSignal = hasArrExpKey ? (data[arrExp], cells.get(arrExp)) : new aoye.Computed(this.getFn(data, arrExp));
|
|
1874
1991
|
forNode.arrSignal = arrSignal;
|
|
1875
|
-
forNode.realAfter = this.insertAnchor('for-after');
|
|
1992
|
+
forNode.realAfter = this.insertAnchor(forNode, 'for-after');
|
|
1876
1993
|
const _forNode$snapshot = forNode.snapshot;
|
|
1877
1994
|
_forNode$snapshot.dentStack;
|
|
1878
1995
|
_forNode$snapshot.isFirstToken;
|
|
@@ -1895,8 +2012,8 @@
|
|
|
1895
2012
|
const len = arr.length;
|
|
1896
2013
|
for (let i = len; i--;) {
|
|
1897
2014
|
const item = this.createForItem(forNode, i, data);
|
|
1898
|
-
item.realAfter = this.insertAnchor('for-item-after');
|
|
1899
|
-
item.realBefore = this.insertAnchor('for-item-before', true);
|
|
2015
|
+
item.realAfter = this.insertAnchor(item, 'for-item-after');
|
|
2016
|
+
item.realBefore = this.insertAnchor(item, 'for-item-before', true);
|
|
1900
2017
|
item.realParent = forNode.realParent;
|
|
1901
2018
|
children[i] = item;
|
|
1902
2019
|
}
|
|
@@ -2058,10 +2175,14 @@
|
|
|
2058
2175
|
}, aoye.ScheduleType.Render);
|
|
2059
2176
|
return forNode.children[0] || forNode;
|
|
2060
2177
|
}
|
|
2178
|
+
anchorRefBack(anchor, node) {
|
|
2179
|
+
anchor[FakeNode] = node;
|
|
2180
|
+
}
|
|
2061
2181
|
insertForItem(forNode, i, parentData, newChildren, before, snapshotForUpdate) {
|
|
2062
2182
|
const item = this.createForItem(forNode, i, parentData);
|
|
2063
2183
|
newChildren[i] = item;
|
|
2064
2184
|
let realAfter = this.createAnchor('for-item-after');
|
|
2185
|
+
this.anchorRefBack(realAfter, item);
|
|
2065
2186
|
this.handleInsert(forNode.realParent, realAfter, before);
|
|
2066
2187
|
let realBefore = this.createAnchor('for-item-before', true);
|
|
2067
2188
|
this.handleInsert(forNode.realParent, realBefore, before);
|
|
@@ -2148,7 +2269,7 @@
|
|
|
2148
2269
|
cells.set(name, new aoye.Computed(() => computedData.get()[name]));
|
|
2149
2270
|
}
|
|
2150
2271
|
}
|
|
2151
|
-
|
|
2272
|
+
aoye.backupSignal(data, parentData);
|
|
2152
2273
|
return data;
|
|
2153
2274
|
}
|
|
2154
2275
|
getData() {
|
|
@@ -2189,7 +2310,7 @@
|
|
|
2189
2310
|
} else if (ComponentOrRender instanceof InlineFragment) {
|
|
2190
2311
|
const conf = ComponentOrRender;
|
|
2191
2312
|
child = aoye.deepSignal({}, aoye.getPulling(), true);
|
|
2192
|
-
|
|
2313
|
+
aoye.backupSignal(child, conf.data);
|
|
2193
2314
|
tokenizer = conf.tokenizer;
|
|
2194
2315
|
fragmentSnapshot = conf.snapshot;
|
|
2195
2316
|
__logicType = FakeType.Fragment;
|
|
@@ -2199,7 +2320,7 @@
|
|
|
2199
2320
|
const boundStore = render.boundStore;
|
|
2200
2321
|
child = aoye.deepSignal({}, aoye.getPulling(), true);
|
|
2201
2322
|
if (boundStore) {
|
|
2202
|
-
|
|
2323
|
+
aoye.backupSignal(child, boundStore);
|
|
2203
2324
|
}
|
|
2204
2325
|
tokenizer = render(true);
|
|
2205
2326
|
__logicType = FakeType.Fragment;
|
|
@@ -2232,7 +2353,7 @@
|
|
|
2232
2353
|
resumeSnapshot
|
|
2233
2354
|
};
|
|
2234
2355
|
this.onePropParsed = onePropParsed;
|
|
2235
|
-
node.realAfter = this.insertAnchor('component-after');
|
|
2356
|
+
node.realAfter = this.insertAnchor(node, 'component-after');
|
|
2236
2357
|
return node;
|
|
2237
2358
|
}
|
|
2238
2359
|
getFn(data, expression) {
|
|
@@ -2327,7 +2448,7 @@
|
|
|
2327
2448
|
break;
|
|
2328
2449
|
}
|
|
2329
2450
|
ifNode.condition = signal;
|
|
2330
|
-
ifNode.realAfter = this.insertAnchor(`${keyWord.value}-after`);
|
|
2451
|
+
ifNode.realAfter = this.insertAnchor(ifNode, `${keyWord.value}-after`);
|
|
2331
2452
|
const ef = this.effect(({
|
|
2332
2453
|
val
|
|
2333
2454
|
}) => {
|
|
@@ -2370,10 +2491,11 @@
|
|
|
2370
2491
|
const tokenizer = this.tokenizer;
|
|
2371
2492
|
do {
|
|
2372
2493
|
const isComponent = _node.__logicType & TokenizerSwitcherBit;
|
|
2494
|
+
const isTp = _node.__logicType === FakeType.Tp;
|
|
2373
2495
|
let snapshot, dentLen;
|
|
2374
2496
|
const data = this.getData();
|
|
2375
2497
|
const unHandledKey = this.attributeList(_node, data);
|
|
2376
|
-
if (isComponent) {
|
|
2498
|
+
if (isComponent || isTp) {
|
|
2377
2499
|
snapshot = tokenizer.snapshot(undefined, -1);
|
|
2378
2500
|
dentLen = tokenizer.dentStack[tokenizer.dentStack.length - 1];
|
|
2379
2501
|
}
|
|
@@ -2385,6 +2507,9 @@
|
|
|
2385
2507
|
if ((tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
2386
2508
|
break;
|
|
2387
2509
|
}
|
|
2510
|
+
} else if (isTp) {
|
|
2511
|
+
_node.snapshot = snapshot;
|
|
2512
|
+
break;
|
|
2388
2513
|
} else {
|
|
2389
2514
|
break;
|
|
2390
2515
|
}
|
|
@@ -2443,7 +2568,7 @@
|
|
|
2443
2568
|
prevKeys.delete(k);
|
|
2444
2569
|
if (isComponent) {
|
|
2445
2570
|
const savedK = savedDefaults.has(k);
|
|
2446
|
-
if (!savedK &&
|
|
2571
|
+
if (!savedK && bobeShared.hasOwn(rawTarget, k)) {
|
|
2447
2572
|
savedDefaults.set(k, rawTarget[k]);
|
|
2448
2573
|
}
|
|
2449
2574
|
const val = props[k];
|
|
@@ -2476,7 +2601,7 @@
|
|
|
2476
2601
|
}).get();
|
|
2477
2602
|
}
|
|
2478
2603
|
} else if (hookType === 'dynamic') {
|
|
2479
|
-
const valueIsMapKey =
|
|
2604
|
+
const valueIsMapKey = Boolean(aoye.getProxyHasKey(data, value));
|
|
2480
2605
|
const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
|
|
2481
2606
|
this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
|
|
2482
2607
|
} else if (hookType === 'static') {
|