octane 0.1.19 → 0.1.21

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/runtime.js CHANGED
@@ -315,6 +315,13 @@ function flushTransitionActionBatch(batch) {
315
315
  );
316
316
  scheduleRender(block);
317
317
  }
318
+ if (batch.updates.size > 0) {
319
+ const retained = [];
320
+ for (const update of batch.updates.values()) {
321
+ if (!update.block.disposed) retained.push(update);
322
+ }
323
+ if (retained.length > 0) FLUSHED_TRANSITION_UPDATES.push(retained);
324
+ }
318
325
  batch.updates.clear();
319
326
  if (IN_FLIGHT_TRANSITION_ACTION_BATCH === batch) {
320
327
  IN_FLIGHT_TRANSITION_ACTION_BATCH = null;
@@ -331,6 +338,410 @@ const HELD_TRANSITIONS = /* @__PURE__ */ new Set();
331
338
  const STAGED_REVEALS = /* @__PURE__ */ new Set();
332
339
  let flushingStagedReveals = false;
333
340
  let deferringStagedRevealEffects = false;
341
+ let ACTIVE_TRANSITION_ATTEMPT = null;
342
+ let FLUSHED_TRANSITION_UPDATES = [];
343
+ let HELD_SYNC_TRANSITION = null;
344
+ let PROMOTED_PU_SWAPS = null;
345
+ let PROMOTED_WARM_HARVEST = null;
346
+ function beginTransitionAttempt(block) {
347
+ if (block.pendingMode !== "transition" || ACTIVE_TRANSITION_ATTEMPT !== null) return null;
348
+ TRANSITION_JOURNAL ??= [];
349
+ TRANSITION_JOURNAL_BAGS ??= /* @__PURE__ */ new Set();
350
+ TRANSITION_JOURNAL_DEPTH++;
351
+ const attempt = {
352
+ origin: block,
353
+ journalCheckpoint: TRANSITION_JOURNAL.length,
354
+ effects: [effectQueues[0].length, effectQueues[1].length, effectQueues[2].length],
355
+ effectEvents: effectEventQueue.length,
356
+ effectEventActions: effectEventCommitActions.length,
357
+ stores: storeSyncQueue.length,
358
+ refAttach: refAttachQueue.length,
359
+ refDetach: refDetachQueue.length,
360
+ effectDeps: snapshotSubtreeEffectDeps(block),
361
+ heldSlots: null,
362
+ puSwaps: null
363
+ };
364
+ ACTIVE_TRANSITION_ATTEMPT = attempt;
365
+ return attempt;
366
+ }
367
+ function endTransitionAttempt(attempt) {
368
+ if (attempt === null) return;
369
+ ACTIVE_TRANSITION_ATTEMPT = null;
370
+ const held = attempt.heldSlots;
371
+ if (held === null || held.size === 0) {
372
+ PROMOTED_PU_SWAPS = null;
373
+ PROMOTED_WARM_HARVEST = null;
374
+ }
375
+ let entries = null;
376
+ if (held !== null && held.size > 0) {
377
+ entries = [];
378
+ for (let i = FLUSHED_TRANSITION_UPDATES.length - 1; i >= 0; i--) {
379
+ const group = FLUSHED_TRANSITION_UPDATES[i];
380
+ let single = true;
381
+ for (let k = 0; k < group.length; k++) {
382
+ if (group[k].block !== attempt.origin) {
383
+ single = false;
384
+ break;
385
+ }
386
+ }
387
+ if (!single) continue;
388
+ for (let k = 0; k < group.length; k++) entries.push(group[k]);
389
+ FLUSHED_TRANSITION_UPDATES.splice(i, 1);
390
+ }
391
+ }
392
+ if (held !== null && held.size > 0 && entries !== null && entries.length > 0) {
393
+ rollbackTransitionJournal(attempt.journalCheckpoint);
394
+ for (let phase = 0; phase < 3; phase++) {
395
+ effectQueues[phase].length = attempt.effects[phase];
396
+ }
397
+ effectEventQueue.length = attempt.effectEvents;
398
+ effectEventCommitActions.length = attempt.effectEventActions;
399
+ for (let i = attempt.stores; i < storeSyncQueue.length; i++) {
400
+ storeSyncQueue[i].queued = false;
401
+ }
402
+ storeSyncQueue.length = attempt.stores;
403
+ refAttachQueue.length = attempt.refAttach;
404
+ refDetachQueue.length = attempt.refDetach;
405
+ restoreSubtreeEffectDeps(attempt.origin, attempt.effectDeps);
406
+ const continuing = PROMOTED_PU_SWAPS !== null || PROMOTED_WARM_HARVEST !== null;
407
+ let puSwaps = attempt.puSwaps;
408
+ if (continuing) {
409
+ if (PROMOTED_PU_SWAPS !== null) {
410
+ puSwaps = puSwaps === null ? PROMOTED_PU_SWAPS : PROMOTED_PU_SWAPS.concat(puSwaps);
411
+ PROMOTED_PU_SWAPS = null;
412
+ }
413
+ } else if (puSwaps !== null) {
414
+ for (let i = puSwaps.length - 1; i >= 0; i--) {
415
+ const [hooks, slot, prev] = puSwaps[i];
416
+ if (prev === void 0) hooks.delete(slot);
417
+ else hooks.set(slot, prev);
418
+ }
419
+ }
420
+ for (let i = 0; i < entries.length; i++) {
421
+ entries[i].slot.value = entries[i].baseValue;
422
+ }
423
+ let warmHarvest = PROMOTED_WARM_HARVEST;
424
+ PROMOTED_WARM_HARVEST = null;
425
+ if (warmHarvest !== null) {
426
+ for (let i = 0; i < warmHarvest.length; i++) warmHarvest[i].taken = false;
427
+ }
428
+ const harvest = (scope) => {
429
+ const cache = scope.block.__warmCache;
430
+ if (cache !== void 0) {
431
+ for (const [slot, list] of cache) {
432
+ for (let i = 0; i < list.length; i++) {
433
+ const entry = list[i];
434
+ if (entry.available) {
435
+ (warmHarvest ??= []).push({
436
+ slot,
437
+ deps: entry.deps,
438
+ value: entry.value,
439
+ taken: false
440
+ });
441
+ }
442
+ }
443
+ }
444
+ }
445
+ forEachSubtreeChild(scope, harvest);
446
+ };
447
+ harvest(attempt.origin);
448
+ HELD_SYNC_TRANSITION = {
449
+ origin: attempt.origin,
450
+ entries,
451
+ puSwaps,
452
+ warmHarvest,
453
+ holders: new Set(held)
454
+ };
455
+ if (!continuing) scheduleRender(attempt.origin);
456
+ }
457
+ if (--TRANSITION_JOURNAL_DEPTH === 0) {
458
+ TRANSITION_JOURNAL = null;
459
+ TRANSITION_JOURNAL_BAGS = null;
460
+ flushParkedItems();
461
+ }
462
+ }
463
+ function journalPuEntry(scope, slot, next) {
464
+ const attempt = ACTIVE_TRANSITION_ATTEMPT;
465
+ if (attempt === null) return;
466
+ const hooks = ensureHooks(scope);
467
+ (attempt.puSwaps ??= []).push([hooks, slot, hooks.get(slot), next]);
468
+ }
469
+ function heldSyncCellsIntact(state) {
470
+ const held = HELD_SYNC_TRANSITION;
471
+ if (held === null || !held.holders.has(state)) return false;
472
+ for (let i = 0; i < held.entries.length; i++) {
473
+ const entry = held.entries[i];
474
+ if (!Object.is(entry.slot.value, entry.baseValue)) return false;
475
+ }
476
+ return true;
477
+ }
478
+ function promoteHeldSyncTransition() {
479
+ const held = HELD_SYNC_TRANSITION;
480
+ if (held === null) return false;
481
+ HELD_SYNC_TRANSITION = null;
482
+ const puSwaps = held.puSwaps;
483
+ if (puSwaps !== null) {
484
+ for (let i = 0; i < puSwaps.length; i++) {
485
+ const [hooks, slot, , next] = puSwaps[i];
486
+ hooks.set(slot, next);
487
+ }
488
+ PROMOTED_PU_SWAPS = PROMOTED_PU_SWAPS === null ? puSwaps : PROMOTED_PU_SWAPS.concat(puSwaps);
489
+ }
490
+ PROMOTED_WARM_HARVEST = held.warmHarvest;
491
+ const promoted = [];
492
+ TRANSITION_DEPTH++;
493
+ try {
494
+ for (let i = 0; i < held.entries.length; i++) {
495
+ const entry = held.entries[i];
496
+ if (!Object.is(entry.slot.value, entry.baseValue)) continue;
497
+ entry.slot.value = entry.value;
498
+ if (!entry.block.disposed) {
499
+ promoted.push(entry);
500
+ scheduleRender(entry.block);
501
+ }
502
+ }
503
+ } finally {
504
+ TRANSITION_DEPTH--;
505
+ }
506
+ if (promoted.length > 0) FLUSHED_TRANSITION_UPDATES.push(promoted);
507
+ return true;
508
+ }
509
+ function discardHeldSyncTransition(state) {
510
+ const held = HELD_SYNC_TRANSITION;
511
+ if (held === null || !held.holders.delete(state)) return;
512
+ if (held.holders.size === 0) {
513
+ HELD_SYNC_TRANSITION = null;
514
+ PROMOTED_PU_SWAPS = null;
515
+ PROMOTED_WARM_HARVEST = null;
516
+ }
517
+ }
518
+ const JOURNAL_TEXT = 0;
519
+ const JOURNAL_ATTR = 1;
520
+ const JOURNAL_BAG = 2;
521
+ const JOURNAL_PROP = 3;
522
+ const JOURNAL_FOR = 4;
523
+ let TRANSITION_JOURNAL = null;
524
+ let TRANSITION_JOURNAL_BAGS = null;
525
+ let TRANSITION_JOURNAL_DEPTH = 0;
526
+ function journalBag() {
527
+ const scope = CURRENT_SCOPE;
528
+ if (scope === null) return;
529
+ const bag = scope.slots[0];
530
+ if (bag === null || typeof bag !== "object" || bag.__kind !== void 0) return;
531
+ journalObjectOnce(bag);
532
+ }
533
+ function journalObjectOnce(obj) {
534
+ const seen = TRANSITION_JOURNAL_BAGS;
535
+ if (seen.has(obj)) return;
536
+ seen.add(obj);
537
+ const keys = Object.keys(obj);
538
+ const values = [];
539
+ for (let i = 0; i < keys.length; i++) values.push(obj[keys[i]]);
540
+ TRANSITION_JOURNAL.push(JOURNAL_BAG, obj, keys, values);
541
+ }
542
+ function journalControlled(el, prop, defaultProp) {
543
+ const log = TRANSITION_JOURNAL;
544
+ log.push(JOURNAL_PROP, el, prop, el[prop]);
545
+ log.push(JOURNAL_PROP, el, defaultProp, el[defaultProp]);
546
+ const ctrl = el.$$ctrl;
547
+ if (ctrl !== void 0) journalObjectOnce(ctrl);
548
+ const input = el;
549
+ if (prop === "checked" && input.type === "radio" && input.name !== "") journalRadioCousins(input);
550
+ journalBag();
551
+ }
552
+ function journalRadioCousins(input) {
553
+ const name = input.name;
554
+ const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
555
+ for (let i = 0; i < group.length; i++) {
556
+ const other = group[i];
557
+ if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
558
+ continue;
559
+ }
560
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, other, "checked", true);
561
+ }
562
+ }
563
+ function journalControlledOption(option, withDefault) {
564
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, option, "selected", option.selected);
565
+ if (withDefault)
566
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, option, "defaultSelected", option.defaultSelected);
567
+ }
568
+ let PARKED_ITEMS = null;
569
+ function parkItemForHold(block) {
570
+ const nodes = [];
571
+ const start = block.startMarker;
572
+ const end = block.endMarker;
573
+ if (start && end) {
574
+ const parent = start.parentNode;
575
+ if (parent !== null) {
576
+ const exclusive = block.exclusiveMarkers;
577
+ let n = exclusive ? start.nextSibling : start;
578
+ const stop = exclusive ? end : end.nextSibling;
579
+ while (n !== null && n !== stop) {
580
+ const next = getNextSibling(n);
581
+ parent.removeChild(n);
582
+ nodes.push(n);
583
+ n = next;
584
+ }
585
+ }
586
+ }
587
+ (PARKED_ITEMS ??= []).push({ block, nodes });
588
+ }
589
+ function itemRemovalDefers() {
590
+ return TRANSITION_JOURNAL !== null;
591
+ }
592
+ function forSlotParkable(state) {
593
+ return TRANSITION_JOURNAL !== null && TRANSITION_JOURNAL_BAGS.has(state);
594
+ }
595
+ function journalForSlot(state) {
596
+ const seen = TRANSITION_JOURNAL_BAGS;
597
+ if (seen.has(state)) return;
598
+ seen.add(state);
599
+ const chain = [];
600
+ for (let b = state.head; b !== null; b = b.nextSibling) {
601
+ chain.push([b, b.nextSibling, b.prevSibling]);
602
+ }
603
+ TRANSITION_JOURNAL.push(
604
+ JOURNAL_FOR,
605
+ state,
606
+ {
607
+ head: state.head,
608
+ tail: state.tail,
609
+ size: state.size,
610
+ empty: state.emptyBlock,
611
+ entries: [...state.items]
612
+ },
613
+ chain
614
+ );
615
+ }
616
+ function restoreForSlot(state, snapshot, chain) {
617
+ const kept = /* @__PURE__ */ new Set();
618
+ for (let i = 0; i < chain.length; i++) kept.add(chain[i][0]);
619
+ for (let b = state.head; b !== null; b = b.nextSibling) {
620
+ if (!kept.has(b)) unmountBlock(b, false);
621
+ }
622
+ if (state.end.parentNode === null) return;
623
+ state.head = snapshot.head;
624
+ state.tail = snapshot.tail;
625
+ state.size = snapshot.size;
626
+ state.items.clear();
627
+ for (let i = 0; i < snapshot.entries.length; i++) {
628
+ state.items.set(snapshot.entries[i][0], snapshot.entries[i][1]);
629
+ }
630
+ for (let i = 0; i < chain.length; i++) {
631
+ chain[i][0].nextSibling = chain[i][1];
632
+ chain[i][0].prevSibling = chain[i][2];
633
+ }
634
+ const parent = state.end.parentNode;
635
+ const ranges = [];
636
+ for (let b = state.head; b !== null; b = b.nextSibling) {
637
+ ranges.push(takeParkedItem(b) ?? collectBlockRange(b));
638
+ }
639
+ let n = state.start.nextSibling;
640
+ while (n !== null && n !== state.end) {
641
+ const next = n.nextSibling;
642
+ parent.removeChild(n);
643
+ n = next;
644
+ }
645
+ for (let i = 0; i < ranges.length; i++) {
646
+ const nodes = ranges[i];
647
+ for (let k = 0; k < nodes.length; k++) parent.insertBefore(nodes[k], state.end);
648
+ }
649
+ if (state.emptyBlock !== snapshot.empty) {
650
+ if (state.emptyBlock !== null) unmountBlock(state.emptyBlock, false);
651
+ state.emptyBlock = snapshot.empty;
652
+ }
653
+ if (snapshot.empty !== null && state.end.parentNode !== null) {
654
+ const parkedEmpty = takeParkedItem(snapshot.empty);
655
+ const nodes = parkedEmpty ?? collectBlockRange(snapshot.empty);
656
+ for (let k = 0; k < nodes.length; k++) parent.insertBefore(nodes[k], state.end);
657
+ }
658
+ }
659
+ function takeParkedItem(block) {
660
+ const parked = PARKED_ITEMS;
661
+ if (parked === null) return null;
662
+ for (let i = 0; i < parked.length; i++) {
663
+ if (parked[i].block === block) {
664
+ const nodes = parked[i].nodes;
665
+ parked.splice(i, 1);
666
+ return nodes;
667
+ }
668
+ }
669
+ return null;
670
+ }
671
+ function collectBlockRange(block) {
672
+ const nodes = [];
673
+ const start = block.startMarker;
674
+ const end = block.endMarker;
675
+ if (!start || !end || start.parentNode === null) return nodes;
676
+ const exclusive = block.exclusiveMarkers;
677
+ let n = exclusive ? start.nextSibling : start;
678
+ const stop = exclusive ? end : end.nextSibling;
679
+ while (n !== null && n !== stop) {
680
+ nodes.push(n);
681
+ n = getNextSibling(n);
682
+ }
683
+ return nodes;
684
+ }
685
+ function journalText(node) {
686
+ TRANSITION_JOURNAL.push(JOURNAL_TEXT, node, node.nodeValue, null);
687
+ journalBag();
688
+ }
689
+ function journalAttr(el, name) {
690
+ TRANSITION_JOURNAL.push(JOURNAL_ATTR, el, name, el.getAttribute(name));
691
+ journalBag();
692
+ }
693
+ function armTransitionJournal(state) {
694
+ if (!state.hasResolved || state.hiddenDom !== null || !(state.transitionHeld || (state.tryBlock?.pendingMode ?? CURRENT_BLOCK?.currentRenderMode) === "transition"))
695
+ return -1;
696
+ TRANSITION_JOURNAL ??= [];
697
+ TRANSITION_JOURNAL_BAGS ??= /* @__PURE__ */ new Set();
698
+ TRANSITION_JOURNAL_DEPTH++;
699
+ return TRANSITION_JOURNAL.length;
700
+ }
701
+ function disarmTransitionJournal(checkpoint) {
702
+ if (checkpoint < 0) return;
703
+ if (--TRANSITION_JOURNAL_DEPTH === 0) {
704
+ TRANSITION_JOURNAL = null;
705
+ TRANSITION_JOURNAL_BAGS = null;
706
+ flushParkedItems();
707
+ }
708
+ }
709
+ function flushParkedItems() {
710
+ const parked = PARKED_ITEMS;
711
+ if (parked === null) return;
712
+ PARKED_ITEMS = null;
713
+ for (let i = 0; i < parked.length; i++) unmountBlock(parked[i].block, false);
714
+ }
715
+ function rollbackTransitionJournal(checkpoint) {
716
+ if (checkpoint < 0) return;
717
+ const log = TRANSITION_JOURNAL;
718
+ if (log === null) return;
719
+ for (let i = log.length - 4; i >= checkpoint; i -= 4) {
720
+ const target = log[i + 1];
721
+ const a = log[i + 2];
722
+ const b = log[i + 3];
723
+ switch (log[i]) {
724
+ case JOURNAL_TEXT:
725
+ target.nodeValue = a;
726
+ break;
727
+ case JOURNAL_ATTR:
728
+ if (b === null) target.removeAttribute(a);
729
+ else target.setAttribute(a, b);
730
+ break;
731
+ case JOURNAL_PROP:
732
+ target[a] = b;
733
+ break;
734
+ case JOURNAL_FOR:
735
+ restoreForSlot(target, a, b);
736
+ TRANSITION_JOURNAL_BAGS.delete(target);
737
+ break;
738
+ default:
739
+ for (let k = 0; k < a.length; k++) target[a[k]] = b[k];
740
+ TRANSITION_JOURNAL_BAGS.delete(target);
741
+ }
742
+ }
743
+ log.length = checkpoint;
744
+ }
334
745
  class ViewTransitionPseudoElement {
335
746
  /** The pseudo-element selector, e.g. `::view-transition-new(hero)`. */
336
747
  selector;
@@ -780,7 +1191,12 @@ function drainQueue() {
780
1191
  block.drainStamp = drainId;
781
1192
  block.drainRenders = 1;
782
1193
  }
783
- renderBlock(block);
1194
+ const attempt = beginTransitionAttempt(block);
1195
+ try {
1196
+ renderBlock(block);
1197
+ } finally {
1198
+ endTransitionAttempt(attempt);
1199
+ }
784
1200
  } catch (err) {
785
1201
  try {
786
1202
  handleRenderError(block, err);
@@ -813,6 +1229,7 @@ function flush() {
813
1229
  }
814
1230
  function flushWork() {
815
1231
  inFlush = true;
1232
+ const clearRetainedTransitionUpdates = FLUSHED_TRANSITION_UPDATES.length > 0;
816
1233
  const viewTransitionDriver = VIEW_TRANSITION_DRIVER;
817
1234
  const clearViewTransitionTypes = viewTransitionDriver?.shouldClearTypesAfterFlush() === true;
818
1235
  try {
@@ -822,6 +1239,8 @@ function flushWork() {
822
1239
  if (pendingError !== null) throw pendingError.err;
823
1240
  } finally {
824
1241
  inFlush = false;
1242
+ if (clearRetainedTransitionUpdates || FLUSHED_TRANSITION_UPDATES.length > 0)
1243
+ FLUSHED_TRANSITION_UPDATES.length = 0;
825
1244
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
826
1245
  __devtoolsNotifyFlush();
827
1246
  if (clearViewTransitionTypes) viewTransitionDriver.clearTypes();
@@ -2539,16 +2958,19 @@ function useMemo(compute, deps, slot) {
2539
2958
  if (WARM_EVER && d !== void 0) {
2540
2959
  const adopted = adoptWarmValue(s, d);
2541
2960
  if (adopted !== WARM_MISS) {
2542
- ensureHooks(scope).set(s, {
2961
+ const adoptedEntry = {
2543
2962
  deps: d,
2544
2963
  value: adopted,
2545
2964
  warmEpisode: CURRENT_WARM_EPISODE
2546
- });
2965
+ };
2966
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalPuEntry(scope, s, adoptedEntry);
2967
+ ensureHooks(scope).set(s, adoptedEntry);
2547
2968
  return adopted;
2548
2969
  }
2549
2970
  }
2550
2971
  const value = compute.apply(null, d ?? []);
2551
2972
  const entry = { deps: d, value };
2973
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalPuEntry(scope, s, entry);
2552
2974
  ensureHooks(scope).set(s, entry);
2553
2975
  if (d !== void 0 && recordRealWarmMemo(s, d, entry)) {
2554
2976
  entry.warmEpisode = CURRENT_WARM_EPISODE;
@@ -3558,7 +3980,7 @@ const ErrorBoundary = /* @__PURE__ */ markComponentFlags(
3558
3980
  ) : props.fallback;
3559
3981
  childSlot(s, 1, s.block.parentNode, fb, s.block.endMarker);
3560
3982
  };
3561
- tryBlock(
3983
+ const reset = tryBlock(
3562
3984
  scope,
3563
3985
  0,
3564
3986
  block.parentNode,
@@ -3569,6 +3991,12 @@ const ErrorBoundary = /* @__PURE__ */ markComponentFlags(
3569
3991
  void 0,
3570
3992
  true
3571
3993
  );
3994
+ const previousResetRef = scope.slots[1];
3995
+ if (previousResetRef !== props.resetRef) {
3996
+ if (previousResetRef?.current === reset) previousResetRef.current = null;
3997
+ scope.slots[1] = props.resetRef;
3998
+ }
3999
+ if (props.resetRef) props.resetRef.current = reset;
3572
4000
  },
3573
4001
  COMPONENT_FLAG_BOUNDARY,
3574
4002
  "ErrorBoundary"
@@ -4099,6 +4527,16 @@ function adoptWarmValue(slot, deps) {
4099
4527
  }
4100
4528
  b = b.parentBlock;
4101
4529
  }
4530
+ const harvestList = HELD_SYNC_TRANSITION?.warmHarvest ?? PROMOTED_WARM_HARVEST;
4531
+ if (harvestList !== null && harvestList !== void 0) {
4532
+ for (let i = 0; i < harvestList.length; i++) {
4533
+ const entry = harvestList[i];
4534
+ if (!entry.taken && entry.slot === slot && !depsChanged(entry.deps, deps)) {
4535
+ entry.taken = true;
4536
+ return entry.value;
4537
+ }
4538
+ }
4539
+ }
4102
4540
  return WARM_MISS;
4103
4541
  }
4104
4542
  const puMiss = /* @__PURE__ */ Symbol("octane.pu.miss");
@@ -4111,11 +4549,13 @@ function puHit(slot, entry) {
4111
4549
  function puAdopt(slot, deps) {
4112
4550
  const adopted = adoptWarmValue(slot, deps);
4113
4551
  if (adopted === WARM_MISS) return puMiss;
4114
- ensureHooks(CURRENT_SCOPE).set(slot, {
4552
+ const adoptedEntry = {
4115
4553
  deps,
4116
4554
  value: adopted,
4117
4555
  warmEpisode: CURRENT_WARM_EPISODE
4118
- });
4556
+ };
4557
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalPuEntry(CURRENT_SCOPE, slot, adoptedEntry);
4558
+ ensureHooks(CURRENT_SCOPE).set(slot, adoptedEntry);
4119
4559
  return adopted;
4120
4560
  }
4121
4561
  function puTake0(slot) {
@@ -4170,6 +4610,7 @@ function puTake4(slot, d0, d1, d2, d3) {
4170
4610
  }
4171
4611
  function puPub(slot, value, ...deps) {
4172
4612
  const entry = { deps, value };
4613
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalPuEntry(CURRENT_SCOPE, slot, entry);
4173
4614
  ensureHooks(CURRENT_SCOPE).set(slot, entry);
4174
4615
  if (recordRealWarmMemo(slot, deps, entry)) entry.warmEpisode = CURRENT_WARM_EPISODE;
4175
4616
  return value;
@@ -5057,6 +5498,7 @@ function sibling(node, n = 1) {
5057
5498
  }
5058
5499
  function setText(node, value) {
5059
5500
  VIEW_TRANSITION_DRIVER?.markDirty();
5501
+ if (TRANSITION_JOURNAL !== null) journalText(node);
5060
5502
  node.nodeValue = coerceText(value);
5061
5503
  }
5062
5504
  function setScriptText(el, value) {
@@ -5713,6 +6155,7 @@ function setAttribute(el, name, value) {
5713
6155
  const hydration = activeHydration();
5714
6156
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
5715
6157
  const ns = attrNamespace(name);
6158
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
5716
6159
  if (next === null) {
5717
6160
  if (ns) {
5718
6161
  const colon = name.indexOf(":");
@@ -5755,6 +6198,7 @@ function setStringData(el, name, value) {
5755
6198
  }
5756
6199
  const hydration = activeHydration();
5757
6200
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
6201
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
5758
6202
  if (next === null) el.removeAttribute(name);
5759
6203
  else el.setAttribute(name, next);
5760
6204
  }
@@ -5763,6 +6207,7 @@ function setBooleanAttribute(el, name, value) {
5763
6207
  const next = !value || type === "function" || type === "symbol" ? null : "";
5764
6208
  const hydration = activeHydration();
5765
6209
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
6210
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
5766
6211
  if (next === null) el.removeAttribute(name);
5767
6212
  else el.setAttribute(name, next);
5768
6213
  }
@@ -5770,6 +6215,7 @@ function setAriaAttribute(el, name, value) {
5770
6215
  const next = value == null ? null : String(value);
5771
6216
  const hydration = activeHydration();
5772
6217
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
6218
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
5773
6219
  if (next === null) el.removeAttribute(name);
5774
6220
  else el.setAttribute(name, next);
5775
6221
  }
@@ -5852,6 +6298,7 @@ function setClassName(el, value) {
5852
6298
  hydration.queueClass(el, cls, true, false, value == null || value === false);
5853
6299
  return;
5854
6300
  }
6301
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, "class");
5855
6302
  if (value == null || value === false) el.removeAttribute("class");
5856
6303
  else el.className = cls;
5857
6304
  }
@@ -5862,6 +6309,7 @@ function setClassAttr(el, value) {
5862
6309
  hydration.queueClass(el, cls, false, true, cls === null);
5863
6310
  return;
5864
6311
  }
6312
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, "class");
5865
6313
  if (cls === null) el.removeAttribute("class");
5866
6314
  else el.setAttribute("class", cls);
5867
6315
  }
@@ -5877,6 +6325,7 @@ function setStyle(el, value, prev) {
5877
6325
  const style = el.style;
5878
6326
  const hydration = activeHydration();
5879
6327
  if (hydration !== null && hydration.applyStyle(el, value, prev)) return;
6328
+ if (TRANSITION_JOURNAL !== null) journalAttr(el, "style");
5880
6329
  applyStyleValue(style, value, prev);
5881
6330
  }
5882
6331
  function applyStyleValue(style, value, prev) {
@@ -6980,6 +7429,7 @@ function setNativeChangeDiagnosticMetadata(el, value) {
6980
7429
  function setValue(el, value) {
6981
7430
  const input = el;
6982
7431
  const ctrl = armControlled(el);
7432
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
6983
7433
  const first = !ctrl.sawV;
6984
7434
  ctrl.sawV = true;
6985
7435
  if (value == null) {
@@ -7047,14 +7497,22 @@ function inActivationWindow(input) {
7047
7497
  return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form;
7048
7498
  }
7049
7499
  function setChecked(el, value) {
7050
- setCheckedState(el, value, armControlled(el));
7500
+ const ctrl = armControlled(el);
7501
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "checked", "defaultChecked");
7502
+ setCheckedState(el, value, ctrl);
7051
7503
  }
7052
7504
  function setCheckedCheckable(el, value) {
7053
- setCheckedState(el, value, armControlledBase(el));
7505
+ const ctrl = armControlledBase(el);
7506
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "checked", "defaultChecked");
7507
+ setCheckedState(el, value, ctrl);
7054
7508
  }
7055
7509
  function setSelectValue(el, value) {
7056
7510
  const sel = el;
7057
7511
  const ctrl = armControlled(el);
7512
+ if (TRANSITION_JOURNAL !== null) {
7513
+ journalObjectOnce(ctrl);
7514
+ journalBag();
7515
+ }
7058
7516
  const first = !ctrl.sawV;
7059
7517
  ctrl.sawV = true;
7060
7518
  if (value == null) {
@@ -7101,6 +7559,11 @@ function setSelectValue(el, value) {
7101
7559
  }
7102
7560
  function projectSelectValue(sel, sv, setDefaultSelected) {
7103
7561
  const options = sel.options;
7562
+ if (TRANSITION_JOURNAL !== null) {
7563
+ for (let i = 0; i < options.length; i++) {
7564
+ journalControlledOption(options[i], setDefaultSelected);
7565
+ }
7566
+ }
7104
7567
  if (typeof sv !== "string") {
7105
7568
  for (let i = 0; i < options.length; i++) {
7106
7569
  const selected = sv.has(options[i].value);
@@ -8337,6 +8800,8 @@ function clearChildContent(state) {
8337
8800
  host.removeChild(n);
8338
8801
  n = next;
8339
8802
  }
8803
+ state.start = null;
8804
+ state.end = null;
8340
8805
  } else if (state.start !== null) {
8341
8806
  const parent = state.start.parentNode;
8342
8807
  if (parent !== null) {
@@ -9464,6 +9929,10 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
9464
9929
  if (preparedList !== null) {
9465
9930
  if (state.forSlot === null) {
9466
9931
  if (hydration === null && !upgradeArmed) clearChildContent(state);
9932
+ if (state.end !== null && state.end.parentNode === null) {
9933
+ state.end = null;
9934
+ state.start = null;
9935
+ }
9467
9936
  if (state.end === null) {
9468
9937
  state.end = document.createComment("");
9469
9938
  domParent.insertBefore(state.end, null);
@@ -10131,7 +10600,7 @@ function mountPassthroughCatch(state, error) {
10131
10600
  null,
10132
10601
  null,
10133
10602
  state.catchBody,
10134
- { err: error, reset: () => requestReset(state) },
10603
+ { err: error, reset: state.reset },
10135
10604
  state.env
10136
10605
  );
10137
10606
  state.block = block;
@@ -10166,7 +10635,7 @@ function mountPassthroughPending(state, thenable) {
10166
10635
  function renderPassthroughTry(state) {
10167
10636
  if (state.branch === 0 && state.block !== null) {
10168
10637
  state.block.body = state.catchBody;
10169
- state.block.props = { err: state.err, reset: () => requestReset(state) };
10638
+ state.block.props = { err: state.err, reset: state.reset };
10170
10639
  state.block.extra = state.env;
10171
10640
  renderBlock(state.block);
10172
10641
  return;
@@ -10247,7 +10716,8 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
10247
10716
  domParent.insertBefore(start, anchor ?? null);
10248
10717
  domParent.insertBefore(end, anchor ?? null);
10249
10718
  }
10250
- const newState = {
10719
+ let newState;
10720
+ newState = {
10251
10721
  __kind: "trySlotSlot",
10252
10722
  start,
10253
10723
  end,
@@ -10271,7 +10741,8 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
10271
10741
  domParent,
10272
10742
  parentBlock,
10273
10743
  idState: parentBlock.idState,
10274
- passthrough
10744
+ passthrough,
10745
+ reset: () => requestReset(newState)
10275
10746
  };
10276
10747
  parentScope.slots[slotKey] = newState;
10277
10748
  registerSlot(parentScope, newState);
@@ -10286,11 +10757,11 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
10286
10757
  const s = state;
10287
10758
  if (s.passthrough) {
10288
10759
  renderPassthroughTry(s);
10289
- return;
10760
+ return s.reset;
10290
10761
  }
10291
10762
  if (s.branch === 0) {
10292
10763
  s.block.body = s.catchBody;
10293
- s.block.props = { err: s.err, reset: () => requestReset(s) };
10764
+ s.block.props = { err: s.err, reset: s.reset };
10294
10765
  s.block.extra = s.env;
10295
10766
  renderBlock(s.block);
10296
10767
  } else if (s.branch === 2 && s.tryBlock && !s.tryBlock.disposed && s.hiddenDom) {
@@ -10301,20 +10772,26 @@ function tryBlock(parentScope, slotKey, domParent, tryBody, catchBody, pendingBo
10301
10772
  } else if (s.branch === 1 && s.tryBlock) {
10302
10773
  s.tryBlock.body = s.tryBody;
10303
10774
  s.tryBlock.extra = s.env;
10775
+ const journalCheckpoint = armTransitionJournal(s);
10304
10776
  try {
10305
10777
  renderBlock(s.tryBlock);
10306
- releaseHeldTransition(s);
10307
- s.pendingThenable = null;
10778
+ if (!heldSyncCellsIntact(s)) {
10779
+ releaseHeldTransition(s);
10780
+ s.pendingThenable = null;
10781
+ }
10308
10782
  } catch (err) {
10309
10783
  if (isHostContextRequest(err)) throw err;
10310
10784
  if (isSuspenseException(err)) {
10311
10785
  if (s.propagateSuspense) throw err;
10312
- handleSuspense(s, err.thenable, s.tryBlock);
10786
+ handleSuspense(s, err.thenable, s.tryBlock, journalCheckpoint);
10313
10787
  } else switchToCatch(s, err);
10788
+ } finally {
10789
+ disarmTransitionJournal(journalCheckpoint);
10314
10790
  }
10315
10791
  } else {
10316
10792
  mountTry(s);
10317
10793
  }
10794
+ return s.reset;
10318
10795
  }
10319
10796
  function mountTry(state) {
10320
10797
  const hydration = activeHydration();
@@ -10527,6 +11004,7 @@ function showTryBlock(state) {
10527
11004
  }
10528
11005
  }
10529
11006
  function releaseHeldTransition(state) {
11007
+ discardHeldSyncTransition(state);
10530
11008
  if (state.transitionHeld) {
10531
11009
  state.transitionHeld = false;
10532
11010
  tickTransitionCount(-1);
@@ -10537,9 +11015,13 @@ function releaseHeldTransition(state) {
10537
11015
  state.transitionTimeoutId = null;
10538
11016
  }
10539
11017
  }
10540
- function handleSuspense(state, thenable, sourceBlock) {
11018
+ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
10541
11019
  const isTransition = sourceBlock.currentRenderMode === "transition";
10542
11020
  if ((isTransition || state.transitionHeld) && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
11021
+ rollbackTransitionJournal(journalCheckpoint);
11022
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) {
11023
+ (ACTIVE_TRANSITION_ATTEMPT.heldSlots ??= /* @__PURE__ */ new Set()).add(state);
11024
+ }
10543
11025
  if (!state.transitionHeld) {
10544
11026
  state.transitionHeld = true;
10545
11027
  tickTransitionCount(1);
@@ -10656,6 +11138,9 @@ function refreshPendingBody(state) {
10656
11138
  }
10657
11139
  function swapToPendingFallback(state) {
10658
11140
  if (!state.pendingBody || state.branch !== 1 || !state.tryBlock) return;
11141
+ if (HELD_SYNC_TRANSITION !== null && HELD_SYNC_TRANSITION.holders.has(state)) {
11142
+ promoteHeldSyncTransition();
11143
+ }
10659
11144
  hideTryContentAndMountPending(state);
10660
11145
  }
10661
11146
  function commitResume(state) {
@@ -10700,6 +11185,7 @@ function commitResumeInner(state) {
10700
11185
  spliceOffscreenCapture(stagedCapture);
10701
11186
  state.hasResolved = true;
10702
11187
  } else {
11188
+ const journalCheckpoint = armTransitionJournal(state);
10703
11189
  const resumeCapture = createOffscreenCapture();
10704
11190
  const effectDeps = snapshotSubtreeEffectDeps(tryBlock2);
10705
11191
  const previousCapture = WIP_CAPTURE;
@@ -10721,6 +11207,7 @@ function commitResumeInner(state) {
10721
11207
  } finally {
10722
11208
  WIP_CAPTURE = previousCapture;
10723
11209
  RESUME_REPLAY = prevReplay;
11210
+ if (!didThrow) disarmTransitionJournal(journalCheckpoint);
10724
11211
  }
10725
11212
  if (!didThrow) {
10726
11213
  if (state.detachedRefs !== null) {
@@ -10730,13 +11217,17 @@ function commitResumeInner(state) {
10730
11217
  spliceOffscreenCapture(resumeCapture);
10731
11218
  state.hasResolved = true;
10732
11219
  } else {
10733
- refDetachQueue.splice(refDetachCheckpoint);
10734
- restoreSubtreeEffectDeps(tryBlock2, effectDeps);
10735
- discardOffscreenCapture(resumeCapture);
10736
- if (isSuspenseException(renderError)) {
10737
- handleSuspense(state, renderError.thenable, tryBlock2);
10738
- } else {
10739
- switchToCatch(state, renderError);
11220
+ try {
11221
+ refDetachQueue.splice(refDetachCheckpoint);
11222
+ restoreSubtreeEffectDeps(tryBlock2, effectDeps);
11223
+ discardOffscreenCapture(resumeCapture);
11224
+ if (isSuspenseException(renderError)) {
11225
+ handleSuspense(state, renderError.thenable, tryBlock2, journalCheckpoint);
11226
+ } else {
11227
+ switchToCatch(state, renderError);
11228
+ }
11229
+ } finally {
11230
+ disarmTransitionJournal(journalCheckpoint);
10740
11231
  }
10741
11232
  if (state.parentBlock.disposed) return;
10742
11233
  }
@@ -11005,6 +11496,20 @@ function rebaseOffscreenCaptureSeq(capture) {
11005
11496
  }
11006
11497
  function flushStagedReveals() {
11007
11498
  if (flushingStagedReveals) return;
11499
+ if (HELD_SYNC_TRANSITION !== null) {
11500
+ let allVisible = true;
11501
+ for (const holder of HELD_SYNC_TRANSITION.holders) {
11502
+ if (holder.hiddenDom !== null) {
11503
+ allVisible = false;
11504
+ break;
11505
+ }
11506
+ }
11507
+ if (allVisible && promoteHeldSyncTransition()) {
11508
+ STAGED_REVEALS.clear();
11509
+ flush();
11510
+ return;
11511
+ }
11512
+ }
11008
11513
  flushingStagedReveals = true;
11009
11514
  try {
11010
11515
  const run = () => {
@@ -11407,6 +11912,7 @@ function useDeferredValue(value, ...rest) {
11407
11912
  return s.current;
11408
11913
  }
11409
11914
  function requestReset(state) {
11915
+ if (state.parentBlock.disposed || state.branch !== 0) return;
11410
11916
  setTryBranch(state, -1);
11411
11917
  state.err = null;
11412
11918
  state.hasResolved = false;
@@ -11699,10 +12205,31 @@ function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, ma
11699
12205
  let bStart;
11700
12206
  let bEnd;
11701
12207
  let borrowed = false;
12208
+ let rebuild = false;
12209
+ let inner = null;
12210
+ let innerEnd = null;
11702
12211
  if (hydration !== null && hydration.isOpen(state.start.nextSibling)) {
11703
- bStart = state.start.nextSibling;
11704
- bEnd = hydration.close(bStart);
11705
- hydration.node = bStart.nextSibling;
12212
+ inner = state.start.nextSibling;
12213
+ innerEnd = hydration.close(inner);
12214
+ if (innerEnd !== state.end && innerEnd.nextSibling !== state.end) {
12215
+ if (process.env.NODE_ENV !== "production") {
12216
+ const mmLoc = siteLoc(parentScope, slotKey);
12217
+ if (mmLoc)
12218
+ hydration.warnStructural(
12219
+ mmLoc,
12220
+ "a single branch range",
12221
+ hydration.describe(innerEnd.nextSibling)
12222
+ );
12223
+ }
12224
+ removeRange(state.start.nextSibling, state.end);
12225
+ inner = null;
12226
+ rebuild = true;
12227
+ }
12228
+ }
12229
+ if (inner !== null) {
12230
+ bStart = inner;
12231
+ bEnd = innerEnd;
12232
+ hydration.node = inner.nextSibling;
11706
12233
  } else {
11707
12234
  bStart = state.start;
11708
12235
  bEnd = state.end;
@@ -11721,7 +12248,12 @@ function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, ma
11721
12248
  );
11722
12249
  if (borrowed) b.exclusiveMarkers = true;
11723
12250
  state.block = b;
11724
- renderBlock(b);
12251
+ if (rebuild) {
12252
+ hydration.suspend(() => renderBlock(b));
12253
+ hydration.node = state.end.nextSibling;
12254
+ } else {
12255
+ renderBlock(b);
12256
+ }
11725
12257
  } else if (hydration !== null && state.start.nextSibling !== state.end) {
11726
12258
  if (process.env.NODE_ENV !== "production") {
11727
12259
  const mmLoc = siteLoc(parentScope, slotKey);
@@ -12059,7 +12591,9 @@ function deactivateScope(scope, disconnectPassive = true) {
12059
12591
  for (const slot of hooks.values()) {
12060
12592
  if (slot && slot.effect === true) {
12061
12593
  const e = slot;
12062
- if (e.phase === INSERTION || !disconnectPassive && e.phase === PASSIVE) continue;
12594
+ if (e.phase === INSERTION || !disconnectPassive && e.phase === PASSIVE && e.connectedFn !== null) {
12595
+ continue;
12596
+ }
12063
12597
  if (typeof e.cleanup === "function") {
12064
12598
  const cleanup = e.cleanup;
12065
12599
  e.cleanup = void 0;
@@ -12200,7 +12734,10 @@ function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flag
12200
12734
  return;
12201
12735
  }
12202
12736
  if (state.emptyBlock) {
12203
- unmountBlock(state.emptyBlock);
12737
+ if (itemRemovalDefers()) {
12738
+ journalForSlot(state);
12739
+ parkItemForHold(state.emptyBlock);
12740
+ } else unmountBlock(state.emptyBlock);
12204
12741
  state.emptyBlock = null;
12205
12742
  }
12206
12743
  if (!isEmpty && hydration !== null && (serverMarkerState === 0 || serverMarkerState === -1 && ((flags || 0) & 16) === 0 && state.start.nextSibling !== null && state.start.nextSibling !== state.end && !hydration.isOpen(state.start.nextSibling))) {
@@ -12293,6 +12830,7 @@ function updateSurvivor(block, newItem, newIdx, itemBody, pure, lite, indexIndep
12293
12830
  function mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless) {
12294
12831
  const newLen = items.length;
12295
12832
  if (newLen === 0) return;
12833
+ if (TRANSITION_JOURNAL !== null) journalForSlot(state);
12296
12834
  const oldItems = state.items;
12297
12835
  const parentNode = state.end.parentNode;
12298
12836
  const adopt = state.adopt;
@@ -12348,6 +12886,7 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
12348
12886
  const oldSize = state.size;
12349
12887
  const newLen = items.length;
12350
12888
  const parentNode = state.end.parentNode;
12889
+ if (oldSize > 0 && TRANSITION_JOURNAL !== null) journalForSlot(state);
12351
12890
  if (oldSize === 0) {
12352
12891
  mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless);
12353
12892
  return;
@@ -12435,7 +12974,8 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
12435
12974
  let removed = 0;
12436
12975
  while (cur2 !== afterMiddle) {
12437
12976
  const next = cur2.nextSibling;
12438
- unmountBlock(cur2);
12977
+ if (itemRemovalDefers()) parkItemForHold(cur2);
12978
+ else unmountBlock(cur2);
12439
12979
  oldItems.delete(cur2.key);
12440
12980
  cur2 = next;
12441
12981
  removed++;
@@ -12509,7 +13049,8 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
12509
13049
  const next = cur.nextSibling;
12510
13050
  const newRelIdx = newKeysToIdx.get(cur.key);
12511
13051
  if (newRelIdx === void 0) {
12512
- unmountBlock(cur);
13052
+ if (itemRemovalDefers()) parkItemForHold(cur);
13053
+ else unmountBlock(cur);
12513
13054
  oldItems.delete(cur.key);
12514
13055
  state.size--;
12515
13056
  } else {
@@ -12669,6 +13210,15 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
12669
13210
  }
12670
13211
  const RANGE_CLEAR_MIN_ITEMS = 512;
12671
13212
  function batchClearItems(state, oldItems) {
13213
+ if (forSlotParkable(state)) {
13214
+ let next;
13215
+ for (let b = state.head; b !== null; b = next) {
13216
+ next = b.nextSibling;
13217
+ parkItemForHold(b);
13218
+ }
13219
+ oldItems.clear();
13220
+ return;
13221
+ }
12672
13222
  const p = state.start.parentNode;
12673
13223
  if (state.start.previousSibling === null && state.end.nextSibling === null) {
12674
13224
  p.textContent = "";