marko 6.2.5 → 6.3.1

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.
package/dist/html.js CHANGED
@@ -238,10 +238,10 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
238
238
  [JSON, "JSON"],
239
239
  [Math, "Math"],
240
240
  [Reflect, "Reflect"]
241
- ]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
241
+ ]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
242
242
  let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
243
243
  return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
244
- }, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g, doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g, needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
244
+ }, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
245
245
  let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
246
246
  if (typeof renderer == "string") {
247
247
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
@@ -643,7 +643,7 @@ function writeObject(state, val, parent, accessor) {
643
643
  return wellKnownObject ? (state.buf.push(wellKnownObject), !0) : writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
644
644
  }
645
645
  function writeUnknownObject(state, val, ref) {
646
- switch (val.constructor) {
646
+ switch (Object.getPrototypeOf(val)?.constructor) {
647
647
  case void 0: return writeNullObject(state, val, ref);
648
648
  case Object: return writePlainObject(state, val, ref);
649
649
  case Array: return writeArray(state, val, ref);
@@ -769,10 +769,14 @@ function writeWeakMap(state) {
769
769
  }
770
770
  function writeError(state, val, ref) {
771
771
  let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
772
- return val.cause === void 0 ? state.buf.push(result + ")") : (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")), !0;
772
+ if (val.cause !== void 0) {
773
+ let pos = state.buf.push(result + ",{cause:") - 1;
774
+ writeProp(state, val.cause, ref, "cause") ? state.buf.push("})") : state.buf[pos] = state.buf[pos].slice(0, -8) + ")";
775
+ } else state.buf.push(result + ")");
776
+ return !0;
773
777
  }
774
778
  function writeAggregateError(state, val, ref) {
775
- return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
779
+ return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors") || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
776
780
  }
777
781
  function writeURL(state, val) {
778
782
  return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
@@ -903,32 +907,45 @@ function toAccess(accessor) {
903
907
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
904
908
  }
905
909
  function quote(str, startPos) {
910
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
906
911
  let result = "", lastPos = 0;
907
912
  for (let i = startPos; i < str.length; i++) {
908
- let replacement;
909
- switch (str[i]) {
910
- case "\"":
913
+ let replacement, code = str.charCodeAt(i);
914
+ switch (code) {
915
+ case 34:
911
916
  replacement = "\\\"";
912
917
  break;
913
- case "\\":
918
+ case 92:
914
919
  replacement = "\\\\";
915
920
  break;
916
- case "<":
921
+ case 60:
917
922
  replacement = "\\x3C";
918
923
  break;
919
- case "\n":
924
+ case 10:
920
925
  replacement = "\\n";
921
926
  break;
922
- case "\r":
927
+ case 13:
923
928
  replacement = "\\r";
924
929
  break;
925
- case "\u2028":
930
+ case 8232:
926
931
  replacement = "\\u2028";
927
932
  break;
928
- case "\u2029":
933
+ case 8233:
929
934
  replacement = "\\u2029";
930
935
  break;
931
- default: continue;
936
+ case 0:
937
+ replacement = "\\x00";
938
+ break;
939
+ default:
940
+ if (code < 55296 || code > 57343) continue;
941
+ if (code < 56320) {
942
+ let next = str.charCodeAt(i + 1);
943
+ if (next >= 56320 && next <= 57343) {
944
+ i++;
945
+ continue;
946
+ }
947
+ }
948
+ replacement = "\\u" + code.toString(16);
932
949
  }
933
950
  result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
934
951
  }
@@ -1278,7 +1295,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1278
1295
  let branchId = _peek_scope_id();
1279
1296
  $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1280
1297
  } else withIsAsync(content, value);
1281
- }), boundary.endAsync(chunk)));
1298
+ }), boundary.endAsync()));
1282
1299
  }, (err) => {
1283
1300
  chunk.async = !1, boundary.abort(err);
1284
1301
  });
@@ -1306,7 +1323,7 @@ function tryPlaceholder(content, placeholder, branchId) {
1306
1323
  };
1307
1324
  }
