marko 6.3.23 → 6.3.24

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/debug/dom.js CHANGED
@@ -1496,58 +1496,59 @@ function _await_promise(nodeAccessor, params) {
1496
1496
  const promiseAccessor = Promise$1 + nodeAccessor;
1497
1497
  const branchAccessor = BranchScopes$1 + nodeAccessor;
1498
1498
  _enable_catch();
1499
- return (scope, promise) => {
1500
- if (!isPromise(promise)) {
1501
- if (!scope[promiseAccessor]) {
1502
- const resolve = () => resolveAwait(scope, branchAccessor, nodeAccessor, scope[nodeAccessor], params, promise);
1503
- if (scope[branchAccessor]) resolve();
1504
- else scope[promiseAccessor] = resolve;
1505
- return;
1506
- }
1507
- promise = Promise.resolve(promise);
1499
+ const resolveAwait = (scope, referenceNode, value) => {
1500
+ const awaitBranch = scope[branchAccessor];
1501
+ if (awaitBranch["#DetachedAwait"]) {
1502
+ awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1503
+ setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1504
+ awaitBranch[DetachedAwait] = 0;
1505
+ insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1506
+ referenceNode.remove();
1508
1507
  }
1508
+ params?.(awaitBranch, [value]);
1509
+ return awaitBranch;
1510
+ };
1511
+ const awaitPromise = (scope, promise) => {
1512
+ if (!isPromise(promise) && scope[promiseAccessor]) promise = Promise.resolve(promise);
1509
1513
  let awaitBranch = scope[branchAccessor];
1510
1514
  const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
1511
1515
  const tryBranch = tryPlaceholder || awaitBranch;
1516
+ if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1517
+ scope[promiseAccessor] = () => awaitPromise(scope, promise);
1518
+ return;
1519
+ }
1520
+ if (!isPromise(promise)) {
1521
+ resolveAwait(scope, scope[nodeAccessor], promise);
1522
+ return;
1523
+ }
1512
1524
  let awaitCounter = tryBranch[AwaitCounter];
1513
1525
  placeholderShown.add(pendingEffects);
1514
- if (tryPlaceholder) {
1515
- if (!scope[promiseAccessor]) {
1516
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1517
- awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1518
- }
1519
- } else {
1520
- if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
1521
- i: 0,
1522
- c() {
1523
- if (--awaitCounter.i) return 1;
1524
- if (tryBranch === scope[branchAccessor]) {
1525
- const anchor = scope[nodeAccessor];
1526
- if (anchor.parentNode) {
1527
- const detachedParent = scope[branchAccessor][StartNode].parentNode;
1528
- if (detachedParent === anchor.parentNode) anchor.remove();
1529
- else anchor.replaceWith(detachedParent);
1530
- }
1531
- } else dismissPlaceholder(tryBranch);
1532
- queueEffect(tryBranch, runPendingEffects);
1526
+ if (!tryPlaceholder && !awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
1527
+ if (tryBranch === scope[branchAccessor]) {
1528
+ const anchor = scope[nodeAccessor];
1529
+ if (anchor.parentNode) {
1530
+ const detachedParent = scope[branchAccessor][StartNode].parentNode;
1531
+ if (detachedParent === anchor.parentNode) anchor.remove();
1532
+ else anchor.replaceWith(detachedParent);
1533
1533
  }
1534
- };
1535
- if (!scope[promiseAccessor]) {
1536
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1537
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1538
- if (!awaitBranch["#DetachedAwait"]) {
1539
- awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1540
- tempDetachBranch(tryBranch);
1541
- }
1542
- }, -1))));
1543
- }
1534
+ } else dismissPlaceholder(tryBranch);
1535
+ });
1536
+ if (!scope[promiseAccessor]) {
1537
+ if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1538
+ if (tryPlaceholder) awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1539
+ else if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1540
+ if (!awaitBranch["#DetachedAwait"]) {
1541
+ awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1542
+ tempDetachBranch(tryBranch);
1543
+ }
1544
+ }, -1))));
1544
1545
  }
