marko 6.3.56 → 6.4.0

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 (81) hide show
  1. package/cheatsheet.md +2 -2
  2. package/dist/common/constants/accessor-prefix.d.ts +1 -0
  3. package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
  4. package/dist/common/constants/accessor-prop.d.ts +3 -0
  5. package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
  6. package/dist/common/types.d.ts +8 -2
  7. package/dist/debug/dom/catch.feat.js +12 -14
  8. package/dist/debug/dom/catch.feat.mjs +12 -14
  9. package/dist/debug/dom/controllable-input.feat.js +1 -1
  10. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-open.feat.js +1 -1
  12. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable-select.feat.js +1 -1
  14. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  16. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  17. package/dist/debug/dom/controllable.feat.js +1 -1
  18. package/dist/debug/dom/controllable.feat.mjs +1 -1
  19. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  20. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  21. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  22. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  23. package/dist/debug/dom/lazy.feat.js +4 -0
  24. package/dist/debug/dom/lazy.feat.mjs +4 -0
  25. package/dist/debug/dom/placeholder.feat.js +1 -1
  26. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  27. package/dist/debug/{dom-DcwejnYg.js → dom-BRO5aArp.js} +232 -178
  28. package/dist/debug/{dom-BeCNT5R5.mjs → dom-Btj2QJhk.mjs} +215 -167
  29. package/dist/debug/dom.js +14 -12
  30. package/dist/debug/dom.mjs +14 -12
  31. package/dist/debug/html.js +603 -517
  32. package/dist/debug/html.mjs +602 -518
  33. package/dist/dom/abort-signal.d.ts +2 -0
  34. package/dist/dom/catch.feat.js +6 -7
  35. package/dist/dom/catch.feat.mjs +5 -7
  36. package/dist/dom/control-flow.d.ts +3 -5
  37. package/dist/dom/controllable-input.feat.js +3 -2
  38. package/dist/dom/controllable-input.feat.mjs +1 -1
  39. package/dist/dom/controllable-open.feat.js +3 -2
  40. package/dist/dom/controllable-open.feat.mjs +1 -1
  41. package/dist/dom/controllable-select.feat.js +3 -2
  42. package/dist/dom/controllable-select.feat.mjs +1 -1
  43. package/dist/dom/controllable-textarea.feat.js +3 -2
  44. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  45. package/dist/dom/controllable.feat.js +3 -2
  46. package/dist/dom/controllable.feat.mjs +1 -1
  47. package/dist/dom/dynamic-tag-script.feat.js +3 -2
  48. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  49. package/dist/dom/dynamic-tag-var.feat.js +2 -1
  50. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  51. package/dist/dom/lazy.feat.d.ts +1 -0
  52. package/dist/dom/lazy.feat.js +4 -0
  53. package/dist/dom/lazy.feat.mjs +4 -0
  54. package/dist/dom/load.d.ts +3 -3
  55. package/dist/dom/placeholder.feat.js +4 -3
  56. package/dist/dom/placeholder.feat.mjs +1 -1
  57. package/dist/dom/queue.d.ts +2 -4
  58. package/dist/dom/resume.d.ts +1 -1
  59. package/dist/dom/scope.d.ts +0 -1
  60. package/dist/{dom-BwNsIevR.mjs → dom-B-v8Gw6T.mjs} +114 -87
  61. package/dist/{dom-QEF0csuC.js → dom-BSsI9OPC.js} +210 -182
  62. package/dist/dom.js +59 -56
  63. package/dist/dom.mjs +34 -32
  64. package/dist/html/attrs.d.ts +2 -0
  65. package/dist/html/writer.d.ts +5 -11
  66. package/dist/html.d.ts +1 -1
  67. package/dist/html.js +362 -317
  68. package/dist/html.mjs +361 -317
  69. package/dist/translator/index.js +791 -650
  70. package/dist/translator/util/binding-has-prop.d.ts +2 -0
  71. package/dist/translator/util/entry-builder.d.ts +2 -0
  72. package/dist/translator/util/generate-uid.d.ts +5 -0
  73. package/dist/translator/util/references.d.ts +3 -2
  74. package/dist/translator/util/runtime.d.ts +3 -3
  75. package/dist/translator/util/sections.d.ts +8 -2
  76. package/dist/translator/util/serialize-reasons.d.ts +2 -2
  77. package/dist/translator/util/setup-work.d.ts +5 -0
  78. package/dist/translator/util/signals.d.ts +5 -7
  79. package/dist/translator/visitors/tag/native-tag.d.ts +1 -0
  80. package/package.json +3 -3
  81. package/dist/translator/util/setup-statements.d.ts +0 -5
package/dist/html.js CHANGED
@@ -1,10 +1,13 @@
1
+ "use strict";
1
2
  let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
3
  let str = "", sep = "", part;
3
- if (val) if (typeof val != "object") str += val;
4
- else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
- else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
4
+ if (val) {
5
+ if (typeof val != "object") str += val;
6
+ else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
7
+ else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
8
+ }
6
9
  return str;
7
- }, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : "&#13;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, "&gt;") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = /* @__PURE__ */ Symbol.for("marko.touchedIterator"), { hasOwnProperty } = {}, objectProto = Object.prototype, arrayProto = Array.prototype, Generator = (/* @__PURE__ */ (function* () {})()).constructor, AsyncGenerator = (/* @__PURE__ */ (async function* () {})()).constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = /* @__PURE__ */ (() => {
10
+ }, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = /* @__PURE__ */ Symbol.for("marko.touchedIterator"), { hasOwnProperty } = {}, objectProto = Object.prototype, arrayProto = Array.prototype, Generator = (/* @__PURE__ */ (function* () {})()).constructor, AsyncGenerator = (/* @__PURE__ */ (async function* () {})()).constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = /* @__PURE__ */ (() => {
8
11
  let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
9
12
  for (let name of Object.getOwnPropertyNames(Symbol)) {
10
13
  let symbol = Symbol[name];
@@ -80,7 +83,6 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
80
83
  [Function, "Function"],
81
84
  [globalThis.atob, "atob"],
82
85
  [globalThis.btoa, "btoa"],
83
- [globalThis.clearImmediate, "clearImmediate"],
84
86
  [globalThis.clearInterval, "clearInterval"],
85
87
  [globalThis.clearTimeout, "clearTimeout"],
86
88
  [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
@@ -88,7 +90,6 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
88
90
  [globalThis.fetch, "fetch"],
89
91
  [globalThis.performance?.now, "performance.now"],
90
92
  [globalThis.queueMicrotask, "queueMicrotask"],
91
- [globalThis.setImmediate, "setImmediate"],
92
93
  [globalThis.setInterval, "setInterval"],
93
94
  [globalThis.setTimeout, "setTimeout"],
94
95
  [globalThis.structuredClone, "structuredClone"],
@@ -244,17 +245,17 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
244
245
  if (ch === "\0") return "\\x00";
245
246
  let code = ch.charCodeAt(0);
246
247
  return code >= 55296 && code <= 57343 ? "\\u" + code.toString(16).padStart(4, "0") : match;
247
- }, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
248
+ }, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
248
249
  let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
249
- return state.needsMainRuntime = !0, countResumeWrite($chunk.boundary), Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
250
- }, CLIENT_ALL = 715827883, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#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) => {
250
+ return state.needsMainRuntime = !0, countResumeWrite($chunk), Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
251
+ }, CLIENT_ALL = 715827883, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : "&#13;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/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) => {
251
252
  let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
