marko 6.0.0-next.3.26 → 6.0.0-next.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dom.mjs CHANGED
@@ -45,49 +45,6 @@ function triggerMacroTask() {
45
45
  port2.postMessage(0);
46
46
  }
47
47
 
48
- // src/dom/scope.ts
49
- var pendingScopes = [];
50
- function createScope($global) {
51
- let scope = {
52
- f: 1,
53
- $global
54
- };
55
- return pendingScopes.push(scope), scope;
56
- }
57
- function finishPendingScopes() {
58
- for (let scope of pendingScopes)
59
- scope.f = 0;
60
- pendingScopes = [];
61
- }
62
- var emptyBranch = createScope({});
63
- function getEmptyBranch(marker) {
64
- return emptyBranch.a = emptyBranch.c = marker, emptyBranch;
65
- }
66
- function destroyBranch(branch) {
67
- branch.n?.k?.delete(branch), destroyNestedBranches(branch);
68
- }
69
- function destroyNestedBranches(branch) {
70
- branch.z = 1, branch.k?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
71
- for (let id in scope.g)
72
- scope.g[id]?.abort();
73
- });
74
- }
75
- function removeAndDestroyBranch(branch) {
76
- destroyBranch(branch);
77
- let current = branch.a, stop = branch.c.nextSibling;
78
- for (; current !== stop; ) {
79
- let next = current.nextSibling;
80
- current.remove(), current = next;
81
- }
82
- }
83
- function insertBranchBefore(branch, parent, nextSibling) {
84
- let current = branch.a, stop = branch.c.nextSibling;
85
- for (; current !== stop; ) {
86
- let next = current.nextSibling;
87
- parent.insertBefore(current, nextSibling), current = next;
88
- }
89
- }
90
-
91
48
  // src/common/helpers.ts
