marko 6.0.113 → 6.0.114

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.
@@ -408,7 +408,6 @@ function getDebugKey(index, node) {
408
408
  // src/dom/resume.ts
409
409
  var registeredValues = {};
410
410
  var branchesEnabled;
411
- var isInit;
412
411
  function enableBranches() {
413
412
  branchesEnabled = 1;
414
413
  }
@@ -513,60 +512,64 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
513
512
  let lastScopeId = 0;
514
513
  const nextToken = () => lastToken = visitText.slice(
515
514
  lastTokenIndex,
516
- // eslint-disable-next-line no-cond-assign
517
- (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
515
+ (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1
518
516
  );
519
- render.w = (effects = []) => {
520
- try {
521
- isInit || walk2();
522
- isResuming = 1;
523
- for (const serialized of resumes = render.r || []) {
524
- if (typeof serialized === "string") {
525
- lastEffect = serialized;
526
- } else if (typeof serialized === "number") {
527
- effects.push(
528
- registeredValues[lastEffect],
529
- scopeLookup[serialized] ||= {
530
- ["#Id" /* Id */]: serialized
531
- }
532
- );
533
- } else {
534
- for (const scope of serialized(serializeContext)) {
535
- if (!$global) {
536
- $global = scope || {};
537
- $global.runtimeId = runtimeId;
538
- $global.renderId = renderId;
539
- } else if (typeof scope === "number") {
540
- lastScopeId += scope;
541
- } else {
542
- scopeLookup[scope["#Id" /* Id */] = ++lastScopeId] = scope;
543
- scope["$global" /* Global */] = $global;
544
- if (branchesEnabled) {
545
- scope["#ClosestBranch" /* ClosestBranch */] = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */]];
517
+ render.m = (effects = []) => {
518
+ for (const serialized of resumes = render.r || []) {
519
+ if (typeof serialized === "string") {
520
+ lastTokenIndex = 0;
521
+ visitText = serialized;
522
+ while (nextToken()) {
523
+ if (/\D/.test(lastToken)) {
524
+ lastEffect = registeredValues[lastToken];
525
+ } else {
526
+ effects.push(
527
+ lastEffect,
528
+ scopeLookup[lastToken] ||= {
529
+ ["#Id" /* Id */]: +lastToken
546
530
  }
531
+ );
532
+ }
533
+ }
534
+ } else {
535
+ for (const scope of serialized(serializeContext)) {
536
+ if (!$global) {
537
+ $global = scope || {};
538
+ $global.runtimeId = runtimeId;
539
+ $global.renderId = renderId;
540
+ } else if (typeof scope === "number") {
541
+ lastScopeId += scope;
542
+ } else {
543
+ scopeLookup[scope["#Id" /* Id */] = ++lastScopeId] = scope;
544
+ scope["$global" /* Global */] = $global;
545
+ if (branchesEnabled) {
546
+ scope["#ClosestBranch" /* ClosestBranch */] = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */]];
547
547
  }
548
548
  }
549
549
  }
550
550
  }
551
- for (visit of visits = render.v) {
552
- lastTokenIndex = render.i.length;
553
- visitText = visit.data;
554
- visitType = visitText[lastTokenIndex++];
555
- visitScope = scopeLookup[+nextToken(
556
- /* read scope id */
557
- )] ||= {
558
- ["#Id" /* Id */]: +lastToken
559
- };
560
- if (visitType === "*" /* Node */) {
561
- visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
562
- } else if (branchesEnabled) {
563
- visitBranches();
564
- }
551
+ }
552
+ for (visit of visits = render.v) {
553
+ lastTokenIndex = render.i.length;
554
+ visitText = visit.data;
555
+ visitType = visitText[lastTokenIndex++];
556
+ visitScope = scopeLookup[+nextToken(
557
+ /* read scope id */
558
+ )] ||= {
559
+ ["#Id" /* Id */]: +lastToken
560
+ };
561
+ if (visitType === "*" /* Node */) {
562
+ visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
563
+ } else if (branchesEnabled) {
564
+ visitBranches();
565
565
  }
566
- runEffects(effects);
567
- } finally {
568
- isInit = isResuming = visits.length = resumes.length = 0;
569
566
  }
567
+ visits.length = resumes.length = 0;
568
+ return effects;
569
+ };
570
+ render.w = () => {
571
+ walk2();
572
+ runResumeEffects(render);
570
573
  };
571
574
  return render;
572
575
  })
@@ -575,8 +578,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
575
578
  if (renders) {
576
579
  initRuntime(renders);
577
580
  for (const renderId in renders) {
578
- isInit = 1;
579
- resumeRender(renderId).w();
581
+ runResumeEffects(resumeRender(renderId));
580
582
  }
581
583
  } else {
582
584
  defineRuntime({
@@ -586,6 +588,14 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
586
588
  }
587
589
  }
588
590
  var isResuming;
591
+ function runResumeEffects(render) {
592
+ try {
593
+ isResuming = 1;
594
+ runEffects(render.m(), 1);
595
+ } finally {
596
+ isResuming = 0;
597
+ }
598
+ }
589
599
  function getRegisteredWithScope(id, scope) {
590
600
  const val = registeredValues[id];
591
601
  return scope ? val(scope) : val;
@@ -1672,24 +1682,52 @@ function longestIncreasingSubsequence(a) {
1672
1682
  }
1673
1683
 
1674
1684
  // src/dom/control-flow.ts
1675
- function _await(nodeAccessor, template, walks, setup, params) {
1685
+ function _await_promise(nodeAccessor, params) {
1676
1686
  if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
1677
1687
  const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
1678
1688
  const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
1679
- const renderer = _content("", template, walks, setup)();
1680
- enableBranches();
1689
+ const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
1690
+ _enable_catch();
1681
1691
  return (scope, promise) => {
1682
- const referenceNode = scope[nodeAccessor];
1692
+ let awaitCounter;
1693
+ let renderData;
1683
1694
  const tryWithPlaceholder = findBranchWithKey(
1684
1695
  scope,
1685
1696
  "#PlaceholderContent" /* PlaceholderContent */
1686
1697
  );
1687
- let awaitBranch = scope[branchAccessor];
1688
1698
  if (tryWithPlaceholder) {
1699
+ renderData = self[tryWithPlaceholder["$global" /* Global */].runtimeId]?.[tryWithPlaceholder["$global" /* Global */].renderId];
1700
+ awaitCounter = tryWithPlaceholder["#AwaitCounter" /* AwaitCounter */] ||= renderData?.p?.[tryWithPlaceholder["#Id" /* Id */]];
1701
+ if (!awaitCounter?.i) {
1702
+ awaitCounter = tryWithPlaceholder["#AwaitCounter" /* AwaitCounter */] = {
1703
+ d: 1,
1704
+ i: 0,
1705
+ c() {
1706
+ if (!--awaitCounter.i) {
1707
+ const placeholderBranch = tryWithPlaceholder["#PlaceholderBranch" /* PlaceholderBranch */];
1708
+ tryWithPlaceholder["#PlaceholderBranch" /* PlaceholderBranch */] = 0;
1709
+ if (placeholderBranch) {
1710
+ placeholderBranch["#StartNode" /* StartNode */].parentNode.insertBefore(
1711
+ tryWithPlaceholder["#StartNode" /* StartNode */].parentNode,
1712
+ placeholderBranch["#StartNode" /* StartNode */]
1713
+ );
1714
+ removeAndDestroyBranch(placeholderBranch);
1715
+ }
1716
+ queueEffect(tryWithPlaceholder, (scope2) => {
1717
+ const pendingEffects2 = scope2["#PendingEffects" /* PendingEffects */];
1718
+ if (pendingEffects2) {
1719
+ scope2["#PendingEffects" /* PendingEffects */] = [];
1720
+ runEffects(pendingEffects2, true);
1721
+ }
1722
+ });
1723
+ }
1724
+ }
1725
+ };
1726
+ }
1689
1727
  placeholderShown.add(pendingEffects);
1690
- if (!scope[promiseAccessor] && (tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */] = (tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */] || 0) + 1) === 1) {
1728
+ if (!scope[promiseAccessor] && !awaitCounter.i++) {
1691
1729
  requestAnimationFrame(
1692
- () => tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */] && runEffects(
1730
+ () => awaitCounter.i && runEffects(
1693
1731
  prepareEffects(
1694
1732
  () => queueRender(
1695
1733
  tryWithPlaceholder,
@@ -1712,12 +1750,12 @@ function _await(nodeAccessor, template, walks, setup, params) {
1712
1750
  )
1713
1751
  );
1714
1752
  }
1715
- } else if (awaitBranch && !scope[promiseAccessor]) {
1716
- awaitBranch["#StartNode" /* StartNode */].parentNode.insertBefore(
1717
- referenceNode,
1718
- awaitBranch["#StartNode" /* StartNode */]
1753
+ } else if (scope[branchAccessor] && !scope[promiseAccessor]) {
1754
+ scope[branchAccessor]["#StartNode" /* StartNode */].parentNode.insertBefore(
1755
+ scope[nodeAccessor],
1756
+ scope[branchAccessor]["#StartNode" /* StartNode */]
1719
1757
  );
1720
- tempDetachBranch(awaitBranch);
1758
+ tempDetachBranch(scope[branchAccessor]);
1721
1759
  }
1722
1760
  const thisPromise = scope[promiseAccessor] = promise.then(
1723
1761
  (data) => {
@@ -1727,45 +1765,47 @@ function _await(nodeAccessor, template, walks, setup, params) {
1727
1765
  queueRender(
1728
1766
  scope,
1729
1767
  () => {
1730
- if (awaitBranch) {
1768
+ if (scope[branchAccessor]) {
1731
1769
  if (!tryWithPlaceholder) {
1732
- referenceNode.replaceWith(
1733
- awaitBranch["#StartNode" /* StartNode */].parentNode
1770
+ scope[nodeAccessor].replaceWith(
1771
+ scope[branchAccessor]["#StartNode" /* StartNode */].parentNode
1734
1772
  );
1735
1773
  }
1736
1774
  } else {
1737
1775
  insertBranchBefore(
1738
- awaitBranch = scope[branchAccessor] = createAndSetupBranch(
1776
+ scope[branchAccessor] = createAndSetupBranch(
1739
1777
  scope["$global" /* Global */],
1740
- renderer,
1778
+ scope[rendererAccessor],
1741
1779
  scope,
1742
- referenceNode.parentNode
1780
+ scope[nodeAccessor].parentNode
1743
1781
  ),
1744
- referenceNode.parentNode,
1745
- referenceNode
1782
+ scope[nodeAccessor].parentNode,
1783
+ scope[nodeAccessor]
1746
1784
  );
1747
- referenceNode.remove();
1785
+ scope[nodeAccessor].remove();
1748
1786
  }
1749
- params?.(awaitBranch, [data]);
1750
- if (tryWithPlaceholder) {
1787
+ params?.(scope[branchAccessor], [data]);
1788
+ if (awaitCounter) {
1751
1789
  placeholderShown.add(pendingEffects);
1752
- if (!--tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */]) {
1753
- const placeholderBranch = tryWithPlaceholder["#PlaceholderBranch" /* PlaceholderBranch */];
1754
- tryWithPlaceholder["#PlaceholderBranch" /* PlaceholderBranch */] = 0;
1755
- if (placeholderBranch) {
1756
- placeholderBranch["#StartNode" /* StartNode */].parentNode.insertBefore(
1757
- tryWithPlaceholder["#StartNode" /* StartNode */].parentNode,
1758
- placeholderBranch["#StartNode" /* StartNode */]
1759
- );
1760
- removeAndDestroyBranch(placeholderBranch);
1790
+ awaitCounter.c();
1791
+ if (!awaitCounter.d) {
1792
+ const fnScopes = /* @__PURE__ */ new Map();
1793
+ const effects = renderData.m();
1794
+ for (let i = 0; i < pendingEffects.length; ) {
1795
+ const fn = pendingEffects[i++];
1796
+ let scopes = fnScopes.get(fn);
1797
+ if (!scopes) {
1798
+ fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
1799
+ }
1800
+ scopes.add(pendingEffects[i++]);
1761
1801
  }
1762
- queueEffect(tryWithPlaceholder, (scope2) => {
1763
- const pendingEffects2 = scope2["#PendingEffects" /* PendingEffects */];
1764
- if (pendingEffects2) {
1765
- scope2["#PendingEffects" /* PendingEffects */] = [];
1766
- runEffects(pendingEffects2, true);
1802
+ for (let i = 0; i < effects.length; ) {
1803
+ const fn = effects[i++];
1804
+ const scope2 = effects[i++];
1805
+ if (!fnScopes.get(fn)?.has(scope2)) {
1806
+ queueEffect(scope2, fn);
1767
1807
  }
1768
- });
1808
+ }
1769
1809
  }
1770
1810
  }
1771
1811
  },
@@ -1775,8 +1815,7 @@ function _await(nodeAccessor, template, walks, setup, params) {
1775
1815
  },
1776
1816
  (error) => {
1777
1817
  if (thisPromise === scope[promiseAccessor]) {
1778
- if (tryWithPlaceholder)
1779
- tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */] = 0;
1818
+ if (awaitCounter) awaitCounter.i = 0;
1780
1819
  scope[promiseAccessor] = 0;
1781
1820
  schedule();
1782
1821
  queueRender(scope, renderCatch, -1, error);
@@ -1785,6 +1824,13 @@ function _await(nodeAccessor, template, walks, setup, params) {
1785
1824
  );
1786
1825
  };
1787
1826
  }
1827
+ function _await_content(nodeAccessor, template, walks, setup) {
1828
+ const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + (true ? nodeAccessor : decodeAccessor4(nodeAccessor));
1829
+ const renderer = _content("", template, walks, setup)();
1830
+ return (scope) => {
1831
+ scope[rendererAccessor] = renderer;
1832
+ };
1833
+ }
1788
1834
  function _try(nodeAccessor, template, walks, setup) {
1789
1835
  if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
1790
1836
  const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
@@ -1816,7 +1862,8 @@ function renderCatch(scope, error) {
1816
1862
  const owner = tryWithCatch["_" /* Owner */];
1817
1863
  const placeholderBranch = tryWithCatch["#PlaceholderBranch" /* PlaceholderBranch */];
1818
1864
  if (placeholderBranch) {
1819
- tryWithCatch["#PendingAsyncCount" /* PendingAsyncCount */] = 0;
1865
+ if (tryWithCatch["#AwaitCounter" /* AwaitCounter */])
1866
+ tryWithCatch["#AwaitCounter" /* AwaitCounter */].i = 0;
1820
1867
  owner["BranchScopes:" /* BranchScopes */ + tryWithCatch["#BranchAccessor" /* BranchAccessor */]] = placeholderBranch;
1821
1868
  destroyBranch(tryWithCatch);
1822
1869
  }
@@ -2193,7 +2240,7 @@ var _enable_catch = () => {
2193
2240
  enableBranches();
2194
2241
  const handlePendingTry = (fn, scope, branch) => {
2195
2242
  while (branch) {
2196
- if (branch["#PendingAsyncCount" /* PendingAsyncCount */]) {
2243
+ if (branch["#AwaitCounter" /* AwaitCounter */]?.i) {
2197
2244
  return (branch["#PendingEffects" /* PendingEffects */] ||= []).push(fn, scope);
2198
2245
  }
2199
2246
  branch = branch["#ParentBranch" /* ParentBranch */];
@@ -2474,7 +2521,8 @@ export {
2474
2521
  _attrs_partial,
2475
2522
  _attrs_partial_content,
2476
2523
  _attrs_script,
2477
- _await,
2524
+ _await_content,
2525
+ _await_promise,
2478
2526
  _call,
2479
2527
  _child_setup,
2480
2528
  _closure,
@@ -374,7 +374,7 @@ var REORDER_RUNTIME_CODE = true ? (
374
374
  let onNextSibling,
375
375
  placeholder,
376
376
  nextSibling,
377
- placeholders = {},
377
+ placeholders = runtime.p = {},
378
378
  replace = (id, container) => runtime.l[id].replaceWith(...container.childNodes);
379
379
  runtime.d.head.append(
380
380
  runtime.d.querySelector("style[" + runtime.i + "]") || ""
@@ -424,7 +424,7 @@ var REORDER_RUNTIME_CODE = true ? (
424
424
  }
425
425
  };
426
426
  })`
427
- ) : `(e=>{if(e.j)return;let i,l,r,t={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),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)))}})`;
427
+ ) : `(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),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)))}})`;
428
428
 
429
429
  // src/html/serializer.ts
430
430
  var kTouchedIterator = Symbol();
@@ -1792,6 +1792,9 @@ function writeScript(script) {
1792
1792
  $chunk.writeScript(script);
1793
1793
  }
1794
1794
  function _script(scopeId, registryId) {
1795
+ if ($chunk.context?.[kIsAsync]) {
1796
+ _resume_branch(scopeId);
1797
+ }
1795
1798
  $chunk.boundary.state.needsMainRuntime = true;
1796
1799
  $chunk.writeEffect(scopeId, registryId);
1797
1800
  }
@@ -1831,13 +1834,13 @@ function normalizeServerRender(value) {
1831
1834
  }
1832
1835
  }
1833
1836
  var kPendingContexts = Symbol("Pending Contexts");
1834
- function withContext(key, value, cb) {
1837
+ function withContext(key, value, cb, cbValue) {
1835
1838
  const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
1836
1839
  const prev = ctx[key];
1837
1840
  ctx[kPendingContexts]++;
1838
1841
  ctx[key] = value;
1839
1842
  try {
1840
- return cb();
1843
+ return cb(cbValue);
1841
1844
  } finally {
1842
1845
  ctx[kPendingContexts]--;
1843
1846
  ctx[key] = prev;
@@ -1906,17 +1909,21 @@ function _hoist(scopeId, id) {
1906
1909
  return _resume(getter, id, scopeId);
1907
1910
  }
1908
1911
  function _resume_branch(scopeId) {
1909
- const branchId = $chunk.context?.[branchIdKey];
1912
+ const branchId = $chunk.context?.[kBranchId];
1910
1913
  if (branchId !== void 0 && branchId !== scopeId) {
1911
1914
  writeScope(scopeId, { ["#ClosestBranchId" /* ClosestBranchId */]: branchId });
1912
1915
  }
1913
1916
  }
1914
- var branchIdKey = Symbol();
1917
+ var kBranchId = Symbol("Branch Id");
1918
+ var kIsAsync = Symbol("Is Async");
1915
1919
  function isInResumedBranch() {
1916
- return $chunk?.context?.[branchIdKey] !== void 0;
1920
+ return $chunk?.context?.[kBranchId] !== void 0;
1917
1921
  }
1918
1922
  function withBranchId(branchId, cb) {
1919
- return withContext(branchIdKey, branchId, cb);
1923
+ return withContext(kBranchId, branchId, cb);
1924
+ }
1925
+ function withIsAsync(cb, value) {
1926
+ return withContext(kIsAsync, true, cb, value);
1920
1927
  }
1921
1928
  function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1922
1929
  const { state } = $chunk.boundary;
@@ -2300,7 +2307,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2300
2307
  $chunk.writeHTML(
2301
2308
  $chunk.boundary.state.mark("[" /* BranchStart */, "")
2302
2309
  );
2303
- content(value);
2310
+ withIsAsync(content, value);
2304
2311
  $chunk.writeHTML(
2305
2312
  $chunk.boundary.state.mark(
2306
2313
  "]" /* BranchEnd */,
@@ -2308,7 +2315,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2308
2315
  )
2309
2316
  );
2310
2317
  } else {
2311
- content(value);
2318
+ withIsAsync(content, value);
2312
2319
  }
2313
2320
  });
2314
2321
  boundary.endAsync(chunk);
@@ -2328,11 +2335,11 @@ function _try(scopeId, accessor, content, input) {
2328
2335
  const placeholderContent = normalizeDynamicRenderer(input.placeholder);
2329
2336
  if (catchContent) {
2330
2337
  tryCatch(
2331
- placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
2338
+ placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId) : content,
2332
2339
  catchContent
2333
2340
  );
2334
2341
  } else if (placeholderContent) {
2335
- tryPlaceholder(content, placeholderContent);
2342
+ tryPlaceholder(content, placeholderContent, branchId);
2336
2343
  } else {
2337
2344
  content();
2338
2345
  }
@@ -2348,7 +2355,7 @@ function _try(scopeId, accessor, content, input) {
2348
2355
  )
2349
2356
  );
2350
2357
  }
2351
- function tryPlaceholder(content, placeholder) {
2358
+ function tryPlaceholder(content, placeholder, branchId) {
2352
2359
  const chunk = $chunk;
2353
2360
  const { boundary } = chunk;
2354
2361
  const body = new Chunk(boundary, null, chunk.context);
@@ -2356,9 +2363,10 @@ function tryPlaceholder(content, placeholder) {
2356
2363
  chunk.append(body);
2357
2364
  return;
2358
2365
  }
2359
- chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context);
2366
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context);
2360
2367
  chunk.placeholderBody = body;
2361
2368
  chunk.placeholderRender = placeholder;
2369
+ chunk.placeholderBranchId = branchId;
2362
2370
  }
2363
2371
  function tryCatch(content, catchContent) {
2364
2372
  const chunk = $chunk;
@@ -2534,18 +2542,16 @@ var Chunk = class {
2534
2542
  reorderId = null;
2535
2543
  placeholderBody = null;
2536
2544
  placeholderRender = null;
2545
+ placeholderBranchId = null;
2537
2546
  writeHTML(html) {
2538
2547
  this.html += html;
2539
2548
  }
2540
2549
  writeEffect(scopeId, registryId) {
2541
2550
  if (this.lastEffect === registryId) {
2542
- this.effects += "," + scopeId;
2551
+ this.effects += " " + scopeId;
2543
2552
  } else {
2544
2553
  this.lastEffect = registryId;
2545
- this.effects = concatEffects(
2546
- this.effects,
2547
- '"' + registryId + '",' + scopeId
2548
- );
2554
+ this.effects = concatEffects(this.effects, registryId + " " + scopeId);
2549
2555
  }
2550
2556
  }
2551
2557
  writeScript(script) {
@@ -2562,7 +2568,8 @@ var Chunk = class {
2562
2568
  const body = this.placeholderBody.consume();
2563
2569
  if (body.async) {
2564
2570
  const { state } = this.boundary;
2565
- const reorderId = body.reorderId = state.nextReorderId();
2571
+ const reorderId = body.reorderId = this.placeholderBranchId ? this.placeholderBranchId + "" : state.nextReorderId();
2572
+ this.placeholderBranchId = null;
2566
2573
  this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
2567
2574
  const after = this.render(this.placeholderRender);
2568
2575
  if (after !== this) {
@@ -2634,7 +2641,7 @@ var Chunk = class {
2634
2641
  }
2635
2642
  if (effects) {
2636
2643
  needsWalk = true;
2637
- state.resumes = state.resumes ? state.resumes + "," + effects : effects;
2644
+ state.resumes = state.resumes ? state.resumes + ',"' + effects + '"' : '"' + effects + '"';
2638
2645
  }
2639
2646
  if (state.resumes) {
2640
2647
  if (state.hasWrittenResume) {
@@ -2698,12 +2705,12 @@ var Chunk = class {
2698
2705
  }
2699
2706
  reorderScripts = concatScripts(
2700
2707
  reorderScripts,
2701
- "_.push(" + reorderEffects + ")"
2708
+ '_.push("' + reorderEffects + '")'
2702
2709
  );
2703
2710
  }
2704
2711
  scripts = concatScripts(
2705
2712
  scripts,
2706
- reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
2713
+ reorderScripts && runtimePrefix + ".j" /* Scripts */ + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"
2707
2714
  );
2708
2715
  html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2709
2716
  }
@@ -2762,7 +2769,7 @@ function flushSerializer(boundary) {
2762
2769
  if (scopeIdDelta) serializeData.push(scopeIdDelta);
2763
2770
  serializeData.push(scope);
2764
2771
  }
2765
- state.resumes = concatEffects(
2772
+ state.resumes = concatSequence(
2766
2773
  state.resumes,
2767
2774
  serializer.stringify(serializeData, boundary)
2768
2775
  );
@@ -2777,6 +2784,9 @@ function _trailers(html) {
2777
2784
  $chunk.boundary.state.trailerHTML += html;
2778
2785
  }
2779
2786
  function concatEffects(a, b) {
2787
+ return a ? b ? a + " " + b : a : b;
2788
+ }
2789
+ function concatSequence(a, b) {
2780
2790
  return a ? b ? a + "," + b : a : b;
2781
2791
  }
2782
2792
  function concatScripts(a, b) {