@marko/runtime-tags 6.1.11 → 6.1.13

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.
@@ -24,8 +24,7 @@ export declare enum AccessorProp {
24
24
  CatchContent = "E",
25
25
  ClosestBranch = "F",
26
26
  ClosestBranchId = "G",
27
- Creating = "H",
28
- Destroyed = "I",
27
+ Gen = "H",
29
28
  DetachedAwait = "V",
30
29
  EndNode = "K",
31
30
  Id = "L",
@@ -34,6 +33,7 @@ export declare enum AccessorProp {
34
33
  ParentBranch = "N",
35
34
  PendingEffects = "J",
36
35
  PendingRenders = "W",
36
+ PendingScopes = "Y",
37
37
  PlaceholderBranch = "P",
38
38
  PlaceholderContent = "Q",
39
39
  Renderer = "R",
@@ -24,8 +24,7 @@ export declare enum AccessorProp {
24
24
  CatchContent = "#CatchContent",
25
25
  ClosestBranch = "#ClosestBranch",
26
26
  ClosestBranchId = "#ClosestBranchId",
27
- Creating = "#Creating",
28
- Destroyed = "#Destroyed",
27
+ Gen = "#Gen",
29
28
  DetachedAwait = "#DetachedAwait",
30
29
  EndNode = "#EndNode",
31
30
  Id = "#Id",
@@ -34,6 +33,7 @@ export declare enum AccessorProp {
34
33
  ParentBranch = "#ParentBranch",
35
34
  PendingEffects = "#PendingEffects",
36
35
  PendingRenders = "#PendingRenders",
36
+ PendingScopes = "#PendingScopes",
37
37
  PlaceholderBranch = "#PlaceholderBranch",
38
38
  PlaceholderContent = "#PlaceholderContent",
39
39
  Renderer = "#Renderer",
@@ -1,9 +1,9 @@
1
- import { type Scope } from "./types";
2
1
  export declare function _el_read_error(): void;
3
2
  export declare function _hoist_read_error(): void;
4
3
  export declare function _assert_hoist(value: unknown): void;
5
- export declare function _assert_init(scope: Scope, accessor: string): any;
6
4
  export declare function assertExclusiveAttrs(attrs: Record<string, unknown> | undefined, onError?: typeof throwErr): void;
5
+ export declare function assertValidEventHandlerAttr(name: string, value: unknown): void;
6
+ export declare function assertHandlerIsFunction(name: string, value: unknown): void;
7
7
  export declare function assertValidTagName(tagName: string): void;
8
8
  declare function throwErr(msg: string): void;
9
9
  export {};
@@ -6,7 +6,6 @@ export interface BranchScope extends Scope {
6
6
  [AccessorProp.StartNode]: ChildNode;
7
7
  [AccessorProp.EndNode]: ChildNode;
8
8
  [AccessorProp.ParentBranch]: BranchScope | undefined;
9
- [AccessorProp.Destroyed]: 1 | undefined;
10
9
  [AccessorProp.AbortScopes]: Set<Scope> | undefined;
11
10
  [AccessorProp.BranchScopes]: Set<BranchScope> | undefined;
12
11
  [AccessorProp.Renderer]: ClientRenderer | string;
@@ -15,12 +14,13 @@ export interface BranchScope extends Scope {
15
14
  [AccessorProp.PlaceholderBranch]: BranchScope | undefined | 0;
16
15
  [AccessorProp.PendingRenders]: PendingRender[] | 0 | undefined;
17
16
  [AccessorProp.DetachedAwait]: Renderer | 0 | undefined;
17
+ [AccessorProp.PendingScopes]: Scope[] | void;
18
18
  }
19
19
  export interface Scope {
20
20
  [AccessorProp.Owner]: Scope | undefined;
21
21
  [AccessorProp.Global]: Record<string, unknown>;
22
22
  [AccessorProp.Id]: number;
23
- [AccessorProp.Creating]: 1 | 0 | undefined;
23
+ [AccessorProp.Gen]: number;
24
24
  [AccessorProp.AbortControllers]: Record<string | number, AbortController | void> | undefined;
25
25
  [AccessorProp.ClosestBranch]: BranchScope | undefined;
26
26
  [AccessorProp.ClosestBranchId]: number | undefined;
package/dist/debug/dom.js CHANGED
@@ -22,6 +22,7 @@ function* attrTagIterator() {
22
22
  }
23
23
  //#endregion
24
24
  //#region src/common/errors.ts
25
+ const lowercaseEventHandlerReg = /^on[a-z]/;
25
26
  function _el_read_error() {
26
27
  throw new Error("Element references can only be read in scripts and event handlers.");
27
28
  }
@@ -31,10 +32,6 @@ function _hoist_read_error() {
31
32
  function _assert_hoist(value) {
32
33
  if (typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
33
34
  }
34
- function _assert_init(scope, accessor) {
35
- if (scope["#Creating"] || !(accessor in scope)) throw new ReferenceError(`Cannot access '${accessor}' before initialization`);
36
- return scope[accessor];
37
- }
38
35
  function assertExclusiveAttrs(attrs, onError = throwErr) {
39
36
  if (attrs) {
40
37
  let exclusiveAttrs;
@@ -50,6 +47,12 @@ function assertExclusiveAttrs(attrs, onError = throwErr) {
50
47
  if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
51
48
  }
52
49
  }
50
+ function assertValidEventHandlerAttr(name, value) {
51
+ if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
52
+ }
53
+ function assertHandlerIsFunction(name, value) {
54
+ if (value && typeof value !== "function") throw new Error(`The \`${name}\` handler must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}".`);
55
+ }
53
56
  function assertValidTagName(tagName) {
54
57
  if (!/^[a-z][a-z0-9._-]*$/i.test(tagName)) throw new Error(`Invalid tag name: "${tagName}". Tag names must start with a letter and contain only letters, numbers, periods, hyphens, and underscores.`);
55
58
  }
@@ -150,6 +153,7 @@ function push(opt, item) {
150
153
  //#region src/dom/event.ts
151
154
  const defaultDelegator = /* @__PURE__ */ createDelegator();
152
155
  function _on(element, type, handler) {
156
+ assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
153
157
  if (element["$" + type] === void 0) defaultDelegator(element, type, handleDelegated);
154
158
  element["$" + type] = handler || null;
155
159
  }
@@ -202,16 +206,34 @@ function parseHTML(html, ns) {
202
206
  //#endregion
203
207
  //#region src/dom/scope.ts
204
208
  let nextScopeId = 1e6;
209
+ let collectingScopes;
205
210
  function createScope($global, closestBranch) {
206
211
  const scope = {
207
212
  ["#Id"]: nextScopeId++,
208
- ["#Creating"]: 1,
213
+ ["#Gen"]: runId,
209
214
  ["#ClosestBranch"]: closestBranch,
210
215
  ["$global"]: $global
211
216
  };
212
- pendingScopes.push(scope);
217
+ collectingScopes?.push(scope);
213
218
  return scope;
214
219
  }
220
+ function syncGen(scope) {
221
+ scope["#Gen"] = runId;
222
+ }
223
+ function _assert_init(scope, accessor) {
224
+ if (scope["#Gen"] === runId || !(accessor in scope)) throw new ReferenceError(`Cannot access '${accessor}' before initialization`);
225
+ return scope[accessor];
226
+ }
227
+ function collectScopes(fn) {
228
+ const prev = collectingScopes;
229
+ collectingScopes = [];
230
+ try {
231
+ fn();
232
+ return collectingScopes;
233
+ } finally {
234
+ collectingScopes = prev;
235
+ }
236
+ }
215
237
  function skipScope() {
216
238
  return nextScopeId++;
217
239
  }
@@ -225,13 +247,13 @@ function destroyBranch(branch) {
225
247
  destroyNestedScopes(branch);
226
248
  }
227
249
  function destroyScope(scope) {
228
- if (!scope["#Destroyed"]) {
250
+ if (scope["#Gen"]) {
229
251
  destroyNestedScopes(scope);
230
252
  resetControllers(scope);
231
253
  }
232
254
  }
233
255
  const destroyNestedScopes = function destroyNestedScopes(scope) {
234
- scope["#Destroyed"] = 1;
256
+ scope["#Gen"] = 0;
235
257
  scope["#BranchScopes"]?.forEach(destroyNestedScopes);
236
258
  scope["#AbortScopes"]?.forEach(resetControllers);
237
259
  };
@@ -290,7 +312,7 @@ function _let(id, fn) {
290
312
  id = +id.slice(id.lastIndexOf("/") + 1);
291
313
  return (scope, value) => {
292
314
  if (rendering) {
293
- if (scope["#Creating"]) {
315
+ if (scope["#Gen"] === runId) {
294
316
  scope[valueAccessor] = value;
295
317
  fn?.(scope);
296
318
  }
@@ -325,7 +347,7 @@ function _const(valueAccessor, fn) {
325
347
  }
326
348
  function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
327
349
  return (scope) => {
328
- if (scope["#Creating"]) if (id in scope) {
350
+ if (scope["#Gen"] === runId) if (id in scope) {
329
351
  if (!--scope[id]) fn(scope);
330
352
  } else scope[id] = defaultPending;
331
353
  else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
@@ -336,7 +358,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
336
358
  const ownerSignal = (ownerScope) => {
337
359
  const scopes = toArray(ownerScope[scopeAccessor]);
338
360
  if (scopes.length) queueRender(ownerScope, () => {
339
- for (const scope of scopes) if (!scope["#Creating"] && !scope["#Destroyed"]) fn(scope);
361
+ for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
340
362
  }, -1, 0, scopes[0]["#Id"]);
341
363
  };
342
364
  ownerSignal._ = fn;
@@ -347,7 +369,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
347
369
  const branchAccessor = "ConditionalRenderer:" + ownerConditionalNodeAccessor;
348
370
  const ownerSignal = (scope) => {
349
371
  const ifScope = scope[scopeAccessor];
350
- if (ifScope && !ifScope["#Creating"] && (scope[branchAccessor] || 0) === branch) queueRender(ifScope, fn, -1);
372
+ if (ifScope && ifScope["#Gen"] > 0 && ifScope["#Gen"] < runId && (scope[branchAccessor] || 0) === branch) queueRender(ifScope, fn, -1);
351
373
  };
352
374
  ownerSignal._ = fn;
353
375
  return ownerSignal;
@@ -366,7 +388,7 @@ function _closure(...closureSignals) {
366
388
  for (let i = closureSignals.length; i--;) closureSignals[i]["index"] = i;
367
389
  return (scope) => {
368
390
  if (scope[scopeInstances]) {
369
- for (const childScope of scope[scopeInstances]) if (!childScope["#Creating"]) queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
391
+ for (const childScope of scope[scopeInstances]) if (childScope["#Gen"] > 0 && childScope["#Gen"] < runId) queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
370
392
  }
371
393
  };
372
394
  }
@@ -606,6 +628,7 @@ function init(runtimeId = "M") {
606
628
  renderId
607
629
  };
608
630
  const initScope = (scope) => {
631
+ scope["#Gen"] = 1;
609
632
  scope["$global"] = initGlobal();
610
633
  if (branchesEnabled && scope["#ClosestBranchId"]) scope["#ClosestBranch"] = getScope(scope["#ClosestBranchId"]);
611
634
  return scope;
@@ -770,7 +793,7 @@ function _attr_input_checked_default(scope, nodeAccessor, checked) {
770
793
  const el = scope[nodeAccessor];
771
794
  const normalizedChecked = isNotVoid(checked);
772
795
  if (el.defaultChecked !== normalizedChecked) {
773
- const restoreValue = scope["#Creating"] ? normalizedChecked : el.checked;
796
+ const restoreValue = scope["#Gen"] < runId ? el.checked : normalizedChecked;
774
797
  el.defaultChecked = normalizedChecked;
775
798
  if (restoreValue !== normalizedChecked) el.checked = restoreValue;
776
799
  }
@@ -778,9 +801,10 @@ function _attr_input_checked_default(scope, nodeAccessor, checked) {
778
801
  function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
779
802
  const el = scope[nodeAccessor];
780
803
  const normalizedChecked = isNotVoid(checked);
804
+ assertHandlerIsFunction("checkedChange", checkedChange);
781
805
  scope["ControlledHandler:" + nodeAccessor] = checkedChange;
782
806
  scope["ControlledType:" + nodeAccessor] = checkedChange ? 0 : 5;
783
- if (checkedChange && !scope["#Creating"]) el.checked = normalizedChecked;
807
+ if (checkedChange && scope["#Gen"] < runId) el.checked = normalizedChecked;
784
808
  else _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
785
809
  }
786
810
  function _attr_input_checked_script(scope, nodeAccessor) {
@@ -806,9 +830,10 @@ function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValu
806
830
  const el = scope[nodeAccessor];
807
831
  const multiple = Array.isArray(checkedValue);
808
832
  const normalizedCheckedValue = scope["ControlledValue:" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
833
+ assertHandlerIsFunction("checkedValueChange", checkedValueChange);
809
834
  scope["ControlledHandler:" + nodeAccessor] = checkedValueChange;
810
835
  scope["ControlledType:" + nodeAccessor] = checkedValueChange ? 1 : 5;
811
- if (checkedValueChange && !scope["#Creating"]) {
836
+ if (checkedValueChange && scope["#Gen"] < runId) {
812
837
  el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue;
813
838
  _attr(el, "value", value);
814
839
  } else _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value);
@@ -834,7 +859,7 @@ function _attr_input_value_default(scope, nodeAccessor, value) {
834
859
  const el = scope[nodeAccessor];
835
860
  const normalizedValue = normalizeAttrValue(value) || "";
836
861
  if (el.defaultValue !== normalizedValue) {
837
- const restoreValue = scope["#Creating"] ? normalizedValue : el.value;
862
+ const restoreValue = scope["#Gen"] < runId ? el.value : normalizedValue;
838
863
  el.defaultValue = normalizedValue;
839
864
  setInputValue(el, restoreValue);
840
865
  }
@@ -842,10 +867,11 @@ function _attr_input_value_default(scope, nodeAccessor, value) {
842
867
  function _attr_input_value(scope, nodeAccessor, value, valueChange) {
843
868
  const el = scope[nodeAccessor];
844
869
  const normalizedValue = normalizeAttrValue(value) || "";
870
+ assertHandlerIsFunction("valueChange", valueChange);
845
871
  scope["ControlledHandler:" + nodeAccessor] = valueChange;
846
872
  scope["ControlledValue:" + nodeAccessor] = normalizedValue;
847
873
  scope["ControlledType:" + nodeAccessor] = valueChange ? 2 : 5;
848
- if (valueChange && !scope["#Creating"]) setInputValue(el, normalizedValue);
874
+ if (valueChange && scope["#Gen"] < runId) setInputValue(el, normalizedValue);
849
875
  else _attr_input_value_default(scope, nodeAccessor, normalizedValue);
850
876
  }
851
877
  function _attr_input_value_script(scope, nodeAccessor) {
@@ -871,14 +897,14 @@ function setInputValue(el, value) {
871
897
  function _attr_select_value_default(scope, nodeAccessor, value) {
872
898
  let restoreValue;
873
899
  const el = scope[nodeAccessor];
874
- const existing = !scope["#Creating"];
900
+ const live = scope["#Gen"] < runId;
875
901
  const multiple = Array.isArray(value);
876
902
  const normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
877
903
  pendingEffects.unshift(() => {
878
904
  for (const opt of el.options) {
879
905
  const selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
880
906
  if (opt.defaultSelected !== selected) {
881
- if (existing) restoreValue ??= getSelectValue(el, multiple);
907
+ if (live) restoreValue ??= getSelectValue(el, multiple);
882
908
  opt.defaultSelected = selected;
883
909
  }
884
910
  }
@@ -887,9 +913,10 @@ function _attr_select_value_default(scope, nodeAccessor, value) {
887
913
  }
888
914
  function _attr_select_value(scope, nodeAccessor, value, valueChange) {
889
915
  const el = scope[nodeAccessor];
890
- const existing = !scope["#Creating"];
916
+ const existing = scope["#Gen"] < runId;
891
917
  const multiple = Array.isArray(value);
892
918
  const normalizedValue = scope["ControlledValue:" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
919
+ assertHandlerIsFunction("valueChange", valueChange);
893
920
  scope["ControlledHandler:" + nodeAccessor] = valueChange;
894
921
  scope["ControlledType:" + nodeAccessor] = valueChange ? 3 : 5;
895
922
  if (valueChange && existing) pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope);
@@ -935,13 +962,14 @@ function getSelectValue(el, multiple) {
935
962
  return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
936
963
  }
937
964
  function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
938
- if (scope["#Creating"]) scope[nodeAccessor].open = isNotVoid(open);
965
+ if (scope["#Gen"] === runId) scope[nodeAccessor].open = isNotVoid(open);
939
966
  }
940
967
  function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
941
968
  const normalizedOpen = scope["ControlledValue:" + nodeAccessor] = isNotVoid(open);
969
+ assertHandlerIsFunction("openChange", openChange);
942
970
  scope["ControlledHandler:" + nodeAccessor] = openChange;
943
971
  scope["ControlledType:" + nodeAccessor] = openChange ? 4 : 5;
944
- if (openChange && !scope["#Creating"]) scope[nodeAccessor].open = normalizedOpen;
972
+ if (openChange && scope["#Gen"] < runId) scope[nodeAccessor].open = normalizedOpen;
945
973
  else _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
946
974
  }
947
975
  function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
@@ -1000,6 +1028,7 @@ function _to_text(value) {
1000
1028
  return value || value === 0 ? value + "" : "";
1001
1029
  }
1002
1030
  function _attr(element, name, value) {
1031
+ assertValidEventHandlerAttr(name, value);
1003
1032
  setAttribute(element, name, normalizeAttrValue(value));
1004
1033
  }
1005
1034
  function setAttribute(element, name, value) {
@@ -1074,8 +1103,9 @@ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
1074
1103
  }
1075
1104
  function attrsInternal(scope, nodeAccessor, nextAttrs) {
1076
1105
  const el = scope[nodeAccessor];
1077
- let events;
1106
+ let events = scope["EventAttributes:" + nodeAccessor];
1078
1107
  let skip;
1108
+ for (const name in events) events[name] = 0;
1079
1109
  switch (el.tagName) {
1080
1110
  case "INPUT":
1081
1111
  if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
@@ -1245,7 +1275,7 @@ function _await_promise(nodeAccessor, params) {
1245
1275
  scope[promiseAccessor] = 0;
1246
1276
  queueAsyncRender(scope, () => {
1247
1277
  if ((awaitBranch = scope[branchAccessor])["#DetachedAwait"]) {
1248
- pendingScopes.push(awaitBranch);
1278
+ awaitBranch["#PendingScopes"] = awaitBranch["#PendingScopes"]?.forEach(syncGen);
1249
1279
  setupBranch(awaitBranch["#DetachedAwait"], awaitBranch);
1250
1280
  awaitBranch["#DetachedAwait"] = 0;
1251
1281
  insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
@@ -1286,8 +1316,8 @@ function _await_content(nodeAccessor, template, walks, setup) {
1286
1316
  const branchAccessor = "BranchScopes:" + nodeAccessor;
1287
1317
  const renderer = _content("", template, walks, setup)();
1288
1318
  return (scope) => {
1289
- (scope[branchAccessor] = createBranch(scope["$global"], renderer, scope, scope[nodeAccessor].parentNode))["#DetachedAwait"] = renderer;
1290
- pendingScopes.pop();
1319
+ const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope["$global"], renderer, scope, scope[nodeAccessor].parentNode))["#DetachedAwait"] = renderer);
1320
+ scope[branchAccessor]["#PendingScopes"] = pendingScopes;
1291
1321
  };
1292
1322
  }
1293
1323
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "#PlaceholderContent")) {
@@ -1359,7 +1389,7 @@ function _if(nodeAccessor, ...branchesArgs) {
1359
1389
  while (i < branchesArgs.length) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
1360
1390
  enableBranches();
1361
1391
  return (scope, newBranch) => {
1362
- if (newBranch !== scope[branchAccessor]) setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
1392
+ if (newBranch !== (scope[branchAccessor] ?? (scope["BranchScopes:" + nodeAccessor] && 0))) setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
1363
1393
  };
1364
1394
  }
1365
1395
  function patchDynamicTag(fn) {
@@ -1451,7 +1481,8 @@ function loop(forEach) {
1451
1481
  let hasPotentialMoves;
1452
1482
  var seenKeys = /* @__PURE__ */ new Set();
1453
1483
  forEach(value, (key, args) => {
1454
- if (seenKeys.has(key)) console.error(`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`, key);
1484
+ if (typeof key !== "string" && typeof key !== "number") console.error(`A <for> tag's \`by\` attribute must return a string or number, but it returned:`, key);
1485
+ else if (seenKeys.has(key)) console.error(`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`, key);
1455
1486
  else seenKeys.add(key);
1456
1487
  let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce((map, scope, i) => map.set(scope["#LoopKey"] ?? i, scope), /* @__PURE__ */ new Map())).get(key);
1457
1488
  if (branch) hasPotentialMoves = oldScopesByKey.delete(key);
@@ -1550,13 +1581,12 @@ function byFirstArg(name) {
1550
1581
  }
1551
1582
  //#endregion
1552
1583
  //#region src/dom/queue.ts
1553
- let runId = 1;
1554
- let pendingRenders = [];
1584
+ let rendering;
1585
+ let runId = 2;
1555
1586
  const caughtError = /* @__PURE__ */ new WeakSet();
1556
1587
  const placeholderShown = /* @__PURE__ */ new WeakSet();
1557
1588
  let pendingEffects = [];
1558
- let pendingScopes = [];
1559
- let rendering;
1589
+ let pendingRenders = [];
1560
1590
  const scopeKeyOffset = 1e3;
1561
1591
  function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
1562
1592
  let render;
@@ -1649,13 +1679,11 @@ function runRenders() {
1649
1679
  }
1650
1680
  runRender(render);
1651
1681
  }
1652
- for (const scope of pendingScopes) scope["#Creating"] = 0;
1653
- pendingScopes = [];
1654
1682
  }
1655
1683
  let runRender = (render) => render["signal"](render["scope"], render["value"]);
1656
1684
  function skipDestroyedRenders() {
1657
1685
  runRender = ((runRender) => (render) => {
1658
- if (!render["scope"]["#ClosestBranch"]?.["#Destroyed"]) runRender(render);
1686
+ if (render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) runRender(render);
1659
1687
  })(runRender);
1660
1688
  }
1661
1689
  let catchEnabled;
@@ -1678,8 +1706,7 @@ function _enable_catch() {
1678
1706
  for (; i < effects.length;) {
1679
1707
  fn = effects[i++];
1680
1708
  scope = effects[i++];
1681
- branch = scope["#ClosestBranch"];
1682
- if (!branch?.["#Destroyed"] && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
1709
+ if ((branch = scope["#ClosestBranch"])?.["#Gen"] !== 0 && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
1683
1710
  }
1684
1711
  } else runEffects(effects);
1685
1712
  })(runEffects);
@@ -1903,13 +1930,12 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
1903
1930
  }
1904
1931
  function insertLoaded(renderer, branch, marker, awaitCounter) {
1905
1932
  const parent = marker.parentNode;
1906
- branch["#Creating"] = 1;
1933
+ syncGen(branch);
1907
1934
  renderer["clone"](branch, parent.namespaceURI);
1908
1935
  setupBranch(renderer, branch);
1909
1936
  applyLoad(branch, () => {
1910
1937
  insertBranchBefore(branch, parent, marker);
1911
1938
  marker.remove();
1912
- pendingScopes.push(branch);
1913
1939
  awaitCounter?.c();
1914
1940
  });
1915
1941
  }
@@ -1925,14 +1951,11 @@ function applyLoad(scope, insert) {
1925
1951
  scope["#Load"] = 0;
1926
1952
  if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
1927
1953
  entry["signal"] = signal;
1928
- if (!--remaining) {
1929
- scope["#Creating"] = 1;
1930
- pendingScopes.push(scope);
1931
- queueAsyncRender(scope, (scope) => {
1932
- values.forEach((e) => e["signal"]._(scope, e["value"]));
1933
- insert();
1934
- });
1935
- }
1954
+ if (!--remaining) queueAsyncRender(scope, (scope) => {
1955
+ syncGen(scope);
1956
+ values.forEach((e) => e["signal"]._(scope, e["value"]));
1957
+ insert();
1958
+ });
1936
1959
  }, () => 0);
1937
1960
  else insert();
1938
1961
  }
@@ -1941,7 +1964,7 @@ function _load_signal(load) {
1941
1964
  let signal;
1942
1965
  return (scope, value) => {
1943
1966
  pending ||= load();
1944
- if (scope["#Load"] || !("#Load" in scope) && scope["#Creating"]) (scope["#Load"] ||= /* @__PURE__ */ new Map()).set(pending, { ["value"]: value });
1967
+ if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope["#Load"] ||= /* @__PURE__ */ new Map()).set(pending, { ["value"]: value });
1945
1968
  else if (signal) signal(scope, value);
1946
1969
  else pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
1947
1970
  };