marko 6.0.0-next.3.24 → 6.0.0-next.3.26

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.js CHANGED
@@ -133,25 +133,28 @@ function triggerMacroTask() {
133
133
  var pendingScopes = [];
134
134
  function createScope($global) {
135
135
  let scope = {
136
- g: 1,
136
+ f: 1,
137
137
  $global
138
138
  };
139
139
  return pendingScopes.push(scope), scope;
140
140
  }
141
141
  function finishPendingScopes() {
142
142
  for (let scope of pendingScopes)
143
- scope.g = 0;
143
+ scope.f = 0;
144
144
  pendingScopes = [];
145
145
  }
146
- var emptyScope = createScope({});
147
- function getEmptyScope(marker) {
148
- return emptyScope.a = emptyScope.c = marker, emptyScope;
146
+ var emptyBranch = createScope({});
147
+ function getEmptyBranch(marker) {
148
+ return emptyBranch.a = emptyBranch.c = marker, emptyBranch;
149
149
  }
150
150
  function destroyBranch(branch) {
151
- if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
152
- for (let scope of branch.n)
153
- for (let id in scope.h)
154
- scope.h[id]?.abort();
151
+ branch.n?.k?.delete(branch), destroyNestedBranches(branch);
152
+ }
153
+ function destroyNestedBranches(branch) {
154
+ branch.z = 1, branch.k?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
155
+ for (let id in scope.g)
156
+ scope.g[id]?.abort();
157
+ });
155
158
  }
156
159
  function removeAndDestroyBranch(branch) {
157
160
  destroyBranch(branch);
@@ -161,8 +164,8 @@ function removeAndDestroyBranch(branch) {
161
164
  current.remove(), current = next;
162
165
  }
163
166
  }
164
- function insertBefore(scope, parent, nextSibling) {
165
- let current = scope.a, stop = scope.c.nextSibling;
167
+ function insertBranchBefore(branch, parent, nextSibling) {
168
+ let current = branch.a, stop = branch.c.nextSibling;
166
169
  for (; current !== stop; ) {
167
170
  let next = current.nextSibling;
168
171
  parent.insertBefore(current, nextSibling), current = next;
@@ -235,7 +238,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
235
238
  if (newStart <= newEnd) {
236
239
  k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
237
240
  do
238
- insertBefore(newBranches[newStart++], parent, nextSibling);
241
+ insertBranchBefore(newBranches[newStart++], parent, nextSibling);
239
242
  while (newStart <= newEnd);
240
243
  }
241
244
  } else if (newStart > newEnd)
@@ -253,7 +256,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
253
256
  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);
254
257
  if (oldLength === oldBranches.length && synced === 0) {
255
258
  for (; newStart < newLength; ++newStart)
256
- insertBefore(newBranches[newStart], parent, afterReference);
259
+ insertBranchBefore(newBranches[newStart], parent, afterReference);
257
260
  for (; oldStart < oldLength; ++oldStart)
258
261
  removeAndDestroyBranch(oldBranches[oldStart]);
259
262
  } else {
@@ -262,10 +265,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
262
265
  if (pos === WRONG_POS) {
263
266
  let seq = longestIncreasingSubsequence(sources);
264
267
  for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
265
- sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : --j;
268
+ 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;
266
269
  } else if (synced !== newLength)
267
270
  for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
268
- sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling));
271
+ sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
269
272
  }
270
273
  }
271
274
  }
