octane 0.1.26 → 0.1.27

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.
Files changed (2) hide show
  1. package/dist/runtime.js +138 -52
  2. package/package.json +1 -1
package/dist/runtime.js CHANGED
@@ -1184,12 +1184,18 @@ function drainQueue() {
1184
1184
  }
1185
1185
  const crossRenderUpdate = block.crossRenderUpdate;
1186
1186
  block.crossRenderUpdate = false;
1187
+ const hiddenOwner = findHiddenRenderOwner(block, true);
1188
+ let hiddenActivity = null;
1189
+ let hiddenTry = null;
1190
+ if (hiddenOwner !== null) {
1191
+ if (hiddenOwner.__kind === "trySlotSlot") hiddenTry = hiddenOwner;
1192
+ else hiddenActivity = hiddenOwner;
1193
+ }
1187
1194
  try {
1188
1195
  if (block.nestedUpdateError) {
1189
1196
  block.nestedUpdateError = false;
1190
1197
  throw maximumUpdateDepthError();
1191
1198
  }
1192
- const hiddenTry = findSuspenseHiddenTry(block);
1193
1199
  if (hiddenTry !== null) {
1194
1200
  attemptHiddenReveal(hiddenTry, block.pendingMode ?? "urgent");
1195
1201
  continue;
@@ -1221,6 +1227,8 @@ function drainQueue() {
1221
1227
  while (root.parentBlock !== null) root = root.parentBlock;
1222
1228
  if (root.kind === "root" && !root.disposed) unmountBlock(root);
1223
1229
  }
1230
+ } finally {
1231
+ if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
1224
1232
  }
1225
1233
  }
1226
1234
  QUEUE.length = 0;
