marko 6.3.32 → 6.3.34

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.
Files changed (63) hide show
  1. package/cheatsheet.md +38 -31
  2. package/dist/common/errors.d.ts +1 -0
  3. package/dist/debug/dom/catch.feat.js +1 -1
  4. package/dist/debug/dom/catch.feat.mjs +1 -1
  5. package/dist/debug/dom/controllable-input.feat.js +1 -1
  6. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  7. package/dist/debug/dom/controllable-open.feat.js +1 -1
  8. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-select.feat.js +1 -1
  10. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  12. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable.feat.js +1 -1
  14. package/dist/debug/dom/controllable.feat.mjs +1 -1
  15. package/dist/debug/{dom-CiFITSPN.js → dom-Bj58jt8y.js} +55 -30
  16. package/dist/debug/{dom-BJ93mcSe.mjs → dom-klf8Ec_o.mjs} +55 -30
  17. package/dist/debug/dom.js +3 -1
  18. package/dist/debug/dom.mjs +3 -1
  19. package/dist/debug/html.js +154 -86
  20. package/dist/debug/html.mjs +155 -84
  21. package/dist/dom/catch.feat.js +1 -1
  22. package/dist/dom/catch.feat.mjs +1 -1
  23. package/dist/dom/control-flow.d.ts +3 -1
  24. package/dist/dom/controllable-input.feat.js +1 -1
  25. package/dist/dom/controllable-input.feat.mjs +1 -1
  26. package/dist/dom/controllable-open.feat.js +1 -1
  27. package/dist/dom/controllable-open.feat.mjs +1 -1
  28. package/dist/dom/controllable-select.feat.js +1 -1
  29. package/dist/dom/controllable-select.feat.mjs +1 -1
  30. package/dist/dom/controllable-textarea.feat.js +1 -1
  31. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  32. package/dist/dom/controllable.feat.js +1 -1
  33. package/dist/dom/controllable.feat.mjs +1 -1
  34. package/dist/{dom-Cj4HQ7T_.mjs → dom-6hBvZW7X.mjs} +27 -21
  35. package/dist/{dom-CI-06TZb.js → dom-B-XpL2_H.js} +27 -21
  36. package/dist/dom.js +3 -1
  37. package/dist/dom.mjs +3 -1
  38. package/dist/html/compat.d.ts +6 -2
  39. package/dist/html/writer.d.ts +3 -0
  40. package/dist/html.d.ts +1 -1
  41. package/dist/html.js +104 -65
  42. package/dist/html.mjs +104 -65
  43. package/dist/translator/core/client.d.ts +1 -2
  44. package/dist/translator/core/server.d.ts +1 -2
  45. package/dist/translator/core/static.d.ts +1 -2
  46. package/dist/translator/index.js +430 -294
  47. package/dist/translator/util/branch-tag.d.ts +5 -0
  48. package/dist/translator/util/constants/binding-type.d.ts +1 -0
  49. package/dist/translator/util/references.d.ts +8 -1
  50. package/dist/translator/util/serialize-reasons.d.ts +4 -4
  51. package/dist/translator/util/signals.d.ts +4 -3
  52. package/dist/translator/util/statement-tag.d.ts +2 -0
  53. package/dist/translator/visitors/program/index.d.ts +0 -1
  54. package/index.d.ts +19 -1
  55. package/package.json +5 -4
  56. package/tags/html-comment.d.marko +2 -0
  57. package/tags/html-script.d.marko +2 -0
  58. package/tags/html-style.d.marko +2 -0
  59. package/tags/let.d.marko +2 -2
  60. package/tags/show.d.marko +6 -0
  61. package/tags/try.d.marko +1 -1
  62. package/tags-html.d.ts +6 -1
  63. /package/dist/translator/util/{get-accessor-char.d.ts → get-accessor-enums.d.ts} +0 -0
@@ -83,6 +83,7 @@ function stringifyStyleObject(name, value) {
83
83
  warnedStyleKeys.add(name);
84
84
  console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
85
85
  }
86
+ if (value !== value || typeof value === "bigint" && !value) console.warn(`The \`${name}\` style value \`${value !== value ? "NaN" : "0n"}\` drops the declaration; convert it to a string or number to render it.`);
86
87
  return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
87
88
  }
88
89
  const unsafeStyleAttrReg = /[\\;]/g;