252
253
  if (typeof renderer == "string") {
253
254
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
254
255
  rendered = !0, (() => {
255
256
  if (_scope_id(), _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`), !voidElementsReg.test(renderer)) {
256
257
  let renderContent = content || normalizeDynamicRenderer(input.content);
257
- if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
258
+ if (renderer === "textarea") _html(_attrs_textarea_value(branchId, "a", input));
258
259
  else {
259
260
  if (renderContent && typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
260
261
  renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason) : void 0, 1) : renderContent && _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
@@ -303,8 +304,8 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
303
304
  },
304
305
  onFlush(fn) {
305
306
  let { flushHTML } = Chunk.prototype;
306
- Chunk.prototype.flushHTML = function() {
307
- return fn(this), flushHTML.call(this);
307
+ Chunk.prototype.flushHTML = function(boundary) {
308
+ return fn(this), flushHTML.call(this, boundary);
308
309
  };
309
310
  },
310
311
  patchDynamicTag,
@@ -333,15 +334,13 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
333
334
  },
334
335
  flushScript($global, chunk) {
335
336
  chunk ||= this.createChunk($global);
336
- let { boundary } = chunk;
337
- switch (boundary.flush()) {
338
- case 2: throw boundary.signal.reason;
339
- case 1: throw Error("Cannot serialize promise across tags/class compat layer.");
340
- }
341
- return chunk.flushScript().scripts;
337
+ let { boundary } = chunk, scripts = boundary.flush() === 0 ? chunk.flushScript(boundary).scripts : "";
338
+ if (boundary.signal.aborted) throw boundary.signal.reason;
339
+ if (boundary.count) throw Error("Cannot serialize promise across tags/class compat layer.");
340
+ return scripts;
342
341
  },
343
342
  render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
344
- let state = this.ensureState(classAPIOut.global), boundary = new Boundary(state), head = new Chunk(boundary, null, getChunk()?.context ?? null, state), normalizedInput = input;
343
+ let state = this.ensureState(classAPIOut.global), boundary = new Boundary(state), context = getChunk()?.context ?? null, head = new Chunk(boundary, new Chunk(boundary, null, context, state), context, state), normalizedInput = input;
345
344
  if ("renderBody" in input) {
346
345
  normalizedInput = {};
347
346
  for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
@@ -455,27 +454,44 @@ function _el_read_error() {}
455
454
  function _hoist_read_error() {}
456
455
  function _assert_hoist(value) {}
457
456
  //#endregion
458
- //#region src/html/content.ts
459
- function _to_text(val) {
460
- return val || val === 0 ? val + "" : "";
457
+ //#region src/common/for.ts
458
+ function forIn(obj, cb) {
459
+ for (let key in obj) cb(key, obj[key]);
461
460
  }
462
- function _unescaped(val) {
463
- return val ? val + "" : val === 0 ? "0" : "";
461
+ function forOf(list, cb) {
462
+ if (list) {
463
+ let i = 0;
464
+ for (let item of list) cb(item, i++);
465
+ }
464
466
  }
465
- function _escape(val) {
466
- return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
467
+ function forTo(to, from, step, cb) {
468
+ let start = from || 0, delta = step || 1;
469
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
467
470
  }
468
- function _escape_script(val) {
469
- return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
471
+ function forUntil(until, from, step, cb) {
472
+ let start = from || 0, delta = step || 1;
473
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
470
474
  }
471
- function _escape_style(val) {
472
- return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
475
+ //#endregion
476
+ //#region src/common/opt.ts
477
+ function forEach(opt, cb) {
478
+ if (opt) {
479
+ if (Array.isArray(opt)) for (let item of opt) cb(item);
480
+ else cb(opt);
481
+ }
473
482
  }
474
- function _escape_style_value(val) {
475
- return val || val === 0 ? escapeStyleValue(val + "") : "";
483
+ function push(opt, item) {
484
+ return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
476
485
  }
477
- function _escape_comment(val) {
478
- return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
486
+ function concat(opt, other) {
487
+ if (!opt) return other;
488
+ if (!other) return opt;
489
+ if (Array.isArray(opt)) {
490
+ if (Array.isArray(other)) for (let item of other) opt.push(item);
491
+ else opt.push(other);
492
+ return opt;
493
+ }
494
+ return Array.isArray(other) ? [opt, ...other] : [opt, other];
479
495
  }
480
496
  patchIteratorNext(Generator.prototype), patchIteratorNext(AsyncGenerator.prototype);
481
497
  var State$1 = class {
@@ -515,6 +531,8 @@ var State$1 = class {
515
531
  stringifyScopes(flushes, boundary, channel) {
516
532
  try {
517
533
  return this.#state.boundary = boundary, this.#state.channel = channel, writeScopesRoot(this.#state, flushes);
534
+ } catch (err) {
535
+ return abortRender(boundary, err), "";
518
536
  } finally {
519
537
  this.#state.flushId++, this.#state.buf = [];
520
538
  }
@@ -594,10 +612,12 @@ function writeAssigned(state) {
594
612
  objectRef && objectRef.scopeId === void 0 && (objectRef.id ? hasSeen || (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")")) : (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")));
595
613
  } else state.buf.push("void 0");
596
614
  let valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
597
- if (mutation.value !== void 0) if (writeProp(state, mutation.value, null, "")) {
598
- let valueRef = typeof mutation.value == "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
599
- valueRef && !valueRef.id && valueRef.scopeId === void 0 && (valueRef.id = mutation.valueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
600
- } else state.buf.push("void 0");
615
+ if (mutation.value !== void 0) {
616
+ if (writeProp(state, mutation.value, null, "")) {
617
+ let valueRef = typeof mutation.value == "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
618
+ valueRef && !valueRef.id && valueRef.scopeId === void 0 && (valueRef.id = mutation.valueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
619
+ } else state.buf.push("void 0");
620
+ }
601
621
  state.buf.push(")");
602
622
  }
603
623
  state.mutated = remaining;
@@ -717,7 +737,8 @@ function writeUnknownObject(state, val, ref) {
717
737
  let proto = Object.getPrototypeOf(val);
718
738
  if (proto === objectProto) return writePlainObject(state, val, ref);
719
739
  if (proto === arrayProto) return writeArray(state, val, ref);
720
- switch (proto?.constructor) {
740
+ let constructor = proto?.constructor;
741
+ switch (constructor) {
721
742
  case void 0: return writeNullObject(state, val, ref);
722
743
  case Object: return writePlainObject(state, val, ref);
723
744
  case Array: return writeArray(state, val, ref);
@@ -734,7 +755,7 @@ function writeUnknownObject(state, val, ref) {
734
755
  case ReferenceError:
735
756
  case SyntaxError:
736
757
  case TypeError:
737
- case URIError: return writeError(state, val, ref);
758
+ case URIError: return writeError(state, val, constructor.name, ref);
738
759
  case AggregateError: return writeAggregateError(state, val, ref);
739
760
  case ArrayBuffer: return writeArrayBuffer(state, val);
740
761
  case Int8Array:
@@ -747,7 +768,7 @@ function writeUnknownObject(state, val, ref) {
747
768
  case Float32Array:
748
769
  case Float64Array:
749
770
  case BigInt64Array:
750
- case BigUint64Array: return writeTypedArray(state, val, ref);
771
+ case BigUint64Array: return writeTypedArray(state, val, constructor.name, ref);
751
772
  case DataView: return writeDataView(state, val, ref);
752
773
  case WeakSet: return writeWeakSet(state);
753
774
  case WeakMap: return writeWeakMap(state);
@@ -885,12 +906,12 @@ function writeArrayBuffer(state, val) {
885
906
  } else result = "new ArrayBuffer";
886
907
  return state.buf.push(result), !0;
887
908
  }
888
- function writeTypedArray(state, val, ref) {
909
+ function writeTypedArray(state, val, name, ref) {
889
910
  if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
890
911
  if (!canWriteBuffer(state, val.buffer, ref)) return !1;
891
912
  let needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
892
- state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
893
- } else state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null)), state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
913
+ state.buf.push("new " + name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
914
+ } else state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null)), state.buf.push("new " + name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
894
915
  return !0;
895
916
  }
896
917
  function writeWeakSet(state) {
@@ -899,8 +920,8 @@ function writeWeakSet(state) {
899
920
  function writeWeakMap(state) {
900
921
  return state.buf.push("new WeakMap"), !0;
901
922
  }
902
- function writeError(state, val, ref) {
903
- let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
923
+ function writeError(state, val, name, ref) {
924
+ let result = "new " + name + "(" + quote(val.message + "", 0);
904
925
  if (val.cause !== void 0) {
905
926
  let pos = state.buf.push(result + ",{cause:") - 1;
906
927
  writeProp(state, val.cause, ref, "cause") ? state.buf.push("})") : state.buf[pos] = state.buf[pos].slice(0, -8) + ")";
@@ -1067,6 +1088,10 @@ function trackChannel(state, ref) {
1067
1088
  }
1068
1089
  return !1;
1069
1090
  }
1091
+ function abortRender(boundary, err) {
1092
+ for (; boundary.parent;) boundary = boundary.parent;
1093
+ boundary.abort(err);
1094
+ }
1070
1095
  function isCircular(parent, ref) {
1071
1096
  let cur = parent;
1072
1097
  for (; cur;) {
@@ -1079,16 +1104,17 @@ function toObjectKey(name) {
1079
1104
  if (name === "") return "\"\"";
1080
1105
  if (name === "__proto__") return "[\"__proto__\"]";
1081
1106
  let len = name.length, c0 = name.charCodeAt(0);
1082
- if (c0 >= 48 && c0 <= 57) if (c0 === 48) {
1083
- if (len !== 1) return quote(name, 1);
1084
- } else {
1085
- for (let i = 1; i < len; i++) {
1086
- let c = name.charCodeAt(i);
1087
- if (c < 48 || c > 57) return quote(name, i);
1107
+ if (c0 >= 48 && c0 <= 57) {
1108
+ if (c0 === 48) {
1109
+ if (len !== 1) return quote(name, 1);
1110
+ } else {
1111
+ for (let i = 1; i < len; i++) {
1112
+ let c = name.charCodeAt(i);
1113
+ if (c < 48 || c > 57) return quote(name, i);
1114
+ }
1115
+ if (len > 15 && "" + +name !== name) return quote(name, 0);
1088
1116
  }
1089
- if (len > 15 && "" + +name !== name) return quote(name, 0);
1090
- }
1091
- else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
1117
+ } else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
1092
1118
  let c = name.charCodeAt(i);
1093
1119
  if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 95 || c === 36)) return quote(name, i);
1094
1120
  }
@@ -1181,7 +1207,7 @@ function nextRefAccess(state) {
1181
1207
  function nextId(state) {
1182
1208
  let c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = state.ids++, r = c[n % 53];
1183
1209
  for (n = n / 53 | 0; n; n >>>= 6) r += c[n & 63];
1184
- return r;
1210
+ return r === "name" ? nextId(state) : r;
1185
1211
  }
1186
1212
  function hasSymbolIterator(value) {
1187
1213
  return Symbol.iterator in value;
@@ -1219,42 +1245,161 @@ function patchIteratorNext(proto) {
1219
1245
  }, proto.next[kTouchedIterator] = !0;
1220
1246
  }
1221
1247
  //#endregion
1222
- //#region src/common/for.ts
1223
- function forIn(obj, cb) {
1224
- for (let key in obj) cb(key, obj[key]);
1248
+ //#region src/html/attrs.ts
1249
+ function _attr_class(value) {
1250
+ return stringAttr("class", toDelimitedString(value, " ", stringifyClassObject));
1225
1251
  }
1226
- function forOf(list, cb) {
1227
- if (list) {
1228
- let i = 0;
1229
- for (let item of list) cb(item, i++);
1252
+ function _attr_style(value) {
1253
+ return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
1254
+ }
1255
+ function _attr_option_value(value) {
1256
+ let valueAttr = _attr("value", value), selectedValue = getContext(kSelectedValue);
1257
+ return selectedValue !== void 0 && normalizedValueMatches(selectedValue, value) ? valueAttr + " selected" : valueAttr;
1258
+ }
1259
+ function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
1260
+ valueChange && writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType), content && withContext(kSelectedValue, value ?? "", content);
1261
+ }
1262
+ function _attrs_select_value(scopeId, nodeAccessor, data, content) {
1263
+ data && ("value" in data || data.valueChange) ? _attr_select_value(scopeId, nodeAccessor, data.value, data.valueChange, content, 1) : content();
1264
+ }
1265
+ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
1266
+ return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _textarea_value(value);
1267
+ }
1268
+ function _attrs_textarea_value(scopeId, nodeAccessor, data) {
1269
+ return _attr_textarea_value(scopeId, nodeAccessor, data?.value, data?.valueChange, 1);
1270
+ }
1271
+ function _textarea_value(value) {
1272
+ let escaped = _escape(normalizeStrAttrValue(value));
1273
+ return escaped[0] === "\n" ? "\n" + escaped : escaped;
1274
+ }
1275
+ function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
1276
+ return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
1277
+ }
1278
+ function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
1279
+ return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType), isNotVoid(checked) ? " checked" : "";
1280
+ }
1281
+ function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
1282
+ let valueAttr = _attr("value", value);
1283
+ return checkedValueChange && writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType), normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
1284
+ }
1285
+ function getCheckedValueRef(checkedValue) {
1286
+ if (Array.isArray(checkedValue)) {
1287
+ let ref = checkedValuesRefs.get(checkedValue);
1288
+ return ref || (ref = [], checkedValuesRefs.set(checkedValue, ref)), ref;
1230
1289
  }
1231
1290
  }
1232
- function forTo(to, from, step, cb) {
1233
- let start = from || 0, delta = step || 1;
1234
- for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
1291
+ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
1292
+ let normalizedOpen = isNotVoid(open);
1293
+ return openChange && writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType), normalizedOpen ? " open" : "";
1235
1294
  }
1236
- function forUntil(until, from, step, cb) {
1237
- let start = from || 0, delta = step || 1;
1238
- for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
1295
+ function _attr_nonce() {
1296
+ return getChunk().boundary.state.nonceAttr;
1239
1297
  }
1240
- //#endregion
1241
- //#region src/common/opt.ts
1242
- function forEach(opt, cb) {
1243
- if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
1244
- else cb(opt);
1298
+ function _style_html(decls) {
1299
+ let id = _id();
1300
+ return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
1245
1301
  }
1246
- function push(opt, item) {
1247
- return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
1302
+ function _attr(name, value) {
1303
+ return isVoid(value) ? "" : nonVoidAttr(name, value);
1248
1304
  }
1249
- function concat(opt, other) {
1250
- if (!opt) return other;
1251
- if (!other) return opt;
1252
- if (Array.isArray(opt)) {
1253
- if (Array.isArray(other)) for (let item of other) opt.push(item);
1254
- else opt.push(other);
1255
- return opt;
1305
+ function _attr_and(name, value, attr) {
1306
+ return value ? attr : _attr(name, value);
1307
+ }
1308
+ function _attr_or(name, value, attr) {
1309
+ return value ? _attr(name, value) : attr;
1310
+ }
1311
+ function _attr_nullish(name, value, attr) {
1312
+ return value == null ? attr : _attr(name, value);
1313
+ }
1314
+ function _attrs(data, nodeAccessor, scopeId, tagName) {
1315
+ let result = "", skip = /[\s/>"'=]/, events;
1316
+ switch (data && tagName) {
1317
+ case "input":
1318
+ data.checkedChange ? (result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1), skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/) : "checkedValue" in data || data.checkedValueChange ? (result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1), skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/) : data.valueChange && (result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1), skip = /^value(?:Change)?$|[\s/>"'=]/);
1319
+ break;
1320
+ case "select":
1321
+ case "textarea":
1322
+ ("value" in data || data.valueChange) && (skip = /^value(?:Change)?$|[\s/>"'=]/);
1323
+ break;
1324
+ case "option":
1325
+ "value" in data && (result += _attr_option_value(data.value), skip = /^value$|[\s/>"'=]/);
1326
+ break;
1327
+ case "details":
1328
+ case "dialog": data.openChange && (result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1), skip = /^open(?:Change)?$|[\s/>"'=]/);
1256
1329
  }
1257
- return Array.isArray(other) ? [opt, ...other] : [opt, other];
1330
+ for (let name in data) {
1331
+ let value = data[name];
1332
+ switch (name) {
1333
+ case "class":
1334
+ result += _attr_class(value);
1335
+ break;
1336
+ case "style":
1337
+ result += _attr_style(value);
1338
+ break;
1339
+ default: name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, { ["I" + nodeAccessor]: events })), events[getEventHandlerName(name)] = value) : result += nonVoidAttr(name, value));
1340
+ }
1341
+ }
1342
+ return result;
1343
+ }
1344
+ function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
1345
+ _html(`${_attrs(data, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
1346
+ }
1347
+ function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
1348
+ let partial = {};
1349
+ for (let name in data) {
1350
+ let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
1351
+ skip[key] || (partial[key] = data[name]);
1352
+ }
1353
+ return _attrs(partial, nodeAccessor, scopeId, tagName);
1354
+ }
1355
+ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
1356
+ _html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
1357
+ }
1358
+ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
1359
+ writeScope(scopeId, serializeType ? {
1360
+ ["F" + nodeAccessor]: type,
1361
+ ["G" + nodeAccessor]: value,
1362
+ ["E" + nodeAccessor]: valueChange
1363
+ } : {
1364
+ ["G" + nodeAccessor]: value,
1365
+ ["E" + nodeAccessor]: valueChange
1366
+ });
1367
+ }
1368
+ function stringAttr(name, value) {
1369
+ return value && " " + name + attrAssignment(value);
1370
+ }
1371
+ function nonVoidAttr(name, value) {
1372
+ switch (typeof value) {
1373
+ case "string": return " " + name + attrAssignment(value);
1374
+ case "boolean": return " " + name;
1375
+ case "number": return " " + name + "=" + value;
1376
+ }
1377
+ return " " + name + attrAssignment(value + "");
1378
+ }
1379
+ function attrAssignment(value) {
1380
+ return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
1381
+ }
1382
+ function escapeSingleQuotedAttrValue(value) {
1383
+ return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
1384
+ }
1385
+ function replaceUnsafeSingleQuoteAttrChar(match) {
1386
+ return match === "'" ? "&#39;" : match === "\r" ? "&#13;" : "&amp;";
1387
+ }
1388
+ function escapeDoubleQuotedAttrValue(value) {
1389
+ return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
1390
+ }
1391
+ function replaceUnsafeDoubleQuoteAttrChar(match) {
1392
+ return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
1393
+ }
1394
+ function normalizedValueMatches(a, b) {
1395
+ let value = normalizeStrAttrValue(b);
1396
+ if (Array.isArray(a)) {
1397
+ for (let item of a) if (normalizeStrAttrValue(item) === value) return !0;
1398
+ } else if (normalizeStrAttrValue(a) === value) return !0;
1399
+ return !1;
1400
+ }
1401
+ function normalizeStrAttrValue(value) {
1402
+ return isNotVoid(value) && value !== !0 ? value + "" : "";
1258
1403
  }
1259
1404
  //#endregion
1260
1405
  //#region src/html/for.ts
@@ -1320,14 +1465,20 @@ function withContext(key, value, cb, cbValue) {
1320
1465
  ctx[kPendingContexts]--, ctx[key] = prev;
1321
1466
  }
1322
1467
  }
1468
+ function captureContext(chunk) {
1469
+ chunk.context?.[kPendingContexts] && (chunk.context = {
1470
+ ...chunk.context,
1471
+ [kPendingContexts]: 0
1472
+ });
1473
+ }
1323
1474
  function isInResumedBranch() {
1324
1475
  return $chunk?.context?.[kBranchId] !== void 0;
1325
1476
  }
1326
1477
  function withBranchId(branchId, cb, cbValue) {
1327
1478
  return withContext(kBranchId, branchId, cb, cbValue);
1328
1479
  }
1329
- function withIsAsync(cb, value) {
1330
- return withContext(kIsAsync, !0, cb, value);
1480
+ function withIsAsync(async, cb, value) {
1481
+ return withContext(kIsAsync, async, cb, value);
1331
1482
  }
1332
1483
  function _html(html) {
1333
1484
  $chunk.writeHTML(html);
@@ -1464,11 +1615,12 @@ function applyBranchStart(chunk, beforeBranch, rendered) {
1464
1615
  }
1465
1616
  function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
1466
1617
  let endTag = parentEndTag || "";
1467
- if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
1468
- let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
1469
- $chunk.writeHTML(mark + endTag);
1470
- } else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1471
- else $chunk.writeHTML(endTag);
1618
+ if (serializeMarker !== 0) {
1619
+ if (!parentEndTag || serializeStateful !== 0) {
1620
+ let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
1621
+ $chunk.writeHTML(mark + endTag);
1622
+ } else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1623
+ } else $chunk.writeHTML(endTag);
1472
1624
  }
1473
1625
  function _existing_scope(scopeId) {
1474
1626
  return writeScope(scopeId, {});
@@ -1522,26 +1674,24 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1522
1674
  } else content(promise);
1523
1675
  return;
1524
1676
  }