1545
1546
  const thisPromise = scope[promiseAccessor] = promise.then((data) => {
1546
1547
  if (thisPromise === scope[promiseAccessor]) {
1547
1548
  const referenceNode = scope[nodeAccessor];
1548
1549
  scope[promiseAccessor] = 0;
1549
1550
  queueAsyncRender(scope, () => {
1550
- awaitBranch = resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, data);
1551
+ awaitBranch = resolveAwait(scope, referenceNode, data);
1551
1552
  const pendingRenders = awaitBranch[PendingRenders];
1552
1553
  awaitBranch[PendingRenders] = 0;
1553
1554
  pendingRenders?.forEach(queuePendingRender);
@@ -1579,18 +1580,7 @@ function _await_promise(nodeAccessor, params) {
1579
1580
  }
1580
1581
  });
1581
1582
  };
1582
- }
1583
- function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, value) {
1584
- const awaitBranch = scope[branchAccessor];
1585
- if (awaitBranch["#DetachedAwait"]) {
1586
- awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1587
- setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1588
- awaitBranch[DetachedAwait] = 0;
1589
- insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1590
- referenceNode.remove();
1591
- }
1592
- params?.(awaitBranch, [value]);
1593
- return awaitBranch;
1583
+ return awaitPromise;
1594
1584
  }
1595
1585
  function _await_content(nodeAccessor, template, walks, setup) {
1596
1586
  const branchAccessor = BranchScopes$1 + nodeAccessor;
@@ -1609,19 +1599,23 @@ function _await_content(nodeAccessor, template, walks, setup) {
1609
1599
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
1610
1600
  if (!tryBranch) return;
1611
1601
  let awaitCounter = tryBranch[AwaitCounter];
1612
- if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
1602
+ if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch));
1603
+ placeholderShown.add(pendingEffects);
1604
+ if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1605
+ insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1606
+ tempDetachBranch(tryBranch);
1607
+ }, -1))));
1608
+ return awaitCounter;
1609
+ }
1610
+ function createAwaitCounter(tryBranch, done) {
1611
+ const awaitCounter = tryBranch[AwaitCounter] = {
1613
1612
  i: 0,
1614
1613
  c() {
1615
1614
  if (--awaitCounter.i) return 1;
1616
- dismissPlaceholder(tryBranch);
1615
+ done();
1617
1616
  queueEffect(tryBranch, runPendingEffects);
1618
1617
  }
1619
1618
  };
1620
- placeholderShown.add(pendingEffects);
1621
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1622
- insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1623
- tempDetachBranch(tryBranch);
1624
- }, -1))));
1625
1619
  return awaitCounter;
1626
1620
  }
1627
1621
  function runPendingEffects(scope) {
@@ -1494,58 +1494,59 @@ function _await_promise(nodeAccessor, params) {
1494
1494
  const promiseAccessor = Promise$1 + nodeAccessor;
1495
1495
  const branchAccessor = BranchScopes$1 + nodeAccessor;
1496
1496
  _enable_catch();
1497
- return (scope, promise) => {
1498
- if (!isPromise(promise)) {
1499
- if (!scope[promiseAccessor]) {
1500
- const resolve = () => resolveAwait(scope, branchAccessor, nodeAccessor, scope[nodeAccessor], params, promise);
1501
- if (scope[branchAccessor]) resolve();
1502
- else scope[promiseAccessor] = resolve;
1503
- return;
1504
- }
1505
- promise = Promise.resolve(promise);
1497
+ const resolveAwait = (scope, referenceNode, value) => {
1498
+ const awaitBranch = scope[branchAccessor];
1499
+ if (awaitBranch["#DetachedAwait"]) {
1500
+ awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1501
+ setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1502
+ awaitBranch[DetachedAwait] = 0;
1503
+ insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1504
+ referenceNode.remove();
1506
1505
  }
1506
+ params?.(awaitBranch, [value]);
1507
+ return awaitBranch;
1508
+ };
1509
+ const awaitPromise = (scope, promise) => {
1510
+ if (!isPromise(promise) && scope[promiseAccessor]) promise = Promise.resolve(promise);
1507
1511
  let awaitBranch = scope[branchAccessor];
1508
1512
  const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
1509
1513
  const tryBranch = tryPlaceholder || awaitBranch;
1514
+ if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1515
+ scope[promiseAccessor] = () => awaitPromise(scope, promise);
1516
+ return;
1517
+ }
1518
+ if (!isPromise(promise)) {
1519
+ resolveAwait(scope, scope[nodeAccessor], promise);
1520
+ return;
1521
+ }
1510
1522
  let awaitCounter = tryBranch[AwaitCounter];
1511
1523
  placeholderShown.add(pendingEffects);
1512
- if (tryPlaceholder) {
1513
- if (!scope[promiseAccessor]) {
1514
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1515
- awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1516
- }
1517
- } else {
1518
- if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
1519
- i: 0,
1520
- c() {
1521
- if (--awaitCounter.i) return 1;
1522
- if (tryBranch === scope[branchAccessor]) {
1523
- const anchor = scope[nodeAccessor];
1524
- if (anchor.parentNode) {
1525
- const detachedParent = scope[branchAccessor][StartNode].parentNode;
1526
- if (detachedParent === anchor.parentNode) anchor.remove();
1527
- else anchor.replaceWith(detachedParent);
1528
- }
1529
- } else dismissPlaceholder(tryBranch);
1530
- queueEffect(tryBranch, runPendingEffects);
1524
+ if (!tryPlaceholder && !awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
1525
+ if (tryBranch === scope[branchAccessor]) {
1526
+ const anchor = scope[nodeAccessor];
1527
+ if (anchor.parentNode) {
1528
+ const detachedParent = scope[branchAccessor][StartNode].parentNode;
1529
+ if (detachedParent === anchor.parentNode) anchor.remove();
1530
+ else anchor.replaceWith(detachedParent);
1531
1531
  }
1532
- };
1533
- if (!scope[promiseAccessor]) {
1534
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1535
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1536
- if (!awaitBranch["#DetachedAwait"]) {
1537
- awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1538
- tempDetachBranch(tryBranch);
1539
- }
1540
- }, -1))));
1541
- }
1532
+ } else dismissPlaceholder(tryBranch);
1533
+ });
1534
+ if (!scope[promiseAccessor]) {
1535
+ if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1536
+ if (tryPlaceholder) awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1537
+ else if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1538
+ if (!awaitBranch["#DetachedAwait"]) {
1539
+ awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1540
+ tempDetachBranch(tryBranch);
1541
+ }
1542
+ }, -1))));
1542
1543
  }
