@marko/runtime-tags 6.3.0 → 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.
@@ -1323,34 +1323,49 @@ function toAccess(accessor) {
1323
1323
  const start = accessor[0];
1324
1324
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1325
1325
  }
1326
+ const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
1326
1327
  function quote(str, startPos) {
1328
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
1327
1329
  let result = "";
1328
1330
  let lastPos = 0;
1329
1331
  for (let i = startPos; i < str.length; i++) {
1330
1332
  let replacement;
1331
- switch (str[i]) {
1332
- case "\"":
1333
+ const code = str.charCodeAt(i);
1334
+ switch (code) {
1335
+ case 34:
1333
1336
  replacement = "\\\"";
1334
1337
  break;
1335
- case "\\":
1338
+ case 92:
1336
1339
  replacement = "\\\\";
1337
1340
  break;
1338
- case "<":
1341
+ case 60:
1339
1342
  replacement = "\\x3C";
1340
1343
  break;
1341
- case "\n":
1344
+ case 10:
1342
1345
  replacement = "\\n";
1343
1346
  break;
1344
- case "\r":
1347
+ case 13:
1345
1348
  replacement = "\\r";
1346
1349
  break;
1347
- case "\u2028":
1350
+ case 8232:
1348
1351
  replacement = "\\u2028";
1349
1352
  break;
1350
- case "\u2029":
1353
+ case 8233:
1351
1354
  replacement = "\\u2029";
1352
1355
  break;
1353
- default: continue;
1356
+ case 0:
1357
+ replacement = "\\x00";
1358
+ break;
1359
+ default:
1360
+ if (code < 55296 || code > 57343) continue;
1361
+ if (code < 56320) {
1362
+ const next = str.charCodeAt(i + 1);
1363
+ if (next >= 56320 && next <= 57343) {
1364
+ i++;
1365
+ continue;
1366
+ }
1367
+ }
1368
+ replacement = "\\u" + code.toString(16);
1354
1369
  }
1355
1370
  result += str.slice(lastPos, i) + replacement;
1356
1371
  lastPos = i + 1;
@@ -1917,7 +1932,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1917
1932
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1918
1933
  } else withIsAsync(content, value);
1919
1934
  });
1920
- boundary.endAsync(chunk);
1935
+ boundary.endAsync();
1921
1936
  }
1922
1937
  }