92
49
  function classValue(value2) {
93
50
  return toDelimitedString(value2, " ", stringifyClassObject);
@@ -134,83 +91,6 @@ function normalizeDynamicRenderer(value2) {
134
91
  if (value2) return value2.content || value2.default || value2;
135
92
  }
136
93
 
137
- // src/dom/reconcile.ts
138
- var WRONG_POS = 2147483647;
139
- function reconcile(parent, oldBranches, newBranches, afterReference) {
140
- let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
141
- outer: {
142
- for (; oldStartBranch === newStartBranch; ) {
143
- if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
144
- break outer;
145
- oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
146
- }
147
- for (; oldEndBranch === newEndBranch; ) {
148
- if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
149
- break outer;
150
- oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
151
- }
152
- }
153
- if (oldStart > oldEnd) {
154
- if (newStart <= newEnd) {
155
- k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
156
- do
157
- insertBranchBefore(newBranches[newStart++], parent, nextSibling);
158
- while (newStart <= newEnd);
159
- }
160
- } else if (newStart > newEnd)
161
- do
162
- removeAndDestroyBranch(oldBranches[oldStart++]);
163
- while (oldStart <= oldEnd);
164
- else {
165
- let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
166
- for (i = 0; i < newLength; ++i)
167
- sources[i] = -1;
168
- let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
169
- for (j = newStart; j <= newEnd; ++j)
170
- keyIndex.set(newBranches[j], j);
171
- for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
172
- oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
173
- if (oldLength === oldBranches.length && synced === 0) {
174
- for (; newStart < newLength; ++newStart)
175
- insertBranchBefore(newBranches[newStart], parent, afterReference);
176
- for (; oldStart < oldLength; ++oldStart)
177
- removeAndDestroyBranch(oldBranches[oldStart]);
178
- } else {
179
- for (i = oldLength - synced; i > 0; )
180
- oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
181
- if (pos === WRONG_POS) {
182
- let seq = longestIncreasingSubsequence(sources);
183
- for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
184
- sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
185
- } else if (synced !== newLength)
186
- for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
187
- sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
188
- }
189
- }
190
- }
191
- function longestIncreasingSubsequence(a) {
192
- let p = a.slice(), result = [];
193
- result.push(0);
194
- let u, v;
195
- for (let i = 0, il = a.length; i < il; ++i) {
196
- if (a[i] === -1)
197
- continue;
198
- let j = result[result.length - 1];
199
- if (a[j] < a[i]) {
200
- p[i] = j, result.push(i);
201
- continue;
202
- }
203
- for (u = 0, v = result.length - 1; u < v; ) {
204
- let c = (u + v) / 2 | 0;
205
- a[result[c]] < a[i] ? u = c + 1 : v = c;
206
- }
207
- a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
208
- }
209
- for (u = result.length, v = result[u - 1]; u-- > 0; )
210
- result[u] = v, v = p[v];
211
- return result;
212
- }
213
-
214
94
  // src/dom/event.ts
215
95
  var elementHandlersByEvent = /* @__PURE__ */ new Map(), defaultDelegator = createDelegator();
216
96
  function on(element, type, handler) {
@@ -225,7 +105,7 @@ function createDelegator() {
225
105
  };
226
106
  }
227
107
  function handleDelegated(ev) {
228
- let target = ev.target;
108
+ let target = !rendering && ev.target;
229
109
  if (target) {
230
110
  let handlersByElement = elementHandlersByEvent.get(ev.type);
231
111
  if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
@@ -261,28 +141,28 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
261
141
 
262
142
  // src/dom/resume.ts
263
143
  var registeredValues = {}, Render = class {
264
- o = [];
265
- p = {};
266
- B = {
144
+ n = [];
145
+ o = {};
146
+ z = {
267
147
  _: registeredValues
268
148
  };
269
149
  constructor(renders, runtimeId, renderId) {
270
- this.C = renders, this.D = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
150
+ this.A = renders, this.B = runtimeId, this.p = renderId, this.q = renders[renderId], this.s();
271
151
  }
272
152
  w() {
273
- this.s.w(), this.t();
153
+ this.q.w(), this.s();
274
154
  }
275
- t() {
276
- let data2 = this.s, serializeContext = this.B, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
155
+ s() {
156
+ let data2 = this.q, serializeContext = this.z, scopeLookup = this.o, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
277
157
  if (visits.length) {
278
- let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
158
+ let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
279
159
  data2.v = [];
280
- let branchEnd = (branchId, visit, curNode) => {
281
- let branch = scopeLookup[branchId] ||= {}, endNode = curNode;
282
- for (; (endNode = endNode.previousSibling).nodeType === 8; ) ;
283
- branch.c = endNode, branch.a ||= endNode;
160
+ let branchEnd = (branchId, visit, reference) => {
161
+ let branch = scopeLookup[branchId] ||= {}, endNode = reference;
162
+ for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
163
+ endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(new Text(), reference)), branch.b = lastEndNode = endNode, branch.a ||= endNode;
284
164
  for (let [markerScopeId, markerNode] of closestBranchMarkers)
285
- branch.a.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
165
+ branch.a.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
286
166
  return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
287
167
  };
288
168
  for (let visit of visits) {
@@ -295,7 +175,7 @@ var registeredValues = {}, Render = class {
295
175
  else if (token === "$" /* ClosestBranch */)
296
176
  closestBranchMarkers.set(scopeId, visit);
297
177
  else if (token === "[" /* BranchStart */)
298
- this.e && (dataIndex && branchEnd(this.e, visit, visit), this.o.push(this.e)), this.e = scopeId, scope.a = visit;
178
+ this.e && (dataIndex && branchEnd(this.e, visit, visit), this.n.push(this.e)), this.e = scopeId, scope.a = visit;
299
179
  else if (token === "]" /* BranchEnd */) {
300
180
  scope[data3] = visit;
301
181
  let curParent = visit.parentNode, startNode = branchEnd(
@@ -303,14 +183,14 @@ var registeredValues = {}, Render = class {
303
183
  visit,
304
184
  visit
305
185
  ).a;
306
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.o.pop();
186
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.n.pop();
307
187
  } else if (token === "|" /* BranchSingleNode */) {
308
188
  let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
309
189
  for (; ~next; ) {
310
190
  let start = next + 1;
311
191
  next = data3.indexOf(" ", start);
312
192
  let childScopeId = data3.slice(start, ~next ? next : data3.length);
313
- curNode = branchEnd(childScopeId, visit, curNode).c;
193
+ curNode = branchEnd(childScopeId, visit, curNode).b;
314
194
  }
315
195
  }
316
196
  }
@@ -324,7 +204,7 @@ var registeredValues = {}, Render = class {
324
204
  let resumeData = resumes[i++];
325
205
  if (typeof resumeData == "function") {
326
206
  let scopes = resumeData(serializeContext), { $global } = scopeLookup;
327
- $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.D, $global.renderId = this.q);
207
+ $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.p);
328
208
  for (let scopeId in scopes)
329
209
  if (scopeId !== "$") {
330
210
  let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
@@ -333,12 +213,12 @@ var registeredValues = {}, Render = class {
333
213
  prevScope
334
214
  ));
335
215
  let parentBranchId = parentBranchIds.get(scopeId);
336
- if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
337
- let branch = scope, parentBranch = branch.b;
338
- branch.h = +scopeId, scope.b = branch, parentBranch && (branch.n = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
216
+ if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
217
+ let branch = scope, parentBranch = branch.c;
218
+ branch.f = +scopeId, scope.c = branch, parentBranch && (branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
339
219
  }
340
220
  }
341
- } else i === len || typeof resumes[i] != "string" ? delete this.C[this.q] : registeredValues[resumes[i++]](
221
+ } else i === len || typeof resumes[i] != "string" ? delete this.A[this.p] : registeredValues[resumes[i++]](
342
222
  scopeLookup[resumeData],
343
223
  scopeLookup[resumeData]
344
224
  );
@@ -376,7 +256,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
376
256
  }
377
257
  }
378
258
  function registerSubscriber(id, signal) {
379
- return register(id, signal.E), signal;
259
+ return register(id, signal.C), signal;
380
260
  }
381
261
  function nodeRef(id, key) {
382
262
  return register(id, (scope) => () => scope[key]);
@@ -555,7 +435,7 @@ function toValueProp(it) {
555
435
  }
556
436
 
557
437
  // src/dom/parse-html.ts
558
- var fallback = /* @__PURE__ */ new Text(), parser = /* @__PURE__ */ document.createElement("template");
438
+ var parser = /* @__PURE__ */ document.createElement("template");
559
439
  function parseHTML(html2) {
560
440
  return parser.innerHTML = html2, parser.content;
561
441
  }
@@ -570,7 +450,7 @@ function parseHTMLOrSingleNode(html2) {
570
450
  let fragment = new DocumentFragment();
571
451
  return fragment.appendChild(content), fragment;
572
452
  }
573
- return fallback;
453
+ return new Text();
574
454
  }
575
455
 
576
456
  // src/dom/dom.ts
@@ -709,14 +589,12 @@ function attrsEvents(scope, nodeAccessor) {
709
589
  for (let name in events)
710
590
  on(el, name, events[name]);
711
591
  }
712
- function html(scope, value2, index) {
713
- let firstChild = scope[index], lastChild = scope[index + "-"] || firstChild, parentNode = firstChild.parentNode, afterReference = lastChild.nextSibling, newContent = parseHTML(value2 || value2 === 0 ? value2 + "" : "<!>");
714
- scope[index] = newContent.firstChild, scope[index + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild, parentNode.insertBefore(newContent, firstChild);
715
- let current = firstChild;
716
- for (; current !== afterReference; ) {
717
- let next = current.nextSibling;
718
- current.remove(), current = next;
719
- }
592
+ function html(scope, value2, accessor) {
593
+ let firstChild = scope[accessor], lastChild = scope[accessor + "-" /* DynamicPlaceholderLastChild */] || firstChild, newContent = parseHTML(
594
+ value2 || value2 === 0 ? value2 + "" : "<!>"
595
+ // TODO: is the comment needed
596
+ );
597
+ scope[accessor] = newContent.firstChild, scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild, firstChild.parentNode.insertBefore(newContent, firstChild), removeChildNodes(firstChild, lastChild);
720
598
  }
721
599
  function props(scope, nodeIndex, index) {
722
600
  let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
@@ -741,6 +619,128 @@ function lifecycle(scope, index, thisObj) {
741
619
  "-" /* LifecycleAbortController */ + index
742
620
  ).onabort = () => thisObj.onDestroy?.());
743
621
  }
622
+ function removeChildNodes(startNode, endNode) {
623
+ let stop = endNode.nextSibling, current = startNode;
624
+ for (; current !== stop; ) {
625
+ let next = current.nextSibling;
626
+ current.remove(), current = next;
627
+ }
628
+ }
629
+
630
+ // src/dom/scope.ts
631
+ var pendingScopes = [];
632
+ function createScope($global) {
633
+ let scope = {
634
+ g: 1,
635
+ $global
636
+ };
637
+ return pendingScopes.push(scope), scope;
638
+ }
639
+ function finishPendingScopes() {
640
+ for (let scope of pendingScopes)
641
+ scope.g = 0;
642
+ pendingScopes = [];
643
+ }
644
+ var emptyBranch = createScope({});
645
+ function getEmptyBranch(marker) {
646
+ return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
647
+ }
648
+ function destroyBranch(branch) {
649
+ branch.t?.k?.delete(branch), destroyNestedBranches(branch);
650
+ }
651
+ function destroyNestedBranches(branch) {
652
+ branch.D = 1, branch.k?.forEach(destroyNestedBranches), branch.E?.forEach((scope) => {
653
+ for (let id in scope.h)
654
+ scope.h[id]?.abort();
655
+ });
656
+ }
657
+ function removeAndDestroyBranch(branch) {
658
+ destroyBranch(branch), removeChildNodes(branch.a, branch.b);
659
+ }
660
+ function insertBranchBefore(branch, parentNode, nextSibling) {
661
+ let current = branch.a, stop = branch.b.nextSibling;
662
+ for (; current !== stop; ) {
663
+ let next = current.nextSibling;
664
+ parentNode.insertBefore(current, nextSibling), current = next;
665
+ }
666
+ }
667
+
668
+ // src/dom/reconcile.ts
669
+ var WRONG_POS = 2147483647;
670
+ function reconcile(parent, oldBranches, newBranches, afterReference) {
671
+ let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
672
+ outer: {
673
+ for (; oldStartBranch === newStartBranch; ) {
674
+ if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
675
+ break outer;
676
+ oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
677
+ }
678
+ for (; oldEndBranch === newEndBranch; ) {
679
+ if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
680
+ break outer;
681
+ oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
682
+ }
683
+ }
684
+ if (oldStart > oldEnd) {
685
+ if (newStart <= newEnd) {
686
+ k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
687
+ do
688
+ insertBranchBefore(newBranches[newStart++], parent, nextSibling);
689
+ while (newStart <= newEnd);
690
+ }
691
+ } else if (newStart > newEnd)
692
+ do
693
+ removeAndDestroyBranch(oldBranches[oldStart++]);
694
+ while (oldStart <= oldEnd);
695
+ else {
696
+ let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
697
+ for (i = 0; i < newLength; ++i)
698
+ sources[i] = -1;
699
+ let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
700
+ for (j = newStart; j <= newEnd; ++j)
701
+ keyIndex.set(newBranches[j], j);
702
+ for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
703
+ oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
704
+ if (oldLength === oldBranches.length && synced === 0) {
705
+ for (; newStart < newLength; ++newStart)
706
+ insertBranchBefore(newBranches[newStart], parent, afterReference);
707
+ for (; oldStart < oldLength; ++oldStart)
708
+ removeAndDestroyBranch(oldBranches[oldStart]);
709
+ } else {
710
+ for (i = oldLength - synced; i > 0; )
711
+ oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
712
+ if (pos === WRONG_POS) {
713
+ let seq = longestIncreasingSubsequence(sources);
714
+ for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
715
+ sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
716
+ } else if (synced !== newLength)
717
+ for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
718
+ sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
719
+ }
720
+ }
721
+ }
722
+ function longestIncreasingSubsequence(a) {
723
+ let p = a.slice(), result = [];
724
+ result.push(0);
725
+ let u, v;
726
+ for (let i = 0, il = a.length; i < il; ++i) {
727
+ if (a[i] === -1)
728
+ continue;
729
+ let j = result[result.length - 1];
730
+ if (a[j] < a[i]) {
731
+ p[i] = j, result.push(i);
732
+ continue;
733
+ }
734
+ for (u = 0, v = result.length - 1; u < v; ) {
735
+ let c = (u + v) / 2 | 0;
736
+ a[result[c]] < a[i] ? u = c + 1 : v = c;
737
+ }
738
+ a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
739
+ }
740
+ for (u = result.length, v = result[u - 1]; u-- > 0; )
741
+ result[u] = v, v = p[v];
742
+ return result;
743
+ }
744
744
 
745
745
  // src/dom/walker.ts
746
746
  var walker = /* @__PURE__ */ document.createTreeWalker(document);
@@ -749,8 +749,8 @@ function trimWalkString(walkString) {
749
749
  for (; walkString.charCodeAt(--end) > 47 /* BeginChild */; ) ;
750
750
  return walkString.slice(0, end + 1);
751
751
  }
752
- function walk(startNode, walkCodes, scope) {
753
- walker.currentNode = startNode, walkInternal(walkCodes, scope, 0), walker.currentNode = document;
752
+ function walk(startNode, walkCodes, branch) {
753
+ walker.currentNode = startNode, walkInternal(walkCodes, branch, 0), walker.currentNode = document;
754
754
  }
755
755
  function walkInternal(walkCodes, scope, currentWalkIndex) {
756
756
  let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
@@ -769,7 +769,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
769
769
  walker.nextNode();
770
770
  else if (value2 === 47 /* BeginChild */) {
771
771
  let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
772
- childScope.a = walker.currentNode, childScope.b = scope.b, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
772
+ childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
773
773
  } else {
774
774
  if (value2 === 38 /* EndChild */)
775
775
  return currentWalkIndex;
@@ -800,11 +800,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
800
800
  parentScope
801
801
  );
802
802
  let branch = createBranch($global, parentScope, parentScope);
803
- return branch[0] = branch.a = branch.c = document.createElement(tagNameOrRenderer), branch;
803
+ return branch[0] = branch.a = branch.b = document.createElement(tagNameOrRenderer), branch;
804
804
  }
805
805
  function createBranch($global, ownerScope, parentScope) {
806
- let branch = createScope($global), parentBranch = parentScope.b;
807
- return branch._ = ownerScope, branch.b = branch, parentBranch ? (branch.h = parentBranch.h + 1, branch.n = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch)) : branch.h = 1, branch;
806
+ let branch = createScope($global), parentBranch = parentScope.c;
807
+ return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
808
808
  }
809
809
  function initBranch(renderer, branch) {
810
810
  let dom = renderer.l();
@@ -812,7 +812,7 @@ function initBranch(renderer, branch) {
812
812
  dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
813
813
  renderer.F,
814
814
  branch
815
- ), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, branch.c = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(branch, renderer.x), dom;
815
+ ), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, branch.b = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(branch, renderer.x), dom;
816
816
  }
817
817
  function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
818
818
  return (scope, attrsOrOp) => {
@@ -883,8 +883,8 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
883
883
  let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
884
884
  insertBranchBefore(
885
885
  newBranch,
886
- prevBranch.a.parentNode,
887
- prevBranch.a
886
+ prevBranch.b.parentNode,
887
+ prevBranch.b.nextSibling
888
888
  ), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
889
889
  }
890
890
  var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
@@ -957,7 +957,7 @@ function loop(nodeAccessor, renderer, forEach) {
957
957
  if (referenceIsMarker) {
958
958
  oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
959
959
  let oldLastChild = oldArray[oldArray.length - 1];
960
- afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
960
+ afterReference = oldLastChild.b.nextSibling, parentNode = oldLastChild.a.parentNode;
961
961
  } else
962
962
  afterReference = null, parentNode = referenceNode;
963
963
  reconcile(parentNode, oldArray, newArray, afterReference);
@@ -1013,14 +1013,14 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
1013
1013
  let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
1014
1014
  if (loopScopes !== emptyMarkerArray)
1015
1015
  for (let scope of loopScopes)
1016
- scope.f || queueSource(scope, signal, value2);
1016
+ scope.g || queueSource(scope, signal, value2);
1017
1017
  };
1018
1018
  return helperSignal._ = signal, helperSignal;
1019
1019
  }
1020
1020
  function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
1021
1021
  let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
1022
1022
  let conditionalScope = scope[scopeAccessor];
1023
- conditionalScope && !conditionalScope.f && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1023
+ conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1024
1024
  };
1025
1025
  return helperSignal._ = signal, helperSignal;
1026
1026
  }
@@ -1030,7 +1030,7 @@ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersectio
1030
1030
  let subscribers = ownerScope[ownerSubscribersAccessor];
1031
1031
  if (subscribers)
1032
1032
  for (let subscriber of subscribers)
1033
- subscriber.f || queueSource(subscriber, _signal, value2);
1033
+ subscriber.g || queueSource(subscriber, _signal, value2);
1034
1034
  }, setupSignal = (scope, value2) => {
1035
1035
  _signal(scope, value2), subscribe(scope);
1036
1036
  }, subscribe = (scope) => {
@@ -1038,7 +1038,7 @@ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersectio
1038
1038
  getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
1039
1039
  });
1040
1040
  };
1041
- return helperSignal._ = setupSignal, helperSignal.E = subscribe, helperSignal;
1041
+ return helperSignal._ = setupSignal, helperSignal.C = subscribe, helperSignal;
1042
1042
  }