1543
1544
  const thisPromise = scope[promiseAccessor] = promise.then((data) => {
1544
1545
  if (thisPromise === scope[promiseAccessor]) {
1545
1546
  const referenceNode = scope[nodeAccessor];
1546
1547
  scope[promiseAccessor] = 0;
1547
1548
  queueAsyncRender(scope, () => {
1548
- awaitBranch = resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, data);
1549
+ awaitBranch = resolveAwait(scope, referenceNode, data);
1549
1550
  const pendingRenders = awaitBranch[PendingRenders];
1550
1551
  awaitBranch[PendingRenders] = 0;
1551
1552
  pendingRenders?.forEach(queuePendingRender);
@@ -1577,18 +1578,7 @@ function _await_promise(nodeAccessor, params) {
1577
1578
  }
1578
1579
  });
1579
1580
  };
1580
- }
1581
- function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, value) {
1582
- const awaitBranch = scope[branchAccessor];
1583
- if (awaitBranch["#DetachedAwait"]) {
1584
- awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1585
- setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1586
- awaitBranch[DetachedAwait] = 0;
1587
- insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1588
- referenceNode.remove();
1589
- }
1590
- params?.(awaitBranch, [value]);
1591
- return awaitBranch;
1581
+ return awaitPromise;
1592
1582
  }
1593
1583
  function _await_content(nodeAccessor, template, walks, setup) {
1594
1584
  const branchAccessor = BranchScopes$1 + nodeAccessor;
@@ -1607,19 +1597,23 @@ function _await_content(nodeAccessor, template, walks, setup) {
1607
1597
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
1608
1598
  if (!tryBranch) return;
1609
1599
  let awaitCounter = tryBranch[AwaitCounter];
1610
- if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
1600
+ if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch));
1601
+ placeholderShown.add(pendingEffects);
1602
+ if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1603
+ insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1604
+ tempDetachBranch(tryBranch);
1605
+ }, -1))));
1606
+ return awaitCounter;
1607
+ }
1608
+ function createAwaitCounter(tryBranch, done) {
1609
+ const awaitCounter = tryBranch[AwaitCounter] = {
1611
1610
  i: 0,
1612
1611
  c() {
1613
1612
  if (--awaitCounter.i) return 1;
1614
- dismissPlaceholder(tryBranch);
1613
+ done();
1615
1614
  queueEffect(tryBranch, runPendingEffects);
1616
1615
  }
1617
1616
  };
1618
- placeholderShown.add(pendingEffects);
1619
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1620
- insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1621
- tempDetachBranch(tryBranch);
1622
- }, -1))));
1623
1617
  return awaitCounter;
1624
1618
  }
