marko 6.0.0-next.3.50 → 6.0.0-next.3.52

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
@@ -117,19 +117,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
117
117
 
118
118
  // src/dom/resume.ts
119
119
  var registeredValues = {}, Render = class {
120
- p = [];
121
- q = {};
122
- B = {
120
+ q = [];
121
+ s = {};
122
+ F = {
123
123
  _: registeredValues
124
124
  };
125
125
  constructor(renders, runtimeId, renderId) {
126
- this.C = renders, this.D = runtimeId, this.s = renderId, this.t = renders[renderId], this.u();
126
+ this.G = renders, this.H = runtimeId, this.t = renderId, this.u = renders[renderId], this.x();
127
127
  }
128
128
  w() {
129
- this.t.w(), this.u();
129
+ this.u.w(), this.x();
130
130
  }
131
- u() {
132
- let data2 = this.t, serializeContext = this.B, scopeLookup = this.q, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
131
+ x() {
132
+ let data2 = this.u, serializeContext = this.F, scopeLookup = this.s, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
133
133
  if (visits.length) {
134
134
  let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
135
135
  data2.v = [];
@@ -152,7 +152,7 @@ var registeredValues = {}, Render = class {
152
152
  } else if (token === "$" /* ClosestBranch */)
153
153
  closestBranchMarkers.set(scopeId, visit);
154
154
  else if (token === "[" /* BranchStart */)
155
- this.f && (dataIndex && branchEnd(this.f, visit, visit), this.p.push(this.f)), this.f = scopeId, scope.a = visit;
155
+ this.f && (dataIndex && branchEnd(this.f, visit, visit), this.q.push(this.f)), this.f = scopeId, scope.a = visit;
156
156
  else if (token === "]" /* BranchEnd */) {
157
157
  scope[data3] = visit;
158
158
  let curParent = visit.parentNode, startNode = branchEnd(
@@ -160,7 +160,7 @@ var registeredValues = {}, Render = class {
160
160
  visit,
161
161
  visit
162
162
  ).a;
163
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.p.pop();
163
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.q.pop();
164
164
  } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
165
165
  let next = data3.indexOf(" "), curNode = visit;
166
166
  for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
@@ -181,7 +181,7 @@ var registeredValues = {}, Render = class {
181
181
  let resumeData = resumes[i++];
182
182
  if (typeof resumeData == "function") {
183
183
  let scopes = resumeData(serializeContext), { $global } = scopeLookup;
184
- $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.D, $global.renderId = this.s, $global.g = 1e6);
184
+ $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.H, $global.renderId = this.t, $global.g = 1e6);
185
185
  for (let scopeId in scopes)
186
186
  if (scopeId !== "$") {
187
187
  let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
@@ -192,10 +192,10 @@ var registeredValues = {}, Render = class {
192
192
  let parentBranchId = parentBranchIds.get(scopeId);
193
193
  if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
194
194
  let branch = scope, parentBranch = branch.c;
195
- scope.c = branch, parentBranch && (branch.x = parentBranch, (parentBranch.n ||= /* @__PURE__ */ new Set()).add(branch));
195
+ scope.c = branch, parentBranch && (branch.y = parentBranch, (parentBranch.n ||= /* @__PURE__ */ new Set()).add(branch));
196
196
  }
197
197
  }
198
- } else i === len || typeof resumes[i] != "string" ? delete this.C[this.s] : registeredValues[resumes[i++]](
198
+ } else i === len || typeof resumes[i] != "string" ? delete this.G[this.t] : registeredValues[resumes[i++]](
199
199
  scopeLookup[resumeData],
200
200
  scopeLookup[resumeData]
201
201
  );
@@ -647,10 +647,10 @@ function finishPendingScopes() {
647
647
  pendingScopes = [];
648
648
  }
649
649
  function destroyBranch(branch) {
650
- branch.x?.n?.delete(branch), destroyNestedBranches(branch);
650
+ branch.y?.n?.delete(branch), destroyNestedBranches(branch);
651
651
  }
652
652
  function destroyNestedBranches(branch) {
653
- branch.y = 1, branch.n?.forEach(destroyNestedBranches), branch.E?.forEach((scope) => {
653
+ branch.z = 1, branch.n?.forEach(destroyNestedBranches), branch.I?.forEach((scope) => {
654
654
  for (let id in scope.k)
655
655
  scope.k[id]?.abort();
656
656
  });
@@ -672,13 +672,13 @@ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendi
672
672
  function queueRender(scope, signal, signalKey, value2, scopeKey = scope.d) {
673
673
  let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
674
674
  if (existingRender)
675
- existingRender.z = value2;
675
+ existingRender.A = value2;
676
676
  else {
677
677
  let render = {
678
678
  j: key,
679
- A: scope,
680
- F: signal,
681
- z: value2
679
+ B: scope,
680
+ J: signal,
681
+ A: value2
682
682
  }, i = pendingRenders.push(render) - 1;
683
683
  for (; i; ) {
684
684
  let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
@@ -730,7 +730,7 @@ function runRenders() {
730
730
  }
731
731
  pendingRenders[i] = item;
732
732
  }
733
- render.A.c?.y || render.F(render.A, render.z);
733
+ render.B.c?.z || render.J(render.B, render.A);
734
734
  }
735
735
  finishPendingScopes();
736
736
  }
@@ -741,7 +741,7 @@ function resetAbortSignal(scope, id) {
741
741
  ctrl && (queueEffect(ctrl, abort), scope.k[id] = void 0);
742
742
  }
743
743
  function getAbortSignal(scope, id) {
744
- return scope.c && (scope.c.E ||= /* @__PURE__ */ new Set()).add(scope), ((scope.k ||= {})[id] ||= new AbortController()).signal;
744
+ return scope.c && (scope.c.I ||= /* @__PURE__ */ new Set()).add(scope), ((scope.k ||= {})[id] ||= new AbortController()).signal;
745
745
  }
746
746
  function abort(ctrl) {
747
747
  ctrl.abort();
@@ -865,57 +865,68 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
865
865
  }
866
866
 
867
867
  // src/dom/renderer.ts
868
- function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
869
- let branch = createBranch(
870
- $global,
871
- tagNameOrRenderer,
872
- parentScope,
873
- parentNode
874
- );
875
- return typeof tagNameOrRenderer == "string" && (branch[0] = branch.a = branch.b = document.createElementNS(
876
- tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
877
- tagNameOrRenderer
878
- )), branch;
879
- }
880
868
  function createBranch($global, renderer, parentScope, parentNode) {
881
869
  let branch = createScope($global), parentBranch = parentScope?.c;
882
- return branch._ = renderer.l || parentScope, branch.c = branch, parentBranch && (branch.x = parentBranch, (parentBranch.n ||= /* @__PURE__ */ new Set()).add(branch)), renderer.o?.(
870
+ return branch._ = renderer.l || parentScope, branch.c = branch, parentBranch && (branch.y = parentBranch, (parentBranch.n ||= /* @__PURE__ */ new Set()).add(branch)), renderer.o?.(
883
871
  branch,
884
872
  parentNode.namespaceURI
885
873
  ), branch;
886
874
  }
887
- function createContent(id, template, walks, setup, getArgs, dynamicScopesAccessor) {
888
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
889
- let args, init2 = template ? (branch, ns) => {
875
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
876
+ return setupBranch(
877
+ renderer,
878
+ createBranch($global, renderer, parentScope, parentNode)
879
+ );
880
+ }
881
+ function setupBranch(renderer, branch) {
882
+ return (renderer.p || renderer.C) && queueRender(
883
+ branch,
884
+ (branch2) => {
885
+ renderer.p?.(branch2), renderer.C?.(branch2);
886
+ },
887
+ -1
888
+ ), branch;
889
+ }
890
+ function createContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
891
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup ||= void 0, params ||= void 0, closures ||= void 0;
892
+ let clone = template ? (branch, ns) => {
890
893
  ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
891
894
  template,
892
895
  ns
893
- ))(branch, walks), setup && queueRender(branch, setup, -1);
896
+ ))(branch, walks);
894
897
  } : (branch) => {
895
898
  walk(
896
899
  branch.a = branch.b = new Text(),
897
900
  walks,
898
901
  branch
899
- ), setup && queueRender(branch, setup, -1);
902
+ );
900
903
  };
901
904
  return (owner) => ({
902
905
  d: id,
903
- o: init2,
906
+ o: clone,
904
907
  l: owner,
905
- m: dynamicScopesAccessor,
906
- get e() {
907
- return args ||= getArgs ? getArgs() : void 0;
908
- }
908
+ p: setup,
909
+ e: params,
910
+ C: closures,
911
+ m: dynamicScopesAccessor
909
912
  });
910
913
  }
911
- function registerContent(id, template, walks, setup, getArgs, dynamicScopesAccessor) {
914
+ function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
912
915
  return register(
913
916
  id,
914
- createContent(id, template, walks, setup, getArgs, dynamicScopesAccessor)
917
+ createContent(
918
+ id,
919
+ template,
920
+ walks,
921
+ setup,
922
+ params,
923
+ closures,
924
+ dynamicScopesAccessor
925
+ )
915
926
  );
916
927
  }
917
- function createRenderer(template, walks, setup, getArgs) {
918
- return createContent("", template, walks, setup, getArgs)();
928
+ function createRenderer(template, walks, setup, params, closures) {
929
+ return createContent("", template, walks, setup, params, closures)();
919
930
  }
920
931
  var cloneCache = {};
921
932
  function createCloneableHTML(html2, ns) {
@@ -969,7 +980,6 @@ function value(valueAccessor, fn = () => {
969
980
  (!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
970
981
  };
971
982
  }
972
- var accessorId = 0;
973
983
  function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "d") {
974
984
  return (scope) => {
975
985
  scope.h ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
@@ -982,7 +992,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
982
992
  ownerScope,
983
993
  () => {
984
994
  for (let scope of scopes)
985
- !scope.h && !scope.y && childSignal(scope);
995
+ !scope.h && !scope.z && childSignal(scope);
986
996
  },
987
997
  -1,
988
998
  0,
@@ -1005,24 +1015,29 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
1005
1015
  () => ownerScope[accessor].delete(scope)
1006
1016
  ));
1007
1017
  }
1008
- function dynamicClosure(valueAccessor, fn, getOwnerScope) {
1009
- let subscribersAccessor = "?" /* Dynamic */ + accessorId++, childSignal = closure(valueAccessor, fn, getOwnerScope), ownerSignal = (ownerScope) => {
1010
- let subscribers = ownerScope[subscribersAccessor];
1011
- if (subscribers)
1012
- for (let subscriber of subscribers)
1013
- subscriber.h || queueRender(subscriber, childSignal, -1);
1014
- }, subscribe = ownerSignal.G = (scope) => subscribeToScopeSet(
1015
- getOwnerScope ? getOwnerScope(scope) : scope._,
1016
- subscribersAccessor,
1017
- scope
1018
- );
1019
- return ownerSignal._ = (scope) => {
1020
- childSignal(scope), subscribe(scope);
1021
- }, ownerSignal;
1018
+ function dynamicClosure(...closureSignals) {
1019
+ let [{ D: ___scopeInstancesAccessor, E: ___signalIndexAccessor }] = closureSignals;
1020
+ for (let i = closureSignals.length; i--; )
1021
+ closureSignals[i].K = i;
1022
+ return (scope) => {
1023
+ if (scope[___scopeInstancesAccessor])
1024
+ for (let childScope of scope[___scopeInstancesAccessor])
1025
+ childScope.h || queueRender(
1026
+ childScope,
1027
+ closureSignals[childScope[___signalIndexAccessor]],
1028
+ -1
1029
+ );
1030
+ };
1022
1031
  }
1023
- function registerDynamicClosure(registryId, valueAccessor, fn, getOwnerScope) {
1024
- let signal = dynamicClosure(valueAccessor, fn, getOwnerScope);
1025
- return register(registryId, signal.G), signal;
1032
+ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
1033
+ let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
1034
+ scope[closureSignal.E] = closureSignal.K, childSignal(scope), subscribeToScopeSet(
1035
+ getOwnerScope ? getOwnerScope(scope) : scope._,
1036
+ closureSignal.D,
1037
+ scope
1038
+ );
1039
+ };
1040
+ return closureSignal.D = valueAccessor + "!" /* ClosureScopes */, closureSignal.E = valueAccessor + "(" /* ClosureSignalIndex */, closureSignal;
1026
1041
  }
1027
1042
  function closure(valueAccessor, fn, getOwnerScope) {
1028
1043
  return (scope) => {
@@ -1068,7 +1083,7 @@ function conditional(nodeAccessor, ...branches) {
1068
1083
  scope,
1069
1084
  nodeAccessor,
1070
1085
  branches[scope[branchAccessor] = newBranch],
1071
- createBranch
1086
+ createAndSetupBranch
1072
1087
  );
1073
1088
  };
1074
1089
  }
@@ -1092,7 +1107,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1092
1107
  scope[childScopeAccessor],
1093
1108
  0,
1094
1109
  content,
1095
- createBranch
1110
+ createAndSetupBranch
1096
1111
  ), content.m && subscribeToScopeSet(
1097
1112
  content.l,
1098
1113
  content.m,
@@ -1168,13 +1183,25 @@ function loop(nodeAccessor, renderer, forEach) {
1168
1183
  ...oldMap.values()
1169
1184
  ] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].a.parentNode : referenceNode, newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map(), newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
1170
1185
  forEach(value2, (key, args) => {
1171
- let branch = oldMap?.get(key) || createBranch(scope.$global, renderer, scope, parentNode);
1186
+ let branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
1172
1187
  params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
1173
1188
  });
1174
1189
  let afterReference = null;
1175
1190
  referenceNode !== parentNode && (oldArray.length ? (afterReference = oldArray[oldArray.length - 1].b.nextSibling, newArray.length || parentNode.insertBefore(referenceNode, afterReference)) : newArray.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldArray, newArray, afterReference);
1176
1191
  };
1177
1192
  }
1193
+ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1194
+ let branch = createBranch(
1195
+ $global,
1196
+ tagNameOrRenderer,
1197
+ parentScope,
1198
+ parentNode
1199
+ );
1200
+ return typeof tagNameOrRenderer == "string" ? branch[0] = branch.a = branch.b = document.createElementNS(
1201
+ tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
1202
+ tagNameOrRenderer
1203
+ ) : setupBranch(tagNameOrRenderer, branch), branch;
1204
+ }
1178
1205
  function bySecondArg(_item, index) {
1179
1206
  return index;
1180
1207
  }