1043
1043
  function setTagVar(scope, childAccessor, tagVarSignal2) {
1044
1044
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
@@ -1135,7 +1135,7 @@ function runRenders() {
1135
1135
  }
1136
1136
  pendingRenders[i] = item;
1137
1137
  }
1138
- render.m.b?.z || render.I(render.m, render.J);
1138
+ render.m.c?.D || render.I(render.m, render.J);
1139
1139
  }
1140
1140
  finishPendingScopes();
1141
1141
  }
@@ -1143,32 +1143,32 @@ function comparePendingRenders(a, b) {
1143
1143
  return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
1144
1144
  }
1145
1145
  function getBranchDepth(render) {
1146
- return render.m.b?.h || 0;
1146
+ return render.m.c?.f || 0;
1147
1147
  }
1148
1148
 
1149
1149
  // src/dom/abort-signal.ts
1150
1150
  function resetAbortSignal(scope, id) {
1151
- let ctrl = scope.g?.[id];
1152
- ctrl && (queueEffect(ctrl, abort), scope.g[id] = void 0);
1151
+ let ctrl = scope.h?.[id];
1152
+ ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
1153
1153
  }
1154
1154
  function getAbortSignal(scope, id) {
1155
- return scope.b && (scope.b.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.g ||= {})[id] ||= new AbortController()).signal;
1155
+ return scope.c && (scope.c.E ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1156
1156
  }