1625
1619
  function runPendingEffects(scope) {
@@ -624,7 +624,7 @@ function writeScopesRoot(state, flushes) {
624
624
  const ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId);
625
625
  const openIndex = buf.push("") - 1;
626
626
  if (writeObjectProps(state, flush[2], ref)) {
627
- buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId > nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
627
+ buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId !== nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
628
628
  if (fillIndex === -1) fillIndex = openIndex;
629
629
  nextSlotId = scopeId + 1;
630
630
  buf.push("}");
@@ -622,7 +622,7 @@ function writeScopesRoot(state, flushes) {
622
622
  const ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId);
623
623
  const openIndex = buf.push("") - 1;
624
624
  if (writeObjectProps(state, flush[2], ref)) {
625
- buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId > nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
625
+ buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId !== nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
626
626
  if (fillIndex === -1) fillIndex = openIndex;
627
627
  nextSlotId = scopeId + 1;
628
628
  buf.push("}");
package/dist/dom.js CHANGED
@@ -934,37 +934,38 @@ function toInsertNode(startNode, endNode) {
934
934
  function _await_promise(nodeAccessor, params) {
935
935
  nodeAccessor = decodeAccessor(nodeAccessor);
936
936
  let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor;
937
- return _enable_catch(), (scope, promise) => {
937
+ _enable_catch();
938
+ let resolveAwait = (scope, referenceNode, value) => {
939
+ let awaitBranch = scope[branchAccessor];
940
+ return awaitBranch.V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [value]), awaitBranch;
941
+ }, awaitPromise = (scope, promise) => {
942
+ !isPromise(promise) && scope[promiseAccessor] && (promise = Promise.resolve(promise));
943
+ let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch;
944
+ if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
945
+ scope[promiseAccessor] = () => awaitPromise(scope, promise);
946
+ return;
947
+ }
938
948
  if (!isPromise(promise)) {
939
- if (!scope[promiseAccessor]) {
940
- let resolve = () => resolveAwait(scope, branchAccessor, nodeAccessor, scope[nodeAccessor], params, promise);
941
- scope[branchAccessor] ? resolve() : scope[promiseAccessor] = resolve;
942
- return;
943
- }
944
- promise = Promise.resolve(promise);
949
+ resolveAwait(scope, scope[nodeAccessor], promise);
950
+ return;
945
951
  }
946
- let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch, awaitCounter = tryBranch.O;
947
- placeholderShown.add(pendingEffects), tryPlaceholder ? scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter = addAwaitCounter(scope, tryPlaceholder)) : (awaitCounter?.i || (awaitCounter = tryBranch.O = {
948
- i: 0,
949
- c() {
950
- if (--awaitCounter.i) return 1;
951
- if (tryBranch === scope[branchAccessor]) {
952
- let anchor = scope[nodeAccessor];
953
- if (anchor.parentNode) {
954
- let detachedParent = scope[branchAccessor].S.parentNode;
955
- detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
956
- }
957
- } else dismissPlaceholder(tryBranch);
958
- queueEffect(tryBranch, runPendingEffects);
959
- }
960
- }), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
952
+ let awaitCounter = tryBranch.O;
953
+ placeholderShown.add(pendingEffects), !tryPlaceholder && !awaitCounter?.i && (awaitCounter = createAwaitCounter(tryBranch, () => {
954
+ if (tryBranch === scope[branchAccessor]) {
955
+ let anchor = scope[nodeAccessor];
956
+ if (anchor.parentNode) {
957
+ let detachedParent = scope[branchAccessor].S.parentNode;
958
+ detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
959
+ }
960
+ } else dismissPlaceholder(tryBranch);
961
+ })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
961
962
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
962
- }, -1))))));
963
+ }, -1)))));
963
964
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
964
965
  if (thisPromise === scope[promiseAccessor]) {
965
966
  let referenceNode = scope[nodeAccessor];
966
967
  scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
967
- awaitBranch = resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, data);
968
+ awaitBranch = resolveAwait(scope, referenceNode, data);
968
969
  let pendingRenders = awaitBranch.W;
969
970
  if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
970
971
  let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
@@ -983,10 +984,7 @@ function _await_promise(nodeAccessor, params) {
983
984
  thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, tryPlaceholder && !awaitCounter.m ? awaitCounter.c() : awaitCounter.i = 0, queueAsyncRender(scope, renderCatch, error));
984
985
  });
985
986
  };
986
- }
987
- function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, value) {
988
- let awaitBranch = scope[branchAccessor];
989
- return awaitBranch.V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [value]), awaitBranch;
987
+ return awaitPromise;
990
988
  }
