marko 6.3.20 → 6.3.22

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 (66) hide show
  1. package/cheatsheet.md +29 -3
  2. package/dist/common/accessor.d.ts +21 -75
  3. package/dist/common/accessor.debug.d.ts +21 -75
  4. package/dist/common/constants/accessor-prefix.d.ts +16 -0
  5. package/dist/common/constants/accessor-prefix.debug.d.ts +16 -0
  6. package/dist/common/constants/accessor-prop.d.ts +30 -0
  7. package/dist/common/constants/accessor-prop.debug.d.ts +30 -0
  8. package/dist/common/constants/closure-signal-prop.d.ts +6 -0
  9. package/dist/common/constants/closure-signal-prop.debug.d.ts +6 -0
  10. package/dist/common/constants/controlled-type.d.ts +9 -0
  11. package/dist/common/constants/keyed-scopes-prop.d.ts +4 -0
  12. package/dist/common/constants/keyed-scopes-prop.debug.d.ts +4 -0
  13. package/dist/common/constants/load-signal-value.d.ts +5 -0
  14. package/dist/common/constants/load-signal-value.debug.d.ts +5 -0
  15. package/dist/common/constants/node-type.d.ts +7 -0
  16. package/dist/common/constants/pending-render-prop.d.ts +9 -0
  17. package/dist/common/constants/pending-render-prop.debug.d.ts +9 -0
  18. package/dist/common/constants/renderer-prop.d.ts +12 -0
  19. package/dist/common/constants/renderer-prop.debug.d.ts +12 -0
  20. package/dist/common/constants/resume-symbol.d.ts +10 -0
  21. package/dist/common/constants/walk-code.d.ts +17 -0
  22. package/dist/common/constants/walk-range-size.d.ts +7 -0
  23. package/dist/common/types.d.ts +15 -45
  24. package/dist/debug/dom.js +291 -225
  25. package/dist/debug/dom.mjs +291 -225
  26. package/dist/debug/html.js +187 -41
  27. package/dist/debug/html.mjs +187 -42
  28. package/dist/dom/compat.d.ts +1 -1
  29. package/dist/dom/control-flow.d.ts +1 -1
  30. package/dist/dom/renderer.d.ts +2 -2
  31. package/dist/dom/scope.d.ts +1 -1
  32. package/dist/dom.js +8 -6
  33. package/dist/dom.mjs +8 -6
  34. package/dist/html/constants/char.d.ts +11 -0
  35. package/dist/html/constants/flush-status.d.ts +6 -0
  36. package/dist/html/constants/mark.d.ts +6 -0
  37. package/dist/html/constants/runtime-key.d.ts +7 -0
  38. package/dist/html/writer.d.ts +20 -23
  39. package/dist/html.d.ts +1 -1
  40. package/dist/html.js +131 -29
  41. package/dist/html.mjs +131 -29
  42. package/dist/translator/core/if.d.ts +7 -7
  43. package/dist/translator/core/index.d.ts +7 -7
  44. package/dist/translator/index.d.ts +9 -9
  45. package/dist/translator/index.js +245 -139
  46. package/dist/translator/interop/constants/feature-type.d.ts +5 -0
  47. package/dist/translator/interop/index.d.ts +2 -2
  48. package/dist/translator/util/body-to-text-literal.d.ts +2 -2
  49. package/dist/translator/util/constants/binding-type.d.ts +10 -0
  50. package/dist/translator/util/constants/compile-stage.d.ts +8 -0
  51. package/dist/translator/util/constants/content-type.d.ts +8 -0
  52. package/dist/translator/util/constants/step.d.ts +5 -0
  53. package/dist/translator/util/constants/tag-name-type.d.ts +7 -0
  54. package/dist/translator/util/is-static.d.ts +1 -1
  55. package/dist/translator/util/references.d.ts +9 -12
  56. package/dist/translator/util/sections.d.ts +4 -8
  57. package/dist/translator/util/signals.d.ts +1 -0
  58. package/dist/translator/util/tag-name-type.d.ts +4 -7
  59. package/dist/translator/util/walks.d.ts +4 -6
  60. package/dist/translator/visitors/constants/sibling-text.d.ts +7 -0
  61. package/dist/translator/visitors/placeholder.d.ts +2 -6
  62. package/dist/translator/visitors/program/index.d.ts +1 -0
  63. package/dist/translator/visitors/tag/constants/class-hydration.d.ts +5 -0
  64. package/dist/translator/visitors/tag/dynamic-tag.d.ts +2 -4
  65. package/package.json +16 -16
  66. package/tags-html.d.ts +98 -22