1525
- let chunk = $chunk, { boundary } = chunk;
1526
- chunk.next = $chunk = chunk.fork(boundary, chunk.next), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = {
1527
- ...chunk.context,
1528
- [kPendingContexts]: 0
1529
- }), boundary.startAsync(), promise.then((value) => {
1677
+ let chunk = $chunk, { boundary } = chunk, startId = _peek_scope_id(), after = chunk.next = $chunk = chunk.fork(boundary, chunk.next);
1678
+ chunk.async = !0, captureContext(chunk), boundary.startAsync(), promise.then((value) => {
1530
1679
  chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
1531
1680
  if (resumeMarker) {
1532
1681
  let branchId = _peek_scope_id();
1533
- $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, () => withIsAsync(content, value)), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1534
- } else withIsAsync(content, value);
1682
+ $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, () => withIsAsync({ parent: getAsyncContent(chunk) }, content, value)), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1683
+ } else {
1684
+ let renderedSince = _peek_scope_id() !== startId, async = { parent: getAsyncContent(chunk) };
1685
+ withIsAsync(async, content, value), async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "", async.resumed && $chunk.writeHTML(async.visit), async.end = $chunk;
1686
+ }
1535
1687
  }), boundary.endAsync()));
1536
1688
  }, (err) => {
1537
1689
  chunk.async = !1, boundary.abort(err);
1538
1690
  });
