marko 6.0.0-next.3.69 → 6.0.0-next.3.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/html.js CHANGED
@@ -1393,7 +1393,7 @@ function tryCatch(content, catchContent) {
1393
1393
  }
1394
1394
  let catchChunk = new Chunk(boundary, null, chunk.context);
1395
1395
  catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1396
- } else catchBoundary.done ? boundary.endAsync() : boundary.onNext();
1396
+ } else catchBoundary.count ? boundary.onNext() : boundary.endAsync();
1397
1397
  };
1398
1398
  }
1399
1399
  var State2 = class {
@@ -1411,6 +1411,7 @@ var State2 = class {
1411
1411
  hasReorderRuntime = !1;
1412
1412
  hasWrittenResume = !1;
1413
1413
  trailerHTML = "";
1414
+ resumes = "";
1414
1415
  nonceAttr = "";
1415
1416
  serializer = new Serializer();
1416
1417
  writeReorders = null;
@@ -1449,7 +1450,7 @@ var State2 = class {
1449
1450
  onNext = NOOP;
1450
1451
  count = 0;
1451
1452
  get done() {
1452
- return this.count === 0;
1453
+ return flushSerializer(this), !this.count;
1453
1454
  }
1454
1455
  startAsync() {
1455
1456
  this.signal.aborted || this.count++;
@@ -1524,65 +1525,71 @@ var State2 = class {
1524
1525
  $chunk = prev;
1525
1526
  }
1526
1527
  }
1528
+ flushScript() {
1529
+ flushSerializer(this.boundary);
1530
+ let { boundary, effects } = this, { state } = boundary, { $global: $global2, runtimePrefix, nonceAttr } = state, { resumes } = state, { html, scripts } = this, hasWalk = !1;
1531
+ if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1532
+ scripts,
1533
+ WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1534
+ )), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
1535
+ scripts,
1536
+ runtimePrefix + ".r.push(" + resumes + ")"
1537
+ ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1538
+ scripts,
1539
+ runtimePrefix + ".r=[" + resumes + "]"
1540
+ ))), state.writeReorders) {
1541
+ hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1542
+ scripts,
1543
+ REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1544
+ ));
1545
+ for (let reorderedChunk of state.writeReorders) {
1546
+ let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1547
+ for (reorderedChunk.reorderId = null; ; ) {
1548
+ cur.flushPlaceholder();
1549
+ let { next } = cur;
1550
+ if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1551
+ "#" /* ReorderMarker */,
1552
+ cur.reorderId = state.nextReorderId()
1553
+ ), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
1554
+ cur = next;
1555
+ else
1556
+ break;
1557
+ }
1558
+ reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1559
+ scripts,
1560
+ runtimePrefix + ".r=[]"
1561
+ )), reorderScripts = concatScripts(
1562
+ reorderScripts,
1563
+ "_.push(" + reorderEffects + ")"
1564
+ )), scripts = concatScripts(
1565
+ scripts,
1566
+ reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1567
+ ), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1568
+ }
1569
+ state.writeReorders = null;
1570
+ }
1571
+ return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.effects = state.resumes = "", this.html = html, this.scripts = scripts, this;
1572
+ }
1573
+ flushHTML() {
1574
+ this.flushScript();
1575
+ let { boundary, scripts } = this, { state } = boundary, { $global: $global2, nonceAttr } = state, { __flush__ } = $global2, { html } = this;
1576
+ return this.html = this.scripts = "", scripts && (html += "<script" + nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, html = __flush__($global2, html)), boundary.count || (html += state.trailerHTML), html;
1577
+ }
1527
1578
  };
