tutuca 0.9.113 → 0.9.115

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.
@@ -2,9 +2,8 @@
2
2
  import { is } from "immutable";
3
3
 
4
4
  // src/path.js
5
- var NONE = Symbol("NONE");
6
-
7
- class Step {
5
+ var NONE = /* @__PURE__ */ Symbol("NONE");
6
+ var Step = class {
8
7
  lookup(_v, dval = null) {
9
8
  return dval;
10
9
  }
@@ -17,15 +16,19 @@ class Step {
17
16
  toAbstractPathStep() {
18
17
  return this;
19
18
  }
19
+ // Freeze any field-resolved key against the value `v` entering this step (see
20
+ // `Path.pinKeys`). Most steps carry no live key and pin to themselves.
20
21
  pinKey(_v) {
21
22
  return this;
22
23
  }
24
+ // A generic `{ field, key? }` descriptor for this step, or null for frame-only
25
+ // steps (binds) that address no field. Used by `Path.toKeys()` so tooling can
26
+ // introspect a path without reaching into Step subclasses.
23
27
  toKey() {
24
28
  return null;
25
29
  }
26
- }
27
-
28
- class BindStep extends Step {
30
+ };
31
+ var BindStep = class _BindStep extends Step {
29
32
  constructor(binds) {
30
33
  super();
31
34
  this.binds = binds;
@@ -40,17 +43,16 @@ class BindStep extends Step {
40
43
  return stack.enter(next, { ...this.binds }, false);
41
44
  }
42
45
  withIndex(i) {
43
- return new BindStep({ ...this.binds, key: i });
46
+ return new _BindStep({ ...this.binds, key: i });
44
47
  }
45
48
  withKey(key) {
46
- return new BindStep({ ...this.binds, key });
49
+ return new _BindStep({ ...this.binds, key });
47
50
  }
48
51
  toAbstractPathStep() {
49
52
  return null;
50
53
  }
51
- }
52
-
53
- class ScopeBindStep extends BindStep {
54
+ };
55
+ var ScopeBindStep = class _ScopeBindStep extends BindStep {
54
56
  constructor(val, binds = {}) {
55
57
  super(binds);
56
58
  this.val = val;
@@ -60,14 +62,13 @@ class ScopeBindStep extends BindStep {
60
62
  return stack.enter(next, { ...this.binds, ...dyn }, false);
61
63
  }
62
64
  withIndex(i) {
63
- return new ScopeBindStep(this.val, { ...this.binds, key: i });
65
+ return new _ScopeBindStep(this.val, { ...this.binds, key: i });
64
66
  }
65
67
  withKey(key) {
66
- return new ScopeBindStep(this.val, { ...this.binds, key });
68
+ return new _ScopeBindStep(this.val, { ...this.binds, key });
67
69
  }
68
- }
69
-
70
- class FieldStep extends Step {
70
+ };
71
+ var FieldStep = class extends Step {
71
72
  constructor(field) {
72
73
  super();
73
74
  this.field = field;
@@ -87,9 +88,8 @@ class FieldStep extends Step {
87
88
  toKey() {
88
89
  return { field: this.field };
89
90
  }
90
- }
91
-
92
- class SeqStep extends Step {
91
+ };
92
+ var SeqStep = class extends Step {
93
93
  constructor(field, key) {
94
94
  super();
95
95
  this.field = field;
@@ -109,9 +109,8 @@ class SeqStep extends Step {
109
109
  toKey() {
110
110
  return { field: this.field, key: this.key };
111
111
  }
112
- }
113
-
114
- class SeqAccessStep extends Step {
112
+ };
113
+ var SeqAccessStep = class extends Step {
115
114
  constructor(seqField, keyField) {
116
115
  super();
117
116
  this.seqField = seqField;
@@ -127,16 +126,20 @@ class SeqAccessStep extends Step {
127
126
  const key = root?.get(this.keyField, NONE);
128
127
  return seq === NONE || key === NONE ? root : root.set(this.seqField, seq.set(key, v));
129
128
  }
129
+ // Resolve `keyField` against `v` now and freeze it as a literal-key `SeqStep`, so a
130
+ // later lookup/setValue lands on this same item even if `keyField` changes meanwhile.
130
131
  pinKey(v) {
131
132
  const key = v?.get(this.keyField, NONE);
132
133
  return key === NONE ? this : new SeqStep(this.seqField, key);
133
134
  }
135
+ // The key is a *field reference* resolved live, so it is unknown without a value;
136
+ // report the seq field (no key) rather than dropping the step, which would shift
137
+ // the indices of later keys. Call `Path.pinKeys(root)` first to get a concrete key.
134
138
  toKey() {
135
139
  return { field: this.seqField };
136
140
  }
137
- }
138
-
139
- class EachBindStep extends Step {
141
+ };
142
+ var EachBindStep = class extends Step {
140
143
  constructor(iterInfo, key) {
141
144
  super();
142
145
  this.iterInfo = iterInfo;
@@ -148,33 +151,34 @@ class EachBindStep extends Step {
148
151
  setValue(_root, v) {
149
152
  return v;
150
153
  }
154
+ // Replay the renderer's per-item binds (key, value + any @enrich-with binds)
155
+ // so a rebuilt stack matches the one @each rendered with.
151
156
  enterFrame(stack, _prev, next) {
152
157
  return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
153
158
  }
154
159
  toAbstractPathStep() {
155
160
  return null;
156
161
  }
157
- }
158
-
159
- class EachRenderItStep extends SeqStep {
162
+ };
163
+ var EachRenderItStep = class extends SeqStep {
160
164
  enterFrame(stack, _prev, next) {
161
165
  return stack.enter(next, { key: this.key, value: next }, false).enter(next, {}, true);
162
166
  }
163
167
  toAbstractPathStep() {
164
168
  return new SeqStep(this.field, this.key);
165
169
  }
166
- }
170
+ };
167
171
  function warnRawDynStep(op, step) {
168
172
  console.warn(`Path.${op} reached a DynStep: call toTransactionPath() first`, step);
169
173
  }
170
-
171
- class DynStep extends Step {
174
+ var DynStep = class extends Step {
172
175
  constructor(producerCompId, producerSteps) {
173
176
  super();
174
177
  this.producerCompId = producerCompId;
175
178
  this.producerSteps = producerSteps;
176
- this.interiorCids = new Set;
179
+ this.interiorCids = /* @__PURE__ */ new Set();
177
180
  }
181
+ // Steps spliced into the transaction path in place of this marker.
178
182
  teleportSteps() {
179
183
  return this.producerSteps;
180
184
  }
@@ -190,17 +194,15 @@ class DynStep extends Step {
190
194
  warnRawDynStep("enterFrame", this);
191
195
  return stack;
192
196
  }
193
- }
194
-
195
- class DynEachStep extends DynStep {
197
+ };
198
+ var DynEachStep = class extends DynStep {
196
199
  constructor(producerCompId, producerSteps, key) {
197
200
  super(producerCompId, producerSteps);
198
201
  this.key = key;
199
202
  }
200
203
  teleportSteps() {
201
204
  const { producerSteps, key } = this;
202
- if (producerSteps.length === 0)
203
- return producerSteps;
205
+ if (producerSteps.length === 0) return producerSteps;
204
206
  const last = producerSteps[producerSteps.length - 1];
205
207
  if (!(last instanceof FieldStep)) {
206
208
  console.warn("DynEachStep: seq-access dynamic cannot be iterated", this);
@@ -208,30 +210,34 @@ class DynEachStep extends DynStep {
208
210
  }
209
211
  return producerSteps.slice(0, -1).concat(new SeqStep(last.field, key));
210
212
  }
211
- }
212
-
213
- class Path {
213
+ };
214
+ var Path = class _Path {
214
215
  constructor(steps = []) {
215
216
  this.steps = steps;
216
217
  }
217
218
  concat(steps) {
218
- return new Path(this.steps.concat(steps));
219
+ return new _Path(this.steps.concat(steps));
219
220
  }
220
221
  popStep() {
221
- return new Path(this.steps.slice(0, -1));
222
+ return new _Path(this.steps.slice(0, -1));
222
223
  }
224
+ // The dispatch path: frame-only steps removed, one step per crossed component
225
+ // (DynStep included). `popStep` over it bubbles through every component.
223
226
  compact() {
224
227
  const out = [];
225
228
  for (const step of this.steps) {
226
229
  const s = step.toAbstractPathStep();
227
230
  if (s !== null) {
228
- if (s !== step)
229
- s._originCid = step._originCid;
231
+ if (s !== step) s._originCid = step._originCid;
230
232
  out.push(s);
231
233
  }
232
234
  }
233
- return new Path(out);
235
+ return new _Path(out);
234
236
  }
237
+ // The abstract path used to apply a transaction: every DynStep is teleported —
238
+ // the steps interior to its producer..consumer span are dropped and the
239
+ // producer's own path spliced in — so a mutation lands on the data's real
240
+ // location. A path with no DynStep is returned unchanged.
235
241
  toTransactionPath() {
236
242
  let hasDyn = false;
237
243
  for (const step of this.steps)
@@ -239,76 +245,80 @@ class Path {
239
245
  hasDyn = true;
240
246
  break;
241
247
  }
242
- if (!hasDyn)
243
- return this;
248
+ if (!hasDyn) return this;
244
249
  const out = [];
245
250
  for (const step of this.steps) {
246
251
  if (step instanceof DynStep) {
247
- while (out.length > 0 && step.interiorCids.has(out[out.length - 1]._originCid))
248
- out.pop();
252
+ while (out.length > 0 && step.interiorCids.has(out[out.length - 1]._originCid)) out.pop();
249
253
  for (const ts of step.teleportSteps()) {
250
254
  ts._originCid = step.producerCompId;
251
255
  out.push(ts);
252
256
  }
253
- } else
254
- out.push(step);
257
+ } else out.push(step);
255
258
  }
256
- return new Path(out);
259
+ return new _Path(out);
257
260
  }
261
+ // Resolve every field-keyed step (e.g. `SeqAccessStep`) against `root`, freezing the
262
+ // key as it is *now* so a later lookup/setValue lands on the same item even if the
263
+ // keyField changed meanwhile (e.g. the selected tab moved while a request was in
264
+ // flight). Returns a new Path with those steps replaced; `this` if nothing pinned.
265
+ // Must be called on a transaction path (no DynSteps — call toTransactionPath first).
258
266
  pinKeys(root) {
259
267
  let curVal = root;
260
268
  let out = null;
261
- for (let i = 0;i < this.steps.length; i++) {
269
+ for (let i = 0; i < this.steps.length; i++) {
262
270
  const step = this.steps[i];
263
271
  const pinned = step.pinKey(curVal);
264
- if (pinned !== step)
265
- (out ??= this.steps.slice())[i] = pinned;
272
+ if (pinned !== step) (out ??= this.steps.slice())[i] = pinned;
266
273
  curVal = step.lookup(curVal, NONE);
267
- if (curVal === NONE)
268
- break;
274
+ if (curVal === NONE) break;
269
275
  }
270
- return out ? new Path(out) : this;
276
+ return out ? new _Path(out) : this;
271
277
  }
272
278
  lookup(v, dval = null) {
273
279
  let curVal = v;
274
280
  for (const step of this.steps) {
275
281
  curVal = step.lookup(curVal, NONE);
276
- if (curVal === NONE)
277
- return dval;
282
+ if (curVal === NONE) return dval;
278
283
  }
279
284
  return curVal;
280
285
  }
286
+ // The values entered along the path, root→leaf (root included): index 0 is `root`,
287
+ // the last entry is the leaf this path resolves to. Stops early at the first
288
+ // unresolvable step. Call on a transaction path (no DynSteps). Used to walk the
289
+ // component instances on a dispatch path (filter via Components.getCompFor).
281
290
  resolveChain(root) {
282
291
  const out = [root];
283
292
  let curVal = root;
284
293
  for (const step of this.steps) {
285
294
  curVal = step.lookup(curVal, NONE);
286
- if (curVal === NONE)
287
- break;
295
+ if (curVal === NONE) break;
288
296
  out.push(curVal);
289
297
  }
290
298
  return out;
291
299
  }
300
+ // A flat `[{ field, key? }]` list of the addressing steps, skipping frame-only
301
+ // steps (binds). Generic path introspection so tooling (e.g. the storybook
302
+ // activity log) can identify which subtree a transaction touched without
303
+ // depending on Step internals. Call on a transaction path (no DynSteps).
292
304
  toKeys() {
293
305
  const out = [];
294
306
  for (const step of this.steps) {
295
307
  const k = step.toKey();
296
- if (k !== null)
297
- out.push(k);
308
+ if (k !== null) out.push(k);
298
309
  }
299
310
  return out;
300
311
  }
301
312
  setValue(root, v) {
302
313
  const intermediates = new Array(this.steps.length);
303
314
  let curVal = root;
304
- for (let i = 0;i < this.steps.length; i++) {
315
+ for (let i = 0; i < this.steps.length; i++) {
305
316
  intermediates[i] = curVal;
306
317
  curVal = this.steps[i].lookup(curVal, NONE);
307
- if (curVal === NONE)
308
- return root;
318
+ if (curVal === NONE) return root;
309
319
  }
310
320
  let newVal = v;
311
- for (let i = this.steps.length - 1;i >= 0; i--) {
321
+ for (let i = this.steps.length - 1; i >= 0; i--) {
312
322
  newVal = this.steps[i].setValue(intermediates[i], newVal);
313
323
  intermediates[i] = newVal;
314
324
  }
@@ -342,8 +352,7 @@ class Path {
342
352
  if (handlers === null && (isLeafComponent || bubbles)) {
343
353
  handlers = findHandlers(comp, eventIds, vid, eventName);
344
354
  if (handlers === null) {
345
- if (isLeafComponent && stopOnNoEvent && !bubbles)
346
- return false;
355
+ if (isLeafComponent && stopOnNoEvent && !bubbles) return false;
347
356
  } else if (!isLeafComponent) {
348
357
  pathSteps.length = 0;
349
358
  pendingDyns.length = 0;
@@ -351,8 +360,7 @@ class Path {
351
360
  }
352
361
  }
353
362
  isLeafComponent = false;
354
- for (const dyn of pendingDyns)
355
- dyn.interiorCids.add(cidNum);
363
+ for (const dyn of pendingDyns) dyn.interiorCids.add(cidNum);
356
364
  if (pushStep) {
357
365
  const step = resolvePathStep(comp, nodeIds, vid);
358
366
  if (step) {
@@ -364,9 +372,8 @@ class Path {
364
372
  }
365
373
  }
366
374
  }
367
- for (let i = pendingDyns.length - 1;i >= 0; i--)
368
- if (pendingDyns[i].producerCompId === cidNum)
369
- pendingDyns.splice(i, 1);
375
+ for (let i = pendingDyns.length - 1; i >= 0; i--)
376
+ if (pendingDyns[i].producerCompId === cidNum) pendingDyns.splice(i, 1);
370
377
  eventIds = [];
371
378
  nodeIds = [];
372
379
  return true;
@@ -374,35 +381,32 @@ class Path {
374
381
  while (node && node !== rootNode && depth < maxDepth) {
375
382
  if (node?.dataset) {
376
383
  const { eid, cid, vid } = node.dataset;
377
- if (eid !== undefined)
378
- eventIds.push(eid);
384
+ if (eid !== void 0) eventIds.push(eid);
379
385
  const metas = metaChain(node.previousSibling);
380
386
  let sawComp = false;
381
387
  for (const m of metas) {
382
388
  if (m.$ === "Comp") {
383
389
  sawComp = true;
384
- if (!crossComponent(m.cid, m.vid))
385
- return NO_EVENT_INFO;
390
+ if (!crossComponent(m.cid, m.vid)) return NO_EVENT_INFO;
386
391
  nodeIds.push({ nid: m.nid });
387
392
  } else {
388
393
  nodeIds.push({ nid: m.nid, si: m.si, sk: m.sk });
389
394
  }
390
395
  }
391
- if (!sawComp && cid !== undefined && !crossComponent(+cid, vid))
392
- return NO_EVENT_INFO;
396
+ if (!sawComp && cid !== void 0 && !crossComponent(+cid, vid)) return NO_EVENT_INFO;
393
397
  }
394
398
  depth += 1;
395
399
  node = node.parentNode;
396
400
  }
397
401
  if (pendingDyns.length > 0)
398
402
  console.warn("event reconstruction: dynamic-var producer not found", pendingDyns);
399
- return [new Path(pathSteps.reverse()), handlers];
403
+ return [new _Path(pathSteps.reverse()), handlers];
400
404
  }
401
405
  static fromEvent(e, rNode, maxDepth, comps, stopOnNoEvent = true) {
402
406
  const { type, target } = e;
403
- return Path.fromNodeAndEventName(target, type, rNode, maxDepth, comps, stopOnNoEvent);
407
+ return _Path.fromNodeAndEventName(target, type, rNode, maxDepth, comps, stopOnNoEvent);
404
408
  }
405
- }
409
+ };
406
410
  function metaChain(n) {
407
411
  const out = [];
408
412
  while (n?.nodeType === 8 && n.textContent[0] === "§") {
@@ -418,13 +422,11 @@ function metaChain(n) {
418
422
  function findHandlers(comp, eventIds, vid, eventName) {
419
423
  for (const eid of eventIds) {
420
424
  const handlers = comp.getEventForId(+eid, vid).getHandlersFor(eventName);
421
- if (handlers !== null)
422
- return handlers;
425
+ if (handlers !== null) return handlers;
423
426
  }
424
427
  return null;
425
428
  }
426
-
427
- class StepCtx {
429
+ var StepCtx = class _StepCtx {
428
430
  constructor(comp, nodeIds, idx, vid) {
429
431
  this.comp = comp;
430
432
  this.nodeIds = nodeIds;
@@ -436,43 +438,38 @@ class StepCtx {
436
438
  }
437
439
  get key() {
438
440
  const m = this.meta;
439
- return m.si !== undefined ? +m.si : m.sk;
441
+ return m.si !== void 0 ? +m.si : m.sk;
440
442
  }
441
443
  get hasKey() {
442
444
  const m = this.meta;
443
- return m.si !== undefined || m.sk !== undefined;
445
+ return m.si !== void 0 || m.sk !== void 0;
444
446
  }
445
447
  next() {
446
448
  const { idx, nodeIds } = this;
447
- return idx + 1 < nodeIds.length ? new StepCtx(this.comp, nodeIds, idx + 1, this.vid) : null;
449
+ return idx + 1 < nodeIds.length ? new _StepCtx(this.comp, nodeIds, idx + 1, this.vid) : null;
448
450
  }
449
451
  resolveNode() {
450
452
  return this.comp.getNodeForId(+this.meta.nid, this.vid);
451
453
  }
452
454
  applyKey(pi) {
453
- if (pi === null)
454
- return null;
455
+ if (pi === null) return null;
455
456
  const m = this.meta;
456
- if (m.si !== undefined)
457
- return pi.withIndex(+m.si);
458
- if (m.sk !== undefined)
459
- return pi.withKey(m.sk);
457
+ if (m.si !== void 0) return pi.withIndex(+m.si);
458
+ if (m.sk !== void 0) return pi.withKey(m.sk);
460
459
  return pi;
461
460
  }
462
- }
461
+ };
463
462
  function resolvePathStep(comp, nodeIds, vid) {
464
- for (let i = 0;i < nodeIds.length; i++) {
463
+ for (let i = 0; i < nodeIds.length; i++) {
465
464
  const ctx = new StepCtx(comp, nodeIds, i, vid);
466
465
  const step = ctx.resolveNode().toPathStep(ctx);
467
- if (step !== null)
468
- return step;
466
+ if (step !== null) return step;
469
467
  }
470
468
  return null;
471
469
  }
472
470
  var NO_EVENT_INFO = [null, null];
473
- var BUBBLING_EVENTS = new Set(["drop"]);
474
-
475
- class PathBuilder {
471
+ var BUBBLING_EVENTS = /* @__PURE__ */ new Set(["drop"]);
472
+ var PathBuilder = class {
476
473
  constructor() {
477
474
  this.pathChanges = [];
478
475
  }
@@ -489,7 +486,7 @@ class PathBuilder {
489
486
  key(name, key) {
490
487
  return this.add(new SeqStep(name, key));
491
488
  }
492
- }
489
+ };
493
490
 
494
491
  // src/value.js
495
492
  var VALID_VAL_ID_RE = /^[a-zA-Z][a-zA-Z0-9_]*\??$/;
@@ -518,11 +515,9 @@ var G_FIELD = K_FIELD | K_METHOD | K_CONST | K_SEQ;
518
515
  var G_VALUE = K_FIELD | K_METHOD | K_BIND | K_DYN | K_NAME | K_TYPE | K_CONST;
519
516
  var G_ALL = G_VALUE | K_STRTPL | K_SEQ;
520
517
  function sizeOf(v) {
521
- if (v == null)
522
- return null;
518
+ if (v == null) return null;
523
519
  const s = v.size;
524
- if (typeof s === "number")
525
- return s;
520
+ if (typeof s === "number") return s;
526
521
  const l = v.length;
527
522
  return typeof l === "number" ? l : null;
528
523
  }
@@ -537,209 +532,174 @@ var PREDICATES = {
537
532
  "null?": { name: "null?", arity: 1, fn: (v) => v == null },
538
533
  "equals?": { name: "equals?", arity: 2, fn: (a, b) => is(a, b) }
539
534
  };
540
-
541
- class ValParser {
542
- constructor() {
543
- this.nullConstVal = new ConstVal(null);
544
- }
545
- const(v) {
546
- return new ConstVal(v);
547
- }
548
- parseToken(s, px) {
549
- const c0 = s.charCodeAt(0);
550
- if (c0 === 39)
551
- return s.length >= 2 && s.charCodeAt(s.length - 1) === 39 ? new ConstVal(unescapeStr(s.slice(1, -1))) : null;
552
- if (c0 === 36 && s.charCodeAt(1) === 39)
553
- return s.length >= 3 && s.charCodeAt(s.length - 1) === 39 ? StrTplVal.parse(s.slice(2, -1), px) : null;
554
- if (s.indexOf("[") !== -1 || s.indexOf("]") !== -1)
555
- return this._parseSeqAccess(s, px);
556
- if (s.indexOf("{") !== -1 || s.indexOf("}") !== -1)
557
- return null;
558
- switch (c0) {
559
- case 94: {
560
- const name = s.slice(1);
561
- const newS = px.frame.macroVars?.[name];
562
- if (newS !== undefined) {
563
- const tokens = tokenizeValue(newS.trim());
564
- if (tokens.length !== 1)
565
- return null;
566
- const val = this.parseToken(tokens[0], px);
567
- if (val instanceof ConstVal)
568
- val.fromMacroVar = true;
569
- return val;
570
- }
571
- px.onParseIssue("bad-value", { role: "macro-var", name, value: s });
572
- return null;
573
- }
574
- case 36:
575
- return mkVal(s.slice(1), MethodVal);
576
- case 64: {
577
- const dot = s.indexOf(".", 1);
578
- if (dot === -1)
579
- return mkVal(s.slice(1), BindVal);
580
- const name = s.slice(1, dot);
581
- const member = s.slice(dot + 1);
582
- return isValidValId(name) && isValidValId(member) ? new BindMemberVal(name, member) : null;
535
+ function parseToken(s, px) {
536
+ const c0 = s.charCodeAt(0);
537
+ if (c0 === 39)
538
+ return s.length >= 2 && s.charCodeAt(s.length - 1) === 39 ? new ConstVal(unescapeStr(s.slice(1, -1))) : null;
539
+ if (c0 === 36 && s.charCodeAt(1) === 39)
540
+ return s.length >= 3 && s.charCodeAt(s.length - 1) === 39 ? StrTplVal.parse(s.slice(2, -1), px) : null;
541
+ if (s.indexOf("[") !== -1 || s.indexOf("]") !== -1) return _parseSeqAccess(s, px);
542
+ if (s.indexOf("{") !== -1 || s.indexOf("}") !== -1) return null;
543
+ switch (c0) {
544
+ case 94: {
545
+ const name = s.slice(1);
546
+ const newS = px.frame.macroVars?.[name];
547
+ if (newS !== void 0) {
548
+ const tokens = tokenizeValue(newS.trim());
549
+ if (tokens.length !== 1) return null;
550
+ const val = parseToken(tokens[0], px);
551
+ if (val instanceof ConstVal) val.fromMacroVar = true;
552
+ return val;
583
553
  }
584
- case 42:
585
- return mkVal(s.slice(1), DynVal);
586
- case 46:
587
- return mkVal(s.slice(1), FieldVal);
554
+ px.onParseIssue("bad-value", { role: "macro-var", name, value: s });
555
+ return null;
556
+ }
557
+ case 36:
558
+ return mkVal(s.slice(1), MethodVal);
559
+ case 64: {
560
+ const dot = s.indexOf(".", 1);
561
+ if (dot === -1) return mkVal(s.slice(1), BindVal);
562
+ const name = s.slice(1, dot);
563
+ const member = s.slice(dot + 1);
564
+ return isValidValId(name) && isValidValId(member) ? new BindMemberVal(name, member) : null;
588
565
  }
589
- const num = VALID_FLOAT_RE.test(s) ? parseFloat(s) : null;
590
- if (Number.isFinite(num))
591
- return new ConstVal(num);
592
- if (s === "true" || s === "false")
593
- return new ConstVal(s === "true");
594
- if (c0 >= 97 && c0 <= 122)
595
- return mkVal(s, NameVal);
596
- if (c0 >= 65 && c0 <= 90)
597
- return mkVal(s, TypeVal);
566
+ case 42:
567
+ return mkVal(s.slice(1), DynVal);
568
+ case 46:
569
+ return mkVal(s.slice(1), FieldVal);
570
+ }
571
+ const num = VALID_FLOAT_RE.test(s) ? parseFloat(s) : null;
572
+ if (Number.isFinite(num)) return new ConstVal(num);
573
+ if (s === "true" || s === "false") return new ConstVal(s === "true");
574
+ if (c0 >= 97 && c0 <= 122) return mkVal(s, NameVal);
575
+ if (c0 >= 65 && c0 <= 90) return mkVal(s, TypeVal);
576
+ return null;
577
+ }
578
+ function _parseSeqAccess(s, px) {
579
+ const open = s.indexOf("[");
580
+ const close = s.indexOf("]");
581
+ if (open < 1 || close !== s.length - 1 || close < open || s.indexOf("[", open + 1) !== -1)
582
+ return null;
583
+ const left = parseToken(s.slice(0, open), px);
584
+ const right = parseToken(s.slice(open + 1, close), px);
585
+ return left instanceof FieldVal && right instanceof FieldVal ? new SeqAccessVal(left, right) : null;
586
+ }
587
+ function _parseSingle(s, px, group) {
588
+ const tokens = tokenizeValue(s.trim());
589
+ if (tokens.length !== 1) return null;
590
+ const val = parseToken(tokens[0], px);
591
+ return val !== null && kindOf(val) & group ? val : null;
592
+ }
593
+ function parseBool(s, px) {
594
+ const t = s.trim();
595
+ const tokens = tokenizeValue(t);
596
+ if (tokens.length !== 1) return tokens.length === 0 ? null : _parsePredicate(t, tokens, px);
597
+ const val = parseToken(tokens[0], px);
598
+ return val !== null && kindOf(val) & G_BOOL ? val : null;
599
+ }
600
+ function parseText(s, px) {
601
+ return _parseSingle(s, px, G_TEXT);
602
+ }
603
+ function parseComponent(s, px) {
604
+ return _parseSingle(s, px, G_COMPONENT);
605
+ }
606
+ function parseSequence(s, px) {
607
+ return _parseSingle(s, px, G_SEQUENCE);
608
+ }
609
+ function parseField(s, px) {
610
+ return _parseSingle(s, px, G_FIELD);
611
+ }
612
+ function parseProvide(s, px) {
613
+ return _parseSingle(s, px, G_PROVIDE);
614
+ }
615
+ function parseMacroAttr(s, px) {
616
+ return _parseSingle(s, px, G_ALL);
617
+ }
618
+ function parseInputHandler(s, px) {
619
+ return _parseHandler(s, px, "input", true, true);
620
+ }
621
+ function parseAlterHandler(s, px) {
622
+ const r = _parseHandler(s, px, "alter", false, false);
623
+ return r === null ? null : r.handlerVal;
624
+ }
625
+ function _parseHandler(s, px, namespace, allowArgs, report) {
626
+ const tokens = tokenizeValue(s.trim());
627
+ const headTok = tokens[0] ?? "";
628
+ const head = headTok === "" ? null : parseToken(headTok, px);
629
+ const hk = kindOf(head);
630
+ let handlerVal;
631
+ if (hk & K_METHOD) handlerVal = head;
632
+ else if (hk & K_NAME) handlerVal = new HandlerNameVal(head.name, namespace);
633
+ else {
634
+ if (report) px.onParseIssue("bad-value", { role: "handler-name", value: headTok });
598
635
  return null;
599
636
  }
600
- _parseSeqAccess(s, px) {
601
- const open = s.indexOf("[");
602
- const close = s.indexOf("]");
603
- if (open < 1 || close !== s.length - 1 || close < open || s.indexOf("[", open + 1) !== -1)
604
- return null;
605
- const left = this.parseToken(s.slice(0, open), px);
606
- const right = this.parseToken(s.slice(open + 1, close), px);
607
- return left instanceof FieldVal && right instanceof FieldVal ? new SeqAccessVal(left, right) : null;
608
- }
609
- _parseSingle(s, px, group) {
610
- const tokens = tokenizeValue(s.trim());
611
- if (tokens.length !== 1)
612
- return null;
613
- const val = this.parseToken(tokens[0], px);
614
- return val !== null && kindOf(val) & group ? val : null;
615
- }
616
- parseBool(s, px) {
617
- const t = s.trim();
618
- const tokens = tokenizeValue(t);
619
- if (tokens.length !== 1)
620
- return tokens.length === 0 ? null : this._parsePredicate(t, tokens, px);
621
- const val = this.parseToken(tokens[0], px);
622
- return val !== null && kindOf(val) & G_BOOL ? val : null;
623
- }
624
- parseText(s, px) {
625
- return this._parseSingle(s, px, G_TEXT);
626
- }
627
- parseComponent(s, px) {
628
- return this._parseSingle(s, px, G_COMPONENT);
629
- }
630
- parseSequence(s, px) {
631
- return this._parseSingle(s, px, G_SEQUENCE);
632
- }
633
- parseField(s, px) {
634
- return this._parseSingle(s, px, G_FIELD);
635
- }
636
- parseProvide(s, px) {
637
- return this._parseSingle(s, px, G_PROVIDE);
638
- }
639
- parseHandlerArg(s, px) {
640
- return this._parseSingle(s, px, G_VALUE);
641
- }
642
- parseMacroAttr(s, px) {
643
- return this._parseSingle(s, px, G_ALL);
644
- }
645
- parseInputHandler(s, px) {
646
- return this._parseHandler(s, px, "input", true, true);
647
- }
648
- parseAlterHandler(s, px) {
649
- const r = this._parseHandler(s, px, "alter", false, false);
650
- return r === null ? null : r.handlerVal;
651
- }
652
- _parseHandler(s, px, namespace, allowArgs, report) {
653
- const tokens = tokenizeValue(s.trim());
654
- const headTok = tokens[0] ?? "";
655
- const head = headTok === "" ? null : this.parseToken(headTok, px);
656
- const hk = kindOf(head);
657
- let handlerVal;
658
- if (hk & K_METHOD)
659
- handlerVal = head;
660
- else if (hk & K_NAME)
661
- handlerVal = new HandlerNameVal(head.name, namespace);
637
+ if (!allowArgs) return tokens.length === 1 ? { handlerVal, args: [] } : null;
638
+ const args = new Array(tokens.length - 1);
639
+ for (let i = 1; i < tokens.length; i++) {
640
+ const val = parseToken(tokens[i], px);
641
+ if (val !== null && kindOf(val) & G_VALUE) args[i - 1] = val;
662
642
  else {
663
- if (report)
664
- px.onParseIssue("bad-value", { role: "handler-name", value: headTok });
665
- return null;
666
- }
667
- if (!allowArgs)
668
- return tokens.length === 1 ? { handlerVal, args: [] } : null;
669
- const args = new Array(tokens.length - 1);
670
- for (let i = 1;i < tokens.length; i++) {
671
- const val = this.parseToken(tokens[i], px);
672
- if (val !== null && kindOf(val) & G_VALUE)
673
- args[i - 1] = val;
674
- else {
675
- if (report)
676
- px.onParseIssue("bad-value", { role: "handler-arg", value: tokens[i] });
677
- args[i - 1] = this.nullConstVal;
678
- }
643
+ if (report) px.onParseIssue("bad-value", { role: "handler-arg", value: tokens[i] });
644
+ args[i - 1] = NULL_CONST_VAL;
679
645
  }
680
- return { handlerVal, args };
681
646
  }
682
- _parsePredicate(s, tokens, px) {
683
- const predName = tokens[0];
684
- const pred = PREDICATES[predName];
685
- if (pred === undefined) {
686
- px.onParseIssue("bad-value", { role: "predicate", value: predName });
687
- return null;
688
- }
689
- const arity = tokens.length - 1;
690
- if (arity !== pred.arity) {
691
- px.onParseIssue("bad-value", { role: "predicate-arity", value: s, predicate: predName });
647
+ return { handlerVal, args };
648
+ }
649
+ function _parsePredicate(s, tokens, px) {
650
+ const predName = tokens[0];
651
+ const pred = PREDICATES[predName];
652
+ if (pred === void 0) {
653
+ px.onParseIssue("bad-value", { role: "predicate", value: predName });
654
+ return null;
655
+ }
656
+ const arity = tokens.length - 1;
657
+ if (arity !== pred.arity) {
658
+ px.onParseIssue("bad-value", { role: "predicate-arity", value: s, predicate: predName });
659
+ return null;
660
+ }
661
+ const args = new Array(arity);
662
+ for (let i = 0; i < arity; i++) {
663
+ const tok = tokens[i + 1];
664
+ const val = parseToken(tok, px);
665
+ if (val === null || !(kindOf(val) & G_BOOL)) {
666
+ px.onParseIssue("bad-value", { role: "predicate-arg", value: tok });
692
667
  return null;
693
668
  }
694
- const args = new Array(arity);
695
- for (let i = 0;i < arity; i++) {
696
- const tok = tokens[i + 1];
697
- const val = this.parseToken(tok, px);
698
- if (val === null || !(kindOf(val) & G_BOOL)) {
699
- px.onParseIssue("bad-value", { role: "predicate-arg", value: tok });
700
- return null;
701
- }
702
- args[i] = val;
703
- }
704
- return new PredicateVal(pred, args);
669
+ args[i] = val;
705
670
  }
671
+ return new PredicateVal(pred, args);
706
672
  }
707
673
  function kindOf(val) {
708
- if (val === null)
709
- return 0;
710
- if (val instanceof ConstVal)
711
- return val.kind;
712
- if (val instanceof StrTplVal)
713
- return val.kind;
714
- if (val instanceof SeqAccessVal)
715
- return K_SEQ;
716
- if (val instanceof FieldVal)
717
- return K_FIELD;
718
- if (val instanceof MethodVal)
719
- return K_METHOD;
720
- if (val instanceof BindVal)
721
- return K_BIND;
722
- if (val instanceof DynVal)
723
- return K_DYN;
724
- if (val instanceof TypeVal)
725
- return K_TYPE;
726
- if (val instanceof NameVal)
727
- return K_NAME;
674
+ if (val === null) return 0;
675
+ if (val instanceof ConstVal) return val.kind;
676
+ if (val instanceof StrTplVal) return val.kind;
677
+ if (val instanceof SeqAccessVal) return K_SEQ;
678
+ if (val instanceof FieldVal) return K_FIELD;
679
+ if (val instanceof MethodVal) return K_METHOD;
680
+ if (val instanceof BindVal) return K_BIND;
681
+ if (val instanceof DynVal) return K_DYN;
682
+ if (val instanceof TypeVal) return K_TYPE;
683
+ if (val instanceof NameVal) return K_NAME;
728
684
  return 0;
729
685
  }
730
-
731
- class BaseVal {
732
- render(_stack, _rx) {}
733
- eval(_stack) {}
686
+ var BaseVal = class {
687
+ render(_stack, _rx) {
688
+ }
689
+ eval(_stack) {
690
+ }
734
691
  toPathItem() {
735
692
  return null;
736
693
  }
694
+ // Value of this expression when it sits in handler position (`@on.<event>`,
695
+ // `@when`, `@enrich-with`, `@loop-with`): the dispatch machinery calls the
696
+ // result with the event args. Defaults to `eval`; `MethodVal` overrides it
697
+ // to hand back the raw function instead of invoking it.
737
698
  evalAsHandler(stack) {
738
699
  return this.eval(stack);
739
700
  }
740
- }
741
-
742
- class ConstVal extends BaseVal {
701
+ };
702
+ var ConstVal = class extends BaseVal {
743
703
  constructor(val, kind = K_CONST) {
744
704
  super();
745
705
  this.val = val;
@@ -755,9 +715,9 @@ class ConstVal extends BaseVal {
755
715
  const v = this.val;
756
716
  return typeof v === "string" ? `'${v.replace(/(['\\])/g, "\\$1")}'` : `${v}`;
757
717
  }
758
- }
759
-
760
- class PredicateVal extends BaseVal {
718
+ };
719
+ var NULL_CONST_VAL = new ConstVal(null);
720
+ var PredicateVal = class extends BaseVal {
761
721
  constructor(pred, args) {
762
722
  super();
763
723
  this.pred = pred;
@@ -766,28 +726,26 @@ class PredicateVal extends BaseVal {
766
726
  eval(stack) {
767
727
  const n = this.args.length;
768
728
  const vals = new Array(n);
769
- for (let i = 0;i < n; i++)
770
- vals[i] = this.args[i].eval(stack);
729
+ for (let i = 0; i < n; i++) vals[i] = this.args[i].eval(stack);
771
730
  return this.pred.fn(...vals);
772
731
  }
773
732
  toString() {
774
733
  return `${this.pred.name} ${this.args.map(String).join(" ")}`;
775
734
  }
776
- }
777
-
778
- class VarVal extends BaseVal {
779
- }
780
-
781
- class StrTplVal extends VarVal {
735
+ };
736
+ var VarVal = class extends BaseVal {
737
+ };
738
+ var StrTplVal = class _StrTplVal extends VarVal {
782
739
  constructor(vals) {
783
740
  super();
784
741
  this.vals = vals;
785
742
  this.kind = this.isLiteral() ? K_CONST : K_STRTPL;
786
743
  }
744
+ // True when this template carries no dynamic placeholder: every part is a
745
+ // plain `ConstVal` and none was bound from a macro variable (the macro
746
+ // placeholder is real in the body even when it resolved to a constant).
787
747
  isLiteral() {
788
- for (const v of this.vals)
789
- if (!(v instanceof ConstVal) || v.fromMacroVar)
790
- return false;
748
+ for (const v of this.vals) if (!(v instanceof ConstVal) || v.fromMacroVar) return false;
791
749
  return true;
792
750
  }
793
751
  render(stack, _rx) {
@@ -795,38 +753,41 @@ class StrTplVal extends VarVal {
795
753
  }
796
754
  eval(stack) {
797
755
  const strs = new Array(this.vals.length);
798
- for (let i = 0;i < this.vals.length; i++)
799
- strs[i] = this.vals[i]?.eval(stack, "");
756
+ for (let i = 0; i < this.vals.length; i++) strs[i] = this.vals[i]?.eval(stack, "");
800
757
  return strs.join("");
801
758
  }
759
+ // When this is a placeholderless literal (see `isLiteral`), returns the
760
+ // string it spells out, in `'…'` source form; otherwise null. The linter
761
+ // uses this to nudge `$'foo'` → `'foo'` (PLACEHOLDERLESS_TEMPLATE_STRING).
802
762
  toLiteralSource() {
803
- if (!this.isLiteral())
804
- return null;
763
+ if (!this.isLiteral()) return null;
805
764
  let out = "";
806
- for (const v of this.vals)
807
- out += v.val;
765
+ for (const v of this.vals) out += v.val;
808
766
  return new ConstVal(out).toString();
809
767
  }
768
+ // `s` is the interior of a `$'…'` template (the text between `$'` and `'`).
769
+ // The interior is unescaped once (`\'`, `\\`) then split on `{…}` groups:
770
+ // text between them becomes a `ConstVal`, expressions inside braces are
771
+ // parsed via `parseText`. A constant-only template is left as a `StrTplVal`
772
+ // (not folded to a `ConstVal`) so the linter can flag it — see
773
+ // `toLiteralSource` and the PLACEHOLDERLESS_TEMPLATE_STRING lint rule.
810
774
  static parse(s, px) {
811
775
  const parts = unescapeStr(s).split(STR_TPL_SPLIT_RE);
812
776
  const vals = new Array(parts.length);
813
- for (let i = 0;i < parts.length; i++) {
777
+ for (let i = 0; i < parts.length; i++) {
814
778
  const part = parts[i];
815
779
  const isExpr = part[0] === "{" && part.at(-1) === "}";
816
- vals[i] = isExpr ? vp.parseText(part.slice(1, -1), px) : new ConstVal(part);
780
+ vals[i] = isExpr ? parseText(part.slice(1, -1), px) : new ConstVal(part);
817
781
  }
818
782
  let lo = 0;
819
783
  let hi = vals.length;
820
784
  const isTrimmable = (v) => v instanceof ConstVal && v.val === "" && !v.fromMacroVar;
821
- while (lo < hi && isTrimmable(vals[lo]))
822
- lo++;
823
- while (hi > lo && isTrimmable(vals[hi - 1]))
824
- hi--;
825
- return new StrTplVal(lo === 0 && hi === vals.length ? vals : vals.slice(lo, hi));
785
+ while (lo < hi && isTrimmable(vals[lo])) lo++;
786
+ while (hi > lo && isTrimmable(vals[hi - 1])) hi--;
787
+ return new _StrTplVal(lo === 0 && hi === vals.length ? vals : vals.slice(lo, hi));
826
788
  }
827
- }
828
-
829
- class NameVal extends VarVal {
789
+ };
790
+ var NameVal = class extends VarVal {
830
791
  constructor(name) {
831
792
  super();
832
793
  this.name = name;
@@ -837,9 +798,8 @@ class NameVal extends VarVal {
837
798
  toString() {
838
799
  return this.name;
839
800
  }
840
- }
841
-
842
- class HandlerNameVal extends NameVal {
801
+ };
802
+ var HandlerNameVal = class extends NameVal {
843
803
  constructor(name, namespace) {
844
804
  super(name);
845
805
  this.namespace = namespace;
@@ -847,41 +807,36 @@ class HandlerNameVal extends NameVal {
847
807
  eval(stack) {
848
808
  return stack.getHandlerFor(this.name, this.namespace) ?? mk404Handler(this.namespace, this.name);
849
809
  }
850
- }
810
+ };
851
811
  var mk404Handler = (type, name) => function(...args) {
852
812
  console.warn("handler not found", { type, name, args }, this);
853
813
  return this;
854
814
  };
855
-
856
- class TypeVal extends NameVal {
815
+ var TypeVal = class extends NameVal {
857
816
  eval(stack) {
858
817
  return stack.lookupType(this.name);
859
818
  }
860
- }
861
-
862
- class RenderVal extends BaseVal {
819
+ };
820
+ var RenderVal = class extends BaseVal {
863
821
  render(stack, _rx) {
864
822
  return this.eval(stack);
865
823
  }
866
- }
867
-
868
- class RenderNameVal extends RenderVal {
824
+ };
825
+ var RenderNameVal = class extends RenderVal {
869
826
  constructor(name) {
870
827
  super();
871
828
  this.name = name;
872
829
  }
873
- }
874
-
875
- class BindVal extends RenderNameVal {
830
+ };
831
+ var BindVal = class extends RenderNameVal {
876
832
  eval(stack) {
877
833
  return stack.lookupBind(this.name);
878
834
  }
879
835
  toString() {
880
836
  return `@${this.name}`;
881
837
  }
882
- }
883
-
884
- class BindMemberVal extends BindVal {
838
+ };
839
+ var BindMemberVal = class extends BindVal {
885
840
  constructor(name, member) {
886
841
  super(name);
887
842
  this.member = member;
@@ -893,18 +848,16 @@ class BindMemberVal extends BindVal {
893
848
  toString() {
894
849
  return `@${this.name}.${this.member}`;
895
850
  }
896
- }
897
-
898
- class DynVal extends RenderNameVal {
851
+ };
852
+ var DynVal = class extends RenderNameVal {
899
853
  eval(stack) {
900
854
  return stack.lookupDynamic(this.name);
901
855
  }
902
856
  toString() {
903
857
  return `*${this.name}`;
904
858
  }
905
- }
906
-
907
- class FieldVal extends RenderNameVal {
859
+ };
860
+ var FieldVal = class extends RenderNameVal {
908
861
  eval(stack) {
909
862
  return stack.lookupFieldRaw(this.name);
910
863
  }
@@ -914,9 +867,8 @@ class FieldVal extends RenderNameVal {
914
867
  toString() {
915
868
  return `.${this.name}`;
916
869
  }
917
- }
918
-
919
- class MethodVal extends RenderNameVal {
870
+ };
871
+ var MethodVal = class extends RenderNameVal {
920
872
  eval(stack) {
921
873
  return stack.lookupMethod(this.name);
922
874
  }
@@ -926,9 +878,8 @@ class MethodVal extends RenderNameVal {
926
878
  toString() {
927
879
  return `$${this.name}`;
928
880
  }
929
- }
930
-
931
- class SeqAccessVal extends RenderVal {
881
+ };
882
+ var SeqAccessVal = class extends RenderVal {
932
883
  constructor(seqVal, keyVal) {
933
884
  super();
934
885
  this.seqVal = seqVal;
@@ -944,11 +895,10 @@ class SeqAccessVal extends RenderVal {
944
895
  toString() {
945
896
  return `${this.seqVal}[${this.keyVal}]`;
946
897
  }
947
- }
948
- var vp = new ValParser;
898
+ };
949
899
 
950
900
  // src/attribute.js
951
- class Attributes {
901
+ var Attributes = class {
952
902
  constructor(items) {
953
903
  this.items = items;
954
904
  }
@@ -961,11 +911,10 @@ class Attributes {
961
911
  isConstant() {
962
912
  return false;
963
913
  }
964
- }
914
+ };
965
915
  var booleanAttrsRaw = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected";
966
916
  var booleanAttrs = new Set(booleanAttrsRaw.split(","));
967
-
968
- class AttrParser {
917
+ var AttrParser = class {
969
918
  constructor(px) {
970
919
  this.clear(px);
971
920
  }
@@ -980,13 +929,12 @@ class AttrParser {
980
929
  this.events = null;
981
930
  }
982
931
  parseAttr(name, value, parseAll = false) {
983
- const val = parseAll ? vp.parseMacroAttr(value, this.px) : vp.parseText(value, this.px);
932
+ const val = parseAll ? parseMacroAttr(value, this.px) : parseText(value, this.px);
984
933
  if (val !== null) {
985
934
  this.attrs ??= [];
986
935
  this.attrs.push(new Attr(name, val));
987
936
  this.hasDynamic ||= !(val instanceof ConstVal);
988
- } else
989
- this.px.onParseIssue("bad-value", { role: "attr", attr: name, value });
937
+ } else this.px.onParseIssue("bad-value", { role: "attr", attr: name, value });
990
938
  }
991
939
  pushWrapper(name, raw, val) {
992
940
  const node = { name, val, raw };
@@ -995,7 +943,7 @@ class AttrParser {
995
943
  return node;
996
944
  }
997
945
  parseIf(directiveName, value) {
998
- const dynVal = vp.parseBool(value, this.px);
946
+ const dynVal = parseBool(value, this.px);
999
947
  if (dynVal) {
1000
948
  this.ifAttr = new IfAttr(directiveName.slice(3), dynVal);
1001
949
  this.attrs ??= [];
@@ -1007,12 +955,10 @@ class AttrParser {
1007
955
  }
1008
956
  }
1009
957
  parseThen(s) {
1010
- if (this.ifAttr)
1011
- this.ifAttr.thenVal = vp.parseText(s, this.px) ?? NOT_SET_VAL;
958
+ if (this.ifAttr) this.ifAttr.thenVal = parseText(s, this.px) ?? NOT_SET_VAL;
1012
959
  }
1013
960
  parseElse(value) {
1014
- if (this.ifAttr)
1015
- this.ifAttr.elseVal = vp.parseText(value, this.px) ?? NOT_SET_VAL;
961
+ if (this.ifAttr) this.ifAttr.elseVal = parseText(value, this.px) ?? NOT_SET_VAL;
1016
962
  }
1017
963
  parseEvent(directiveName, value) {
1018
964
  const [eventName, ...modifiers] = directiveName.slice(3).split("+");
@@ -1021,13 +967,13 @@ class AttrParser {
1021
967
  if (this.events === null) {
1022
968
  this.events = this.px.registerEvents();
1023
969
  this.attrs ??= [];
1024
- this.attrs.push(new ConstAttr("data-eid", vp.const(this.events.id)));
970
+ this.attrs.push(new ConstAttr("data-eid", new ConstVal(this.events.id)));
1025
971
  }
1026
972
  this.events.add(eventName, handler, modifiers);
1027
973
  }
1028
974
  }
1029
975
  _parseDirectiveValue(directiveName, s, parserFn) {
1030
- const val = parserFn.call(vp, s, this.px);
976
+ const val = parserFn(s, this.px);
1031
977
  if (val === null) {
1032
978
  const info = { role: "directive", directive: directiveName, value: s };
1033
979
  this.px.onParseIssue("bad-value", info);
@@ -1038,31 +984,39 @@ class AttrParser {
1038
984
  switch (directiveName) {
1039
985
  case "dangerouslysetinnerhtml":
1040
986
  this.attrs ??= [];
1041
- this.attrs.push(new RawHtmlAttr(this._parseDirectiveValue(directiveName, s, vp.parseText)));
987
+ this.attrs.push(new RawHtmlAttr(this._parseDirectiveValue(directiveName, s, parseText)));
1042
988
  this.hasDynamic = true;
1043
989
  return;
1044
990
  case "push-view":
1045
- this.pushWrapper("push-view", s, this._parseDirectiveValue(directiveName, s, vp.parseText));
991
+ this.pushWrapper("push-view", s, this._parseDirectiveValue(directiveName, s, parseText));
1046
992
  return;
1047
993
  case "text":
1048
- this.textChild = this._parseDirectiveValue(directiveName, s, vp.parseText);
994
+ this.textChild = this._parseDirectiveValue(directiveName, s, parseText);
1049
995
  return;
1050
996
  case "show":
1051
- this.pushWrapper("show", s, this._parseDirectiveValue(directiveName, s, vp.parseBool));
997
+ this.pushWrapper("show", s, this._parseDirectiveValue(directiveName, s, parseBool));
1052
998
  return;
1053
999
  case "hide":
1054
- this.pushWrapper("hide", s, this._parseDirectiveValue(directiveName, s, vp.parseBool));
1000
+ this.pushWrapper("hide", s, this._parseDirectiveValue(directiveName, s, parseBool));
1055
1001
  return;
1056
1002
  case "each": {
1057
- const val = this._parseDirectiveValue(directiveName, s, vp.parseSequence);
1003
+ const val = this._parseDirectiveValue(directiveName, s, parseSequence);
1058
1004
  this.eachAttr = this.pushWrapper("each", s, val);
1059
1005
  return;
1060
1006
  }
1061
1007
  case "enrich-with":
1062
1008
  if (this.eachAttr !== null)
1063
- this.eachAttr.enrichWithVal = this._parseDirectiveValue(directiveName, s, vp.parseAlterHandler);
1009
+ this.eachAttr.enrichWithVal = this._parseDirectiveValue(
1010
+ directiveName,
1011
+ s,
1012
+ parseAlterHandler
1013
+ );
1064
1014
  else
1065
- this.pushWrapper("scope", s, this._parseDirectiveValue(directiveName, s, vp.parseAlterHandler));
1015
+ this.pushWrapper(
1016
+ "scope",
1017
+ s,
1018
+ this._parseDirectiveValue(directiveName, s, parseAlterHandler)
1019
+ );
1066
1020
  return;
1067
1021
  case "when":
1068
1022
  this._parseWhen(s);
@@ -1077,14 +1031,10 @@ class AttrParser {
1077
1031
  this.parseElse(s);
1078
1032
  return;
1079
1033
  }
1080
- if (directiveName.startsWith("on."))
1081
- this.parseEvent(directiveName, s);
1082
- else if (directiveName.startsWith("if."))
1083
- this.parseIf(directiveName, s);
1084
- else if (directiveName.startsWith("then."))
1085
- this.parseThen(s);
1086
- else if (directiveName.startsWith("else."))
1087
- this.parseElse(s);
1034
+ if (directiveName.startsWith("on.")) this.parseEvent(directiveName, s);
1035
+ else if (directiveName.startsWith("if.")) this.parseIf(directiveName, s);
1036
+ else if (directiveName.startsWith("then.")) this.parseThen(s);
1037
+ else if (directiveName.startsWith("else.")) this.parseElse(s);
1088
1038
  else {
1089
1039
  const info = { name: directiveName, value: s };
1090
1040
  this.px.onParseIssue("unknown-directive", info);
@@ -1092,59 +1042,54 @@ class AttrParser {
1092
1042
  }
1093
1043
  _parseWhen(s) {
1094
1044
  if (this.eachAttr !== null)
1095
- this.eachAttr.whenVal = this._parseDirectiveValue("when", s, vp.parseAlterHandler);
1045
+ this.eachAttr.whenVal = this._parseDirectiveValue("when", s, parseAlterHandler);
1096
1046
  }
1097
1047
  _parseLoopWith(s) {
1098
1048
  if (this.eachAttr !== null)
1099
- this.eachAttr.loopWithVal = this._parseDirectiveValue("loop-with", s, vp.parseAlterHandler);
1049
+ this.eachAttr.loopWithVal = this._parseDirectiveValue("loop-with", s, parseAlterHandler);
1100
1050
  }
1101
1051
  parse(attributes, parseAll = false) {
1102
1052
  for (const { name, value } of attributes) {
1103
1053
  const charCode = name.charCodeAt(0);
1104
1054
  if (charCode === 58)
1105
1055
  this.parseAttr(name === ":viewbox" ? "viewBox" : name.slice(1), value, parseAll);
1106
- else if (charCode === 64)
1107
- this.parseDirective(value, name.slice(1));
1056
+ else if (charCode === 64) this.parseDirective(value, name.slice(1));
1108
1057
  else {
1109
1058
  this.attrs ??= [];
1110
1059
  const constVal = value === "" && booleanAttrs.has(name) ? true : value;
1111
- this.attrs.push(new ConstAttr(name, vp.const(constVal)));
1060
+ this.attrs.push(new ConstAttr(name, new ConstVal(constVal)));
1112
1061
  }
1113
1062
  }
1114
1063
  const { attrs, hasDynamic } = this;
1115
1064
  const pAttrs = hasDynamic ? new DynAttrs(attrs) : ConstAttrs.fromAttrs(attrs ?? []);
1116
1065
  return [pAttrs, this.wrapperAttrs, this.textChild];
1117
1066
  }
1118
- }
1119
-
1120
- class ConstAttrs extends Attributes {
1067
+ };
1068
+ var ConstAttrs = class _ConstAttrs extends Attributes {
1121
1069
  eval(_stack) {
1122
1070
  return this.items;
1123
1071
  }
1124
1072
  static fromAttrs(attrs) {
1125
1073
  const attrsObj = {};
1126
- for (const attr of attrs)
1127
- attrsObj[attr.name] = attr.val.eval(null);
1128
- return new ConstAttrs(attrsObj);
1074
+ for (const attr of attrs) attrsObj[attr.name] = attr.val.eval(null);
1075
+ return new _ConstAttrs(attrsObj);
1129
1076
  }
1130
1077
  setDataAttr(key, val) {
1131
1078
  this.items[key] = val;
1132
1079
  }
1133
1080
  toMacroVars() {
1134
1081
  const r = {};
1135
- for (const name in this.items)
1136
- r[name] = new ConstVal(`${this.items[name]}`).toString();
1082
+ for (const name in this.items) r[name] = new ConstVal(`${this.items[name]}`).toString();
1137
1083
  return r;
1138
1084
  }
1139
1085
  isConstant() {
1140
1086
  return true;
1141
1087
  }
1142
- }
1143
-
1144
- class DynAttrs extends Attributes {
1088
+ };
1089
+ var DynAttrs = class extends Attributes {
1145
1090
  eval(stack) {
1146
1091
  const attrs = {};
1147
- for (let i = 0;i < this.items.length; i++) {
1092
+ for (let i = 0; i < this.items.length; i++) {
1148
1093
  const attr = this.items[i];
1149
1094
  attrs[attr.name] = attr.eval(stack);
1150
1095
  }
@@ -1155,19 +1100,16 @@ class DynAttrs extends Attributes {
1155
1100
  }
1156
1101
  toMacroVars() {
1157
1102
  const r = {};
1158
- for (const attr of this.items)
1159
- r[attr.name] = attr.val.toString();
1103
+ for (const attr of this.items) r[attr.name] = attr.val.toString();
1160
1104
  return r;
1161
1105
  }
1162
- }
1163
-
1164
- class BaseAttr {
1106
+ };
1107
+ var BaseAttr = class {
1165
1108
  constructor(name) {
1166
1109
  this.name = name;
1167
1110
  }
1168
- }
1169
-
1170
- class Attr extends BaseAttr {
1111
+ };
1112
+ var Attr = class extends BaseAttr {
1171
1113
  constructor(name, val) {
1172
1114
  super(name);
1173
1115
  this.val = val;
@@ -1175,22 +1117,19 @@ class Attr extends BaseAttr {
1175
1117
  eval(stack) {
1176
1118
  return this.val.eval(stack);
1177
1119
  }
1178
- }
1179
-
1180
- class ConstAttr extends Attr {
1181
- }
1182
-
1183
- class RawHtmlAttr extends Attr {
1120
+ };
1121
+ var ConstAttr = class extends Attr {
1122
+ };
1123
+ var RawHtmlAttr = class extends Attr {
1184
1124
  constructor(val) {
1185
- super("dangerouslySetInnerHTML", val ?? vp.nullConstVal);
1125
+ super("dangerouslySetInnerHTML", val ?? NULL_CONST_VAL);
1186
1126
  }
1187
1127
  eval(stack) {
1188
1128
  return { __html: `${this.val.eval(stack)}` };
1189
1129
  }
1190
- }
1191
- var NOT_SET_VAL = vp.nullConstVal;
1192
-
1193
- class IfAttr extends BaseAttr {
1130
+ };
1131
+ var NOT_SET_VAL = NULL_CONST_VAL;
1132
+ var IfAttr = class extends BaseAttr {
1194
1133
  constructor(name, condVal) {
1195
1134
  super(name);
1196
1135
  this.condVal = condVal;
@@ -1202,73 +1141,66 @@ class IfAttr extends BaseAttr {
1202
1141
  eval(stack) {
1203
1142
  return this.condVal.eval(stack) ? this.thenVal.eval(stack) : this.elseVal.eval(stack);
1204
1143
  }
1205
- }
1144
+ };
1206
1145
  var _attrParser = null;
1207
1146
  function getAttrParser(px) {
1208
1147
  _attrParser ??= new AttrParser(px);
1209
1148
  _attrParser.clear(px);
1210
1149
  return _attrParser;
1211
1150
  }
1212
-
1213
- class EventHandler {
1151
+ var EventHandler = class _EventHandler {
1214
1152
  constructor(handlerVal, args = []) {
1215
1153
  this.handlerVal = handlerVal;
1216
1154
  this.args = args;
1217
1155
  }
1218
1156
  getHandlerAndArgs(stack, _event) {
1219
1157
  const argValues = new Array(this.args.length);
1220
- for (let i = 0;i < argValues.length; i++)
1221
- argValues[i] = this.args[i].eval(stack);
1158
+ for (let i = 0; i < argValues.length; i++) argValues[i] = this.args[i].eval(stack);
1222
1159
  return [this.handlerVal.evalAsHandler(stack), argValues];
1223
1160
  }
1224
1161
  static parse(s, px) {
1225
- const r = vp.parseInputHandler(s, px);
1226
- return r === null ? null : new EventHandler(r.handlerVal, r.args);
1162
+ const r = parseInputHandler(s, px);
1163
+ return r === null ? null : new _EventHandler(r.handlerVal, r.args);
1227
1164
  }
1228
- }
1229
-
1230
- class RequestHandler {
1165
+ };
1166
+ var RequestHandler = class {
1231
1167
  constructor(name, fn) {
1232
1168
  this.name = name;
1233
1169
  this.fn = fn;
1234
1170
  }
1235
- }
1171
+ };
1236
1172
 
1237
1173
  // src/renderer.js
1238
1174
  import { isIndexed, isKeyed } from "immutable";
1239
1175
 
1240
1176
  // src/cache.js
1241
1177
  var isWeakKey = (k) => k !== null && (typeof k === "object" || typeof k === "function");
1242
-
1243
- class NullDomCache {
1244
- get(_keys, _cacheKey) {}
1245
- set(_keys, _cacheKey, _v) {}
1178
+ var NullDomCache = class {
1179
+ get(_keys, _cacheKey) {
1180
+ }
1181
+ set(_keys, _cacheKey, _v) {
1182
+ }
1246
1183
  evict() {
1247
1184
  return { hit: 0, miss: 0, badKey: 0 };
1248
1185
  }
1249
- }
1250
-
1251
- class WeakMapDomCache {
1186
+ };
1187
+ var WeakMapDomCache = class {
1252
1188
  constructor() {
1253
1189
  this.hit = this.miss = this.badKey = 0;
1254
- this.keysByLen = new Map;
1190
+ this.keysByLen = /* @__PURE__ */ new Map();
1255
1191
  }
1256
1192
  _returnValue(r) {
1257
- if (r === undefined)
1258
- this.miss += 1;
1259
- else
1260
- this.hit += 1;
1193
+ if (r === void 0) this.miss += 1;
1194
+ else this.hit += 1;
1261
1195
  return r;
1262
1196
  }
1263
1197
  get(keys, cacheKey) {
1264
1198
  const len = keys.length;
1265
1199
  let cur = this.keysByLen.get(len);
1266
- if (!cur)
1267
- return this._returnValue(undefined);
1268
- for (let i = 0;i < len - 1; i++) {
1200
+ if (!cur) return this._returnValue(void 0);
1201
+ for (let i = 0; i < len - 1; i++) {
1269
1202
  cur = cur.get(keys[i]);
1270
- if (!cur)
1271
- return this._returnValue(undefined);
1203
+ if (!cur) return this._returnValue(void 0);
1272
1204
  }
1273
1205
  return this._returnValue(cur.get(keys[len - 1])?.[cacheKey]);
1274
1206
  }
@@ -1276,10 +1208,10 @@ class WeakMapDomCache {
1276
1208
  const len = keys.length;
1277
1209
  let cur = this.keysByLen.get(len);
1278
1210
  if (!cur) {
1279
- cur = new WeakMap;
1211
+ cur = /* @__PURE__ */ new WeakMap();
1280
1212
  this.keysByLen.set(len, cur);
1281
1213
  }
1282
- for (let i = 0;i < len - 1; i++) {
1214
+ for (let i = 0; i < len - 1; i++) {
1283
1215
  const key = keys[i];
1284
1216
  let next = cur.get(key);
1285
1217
  if (!next) {
@@ -1287,27 +1219,24 @@ class WeakMapDomCache {
1287
1219
  this.badKey += 1;
1288
1220
  return;
1289
1221
  }
1290
- next = new WeakMap;
1222
+ next = /* @__PURE__ */ new WeakMap();
1291
1223
  cur.set(key, next);
1292
1224
  }
1293
1225
  cur = next;
1294
1226
  }
1295
1227
  const lastKey = keys[len - 1];
1296
1228
  const leaf = cur.get(lastKey);
1297
- if (leaf)
1298
- leaf[cacheKey] = v;
1299
- else if (isWeakKey(lastKey))
1300
- cur.set(lastKey, { [cacheKey]: v });
1301
- else
1302
- this.badKey += 1;
1229
+ if (leaf) leaf[cacheKey] = v;
1230
+ else if (isWeakKey(lastKey)) cur.set(lastKey, { [cacheKey]: v });
1231
+ else this.badKey += 1;
1303
1232
  }
1304
1233
  evict() {
1305
1234
  const { hit, miss, badKey } = this;
1306
1235
  this.hit = this.miss = this.badKey = 0;
1307
- this.keysByLen = new Map;
1236
+ this.keysByLen = /* @__PURE__ */ new Map();
1308
1237
  return { hit, miss, badKey };
1309
1238
  }
1310
- }
1239
+ };
1311
1240
 
1312
1241
  // src/vdom.js
1313
1242
  var HTML_NS = "http://www.w3.org/1999/xhtml";
@@ -1323,7 +1252,7 @@ function childOpts(vnode, ns, opts) {
1323
1252
  const target = ns === SVG_NS && isForeignObject(vnode.tag) ? null : ns;
1324
1253
  return target === (opts.namespace ?? null) ? opts : { ...opts, namespace: target };
1325
1254
  }
1326
- var NEVER_ASSIGN = new Set([
1255
+ var NEVER_ASSIGN = /* @__PURE__ */ new Set([
1327
1256
  "width",
1328
1257
  "height",
1329
1258
  "href",
@@ -1339,39 +1268,35 @@ var NEVER_ASSIGN = new Set([
1339
1268
  var PROP_ATTR_NAME = { className: "class", htmlFor: "for" };
1340
1269
  function applyProperties(node, props) {
1341
1270
  const namespaced = isNamespaced(node);
1342
- for (const name in props)
1343
- setProp(node, name, props[name], namespaced);
1271
+ for (const name in props) setProp(node, name, props[name], namespaced);
1344
1272
  }
1345
1273
  function setProp(node, name, value, namespaced) {
1346
1274
  if (name === "dangerouslySetInnerHTML") {
1347
- if (value === undefined)
1348
- node.replaceChildren();
1275
+ if (value === void 0) node.replaceChildren();
1349
1276
  else {
1350
- const html = value.__html ?? "";
1351
- if (html !== node.innerHTML)
1352
- node.innerHTML = html;
1277
+ const html2 = value.__html ?? "";
1278
+ if (html2 !== node.innerHTML) node.innerHTML = html2;
1353
1279
  }
1354
1280
  return;
1355
1281
  }
1356
- if (typeof value === "function")
1357
- return;
1282
+ if (typeof value === "function") return;
1358
1283
  const usesProp = !namespaced && !NEVER_ASSIGN.has(name) && name in node;
1359
1284
  if (usesProp && value != null) {
1360
1285
  try {
1361
1286
  node[name] = value;
1362
1287
  return;
1363
- } catch {}
1288
+ } catch {
1289
+ }
1364
1290
  }
1365
1291
  if (value == null || value === false && name[4] !== "-") {
1366
1292
  if (usesProp) {
1367
1293
  try {
1368
1294
  node[name] = "";
1369
- } catch {}
1295
+ } catch {
1296
+ }
1370
1297
  node.removeAttribute(PROP_ATTR_NAME[name] ?? name);
1371
- } else
1372
- node.removeAttribute(name);
1373
- } else
1374
- node.setAttribute(name, value);
1298
+ } else node.removeAttribute(name);
1299
+ } else node.setAttribute(name, value);
1375
1300
  }
1376
1301
  function applyValueLast(node, value) {
1377
1302
  if (node.tagName === "PROGRESS" && (value == null || value === 0)) {
@@ -1380,39 +1305,28 @@ function applyValueLast(node, value) {
1380
1305
  setProp(node, "value", value, isNamespaced(node));
1381
1306
  }
1382
1307
  }
1383
-
1384
- class VBase {
1385
- }
1386
- var getKey = (child) => child instanceof VNode ? child.key : undefined;
1308
+ var VBase = class {
1309
+ };
1310
+ var getKey = (child) => child instanceof VNode ? child.key : void 0;
1387
1311
  var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
1388
1312
  function childsEqual(a, b) {
1389
- if (a === b)
1390
- return true;
1391
- for (let i = 0;i < a.length; i++)
1392
- if (!a[i].isEqualTo(b[i]))
1393
- return false;
1313
+ if (a === b) return true;
1314
+ for (let i = 0; i < a.length; i++) if (!a[i].isEqualTo(b[i])) return false;
1394
1315
  return true;
1395
1316
  }
1396
1317
  function appendChildNodes(parent, childs, opts) {
1397
- for (const child of childs)
1398
- parent.appendChild(child.toDom(opts));
1318
+ for (const child of childs) parent.appendChild(child.toDom(opts));
1399
1319
  }
1400
1320
  function addChild(normalizedChildren, child) {
1401
- if (child == null)
1402
- return;
1321
+ if (child == null) return;
1403
1322
  if (isIterable(child)) {
1404
- for (const c of child)
1405
- addChild(normalizedChildren, c);
1323
+ for (const c of child) addChild(normalizedChildren, c);
1406
1324
  } else if (child instanceof VBase) {
1407
- if (child instanceof VFragment)
1408
- normalizedChildren.push(...child.childs);
1409
- else
1410
- normalizedChildren.push(child);
1411
- } else
1412
- normalizedChildren.push(new VText(child));
1325
+ if (child instanceof VFragment) normalizedChildren.push(...child.childs);
1326
+ else normalizedChildren.push(child);
1327
+ } else normalizedChildren.push(new VText(child));
1413
1328
  }
1414
-
1415
- class VText extends VBase {
1329
+ var VText = class _VText extends VBase {
1416
1330
  constructor(text) {
1417
1331
  super();
1418
1332
  this.text = String(text);
@@ -1421,14 +1335,13 @@ class VText extends VBase {
1421
1335
  return 3;
1422
1336
  }
1423
1337
  isEqualTo(other) {
1424
- return other instanceof VText && this.text === other.text;
1338
+ return other instanceof _VText && this.text === other.text;
1425
1339
  }
1426
1340
  toDom(opts) {
1427
1341
  return opts.document.createTextNode(this.text);
1428
1342
  }
1429
- }
1430
-
1431
- class VComment extends VBase {
1343
+ };
1344
+ var VComment = class _VComment extends VBase {
1432
1345
  constructor(text) {
1433
1346
  super();
1434
1347
  this.text = text;
@@ -1437,14 +1350,13 @@ class VComment extends VBase {
1437
1350
  return 8;
1438
1351
  }
1439
1352
  isEqualTo(other) {
1440
- return other instanceof VComment && this.text === other.text;
1353
+ return other instanceof _VComment && this.text === other.text;
1441
1354
  }
1442
1355
  toDom(opts) {
1443
1356
  return opts.document.createComment(this.text);
1444
1357
  }
1445
- }
1446
-
1447
- class VFragment extends VBase {
1358
+ };
1359
+ var VFragment = class _VFragment extends VBase {
1448
1360
  constructor(childs) {
1449
1361
  super();
1450
1362
  this.childs = [];
@@ -1454,8 +1366,7 @@ class VFragment extends VBase {
1454
1366
  return 11;
1455
1367
  }
1456
1368
  isEqualTo(other) {
1457
- if (!(other instanceof VFragment) || this.childs.length !== other.childs.length)
1458
- return false;
1369
+ if (!(other instanceof _VFragment) || this.childs.length !== other.childs.length) return false;
1459
1370
  return childsEqual(this.childs, other.childs);
1460
1371
  }
1461
1372
  toDom(opts) {
@@ -1463,15 +1374,14 @@ class VFragment extends VBase {
1463
1374
  appendChildNodes(fragment, this.childs, opts);
1464
1375
  return fragment;
1465
1376
  }
1466
- }
1467
-
1468
- class VNode extends VBase {
1377
+ };
1378
+ var VNode = class _VNode extends VBase {
1469
1379
  constructor(tag, attrs, childs, key, namespace) {
1470
1380
  super();
1471
1381
  this.tag = tag;
1472
1382
  this.attrs = attrs ?? {};
1473
1383
  this.childs = childs ?? [];
1474
- this.key = key != null ? String(key) : undefined;
1384
+ this.key = key != null ? String(key) : void 0;
1475
1385
  this.namespace = typeof namespace === "string" ? namespace : null;
1476
1386
  }
1477
1387
  get nodeType() {
@@ -1481,18 +1391,13 @@ class VNode extends VBase {
1481
1391
  return this.tag === other.tag && this.namespace === other.namespace && this.key === other.key;
1482
1392
  }
1483
1393
  isEqualTo(other) {
1484
- if (this === other)
1485
- return true;
1486
- if (!(other instanceof VNode) || !this.isSameKind(other) || this.childs.length !== other.childs.length) {
1394
+ if (this === other) return true;
1395
+ if (!(other instanceof _VNode) || !this.isSameKind(other) || this.childs.length !== other.childs.length) {
1487
1396
  return false;
1488
1397
  }
1489
1398
  if (this.attrs !== other.attrs) {
1490
- for (const key in this.attrs)
1491
- if (this.attrs[key] !== other.attrs[key])
1492
- return false;
1493
- for (const key in other.attrs)
1494
- if (!Object.hasOwn(this.attrs, key))
1495
- return false;
1399
+ for (const key in this.attrs) if (this.attrs[key] !== other.attrs[key]) return false;
1400
+ for (const key in other.attrs) if (!Object.hasOwn(this.attrs, key)) return false;
1496
1401
  }
1497
1402
  return childsEqual(this.childs, other.childs);
1498
1403
  }
@@ -1501,32 +1406,29 @@ class VNode extends VBase {
1501
1406
  const ns = effectiveNs(this, opts);
1502
1407
  const tag = ns !== null && this.tag === this.tag.toUpperCase() ? this.tag.toLowerCase() : this.tag;
1503
1408
  const attrs = this.attrs;
1504
- const createOpts = attrs.is != null ? { is: attrs.is } : undefined;
1409
+ const createOpts = attrs.is != null ? { is: attrs.is } : void 0;
1505
1410
  const node = ns === null ? doc.createElement(tag, createOpts) : doc.createElementNS(ns, tag, createOpts);
1506
1411
  const cOpts = childOpts(this, ns, opts);
1507
1412
  if ("value" in attrs || "checked" in attrs) {
1508
1413
  const { value, checked, ...rest } = attrs;
1509
1414
  applyProperties(node, rest);
1510
1415
  appendChildNodes(node, this.childs, cOpts);
1511
- if (value !== undefined)
1512
- applyValueLast(node, value);
1513
- if (checked !== undefined)
1514
- setProp(node, "checked", checked, false);
1416
+ if (value !== void 0) applyValueLast(node, value);
1417
+ if (checked !== void 0) setProp(node, "checked", checked, false);
1515
1418
  } else {
1516
1419
  applyProperties(node, attrs);
1517
1420
  appendChildNodes(node, this.childs, cOpts);
1518
1421
  }
1519
1422
  return node;
1520
1423
  }
1521
- }
1424
+ };
1522
1425
  function diffProps(a, b) {
1523
- if (a === b)
1524
- return null;
1426
+ if (a === b) return null;
1525
1427
  let diff = null;
1526
1428
  for (const aKey in a) {
1527
1429
  if (!Object.hasOwn(b, aKey)) {
1528
1430
  diff ??= {};
1529
- diff[aKey] = undefined;
1431
+ diff[aKey] = void 0;
1530
1432
  } else if (a[aKey] !== b[aKey]) {
1531
1433
  diff ??= {};
1532
1434
  diff[aKey] = b[aKey];
@@ -1541,8 +1443,7 @@ function diffProps(a, b) {
1541
1443
  return diff;
1542
1444
  }
1543
1445
  function morphNode(domNode, source, target, opts) {
1544
- if (source === target || source.isEqualTo(target))
1545
- return domNode;
1446
+ if (source === target || source.isEqualTo(target)) return domNode;
1546
1447
  const type = source.nodeType;
1547
1448
  if (type === target.nodeType) {
1548
1449
  if (type === 3 || type === 8) {
@@ -1557,19 +1458,16 @@ function morphNode(domNode, source, target, opts) {
1557
1458
  if (hasValue || hasChecked) {
1558
1459
  const { value: _v, checked: _c, ...rest } = propsDiff;
1559
1460
  applyProperties(domNode, rest);
1560
- } else
1561
- applyProperties(domNode, propsDiff);
1461
+ } else applyProperties(domNode, propsDiff);
1562
1462
  }
1563
1463
  if (!target.attrs.dangerouslySetInnerHTML) {
1564
1464
  const ns = effectiveNs(target, opts);
1565
1465
  morphChildren(domNode, source.childs, target.childs, childOpts(target, ns, opts));
1566
1466
  }
1567
- if (hasValue)
1568
- applyValueLast(domNode, propsDiff.value);
1569
- else if (source.tag === "SELECT" && target.attrs.value !== undefined)
1467
+ if (hasValue) applyValueLast(domNode, propsDiff.value);
1468
+ else if (source.tag === "SELECT" && target.attrs.value !== void 0)
1570
1469
  applyValueLast(domNode, target.attrs.value);
1571
- if (hasChecked)
1572
- setProp(domNode, "checked", propsDiff.checked, false);
1470
+ if (hasChecked) setProp(domNode, "checked", propsDiff.checked, false);
1573
1471
  return domNode;
1574
1472
  }
1575
1473
  if (type === 11) {
@@ -1592,7 +1490,7 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
1592
1490
  }
1593
1491
  if (oldChilds.length === newChilds.length) {
1594
1492
  let hasKey = false;
1595
- for (let i = 0;i < oldChilds.length; i++) {
1493
+ for (let i = 0; i < oldChilds.length; i++) {
1596
1494
  if (getKey(oldChilds[i]) != null || getKey(newChilds[i]) != null) {
1597
1495
  hasKey = true;
1598
1496
  break;
@@ -1600,7 +1498,7 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
1600
1498
  }
1601
1499
  if (!hasKey) {
1602
1500
  let dom = parentDom.firstChild;
1603
- for (let i = 0;i < oldChilds.length; i++) {
1501
+ for (let i = 0; i < oldChilds.length; i++) {
1604
1502
  const next = dom.nextSibling;
1605
1503
  morphNode(dom, oldChilds[i], newChilds[i], opts);
1606
1504
  dom = next;
@@ -1609,21 +1507,19 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
1609
1507
  }
1610
1508
  }
1611
1509
  const domNodes = Array.from(parentDom.childNodes);
1612
- const oldKeyMap = Object.create(null);
1613
- for (let i = 0;i < oldChilds.length; i++) {
1510
+ const oldKeyMap = /* @__PURE__ */ Object.create(null);
1511
+ for (let i = 0; i < oldChilds.length; i++) {
1614
1512
  const key = getKey(oldChilds[i]);
1615
- if (key != null)
1616
- oldKeyMap[key] = i;
1513
+ if (key != null) oldKeyMap[key] = i;
1617
1514
  }
1618
1515
  const used = new Uint8Array(oldChilds.length);
1619
1516
  let unkeyedCursor = 0;
1620
- for (let j = 0;j < newChilds.length; j++) {
1517
+ for (let j = 0; j < newChilds.length; j++) {
1621
1518
  const newChild = newChilds[j];
1622
1519
  const newKey = getKey(newChild);
1623
1520
  let oldIdx = -1;
1624
1521
  if (newKey != null) {
1625
- if (newKey in oldKeyMap && !used[oldKeyMap[newKey]])
1626
- oldIdx = oldKeyMap[newKey];
1522
+ if (newKey in oldKeyMap && !used[oldKeyMap[newKey]]) oldIdx = oldKeyMap[newKey];
1627
1523
  } else {
1628
1524
  while (unkeyedCursor < oldChilds.length) {
1629
1525
  if (!used[unkeyedCursor] && getKey(oldChilds[unkeyedCursor]) == null) {
@@ -1637,16 +1533,14 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
1637
1533
  used[oldIdx] = 1;
1638
1534
  const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
1639
1535
  const ref = parentDom.childNodes[j] ?? null;
1640
- if (newDom !== ref)
1641
- parentDom.insertBefore(newDom, ref);
1536
+ if (newDom !== ref) parentDom.insertBefore(newDom, ref);
1642
1537
  } else {
1643
1538
  const ref = parentDom.childNodes[j] ?? null;
1644
1539
  parentDom.insertBefore(newChild.toDom(opts), ref);
1645
1540
  }
1646
1541
  }
1647
- for (let i = oldChilds.length - 1;i >= 0; i--)
1648
- if (!used[i] && domNodes[i].parentNode === parentDom)
1649
- parentDom.removeChild(domNodes[i]);
1542
+ for (let i = oldChilds.length - 1; i >= 0; i--)
1543
+ if (!used[i] && domNodes[i].parentNode === parentDom) parentDom.removeChild(domNodes[i]);
1650
1544
  }
1651
1545
  function render(vnode, container, options, prev) {
1652
1546
  const isFragment = vnode instanceof VFragment;
@@ -1665,12 +1559,9 @@ function h(tagName, properties, children, namespace) {
1665
1559
  if (properties) {
1666
1560
  for (const propName in properties) {
1667
1561
  const propVal = properties[propName];
1668
- if (propName === "key")
1669
- key = propVal;
1670
- else if (propName === "namespace")
1671
- namespace = namespace ?? propVal;
1672
- else
1673
- props[propName] = propVal;
1562
+ if (propName === "key") key = propVal;
1563
+ else if (propName === "namespace") namespace = namespace ?? propVal;
1564
+ else props[propName] = propVal;
1674
1565
  }
1675
1566
  }
1676
1567
  if (namespace == null) {
@@ -1692,11 +1583,10 @@ function h(tagName, properties, children, namespace) {
1692
1583
 
1693
1584
  // src/renderer.js
1694
1585
  var DATASET_ATTRS = ["nid", "cid", "eid", "vid", "si", "sk"];
1695
-
1696
- class Renderer {
1586
+ var Renderer = class {
1697
1587
  constructor(comps) {
1698
1588
  this.comps = comps;
1699
- this.cache = new WeakMapDomCache;
1589
+ this.cache = new WeakMapDomCache();
1700
1590
  this.renderTag = h;
1701
1591
  }
1702
1592
  renderFragment(childs) {
@@ -1706,7 +1596,7 @@ class Renderer {
1706
1596
  return new VComment(text);
1707
1597
  }
1708
1598
  setNullCache() {
1709
- this.cache = new NullDomCache;
1599
+ this.cache = new NullDomCache();
1710
1600
  }
1711
1601
  renderToDOM(stack, val) {
1712
1602
  const rootNode = document.createElement("div");
@@ -1718,33 +1608,33 @@ class Renderer {
1718
1608
  const dom = this.renderToDOM(stack, val);
1719
1609
  if (cleanAttrs) {
1720
1610
  const nodes = dom.querySelectorAll("[data-nid],[data-cid],[data-eid]");
1721
- for (const { dataset } of nodes)
1722
- for (const name of DATASET_ATTRS)
1723
- delete dataset[name];
1611
+ for (const { dataset } of nodes) for (const name of DATASET_ATTRS) delete dataset[name];
1724
1612
  }
1725
1613
  return dom.innerHTML;
1726
1614
  }
1727
1615
  renderRoot(stack, val, viewName = null) {
1728
1616
  const comp = this.comps.getCompFor(val);
1729
- if (comp === null)
1730
- return null;
1617
+ if (comp === null) return null;
1731
1618
  return this._rValComp(stack, val, comp, comp.getView(viewName).anode, "ROOT", viewName);
1732
1619
  }
1733
1620
  renderIt(stack, node, key, viewName) {
1734
1621
  const comp = this.comps.getCompFor(stack.it);
1735
1622
  return comp ? this._rValComp(stack, stack.it, comp, node, key, viewName) : null;
1736
1623
  }
1624
+ // `node` is the parse node of the render site (`<x render>` / `render-it` /
1625
+ // `render-each`, or the view's root anode for the app root). It keys the
1626
+ // cache as a globally-unique object: node ids alone are unique only within a
1627
+ // single view, so the same value rendered by two components (e.g. through a
1628
+ // shared dynamic-var sequence) would otherwise collide in the cache.
1737
1629
  _rValComp(stack, val, comp, node, key, viewName) {
1738
- const cacheKey = `${viewName ?? ""}\x1F${stack.viewsId ?? ""}\x1F${key}`;
1630
+ const cacheKey = `${viewName ?? ""}${stack.viewsId ?? ""}${key}`;
1739
1631
  const cachePath = [node, val];
1740
1632
  stack._pushDynBindValuesToArray(cachePath, comp);
1741
1633
  const cachedNode = this.cache.get(cachePath, cacheKey);
1742
- if (cachedNode)
1743
- return cachedNode;
1634
+ if (cachedNode) return cachedNode;
1744
1635
  const view = viewName ? comp.getView(viewName) : stack.lookupBestView(comp.views, "main");
1745
1636
  const body = this.renderView(view, stack);
1746
- if (body == null)
1747
- return null;
1637
+ if (body == null) return null;
1748
1638
  const meta = this._renderMetadata({
1749
1639
  $: "Comp",
1750
1640
  nid: node?.nodeId ?? null,
@@ -1762,30 +1652,33 @@ class Renderer {
1762
1652
  const { seq, filter, loopWith, enricher } = iterInfo.eval(stack);
1763
1653
  const r = [];
1764
1654
  const it = stack.it;
1765
- const { iterData, start, end, keys } = unpackLoopResult(loopWith.call(it, seq, makeLoopCtx(stack, filter)), seq);
1655
+ const { iterData, start, end, keys } = unpackLoopResult(
1656
+ loopWith.call(it, seq, makeLoopCtx(stack, filter)),
1657
+ seq
1658
+ );
1766
1659
  const renderOne = (key, value, attrName) => {
1767
1660
  const cachePath = enricher ? [view, it, value] : [view, value];
1768
1661
  const binds = { key, value };
1769
- const cacheKey = `${stack.viewsId ?? ""}\x1F${nid}\x1F${key}`;
1770
- if (enricher)
1771
- callEnricher(enricher, it, binds, key, value, iterData);
1662
+ const cacheKey = `${stack.viewsId ?? ""}${nid}${key}`;
1663
+ if (enricher) callEnricher(enricher, it, binds, key, value, iterData);
1772
1664
  const cachedNode = this.cache.get(cachePath, cacheKey);
1773
- if (cachedNode)
1774
- this.pushEachEntry(r, nid, attrName, key, cachedNode);
1665
+ if (cachedNode) this.pushEachEntry(r, nid, attrName, key, cachedNode);
1775
1666
  else {
1776
1667
  const dom = this.renderView(view, stack.enter(value, binds, false));
1777
- if (dom != null)
1778
- this.pushEachEntry(r, nid, attrName, key, dom);
1668
+ if (dom != null) this.pushEachEntry(r, nid, attrName, key, dom);
1779
1669
  this.cache.set(cachePath, cacheKey, dom);
1780
1670
  }
1781
1671
  };
1782
- if (keys)
1783
- imKeysIter(seq, renderOne, keys);
1672
+ if (keys) imKeysIter(seq, renderOne, keys);
1784
1673
  else
1785
- getSeqInfo(seq)(seq, (key, value, attrName) => {
1786
- if (filter.call(it, key, value, iterData))
1787
- renderOne(key, value, attrName);
1788
- }, start, end);
1674
+ getSeqInfo(seq)(
1675
+ seq,
1676
+ (key, value, attrName) => {
1677
+ if (filter.call(it, key, value, iterData)) renderOne(key, value, attrName);
1678
+ },
1679
+ start,
1680
+ end
1681
+ );
1789
1682
  return r;
1790
1683
  }
1791
1684
  renderView(view, stack) {
@@ -1793,8 +1686,7 @@ class Renderer {
1793
1686
  while (n !== null) {
1794
1687
  const b = n[0];
1795
1688
  if (b.isFrame) {
1796
- if (stack.it !== b.it)
1797
- break;
1689
+ if (stack.it !== b.it) break;
1798
1690
  console.error("recursion detected", stack.it, b.it);
1799
1691
  return new VComment("RECURSION AVOIDED");
1800
1692
  }
@@ -1805,10 +1697,12 @@ class Renderer {
1805
1697
  _renderMetadata(info) {
1806
1698
  return new VComment(`§${JSON.stringify(info)}§`);
1807
1699
  }
1700
+ // Prefix a loop-less @enrich-with subtree with a boundary meta so event-path
1701
+ // reconstruction replays its binds (mirrors the §Each§ / §Comp§ metas).
1808
1702
  renderScopeMeta(nid, dom) {
1809
1703
  return new VFragment([this._renderMetadata({ $: "Scope", nid }), dom]);
1810
1704
  }
1811
- }
1705
+ };
1812
1706
  var getSeqInfo = (seq) => isIndexed(seq) ? imIndexedIter : isKeyed(seq) ? imKeyedIter : seq?.[SEQ_INFO] ?? unkIter;
1813
1707
  var normalizeRange = (start, end, size) => {
1814
1708
  let s = start == null ? 0 : start < 0 ? size + start : start;
@@ -1819,7 +1713,10 @@ var normalizeRange = (start, end, size) => {
1819
1713
  };
1820
1714
  var callEnricher = (enricher, it, binds, key, value, iterData) => {
1821
1715
  enricher.call(it, binds, key, value, iterData);
1822
- console.assert(binds.key === key && binds.value === value, "@enrich-with handlers must not overwrite binds.key or binds.value");
1716
+ console.assert(
1717
+ binds.key === key && binds.value === value,
1718
+ "@enrich-with handlers must not overwrite binds.key or binds.value"
1719
+ );
1823
1720
  binds.key = key;
1824
1721
  binds.value = value;
1825
1722
  };
@@ -1831,8 +1728,7 @@ var unpackLoopResult = (result, seq) => {
1831
1728
  };
1832
1729
  var imKeysIter = (seq, visit, keys) => {
1833
1730
  const attrName = isIndexed(seq) ? "si" : "sk";
1834
- for (const key of keys)
1835
- visit(key, seq.get(key), attrName);
1731
+ for (const key of keys) visit(key, seq.get(key), attrName);
1836
1732
  };
1837
1733
  var makeLoopCtx = (stack, filter) => ({
1838
1734
  lookup: (name) => stack.lookupBind(name),
@@ -1840,22 +1736,20 @@ var makeLoopCtx = (stack, filter) => ({
1840
1736
  });
1841
1737
  var imIndexedIter = (seq, visit, start, end) => {
1842
1738
  const [s, e] = normalizeRange(start, end, seq.size);
1843
- for (let i = s;i < e; i++)
1844
- visit(i, seq.get(i), "si");
1739
+ for (let i = s; i < e; i++) visit(i, seq.get(i), "si");
1845
1740
  };
1846
1741
  var imKeyedIter = (seq, visit, start, end) => {
1847
1742
  const [s, e] = normalizeRange(start, end, seq.size);
1848
1743
  let i = 0;
1849
1744
  for (const [k, v] of seq.toSeq().entries()) {
1850
- if (i >= e)
1851
- break;
1852
- if (i >= s)
1853
- visit(k, v, "sk");
1745
+ if (i >= e) break;
1746
+ if (i >= s) visit(k, v, "sk");
1854
1747
  i++;
1855
1748
  }
1856
1749
  };
1857
- var unkIter = () => {};
1858
- var SEQ_INFO = Symbol.for("tutuca.seqInfo");
1750
+ var unkIter = () => {
1751
+ };
1752
+ var SEQ_INFO = /* @__PURE__ */ Symbol.for("tutuca.seqInfo");
1859
1753
 
1860
1754
  // src/util/env.js
1861
1755
  var isMac = (globalThis.navigator?.userAgent ?? "").toLowerCase().includes("mac");
@@ -1869,18 +1763,15 @@ function resolveDynProducer(comp, name) {
1869
1763
  producerProvide = producerComp?.provide?.[lk.provideName];
1870
1764
  } else {
1871
1765
  const p = comp?.provide?.[name];
1872
- if (p == null)
1873
- return null;
1766
+ if (p == null) return null;
1874
1767
  producerComp = comp;
1875
1768
  producerProvide = p;
1876
1769
  }
1877
- if (producerComp == null || producerProvide == null)
1878
- return null;
1770
+ if (producerComp == null || producerProvide == null) return null;
1879
1771
  const pi = producerProvide.val?.toPathItem?.() ?? null;
1880
1772
  return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
1881
1773
  }
1882
-
1883
- class BaseNode {
1774
+ var BaseNode = class {
1884
1775
  render(_stack, _rx) {
1885
1776
  return null;
1886
1777
  }
@@ -1893,10 +1784,10 @@ class BaseNode {
1893
1784
  isWhiteSpace() {
1894
1785
  return false;
1895
1786
  }
1896
- optimize() {}
1897
- }
1898
-
1899
- class TextNode extends BaseNode {
1787
+ optimize() {
1788
+ }
1789
+ };
1790
+ var TextNode = class extends BaseNode {
1900
1791
  constructor(val) {
1901
1792
  super();
1902
1793
  this.val = val;
@@ -1905,18 +1796,16 @@ class TextNode extends BaseNode {
1905
1796
  return this.val;
1906
1797
  }
1907
1798
  isWhiteSpace() {
1908
- for (let i = 0;i < this.val.length; i++) {
1799
+ for (let i = 0; i < this.val.length; i++) {
1909
1800
  const c = this.val.charCodeAt(i);
1910
- if (!(c === 32 || c === 10 || c === 9 || c === 13))
1911
- return false;
1801
+ if (!(c === 32 || c === 10 || c === 9 || c === 13)) return false;
1912
1802
  }
1913
1803
  return true;
1914
1804
  }
1915
1805
  hasNewLine() {
1916
- for (let i = 0;i < this.val.length; i++) {
1806
+ for (let i = 0; i < this.val.length; i++) {
1917
1807
  const c = this.val.charCodeAt(i);
1918
- if (c === 10 || c === 13)
1919
- return true;
1808
+ if (c === 10 || c === 13) return true;
1920
1809
  }
1921
1810
  return false;
1922
1811
  }
@@ -1926,31 +1815,27 @@ class TextNode extends BaseNode {
1926
1815
  isConstant() {
1927
1816
  return true;
1928
1817
  }
1929
- setDataAttr(_key, _val) {}
1930
- }
1931
-
1932
- class CommentNode extends TextNode {
1818
+ setDataAttr(_key, _val) {
1819
+ }
1820
+ };
1821
+ var CommentNode = class extends TextNode {
1933
1822
  render(_stack, rx) {
1934
1823
  return rx.renderComment(this.val);
1935
1824
  }
1936
- }
1825
+ };
1937
1826
  function optimizeChilds(childs) {
1938
- for (let i = 0;i < childs.length; i++) {
1827
+ for (let i = 0; i < childs.length; i++) {
1939
1828
  const child = childs[i];
1940
- if (child.isConstant())
1941
- childs[i] = new RenderOnceNode(child);
1942
- else
1943
- child.optimize();
1829
+ if (child.isConstant()) childs[i] = new RenderOnceNode(child);
1830
+ else child.optimize();
1944
1831
  }
1945
1832
  }
1946
1833
  function optimizeNode(node) {
1947
- if (node.isConstant())
1948
- return new RenderOnceNode(node);
1834
+ if (node.isConstant()) return new RenderOnceNode(node);
1949
1835
  node.optimize();
1950
1836
  return node;
1951
1837
  }
1952
-
1953
- class ChildsNode extends BaseNode {
1838
+ var ChildsNode = class extends BaseNode {
1954
1839
  constructor(childs) {
1955
1840
  super();
1956
1841
  this.childs = childs;
@@ -1961,9 +1846,8 @@ class ChildsNode extends BaseNode {
1961
1846
  optimize() {
1962
1847
  optimizeChilds(this.childs);
1963
1848
  }
1964
- }
1965
-
1966
- class DomNode extends ChildsNode {
1849
+ };
1850
+ var DomNode = class extends ChildsNode {
1967
1851
  constructor(tagName, attrs, childs, namespace = null) {
1968
1852
  super(childs);
1969
1853
  this.tagName = tagName;
@@ -1972,7 +1856,7 @@ class DomNode extends ChildsNode {
1972
1856
  }
1973
1857
  render(stack, rx) {
1974
1858
  const childNodes = new Array(this.childs.length);
1975
- for (let i = 0;i < childNodes.length; i++)
1859
+ for (let i = 0; i < childNodes.length; i++)
1976
1860
  childNodes[i] = this.childs[i]?.render?.(stack, rx) ?? null;
1977
1861
  return rx.renderTag(this.tagName, this.attrs.eval(stack), childNodes, this.namespace);
1978
1862
  }
@@ -1982,21 +1866,18 @@ class DomNode extends ChildsNode {
1982
1866
  isConstant() {
1983
1867
  return this.attrs.isConstant() && super.isConstant();
1984
1868
  }
1985
- }
1986
-
1987
- class FragmentNode extends ChildsNode {
1869
+ };
1870
+ var FragmentNode = class extends ChildsNode {
1988
1871
  render(stack, rx) {
1989
1872
  return rx.renderFragment(this.childs.map((c) => c?.render(stack, rx)));
1990
1873
  }
1991
1874
  setDataAttr(key, val) {
1992
- for (const child of this.childs)
1993
- child.setDataAttr(key, val);
1875
+ for (const child of this.childs) child.setDataAttr(key, val);
1994
1876
  }
1995
- }
1877
+ };
1996
1878
  var maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs);
1997
1879
  var VALID_NODE_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
1998
-
1999
- class ANode extends BaseNode {
1880
+ var ANode = class _ANode extends BaseNode {
2000
1881
  constructor(nodeId, val) {
2001
1882
  super();
2002
1883
  this.nodeId = nodeId;
@@ -2005,41 +1886,33 @@ class ANode extends BaseNode {
2005
1886
  toPathStep(ctx) {
2006
1887
  return ctx.applyKey(this.val?.toPathItem?.() ?? null);
2007
1888
  }
2008
- static parse(html, px) {
2009
- const nodes = px.parseHTML(html);
2010
- if (nodes.length === 0)
2011
- return new CommentNode("Empty View in ANode.parse");
2012
- if (nodes.length === 1)
2013
- return ANode.fromDOM(nodes[0], px);
1889
+ static parse(html2, px) {
1890
+ const nodes = px.parseHTML(html2);
1891
+ if (nodes.length === 0) return new CommentNode("Empty View in ANode.parse");
1892
+ if (nodes.length === 1) return _ANode.fromDOM(nodes[0], px);
2014
1893
  const childs = [];
2015
- for (let i = 0;i < nodes.length; i++) {
2016
- const child = ANode.fromDOM(nodes[i], px);
2017
- if (child !== null)
2018
- childs.push(child);
1894
+ for (let i = 0; i < nodes.length; i++) {
1895
+ const child = _ANode.fromDOM(nodes[i], px);
1896
+ if (child !== null) childs.push(child);
2019
1897
  }
2020
1898
  const trimmed = condenseChildsWhites(childs);
2021
- if (trimmed.length === 0)
2022
- return new CommentNode("Empty View in ANode.parse");
1899
+ if (trimmed.length === 0) return new CommentNode("Empty View in ANode.parse");
2023
1900
  return maybeFragment(trimmed);
2024
1901
  }
2025
1902
  static fromDOM(node, px) {
2026
- if (node instanceof px.Text)
2027
- return new TextNode(node.textContent);
2028
- else if (node instanceof px.Comment)
2029
- return new CommentNode(node.textContent);
1903
+ if (node instanceof px.Text) return new TextNode(node.textContent);
1904
+ else if (node instanceof px.Comment) return new CommentNode(node.textContent);
2030
1905
  const { childNodes, attributes: attrs, tagName: tag } = node;
2031
1906
  const childs = [];
2032
- for (let i = 0;i < childNodes.length; i++) {
2033
- const child = ANode.fromDOM(childNodes[i], px);
2034
- if (child !== null)
2035
- childs.push(child);
1907
+ for (let i = 0; i < childNodes.length; i++) {
1908
+ const child = _ANode.fromDOM(childNodes[i], px);
1909
+ if (child !== null) childs.push(child);
2036
1910
  }
2037
1911
  const prevTag = px.currentTag;
2038
1912
  px.currentTag = tag;
2039
1913
  try {
2040
1914
  const isPseudoX = attrs[0]?.name === "@x";
2041
- if (tag === "X" || isPseudoX)
2042
- return parseXOp(attrs, childs, isPseudoX ? 1 : 0, px);
1915
+ if (tag === "X" || isPseudoX) return parseXOp(attrs, childs, isPseudoX ? 1 : 0, px);
2043
1916
  else if (tag.charCodeAt(1) === 58 && (tag.charCodeAt(0) === 88 || tag.charCodeAt(0) === 120)) {
2044
1917
  const macroName = tag.slice(2).toLowerCase();
2045
1918
  if (macroName === "slot") {
@@ -2052,8 +1925,7 @@ class ANode extends BaseNode {
2052
1925
  } else if (VALID_NODE_RE.test(tag)) {
2053
1926
  const [nAttrs, wrappers, textChild] = Attributes.parse(attrs, px);
2054
1927
  px.onAttributes(nAttrs, wrappers, textChild, false, tag);
2055
- if (textChild)
2056
- childs.unshift(new RenderTextNode(null, textChild));
1928
+ if (textChild) childs.unshift(new RenderTextNode(null, textChild));
2057
1929
  const domChilds = tag !== "PRE" ? condenseChildsWhites(childs) : childs;
2058
1930
  const ns = node.namespaceURI;
2059
1931
  const namespace = ns && ns !== HTML_NS ? ns : null;
@@ -2064,10 +1936,9 @@ class ANode extends BaseNode {
2064
1936
  px.currentTag = prevTag;
2065
1937
  }
2066
1938
  }
2067
- }
1939
+ };
2068
1940
  function parseXOp(attrs, childs, opIdx, px) {
2069
- if (attrs.length <= opIdx)
2070
- return maybeFragment(childs);
1941
+ if (attrs.length <= opIdx) return maybeFragment(childs);
2071
1942
  const { name, value } = attrs[opIdx];
2072
1943
  if (X_OPS[name]?.ignoresChildren && hasMeaningfulChilds(childs))
2073
1944
  px.onParseIssue("x-op-ignores-children", { op: name });
@@ -2076,13 +1947,13 @@ function parseXOp(attrs, childs, opIdx, px) {
2076
1947
  let node;
2077
1948
  switch (name) {
2078
1949
  case "slot":
2079
- node = new SlotNode(null, vp.const(value), maybeFragment(childs));
1950
+ node = new SlotNode(null, new ConstVal(value), maybeFragment(childs));
2080
1951
  break;
2081
1952
  case "text":
2082
- node = px.addNodeIf(RenderTextNode, parseXOpVal(name, value, px, vp.parseText));
1953
+ node = px.addNodeIf(RenderTextNode, parseXOpVal(name, value, px, parseText));
2083
1954
  break;
2084
1955
  case "render":
2085
- node = px.addNodeIf(RenderNode, parseXOpVal(name, value, px, vp.parseComponent), as);
1956
+ node = px.addNodeIf(RenderNode, parseXOpVal(name, value, px, parseComponent), as);
2086
1957
  break;
2087
1958
  case "render-it":
2088
1959
  node = px.addNode(RenderItNode, as);
@@ -2091,12 +1962,12 @@ function parseXOp(attrs, childs, opIdx, px) {
2091
1962
  node = parseRenderEach(px, value, as, attrs);
2092
1963
  break;
2093
1964
  case "show": {
2094
- const val = parseXOpVal(name, value, px, vp.parseBool);
1965
+ const val = parseXOpVal(name, value, px, parseBool);
2095
1966
  node = px.addNodeIf(ShowNode, val, maybeFragment(childs));
2096
1967
  break;
2097
1968
  }
2098
1969
  case "hide": {
2099
- const val = parseXOpVal(name, value, px, vp.parseBool);
1970
+ const val = parseXOpVal(name, value, px, parseBool);
2100
1971
  node = px.addNodeIf(HideNode, val, maybeFragment(childs));
2101
1972
  break;
2102
1973
  }
@@ -2107,39 +1978,35 @@ function parseXOp(attrs, childs, opIdx, px) {
2107
1978
  return processXExtras(node, attrs, name, opIdx + 1, px);
2108
1979
  }
2109
1980
  function parseXOpVal(opName, value, px, parserFn) {
2110
- const val = parserFn.call(vp, value, px);
2111
- if (val === null)
2112
- px.onParseIssue("bad-value", { role: "x-op", op: opName, value });
1981
+ const val = parserFn(value, px);
1982
+ if (val === null) px.onParseIssue("bad-value", { role: "x-op", op: opName, value });
2113
1983
  return val;
2114
1984
  }
2115
1985
  function parseViewName(s, px) {
2116
- return vp.parseText(s, px) ?? vp.const(s);
1986
+ return parseText(s, px) ?? new ConstVal(s);
2117
1987
  }
2118
1988
  function processXExtras(node, attrs, opName, startIdx, px) {
2119
1989
  const { consumed, wrappable } = X_OPS[opName];
2120
1990
  const wrappers = [];
2121
- for (let i = startIdx;i < attrs.length; i++) {
1991
+ for (let i = startIdx; i < attrs.length; i++) {
2122
1992
  const a = attrs[i];
2123
1993
  const aName = a.name;
2124
- if (consumed.has(aName))
2125
- continue;
1994
+ if (consumed.has(aName)) continue;
2126
1995
  const atPrefixed = aName.charCodeAt(0) === 64;
2127
1996
  const baseName = atPrefixed ? aName.slice(1) : aName;
2128
1997
  const wrapper = wrappable ? X_OPS[baseName]?.wrapper : null;
2129
1998
  if (wrapper) {
2130
- if (!atPrefixed)
2131
- maybeDeprecateBareXDirective(px, opName, baseName);
2132
- wrappers.push([wrapper, vp.parseBool(a.value, px)]);
1999
+ if (!atPrefixed) maybeDeprecateBareXDirective(px, opName, baseName);
2000
+ wrappers.push([wrapper, parseBool(a.value, px)]);
2133
2001
  continue;
2134
2002
  }
2135
2003
  const issueInfo = { op: opName, name: aName, value: a.value };
2136
2004
  px.onParseIssue("unknown-x-attr", issueInfo);
2137
2005
  }
2138
- for (let i = wrappers.length - 1;i >= 0; i--) {
2006
+ for (let i = wrappers.length - 1; i >= 0; i--) {
2139
2007
  const [Cls, val] = wrappers[i];
2140
2008
  const wrapper = px.addNodeIf(Cls, val, node);
2141
- if (wrapper !== null)
2142
- node = wrapper;
2009
+ if (wrapper !== null) node = wrapper;
2143
2010
  }
2144
2011
  return node;
2145
2012
  }
@@ -2148,7 +2015,7 @@ function maybeDeprecateBareXDirective(px, opName, name) {
2148
2015
  }
2149
2016
  function wrap(node, px, wrappers) {
2150
2017
  if (wrappers) {
2151
- for (let i = wrappers.length - 1;i >= 0; i--) {
2018
+ for (let i = wrappers.length - 1; i >= 0; i--) {
2152
2019
  const wrapperNode = makeWrapperNode(wrappers[i], px);
2153
2020
  if (wrapperNode) {
2154
2021
  wrapperNode.wrapNode(node);
@@ -2168,8 +2035,7 @@ function makeWrapperNode(data, px) {
2168
2035
  }
2169
2036
  return node;
2170
2037
  }
2171
-
2172
- class MacroNode extends BaseNode {
2038
+ var MacroNode = class extends BaseNode {
2173
2039
  constructor(name, attrs, slots, px) {
2174
2040
  super();
2175
2041
  this.name = name;
@@ -2181,16 +2047,13 @@ class MacroNode extends BaseNode {
2181
2047
  }
2182
2048
  compile(scope) {
2183
2049
  const { name, attrs, slots } = this;
2184
- if (this.px.isInsideMacro(name))
2185
- throw new Error(`Recursive macro expansion: ${name}`);
2186
- const macro = scope.lookupMacro(name);
2187
- if (macro === null)
2188
- this.node = new CommentNode(`bad macro: ${name}`);
2050
+ if (this.px.isInsideMacro(name)) throw new Error(`Recursive macro expansion: ${name}`);
2051
+ const macro2 = scope.lookupMacro(name);
2052
+ if (macro2 === null) this.node = new CommentNode(`bad macro: ${name}`);
2189
2053
  else {
2190
- const vars = { ...macro.defaults, ...attrs };
2191
- this.node = macro.expand(this.px.enterMacro(name, vars, slots));
2192
- for (const key in this.dataAttrs)
2193
- this.node.setDataAttr(key, this.dataAttrs[key]);
2054
+ const vars = { ...macro2.defaults, ...attrs };
2055
+ this.node = macro2.expand(this.px.enterMacro(name, vars, slots));
2056
+ for (const key in this.dataAttrs) this.node.setDataAttr(key, this.dataAttrs[key]);
2194
2057
  }
2195
2058
  }
2196
2059
  render(stack, rx) {
@@ -2205,9 +2068,8 @@ class MacroNode extends BaseNode {
2205
2068
  optimize() {
2206
2069
  this.node = optimizeNode(this.node);
2207
2070
  }
2208
- }
2209
-
2210
- class Macro {
2071
+ };
2072
+ var Macro = class {
2211
2073
  constructor(defaults, rawView) {
2212
2074
  this.defaults = defaults;
2213
2075
  this.rawView = rawView;
@@ -2215,46 +2077,47 @@ class Macro {
2215
2077
  expand(px) {
2216
2078
  return ANode.parse(this.rawView, px);
2217
2079
  }
2218
- }
2219
-
2220
- class RenderViewId extends ANode {
2080
+ };
2081
+ var RenderViewId = class extends ANode {
2221
2082
  constructor(nodeId, val, viewVal) {
2222
2083
  super(nodeId, val);
2223
2084
  this.viewVal = viewVal;
2224
2085
  }
2086
+ // The `as=` view selector, evaluated against the host (enclosing) stack like
2087
+ // `@push-view`. Null when `as=` is absent, so the renderer falls through to
2088
+ // `stack.lookupBestView`.
2225
2089
  evalViewName(stack) {
2226
2090
  return this.viewVal ? this.viewVal.eval(stack) : null;
2227
2091
  }
2228
- setDataAttr(_key, _val) {}
2229
- }
2092
+ // A `<x render*>` produces no DOM element of its own to carry `data-cid`;
2093
+ // when it is a view's root the component boundary is recorded in the `Comp`
2094
+ // meta comment instead (see Renderer._rValComp), so this is a no-op.
2095
+ setDataAttr(_key, _val) {
2096
+ }
2097
+ };
2230
2098
  function dynRenderStep(comp, name, key) {
2231
2099
  const p = resolveDynProducer(comp, name);
2232
- if (!p)
2233
- return null;
2234
- return key === undefined ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
2100
+ if (!p) return null;
2101
+ return key === void 0 ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
2235
2102
  }
2236
-
2237
- class RenderNode extends RenderViewId {
2103
+ var RenderNode = class extends RenderViewId {
2238
2104
  render(stack, rx) {
2239
2105
  const newStack = stack.enter(this.val.eval(stack), {}, true);
2240
2106
  return rx.renderIt(newStack, this, "", this.evalViewName(stack));
2241
2107
  }
2242
2108
  toPathStep(ctx) {
2243
- if (this.val instanceof DynVal)
2244
- return dynRenderStep(ctx.comp, this.val.name);
2109
+ if (this.val instanceof DynVal) return dynRenderStep(ctx.comp, this.val.name);
2245
2110
  return super.toPathStep(ctx);
2246
2111
  }
2247
- }
2248
-
2249
- class RenderItNode extends RenderViewId {
2112
+ };
2113
+ var RenderItNode = class extends RenderViewId {
2250
2114
  render(stack, rx) {
2251
2115
  const newStack = stack.enter(stack.it, {}, true);
2252
2116
  return rx.renderIt(newStack, this, "", this.evalViewName(stack));
2253
2117
  }
2254
2118
  toPathStep(ctx) {
2255
2119
  const next = ctx.next();
2256
- if (next === null)
2257
- return null;
2120
+ if (next === null) return null;
2258
2121
  const nextNode = next.resolveNode();
2259
2122
  if (nextNode instanceof EachNode && next.hasKey) {
2260
2123
  if (nextNode.val instanceof DynVal)
@@ -2263,18 +2126,17 @@ class RenderItNode extends RenderViewId {
2263
2126
  }
2264
2127
  return null;
2265
2128
  }
2266
- }
2129
+ };
2267
2130
  function parseRenderEach(px, value, as, attrs) {
2268
- const seqVal = parseXOpVal("render-each", value, px, vp.parseSequence);
2269
- if (seqVal === null)
2270
- return null;
2131
+ const seqVal = parseXOpVal("render-each", value, px, parseSequence);
2132
+ if (seqVal === null) return null;
2271
2133
  const renderIt = px.addNode(RenderItNode, as);
2272
2134
  const attrParser = getAttrParser(px);
2273
- const eachAttr = attrParser.eachAttr = attrParser.pushWrapper("each", value, seqVal);
2135
+ const eachAttr = attrParser.pushWrapper("each", value, seqVal);
2136
+ attrParser.eachAttr = eachAttr;
2274
2137
  const when = attrs.getNamedItem("@when") ?? attrs.getNamedItem("when");
2275
2138
  if (when) {
2276
- if (when.name.charCodeAt(0) !== 64)
2277
- maybeDeprecateBareXDirective(px, "render-each", "when");
2139
+ if (when.name.charCodeAt(0) !== 64) maybeDeprecateBareXDirective(px, "render-each", "when");
2278
2140
  attrParser._parseWhen(when.value);
2279
2141
  }
2280
2142
  const lWith = attrs.getNamedItem("@loop-with") ?? attrs.getNamedItem("loop-with");
@@ -2290,15 +2152,15 @@ function parseRenderEach(px, value, as, attrs) {
2290
2152
  each.wrapNode(renderIt);
2291
2153
  return each;
2292
2154
  }
2293
-
2294
- class RenderTextNode extends ANode {
2155
+ var RenderTextNode = class extends ANode {
2295
2156
  render(stack, _rx) {
2296
2157
  return this.val.eval(stack);
2297
2158
  }
2298
- setDataAttr(_key, _val) {}
2299
- }
2300
-
2301
- class RenderOnceNode extends BaseNode {
2159
+ // Renders to a text node, which can't carry `data-cid`.
2160
+ setDataAttr(_key, _val) {
2161
+ }
2162
+ };
2163
+ var RenderOnceNode = class extends BaseNode {
2302
2164
  constructor(node) {
2303
2165
  super();
2304
2166
  this.node = node;
@@ -2311,9 +2173,8 @@ class RenderOnceNode extends BaseNode {
2311
2173
  render(stack, rx) {
2312
2174
  return this._render(stack, rx);
2313
2175
  }
2314
- }
2315
-
2316
- class WrapperNode extends ANode {
2176
+ };
2177
+ var WrapperNode = class extends ANode {
2317
2178
  constructor(nodeId, val, node = null) {
2318
2179
  super(nodeId, val);
2319
2180
  this.node = node;
@@ -2328,34 +2189,33 @@ class WrapperNode extends ANode {
2328
2189
  this.node = optimizeNode(this.node);
2329
2190
  }
2330
2191
  static register = false;
2331
- }
2332
-
2333
- class ShowNode extends WrapperNode {
2192
+ };
2193
+ var ShowNode = class extends WrapperNode {
2334
2194
  render(stack, rx) {
2335
2195
  return this.val.eval(stack) ? this.node.render(stack, rx) : null;
2336
2196
  }
2337
- }
2338
-
2339
- class HideNode extends WrapperNode {
2197
+ };
2198
+ var HideNode = class extends WrapperNode {
2340
2199
  render(stack, rx) {
2341
2200
  return this.val.eval(stack) ? null : this.node.render(stack, rx);
2342
2201
  }
2343
- }
2344
-
2345
- class PushViewNameNode extends WrapperNode {
2202
+ };
2203
+ var PushViewNameNode = class extends WrapperNode {
2346
2204
  render(stack, rx) {
2347
2205
  return this.node.render(stack.pushViewName(this.val.eval(stack)), rx);
2348
2206
  }
2349
- }
2350
-
2351
- class SlotNode extends WrapperNode {
2207
+ };
2208
+ var SlotNode = class extends WrapperNode {
2209
+ // Marker instead of `instanceof`: newMacroNode receives nodes that may come
2210
+ // from a different copy of this module (CLI tools import src/ while the
2211
+ // module under render imports the dist bundle), and cross-copy instanceof
2212
+ // is always false.
2352
2213
  isSlotNode = true;
2353
2214
  optimize() {
2354
2215
  this.node.optimize();
2355
2216
  }
2356
- }
2357
-
2358
- class ScopeNode extends WrapperNode {
2217
+ };
2218
+ var ScopeNode = class extends WrapperNode {
2359
2219
  render(stack, rx) {
2360
2220
  const binds = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
2361
2221
  const dom = this.node.render(stack.enter(stack.it, binds, false), rx);
@@ -2369,9 +2229,8 @@ class ScopeNode extends WrapperNode {
2369
2229
  this.node.setDataAttr("data-nid", this.nodeId);
2370
2230
  }
2371
2231
  static register = true;
2372
- }
2373
-
2374
- class EachNode extends WrapperNode {
2232
+ };
2233
+ var EachNode = class extends WrapperNode {
2375
2234
  constructor(nodeId, val) {
2376
2235
  super(nodeId, val);
2377
2236
  this.iterInfo = new IterInfo(val, null, null, null);
@@ -2383,9 +2242,8 @@ class EachNode extends WrapperNode {
2383
2242
  return ctx.hasKey ? new EachBindStep(this.iterInfo, ctx.key) : null;
2384
2243
  }
2385
2244
  static register = true;
2386
- }
2387
-
2388
- class IterInfo {
2245
+ };
2246
+ var IterInfo = class {
2389
2247
  constructor(val, whenVal, loopWithVal, enrichWithVal) {
2390
2248
  this.val = val;
2391
2249
  this.whenVal = whenVal;
@@ -2399,17 +2257,22 @@ class IterInfo {
2399
2257
  const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
2400
2258
  return { seq, filter, loopWith, enricher };
2401
2259
  }
2260
+ // Rebuild the per-item binds for `key`, mirroring renderEachWhen: seed
2261
+ // { key, value }, then run @enrich-with (with @loop-with's iterData) if any.
2402
2262
  enrichBinds(stack, key) {
2403
2263
  const { seq, filter, loopWith, enricher } = this.eval(stack);
2404
2264
  const value = seq?.get ? seq.get(key, null) : null;
2405
2265
  const binds = { key, value };
2406
2266
  if (enricher) {
2407
- const { iterData } = unpackLoopResult(loopWith.call(stack.it, seq, makeLoopCtx(stack, filter)), seq);
2267
+ const { iterData } = unpackLoopResult(
2268
+ loopWith.call(stack.it, seq, makeLoopCtx(stack, filter)),
2269
+ seq
2270
+ );
2408
2271
  callEnricher(enricher, stack.it, binds, key, value, iterData);
2409
2272
  }
2410
2273
  return binds;
2411
2274
  }
2412
- }
2275
+ };
2413
2276
  function xOp(consumed = [], { wrappable = false, wrapper = null, ignoresChildren = false } = {}) {
2414
2277
  return { consumed: new Set(consumed), wrappable, wrapper, ignoresChildren };
2415
2278
  }
@@ -2418,6 +2281,10 @@ var X_OPS = {
2418
2281
  text: xOp([], { wrappable: true, ignoresChildren: true }),
2419
2282
  render: xOp(["as"], { wrappable: true, ignoresChildren: true }),
2420
2283
  "render-it": xOp(["as"], { wrappable: true, ignoresChildren: true }),
2284
+ // `@when`/`@loop-with` are consumed here (handled in parseRenderEach) so
2285
+ // `processXExtras` does not flag them as unknown attrs. TEMPORARY: the bare
2286
+ // `when`/`loop-with` spellings are deprecated in favor of the `@` form — see
2287
+ // maybeDeprecateBareXDirective (added 2026-07-08).
2421
2288
  "render-each": xOp(["as", "when", "loop-with", "@when", "@loop-with"], {
2422
2289
  wrappable: true,
2423
2290
  ignoresChildren: true
@@ -2429,11 +2296,11 @@ var WRAPPER_NODES = {
2429
2296
  show: ShowNode,
2430
2297
  hide: HideNode,
2431
2298
  each: EachNode,
2299
+ // internal wrapper produced by a loop-less @enrich-with (no surface @scope directive)
2432
2300
  scope: ScopeNode,
2433
2301
  "push-view": PushViewNameNode
2434
2302
  };
2435
-
2436
- class ParseContext {
2303
+ var ParseContext = class _ParseContext {
2437
2304
  constructor(document2, Text, Comment, nodes, events, macroNodes, frame, parent) {
2438
2305
  this.nodes = nodes ?? [];
2439
2306
  this.events = events ?? [];
@@ -2452,11 +2319,11 @@ class ParseContext {
2452
2319
  enterMacro(macroName, macroVars, macroSlots) {
2453
2320
  const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
2454
2321
  const frame = { macroName, macroVars, macroSlots };
2455
- return new ParseContext(document2, Text, Comment, nodes, events, macroNodes, frame, this);
2322
+ return new _ParseContext(document2, Text, Comment, nodes, events, macroNodes, frame, this);
2456
2323
  }
2457
- parseHTML(html) {
2324
+ parseHTML(html2) {
2458
2325
  const t = this.document.createElement("template");
2459
- t.innerHTML = html;
2326
+ t.innerHTML = html2;
2460
2327
  return t.content.childNodes;
2461
2328
  }
2462
2329
  addNodeIf(Class, val, extra) {
@@ -2468,6 +2335,8 @@ class ParseContext {
2468
2335
  }
2469
2336
  return null;
2470
2337
  }
2338
+ // For nodes that carry no value (e.g. RenderItNode, which reads stack.it at
2339
+ // render time); addNodeIf treats a null val as a failed parse.
2471
2340
  addNode(Class, extra) {
2472
2341
  const nodeId = this.nodes.length;
2473
2342
  const node = new Class(nodeId, null, extra);
@@ -2484,21 +2353,17 @@ class ParseContext {
2484
2353
  const anySlot = [];
2485
2354
  const slots = { _: new FragmentNode(anySlot) };
2486
2355
  for (const child of childs)
2487
- if (child.isSlotNode)
2488
- slots[child.val.val] = child.node;
2489
- else if (!child.isWhiteSpace())
2490
- anySlot.push(child);
2356
+ if (child.isSlotNode) slots[child.val.val] = child.node;
2357
+ else if (!child.isWhiteSpace()) anySlot.push(child);
2491
2358
  const node = new MacroNode(macroName, mAttrs, slots, this);
2492
2359
  this.macroNodes.push(node);
2493
2360
  return node;
2494
2361
  }
2495
2362
  compile(scope) {
2496
- for (let i = 0;i < this.macroNodes.length; i++)
2497
- this.macroNodes[i].compile(scope);
2363
+ for (let i = 0; i < this.macroNodes.length; i++) this.macroNodes[i].compile(scope);
2498
2364
  }
2499
2365
  *genEventNames() {
2500
- for (const event of this.events)
2501
- yield* event.genEventNames();
2366
+ for (const event of this.events) yield* event.genEventNames();
2502
2367
  }
2503
2368
  getEventForId(id) {
2504
2369
  return this.events[id] ?? null;
@@ -2506,12 +2371,16 @@ class ParseContext {
2506
2371
  getNodeForId(id) {
2507
2372
  return this.nodes[id] ?? null;
2508
2373
  }
2509
- onAttributes(_attrs, _wrapperAttrs, _textChild, _isMacroCall, _tag) {}
2374
+ onAttributes(_attrs, _wrapperAttrs, _textChild, _isMacroCall, _tag) {
2375
+ }
2510
2376
  onParseIssue(kind, info) {
2511
2377
  console.warn(`tutuca parse issue [${kind}]`, info);
2512
2378
  }
2513
- onDeprecatedSyntax(_kind, _info) {}
2514
- }
2379
+ // Lint-only channel for deprecation nudges on still-valid syntax; the base
2380
+ // (runtime) context ignores them so live apps stay quiet. See LintParseContext.
2381
+ onDeprecatedSyntax(_kind, _info) {
2382
+ }
2383
+ };
2515
2384
  var _htmlBlockTags = "ADDRESS,ARTICLE,ASIDE,BLOCKQUOTE,CAPTION,COL,COLGROUP,DETAILS,DIALOG,DIV,DD,DL,DT,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEADER,HGROUP,HR,LEGEND,LI,MAIN,MENU,NAV,OL,P,PRE,SECTION,SUMMARY,TABLE,TBODY,TD,TFOOT,TH,THEAD,TR,UL";
2516
2385
  var HTML_BLOCK_TAGS = new Set(_htmlBlockTags.split(","));
2517
2386
  var isBlockDomNode = (n) => {
@@ -2522,31 +2391,25 @@ var isEmptyText = (c) => c instanceof TextNode && c.val === "";
2522
2391
  var isIgnorableXChild = (c) => c instanceof CommentNode || (c.isWhiteSpace?.() ?? false);
2523
2392
  var hasMeaningfulChilds = (childs) => childs.some((c) => !isIgnorableXChild(c));
2524
2393
  function trimEdgeWhite(node) {
2525
- if (!node.isWhiteSpace?.())
2526
- return false;
2394
+ if (!node.isWhiteSpace?.()) return false;
2527
2395
  node.condenseWhiteSpace();
2528
2396
  return true;
2529
2397
  }
2530
2398
  function condenseChildsWhites(childs) {
2531
- if (childs.length === 0)
2532
- return childs;
2399
+ if (childs.length === 0) return childs;
2533
2400
  const last = childs.length - 1;
2534
2401
  let emptied = trimEdgeWhite(childs[0]);
2535
- if (last > 0 && trimEdgeWhite(childs[last]))
2536
- emptied = true;
2537
- for (let i = 1;i < last; i++) {
2402
+ if (last > 0 && trimEdgeWhite(childs[last])) emptied = true;
2403
+ for (let i = 1; i < last; i++) {
2538
2404
  const cur = childs[i];
2539
- if (!(cur.isWhiteSpace?.() && cur.hasNewLine()))
2540
- continue;
2405
+ if (!(cur.isWhiteSpace?.() && cur.hasNewLine())) continue;
2541
2406
  const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
2542
2407
  cur.condenseWhiteSpace(bothBlock ? "" : " ");
2543
- if (bothBlock)
2544
- emptied = true;
2408
+ if (bothBlock) emptied = true;
2545
2409
  }
2546
2410
  return emptied ? childs.filter((c) => !isEmptyText(c)) : childs;
2547
2411
  }
2548
-
2549
- class View {
2412
+ var View = class {
2550
2413
  constructor(name, rawView = "No View Defined", style = "", anode = null, ctx = null) {
2551
2414
  this.name = name;
2552
2415
  this.anode = anode;
@@ -2560,18 +2423,18 @@ class View {
2560
2423
  this.anode.setDataAttr("data-cid", cid);
2561
2424
  this.anode.setDataAttr("data-vid", this.name);
2562
2425
  this.ctx.compile(scope);
2563
- if (ctx.cacheConstNodes)
2564
- this.anode = optimizeNode(this.anode);
2426
+ if (ctx.cacheConstNodes) this.anode = optimizeNode(this.anode);
2565
2427
  }
2566
2428
  render(stack, rx) {
2567
2429
  if (this.anode === null) {
2568
- throw new Error(`tutuca: view "${this.name}" was rendered before it was compiled — its ` + `component is not registered in this app/scope. Source: ` + `${String(this.rawView).slice(0, 80).replace(/\s+/g, " ")}…`);
2430
+ throw new Error(
2431
+ `tutuca: view "${this.name}" was rendered before it was compiled — its component is not registered in this app/scope. Source: ${String(this.rawView).slice(0, 80).replace(/\s+/g, " ")}…`
2432
+ );
2569
2433
  }
2570
2434
  return this.anode.render(stack, rx);
2571
2435
  }
2572
- }
2573
-
2574
- class NodeEvents {
2436
+ };
2437
+ var NodeEvents = class {
2575
2438
  constructor(id) {
2576
2439
  this.id = id;
2577
2440
  this.handlers = [];
@@ -2580,8 +2443,7 @@ class NodeEvents {
2580
2443
  this.handlers.push(new NodeEvent(name, handlerCall, modifiers));
2581
2444
  }
2582
2445
  *genEventNames() {
2583
- for (const handler of this.handlers)
2584
- yield handler.name;
2446
+ for (const handler of this.handlers) yield handler.name;
2585
2447
  }
2586
2448
  getHandlersFor(eventName) {
2587
2449
  let r = null;
@@ -2592,9 +2454,8 @@ class NodeEvents {
2592
2454
  }
2593
2455
  return r;
2594
2456
  }
2595
- }
2596
-
2597
- class NodeEvent {
2457
+ };
2458
+ var NodeEvent = class {
2598
2459
  constructor(name, handlerCall, modifiers) {
2599
2460
  this.name = name;
2600
2461
  this.handlerCall = handlerCall;
@@ -2609,31 +2470,45 @@ class NodeEvent {
2609
2470
  r[0] = this.modifierWrapper(r[0], event);
2610
2471
  return r;
2611
2472
  }
2612
- }
2473
+ };
2613
2474
  var fwdIfCtxPred = (pred) => (w) => (that, f, args, ctx) => pred(ctx) ? w(that, f, args, ctx) : that;
2614
2475
  var fwdIfKey = (keyName) => fwdIfCtxPred((ctx) => ctx.e.key === keyName);
2615
2476
  var fwdCtrl = fwdIfCtxPred(({ e }) => isMac && e.metaKey || e.ctrlKey);
2616
2477
  var fwdMeta = fwdIfCtxPred(({ e }) => e.metaKey);
2617
2478
  var fwdAlt = fwdIfCtxPred(({ e }) => e.altKey);
2618
- var metaWraps = { ctrl: fwdCtrl, cmd: fwdCtrl, meta: fwdMeta, alt: fwdAlt };
2479
+ var MOD_WRAPPERS_FOR_ANY_EVENT = {
2480
+ ctrl: fwdCtrl,
2481
+ cmd: fwdCtrl,
2482
+ meta: fwdMeta,
2483
+ alt: fwdAlt
2484
+ };
2619
2485
  var MOD_WRAPPERS_BY_EVENT = {
2620
2486
  keydown: {
2621
2487
  send: fwdIfKey("Enter"),
2622
- cancel: fwdIfKey("Escape"),
2623
- ...metaWraps
2624
- },
2625
- click: { ...metaWraps }
2488
+ cancel: fwdIfKey("Escape")
2489
+ }
2626
2490
  };
2491
+ var MOD_EFFECTS = {
2492
+ prevent: (e) => e.preventDefault?.(),
2493
+ stop: (e) => e.stopPropagation?.()
2494
+ };
2495
+ var NO_WRAPPERS = {};
2627
2496
  var identityModifierWrapper = (f, _ctx) => f;
2628
2497
  function compileModifiers(eventName, names) {
2629
- if (names.length === 0)
2630
- return identityModifierWrapper;
2631
- const wrappers = MOD_WRAPPERS_BY_EVENT[eventName] ?? {};
2632
- let w = (that, f, args, _ctx) => f.apply(that, args);
2498
+ if (names.length === 0) return identityModifierWrapper;
2499
+ const wrappers = MOD_WRAPPERS_BY_EVENT[eventName] ?? NO_WRAPPERS;
2500
+ const effects = [];
2501
+ for (const name of names) {
2502
+ const effect = MOD_EFFECTS[name];
2503
+ if (effect !== void 0) effects.push(effect);
2504
+ }
2505
+ let w = effects.length === 0 ? (that, f, args, _ctx) => f.apply(that, args) : (that, f, args, ctx) => {
2506
+ for (const effect of effects) effect(ctx.e);
2507
+ return f.apply(that, args);
2508
+ };
2633
2509
  for (const name of names) {
2634
- const wrapper = wrappers[name];
2635
- if (wrapper !== undefined)
2636
- w = wrapper(w);
2510
+ const wrapper = wrappers[name] ?? MOD_WRAPPERS_FOR_ANY_EVENT[name];
2511
+ if (wrapper !== void 0) w = wrapper(w);
2637
2512
  }
2638
2513
  return (f, ctx) => function(...args) {
2639
2514
  return w(this, f, args, ctx);
@@ -2641,10 +2516,10 @@ function compileModifiers(eventName, names) {
2641
2516
  }
2642
2517
 
2643
2518
  // src/components.js
2644
- class Components {
2519
+ var Components = class {
2645
2520
  constructor() {
2646
- this.getComponentSymbol = Symbol("getComponent");
2647
- this.byId = new Map;
2521
+ this.getComponentSymbol = /* @__PURE__ */ Symbol("getComponent");
2522
+ this.byId = /* @__PURE__ */ new Map();
2648
2523
  }
2649
2524
  registerComponent(comp) {
2650
2525
  comp.Class.prototype[this.getComponentSymbol] = () => comp;
@@ -2664,15 +2539,12 @@ class Components {
2664
2539
  }
2665
2540
  compileStyles() {
2666
2541
  const styles = [];
2667
- for (const comp of this.byId.values())
2668
- styles.push(comp.compileStyle());
2669
- return styles.join(`
2670
- `);
2542
+ for (const comp of this.byId.values()) styles.push(comp.compileStyle());
2543
+ return styles.join("\n");
2671
2544
  }
2672
- }
2673
-
2674
- class ComponentStack {
2675
- constructor(comps = new Components, parent = null) {
2545
+ };
2546
+ var ComponentStack = class _ComponentStack {
2547
+ constructor(comps = new Components(), parent = null) {
2676
2548
  this.comps = comps;
2677
2549
  this.parent = parent;
2678
2550
  this.byName = {};
@@ -2680,11 +2552,11 @@ class ComponentStack {
2680
2552
  this.macros = {};
2681
2553
  }
2682
2554
  enter() {
2683
- return new ComponentStack(this.comps, this);
2555
+ return new _ComponentStack(this.comps, this);
2684
2556
  }
2685
2557
  registerComponents(comps, opts) {
2686
2558
  const { aliases = {} } = opts ?? {};
2687
- for (let i = 0;i < comps.length; i++) {
2559
+ for (let i = 0; i < comps.length; i++) {
2688
2560
  const comp = comps[i];
2689
2561
  comp.scope = this.enter();
2690
2562
  comp.Class.scope = comp.scope;
@@ -2693,17 +2565,15 @@ class ComponentStack {
2693
2565
  }
2694
2566
  for (const alias in aliases) {
2695
2567
  const comp = this.byName[aliases[alias]];
2696
- console.assert(this.byName[alias] === undefined, "alias overrides component", alias);
2697
- if (comp !== undefined)
2698
- this.byName[alias] = comp;
2699
- else
2700
- console.warn("alias", alias, "to inexistent component", aliases[alias]);
2568
+ console.assert(this.byName[alias] === void 0, "alias overrides component", alias);
2569
+ if (comp !== void 0) this.byName[alias] = comp;
2570
+ else console.warn("alias", alias, "to inexistent component", aliases[alias]);
2701
2571
  }
2702
2572
  }
2703
2573
  registerMacros(macros) {
2704
2574
  for (const key in macros) {
2705
2575
  const lower = key.toLowerCase();
2706
- console.assert(this.macros[lower] === undefined, "macro key collision", lower);
2576
+ console.assert(this.macros[lower] === void 0, "macro key collision", lower);
2707
2577
  this.macros[lower] = macros[key];
2708
2578
  }
2709
2579
  }
@@ -2711,8 +2581,7 @@ class ComponentStack {
2711
2581
  return this.comps.getCompFor(v);
2712
2582
  }
2713
2583
  registerRequestHandlers(handlers) {
2714
- for (const name in handlers)
2715
- this.reqsByName[name] = new RequestHandler(name, handlers[name]);
2584
+ for (const name in handlers) this.reqsByName[name] = new RequestHandler(name, handlers[name]);
2716
2585
  }
2717
2586
  lookupRequest(name) {
2718
2587
  return this.reqsByName[name] ?? this.parent?.lookupRequest(name) ?? null;
@@ -2723,36 +2592,33 @@ class ComponentStack {
2723
2592
  lookupMacro(name) {
2724
2593
  return this.macros[name] ?? this.parent?.lookupMacro(name) ?? null;
2725
2594
  }
2726
- }
2727
-
2728
- class ProvideInfo {
2595
+ };
2596
+ var ProvideInfo = class {
2729
2597
  constructor(name, val, symbol) {
2730
2598
  this.name = name;
2731
2599
  this.val = val;
2732
2600
  this.symbol = symbol;
2733
2601
  }
2734
- }
2735
-
2736
- class LookupInfo {
2602
+ };
2603
+ var LookupInfo = class {
2737
2604
  constructor(name, compName, provideName, val) {
2738
2605
  this.name = name;
2739
2606
  this.compName = compName;
2740
2607
  this.provideName = provideName;
2741
2608
  this.val = val;
2742
- this._sym = undefined;
2609
+ this._sym = void 0;
2743
2610
  }
2744
2611
  getProducerSymbol(stack) {
2745
- if (this._sym === undefined)
2612
+ if (this._sym === void 0)
2746
2613
  this._sym = stack.lookupType(this.compName)?.provide?.[this.provideName]?.symbol ?? null;
2747
2614
  return this._sym;
2748
2615
  }
2749
- }
2616
+ };
2750
2617
  var isString = (v) => typeof v === "string";
2751
2618
  var _rawSpecKeys = "name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics";
2752
2619
  var KNOWN_SPEC_KEYS = new Set(_rawSpecKeys.split(" "));
2753
2620
  var _compId = 0;
2754
-
2755
- class Component {
2621
+ var Component = class {
2756
2622
  constructor(Class, o) {
2757
2623
  this.id = _compId++;
2758
2624
  this.name = o.name ?? "UnkComp";
@@ -2777,31 +2643,27 @@ class Component {
2777
2643
  this.scope = null;
2778
2644
  this.spec = o;
2779
2645
  this.extra = {};
2780
- for (const key of Object.keys(o))
2781
- if (!KNOWN_SPEC_KEYS.has(key))
2782
- this.extra[key] = o[key];
2646
+ for (const key of Object.keys(o)) if (!KNOWN_SPEC_KEYS.has(key)) this.extra[key] = o[key];
2783
2647
  }
2784
2648
  compile(ParseContext2) {
2785
2649
  for (const name in this.views)
2786
- this.views[name].compile(new ParseContext2, this.scope, this.id);
2650
+ this.views[name].compile(new ParseContext2(), this.scope, this.id);
2787
2651
  const ctx = this.views.main.ctx;
2788
2652
  for (const key in this._rawProvide) {
2789
- const val = vp.parseProvide(this._rawProvide[key], ctx);
2790
- if (val)
2791
- this.provide[key] = new ProvideInfo(key, val, Symbol(key));
2653
+ const val = parseProvide(this._rawProvide[key], ctx);
2654
+ if (val) this.provide[key] = new ProvideInfo(key, val, Symbol(key));
2792
2655
  }
2793
2656
  for (const key in this._rawLookup) {
2794
2657
  const linfo = this._rawLookup[key];
2795
2658
  const forStr = isString(linfo) ? linfo : isString(linfo?.for) ? linfo.for : null;
2796
2659
  const [compName, provideName] = forStr === null ? [] : forStr.split(".");
2797
- if (!isString(compName) || !isString(provideName))
2798
- continue;
2660
+ if (!isString(compName) || !isString(provideName)) continue;
2799
2661
  const defStr = isString(linfo?.default) ? linfo.default : null;
2800
- const val = defStr === null ? null : vp.parseField(defStr, ctx);
2662
+ const val = defStr === null ? null : parseField(defStr, ctx);
2801
2663
  this.lookup[key] = new LookupInfo(key, compName, provideName, val);
2802
2664
  }
2803
2665
  for (const key in this.lookup)
2804
- if (this.provide[key] !== undefined)
2666
+ if (this.provide[key] !== void 0)
2805
2667
  console.warn("name declared in both provide and lookup", this.name, key);
2806
2668
  }
2807
2669
  make(args, opts) {
@@ -2819,35 +2681,29 @@ class Component {
2819
2681
  compileStyle() {
2820
2682
  const { id, commonStyle, globalStyle, views } = this;
2821
2683
  const styles = commonStyle ? [`[data-cid="${id}"]{${commonStyle}}`] : [];
2822
- if (globalStyle !== "")
2823
- styles.push(globalStyle);
2684
+ if (globalStyle !== "") styles.push(globalStyle);
2824
2685
  for (const name in views) {
2825
2686
  const { style } = views[name];
2826
- if (style !== "")
2827
- styles.push(`[data-cid="${id}"][data-vid="${name}"]{${style}}`);
2687
+ if (style !== "") styles.push(`[data-cid="${id}"][data-vid="${name}"]{${style}}`);
2828
2688
  }
2829
- return styles.join(`
2830
- `);
2689
+ return styles.join("\n");
2831
2690
  }
2832
- }
2691
+ };
2833
2692
 
2834
2693
  // src/stack.js
2835
- var STOP = Symbol("STOP");
2836
- var NEXT = Symbol("NEXT");
2694
+ var STOP = /* @__PURE__ */ Symbol("STOP");
2695
+ var NEXT = /* @__PURE__ */ Symbol("NEXT");
2837
2696
  function lookup(chain, name, dv = null) {
2838
2697
  let n = chain;
2839
2698
  while (n !== null) {
2840
2699
  const r = n[0].lookup(name);
2841
- if (r === STOP)
2842
- return dv;
2843
- if (r !== NEXT)
2844
- return r;
2700
+ if (r === STOP) return dv;
2701
+ if (r !== NEXT) return r;
2845
2702
  n = n[1];
2846
2703
  }
2847
2704
  return dv;
2848
2705
  }
2849
-
2850
- class BindFrame {
2706
+ var BindFrame = class {
2851
2707
  constructor(it, binds, isFrame) {
2852
2708
  this.it = it;
2853
2709
  this.binds = binds;
@@ -2855,19 +2711,18 @@ class BindFrame {
2855
2711
  }
2856
2712
  lookup(name) {
2857
2713
  const v = this.binds[name];
2858
- return v === undefined ? this.isFrame ? STOP : NEXT : v;
2714
+ return v === void 0 ? this.isFrame ? STOP : NEXT : v;
2859
2715
  }
2860
- }
2861
-
2862
- class ObjectFrame {
2716
+ };
2717
+ var ObjectFrame = class {
2863
2718
  constructor(binds) {
2864
2719
  this.binds = binds;
2865
2720
  }
2866
2721
  lookup(key) {
2867
2722
  const v = this.binds[key];
2868
- return v === undefined ? NEXT : v;
2723
+ return v === void 0 ? NEXT : v;
2869
2724
  }
2870
- }
2725
+ };
2871
2726
  function computeViewsId(views) {
2872
2727
  let s = "";
2873
2728
  let n = views;
@@ -2877,8 +2732,7 @@ function computeViewsId(views) {
2877
2732
  }
2878
2733
  return s === "main" ? "" : s;
2879
2734
  }
2880
-
2881
- class Stack {
2735
+ var Stack = class _Stack {
2882
2736
  constructor(comps, it, binds, dynBinds, views, viewsId, ctx = null) {
2883
2737
  this.comps = comps;
2884
2738
  this.it = it;
@@ -2888,44 +2742,42 @@ class Stack {
2888
2742
  this.viewsId = viewsId;
2889
2743
  this.ctx = ctx;
2890
2744
  }
2745
+ // Evaluate every provide the entered component publishes and push them as one
2746
+ // dynBinds frame (keyed by each provide's symbol). No-op when there are no provides.
2891
2747
  _pushProvides() {
2892
2748
  const provide = this.comps.getCompFor(this.it)?.provide;
2893
- if (provide == null)
2894
- return this;
2749
+ if (provide == null) return this;
2895
2750
  const dynObj = {};
2896
- let has = false;
2751
+ let has2 = false;
2897
2752
  for (const k in provide) {
2898
2753
  dynObj[provide[k].symbol] = provide[k].val.eval(this);
2899
- has = true;
2754
+ has2 = true;
2900
2755
  }
2901
- if (!has)
2902
- return this;
2756
+ if (!has2) return this;
2903
2757
  const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
2904
2758
  const { comps, it, binds, views, viewsId, ctx } = this;
2905
- return new Stack(comps, it, binds, newDynBinds, views, viewsId, ctx);
2759
+ return new _Stack(comps, it, binds, newDynBinds, views, viewsId, ctx);
2906
2760
  }
2907
2761
  static root(comps, it, ctx) {
2908
2762
  const binds = [new BindFrame(it, {}, true), null];
2909
2763
  const dynBinds = [new ObjectFrame({}), null];
2910
2764
  const views = ["main", null];
2911
- return new Stack(comps, it, binds, dynBinds, views, "", ctx)._pushProvides();
2765
+ return new _Stack(comps, it, binds, dynBinds, views, "", ctx)._pushProvides();
2912
2766
  }
2913
2767
  enter(it, bindings = {}, isFrame = true) {
2914
2768
  const { comps, binds, dynBinds, views, viewsId, ctx } = this;
2915
2769
  const newBinds = [new BindFrame(it, bindings, isFrame), binds];
2916
- const stack = new Stack(comps, it, newBinds, dynBinds, views, viewsId, ctx);
2770
+ const stack = new _Stack(comps, it, newBinds, dynBinds, views, viewsId, ctx);
2917
2771
  return isFrame ? stack._pushProvides() : stack;
2918
2772
  }
2919
2773
  pushViewName(name) {
2920
2774
  const { comps, it, binds, dynBinds, views, ctx } = this;
2921
2775
  const newViews = [name, views];
2922
- return new Stack(comps, it, binds, dynBinds, newViews, computeViewsId(newViews), ctx);
2776
+ return new _Stack(comps, it, binds, dynBinds, newViews, computeViewsId(newViews), ctx);
2923
2777
  }
2924
2778
  _pushDynBindValuesToArray(arr, comp) {
2925
- for (const k in comp.provide)
2926
- arr.push(this._lookupProvide(comp.provide[k]));
2927
- for (const k in comp.lookup)
2928
- arr.push(this._lookupAlias(comp.lookup[k]));
2779
+ for (const k in comp.provide) arr.push(this._lookupProvide(comp.provide[k]));
2780
+ for (const k in comp.lookup) arr.push(this._lookupAlias(comp.lookup[k]));
2929
2781
  }
2930
2782
  _lookupProvide(p) {
2931
2783
  return lookup(this.dynBinds, p.symbol) ?? p.val.eval(this) ?? null;
@@ -2936,13 +2788,11 @@ class Stack {
2936
2788
  }
2937
2789
  lookupDynamic(name) {
2938
2790
  const comp = this.comps.getCompFor(this.it);
2939
- if (comp == null)
2940
- return null;
2791
+ if (comp == null) return null;
2941
2792
  const lk = comp.lookup[name];
2942
- if (lk !== undefined)
2943
- return this._lookupAlias(lk);
2793
+ if (lk !== void 0) return this._lookupAlias(lk);
2944
2794
  const p = comp.provide[name];
2945
- return p !== undefined ? this._lookupProvide(p) : null;
2795
+ return p !== void 0 ? this._lookupProvide(p) : null;
2946
2796
  }
2947
2797
  lookupBind(name) {
2948
2798
  return lookup(this.binds, name);
@@ -2967,16 +2817,15 @@ class Stack {
2967
2817
  let n = this.views;
2968
2818
  while (n !== null) {
2969
2819
  const view = views[n[0]];
2970
- if (view !== undefined)
2971
- return view;
2820
+ if (view !== void 0) return view;
2972
2821
  n = n[1];
2973
2822
  }
2974
2823
  return views[defaultViewName];
2975
2824
  }
2976
- }
2825
+ };
2977
2826
 
2978
2827
  // src/transactor.js
2979
- class State {
2828
+ var State = class {
2980
2829
  constructor(val) {
2981
2830
  this.val = val;
2982
2831
  this.changeSubs = [];
@@ -2987,44 +2836,47 @@ class State {
2987
2836
  set(val, info) {
2988
2837
  const old = this.val;
2989
2838
  this.val = val;
2990
- for (const sub of this.changeSubs)
2991
- sub({ val, old, info, timestamp: Date.now() });
2839
+ for (const sub of this.changeSubs) sub({ val, old, info, timestamp: Date.now() });
2992
2840
  }
2993
2841
  update(fn, info) {
2994
2842
  return this.set(fn(this.val), info);
2995
2843
  }
2996
- }
2997
-
2998
- class Transactor {
2844
+ };
2845
+ var Transactor = class {
2999
2846
  constructor(comps, rootValue) {
3000
2847
  this.comps = comps;
3001
2848
  this.transactions = [];
3002
2849
  this.state = new State(rootValue);
3003
- this.onTransactionPushed = () => {};
2850
+ this.onTransactionPushed = () => {
2851
+ };
3004
2852
  this._observers = [];
3005
- this._inflight = new Set;
2853
+ this._inflight = /* @__PURE__ */ new Set();
3006
2854
  }
3007
2855
  pushTransaction(t) {
3008
2856
  this.transactions.push(t);
3009
2857
  this.onTransactionPushed(t);
3010
2858
  }
2859
+ // Subscribe to a normalized record for every handler invocation (send/receive,
2860
+ // bubble, request/response, input). Returns an unsubscribe function. Records
2861
+ // carry: kind, name, args, path, pathKeys, targetPath, handler, handlerName,
2862
+ // matched, before, after, parent, timestamp. Purely observational.
3011
2863
  observe(cb) {
3012
2864
  this._observers.push(cb);
3013
2865
  return () => {
3014
2866
  const i = this._observers.indexOf(cb);
3015
- if (i !== -1)
3016
- this._observers.splice(i, 1);
2867
+ if (i !== -1) this._observers.splice(i, 1);
3017
2868
  };
3018
2869
  }
3019
2870
  _emit(record) {
3020
- for (const cb of this._observers)
3021
- cb(record);
2871
+ for (const cb of this._observers) cb(record);
3022
2872
  }
2873
+ // Build and dispatch the observer record for a settled transaction. The
2874
+ // resolved handler (`_resolvedHandler`/`_matched`) and per-leaf before/after
2875
+ // (`_before`/`_after`) were captured while the handler ran (see callHandler /
2876
+ // updateRootValue). No-op when nobody is observing.
3023
2877
  _emitTransaction(transaction, root) {
3024
- if (this._observers.length === 0)
3025
- return;
3026
- if (transaction._resolvedHandler === undefined)
3027
- return;
2878
+ if (this._observers.length === 0) return;
2879
+ if (transaction._resolvedHandler === void 0) return;
3028
2880
  const path = transaction.getTransactionPath().pinKeys(root);
3029
2881
  this._emit({
3030
2882
  kind: transaction.observeKind,
@@ -3042,6 +2894,10 @@ class Transactor {
3042
2894
  timestamp: Date.now()
3043
2895
  });
3044
2896
  }
2897
+ // Make `child` a tracked unit of `parent`'s subtree: the parent's completion stays open
2898
+ // until the child's *whole* subtree settles. Tracking happens at dispatch time — during
2899
+ // the parent's handler or afterTransaction — while the parent's self-unit is still held,
2900
+ // so the parent counter can't reach zero before the child is registered. Returns `child`.
3045
2901
  _link(child, parent) {
3046
2902
  if (parent) {
3047
2903
  const release = parent.completion.track();
@@ -3072,12 +2928,13 @@ class Transactor {
3072
2928
  p.finally(() => this._inflight.delete(p));
3073
2929
  return p;
3074
2930
  }
2931
+ // Drain queued transactions and await in-flight requests until quiescent. Each
2932
+ // awaited request enqueues a ResponseEvent, which may dispatch more work, so we
2933
+ // loop. `maxTurns` backstops a pathological non-terminating cascade.
3075
2934
  async settle(maxTurns = 1e4) {
3076
2935
  while ((this.hasPendingTransactions || this._inflight.size) && maxTurns-- > 0) {
3077
- while (this.hasPendingTransactions)
3078
- this.transactNext();
3079
- if (this._inflight.size)
3080
- await Promise.allSettled([...this._inflight]);
2936
+ while (this.hasPendingTransactions) this.transactNext();
2937
+ if (this._inflight.size) await Promise.allSettled([...this._inflight]);
3081
2938
  }
3082
2939
  }
3083
2940
  async _runRequest(path, name, args = [], opts = {}, parent = null, release = null) {
@@ -3107,7 +2964,7 @@ class Transactor {
3107
2964
  handlerName: found?.fn?.name || name,
3108
2965
  matched: found ? "exact" : "none",
3109
2966
  before: curLeaf,
3110
- after: undefined,
2967
+ after: void 0,
3111
2968
  parent,
3112
2969
  timestamp: Date.now()
3113
2970
  });
@@ -3128,27 +2985,24 @@ class Transactor {
3128
2985
  push(opts?.onErrorName, resHandlerName, error, null, error);
3129
2986
  }
3130
2987
  } finally {
3131
- if (release && !released)
3132
- release();
2988
+ if (release && !released) release();
3133
2989
  }
3134
2990
  }
3135
2991
  get hasPendingTransactions() {
3136
2992
  return this.transactions.length > 0;
3137
2993
  }
3138
2994
  transactNext() {
3139
- if (this.hasPendingTransactions)
3140
- this.transact(this.transactions.shift());
2995
+ if (this.hasPendingTransactions) this.transact(this.transactions.shift());
3141
2996
  }
3142
2997
  transact(transaction) {
3143
2998
  try {
3144
2999
  const curState = this.state.val;
3145
3000
  const newState = transaction.run(curState, this.comps);
3146
- if (newState !== undefined) {
3001
+ if (newState !== void 0) {
3147
3002
  this.state.set(newState, { transaction });
3148
3003
  transaction.afterTransaction();
3149
3004
  this._emitTransaction(transaction, curState);
3150
- } else
3151
- console.warn("undefined new state", { curState, transaction });
3005
+ } else console.warn("undefined new state", { curState, transaction });
3152
3006
  } finally {
3153
3007
  transaction._completion?.ensureSelfSettled();
3154
3008
  transaction._completion?.releaseSelf();
@@ -3157,7 +3011,7 @@ class Transactor {
3157
3011
  transactInputNow(path, event, eventHandler, dragInfo) {
3158
3012
  this.transact(new InputEvent(path, event, eventHandler, this, dragInfo));
3159
3013
  }
3160
- }
3014
+ };
3161
3015
  function mkReq404(name) {
3162
3016
  const fn = () => {
3163
3017
  throw new Error(`Request not found: ${name}`);
@@ -3167,37 +3021,46 @@ function mkReq404(name) {
3167
3021
  function nullHandler() {
3168
3022
  return this;
3169
3023
  }
3170
-
3171
- class Transaction {
3024
+ var Transaction = class {
3172
3025
  constructor(path, transactor, parentTransaction = null) {
3173
3026
  this.path = path;
3174
3027
  this.transactor = transactor;
3175
3028
  this.parentTransaction = parentTransaction;
3176
3029
  this._completion = null;
3177
3030
  }
3031
+ // Lazily created (like the rest of the per-transaction state): a leaf event that
3032
+ // nobody tracks or awaits never allocates one. See `class Completion`.
3178
3033
  get completion() {
3179
- this._completion ??= new Completion;
3034
+ this._completion ??= new Completion();
3180
3035
  return this._completion;
3181
3036
  }
3037
+ // Resolves once this transaction's own handler has run.
3182
3038
  whenSettled() {
3183
3039
  return this.completion.whenSettled();
3184
3040
  }
3041
+ // Resolves once this transaction AND all transitively-derived work (sends, bubbles,
3042
+ // requests and the responses they produce, recursively) have settled.
3185
3043
  whenSubtreeSettled() {
3186
3044
  return this.completion.whenSubtreeSettled();
3187
3045
  }
3188
3046
  run(rootValue, comps) {
3189
3047
  return this.updateRootValue(rootValue, comps);
3190
3048
  }
3191
- afterTransaction() {}
3049
+ afterTransaction() {
3050
+ }
3192
3051
  buildRootStack(root, comps) {
3193
3052
  return Stack.root(comps, root);
3194
3053
  }
3195
3054
  buildStack(root, comps) {
3196
3055
  return this.path.toTransactionPath().buildStack(this.buildRootStack(root, comps));
3197
3056
  }
3057
+ // The kind reported to observers (see Transactor.observe); null on the base.
3198
3058
  get observeKind() {
3199
3059
  return null;
3200
3060
  }
3061
+ // The name reported to observers; null on the base. Overridden by NameArgs (the
3062
+ // dispatched message name) and InputEvent (the DOM event type). Kept separate from
3063
+ // `name`/`ctx.name` so it can't change handler-visible behavior.
3201
3064
  get observeName() {
3202
3065
  return null;
3203
3066
  }
@@ -3209,6 +3072,9 @@ class Transaction {
3209
3072
  getHandlerAndArgs(_root, _instance, _comps) {
3210
3073
  return null;
3211
3074
  }
3075
+ // The path used to apply the mutation. Teleports dynamic-var renders so it lands on
3076
+ // the data's real location (the dispatch `this.path` keeps intermediates). A subclass
3077
+ // may override to supply a pre-resolved path (see ResponseEvent's pinned keys).
3212
3078
  getTransactionPath() {
3213
3079
  return this.path.toTransactionPath();
3214
3080
  }
@@ -3224,13 +3090,12 @@ class Transaction {
3224
3090
  lookupName(_name) {
3225
3091
  return null;
3226
3092
  }
3227
- }
3093
+ };
3228
3094
  var toNullIfNaN = (v) => Number.isNaN(v) ? null : v;
3229
3095
  function getValue(e) {
3230
3096
  return e.target.type === "checkbox" ? e.target.checked : (e instanceof CustomEvent ? e.detail : e.target.value) ?? null;
3231
3097
  }
3232
-
3233
- class InputEvent extends Transaction {
3098
+ var InputEvent = class extends Transaction {
3234
3099
  constructor(path, e, handler, transactor, dragInfo) {
3235
3100
  super(path, transactor);
3236
3101
  this.e = e;
@@ -3238,6 +3103,8 @@ class InputEvent extends Transaction {
3238
3103
  this.dragInfo = dragInfo;
3239
3104
  this._dispatchPath = null;
3240
3105
  }
3106
+ // Frame steps removed, DynStep + one step per crossed component kept: bubbling
3107
+ // it visits every component (including intermediates of a dynamic-var render).
3241
3108
  get dispatchPath() {
3242
3109
  this._dispatchPath ??= this.path.compact();
3243
3110
  return this._dispatchPath;
@@ -3276,6 +3143,7 @@ class InputEvent extends Transaction {
3276
3143
  case "isShift":
3277
3144
  return e.shiftKey;
3278
3145
  case "isCtrl":
3146
+ /* falls through */
3279
3147
  case "isCmd":
3280
3148
  return isMac && e.metaKey || e.ctrlKey;
3281
3149
  case "key":
@@ -3299,9 +3167,8 @@ class InputEvent extends Transaction {
3299
3167
  }
3300
3168
  return null;
3301
3169
  }
3302
- }
3303
-
3304
- class NameArgsTransaction extends Transaction {
3170
+ };
3171
+ var NameArgsTransaction = class extends Transaction {
3305
3172
  constructor(path, transactor, name, args, parentTransaction, opts = {}) {
3306
3173
  super(path, transactor, parentTransaction);
3307
3174
  this.name = name;
@@ -3310,6 +3177,8 @@ class NameArgsTransaction extends Transaction {
3310
3177
  this.targetPath = path;
3311
3178
  }
3312
3179
  handlerProp = null;
3180
+ // NameArgs verbs map their handler bucket straight to the observed kind:
3181
+ // receive / bubble / response / input.
3313
3182
  get observeKind() {
3314
3183
  return this.handlerProp;
3315
3184
  }
@@ -3335,9 +3204,8 @@ class NameArgsTransaction extends Transaction {
3335
3204
  const handler = this.getHandlerForName(comps.getCompFor(instance));
3336
3205
  return [handler, [...this.args, new EventContext(this.path, this.transactor, this)]];
3337
3206
  }
3338
- }
3339
-
3340
- class ResponseEvent extends NameArgsTransaction {
3207
+ };
3208
+ var ResponseEvent = class extends NameArgsTransaction {
3341
3209
  handlerProp = "response";
3342
3210
  constructor(path, transactor, name, args, parent, txnPath = null) {
3343
3211
  super(path, transactor, name, args, parent);
@@ -3346,9 +3214,8 @@ class ResponseEvent extends NameArgsTransaction {
3346
3214
  getTransactionPath() {
3347
3215
  return this._txnPath ?? super.getTransactionPath();
3348
3216
  }
3349
- }
3350
-
3351
- class SendEvent extends NameArgsTransaction {
3217
+ };
3218
+ var SendEvent = class extends NameArgsTransaction {
3352
3219
  handlerProp = "receive";
3353
3220
  run(rootVal, comps) {
3354
3221
  return this.opts.skipSelf ? rootVal : this.updateRootValue(rootVal, comps);
@@ -3358,9 +3225,8 @@ class SendEvent extends NameArgsTransaction {
3358
3225
  if (opts.bubbles && path.steps.length > 0)
3359
3226
  this.transactor.pushBubble(path.popStep(), name, args, opts, this, targetPath);
3360
3227
  }
3361
- }
3362
-
3363
- class BubbleEvent extends SendEvent {
3228
+ };
3229
+ var BubbleEvent = class extends SendEvent {
3364
3230
  handlerProp = "bubble";
3365
3231
  constructor(path, transactor, name, args, parent, opts, targetPath) {
3366
3232
  super(path, transactor, name, args, parent, opts);
@@ -3369,15 +3235,13 @@ class BubbleEvent extends SendEvent {
3369
3235
  stopPropagation() {
3370
3236
  this.opts.bubbles = false;
3371
3237
  }
3372
- }
3373
-
3374
- class InputDispatchEvent extends NameArgsTransaction {
3238
+ };
3239
+ var InputDispatchEvent = class extends NameArgsTransaction {
3375
3240
  handlerProp = "input";
3376
- }
3377
-
3378
- class Completion {
3241
+ };
3242
+ var Completion = class {
3379
3243
  constructor() {
3380
- this.val = undefined;
3244
+ this.val = void 0;
3381
3245
  this.selfSettled = false;
3382
3246
  this.subtreeSettled = false;
3383
3247
  this.pending = 1;
@@ -3388,45 +3252,42 @@ class Completion {
3388
3252
  this._selfReleased = false;
3389
3253
  }
3390
3254
  whenSettled() {
3391
- if (this.selfSettled)
3392
- return Promise.resolve(this.val);
3255
+ if (this.selfSettled) return Promise.resolve(this.val);
3393
3256
  this._selfPromise ??= new Promise((res) => {
3394
3257
  this._selfResolve = res;
3395
3258
  });
3396
3259
  return this._selfPromise;
3397
3260
  }
3398
3261
  whenSubtreeSettled() {
3399
- if (this.subtreeSettled)
3400
- return Promise.resolve(this.val);
3262
+ if (this.subtreeSettled) return Promise.resolve(this.val);
3401
3263
  this._subtreePromise ??= new Promise((res) => {
3402
3264
  this._subtreeResolve = res;
3403
3265
  });
3404
3266
  return this._subtreePromise;
3405
3267
  }
3268
+ // The transaction's own handler ran (records its {value, old}). Does not touch the counter.
3406
3269
  markSelfSettled(val) {
3407
- if (this.selfSettled)
3408
- return;
3270
+ if (this.selfSettled) return;
3409
3271
  this.selfSettled = true;
3410
3272
  this.val = val;
3411
3273
  this._selfResolve?.(val);
3412
3274
  }
3275
+ // Settle self even when no handler produced a value (skipSelf / undefined / throw paths).
3413
3276
  ensureSelfSettled() {
3414
- if (!this.selfSettled)
3415
- this.markSelfSettled(this.val);
3277
+ if (!this.selfSettled) this.markSelfSettled(this.val);
3416
3278
  }
3279
+ // Register an outstanding unit; returns a one-shot release.
3417
3280
  track() {
3418
3281
  this.pending++;
3419
3282
  let done = false;
3420
3283
  return () => {
3421
- if (done)
3422
- return;
3284
+ if (done) return;
3423
3285
  done = true;
3424
3286
  this._release();
3425
3287
  };
3426
3288
  }
3427
3289
  releaseSelf() {
3428
- if (this._selfReleased)
3429
- return;
3290
+ if (this._selfReleased) return;
3430
3291
  this._selfReleased = true;
3431
3292
  this._release();
3432
3293
  }
@@ -3436,22 +3297,22 @@ class Completion {
3436
3297
  this._subtreeResolve?.(this.val);
3437
3298
  }
3438
3299
  }
3439
- }
3440
-
3441
- class Dispatcher {
3300
+ };
3301
+ var Dispatcher = class {
3442
3302
  constructor(path, transactor, parentTransaction, root = transactor.state.val) {
3443
3303
  this.path = path;
3444
3304
  this.transactor = transactor;
3445
3305
  this.parent = parentTransaction;
3446
3306
  this.root = root;
3447
3307
  }
3308
+ // Walk the component instances on this ctx's path, leaf→root, calling
3309
+ // callback(Component, instance). Return false from the callback to stop early.
3448
3310
  walkPath(callback) {
3449
3311
  const comps = this.transactor.comps;
3450
3312
  const chain = this.path.toTransactionPath().resolveChain(this.root);
3451
- for (let i = chain.length - 1;i >= 0; i--) {
3313
+ for (let i = chain.length - 1; i >= 0; i--) {
3452
3314
  const comp = comps.getCompFor(chain[i]);
3453
- if (comp && callback(comp, chain[i]) === false)
3454
- return;
3315
+ if (comp && callback(comp, chain[i]) === false) return;
3455
3316
  }
3456
3317
  }
3457
3318
  get at() {
@@ -3478,9 +3339,8 @@ class Dispatcher {
3478
3339
  lookupTypeFor(name, inst) {
3479
3340
  return this.transactor.comps.getCompFor(inst).scope.lookupComponent(name);
3480
3341
  }
3481
- }
3482
-
3483
- class EventContext extends Dispatcher {
3342
+ };
3343
+ var EventContext = class extends Dispatcher {
3484
3344
  get name() {
3485
3345
  return this.parent?.name ?? null;
3486
3346
  }
@@ -3490,12 +3350,10 @@ class EventContext extends Dispatcher {
3490
3350
  stopPropagation() {
3491
3351
  return this.parent.stopPropagation();
3492
3352
  }
3493
- }
3494
-
3495
- class RequestContext extends Dispatcher {
3496
- }
3497
-
3498
- class PathChanges extends PathBuilder {
3353
+ };
3354
+ var RequestContext = class extends Dispatcher {
3355
+ };
3356
+ var PathChanges = class extends PathBuilder {
3499
3357
  constructor(dispatcher) {
3500
3358
  super();
3501
3359
  this.dispatcher = dispatcher;
@@ -3509,15 +3367,14 @@ class PathChanges extends PathBuilder {
3509
3367
  buildPath() {
3510
3368
  return this.dispatcher.path.concat(this.pathChanges);
3511
3369
  }
3512
- }
3370
+ };
3513
3371
  function rootDispatcher(transactor) {
3514
3372
  return new Dispatcher(new Path([]), transactor, null);
3515
3373
  }
3516
3374
 
3517
3375
  // src/app.js
3518
3376
  var _evs = "dragstart dragover dragend touchstart touchmove touchend touchcancel".split(" ");
3519
-
3520
- class App {
3377
+ var App = class {
3521
3378
  constructor(rootNode, comps, renderer, ParseContext2) {
3522
3379
  this.rootNode = rootNode;
3523
3380
  this.comps = comps;
@@ -3531,8 +3388,7 @@ class App {
3531
3388
  this.dragInfo = this.curDragOver = null;
3532
3389
  this._touch = null;
3533
3390
  this.transactor.onTransactionPushed = (_transaction) => {
3534
- if (this._transactNextBatchId === null)
3535
- this._scheduleNextTransactionBatchExecution();
3391
+ if (this._transactNextBatchId === null) this._scheduleNextTransactionBatchExecution();
3536
3392
  };
3537
3393
  this._compiled = false;
3538
3394
  this._renderOpts = { document: rootNode.ownerDocument };
@@ -3555,29 +3411,23 @@ class App {
3555
3411
  const isDrag = type === "dragover" || type === "dragstart" || type === "dragend" || type === "drop";
3556
3412
  const { rootNode: root, maxEventNodeDepth: maxDepth, comps, transactor } = this;
3557
3413
  const [path, handlers] = Path.fromEvent(e, root, maxDepth, comps, !isDrag);
3558
- if (isDrag)
3559
- this._handleDragEvent(e, type, path);
3414
+ if (isDrag) this._handleDragEvent(e, type, path);
3560
3415
  if (path !== null && handlers !== null)
3561
- for (const handler of handlers)
3562
- transactor.transactInputNow(path, e, handler, this.dragInfo);
3416
+ for (const handler of handlers) transactor.transactInputNow(path, e, handler, this.dragInfo);
3563
3417
  }
3564
3418
  _handleTouchEvent(e) {
3565
3419
  const { type } = e;
3566
3420
  if (type === "touchstart") {
3567
- if (this._touch !== null || e.touches.length !== 1)
3568
- return;
3421
+ if (this._touch !== null || e.touches.length !== 1) return;
3569
3422
  const t = e.touches[0];
3570
3423
  const draggable = t.target?.closest?.('[draggable="true"]');
3571
- if (!draggable)
3572
- return;
3424
+ if (!draggable) return;
3573
3425
  this._touch = makeTouchInfo(t.identifier, t.clientX, t.clientY, draggable, false);
3574
3426
  return;
3575
3427
  }
3576
- if (this._touch === null)
3577
- return;
3428
+ if (this._touch === null) return;
3578
3429
  const touch = findTouch(e, this._touch.id);
3579
- if (touch === null)
3580
- return;
3430
+ if (touch === null) return;
3581
3431
  const { rootNode, _touch } = this;
3582
3432
  const { clientX, clientY } = touch;
3583
3433
  const fire = (type2, target) => {
@@ -3588,8 +3438,7 @@ class App {
3588
3438
  if (!_touch.active) {
3589
3439
  const dx = clientX - _touch.startX;
3590
3440
  const dy = clientY - _touch.startY;
3591
- if (dx * dx + dy * dy < 100)
3592
- return;
3441
+ if (dx * dx + dy * dy < 100) return;
3593
3442
  _touch.active = true;
3594
3443
  e.preventDefault();
3595
3444
  fire("dragstart", _touch.target);
@@ -3601,8 +3450,7 @@ class App {
3601
3450
  }
3602
3451
  if (type === "touchend" || type === "touchcancel") {
3603
3452
  if (_touch.active) {
3604
- if (type === "touchend")
3605
- fire("drop", hitTest(rootNode, clientX, clientY));
3453
+ if (type === "touchend") fire("drop", hitTest(rootNode, clientX, clientY));
3606
3454
  fire("dragend", _touch.target);
3607
3455
  }
3608
3456
  this._touch = null;
@@ -3649,13 +3497,20 @@ class App {
3649
3497
  const root = this.state.val;
3650
3498
  const stack = this.makeStack(root);
3651
3499
  const { renderer, rootNode, _renderOpts, _renderState } = this;
3652
- const newState = render(renderer.renderRoot(stack, root, this.rootViewName), rootNode, _renderOpts, _renderState);
3500
+ const newState = render(
3501
+ renderer.renderRoot(stack, root, this.rootViewName),
3502
+ rootNode,
3503
+ _renderOpts,
3504
+ _renderState
3505
+ );
3653
3506
  this._renderState = newState;
3654
3507
  return newState.dom;
3655
3508
  }
3656
3509
  onChange(callback) {
3657
3510
  this.transactor.state.onChange(callback);
3658
3511
  }
3512
+ // Subscribe to a normalized record for every handler invocation. Returns an
3513
+ // unsubscribe function. See Transactor.observe.
3659
3514
  observe(callback) {
3660
3515
  return this.transactor.observe(callback);
3661
3516
  }
@@ -3663,31 +3518,25 @@ class App {
3663
3518
  for (const Comp of this.comps.byId.values()) {
3664
3519
  Comp.compile(this.ParseContext);
3665
3520
  for (const key in Comp.views)
3666
- for (const name of Comp.views[key].ctx.genEventNames())
3667
- this._eventNames.add(name);
3521
+ for (const name of Comp.views[key].ctx.genEventNames()) this._eventNames.add(name);
3668
3522
  }
3669
3523
  this._compiled = true;
3670
3524
  }
3671
3525
  subscribeToEvents(eventNames) {
3672
- for (const name of eventNames)
3673
- this.rootNode.addEventListener(name, this, listenerOpts(name));
3526
+ for (const name of eventNames) this.rootNode.addEventListener(name, this, listenerOpts(name));
3674
3527
  }
3675
3528
  recompileStyles(opts) {
3676
3529
  injectCss("tutuca-app", this.comps.compileStyles(), opts?.head ?? document.head);
3677
3530
  }
3678
3531
  start(opts) {
3679
- if (!this._compiled)
3680
- this.compile();
3532
+ if (!this._compiled) this.compile();
3681
3533
  this.subscribeToEvents(this._eventNames);
3682
3534
  this.onChange((info) => {
3683
- if (info.val !== info.old)
3684
- this.render();
3535
+ if (info.val !== info.old) this.render();
3685
3536
  });
3686
3537
  this.recompileStyles(opts);
3687
- if (opts?.noCache)
3688
- this.renderer.setNullCache();
3689
- else
3690
- this.startCacheEvictionInterval();
3538
+ if (opts?.noCache) this.renderer.setNullCache();
3539
+ else this.startCacheEvictionInterval();
3691
3540
  this.render();
3692
3541
  }
3693
3542
  stop() {
@@ -3707,42 +3556,36 @@ class App {
3707
3556
  this._transactNextBatchId = null;
3708
3557
  const startTs = Date.now();
3709
3558
  const t = this.transactor;
3710
- while (t.hasPendingTransactions && Date.now() - startTs < maxRunTimeMs)
3711
- t.transactNext();
3712
- if (t.hasPendingTransactions)
3713
- this._scheduleNextTransactionBatchExecution();
3559
+ while (t.hasPendingTransactions && Date.now() - startTs < maxRunTimeMs) t.transactNext();
3560
+ if (t.hasPendingTransactions) this._scheduleNextTransactionBatchExecution();
3714
3561
  }
3715
3562
  _scheduleNextTransactionBatchExecution() {
3716
3563
  this._transactNextBatchId = setTimeout(() => this._transactNextBatch(), 0);
3717
3564
  }
3718
- startCacheEvictionInterval(intervalMs = 30000) {
3565
+ startCacheEvictionInterval(intervalMs = 3e4) {
3719
3566
  this._evictCacheId = setInterval(() => this.renderer.cache.evict(), intervalMs);
3720
3567
  }
3721
3568
  stopCacheEvictionInterval() {
3722
3569
  clearInterval(this._evictCacheId);
3723
3570
  this._evictCacheId = null;
3724
3571
  }
3725
- }
3572
+ };
3726
3573
  function injectCss(nodeId, style, styleTarget = document.head) {
3727
3574
  const styleNode = document.createElement("style");
3728
3575
  const currentNodeWithId = styleTarget.querySelector(`#${nodeId}`);
3729
- if (currentNodeWithId)
3730
- styleTarget.removeChild(currentNodeWithId);
3576
+ if (currentNodeWithId) styleTarget.removeChild(currentNodeWithId);
3731
3577
  styleNode.id = nodeId;
3732
3578
  styleNode.innerHTML = style;
3733
3579
  styleTarget.appendChild(styleNode);
3734
3580
  }
3735
- var NOOP = () => {};
3581
+ var NOOP = () => {
3582
+ };
3736
3583
  function findTouch(e, id) {
3737
- for (const t of e.changedTouches)
3738
- if (t.identifier === id)
3739
- return t;
3740
- for (const t of e.touches)
3741
- if (t.identifier === id)
3742
- return t;
3584
+ for (const t of e.changedTouches) if (t.identifier === id) return t;
3585
+ for (const t of e.touches) if (t.identifier === id) return t;
3743
3586
  return null;
3744
3587
  }
3745
- var listenerOpts = (name) => name === "touchmove" ? { passive: false } : undefined;
3588
+ var listenerOpts = (name) => name === "touchmove" ? { passive: false } : void 0;
3746
3589
  function makeTouchInfo(id, startX, startY, target, active) {
3747
3590
  return { id, startX, startY, target, active };
3748
3591
  }
@@ -3751,8 +3594,7 @@ function hitTest(rootNode, x, y) {
3751
3594
  let el = root.elementFromPoint?.(x, y) ?? null;
3752
3595
  while (el?.shadowRoot) {
3753
3596
  const next = el.shadowRoot.elementFromPoint(x, y);
3754
- if (next === null || next === el)
3755
- break;
3597
+ if (next === null || next === el) break;
3756
3598
  el = next;
3757
3599
  }
3758
3600
  return el ?? rootNode;
@@ -3760,14 +3602,12 @@ function hitTest(rootNode, x, y) {
3760
3602
  function getClosestDropTarget(target, rootNode, count) {
3761
3603
  let node = target;
3762
3604
  while (count-- > 0 && node !== rootNode) {
3763
- if (node.dataset?.droptarget !== undefined)
3764
- return node;
3605
+ if (node.dataset?.droptarget !== void 0) return node;
3765
3606
  node = node.parentNode;
3766
3607
  }
3767
3608
  return null;
3768
3609
  }
3769
-
3770
- class DragInfo {
3610
+ var DragInfo = class {
3771
3611
  constructor(path, stack, e, val, type, node) {
3772
3612
  this.path = path;
3773
3613
  this.stack = stack;
@@ -3779,13 +3619,13 @@ class DragInfo {
3779
3619
  lookupBind(name) {
3780
3620
  return this.stack.lookupBind(name);
3781
3621
  }
3782
- }
3622
+ };
3783
3623
 
3784
3624
  // src/util/parsectx.js
3785
- class ParseCtxClassSetCollector extends ParseContext {
3625
+ var ParseCtxClassSetCollector = class _ParseCtxClassSetCollector extends ParseContext {
3786
3626
  constructor(...args) {
3787
3627
  super(...args);
3788
- this.classes = new Set;
3628
+ this.classes = /* @__PURE__ */ new Set();
3789
3629
  }
3790
3630
  _addClasses(s) {
3791
3631
  for (const v of s.split(/\s+/)) {
@@ -3795,7 +3635,16 @@ class ParseCtxClassSetCollector extends ParseContext {
3795
3635
  enterMacro(macroName, macroVars, macroSlots) {
3796
3636
  const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
3797
3637
  const frame = { macroName, macroVars, macroSlots };
3798
- const v = new ParseCtxClassSetCollector(document2, Text, Comment, nodes, events, macroNodes, frame, this);
3638
+ const v = new _ParseCtxClassSetCollector(
3639
+ document2,
3640
+ Text,
3641
+ Comment,
3642
+ nodes,
3643
+ events,
3644
+ macroNodes,
3645
+ frame,
3646
+ this
3647
+ );
3799
3648
  v.classes = this.classes;
3800
3649
  return v;
3801
3650
  }
@@ -3806,7 +3655,7 @@ class ParseCtxClassSetCollector extends ParseContext {
3806
3655
  continue;
3807
3656
  }
3808
3657
  const { val, thenVal, elseVal } = attr;
3809
- if (thenVal !== undefined) {
3658
+ if (thenVal !== void 0) {
3810
3659
  this._maybeAddVal(thenVal);
3811
3660
  this._maybeAddVal(elseVal);
3812
3661
  } else {
@@ -3826,7 +3675,7 @@ class ParseCtxClassSetCollector extends ParseContext {
3826
3675
  }
3827
3676
  }
3828
3677
  _maybeAddStrTpl(value) {
3829
- if (value?.vals !== undefined) {
3678
+ if (value?.vals !== void 0) {
3830
3679
  for (const val of value.vals) {
3831
3680
  if (val instanceof ConstVal && val.val !== "") {
3832
3681
  this._addClasses(val.val);
@@ -3836,9 +3685,9 @@ class ParseCtxClassSetCollector extends ParseContext {
3836
3685
  }
3837
3686
  return false;
3838
3687
  }
3839
- }
3688
+ };
3840
3689
  function collectAppClassesInSet(app) {
3841
- const classes = new Set;
3690
+ const classes = /* @__PURE__ */ new Set();
3842
3691
  for (const Comp of app.comps.byId.values()) {
3843
3692
  for (const key in Comp.views) {
3844
3693
  const view = Comp.views[key];
@@ -3909,26 +3758,20 @@ import {
3909
3758
  var OP_KINDS = ["send", "bubble", "request", "input"];
3910
3759
  function phaseOps(phase) {
3911
3760
  const ops = [];
3912
- for (const type of OP_KINDS)
3913
- for (const a of phase[type] ?? [])
3914
- ops.push({ type, ...a });
3915
- for (const a of phase.do ?? [])
3916
- ops.push(a);
3761
+ for (const type of OP_KINDS) for (const a of phase[type] ?? []) ops.push({ type, ...a });
3762
+ for (const a of phase.do ?? []) ops.push(a);
3917
3763
  return ops;
3918
3764
  }
3919
3765
  function resolveArgs(args, self) {
3920
3766
  return typeof args === "function" ? args(self) ?? [] : args ?? [];
3921
3767
  }
3922
3768
  function phaseHasBubble(phase) {
3923
- if (!phase)
3924
- return false;
3925
- if (phase.bubble?.length)
3926
- return true;
3769
+ if (!phase) return false;
3770
+ if (phase.bubble?.length) return true;
3927
3771
  return (phase.do ?? []).some((op) => op.type === "bubble");
3928
3772
  }
3929
3773
  function dispatchPhase(dispatcher, targetPath, phase, self) {
3930
- if (!phase)
3931
- return;
3774
+ if (!phase) return;
3932
3775
  for (const op of phaseOps(phase)) {
3933
3776
  const args = resolveArgs(op.args, self);
3934
3777
  switch (op.type) {
@@ -3951,12 +3794,12 @@ function dispatchPhase(dispatcher, targetPath, phase, self) {
3951
3794
  }
3952
3795
  }
3953
3796
  }
3797
+
3954
3798
  // src/oo.js
3955
3799
  import { Map as IMap, Set as ISet, List, OrderedMap, Record } from "immutable";
3956
- var BAD_VALUE = Symbol("BadValue");
3800
+ var BAD_VALUE = /* @__PURE__ */ Symbol("BadValue");
3957
3801
  var nullCoercer = (v) => v;
3958
-
3959
- class Field {
3802
+ var Field = class {
3960
3803
  constructor(type, name, typeCheck, coercer, defaultValue = null) {
3961
3804
  this.type = type;
3962
3805
  this.name = name;
@@ -3970,30 +3813,27 @@ class Field {
3970
3813
  return { type, defaultValue: dv?.toJS ? dv.toJS() : dv };
3971
3814
  }
3972
3815
  getFirstFailingCheck(v) {
3973
- if (!this.typeCheck.isValid(v))
3974
- return this.typeCheck;
3975
- for (const check of this.checks)
3976
- if (!check.isValid(v))
3977
- return check;
3816
+ if (!this.typeCheck.isValid(v)) return this.typeCheck;
3817
+ for (const check2 of this.checks) if (!check2.isValid(v)) return check2;
3978
3818
  return null;
3979
3819
  }
3980
3820
  isValid(v) {
3981
3821
  return this.getFirstFailingCheck(v) === null;
3982
3822
  }
3983
- addCheck(check) {
3984
- this.checks.push(check);
3823
+ addCheck(check2) {
3824
+ this.checks.push(check2);
3985
3825
  return this;
3986
3826
  }
3987
3827
  coerceOr(v, defaultValue = null) {
3988
- if (this.isValid(v))
3989
- return v;
3828
+ if (this.isValid(v)) return v;
3990
3829
  const v1 = this.coercer(v);
3991
3830
  return this.isValid(v1) ? v1 : defaultValue;
3992
3831
  }
3993
3832
  coerceOrDefault(v) {
3994
3833
  return this.coerceOr(v, this.defaultValue);
3995
3834
  }
3996
- extendProtoForType(_proto, _uname) {}
3835
+ extendProtoForType(_proto, _uname) {
3836
+ }
3997
3837
  extendProto(proto) {
3998
3838
  const { name } = this;
3999
3839
  const uname = name[0].toUpperCase() + name.slice(1);
@@ -4015,22 +3855,19 @@ class Field {
4015
3855
  };
4016
3856
  this.extendProtoForType(proto, uname);
4017
3857
  }
4018
- }
4019
-
4020
- class Check {
3858
+ };
3859
+ var Check = class {
4021
3860
  isValid(_v) {
4022
3861
  return true;
4023
3862
  }
4024
3863
  getMessage(_v) {
4025
3864
  return "Invalid";
4026
3865
  }
4027
- }
4028
-
4029
- class CheckTypeAny extends Check {
4030
- }
4031
- var CHECK_TYPE_ANY = new CheckTypeAny;
4032
-
4033
- class FnCheck extends Check {
3866
+ };
3867
+ var CheckTypeAny = class extends Check {
3868
+ };
3869
+ var CHECK_TYPE_ANY = new CheckTypeAny();
3870
+ var FnCheck = class extends Check {
4034
3871
  constructor(isValidFn, getMessageFn) {
4035
3872
  super();
4036
3873
  this._isValid = isValidFn;
@@ -4042,18 +3879,41 @@ class FnCheck extends Check {
4042
3879
  getMessage(v) {
4043
3880
  return this._getMessage(v);
4044
3881
  }
4045
- }
4046
- var CHECK_TYPE_INT = new FnCheck((v) => Number.isInteger(v), () => "Integer expected");
4047
- var CHECK_TYPE_FLOAT = new FnCheck((v) => Number.isFinite(v), () => "Float expected");
4048
- var CHECK_TYPE_BOOL = new FnCheck((v) => typeof v === "boolean", () => "Boolean expected");
4049
- var CHECK_TYPE_STRING = new FnCheck((v) => typeof v === "string", () => "String expected");
4050
- var CHECK_TYPE_LIST = new FnCheck((v) => List.isList(v), () => "List expected");
4051
- var CHECK_TYPE_MAP = new FnCheck((v) => IMap.isMap(v), () => "Map expected");
4052
- var CHECK_TYPE_OMAP = new FnCheck((v) => OrderedMap.isOrderedMap(v), () => "OrderedMap expected");
4053
- var CHECK_TYPE_SET = new FnCheck((v) => ISet.isSet(v), () => "Set expected");
3882
+ };
3883
+ var CHECK_TYPE_INT = new FnCheck(
3884
+ (v) => Number.isInteger(v),
3885
+ () => "Integer expected"
3886
+ );
3887
+ var CHECK_TYPE_FLOAT = new FnCheck(
3888
+ (v) => Number.isFinite(v),
3889
+ () => "Float expected"
3890
+ );
3891
+ var CHECK_TYPE_BOOL = new FnCheck(
3892
+ (v) => typeof v === "boolean",
3893
+ () => "Boolean expected"
3894
+ );
3895
+ var CHECK_TYPE_STRING = new FnCheck(
3896
+ (v) => typeof v === "string",
3897
+ () => "String expected"
3898
+ );
3899
+ var CHECK_TYPE_LIST = new FnCheck(
3900
+ (v) => List.isList(v),
3901
+ () => "List expected"
3902
+ );
3903
+ var CHECK_TYPE_MAP = new FnCheck(
3904
+ (v) => IMap.isMap(v),
3905
+ () => "Map expected"
3906
+ );
3907
+ var CHECK_TYPE_OMAP = new FnCheck(
3908
+ (v) => OrderedMap.isOrderedMap(v),
3909
+ () => "OrderedMap expected"
3910
+ );
3911
+ var CHECK_TYPE_SET = new FnCheck(
3912
+ (v) => ISet.isSet(v),
3913
+ () => "Set expected"
3914
+ );
4054
3915
  var boolCoercer = (v) => !!v;
4055
-
4056
- class FieldBool extends Field {
3916
+ var FieldBool = class extends Field {
4057
3917
  constructor(name, defaultValue = false) {
4058
3918
  super("bool", name, CHECK_TYPE_BOOL, boolCoercer, defaultValue);
4059
3919
  }
@@ -4066,9 +3926,8 @@ class FieldBool extends Field {
4066
3926
  return this.set(name, !!v);
4067
3927
  };
4068
3928
  }
4069
- }
4070
-
4071
- class FieldAny extends Field {
3929
+ };
3930
+ var FieldAny = class extends Field {
4072
3931
  constructor(name, defaultValue = null) {
4073
3932
  super("any", name, CHECK_TYPE_ANY, nullCoercer, defaultValue);
4074
3933
  }
@@ -4077,34 +3936,30 @@ class FieldAny extends Field {
4077
3936
  const type = getTypeName(dv) ?? "any";
4078
3937
  return { type, defaultValue: dv?.toJS ? dv.toJS() : dv };
4079
3938
  }
4080
- }
3939
+ };
4081
3940
  var stringCoercer = (v) => v?.toString?.() ?? "";
4082
-
4083
- class FieldString extends Field {
3941
+ var FieldString = class extends Field {
4084
3942
  constructor(name, defaultValue = "") {
4085
3943
  super("text", name, CHECK_TYPE_STRING, stringCoercer, defaultValue);
4086
3944
  }
4087
3945
  extendProtoForType(proto, _uname) {
4088
3946
  extendProtoSized(proto, this.name, "", "length");
4089
3947
  }
4090
- }
3948
+ };
4091
3949
  var intCoercer = (v) => Number.isFinite(v) ? Math.trunc(v) : null;
4092
-
4093
- class FieldInt extends Field {
3950
+ var FieldInt = class extends Field {
4094
3951
  constructor(name, defaultValue = 0) {
4095
3952
  super("int", name, CHECK_TYPE_INT, intCoercer, defaultValue);
4096
3953
  }
4097
- }
3954
+ };
4098
3955
  var floatCoercer = (_) => null;
4099
-
4100
- class FieldFloat extends Field {
3956
+ var FieldFloat = class extends Field {
4101
3957
  constructor(name, defaultValue = 0) {
4102
3958
  super("float", name, CHECK_TYPE_FLOAT, floatCoercer, defaultValue);
4103
3959
  }
4104
- }
3960
+ };
4105
3961
  var getTypeName = (v) => v?.constructor?.getMetaClass?.()?.name;
4106
-
4107
- class CheckTypeName {
3962
+ var CheckTypeName = class {
4108
3963
  constructor(typeName) {
4109
3964
  this.typeName = typeName;
4110
3965
  }
@@ -4115,9 +3970,8 @@ class CheckTypeName {
4115
3970
  const got = getTypeName(v);
4116
3971
  return `Expected "${this.typeName}", got "${got}"`;
4117
3972
  }
4118
- }
4119
-
4120
- class FieldComp extends Field {
3973
+ };
3974
+ var FieldComp = class extends Field {
4121
3975
  constructor(type, name, args) {
4122
3976
  super(type, name, new CheckTypeName(type), nullCoercer, null);
4123
3977
  this.args = args;
@@ -4125,8 +3979,8 @@ class FieldComp extends Field {
4125
3979
  toDataDef() {
4126
3980
  return { component: this.typeName, args: this.args };
4127
3981
  }
4128
- }
4129
- var NONE2 = Symbol("NONE");
3982
+ };
3983
+ var NONE2 = /* @__PURE__ */ Symbol("NONE");
4130
3984
  function extendProtoForKeyed(proto, name, uname) {
4131
3985
  extendProtoSized(proto, name, EMPTY_LIST);
4132
3986
  proto[`setIn${uname}At`] = function(i, v) {
@@ -4138,8 +3992,7 @@ function extendProtoForKeyed(proto, name, uname) {
4138
3992
  proto[`updateIn${uname}At`] = function(i, fn) {
4139
3993
  const col = this.get(name);
4140
3994
  const v = col.get(i, NONE2);
4141
- if (v !== NONE2)
4142
- return this.set(name, col.set(i, fn(v)));
3995
+ if (v !== NONE2) return this.set(name, col.set(i, fn(v)));
4143
3996
  console.warn("key", i, "not found in", name, col);
4144
3997
  return this;
4145
3998
  };
@@ -4153,8 +4006,7 @@ function extendDeleteInAt(proto, name, uname) {
4153
4006
  }
4154
4007
  var EMPTY_LIST = List();
4155
4008
  var listCoercer = (v) => Array.isArray(v) ? List(v) : null;
4156
-
4157
- class FieldList extends Field {
4009
+ var FieldList = class extends Field {
4158
4010
  constructor(name, defaultValue = EMPTY_LIST) {
4159
4011
  super("list", name, CHECK_TYPE_LIST, listCoercer, defaultValue);
4160
4012
  }
@@ -4168,27 +4020,25 @@ class FieldList extends Field {
4168
4020
  return this.set(name, this.get(name).insert(i, v));
4169
4021
  };
4170
4022
  }
4171
- }
4023
+ };
4172
4024
  var imapCoercer = (v) => IMap(v);
4173
-
4174
- class FieldMap extends Field {
4025
+ var FieldMap = class extends Field {
4175
4026
  constructor(name, defaultValue = IMap()) {
4176
4027
  super("map", name, CHECK_TYPE_MAP, imapCoercer, defaultValue);
4177
4028
  }
4178
4029
  extendProtoForType(proto, uname) {
4179
4030
  extendProtoForKeyed(proto, this.name, uname);
4180
4031
  }
4181
- }
4032
+ };
4182
4033
  var omapCoercer = (v) => OrderedMap(v);
4183
-
4184
- class FieldOMap extends Field {
4034
+ var FieldOMap = class extends Field {
4185
4035
  constructor(name, defaultValue = OrderedMap()) {
4186
4036
  super("omap", name, CHECK_TYPE_OMAP, omapCoercer, defaultValue);
4187
4037
  }
4188
4038
  extendProtoForType(proto, uname) {
4189
4039
  extendProtoForKeyed(proto, this.name, uname);
4190
4040
  }
4191
- }
4041
+ };
4192
4042
  function extendProtoSized(proto, name, defaultEmpty, propName = "size") {
4193
4043
  proto[`${name}Len`] = function() {
4194
4044
  return this.get(name, defaultEmpty)[propName];
@@ -4196,8 +4046,7 @@ function extendProtoSized(proto, name, defaultEmpty, propName = "size") {
4196
4046
  }
4197
4047
  var EMPTY_SET = ISet();
4198
4048
  var isetCoercer = (v) => Array.isArray(v) ? ISet(v) : v instanceof Set ? ISet(v) : null;
4199
-
4200
- class FieldSet extends Field {
4049
+ var FieldSet = class extends Field {
4201
4050
  constructor(name, defaultValue = EMPTY_SET) {
4202
4051
  super("set", name, CHECK_TYPE_SET, isetCoercer, defaultValue);
4203
4052
  }
@@ -4216,18 +4065,19 @@ class FieldSet extends Field {
4216
4065
  return this.set(name, current.has(v) ? current.delete(v) : current.add(v));
4217
4066
  };
4218
4067
  }
4219
- }
4068
+ };
4220
4069
  function mkCompField(field, scope, args) {
4221
4070
  const Comp = scope?.lookupComponent(field.type) ?? null;
4222
4071
  if (Comp === null)
4223
- console.warn(scope ? `component field "${field.name}": component "${field.type}" not found in scope` : `component field "${field.name}": cannot resolve component "${field.type}" — built without a registered scope (use ${field.type}.make({}) as the default, or build via a registered component)`);
4072
+ console.warn(
4073
+ scope ? `component field "${field.name}": component "${field.type}" not found in scope` : `component field "${field.name}": cannot resolve component "${field.type}" — built without a registered scope (use ${field.type}.make({}) as the default, or build via a registered component)`
4074
+ );
4224
4075
  return Comp?.make({ ...field.args, ...args }, { scope }) ?? null;
4225
4076
  }
4226
-
4227
- class ClassBuilder {
4077
+ var ClassBuilder = class {
4228
4078
  constructor(name) {
4229
4079
  const fields = {};
4230
- const compFields = new Set;
4080
+ const compFields = /* @__PURE__ */ new Set();
4231
4081
  this.name = name;
4232
4082
  this.fields = fields;
4233
4083
  this.compFields = compFields;
@@ -4238,16 +4088,13 @@ class ClassBuilder {
4238
4088
  const scope = opts.scope ?? this.scope;
4239
4089
  for (const key in inArgs) {
4240
4090
  const field = fields[key];
4241
- if (compFields.has(key))
4242
- args[key] = mkCompField(field, scope, inArgs[key]);
4243
- else if (field === undefined)
4091
+ if (compFields.has(key)) args[key] = mkCompField(field, scope, inArgs[key]);
4092
+ else if (field === void 0)
4244
4093
  console.warn("extra argument to constructor:", name, key, inArgs);
4245
- else
4246
- args[key] = field.coerceOrDefault(inArgs[key]);
4094
+ else args[key] = field.coerceOrDefault(inArgs[key]);
4247
4095
  }
4248
4096
  for (const key of compFields)
4249
- if (args[key] === undefined)
4250
- args[key] = mkCompField(fields[key], scope, inArgs[key]);
4097
+ if (args[key] === void 0) args[key] = mkCompField(fields[key], scope, inArgs[key]);
4251
4098
  return this(args);
4252
4099
  }
4253
4100
  };
@@ -4268,12 +4115,10 @@ class ClassBuilder {
4268
4115
  return Class;
4269
4116
  }
4270
4117
  methods(proto) {
4271
- for (const k in proto)
4272
- this._methods[k] = proto[k];
4118
+ for (const k in proto) this._methods[k] = proto[k];
4273
4119
  }
4274
4120
  statics(proto) {
4275
- for (const k in proto)
4276
- this._statics[k] = proto[k];
4121
+ for (const k in proto) this._statics[k] = proto[k];
4277
4122
  }
4278
4123
  addField(name, dval, FieldCls) {
4279
4124
  const field = new FieldCls(name, dval);
@@ -4286,8 +4131,8 @@ class ClassBuilder {
4286
4131
  this.fields[name] = field;
4287
4132
  return field;
4288
4133
  }
4289
- }
4290
- var FIELD_CLASS = Symbol.for("tutuca.fieldClass");
4134
+ };
4135
+ var FIELD_CLASS = /* @__PURE__ */ Symbol.for("tutuca.fieldClass");
4291
4136
  var fieldsByTypeName = {
4292
4137
  text: FieldString,
4293
4138
  int: FieldInt,
@@ -4304,22 +4149,16 @@ function classFromData(name, { fields = {}, methods, statics }) {
4304
4149
  for (const field in fields) {
4305
4150
  const value = fields[field];
4306
4151
  const type = typeof value;
4307
- if (type === "string")
4308
- b.addField(field, value, FieldString);
4309
- else if (type === "number")
4310
- b.addField(field, value, FieldFloat);
4311
- else if (type === "boolean")
4312
- b.addField(field, value, FieldBool);
4313
- else if (List.isList(value) || Array.isArray(value))
4314
- b.addField(field, List(value), FieldList);
4315
- else if (ISet.isSet(value) || value instanceof Set)
4316
- b.addField(field, ISet(value), FieldSet);
4317
- else if (OrderedMap.isOrderedMap(value))
4318
- b.addField(field, value, FieldOMap);
4319
- else if (value?.type && value?.defaultValue !== undefined) {
4152
+ if (type === "string") b.addField(field, value, FieldString);
4153
+ else if (type === "number") b.addField(field, value, FieldFloat);
4154
+ else if (type === "boolean") b.addField(field, value, FieldBool);
4155
+ else if (List.isList(value) || Array.isArray(value)) b.addField(field, List(value), FieldList);
4156
+ else if (ISet.isSet(value) || value instanceof Set) b.addField(field, ISet(value), FieldSet);
4157
+ else if (OrderedMap.isOrderedMap(value)) b.addField(field, value, FieldOMap);
4158
+ else if (value?.type && value?.defaultValue !== void 0) {
4320
4159
  const Field2 = fieldsByTypeName[value.type] ?? FieldAny;
4321
4160
  b.addField(field, new Field2().coerceOr(value.defaultValue), Field2);
4322
- } else if (value?.component && value?.args !== undefined)
4161
+ } else if (value?.component && value?.args !== void 0)
4323
4162
  b.addCompField(field, value.component, value.args);
4324
4163
  else if (IMap.isMap(value) || value?.constructor === Object)
4325
4164
  b.addField(field, IMap(value), FieldMap);
@@ -4328,10 +4167,8 @@ function classFromData(name, { fields = {}, methods, statics }) {
4328
4167
  b.addField(field, value, Field2);
4329
4168
  }
4330
4169
  }
4331
- if (methods)
4332
- b.methods(methods);
4333
- if (statics)
4334
- b.statics(statics);
4170
+ if (methods) b.methods(methods);
4171
+ if (statics) b.statics(statics);
4335
4172
  return b.build();
4336
4173
  }
4337
4174
  Component.fromSpec = (opts) => new Component(classFromData(opts.name, opts), opts);
@@ -4348,12 +4185,14 @@ async function test(_opts) {
4348
4185
  return null;
4349
4186
  }
4350
4187
  function collectIterBindings() {
4351
- console.warn("collectIterBindings is a no-op in the core tutuca build; use the tutuca-dev build for a functional implementation");
4188
+ console.warn(
4189
+ "collectIterBindings is a no-op in the core tutuca build; use the tutuca-dev build for a functional implementation"
4190
+ );
4352
4191
  return [];
4353
4192
  }
4354
4193
  function tutuca(nodeOrSelector) {
4355
4194
  const rootNode = typeof nodeOrSelector === "string" ? document.querySelector(nodeOrSelector) : nodeOrSelector;
4356
- const comps = new Components;
4195
+ const comps = new Components();
4357
4196
  const renderer = new Renderer(comps);
4358
4197
  return new App(rootNode, comps, renderer, ParseContext);
4359
4198
  }
@@ -4372,74 +4211,74 @@ async function compileClassesToStyleText(app, compileClasses, Ctx = ParseCtxClas
4372
4211
  return await compileClasses(Array.from(collectAppClassesInSet(app)));
4373
4212
  }
4374
4213
  export {
4375
- version,
4376
- updateIn,
4377
- update,
4378
- tutuca,
4379
- test,
4380
- setIn,
4381
- set,
4382
- rootDispatcher,
4383
- resolveArgs,
4384
- removeIn,
4385
- remove,
4386
- phaseOps,
4387
- phaseHasBubble,
4388
- mergeWith,
4389
- mergeDeepWith,
4390
- mergeDeep,
4391
- merge,
4392
- macro,
4393
- isValueObject,
4394
- isStack,
4395
- isSet,
4396
- isSeq,
4397
- isRecord,
4398
- isPlainObject,
4399
- isOrderedSet,
4400
- isOrderedMap,
4401
- isOrdered,
4402
- isOrderedMap2 as isOMap,
4403
- isMap,
4404
- isList,
4405
- isKeyed2 as isKeyed,
4406
- isIndexed2 as isIndexed,
4407
- isImmutable,
4408
- isMap2 as isIMap,
4409
- isCollection,
4410
- isAssociative,
4411
- is2 as is,
4412
- injectCss,
4413
- html,
4414
- hash,
4415
- hasIn,
4416
- has,
4417
- getIn,
4418
- get,
4419
- fromJS,
4420
- dispatchPhase,
4421
- css,
4422
- component,
4423
- compileClassesToStyleText,
4424
- compileClassesToStyle,
4425
- collectIterBindings,
4426
- check,
4427
- Stack2 as Stack,
4428
- Set2 as Set,
4429
- Seq,
4430
- SEQ_INFO,
4431
- Repeat,
4432
- Record2 as Record,
4433
- Range,
4434
- ParseContext,
4435
- PairSorting,
4436
- OrderedSet,
4437
- OrderedMap2 as OrderedMap,
4438
- OrderedMap3 as OMap,
4439
- Map2 as Map,
4440
- List2 as List,
4441
- Set3 as ISet,
4442
- Map3 as IMap,
4214
+ Collection,
4443
4215
  FIELD_CLASS,
4444
- Collection
4216
+ Map3 as IMap,
4217
+ Set3 as ISet,
4218
+ List2 as List,
4219
+ Map2 as Map,
4220
+ OrderedMap3 as OMap,
4221
+ OrderedMap2 as OrderedMap,
4222
+ OrderedSet,
4223
+ PairSorting,
4224
+ ParseContext,
4225
+ Range,
4226
+ Record2 as Record,
4227
+ Repeat,
4228
+ SEQ_INFO,
4229
+ Seq,
4230
+ Set2 as Set,
4231
+ Stack2 as Stack,
4232
+ check,
4233
+ collectIterBindings,
4234
+ compileClassesToStyle,
4235
+ compileClassesToStyleText,
4236
+ component,
4237
+ css,
4238
+ dispatchPhase,
4239
+ fromJS,
4240
+ get,
4241
+ getIn,
4242
+ has,
4243
+ hasIn,
4244
+ hash,
4245
+ html,
4246
+ injectCss,
4247
+ is2 as is,
4248
+ isAssociative,
4249
+ isCollection,
4250
+ isMap2 as isIMap,
4251
+ isImmutable,
4252
+ isIndexed2 as isIndexed,
4253
+ isKeyed2 as isKeyed,
4254
+ isList,
4255
+ isMap,
4256
+ isOrderedMap2 as isOMap,
4257
+ isOrdered,
4258
+ isOrderedMap,
4259
+ isOrderedSet,
4260
+ isPlainObject,
4261
+ isRecord,
4262
+ isSeq,
4263
+ isSet,
4264
+ isStack,
4265
+ isValueObject,
4266
+ macro,
4267
+ merge,
4268
+ mergeDeep,
4269
+ mergeDeepWith,
4270
+ mergeWith,
4271
+ phaseHasBubble,
4272
+ phaseOps,
4273
+ remove,
4274
+ removeIn,
4275
+ resolveArgs,
4276
+ rootDispatcher,
4277
+ set,
4278
+ setIn,
4279
+ test,
4280
+ tutuca,
4281
+ update,
4282
+ updateIn,
4283
+ version
4445
4284
  };