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
@@ -85,6 +85,7 @@ function stringifyStyleObject(name, value) {
85
85
  warnedStyleKeys.add(name);
86
86
  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-")}\`.`);
87
87
  }
88
+ 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.`);
88
89
  return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
89
90
  }
90
91
  const unsafeStyleAttrReg = /[\\;]/g;
@@ -159,6 +160,13 @@ function assertValidAttrValue(name, value) {
159
160
  function assertValidTextValue(value) {
160
161
  const unrenderable = describeUnrenderable(value);
161
162
  if (unrenderable) throw new Error(`Text content cannot be ${unrenderable}.`);
163
+ if (isSilentlyDropped(value)) console.warn(`Text content of \`${describeDropped(value)}\` renders as nothing; convert it to a string or number to render it.`);
164
+ }
165
+ function isSilentlyDropped(value) {
166
+ return value !== value || typeof value === "bigint" && !value;
167
+ }
168
+ function describeDropped(value) {
169
+ return value !== value ? "NaN" : "0n";
162
170
  }
163
171
  function describeUnrenderable(value) {
164
172
  if (typeof value === "symbol") return "a symbol";
@@ -182,6 +190,9 @@ function assertValidLoopKey(key, seenKeys) {
182
190
  function assertValidList(value) {
183
191
  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)}.`);
184
192
  }
193
+ function assertValidRangeStart(name, value) {
194
+ 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)}.`);
195
+ }
185
196
  function assertValidRangeBound(name, value) {
186
197
  if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
187
198
  }
@@ -527,31 +538,31 @@ const KNOWN_OBJECTS = /* @__PURE__ */ new Map([
527
538
  ]);
528
539
  var State$1 = class {
529
540
  ids = 0;
530
- flush = 0;
541
+ flushId = 0;
531
542
  wroteUndefined = false;
532
543
  buf = [];
533
544
  strs = /* @__PURE__ */ new Map();
534
545
  refs = /* @__PURE__ */ new WeakMap();
535
- assigned = /* @__PURE__ */ new Set();
546
+ pendingAssignments = /* @__PURE__ */ new Set();
536
547
  boundary = void 0;
537
548
  channel = void 0;
538
549
  channelDeps = null;
539
550
  mutated = [];
540
551
  };