1308
1325
  function tryCatch(content, catchContent) {
1309
- let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
1326
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
1310
1327
  if (catchBoundary.signal.aborted) {
1311
1328
  catchContent(catchBoundary.signal.reason);
1312
1329
  return;
@@ -1384,13 +1401,14 @@ var State = class {
1384
1401
  }
1385
1402
  }, Boundary = class extends AbortController {
1386
1403
  state;
1404
+ parent;
1387
1405
  onNext = NOOP$2;
1388
1406
  count = 0;
1389
- constructor(state, parent) {
1390
- super(), this.state = state, this.signal.addEventListener("abort", () => {
1407
+ constructor(state, signal, parent) {
1408
+ super(), this.state = state, this.parent = parent, this.signal.addEventListener("abort", () => {
1391
1409
  this.count = 0, this.state = new State(this.state.$global), this.onNext();
1392
- }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1393
- this.abort(parent.reason);
1410
+ }), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
1411
+ this.abort(signal.reason);
1394
1412
  }));
1395
1413
  }
1396
1414
  flush() {
@@ -1399,8 +1417,8 @@ var State = class {
1399
1417
  startAsync() {
1400
1418
  this.signal.aborted || this.count++;
1401
1419
  }
1402
- endAsync(chunk) {
1403
- !this.signal.aborted && this.count && (this.count--, chunk?.reorderId && this.state.reorder(chunk), this.onNext());
1420
+ endAsync() {
1421
+ !this.signal.aborted && this.count && (this.count--, this.onNext());
1404
1422
  }
1405
1423
  }, Chunk = class Chunk {
1406
1424
  boundary;
@@ -1505,20 +1523,30 @@ var State = class {
1505
1523
  readyResumeScripts && (needsWalk = !0);
1506
1524
  let effects = this.async ? "" : this.effects, { html, scripts } = this;
1507
1525
  if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
1508
- needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
1526
+ let carried = null;
1509
1527
  for (let reorderedChunk of state.writeReorders) {
1528
+ if (reorderedChunk.async && reorderedChunk.consumed) {
1529
+ let aborted = reorderedChunk.boundary;
1530
+ for (; aborted && !aborted.signal.aborted;) aborted = aborted.parent;
1531
+ if (!aborted) {
1532
+ (carried ||= []).push(reorderedChunk);
1533
+ continue;
1534
+ }
1535
+ reorderedChunk.async = !1;
1536
+ }
1537
+ needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
1510
1538
  let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1511
1539
  for (reorderedChunk.reorderId = null;;) {
1512
1540
  cur.flushPlaceholder(), cur.deferOwnReady();
1513
1541
  let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations);
1514
- if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
1542
+ if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), state.reorder(cur), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
1515
1543
  else break;
1516
1544
  }
1517
1545
  reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
1518
1546
  for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
1519
1547
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1520
1548
  }
1521
- state.writeReorders = null;
1549
+ state.writeReorders = carried;
1522
1550
  }
1523
1551
  return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1524
1552
  }
@@ -1744,9 +1772,6 @@ function nonVoidAttr(name, value) {
1744
1772
  case "string": return " " + name + attrAssignment(value);
1745
1773
  case "boolean": return " " + name;
1746
1774
  case "number": return " " + name + "=" + value;
1747
- case "object":
1748
- if (value instanceof RegExp) return " " + name + attrAssignment(value.source);
1749
- break;
1750
1775
  }
1751
1776
  return " " + name + attrAssignment(value + "");
1752
1777
  }
package/dist/html.mjs CHANGED
@@ -238,10 +238,10 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
238
238
  [JSON, "JSON"],
239
239
  [Math, "Math"],
240
240
  [Reflect, "Reflect"]
241
- ]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
241
+ ]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
242
242
  let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
243
243
  return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
244
- }, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g, doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g, needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
244
+ }, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
245
245
  let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
246
246
  if (typeof renderer == "string") {
247
247
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
@@ -642,7 +642,7 @@ function writeObject(state, val, parent, accessor) {
642
642
  return wellKnownObject ? (state.buf.push(wellKnownObject), !0) : writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
643
643
  }
644
644
  function writeUnknownObject(state, val, ref) {
645
- switch (val.constructor) {
645
+ switch (Object.getPrototypeOf(val)?.constructor) {
646
646
  case void 0: return writeNullObject(state, val, ref);
647
647
  case Object: return writePlainObject(state, val, ref);
648
648
  case Array: return writeArray(state, val, ref);
@@ -768,10 +768,14 @@ function writeWeakMap(state) {
768
768
  }
769
769
  function writeError(state, val, ref) {
770
770
  let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
771
- return val.cause === void 0 ? state.buf.push(result + ")") : (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")), !0;
771
+ if (val.cause !== void 0) {
772
+ let pos = state.buf.push(result + ",{cause:") - 1;
773
+ writeProp(state, val.cause, ref, "cause") ? state.buf.push("})") : state.buf[pos] = state.buf[pos].slice(0, -8) + ")";
774
+ } else state.buf.push(result + ")");
775
+ return !0;
772
776
  }
773
777
  function writeAggregateError(state, val, ref) {
774
- return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
778
+ return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors") || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
775
779
  }
776
780
  function writeURL(state, val) {
777
781
  return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
@@ -902,32 +906,45 @@ function toAccess(accessor) {
902
906
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
903
907
  }
904
908
  function quote(str, startPos) {
909
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
905
910
  let result = "", lastPos = 0;
906
911
  for (let i = startPos; i < str.length; i++) {
907
- let replacement;
908
- switch (str[i]) {
909
- case "\"":
912
+ let replacement, code = str.charCodeAt(i);
913
+ switch (code) {
914
+ case 34:
910
915
  replacement = "\\\"";
911
916
  break;
912
- case "\\":
917
+ case 92:
913
918
  replacement = "\\\\";
914
919
  break;
915
- case "<":
920
+ case 60:
916
921
  replacement = "\\x3C";
917
922
  break;
918
- case "\n":
923
+ case 10:
919
924
  replacement = "\\n";
920
925
  break;
921
- case "\r":
926
+ case 13:
922
927
  replacement = "\\r";
923
928
  break;
924
- case "\u2028":
929
+ case 8232:
925
930
  replacement = "\\u2028";
926
931
  break;
927
- case "\u2029":
932
+ case 8233:
928
933
  replacement = "\\u2029";
929
934
  break;
930
- default: continue;
935
+ case 0:
936
+ replacement = "\\x00";
937
+ break;
938
+ default:
939
+ if (code < 55296 || code > 57343) continue;
940
+ if (code < 56320) {
941
+ let next = str.charCodeAt(i + 1);
942
+ if (next >= 56320 && next <= 57343) {
943
+ i++;
944
+ continue;
945
+ }
946
+ }
947
+ replacement = "\\u" + code.toString(16);
931
948
  }
932
949
  result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
933
950
  }
@@ -1277,7 +1294,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1277
1294
  let branchId = _peek_scope_id();
1278
1295
  $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1279
1296
  } else withIsAsync(content, value);
1280
- }), boundary.endAsync(chunk)));
1297
+ }), boundary.endAsync()));
1281
1298
  }, (err) => {
1282
1299
  chunk.async = !1, boundary.abort(err);
1283
1300
  });