@@ -10700,8 +10708,63 @@ function setTransitionFallbackTimeout(ms) {
10700
10708
  function getTransitionFallbackTimeout() {
10701
10709
  return TRANSITION_FALLBACK_TIMEOUT_MS;
10702
10710
  }
10703
- const SUSPENSE_HIDDEN_DISPLAYS = /* @__PURE__ */ new WeakMap();
10704
- const SUSPENSE_HIDDEN_TEXTS = /* @__PURE__ */ new WeakMap();
10711
+ const HIDDEN_DISPLAYS = /* @__PURE__ */ new WeakMap();
10712
+ const HIDDEN_TEXTS = /* @__PURE__ */ new WeakMap();
10713
+ function enforceHiddenDisplay(el) {
10714
+ const hidden = HIDDEN_DISPLAYS.get(el);
10715
+ el.style.setProperty(
10716
+ "display",
10717
+ "none",
10718
+ hidden !== void 0 && hidden.importantOwners > 0 ? "important" : ""
10719
+ );
10720
+ }
10721
+ function retainHiddenDisplay(el, important) {
10722
+ const existing = HIDDEN_DISPLAYS.get(el);
10723
+ if (existing === void 0) {
10724
+ HIDDEN_DISPLAYS.set(el, {
10725
+ owners: 1,
10726
+ importantOwners: important ? 1 : 0,
10727
+ value: el.style.getPropertyValue("display"),
10728
+ priority: el.style.getPropertyPriority("display"),
10729
+ hadStyle: el.hasAttribute("style")
10730
+ });
10731
+ } else {
10732
+ existing.owners++;
10733
+ if (important) existing.importantOwners++;
10734
+ }
10735
+ enforceHiddenDisplay(el);
10736
+ }
10737
+ function releaseHiddenDisplay(el, important) {
10738
+ const display = HIDDEN_DISPLAYS.get(el);
10739
+ if (display === void 0) return;
10740
+ if (important) display.importantOwners--;
10741
+ if (--display.owners === 0) {
10742
+ HIDDEN_DISPLAYS.delete(el);
10743
+ if (display.value === "") el.style.removeProperty("display");
10744
+ else el.style.setProperty("display", display.value, display.priority);
10745
+ if (!display.hadStyle && el.getAttribute("style") === "") el.removeAttribute("style");
10746
+ } else {
10747
+ enforceHiddenDisplay(el);
10748
+ }
10749
+ }
10750
+ function enforceHiddenText(text) {
10751
+ if (text.data !== "") text.data = "";
10752
+ }
10753
+ function retainHiddenText(text) {
10754
+ const existing = HIDDEN_TEXTS.get(text);
10755
+ if (existing === void 0) HIDDEN_TEXTS.set(text, { owners: 1, data: text.data });
10756
+ else existing.owners++;
10757
+ }
10758
+ function releaseHiddenText(text) {
10759
+ const saved = HIDDEN_TEXTS.get(text);
10760
+ if (saved === void 0) return;
10761
+ if (--saved.owners === 0) {
10762
+ HIDDEN_TEXTS.delete(text);
10763
+ text.data = saved.data;
10764
+ } else {
10765
+ enforceHiddenText(text);
10766
+ }
10767
+ }
10705
10768
  function setTryBranch(slot, next) {
10706
10769
  slot.branch = next;
10707
10770
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
@@ -11063,31 +11126,17 @@ function hideBlockHostRange(block, hidden) {
11063
11126
  const el = node;
11064
11127
  if (!hidden.displays.has(el)) {
11065
11128
  hidden.displays.add(el);
11066
- const existing = SUSPENSE_HIDDEN_DISPLAYS.get(el);
11067
- if (existing === void 0) {
11068
- SUSPENSE_HIDDEN_DISPLAYS.set(el, {
11069
- owners: 1,
11070
- value: el.style.getPropertyValue("display"),
11071
- priority: el.style.getPropertyPriority("display"),
11072
- hadStyle: el.hasAttribute("style")
11073
- });
11074
- } else {
11075
- existing.owners++;
11076
- }
11129
+ retainHiddenDisplay(el, true);
11130
+ } else {
11131
+ enforceHiddenDisplay(el);
11077
11132
  }
11078
- el.style.setProperty("display", "none", "important");
11079
11133
  } else if (node.nodeType === 3) {
11080
11134
  const text = node;
11081
11135
  if (!hidden.texts.has(text)) {
11082
11136
  hidden.texts.add(text);
11083
- const existing = SUSPENSE_HIDDEN_TEXTS.get(text);
11084
- if (existing === void 0) {
11085
- SUSPENSE_HIDDEN_TEXTS.set(text, { owners: 1, data: text.data });
11086
- } else {
11087
- existing.owners++;
11088
- }
11137
+ retainHiddenText(text);
11089
11138
  }
11090
- if (text.data !== "") text.data = "";
11139
+ enforceHiddenText(text);
11091
11140
  }
11092
11141
  node = node.nextSibling;
11093
11142
  }
@@ -11115,26 +11164,10 @@ function showTryBlock(state) {
11115
11164
  if (hidden === null) return;
11116
11165
  state.hiddenDom = null;
11117
11166
  for (const el of hidden.displays) {
11118
- const display = SUSPENSE_HIDDEN_DISPLAYS.get(el);
11119
- if (display === void 0) continue;
11120
- if (--display.owners === 0) {
11121
- SUSPENSE_HIDDEN_DISPLAYS.delete(el);
11122
- if (display.value === "") el.style.removeProperty("display");
11123
- else el.style.setProperty("display", display.value, display.priority);
11124
- if (!display.hadStyle && el.getAttribute("style") === "") el.removeAttribute("style");
11125
- } else {
11126
- el.style.setProperty("display", "none", "important");
11127
- }
11167
+ releaseHiddenDisplay(el, true);
11128
11168
  }
11129
11169
  for (const text of hidden.texts) {
11130
- const saved = SUSPENSE_HIDDEN_TEXTS.get(text);
11131
- if (saved === void 0) continue;
11132
- if (--saved.owners === 0) {
11133
- SUSPENSE_HIDDEN_TEXTS.delete(text);
11134
- text.data = saved.data;
11135
- } else if (text.data !== "") {
11136
- text.data = "";
11137
- }
11170
+ releaseHiddenText(text);
11138
11171
  }
11139
11172
  }
11140
11173
  function releaseHeldTransition(state) {
@@ -11286,6 +11319,7 @@ function commitResume(state) {
11286
11319
  }
11287
11320
  function commitResumeInner(state) {
11288
11321
  if (state.parentBlock.disposed) return;
11322
+ const hiddenActivity = findHiddenActivity(state.parentBlock);
11289
11323
  const wasHeld = state.transitionHeld;
11290
11324
  if (wasHeld) state.transitionHeld = false;
11291
11325
  HELD_TRANSITIONS.delete(state);
@@ -11377,14 +11411,33 @@ function commitResumeInner(state) {
11377
11411
  }
11378
11412
  if (!deferringStagedRevealEffects) commitEffects();
11379
11413
  } finally {
11414
+ if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
11380
11415
  if (wasHeld) tickTransitionCount(-1);
11381
11416
  }
11382
11417
  }
11383
- function findSuspenseHiddenTry(block) {
11418
+ function findHiddenRenderOwner(block, includeActivity) {
11419
+ let activity = null;
11384
11420
  for (let p = block; p !== null; p = p.parentBlock) {
11421
+ if (includeActivity && activity === null && p.inactive) {
11422
+ const candidate = p.__activitySlot;
11423
+ if (candidate !== void 0 && candidate.block === p && candidate.hidden) {
11424
+ activity = candidate;
11425
+ }
11426
+ }
11385
11427
  const slot = p.__trySlot;
11386
11428
  if (slot !== void 0 && slot.tryBlock === p && slot.hiddenDom !== null) return slot;
11387
11429
  }
11430
+ return activity;
11431
+ }
11432
+ function findSuspenseHiddenTry(block) {
11433
+ return findHiddenRenderOwner(block, false);
11434
+ }
11435
+ function findHiddenActivity(block) {
11436
+ for (let p = block; p !== null; p = p.parentBlock) {
11437
+ if (!p.inactive) continue;
11438
+ const candidate = p.__activitySlot;
11439
+ if (candidate !== void 0 && candidate.block === p && candidate.hidden) return candidate;
11440
+ }
11388
11441
  return null;
11389
11442
  }
11390
11443
  function snapshotSubtreeEffectDeps(scope) {
@@ -11500,11 +11553,19 @@ function queueCurrentHiddenRefs(state) {
11500
11553
  }
11501
11554
  }
11502
11555
  function attemptHiddenReveal(state, scheduledMode) {
11556
+ const hiddenActivity = findHiddenActivity(state.tryBlock);
11557
+ try {
11558
+ attemptHiddenRevealInner(state, scheduledMode);
11559
+ } finally {
11560
+ if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
11561
+ }
11562
+ }
11563
+ function attemptHiddenRevealInner(state, scheduledMode) {
11503
11564
  const tryBlock2 = state.tryBlock;
11504
11565
  if (tryBlock2 === null || tryBlock2.disposed || state.hiddenDom === null) return;
11505
11566
  const hiddenAncestor = findSuspenseHiddenTry(tryBlock2.parentBlock);
11506
11567
  if (hiddenAncestor !== null) {
11507
- attemptHiddenReveal(hiddenAncestor, scheduledMode);
11568
+ attemptHiddenRevealInner(hiddenAncestor, scheduledMode);
11508
11569
  return;
11509
11570
  }
11510
11571
  STAGED_REVEALS.delete(state);
@@ -12492,25 +12553,49 @@ function ifBlock(parentScope, slotKey, domParent, cond, thenBody, elseBody, anch
12492
12553
  function hideActivityRange(state) {
12493
12554
  const b = state.block;
12494
12555
  if (!b) return;
12556
+ for (const el of state.hiddenDisplays) {
12557
+ if (el.parentNode !== b.parentNode) {
12558
+ state.hiddenDisplays.delete(el);
12559
+ releaseHiddenDisplay(el, false);
12560
+ }
12561
+ }
12562
+ for (const text of state.hiddenTexts) {
12563
+ if (text.parentNode !== b.parentNode) {
12564
+ state.hiddenTexts.delete(text);
12565
+ releaseHiddenText(text);
12566
+ }
12567
+ }
12495
12568
  let node = b.startMarker.nextSibling;
12496
12569
  while (node && node !== b.endMarker) {
12497
12570
  if (node.nodeType === 1) {
12498
12571
  const el = node;
12499
- if (!state.savedDisplay.has(el)) state.savedDisplay.set(el, el.style.display);
12500
- el.style.display = "none";
12572
+ if (!state.hiddenDisplays.has(el)) {
12573
+ state.hiddenDisplays.add(el);
12574
+ retainHiddenDisplay(el, false);
12575
+ } else {
12576
+ enforceHiddenDisplay(el);
12577
+ }
12501
12578
  } else if (node.nodeType === 3) {
12502
12579
  const t = node;
12503
- if (!state.savedText.has(t)) state.savedText.set(t, t.nodeValue ?? "");
12504
- if (t.nodeValue !== "") t.nodeValue = "";
12580
+ if (!state.hiddenTexts.has(t)) {
12581
+ state.hiddenTexts.add(t);
12582
+ retainHiddenText(t);
12583
+ }
12584
+ enforceHiddenText(t);
12505
12585
  }
12506
12586
  node = node.nextSibling;
12507
12587
  }
12508
12588
  }
12589
+ function rehideActivityAfterDescendantRender(state) {
12590
+ const b = state.block;
12591
+ if (b === null || !state.hidden || state.deactivationPending || blockSubtreeDisposed(b)) return;
12592
+ hideActivityRange(state);
12593
+ }
12509
12594
  function showActivityRange(state) {
12510
- for (const [el, display] of state.savedDisplay) el.style.display = display;
12511
- state.savedDisplay.clear();
12512
- for (const [t, data] of state.savedText) t.nodeValue = data;
12513
- state.savedText.clear();
12595
+ for (const el of state.hiddenDisplays) releaseHiddenDisplay(el, false);
12596
+ state.hiddenDisplays.clear();
12597
+ for (const text of state.hiddenTexts) releaseHiddenText(text);
12598
+ state.hiddenTexts.clear();
12514
12599
  }
12515
12600
  function queueActivityDeactivation(state, block, commitVersion) {
12516
12601
  enqueueEffectEventCommitAction(() => {
@@ -12560,9 +12645,10 @@ function activityBlock(parentScope, slotKey, domParent, mode, body, anchor, env)
12560
12645
  hidden: false,
12561
12646
  commitVersion: 0,
12562
12647
  deactivationPending: false,
12563
- savedDisplay: /* @__PURE__ */ new Map(),
12564
- savedText: /* @__PURE__ */ new Map()
12648
+ hiddenDisplays: /* @__PURE__ */ new Set(),
12649
+ hiddenTexts: /* @__PURE__ */ new Set()
12565
12650
  };
12651
+ b2.__activitySlot = state;
12566
12652
  parentScope.slots[slotKey] = state;
12567
12653
  registerSlot(parentScope, state);
12568
12654
  const adopted = open !== null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octane",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,