marko 6.0.0-next.3.59 → 6.0.0-next.3.60

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
@@ -151,7 +151,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
151
151
  commentPrefixLen + 1,
152
152
  dataIndex ? dataIndex - 1 : commentText.length
153
153
  ), scope = scopeLookup[scopeId] ||= {
154
- d: +scopeId
154
+ e: +scopeId
155
155
  }, data2 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
156
156
  if (token === "*" /* Node */) {
157
157
  let node = scope[data2] = visit.previousSibling;
@@ -193,14 +193,14 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
193
193
  for (let scopeId in scopes)
194
194
  if (scopeId !== "$") {
195
195
  let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
196
- scope.$global = $global, scope.d = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
196
+ scope.$global = $global, scope.e = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
197
197
  scope,
198
198
  prevScope
199
199
  ));
200
200
  let parentBranchId = parentBranchIds.get(scopeId);
201
201
  if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
202
202
  let branch = scope, parentBranch = branch.c;
203
- scope.c = branch, parentBranch && (branch.p = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(
203
+ scope.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(
204
204
  branch
205
205
  ));
206
206
  }
@@ -633,8 +633,8 @@ function toInsertNode(startNode, endNode) {
633
633
  var pendingScopes = [];
634
634
  function createScope($global, closestBranch) {
635
635
  let scope = {
636
- d: $global.f++,
637
- g: 1,
636
+ e: $global.f++,
637
+ h: 1,
638
638
  c: closestBranch,
639
639
  $global
640
640
  };
@@ -645,16 +645,16 @@ function skipScope(scope) {
645
645
  }
646
646
  function finishPendingScopes() {
647
647
  for (let scope of pendingScopes)
648
- scope.g = 0;
648
+ scope.h = 0;
649
649
  pendingScopes = [];
650
650
  }
651
651
  function destroyBranch(branch) {
652
- branch.p?.m?.delete(branch), destroyNestedBranches(branch);
652
+ branch.g?.o?.delete(branch), destroyNestedBranches(branch);
653
653
  }
654
654
  function destroyNestedBranches(branch) {
655
- branch.q = 1, branch.m?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
656
- for (let id in scope.j)
657
- scope.j[id]?.abort();
655
+ branch.k = 1, branch.o?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
656
+ for (let id in scope.l)
657
+ scope.l[id]?.abort();
658
658
  });
659
659
  }
660
660
  function removeAndDestroyBranch(branch) {
@@ -668,90 +668,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
668
668
  branch.b
669
669
  );
670
670
  }
671
-
672
- // src/dom/queue.ts
673
- var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
674
- function queueRender(scope, signal, signalKey, value2, scopeKey = scope.d) {
675
- let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
676
- if (existingRender)
677
- existingRender.t = value2;
678
- else {
679
- let render = {
680
- h: key,
681
- u: scope,
682
- B: signal,
683
- t: value2
684
- }, i = pendingRenders.push(render) - 1;
685
- for (; i; ) {
686
- let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
687
- if (key - parent.h >= 0) break;
688
- pendingRenders[i] = parent, i = parentIndex;
689
- }
690
- signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
691
- }
692
- }
693
- function queueEffect(scope, fn) {
694
- pendingEffects.push(fn, scope);
695
- }
696
- function run() {
697
- let effects = pendingEffects;
698
- try {
699
- rendering = !0, runRenders();
700
- } finally {
701
- pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
702
- }
703
- runEffects(effects);
704
- }
705
- function prepareEffects(fn) {
706
- let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
707
- pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
708
- try {
709
- rendering = !0, fn(), runRenders();
710
- } finally {
711
- rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
712
- }
713
- return preparedEffects;
714
- }
715
- function runEffects(effects) {
716
- for (let i = 0, scope; i < effects.length; )
717
- effects[i++](
718
- scope = effects[i++],
719
- scope
720
- );
721
- }
722
- function runRenders() {
723
- for (; pendingRenders.length; ) {
724
- let render = pendingRenders[0], item = pendingRenders.pop();
725
- if (render !== item) {
726
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).h;
727
- for (; i < mid; ) {
728
- let bestChild = (i << 1) + 1, right = bestChild + 1;
729
- if (right < pendingRenders.length && pendingRenders[right].h - pendingRenders[bestChild].h < 0 && (bestChild = right), pendingRenders[bestChild].h - key >= 0)
730
- break;
731
- pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
732
- }
733
- pendingRenders[i] = item;
734
- }
735
- render.u.c?.q || render.B(render.u, render.t);
736
- }
737
- finishPendingScopes();
738
- }
739
-
740
- // src/dom/abort-signal.ts
741
- function resetAbortSignal(scope, id) {
742
- let ctrl = scope.j?.[id];
743
- ctrl && (queueEffect(ctrl, abort), scope.j[id] = void 0);
744
- }
745
- function getAbortSignal(scope, id) {
746
- return scope.c && (scope.c.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.j ||= {})[id] ||= new AbortController()).signal;
747
- }
748
- function abort(ctrl) {
749
- ctrl.abort();
671
+ function tempDetatchBranch(branch) {
672
+ insertChildNodes(
673
+ branch.a.ownerDocument.createDocumentFragment(),
674
+ null,
675
+ branch.a,
676
+ branch.b
677
+ );
750
678
  }
751
679
 
752
- // src/common/compat-meta.ts
753
- var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
754
-
755
680
  // src/dom/reconcile.ts
756
681
  var WRONG_POS = 2147483647;
757
682
  function reconcile(parent, oldBranches, newBranches, afterReference) {
@@ -869,7 +794,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
869
794
  // src/dom/renderer.ts
870
795
  function createBranch($global, renderer, parentScope, parentNode) {
871
796
  let branch = createScope($global), parentBranch = parentScope?.c;
872
- return branch._ = renderer.k || parentScope, branch.c = branch, parentBranch && (branch.p = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch)), renderer.n?.(
797
+ return branch._ = renderer.m || parentScope, branch.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(branch)), renderer.p?.(
873
798
  branch,
874
799
  parentNode.namespaceURI
875
800
  ), branch;
@@ -881,10 +806,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
881
806
  );
882
807
  }