1539
1691
  }
1540
- function _try(scopeId, accessor, content, input) {
1541
- let catchContent = input.catch ? normalizeDynamicRenderer(input.catch) || 0 : void 0, placeholderContent = normalizeDynamicRenderer(input.placeholder), placeholderBranchId = placeholderContent ? _scope_id() : 0, branchId = _peek_scope_id(), chunk = $chunk, { boundary } = chunk, { state } = boundary, { resumeWrites } = boundary, beforeBranch = deferBranchStart(chunk), renderersAtSettle = !1;
1542
- catchContent !== void 0 || placeholderContent ? renderersAtSettle = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, placeholderContent, branchId) : withBranchId(branchId, content);
1543
- let rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
1544
- applyBranchStart(chunk, beforeBranch, rendered), rendered && (renderersAtSettle || writeTryRenderers(branchId, catchContent, placeholderContent), $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId)));
1692
+ function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
1693
+ let placeholderBranchId = placeholderContent ? _scope_id() : 0, branchId = _peek_scope_id(), chunk = $chunk, { boundary } = chunk, { state } = boundary, { resumeWrites } = boundary, beforeBranch = deferBranchStart(chunk), renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId)), renderersWritten = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers), rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
1694
+ applyBranchStart(chunk, beforeBranch, rendered), rendered && (renderersWritten || renderers(), $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId)));
1545
1695
  }