1528
- function prepareChunk(chunk) {
1529
- let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer, nonceAttr } = state, { html, scripts } = head, hasWalk = !1;
1530
- head.effects = "", state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1531
- scripts,
1532
- WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1533
- ));
1534
- let resumes = "";
1535
- if (state.writeScopes || serializer.flushed) {
1536
- let { lastSerializedScopeId } = state, serializeData = [];
1579
+ function flushSerializer(boundary) {
1580
+ let { state } = boundary, { writeScopes, serializer } = state;
1581
+ if (writeScopes || serializer.flushed) {
1582
+ let serializeData = [], { lastSerializedScopeId } = state;
1537
1583
  state.hasGlobals || (state.hasGlobals = !0, serializeData.push(getFilteredGlobals(state.$global)));
1538
- for (let key in state.writeScopes) {
1539
- let scope = state.writeScopes[key], scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
1584
+ for (let key in writeScopes) {
1585
+ let scope = writeScopes[key], scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
1540
1586
  lastSerializedScopeId = scopeId + 1, scopeIdDelta && serializeData.push(scopeIdDelta), serializeData.push(scope);
1541
1587
  }
1542
- resumes = state.serializer.stringify(serializeData, boundary), state.writeScopes = null, state.lastSerializedScopeId = lastSerializedScopeId;
1588
+ state.resumes = concatEffects(
1589
+ state.resumes,
1590
+ serializer.stringify(serializeData, boundary)
1591
+ ), state.lastSerializedScopeId = lastSerializedScopeId, state.writeScopes = null;
1543
1592
  }
1544
- if (effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
1545
- scripts,
1546
- runtimePrefix + ".r.push(" + resumes + ")"
1547
- ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1548
- scripts,
1549
- runtimePrefix + ".r=[" + resumes + "]"
1550
- ))), state.writeReorders) {
1551
- hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1552
- scripts,
1553
- REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1554
- ));
1555
- for (let reorderedChunk of state.writeReorders) {
1556
- let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1557
- for (reorderedChunk.reorderId = null; ; ) {
1558
- cur.flushPlaceholder();
1559
- let { next } = cur;
1560
- if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1561
- "#" /* ReorderMarker */,
1562
- cur.reorderId = state.nextReorderId()
1563
- ), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
1564
- cur = next;
1565
- else
1566
- break;
1567
- }
1568
- reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1569
- scripts,
1570
- runtimePrefix + ".r=[]"
1571
- )), reorderScripts = concatScripts(
1572
- reorderScripts,
1573
- "_.push(" + reorderEffects + ")"
1574
- )), scripts = concatScripts(
1575
- scripts,
1576
- reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1577
- ), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1578
- }
1579
- state.writeReorders = null;
1580
- }
1581
- return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
1582
- }
1583
- function flushChunk(head, last) {
1584
- let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
1585
- return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1586
1593
  }
1587
1594
  function writeTrailers(html) {
1588
1595
  $chunk.boundary.state.trailerHTML += html;
@@ -1946,14 +1953,16 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
1946
1953
  renderer(normalizedInput);
1947
1954
  });
1948
1955
  let asyncOut = classAPIOut.beginAsync();
1949
- (boundary.onNext = () => {
1950
- boundary.done && (boundary.signal.aborted ? asyncOut.error(boundary.signal.reason) : queueMicrotask(() => {
1951
- if (head = prepareChunk(head), boundary.done) {
1952
- let { scripts, html } = head;
1953
- asyncOut.script(scripts), asyncOut.write(html), asyncOut.end(), head.html = head.scripts = "";
1956
+ queueMicrotask(
1957
+ boundary.onNext = () => {
1958
+ if (boundary.signal.aborted)
1959
+ asyncOut.error(boundary.signal.reason);
1960
+ else if (boundary.done) {
1961
+ let { scripts, html } = head.consume().flushScript();
1962
+ asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
1954
1963
  }
1955
- }));
1956
- })();
1964
+ }
1965
+ );
1957
1966
  },
1958
1967
  registerRenderer(renderer, id) {
1959
1968
  return register(
@@ -1987,10 +1996,7 @@ function render(input = {}) {
1987
1996
  runtimeId: DEFAULT_RUNTIME_ID,
1988
1997
  renderId: DEFAULT_RENDER_ID,
1989
1998
  ...$global2
1990
- }) : $global2 = {
1991
- runtimeId: DEFAULT_RUNTIME_ID,
1992
- renderId: DEFAULT_RENDER_ID
1993
- };
1999
+ }) : $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
1994
2000
  let head = new Chunk(
1995
2001
  new Boundary(new State2($global2), $global2.signal),
1996
2002
  null,
@@ -2026,16 +2032,10 @@ var ServerRenderResult = class {
2026
2032
  } else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
2027
2033
  },
2028
2034
  throw(error) {
2029
- return done || aborted || boundary?.abort(error), Promise.resolve({
2030
- value: "",
2031
- done: !0
2032
- });
2035
+ return done || aborted || boundary?.abort(error), Promise.resolve({ value: "", done: !0 });
2033
2036
  },