@@ -344,17 +347,17 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
344
347
  var registeredValues = {}, Render = class {
345
348
  o = [];
346
349
  p = {};
347
- z = {
350
+ B = {
348
351
  _: registeredValues
349
352
  };
350
353
  constructor(renders, runtimeId, renderId) {
351
- this.A = renders, this.B = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
354
+ this.C = renders, this.D = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
352
355
  }
353
356
  w() {
354
357
  this.s.w(), this.t();
355
358
  }
356
359
  t() {
357
- let data2 = this.s, serializeContext = this.z, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
360
+ let data2 = this.s, serializeContext = this.B, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
358
361
  if (visits.length) {
359
362
  let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
360
363
  data2.v = [];
@@ -376,15 +379,15 @@ var registeredValues = {}, Render = class {
376
379
  else if (token === "$" /* ClosestBranch */)
377
380
  closestBranchMarkers.set(scopeId, visit);
378
381
  else if (token === "[" /* BranchStart */)
379
- this.f && (dataIndex && branchEnd(this.f, visit, visit), this.o.push(this.f)), this.f = scopeId, scope.a = visit;
382
+ this.e && (dataIndex && branchEnd(this.e, visit, visit), this.o.push(this.e)), this.e = scopeId, scope.a = visit;
380
383
  else if (token === "]" /* BranchEnd */) {
381
384
  scope[data3] = visit;
382
385
  let curParent = visit.parentNode, startNode = branchEnd(
383
- this.f,
386
+ this.e,
384
387
  visit,
385
388
  visit
386
389
  ).a;
387
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.o.pop();
390
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.o.pop();
388
391
  } else if (token === "|" /* BranchSingleNode */) {
389
392
  let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
390
393
  for (; ~next; ) {
@@ -405,7 +408,7 @@ var registeredValues = {}, Render = class {
405
408
  let resumeData = resumes[i++];
406
409
  if (typeof resumeData == "function") {
407
410
  let scopes = resumeData(serializeContext), { $global } = scopeLookup;
408
- $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.q);
411
+ $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.D, $global.renderId = this.q);
409
412
  for (let scopeId in scopes)
410
413
  if (scopeId !== "$") {
411
414
  let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
@@ -416,10 +419,10 @@ var registeredValues = {}, Render = class {
416
419
  let parentBranchId = parentBranchIds.get(scopeId);
417
420
  if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
418
421
  let branch = scope, parentBranch = branch.b;
419
- scope.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch));
422
+ branch.h = +scopeId, scope.b = branch, parentBranch && (branch.n = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
420
423
  }
421
424
  }
422
- } else i === len || typeof resumes[i] != "string" ? delete this.A[this.q] : registeredValues[resumes[i++]](
425
+ } else i === len || typeof resumes[i] != "string" ? delete this.C[this.q] : registeredValues[resumes[i++]](
423
426
  scopeLookup[resumeData],
424
427
  scopeLookup[resumeData]
425
428
  );
@@ -457,7 +460,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
457
460
  }
458
461
  }
459
462
  function registerSubscriber(id, signal) {
460
- return register(id, signal.D), signal;
463
+ return register(id, signal.E), signal;
461
464
  }
462
465
  function nodeRef(id, key) {
463
466
  return register(id, (scope) => () => scope[key]);
@@ -871,7 +874,7 @@ function createBranchScopeWithRenderer(renderer, $global, parentScope) {
871
874
  renderer.u || parentScope,
872
875
  parentScope
873
876
  );
874
- return initRenderer(renderer, branch), branch;
877
+ return initBranch(renderer, branch), branch;
875
878
  }
876
879
  function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
877
880
  if (typeof tagNameOrRenderer != "string")
@@ -885,15 +888,15 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
885
888
  }
886
889
  function createBranch($global, ownerScope, parentScope) {
887
890
  let branch = createScope($global), parentBranch = parentScope.b;
888
- return branch._ = ownerScope, branch.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch)), branch;
891
+ 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;
889
892
  }
890
- function initRenderer(renderer, scope) {
893
+ function initBranch(renderer, branch) {
891
894
  let dom = renderer.l();
892
895
  return walk(
893
896
  dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
894
- renderer.E,
895
- scope
896
- ), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.c = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(scope, renderer.x), dom;
897
+ renderer.F,
898
+ branch
899
+ ), 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;
897
900
  }
898
901
  function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