1546
1696
  function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
1547
1697
  let chunk = $chunk, { boundary } = chunk, body = chunk.fork(boundary, null);
@@ -1549,7 +1699,7 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
1549
1699
  chunk.append(body);
1550
1700
  return;
1551
1701
  }
1552
- chunk.next = $chunk = chunk.fork(boundary, chunk.next), chunk.placeholder = {
1702
+ chunk.next = $chunk = chunk.fork(boundary, chunk.next), captureContext(chunk), chunk.placeholder = {
1553
1703
  body,
1554
1704
  render: placeholder,
1555
1705
  branchId,
@@ -1557,29 +1707,31 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
1557
1707
  placeholderBranchId
1558
1708
  };
1559
1709
  }
1560
- function tryBoundary(content, catchContent, placeholderContent, branchId) {
1561
- let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, boundary.signal, boundary), body = chunk.fork(catchBoundary, null), bodyEnd = withBranchId(branchId, () => body.render(content));
1562
- if (catchBoundary.signal.aborted) return catchContent === void 0 ? boundary.abort(catchBoundary.signal.reason) : catchContent && catchContent(catchBoundary.signal.reason), !1;
1710
+ function tryBoundary(content, catchContent, branchId, renderers) {
1711
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, boundary.signal, boundary), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(() => withBranchId(branchId, content));
1712
+ if (catchBoundary.signal.aborted) return catchContent ? catchContent(catchBoundary.signal.reason) : boundary.abort(catchBoundary.signal.reason), !0;
1563
1713
  if (body === bodyEnd) return chunk.append(body), !1;
1564
1714
  let renderersAtSettle = !catchBoundary.resumeWrites, bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
1565
1715
  chunk.next = body, boundary.startAsync();
1566
- let reorderId = catchContent === void 0 ? "" : state.nextReorderId(), endMarker = reorderId && state.mark("!", reorderId);
1567
- return reorderId && (chunk.writeHTML(state.mark("!^", reorderId)), bodyEnd.writeHTML(endMarker)), catchBoundary.onNext = () => {
1568
- if (!boundary.signal.aborted) if (catchBoundary.signal.aborted) {
1569
- if (!reorderId) {
1570
- boundary.abort(catchBoundary.signal.reason);
1571
- return;
1572
- }
1573
- if (!bodyEnd.consumed) {
1574
- let cur = body, writeMarker = !0;
1575
- do {
1576
- let next = cur.next;
1577
- cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.needsWalk = !0, cur.html = endMarker, cur.scripts = cur.effects = cur.lastEffect = "", cur.placeholder = cur.reorderId = cur.deferredReady = null), cur = next;
1578
- } while (cur !== bodyNext);
1579
- }
1580
- let catchChunk = chunk.fork(boundary, null), { resumeWrites } = boundary;
1581
- catchChunk.reorderId = reorderId, (catchChunk.render(catchContent || NOOP$2, catchBoundary.signal.reason) !== catchChunk || boundary.resumeWrites !== resumeWrites) && renderersAtSettle && catchChunk.render(() => writeTryRenderers(branchId, catchContent, placeholderContent)), state.reorder(catchChunk), boundary.endAsync();
1582
- } else catchBoundary.count ? boundary.onNext() : (renderersAtSettle && catchBoundary.resumeWrites && bodyEnd.render(() => writeTryRenderers(branchId, catchContent, placeholderContent)), boundary.endAsync());
1716
+ let reorderId = catchContent ? state.nextReorderId() : "", endMarker = reorderId && state.mark("!", reorderId);
1717
+ return reorderId && (chunk.writeHTML(state.mark("!^", reorderId)), bodyEnd.writeHTML(endMarker), captureContext(chunk)), catchBoundary.onNext = () => {
1718
+ if (!boundary.signal.aborted) {
1719
+ if (catchBoundary.signal.aborted) {
1720
+ if (!reorderId) {
1721
+ boundary.abort(catchBoundary.signal.reason);
1722
+ return;
1723
+ }
1724
+ if (!bodyEnd.consumed) {
1725
+ let cur = body, writeMarker = !0;
1726
+ do {
1727
+ let next = cur.next;
1728
+ cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.needsWalk = !0, cur.html = endMarker, cur.scripts = cur.effects = cur.lastEffect = "", cur.placeholder = cur.reorderId = cur.deferredReady = null), cur = next;
1729
+ } while (cur !== bodyNext);
1730
+ }
1731
+ let catchChunk = chunk.fork(boundary, null);
1732
+ catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1733
+ } else catchBoundary.count ? boundary.onNext() : (renderersAtSettle && catchBoundary.resumeWrites && bodyEnd.render(renderers), boundary.endAsync());
1734
+ }
1583
1735
  }, renderersAtSettle;
1584
1736
  }
1585
1737
  function writeTryRenderers(branchId, catchContent, placeholderContent) {
@@ -1588,8 +1740,12 @@ function writeTryRenderers(branchId, catchContent, placeholderContent) {
1588
1740
  Q: placeholderContent
1589
1741
  });
1590
1742
  }
1591
- function countResumeWrite(boundary) {
1592
- for (; boundary; boundary = boundary.parent) boundary.resumeWrites++;
1743
+ function countResumeWrite(chunk) {
1744
+ for (let boundary = chunk.boundary; boundary; boundary = boundary.parent) boundary.resumeWrites++;
1745
+ for (let async = getAsyncContent(chunk); async && !async.resumed; async = async.parent) async.resumed = !0, async.end?.writeHTML(async.visit);
1746
+ }
1747
+ function getAsyncContent(chunk) {
1748
+ return chunk.context?.[kIsAsync];
1593
1749
  }
1594
1750
  var State = class {
1595
1751
  tagId = 1;
@@ -1663,9 +1819,10 @@ var State = class {
1663
1819
  constructor(state, signal, parent) {
1664
1820
  super(), this.state = state, this.parent = parent, this.signal.addEventListener("abort", () => {
1665
1821
  this.count = 0, this.state = new State(this.state.$global), this.onNext();
1666
- }), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
1667
- this.abort(signal.reason);
1668
- }));
1822
+ }), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", this));
1823
+ }
1824
+ handleEvent(event) {
1825
+ this.abort(event.target.reason);
1669
1826
  }
