@octane-xplat/patches 0.9.0 → 0.10.0
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/package.json +1 -1
- package/patches/@lexical__link@0.51.0.patch +29 -0
- package/patches/@nativescript-community__octane@0.2.4.patch +25 -0
- package/patches/@nativescript__core@9.1.3-next.2.patch +1196 -0
- package/patches/@nativescript__vite@8.0.17.patch +135 -1
- package/patches/octane@0.6.3.patch +418 -26
|
@@ -592,7 +592,7 @@ index 0000000000000000000000000000000000000000..ff5eb43e8f0ddcadbcf8e861f42788b3
|
|
|
592
592
|
+ universalSignalDocument
|
|
593
593
|
+};
|
|
594
594
|
diff --git a/dist/node/universal-core.js b/dist/node/universal-core.js
|
|
595
|
-
index 4dbe2f938d039d415b44821bcb3be520172bcada..
|
|
595
|
+
index 4dbe2f938d039d415b44821bcb3be520172bcada..735a017364cd23bdb8972a04401385f0bde99062 100644
|
|
596
596
|
--- a/dist/node/universal-core.js
|
|
597
597
|
+++ b/dist/node/universal-core.js
|
|
598
598
|
@@ -17,6 +17,14 @@ import {
|
|
@@ -610,7 +610,141 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
610
610
|
import { __methodDep } from "./method-dep.js";
|
|
611
611
|
const UNIVERSAL_PLAN = /* @__PURE__ */ Symbol.for("octane.universal.plan");
|
|
612
612
|
const UNIVERSAL_VALUE = /* @__PURE__ */ Symbol.for("octane.universal.value");
|
|
613
|
-
@@ -
|
|
613
|
+
@@ -474,6 +482,133 @@ function universalComponent(renderer, component, props = null, key = NO_KEY) {
|
|
614
|
+
hasKey: key !== NO_KEY || normalized.hasKey
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
+const NORMALIZED_CHILD_KEYS = new WeakMap();
|
|
618
|
+
+/** Normalize deferred JSX without mounting components or consuming their context.
|
|
619
|
+
+ * Structural owners (blocks, providers, boundaries and loops) remain renderables;
|
|
620
|
+
+ * only transparent child groups, plan ranges, slots and JS arrays are flattened.
|
|
621
|
+
+ */
|
|
622
|
+
+function universalChildEntries(children) {
|
|
623
|
+
+ const out = [];
|
|
624
|
+
+ const collectionKey = (child) => {
|
|
625
|
+
+ const key = renderableKey(child);
|
|
626
|
+
+ if (key !== null)
|
|
627
|
+
+ return key;
|
|
628
|
+
+ if (child?.$$kind !== UNIVERSAL_VALUE)
|
|
629
|
+
+ return null;
|
|
630
|
+
+ const { plan, values } = child;
|
|
631
|
+
+ let node = plan.root;
|
|
632
|
+
+ while (node.kind === 'range' && node.children.length === 1)
|
|
633
|
+
+ node = node.children[0];
|
|
634
|
+
+ if (node.kind === 'slot')
|
|
635
|
+
+ return collectionKey(values[node.slot]);
|
|
636
|
+
+ if (node.kind !== 'host' && node.kind !== 'component')
|
|
637
|
+
+ return null;
|
|
638
|
+
+ if (node.kind === 'component' && node.keySlot !== undefined)
|
|
639
|
+
+ return normalizeUniversalKey(values[node.keySlot]);
|
|
640
|
+
+ return normalizeUniversalKey(node.propsSlot === undefined ? node.kind === 'host' ? node.props?.key : null : normalizePropsValue(values[node.propsSlot]).key);
|
|
641
|
+
+ };
|
|
642
|
+
+ const visit = (child, path) => {
|
|
643
|
+
+ if (child == null || typeof child === 'boolean')
|
|
644
|
+
+ return;
|
|
645
|
+
+ if (typeof child === 'object') {
|
|
646
|
+
+ const normalizedKey = NORMALIZED_CHILD_KEYS.get(child);
|
|
647
|
+
+ if (normalizedKey !== undefined) {
|
|
648
|
+
+ out.push({ child, key: normalizedKey });
|
|
649
|
+
+ return;
|
|
650
|
+
+ }
|
|
651
|
+
+ }
|
|
652
|
+
+ if (Array.isArray(child)) {
|
|
653
|
+
+ child.forEach((item, index) => {
|
|
654
|
+
+ const key = collectionKey(item);
|
|
655
|
+
+ visit(item, [...path, key === null ? 'index' : 'key', key ?? index]);
|
|
656
|
+
+ });
|
|
657
|
+
+ return;
|
|
658
|
+
+ }
|
|
659
|
+
+ if (child?.$$kind === UNIVERSAL_CHILDREN) {
|
|
660
|
+
+ const children = child;
|
|
661
|
+
+ if (CURRENT_OWNER !== null && children.renderer !== currentAttempt().root.renderer) {
|
|
662
|
+
+ throw new Error('Universal renderer mismatch while normalizing children.');
|
|
663
|
+
+ }
|
|
664
|
+
+ visit(children.render(), path);
|
|
665
|
+
+ return;
|
|
666
|
+
+ }
|
|
667
|
+
+ if (child?.$$kind === UNIVERSAL_LIST) {
|
|
668
|
+
+ const list = child;
|
|
669
|
+
+ visit(list.values.length === 0 ? list.empty : list.values, path);
|
|
670
|
+
+ return;
|
|
671
|
+
+ }
|
|
672
|
+
+ if (child?.$$kind === UNIVERSAL_VALUE) {
|
|
673
|
+
+ const value = child;
|
|
674
|
+
+ if (CURRENT_OWNER !== null && value.plan.renderer !== currentAttempt().root.renderer) {
|
|
675
|
+
+ throw new Error('Universal renderer mismatch while normalizing children.');
|
|
676
|
+
+ }
|
|
677
|
+
+ if (value.key !== null) {
|
|
678
|
+
+ out.push({ child, key: JSON.stringify([...path, 'key', value.key]) });
|
|
679
|
+
+ return;
|
|
680
|
+
+ }
|
|
681
|
+
+ const visitNode = (node, nodePath) => {
|
|
682
|
+
+ if (node.kind === 'range') {
|
|
683
|
+
+ node.children.forEach((item, index) => visitNode(item, [...nodePath, index]));
|
|
684
|
+
+ }
|
|
685
|
+
+ else if (node.kind === 'slot') {
|
|
686
|
+
+ visit(value.values[node.slot], nodePath);
|
|
687
|
+
+ }
|
|
688
|
+
+ else if (node.kind === 'text') {
|
|
689
|
+
+ visit((node.slot === undefined ? node.value : value.values[node.slot]), nodePath);
|
|
690
|
+
+ }
|
|
691
|
+
+ else {
|
|
692
|
+
+ const key = node.kind === 'component'
|
|
693
|
+
+ ? node.keySlot === undefined
|
|
694
|
+
+ ? node.propsSlot === undefined ? null : normalizePropsValue(value.values[node.propsSlot]).key
|
|
695
|
+
+ : value.values[node.keySlot]
|
|
696
|
+
+ : node.kind === 'host'
|
|
697
|
+
+ ? node.propsSlot === undefined ? node.props?.key ?? null : normalizePropsValue(value.values[node.propsSlot]).key
|
|
698
|
+
+ : null;
|
|
699
|
+
+ const item = universalValue(universalPlan(value.plan.renderer, node), value.values);
|
|
700
|
+
+ out.push({ child: item, key: JSON.stringify(key == null ? nodePath : [...(node === value.plan.root ? path : nodePath.slice(0, -1)), 'key', key]) });
|
|
701
|
+
+ }
|
|
702
|
+
+ };
|
|
703
|
+
+ visitNode(value.plan.root, path);
|
|
704
|
+
+ return;
|
|
705
|
+
+ }
|
|
706
|
+
+ const key = renderableKey(child);
|
|
707
|
+
+ out.push({ child, key: JSON.stringify(key === null ? path : [...path, 'key', key]) });
|
|
708
|
+
+ };
|
|
709
|
+
+ visit(children, []);
|
|
710
|
+
+ return out;
|
|
711
|
+
+}
|
|
712
|
+
+/** Renderer-supported child collection operations. They never render a component
|
|
713
|
+
+ * to discover its output. Returned entries retain their keys when mapped into
|
|
714
|
+
+ * wrapper hosts, and are materialized normally at their eventual placement.
|
|
715
|
+
+ */
|
|
716
|
+
+function normalizedChild(key, child) {
|
|
717
|
+
+ const value = universalKey(key, child);
|
|
718
|
+
+ NORMALIZED_CHILD_KEYS.set(value, key);
|
|
719
|
+
+ return value;
|
|
720
|
+
+}
|
|
721
|
+
+const Children = {
|
|
722
|
+
+ toArray(children) {
|
|
723
|
+
+ return universalChildEntries(children).map(({ child, key }) => typeof child === 'object' ? normalizedChild(key, child) : child);
|
|
724
|
+
+ },
|
|
725
|
+
+ map(children, fn) {
|
|
726
|
+
+ const out = [];
|
|
727
|
+
+ universalChildEntries(children).forEach(({ child, key }, index) => {
|
|
728
|
+
+ const mapped = fn(child, index);
|
|
729
|
+
+ if (mapped == null || typeof mapped === 'boolean')
|
|
730
|
+
+ return;
|
|
731
|
+
+ if (Array.isArray(mapped)) {
|
|
732
|
+
+ for (const entry of universalChildEntries(mapped)) {
|
|
733
|
+
+ out.push(normalizedChild(JSON.stringify([key, entry.key]), entry.child));
|
|
734
|
+
+ }
|
|
735
|
+
+ }
|
|
736
|
+
+ else {
|
|
737
|
+
+ out.push(normalizedChild(key, mapped));
|
|
738
|
+
+ }
|
|
739
|
+
+ });
|
|
740
|
+
+ return out;
|
|
741
|
+
+ },
|
|
742
|
+
+};
|
|
743
|
+
+
|
|
744
|
+
function universalChildren(renderer, render) {
|
|
745
|
+
assertRendererId(renderer, "universalChildren renderer");
|
|
746
|
+
if (typeof render !== "function") throw new TypeError("universalChildren expected a function.");
|
|
747
|
+
@@ -842,6 +977,7 @@ function draftOwner(record, parent, replayPath) {
|
|
614
748
|
boundaryThenable: record.boundaryThenable,
|
|
615
749
|
isBoundary: record.isBoundary,
|
|
616
750
|
canHandleSuspense: record.canHandleSuspense,
|
|
@@ -618,7 +752,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
618
752
|
visibility: parent?.visibility ?? record.visibility,
|
|
619
753
|
contextStable: null
|
|
620
754
|
};
|
|
621
|
-
@@ -1012,6 +
|
|
755
|
+
@@ -1012,6 +1148,7 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
622
756
|
owner.contextStable = null;
|
|
623
757
|
owner.needsRender = false;
|
|
624
758
|
owner.implicitSlot = 0;
|
|
@@ -626,7 +760,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
626
760
|
const previousOwner = CURRENT_OWNER;
|
|
627
761
|
const previousAttemptOwner = attempt.owner;
|
|
628
762
|
CURRENT_OWNER = owner;
|
|
629
|
-
@@ -1023,13 +
|
|
763
|
+
@@ -1023,13 +1160,18 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
630
764
|
const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && component !== null ? __profileBeginRender(owner.record, component, owner.record.mounted) : null;
|
|
631
765
|
let didThrow = false;
|
|
632
766
|
let thrown;
|
|
@@ -648,7 +782,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
648
782
|
if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
|
|
649
783
|
__profileEndRender(profileFrame, didThrow, thrown);
|
|
650
784
|
}
|
|
651
|
-
@@ -1196,6 +
|
|
785
|
+
@@ -1196,6 +1338,8 @@ function disposeUncommittedDraft(owner) {
|
|
652
786
|
owner.record.componentProps = null;
|
|
653
787
|
owner.record.range = null;
|
|
654
788
|
owner.record.updates.clear();
|
|
@@ -657,7 +791,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
657
791
|
for (const hook of owner.hooks.values()) {
|
|
658
792
|
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
659
793
|
}
|
|
660
|
-
@@ -3142,6 +
|
|
794
|
+
@@ -3142,6 +3286,85 @@ function scheduleOwner(owner, slot) {
|
|
661
795
|
}
|
|
662
796
|
owner.root.scheduleOwned(owner);
|
|
663
797
|
}
|
|
@@ -743,7 +877,50 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
743
877
|
function currentDraftOwner() {
|
|
744
878
|
currentAttempt();
|
|
745
879
|
const owner = activateLazyLeafOwner();
|
|
746
|
-
@@ -
|
|
880
|
+
@@ -4142,15 +4365,35 @@ function use(usable) {
|
|
881
|
+
function useImperativeHandle(ref, create, deps, slot) {
|
|
882
|
+
useLayoutEffect(
|
|
883
|
+
() => {
|
|
884
|
+
- const value = create();
|
|
885
|
+
- if (typeof ref === "function") ref(value);
|
|
886
|
+
- else if (ref !== null) ref.current = value;
|
|
887
|
+
- return () => {
|
|
888
|
+
- if (typeof ref === "function") ref(null);
|
|
889
|
+
- else if (ref !== null) ref.current = null;
|
|
890
|
+
+ const cleanups = [];
|
|
891
|
+
+ let value;
|
|
892
|
+
+ let initialized = false;
|
|
893
|
+
+ const attach = (target) => {
|
|
894
|
+
+ if (target == null) return;
|
|
895
|
+
+ if (Array.isArray(target)) {
|
|
896
|
+
+ for (const entry of target) attach(entry);
|
|
897
|
+
+ return;
|
|
898
|
+
+ }
|
|
899
|
+
+ if (!initialized) {
|
|
900
|
+
+ value = create();
|
|
901
|
+
+ initialized = true;
|
|
902
|
+
+ }
|
|
903
|
+
+ if (typeof target === "function") {
|
|
904
|
+
+ const cleanup = target(value);
|
|
905
|
+
+ cleanups.push(typeof cleanup === "function" ? cleanup : () => target(null));
|
|
906
|
+
+ } else {
|
|
907
|
+
+ target.current = value;
|
|
908
|
+
+ cleanups.push(() => { target.current = null; });
|
|
909
|
+
+ }
|
|
910
|
+
};
|
|
911
|
+
+ try {
|
|
912
|
+
+ attach(ref);
|
|
913
|
+
+ } catch (error) {
|
|
914
|
+
+ try { runCommitTasks(cleanups); } finally { throw error; }
|
|
915
|
+
+ }
|
|
916
|
+
+ return () => runCommitTasks(cleanups);
|
|
917
|
+
},
|
|
918
|
+
- deps,
|
|
919
|
+
+ deps == null ? deps : [...deps, ref],
|
|
920
|
+
slot
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
@@ -5520,9 +5763,9 @@ class UniversalRootImpl {
|
|
747
924
|
}
|
|
748
925
|
let result;
|
|
749
926
|
try {
|
|
@@ -755,7 +932,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
755
932
|
}
|
|
756
933
|
return result;
|
|
757
934
|
}
|
|
758
|
-
@@ -6096,6 +
|
|
935
|
+
@@ -6096,6 +6339,8 @@ class UniversalRootImpl {
|
|
759
936
|
draft.record.componentProps = null;
|
|
760
937
|
draft.record.range = null;
|
|
761
938
|
draft.record.updates.clear();
|
|
@@ -764,7 +941,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
764
941
|
for (const hook of draft.hooks.values()) {
|
|
765
942
|
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
766
943
|
}
|
|
767
|
-
@@ -6776,6 +
|
|
944
|
+
@@ -6776,6 +7021,7 @@ class UniversalRootImpl {
|
|
768
945
|
owner.componentProps = draftOwner2.componentProps;
|
|
769
946
|
owner.componentRevision = draftOwner2.componentRevision;
|
|
770
947
|
owner.hooks = draftOwner2.hooks;
|
|
@@ -772,7 +949,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
772
949
|
for (const [slot, applied] of draftOwner2.appliedUpdates) {
|
|
773
950
|
const queue = owner.updates.get(slot);
|
|
774
951
|
if (queue !== applied.queue || applied.lane) continue;
|
|
775
|
-
@@ -6809,6 +
|
|
952
|
+
@@ -6809,6 +7055,7 @@ class UniversalRootImpl {
|
|
776
953
|
record.componentRevision = draft.componentRevision;
|
|
777
954
|
record.parent = draft.parent?.record ?? null;
|
|
778
955
|
record.hooks = draft.hooks;
|
|
@@ -780,7 +957,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
780
957
|
record.effectOrder = [...draft.seenEffects];
|
|
781
958
|
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
782
959
|
draft.seenEffects[index].previous = null;
|
|
783
|
-
@@ -8455,6 +
|
|
960
|
+
@@ -8455,6 +8702,8 @@ class UniversalRootImpl {
|
|
784
961
|
owner.componentProps = null;
|
|
785
962
|
owner.range = null;
|
|
786
963
|
owner.updates.clear();
|
|
@@ -789,7 +966,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
789
966
|
}
|
|
790
967
|
for (const draft of draftOwnersParentFirst) {
|
|
791
968
|
const record = draft.record;
|
|
792
|
-
@@ -8464,6 +
|
|
969
|
+
@@ -8464,6 +8713,7 @@ class UniversalRootImpl {
|
|
793
970
|
record.parent = draft.parent?.record ?? null;
|
|
794
971
|
}
|
|
795
972
|
record.hooks = draft.hooks;
|
|
@@ -797,7 +974,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
797
974
|
record.effectOrder = [...draft.seenEffects];
|
|
798
975
|
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
799
976
|
draft.seenEffects[index].previous = null;
|
|
800
|
-
@@ -8985,6 +
|
|
977
|
+
@@ -8985,6 +9235,8 @@ class UniversalRootImpl {
|
|
801
978
|
owner.componentProps = null;
|
|
802
979
|
owner.range = null;
|
|
803
980
|
owner.updates.clear();
|
|
@@ -806,6 +983,14 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
806
983
|
}
|
|
807
984
|
const deactivatedRegionCells = /* @__PURE__ */ new Set();
|
|
808
985
|
for (const bridge of regionBridges) {
|
|
986
|
+
@@ -9937,6 +10189,7 @@ function createObjectDriver(renderer = "object") {
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
export {
|
|
990
|
+
+ Children,
|
|
991
|
+
Activity,
|
|
992
|
+
UNIVERSAL_HMR,
|
|
993
|
+
UNIVERSAL_TRANSPORT_PROTOCOL_VERSION,
|
|
809
994
|
diff --git a/dist/node/universal-native.js b/dist/node/universal-native.js
|
|
810
995
|
index 55ac9b640dc8bbfd977bb2cbe0b7993c8ddb425a..3ff9a5750fb59cd91b63299aec3a3e0c030b4579 100644
|
|
811
996
|
--- a/dist/node/universal-native.js
|
|
@@ -1060,8 +1245,30 @@ index 0000000000000000000000000000000000000000..ff5eb43e8f0ddcadbcf8e861f42788b3
|
|
|
1060
1245
|
+ installUniversalSignalDocumentProvider,
|
|
1061
1246
|
+ universalSignalDocument
|
|
1062
1247
|
+};
|
|
1248
|
+
diff --git a/dist/universal-core.d.ts b/dist/universal-core.d.ts
|
|
1249
|
+
index 7e60feece0d3ded5f088bf4e4044516bef588663..3e4cfc19341496009be773b80562476ffd04f2d2 100644
|
|
1250
|
+
--- a/dist/universal-core.d.ts
|
|
1251
|
+
+++ b/dist/universal-core.d.ts
|
|
1252
|
+
@@ -764,9 +764,8 @@ export declare function lazy<C extends UniversalComponent<any>>(load: () => Prom
|
|
1253
|
+
default: C;
|
|
1254
|
+
} | C>): C;
|
|
1255
|
+
export declare function use<T>(usable: UniversalContext<T> | PromiseLike<T>): T;
|
|
1256
|
+
-export declare function useImperativeHandle<T>(ref: {
|
|
1257
|
+
- current: T | null;
|
|
1258
|
+
-} | ((value: T | null) => void) | null, create: () => T, deps?: readonly unknown[] | null, slot?: unknown): void;
|
|
1259
|
+
+type UniversalImperativeRef<T> = { current: T | null } | ((value: T | null) => void | (() => void)) | readonly UniversalImperativeRef<T>[] | null | undefined;
|
|
1260
|
+
+export declare function useImperativeHandle<T>(ref: UniversalImperativeRef<T>, create: () => T, deps?: readonly unknown[] | null, slot?: unknown): void;
|
|
1261
|
+
export declare function useEffectEvent<T extends (...args: any[]) => any>(fn: T, slot?: unknown): T;
|
|
1262
|
+
export declare function useDebugValue(): void;
|
|
1263
|
+
export declare function startTransition(fn: () => void | Promise<unknown>): void;
|
|
1264
|
+
@@ -817,3 +816,5 @@ export interface ObjectHostContainer {
|
|
1265
|
+
}
|
|
1266
|
+
export declare function createObjectContainer(renderer?: string): ObjectHostContainer;
|
|
1267
|
+
export declare function createObjectDriver(renderer?: string): UniversalHostDriver<ObjectHostContainer, ObjectHostInstance>;
|
|
1268
|
+
+
|
|
1269
|
+
+export declare const Children: { toArray(children: UniversalRenderable): UniversalRenderable[]; map(children: UniversalRenderable, fn: (child: UniversalRenderable, index: number) => UniversalRenderable): UniversalRenderable[]; };
|
|
1063
1270
|
diff --git a/dist/universal-core.js b/dist/universal-core.js
|
|
1064
|
-
index 4dbe2f938d039d415b44821bcb3be520172bcada..
|
|
1271
|
+
index 4dbe2f938d039d415b44821bcb3be520172bcada..735a017364cd23bdb8972a04401385f0bde99062 100644
|
|
1065
1272
|
--- a/dist/universal-core.js
|
|
1066
1273
|
+++ b/dist/universal-core.js
|
|
1067
1274
|
@@ -17,6 +17,14 @@ import {
|
|
@@ -1079,7 +1286,141 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1079
1286
|
import { __methodDep } from "./method-dep.js";
|
|
1080
1287
|
const UNIVERSAL_PLAN = /* @__PURE__ */ Symbol.for("octane.universal.plan");
|
|
1081
1288
|
const UNIVERSAL_VALUE = /* @__PURE__ */ Symbol.for("octane.universal.value");
|
|
1082
|
-
@@ -
|
|
1289
|
+
@@ -474,6 +482,133 @@ function universalComponent(renderer, component, props = null, key = NO_KEY) {
|
|
1290
|
+
hasKey: key !== NO_KEY || normalized.hasKey
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
+const NORMALIZED_CHILD_KEYS = new WeakMap();
|
|
1294
|
+
+/** Normalize deferred JSX without mounting components or consuming their context.
|
|
1295
|
+
+ * Structural owners (blocks, providers, boundaries and loops) remain renderables;
|
|
1296
|
+
+ * only transparent child groups, plan ranges, slots and JS arrays are flattened.
|
|
1297
|
+
+ */
|
|
1298
|
+
+function universalChildEntries(children) {
|
|
1299
|
+
+ const out = [];
|
|
1300
|
+
+ const collectionKey = (child) => {
|
|
1301
|
+
+ const key = renderableKey(child);
|
|
1302
|
+
+ if (key !== null)
|
|
1303
|
+
+ return key;
|
|
1304
|
+
+ if (child?.$$kind !== UNIVERSAL_VALUE)
|
|
1305
|
+
+ return null;
|
|
1306
|
+
+ const { plan, values } = child;
|
|
1307
|
+
+ let node = plan.root;
|
|
1308
|
+
+ while (node.kind === 'range' && node.children.length === 1)
|
|
1309
|
+
+ node = node.children[0];
|
|
1310
|
+
+ if (node.kind === 'slot')
|
|
1311
|
+
+ return collectionKey(values[node.slot]);
|
|
1312
|
+
+ if (node.kind !== 'host' && node.kind !== 'component')
|
|
1313
|
+
+ return null;
|
|
1314
|
+
+ if (node.kind === 'component' && node.keySlot !== undefined)
|
|
1315
|
+
+ return normalizeUniversalKey(values[node.keySlot]);
|
|
1316
|
+
+ return normalizeUniversalKey(node.propsSlot === undefined ? node.kind === 'host' ? node.props?.key : null : normalizePropsValue(values[node.propsSlot]).key);
|
|
1317
|
+
+ };
|
|
1318
|
+
+ const visit = (child, path) => {
|
|
1319
|
+
+ if (child == null || typeof child === 'boolean')
|
|
1320
|
+
+ return;
|
|
1321
|
+
+ if (typeof child === 'object') {
|
|
1322
|
+
+ const normalizedKey = NORMALIZED_CHILD_KEYS.get(child);
|
|
1323
|
+
+ if (normalizedKey !== undefined) {
|
|
1324
|
+
+ out.push({ child, key: normalizedKey });
|
|
1325
|
+
+ return;
|
|
1326
|
+
+ }
|
|
1327
|
+
+ }
|
|
1328
|
+
+ if (Array.isArray(child)) {
|
|
1329
|
+
+ child.forEach((item, index) => {
|
|
1330
|
+
+ const key = collectionKey(item);
|
|
1331
|
+
+ visit(item, [...path, key === null ? 'index' : 'key', key ?? index]);
|
|
1332
|
+
+ });
|
|
1333
|
+
+ return;
|
|
1334
|
+
+ }
|
|
1335
|
+
+ if (child?.$$kind === UNIVERSAL_CHILDREN) {
|
|
1336
|
+
+ const children = child;
|
|
1337
|
+
+ if (CURRENT_OWNER !== null && children.renderer !== currentAttempt().root.renderer) {
|
|
1338
|
+
+ throw new Error('Universal renderer mismatch while normalizing children.');
|
|
1339
|
+
+ }
|
|
1340
|
+
+ visit(children.render(), path);
|
|
1341
|
+
+ return;
|
|
1342
|
+
+ }
|
|
1343
|
+
+ if (child?.$$kind === UNIVERSAL_LIST) {
|
|
1344
|
+
+ const list = child;
|
|
1345
|
+
+ visit(list.values.length === 0 ? list.empty : list.values, path);
|
|
1346
|
+
+ return;
|
|
1347
|
+
+ }
|
|
1348
|
+
+ if (child?.$$kind === UNIVERSAL_VALUE) {
|
|
1349
|
+
+ const value = child;
|
|
1350
|
+
+ if (CURRENT_OWNER !== null && value.plan.renderer !== currentAttempt().root.renderer) {
|
|
1351
|
+
+ throw new Error('Universal renderer mismatch while normalizing children.');
|
|
1352
|
+
+ }
|
|
1353
|
+
+ if (value.key !== null) {
|
|
1354
|
+
+ out.push({ child, key: JSON.stringify([...path, 'key', value.key]) });
|
|
1355
|
+
+ return;
|
|
1356
|
+
+ }
|
|
1357
|
+
+ const visitNode = (node, nodePath) => {
|
|
1358
|
+
+ if (node.kind === 'range') {
|
|
1359
|
+
+ node.children.forEach((item, index) => visitNode(item, [...nodePath, index]));
|
|
1360
|
+
+ }
|
|
1361
|
+
+ else if (node.kind === 'slot') {
|
|
1362
|
+
+ visit(value.values[node.slot], nodePath);
|
|
1363
|
+
+ }
|
|
1364
|
+
+ else if (node.kind === 'text') {
|
|
1365
|
+
+ visit((node.slot === undefined ? node.value : value.values[node.slot]), nodePath);
|
|
1366
|
+
+ }
|
|
1367
|
+
+ else {
|
|
1368
|
+
+ const key = node.kind === 'component'
|
|
1369
|
+
+ ? node.keySlot === undefined
|
|
1370
|
+
+ ? node.propsSlot === undefined ? null : normalizePropsValue(value.values[node.propsSlot]).key
|
|
1371
|
+
+ : value.values[node.keySlot]
|
|
1372
|
+
+ : node.kind === 'host'
|
|
1373
|
+
+ ? node.propsSlot === undefined ? node.props?.key ?? null : normalizePropsValue(value.values[node.propsSlot]).key
|
|
1374
|
+
+ : null;
|
|
1375
|
+
+ const item = universalValue(universalPlan(value.plan.renderer, node), value.values);
|
|
1376
|
+
+ out.push({ child: item, key: JSON.stringify(key == null ? nodePath : [...(node === value.plan.root ? path : nodePath.slice(0, -1)), 'key', key]) });
|
|
1377
|
+
+ }
|
|
1378
|
+
+ };
|
|
1379
|
+
+ visitNode(value.plan.root, path);
|
|
1380
|
+
+ return;
|
|
1381
|
+
+ }
|
|
1382
|
+
+ const key = renderableKey(child);
|
|
1383
|
+
+ out.push({ child, key: JSON.stringify(key === null ? path : [...path, 'key', key]) });
|
|
1384
|
+
+ };
|
|
1385
|
+
+ visit(children, []);
|
|
1386
|
+
+ return out;
|
|
1387
|
+
+}
|
|
1388
|
+
+/** Renderer-supported child collection operations. They never render a component
|
|
1389
|
+
+ * to discover its output. Returned entries retain their keys when mapped into
|
|
1390
|
+
+ * wrapper hosts, and are materialized normally at their eventual placement.
|
|
1391
|
+
+ */
|
|
1392
|
+
+function normalizedChild(key, child) {
|
|
1393
|
+
+ const value = universalKey(key, child);
|
|
1394
|
+
+ NORMALIZED_CHILD_KEYS.set(value, key);
|
|
1395
|
+
+ return value;
|
|
1396
|
+
+}
|
|
1397
|
+
+const Children = {
|
|
1398
|
+
+ toArray(children) {
|
|
1399
|
+
+ return universalChildEntries(children).map(({ child, key }) => typeof child === 'object' ? normalizedChild(key, child) : child);
|
|
1400
|
+
+ },
|
|
1401
|
+
+ map(children, fn) {
|
|
1402
|
+
+ const out = [];
|
|
1403
|
+
+ universalChildEntries(children).forEach(({ child, key }, index) => {
|
|
1404
|
+
+ const mapped = fn(child, index);
|
|
1405
|
+
+ if (mapped == null || typeof mapped === 'boolean')
|
|
1406
|
+
+ return;
|
|
1407
|
+
+ if (Array.isArray(mapped)) {
|
|
1408
|
+
+ for (const entry of universalChildEntries(mapped)) {
|
|
1409
|
+
+ out.push(normalizedChild(JSON.stringify([key, entry.key]), entry.child));
|
|
1410
|
+
+ }
|
|
1411
|
+
+ }
|
|
1412
|
+
+ else {
|
|
1413
|
+
+ out.push(normalizedChild(key, mapped));
|
|
1414
|
+
+ }
|
|
1415
|
+
+ });
|
|
1416
|
+
+ return out;
|
|
1417
|
+
+ },
|
|
1418
|
+
+};
|
|
1419
|
+
+
|
|
1420
|
+
function universalChildren(renderer, render) {
|
|
1421
|
+
assertRendererId(renderer, "universalChildren renderer");
|
|
1422
|
+
if (typeof render !== "function") throw new TypeError("universalChildren expected a function.");
|
|
1423
|
+
@@ -842,6 +977,7 @@ function draftOwner(record, parent, replayPath) {
|
|
1083
1424
|
boundaryThenable: record.boundaryThenable,
|
|
1084
1425
|
isBoundary: record.isBoundary,
|
|
1085
1426
|
canHandleSuspense: record.canHandleSuspense,
|
|
@@ -1087,7 +1428,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1087
1428
|
visibility: parent?.visibility ?? record.visibility,
|
|
1088
1429
|
contextStable: null
|
|
1089
1430
|
};
|
|
1090
|
-
@@ -1012,6 +
|
|
1431
|
+
@@ -1012,6 +1148,7 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
1091
1432
|
owner.contextStable = null;
|
|
1092
1433
|
owner.needsRender = false;
|
|
1093
1434
|
owner.implicitSlot = 0;
|
|
@@ -1095,7 +1436,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1095
1436
|
const previousOwner = CURRENT_OWNER;
|
|
1096
1437
|
const previousAttemptOwner = attempt.owner;
|
|
1097
1438
|
CURRENT_OWNER = owner;
|
|
1098
|
-
@@ -1023,13 +
|
|
1439
|
+
@@ -1023,13 +1160,18 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
1099
1440
|
const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && component !== null ? __profileBeginRender(owner.record, component, owner.record.mounted) : null;
|
|
1100
1441
|
let didThrow = false;
|
|
1101
1442
|
let thrown;
|
|
@@ -1117,7 +1458,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1117
1458
|
if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
|
|
1118
1459
|
__profileEndRender(profileFrame, didThrow, thrown);
|
|
1119
1460
|
}
|
|
1120
|
-
@@ -1196,6 +
|
|
1461
|
+
@@ -1196,6 +1338,8 @@ function disposeUncommittedDraft(owner) {
|
|
1121
1462
|
owner.record.componentProps = null;
|
|
1122
1463
|
owner.record.range = null;
|
|
1123
1464
|
owner.record.updates.clear();
|
|
@@ -1126,7 +1467,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1126
1467
|
for (const hook of owner.hooks.values()) {
|
|
1127
1468
|
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
1128
1469
|
}
|
|
1129
|
-
@@ -3142,6 +
|
|
1470
|
+
@@ -3142,6 +3286,85 @@ function scheduleOwner(owner, slot) {
|
|
1130
1471
|
}
|
|
1131
1472
|
owner.root.scheduleOwned(owner);
|
|
1132
1473
|
}
|
|
@@ -1212,7 +1553,50 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1212
1553
|
function currentDraftOwner() {
|
|
1213
1554
|
currentAttempt();
|
|
1214
1555
|
const owner = activateLazyLeafOwner();
|
|
1215
|
-
@@ -
|
|
1556
|
+
@@ -4142,15 +4365,35 @@ function use(usable) {
|
|
1557
|
+
function useImperativeHandle(ref, create, deps, slot) {
|
|
1558
|
+
useLayoutEffect(
|
|
1559
|
+
() => {
|
|
1560
|
+
- const value = create();
|
|
1561
|
+
- if (typeof ref === "function") ref(value);
|
|
1562
|
+
- else if (ref !== null) ref.current = value;
|
|
1563
|
+
- return () => {
|
|
1564
|
+
- if (typeof ref === "function") ref(null);
|
|
1565
|
+
- else if (ref !== null) ref.current = null;
|
|
1566
|
+
+ const cleanups = [];
|
|
1567
|
+
+ let value;
|
|
1568
|
+
+ let initialized = false;
|
|
1569
|
+
+ const attach = (target) => {
|
|
1570
|
+
+ if (target == null) return;
|
|
1571
|
+
+ if (Array.isArray(target)) {
|
|
1572
|
+
+ for (const entry of target) attach(entry);
|
|
1573
|
+
+ return;
|
|
1574
|
+
+ }
|
|
1575
|
+
+ if (!initialized) {
|
|
1576
|
+
+ value = create();
|
|
1577
|
+
+ initialized = true;
|
|
1578
|
+
+ }
|
|
1579
|
+
+ if (typeof target === "function") {
|
|
1580
|
+
+ const cleanup = target(value);
|
|
1581
|
+
+ cleanups.push(typeof cleanup === "function" ? cleanup : () => target(null));
|
|
1582
|
+
+ } else {
|
|
1583
|
+
+ target.current = value;
|
|
1584
|
+
+ cleanups.push(() => { target.current = null; });
|
|
1585
|
+
+ }
|
|
1586
|
+
};
|
|
1587
|
+
+ try {
|
|
1588
|
+
+ attach(ref);
|
|
1589
|
+
+ } catch (error) {
|
|
1590
|
+
+ try { runCommitTasks(cleanups); } finally { throw error; }
|
|
1591
|
+
+ }
|
|
1592
|
+
+ return () => runCommitTasks(cleanups);
|
|
1593
|
+
},
|
|
1594
|
+
- deps,
|
|
1595
|
+
+ deps == null ? deps : [...deps, ref],
|
|
1596
|
+
slot
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
@@ -5520,9 +5763,9 @@ class UniversalRootImpl {
|
|
1216
1600
|
}
|
|
1217
1601
|
let result;
|
|
1218
1602
|
try {
|
|
@@ -1224,7 +1608,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1224
1608
|
}
|
|
1225
1609
|
return result;
|
|
1226
1610
|
}
|
|
1227
|
-
@@ -6096,6 +
|
|
1611
|
+
@@ -6096,6 +6339,8 @@ class UniversalRootImpl {
|
|
1228
1612
|
draft.record.componentProps = null;
|
|
1229
1613
|
draft.record.range = null;
|
|
1230
1614
|
draft.record.updates.clear();
|
|
@@ -1233,7 +1617,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1233
1617
|
for (const hook of draft.hooks.values()) {
|
|
1234
1618
|
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
1235
1619
|
}
|
|
1236
|
-
@@ -6776,6 +
|
|
1620
|
+
@@ -6776,6 +7021,7 @@ class UniversalRootImpl {
|
|
1237
1621
|
owner.componentProps = draftOwner2.componentProps;
|
|
1238
1622
|
owner.componentRevision = draftOwner2.componentRevision;
|
|
1239
1623
|
owner.hooks = draftOwner2.hooks;
|
|
@@ -1241,7 +1625,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1241
1625
|
for (const [slot, applied] of draftOwner2.appliedUpdates) {
|
|
1242
1626
|
const queue = owner.updates.get(slot);
|
|
1243
1627
|
if (queue !== applied.queue || applied.lane) continue;
|
|
1244
|
-
@@ -6809,6 +
|
|
1628
|
+
@@ -6809,6 +7055,7 @@ class UniversalRootImpl {
|
|
1245
1629
|
record.componentRevision = draft.componentRevision;
|
|
1246
1630
|
record.parent = draft.parent?.record ?? null;
|
|
1247
1631
|
record.hooks = draft.hooks;
|
|
@@ -1249,7 +1633,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1249
1633
|
record.effectOrder = [...draft.seenEffects];
|
|
1250
1634
|
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
1251
1635
|
draft.seenEffects[index].previous = null;
|
|
1252
|
-
@@ -8455,6 +
|
|
1636
|
+
@@ -8455,6 +8702,8 @@ class UniversalRootImpl {
|
|
1253
1637
|
owner.componentProps = null;
|
|
1254
1638
|
owner.range = null;
|
|
1255
1639
|
owner.updates.clear();
|
|
@@ -1258,7 +1642,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1258
1642
|
}
|
|
1259
1643
|
for (const draft of draftOwnersParentFirst) {
|
|
1260
1644
|
const record = draft.record;
|
|
1261
|
-
@@ -8464,6 +
|
|
1645
|
+
@@ -8464,6 +8713,7 @@ class UniversalRootImpl {
|
|
1262
1646
|
record.parent = draft.parent?.record ?? null;
|
|
1263
1647
|
}
|
|
1264
1648
|
record.hooks = draft.hooks;
|
|
@@ -1266,7 +1650,7 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1266
1650
|
record.effectOrder = [...draft.seenEffects];
|
|
1267
1651
|
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
1268
1652
|
draft.seenEffects[index].previous = null;
|
|
1269
|
-
@@ -8985,6 +
|
|
1653
|
+
@@ -8985,6 +9235,8 @@ class UniversalRootImpl {
|
|
1270
1654
|
owner.componentProps = null;
|
|
1271
1655
|
owner.range = null;
|
|
1272
1656
|
owner.updates.clear();
|
|
@@ -1275,6 +1659,14 @@ index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac1
|
|
|
1275
1659
|
}
|
|
1276
1660
|
const deactivatedRegionCells = /* @__PURE__ */ new Set();
|
|
1277
1661
|
for (const bridge of regionBridges) {
|
|
1662
|
+
@@ -9937,6 +10189,7 @@ function createObjectDriver(renderer = "object") {
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
export {
|
|
1666
|
+
+ Children,
|
|
1667
|
+
Activity,
|
|
1668
|
+
UNIVERSAL_HMR,
|
|
1669
|
+
UNIVERSAL_TRANSPORT_PROTOCOL_VERSION,
|
|
1278
1670
|
diff --git a/dist/universal-native.js b/dist/universal-native.js
|
|
1279
1671
|
index 55ac9b640dc8bbfd977bb2cbe0b7993c8ddb425a..3ff9a5750fb59cd91b63299aec3a3e0c030b4579 100644
|
|
1280
1672
|
--- a/dist/universal-native.js
|