991
989
  function _await_content(nodeAccessor, template, walks, setup) {
992
990
  nodeAccessor = decodeAccessor(nodeAccessor);
@@ -1001,15 +999,19 @@ function _await_content(nodeAccessor, template, walks, setup) {
1001
999
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
1002
1000
  if (!tryBranch) return;
1003
1001
  let awaitCounter = tryBranch.O;
1004
- return awaitCounter?.i || (awaitCounter = tryBranch.O = {
1002
+ return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1003
+ insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1004
+ }, -1)))), awaitCounter;
1005
+ }
1006
+ function createAwaitCounter(tryBranch, done) {
1007
+ let awaitCounter = tryBranch.O = {
1005
1008
  i: 0,
1006
1009
  c() {
1007
1010
  if (--awaitCounter.i) return 1;
1008
- dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
1011
+ done(), queueEffect(tryBranch, runPendingEffects);
1009
1012
  }
1010
- }), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1011
- insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1012
- }, -1)))), awaitCounter;
1013
+ };
1014
+ return awaitCounter;
1013
1015
  }
1014
1016
  function runPendingEffects(scope) {
1015
1017
  let effects = scope.J;
package/dist/dom.mjs CHANGED
@@ -933,37 +933,38 @@ function toInsertNode(startNode, endNode) {
933
933
  function _await_promise(nodeAccessor, params) {
934
934
  nodeAccessor = decodeAccessor(nodeAccessor);
935
935
  let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor;
936
- return _enable_catch(), (scope, promise) => {
936
+ _enable_catch();
937
+ let resolveAwait = (scope, referenceNode, value) => {
938
+ let awaitBranch = scope[branchAccessor];
939
+ return awaitBranch.V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [value]), awaitBranch;
940
+ }, awaitPromise = (scope, promise) => {
941
+ !isPromise(promise) && scope[promiseAccessor] && (promise = Promise.resolve(promise));
942
+ let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch;
943
+ if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
944
+ scope[promiseAccessor] = () => awaitPromise(scope, promise);
945
+ return;
946
+ }
937
947
  if (!isPromise(promise)) {
938
- if (!scope[promiseAccessor]) {
939
- let resolve = () => resolveAwait(scope, branchAccessor, nodeAccessor, scope[nodeAccessor], params, promise);
940
- scope[branchAccessor] ? resolve() : scope[promiseAccessor] = resolve;
941
- return;
942
- }
943
- promise = Promise.resolve(promise);
948
+ resolveAwait(scope, scope[nodeAccessor], promise);
949
+ return;
944
950
  }
945
- let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch, awaitCounter = tryBranch.O;
946
- placeholderShown.add(pendingEffects), tryPlaceholder ? scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter = addAwaitCounter(scope, tryPlaceholder)) : (awaitCounter?.i || (awaitCounter = tryBranch.O = {
947
- i: 0,
948
- c() {
949
- if (--awaitCounter.i) return 1;
950
- if (tryBranch === scope[branchAccessor]) {
951
- let anchor = scope[nodeAccessor];
952
- if (anchor.parentNode) {
953
- let detachedParent = scope[branchAccessor].S.parentNode;
954
- detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
955
- }
956
- } else dismissPlaceholder(tryBranch);
957
- queueEffect(tryBranch, runPendingEffects);
958
- }
959
- }), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
951
+ let awaitCounter = tryBranch.O;
952
+ placeholderShown.add(pendingEffects), !tryPlaceholder && !awaitCounter?.i && (awaitCounter = createAwaitCounter(tryBranch, () => {
953
+ if (tryBranch === scope[branchAccessor]) {
954
+ let anchor = scope[nodeAccessor];
955
+ if (anchor.parentNode) {
956
+ let detachedParent = scope[branchAccessor].S.parentNode;
957
+ detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
958
+ }
959
+ } else dismissPlaceholder(tryBranch);
960
+ })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
960
961
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
961
- }, -1))))));
962
+ }, -1)))));
962
963
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
963
964
  if (thisPromise === scope[promiseAccessor]) {
964
965
  let referenceNode = scope[nodeAccessor];
965
966
  scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
966
- awaitBranch = resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, data);
967
+ awaitBranch = resolveAwait(scope, referenceNode, data);
967
968
  let pendingRenders = awaitBranch.W;
968
969
  if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
969
970
  let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
@@ -982,10 +983,7 @@ function _await_promise(nodeAccessor, params) {
982
983
  thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, tryPlaceholder && !awaitCounter.m ? awaitCounter.c() : awaitCounter.i = 0, queueAsyncRender(scope, renderCatch, error));