@@ -157,6 +158,13 @@ function assertValidAttrValue(name, value) {
157
158
  function assertValidTextValue(value) {
158
159
  const unrenderable = describeUnrenderable(value);
159
160
  if (unrenderable) throw new Error(`Text content cannot be ${unrenderable}.`);
161
+ if (isSilentlyDropped(value)) console.warn(`Text content of \`${describeDropped(value)}\` renders as nothing; convert it to a string or number to render it.`);
162
+ }
163
+ function isSilentlyDropped(value) {
164
+ return value !== value || typeof value === "bigint" && !value;
165
+ }
166
+ function describeDropped(value) {
167
+ return value !== value ? "NaN" : "0n";
160
168
  }
161
169
  function describeUnrenderable(value) {
162
170
  if (typeof value === "symbol") return "a symbol";
@@ -180,6 +188,9 @@ function assertValidLoopKey(key, seenKeys) {
180
188
  function assertValidList(value) {
181
189
  if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
182
190
  }
191
+ function assertValidRangeStart(name, value) {
192
+ if (value && (typeof value !== "number" || !isFinite(value))) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
193
+ }
183
194
  function assertValidRangeBound(name, value) {
184
195
  if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
185
196
  }
@@ -525,31 +536,31 @@ const KNOWN_OBJECTS = /* @__PURE__ */ new Map([
525
536
  ]);
526
537
  var State$1 = class {
527
538
  ids = 0;
528
- flush = 0;
539
+ flushId = 0;
529
540
  wroteUndefined = false;
530
541
  buf = [];
531
542
  strs = /* @__PURE__ */ new Map();
532
543
  refs = /* @__PURE__ */ new WeakMap();
533
- assigned = /* @__PURE__ */ new Set();
544
+ pendingAssignments = /* @__PURE__ */ new Set();
534
545
  boundary = void 0;
535
546
  channel = void 0;
536
547
  channelDeps = null;
537
548
  mutated = [];
538
549
  };
539
550
  var Reference = class {
540
- assigns = null;
551
+ assignments = null;
541
552
  calls = null;
542
553
  scopeId = void 0;
543
554
  channel = void 0;
544
555
  parent;
545
556
  accessor;
546
- flush;
557
+ flushId;
547
558
  pos;
548
559
  id;
549
- constructor(parent, accessor, flush, pos = null, id = null) {
560
+ constructor(parent, accessor, flushId, pos = null, id = null) {
550
561
  this.parent = parent;
551
562
  this.accessor = accessor;
552
- this.flush = flush;
563
+ this.flushId = flushId;
553
564
  this.pos = pos;
554
565
  this.id = id;
555
566
  }
@@ -576,7 +587,7 @@ var Serializer = class {
576
587
  this.#state.channel = channel;
577
588
  return writeScopesRoot(this.#state, flushes);
578
589
  } finally {
579
- this.#state.flush++;
590
+ this.#state.flushId++;
580
591
  this.#state.buf = [];
581
592
  }
582
593
  }
@@ -630,7 +641,7 @@ function writeScopesRoot(state, flushes) {
630
641
  }
631
642
  if (nextSlotId !== -1) buf.push("]");
632
643
  let extras = "";
633
- if (state.assigned.size || hasChannelMutations(state)) {
644
+ if (state.pendingAssignments.size || hasChannelMutations(state)) {
634
645
  extras = ",0)";
635
646
  if (fillIndex !== -1) {
636
647
  buf[fillIndex] = "_(" + buf[fillIndex];
@@ -649,21 +660,21 @@ function writeScopesRoot(state, flushes) {
649
660
  }
650
661
  function writeAssigned(state) {
651
662
  let sep = state.buf.length ? "," : "";
652
- if (state.assigned.size) {
653
- const assigned = state.assigned;
654
- state.assigned = /* @__PURE__ */ new Set();
663
+ if (state.pendingAssignments.size) {
664
+ const pending = state.pendingAssignments;
665
+ state.pendingAssignments = /* @__PURE__ */ new Set();
655
666
  let buf = "";
656
667
  let hasCalls = false;
657
- for (const ref of assigned) {
658
- if (ref.assigns) {
659
- buf += sep + assignsToString(ref.assigns, ref.id);
660
- ref.assigns = null;
668
+ for (const ref of pending) {
669
+ if (ref.assignments) {
670
+ buf += sep + assignmentsToString(ref.assignments, ref.id);
671
+ ref.assignments = null;
661
672
  sep = ",";
662
673
  }
663
674
  hasCalls ||= ref.calls !== null;
664
675
  }
665
676
  if (buf) state.buf.push(buf);
666
- if (hasCalls) for (const ref of assigned) {
677
+ if (hasCalls) for (const ref of pending) {
667
678
  if (!ref.calls) continue;
668
679
  for (const { method, args } of ref.calls) {
669
680
  state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
@@ -710,13 +721,16 @@ function writeAssigned(state) {
710
721
  }
711
722
  state.mutated = remaining;
712
723
  }
713
- if (state.assigned.size) writeAssigned(state);
724
+ if (state.pendingAssignments.size) writeAssigned(state);
714
725
  }
715
726
  function writeCallArg(state, val) {
716
727
  if (val === void 0) {
717
728
  state.wroteUndefined = true;
718
729
  state.buf.push("$");
719
- } else if (!writeProp(state, val, null, "")) state.buf.push("void 0");
730
+ } else if (writeProp(state, val, null, "")) {
731
+ const ref = state.refs.get(val) || state.strs.get(val);
732
+ if (ref && ref.id === null) assignId(state, ref);
733
+ } else state.buf.push("void 0");
720
734
  }
721
735
  function hasChannelMutations(state) {
722
736
  return hasMatchingMutations(state.mutated, state.channel?.readyId);
@@ -751,7 +765,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
751
765
  }
752
766
  if (parent && isCircular(parent, ref)) {
753
767
  ensureId(state, ref);
754
- state.assigned.add(ref);
768
+ state.pendingAssignments.add(ref);
755
769
  addAssignment(ref, accessId(state, parent) + toAccess(accessor));
756
770
  return false;
757
771
  }
@@ -760,7 +774,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
760
774
  }
761
775
  const registered = REGISTRY.get(val);
762
776
  if (registered) return writeRegistered(state, val, parent, accessor, registered);
763
- state.refs.set(val, ref = new Reference(parent, accessor, state.flush, state.buf.length));
777
+ state.refs.set(val, ref = new Reference(parent, accessor, state.flushId, state.buf.length));
764
778
  ref.channel = state.channel;
765
779
  ref.debug = DEBUG.get(val);
766
780
  if (write(state, val, ref)) return true;
@@ -773,7 +787,7 @@ function trackScope(state, val, scopeId) {
773
787
  else newScopeReference(state, val, scopeId);
774
788
  }
775
789
  function newScopeReference(state, val, scopeId) {
776
- const ref = new Reference(null, null, state.flush);
790
+ const ref = new Reference(null, null, state.flushId);
777
791
  ref.scopeId = scopeId;
778
792
  ref.channel = state.channel;
779
793
  state.refs.set(val, ref);
@@ -783,7 +797,7 @@ function newScopeReference(state, val, scopeId) {
783
797
  function writeRegistered(state, val, parent, accessor, registered) {
784
798
  const { scope } = registered;
785
799
  if (scope) {
786
- const ref = new Reference(parent, accessor, state.flush, state.buf.length);
800
+ const ref = new Reference(parent, accessor, state.flushId, state.buf.length);
787
801
  ref.channel = state.channel;
788
802
  state.refs.set(val, ref);
789
803
  ref.debug = DEBUG.get(val);
@@ -803,7 +817,7 @@ function writeString(state, val, parent, accessor) {
803
817
  return true;
804
818
  }
805
819
  } else {
806
- const ref = new Reference(parent, accessor, state.flush, state.buf.length);
820
+ const ref = new Reference(parent, accessor, state.flushId, state.buf.length);
807
821
  ref.channel = state.channel;
808
822
  state.strs.set(val, ref);
809
823
  }
@@ -989,7 +1003,7 @@ function writePromise(state, val, ref) {
989
1003
  }
990
1004
  function newAsyncHandle(state, parent, id) {
991
1005
  const handle = {};
992
- const handleRef = new Reference(parent, null, state.flush, null, id);
1006
+ const handleRef = new Reference(parent, null, state.flushId, null, id);
993
1007
  handleRef.channel = state.channel;
994
1008
  state.refs.set(handle, handleRef);
995
1009
  return handle;
@@ -1000,7 +1014,7 @@ function writeMap(state, val, ref) {
1000
1014
  return true;
1001
1015
  }
1002
1016
  const items = [];
1003
- let assigns;
1017
+ let assignments;
1004
1018
  let needsId;
1005
1019
  let deferring = false;
1006
1020
  let i = 0;
@@ -1013,16 +1027,16 @@ function writeMap(state, val, ref) {
1013
1027
  }
1014
1028
  if (itemKey === val) {
1015
1029
  itemKey = void 0;
1016
- (assigns ||= []).push("a[" + i + "][0]");
1030
+ (assignments ||= []).push("a[" + i + "][0]");
1017
1031
  }
1018
1032
  if (itemValue === val) {
1019
1033
  itemValue = void 0;
1020
- (assigns ||= []).push("a[" + i + "][1]");
1034
+ (assignments ||= []).push("a[" + i + "][1]");
1021
1035
  }
1022
1036
  needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue);
1023
1037
  i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
1024
1038
  }
1025
- writeArrayArg(state, ref, items, assigns && "((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
1039
+ writeArrayArg(state, ref, items, assignments && "((m,a)=>(" + assignmentsToString(assignments, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
1026
1040
  } else {
1027
1041
  for (let [itemKey, itemValue] of val) {
1028
1042
  if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
@@ -1032,16 +1046,16 @@ function writeMap(state, val, ref) {
1032
1046
  }
1033
1047
  if (itemKey === val) {
1034
1048
  itemKey = 0;
1035
- (assigns ||= []).push("a[" + i + "]");
1049
+ (assignments ||= []).push("a[" + i + "]");
1036
1050
  }
1037
1051
  if (itemValue === val) {
1038
1052
  itemValue = 0;
1039
- (assigns ||= []).push("a[" + (i + 1) + "]");
1053
+ (assignments ||= []).push("a[" + (i + 1) + "]");
1040
1054
  }
1041
1055
  needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue);
1042
1056
  i = items.push(itemKey, itemValue);
1043
1057
  }
1044
- writeArrayArg(state, ref, items, assigns && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
1058
+ writeArrayArg(state, ref, items, assignments && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignmentsToString(assignments, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
1045
1059
  }
1046
1060
  return true;
1047
1061
  }
@@ -1051,7 +1065,7 @@ function writeSet(state, val, ref) {
1051
1065
  return true;
1052
1066
  }
1053
1067
  const items = [];
1054
- let assigns;
1068
+ let assignments;
1055
1069
  let needsId;
1056
1070
  let deferring = false;
1057
1071
  let i = 0;
@@ -1063,11 +1077,11 @@ function writeSet(state, val, ref) {
1063
1077
  }
1064
1078
  if (item === val) {
1065
1079
  item = 0;
1066
- (assigns ||= []).push("i[" + i + "]");
1080
+ (assignments ||= []).push("i[" + i + "]");
1067
1081
  } else needsId ||= isDedupedMember(item);
1068
1082
  i = items.push(item);
1069
1083
  }
1070
- writeArrayArg(state, ref, items, assigns && "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
1084
+ writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
1071
1085
  return true;
1072
1086
  }
1073
1087
  function isAncestorMember(state, container, member) {
@@ -1081,16 +1095,16 @@ function deferCall(state, ref, method, args) {
1081
1095
  method,
1082
1096
  args
1083
1097
  });
1084
- state.assigned.add(ref);
1098
+ state.pendingAssignments.add(ref);
1085
1099
  }
1086
1100
  function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
1087
1101
  if (assignsPrefix || needsId) {
1088
- const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1102
+ const arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1089
1103
  state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "=");
1090
1104
  writeArray(state, items, arrayRef);
1091
1105
  } else {
1092
1106
  state.buf.push(plainPrefix);
1093
- writeArray(state, items, new Reference(ref, null, state.flush, state.buf.length));
1107
+ writeArray(state, items, new Reference(ref, null, state.flushId, state.buf.length));
1094
1108
  }
1095
1109
  state.buf.push(")");
1096
1110
  }
@@ -1134,7 +1148,7 @@ function writeTypedArray(state, val, ref) {
1134
1148
  writeProp(state, val.buffer, ref, "buffer");
1135
1149
  state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
1136
1150
  } else {
1137
- state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null));
1151
+ state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null));
1138
1152
  state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
1139
1153
  }
1140
1154
  return true;
@@ -1165,7 +1179,7 @@ function writeAggregateError(state, val, ref) {
1165
1179
  if (inlined) {
1166
1180
  const errorsRef = state.refs.get(val.errors);
1167
1181
  if (errorsRef?.id) {
1168
- state.assigned.add(errorsRef);
1182
+ state.pendingAssignments.add(errorsRef);
1169
1183
  addAssignment(errorsRef, accessId(state, ref) + toAccess("errors"));
1170
1184
  }
1171
1185
  }
@@ -1228,7 +1242,7 @@ function writeRequest(state, val, ref) {
1228
1242
  options += sep + "headers:" + ensureId(state, seenHeaders);
1229
1243
  sep = ",";
1230
1244
  } else {
1231
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1245
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
1232
1246
  const headers = stringEntriesToHeadersInit(val.headers);
1233
1247
  if (headers) {
1234
1248
  options += sep + "headers:" + headers;
@@ -1277,7 +1291,7 @@ function writeResponse(state, val, ref) {
1277
1291
  const seenHeaders = state.refs.get(val.headers);
1278
1292
  if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
1279
1293
  else {
1280
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1294
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
1281
1295
  const headers = stringEntriesToHeadersInit(val.headers);
1282
1296
  if (headers) options += sep + "headers:" + headers;
1283
1297
  }
@@ -1298,10 +1312,10 @@ function writeIntl(state, val, name, ref) {
1298
1312
  state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
1299
1313
  let optionsRef;
1300
1314
  if (needsId) {
1301
- optionsRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1315
+ optionsRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1302
1316
  state.buf.push(optionsRef.id + "={");
1303
1317
  } else {
1304
- optionsRef = new Reference(ref, null, state.flush, state.buf.length);
1318
+ optionsRef = new Reference(ref, null, state.flushId, state.buf.length);
1305
1319
  state.buf.push("{");
1306
1320
  }
1307
1321
  writeObjectProps(state, options, optionsRef);
@@ -1362,12 +1376,12 @@ function writeGenerator(state, iter, ref) {
1362
1376
  const heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
1363
1377
  state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : heldReturn ? "(function*(a,r){yield*a;return r.v})(" : "(function*(a,r){yield*a;return r})(");
1364
1378
  if (needsId) {
1365
- const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1379
+ const arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1366
1380
  state.buf.push(arrayRef.id + "=");
1367
1381
  writeArray(state, yields, arrayRef);
1368
- } else writeArray(state, yields, new Reference(ref, null, state.flush, state.buf.length));
1382
+ } else writeArray(state, yields, new Reference(ref, null, state.flushId, state.buf.length));
1369
1383
  if (heldReturn) {
1370
- const holder = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1384
+ const holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1371
1385
  state.buf.push("," + holder.id + "={}");
1372
1386
  writeProp(state, returnValue, holder, "v");
1373
1387
  } else if (returnValue !== void 0) {
@@ -1431,7 +1445,7 @@ function writeMaybeIterableProps(state, val, ref) {
1431
1445
  for (const item of val) if (item === val && !(yieldSelf || iterArr.length)) yieldSelf = "yield this;";
1432
1446
  else iterArr.push(item);
1433
1447
  if (iterArr.length) {
1434
- const iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1448
+ const iterRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1435
1449
  state.buf.push(sep + "*[(" + iterRef.id + "=");
1436
1450
  writeArray(state, iterArr, iterRef);
1437
1451
  state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
@@ -1601,7 +1615,7 @@ function accessId(state, ref) {
1601
1615
  function assignId(state, ref) {
1602
1616
  const { pos } = ref;
1603
1617
  ref.id = nextRefAccess(state);
1604
- if (pos !== null && ref.flush === state.flush) {
1618
+ if (pos !== null && ref.flushId === state.flushId) {
1605
1619
  if (pos === 0) state.buf[0] = ref.id + "=" + state.buf[0];
1606
1620
  else state.buf[pos - 1] += ref.id + "=";
1607
1621
  return ref.id;
@@ -1618,7 +1632,7 @@ function assignId(state, ref) {
1618
1632
  break;
1619
1633
  }
1620
1634
  }
1621
- if (parent.flush === state.flush || parent.scopeId !== void 0) {
1635
+ if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
1622
1636
  accessPrevValue = accessId(state, parent) + accessPrevValue;
1623
1637
  break;
1624
1638
  }
@@ -1626,13 +1640,13 @@ function assignId(state, ref) {
1626
1640
  } while (cur);
1627
1641
  return ref.id + "=" + accessPrevValue;
1628
1642
  }
1629
- function assignsToString(assigns, value) {
1630
- if (assigns.length > 100) return "($=>(" + assigns.join("=$,") + "=$))(" + value + ")";
1631
- return assigns.join("=") + "=" + value;
1643
+ function assignmentsToString(assignments, value) {
1644
+ if (assignments.length > 100) return "($=>(" + assignments.join("=$,") + "=$))(" + value + ")";
1645
+ return assignments.join("=") + "=" + value;
1632
1646
  }
1633
1647
  function addAssignment(ref, assign) {
1634
- if (ref.assigns) ref.assigns.push(assign);
1635
- else ref.assigns = [assign];
1648
+ if (ref.assignments) ref.assignments.push(assign);
1649
+ else ref.assignments = [assign];
1636
1650
  }
1637
1651
  function nextRefAccess(state) {
1638
1652
  return "_." + nextId(state);
@@ -1706,12 +1720,16 @@ function forOf(list, cb) {
1706
1720
  }
1707
1721
  function forTo(to, from, step, cb) {
1708
1722
  assertValidRangeBound("to", to);
1723
+ assertValidRangeStart("from", from);
1724
+ assertValidRangeStart("step", step);
1709
1725
  const start = from || 0;
1710
1726
  const delta = step || 1;
1711
1727
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
1712
1728
  }
1713
1729
  function forUntil(until, from, step, cb) {
1714
1730
  assertValidRangeBound("until", until);
1731
+ assertValidRangeStart("from", from);
1732
+ assertValidRangeStart("step", step);
1715
1733
  const start = from || 0;
1716
1734
  const delta = step || 1;
1717
1735
  for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
@@ -1842,6 +1860,15 @@ let $chunk;
1842
1860
  function getChunk() {
1843
1861
  return $chunk;
1844
1862
  }
1863
+ function withChunk(chunk, cb) {
1864
+ const prev = $chunk;
1865
+ $chunk = chunk;
1866
+ try {
1867
+ return cb();
1868
+ } finally {
1869
+ $chunk = prev;
1870
+ }
1871
+ }
1845
1872
  function getContext(key) {
1846
1873
  return $chunk.context?.[key];
1847
1874
  }
@@ -2039,19 +2066,28 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
2039
2066
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
2040
2067
  }
2041
2068
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
2042
- const { state } = $chunk.boundary;
2043
2069
  const resumeBranch = serializeBranch !== 0;
2044
2070
  const resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0);
2045
2071
  const branchId = _peek_scope_id();
2046
- if (resumeMarker && resumeBranch && !singleNode) $chunk.writeHTML(state.mark("[", ""));
2072
+ const chunk = $chunk;
2073
+ const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
2047
2074
  const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
2048
2075
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
2076
+ if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
2049
2077
  if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
2050
2078
  [ConditionalRenderer + accessor]: branchIndex || void 0,
2051
2079
  [BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
2052
2080
  });
2053
2081
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
2054
2082
  }
2083
+ function deferBranchStart(chunk) {
2084
+ const beforeBranch = chunk.html;
2085
+ chunk.html = "";
2086
+ return beforeBranch;
2087
+ }
2088
+ function applyBranchStart(chunk, beforeBranch, rendered) {
2089
+ chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
2090
+ }
2055
2091
  function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
2056
2092
  const endTag = parentEndTag || "";
2057
2093
  if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
@@ -2721,7 +2757,13 @@ function offTick(cb) {
2721
2757
  function flushTickQueue() {
2722
2758
  const queue = tickQueue;
2723
2759
  tickQueue = void 0;
2724
- for (const cb of queue) cb(true);
2760
+ for (const cb of queue) try {
2761
+ cb(true);
2762
+ } catch (err) {
2763
+ tick(() => {
2764
+ throw err;
2765
+ });
2766
+ }
2725
2767
  }
2726
2768
  //#endregion
2727
2769
  //#region src/html/attrs.ts
@@ -2858,16 +2900,14 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2858
2900
  result += _attr_style(value);
2859
2901
  break;
2860
2902
  default:
2861
- if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) {
2862
- assertValidAttrName(name);
2863
- if (isEventHandler(name)) {
2864
- if (!events) {
2865
- events = {};
2866
- writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
2867
- }
2868
- events[getEventHandlerName(name)] = value;
2869
- } else result += nonVoidAttr(name, value);
2870
- }
2903
+ if (name) assertValidAttrName(name);
2904
+ if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
2905
+ if (!events) {
2906
+ events = {};
2907
+ writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
2908
+ }
2909
+ events[getEventHandlerName(name)] = value;
2910
+ } else result += nonVoidAttr(name, value);
2871
2911
  break;
2872
2912
  }
2873
2913
  }
@@ -2883,6 +2923,10 @@ function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
2883
2923
  const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
2884
2924
  if (!skip[key]) partial[key] = data[name];
2885
2925
  }
2926
+ assertExclusiveAttrs({
2927
+ ...data,
2928
+ ...skip
2929
+ });
2886
2930
  return _attrs(partial, nodeAccessor, scopeId, tagName);
2887
2931
  }
2888
2932
  function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
@@ -2890,7 +2934,13 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
2890
2934
  _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
2891
2935
  }
2892
2936
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2893
- assertHandlerIsFunction("valueChange", valueChange);
2937
+ assertHandlerIsFunction([
2938
+ "checkedChange",
2939
+ "checkedValueChange",
2940
+ "valueChange",
2941
+ "valueChange",
2942
+ "openChange"
2943
+ ][type], valueChange);
2894
2944
  writeScope(scopeId, serializeType ? {
2895
2945
  [ControlledType + nodeAccessor]: type,
2896
2946
  [ControlledValue + nodeAccessor]: value,
@@ -2912,8 +2962,8 @@ function nonVoidAttr(name, value) {
2912
2962
  }
2913
2963
  return " " + name + attrAssignment(value + "");
2914
2964
  }
2915
- const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
2916
- const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
2965
+ const singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g;
2966
+ const doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g;
2917
2967
  const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
2918
2968
  function attrAssignment(value) {
2919
2969
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
@@ -2922,13 +2972,13 @@ function escapeSingleQuotedAttrValue(value) {
2922
2972
  return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
2923
2973
  }
2924
2974
  function replaceUnsafeSingleQuoteAttrChar(match) {
2925
- return match === "'" ? "&#39;" : "&amp;";
2975
+ return match === "'" ? "&#39;" : match === "\r" ? "&#13;" : "&amp;";
2926
2976
  }
2927
2977
  function escapeDoubleQuotedAttrValue(value) {
2928
2978
  return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
2929
2979
  }
2930
2980
  function replaceUnsafeDoubleQuoteAttrChar(match) {
2931
- return match === "\"" ? "&#34;" : "&amp;";
2981
+ return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
2932
2982
  }
2933
2983
  function normalizedValueMatches(a, b) {
2934
2984
  const value = normalizeStrAttrValue(b);
@@ -2956,21 +3006,21 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2956
3006
  rendered = true;
2957
3007
  const renderNative = () => {
2958
3008
  _scope_id();
2959
- _html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
3009
+ _html(`<${renderer}${_attrs(input, `#${renderer.toLowerCase()}/0`, branchId, renderer)}>`);
2960
3010
  if (!voidElementsReg.test(renderer)) {
2961
3011
  const renderContent = content || normalizeDynamicRenderer(input.content);
2962
3012
  if (renderer === "textarea") {
2963
3013
  if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2964
- _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
3014
+ _html(_attr_textarea_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, 1));
2965
3015
  } else if (renderContent) {
2966
3016
  if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2967
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2968
- else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
3017
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, renderContent, 1);
3018
+ else _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, serializeReason);
2969
3019
  }
2970
3020
  _html(`</${renderer}>`);
2971
3021
  } else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2972
3022
  const childScope = getScopeById(branchId);
2973
- const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
3023
+ const needsScript = childScope && (childScope[`EventAttributes:#${renderer.toLowerCase()}/0`] || childScope[`ControlledHandler:#${renderer.toLowerCase()}/0`]);
2974
3024
  if (needsScript) {
2975
3025
  writeScope(branchId, { [Renderer]: renderer });
2976
3026
  _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
@@ -2979,7 +3029,8 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2979
3029
  };
2980
3030
  renderNative();
2981
3031
  } else {
2982
- if (shouldResume) _html(state.mark("[", ""));
3032
+ const chunk = getChunk();
3033
+ const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
2983
3034
  const render = () => {
2984
3035
  if (renderer) try {
2985
3036
  _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
@@ -2994,7 +3045,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2994
3045
  };
2995
3046
  result = shouldResume ? withBranchId(branchId, render) : render();
2996
3047
  rendered = _peek_scope_id() !== branchId;
2997
- if (shouldResume) _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
3048
+ if (beforeBranch !== void 0) {
3049
+ applyBranchStart(chunk, beforeBranch, rendered);
3050
+ _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
3051
+ }
2998
3052
  }
2999
3053
  if (rendered) {
3000
3054
  if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer?.["id"] || renderer });
@@ -3145,6 +3199,8 @@ var ServerRendered = class {
3145
3199
  }, (err) => {
3146
3200
  const socket = "socket" in stream && stream.socket;
3147
3201
  if (socket && typeof socket.destroySoon === "function") socket.destroySoon();
3202
+ else if (stream.destroy) stream.destroy();
3203
+ else stream.end();
3148
3204
  if (!stream.emit?.("error", err)) throw err;
3149
3205
  }, () => {
3150
3206
  stream.end();
@@ -3358,6 +3414,8 @@ const compat = {
3358
3414
  nextScopeId: _scope_id,
3359
3415
  peekNextScopeId: _peek_scope_id,
3360
3416
  isInResumedBranch,
3417
+ withChunk,
3418
+ getChunk,
3361
3419
  ensureState($global) {
3362
3420
  let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
3363
3421
  if (!state) {
@@ -3399,11 +3457,18 @@ const compat = {
3399
3457
  return compatRegistered;
3400
3458
  };
3401
3459
  },
3402
- flushScript($global) {
3460
+ createChunk($global) {
3403
3461
  const state = this.ensureState($global);
3404
- const boundary = new Boundary(state);
3405
- if (boundary.flush() === 1) throw new Error("Cannot serialize promise across tags/class compat layer.");
3406
- return new Chunk(boundary, null, null, state).flushScript().scripts;
3462
+ return new Chunk(new Boundary(state), null, null, state);
3463
+ },
3464
+ flushScript($global, chunk) {
3465
+ chunk ||= this.createChunk($global);
3466
+ const { boundary } = chunk;
3467
+ switch (boundary.flush()) {
3468
+ case 2: throw boundary.signal.reason;
3469
+ case 1: throw new Error("Cannot serialize promise across tags/class compat layer.");
3470
+ }
3471
+ return chunk.flushScript().scripts;
3407
3472
  },
3408
3473
  render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
3409
3474
  const state = this.ensureState(classAPIOut.global);
@@ -3452,8 +3517,14 @@ const compat = {
3452
3517
  register,
3453
3518
  registerRenderBody(fn) {
3454
3519
  register(RENDER_BODY_ID, fn);
3520
+ },
3521
+ registerClassFunctions(input) {
3522
+ for (const key in input) {
3523
+ const value = input[key];
3524
+ if (typeof value === "function" && !getRegistered(value)) register(RENDER_BODY_ID, value);
3525
+ }
3455
3526
  }
3456
3527
  };
3457
3528
  function NOOP() {}
3458
3529
  //#endregion
3459
- export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
3530
+ export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
@@ -1,4 +1,4 @@
1
- let require_control_flow = require("../dom-CI-06TZb.js"), handlePendingTry = (fn, scope, branch) => {
1
+ let require_control_flow = require("../dom-B-XpL2_H.js"), handlePendingTry = (fn, scope, branch) => {
2
2
  for (; branch;) {
3
3
  if (branch.O?.i) return (branch.J ||= []).push(fn, scope);
4
4
  branch = branch.N;
@@ -4,7 +4,7 @@ let handlePendingTry = (fn, scope, branch) => {
4
4
  branch = branch.N;
5
5
  }
6
6
  };
7
- import { Jt as caughtError, Xt as placeholderShown, Yt as installCatch, h as renderCatch } from "../dom-Cj4HQ7T_.mjs";
7
+ import { Jt as caughtError, Xt as placeholderShown, Yt as installCatch, h as renderCatch } from "../dom-6hBvZW7X.mjs";
8
8
  //#region src/dom/catch.feat.ts
9
9
  installCatch((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
10
10
  if (checkPending || caughtError.has(effects)) {