marko 6.3.19 → 6.3.21

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 (64) 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 +189 -42
  27. package/dist/debug/html.mjs +189 -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 +19 -23
  39. package/dist/html.js +128 -29
  40. package/dist/html.mjs +128 -29
  41. package/dist/translator/core/if.d.ts +7 -7
  42. package/dist/translator/core/index.d.ts +7 -7
  43. package/dist/translator/index.d.ts +9 -9
  44. package/dist/translator/index.js +191 -133
  45. package/dist/translator/interop/constants/feature-type.d.ts +5 -0
  46. package/dist/translator/interop/index.d.ts +2 -2
  47. package/dist/translator/util/body-to-text-literal.d.ts +2 -2
  48. package/dist/translator/util/constants/binding-type.d.ts +10 -0
  49. package/dist/translator/util/constants/compile-stage.d.ts +8 -0
  50. package/dist/translator/util/constants/content-type.d.ts +8 -0
  51. package/dist/translator/util/constants/step.d.ts +5 -0
  52. package/dist/translator/util/constants/tag-name-type.d.ts +7 -0
  53. package/dist/translator/util/is-static.d.ts +1 -1
  54. package/dist/translator/util/references.d.ts +5 -12
  55. package/dist/translator/util/sections.d.ts +4 -8
  56. package/dist/translator/util/signals.d.ts +1 -0
  57. package/dist/translator/util/tag-name-type.d.ts +4 -7
  58. package/dist/translator/util/walks.d.ts +4 -6
  59. package/dist/translator/visitors/constants/sibling-text.d.ts +7 -0
  60. package/dist/translator/visitors/placeholder.d.ts +2 -6
  61. package/dist/translator/visitors/tag/constants/class-hydration.d.ts +5 -0
  62. package/dist/translator/visitors/tag/dynamic-tag.d.ts +2 -4
  63. package/package.json +16 -16
  64. package/tags-html.d.ts +98 -22
@@ -19,6 +19,24 @@ 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
+ //#endregion
30
+ //#region src/common/constants/accessor-prop.debug.ts
31
+ const BranchAccessor = "#BranchAccessor";
32
+ const CatchContent = "#CatchContent";
33
+ const ClosestBranchId = "#ClosestBranchId";
34
+ const LoopKey = "#LoopKey";
35
+ const PlaceholderContent = "#PlaceholderContent";
36
+ const Renderer = "#Renderer";
37
+ const TagVariable = "#TagVariable";
38
+ const Embed = "embed";
39
+ //#endregion
22
40
  //#region src/common/helpers.ts