983
984
  });
984
985
  };
985
- }
986
- function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, value) {
987
- let awaitBranch = scope[branchAccessor];
988
- return awaitBranch.V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [value]), awaitBranch;
986
+ return awaitPromise;
989
987
  }
990
988
  function _await_content(nodeAccessor, template, walks, setup) {
991
989
  nodeAccessor = decodeAccessor(nodeAccessor);
@@ -1000,15 +998,19 @@ function _await_content(nodeAccessor, template, walks, setup) {
1000
998
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
1001
999
  if (!tryBranch) return;
1002
1000
  let awaitCounter = tryBranch.O;
1003
- return awaitCounter?.i || (awaitCounter = tryBranch.O = {
1001
+ return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1002
+ insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1003
+ }, -1)))), awaitCounter;
1004
+ }
1005
+ function createAwaitCounter(tryBranch, done) {
1006
+ let awaitCounter = tryBranch.O = {
1004
1007
  i: 0,
1005
1008
  c() {
1006
1009
  if (--awaitCounter.i) return 1;
1007
- dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
1010
+ done(), queueEffect(tryBranch, runPendingEffects);
1008
1011
  }
1009
- }), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1010
- insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1011
- }, -1)))), awaitCounter;
1012
+ };
1013
+ return awaitCounter;
1012
1014
  }
1013
1015
  function runPendingEffects(scope) {
1014
1016
  let effects = scope.J;
package/dist/html.js CHANGED
@@ -262,7 +262,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
262
262
  _html(`</${renderer}>`);
263
263
  }
264
264
  let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
265
- needsScript && (writeScope(branchId, { R: renderer }), _script(branchId, "d")), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
265
+ needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
266
266
  })();
267
267
  } else {
268
268
  shouldResume && _html(state.mark("[", ""));
@@ -516,7 +516,7 @@ function writeScopesRoot(state, flushes) {
516
516
  let { buf } = state, nextSlotId = -1, fillIndex = -1;
517
517
  for (let flush of flushes) {
518
518
  let scopeId = flush[0], scope = flush[1], ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId), openIndex = buf.push("") - 1;
519
- writeObjectProps(state, flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId > nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{", fillIndex === -1 && (fillIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
519
+ writeObjectProps(state, flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId === nextSlotId ? "" : "," + (scopeId - nextSlotId)) + ",{", fillIndex === -1 && (fillIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
520
520
  }
521
521
  nextSlotId !== -1 && buf.push("]");
522
522
  let extras = "";
package/dist/html.mjs CHANGED
@@ -262,7 +262,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
262
262
  _html(`</${renderer}>`);
263
263
  }
264
264
  let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
265
- needsScript && (writeScope(branchId, { R: renderer }), _script(branchId, "d")), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
265
+ needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
266
266
  })();
267
267
  } else {
268
268
  shouldResume && _html(state.mark("[", ""));
@@ -515,7 +515,7 @@ function writeScopesRoot(state, flushes) {
515
515
  let { buf } = state, nextSlotId = -1, fillIndex = -1;
516
516
  for (let flush of flushes) {
517
517
  let scopeId = flush[0], scope = flush[1], ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId), openIndex = buf.push("") - 1;
518
- writeObjectProps(state, flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId > nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{", fillIndex === -1 && (fillIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
518
+ writeObjectProps(state, flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId === nextSlotId ? "" : "," + (scopeId - nextSlotId)) + ",{", fillIndex === -1 && (fillIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
519
519
  }
520
520
  nextSlotId !== -1 && buf.push("]");
521
521
  let extras = "";
@@ -2071,10 +2071,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2071
2071
  }
2072
2072
  const childScope = getScopeById(branchId);
2073
2073
  const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
2074
- if (needsScript) {
2075
- writeScope(branchId, { [Renderer$1]: renderer });
2076
- _script(branchId, "d");
2077
- }
2074
+ if (needsScript) _script(branchId, "d");
2078
2075
  if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2079
2076
  };
2080
2077
  renderNative();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.23",
3
+ "version": "6.3.24",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -54,8 +54,8 @@
54
54
  "magic-string": "^0.30.21"
55
55
  },
56
56
  "devDependencies": {
57
- "@marko/runtime-tags": "npm:marko@6.3.23",
58
- "marko": "5.39.28"
57
+ "@marko/runtime-tags": "npm:marko@6.3.24",
58
+ "marko": "5.39.29"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=22"