1670
1827
  flush() {
1671
1828
  return this.signal.aborted || flushSerializer(this, this.state), this.count ? 1 : this.signal.aborted ? 2 : 0;
@@ -1674,7 +1831,7 @@ var State = class {
1674
1831
  this.signal.aborted || this.count++;
1675
1832
  }
1676
1833
  endAsync() {
1677
- !this.signal.aborted && this.count && (this.count--, this.onNext());
1834
+ this.signal.aborted || (this.count--, this.onNext());
1678
1835
  }
1679
1836
  }, Chunk = class Chunk {
1680
1837
  html = "";
@@ -1701,7 +1858,7 @@ var State = class {
1701
1858
  this.html += html;
1702
1859
  }
1703
1860
  writeEffect(scopeId, registryId) {
1704
- countResumeWrite(this.boundary), this.lastEffect === registryId ? this.effects += " " + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
1861
+ countResumeWrite(this), this.lastEffect === registryId ? this.effects += " " + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
1705
1862
  }
1706
1863
  writeScript(script) {
1707
1864
  this.scripts = concatScripts(this.scripts, script);
@@ -1722,14 +1879,16 @@ var State = class {
1722
1879
  flushPlaceholder() {
1723
1880
  let { placeholder } = this;
1724
1881
  if (placeholder) {
1882
+ this.placeholder = null;
1725
1883
  let body = placeholder.body.consume();
1726
1884
  if (body.async) {
1727
1885
  let { state } = this.boundary, { branchId, scopeId, placeholderBranchId } = placeholder, reorderId = body.reorderId = branchId ? branchId + "" : state.nextReorderId();
1728
1886
  this.writeHTML(state.mark("!^", reorderId));
1729
- let { effects } = this, beforeBranch = deferBranchStart(this), after = this.render(() => withBranchId(placeholderBranchId, placeholder.render)), stateful = after === this && this.effects !== effects;
1730
- applyBranchStart(this, beforeBranch, stateful), after === this ? stateful && (this.render(() => writeScope(branchId, { P: scopeWithId(state, placeholderBranchId) })), this.writeHTML(state.mark("]", scopeId + " " + ("P" + branchId) + " " + placeholderBranchId)), body.writeEffect(branchId, "_f")) : this.boundary.abort(/* @__PURE__ */ Error("An @placeholder cannot contain async content.")), this.writeHTML(state.mark("!", reorderId)), state.reorder(body);
1887
+ let { effects } = this, beforeBranch = deferBranchStart(this);
1888
+ if (this.render(() => withBranchId(placeholderBranchId, placeholder.render)) !== this && this.boundary.abort(/* @__PURE__ */ Error("An @placeholder cannot contain async content.")), this.boundary.signal.aborted) return;
1889
+ let stateful = this.effects !== effects;
1890
+ applyBranchStart(this, beforeBranch, stateful), stateful && (this.render(() => writeScope(branchId, { P: scopeWithId(state, placeholderBranchId) })), this.writeHTML(state.mark("]", scopeId + " " + ("P" + branchId) + " " + placeholderBranchId)), body.writeEffect(branchId, "_f")), this.writeHTML(state.mark("!", reorderId)), state.reorder(body);
1731
1891
  } else body.next = this.next, this.next = body;
1732
- this.placeholder = null;
1733
1892
  }
1734
1893
  }
1735
1894
  consume() {
@@ -1748,10 +1907,10 @@ var State = class {
1748
1907
  $chunk = prev;
1749
1908
  }
1750
1909
  }
1751
- flushReadyScripts(reservations, holdEffects) {
1752
- let { boundary, serializeState } = this, { readyId } = serializeState, scripts = "";
1910
+ flushReadyScripts(boundary, reservations, holdEffects) {
1911
+ let { serializeState } = this, { readyId } = serializeState, scripts = "";
1753
1912
  if (forEach(this.takeDeferredReady(), (chunk) => {
1754
- scripts = concatScripts(scripts, chunk.flushReadyScripts(reservations, holdEffects)), (chunk.effects || chunk.deferredReady) && (this.deferredReady = push(this.deferredReady, chunk));
1913
+ scripts = concatScripts(scripts, chunk.flushReadyScripts(boundary, reservations, holdEffects)), (chunk.effects || chunk.deferredReady) && (this.deferredReady = push(this.deferredReady, chunk));
1755
1914
  }), readyId && !this.async) {
1756
1915
  let { state } = boundary;
1757
1916
  flushSerializer(boundary, serializeState);
@@ -1768,11 +1927,11 @@ var State = class {
1768
1927
  }
1769
1928
  return scripts;
1770
1929
  }
1771
- flushScript() {
1772
- let { boundary } = this, { state } = boundary, { $global, runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
1930
+ flushScript(boundary) {
1931
+ let { state } = boundary, { $global, runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
1773
1932
  needsWalk && (state.walkOnNextFlush = !1);
1774
- let readyResumeScripts = this.flushReadyScripts(void 0, this.async);
1775
- for (let channel; channel = state.serializer.pendingReadyChannel();) {
1933
+ let readyResumeScripts = this.flushReadyScripts(boundary, void 0, this.async);
1934
+ for (let channel; !boundary.signal.aborted && (channel = state.serializer.pendingReadyChannel());) {
1776
1935
  let resumes = state.serializer.stringifyScopes([], boundary, channel), deps = state.serializer.takeChannelDeps();
1777
1936
  state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
1778
1937
  }
@@ -1796,7 +1955,7 @@ var State = class {
1796
1955
  let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1797
1956
  for (reorderedChunk.reorderId = null;;) {
1798
1957
  cur.flushPlaceholder(), cur.deferOwnReady();
1799
- let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations, this.async);
1958
+ let { next } = cur, readyResumeScripts = cur.flushReadyScripts(boundary, readyReservations, this.async);
1800
1959
  if (this.deferredReady = concat(this.deferredReady, cur.takeDeferredReady()), 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;
1801
1960
  else break;
1802
1961
  }
@@ -1808,9 +1967,9 @@ var State = class {
1808
1967
  }
1809
1968
  return flushSerializer(boundary, state), (state.resumes || needsResumeArray && !state.hasWrittenResume) && (scripts = concatScripts(scripts, state.resumeScript(state.resumes))), scripts = concatScripts(scripts, reordered), needsWalk && (scripts = concatScripts(scripts, state.walkScript())), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1810
1969
  }
1811
- flushHTML() {
1812
- let { boundary } = this, { state } = boundary;
1813
- this.needsWalk && (this.needsWalk = !1, state.walkOnNextFlush = !0), this.flushScript();
1970
+ flushHTML(boundary) {
1971
+ let { state } = boundary;
1972
+ this.needsWalk && (this.needsWalk = !1, state.walkOnNextFlush = !0), this.flushScript(boundary);
1814
1973
  let { html, scripts } = this;
1815
1974
  return this.html = this.scripts = "", state.flushChunk(html, scripts, boundary.count);
1816
1975
  }
@@ -1901,159 +2060,30 @@ function flushTickQueue() {
1901
2060
  }
1902
2061
  }
1903
2062
  //#endregion
1904
- //#region src/html/attrs.ts
1905
- function _attr_class(value) {
1906
- return stringAttr("class", toDelimitedString(value, " ", stringifyClassObject));
1907
- }
1908
- function _attr_style(value) {
1909
- return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
1910
- }
1911
- function _attr_option_value(value) {
1912
- let valueAttr = _attr("value", value), selectedValue = getContext(kSelectedValue);
1913
- return selectedValue !== void 0 && normalizedValueMatches(selectedValue, value) ? valueAttr + " selected" : valueAttr;
1914
- }
1915
- function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
1916
- valueChange && writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType), content && withContext(kSelectedValue, value ?? "", content);
1917
- }
1918
- function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
1919
- return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _textarea_value(value);
1920
- }
1921
- function _textarea_value(value) {
1922
- let escaped = _escape(normalizeStrAttrValue(value));
1923
- return escaped[0] === "\n" ? "\n" + escaped : escaped;
1924
- }
1925
- function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
1926
- return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
1927
- }
1928
- function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
1929
- return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType), isNotVoid(checked) ? " checked" : "";
1930
- }
1931
- function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
1932
- let valueAttr = _attr("value", value);
1933
- return checkedValueChange && writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType), normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
1934
- }
1935
- function getCheckedValueRef(checkedValue) {
1936
- if (Array.isArray(checkedValue)) {
1937
- let ref = checkedValuesRefs.get(checkedValue);
1938
- return ref || (ref = [], checkedValuesRefs.set(checkedValue, ref)), ref;
1939
- }
1940
- }
1941
- function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
1942
- let normalizedOpen = isNotVoid(open);
1943
- return openChange && writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType), normalizedOpen ? " open" : "";
1944
- }
1945
- function _attr_nonce() {
1946
- return getChunk().boundary.state.nonceAttr;
1947
- }
1948
- function _style_html(decls) {
1949
- let id = _id();
1950
- return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
1951
- }
1952
- function _attr(name, value) {
1953
- return isVoid(value) ? "" : nonVoidAttr(name, value);
1954
- }
1955
- function _attr_and(name, value, attr) {
1956
- return value ? attr : _attr(name, value);
1957
- }
1958
- function _attr_or(name, value, attr) {
1959
- return value ? _attr(name, value) : attr;
1960
- }
1961
- function _attr_nullish(name, value, attr) {
1962
- return value == null ? attr : _attr(name, value);
1963
- }
1964
- function _attrs(data, nodeAccessor, scopeId, tagName) {
1965
- let result = "", skip = /[\s/>"'=]/, events;
1966
- switch (data && tagName) {
1967
- case "input":
1968
- data.checkedChange ? (result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1), skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/) : "checkedValue" in data || data.checkedValueChange ? (result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1), skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/) : data.valueChange && (result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1), skip = /^value(?:Change)?$|[\s/>"'=]/);
1969
- break;
1970
- case "select":
1971
- case "textarea":
1972
- ("value" in data || data.valueChange) && (skip = /^value(?:Change)?$|[\s/>"'=]/);
1973
- break;
1974
- case "option":
1975
- "value" in data && (result += _attr_option_value(data.value), skip = /^value$|[\s/>"'=]/);
1976
- break;
1977
- case "details":
1978
- case "dialog":
1979
- data.openChange && (result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1), skip = /^open(?:Change)?$|[\s/>"'=]/);
1980
- break;
1981
- }
1982
- for (let name in data) {
1983
- let value = data[name];
1984
- switch (name) {
1985
- case "class":
1986
- result += _attr_class(value);
1987
- break;
1988
- case "style":
1989
- result += _attr_style(value);
1990
- break;
1991
- default:
1992
- name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, { ["I" + nodeAccessor]: events })), events[getEventHandlerName(name)] = value) : result += nonVoidAttr(name, value));
1993
- break;
1994
- }
1995
- }
1996
- return result;
1997
- }
1998
- function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
1999
- _html(`${_attrs(data, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
2000
- }
2001
- function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
2002
- let partial = {};
2003
- for (let name in data) {
2004
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
2005
- skip[key] || (partial[key] = data[name]);
2006
- }
2007
- return _attrs(partial, nodeAccessor, scopeId, tagName);
2008
- }
2009
- function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
2010
- _html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
2011
- }
2012
- function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2013
- writeScope(scopeId, serializeType ? {
2014
- ["F" + nodeAccessor]: type,
2015
- ["G" + nodeAccessor]: value,
2016
- ["E" + nodeAccessor]: valueChange
2017
- } : {
2018
- ["G" + nodeAccessor]: value,
2019
- ["E" + nodeAccessor]: valueChange
2020
- });
2021
- }
2022
- function stringAttr(name, value) {
2023
- return value && " " + name + attrAssignment(value);
2024
- }
2025
- function nonVoidAttr(name, value) {
2026
- switch (typeof value) {
2027
- case "string": return " " + name + attrAssignment(value);
2028
- case "boolean": return " " + name;
2029
- case "number": return " " + name + "=" + value;
2030
- }
2031
- return " " + name + attrAssignment(value + "");
2063
+ //#region src/html/content.ts
2064
+ function _to_text(val) {
2065
+ return val || val === 0 ? val + "" : "";
2032
2066
  }
2033
- function attrAssignment(value) {
2034
- return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
2067
+ function _unescaped(val) {
2068
+ return val ? val + "" : val === 0 ? "0" : "";
2035
2069
  }
2036
- function escapeSingleQuotedAttrValue(value) {
2037
- return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
2070
+ function _escape(val) {
2071
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
2038
2072
  }
2039
- function replaceUnsafeSingleQuoteAttrChar(match) {
2040
- return match === "'" ? "&#39;" : match === "\r" ? "&#13;" : "&amp;";
2073
+ function _escape_script(val) {
2074
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
2041
2075
  }
2042
- function escapeDoubleQuotedAttrValue(value) {
2043
- return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
2076
+ function _escape_style(val) {
2077
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
2044
2078
  }
2045
- function replaceUnsafeDoubleQuoteAttrChar(match) {
2046
- return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
2079
+ function _escape_style_value(val) {
2080
+ return val || val === 0 ? escapeStyleValue(val + "") : "";
2047
2081
  }
2048
- function normalizedValueMatches(a, b) {
2049
- let value = normalizeStrAttrValue(b);
2050
- if (Array.isArray(a)) {
2051
- for (let item of a) if (normalizeStrAttrValue(item) === value) return !0;
2052
- } else if (normalizeStrAttrValue(a) === value) return !0;
2053
- return !1;
2082
+ function escapeCommentStr(str) {
2083
+ return unsafeCommentReg.test(str) && (str = str.replace(unsafeCommentReg, "&gt;")), str.startsWith(getState().commentPrefix) ? "&#" + str.charCodeAt(0) + ";" + str.slice(1) : str;
2054
2084
  }
2055
- function normalizeStrAttrValue(value) {
2056
- return isNotVoid(value) && value !== !0 ? value + "" : "";
2085
+ function _escape_comment(val) {
2086
+ return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
2057
2087
  }
2058
2088
  //#endregion
2059
2089
  //#region src/html/dynamic-tag.ts
@@ -2127,11 +2157,11 @@ var ServerRendered = class {
2127
2157
  done: !1
2128
2158
  };
2129
2159
  return value = "", Promise.resolve(result);
2130
- } else if (done) return Promise.resolve({
2160
+ }
2161
+ return done ? Promise.resolve({
2131
2162
  value: "",
2132
2163
  done
2133
- });
2134
- else return new Promise(exec);
2164
+ }) : new Promise(exec);
2135
2165
  },
2136
2166
  throw(error) {
2137
2167
  return done || aborted || boundary?.abort(error), Promise.resolve({
@@ -2190,49 +2220,64 @@ var ServerRendered = class {
2190
2220
  return this.#cachedPromise ||= new Promise((resolve, reject) => {
2191
2221
  let head = this.#head;
2192
2222
  if (this.#head = null, !head) return reject(/* @__PURE__ */ Error(CONSUMED_RESULT_MESSAGE));
2193
- let { boundary } = head;
2223
+ let { boundary } = head, html = "";
2194
2224
  (boundary.onNext = () => {
2195
2225
  switch (!boundary.count && boundary.flush()) {
2196
2226
  case 2:
2197
- boundary.onNext = NOOP$1, reject(boundary.signal.reason);
2198
- break;
2199
- case 0: {
2200
- let consumed = head.consume();
2201
- boundary.signal.aborted || resolve(consumed.flushHTML());
2227
+ settle(boundary), reject(boundary.signal.reason);
2202
2228
  break;
2203
- }
2229
+ case 0:
2230
+ if (head = head.consume(), boundary.signal.aborted) break;
2231
+ html += head.flushHTML(boundary), boundary.count || boundary.signal.aborted || (settle(boundary), resolve(html));
2204
2232
  }
2205
2233
  })();
2206
2234
  });
2207
2235
  }
2208
2236
  #read(onWrite, onAbort, onClose) {
2209
- let tick = !0, head = this.#head;
2237
+ let tick = !0, flushing = !1, again = !1, head = this.#head;
2210
2238
  if (this.#head = null, !head) {
2211
2239
  onAbort(/* @__PURE__ */ Error(CONSUMED_RESULT_MESSAGE));
2212
2240
  return;
2213
2241
  }
2214
2242
  let { boundary } = head, onNext = boundary.onNext = (write) => {
2215
- let status = boundary.flush();
2216
- if (status === 2) tick || offTick(onNext), boundary.onNext = NOOP$1, onAbort(boundary.signal.reason);
2217
- else if (write || status === 0) {
2218
- if (head = head.consume(), boundary.signal.aborted) return;
2219
- let html = head.flushHTML();
2220
- html && onWrite(html), status === 0 ? (tick || offTick(onNext), onClose()) : tick = !0;
2221
- } else tick && (tick = !1, queueTick(onNext));
2243
+ if (flushing) {
2244
+ again = !0;
2245
+ return;
2246
+ }
2247
+ flushing = !0;
2248
+ do {
2249
+ again = !1;
2250
+ let status = boundary.flush();
2251
+ if (status === 2) {
2252
+ tick || offTick(onNext), settle(boundary), onAbort(boundary.signal.reason);
2253
+ return;
2254
+ }
2255
+ if (write || status === 0) {
2256
+ if (head = head.consume(), boundary.signal.aborted) continue;
2257
+ let html = head.flushHTML(boundary);
2258
+ if (boundary.signal.aborted) continue;
2259
+ if (html && onWrite(html), !boundary.count) {
2260
+ tick || offTick(onNext), settle(boundary), onClose();
2261
+ return;
2262
+ }
2263
+ write && (tick = !0);
2264
+ } else tick && (tick = !1, queueTick(onNext));
2265
+ } while (again);
2266
+ flushing = !1;
2222
2267
  };
2223
2268
  return onNext(), boundary;
2224
2269
  }
2225
2270
  toString() {
2226
2271
  let head = this.#head;
2227
2272
  if (this.#head = null, !head) throw Error(CONSUMED_RESULT_MESSAGE);
2228
- let { boundary } = head;
2229
- switch (boundary.flush()) {
2230
- case 2: throw boundary.signal.reason;
2231
- case 1: throw Error("Cannot consume asynchronous render with 'toString'");
2232
- }
2233
- return head.consume().flushHTML();
2273
+ let { boundary } = head, html = boundary.flush() === 0 ? head.consume().flushHTML(boundary) : "";
2274
+ if (boundary.count && boundary.abort(/* @__PURE__ */ Error("Cannot consume asynchronous render with 'toString'")), settle(boundary), boundary.signal.aborted) throw boundary.signal.reason;
2275
+ return html;
2234
2276
  }
2235
2277
  };
2278
+ function settle(boundary) {
2279
+ boundary.onNext = NOOP$1, boundary.state.$global.signal?.removeEventListener("abort", boundary);
2280
+ }
2236
2281
  function NOOP$1() {}
2237
2282
  //#endregion
2238
2283
  //#region src/html/assets.ts
@@ -2245,7 +2290,7 @@ function withLoadAssets(renderer, assetId, triggers) {
2245
2290
  function withPageAssets(template, runtime, assetId, runtimeId) {
2246
2291
  return assetFlush = runtime, Object.assign((input) => {
2247
2292
  let g = $global();
2248
- return runtimeId && (g.runtimeId = runtimeId), addAsset(g, assetId), g.__flush__ ? (_html(flush(g, "")), writeWaitReady(assetId, template, input)) : (g.__flush__ = flush, template(input));
2293
+ return runtimeId && (g[kAssets] || (g.runtimeId = runtimeId)), addAsset(g, assetId), g.__flush__ ? (_html(flush(g, "")), writeWaitReady(assetId, template, input)) : (g.__flush__ = flush, template(input));
2249
2294
  }, template);
2250
2295
  }
2251
2296
  function _flush_head() {
@@ -2301,7 +2346,7 @@ function drainClassFunctions($global, writeScope) {
2301
2346
  pending.length = 0;
2302
2347
  }
2303
2348
  function NOOP() {}
2304
- exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr = _attr, exports._attr_and = _attr_and, exports._attr_class = _attr_class, exports._attr_content = _attr_content, exports._attr_details_open = _attr_details_or_dialog_open, exports._attr_dialog_open = _attr_details_or_dialog_open, exports._attr_input_checked = _attr_input_checked, exports._attr_input_checkedValue = _attr_input_checkedValue, exports._attr_input_value = _attr_input_value, exports._attr_nonce = _attr_nonce, exports._attr_nullish = _attr_nullish, exports._attr_option_value = _attr_option_value, exports._attr_or = _attr_or, exports._attr_select_value = _attr_select_value, exports._attr_style = _attr_style, exports._attr_textarea_value = _attr_textarea_value, exports._attrs = _attrs, exports._attrs_content = _attrs_content, exports._attrs_partial = _attrs_partial, exports._attrs_partial_content = _attrs_partial_content, exports._await = _await, exports._content = _content, exports._content_resume = _content_resume, Object.defineProperty(exports, "_dynamic_tag", {
2349
+ exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr = _attr, exports._attr_and = _attr_and, exports._attr_class = _attr_class, exports._attr_content = _attr_content, exports._attr_details_open = _attr_details_or_dialog_open, exports._attr_dialog_open = _attr_details_or_dialog_open, exports._attr_input_checked = _attr_input_checked, exports._attr_input_checkedValue = _attr_input_checkedValue, exports._attr_input_value = _attr_input_value, exports._attr_nonce = _attr_nonce, exports._attr_nullish = _attr_nullish, exports._attr_option_value = _attr_option_value, exports._attr_or = _attr_or, exports._attr_select_value = _attr_select_value, exports._attr_style = _attr_style, exports._attr_textarea_value = _attr_textarea_value, exports._attrs = _attrs, exports._attrs_content = _attrs_content, exports._attrs_partial = _attrs_partial, exports._attrs_partial_content = _attrs_partial_content, exports._attrs_select_value = _attrs_select_value, exports._attrs_textarea_value = _attrs_textarea_value, exports._await = _await, exports._content = _content, exports._content_resume = _content_resume, Object.defineProperty(exports, "_dynamic_tag", {
2305
2350
  enumerable: !0,
2306
2351
  get: function() {
2307
2352
  return _dynamic_tag;