23
41
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
24
42
  const knownWrongAttrs = {
@@ -521,14 +539,15 @@ var State$1 = class {
521
539
  mutated = [];
522
540
  };
523
541
  var Reference = class {
542
+ assigns = null;
543
+ calls = null;
544
+ scopeId = void 0;
545
+ channel = void 0;
524
546
  parent;
525
547
  accessor;
526
548
  flush;
527
549
  pos;
528
550
  id;
529
- assigns = null;
530
- scopeId = void 0;
531
- channel = void 0;
532
551
  constructor(parent, accessor, flush, pos = null, id = null) {
533
552
  this.parent = parent;
534
553
  this.accessor = accessor;
@@ -633,14 +652,31 @@ function writeScopesRoot(state, flushes) {
633
652
  function writeAssigned(state) {
634
653
  let sep = state.buf.length ? "," : "";
635
654
  if (state.assigned.size) {
655
+ const assigned = state.assigned;
656
+ state.assigned = /* @__PURE__ */ new Set();
636
657
  let buf = "";
637
- for (const ref of state.assigned) {
638
- buf += sep + assignsToString(ref.assigns, ref.id);
639
- ref.assigns = null;
640
- sep = ",";
658
+ 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;
663
+ sep = ",";
664
+ }
665
+ hasCalls ||= ref.calls !== null;
666
+ }
667
+ if (buf) state.buf.push(buf);
668
+ if (hasCalls) for (const ref of assigned) {
669
+ if (!ref.calls) continue;
670
+ for (const { method, args } of ref.calls) {
671
+ state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
672
+ for (let a = 0; a < args.length; a++) {
673
+ if (a) state.buf.push(",");
674
+ writeCallArg(state, args[a]);
675
+ }
676
+ state.buf.push(")");
677
+ }
678
+ ref.calls = null;
641
679
  }
642
- state.buf.push(buf);
643
- state.assigned = /* @__PURE__ */ new Set();
644
680
  }
645
681
  if (hasChannelMutations(state)) {
646
682
  const remaining = [];
@@ -675,8 +711,14 @@ function writeAssigned(state) {
675
711
  state.buf.push(")");
676
712
  }
677
713
  state.mutated = remaining;
678
- if (state.assigned.size) writeAssigned(state);
679
714
  }
715
+ if (state.assigned.size) writeAssigned(state);
716
+ }
717
+ function writeCallArg(state, val) {
718
+ if (val === void 0) {
719
+ state.wroteUndefined = true;
720
+ state.buf.push("$");
721
+ } else if (!writeProp(state, val, null, "")) state.buf.push("void 0");
680
722
  }
681
723
  function hasChannelMutations(state) {
682
724
  return hasMatchingMutations(state.mutated, state.channel?.readyId);
@@ -871,6 +913,7 @@ function writeUnknownObject(state, val, ref) {
871
913
  case Float64Array:
872
914
  case BigInt64Array:
873
915
  case BigUint64Array: return writeTypedArray(state, val, ref);
916
+ case DataView: return writeDataView(state, val, ref);
874
917
  case WeakSet: return writeWeakSet(state);
875
918
  case WeakMap: return writeWeakMap(state);
876
919
  case globalThis.URL: return writeURL(state, val);
@@ -880,6 +923,24 @@ function writeUnknownObject(state, val, ref) {
880
923
  case globalThis.ReadableStream: return writeReadableStream(state, val, ref);
881
924
  case globalThis.Request: return writeRequest(state, val, ref);
882
925
  case globalThis.Response: return writeResponse(state, val, ref);
926
+ case globalThis.Intl?.NumberFormat: return writeIntl(state, val, "NumberFormat", ref);
927
+ case globalThis.Intl?.DateTimeFormat: return writeIntl(state, val, "DateTimeFormat", ref);
928
+ case globalThis.Intl?.Collator: return writeIntl(state, val, "Collator", ref);
929
+ case globalThis.Intl?.PluralRules: return writeIntl(state, val, "PluralRules", ref);
930
+ case globalThis.Intl?.RelativeTimeFormat: return writeIntl(state, val, "RelativeTimeFormat", ref);
931
+ case globalThis.Intl?.ListFormat: return writeIntl(state, val, "ListFormat", ref);
932
+ case globalThis.Intl?.DisplayNames: return writeIntl(state, val, "DisplayNames", ref);
933
+ case globalThis.Intl?.Segmenter: return writeIntl(state, val, "Segmenter", ref);
934
+ case globalThis.Intl?.DurationFormat: return writeIntl(state, val, "DurationFormat", ref);
935
+ case globalThis.Intl?.Locale: return writeIntlLocale(state, val);
936
+ case globalThis.Temporal?.Instant: return writeTemporal(state, val, "Instant");
937
+ case globalThis.Temporal?.Duration: return writeTemporal(state, val, "Duration");
938
+ case globalThis.Temporal?.PlainDate: return writeTemporal(state, val, "PlainDate");
939
+ case globalThis.Temporal?.PlainDateTime: return writeTemporal(state, val, "PlainDateTime");
940
+ case globalThis.Temporal?.PlainMonthDay: return writeTemporal(state, val, "PlainMonthDay");
941
+ case globalThis.Temporal?.PlainTime: return writeTemporal(state, val, "PlainTime");
942
+ case globalThis.Temporal?.PlainYearMonth: return writeTemporal(state, val, "PlainYearMonth");
943
+ case globalThis.Temporal?.ZonedDateTime: return writeTemporal(state, val, "ZonedDateTime");
883
944
  }
884
945
  throwUnserializable(state, val, ref);
885
946
  return false;
@@ -948,9 +1009,15 @@ function writeMap(state, val, ref) {
948
1009
  const items = [];
949
1010
  let assigns;
950
1011
  let needsId;
1012
+ let deferring = false;
951
1013
  let i = 0;
952
1014
  if (val.size < 25) {
953
1015
  for (let [itemKey, itemValue] of val) {
1016
+ if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
1017
+ if (deferring) {
1018
+ deferCall(state, ref, "set", [itemKey, itemValue]);
1019
+ continue;
1020
+ }
954
1021
  if (itemKey === val) {
955
1022
  itemKey = void 0;
956
1023
  (assigns ||= []).push("a[" + i + "][0]");
@@ -965,6 +1032,11 @@ function writeMap(state, val, ref) {
965
1032
  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
1033
  } else {
967
1034
  for (let [itemKey, itemValue] of val) {
1035
+ if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
1036
+ if (deferring) {
1037
+ deferCall(state, ref, "set", [itemKey, itemValue]);
1038
+ continue;
1039
+ }
968
1040
  if (itemKey === val) {
969
1041
  itemKey = 0;
970
1042
  (assigns ||= []).push("a[" + i + "]");
@@ -988,8 +1060,14 @@ function writeSet(state, val, ref) {
988
1060
  const items = [];
989
1061
  let assigns;
990
1062
  let needsId;
1063
+ let deferring = false;
991
1064
  let i = 0;
992
1065
  for (let item of val) {
1066
+ if (!deferring && item !== val && isAncestorMember(state, ref, item)) deferring = true;
1067
+ if (deferring) {
1068
+ deferCall(state, ref, "add", [item]);
1069
+ continue;
1070
+ }
993
1071
  if (item === val) {
994
1072
  item = 0;
995
1073
  (assigns ||= []).push("i[" + i + "]");
@@ -999,6 +1077,19 @@ function writeSet(state, val, ref) {
999
1077
  writeArrayArg(state, ref, items, assigns && "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
1000
1078
  return true;
1001
1079
  }
1080
+ function isAncestorMember(state, container, member) {
1081
+ if (member === null || typeof member !== "object" && typeof member !== "function") return false;
1082
+ const ref = state.refs.get(member);
1083
+ return ref !== void 0 && isCircular(container, ref);
1084
+ }
1085
+ function deferCall(state, ref, method, args) {
1086
+ ensureId(state, ref);
1087
+ (ref.calls ||= []).push({
1088
+ method,
1089
+ args
1090
+ });
1091
+ state.assigned.add(ref);
1092
+ }
1002
1093
  function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
1003
1094
  if (assignsPrefix || needsId) {
1004
1095
  const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
@@ -1019,6 +1110,20 @@ function isDedupedMember(val) {
1019
1110
  default: return false;
1020
1111
  }
1021
1112
  }
1113
+ function canWriteBuffer(state, buffer, ref) {
1114
+ if (Object.getPrototypeOf(buffer)?.constructor === ArrayBuffer) return true;
1115
+ throwUnserializable(state, buffer, ref, "buffer");
1116
+ return false;
1117
+ }
1118
+ function writeDataView(state, val, ref) {
1119
+ const { buffer } = val;
1120
+ if (!canWriteBuffer(state, buffer, ref)) return false;
1121
+ const needsLength = val.byteOffset + val.byteLength < buffer.byteLength;
1122
+ state.buf.push("new DataView(");
1123
+ writeProp(state, buffer, ref, "buffer");
1124
+ state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.byteLength : "") : "") + ")");
1125
+ return true;
1126
+ }
1022
1127
  function writeArrayBuffer(state, val) {
1023
1128
  let result;
1024
1129
  if (val.byteLength) {
@@ -1030,6 +1135,7 @@ function writeArrayBuffer(state, val) {
1030
1135
  }
1031
1136
  function writeTypedArray(state, val, ref) {
1032
1137
  if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
1138
+ if (!canWriteBuffer(state, val.buffer, ref)) return false;
1033
1139
  const needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
1034
1140
  state.buf.push("new " + val.constructor.name + "(");
1035
1141
  writeProp(state, val.buffer, ref, "buffer");
@@ -1189,6 +1295,34 @@ function writeResponse(state, val, ref) {
1189
1295
  }
1190
1296
  return true;
1191
1297
  }
1298
+ function writeIntl(state, val, name, ref) {
1299
+ const { locale, ...options } = val.resolvedOptions();
1300
+ let needsId = false;
1301
+ for (const key in options) if (isDedupedMember(options[key])) {
1302
+ needsId = true;
1303
+ break;
1304
+ }
1305
+ state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
1306
+ let optionsRef;
1307
+ if (needsId) {
1308
+ optionsRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1309
+ state.buf.push(optionsRef.id + "={");
1310
+ } else {
1311
+ optionsRef = new Reference(ref, null, state.flush, state.buf.length);
1312
+ state.buf.push("{");
1313
+ }
1314
+ writeObjectProps(state, options, optionsRef);
1315
+ state.buf.push("})");
1316
+ return true;
1317
+ }
1318
+ function writeIntlLocale(state, val) {
1319
+ state.buf.push("new Intl.Locale(" + quote(val.toString(), 0) + ")");
1320
+ return true;
1321
+ }
1322
+ function writeTemporal(state, val, name) {
1323
+ state.buf.push("Temporal." + name + ".from(" + quote(val.toString(), 0) + ")");
1324
+ return true;
1325
+ }
1192
1326
  function writeReadableStream(state, val, ref) {
1193
1327
  const { boundary, channel } = state;
1194
1328
  if (!boundary || val.locked) return false;
@@ -1343,6 +1477,7 @@ function throwUnserializable(state, cause, ref = null, accessor = "") {
1343
1477
  if (accessor) access = toAccess(accessor) + access;
1344
1478
  if (access[0] === ".") access = access.slice(1);
1345
1479
  if (access) message += ` (reading ${access})`;
1480
+ message += ". Values referenced in the browser must be serializable.";
1346
1481
  const err = new TypeError(message, { cause });
1347
1482
  err.stack = void 0;
1348
1483
  state.boundary.abort(err);
@@ -1795,7 +1930,7 @@ function _sep(shouldResume) {
1795
1930
  }
1796
1931
  function _resume_branch(scopeId) {
1797
1932
  const branchId = $chunk.context?.[kBranchId];
1798
- if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
1933
+ if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId]: branchId });
1799
1934
  }
1800
1935
  function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1801
1936
  const shouldResume = serializeReason !== 0;
@@ -1805,8 +1940,8 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1805
1940
  else render();
1806
1941
  if (_peek_scope_id() !== branchId) {
1807
1942
  if (shouldResume) writeScope(scopeId, {
1808
- ["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
1809
- ["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
1943
+ [BranchScopes + nodeAccessor]: writeScope(branchId, {}),
1944
+ [ConditionalRenderer + nodeAccessor]: render?.["id"]
1810
1945
  });
1811
1946
  } else _scope_id();
1812
1947
  }
@@ -1817,8 +1952,8 @@ function normalizeServerRender(value) {
1817
1952
  }
1818
1953
  function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
1819
1954
  writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
1820
- const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
1821
- if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
1955
+ const childScope = writeScopePassive(childScopeId, { [TagVariable]: _resume({}, registryId, parentScopeId) });
1956
+ if (nodeAccessor !== void 0) writeScope(parentScopeId, { [BranchScopes + nodeAccessor]: childScope });
1822
1957
  }
1823
1958
  function writeScopePassive(scopeId, partialScope) {
1824
1959
  const target = $chunk.serializeState;
@@ -1894,11 +2029,11 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
1894
2029
  }
1895
2030
  withBranchId(branchId, () => {
1896
2031
  render();
1897
- const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { ["#LoopKey"]: itemKey } : {});
2032
+ const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { [LoopKey]: itemKey } : {});
1898
2033
  if (!resumeMarker) loopScopes = push(loopScopes, branchScope);
1899
2034
  });
1900
2035
  });
1901
- if (loopScopes) writeScope(scopeId, { ["BranchScopes:" + accessor]: loopScopes });
2036
+ if (loopScopes) writeScope(scopeId, { [BranchScopes + accessor]: loopScopes });
1902
2037
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1903
2038
  }
1904
2039
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
@@ -1910,8 +2045,8 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
1910
2045
  const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
1911
2046
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1912
2047
  if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
1913
- ["ConditionalRenderer:" + accessor]: branchIndex || void 0,
1914
- ["BranchScopes:" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
2048
+ [ConditionalRenderer + accessor]: branchIndex || void 0,
2049
+ [BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
1915
2050
  });
1916
2051
  writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
1917
2052
  }
@@ -2044,9 +2179,9 @@ function _try(scopeId, accessor, content, input) {
2044
2179
  else if (placeholderContent) tryPlaceholder(content, placeholderContent, branchId);
2045
2180
  else content();
2046
2181
  writeScope(branchId, {
2047
- ["#BranchAccessor"]: accessor,
2048
- ["#CatchContent"]: catchContent,
2049
- ["#PlaceholderContent"]: placeholderContent
2182
+ [BranchAccessor]: accessor,
2183
+ [CatchContent]: catchContent,
2184
+ [PlaceholderContent]: placeholderContent
2050
2185
  });
2051
2186
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2052
2187
  }
@@ -2119,7 +2254,6 @@ function tryCatch(content, catchContent) {
2119
2254
  }
2120
2255
  const NOOP$2 = () => {};
2121
2256
  var State = class {
2122
- $global;
2123
2257
  tagId = 1;
2124
2258
  scopeId = 1;
2125
2259
  reorderId = 1;
@@ -2141,6 +2275,7 @@ var State = class {
2141
2275
  writeScopes = {};
2142
2276
  readyIds = null;
2143
2277
  serializeReason;
2278
+ $global;
2144
2279
  constructor($global) {
2145
2280
  this.$global = $global;
2146
2281
  if ($global.cspNonce) this.nonceAttr = " nonce" + attrAssignment($global.cspNonce);
@@ -2183,10 +2318,10 @@ var State = class {
2183
2318
  }
2184
2319
  };
2185
2320
  var Boundary = class extends AbortController {
2186
- state;
2187
- parent;
2188
2321
  onNext = NOOP$2;
2189
2322
  count = 0;
2323
+ state;
2324
+ parent;
2190
2325
  constructor(state, signal, parent) {
2191
2326
  super();
2192
2327
  this.state = state;
@@ -2216,10 +2351,6 @@ var Boundary = class extends AbortController {
2216
2351
  }
2217
2352
  };
2218
2353
  var Chunk = class Chunk {
2219
- boundary;
2220
- next;
2221
- context;
2222
- serializeState;
2223
2354
  html = "";
2224
2355
  scripts = "";
2225
2356
  effects = "";
@@ -2230,6 +2361,10 @@ var Chunk = class Chunk {
2230
2361
  reorderId = null;
2231
2362
  deferredReady = null;
2232
2363
  placeholder = null;
2364
+ boundary;
2365
+ next;
2366
+ context;
2367
+ serializeState;
2233
2368
  constructor(boundary, next, context, serializeState) {
2234
2369
  this.boundary = boundary;
2235
2370
  this.next = next;
@@ -2725,7 +2860,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2725
2860
  if (isEventHandler(name)) {
2726
2861
  if (!events) {
2727
2862
  events = {};
2728
- writeScope(scopeId, { ["EventAttributes:" + nodeAccessor]: events });
2863
+ writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
2729
2864
  }
2730
2865
  events[getEventHandlerName(name)] = value;
2731
2866
  } else result += nonVoidAttr(name, value);
@@ -2754,12 +2889,12 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
2754
2889
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2755
2890
  assertHandlerIsFunction("valueChange", valueChange);
2756
2891
  writeScope(scopeId, serializeType ? {
2757
- ["ControlledType:" + nodeAccessor]: type,
2758
- ["ControlledValue:" + nodeAccessor]: value,
2759
- ["ControlledHandler:" + nodeAccessor]: valueChange
2892
+ [ControlledType + nodeAccessor]: type,
2893
+ [ControlledValue + nodeAccessor]: value,
2894
+ [ControlledHandler + nodeAccessor]: valueChange
2760
2895
  } : {
2761
- ["ControlledValue:" + nodeAccessor]: value,
2762
- ["ControlledHandler:" + nodeAccessor]: valueChange
2896
+ [ControlledValue + nodeAccessor]: value,
2897
+ [ControlledHandler + nodeAccessor]: valueChange
2763
2898
  });
2764
2899
  }
2765
2900
  function stringAttr(name, value) {
@@ -2834,7 +2969,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2834
2969
  const childScope = getScopeById(branchId);
2835
2970
  const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
2836
2971
  if (needsScript) {
2837
- writeScope(branchId, { ["#Renderer"]: renderer });
2972
+ writeScope(branchId, { [Renderer]: renderer });
2838
2973
  _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2839
2974
  }
2840
2975
  if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
@@ -2859,7 +2994,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2859
2994
  if (shouldResume) _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
2860
2995
  }
2861
2996
  if (rendered) {
2862
- if (shouldResume) writeScope(scopeId, { ["ConditionalRenderer:" + accessor]: renderer?.["id"] || renderer });
2997
+ if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer?.["id"] || renderer });
2863
2998
  } else _scope_id();
2864
2999
  return result;
2865
3000
  };
@@ -2882,7 +3017,7 @@ const patchDynamicTag = ((originalDynamicTag) => (patch) => {
2882
3017
  const CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result";
2883
3018
  const _template = (templateId, renderer, page) => {
2884
3019
  renderer.render = render;
2885
- renderer["embed"] = !page;
3020
+ renderer[Embed] = !page;
2886
3021
  renderer._ = renderer;
2887
3022
  renderer.mount = () => {
2888
3023
  throw new Error(`mount() is not implemented for the HTML compilation of a Marko template`);
@@ -2936,7 +3071,9 @@ var ServerRendered = class {
2936
3071
  const boundary = this.#read((html) => {
2937
3072
  value += html;
2938
3073
  if (resolve) {
2939
- resolve({
3074
+ const settle = resolve;
3075
+ resolve = reject = void 0;
3076
+ settle({
2940
3077
  value,
2941
3078
  done
2942
3079
  });
@@ -2945,11 +3082,17 @@ var ServerRendered = class {
2945
3082
  }, (err) => {
2946
3083
  aborted = true;
2947
3084
  reason = err;
2948
- if (reject) reject(err);
3085
+ if (reject) {
3086
+ const settle = reject;
3087
+ resolve = reject = void 0;
3088
+ settle(err);
3089
+ }
2949
3090
  }, () => {
2950
3091
  done = true;
2951
3092
  if (resolve) {
2952
- resolve({
3093
+ const settle = resolve;
3094
+ resolve = reject = void 0;
3095
+ settle({
2953
3096
  value,
2954
3097
  done: !value
2955
3098
  });
@@ -3169,6 +3312,10 @@ function addAsset(g, id, triggers) {
3169
3312
  id,
3170
3313
  triggers
3171
3314
  });
3315
+ else {
3316
+ const existing = assets.find((a) => a.id === id);
3317
+ if (JSON.stringify(existing.triggers) !== JSON.stringify(triggers)) console.error(`The lazy asset "${id}" is imported with different \`load\` triggers; an asset must use one consistent trigger.`);
3318
+ }
3172
3319
  }
3173
3320
  function writeTriggerScript(html, triggers) {
3174
3321
  const htmlStr = _escape_script(JSON.stringify(html));
@@ -3258,7 +3405,7 @@ const compat = {
3258
3405
  render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
3259
3406
  const state = this.ensureState(classAPIOut.global);
3260
3407
  const boundary = new Boundary(state);
3261
- let head = new Chunk(boundary, null, null, state);
3408
+ let head = new Chunk(boundary, null, getChunk()?.context ?? null, state);
3262
3409
  let normalizedInput = input;
3263
3410
  if ("renderBody" in input) {
3264
3411
  normalizedInput = {};
@@ -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 {};