541
552
  var Reference = class {
542
- assigns = null;
553
+ assignments = null;
543
554
  calls = null;
544
555
  scopeId = void 0;
545
556
  channel = void 0;
546
557
  parent;
547
558
  accessor;
548
- flush;
559
+ flushId;
549
560
  pos;
550
561
  id;
551
- constructor(parent, accessor, flush, pos = null, id = null) {
562
+ constructor(parent, accessor, flushId, pos = null, id = null) {
552
563
  this.parent = parent;
553
564
  this.accessor = accessor;
554
- this.flush = flush;
565
+ this.flushId = flushId;
555
566
  this.pos = pos;
556
567
  this.id = id;
557
568
  }
@@ -578,7 +589,7 @@ var Serializer = class {
578
589
  this.#state.channel = channel;
579
590
  return writeScopesRoot(this.#state, flushes);
580
591
  } finally {
581
- this.#state.flush++;
592
+ this.#state.flushId++;
582
593
  this.#state.buf = [];
583
594
  }
584
595
  }
@@ -632,7 +643,7 @@ function writeScopesRoot(state, flushes) {
632
643
  }
633
644
  if (nextSlotId !== -1) buf.push("]");
634
645
  let extras = "";
635
- if (state.assigned.size || hasChannelMutations(state)) {
646
+ if (state.pendingAssignments.size || hasChannelMutations(state)) {
636
647
  extras = ",0)";
637
648
  if (fillIndex !== -1) {
638
649
  buf[fillIndex] = "_(" + buf[fillIndex];
@@ -651,21 +662,21 @@ function writeScopesRoot(state, flushes) {
651
662
  }
652
663
  function writeAssigned(state) {
653
664
  let sep = state.buf.length ? "," : "";
654
- if (state.assigned.size) {
655
- const assigned = state.assigned;
656
- state.assigned = /* @__PURE__ */ new Set();
665
+ if (state.pendingAssignments.size) {
666
+ const pending = state.pendingAssignments;
667
+ state.pendingAssignments = /* @__PURE__ */ new Set();
657
668
  let buf = "";
658
669
  let hasCalls = false;
659
- for (const ref of assigned) {
660
- if (ref.assigns) {
661
- buf += sep + assignsToString(ref.assigns, ref.id);
662
- ref.assigns = null;
670
+ for (const ref of pending) {
671
+ if (ref.assignments) {
672
+ buf += sep + assignmentsToString(ref.assignments, ref.id);
673
+ ref.assignments = null;
663
674
  sep = ",";
664
675
  }
665
676
  hasCalls ||= ref.calls !== null;
666
677
  }
667
678
  if (buf) state.buf.push(buf);
668
- if (hasCalls) for (const ref of assigned) {
679
+ if (hasCalls) for (const ref of pending) {
669
680
  if (!ref.calls) continue;
670
681
  for (const { method, args } of ref.calls) {
671
682
  state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
@@ -712,13 +723,16 @@ function writeAssigned(state) {
712
723
  }
713
724
  state.mutated = remaining;
714
725
  }
715
- if (state.assigned.size) writeAssigned(state);
726
+ if (state.pendingAssignments.size) writeAssigned(state);
716
727
  }
717
728
  function writeCallArg(state, val) {
718
729
  if (val === void 0) {
719
730
  state.wroteUndefined = true;
720
731
  state.buf.push("$");
721
- } else if (!writeProp(state, val, null, "")) state.buf.push("void 0");
732
+ } else if (writeProp(state, val, null, "")) {
733
+ const ref = state.refs.get(val) || state.strs.get(val);
734
+ if (ref && ref.id === null) assignId(state, ref);
735
+ } else state.buf.push("void 0");
722
736
  }
723
737
  function hasChannelMutations(state) {
724
738
  return hasMatchingMutations(state.mutated, state.channel?.readyId);
@@ -753,7 +767,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
753
767
  }
754
768
  if (parent && isCircular(parent, ref)) {
755
769
  ensureId(state, ref);
756
- state.assigned.add(ref);
770
+ state.pendingAssignments.add(ref);
757
771
  addAssignment(ref, accessId(state, parent) + toAccess(accessor));
758
772
  return false;
759
773
  }
@@ -762,7 +776,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
762
776
  }
763
777
  const registered = REGISTRY.get(val);
764
778
  if (registered) return writeRegistered(state, val, parent, accessor, registered);
765
- state.refs.set(val, ref = new Reference(parent, accessor, state.flush, state.buf.length));
779
+ state.refs.set(val, ref = new Reference(parent, accessor, state.flushId, state.buf.length));
766
780
  ref.channel = state.channel;
767
781
  ref.debug = DEBUG.get(val);
768
782
  if (write(state, val, ref)) return true;
@@ -775,7 +789,7 @@ function trackScope(state, val, scopeId) {
775
789
  else newScopeReference(state, val, scopeId);
776
790
  }
777
791
  function newScopeReference(state, val, scopeId) {
778
- const ref = new Reference(null, null, state.flush);
792
+ const ref = new Reference(null, null, state.flushId);
779
793
  ref.scopeId = scopeId;
780
794
  ref.channel = state.channel;
781
795
  state.refs.set(val, ref);
@@ -785,7 +799,7 @@ function newScopeReference(state, val, scopeId) {
785
799
  function writeRegistered(state, val, parent, accessor, registered) {
786
800
  const { scope } = registered;
787
801
  if (scope) {
788
- const ref = new Reference(parent, accessor, state.flush, state.buf.length);
802
+ const ref = new Reference(parent, accessor, state.flushId, state.buf.length);
789
803
  ref.channel = state.channel;
790
804
  state.refs.set(val, ref);
791
805
  ref.debug = DEBUG.get(val);
@@ -805,7 +819,7 @@ function writeString(state, val, parent, accessor) {
805
819
  return true;
806
820
  }
807
821
  } else {
808
- const ref = new Reference(parent, accessor, state.flush, state.buf.length);
822
+ const ref = new Reference(parent, accessor, state.flushId, state.buf.length);
809
823
  ref.channel = state.channel;
810
824
  state.strs.set(val, ref);
811
825
  }
@@ -991,7 +1005,7 @@ function writePromise(state, val, ref) {
991
1005
  }
992
1006
  function newAsyncHandle(state, parent, id) {
993
1007
  const handle = {};
994
- const handleRef = new Reference(parent, null, state.flush, null, id);
1008
+ const handleRef = new Reference(parent, null, state.flushId, null, id);
995
1009
  handleRef.channel = state.channel;
996
1010
  state.refs.set(handle, handleRef);
997
1011
  return handle;
@@ -1002,7 +1016,7 @@ function writeMap(state, val, ref) {
1002
1016
  return true;
1003
1017
  }
1004
1018
  const items = [];
1005
- let assigns;
1019
+ let assignments;
1006
1020
  let needsId;
1007
1021
  let deferring = false;
1008
1022
  let i = 0;
@@ -1015,16 +1029,16 @@ function writeMap(state, val, ref) {
1015
1029
  }
1016
1030
  if (itemKey === val) {
1017
1031
  itemKey = void 0;
1018
- (assigns ||= []).push("a[" + i + "][0]");
1032
+ (assignments ||= []).push("a[" + i + "][0]");
1019
1033
  }
1020
1034
  if (itemValue === val) {
1021
1035
  itemValue = void 0;
1022
- (assigns ||= []).push("a[" + i + "][1]");
1036
+ (assignments ||= []).push("a[" + i + "][1]");
1023
1037
  }
1024
1038
  needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue);
1025
1039
  i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
1026
1040
  }
1027
- 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);
1041
+ 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);
1028
1042
  } else {
1029
1043
  for (let [itemKey, itemValue] of val) {
1030
1044
  if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
@@ -1034,16 +1048,16 @@ function writeMap(state, val, ref) {
1034
1048
  }
1035
1049
  if (itemKey === val) {
1036
1050
  itemKey = 0;
1037
- (assigns ||= []).push("a[" + i + "]");
1051
+ (assignments ||= []).push("a[" + i + "]");
1038
1052
  }
1039
1053
  if (itemValue === val) {
1040
1054
  itemValue = 0;
1041
- (assigns ||= []).push("a[" + (i + 1) + "]");
1055
+ (assignments ||= []).push("a[" + (i + 1) + "]");
1042
1056
  }
1043
1057
  needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue);
1044
1058
  i = items.push(itemKey, itemValue);
1045
1059
  }
1046
- 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);
1060
+ 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);
1047
1061
  }
1048
1062
  return true;
1049
1063
  }
@@ -1053,7 +1067,7 @@ function writeSet(state, val, ref) {
1053
1067
  return true;
1054
1068
  }
1055
1069
  const items = [];
1056
- let assigns;
1070
+ let assignments;
1057
1071
  let needsId;
1058
1072
  let deferring = false;
1059
1073
  let i = 0;
@@ -1065,11 +1079,11 @@ function writeSet(state, val, ref) {
1065
1079
  }
1066
1080
  if (item === val) {
1067
1081
  item = 0;
1068
- (assigns ||= []).push("i[" + i + "]");
1082
+ (assignments ||= []).push("i[" + i + "]");
1069
1083
  } else needsId ||= isDedupedMember(item);
1070
1084
  i = items.push(item);
1071
1085
  }
1072
- writeArrayArg(state, ref, items, assigns && "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
1086
+ writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
1073
1087
  return true;
1074
1088
  }
1075
1089
  function isAncestorMember(state, container, member) {
@@ -1083,16 +1097,16 @@ function deferCall(state, ref, method, args) {
1083
1097
  method,
1084
1098
  args
1085
1099
  });
1086
- state.assigned.add(ref);
1100
+ state.pendingAssignments.add(ref);
1087
1101
  }
1088
1102
  function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
1089
1103
  if (assignsPrefix || needsId) {
1090
- const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1104
+ const arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1091
1105
  state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "=");
1092
1106
  writeArray(state, items, arrayRef);
1093
1107
  } else {
1094
1108
  state.buf.push(plainPrefix);
1095
- writeArray(state, items, new Reference(ref, null, state.flush, state.buf.length));
1109
+ writeArray(state, items, new Reference(ref, null, state.flushId, state.buf.length));
1096
1110
  }
1097
1111
  state.buf.push(")");
1098
1112
  }
