marko 6.0.0-next.3.38 → 6.0.0-next.3.39

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
@@ -28,23 +28,6 @@ function forTo(to, from, step, cb) {
28
28
  cb(start + i * delta);
29
29
  }
30
30
 
31
- // src/dom/schedule.ts
32
- var port2 = /* @__PURE__ */ (() => {
33
- let { port1, port2: port22 } = new MessageChannel();
34
- return port1.onmessage = () => {
35
- isScheduled = !1, run();
36
- }, port22;
37
- })(), isScheduled;
38
- function schedule() {
39
- isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
40
- }
41
- function flushAndWaitFrame() {
42
- run(), requestAnimationFrame(triggerMacroTask);
43
- }
44
- function triggerMacroTask() {
45
- port2.postMessage(0);
46
- }
47
-
48
31
  // src/common/helpers.ts
49
32
  function classValue(value2) {
50
33
  return toDelimitedString(value2, " ", stringifyClassObject);
@@ -141,19 +124,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
141
124
 
142
125
  // src/dom/resume.ts
143
126
  var registeredValues = {}, Render = class {
144
- m = [];
145
- n = {};
146
- A = {
127
+ l = [];
128
+ m = {};
129
+ C = {
147
130
  _: registeredValues
148
131
  };
149
132
  constructor(renders, runtimeId, renderId) {
150
- this.B = renders, this.C = runtimeId, this.o = renderId, this.p = renders[renderId], this.q();
133
+ this.D = renders, this.E = runtimeId, this.n = renderId, this.o = renders[renderId], this.p();
151
134
  }
152
135
  w() {
153
- this.p.w(), this.q();
136
+ this.o.w(), this.p();
154
137
  }
155
- q() {
156
- let data2 = this.p, serializeContext = this.A, scopeLookup = this.n, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
138
+ p() {
139
+ let data2 = this.o, serializeContext = this.C, scopeLookup = this.m, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
157
140
  if (visits.length) {
158
141
  let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
159
142
  data2.v = [];
@@ -175,7 +158,7 @@ var registeredValues = {}, Render = class {
175
158
  else if (token === "$" /* ClosestBranch */)
176
159
  closestBranchMarkers.set(scopeId, visit);
177
160
  else if (token === "[" /* BranchStart */)
178
- this.e && (dataIndex && branchEnd(this.e, visit, visit), this.m.push(this.e)), this.e = scopeId, scope.a = visit;
161
+ this.e && (dataIndex && branchEnd(this.e, visit, visit), this.l.push(this.e)), this.e = scopeId, scope.a = visit;
179
162
  else if (token === "]" /* BranchEnd */) {
180
163
  scope[data3] = visit;
181
164
  let curParent = visit.parentNode, startNode = branchEnd(
@@ -183,7 +166,7 @@ var registeredValues = {}, Render = class {
183
166
  visit,
184
167
  visit
185
168
  ).a;
186
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.m.pop();
169
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.l.pop();
187
170
  } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
188
171
  let next = data3.indexOf(" "), curNode = visit;
189
172
  for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
@@ -204,7 +187,7 @@ var registeredValues = {}, Render = class {
204
187
  let resumeData = resumes[i++];
205
188
  if (typeof resumeData == "function") {
206
189
  let scopes = resumeData(serializeContext), { $global } = scopeLookup;
207
- $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.o);
190
+ $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.E, $global.renderId = this.n);
208
191
  for (let scopeId in scopes)
209
192
  if (scopeId !== "$") {
210
193
  let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
@@ -215,10 +198,10 @@ var registeredValues = {}, Render = class {
215
198
  let parentBranchId = parentBranchIds.get(scopeId);
216
199
  if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
217
200
  let branch = scope, parentBranch = branch.c;
218
- branch.f = +scopeId, scope.c = branch, parentBranch && (branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
201
+ branch.f = +scopeId, scope.c = branch, parentBranch && (branch.q = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
219
202
  }
220
203
  }
221
- } else i === len || typeof resumes[i] != "string" ? delete this.B[this.o] : registeredValues[resumes[i++]](
204
+ } else i === len || typeof resumes[i] != "string" ? delete this.D[this.n] : registeredValues[resumes[i++]](
222
205
  scopeLookup[resumeData],
223
206
  scopeLookup[resumeData]
224
207
  );
@@ -255,9 +238,6 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
255
238
  });
256
239
  }
257
240
  }
258
- function registerSubscriber(id, signal) {
259
- return register(id, signal.D), signal;
260
- }
261
241
  function nodeRef(id, key) {
262
242
  return register(id, (scope) => () => scope[key]);
263
243
  }
@@ -640,9 +620,10 @@ function toInsertNode(startNode, endNode) {
640
620
 
641
621
  // src/dom/scope.ts
642
622
  var pendingScopes = [];
643
- function createScope($global) {
623
+ function createScope($global, closestBranch) {
644
624
  let scope = {
645
625
  g: 1,
626
+ c: closestBranch,
646
627
  $global
647
628
  };
648
629
  return pendingScopes.push(scope), scope;
@@ -657,10 +638,10 @@ function getEmptyBranch(marker) {
657
638
  return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
658
639
  }
659
640
  function destroyBranch(branch) {
660
- branch.s?.j?.delete(branch), destroyNestedBranches(branch);
641
+ branch.q?.j?.delete(branch), destroyNestedBranches(branch);
661
642
  }
662
643
  function destroyNestedBranches(branch) {
663
- branch.E = 1, branch.j?.forEach(destroyNestedBranches), branch.F?.forEach((scope) => {
644
+ branch.F = 1, branch.j?.forEach(destroyNestedBranches), branch.G?.forEach((scope) => {
664
645
  for (let id in scope.h)
665
646
  scope.h[id]?.abort();
666
647
  });
@@ -762,9 +743,9 @@ function trimWalkString(walkString) {
762
743
  return walkString.slice(0, end + 1);
763
744
  }
764
745
  function walk(startNode, walkCodes, branch) {
765
- walker.currentNode = startNode, walkInternal(walkCodes, branch, 0), walker.currentNode = document;
746
+ walker.currentNode = startNode, walkInternal(0, walkCodes, branch), walker.currentNode = document;
766
747
  }
767
- function walkInternal(walkCodes, scope, currentWalkIndex) {
748
+ function walkInternal(currentWalkIndex, walkCodes, scope) {
768
749
  let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
769
750
  for (; value2 = walkCodes.charCodeAt(currentWalkIndex++); )
770
751
  if (currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 >= 117 /* Multiplier */)
@@ -779,10 +760,13 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
779
760
  else if (value2 >= 67 /* Next */)
780
761
  for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
781
762
  walker.nextNode();
782
- else if (value2 === 47 /* BeginChild */) {
783
- let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
784
- childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
785
- } else {
763
+ else if (value2 === 47 /* BeginChild */)
764
+ currentWalkIndex = walkInternal(
765
+ currentWalkIndex,
766
+ walkCodes,
767
+ scope[currentScopeIndex++] = createScope(scope.$global, scope.c)
768
+ );
769
+ else {
786
770
  if (value2 === 38 /* EndChild */)
787
771
  return currentWalkIndex;
788
772
  if (value2 === 32 /* Get */)
@@ -799,7 +783,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
799
783
  function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
800
784
  let branch = createBranch(
801
785
  $global,
802
- renderer.t || parentScope,
786
+ renderer.s || parentScope,
803
787
  parentScope
804
788
  );
805
789
  return initBranch(renderer, branch, parentNode), branch;
@@ -820,11 +804,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
820
804
  }
821
805
  function createBranch($global, ownerScope, parentScope) {
822
806
  let branch = createScope($global), parentBranch = parentScope.c;
823
- return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
807
+ return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.q = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
824
808
  }
825
809
  function initBranch(renderer, branch, parentNode) {
826
810
  let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
827
- walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.u && queueRender(branch, renderer.u);
811
+ cloneParent ? (walk(cloneParent.firstChild, renderer.t, branch), branch.a = cloneParent.firstChild, branch.b = cloneParent.lastChild) : (walk(clone, renderer.t, branch), branch.a = branch.b = clone), renderer.u && queueRender(branch, renderer.u);
828
812
  }
829
813
  function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
830
814
  return (scope, attrsOrOp) => {
@@ -861,10 +845,10 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
861
845
  return (owner) => ({
862
846
  x: id,
863
847
  y: template,
864
- G: walks,
848
+ t: walks,
865
849
  u: setup,
866
850
  k: _clone,
867
- t: owner,
851
+ s: owner,
868
852
  get d() {
869
853
  return args ||= getArgs?.();
870
854
  }
@@ -998,6 +982,23 @@ function isDifferentRenderer(a, b) {
998
982
  return a !== b && (a?.x || 0) !== b?.x;
999
983
  }
1000
984
 
985
+ // src/dom/schedule.ts
986
+ var port2 = /* @__PURE__ */ (() => {
987
+ let { port1, port2: port22 } = new MessageChannel();
988
+ return port1.onmessage = () => {
989
+ isScheduled = !1, run();
990
+ }, port22;
991
+ })(), isScheduled;
992
+ function schedule() {
993
+ isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
994
+ }
995
+ function flushAndWaitFrame() {
996
+ run(), requestAnimationFrame(triggerMacroTask);
997
+ }
998
+ function triggerMacroTask() {
999
+ port2.postMessage(0);
1000
+ }
1001
+
1001
1002
  // src/dom/signals.ts
1002
1003
  var MARK = {}, CLEAN = {}, DIRTY = {};
1003
1004
  function state(valueAccessor, fn, getIntersection) {
@@ -1005,63 +1006,81 @@ function state(valueAccessor, fn, getIntersection) {
1005
1006
  return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
1006
1007
  scope,
1007
1008
  valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
1008
- ) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
1009
+ ) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : (schedule(), queueSource(scope, valueSignal, valueOrOp)), valueOrOp);
1009
1010
  }
1010
1011
  function value(valueAccessor, fn, getIntersection) {
1011
- let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
1012
+ let markAccessor = valueAccessor + "#" /* Mark */, intersection2;
1012
1013
  return (scope, valueOrOp) => {
1013
1014
  if (valueOrOp === MARK)
1014
- (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
1015
+ (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
1015
1016
  else if (valueOrOp !== DIRTY) {
1016
1017
  let existing = scope[markAccessor] !== void 0;
1017
- (scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? intersection2?.(scope, CLEAN) : (scope[valueAccessor] = valueOrOp, fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY))), scope[markAccessor]--;
1018
+ (scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN) : (scope[valueAccessor] = valueOrOp, fn && fn(scope, valueOrOp), getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY))), scope[markAccessor]--;
1018
1019
  }
1019
1020
  };
1020
1021
  }
1021
1022
  var accessorId = 0;
1022
1023
  function intersection(count, fn, getIntersection) {
1023
- let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
1024
+ let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2;
1024
1025
  return (scope, op) => {
1025
- op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK) : scope[markAccessor] === void 0 ? (scope[markAccessor] = count - 1, scope[dirtyAccessor] = !0) : --scope[markAccessor] === 0 ? op === DIRTY || scope[dirtyAccessor] ? (scope[dirtyAccessor] = !1, fn(scope, 0), intersection2?.(scope, DIRTY)) : intersection2?.(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
1026
+ op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && getIntersection && (intersection2 ||= getIntersection())(scope, MARK) : scope[markAccessor] === void 0 ? (scope[markAccessor] = count - 1, scope[dirtyAccessor] = !0) : --scope[markAccessor] === 0 ? op === DIRTY || scope[dirtyAccessor] ? (scope[dirtyAccessor] = !1, fn(scope), getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY)) : getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
1026
1027
  };
1027
1028
  }
1028
- function closure(fn, getIntersection) {
1029
- let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
1030
- return (scope, valueOrOp) => {
1031
- valueOrOp === MARK ? intersection2?.(scope, MARK) : (fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY));
1032
- };
1033
- }
1034
- function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
1035
- let signal = closure(fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, helperSignal = (ownerScope, value2) => {
1029
+ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn, getIntersection) {
1030
+ let childSignal = closure(valueAccessor, fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, ownerSignal = (ownerScope) => {
1036
1031
  let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
1037
1032
  if (loopScopes !== emptyMarkerArray)
1038
1033
  for (let scope of loopScopes)
1039
- scope.g || queueSource(scope, signal, value2);
1034
+ scope.g || queueSource(scope, childSignal);
1040
1035
  };
1041
- return helperSignal._ = signal, helperSignal;
1036
+ return ownerSignal._ = childSignal, ownerSignal;
1042
1037
  }
1043
- function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
1044
- let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
1038
+ function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn, getIntersection) {
1039
+ let childSignal = closure(valueAccessor, fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, ownerSignal = (scope) => {
1045
1040
  let ifScope = scope[scopeAccessor];
1046
- ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, signal, value2);
1041
+ ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, childSignal);
1047
1042
  };
1048
- return helperSignal._ = signal, helperSignal;
1049
- }
1050
- var defaultGetOwnerScope = (scope) => scope._;
1051
- function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
1052
- let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
1053
- let subscribers = ownerScope[ownerSubscribersAccessor];
1043
+ return ownerSignal._ = childSignal, ownerSignal;
1044
+ }
1045
+ function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
1046
+ let subscribersAccessor = "?" /* Dynamic */ + accessorId++, childSignal = closure(
1047
+ valueAccessor,
1048
+ fn,
1049
+ getIntersection,
1050
+ getOwnerScope
1051
+ ), ownerSignal = (ownerScope) => {
1052
+ let subscribers = ownerScope[subscribersAccessor];
1054
1053
  if (subscribers)
1055
1054
  for (let subscriber of subscribers)
1056
- subscriber.g || queueSource(subscriber, _signal, value2);
1057
- }, setupSignal = (scope, value2) => {
1058
- _signal(scope, value2), subscribe(scope);
1055
+ subscriber.g || queueSource(subscriber, childSignal);
1059
1056
  }, subscribe = (scope) => {
1060
- (getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope), getAbortSignal(scope, -1).addEventListener("abort", () => {
1061
- getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
1062
- });
1057
+ let owner = getOwnerScope ? getOwnerScope(scope) : scope._, subscribers = owner[subscribersAccessor] ||= /* @__PURE__ */ new Set();
1058
+ subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
1059
+ "abort",
1060
+ () => owner[subscribersAccessor].delete(scope)
1061
+ ));
1062
+ };
1063
+ return ownerSignal.H = subscribe, ownerSignal._ = (scope) => {
1064
+ childSignal(scope), subscribe(scope);
1065
+ }, ownerSignal;
1066
+ }
1067
+ function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
1068
+ let signal = dynamicClosure(
1069
+ valueAccessor,
1070
+ fn,
1071
+ getIntersection,
1072
+ getOwnerScope
1073
+ );
1074
+ return register(id, signal.H), signal;
1075
+ }
1076
+ function closure(valueAccessor, fn, getIntersection, getOwnerScope) {
1077
+ let intersection2;
1078
+ return (scope, op) => {
1079
+ op || fn && fn(
1080
+ scope,
1081
+ (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
1082
+ ), getIntersection && (intersection2 ||= getIntersection())(scope, op ? MARK : DIRTY);
1063
1083
  };
1064
- return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
1065
1084
  }
1066
1085
  function setTagVar(scope, childAccessor, tagVarSignal2) {
1067
1086
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
@@ -1096,16 +1115,16 @@ function effect(id, fn) {
1096
1115
  // src/dom/queue.ts
1097
1116
  var pendingRenders = [], pendingEffects = [], rendering = !1;
1098
1117
  function queueSource(scope, signal, value2) {
1099
- schedule();
1100
1118
  let prevRendering = rendering;
1101
- return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
1119
+ rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2);
1102
1120
  }
1103
1121
  function queueRender(scope, signal, value2) {
1104
1122
  let i = pendingRenders.length, render = {
1105
- l: scope,
1106
- H: signal,
1107
- I: value2,
1108
- z: i
1123
+ z: scope,
1124
+ I: signal,
1125
+ J: value2,
1126
+ A: scope.c?.f || 0,
1127
+ B: i
1109
1128
  };
1110
1129
  for (pendingRenders.push(render); i; ) {
1111
1130
  let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
@@ -1136,7 +1155,7 @@ function prepareEffects(fn) {
1136
1155
  }
1137
1156
  return preparedEffects;
1138
1157
  }
1139
- function runEffects(effects = pendingEffects) {
1158
+ function runEffects(effects) {
1140
1159
  for (let i = 0; i < effects.length; i += 2 /* Total */) {
1141
1160
  let scope = effects[i], fn = effects[i + 1];
1142
1161
  fn(scope, scope);
@@ -1158,15 +1177,12 @@ function runRenders() {
1158
1177
  }
1159
1178
  pendingRenders[i] = item;
1160
1179
  }
1161
- render.l.c?.E || render.H(render.l, render.I);
1180
+ render.z.c?.F || render.I(render.z, render.J);
1162
1181
  }
1163
1182
  finishPendingScopes();
1164
1183
  }
1165
1184
  function comparePendingRenders(a, b) {
1166
- return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
1167
- }
1168
- function getBranchDepth(render) {
1169
- return render.l.c?.f || 0;
1185
+ return a.A - b.A || a.B - b.B;
1170
1186
  }
1171
1187
 
1172
1188
  // src/dom/abort-signal.ts
@@ -1175,7 +1191,7 @@ function resetAbortSignal(scope, id) {
1175
1191
  ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
1176
1192
  }
1177
1193
  function getAbortSignal(scope, id) {
1178
- return scope.c && (scope.c.F ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1194
+ return scope.c && (scope.c.G ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1179
1195
  }
1180
1196
  function abort(ctrl) {
1181
1197
  ctrl.abort();
@@ -1220,7 +1236,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1220
1236
  }) {
1221
1237
  return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
1222
1238
  value2[0],
1223
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.n[value2[1]]
1239
+ value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.m[value2[1]]
1224
1240
  ) : value2;
1225
1241
  },
1226
1242
  createRenderer(setup, clone, args) {
@@ -1237,7 +1253,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1237
1253
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1238
1254
  }
1239
1255
  if (component.effects = prepareEffects(() => {
1240
- branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.t, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
1256
+ branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.s, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
1241
1257
  }), !existing)
1242
1258
  return toInsertNode(branch.a, branch.b);
1243
1259
  }
@@ -1279,14 +1295,14 @@ function mount(input = {}, reference, position) {
1279
1295
  branch.a,
1280
1296
  branch.b
1281
1297
  ), runEffects(effects), {
1282
- update: (newInput) => {
1298
+ update(newInput) {
1283
1299
  args && runEffects(
1284
1300
  prepareEffects(() => {
1285
1301
  args(branch, MARK), args(branch, [newInput]);
1286
1302
  })
1287
1303
  );
1288
1304
  },
1289
- destroy: () => {
1305
+ destroy() {
1290
1306
  removeAndDestroyBranch(branch);
1291
1307
  }
1292
1308
  };
@@ -1342,7 +1358,7 @@ export {
1342
1358
  props,
1343
1359
  register,
1344
1360
  registerBoundSignal,
1345
- registerSubscriber,
1361
+ registerDynamicClosure,
1346
1362
  resetAbortSignal,
1347
1363
  run,
1348
1364
  setTagVar,
@@ -2084,13 +2084,26 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2084
2084
  scopeIdentifier,
2085
2085
  import_compiler17.types.identifier(referencedBindings.name)
2086
2086
  ]);
2087
- signal.isDynamicClosure = isDynamicClosure;
2088
2087
  const intersection = buildSignalIntersections(signal);
2089
- return isDynamicClosure ? callRuntime(
2088
+ return isDynamicClosure ? isStatefulReferences(referencedBindings) ? callRuntime(
2089
+ "registerDynamicClosure",
2090
+ import_compiler17.types.stringLiteral(
2091
+ getResumeRegisterId(
2092
+ section,
2093
+ signal.referencedBindings,
2094
+ "subscriber"
2095
+ )
2096
+ ),
2097
+ getScopeAccessorLiteral(referencedBindings),
2098
+ render,
2099
+ intersection,
2100
+ isImmediateOwner ? void 0 : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope)
2101
+ ) : callRuntime(
2090
2102
  "dynamicClosure",
2103
+ getScopeAccessorLiteral(referencedBindings),
2091
2104
  render,
2092
- isImmediateOwner ? null : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope),
2093
- intersection
2105
+ intersection,
2106
+ isImmediateOwner ? void 0 : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope)
2094
2107
  ) : builder(signal, render, intersection);
2095
2108
  };
2096
2109
  addStatement(
@@ -2100,10 +2113,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2100
2113
  import_compiler17.types.expressionStatement(
2101
2114
  import_compiler17.types.callExpression(
2102
2115
  import_compiler17.types.memberExpression(signal.identifier, import_compiler17.types.identifier("_")),
2103
- [
2104
- scopeIdentifier,
2105
- createScopeReadExpression(section, referencedBindings)
2106
- ]
2116
+ [scopeIdentifier]
2107
2117
  )
2108
2118
  )
2109
2119
  );
@@ -2191,10 +2201,7 @@ function getSignalFn(signal, params, referencedBindings) {
2191
2201
  if (isStatefulReferences(closureSignal.referencedBindings)) {
2192
2202
  signal.render.push(
2193
2203
  import_compiler17.types.expressionStatement(
2194
- import_compiler17.types.callExpression(closureSignal.identifier, [
2195
- scopeIdentifier2,
2196
- valueIdentifier
2197
- ])
2204
+ import_compiler17.types.callExpression(closureSignal.identifier, [scopeIdentifier2])
2198
2205
  )
2199
2206
  );
2200
2207
  }
@@ -2288,7 +2295,7 @@ function generateSignalName(referencedBindings) {
2288
2295
  return name2;
2289
2296
  }
2290
2297
  function finalizeSignalArgs(args) {
2291
- for (let i = args.length - 1; i >= 0; i--) {
2298
+ for (let i = args.length; i--; ) {
2292
2299
  const arg = args[i];
2293
2300
  if (import_compiler17.types.isArrowFunctionExpression(arg) && import_compiler17.types.isBlockStatement(arg.body)) {
2294
2301
  const body = arg.body.body;
@@ -2297,9 +2304,11 @@ function finalizeSignalArgs(args) {
2297
2304
  } else if (body.length === 1 && import_compiler17.types.isExpressionStatement(body[0])) {
2298
2305
  arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
2299
2306
  }
2307
+ } else if (import_compiler17.types.isNullLiteral(arg) || import_compiler17.types.isUnaryExpression(arg) && arg.operator === "void") {
2308
+ args[i] = import_compiler17.types.numericLiteral(0);
2300
2309
  }
2301
2310
  }
2302
- for (let i = args.length - 1; import_compiler17.types.isNullLiteral(args[i]); ) {
2311
+ for (let i = args.length - 1; import_compiler17.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
2303
2312
  args.length = i--;
2304
2313
  }
2305
2314
  }
@@ -2437,15 +2446,6 @@ function writeSignals(section) {
2437
2446
  value
2438
2447
  );
2439
2448
  }
2440
- if (signal.isDynamicClosure && isStatefulReferences(signal.referencedBindings)) {
2441
- value = callRuntime(
2442
- "registerSubscriber",
2443
- import_compiler17.types.stringLiteral(
2444
- getResumeRegisterId(section, signal.referencedBindings, "subscriber")
2445
- ),
2446
- value
2447
- );
2448
- }
2449
2449
  const signalDeclarator = import_compiler17.types.variableDeclarator(signal.identifier, value);
2450
2450
  let signalDeclaration = !section.parent && !signal.referencedBindings && (import_compiler17.types.isFunctionExpression(value) || import_compiler17.types.isArrowFunctionExpression(value)) ? import_compiler17.types.functionDeclaration(
2451
2451
  signal.identifier,
@@ -3973,7 +3973,7 @@ function isStatefulBinding(binding) {
3973
3973
  case 2 /* input */:
3974
3974
  return true;
3975
3975
  default:
3976
- return !binding.upstreamExpression || isStatefulReferences(binding.upstreamExpression.referencedBindings);
3976
+ return binding.upstreamAlias ? isStatefulBinding(binding.upstreamAlias) : !binding.upstreamExpression || isStatefulReferences(binding.upstreamExpression.referencedBindings);
3977
3977
  }
3978
3978
  }
3979
3979
 
@@ -5265,9 +5265,12 @@ var for_default = {
5265
5265
  const tagExtra = node.extra;
5266
5266
  const { referencedBindings } = tagExtra;
5267
5267
  const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
5268
- setClosureSignalBuilder(tag, (_closureSignal, render, intersection) => {
5268
+ setClosureSignalBuilder(tag, (closureSignal, render, intersection) => {
5269
5269
  return callRuntime(
5270
5270
  "loopClosure",
5271
+ getScopeAccessorLiteral(
5272
+ closureSignal.referencedBindings
5273
+ ),
5271
5274
  getScopeAccessorLiteral(nodeRef2),
5272
5275
  render,
5273
5276
  intersection
@@ -7150,9 +7153,12 @@ var IfTag = {
7150
7153
  rendererIdentifiers.push(import_compiler39.types.identifier(branchBodySection.name));
7151
7154
  setClosureSignalBuilder(
7152
7155
  branchTag,
7153
- (_closureSignal, render, intersection) => {
7156
+ (closureSignal, render, intersection) => {
7154
7157
  return callRuntime(
7155
7158
  "conditionalClosure",
7159
+ getScopeAccessorLiteral(
7160
+ closureSignal.referencedBindings
7161
+ ),
7156
7162
  getScopeAccessorLiteral(nodeRef2),
7157
7163
  import_compiler39.types.numericLiteral(i),
7158
7164
  render,
@@ -2,8 +2,6 @@ import { types as t } from "@marko/compiler";
2
2
  import { type Opt } from "./optional";
3
3
  import { type Binding, type ReferencedBindings } from "./references";
4
4
  import { type Section } from "./sections";
5
- export type closureSignalBuilder = (signal: Signal, render: t.Expression, intersection?: t.Expression) => t.Expression;
6
- export type registerScopeBuilder = (scope: t.Expression) => t.Expression;
7
5
  export type Signal = {
8
6
  identifier: t.Identifier;
9
7
  valueAccessor?: t.Expression;
@@ -11,7 +9,6 @@ export type Signal = {
11
9
  section: Section;
12
10
  build: () => t.Expression;
13
11
  register?: boolean;
14
- isDynamicClosure?: boolean;
15
12
  values: Array<{
16
13
  signal: {
17
14
  identifier: t.Identifier | t.MemberExpression;
@@ -35,6 +32,7 @@ export type Signal = {
35
32
  extraArgs?: t.Expression[];
36
33
  buildAssignment?: (valueSection: Section, value: t.Expression) => t.Expression;
37
34
  };
35
+ type closureSignalBuilder = (signal: Signal, render: t.Expression, intersection?: t.Expression) => t.Expression;
38
36
  export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
39
37
  export declare function setForceResumeScope(section: Section): void;
40
38
  export declare const getSerializedScopeProperties: (section: Section) => Map<t.StringLiteral | t.NumericLiteral, t.Expression>;
@@ -60,3 +58,4 @@ export declare function addHTMLEffectCall(section: Section, referencedBindings?:
60
58
  export declare function writeHTMLResumeStatements(path: t.NodePath<t.MarkoTagBody | t.Program>): void;
61
59
  export declare function getSetup(section: Section): t.Identifier | undefined;
62
60
  export declare function replaceRegisteredFunctionNode(node: t.Node): t.CallExpression | t.ClassPrivateProperty | t.ClassProperty | t.VariableDeclaration | t.Identifier | t.ObjectProperty | undefined;
61
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.38",
3
+ "version": "6.0.0-next.3.39",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",