@@ -19,6 +19,22 @@ function* attrTagIterator() {
19
19
  yield* this[rest];
20
20
  }
21
21
  //#endregion
22
+ //#region src/common/constants/accessor-prefix.debug.ts
23
+ const BranchScopes = "BranchScopes:";
24
+ const ConditionalRenderer = "ConditionalRenderer:";
25
+ const ControlledHandler = "ControlledHandler:";
26
+ const ControlledType = "ControlledType:";
27
+ const ControlledValue = "ControlledValue:";
28
+ const EventAttributes = "EventAttributes:";
29
+ const BranchAccessor = "#BranchAccessor";
30
+ const CatchContent = "#CatchContent";
31
+ const ClosestBranchId = "#ClosestBranchId";
32
+ const LoopKey = "#LoopKey";
33
+ const PlaceholderContent = "#PlaceholderContent";
34
+ const Renderer = "#Renderer";
35
+ const TagVariable = "#TagVariable";
36
+ const Embed = "embed";
37
+ //#endregion
22
38
  //#region src/common/helpers.ts
23
39
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
24
40
  const knownWrongAttrs = {
@@ -521,14 +537,15 @@ var State$1 = class {
521
537
  mutated = [];
522
538
  };
523
539
  var Reference = class {
540
+ assigns = null;
541
+ calls = null;
542
+ scopeId = void 0;
543
+ channel = void 0;
524
544
  parent;
525
545
  accessor;
526
546
  flush;
527
547
  pos;
528
548
  id;
529
- assigns = null;
530
- scopeId = void 0;
531
- channel = void 0;
532
549
  constructor(parent, accessor, flush, pos = null, id = null) {
533
550
  this.parent = parent;
534
551
  this.accessor = accessor;
@@ -633,14 +650,31 @@ function writeScopesRoot(state, flushes) {
633
650
  function writeAssigned(state) {
634
651
  let sep = state.buf.length ? "," : "";
635
652
  if (state.assigned.size) {
653
+ const assigned = state.assigned;
654
+ state.assigned = /* @__PURE__ */ new Set();
636
655
  let buf = "";
637
- for (const ref of state.assigned) {
638
- buf += sep + assignsToString(ref.assigns, ref.id);
639
- ref.assigns = null;
640
- sep = ",";
656
+ 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;
661
+ sep = ",";
662
+ }
663
+ hasCalls ||= ref.calls !== null;
664
+ }
665
+ if (buf) state.buf.push(buf);
666
+ if (hasCalls) for (const ref of assigned) {
667
+ if (!ref.calls) continue;
668
+ for (const { method, args } of ref.calls) {
669
+ state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
670
+ for (let a = 0; a < args.length; a++) {
671
+ if (a) state.buf.push(",");
672
+ writeCallArg(state, args[a]);
673
+ }
674
+ state.buf.push(")");
675
+ }
676
+ ref.calls = null;
641
677
  }
642
- state.buf.push(buf);
643
- state.assigned = /* @__PURE__ */ new Set();
644
678
  }
645
679
  if (hasChannelMutations(state)) {
646
680
  const remaining = [];
@@ -675,8 +709,14 @@ function writeAssigned(state) {
675
709
  state.buf.push(")");
676
710
  }
677
711
  state.mutated = remaining;
678
- if (state.assigned.size) writeAssigned(state);
679
712
  }
713
+ if (state.assigned.size) writeAssigned(state);
714
+ }
715
+ function writeCallArg(state, val) {
716
+ if (val === void 0) {
717
+ state.wroteUndefined = true;
718
+ state.buf.push("$");
719
+ } else if (!writeProp(state, val, null, "")) state.buf.push("void 0");
680
720
  }
681
721
  function hasChannelMutations(state) {
682
722
  return hasMatchingMutations(state.mutated, state.channel?.readyId);
@@ -871,6 +911,7 @@ function writeUnknownObject(state, val, ref) {
871
911
  case Float64Array:
872
912
  case BigInt64Array:
873
913
  case BigUint64Array: return writeTypedArray(state, val, ref);
914
+ case DataView: return writeDataView(state, val, ref);
874
915
  case WeakSet: return writeWeakSet(state);
875
916
  case WeakMap: return writeWeakMap(state);
876
917
  case globalThis.URL: return writeURL(state, val);
@@ -880,6 +921,24 @@ function writeUnknownObject(state, val, ref) {
880
921
  case globalThis.ReadableStream: return writeReadableStream(state, val, ref);
881
922
  case globalThis.Request: return writeRequest(state, val, ref);
882
923
  case globalThis.Response: return writeResponse(state, val, ref);
924
+ case globalThis.Intl?.NumberFormat: return writeIntl(state, val, "NumberFormat", ref);
925
+ case globalThis.Intl?.DateTimeFormat: return writeIntl(state, val, "DateTimeFormat", ref);
926
+ case globalThis.Intl?.Collator: return writeIntl(state, val, "Collator", ref);
927
+ case globalThis.Intl?.PluralRules: return writeIntl(state, val, "PluralRules", ref);
928
+ case globalThis.Intl?.RelativeTimeFormat: return writeIntl(state, val, "RelativeTimeFormat", ref);
929
+ case globalThis.Intl?.ListFormat: return writeIntl(state, val, "ListFormat", ref);
930
+ case globalThis.Intl?.DisplayNames: return writeIntl(state, val, "DisplayNames", ref);
931
+ case globalThis.Intl?.Segmenter: return writeIntl(state, val, "Segmenter", ref);
932
+ case globalThis.Intl?.DurationFormat: return writeIntl(state, val, "DurationFormat", ref);
933
+ case globalThis.Intl?.Locale: return writeIntlLocale(state, val);
934
+ case globalThis.Temporal?.Instant: return writeTemporal(state, val, "Instant");
935
+ case globalThis.Temporal?.Duration: return writeTemporal(state, val, "Duration");
936
+ case globalThis.Temporal?.PlainDate: return writeTemporal(state, val, "PlainDate");
937
+ case globalThis.Temporal?.PlainDateTime: return writeTemporal(state, val, "PlainDateTime");
938
+ case globalThis.Temporal?.PlainMonthDay: return writeTemporal(state, val, "PlainMonthDay");
939
+ case globalThis.Temporal?.PlainTime: return writeTemporal(state, val, "PlainTime");
940
+ case globalThis.Temporal?.PlainYearMonth: return writeTemporal(state, val, "PlainYearMonth");
941
+ case globalThis.Temporal?.ZonedDateTime: return writeTemporal(state, val, "ZonedDateTime");
883
942
  }
884
943
  throwUnserializable(state, val, ref);
885
944
  return false;
@@ -948,9 +1007,15 @@ function writeMap(state, val, ref) {
948
1007
  const items = [];
949
1008
  let assigns;
950
1009
  let needsId;
1010
+ let deferring = false;
951
1011
  let i = 0;
952
1012
  if (val.size < 25) {
953
1013
  for (let [itemKey, itemValue] of val) {
1014
+ if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
1015
+ if (deferring) {
1016
+ deferCall(state, ref, "set", [itemKey, itemValue]);
1017
+ continue;
1018
+ }
954
1019
  if (itemKey === val) {
955
1020
  itemKey = void 0;
956
1021
  (assigns ||= []).push("a[" + i + "][0]");
@@ -965,6 +1030,11 @@ function writeMap(state, val, ref) {
965
1030
  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);
966
1031
  } else {
967
1032
  for (let [itemKey, itemValue] of val) {
1033
+ if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
1034
+ if (deferring) {
1035
+ deferCall(state, ref, "set", [itemKey, itemValue]);
1036
+ continue;
1037
+ }
968
1038
  if (itemKey === val) {
969
1039
  itemKey = 0;
970
1040
  (assigns ||= []).push("a[" + i + "]");
@@ -988,8 +1058,14 @@ function writeSet(state, val, ref) {
988
1058
  const items = [];
989
1059
  let assigns;
990
1060
  let needsId;
1061
+ let deferring = false;
991
1062
  let i = 0;
992
1063
  for (let item of val) {
1064
+ if (!deferring && item !== val && isAncestorMember(state, ref, item)) deferring = true;
1065
+ if (deferring) {
1066
+ deferCall(state, ref, "add", [item]);
1067
+ continue;
1068
+ }
993
1069
  if (item === val) {
994
1070
  item = 0;
995
1071
  (assigns ||= []).push("i[" + i + "]");
@@ -999,6 +1075,19 @@ function writeSet(state, val, ref) {
999
1075
  writeArrayArg(state, ref, items, assigns && "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
1000
1076
  return true;
1001
1077
  }
1078
+ function isAncestorMember(state, container, member) {
1079
+ if (member === null || typeof member !== "object" && typeof member !== "function") return false;
1080
+ const ref = state.refs.get(member);
1081
+ return ref !== void 0 && isCircular(container, ref);
1082
+ }
1083
+ function deferCall(state, ref, method, args) {
1084
+ ensureId(state, ref);
1085
+ (ref.calls ||= []).push({
1086
+ method,
1087
+ args
1088
+ });
1089
+ state.assigned.add(ref);
1090
+ }
1002
1091
  function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
1003
1092
  if (assignsPrefix || needsId) {
1004
1093
  const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
@@ -1019,6 +1108,20 @@ function isDedupedMember(val) {
1019
1108
  default: return false;
1020
1109
  }
1021
1110
  }
1111
+ function canWriteBuffer(state, buffer, ref) {
1112
+ if (Object.getPrototypeOf(buffer)?.constructor === ArrayBuffer) return true;
1113
+ throwUnserializable(state, buffer, ref, "buffer");
1114
+ return false;
1115
+ }
1116
+ function writeDataView(state, val, ref) {
1117
+ const { buffer } = val;
1118
+ if (!canWriteBuffer(state, buffer, ref)) return false;
1119
+ const needsLength = val.byteOffset + val.byteLength < buffer.byteLength;
1120
+ state.buf.push("new DataView(");
1121
+ writeProp(state, buffer, ref, "buffer");
1122
+ state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.byteLength : "") : "") + ")");
1123
+ return true;
1124
+ }
1022
1125
  function writeArrayBuffer(state, val) {
1023
1126
  let result;
1024
1127
  if (val.byteLength) {
@@ -1030,6 +1133,7 @@ function writeArrayBuffer(state, val) {
1030
1133
  }
1031
1134
  function writeTypedArray(state, val, ref) {
1032
1135
  if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
1136
+ if (!canWriteBuffer(state, val.buffer, ref)) return false;
1033
1137
  const needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
1034
1138
  state.buf.push("new " + val.constructor.name + "(");
1035
1139
  writeProp(state, val.buffer, ref, "buffer");
@@ -1189,6 +1293,34 @@ function writeResponse(state, val, ref) {
1189
1293
  }
1190
1294
  return true;
1191
1295
  }
1296
+ function writeIntl(state, val, name, ref) {
1297
+ const { locale, ...options } = val.resolvedOptions();
1298
+ let needsId = false;
1299
+ for (const key in options) if (isDedupedMember(options[key])) {
1300
+ needsId = true;
1301
+ break;
1302
+ }
1303
+ state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
1304
+ let optionsRef;
1305
+ if (needsId) {
1306
+ optionsRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1307
+ state.buf.push(optionsRef.id + "={");
1308
+ } else {
1309
+ optionsRef = new Reference(ref, null, state.flush, state.buf.length);
1310
+ state.buf.push("{");
1311
+ }
1312
+ writeObjectProps(state, options, optionsRef);
1313
+ state.buf.push("})");
1314
+ return true;
1315
+ }
1316
+ function writeIntlLocale(state, val) {
1317
+ state.buf.push("new Intl.Locale(" + quote(val.toString(), 0) + ")");
1318
+ return true;
1319
+ }
1320
+ function writeTemporal(state, val, name) {
1321
+ state.buf.push("Temporal." + name + ".from(" + quote(val.toString(), 0) + ")");
1322
+ return true;
1323
+ }
1192
1324
  function writeReadableStream(state, val, ref) {
1193
1325
  const { boundary, channel } = state;
1194
1326
  if (!boundary || val.locked) return false;
@@ -1343,6 +1475,7 @@ function throwUnserializable(state, cause, ref = null, accessor = "") {
1343
1475
  if (accessor) access = toAccess(accessor) + access;
1344
1476
  if (access[0] === ".") access = access.slice(1);
1345
1477
  if (access) message += ` (reading ${access})`;
1478
+ message += ". Values referenced in the browser must be serializable.";
1346
1479
  const err = new TypeError(message, { cause });
1347
1480
  err.stack = void 0;
1348
1481
  state.boundary.abort(err);
@@ -1776,6 +1909,10 @@ function _trailers(html) {
1776
1909
  function _resume(val, id, scopeId) {
1777
1910
  return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
1778
1911
  }
1912
+ function _resume_locals(val, id, locals, ownerScopeId) {
1913
+ if (ownerScopeId !== void 0) locals["_"] = _scope_with_id(ownerScopeId);
1914
+ return register(id, val, writeScope(_scope_id(), locals));
1915
+ }
1779
1916
  function _el(scopeId, id) {
1780
1917
  return _resume(() => _el_read_error(), id, scopeId);
1781
1918
  }
@@ -1795,7 +1932,7 @@ function _sep(shouldResume) {
1795
1932
  }
1796
1933
  function _resume_branch(scopeId) {
1797
1934
  const branchId = $chunk.context?.[kBranchId];
1798
- if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
1935
+ if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId]: branchId });
1799
1936
  }
1800
1937
  function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1801
1938
  const shouldResume = serializeReason !== 0;
@@ -1805,8 +1942,8 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1805
1942
  else render();
1806
1943
  if (_peek_scope_id() !== branchId) {
1807
1944
  if (shouldResume) writeScope(scopeId, {
1808
- ["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
1809
- ["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
1945
+ [BranchScopes + nodeAccessor]: writeScope(branchId, {}),
1946
+ [ConditionalRenderer + nodeAccessor]: render?.["id"]
1810
1947
  });
1811
1948
  } else _scope_id();
1812
1949
  }
@@ -1817,8 +1954,8 @@ function normalizeServerRender(value) {
1817
1954
  }
1818
1955
  function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
1819
1956
  writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
1820
- const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
1821
- if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
1957
+ const childScope = writeScopePassive(childScopeId, { [TagVariable]: _resume({}, registryId, parentScopeId) });
1958
+ if (nodeAccessor !== void 0) writeScope(parentScopeId, { [BranchScopes + nodeAccessor]: childScope });
1822
1959
  }
1823
1960
  function writeScopePassive(scopeId, partialScope) {
1824
1961
  const target = $chunk.serializeState;
@@ -1894,11 +2031,11 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
1894
2031
  }
1895
2032
  withBranchId(branchId, () => {
1896
2033
  render();
1897
- const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { ["#LoopKey"]: itemKey } : {});
2034
+ const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { [LoopKey]: itemKey } : {});
1898
2035
  if (!resumeMarker) loopScopes = push(loopScopes, branchScope);
1899
2036
  });
1900
2037
  });
1901
- if (loopScopes) writeScope(scopeId, { ["BranchScopes:" + accessor]: loopScopes });
2038
+ if (loopScopes) writeScope(scopeId, { [BranchScopes + accessor]: loopScopes });
1902
2039
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1903
2040
  }
1904
2041
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
@@ -1910,8 +2047,8 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
1910
2047
  const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
1911
2048
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1912
2049
  if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
1913
- ["ConditionalRenderer:" + accessor]: branchIndex || void 0,
1914
- ["BranchScopes:" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
2050
+ [ConditionalRenderer + accessor]: branchIndex || void 0,
2051
+ [BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
1915
2052
  });
1916
2053
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
1917
2054
  }
@@ -2044,9 +2181,9 @@ function _try(scopeId, accessor, content, input) {
2044
2181
  else if (placeholderContent) tryPlaceholder(content, placeholderContent, branchId);
2045
2182
  else content();
2046
2183
  writeScope(branchId, {
2047
- ["#BranchAccessor"]: accessor,
2048
- ["#CatchContent"]: catchContent,
2049
- ["#PlaceholderContent"]: placeholderContent
2184
+ [BranchAccessor]: accessor,
2185
+ [CatchContent]: catchContent,
2186
+ [PlaceholderContent]: placeholderContent
2050
2187
  });
2051
2188
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2052
2189
  }
@@ -2119,7 +2256,6 @@ function tryCatch(content, catchContent) {
2119
2256
  }
2120
2257
  const NOOP$2 = () => {};
2121
2258
  var State = class {
2122
- $global;
2123
2259
  tagId = 1;
2124
2260
  scopeId = 1;
2125
2261
  reorderId = 1;
@@ -2141,6 +2277,7 @@ var State = class {
2141
2277
  writeScopes = {};
2142
2278
  readyIds = null;
2143
2279
  serializeReason;
2280
+ $global;
2144
2281
  constructor($global) {
2145
2282
  this.$global = $global;
2146
2283
  if ($global.cspNonce) this.nonceAttr = " nonce" + attrAssignment($global.cspNonce);
@@ -2183,10 +2320,10 @@ var State = class {
2183
2320
  }
2184
2321
  };
2185
2322
  var Boundary = class extends AbortController {
2186
- state;
2187
- parent;
2188
2323
  onNext = NOOP$2;
2189
2324
  count = 0;
2325
+ state;
2326
+ parent;
2190
2327
  constructor(state, signal, parent) {
2191
2328
  super();
2192
2329
  this.state = state;
@@ -2216,10 +2353,6 @@ var Boundary = class extends AbortController {
2216
2353
  }
2217
2354
  };
2218
2355
  var Chunk = class Chunk {
2219
- boundary;
2220
- next;
2221
- context;
2222
- serializeState;
2223
2356
  html = "";
2224
2357
  scripts = "";
2225
2358
  effects = "";
@@ -2230,6 +2363,10 @@ var Chunk = class Chunk {
2230
2363
  reorderId = null;
2231
2364
  deferredReady = null;
2232
2365
  placeholder = null;
2366
+ boundary;
2367
+ next;
2368
+ context;
2369
+ serializeState;
2233
2370
  constructor(boundary, next, context, serializeState) {
2234
2371
  this.boundary = boundary;
2235
2372
  this.next = next;
@@ -2725,7 +2862,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2725
2862
  if (isEventHandler(name)) {
2726
2863
  if (!events) {
2727
2864
  events = {};
2728
- writeScope(scopeId, { ["EventAttributes:" + nodeAccessor]: events });
2865
+ writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
2729
2866
  }
2730
2867
  events[getEventHandlerName(name)] = value;
2731
2868
  } else result += nonVoidAttr(name, value);
@@ -2754,12 +2891,12 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
2754
2891
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2755
2892
  assertHandlerIsFunction("valueChange", valueChange);
2756
2893
  writeScope(scopeId, serializeType ? {
2757
- ["ControlledType:" + nodeAccessor]: type,
2758
- ["ControlledValue:" + nodeAccessor]: value,
2759
- ["ControlledHandler:" + nodeAccessor]: valueChange
2894
+ [ControlledType + nodeAccessor]: type,
2895
+ [ControlledValue + nodeAccessor]: value,
2896
+ [ControlledHandler + nodeAccessor]: valueChange
2760
2897
  } : {
2761
- ["ControlledValue:" + nodeAccessor]: value,
2762
- ["ControlledHandler:" + nodeAccessor]: valueChange
2898
+ [ControlledValue + nodeAccessor]: value,
2899
+ [ControlledHandler + nodeAccessor]: valueChange
2763
2900
  });
2764
2901
  }
2765
2902
  function stringAttr(name, value) {
@@ -2834,7 +2971,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2834
2971
  const childScope = getScopeById(branchId);
2835
2972
  const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
2836
2973
  if (needsScript) {
2837
- writeScope(branchId, { ["#Renderer"]: renderer });
2974
+ writeScope(branchId, { [Renderer]: renderer });
2838
2975
  _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2839
2976
  }
2840
2977
  if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
@@ -2859,7 +2996,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2859
2996
  if (shouldResume) _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
2860
2997
  }
2861
2998
  if (rendered) {
2862
- if (shouldResume) writeScope(scopeId, { ["ConditionalRenderer:" + accessor]: renderer?.["id"] || renderer });
2999
+ if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer?.["id"] || renderer });
2863
3000
  } else _scope_id();
2864
3001
  return result;
2865
3002
  };
@@ -2882,7 +3019,7 @@ const patchDynamicTag = ((originalDynamicTag) => (patch) => {
2882
3019
  const CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result";
2883
3020
  const _template = (templateId, renderer, page) => {
2884
3021
  renderer.render = render;
2885
- renderer["embed"] = !page;
3022
+ renderer[Embed] = !page;
2886
3023
  renderer._ = renderer;
2887
3024
  renderer.mount = () => {
2888
3025
  throw new Error(`mount() is not implemented for the HTML compilation of a Marko template`);
@@ -2936,7 +3073,9 @@ var ServerRendered = class {
2936
3073
  const boundary = this.#read((html) => {
2937
3074
  value += html;
2938
3075
  if (resolve) {
2939
- resolve({
3076
+ const settle = resolve;
3077
+ resolve = reject = void 0;
3078
+ settle({
2940
3079
  value,
2941
3080
  done
2942
3081
  });
@@ -2945,11 +3084,17 @@ var ServerRendered = class {
2945
3084
  }, (err) => {
2946
3085
  aborted = true;
2947
3086
  reason = err;
2948
- if (reject) reject(err);
3087
+ if (reject) {
3088
+ const settle = reject;
3089
+ resolve = reject = void 0;
3090
+ settle(err);
3091
+ }
2949
3092
  }, () => {
2950
3093
  done = true;
2951
3094
  if (resolve) {
2952
- resolve({
3095
+ const settle = resolve;
3096
+ resolve = reject = void 0;
3097
+ settle({
2953
3098
  value,
2954
3099
  done: !value
2955
3100
  });
@@ -3310,4 +3455,4 @@ const compat = {
3310
3455
  };
3311
3456
  function NOOP() {}
3312
3457
  //#endregion
3313
- 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, 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 };
3458
+ 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 };
@@ -19,7 +19,7 @@ export declare const compat: {
19
19
  runtimeId: string;
20
20
  renderId: string;
21
21
  }): any;
22
- createRenderer(params: NonNullable<Renderer[RendererProp.Params]>, clone: () => {
22
+ createRenderer(params: NonNullable<Renderer[typeof RendererProp.Params]>, clone: () => {
23
23
  startNode: ChildNode;
24
24
  endNode: ChildNode;
25
25
  }): Renderer;
@@ -15,7 +15,7 @@ export declare function patchDynamicTag(fn: <T extends typeof _dynamic_tag>(cond
15
15
  export declare let _dynamic_tag: (nodeAccessor: EncodedAccessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
16
16
  export declare function _dynamic_tag_content(nodeAccessor: EncodedAccessor): Signal<Renderer | undefined>;
17
17
  export declare function _resume_dynamic_tag(): void;
18
- export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: ($global: Scope[AccessorProp.Global], renderer: NonNullable<T>, parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
18
+ export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: ($global: Scope[typeof AccessorProp.Global], renderer: NonNullable<T>, parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
19
19
  export declare const _for_of: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
20
20
  export declare const _for_in: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => void;
21
21
  export declare const _for_to: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [to: number, from: number, step: number, by?: ((v: number) => unknown) | undefined]) => void;
@@ -11,9 +11,9 @@ export type Renderer = {
11
11
  [RendererProp.LocalClosureValues]?: Record<Accessor, unknown>;
12
12
  };
13
13
  export type SetupFn = (scope: Scope) => void;
14
- export declare function createBranch($global: Scope[AccessorProp.Global], renderer: Renderer | string, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
14
+ export declare function createBranch($global: Scope[typeof AccessorProp.Global], renderer: Renderer | string, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
15
15
  export declare function setParentBranch(branch: BranchScope, parentBranch: BranchScope | undefined): void;
16
- export declare function createAndSetupBranch($global: Scope[AccessorProp.Global], renderer: Renderer, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
16
+ export declare function createAndSetupBranch($global: Scope[typeof AccessorProp.Global], renderer: Renderer, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
17
17
  export declare function setupBranch(renderer: Renderer, branch: BranchScope): BranchScope;
18
18
  export declare function _content(id: string, template?: string | 0, walks?: string | 0, setup?: {
19
19
  _: Signal<unknown>;
@@ -1,5 +1,5 @@
1
1
  import { AccessorProp, type BranchScope, type Scope } from "../common/types";
2
- export declare function createScope($global: Scope[AccessorProp.Global], closestBranch?: BranchScope): Scope;
2
+ export declare function createScope($global: Scope[typeof AccessorProp.Global], closestBranch?: BranchScope): Scope;
3
3
  export declare function syncGen(scope: Scope): void;
4
4
  export declare function _assert_init(scope: Scope, accessor: string): any;
5
5
  export declare function collectScopes(fn: () => void): Scope[];
package/dist/dom.js CHANGED
@@ -1314,12 +1314,14 @@ function insertLoaded(renderer, branch, marker, awaitCounter) {
1314
1314
  let parent = marker.parentNode, values = branch.X, insert = () => {
1315
1315
  insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
1316
1316
  }, remaining;
1317
- if (syncGen(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
1318
- entry.b = signal, --remaining || queueAsyncRender(branch, (branch) => {
1319
- syncGen(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
1320
- });
1321
- }, () => 0);
1322
- else setupBranch(renderer, branch), insert();
1317
+ if (syncGen(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) {
1318
+ let fail = loadFailed(branch, awaitCounter);
1319
+ for (let [promise, entry] of values) promise.then((signal) => {
1320
+ entry.b = signal, --remaining || queueAsyncRender(branch, (branch) => {
1321
+ syncGen(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
1322
+ });
1323
+ }, (error) => remaining > 0 && (remaining = 0, fail(error)));
1324
+ } else setupBranch(renderer, branch), insert();
1323
1325
  }
1324
1326
  function loadFailed(scope, awaitCounter) {
1325
1327
  return (error) => {
package/dist/dom.mjs CHANGED
@@ -1313,12 +1313,14 @@ function insertLoaded(renderer, branch, marker, awaitCounter) {
1313
1313
  let parent = marker.parentNode, values = branch.X, insert = () => {
1314
1314
  insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
1315
1315
  }, remaining;
1316
- if (syncGen(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
1317
- entry.b = signal, --remaining || queueAsyncRender(branch, (branch) => {
1318
- syncGen(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
1319
- });
1320
- }, () => 0);
1321
- else setupBranch(renderer, branch), insert();
1316
+ if (syncGen(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) {
1317
+ let fail = loadFailed(branch, awaitCounter);
1318
+ for (let [promise, entry] of values) promise.then((signal) => {
1319
+ entry.b = signal, --remaining || queueAsyncRender(branch, (branch) => {
1320
+ syncGen(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
1321
+ });
1322
+ }, (error) => remaining > 0 && (remaining = 0, fail(error)));
1323
+ } else setupBranch(renderer, branch), insert();
1322
1324
  }
1323
1325
  function loadFailed(scope, awaitCounter) {
1324
1326
  return (error) => {
@@ -0,0 +1,11 @@
1
+ export declare const Dollar = 36;
2
+ export declare const Digit0 = 48;
3
+ export declare const Digit9 = 57;
4
+ export declare const UpperA = 65;
5
+ export declare const UpperZ = 90;
6
+ export declare const Underscore = 95;
7
+ export declare const LowerA = 97;
8
+ export declare const LowerZ = 122;
9
+ type Self = typeof import("./char");
10
+ export type Value = Self[keyof Self];
11
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const complete = 0;
2
+ declare const continue_ = 1;
3
+ export { continue_ as continue };
4
+ export declare const aborted = 2;
5
+ type Self = typeof import("./flush-status");
6
+ export type Value = Self[keyof Self];
@@ -0,0 +1,6 @@
1
+ export declare const Placeholder = "!^";
2
+ export declare const PlaceholderEnd = "!";
3
+ export declare const ReorderMarker = "#";
4
+ type Self = typeof import("./mark");
5
+ export type Value = Self[keyof Self];
6
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const Walk = ".w";
2
+ export declare const Resume = ".r";
3
+ export declare const Ready = ".b";
4
+ export declare const Scripts = ".j";
5
+ type Self = typeof import("./runtime-key");
6
+ export type Value = Self[keyof Self];
7
+ export {};