2034
2037
  return(value2) {
2035
- return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({
2036
- value: value2,
2037
- done: !0
2038
- });
2038
+ return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({ value: value2, done: !0 });
2039
2039
  }
2040
2040
  };
2041
2041
  function exec(_resolve, _reject) {
@@ -2090,7 +2090,7 @@ var ServerRenderResult = class {
2090
2090
  return reject(new Error("Cannot read from a consumed render result"));
2091
2091
  let { boundary } = head;
2092
2092
  (boundary.onNext = () => {
2093
- boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && (head = prepareChunk(head), boundary.done && resolve(flushChunk(head, !0)));
2093
+ boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && resolve(head.consume().flushHTML());
2094
2094
  })();
2095
2095
  });
2096
2096
  }
@@ -2103,18 +2103,21 @@ var ServerRenderResult = class {
2103
2103
  let { boundary } = head, onNext = boundary.onNext = (write2) => {
2104
2104
  if (boundary.signal.aborted)
2105
2105
  tick2 || offTick(onNext), boundary.onNext = NOOP2, onAbort(boundary.signal.reason);
2106
- else if ((write2 || boundary.done) && (head = prepareChunk(head)), write2 || boundary.done) {
2107
- let html = flushChunk(head, boundary.done);
2108
- html && onWrite(html), boundary.done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2109
- } else tick2 && (tick2 = !1, queueTick(onNext));
2106
+ else {
2107
+ let { done } = boundary;
2108
+ if (done || write2) {
2109
+ let html = (head = head.consume()).flushHTML();
2110
+ html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2111
+ } else tick2 && (tick2 = !1, queueTick(onNext));
2112
+ }
2110
2113
  };
2111
2114
  return onNext(), boundary;
2112
2115
  }
2113
2116
  toString() {
2114
2117
  let head = this.#head;
2115
- if (!head) throw new Error("Cannot read from a consumed render result");
2116
- if (head.next) throw new Error("Cannot fork in sync mode");
2117
- return this.#head = null, flushChunk(prepareChunk(head), !0);
2118
+ if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
2119
+ if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
2120
+ return head.consume().flushHTML();
2118
2121
  }
2119
2122
  };
2120
2123
  function NOOP2() {
package/dist/html.mjs CHANGED
@@ -1314,7 +1314,7 @@ function tryCatch(content, catchContent) {
1314
1314
  }
1315
1315
  let catchChunk = new Chunk(boundary, null, chunk.context);
1316
1316
  catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1317
- } else catchBoundary.done ? boundary.endAsync() : boundary.onNext();
1317
+ } else catchBoundary.count ? boundary.onNext() : boundary.endAsync();
1318
1318
  };
1319
1319
  }
1320
1320
  var State2 = class {
@@ -1332,6 +1332,7 @@ var State2 = class {
1332
1332
  hasReorderRuntime = !1;
1333
1333
  hasWrittenResume = !1;
1334
1334
  trailerHTML = "";
1335
+ resumes = "";
1335
1336
  nonceAttr = "";
1336
1337
  serializer = new Serializer();
1337
1338
  writeReorders = null;
@@ -1370,7 +1371,7 @@ var State2 = class {
1370
1371
  onNext = NOOP;
1371
1372
  count = 0;
1372
1373
  get done() {
1373
- return this.count === 0;
1374
+ return flushSerializer(this), !this.count;
1374
1375
  }
1375
1376
  startAsync() {
1376
1377
  this.signal.aborted || this.count++;
@@ -1445,65 +1446,71 @@ var State2 = class {
1445
1446
  $chunk = prev;
1446
1447
  }
1447
1448
  }
1449
+ flushScript() {
1450
+ flushSerializer(this.boundary);
1451
+ let { boundary, effects } = this, { state } = boundary, { $global: $global2, runtimePrefix, nonceAttr } = state, { resumes } = state, { html, scripts } = this, hasWalk = !1;
1452
+ if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1453
+ scripts,
1454
+ WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1455
+ )), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
1456
+ scripts,
1457
+ runtimePrefix + ".r.push(" + resumes + ")"
1458
+ ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1459
+ scripts,
1460
+ runtimePrefix + ".r=[" + resumes + "]"
1461
+ ))), state.writeReorders) {
1462
+ hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1463
+ scripts,
1464
+ REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1465
+ ));
1466
+ for (let reorderedChunk of state.writeReorders) {
1467
+ let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1468
+ for (reorderedChunk.reorderId = null; ; ) {
1469
+ cur.flushPlaceholder();
1470
+ let { next } = cur;
1471
+ if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1472
+ "#" /* ReorderMarker */,
1473
+ cur.reorderId = state.nextReorderId()
1474
+ ), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
1475
+ cur = next;
1476
+ else
1477
+ break;
1478
+ }
1479
+ reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1480
+ scripts,
1481
+ runtimePrefix + ".r=[]"
1482
+ )), reorderScripts = concatScripts(
1483
+ reorderScripts,
1484
+ "_.push(" + reorderEffects + ")"
1485
+ )), scripts = concatScripts(
1486
+ scripts,
1487
+ reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1488
+ ), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1489
+ }
1490
+ state.writeReorders = null;
1491
+ }
1492
+ return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.effects = state.resumes = "", this.html = html, this.scripts = scripts, this;
1493
+ }
1494
+ flushHTML() {
1495
+ this.flushScript();
1496
+ let { boundary, scripts } = this, { state } = boundary, { $global: $global2, nonceAttr } = state, { __flush__ } = $global2, { html } = this;
1497
+ return this.html = this.scripts = "", scripts && (html += "<script" + nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, html = __flush__($global2, html)), boundary.count || (html += state.trailerHTML), html;
1498
+ }
1448
1499
  };