1923
1938
  }, (err) => {
@@ -1959,7 +1974,7 @@ function tryCatch(content, catchContent) {
1959
1974
  const chunk = $chunk;
1960
1975
  const { boundary } = chunk;
1961
1976
  const { state } = boundary;
1962
- const catchBoundary = new Boundary(state);
1977
+ const catchBoundary = new Boundary(state, void 0, boundary);
1963
1978
  const body = chunk.fork(catchBoundary, null);
1964
1979
  const bodyEnd = body.render(content);
1965
1980
  if (catchBoundary.signal.aborted) {
@@ -2073,19 +2088,21 @@ var State = class {
2073
2088
  };
2074
2089
  var Boundary = class extends AbortController {
2075
2090
  state;
2091
+ parent;
2076
2092
  onNext = NOOP$2;
2077
2093
  count = 0;
2078
- constructor(state, parent) {
2094
+ constructor(state, signal, parent) {
2079
2095
  super();
2080
2096
  this.state = state;
2097
+ this.parent = parent;
2081
2098
  this.signal.addEventListener("abort", () => {
2082
2099
  this.count = 0;
2083
2100
  this.state = new State(this.state.$global);
2084
2101
  this.onNext();
2085
2102
  });
2086
- if (parent) if (parent.aborted) this.abort(parent.reason);
2087
- else parent.addEventListener("abort", () => {
2088
- this.abort(parent.reason);
2103
+ if (signal) if (signal.aborted) this.abort(signal.reason);
2104
+ else signal.addEventListener("abort", () => {
2105
+ this.abort(signal.reason);
2089
2106
  });
2090
2107
  }
2091
2108
  flush() {
@@ -2095,10 +2112,9 @@ var Boundary = class extends AbortController {
2095
2112
  startAsync() {
2096
2113
  if (!this.signal.aborted) this.count++;
2097
2114
  }
2098
- endAsync(chunk) {
2115
+ endAsync() {
2099
2116
  if (!this.signal.aborted && this.count) {
2100
2117
  this.count--;
2101
- if (chunk?.reorderId) this.state.reorder(chunk);
2102
2118
  this.onNext();
2103
2119
  }
2104
2120
  }
@@ -2285,12 +2301,22 @@ var Chunk = class Chunk {
2285
2301
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2286
2302
  }
2287
2303
  if (state.writeReorders) {
2288
- needsWalk = true;
2289
- if (!state.hasReorderRuntime) {
2290
- state.hasReorderRuntime = true;
2291
- scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2292
- }
2304
+ let carried = null;
2293
2305
  for (const reorderedChunk of state.writeReorders) {
2306
+ if (reorderedChunk.async && reorderedChunk.consumed) {
2307
+ let aborted = reorderedChunk.boundary;
2308
+ while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
2309
+ if (!aborted) {
2310
+ (carried ||= []).push(reorderedChunk);
2311
+ continue;
2312
+ }
2313
+ reorderedChunk.async = false;
2314
+ }
2315
+ needsWalk = true;
2316
+ if (!state.hasReorderRuntime) {
2317
+ state.hasReorderRuntime = true;
2318
+ scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2319
+ }
2294
2320
  const { reorderId } = reorderedChunk;
2295
2321
  const readyReservations = [];
2296
2322
  let reorderHTML = "";
@@ -2309,6 +2335,7 @@ var Chunk = class Chunk {
2309
2335
  reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
2310
2336
  if (cur.async) {
2311
2337
  reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
2338
+ state.reorder(cur);
2312
2339
  cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
2313
2340
  cur.next = null;
2314
2341
  }
@@ -2326,7 +2353,7 @@ var Chunk = class Chunk {
2326
2353
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2327
2354
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2328
2355
  }
2329
- state.writeReorders = null;
2356
+ state.writeReorders = carried;
2330
2357
  }
2331
2358
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2332
2359
  this.html = html;
@@ -2656,9 +2683,9 @@ function nonVoidAttr(name, value) {
2656
2683
  }
2657
2684
  return " " + name + attrAssignment(value + "");
2658
2685
  }
2659
- const singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
2660
- const doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
2661
- const needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
2686
+ const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
2687
+ const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
2688
+ const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
2662
2689
  function attrAssignment(value) {
2663
2690
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
2664
2691
  }
@@ -1321,34 +1321,49 @@ function toAccess(accessor) {
1321
1321
  const start = accessor[0];
1322
1322
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1323
1323
  }
1324
+ const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
1324
1325
  function quote(str, startPos) {
1326
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
1325
1327
  let result = "";
1326
1328
  let lastPos = 0;
1327
1329
  for (let i = startPos; i < str.length; i++) {
1328
1330
  let replacement;
1329
- switch (str[i]) {
1330
- case "\"":
1331
+ const code = str.charCodeAt(i);
1332
+ switch (code) {
1333
+ case 34:
1331
1334
  replacement = "\\\"";
1332
1335
  break;
1333
- case "\\":
1336
+ case 92:
1334
1337
  replacement = "\\\\";
1335
1338
  break;
1336
- case "<":
1339
+ case 60:
1337
1340
  replacement = "\\x3C";
1338
1341
  break;
1339
- case "\n":
1342
+ case 10:
1340
1343
  replacement = "\\n";
1341
1344
  break;
1342
- case "\r":
1345
+ case 13:
1343
1346
  replacement = "\\r";
1344
1347
  break;
1345
- case "\u2028":
1348
+ case 8232:
1346
1349
  replacement = "\\u2028";
1347
1350
  break;
1348
- case "\u2029":
1351
+ case 8233:
1349
1352
  replacement = "\\u2029";
1350
1353
  break;
1351
- default: continue;
1354
+ case 0:
1355
+ replacement = "\\x00";
1356
+ break;
1357
+ default:
1358
+ if (code < 55296 || code > 57343) continue;
1359
+ if (code < 56320) {
1360
+ const next = str.charCodeAt(i + 1);
1361
+ if (next >= 56320 && next <= 57343) {
1362
+ i++;
1363
+ continue;
1364
+ }
1365
+ }
1366
+ replacement = "\\u" + code.toString(16);
1352
1367
  }
1353
1368
  result += str.slice(lastPos, i) + replacement;
1354
1369
  lastPos = i + 1;
@@ -1915,7 +1930,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1915
1930
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1916
1931
  } else withIsAsync(content, value);
1917
1932
  });
1918
- boundary.endAsync(chunk);
1933
+ boundary.endAsync();
1919
1934
  }
1920
1935
  }
1921
1936
  }, (err) => {
@@ -1957,7 +1972,7 @@ function tryCatch(content, catchContent) {
1957
1972
  const chunk = $chunk;
1958
1973
  const { boundary } = chunk;
1959
1974
  const { state } = boundary;
1960
- const catchBoundary = new Boundary(state);
1975
+ const catchBoundary = new Boundary(state, void 0, boundary);
1961
1976
  const body = chunk.fork(catchBoundary, null);
1962
1977
  const bodyEnd = body.render(content);
1963
1978
  if (catchBoundary.signal.aborted) {
@@ -2071,19 +2086,21 @@ var State = class {
2071
2086
  };
2072
2087
  var Boundary = class extends AbortController {
2073
2088
  state;
2089
+ parent;
2074
2090
  onNext = NOOP$2;
2075
2091
  count = 0;
2076
- constructor(state, parent) {
2092
+ constructor(state, signal, parent) {
2077
2093
  super();
2078
2094
  this.state = state;
2095
+ this.parent = parent;
2079
2096
  this.signal.addEventListener("abort", () => {
2080
2097
  this.count = 0;
2081
2098
  this.state = new State(this.state.$global);
2082
2099
  this.onNext();
2083
2100
  });
2084
- if (parent) if (parent.aborted) this.abort(parent.reason);
2085
- else parent.addEventListener("abort", () => {
2086
- this.abort(parent.reason);
2101
+ if (signal) if (signal.aborted) this.abort(signal.reason);
2102
+ else signal.addEventListener("abort", () => {
2103
+ this.abort(signal.reason);
2087
2104
  });
2088
2105
  }
2089
2106
  flush() {
@@ -2093,10 +2110,9 @@ var Boundary = class extends AbortController {
2093
2110
  startAsync() {
2094
2111
  if (!this.signal.aborted) this.count++;
2095
2112
  }
2096
- endAsync(chunk) {
2113
+ endAsync() {
2097
2114
  if (!this.signal.aborted && this.count) {
2098
2115
  this.count--;
2099
- if (chunk?.reorderId) this.state.reorder(chunk);
2100
2116
  this.onNext();
2101
2117
  }
2102
2118
  }
@@ -2283,12 +2299,22 @@ var Chunk = class Chunk {
2283
2299
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2284
2300
  }
2285
2301
  if (state.writeReorders) {
2286
- needsWalk = true;
2287
- if (!state.hasReorderRuntime) {
2288
- state.hasReorderRuntime = true;
2289
- scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2290
- }
2302
+ let carried = null;
2291
2303
  for (const reorderedChunk of state.writeReorders) {
2304
+ if (reorderedChunk.async && reorderedChunk.consumed) {
2305
+ let aborted = reorderedChunk.boundary;
2306
+ while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
2307
+ if (!aborted) {
2308
+ (carried ||= []).push(reorderedChunk);
2309
+ continue;
2310
+ }
2311
+ reorderedChunk.async = false;
2312
+ }
2313
+ needsWalk = true;
2314
+ if (!state.hasReorderRuntime) {
2315
+ state.hasReorderRuntime = true;
2316
+ scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2317
+ }
2292
2318
  const { reorderId } = reorderedChunk;
2293
2319
  const readyReservations = [];
2294
2320
  let reorderHTML = "";
@@ -2307,6 +2333,7 @@ var Chunk = class Chunk {
2307
2333
  reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
2308
2334
  if (cur.async) {
2309
2335
  reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
2336
+ state.reorder(cur);
2310
2337
  cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
2311
2338
  cur.next = null;
2312
2339
  }
@@ -2324,7 +2351,7 @@ var Chunk = class Chunk {
2324
2351
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2325
2352
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2326
2353
  }
2327
- state.writeReorders = null;
2354
+ state.writeReorders = carried;
2328
2355
  }
2329
2356
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2330
2357
  this.html = html;
@@ -2654,9 +2681,9 @@ function nonVoidAttr(name, value) {
2654
2681
  }
2655
2682
  return " " + name + attrAssignment(value + "");
2656
2683
  }
2657
- const singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
2658
- const doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
2659
- const needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
2684
+ const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
2685
+ const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
2686
+ const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
2660
2687
  function attrAssignment(value) {
2661
2688
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
2662
2689
  }
@@ -121,12 +121,13 @@ export declare enum FlushStatus {
121
121
  }
122
122
  export declare class Boundary extends AbortController {
123
123
  state: State;
124
+ parent?: Boundary | undefined;
124
125
  onNext: () => void;
125
126
  count: number;
126
- constructor(state: State, parent?: AbortSignal);
127
+ constructor(state: State, signal?: AbortSignal, parent?: Boundary | undefined);
127
128
  flush(): FlushStatus;
128
129
  startAsync(): void;
129
- endAsync(chunk?: Chunk): void;
130
+ endAsync(): void;
130
131
  }
131
132
  export declare class Chunk {
132
133
  boundary: Boundary;
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) || {};
@@ -907,32 +907,45 @@ function toAccess(accessor) {
907
907
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
908
908
  }
909
909
  function quote(str, startPos) {
910
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
910
911
  let result = "", lastPos = 0;
911
912
  for (let i = startPos; i < str.length; i++) {
912
- let replacement;
913
- switch (str[i]) {
914
- case "\"":
913
+ let replacement, code = str.charCodeAt(i);
914
+ switch (code) {
915
+ case 34:
915
916
  replacement = "\\\"";
916
917
  break;
917
- case "\\":
918
+ case 92:
918
919
  replacement = "\\\\";
919
920
  break;
920
- case "<":
921
+ case 60:
921
922
  replacement = "\\x3C";
922
923
  break;
923
- case "\n":
924
+ case 10:
924
925
  replacement = "\\n";
925
926
  break;
926
- case "\r":
927
+ case 13:
927
928
  replacement = "\\r";
928
929
  break;
929
- case "\u2028":
930
+ case 8232:
930
931
  replacement = "\\u2028";
931
932
  break;
932
- case "\u2029":
933
+ case 8233:
933
934
  replacement = "\\u2029";
934
935
  break;
935
- 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);
936
949
  }
937
950
  result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
938
951
  }
@@ -1282,7 +1295,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1282
1295
  let branchId = _peek_scope_id();
1283
1296
  $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1284
1297
  } else withIsAsync(content, value);
1285
- }), boundary.endAsync(chunk)));
1298
+ }), boundary.endAsync()));
1286
1299
  }, (err) => {
1287
1300
  chunk.async = !1, boundary.abort(err);
1288
1301
  });
@@ -1310,7 +1323,7 @@ function tryPlaceholder(content, placeholder, branchId) {
1310
1323
  };
1311
1324
  }
1312
1325
  function tryCatch(content, catchContent) {
1313
- 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);
1314
1327
  if (catchBoundary.signal.aborted) {
1315
1328
  catchContent(catchBoundary.signal.reason);
1316
1329
  return;
@@ -1388,13 +1401,14 @@ var State = class {
1388
1401
  }
1389
1402
  }, Boundary = class extends AbortController {
1390
1403
  state;
1404
+ parent;
1391
1405
  onNext = NOOP$2;
1392
1406
  count = 0;
1393
- constructor(state, parent) {
1394
- 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", () => {
1395
1409
  this.count = 0, this.state = new State(this.state.$global), this.onNext();
1396
- }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1397
- this.abort(parent.reason);
1410
+ }), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
1411
+ this.abort(signal.reason);
1398
1412
  }));
1399
1413
  }
1400
1414
  flush() {
@@ -1403,8 +1417,8 @@ var State = class {
1403
1417
  startAsync() {
1404
1418
  this.signal.aborted || this.count++;
1405
1419
  }
1406
- endAsync(chunk) {
1407
- !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());
1408
1422
  }
1409
1423
  }, Chunk = class Chunk {
1410
1424
  boundary;
@@ -1509,20 +1523,30 @@ var State = class {
1509
1523
  readyResumeScripts && (needsWalk = !0);
1510
1524
  let effects = this.async ? "" : this.effects, { html, scripts } = this;
1511
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) {
1512
- 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;
1513
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 + ")"));
1514
1538
  let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1515
1539
  for (reorderedChunk.reorderId = null;;) {
1516
1540
  cur.flushPlaceholder(), cur.deferOwnReady();
1517
1541
  let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations);
1518
- 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;
1519
1543
  else break;
1520
1544
  }
1521
1545
  reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
1522
1546
  for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
1523
1547
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1524
1548
  }
1525
- state.writeReorders = null;
1549
+ state.writeReorders = carried;
1526
1550
  }
