bobe 0.0.61 → 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.
@@ -1,5 +1,5 @@
1
- import { Queue, isNum, matchIdStart2, matchId, escapeMap, pickInPlace, jsVarRegexp, date32 } from 'bobe-shared';
2
- import { Signal, Computed, Keys, isStore, getPulling, setPulling, deepSignal, toRaw, ScheduleType, runWithPulling, Scope, Store, noopEffect, NoopEffect, Effect, effect as effect$1, shareSignal, flushMicroEffectManual } from 'aoye';
1
+ import { Queue, isNum, matchIdStart2, matchId, escapeMap, pickInPlace, jsVarRegexp, date32, hasOwn } from 'bobe-shared';
2
+ import { Signal, Computed, Keys, isStore, getPulling, setPulling, runWithPulling, getProxyHasKey, deepSignal, Scope, backupSignal, toRaw, ScheduleType, Store, noopEffect, NoopEffect, Effect, effect as effect$1, shareSignal, flushMicroEffectManual } from 'aoye';
3
3
  export { Store } from 'aoye';
4
4
 
5
5
  let TokenType = function (TokenType) {
@@ -1461,7 +1461,7 @@ const SAFE_HANDLER = {
1461
1461
  has: () => true,
1462
1462
  get: (t, k) => {
1463
1463
  if (typeof k === 'symbol') return t[k];
1464
- return k in t ? t[k] : undefined;
1464
+ return t[k];
1465
1465
  }
1466
1466
  };
1467
1467
  const safe = data => new Proxy(data, SAFE_HANDLER);
@@ -1521,7 +1521,7 @@ class Interpreter {
1521
1521
  stack.push({
1522
1522
  node: ctx.current,
1523
1523
  prev: ctx.prevSibling
1524
- }, !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 & CtxProviderBit ? NodeSort.CtxProvider : 0));
1524
+ }, !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));
1525
1525
  if (ctx.current.__logicType) {
1526
1526
  this.beforeLogicIndent?.(ctx.current);
1527
1527
  if (isEffectNode) {
@@ -1530,7 +1530,9 @@ class Interpreter {
1530
1530
  ctx.prevSibling = ctx.current.realBefore;
1531
1531
  }
1532
1532
  if (ctx.current.__logicType & FakeType.Tp) {
1533
- ctx.realParent = ctx.current.tpData[Keys.Raw].node;
1533
+ runWithPulling(() => {
1534
+ ctx.realParent = ctx.current.tpData.node;
1535
+ }, null);
1534
1536
  ctx.prevSibling = ctx.current.contentBefore;
1535
1537
  }
1536
1538
  }
@@ -1566,7 +1568,12 @@ class Interpreter {
1566
1568
  sort = _stack$pop2[1];
1567
1569
  if (!parent.__logicType) {
1568
1570
  const prevSameType = stack.peekByType(NodeSort.Real);
1569
- ctx.realParent = prevSameType?.node || root;
1571
+ const sameNode = prevSameType?.node;
1572
+ if (sameNode) {
1573
+ ctx.realParent = sameNode.__logicType === FakeType.Tp ? runWithPulling(() => sameNode.tpData.node, null) : sameNode;
1574
+ } else {
1575
+ ctx.realParent = root;
1576
+ }
1570
1577
  } else {
1571
1578
  if (sort & NodeSort.EffectNode) {
1572
1579
  const parentLogic = stack.peekByType(NodeSort.EffectNode)?.node;
@@ -1703,7 +1710,7 @@ class Interpreter {
1703
1710
  return _node;
1704
1711
  }
1705
1712
  dynamicDeclaration(pData, value, ctx) {
1706
- const valueIsMapKey = Reflect.has(pData[Keys.Raw], value);
1713
+ const valueIsMapKey = Boolean(getProxyHasKey(pData, value));
1707
1714
  let node = {
1708
1715
  __logicType: null,
1709
1716
  realParent: null,
@@ -1787,10 +1794,7 @@ class Interpreter {
1787
1794
  this.removeLogicNode(node);
1788
1795
  }
1789
1796
  };
1790
- }, [() => {
1791
- const val = valueIsMapKey ? pData[value] : this.getFn(pData, value)();
1792
- return val;
1793
- }], {
1797
+ }, [valueIsMapKey ? () => pData[value] : this.getFn(pData, value)], {
1794
1798
  type: 'render'
1795
1799
  });
1796
1800
  return node;
@@ -1818,7 +1822,13 @@ class Interpreter {
1818
1822
  const before = node.contentBefore = this.createAnchor('tp-content-before', true);
1819
1823
  const after = node.contentAfter = this.createAnchor('tp-content-after', true);
1820
1824
  let firstRender = true;
1821
- node.effect = this.effect(({
1825
+ let scope = new Scope(() => {});
1826
+ scope.scope = null;
1827
+ runWithPulling(() => {
1828
+ scope.get();
1829
+ }, null);
1830
+ node.effect = scope;
1831
+ this.effect(({
1822
1832
  old: oldDom,
1823
1833
  val: dom
1824
1834
  }) => {
@@ -1862,19 +1872,29 @@ class Interpreter {
1862
1872
  } else {
1863
1873
  this.handleInsert(dom, after, null);
1864
1874
  this.handleInsert(dom, before, null);
1865
- this.tokenizer = node.owner.tokenizer;
1866
- this.tokenizer.resume(node.snapshot);
1867
- this.tokenizer.useDedentAsEof = false;
1868
- this.program(dom, node.owner, before, node);
1875
+ runWithPulling(() => {
1876
+ this.tokenizer = node.owner.tokenizer;
1877
+ this.tokenizer.resume(node.snapshot);
1878
+ this.tokenizer.useDedentAsEof = false;
1879
+ this.program(dom, node.owner, before, node);
1880
+ }, scope);
1869
1881
  }
1870
1882
  } else {
1871
1883
  removeTpChild();
1884
+ scope.dispose();
1885
+ scope = new Scope(() => {});
1886
+ scope.scope = null;
1887
+ runWithPulling(() => {
1888
+ scope.get();
1889
+ }, null);
1890
+ node.effect = scope;
1872
1891
  }
1873
1892
  }
1874
1893
  firstRender = false;
1875
1894
  return isDestroy => {
1876
1895
  if (isDestroy) {
1877
1896
  removeTpChild();
1897
+ scope.dispose();
1878
1898
  }
1879
1899
  };
1880
1900
  }, [() => child.node], {
@@ -1886,7 +1906,7 @@ class Interpreter {
1886
1906
  const child = deepSignal({}, getPulling());
1887
1907
  const parentContext = this.ctx.stack.peekByType(NodeSort.Context)?.node?.context;
1888
1908
  if (parentContext) {
1889
- Object.setPrototypeOf(child, parentContext);
1909
+ backupSignal(child, parentContext);
1890
1910
  }
1891
1911
  this.onePropParsed = createStoreOnePropParsed(child);
1892
1912
  const node = {
@@ -2274,7 +2294,7 @@ class Interpreter {
2274
2294
  cells.set(name, new Computed(() => computedData.get()[name]));
2275
2295
  }
2276
2296
  }
2277
- Object.setPrototypeOf(data, parentData);
2297
+ backupSignal(data, parentData);
2278
2298
  return data;
2279
2299
  }
2280
2300
  getData() {
@@ -2315,7 +2335,7 @@ class Interpreter {
2315
2335
  } else if (ComponentOrRender instanceof InlineFragment) {
2316
2336
  const conf = ComponentOrRender;
2317
2337
  child = deepSignal({}, getPulling(), true);
2318
- Object.setPrototypeOf(child, conf.data);
2338
+ backupSignal(child, conf.data);
2319
2339
  tokenizer = conf.tokenizer;
2320
2340
  fragmentSnapshot = conf.snapshot;
2321
2341
  __logicType = FakeType.Fragment;
@@ -2325,7 +2345,7 @@ class Interpreter {
2325
2345
  const boundStore = render.boundStore;
2326
2346
  child = deepSignal({}, getPulling(), true);
2327
2347
  if (boundStore) {
2328
- Object.setPrototypeOf(child, boundStore);
2348
+ backupSignal(child, boundStore);
2329
2349
  }
2330
2350
  tokenizer = render(true);
2331
2351
  __logicType = FakeType.Fragment;
@@ -2573,7 +2593,7 @@ class Interpreter {
2573
2593
  prevKeys.delete(k);
2574
2594
  if (isComponent) {
2575
2595
  const savedK = savedDefaults.has(k);
2576
- if (!savedK && Object.prototype.hasOwnProperty.call(rawTarget, k)) {
2596
+ if (!savedK && hasOwn(rawTarget, k)) {
2577
2597
  savedDefaults.set(k, rawTarget[k]);
2578
2598
  }
2579
2599
  const val = props[k];
@@ -2606,7 +2626,7 @@ class Interpreter {
2606
2626
  }).get();
2607
2627
  }
2608
2628
  } else if (hookType === 'dynamic') {
2609
- const valueIsMapKey = Reflect.has(data[Keys.Raw], value);
2629
+ const valueIsMapKey = Boolean(getProxyHasKey(data, value));
2610
2630
  const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
2611
2631
  this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
2612
2632
  } else if (hookType === 'static') {