1157
1157
  function abort(ctrl) {
1158
1158
  ctrl.abort();
1159
1159
  }
1160
1160
 
1161
1161
  // src/common/compat-meta.ts
1162
- var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
1162
+ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
1163
1163
 
1164
1164
  // src/dom/compat.ts
1165
- var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1165
+ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1166
1166
  patchConditionals,
1167
1167
  queueEffect,
1168
- init() {
1169
- register(SET_SCOPE_REGISTER_ID, (scope) => {
1170
- classIdToScope.set(scope.m5c, scope);
1171
- });
1168
+ init(warp10Noop) {
1169
+ register(SET_SCOPE_REGISTER_ID, (branch) => {
1170
+ classIdToBranch.set(branch.m5c, branch);
1171
+ }), register(RENDER_BODY_ID, warp10Noop);
1172
1172
  },
1173
1173
  registerRenderer(fn) {
1174
1174
  register(RENDERER_REGISTER_ID, fn);
@@ -1179,11 +1179,11 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1179
1179
  isRenderer(renderer) {
1180
1180
  return renderer.l !== void 0;
1181
1181
  },
1182
- getStartNode(scope) {
1183
- return scope.a;
1182
+ getStartNode(branch) {
1183
+ return branch.a;
1184
1184
  },
1185
- setScopeNodes(scope, startNode, endNode) {
1186
- scope.a = startNode, scope.c = endNode;
1185
+ setScopeNodes(branch, startNode, endNode) {
1186
+ branch.a = startNode, branch.b = endNode;
1187
1187
  },
1188
1188
  runComponentEffects() {
1189
1189
  runEffects(this.effects);
@@ -1197,7 +1197,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1197
1197
  }) {
1198
1198
  return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
1199
1199
  value2[0],
1200
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.p[value2[1]]
1200
+ value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.o[value2[1]]
1201
1201
  ) : value2;
1202
1202
  },
1203
1203
  createRenderer(setup, clone, args) {
@@ -1205,8 +1205,8 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1205
1205
  return renderer.l = clone, renderer;
1206
1206
  },
1207
1207
  render(out, component, renderer, args) {
1208
- let scope = component.scope;
1209
- scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
1208
+ let branch = component.scope;
1209
+ branch || (branch = classIdToBranch.get(component.id), branch && (component.scope = branch, classIdToBranch.delete(component.id)));
1210
1210
  let applyArgs = renderer.d || noop, existing = !1;
1211
1211
  if (typeof args[0] == "object" && "renderBody" in args[0]) {
1212
1212
  let input = args[0], normalizedInput = args[0] = {};
@@ -1214,9 +1214,9 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1214
1214
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1215
1215
  }
1216
1216
  if (component.effects = prepareEffects(() => {
1217
- scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initBranch(renderer, scope)), applyArgs(scope, args);
1217
+ branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.u, initBranch(renderer, branch)), applyArgs(branch, args);
1218
1218
  }), !existing)
1219
- return scope.a === scope.c ? scope.a : scope.a.parentNode;
1219
+ return branch.a === branch.b ? branch.a : branch.a.parentNode;
1220
1220
  }