1527
1551
  return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1528
1552
  }
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) || {};
@@ -906,32 +906,45 @@ function toAccess(accessor) {
906
906
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
907
907
  }
908
908
  function quote(str, startPos) {
909
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
909
910
  let result = "", lastPos = 0;
910
911
  for (let i = startPos; i < str.length; i++) {
911
- let replacement;
912
- switch (str[i]) {
913
- case "\"":
912
+ let replacement, code = str.charCodeAt(i);
913
+ switch (code) {
914
+ case 34:
914
915
  replacement = "\\\"";
915
916
  break;
916
- case "\\":
917
+ case 92:
917
918
  replacement = "\\\\";
918
919
  break;
919
- case "<":
920
+ case 60:
920
921
  replacement = "\\x3C";
921
922
  break;
922
- case "\n":
923
+ case 10:
923
924
  replacement = "\\n";
924
925
  break;
925
- case "\r":
926
+ case 13:
926
927
  replacement = "\\r";
927
928
  break;
928
- case "\u2028":
929
+ case 8232:
929
930
  replacement = "\\u2028";
930
931
  break;
931
- case "\u2029":
932
+ case 8233:
932
933
  replacement = "\\u2029";
933
934
  break;
934
- 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);
935
948
  }
936
949
  result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
937
950
  }
@@ -1281,7 +1294,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1281
1294
  let branchId = _peek_scope_id();
1282
1295
  $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1283
1296
  } else withIsAsync(content, value);