883
808
  function setupBranch(renderer, branch) {
884
- return (renderer.o || renderer.x) && queueRender(
809
+ return (renderer.q || renderer.u) && queueRender(
885
810
  branch,
886
811
  (branch2) => {
887
- renderer.o?.(branch2), renderer.x?.(branch2);
812
+ renderer.q?.(branch2), renderer.u?.(branch2);
888
813
  },
889
814
  -1
890
815
  ), branch;
@@ -904,13 +829,13 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
904
829
  );
905
830
  };
906
831
  return (owner) => ({
907
- d: id,
908
- n: clone,
909
- k: owner,
910
- o: setup,
911
- e: params,
912
- x: closures,
913
- l: dynamicScopesAccessor
832
+ e: id,
833
+ p: clone,
834
+ m: owner,
835
+ q: setup,
836
+ d: params,
837
+ u: closures,
838
+ n: dynamicScopesAccessor
914
839
  });
915
840
  }
916
841
  function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
@@ -982,9 +907,9 @@ function value(valueAccessor, fn = () => {
982
907
  (!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
983
908
  };
984
909
  }
985
- function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "d") {
910
+ function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "e") {
986
911
  return (scope) => {
987
- scope.g ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
912
+ scope.h ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
988
913
  };
989
914
  }
990
915
  function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
@@ -994,11 +919,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
994
919
  ownerScope,
995
920
  () => {
996
921
  for (let scope of scopes)
997
- !scope.g && !scope.q && childSignal(scope);
922
+ !scope.h && !scope.k && childSignal(scope);
998
923
  },
999
924
  -1,
1000
925
  0,
1001
- firstScope.d
926
+ firstScope.e
1002
927
  );
1003
928
  };
1004
929
  return ownerSignal._ = childSignal, ownerSignal;
@@ -1006,7 +931,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
1006
931
  function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
1007
932
  let childSignal = closure(valueAccessor, fn), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, ownerSignal = (scope) => {
1008
933
  let ifScope = scope[scopeAccessor];
1009
- ifScope && !ifScope.g && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
934
+ ifScope && !ifScope.h && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
1010
935
  };
1011
936
  return ownerSignal._ = childSignal, ownerSignal;
1012
937
  }
@@ -1018,13 +943,13 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
1018
943
  ));
1019
944
  }