1449
- function prepareChunk(chunk) {
1450
- let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer, nonceAttr } = state, { html, scripts } = head, hasWalk = !1;
1451
- head.effects = "", state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1452
- scripts,
1453
- WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1454
- ));
1455
- let resumes = "";
1456
- if (state.writeScopes || serializer.flushed) {
1457
- let { lastSerializedScopeId } = state, serializeData = [];
1500
+ function flushSerializer(boundary) {
1501
+ let { state } = boundary, { writeScopes, serializer } = state;
1502
+ if (writeScopes || serializer.flushed) {
1503
+ let serializeData = [], { lastSerializedScopeId } = state;
1458
1504
  state.hasGlobals || (state.hasGlobals = !0, serializeData.push(getFilteredGlobals(state.$global)));
1459
- for (let key in state.writeScopes) {
1460
- let scope = state.writeScopes[key], scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
1505
+ for (let key in writeScopes) {
1506
+ let scope = writeScopes[key], scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
1461
1507
  lastSerializedScopeId = scopeId + 1, scopeIdDelta && serializeData.push(scopeIdDelta), serializeData.push(scope);
1462
1508
  }
1463
- resumes = state.serializer.stringify(serializeData, boundary), state.writeScopes = null, state.lastSerializedScopeId = lastSerializedScopeId;
1509
+ state.resumes = concatEffects(
1510
+ state.resumes,
1511
+ serializer.stringify(serializeData, boundary)
1512
+ ), state.lastSerializedScopeId = lastSerializedScopeId, state.writeScopes = null;
1464
1513
  }
1465
- if (effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
1466
- scripts,
1467
- runtimePrefix + ".r.push(" + resumes + ")"
1468
- ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1469
- scripts,
1470
- runtimePrefix + ".r=[" + resumes + "]"
1471
- ))), state.writeReorders) {
1472
- hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1473
- scripts,
1474
- REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1475
- ));
1476
- for (let reorderedChunk of state.writeReorders) {
1477
- let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1478
- for (reorderedChunk.reorderId = null; ; ) {
1479
- cur.flushPlaceholder();
1480
- let { next } = cur;
1481
- if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1482
- "#" /* ReorderMarker */,
1483
- cur.reorderId = state.nextReorderId()
1484
- ), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
1485
- cur = next;
1486
- else
1487
- break;
1488
- }
1489
- reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1490
- scripts,
1491
- runtimePrefix + ".r=[]"
1492
- )), reorderScripts = concatScripts(
1493
- reorderScripts,
1494
- "_.push(" + reorderEffects + ")"
1495
- )), scripts = concatScripts(
1496
- scripts,
1497
- reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1498
- ), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1499
- }
1500
- state.writeReorders = null;
1501
- }
1502
- return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
1503
- }
1504
- function flushChunk(head, last) {
1505
- let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
1506
- return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1507
1514
  }
1508
1515
  function writeTrailers(html) {
1509
1516
  $chunk.boundary.state.trailerHTML += html;
@@ -1867,14 +1874,16 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
1867
1874
  renderer(normalizedInput);
1868
1875
  });
