tutuca 0.9.95 → 0.9.96

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.
@@ -8407,7 +8407,7 @@ class PathBuilder {
8407
8407
  return this.add(new SeqStep(name, key));
8408
8408
  }
8409
8409
  }
8410
- var NONE, BindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, DynStep, DynEachStep, NO_EVENT_INFO, BUBBLING_EVENTS;
8410
+ var NONE, BindStep, ScopeBindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, DynStep, DynEachStep, NO_EVENT_INFO, BUBBLING_EVENTS;
8411
8411
  var init_path = __esm(() => {
8412
8412
  NONE = Symbol("NONE");
8413
8413
  BindStep = class BindStep extends Step {
@@ -8434,6 +8434,22 @@ var init_path = __esm(() => {
8434
8434
  return null;
8435
8435
  }
8436
8436
  };
8437
+ ScopeBindStep = class ScopeBindStep extends BindStep {
8438
+ constructor(val, binds = {}) {
8439
+ super(binds);
8440
+ this.val = val;
8441
+ }
8442
+ enterFrame(stack, _prev, next) {
8443
+ const dyn = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
8444
+ return stack.enter(next, { ...this.binds, ...dyn }, false);
8445
+ }
8446
+ withIndex(i) {
8447
+ return new ScopeBindStep(this.val, { ...this.binds, key: i });
8448
+ }
8449
+ withKey(key) {
8450
+ return new ScopeBindStep(this.val, { ...this.binds, key });
8451
+ }
8452
+ };
8437
8453
  FieldStep = class FieldStep extends Step {
8438
8454
  constructor(field) {
8439
8455
  super();
@@ -8492,9 +8508,9 @@ var init_path = __esm(() => {
8492
8508
  }
8493
8509
  };
8494
8510
  EachBindStep = class EachBindStep extends Step {
8495
- constructor(seqVal, key) {
8511
+ constructor(iterInfo, key) {
8496
8512
  super();
8497
- this.seqVal = seqVal;
8513
+ this.iterInfo = iterInfo;
8498
8514
  this.key = key;
8499
8515
  }
8500
8516
  lookup(v, _dval) {
@@ -8504,8 +8520,7 @@ var init_path = __esm(() => {
8504
8520
  return v;
8505
8521
  }
8506
8522
  enterFrame(stack, _prev, next) {
8507
- const item = this.seqVal.eval(stack)?.get(this.key, null);
8508
- return stack.enter(next, { key: this.key, value: item }, false);
8523
+ return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
8509
8524
  }
8510
8525
  toAbstractPathStep() {
8511
8526
  return null;
@@ -9833,6 +9848,9 @@ class Renderer {
9833
9848
  _renderMetadata(info) {
9834
9849
  return new VComment(`§${JSON.stringify(info)}§`);
9835
9850
  }
9851
+ renderScopeMeta(nid, dom) {
9852
+ return new VFragment([this._renderMetadata({ $: "Scope", nid }), dom]);
9853
+ }
9836
9854
  }
9837
9855
  var DATASET_ATTRS, getSeqInfo = (seq) => isIndexed(seq) ? imIndexedIter : isKeyed(seq) ? imKeyedIter : seq?.[SEQ_INFO] ?? unkIter, normalizeRange = (start, end, size) => {
9838
9856
  let s = start == null ? 0 : start < 0 ? size + start : start;
@@ -10029,6 +10047,16 @@ class IterInfo {
10029
10047
  const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
10030
10048
  return { seq, filter, loopWith, enricher };
10031
10049
  }
10050
+ enrichBinds(stack, key) {
10051
+ const { seq, loopWith, enricher } = this.eval(stack);
10052
+ const value = seq?.get ? seq.get(key, null) : null;
10053
+ const binds = { key, value };
10054
+ if (enricher) {
10055
+ const { iterData } = unpackLoopResult(loopWith.call(stack.it, seq), seq);
10056
+ enricher.call(stack.it, binds, key, value, iterData);
10057
+ }
10058
+ return binds;
10059
+ }
10032
10060
  }
10033
10061
  function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
10034
10062
  return { consumed: new Set(consumed), wrappable, wrapper };
@@ -10505,10 +10533,11 @@ var init_anode = __esm(() => {
10505
10533
  ScopeNode = class ScopeNode extends WrapperNode {
10506
10534
  render(stack, rx) {
10507
10535
  const binds = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
10508
- return this.node.render(stack.enter(stack.it, binds, false), rx);
10536
+ const dom = this.node.render(stack.enter(stack.it, binds, false), rx);
10537
+ return rx.renderScopeMeta(this.nodeId, dom);
10509
10538
  }
10510
10539
  toPathStep(_ctx) {
10511
- return new BindStep({});
10540
+ return new ScopeBindStep(this.val);
10512
10541
  }
10513
10542
  wrapNode(node) {
10514
10543
  this.node = node;
@@ -10525,7 +10554,7 @@ var init_anode = __esm(() => {
10525
10554
  return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
10526
10555
  }
10527
10556
  toPathStep(ctx) {
10528
- return ctx.hasKey ? new EachBindStep(this.val, ctx.key) : null;
10557
+ return ctx.hasKey ? new EachBindStep(this.iterInfo, ctx.key) : null;
10529
10558
  }
10530
10559
  static register = true;
10531
10560
  };
@@ -145,6 +145,23 @@ class BindStep extends Step {
145
145
  }
146
146
  }
147
147
 
148
+ class ScopeBindStep extends BindStep {
149
+ constructor(val, binds = {}) {
150
+ super(binds);
151
+ this.val = val;
152
+ }
153
+ enterFrame(stack, _prev, next) {
154
+ const dyn = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
155
+ return stack.enter(next, { ...this.binds, ...dyn }, false);
156
+ }
157
+ withIndex(i) {
158
+ return new ScopeBindStep(this.val, { ...this.binds, key: i });
159
+ }
160
+ withKey(key) {
161
+ return new ScopeBindStep(this.val, { ...this.binds, key });
162
+ }
163
+ }
164
+
148
165
  class FieldStep extends Step {
149
166
  constructor(field) {
150
167
  super();
@@ -206,9 +223,9 @@ class SeqAccessStep extends Step {
206
223
  }
207
224
 
208
225
  class EachBindStep extends Step {
209
- constructor(seqVal, key) {
226
+ constructor(iterInfo, key) {
210
227
  super();
211
- this.seqVal = seqVal;
228
+ this.iterInfo = iterInfo;
212
229
  this.key = key;
213
230
  }
214
231
  lookup(v, _dval) {
@@ -218,8 +235,7 @@ class EachBindStep extends Step {
218
235
  return v;
219
236
  }
220
237
  enterFrame(stack, _prev, next) {
221
- const item = this.seqVal.eval(stack)?.get(this.key, null);
222
- return stack.enter(next, { key: this.key, value: item }, false);
238
+ return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
223
239
  }
224
240
  toAbstractPathStep() {
225
241
  return null;
@@ -1874,6 +1890,9 @@ class Renderer {
1874
1890
  _renderMetadata(info) {
1875
1891
  return new VComment(`§${JSON.stringify(info)}§`);
1876
1892
  }
1893
+ renderScopeMeta(nid, dom) {
1894
+ return new VFragment([this._renderMetadata({ $: "Scope", nid }), dom]);
1895
+ }
1877
1896
  }
1878
1897
  var getSeqInfo = (seq) => isIndexed(seq) ? imIndexedIter : isKeyed(seq) ? imKeyedIter : seq?.[SEQ_INFO] ?? unkIter;
1879
1898
  var normalizeRange = (start, end, size) => {
@@ -2394,10 +2413,11 @@ class SlotNode extends WrapperNode {
2394
2413
  class ScopeNode extends WrapperNode {
2395
2414
  render(stack, rx) {
2396
2415
  const binds = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
2397
- return this.node.render(stack.enter(stack.it, binds, false), rx);
2416
+ const dom = this.node.render(stack.enter(stack.it, binds, false), rx);
2417
+ return rx.renderScopeMeta(this.nodeId, dom);
2398
2418
  }
2399
2419
  toPathStep(_ctx) {
2400
- return new BindStep({});
2420
+ return new ScopeBindStep(this.val);
2401
2421
  }
2402
2422
  wrapNode(node) {
2403
2423
  this.node = node;
@@ -2415,7 +2435,7 @@ class EachNode extends WrapperNode {
2415
2435
  return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
2416
2436
  }
2417
2437
  toPathStep(ctx) {
2418
- return ctx.hasKey ? new EachBindStep(this.val, ctx.key) : null;
2438
+ return ctx.hasKey ? new EachBindStep(this.iterInfo, ctx.key) : null;
2419
2439
  }
2420
2440
  static register = true;
2421
2441
  }
@@ -2434,6 +2454,16 @@ class IterInfo {
2434
2454
  const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
2435
2455
  return { seq, filter, loopWith, enricher };
2436
2456
  }
2457
+ enrichBinds(stack, key) {
2458
+ const { seq, loopWith, enricher } = this.eval(stack);
2459
+ const value = seq?.get ? seq.get(key, null) : null;
2460
+ const binds = { key, value };
2461
+ if (enricher) {
2462
+ const { iterData } = unpackLoopResult(loopWith.call(stack.it, seq), seq);
2463
+ enricher.call(stack.it, binds, key, value, iterData);
2464
+ }
2465
+ return binds;
2466
+ }
2437
2467
  }
2438
2468
  function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
2439
2469
  return { consumed: new Set(consumed), wrappable, wrapper };
@@ -7799,6 +7799,23 @@ class BindStep extends Step {
7799
7799
  }
7800
7800
  }
7801
7801
 
7802
+ class ScopeBindStep extends BindStep {
7803
+ constructor(val, binds = {}) {
7804
+ super(binds);
7805
+ this.val = val;
7806
+ }
7807
+ enterFrame(stack, _prev, next) {
7808
+ const dyn = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
7809
+ return stack.enter(next, { ...this.binds, ...dyn }, false);
7810
+ }
7811
+ withIndex(i) {
7812
+ return new ScopeBindStep(this.val, { ...this.binds, key: i });
7813
+ }
7814
+ withKey(key) {
7815
+ return new ScopeBindStep(this.val, { ...this.binds, key });
7816
+ }
7817
+ }
7818
+
7802
7819
  class FieldStep extends Step {
7803
7820
  constructor(field) {
7804
7821
  super();
@@ -7860,9 +7877,9 @@ class SeqAccessStep extends Step {
7860
7877
  }
7861
7878
 
7862
7879
  class EachBindStep extends Step {
7863
- constructor(seqVal, key) {
7880
+ constructor(iterInfo, key) {
7864
7881
  super();
7865
- this.seqVal = seqVal;
7882
+ this.iterInfo = iterInfo;
7866
7883
  this.key = key;
7867
7884
  }
7868
7885
  lookup(v, _dval) {
@@ -7872,8 +7889,7 @@ class EachBindStep extends Step {
7872
7889
  return v;
7873
7890
  }
7874
7891
  enterFrame(stack, _prev, next) {
7875
- const item = this.seqVal.eval(stack)?.get(this.key, null);
7876
- return stack.enter(next, { key: this.key, value: item }, false);
7892
+ return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
7877
7893
  }
7878
7894
  toAbstractPathStep() {
7879
7895
  return null;
@@ -9525,6 +9541,9 @@ class Renderer {
9525
9541
  _renderMetadata(info) {
9526
9542
  return new VComment(`§${JSON.stringify(info)}§`);
9527
9543
  }
9544
+ renderScopeMeta(nid, dom) {
9545
+ return new VFragment([this._renderMetadata({ $: "Scope", nid }), dom]);
9546
+ }
9528
9547
  }
9529
9548
  var getSeqInfo = (seq) => isIndexed(seq) ? imIndexedIter : isKeyed(seq) ? imKeyedIter : seq?.[SEQ_INFO] ?? unkIter;
9530
9549
  var normalizeRange = (start, end, size) => {
@@ -10045,10 +10064,11 @@ class SlotNode extends WrapperNode {
10045
10064
  class ScopeNode extends WrapperNode {
10046
10065
  render(stack, rx) {
10047
10066
  const binds = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
10048
- return this.node.render(stack.enter(stack.it, binds, false), rx);
10067
+ const dom = this.node.render(stack.enter(stack.it, binds, false), rx);
10068
+ return rx.renderScopeMeta(this.nodeId, dom);
10049
10069
  }
10050
10070
  toPathStep(_ctx) {
10051
- return new BindStep({});
10071
+ return new ScopeBindStep(this.val);
10052
10072
  }
10053
10073
  wrapNode(node) {
10054
10074
  this.node = node;
@@ -10066,7 +10086,7 @@ class EachNode extends WrapperNode {
10066
10086
  return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
10067
10087
  }
10068
10088
  toPathStep(ctx) {
10069
- return ctx.hasKey ? new EachBindStep(this.val, ctx.key) : null;
10089
+ return ctx.hasKey ? new EachBindStep(this.iterInfo, ctx.key) : null;
10070
10090
  }
10071
10091
  static register = true;
10072
10092
  }
@@ -10085,6 +10105,16 @@ class IterInfo {
10085
10105
  const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
10086
10106
  return { seq, filter, loopWith, enricher };
10087
10107
  }
10108
+ enrichBinds(stack, key) {
10109
+ const { seq, loopWith, enricher } = this.eval(stack);
10110
+ const value = seq?.get ? seq.get(key, null) : null;
10111
+ const binds = { key, value };
10112
+ if (enricher) {
10113
+ const { iterData } = unpackLoopResult(loopWith.call(stack.it, seq), seq);
10114
+ enricher.call(stack.it, binds, key, value, iterData);
10115
+ }
10116
+ return binds;
10117
+ }
10088
10118
  }
10089
10119
  function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
10090
10120
  return { consumed: new Set(consumed), wrappable, wrapper };