1020
945
  function dynamicClosure(...closureSignals) {
1021
- let [{ y: ___scopeInstancesAccessor, z: ___signalIndexAccessor }] = closureSignals;
946
+ let [{ x: ___scopeInstancesAccessor, y: ___signalIndexAccessor }] = closureSignals;
1022
947
  for (let i = closureSignals.length; i--; )
1023
- closureSignals[i].C = i;
948
+ closureSignals[i].B = i;
1024
949
  return (scope) => {
1025
950
  if (scope[___scopeInstancesAccessor])
1026
951
  for (let childScope of scope[___scopeInstancesAccessor])
1027
- childScope.g || queueRender(
952
+ childScope.h || queueRender(
1028
953
  childScope,
1029
954
  closureSignals[childScope[___signalIndexAccessor]],
1030
955
  -1
@@ -1033,13 +958,13 @@ function dynamicClosure(...closureSignals) {
1033
958
  }
1034
959
  function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
1035
960
  let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
1036
- scope[closureSignal.z] = closureSignal.C, childSignal(scope), subscribeToScopeSet(
961
+ scope[closureSignal.y] = closureSignal.B, childSignal(scope), subscribeToScopeSet(
1037
962
  getOwnerScope ? getOwnerScope(scope) : scope._,
1038
- closureSignal.y,
963
+ closureSignal.x,
1039
964
  scope
1040
965
  );
1041
966
  };
1042
- return closureSignal.y = valueAccessor + "!" /* ClosureScopes */, closureSignal.z = valueAccessor + "(" /* ClosureSignalIndex */, closureSignal;
967
+ return closureSignal.x = valueAccessor + "!" /* ClosureScopes */, closureSignal.y = valueAccessor + "(" /* ClosureSignalIndex */, closureSignal;
1043
968
  }
1044
969
  function closure(valueAccessor, fn, getOwnerScope) {
1045
970
  return (scope) => {
@@ -1078,6 +1003,94 @@ function hoist(...path) {
1078
1003
  }
1079
1004
 
1080
1005
  // src/dom/control-flow.ts
1006
+ function awaitTag(nodeAccessor, renderer) {
1007
+ let promiseAccessor = nodeAccessor + "?" /* Promise */, branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
1008
+ return (scope, promise) => {
1009
+ let tryBranch = scope.c, awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.a ?? referenceNode).parentNode;
1010
+ for (; tryBranch && !tryBranch["%" /* PlaceholderContent */]; )
1011
+ tryBranch = tryBranch.g;
1012
+ let thisPromise = scope[promiseAccessor] = promise.then((data2) => {
1013
+ if (scope.c?.k || scope[promiseAccessor] !== thisPromise)
1014
+ return;
1015
+ scope[promiseAccessor] = void 0;
1016
+ let effects = prepareEffects(() => {
1017
+ (!awaitBranch || !tryBranch) && (insertBranchBefore(
1018
+ awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
1019
+ scope.$global,
1020
+ renderer,
1021
+ scope,
1022
+ namespaceNode
1023
+ ),
1024
+ referenceNode.parentNode,
1025
+ referenceNode
1026
+ ), referenceNode.remove()), renderer.d?.(awaitBranch, [data2]);
1027
+ });
1028
+ if (tryBranch) {
1029
+ if (!--tryBranch["." /* PendingCount */]) {
1030
+ let placeholderBranch = tryBranch["#" /* PlaceholderBranch */];
1031
+ placeholderBranch ? (insertBranchBefore(
1032
+ tryBranch,
1033
+ placeholderBranch.a.parentNode,
1034
+ placeholderBranch.a
1035
+ ), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
1036
+ tryBranch,
1037
+ referenceNode.parentNode,
1038
+ referenceNode
1039
+ );
1040
+ }
1041
+ } else
1042
+ runEffects(effects);
1043
+ }).catch((error) => {
1044
+ let tryBranch2 = scope.c;
1045
+ for (; tryBranch2 && !tryBranch2["^" /* CatchContent */]; )
1046
+ tryBranch2 = tryBranch2.g;
1047
+ tryBranch2 ? (setConditionalRenderer(
1048
+ tryBranch2._,
1049
+ tryBranch2["*" /* BranchAccessor */],
1050
+ tryBranch2["^" /* CatchContent */],
1051
+ createAndSetupBranch
1052
+ ), tryBranch2["^" /* CatchContent */].d?.(
1053
+ tryBranch2._[tryBranch2["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
1054
+ [error]
1055
+ )) : setTimeout(() => {
1056
+ throw error;
1057
+ });
1058
+ });
1059
+ tryBranch ? (tryBranch["." /* PendingCount */] || (tryBranch["." /* PendingCount */] = 0, requestAnimationFrame(() => {
1060
+ if (tryBranch["." /* PendingCount */] && !tryBranch.k) {
1061
+ let placeholderBranch = tryBranch["#" /* PlaceholderBranch */] = createAndSetupBranch(
1062
+ scope.$global,
1063
+ tryBranch["%" /* PlaceholderContent */],
1064
+ tryBranch._,
1065
+ tryBranch.a.parentNode
1066
+ );
1067
+ insertBranchBefore(
1068
+ placeholderBranch,
1069
+ tryBranch.a.parentNode,
1070
+ tryBranch.a
1071
+ ), tempDetatchBranch(tryBranch);
1072
+ }
1073
+ })), tryBranch["." /* PendingCount */]++) : awaitBranch && (awaitBranch.a.parentNode.insertBefore(
1074
+ referenceNode,
1075
+ awaitBranch.a
1076
+ ), tempDetatchBranch(awaitBranch));
1077
+ };
1078
+ }
1079
+ function createTry(nodeAccessor, tryContent) {
1080
+ let branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
1081
+ return (scope, input) => {
1082
+ scope[branchAccessor] || setConditionalRenderer(
1083
+ scope,
1084
+ nodeAccessor,
1085
+ tryContent,
1086
+ createAndSetupBranch
1087
+ );
1088
+ let branch = scope[branchAccessor];
1089
+ branch && (branch["*" /* BranchAccessor */] = nodeAccessor, branch["^" /* CatchContent */] = normalizeDynamicRenderer(input.catch), branch["%" /* PlaceholderContent */] = normalizeDynamicRenderer(
1090
+ input.placeholder
1091
+ ));
1092
+ };
1093
+ }
1081
1094
  function conditional(nodeAccessor, ...branches) {
1082
1095
  let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1083
1096
  return (scope, newBranch) => {
@@ -1096,7 +1109,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1096
1109
  let childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */, rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1097
1110
  return (scope, newRenderer, getInput) => {
1098
1111
  let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1099
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.d || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1112
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.e || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1100
1113
  if (setConditionalRenderer(
1101
1114
  scope,
1102
1115
  nodeAccessor,
@@ -1110,15 +1123,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1110
1123
  0,
1111
1124
  content,
1112
1125
  createAndSetupBranch
1113
- ), content.l && subscribeToScopeSet(
1114
- content.k,
1115
- content.l,
1126
+ ), content.n && subscribeToScopeSet(
1127
+ content.m,
1128
+ content.n,
1116
1129
  scope[childScopeAccessor][0 + "!" /* ConditionalScope */]
1117
1130
  );
1118
1131
  }
1119
- } else normalizedRenderer?.l && subscribeToScopeSet(
1120
- normalizedRenderer.k,
1121
- normalizedRenderer.l,
1132
+ } else normalizedRenderer?.n && subscribeToScopeSet(
1133
+ normalizedRenderer.m,
1134
+ normalizedRenderer.n,
1122
1135
  scope[childScopeAccessor]
1123
1136
  );
1124
1137
  if (normalizedRenderer) {
@@ -1129,9 +1142,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1129
1142
  0,
1130
1143
  (inputIsArgs ? args[0] : args) || {}
1131
1144
  );
1132
- else if (normalizedRenderer.e)
1145
+ else if (normalizedRenderer.d)
1133
1146
  if (inputIsArgs)
1134
- normalizedRenderer.e(
1147
+ normalizedRenderer.d(
1135
1148
  scope[childScopeAccessor],
1136
1149
  normalizedRenderer._ ? args[0] : args
1137
1150
  );
@@ -1140,7 +1153,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1140
1153
  ...args,
1141
1154
  content: getContent(scope)
1142
1155
  } : args || {};
1143
- normalizedRenderer.e(
1156
+ normalizedRenderer.d(
1144
1157
  scope[childScopeAccessor],
1145
1158
  normalizedRenderer._ ? inputWithContent : [inputWithContent]
1146
1159
  );
@@ -1179,7 +1192,7 @@ function loopTo(nodeAccessor, renderer) {
1179
1192
  );
1180
1193
  }
1181
1194
  function loop(nodeAccessor, renderer, forEach) {
1182
- let params = renderer.e;
1195
+ let params = renderer.d;
1183
1196
  return (scope, value2) => {
1184
1197
  let referenceNode = scope[nodeAccessor], oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */], oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
1185
1198
  ...oldMap.values()
@@ -1211,6 +1224,113 @@ function byFirstArg(name) {
1211
1224
  return name;
1212
1225
  }
1213
1226
 
1227
+ // src/dom/queue.ts
1228
+ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
1229
+ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.e) {
1230
+ let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
1231
+ if (existingRender)
1232
+ existingRender.z = value2;
1233
+ else {
1234
+ let render = {
1235
+ j: key,
1236
+ t: scope,
1237
+ C: signal,
1238
+ z: value2
1239
+ }, i = pendingRenders.push(render) - 1;
1240
+ for (; i; ) {
1241
+ let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1242
+ if (key - parent.j >= 0) break;
1243
+ pendingRenders[i] = parent, i = parentIndex;
1244
+ }
1245
+ signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
1246
+ }
1247
+ }
1248
+ function queueEffect(scope, fn) {
1249
+ pendingEffects.push(fn, scope);
1250
+ }
1251
+ function run() {
1252
+ let effects = pendingEffects;
1253
+ try {
1254
+ rendering = !0, runRenders();
1255
+ } finally {
1256
+ pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
1257
+ }
1258
+ runEffects(effects);
1259
+ }
1260
+ function prepareEffects(fn) {
1261
+ let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1262
+ pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
1263
+ try {
1264
+ rendering = !0, fn(), runRenders();
1265
+ } finally {
1266
+ rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
1267
+ }
1268
+ return preparedEffects;
1269
+ }
1270
+ function runEffects(effects) {
1271
+ for (let i = 0, scope; i < effects.length; )
1272
+ effects[i++](
1273
+ scope = effects[i++],
1274
+ scope
1275
+ );
1276
+ }
1277
+ function runRenders() {
1278
+ for (; pendingRenders.length; ) {
1279
+ let render = pendingRenders[0], item = pendingRenders.pop();
1280
+ if (render !== item) {
1281
+ let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).j;
1282
+ for (; i < mid; ) {
1283
+ let bestChild = (i << 1) + 1, right = bestChild + 1;
1284
+ if (right < pendingRenders.length && pendingRenders[right].j - pendingRenders[bestChild].j < 0 && (bestChild = right), pendingRenders[bestChild].j - key >= 0)
1285
+ break;
1286
+ pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1287
+ }
1288
+ pendingRenders[i] = item;
1289
+ }
1290
+ render.t.c?.k || runRender(render);
1291
+ }
1292
+ finishPendingScopes();
1293
+ }
1294
+ var runRender = (render) => render.C(render.t, render.z), enableCatch = () => {
1295
+ enableCatch = () => {
1296
+ }, runRender = /* @__PURE__ */ ((runRender2) => (render) => {
1297
+ try {
1298
+ runRender2(render);
1299
+ } catch (error) {
1300
+ let branch = render.t.c;
1301
+ for (; branch && !branch["^" /* CatchContent */]; )
1302
+ branch = branch.g;
1303
+ if (branch)
1304
+ setConditionalRenderer(
1305
+ branch._,
1306
+ branch["*" /* BranchAccessor */],
1307
+ branch["^" /* CatchContent */],
1308
+ createAndSetupBranch
1309
+ ), branch["^" /* CatchContent */].d?.(
1310
+ branch._[branch["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
1311
+ [error]
1312
+ );
1313
+ else
1314
+ throw error;
1315
+ }
1316
+ })(runRender);
1317
+ };
1318
+
1319
+ // src/dom/abort-signal.ts
1320
+ function resetAbortSignal(scope, id) {
1321
+ let ctrl = scope.l?.[id];
1322
+ ctrl && (queueEffect(ctrl, abort), scope.l[id] = void 0);
1323
+ }
1324
+ function getAbortSignal(scope, id) {
1325
+ return scope.c && (scope.c.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.l ||= {})[id] ||= new AbortController()).signal;
1326
+ }
1327
+ function abort(ctrl) {
1328
+ ctrl.abort();
1329
+ }
1330
+
1331
+ // src/common/compat-meta.ts
1332
+ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
1333
+
1214
1334
  // src/dom/compat.ts
1215
1335
  var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1216
1336
  patchDynamicTag,
@@ -1224,7 +1344,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1224
1344
  register(RENDERER_REGISTER_ID, fn);
1225
1345
  },
1226
1346
  isRenderer(renderer) {
1227
- return renderer.n;
1347
+ return renderer.p;
1228
1348
  },
1229
1349
  getStartNode(branch) {
1230
1350
  return branch.a;
@@ -1249,7 +1369,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1249
1369
  },
1250
1370
  createRenderer(params, clone) {
1251
1371
  let renderer = createRenderer(0, 0, 0, params);
1252
- return renderer.n = (branch) => {
1372
+ return renderer.p = (branch) => {
1253
1373
  let cloned = clone();
1254
1374
  branch.a = cloned.startNode, branch.b = cloned.endNode;
1255
1375
  }, renderer;
@@ -1267,9 +1387,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1267
1387
  branch ? existing = !0 : (out.global.f ||= 0, branch = component.scope = createAndSetupBranch(
1268
1388
  out.global,
1269
1389
  renderer,
1270
- renderer.k,
1390
+ renderer.m,
1271
1391
  document.body
1272
- )), renderer.e?.(branch, renderer._ ? args[0] : args);
1392
+ )), renderer.d?.(branch, renderer._ ? args[0] : args);
1273
1393
  }), !existing)
1274
1394
  return toInsertNode(branch.a, branch.b);
1275
1395
  }
@@ -1308,13 +1428,13 @@ function mount(input = {}, reference, position) {
1308
1428
  parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1309
1429
  break;
1310
1430
  }
1311
- let args = this.e, effects = prepareEffects(() => {
1431
+ let args = this.d, effects = prepareEffects(() => {
1312
1432
  branch = createBranch(
1313
1433
  $global,
1314
1434
  this,
1315
1435
  void 0,
1316
1436
  parentNode
1317
- ), this.o?.(branch), args?.(branch, input);
1437
+ ), this.q?.(branch), args?.(branch, input);
1318
1438
  });
1319
1439
  return insertChildNodes(
1320
1440
  parentNode,
@@ -1340,6 +1460,7 @@ export {
1340
1460
  attrTags,
1341
1461
  attrs,
1342
1462
  attrsEvents,
1463
+ awaitTag,
1343
1464
  classAttr,
1344
1465
  compat,
1345
1466
  conditional,
@@ -1359,11 +1480,13 @@ export {
1359
1480
  createContent,
1360
1481
  createRenderer,
1361
1482
  createTemplate,
1483
+ createTry,
1362
1484
  data,
1363
1485
  dynamicClosure,
1364
1486
  dynamicClosureRead,
1365
1487
  dynamicTag,
1366
1488
  effect,
1489
+ enableCatch,
1367
1490
  forIn,
1368
1491
  forOf,
1369
1492
  forTo,
@@ -5,10 +5,9 @@ interface BodyContentObject {
5
5
  content: ServerRenderer;
6
6
  }
7
7
  export declare function dynamicTagId(tagName: unknown): string | ServerRenderer | undefined;
8
- export declare function dynamicTagInput(scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, input: Record<string, unknown>, content?: () => void): undefined;
9
- export declare function dynamicTagArgs(scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, args: unknown[]): undefined;
8
+ export declare let dynamicTagInput: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, input: Record<string, unknown>, content?: () => void) => undefined;
9
+ export declare let dynamicTagArgs: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, args: unknown[]) => undefined;
10
10
  export declare function createContent(id: string, fn: ServerRenderer): ServerRenderer;
11
11
  export declare function registerContent(id: string, fn: ServerRenderer, scopeId?: number): ServerRenderer;
12
- declare let getDynamicRenderer: (value: any) => string | ServerRenderer | undefined;
13
- export declare function patchDynamicTag(newGetDynamicRenderer: typeof getDynamicRenderer): void;
12
+ export declare function patchDynamicTag(patch: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject) => unknown): void;
14
13
  export {};
@@ -6,7 +6,8 @@ export declare class Serializer {
6
6
  stringify(val: unknown, boundary: Boundary): string;
7
7
  nextId(): string;
8
8
  symbol(id: string): symbol;
9
- writeCall(value: unknown, object: unknown, method?: string, spread?: boolean): void;
9
+ writeCall(value: unknown, object: unknown, property?: string, spread?: boolean): void;
10
+ writeAssign(value: unknown, object: unknown, property: string): void;
10
11
  }
11
12
  export declare function register<T extends WeakKey>(id: string, val: T, scope?: unknown): T;
12
13
  export declare function registerGetter<T extends WeakKey>(accessor: string, val: T, scope?: unknown): T;
@@ -46,9 +46,8 @@ export declare function $global(): $Global & {
46
46
  renderId: string;
47
47
  runtimeId: string;
48
48
  };
49
- export declare function fork<T>(promise: Promise<T> | T, content: (value: T) => void): void;
50
- export declare function tryContent(input: {
51
- content?(): void;
49
+ export declare function fork<T>(scopeId: number, accessor: Accessor, promise: Promise<T> | T, content: (value: T) => void): void;
50
+ export declare function tryContent(scopeId: number, accessor: Accessor, content: () => void, input: {
52
51
  placeholder?: {
53
52
  content?(): void;
54
53
  };