octane 0.1.40 → 0.1.42
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/README.md +7 -0
- package/dist/cjs/runtime.cjs +287 -94
- package/dist/cjs/runtime.server.cjs +9 -6
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/bundler.js +21 -2
- package/dist/compiler/compile-universal.js +1 -1
- package/dist/compiler/compile.js +895 -306
- package/dist/compiler/hook-deps.js +7 -3
- package/dist/compiler/index.d.ts +182 -0
- package/dist/compiler/inline-hook-memo.js +654 -0
- package/dist/compiler/plain-hook-memo.js +274 -0
- package/dist/compiler/slot-hooks.js +37 -9
- package/dist/compiler/text-type-facts.js +89 -0
- package/dist/compiler/typescript.d.ts +48 -0
- package/dist/compiler/typescript.js +614 -0
- package/dist/runtime.d.ts +31 -2
- package/dist/runtime.js +270 -94
- package/dist/runtime.server.js +9 -6
- package/dist/universal-core.js +100 -18
- package/dist/version.js +1 -1
- package/package.json +16 -2
package/README.md
CHANGED
|
@@ -17,6 +17,10 @@ wrapper is narrower: the wrapper must be locally declared in a fully compiled
|
|
|
17
17
|
parameter to a supported hook. This package ships both the runtime and compiler,
|
|
18
18
|
with the compiler exposed at `octane/compiler`.
|
|
19
19
|
|
|
20
|
+
Custom Node build pipelines can opt into project-aware string-child inference
|
|
21
|
+
through `octane/compiler/typescript`. See the
|
|
22
|
+
[type-aware text compilation guide](https://github.com/octanejs/octane/blob/main/docs/compiler-text-inference.md).
|
|
23
|
+
|
|
20
24
|
Direct Node or Bun server scripts can preload `octane/compiler/register` to
|
|
21
25
|
compile imported Octane components without going through Vite. See the
|
|
22
26
|
[SSR guide](https://github.com/octanejs/octane/blob/main/docs/ssr.md#run-an-ssg-script-directly).
|
|
@@ -32,6 +36,9 @@ For the full story, see the
|
|
|
32
36
|
|
|
33
37
|
## Browser compatibility
|
|
34
38
|
|
|
39
|
+
See the [browser support guide](https://octanejs.dev/docs/browser-support) for
|
|
40
|
+
recommended targets, required browser APIs, and optional fallbacks.
|
|
41
|
+
|
|
35
42
|
Configure your application's build target for the browser engines you support.
|
|
36
43
|
The Rsbuild integration's `modules` target includes Chromium 87 and Samsung
|
|
37
44
|
Internet 14; Samsung Internet can also be selected directly with targets such as
|
package/dist/cjs/runtime.cjs
CHANGED
|
@@ -104,6 +104,15 @@ __export(runtime_exports, {
|
|
|
104
104
|
hasPendingWork: () => hasPendingWork,
|
|
105
105
|
headBlock: () => headBlock,
|
|
106
106
|
hmr: () => hmr,
|
|
107
|
+
hookMemoCreate: () => hookMemoCreate,
|
|
108
|
+
hookMemoEqual: () => hookMemoEqual,
|
|
109
|
+
hookMemoPublish: () => hookMemoPublish,
|
|
110
|
+
hookMemoPublish0: () => hookMemoPublish0,
|
|
111
|
+
hookMemoPublish1: () => hookMemoPublish1,
|
|
112
|
+
hookMemoPublish2: () => hookMemoPublish2,
|
|
113
|
+
hookMemoPublish3: () => hookMemoPublish3,
|
|
114
|
+
hookMemoPublish4: () => hookMemoPublish4,
|
|
115
|
+
hookMemoPublishInvariant: () => hookMemoPublishInvariant,
|
|
107
116
|
hookSlots: () => hookSlots,
|
|
108
117
|
hostComponent: () => hostComponent,
|
|
109
118
|
htext: () => htext,
|
|
@@ -121,6 +130,14 @@ __export(runtime_exports, {
|
|
|
121
130
|
markNativeChangeDiagnosticStatic: () => markNativeChangeDiagnosticStatic,
|
|
122
131
|
markSingleRoot: () => markSingleRoot,
|
|
123
132
|
memo: () => memo,
|
|
133
|
+
memoPublish: () => memoPublish,
|
|
134
|
+
memoPublishAlways: () => memoPublishAlways,
|
|
135
|
+
memoSlot: () => memoSlot,
|
|
136
|
+
memoTake0: () => memoTake0,
|
|
137
|
+
memoTake1: () => memoTake1,
|
|
138
|
+
memoTake2: () => memoTake2,
|
|
139
|
+
memoTake3: () => memoTake3,
|
|
140
|
+
memoTake4: () => memoTake4,
|
|
124
141
|
mountFragmentRef: () => mountFragmentRef,
|
|
125
142
|
namespaceHead: () => namespaceHead,
|
|
126
143
|
namespaceHeadElement: () => namespaceHeadElement,
|
|
@@ -458,18 +475,19 @@ function stagedTransitionValue(slot) {
|
|
|
458
475
|
function stageTransitionValue(slot, block, operation, value, forceRender = false) {
|
|
459
476
|
const batch = transitionActionBatchForUpdate();
|
|
460
477
|
if (batch === null) return false;
|
|
478
|
+
const replay = typeof operation === "function" ? operation : () => operation;
|
|
461
479
|
const current = batch.updates.get(slot);
|
|
462
480
|
if (current === void 0) {
|
|
463
481
|
batch.updates.set(slot, {
|
|
464
482
|
slot,
|
|
465
483
|
block,
|
|
466
|
-
operations: [
|
|
484
|
+
operations: [replay],
|
|
467
485
|
baseValue: slot.value,
|
|
468
486
|
value,
|
|
469
487
|
forceRender
|
|
470
488
|
});
|
|
471
489
|
} else {
|
|
472
|
-
current.operations.push(
|
|
490
|
+
current.operations.push(replay);
|
|
473
491
|
current.value = value;
|
|
474
492
|
current.forceRender ||= forceRender;
|
|
475
493
|
}
|
|
@@ -525,7 +543,7 @@ let deferringStagedRevealEffects = false;
|
|
|
525
543
|
let ACTIVE_TRANSITION_ATTEMPT = null;
|
|
526
544
|
let FLUSHED_TRANSITION_UPDATES = [];
|
|
527
545
|
let HELD_SYNC_TRANSITION = null;
|
|
528
|
-
let
|
|
546
|
+
let PROMOTED_MEMO_SWAPS = null;
|
|
529
547
|
let PROMOTED_WARM_HARVEST = null;
|
|
530
548
|
function beginTransitionAttempt(block) {
|
|
531
549
|
if (block.pendingMode !== "transition" || ACTIVE_TRANSITION_ATTEMPT !== null) return null;
|
|
@@ -543,7 +561,7 @@ function beginTransitionAttempt(block) {
|
|
|
543
561
|
refDetach: refDetachQueue.length,
|
|
544
562
|
effectDeps: snapshotSubtreeEffectDeps(block),
|
|
545
563
|
heldSlots: null,
|
|
546
|
-
|
|
564
|
+
memoSwaps: null
|
|
547
565
|
};
|
|
548
566
|
ACTIVE_TRANSITION_ATTEMPT = attempt;
|
|
549
567
|
return attempt;
|
|
@@ -553,7 +571,7 @@ function endTransitionAttempt(attempt) {
|
|
|
553
571
|
ACTIVE_TRANSITION_ATTEMPT = null;
|
|
554
572
|
const held = attempt.heldSlots;
|
|
555
573
|
if (held === null || held.size === 0) {
|
|
556
|
-
|
|
574
|
+
PROMOTED_MEMO_SWAPS = null;
|
|
557
575
|
PROMOTED_WARM_HARVEST = null;
|
|
558
576
|
}
|
|
559
577
|
let entries = null;
|
|
@@ -587,19 +605,15 @@ function endTransitionAttempt(attempt) {
|
|
|
587
605
|
refAttachQueue.length = attempt.refAttach;
|
|
588
606
|
refDetachQueue.length = attempt.refDetach;
|
|
589
607
|
restoreSubtreeEffectDeps(attempt.origin, attempt.effectDeps);
|
|
590
|
-
const continuing =
|
|
591
|
-
let
|
|
608
|
+
const continuing = PROMOTED_MEMO_SWAPS !== null || PROMOTED_WARM_HARVEST !== null;
|
|
609
|
+
let memoSwaps = attempt.memoSwaps;
|
|
592
610
|
if (continuing) {
|
|
593
|
-
if (
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
} else if (puSwaps !== null) {
|
|
598
|
-
for (let i = puSwaps.length - 1; i >= 0; i--) {
|
|
599
|
-
const [hooks, slot, prev] = puSwaps[i];
|
|
600
|
-
if (prev === void 0) hooks.delete(slot);
|
|
601
|
-
else hooks.set(slot, prev);
|
|
611
|
+
if (PROMOTED_MEMO_SWAPS !== null) {
|
|
612
|
+
memoSwaps = memoSwaps === null ? PROMOTED_MEMO_SWAPS : PROMOTED_MEMO_SWAPS.concat(memoSwaps);
|
|
613
|
+
PROMOTED_MEMO_SWAPS = null;
|
|
602
614
|
}
|
|
615
|
+
} else if (memoSwaps !== null) {
|
|
616
|
+
for (let i = memoSwaps.length - 1; i >= 0; i--) applyTransitionMemoSwap(memoSwaps[i], false);
|
|
603
617
|
}
|
|
604
618
|
for (let i = 0; i < entries.length; i++) {
|
|
605
619
|
entries[i].slot.value = entries[i].baseValue;
|
|
@@ -632,7 +646,7 @@ function endTransitionAttempt(attempt) {
|
|
|
632
646
|
HELD_SYNC_TRANSITION = {
|
|
633
647
|
origin: attempt.origin,
|
|
634
648
|
entries,
|
|
635
|
-
|
|
649
|
+
memoSwaps,
|
|
636
650
|
warmHarvest,
|
|
637
651
|
holders: new Set(held)
|
|
638
652
|
};
|
|
@@ -644,11 +658,26 @@ function endTransitionAttempt(attempt) {
|
|
|
644
658
|
flushParkedItems();
|
|
645
659
|
}
|
|
646
660
|
}
|
|
647
|
-
function
|
|
661
|
+
function journalMemoEntry(scope, slot, next) {
|
|
648
662
|
const attempt = ACTIVE_TRANSITION_ATTEMPT;
|
|
649
663
|
if (attempt === null) return;
|
|
650
664
|
const hooks = ensureHooks(scope);
|
|
651
|
-
(attempt.
|
|
665
|
+
(attempt.memoSwaps ??= []).push([0, hooks, slot, hooks.get(slot), next]);
|
|
666
|
+
}
|
|
667
|
+
function journalHookMemoCells(cells, base, next) {
|
|
668
|
+
const attempt = ACTIVE_TRANSITION_ATTEMPT;
|
|
669
|
+
if (attempt === null) return;
|
|
670
|
+
(attempt.memoSwaps ??= []).push([1, cells, base, cells.slice(base, base + next.length), next]);
|
|
671
|
+
}
|
|
672
|
+
function applyTransitionMemoSwap(swap, forward) {
|
|
673
|
+
if (swap[0] === 0) {
|
|
674
|
+
const value = forward ? swap[4] : swap[3];
|
|
675
|
+
if (!forward && value === void 0) swap[1].delete(swap[2]);
|
|
676
|
+
else swap[1].set(swap[2], value);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const values = forward ? swap[4] : swap[3];
|
|
680
|
+
for (let i = 0; i < values.length; i++) swap[1][swap[2] + i] = values[i];
|
|
652
681
|
}
|
|
653
682
|
function heldSyncCellsIntact(state) {
|
|
654
683
|
const held = HELD_SYNC_TRANSITION;
|
|
@@ -663,13 +692,10 @@ function promoteHeldSyncTransition() {
|
|
|
663
692
|
const held = HELD_SYNC_TRANSITION;
|
|
664
693
|
if (held === null) return false;
|
|
665
694
|
HELD_SYNC_TRANSITION = null;
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
668
|
-
for (let i = 0; i <
|
|
669
|
-
|
|
670
|
-
hooks.set(slot, next);
|
|
671
|
-
}
|
|
672
|
-
PROMOTED_PU_SWAPS = PROMOTED_PU_SWAPS === null ? puSwaps : PROMOTED_PU_SWAPS.concat(puSwaps);
|
|
695
|
+
const memoSwaps = held.memoSwaps;
|
|
696
|
+
if (memoSwaps !== null) {
|
|
697
|
+
for (let i = 0; i < memoSwaps.length; i++) applyTransitionMemoSwap(memoSwaps[i], true);
|
|
698
|
+
PROMOTED_MEMO_SWAPS = PROMOTED_MEMO_SWAPS === null ? memoSwaps : PROMOTED_MEMO_SWAPS.concat(memoSwaps);
|
|
673
699
|
}
|
|
674
700
|
PROMOTED_WARM_HARVEST = held.warmHarvest;
|
|
675
701
|
const promoted = [];
|
|
@@ -695,7 +721,7 @@ function discardHeldSyncTransition(state) {
|
|
|
695
721
|
if (held === null || !held.holders.delete(state)) return;
|
|
696
722
|
if (held.holders.size === 0) {
|
|
697
723
|
HELD_SYNC_TRANSITION = null;
|
|
698
|
-
|
|
724
|
+
PROMOTED_MEMO_SWAPS = null;
|
|
699
725
|
PROMOTED_WARM_HARVEST = null;
|
|
700
726
|
}
|
|
701
727
|
}
|
|
@@ -1432,12 +1458,21 @@ function flush() {
|
|
|
1432
1458
|
}
|
|
1433
1459
|
return;
|
|
1434
1460
|
}
|
|
1461
|
+
if (!hasPendingWork() && refDetachQueue.length === 0 && refAttachQueue.length === 0 && activeFragments.size === 0 && FLUSHED_TRANSITION_UPDATES.length === 0 && VIEW_TRANSITION_DRIVER === null) {
|
|
1462
|
+
if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
|
|
1463
|
+
(0, import_devtools_hook.__devtoolsNotifyFlush)();
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1435
1466
|
if (VIEW_TRANSITION_DRIVER?.routeFlush() === true) return;
|
|
1436
1467
|
flushWork();
|
|
1437
1468
|
}
|
|
1438
1469
|
function activeElementForDocument(doc) {
|
|
1439
1470
|
try {
|
|
1440
1471
|
let focused = doc.activeElement;
|
|
1472
|
+
if (focused === doc.body) {
|
|
1473
|
+
focused = focused?.shadowRoot?.activeElement ?? null;
|
|
1474
|
+
if (focused === null) return null;
|
|
1475
|
+
}
|
|
1441
1476
|
while (focused !== null) {
|
|
1442
1477
|
if (focused.localName === "iframe") {
|
|
1443
1478
|
let nested;
|
|
@@ -3093,10 +3128,9 @@ function useState(initial, slot) {
|
|
|
3093
3128
|
value: initVal,
|
|
3094
3129
|
setter: (next) => {
|
|
3095
3130
|
const previous = stagedTransitionValue(s);
|
|
3096
|
-
const
|
|
3097
|
-
const computed = operation(previous);
|
|
3131
|
+
const computed = typeof next === "function" ? next(previous) : next;
|
|
3098
3132
|
if (Object.is(computed, previous)) return;
|
|
3099
|
-
if (stageTransitionValue(s, block,
|
|
3133
|
+
if (stageTransitionValue(s, block, next, computed)) {
|
|
3100
3134
|
if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
|
|
3101
3135
|
const update = s.pendingActionBatch?.updates.get(s);
|
|
3102
3136
|
if (update !== void 0) {
|
|
@@ -3505,45 +3539,115 @@ function useInsertionEffect(fn, deps, slot) {
|
|
|
3505
3539
|
const [d, s] = resolveHookArgs("useInsertionEffect", deps, slot);
|
|
3506
3540
|
enqueueEffect(s, fn, d, INSERTION);
|
|
3507
3541
|
}
|
|
3542
|
+
function memoEntryHit(slot, entry) {
|
|
3543
|
+
if (entry.warmEpisode !== CURRENT_WARM_EPISODE && recordRealWarmMemo(slot, entry.deps, entry)) {
|
|
3544
|
+
entry.warmEpisode = CURRENT_WARM_EPISODE;
|
|
3545
|
+
}
|
|
3546
|
+
return entry;
|
|
3547
|
+
}
|
|
3548
|
+
function adoptMemoEntry(scope, slot, deps) {
|
|
3549
|
+
const adopted = adoptWarmValue(slot, deps);
|
|
3550
|
+
if (adopted === WARM_MISS) return null;
|
|
3551
|
+
const entry = {
|
|
3552
|
+
deps,
|
|
3553
|
+
value: adopted,
|
|
3554
|
+
warmEpisode: CURRENT_WARM_EPISODE
|
|
3555
|
+
};
|
|
3556
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalMemoEntry(scope, slot, entry);
|
|
3557
|
+
ensureHooks(scope).set(slot, entry);
|
|
3558
|
+
return entry;
|
|
3559
|
+
}
|
|
3560
|
+
function readMemoEntry(scope, slot, deps) {
|
|
3561
|
+
const prev = scope.hooks?.get(slot);
|
|
3562
|
+
if (prev && deps !== void 0 && !depsChanged(prev.deps, deps)) {
|
|
3563
|
+
return memoEntryHit(slot, prev);
|
|
3564
|
+
}
|
|
3565
|
+
return WARM_EVER && deps !== void 0 ? adoptMemoEntry(scope, slot, deps) : null;
|
|
3566
|
+
}
|
|
3567
|
+
function publishMemoEntry(scope, slot, deps, value) {
|
|
3568
|
+
const entry = { deps, value };
|
|
3569
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalMemoEntry(scope, slot, entry);
|
|
3570
|
+
ensureHooks(scope).set(slot, entry);
|
|
3571
|
+
if (deps !== void 0 && recordRealWarmMemo(slot, deps, entry)) {
|
|
3572
|
+
entry.warmEpisode = CURRENT_WARM_EPISODE;
|
|
3573
|
+
}
|
|
3574
|
+
return value;
|
|
3575
|
+
}
|
|
3508
3576
|
function useMemo(compute, deps, slot) {
|
|
3509
3577
|
const [d, s] = resolveHookArgs("useMemo", deps, slot);
|
|
3510
3578
|
const scope = CURRENT_SCOPE;
|
|
3511
|
-
const
|
|
3512
|
-
if (
|
|
3513
|
-
if (prev.warmEpisode !== CURRENT_WARM_EPISODE && recordRealWarmMemo(s, d, prev)) {
|
|
3514
|
-
prev.warmEpisode = CURRENT_WARM_EPISODE;
|
|
3515
|
-
}
|
|
3516
|
-
return prev.value;
|
|
3517
|
-
}
|
|
3518
|
-
if (WARM_EVER && d !== void 0) {
|
|
3519
|
-
const adopted = adoptWarmValue(s, d);
|
|
3520
|
-
if (adopted !== WARM_MISS) {
|
|
3521
|
-
const adoptedEntry = {
|
|
3522
|
-
deps: d,
|
|
3523
|
-
value: adopted,
|
|
3524
|
-
warmEpisode: CURRENT_WARM_EPISODE
|
|
3525
|
-
};
|
|
3526
|
-
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalPuEntry(scope, s, adoptedEntry);
|
|
3527
|
-
ensureHooks(scope).set(s, adoptedEntry);
|
|
3528
|
-
return adopted;
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3579
|
+
const entry = readMemoEntry(scope, s, d);
|
|
3580
|
+
if (entry !== null) return entry.value;
|
|
3531
3581
|
const value = compute.apply(null, d ?? []);
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3582
|
+
return publishMemoEntry(scope, s, d, value);
|
|
3583
|
+
}
|
|
3584
|
+
function useCallback(fn, deps, slot) {
|
|
3585
|
+
const [d, s] = resolveHookArgs("useCallback", deps, slot);
|
|
3586
|
+
const scope = CURRENT_SCOPE;
|
|
3587
|
+
const entry = readMemoEntry(scope, s, d);
|
|
3588
|
+
return entry === null ? publishMemoEntry(scope, s, d, fn) : entry.value;
|
|
3589
|
+
}
|
|
3590
|
+
const hookMemoEqual = Object.is;
|
|
3591
|
+
function hookMemoCreate(size) {
|
|
3592
|
+
return new Array(size).fill(void 0);
|
|
3593
|
+
}
|
|
3594
|
+
function hookMemoPublish0(cells, base, value) {
|
|
3595
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalHookMemoCells(cells, base, [true, value]);
|
|
3596
|
+
cells[base + 1] = value;
|
|
3597
|
+
cells[base] = true;
|
|
3598
|
+
return value;
|
|
3599
|
+
}
|
|
3600
|
+
function hookMemoPublish1(cells, base, value, d0) {
|
|
3601
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalHookMemoCells(cells, base, [true, d0, value]);
|
|
3602
|
+
cells[base + 2] = value;
|
|
3603
|
+
cells[base + 1] = d0;
|
|
3604
|
+
cells[base] = true;
|
|
3605
|
+
return value;
|
|
3606
|
+
}
|
|
3607
|
+
function hookMemoPublish2(cells, base, value, d0, d1) {
|
|
3608
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalHookMemoCells(cells, base, [true, d0, d1, value]);
|
|
3609
|
+
cells[base + 3] = value;
|
|
3610
|
+
cells[base + 1] = d0;
|
|
3611
|
+
cells[base + 2] = d1;
|
|
3612
|
+
cells[base] = true;
|
|
3613
|
+
return value;
|
|
3614
|
+
}
|
|
3615
|
+
function hookMemoPublish3(cells, base, value, d0, d1, d2) {
|
|
3616
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) {
|
|
3617
|
+
journalHookMemoCells(cells, base, [true, d0, d1, d2, value]);
|
|
3537
3618
|
}
|
|
3619
|
+
cells[base + 4] = value;
|
|
3620
|
+
cells[base + 1] = d0;
|
|
3621
|
+
cells[base + 2] = d1;
|
|
3622
|
+
cells[base + 3] = d2;
|
|
3623
|
+
cells[base] = true;
|
|
3538
3624
|
return value;
|
|
3539
3625
|
}
|
|
3540
|
-
function
|
|
3541
|
-
if (
|
|
3542
|
-
|
|
3543
|
-
deps = void 0;
|
|
3626
|
+
function hookMemoPublish4(cells, base, value, d0, d1, d2, d3) {
|
|
3627
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) {
|
|
3628
|
+
journalHookMemoCells(cells, base, [true, d0, d1, d2, d3, value]);
|
|
3544
3629
|
}
|
|
3545
|
-
|
|
3546
|
-
|
|
3630
|
+
cells[base + 5] = value;
|
|
3631
|
+
cells[base + 1] = d0;
|
|
3632
|
+
cells[base + 2] = d1;
|
|
3633
|
+
cells[base + 3] = d2;
|
|
3634
|
+
cells[base + 4] = d3;
|
|
3635
|
+
cells[base] = true;
|
|
3636
|
+
return value;
|
|
3637
|
+
}
|
|
3638
|
+
function hookMemoPublish(cells, base, value, ...deps) {
|
|
3639
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) {
|
|
3640
|
+
journalHookMemoCells(cells, base, [true, ...deps, value]);
|
|
3641
|
+
}
|
|
3642
|
+
cells[base + deps.length + 1] = value;
|
|
3643
|
+
for (let i = 0; i < deps.length; i++) cells[base + i + 1] = deps[i];
|
|
3644
|
+
cells[base] = true;
|
|
3645
|
+
return value;
|
|
3646
|
+
}
|
|
3647
|
+
function hookMemoPublishInvariant(cells, base, value) {
|
|
3648
|
+
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalHookMemoCells(cells, base, [value]);
|
|
3649
|
+
cells[base] = value;
|
|
3650
|
+
return value;
|
|
3547
3651
|
}
|
|
3548
3652
|
function useRef(initial, slot) {
|
|
3549
3653
|
if (slot === void 0 && typeof initial === "symbol") {
|
|
@@ -3628,6 +3732,10 @@ function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
|
|
|
3628
3732
|
scheduleRender(block);
|
|
3629
3733
|
} : () => scheduleRender(block),
|
|
3630
3734
|
onStoreChange: () => {
|
|
3735
|
+
if (block.disposed) return;
|
|
3736
|
+
if (CURRENT_BLOCK === null && block.pending && block.pendingMode === "urgent" && !block.pendingDeferred && !(typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) && (process.env.NODE_ENV === "production" || !IS_OCTANE_ACT_ENVIRONMENT || actScopeDepth !== 0 || syncFlush)) {
|
|
3737
|
+
return;
|
|
3738
|
+
}
|
|
3631
3739
|
if (checkStoreChanged(created)) created.forceUpdate();
|
|
3632
3740
|
},
|
|
3633
3741
|
block,
|
|
@@ -4539,6 +4647,10 @@ function activateHydrateBoundary(state) {
|
|
|
4539
4647
|
renderBlock(block);
|
|
4540
4648
|
drainHydrationRenderPhaseUpdates(block);
|
|
4541
4649
|
if (state.hydrated) {
|
|
4650
|
+
const adoptedSlot = block.slots[0];
|
|
4651
|
+
if (adoptedSlot?.__kind === "trySlotSlot") {
|
|
4652
|
+
hydration.claimRootRemainder(adoptedSlot.end.nextSibling);
|
|
4653
|
+
}
|
|
4542
4654
|
hydration.flushClassWrites();
|
|
4543
4655
|
hydration.flushTextWarnings();
|
|
4544
4656
|
hydration.finishRoot();
|
|
@@ -5360,28 +5472,14 @@ function adoptWarmValue(slot, deps) {
|
|
|
5360
5472
|
return WARM_MISS;
|
|
5361
5473
|
}
|
|
5362
5474
|
const puMiss = /* @__PURE__ */ Symbol("octane.pu.miss");
|
|
5363
|
-
function puHit(slot, entry) {
|
|
5364
|
-
if (entry.warmEpisode !== CURRENT_WARM_EPISODE && recordRealWarmMemo(slot, entry.deps, entry)) {
|
|
5365
|
-
entry.warmEpisode = CURRENT_WARM_EPISODE;
|
|
5366
|
-
}
|
|
5367
|
-
return entry.value;
|
|
5368
|
-
}
|
|
5369
5475
|
function puAdopt(slot, deps) {
|
|
5370
|
-
const
|
|
5371
|
-
|
|
5372
|
-
const adoptedEntry = {
|
|
5373
|
-
deps,
|
|
5374
|
-
value: adopted,
|
|
5375
|
-
warmEpisode: CURRENT_WARM_EPISODE
|
|
5376
|
-
};
|
|
5377
|
-
if (ACTIVE_TRANSITION_ATTEMPT !== null) journalPuEntry(CURRENT_SCOPE, slot, adoptedEntry);
|
|
5378
|
-
ensureHooks(CURRENT_SCOPE).set(slot, adoptedEntry);
|
|
5379
|
-
return adopted;
|
|
5476
|
+
const entry = adoptMemoEntry(CURRENT_SCOPE, slot, deps);
|
|
5477
|
+
return entry === null ? puMiss : entry.value;
|
|
5380
5478
|
}
|
|
5381
5479
|
function puTake0(slot) {
|
|
5382
5480
|
const prev = CURRENT_SCOPE.hooks?.get(slot);
|
|
5383
5481
|
if (prev !== void 0 && prev.deps !== void 0 && prev.deps.length === 0) {
|
|
5384
|
-
return
|
|
5482
|
+
return memoEntryHit(slot, prev).value;
|
|
5385
5483
|
}
|
|
5386
5484
|
if (WARM_EVER) return puAdopt(slot, []);
|
|
5387
5485
|
return puMiss;
|
|
@@ -5390,7 +5488,9 @@ function puTake1(slot, d0) {
|
|
|
5390
5488
|
const prev = CURRENT_SCOPE.hooks?.get(slot);
|
|
5391
5489
|
if (prev !== void 0) {
|
|
5392
5490
|
const pd = prev.deps;
|
|
5393
|
-
if (pd !== void 0 && pd.length === 1 && Object.is(pd[0], d0))
|
|
5491
|
+
if (pd !== void 0 && pd.length === 1 && Object.is(pd[0], d0)) {
|
|
5492
|
+
return memoEntryHit(slot, prev).value;
|
|
5493
|
+
}
|
|
5394
5494
|
}
|
|
5395
5495
|
if (WARM_EVER) return puAdopt(slot, [d0]);
|
|
5396
5496
|
return puMiss;
|
|
@@ -5400,7 +5500,7 @@ function puTake2(slot, d0, d1) {
|
|
|
5400
5500
|
if (prev !== void 0) {
|
|
5401
5501
|
const pd = prev.deps;
|
|
5402
5502
|
if (pd !== void 0 && pd.length === 2 && Object.is(pd[0], d0) && Object.is(pd[1], d1)) {
|
|
5403
|
-
return
|
|
5503
|
+
return memoEntryHit(slot, prev).value;
|
|
5404
5504
|
}
|
|
5405
5505
|
}
|
|
5406
5506
|
if (WARM_EVER) return puAdopt(slot, [d0, d1]);
|
|
@@ -5411,7 +5511,7 @@ function puTake3(slot, d0, d1, d2) {
|
|
|
5411
5511
|
if (prev !== void 0) {
|
|
5412
5512
|
const pd = prev.deps;
|
|
5413
5513
|
if (pd !== void 0 && pd.length === 3 && Object.is(pd[0], d0) && Object.is(pd[1], d1) && Object.is(pd[2], d2)) {
|
|
5414
|
-
return
|
|
5514
|
+
return memoEntryHit(slot, prev).value;
|
|
5415
5515
|
}
|
|
5416
5516
|
}
|
|
5417
5517
|
if (WARM_EVER) return puAdopt(slot, [d0, d1, d2]);
|
|
@@ -5422,18 +5522,77 @@ function puTake4(slot, d0, d1, d2, d3) {
|
|
|
5422
5522
|
if (prev !== void 0) {
|
|
5423
5523
|
const pd = prev.deps;
|
|
5424
5524
|
if (pd !== void 0 && pd.length === 4 && Object.is(pd[0], d0) && Object.is(pd[1], d1) && Object.is(pd[2], d2) && Object.is(pd[3], d3)) {
|
|
5425
|
-
return
|
|
5525
|
+
return memoEntryHit(slot, prev).value;
|
|
5426
5526
|
}
|
|
5427
5527
|
}
|
|
5428
5528
|
if (WARM_EVER) return puAdopt(slot, [d0, d1, d2, d3]);
|
|
5429
5529
|
return puMiss;
|
|
5430
5530
|
}
|
|
5431
5531
|
function puPub(slot, value, ...deps) {
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5532
|
+
return publishMemoEntry(CURRENT_SCOPE, slot, deps, value);
|
|
5533
|
+
}
|
|
5534
|
+
function memoSlot(slot, name) {
|
|
5535
|
+
const resolved = resolveSlot(slot);
|
|
5536
|
+
if (resolved === void 0) missingSlot(name);
|
|
5537
|
+
return resolved;
|
|
5538
|
+
}
|
|
5539
|
+
function memoTake0(slot) {
|
|
5540
|
+
const scope = CURRENT_SCOPE;
|
|
5541
|
+
const prev = scope.hooks?.get(slot);
|
|
5542
|
+
if (prev !== void 0 && prev.deps !== void 0 && prev.deps.length === 0) {
|
|
5543
|
+
return memoEntryHit(slot, prev);
|
|
5544
|
+
}
|
|
5545
|
+
return WARM_EVER ? adoptMemoEntry(scope, slot, []) : null;
|
|
5546
|
+
}
|
|
5547
|
+
function memoTake1(slot, d0) {
|
|
5548
|
+
const scope = CURRENT_SCOPE;
|
|
5549
|
+
const prev = scope.hooks?.get(slot);
|
|
5550
|
+
if (prev !== void 0) {
|
|
5551
|
+
const pd = prev.deps;
|
|
5552
|
+
if (pd !== void 0 && pd.length === 1 && Object.is(pd[0], d0)) {
|
|
5553
|
+
return memoEntryHit(slot, prev);
|
|
5554
|
+
}
|
|
5555
|
+
}
|
|
5556
|
+
return WARM_EVER ? adoptMemoEntry(scope, slot, [d0]) : null;
|
|
5557
|
+
}
|
|
5558
|
+
function memoTake2(slot, d0, d1) {
|
|
5559
|
+
const scope = CURRENT_SCOPE;
|
|
5560
|
+
const prev = scope.hooks?.get(slot);
|
|
5561
|
+
if (prev !== void 0) {
|
|
5562
|
+
const pd = prev.deps;
|
|
5563
|
+
if (pd !== void 0 && pd.length === 2 && Object.is(pd[0], d0) && Object.is(pd[1], d1)) {
|
|
5564
|
+
return memoEntryHit(slot, prev);
|
|
5565
|
+
}
|
|
5566
|
+
}
|
|
5567
|
+
return WARM_EVER ? adoptMemoEntry(scope, slot, [d0, d1]) : null;
|
|
5568
|
+
}
|
|
5569
|
+
function memoTake3(slot, d0, d1, d2) {
|
|
5570
|
+
const scope = CURRENT_SCOPE;
|
|
5571
|
+
const prev = scope.hooks?.get(slot);
|
|
5572
|
+
if (prev !== void 0) {
|
|
5573
|
+
const pd = prev.deps;
|
|
5574
|
+
if (pd !== void 0 && pd.length === 3 && Object.is(pd[0], d0) && Object.is(pd[1], d1) && Object.is(pd[2], d2)) {
|
|
5575
|
+
return memoEntryHit(slot, prev);
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
return WARM_EVER ? adoptMemoEntry(scope, slot, [d0, d1, d2]) : null;
|
|
5579
|
+
}
|
|
5580
|
+
function memoTake4(slot, d0, d1, d2, d3) {
|
|
5581
|
+
const scope = CURRENT_SCOPE;
|
|
5582
|
+
const prev = scope.hooks?.get(slot);
|
|
5583
|
+
if (prev !== void 0) {
|
|
5584
|
+
const pd = prev.deps;
|
|
5585
|
+
if (pd !== void 0 && pd.length === 4 && Object.is(pd[0], d0) && Object.is(pd[1], d1) && Object.is(pd[2], d2) && Object.is(pd[3], d3)) {
|
|
5586
|
+
return memoEntryHit(slot, prev);
|
|
5587
|
+
}
|
|
5588
|
+
}
|
|
5589
|
+
return WARM_EVER ? adoptMemoEntry(scope, slot, [d0, d1, d2, d3]) : null;
|
|
5590
|
+
}
|
|
5591
|
+
function memoPublish(slot, value, ...deps) {
|
|
5592
|
+
return publishMemoEntry(CURRENT_SCOPE, slot, deps, value);
|
|
5593
|
+
}
|
|
5594
|
+
function memoPublishAlways(slot, value) {
|
|
5595
|
+
return publishMemoEntry(CURRENT_SCOPE, slot, void 0, value);
|
|
5437
5596
|
}
|
|
5438
5597
|
const LAZY_COMPONENT = /* @__PURE__ */ Symbol.for("octane.lazy");
|
|
5439
5598
|
function resolveLazyModule(mod) {
|
|
@@ -14836,7 +14995,7 @@ function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flag
|
|
|
14836
14995
|
hydration.node = state.end.nextSibling;
|
|
14837
14996
|
}
|
|
14838
14997
|
}
|
|
14839
|
-
function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
|
|
14998
|
+
function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody) {
|
|
14840
14999
|
const state = parentScope.slots[slotKey];
|
|
14841
15000
|
if (TRANSITION_JOURNAL !== null) {
|
|
14842
15001
|
if (state !== void 0) {
|
|
@@ -14844,7 +15003,15 @@ function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody,
|
|
|
14844
15003
|
state.selectionItems = void 0;
|
|
14845
15004
|
}
|
|
14846
15005
|
flags &= ~4;
|
|
14847
|
-
} else if (state !== void 0 && activeHydration() === null && state.cachedDeps !== null && tryUpdateKeyedSelection(
|
|
15006
|
+
} else if (state !== void 0 && activeHydration() === null && state.cachedDeps !== null && tryUpdateKeyedSelection(
|
|
15007
|
+
state,
|
|
15008
|
+
items,
|
|
15009
|
+
itemBody,
|
|
15010
|
+
state.cachedDeps,
|
|
15011
|
+
deps,
|
|
15012
|
+
flags >>> 6,
|
|
15013
|
+
selectionBody
|
|
15014
|
+
)) {
|
|
14848
15015
|
return;
|
|
14849
15016
|
}
|
|
14850
15017
|
forBlock(
|
|
@@ -14968,7 +15135,7 @@ function fastForBlock(parentScope, slotKey, domParent, items, getKey, itemBody,
|
|
|
14968
15135
|
}
|
|
14969
15136
|
mountFastHostItems(parentScope, state, parent, items, getKey, itemBody, flags, deps, false);
|
|
14970
15137
|
}
|
|
14971
|
-
function fastKeyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
|
|
15138
|
+
function fastKeyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody) {
|
|
14972
15139
|
const state = parentScope.slots[slotKey];
|
|
14973
15140
|
const parent = fastHostListParent(state, items, flags);
|
|
14974
15141
|
if (parent === null) {
|
|
@@ -14983,7 +15150,8 @@ function fastKeyedForBlock(parentScope, slotKey, domParent, items, getKey, itemB
|
|
|
14983
15150
|
deps,
|
|
14984
15151
|
emptyBody,
|
|
14985
15152
|
anchor,
|
|
14986
|
-
ownEnd
|
|
15153
|
+
ownEnd,
|
|
15154
|
+
selectionBody
|
|
14987
15155
|
);
|
|
14988
15156
|
return;
|
|
14989
15157
|
}
|
|
@@ -15055,7 +15223,7 @@ function depsEqual(a, b) {
|
|
|
15055
15223
|
}
|
|
15056
15224
|
return true;
|
|
15057
15225
|
}
|
|
15058
|
-
function tryUpdateKeyedSelection(state, items, itemBody, previousDeps, deps, selectionIndex) {
|
|
15226
|
+
function tryUpdateKeyedSelection(state, items, itemBody, previousDeps, deps, selectionIndex, selectionBody) {
|
|
15059
15227
|
if (state.selectionItems !== items || state.size !== items.length || state.items.size !== state.size || previousDeps.length !== deps.length || selectionIndex >= deps.length) {
|
|
15060
15228
|
return false;
|
|
15061
15229
|
}
|
|
@@ -15078,12 +15246,20 @@ function tryUpdateKeyedSelection(state, items, itemBody, previousDeps, deps, sel
|
|
|
15078
15246
|
if (first !== void 0) {
|
|
15079
15247
|
first.body = itemBody;
|
|
15080
15248
|
first.extra = deps;
|
|
15081
|
-
|
|
15249
|
+
if (selectionBody !== void 0 && first._slots === null) {
|
|
15250
|
+
selectionBody(first.props, first, deps);
|
|
15251
|
+
} else {
|
|
15252
|
+
itemBody(first.props, first, deps);
|
|
15253
|
+
}
|
|
15082
15254
|
}
|
|
15083
15255
|
if (second !== void 0) {
|
|
15084
15256
|
second.body = itemBody;
|
|
15085
15257
|
second.extra = deps;
|
|
15086
|
-
|
|
15258
|
+
if (selectionBody !== void 0 && second._slots === null) {
|
|
15259
|
+
selectionBody(second.props, second, deps);
|
|
15260
|
+
} else {
|
|
15261
|
+
itemBody(second.props, second, deps);
|
|
15262
|
+
}
|
|
15087
15263
|
}
|
|
15088
15264
|
return true;
|
|
15089
15265
|
}
|
|
@@ -16977,6 +17153,15 @@ function scriptResource(attrs) {
|
|
|
16977
17153
|
hasPendingWork,
|
|
16978
17154
|
headBlock,
|
|
16979
17155
|
hmr,
|
|
17156
|
+
hookMemoCreate,
|
|
17157
|
+
hookMemoEqual,
|
|
17158
|
+
hookMemoPublish,
|
|
17159
|
+
hookMemoPublish0,
|
|
17160
|
+
hookMemoPublish1,
|
|
17161
|
+
hookMemoPublish2,
|
|
17162
|
+
hookMemoPublish3,
|
|
17163
|
+
hookMemoPublish4,
|
|
17164
|
+
hookMemoPublishInvariant,
|
|
16980
17165
|
hookSlots,
|
|
16981
17166
|
hostComponent,
|
|
16982
17167
|
htext,
|
|
@@ -16994,6 +17179,14 @@ function scriptResource(attrs) {
|
|
|
16994
17179
|
markNativeChangeDiagnosticStatic,
|
|
16995
17180
|
markSingleRoot,
|
|
16996
17181
|
memo,
|
|
17182
|
+
memoPublish,
|
|
17183
|
+
memoPublishAlways,
|
|
17184
|
+
memoSlot,
|
|
17185
|
+
memoTake0,
|
|
17186
|
+
memoTake1,
|
|
17187
|
+
memoTake2,
|
|
17188
|
+
memoTake3,
|
|
17189
|
+
memoTake4,
|
|
16997
17190
|
mountFragmentRef,
|
|
16998
17191
|
namespaceHead,
|
|
16999
17192
|
namespaceHeadElement,
|
|
@@ -3133,24 +3133,27 @@ const useLayoutEffect = useEffect;
|
|
|
3133
3133
|
const useInsertionEffect = useEffect;
|
|
3134
3134
|
function useImperativeHandle() {
|
|
3135
3135
|
}
|
|
3136
|
-
function
|
|
3136
|
+
function memoHookValue(input, compute, depsOrSlot, maybeSlot) {
|
|
3137
3137
|
const deps = Array.isArray(depsOrSlot) ? depsOrSlot : null;
|
|
3138
3138
|
const slot = maybeSlot ?? (Array.isArray(depsOrSlot) || depsOrSlot === null ? void 0 : depsOrSlot);
|
|
3139
|
-
if (deps === null) return compute();
|
|
3139
|
+
if (deps === null) return compute ? input() : input;
|
|
3140
3140
|
const position = hookPosition(slot);
|
|
3141
|
-
if (position === null) return compute();
|
|
3141
|
+
if (position === null) return compute ? input() : input;
|
|
3142
3142
|
let rec = position.list[position.index];
|
|
3143
3143
|
if (rec === void 0) {
|
|
3144
|
-
rec = { value: compute(), deps: deps.slice() };
|
|
3144
|
+
rec = { value: compute ? input() : input, deps: deps.slice() };
|
|
3145
3145
|
position.list[position.index] = rec;
|
|
3146
3146
|
} else if (!serverDepsEqual(rec.deps, deps)) {
|
|
3147
|
-
rec.value = compute();
|
|
3147
|
+
rec.value = compute ? input() : input;
|
|
3148
3148
|
rec.deps = deps.slice();
|
|
3149
3149
|
}
|
|
3150
3150
|
return rec.value;
|
|
3151
3151
|
}
|
|
3152
|
+
function useMemo(compute, depsOrSlot, maybeSlot) {
|
|
3153
|
+
return memoHookValue(compute, true, depsOrSlot, maybeSlot);
|
|
3154
|
+
}
|
|
3152
3155
|
function useCallback(fn, depsOrSlot, maybeSlot) {
|
|
3153
|
-
return
|
|
3156
|
+
return memoHookValue(fn, false, depsOrSlot, maybeSlot);
|
|
3154
3157
|
}
|
|
3155
3158
|
function useRef(initial, slot) {
|
|
3156
3159
|
if (slot === void 0 && typeof initial === "symbol") {
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
version: () => version
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const version = "0.1.
|
|
24
|
+
const version = "0.1.42";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
version
|