@@ -1136,7 +1150,7 @@ function writeTypedArray(state, val, ref) {
1136
1150
  writeProp(state, val.buffer, ref, "buffer");
1137
1151
  state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
1138
1152
  } else {
1139
- state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null));
1153
+ state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null));
1140
1154
  state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
1141
1155
  }
1142
1156
  return true;
@@ -1167,7 +1181,7 @@ function writeAggregateError(state, val, ref) {
1167
1181
  if (inlined) {
1168
1182
  const errorsRef = state.refs.get(val.errors);
1169
1183
  if (errorsRef?.id) {
1170
- state.assigned.add(errorsRef);
1184
+ state.pendingAssignments.add(errorsRef);
1171
1185
  addAssignment(errorsRef, accessId(state, ref) + toAccess("errors"));
1172
1186
  }
1173
1187
  }
@@ -1230,7 +1244,7 @@ function writeRequest(state, val, ref) {
1230
1244
  options += sep + "headers:" + ensureId(state, seenHeaders);
1231
1245
  sep = ",";
1232
1246
  } else {
1233
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1247
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
1234
1248
  const headers = stringEntriesToHeadersInit(val.headers);
1235
1249
  if (headers) {
1236
1250
  options += sep + "headers:" + headers;
@@ -1279,7 +1293,7 @@ function writeResponse(state, val, ref) {
1279
1293
  const seenHeaders = state.refs.get(val.headers);
1280
1294
  if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
1281
1295
  else {
1282
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1296
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
1283
1297
  const headers = stringEntriesToHeadersInit(val.headers);
1284
1298
  if (headers) options += sep + "headers:" + headers;
1285
1299
  }
@@ -1300,10 +1314,10 @@ function writeIntl(state, val, name, ref) {
1300
1314
  state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
1301
1315
  let optionsRef;
1302
1316
  if (needsId) {
1303
- optionsRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1317
+ optionsRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1304
1318
  state.buf.push(optionsRef.id + "={");
1305
1319
  } else {
1306
- optionsRef = new Reference(ref, null, state.flush, state.buf.length);
1320
+ optionsRef = new Reference(ref, null, state.flushId, state.buf.length);
1307
1321
  state.buf.push("{");
1308
1322
  }
1309
1323
  writeObjectProps(state, options, optionsRef);
@@ -1364,12 +1378,12 @@ function writeGenerator(state, iter, ref) {
1364
1378
  const heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
1365
1379
  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})(");
1366
1380
  if (needsId) {
1367
- const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1381
+ const arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1368
1382
  state.buf.push(arrayRef.id + "=");
1369
1383
  writeArray(state, yields, arrayRef);
1370
- } else writeArray(state, yields, new Reference(ref, null, state.flush, state.buf.length));
1384
+ } else writeArray(state, yields, new Reference(ref, null, state.flushId, state.buf.length));
1371
1385
  if (heldReturn) {
1372
- const holder = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1386
+ const holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1373
1387
  state.buf.push("," + holder.id + "={}");
1374
1388
  writeProp(state, returnValue, holder, "v");
1375
1389
  } else if (returnValue !== void 0) {
@@ -1433,7 +1447,7 @@ function writeMaybeIterableProps(state, val, ref) {
1433
1447
  for (const item of val) if (item === val && !(yieldSelf || iterArr.length)) yieldSelf = "yield this;";
1434
1448
  else iterArr.push(item);
1435
1449
  if (iterArr.length) {
1436
- const iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1450
+ const iterRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1437
1451
  state.buf.push(sep + "*[(" + iterRef.id + "=");
1438
1452
  writeArray(state, iterArr, iterRef);
1439
1453
  state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
@@ -1603,7 +1617,7 @@ function accessId(state, ref) {
1603
1617
  function assignId(state, ref) {
1604
1618
  const { pos } = ref;
1605
1619
  ref.id = nextRefAccess(state);
1606
- if (pos !== null && ref.flush === state.flush) {
1620
+ if (pos !== null && ref.flushId === state.flushId) {
1607
1621
  if (pos === 0) state.buf[0] = ref.id + "=" + state.buf[0];
1608
1622
  else state.buf[pos - 1] += ref.id + "=";
1609
1623
  return ref.id;
@@ -1620,7 +1634,7 @@ function assignId(state, ref) {
1620
1634
  break;
1621
1635
  }
1622
1636
  }
1623
- if (parent.flush === state.flush || parent.scopeId !== void 0) {
1637
+ if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
1624
1638
  accessPrevValue = accessId(state, parent) + accessPrevValue;
1625
1639
  break;
1626
1640
  }
@@ -1628,13 +1642,13 @@ function assignId(state, ref) {
1628
1642
  } while (cur);
1629
1643
  return ref.id + "=" + accessPrevValue;
1630
1644
  }
1631
- function assignsToString(assigns, value) {
1632
- if (assigns.length > 100) return "($=>(" + assigns.join("=$,") + "=$))(" + value + ")";
1633
- return assigns.join("=") + "=" + value;
1645
+ function assignmentsToString(assignments, value) {
1646
+ if (assignments.length > 100) return "($=>(" + assignments.join("=$,") + "=$))(" + value + ")";
1647
+ return assignments.join("=") + "=" + value;
1634
1648
  }
1635
1649
  function addAssignment(ref, assign) {
1636
- if (ref.assigns) ref.assigns.push(assign);
1637
- else ref.assigns = [assign];
1650
+ if (ref.assignments) ref.assignments.push(assign);
1651
+ else ref.assignments = [assign];
1638
1652
  }
1639
1653
  function nextRefAccess(state) {
1640
1654
  return "_." + nextId(state);
@@ -1708,12 +1722,16 @@ function forOf(list, cb) {
1708
1722
  }
1709
1723
  function forTo(to, from, step, cb) {
1710
1724
  assertValidRangeBound("to", to);
1725
+ assertValidRangeStart("from", from);
1726
+ assertValidRangeStart("step", step);
1711
1727
  const start = from || 0;
1712
1728
  const delta = step || 1;
1713
1729
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
1714
1730
  }
1715
1731
  function forUntil(until, from, step, cb) {
1716
1732
  assertValidRangeBound("until", until);
1733
+ assertValidRangeStart("from", from);
1734
+ assertValidRangeStart("step", step);
1717
1735
  const start = from || 0;
1718
1736
  const delta = step || 1;
1719
1737
  for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
@@ -1844,6 +1862,15 @@ let $chunk;
1844
1862
  function getChunk() {
1845
1863
  return $chunk;
1846
1864
  }
1865
+ function withChunk(chunk, cb) {
1866
+ const prev = $chunk;
1867
+ $chunk = chunk;
1868
+ try {
1869
+ return cb();
1870
+ } finally {
1871
+ $chunk = prev;
1872
+ }
1873
+ }
1847
1874
  function getContext(key) {
1848
1875
  return $chunk.context?.[key];
1849
1876
  }
@@ -2041,19 +2068,28 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
2041
2068
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
2042
2069
  }
2043
2070
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
2044
- const { state } = $chunk.boundary;
2045
2071
  const resumeBranch = serializeBranch !== 0;
2046
2072
  const resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0);
2047
2073
  const branchId = _peek_scope_id();
2048
- if (resumeMarker && resumeBranch && !singleNode) $chunk.writeHTML(state.mark("[", ""));
2074
+ const chunk = $chunk;
2075
+ const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
2049
2076
  const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
2050
2077
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
2078
+ if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
2051
2079
  if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
2052
2080
  [ConditionalRenderer + accessor]: branchIndex || void 0,
2053
2081
  [BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
2054
2082
  });
2055
2083
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
2056
2084
  }
2085
+ function deferBranchStart(chunk) {
2086
+ const beforeBranch = chunk.html;
2087
+ chunk.html = "";
2088
+ return beforeBranch;
2089
+ }
2090
+ function applyBranchStart(chunk, beforeBranch, rendered) {
2091
+ chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
2092
+ }
2057
2093
  function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
2058
2094
  const endTag = parentEndTag || "";
2059
2095
  if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
@@ -2723,7 +2759,13 @@ function offTick(cb) {
2723
2759
  function flushTickQueue() {
2724
2760
  const queue = tickQueue;
2725
2761
  tickQueue = void 0;
2726
- for (const cb of queue) cb(true);
2762
+ for (const cb of queue) try {
2763
+ cb(true);
2764
+ } catch (err) {
2765
+ tick(() => {
2766
+ throw err;
2767
+ });
2768
+ }
2727
2769
  }
2728
2770
  //#endregion
2729
2771
  //#region src/html/attrs.ts
@@ -2860,16 +2902,14 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2860
2902
  result += _attr_style(value);
2861
2903
  break;
2862
2904
  default:
2863
- if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) {
2864
- assertValidAttrName(name);
2865
- if (isEventHandler(name)) {
2866
- if (!events) {
2867
- events = {};
2868
- writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
2869
- }
2870
- events[getEventHandlerName(name)] = value;
2871
- } else result += nonVoidAttr(name, value);
2872
- }
2905
+ if (name) assertValidAttrName(name);
2906
+ if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
2907
+ if (!events) {
2908
+ events = {};
2909
+ writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
2910
+ }
2911
+ events[getEventHandlerName(name)] = value;
2912
+ } else result += nonVoidAttr(name, value);
2873
2913
  break;
2874
2914
  }
2875
2915
  }
@@ -2885,6 +2925,10 @@ function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
2885
2925
  const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
2886
2926
  if (!skip[key]) partial[key] = data[name];
2887
2927
  }
2928
+ assertExclusiveAttrs({
2929
+ ...data,
2930
+ ...skip
2931
+ });
2888
2932
  return _attrs(partial, nodeAccessor, scopeId, tagName);
2889
2933
  }
2890
2934
  function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
@@ -2892,7 +2936,13 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
2892
2936
  _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
2893
2937
  }
2894
2938
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2895
- assertHandlerIsFunction("valueChange", valueChange);
2939
+ assertHandlerIsFunction([
2940
+ "checkedChange",
2941
+ "checkedValueChange",
2942
+ "valueChange",
2943
+ "valueChange",
2944
+ "openChange"
2945
+ ][type], valueChange);
2896
2946
  writeScope(scopeId, serializeType ? {
2897
2947
  [ControlledType + nodeAccessor]: type,
2898
2948
  [ControlledValue + nodeAccessor]: value,
@@ -2914,8 +2964,8 @@ function nonVoidAttr(name, value) {
2914
2964
  }
2915
2965
  return " " + name + attrAssignment(value + "");
2916
2966
  }
2917
- const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
2918
- const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
2967
+ const singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g;
2968
+ const doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g;
2919
2969
  const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
2920
2970
  function attrAssignment(value) {
2921
2971
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
@@ -2924,13 +2974,13 @@ function escapeSingleQuotedAttrValue(value) {
2924
2974
  return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
2925
2975
  }
2926
2976
  function replaceUnsafeSingleQuoteAttrChar(match) {
2927
- return match === "'" ? "&#39;" : "&amp;";
2977
+ return match === "'" ? "&#39;" : match === "\r" ? "&#13;" : "&amp;";
2928
2978
  }
2929
2979
  function escapeDoubleQuotedAttrValue(value) {
2930
2980
  return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
2931
2981
  }
2932
2982
  function replaceUnsafeDoubleQuoteAttrChar(match) {
2933
- return match === "\"" ? "&#34;" : "&amp;";
2983
+ return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
2934
2984
  }
2935
2985
  function normalizedValueMatches(a, b) {
2936
2986
  const value = normalizeStrAttrValue(b);
@@ -2958,21 +3008,21 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2958
3008
  rendered = true;
2959
3009
  const renderNative = () => {
2960
3010
  _scope_id();
2961
- _html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
3011
+ _html(`<${renderer}${_attrs(input, `#${renderer.toLowerCase()}/0`, branchId, renderer)}>`);
2962
3012
  if (!voidElementsReg.test(renderer)) {
2963
3013
  const renderContent = content || normalizeDynamicRenderer(input.content);
2964
3014
  if (renderer === "textarea") {
2965
3015
  if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2966
- _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
3016
+ _html(_attr_textarea_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, 1));
2967
3017
  } else if (renderContent) {
2968
3018
  if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2969
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2970
- else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
3019
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, renderContent, 1);
3020
+ else _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, serializeReason);
2971
3021
  }
2972
3022
  _html(`</${renderer}>`);
2973
3023
  } else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2974
3024
  const childScope = getScopeById(branchId);
2975
- const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
3025
+ const needsScript = childScope && (childScope[`EventAttributes:#${renderer.toLowerCase()}/0`] || childScope[`ControlledHandler:#${renderer.toLowerCase()}/0`]);
2976
3026
  if (needsScript) {
2977
3027
  writeScope(branchId, { [Renderer]: renderer });
2978
3028
  _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
@@ -2981,7 +3031,8 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2981
3031
  };
2982
3032
  renderNative();
2983
3033
  } else {
2984
- if (shouldResume) _html(state.mark("[", ""));
3034
+ const chunk = getChunk();
3035
+ const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
2985
3036
  const render = () => {
2986
3037
  if (renderer) try {
2987
3038
  _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
@@ -2996,7 +3047,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2996
3047
  };
2997
3048
  result = shouldResume ? withBranchId(branchId, render) : render();
2998
3049
  rendered = _peek_scope_id() !== branchId;
2999
- if (shouldResume) _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
3050
+ if (beforeBranch !== void 0) {
3051
+ applyBranchStart(chunk, beforeBranch, rendered);
3052
+ _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
3053
+ }
3000
3054
  }
3001
3055
  if (rendered) {
3002
3056
  if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer?.["id"] || renderer });
@@ -3147,6 +3201,8 @@ var ServerRendered = class {
3147
3201
  }, (err) => {
3148
3202
  const socket = "socket" in stream && stream.socket;
3149
3203
  if (socket && typeof socket.destroySoon === "function") socket.destroySoon();
3204
+ else if (stream.destroy) stream.destroy();
3205
+ else stream.end();
3150
3206
  if (!stream.emit?.("error", err)) throw err;
3151
3207
  }, () => {
3152
3208
  stream.end();
@@ -3360,6 +3416,8 @@ const compat = {
3360
3416
  nextScopeId: _scope_id,
3361
3417
  peekNextScopeId: _peek_scope_id,
3362
3418
  isInResumedBranch,
3419
+ withChunk,
3420
+ getChunk,
3363
3421
  ensureState($global) {
3364
3422
  let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
3365
3423
  if (!state) {
@@ -3401,11 +3459,18 @@ const compat = {
3401
3459
  return compatRegistered;
3402
3460
  };
3403
3461
  },
3404
- flushScript($global) {
3462
+ createChunk($global) {
3405
3463
  const state = this.ensureState($global);
3406
- const boundary = new Boundary(state);
3407
- if (boundary.flush() === 1) throw new Error("Cannot serialize promise across tags/class compat layer.");
3408
- return new Chunk(boundary, null, null, state).flushScript().scripts;
3464
+ return new Chunk(new Boundary(state), null, null, state);
3465
+ },
3466
+ flushScript($global, chunk) {
3467
+ chunk ||= this.createChunk($global);
3468
+ const { boundary } = chunk;
3469
+ switch (boundary.flush()) {
3470
+ case 2: throw boundary.signal.reason;
3471
+ case 1: throw new Error("Cannot serialize promise across tags/class compat layer.");
3472
+ }
3473
+ return chunk.flushScript().scripts;
3409
3474
  },
3410
3475
  render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
3411
3476
  const state = this.ensureState(classAPIOut.global);
@@ -3454,6 +3519,12 @@ const compat = {
3454
3519
  register,
3455
3520
  registerRenderBody(fn) {
3456
3521
  register(RENDER_BODY_ID, fn);
3522
+ },
3523
+ registerClassFunctions(input) {
3524
+ for (const key in input) {
3525
+ const value = input[key];
3526
+ if (typeof value === "function" && !getRegistered(value)) register(RENDER_BODY_ID, value);
3527
+ }
3457
3528
  }
3458
3529
  };
3459
3530
  function NOOP() {}
@@ -3541,10 +3612,7 @@ exports.attrTag = attrTag;
3541
3612
  exports.attrTags = attrTags;
3542
3613
  exports.compat = compat;
3543
3614
  exports.forIn = forIn;
3544
- exports.forInBy = forInBy;
3545
3615
  exports.forOf = forOf;
3546
- exports.forOfBy = forOfBy;
3547
- exports.forStepBy = forStepBy;
3548
3616
  exports.forTo = forTo;
3549
3617
  exports.forUntil = forUntil;
3550
3618
  exports.withLoadAssets = withLoadAssets;