1221
1221
  };
1222
1222
  function noop() {
@@ -11,4 +11,5 @@ export declare const compat: {
11
11
  toJSON(this: WeakKey): [registryId: string, scopeId: unknown] | undefined;
12
12
  render(renderer: ServerRenderer, willRerender: boolean, classAPIOut: any, component: any, input: any): void;
13
13
  registerRenderer(renderer: any, id: string): any;
14
+ registerRenderBody(fn: any): void;
14
15
  };
@@ -1,4 +1,5 @@
1
1
  import type { Boundary } from "./writer";
2
+ export declare function debug(obj: WeakKey, file: string, loc: string | 0, vars?: Record<string, string>): WeakKey;
2
3
  export declare class Serializer {
3
4
  #private;
4
5
  get flushed(): boolean;
@@ -12,3 +13,4 @@ export declare function getRegistered(val: WeakKey): {
12
13
  scope: unknown;
13
14
  } | undefined;
14
15
  export declare function stringify(val: unknown): string;
16
+ export declare function toAccess(accessor: string): string;
package/dist/html.d.ts CHANGED
@@ -5,5 +5,6 @@ export { compat } from "./html/compat";
5
5
  export { escapeScript, escapeStyle, escapeXML, toString } from "./html/content";
6
6
  export { createRenderer, dynamicTagArgs, dynamicTagInput, } from "./html/dynamic-tag";
7
7
  export { forIn, forInBy, forOf, forOfBy, forTo, forToBy } from "./html/for";
8
+ export { debug } from "./html/serializer";
8
9
  export { createTemplate } from "./html/template";
9
10
  export { $global, ensureScopeWithId, fork, getScopeById, markResumeNode, nextScopeId, nextTagId, nodeRef, peekNextScope, register, resumeClosestBranch, resumeConditional, resumeForIn, resumeForOf, resumeForTo, resumeSingleNodeConditional, resumeSingleNodeForIn, resumeSingleNodeForOf, resumeSingleNodeForTo, tryContent, write, writeEffect, writeExistingScope, writeScope, writeTrailers, } from "./html/writer";