@@ -1215,11 +1242,11 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1215
1242
  }) {
1216
1243
  return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
1217
1244
  value2[0],
1218
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.q[value2[1]]
1245
+ value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.s[value2[1]]
1219
1246
  ) : value2;
1220
1247
  },
1221
- createRenderer(args, clone) {
1222
- let renderer = createRenderer(0, 0, 0, () => args);
1248
+ createRenderer(params, clone) {
1249
+ let renderer = createRenderer(0, 0, 0, params);
1223
1250
  return renderer.o = (branch) => {
1224
1251
  let cloned = clone();
1225
1252
  branch.a = cloned.startNode, branch.b = cloned.endNode;
@@ -1235,7 +1262,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1235
1262
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1236
1263
  }
1237
1264
  if (component.effects = prepareEffects(() => {
1238
- branch ? existing = !0 : (out.global.g ||= 0, branch = component.scope = createBranch(
1265
+ branch ? existing = !0 : (out.global.g ||= 0, branch = component.scope = createAndSetupBranch(
1239
1266
  out.global,
1240
1267
  renderer,
1241
1268
  renderer.l,
@@ -1253,7 +1280,7 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
1253
1280
  template,
1254
1281
  walks,
1255
1282
  setup,
1256
- inputSignal && (() => inputSignal)
1283
+ inputSignal
1257
1284
  )();
1258
1285
  return renderer.mount = mount, renderer._ = renderer, register(id, renderer);
1259
1286
  };
@@ -1285,7 +1312,7 @@ function mount(input = {}, reference, position) {
1285
1312
  this,
1286
1313
  void 0,
1287
1314
  parentNode
1288
- ), args?.(branch, input);
1315
+ ), this.p?.(branch), args?.(branch, input);
1289
1316
  });
1290
1317
  return insertChildNodes(
1291
1318
  parentNode,
@@ -1332,6 +1359,7 @@ export {
1332
1359
  createTemplate,
1333
1360
  data,
1334
1361
  dynamicClosure,
1362
+ dynamicClosureRead,
1335
1363
  dynamicTag,
1336
1364
  effect,
1337
1365
  forIn,
@@ -1355,7 +1383,6 @@ export {
1355
1383
  register,
1356
1384
  registerBoundSignal,
1357
1385
  registerContent,
1358
- registerDynamicClosure,
1359
1386
  resetAbortSignal,
1360
1387
  run,
1361
1388
  setTagVar,