@@ -1305,7 +1322,7 @@ function tryPlaceholder(content, placeholder, branchId) {
1305
1322
  };
1306
1323
  }
1307
1324
  function tryCatch(content, catchContent) {
1308
- let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
1325
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
1309
1326
  if (catchBoundary.signal.aborted) {
1310
1327
  catchContent(catchBoundary.signal.reason);
1311
1328
  return;
@@ -1383,13 +1400,14 @@ var State = class {
1383
1400
  }
1384
1401
  }, Boundary = class extends AbortController {
1385
1402
  state;
1403
+ parent;
1386
1404
  onNext = NOOP$2;
1387
1405
  count = 0;
1388
- constructor(state, parent) {
1389
- super(), this.state = state, this.signal.addEventListener("abort", () => {
1406
+ constructor(state, signal, parent) {
1407
+ super(), this.state = state, this.parent = parent, this.signal.addEventListener("abort", () => {
1390
1408
  this.count = 0, this.state = new State(this.state.$global), this.onNext();
1391
- }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1392
- this.abort(parent.reason);
1409
+ }), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
1410
+ this.abort(signal.reason);
1393
1411
  }));
1394
1412
  }
1395
1413
  flush() {
@@ -1398,8 +1416,8 @@ var State = class {
1398
1416
  startAsync() {
1399
1417
  this.signal.aborted || this.count++;
1400
1418
  }
1401
- endAsync(chunk) {
1402
- !this.signal.aborted && this.count && (this.count--, chunk?.reorderId && this.state.reorder(chunk), this.onNext());
1419
+ endAsync() {
1420
+ !this.signal.aborted && this.count && (this.count--, this.onNext());
1403
1421
  }
1404
1422
  }, Chunk = class Chunk {
1405
1423
  boundary;
@@ -1504,20 +1522,30 @@ var State = class {
1504
1522
  readyResumeScripts && (needsWalk = !0);
1505
1523
  let effects = this.async ? "" : this.effects, { html, scripts } = this;
1506
1524
  if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
1507
- needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
1525
+ let carried = null;
1508
1526
  for (let reorderedChunk of state.writeReorders) {
1527
+ if (reorderedChunk.async && reorderedChunk.consumed) {
1528
+ let aborted = reorderedChunk.boundary;
1529
+ for (; aborted && !aborted.signal.aborted;) aborted = aborted.parent;
1530
+ if (!aborted) {
1531
+ (carried ||= []).push(reorderedChunk);
1532
+ continue;
1533
+ }
1534
+ reorderedChunk.async = !1;
1535
+ }
1536
+ needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
1509
1537
  let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1510
1538
  for (reorderedChunk.reorderId = null;;) {
1511
1539
  cur.flushPlaceholder(), cur.deferOwnReady();
1512
1540
  let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations);
1513
- if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
1541
+ if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), state.reorder(cur), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
1514
1542
  else break;
1515
1543
  }
1516
1544
  reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
1517
1545
  for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
1518
1546
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1519
1547
  }
1520
- state.writeReorders = null;
1548
+ state.writeReorders = carried;
1521
1549
  }
1522
1550
  return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1523
1551
  }
@@ -1743,9 +1771,6 @@ function nonVoidAttr(name, value) {
1743
1771
  case "string": return " " + name + attrAssignment(value);
1744
1772
  case "boolean": return " " + name;
1745
1773
  case "number": return " " + name + "=" + value;
1746
- case "object":
1747
- if (value instanceof RegExp) return " " + name + attrAssignment(value.source);
1748
- break;
1749
1774
  }
1750
1775
  return " " + name + attrAssignment(value + "");
1751
1776
  }