1284
- }), boundary.endAsync(chunk)));
1297
+ }), boundary.endAsync()));
1285
1298
  }, (err) => {
1286
1299
  chunk.async = !1, boundary.abort(err);
1287
1300
  });
@@ -1309,7 +1322,7 @@ function tryPlaceholder(content, placeholder, branchId) {
1309
1322
  };
1310
1323
  }
1311
1324
  function tryCatch(content, catchContent) {
1312
- 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);
1313
1326
  if (catchBoundary.signal.aborted) {
1314
1327
  catchContent(catchBoundary.signal.reason);
1315
1328
  return;
@@ -1387,13 +1400,14 @@ var State = class {
1387
1400
  }
1388
1401
  }, Boundary = class extends AbortController {
1389
1402
  state;
1403
+ parent;
1390
1404
  onNext = NOOP$2;
1391
1405
  count = 0;
1392
- constructor(state, parent) {
1393
- 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", () => {
1394
1408
  this.count = 0, this.state = new State(this.state.$global), this.onNext();
1395
- }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1396
- this.abort(parent.reason);
1409
+ }), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
1410
+ this.abort(signal.reason);
1397
1411
  }));
1398
1412
  }
1399
1413
  flush() {
@@ -1402,8 +1416,8 @@ var State = class {
1402
1416
  startAsync() {
1403
1417
  this.signal.aborted || this.count++;
1404
1418
  }
1405
- endAsync(chunk) {
1406
- !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());
1407
1421
  }
1408
1422
  }, Chunk = class Chunk {
1409
1423
  boundary;
@@ -1508,20 +1522,30 @@ var State = class {
1508
1522
  readyResumeScripts && (needsWalk = !0);
1509
1523
  let effects = this.async ? "" : this.effects, { html, scripts } = this;
1510
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) {
1511
- 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;
1512
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 + ")"));
1513
1537
  let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1514