1869
1876
  let asyncOut = classAPIOut.beginAsync();
1870
- (boundary.onNext = () => {
1871
- boundary.done && (boundary.signal.aborted ? asyncOut.error(boundary.signal.reason) : queueMicrotask(() => {
1872
- if (head = prepareChunk(head), boundary.done) {
1873
- let { scripts, html } = head;
1874
- asyncOut.script(scripts), asyncOut.write(html), asyncOut.end(), head.html = head.scripts = "";
1877
+ queueMicrotask(
1878
+ boundary.onNext = () => {
1879
+ if (boundary.signal.aborted)
1880
+ asyncOut.error(boundary.signal.reason);
1881
+ else if (boundary.done) {
1882
+ let { scripts, html } = head.consume().flushScript();
1883
+ asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
1875
1884
  }
1876
- }));
1877
- })();
1885
+ }
1886
+ );
1878
1887
  },
1879
1888
  registerRenderer(renderer, id) {
1880
1889
  return register(
@@ -1908,10 +1917,7 @@ function render(input = {}) {
1908
1917
  runtimeId: DEFAULT_RUNTIME_ID,
1909
1918
  renderId: DEFAULT_RENDER_ID,
1910
1919
  ...$global2
1911
- }) : $global2 = {
1912
- runtimeId: DEFAULT_RUNTIME_ID,
1913
- renderId: DEFAULT_RENDER_ID
1914
- };
1920
+ }) : $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
1915
1921
  let head = new Chunk(
1916
1922
  new Boundary(new State2($global2), $global2.signal),
1917
1923
  null,
@@ -1947,16 +1953,10 @@ var ServerRenderResult = class {
1947
1953
  } else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
1948
1954
  },
1949
1955
  throw(error) {
1950
- return done || aborted || boundary?.abort(error), Promise.resolve({
1951
- value: "",
1952
- done: !0
1953
- });
1956
+ return done || aborted || boundary?.abort(error), Promise.resolve({ value: "", done: !0 });
1954
1957
  },
1955
1958
  return(value2) {
1956
- return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({
1957
- value: value2,
1958
- done: !0
1959
- });
1959
+ return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({ value: value2, done: !0 });
1960
1960
  }
1961
1961
  };
1962
1962
  function exec(_resolve, _reject) {
@@ -2011,7 +2011,7 @@ var ServerRenderResult = class {
2011
2011
  return reject(new Error("Cannot read from a consumed render result"));
2012
2012
  let { boundary } = head;
2013
2013
  (boundary.onNext = () => {
2014
- boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && (head = prepareChunk(head), boundary.done && resolve(flushChunk(head, !0)));
2014
+ boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && resolve(head.consume().flushHTML());
2015
2015
  })();
2016
2016
  });
2017
2017
  }
@@ -2024,18 +2024,21 @@ var ServerRenderResult = class {
2024
2024
  let { boundary } = head, onNext = boundary.onNext = (write2) => {
2025
2025
  if (boundary.signal.aborted)
2026
2026
  tick2 || offTick(onNext), boundary.onNext = NOOP2, onAbort(boundary.signal.reason);
2027
- else if ((write2 || boundary.done) && (head = prepareChunk(head)), write2 || boundary.done) {
2028
- let html = flushChunk(head, boundary.done);
2029
- html && onWrite(html), boundary.done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2030
- } else tick2 && (tick2 = !1, queueTick(onNext));
2027
+ else {
2028
+ let { done } = boundary;
2029
+ if (done || write2) {
2030
+ let html = (head = head.consume()).flushHTML();
2031
+ html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2032
+ } else tick2 && (tick2 = !1, queueTick(onNext));
2033
+ }
2031
2034
  };
2032
2035
  return onNext(), boundary;
2033
2036
  }
2034
2037
  toString() {
2035
2038
  let head = this.#head;
2036
- if (!head) throw new Error("Cannot read from a consumed render result");
2037
- if (head.next) throw new Error("Cannot fork in sync mode");
2038
- return this.#head = null, flushChunk(prepareChunk(head), !0);
2039
+ if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
2040
+ if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
2041
+ return head.consume().flushHTML();
2039
2042
  }
2040
2043
  };
2041
2044
  function NOOP2() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.69",
3
+ "version": "6.0.0-next.3.71",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",