899
902
  return (scope, attrsOrOp) => {
@@ -902,13 +905,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
902
905
  return;
903
906
  let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
904
907
  if (attrsOrOp === MARK || attrsOrOp === CLEAN)
905
- return renderer.e?.(childScope, attrsOrOp);
908
+ return renderer.d?.(childScope, attrsOrOp);
906
909
  let content = getContent?.(scope);
907
910
  if (typeof renderer == "string")
908
911
  setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
909
- else if (renderer.e) {
912
+ else if (renderer.d) {
910
913
  let attributes = attrsOrOp();
911
- renderer.e(
914
+ renderer.d(
912
915
  childScope,
913
916
  inputIsArgs ? attributes : [
914
917
  content ? {
@@ -924,13 +927,13 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
924
927
  let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
925
928
  return (owner) => ({
926
929
  j: id,
927
- F: template,
928
- E: walks,
930
+ G: template,
931
+ F: walks,
929
932
  x: setup,
930
933
  l: _clone,
931
934
  u: owner,
932
- G: void 0,
933
- get e() {
935
+ H: void 0,
936
+ get d() {
934
937
  return args ||= getArgs?.();
935
938
  }
936
939
  });
@@ -939,8 +942,8 @@ function createRenderer(template, walks, setup, getArgs) {
939
942
  return createRendererWithOwner(template, walks, setup, getArgs)();
940
943
  }
941
944
  function _clone() {
942
- return (this.G ||= parseHTMLOrSingleNode(
943
- this.F
945
+ return (this.H ||= parseHTMLOrSingleNode(
946
+ this.G
944
947
  )).cloneNode(!0);
945
948
  }
946
949
 
@@ -955,18 +958,18 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
955
958
  let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
956
959
  if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
957
960
  let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
958
- isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
961
+ isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
959
962
  }
960
963
  intersection2?.(scope, op);
961
964
  };
962
965
  };
963
966
  function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
964
- let newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0, prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyScope(scope[nodeAccessor]);
965
- insertBefore(
966
- newBranch || getEmptyScope(scope[nodeAccessor]),
967
+ let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
968
+ insertBranchBefore(
969
+ newBranch,
967
970
  prevBranch.a.parentNode,
968
971
  prevBranch.a
969
- ), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "(" /* ConditionalRenderer */] = newRenderer, scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
972
+ ), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
970
973
  }
971
974
  var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
972
975
  let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
@@ -986,12 +989,12 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
986
989
  };
987
990
  function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
988
991
  let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
989
- referenceNode.textContent = "", newBranch && insertBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
992
+ referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
990
993
  }
991
994
  var emptyMarkerMap = /* @__PURE__ */ new Map([
992
- [Symbol(), getEmptyScope(void 0)]
995
+ [Symbol(), getEmptyBranch(void 0)]
993
996
  ]), emptyMarkerArray = [
994
- /* @__PURE__ */ getEmptyScope(void 0)
997
+ /* @__PURE__ */ getEmptyBranch(void 0)
995
998
  ], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
996
999
  function loopOf(nodeAccessor, renderer) {
997
1000
  return loop(
@@ -1020,7 +1023,7 @@ function loopTo(nodeAccessor, renderer) {
1020
1023
  );
1021
1024
  }
1022
1025
  function loop(nodeAccessor, renderer, forEach) {
1023
- let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.e;
1026
+ let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
1024
1027
  return (scope, valueOrOp) => {
1025
1028
  if (valueOrOp === DIRTY) return;
1026
1029
  if (valueOrOp === MARK || valueOrOp === CLEAN) {
@@ -1034,9 +1037,9 @@ function loop(nodeAccessor, renderer, forEach) {
1034
1037
  if (forEach(valueOrOp, (key, args) => {
1035
1038
  let branch = oldMap.get(key);
1036
1039
  branch || (branch = createBranchScopeWithRenderer(renderer, scope.$global, scope)), params && params(branch, args), newMap ? (newMap.set(key, branch), newArray.push(branch)) : (newMap = /* @__PURE__ */ new Map([[key, branch]]), newArray = [branch]);
1037
- }), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyScope(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
1040
+ }), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyBranch(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
1038
1041
  if (referenceIsMarker) {
1039
- oldMap === emptyMarkerMap && getEmptyScope(referenceNode);
1042
+ oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
1040
1043
  let oldLastChild = oldArray[oldArray.length - 1];
1041
1044
  afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
1042
1045
  } else
@@ -1094,24 +1097,24 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
1094
1097
  let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
1095
1098
  if (loopScopes !== emptyMarkerArray)
1096
1099
  for (let scope of loopScopes)
1097
- scope.g || queueSource(scope, signal, value2);
1100
+ scope.f || queueSource(scope, signal, value2);
1098
1101
  };
1099
1102
  return helperSignal._ = signal, helperSignal;
1100
1103
  }
1101
1104
  function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
1102
1105
  let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
1103
1106
  let conditionalScope = scope[scopeAccessor];
1104
- conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1107
+ conditionalScope && !conditionalScope.f && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1105
1108
  };
1106
1109
  return helperSignal._ = signal, helperSignal;
1107
1110
  }
1108
1111
  var defaultGetOwnerScope = (scope) => scope._;
1109
- function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
1110
- let ownerSubscribersAccessor = ownerValueAccessor + "*" /* Subscribers */, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
1112
+ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
1113
+ let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
1111
1114
  let subscribers = ownerScope[ownerSubscribersAccessor];
1112
1115
  if (subscribers)
1113
1116
  for (let subscriber of subscribers)
1114
- subscriber.g || queueSource(subscriber, _signal, value2);
1117
+ subscriber.f || queueSource(subscriber, _signal, value2);
1115
1118
  }, setupSignal = (scope, value2) => {
1116
1119
  _signal(scope, value2), subscribe(scope);
1117
1120
  }, subscribe = (scope) => {
@@ -1119,7 +1122,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
1119
1122
  getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
1120
1123
  });
1121
1124
  };
1122
- return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
1125
+ return helperSignal._ = setupSignal, helperSignal.E = subscribe, helperSignal;
1123
1126
  }
1124
1127
  function setTagVar(scope, childAccessor, tagVarSignal2) {
1125
1128
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
@@ -1152,29 +1155,25 @@ function effect(id, fn) {
1152
1155
  }
1153
1156
 
1154
1157
  // src/dom/queue.ts
1155
- var pendingRender, pendingEffects = [], rendering = !1;
1158
+ var pendingRenders = [], pendingEffects = [], rendering = !1;
1156
1159
  function queueSource(scope, signal, value2) {
1157
1160
  schedule();
1158
1161
  let prevRendering = rendering;
1159
1162
  return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
1160
1163
  }
1161
1164
  function queueRender(scope, signal, value2) {
1162
- let nextRender = {
1163
- k: scope,
1164
- H: signal,
1165
- I: value2,
1166
- d: void 0
1165
+ let i = pendingRenders.length, render = {
1166
+ m: scope,
1167
+ I: signal,
1168
+ J: value2,
1169
+ y: i
1167
1170
  };
1168
- if (!pendingRender)
1169
- pendingRender = nextRender;
1170
- else if (comparePendingRenders(pendingRender, nextRender) < 0)
1171
- nextRender.d = pendingRender, pendingRender = nextRender;
1172
- else {
1173
- let curRender = pendingRender;
1174
- for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
1175
- curRender = curRender.d;
1176
- nextRender.d = curRender.d, curRender.d = nextRender;
1171
+ for (pendingRenders.push(render); i; ) {
1172
+ let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1173
+ if (comparePendingRenders(render, parent) >= 0) break;
1174
+ pendingRenders[i] = parent, i = parentIndex;
1177
1175
  }
1176
+ pendingRenders[i] = render;
1178
1177
  }
1179
1178
  function queueEffect(scope, fn) {
1180
1179
  pendingEffects.push(scope, fn);
@@ -1184,17 +1183,17 @@ function run() {
1184
1183
  try {
1185
1184
  rendering = !0, runRenders();
1186
1185
  } finally {
1187
- pendingRender = void 0, rendering = !1;
1186
+ pendingRenders = [], pendingEffects = [], rendering = !1;
1188
1187
  }
1189
- pendingEffects = [], runEffects(effects);
1188
+ runEffects(effects);
1190
1189
  }
1191
1190
  function prepareEffects(fn) {
1192
- let prevRender = pendingRender, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1193
- pendingRender = void 0;
1191
+ let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1192
+ pendingRenders = [];
1194
1193
  try {
1195
1194
  rendering = !0, fn(), runRenders();
1196
1195
  } finally {
1197
- rendering = !1, pendingRender = prevRender, pendingEffects = prevEffects;
1196
+ rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
1198
1197
  }
1199
1198
  return preparedEffects;
1200
1199
  }
@@ -1205,25 +1204,39 @@ function runEffects(effects = pendingEffects) {
1205
1204
  }
1206
1205
  }
1207
1206
  function runRenders() {
1208
- for (; pendingRender; )
1209
- pendingRender.k.b?.y || pendingRender.H(pendingRender.k, pendingRender.I), pendingRender = pendingRender.d;
1207
+ for (; pendingRenders.length; ) {
1208
+ let render = pendingRenders[0], next = pendingRenders.pop();
1209
+ if (render !== next) {
1210
+ let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
1211
+ for (; i < mid; ) {
1212
+ let bestChild = (i << 1) + 1, right = bestChild + 1;
1213
+ if (right < pendingRenders.length && comparePendingRenders(
1214
+ pendingRenders[right],
1215
+ pendingRenders[bestChild]
1216
+ ) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
1217
+ break;
1218
+ pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1219
+ }
1220
+ pendingRenders[i] = item;
1221
+ }
1222
+ render.m.b?.z || render.I(render.m, render.J);
1223
+ }
1210
1224
  finishPendingScopes();
1211
1225
  }
1212
1226
  function comparePendingRenders(a, b) {
1213
- let aStart = ownerStartNode(a.k), bStart = ownerStartNode(b.k);
1214
- return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
1227
+ return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
1215
1228
  }
1216
- function ownerStartNode(scope) {
1217
- return (scope.b || scope).a;
1229
+ function getBranchDepth(render) {
1230
+ return render.m.b?.h || 0;
1218
1231
  }
1219
1232
 
1220
1233
  // src/dom/abort-signal.ts
1221
1234
  function resetAbortSignal(scope, id) {
1222
- let ctrl = scope.h?.[id];
1223
- ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
1235
+ let ctrl = scope.g?.[id];
1236
+ ctrl && (queueEffect(ctrl, abort), scope.g[id] = void 0);
1224
1237
  }
1225
1238
  function getAbortSignal(scope, id) {
1226
- return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1239
+ return scope.b && (scope.b.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.g ||= {})[id] ||= new AbortController()).signal;
1227
1240
  }
1228
1241
  function abort(ctrl) {
1229
1242
  ctrl.abort();
@@ -1278,14 +1291,14 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1278
1291
  render(out, component, renderer, args) {
1279
1292
  let scope = component.scope;
1280
1293
  scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
1281
- let applyArgs = renderer.e || noop, existing = !1;
1294
+ let applyArgs = renderer.d || noop, existing = !1;
1282
1295
  if (typeof args[0] == "object" && "renderBody" in args[0]) {
1283
1296
  let input = args[0], normalizedInput = args[0] = {};
1284
1297
  for (let key in input)
1285
1298
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1286
1299
  }
1287
1300
  if (component.effects = prepareEffects(() => {
1288
- scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initRenderer(renderer, scope)), applyArgs(scope, args);
1301
+ scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initBranch(renderer, scope)), applyArgs(scope, args);
1289
1302
  }), !existing)
1290
1303
  return scope.a === scope.c ? scope.a : scope.a.parentNode;
1291
1304
  }
@@ -1299,33 +1312,29 @@ var createTemplate = (templateId, ...rendererArgs) => {
1299
1312
  return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
1300
1313
  };
1301
1314
  function mount(input = {}, reference, position) {
1302
- let branch, dom, { $global } = input;
1303
- $global ? ({ $global, ...input } = input, $global = {
1315
+ let branch, dom, parentNode = reference, nextSibling = null, { $global } = input;
1316
+ switch ($global ? ({ $global, ...input } = input, $global = {
1304
1317
  runtimeId: DEFAULT_RUNTIME_ID,
1305
1318
  renderId: DEFAULT_RENDER_ID,
1306
1319
  ...$global
1307
1320
  }) : $global = {
1308
1321
  runtimeId: DEFAULT_RUNTIME_ID,
1309
1322
  renderId: DEFAULT_RENDER_ID
1310
- };
1311
- let args = this.e, effects = prepareEffects(() => {
1312
- branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
1313
- });
1314
- switch (position) {
1323
+ }, position) {
1315
1324
  case "beforebegin":
1316
- reference.parentNode.insertBefore(dom, reference);
1325
+ parentNode = reference.parentNode, nextSibling = reference;
1317
1326
  break;
1318
1327
  case "afterbegin":
1319
- reference.insertBefore(dom, reference.firstChild);
1328
+ nextSibling = reference.firstChild;
1320
1329
  break;
1321
1330
  case "afterend":
1322
- reference.parentNode.insertBefore(dom, reference.nextSibling);
1323
- break;
1324
- default:
1325
- reference.appendChild(dom);
1331
+ parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1326
1332
  break;
1327
1333
  }
1328
- return runEffects(effects), {
1334
+ let args = this.d, effects = prepareEffects(() => {
1335
+ branch = createScope($global), dom = initBranch(this, branch), args?.(branch, [input]);
1336
+ });
1337
+ return parentNode.insertBefore(dom, nextSibling), runEffects(effects), {
1329
1338
  update: (newInput) => {
1330
1339
  args && runEffects(
1331
1340
  prepareEffects(() => {