1538
  for (reorderedChunk.reorderId = null;;) {
1515
1539
  cur.flushPlaceholder(), cur.deferOwnReady();
1516
1540
  let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations);
1517
- 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;
1518
1542
  else break;
1519
1543
  }
1520
1544
  reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
1521
1545
  for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
1522
1546
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1523
1547
  }
1524
- state.writeReorders = null;
1548
+ state.writeReorders = carried;
1525
1549
  }
1526
1550
  return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1527
1551
  }
@@ -1931,9 +1931,9 @@ function nonVoidAttr(name, value) {
1931
1931
  }
1932
1932
  return " " + name + attrAssignment(value + "");
1933
1933
  }
1934
- const singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
1935
- const doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
1936
- const needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
1934
+ const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
1935
+ const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
1936
+ const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
1937
1937
  function attrAssignment(value) {
1938
1938
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
1939
1939
  }
@@ -2134,6 +2134,9 @@ function sectionHasSetupStatements(section) {
2134
2134
  }
2135
2135
  //#endregion
2136
2136
  //#region src/translator/util/binding-has-prop.ts
2137
+ function isSectionRendererElided(section) {
2138
+ return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
2139
+ }
2137
2140
  function bindingHasProperty(binding, properties) {
2138
2141
  if (binding.pruned) return false;
2139
2142
  else if (binding.pruned === void 0) throw new Error("Binding must be pruned before checking properties");
@@ -3513,7 +3516,7 @@ var dom_default = { translate: {
3513
3516
  const setup = getSetup(childSection);
3514
3517
  const written = writeSignals(childSection);
3515
3518
  const setupIdentifier = setup && written.has(setup) ? setup.identifier : void 0;
3516
- if (!childSection.downstreamBinding || bindingHasProperty(childSection.downstreamBinding.binding, childSection.downstreamBinding.properties)) if (getSectionParentIsOwner(childSection)) setBranchRendererArgs(childSection, [
3519
+ if (!isSectionRendererElided(childSection)) if (getSectionParentIsOwner(childSection)) setBranchRendererArgs(childSection, [
3517
3520
  writes,
3518
3521
  walks,
3519
3522
  setupIdentifier,
@@ -4269,9 +4272,12 @@ function buildContent(body) {
4269
4272
  if (dynamicSerializeReason) body.node.body.unshift(getScopeReasonDeclaration(bodySection));
4270
4273
  else body.node.body.unshift(_marko_compiler.types.expressionStatement(callRuntime("_scope_reason")));
4271
4274
  return callRuntime(serialized ? "_content_resume" : "_content", _marko_compiler.types.stringLiteral(getResumeRegisterId(bodySection, "content")), _marko_compiler.types.arrowFunctionExpression(body.node.params, _marko_compiler.types.blockStatement(body.node.body)), serialized ? getScopeIdIdentifier(getSection(getAttributeTagParent(body.parentPath))) : void 0);
4272
- } else return _marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), bodySection.referencedLocalClosures ? [scopeIdentifier, _marko_compiler.types.objectExpression(toArray(bodySection.referencedLocalClosures, (ref) => {
4273
- return toObjectProperty(getScopeAccessor(ref, true), getDeclaredBindingExpression(ref));
4274
- }))] : [scopeIdentifier]);
4275
+ } else {
4276
+ if (isSectionRendererElided(bodySection)) return;
4277
+ return _marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), bodySection.referencedLocalClosures ? [scopeIdentifier, _marko_compiler.types.objectExpression(toArray(bodySection.referencedLocalClosures, (ref) => {
4278
+ return toObjectProperty(getScopeAccessor(ref, true), getDeclaredBindingExpression(ref));
4279
+ }))] : [scopeIdentifier]);
4280
+ }
4275
4281
  }
4276
4282
  //#endregion
4277
4283
  //#region src/translator/visitors/tag/native-tag.ts
@@ -8953,12 +8959,13 @@ var placeholder_default = {
8953
8959
  const siblingText = extra[kSiblingText];
8954
8960
  const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
8955
8961
  if (siblingText === 1) {
8956
- if (isHTML && markerSerializeReason) if (markerSerializeReason === true || markerSerializeReason.state) write`<!>`;
8957
- else write`${callRuntime("_sep", getSerializeGuard(section, markerSerializeReason, true))}`;
8962
+ if (isHTML && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
8958
8963
  visit(placeholder, 37);
8959
8964
  } else if (siblingText === 2) visit(placeholder, 37);
8960
8965
  else {
8961
- if (!isHTML) write` `;
8966
+ if (isHTML) {
8967
+ if (siblingText === 3 && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
8968
+ } else write` `;
8962
8969
  visit(placeholder, 32);
8963
8970
  }
8964
8971
  if (isHTML) {
@@ -8990,8 +8997,13 @@ function buildEscapedTextExpression(value) {
8990
8997
  default: return callRuntime("_escape", value);
8991
8998
  }
8992
8999
  }
9000
+ function writeSeparator(write, section, reason) {
9001
+ if (reason === true || reason.state) write`<!>`;
9002
+ else write`${callRuntime("_sep", getSerializeGuard(section, reason, true))}`;
9003
+ }
8993
9004
  function analyzeSiblingText(placeholder) {
8994
9005
  const placeholderExtra = placeholder.node.extra;
9006
+ let hasNodeBefore = false;
8995
9007
  let prev = placeholder.getPrevSibling();
8996
9008
  let prevParent = placeholder.parentPath;
8997
9009
  for (;;) {
@@ -9007,7 +9019,10 @@ function analyzeSiblingText(placeholder) {
9007
9019
  const contentType = getNodeContentType(prev, "endType");
9008
9020
  if (contentType === null) prev = prev.getPrevSibling();
9009
9021
  else if (contentType === 4 || contentType === 1 || contentType === 2) return placeholderExtra[kSiblingText] = 1;
9010
- else break;
9022
+ else {
9023
+ hasNodeBefore = true;
9024
+ break;
9025
+ }
9011
9026
  }
9012
9027
  if (!prev.node && prevParent.isProgram()) return placeholderExtra[kSiblingText] = 1;
9013
9028
  let next = placeholder.getNextSibling();
@@ -9028,7 +9043,7 @@ function analyzeSiblingText(placeholder) {
9028
9043
  else break;
9029
9044
  }
9030
9045
  if (!next.node && nextParent.isProgram()) return placeholderExtra[kSiblingText] = 2;
9031
- return placeholderExtra[kSiblingText] = 0;
9046
+ return placeholderExtra[kSiblingText] = hasNodeBefore ? 3 : 0;
9032
9047
  }
9033
9048
  function getInlinedBodyTag(parent) {
9034
9049
  if (parent.isMarkoTagBody()) {
@@ -1,3 +1,5 @@
1
1
  import type { Opt } from "./optional";
2
2
  import type { Binding } from "./references";
3
+ import type { Section } from "./sections";
4
+ export declare function isSectionRendererElided(section: Section): boolean;
3
5
  export declare function bindingHasProperty(binding: Binding, properties: Opt<string>): boolean;
@@ -6,7 +6,8 @@ declare const kSharedText: unique symbol;
6
6
  declare enum SiblingText {
7
7
  None = 0,
8
8
  Before = 1,
9
- After = 2
9
+ After = 2,
10
+ NodeBefore = 3
10
11
  }
11
12
  declare module "@marko/compiler/dist/types" {
12
13
  interface MarkoPlaceholderExtra {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",