@oxyhq/bloom 1.6.0 → 1.8.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/NOTICE +46 -0
- package/docs/media-flight.mdx +151 -3
- package/docs/teleport.mdx +72 -0
- package/lib/commonjs/media-flight/MediaFlightLayer.js +4 -5
- package/lib/commonjs/media-flight/MediaFlightLayer.js.map +1 -1
- package/lib/commonjs/media-flight/media-node.web.js +37 -1
- package/lib/commonjs/media-flight/media-node.web.js.map +1 -1
- package/lib/commonjs/teleport/Portal.js +109 -0
- package/lib/commonjs/teleport/Portal.js.map +1 -0
- package/lib/commonjs/teleport/PortalHost.js +75 -0
- package/lib/commonjs/teleport/PortalHost.js.map +1 -0
- package/lib/commonjs/teleport/PortalHostView.js +40 -0
- package/lib/commonjs/teleport/PortalHostView.js.map +1 -0
- package/lib/commonjs/teleport/PortalHostView.native.js +24 -0
- package/lib/commonjs/teleport/PortalHostView.native.js.map +1 -0
- package/lib/commonjs/teleport/PortalProvider.js +57 -0
- package/lib/commonjs/teleport/PortalProvider.js.map +1 -0
- package/lib/commonjs/teleport/PortalProviderView.js +59 -0
- package/lib/commonjs/teleport/PortalProviderView.js.map +1 -0
- package/lib/commonjs/teleport/PortalProviderView.native.js +19 -0
- package/lib/commonjs/teleport/PortalProviderView.native.js.map +1 -0
- package/lib/commonjs/teleport/PortalView.js +83 -0
- package/lib/commonjs/teleport/PortalView.js.map +1 -0
- package/lib/commonjs/teleport/PortalView.native.js +14 -0
- package/lib/commonjs/teleport/PortalView.native.js.map +1 -0
- package/lib/commonjs/teleport/index.js +35 -0
- package/lib/commonjs/teleport/index.js.map +1 -0
- package/lib/commonjs/teleport/portal-manager.js +40 -0
- package/lib/commonjs/teleport/portal-manager.js.map +1 -0
- package/lib/commonjs/teleport/portal-registry.js +24 -0
- package/lib/commonjs/teleport/portal-registry.js.map +1 -0
- package/lib/commonjs/teleport/reducer.js +86 -0
- package/lib/commonjs/teleport/reducer.js.map +1 -0
- package/lib/commonjs/teleport/scroll-view-context/context.js +17 -0
- package/lib/commonjs/teleport/scroll-view-context/context.js.map +1 -0
- package/lib/commonjs/teleport/scroll-view-context/context.native.js +22 -0
- package/lib/commonjs/teleport/scroll-view-context/context.native.js.map +1 -0
- package/lib/commonjs/teleport/scroll-view-context/types.js +2 -0
- package/lib/commonjs/teleport/scroll-view-context/types.js.map +1 -0
- package/lib/commonjs/teleport/specs/PortalHostViewNativeComponent.js +17 -0
- package/lib/commonjs/teleport/specs/PortalHostViewNativeComponent.js.map +1 -0
- package/lib/commonjs/teleport/specs/PortalViewNativeComponent.js +17 -0
- package/lib/commonjs/teleport/specs/PortalViewNativeComponent.js.map +1 -0
- package/lib/commonjs/teleport/teleport-global.d.js +2 -0
- package/lib/commonjs/teleport/teleport-global.d.js.map +1 -0
- package/lib/commonjs/teleport/types.js +6 -0
- package/lib/commonjs/teleport/types.js.map +1 -0
- package/lib/commonjs/teleport/use-id.js +24 -0
- package/lib/commonjs/teleport/use-id.js.map +1 -0
- package/lib/commonjs/teleport/use-portal.js +59 -0
- package/lib/commonjs/teleport/use-portal.js.map +1 -0
- package/lib/module/media-flight/MediaFlightLayer.js +4 -5
- package/lib/module/media-flight/MediaFlightLayer.js.map +1 -1
- package/lib/module/media-flight/media-node.web.js +37 -1
- package/lib/module/media-flight/media-node.web.js.map +1 -1
- package/lib/module/teleport/Portal.js +103 -0
- package/lib/module/teleport/Portal.js.map +1 -0
- package/lib/module/teleport/PortalHost.js +71 -0
- package/lib/module/teleport/PortalHost.js.map +1 -0
- package/lib/module/teleport/PortalHostView.js +35 -0
- package/lib/module/teleport/PortalHostView.js.map +1 -0
- package/lib/module/teleport/PortalHostView.native.js +18 -0
- package/lib/module/teleport/PortalHostView.native.js.map +1 -0
- package/lib/module/teleport/PortalProvider.js +51 -0
- package/lib/module/teleport/PortalProvider.js.map +1 -0
- package/lib/module/teleport/PortalProviderView.js +54 -0
- package/lib/module/teleport/PortalProviderView.js.map +1 -0
- package/lib/module/teleport/PortalProviderView.native.js +15 -0
- package/lib/module/teleport/PortalProviderView.native.js.map +1 -0
- package/lib/module/teleport/PortalView.js +79 -0
- package/lib/module/teleport/PortalView.js.map +1 -0
- package/lib/module/teleport/PortalView.native.js +10 -0
- package/lib/module/teleport/PortalView.native.js.map +1 -0
- package/lib/module/teleport/index.js +30 -0
- package/lib/module/teleport/index.js.map +1 -0
- package/lib/module/teleport/portal-manager.js +33 -0
- package/lib/module/teleport/portal-manager.js.map +1 -0
- package/lib/module/teleport/portal-registry.js +18 -0
- package/lib/module/teleport/portal-registry.js.map +1 -0
- package/lib/module/teleport/reducer.js +81 -0
- package/lib/module/teleport/reducer.js.map +1 -0
- package/lib/module/teleport/scroll-view-context/context.js +12 -0
- package/lib/module/teleport/scroll-view-context/context.js.map +1 -0
- package/lib/module/teleport/scroll-view-context/context.native.js +18 -0
- package/lib/module/teleport/scroll-view-context/context.native.js.map +1 -0
- package/lib/module/teleport/scroll-view-context/types.js +2 -0
- package/lib/module/teleport/scroll-view-context/types.js.map +1 -0
- package/lib/module/teleport/specs/PortalHostViewNativeComponent.js +13 -0
- package/lib/module/teleport/specs/PortalHostViewNativeComponent.js.map +1 -0
- package/lib/module/teleport/specs/PortalViewNativeComponent.js +13 -0
- package/lib/module/teleport/specs/PortalViewNativeComponent.js.map +1 -0
- package/lib/module/teleport/teleport-global.d.js +2 -0
- package/lib/module/teleport/teleport-global.d.js.map +1 -0
- package/lib/module/teleport/types.js +4 -0
- package/lib/module/teleport/types.js.map +1 -0
- package/lib/module/teleport/use-id.js +19 -0
- package/lib/module/teleport/use-id.js.map +1 -0
- package/lib/module/teleport/use-portal.js +55 -0
- package/lib/module/teleport/use-portal.js.map +1 -0
- package/lib/typescript/commonjs/media-flight/MediaFlightLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-flight/media-node.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/teleport/Portal.d.ts +48 -0
- package/lib/typescript/commonjs/teleport/Portal.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalHost.d.ts +25 -0
- package/lib/typescript/commonjs/teleport/PortalHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.d.ts +5 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.native.d.ts +4 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalProvider.d.ts +23 -0
- package/lib/typescript/commonjs/teleport/PortalProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.d.ts +3 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.native.d.ts +9 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalView.d.ts +9 -0
- package/lib/typescript/commonjs/teleport/PortalView.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalView.native.d.ts +8 -0
- package/lib/typescript/commonjs/teleport/PortalView.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/index.d.ts +29 -0
- package/lib/typescript/commonjs/teleport/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/portal-manager.d.ts +16 -0
- package/lib/typescript/commonjs/teleport/portal-manager.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/portal-registry.d.ts +10 -0
- package/lib/typescript/commonjs/teleport/portal-registry.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/reducer.d.ts +40 -0
- package/lib/typescript/commonjs/teleport/reducer.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.d.ts +4 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.native.d.ts +13 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/types.d.ts +10 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/specs/PortalHostViewNativeComponent.d.ts +13 -0
- package/lib/typescript/commonjs/teleport/specs/PortalHostViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/specs/PortalViewNativeComponent.d.ts +14 -0
- package/lib/typescript/commonjs/teleport/specs/PortalViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/types.d.ts +22 -0
- package/lib/typescript/commonjs/teleport/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/use-id.d.ts +2 -0
- package/lib/typescript/commonjs/teleport/use-id.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/use-portal.d.ts +35 -0
- package/lib/typescript/commonjs/teleport/use-portal.d.ts.map +1 -0
- package/lib/typescript/module/media-flight/MediaFlightLayer.d.ts.map +1 -1
- package/lib/typescript/module/media-flight/media-node.web.d.ts.map +1 -1
- package/lib/typescript/module/teleport/Portal.d.ts +48 -0
- package/lib/typescript/module/teleport/Portal.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalHost.d.ts +25 -0
- package/lib/typescript/module/teleport/PortalHost.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalHostView.d.ts +5 -0
- package/lib/typescript/module/teleport/PortalHostView.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalHostView.native.d.ts +4 -0
- package/lib/typescript/module/teleport/PortalHostView.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalProvider.d.ts +23 -0
- package/lib/typescript/module/teleport/PortalProvider.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalProviderView.d.ts +3 -0
- package/lib/typescript/module/teleport/PortalProviderView.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalProviderView.native.d.ts +9 -0
- package/lib/typescript/module/teleport/PortalProviderView.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalView.d.ts +9 -0
- package/lib/typescript/module/teleport/PortalView.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalView.native.d.ts +8 -0
- package/lib/typescript/module/teleport/PortalView.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/index.d.ts +29 -0
- package/lib/typescript/module/teleport/index.d.ts.map +1 -0
- package/lib/typescript/module/teleport/portal-manager.d.ts +16 -0
- package/lib/typescript/module/teleport/portal-manager.d.ts.map +1 -0
- package/lib/typescript/module/teleport/portal-registry.d.ts +10 -0
- package/lib/typescript/module/teleport/portal-registry.d.ts.map +1 -0
- package/lib/typescript/module/teleport/reducer.d.ts +40 -0
- package/lib/typescript/module/teleport/reducer.d.ts.map +1 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.d.ts +4 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.d.ts.map +1 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.native.d.ts +13 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/scroll-view-context/types.d.ts +10 -0
- package/lib/typescript/module/teleport/scroll-view-context/types.d.ts.map +1 -0
- package/lib/typescript/module/teleport/specs/PortalHostViewNativeComponent.d.ts +13 -0
- package/lib/typescript/module/teleport/specs/PortalHostViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/teleport/specs/PortalViewNativeComponent.d.ts +14 -0
- package/lib/typescript/module/teleport/specs/PortalViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/teleport/types.d.ts +22 -0
- package/lib/typescript/module/teleport/types.d.ts.map +1 -0
- package/lib/typescript/module/teleport/use-id.d.ts +2 -0
- package/lib/typescript/module/teleport/use-id.d.ts.map +1 -0
- package/lib/typescript/module/teleport/use-portal.d.ts +35 -0
- package/lib/typescript/module/teleport/use-portal.d.ts.map +1 -0
- package/package.json +16 -1
- package/src/media-flight/MediaFlightLayer.tsx +4 -5
- package/src/media-flight/media-node.web.ts +42 -1
- package/src/teleport/Portal.tsx +97 -0
- package/src/teleport/PortalHost.tsx +61 -0
- package/src/teleport/PortalHostView.native.tsx +14 -0
- package/src/teleport/PortalHostView.tsx +30 -0
- package/src/teleport/PortalProvider.tsx +51 -0
- package/src/teleport/PortalProviderView.native.tsx +11 -0
- package/src/teleport/PortalProviderView.tsx +67 -0
- package/src/teleport/PortalView.native.tsx +7 -0
- package/src/teleport/PortalView.tsx +94 -0
- package/src/teleport/index.ts +32 -0
- package/src/teleport/portal-manager.tsx +48 -0
- package/src/teleport/portal-registry.ts +27 -0
- package/src/teleport/reducer.ts +94 -0
- package/src/teleport/scroll-view-context/context.native.ts +19 -0
- package/src/teleport/scroll-view-context/context.ts +12 -0
- package/src/teleport/scroll-view-context/types.ts +7 -0
- package/src/teleport/specs/PortalHostViewNativeComponent.ts +15 -0
- package/src/teleport/specs/PortalViewNativeComponent.ts +16 -0
- package/src/teleport/teleport-global.d.ts +11 -0
- package/src/teleport/types.ts +22 -0
- package/src/teleport/use-id.ts +18 -0
- package/src/teleport/use-portal.ts +47 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/state/reducer.ts`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
6
|
+
*/
|
|
7
|
+
import type { ScrollViewContextValue } from "./scroll-view-context/types";
|
|
8
|
+
export type PortalState = {
|
|
9
|
+
removed: Record<string, Record<string, Record<string, boolean>>>;
|
|
10
|
+
hosts: Record<string, number>;
|
|
11
|
+
hostScrollViewContexts: Record<string, ScrollViewContextValue | undefined>;
|
|
12
|
+
};
|
|
13
|
+
export type Action = {
|
|
14
|
+
type: "REMOVE_PORTAL";
|
|
15
|
+
hostName: string;
|
|
16
|
+
name: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "CLEAR_REMOVED_ON_UNMOUNT";
|
|
19
|
+
hostName: string;
|
|
20
|
+
name: string;
|
|
21
|
+
instanceId: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: "REGISTER_PORTAL";
|
|
24
|
+
hostName: string;
|
|
25
|
+
name: string;
|
|
26
|
+
instanceId: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "REGISTER_HOST";
|
|
29
|
+
hostName: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "UNREGISTER_HOST";
|
|
32
|
+
hostName: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "SET_HOST_SCROLL_VIEW_CONTEXT";
|
|
35
|
+
hostName: string;
|
|
36
|
+
value: ScrollViewContextValue;
|
|
37
|
+
};
|
|
38
|
+
export declare const initialState: PortalState;
|
|
39
|
+
export declare const reducer: (state: PortalState, action: Action) => PortalState;
|
|
40
|
+
//# sourceMappingURL=reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/teleport/reducer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzD;IACE,IAAI,EAAE,0BAA0B,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,GACD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC7C;IACE,IAAI,EAAE,8BAA8B,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,sBAAsB,CAAC;CAC/B,CAAC;AAEN,eAAO,MAAM,YAAY,EAAE,WAI1B,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,OAAO,WAAW,EAAE,QAAQ,MAAM,KAAG,WAmD5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/teleport/scroll-view-context/context.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,QAAA,MAAM,iBAAiB,iDAA8C,CAAC;AAEtE,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/contexts/ScrollViewContext/index.native.ts`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths, and `ScrollView.Context` is reached through a cast
|
|
6
|
+
* because Bloom does not compile with their `react-native-strict-api` condition,
|
|
7
|
+
* which is the only place that property is declared.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from "react";
|
|
10
|
+
import type { ScrollViewContextValue } from "./types";
|
|
11
|
+
declare const ScrollViewContext: Context<ScrollViewContextValue>;
|
|
12
|
+
export default ScrollViewContext;
|
|
13
|
+
//# sourceMappingURL=context.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.native.d.ts","sourceRoot":"","sources":["../../../../../src/teleport/scroll-view-context/context.native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAKtD,QAAA,MAAM,iBAAiB,iCACb,CAAC;AAEX,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/contexts/ScrollViewContext/types.ts`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
6
|
+
*/
|
|
7
|
+
export type ScrollViewContextValue = {
|
|
8
|
+
horizontal: boolean;
|
|
9
|
+
} | null;
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/teleport/scroll-view-context/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/specs/PortalHostViewNativeComponent.ts`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
6
|
+
*/
|
|
7
|
+
import { type ViewProps } from "react-native";
|
|
8
|
+
interface NativeProps extends ViewProps {
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import("react-native").HostComponent<NativeProps>;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=PortalHostViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PortalHostViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../../src/teleport/specs/PortalHostViewNativeComponent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,UAAU,WAAY,SAAQ,SAAS;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;;AAED,wBAEG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/specs/PortalViewNativeComponent.ts`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
6
|
+
*/
|
|
7
|
+
import { type ViewProps } from "react-native";
|
|
8
|
+
interface NativeProps extends ViewProps {
|
|
9
|
+
name?: string;
|
|
10
|
+
hostName?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react-native").HostComponent<NativeProps>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=PortalViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PortalViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../../src/teleport/specs/PortalViewNativeComponent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,UAAU,WAAY,SAAQ,SAAS;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;;AAED,wBAEG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/types/index.ts`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
6
|
+
*/
|
|
7
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
8
|
+
export type PortalProviderProps = {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export type PortalHostProps = {
|
|
12
|
+
name: string;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
export type PortalProps = {
|
|
17
|
+
name?: string;
|
|
18
|
+
hostName?: string;
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/teleport/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-id.d.ts","sourceRoot":"","sources":["../../../../src/teleport/use-id.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,MAAM,SAAQ,GAAG,MAAM,CAOpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `usePortal` hook allows you to manage portals in imperative way.
|
|
3
|
+
*
|
|
4
|
+
* @category hooks
|
|
5
|
+
* @param `hostName` - `name` of the `<PortalHost />` component
|
|
6
|
+
* @returns an object that helps to manipulate portals
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { usePortal } from "react-native-teleport";
|
|
10
|
+
* export default function App() {
|
|
11
|
+
* const { removePortal, isHostAvailable } = usePortal("root");
|
|
12
|
+
* return (
|
|
13
|
+
* <View style={{ flex: 1 }}>
|
|
14
|
+
* <Text>{isHostAvailable ? "Host is available" : "Host is not available"}</Text>
|
|
15
|
+
* <Button title="Remove" onPress={() => removePortal("portal")} />
|
|
16
|
+
* </View>
|
|
17
|
+
* );
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export default function usePortal(hostName?: string): {
|
|
22
|
+
/**
|
|
23
|
+
* Whether a `<PortalHost />` with the given `hostName` is currently mounted.
|
|
24
|
+
*/
|
|
25
|
+
isHostAvailable: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Remove portal from host container. Subsequent re-renders will not restore portal,
|
|
28
|
+
* but if you mount a new portal with the same name it will be shown (i. e. hook doesn't
|
|
29
|
+
* prevent new portal from being added).
|
|
30
|
+
*
|
|
31
|
+
* @param name - `name` of `<Portal />` component.
|
|
32
|
+
*/
|
|
33
|
+
removePortal: (name: string) => void;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=use-portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-portal.d.ts","sourceRoot":"","sources":["../../../../src/teleport/use-portal.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,GAAE,MAAe;IAIvD;;OAEG;;IAEH;;;;;;OAMG;yBACkB,MAAM;EAG9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/bloom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"packageManager": "bun@1.3.14",
|
|
5
5
|
"description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
|
@@ -624,6 +624,20 @@
|
|
|
624
624
|
"default": "./lib/commonjs/media-flight/index.js"
|
|
625
625
|
}
|
|
626
626
|
},
|
|
627
|
+
"./teleport": {
|
|
628
|
+
"react-native": {
|
|
629
|
+
"types": "./lib/typescript/module/teleport/index.d.ts",
|
|
630
|
+
"default": "./src/teleport/index.ts"
|
|
631
|
+
},
|
|
632
|
+
"import": {
|
|
633
|
+
"types": "./lib/typescript/module/teleport/index.d.ts",
|
|
634
|
+
"default": "./lib/module/teleport/index.js"
|
|
635
|
+
},
|
|
636
|
+
"require": {
|
|
637
|
+
"types": "./lib/typescript/commonjs/teleport/index.d.ts",
|
|
638
|
+
"default": "./lib/commonjs/teleport/index.js"
|
|
639
|
+
}
|
|
640
|
+
},
|
|
627
641
|
"./pressable-scale": {
|
|
628
642
|
"react-native": {
|
|
629
643
|
"types": "./lib/typescript/module/pressable-scale/index.d.ts",
|
|
@@ -1457,6 +1471,7 @@
|
|
|
1457
1471
|
"./package.json": "./package.json"
|
|
1458
1472
|
},
|
|
1459
1473
|
"files": [
|
|
1474
|
+
"NOTICE",
|
|
1460
1475
|
"src",
|
|
1461
1476
|
"lib",
|
|
1462
1477
|
"docs/*.mdx",
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* ## The problem it exists for
|
|
5
5
|
*
|
|
6
6
|
* A shared-element transition normally assumes the ORIGIN screen is still
|
|
7
|
-
* mounted while the element travels
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* before the first frame of the transition.
|
|
7
|
+
* mounted while the element travels. Under expo-router on web the origin route
|
|
8
|
+
* is UNMOUNTED the moment the URL changes, so anything the origin was rendering
|
|
9
|
+
* (a `VideoView`, a decoded image) is gone before the first frame of the
|
|
10
|
+
* transition.
|
|
12
11
|
*
|
|
13
12
|
* The fix is to move the surface OUT of both screens for the duration of the
|
|
14
13
|
* flight. `<MediaFlightLayer>` is mounted ONCE at the app root and renders
|
|
@@ -225,6 +225,47 @@ function pick(claims: readonly MediaNodeClaim[]): MediaNodeClaim | null {
|
|
|
225
225
|
return best;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* An element that can be MOVED rather than removed and re-inserted.
|
|
230
|
+
*
|
|
231
|
+
* `moveBefore` is newer than TypeScript's DOM library, so the capability is
|
|
232
|
+
* named here and checked at runtime rather than assumed.
|
|
233
|
+
*/
|
|
234
|
+
interface MovingParent {
|
|
235
|
+
moveBefore(node: Node, child: Node | null): void;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* DERIVED FROM react-native-teleport 1.2.0 — `src/views/Portal/index.tsx`,
|
|
240
|
+
* its `moveElementTo`. MIT, Copyright (c) 2025 Kiryl Ziusko; see `NOTICE`.
|
|
241
|
+
*
|
|
242
|
+
* Changed: typed for TypeScript's DOM library, which does not know `moveBefore`
|
|
243
|
+
* yet, and reduced to the append case Bloom needs (no `before` sibling).
|
|
244
|
+
*
|
|
245
|
+
* Why it is worth taking rather than keeping `appendChild`: `appendChild` of an
|
|
246
|
+
* ATTACHED node is a remove followed by an insert, and the only reason media
|
|
247
|
+
* survives it is that HTML's removal steps await a stable state and abort if
|
|
248
|
+
* the node is back in a document by then. `moveBefore` does not run the removal
|
|
249
|
+
* steps at all — it is the state-preserving primitive, which matters for
|
|
250
|
+
* anything the abort does not cover: focus, `<iframe>`s, CSS animations.
|
|
251
|
+
*
|
|
252
|
+
* Measured for a playing `<video>` in Chrome 151: indistinguishable from
|
|
253
|
+
* `appendChild` (ct 0.60 -> 1.00, never paused, 6 frames, worst frame gap
|
|
254
|
+
* 100 ms — the clip's own cadence — under both), while a real removal pauses
|
|
255
|
+
* and freezes. So this is not a fix for a defect Bloom has; it is the correct
|
|
256
|
+
* primitive for the ones it does not have yet.
|
|
257
|
+
*/
|
|
258
|
+
function moveInto(parent: HTMLElement, child: HTMLElement): void {
|
|
259
|
+
if (supportsMoveBefore && child.parentNode !== null) {
|
|
260
|
+
(parent as unknown as MovingParent).moveBefore(child, null);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
parent.appendChild(child);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const supportsMoveBefore =
|
|
267
|
+
typeof Element !== 'undefined' && 'moveBefore' in Element.prototype;
|
|
268
|
+
|
|
228
269
|
/**
|
|
229
270
|
* Put the wrapper where its top claim says, in ONE synchronous move.
|
|
230
271
|
*
|
|
@@ -237,7 +278,7 @@ function place(record: MediaNodeRecord): void {
|
|
|
237
278
|
const target = topClaim(record)?.el ?? holder(reg);
|
|
238
279
|
if (target === null) return;
|
|
239
280
|
if (record.wrapper.parentElement === target) return;
|
|
240
|
-
target
|
|
281
|
+
moveInto(target, record.wrapper);
|
|
241
282
|
}
|
|
242
283
|
|
|
243
284
|
function sameRender(a: MediaNodeRender, b: MediaNodeRender): boolean {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/components/Portal.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
import { useContext, useEffect } from "react";
|
|
8
|
+
import { usePortalManagerContext } from "./portal-manager";
|
|
9
|
+
import ScrollViewContext from "./scroll-view-context/context";
|
|
10
|
+
import PortalView from "./PortalView";
|
|
11
|
+
import useId from "./use-id";
|
|
12
|
+
import type { PortalProps } from "./types";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Portal helps you to render a component in a different place in the view hierarchy.
|
|
16
|
+
* This is useful when you need a view to visually “break out” of its parent container (for example: modals, toasts, floating UI, popovers).
|
|
17
|
+
*
|
|
18
|
+
* @category components
|
|
19
|
+
* @param hostName - The `name` of the `PortalHost`. It's used to identify the host where the content should be rendered.
|
|
20
|
+
* @param name - The name of the portal. It's used to identify the portal.
|
|
21
|
+
* @param children - The content that should be rendered in the portal.
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { useState } from "react";
|
|
25
|
+
* import { View, StyleSheet, Button } from "react-native";
|
|
26
|
+
* import { Portal } from "react-native-teleport";
|
|
27
|
+
* export default function InstantRootExample() {
|
|
28
|
+
* const [shouldBeTeleported, setTeleported] = useState(true);
|
|
29
|
+
* return (
|
|
30
|
+
* <View style={styles.container}>
|
|
31
|
+
* {shouldBeTeleported && (
|
|
32
|
+
* <Portal hostName={"overlay"}>
|
|
33
|
+
* <View style={styles.box} />
|
|
34
|
+
* </Portal>
|
|
35
|
+
* )}
|
|
36
|
+
* <Button
|
|
37
|
+
* title={shouldBeTeleported ? "Hide" : "Show"}
|
|
38
|
+
* onPress={() => setTeleported((t) => !t)}
|
|
39
|
+
* />
|
|
40
|
+
* </View>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* const styles = StyleSheet.create({
|
|
44
|
+
* container: {
|
|
45
|
+
* flex: 1,
|
|
46
|
+
* alignItems: "center",
|
|
47
|
+
* justifyContent: "center",
|
|
48
|
+
* },
|
|
49
|
+
* box: {
|
|
50
|
+
* width: 160,
|
|
51
|
+
* height: 160,
|
|
52
|
+
* marginVertical: 20,
|
|
53
|
+
* backgroundColor: "blue",
|
|
54
|
+
* },
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
const PortalComponent = ({ hostName, name, style, children }: PortalProps) => {
|
|
59
|
+
const sourceScrollViewContext = useContext(ScrollViewContext);
|
|
60
|
+
const { state, dispatch } = usePortalManagerContext();
|
|
61
|
+
const instanceId = useId();
|
|
62
|
+
|
|
63
|
+
const scrollViewContext =
|
|
64
|
+
hostName && state.hosts[hostName]
|
|
65
|
+
? (state.hostScrollViewContexts[hostName] ?? null)
|
|
66
|
+
: sourceScrollViewContext;
|
|
67
|
+
|
|
68
|
+
const isRemoved =
|
|
69
|
+
hostName && name ? state.removed[hostName]?.[name]?.[instanceId] : false;
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!hostName || !name) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
dispatch({ type: "REGISTER_PORTAL", hostName, name, instanceId });
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
dispatch({
|
|
80
|
+
type: "CLEAR_REMOVED_ON_UNMOUNT",
|
|
81
|
+
hostName,
|
|
82
|
+
name,
|
|
83
|
+
instanceId,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
}, [dispatch, hostName, name, instanceId]);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<ScrollViewContext.Provider value={scrollViewContext}>
|
|
90
|
+
<PortalView hostName={hostName} name={name} style={style}>
|
|
91
|
+
{isRemoved ? null : children}
|
|
92
|
+
</PortalView>
|
|
93
|
+
</ScrollViewContext.Provider>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default PortalComponent;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/components/PortalHost.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
import { useContext, useEffect } from "react";
|
|
8
|
+
import { usePortalManagerContext } from "./portal-manager";
|
|
9
|
+
import ScrollViewContext from "./scroll-view-context/context";
|
|
10
|
+
import type { PortalHostProps } from "./types";
|
|
11
|
+
import PortalHost from "./PortalHostView";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* PortalHost is a component that acts as an anchor for the portals.
|
|
15
|
+
* You can define multiple portal hosts in your app and use them to render different portals.
|
|
16
|
+
* Each portal host has a unique name that you can use to identify a necessary one among the others.
|
|
17
|
+
*
|
|
18
|
+
* @category components
|
|
19
|
+
* @param name - The name of the portal host. It's used by `<Portal />` component to identify the host.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { StyleSheet, View } from "react-native";
|
|
24
|
+
* import { PortalHost, PortalProvider } from "react-native-teleport";
|
|
25
|
+
* export default function App() {
|
|
26
|
+
* return (
|
|
27
|
+
* <PortalProvider>
|
|
28
|
+
* <PortalHost style={StyleSheet.absoluteFillObject} name="overlay" />
|
|
29
|
+
* </PortalProvider>
|
|
30
|
+
* );
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
const PortalHostComponent = ({ name, children, style }: PortalHostProps) => {
|
|
35
|
+
const { dispatch } = usePortalManagerContext();
|
|
36
|
+
const scrollViewContext = useContext(ScrollViewContext);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
dispatch({ type: "REGISTER_HOST", hostName: name });
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
dispatch({ type: "UNREGISTER_HOST", hostName: name });
|
|
43
|
+
};
|
|
44
|
+
}, [name, dispatch]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
dispatch({
|
|
48
|
+
type: "SET_HOST_SCROLL_VIEW_CONTEXT",
|
|
49
|
+
hostName: name,
|
|
50
|
+
value: scrollViewContext,
|
|
51
|
+
});
|
|
52
|
+
}, [name, dispatch, scrollViewContext]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<PortalHost name={name} style={style}>
|
|
56
|
+
{children}
|
|
57
|
+
</PortalHost>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default PortalHostComponent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/PortalHost/index.native.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
import PortalHostNativeComponent from "./specs/PortalHostViewNativeComponent";
|
|
8
|
+
import type { PortalHostProps } from "./types";
|
|
9
|
+
|
|
10
|
+
const PortalHost = (props: PortalHostProps) => {
|
|
11
|
+
return <PortalHostNativeComponent pointerEvents="box-none" {...props} />;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default PortalHost;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/PortalHost/index.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
import { memo, useEffect } from "react";
|
|
8
|
+
import { usePortalRegistryContext } from "./portal-registry";
|
|
9
|
+
import type { PortalHostProps } from "./types";
|
|
10
|
+
|
|
11
|
+
function PortalHost({ name, children, style }: PortalHostProps) {
|
|
12
|
+
const { registerHost } = usePortalRegistryContext();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
return () => {
|
|
16
|
+
registerHost(name, null);
|
|
17
|
+
};
|
|
18
|
+
}, [name, registerHost]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
style={{ ...style, pointerEvents: "none" } as React.CSSProperties}
|
|
23
|
+
ref={(ref) => registerHost(name, ref)}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default memo(PortalHost);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/PortalProvider.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
import PortalHost from "./PortalHost";
|
|
8
|
+
import NativePortalProvider from "./PortalProviderView";
|
|
9
|
+
import { PortalManagerProvider } from "./portal-manager";
|
|
10
|
+
|
|
11
|
+
type PortalProviderProps = {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Wraps your app with this component to use the teleport API.
|
|
17
|
+
*
|
|
18
|
+
* This component provides a context/registry for all Portals so that you can use imperative API, such as `usePortal` hook to manage Portals.
|
|
19
|
+
*
|
|
20
|
+
* @category components
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { PortalProvider } from "react-native-teleport";
|
|
24
|
+
* export default function App() {
|
|
25
|
+
* return (
|
|
26
|
+
* <PortalProvider>
|
|
27
|
+
* //* your main application code goes here
|
|
28
|
+
* </PortalProvider>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
export default function PortalProvider({ children }: PortalProviderProps) {
|
|
33
|
+
return (
|
|
34
|
+
<NativePortalProvider>
|
|
35
|
+
<PortalManagerProvider>
|
|
36
|
+
{children}
|
|
37
|
+
<PortalHost name="root" style={styles.root} />
|
|
38
|
+
</PortalManagerProvider>
|
|
39
|
+
</NativePortalProvider>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const styles = {
|
|
44
|
+
root: {
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: 0,
|
|
47
|
+
bottom: 0,
|
|
48
|
+
left: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
},
|
|
51
|
+
} as const;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/PortalProvider/index.native.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
6
|
+
*/
|
|
7
|
+
import type { PortalProviderProps } from "./types";
|
|
8
|
+
|
|
9
|
+
export default function PortalProvider({ children }: PortalProviderProps) {
|
|
10
|
+
return children;
|
|
11
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/PortalProvider/index.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
8
|
+
import { PortalRegistryContext } from "./portal-registry";
|
|
9
|
+
import type { PortalProviderProps } from "./types";
|
|
10
|
+
|
|
11
|
+
export default function PortalProvider({ children }: PortalProviderProps) {
|
|
12
|
+
const hostsRef = useRef<Map<string, HTMLElement>>(new Map());
|
|
13
|
+
const pendingPortalsRef = useRef<Map<string, Set<() => void>>>(new Map());
|
|
14
|
+
|
|
15
|
+
const registerHost = useCallback((name: string, node: HTMLElement | null) => {
|
|
16
|
+
if (node) {
|
|
17
|
+
hostsRef.current.set(name, node);
|
|
18
|
+
} else {
|
|
19
|
+
hostsRef.current.delete(name);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const callbacks = pendingPortalsRef.current.get(name);
|
|
23
|
+
if (callbacks) {
|
|
24
|
+
callbacks.forEach((callback) => callback());
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
const getHost = useCallback(
|
|
28
|
+
(name: string) => hostsRef.current.get(name) ?? null,
|
|
29
|
+
[],
|
|
30
|
+
);
|
|
31
|
+
const registerPendingPortal = useCallback(
|
|
32
|
+
(name: string, callback: () => void) => {
|
|
33
|
+
const callbacks = pendingPortalsRef.current.get(name) ?? new Set();
|
|
34
|
+
callbacks.add(callback);
|
|
35
|
+
pendingPortalsRef.current.set(name, callbacks);
|
|
36
|
+
},
|
|
37
|
+
[],
|
|
38
|
+
);
|
|
39
|
+
const unregisterPendingPortal = useCallback(
|
|
40
|
+
(name: string, callback: () => void) => {
|
|
41
|
+
const callbacks = pendingPortalsRef.current.get(name);
|
|
42
|
+
if (callbacks) {
|
|
43
|
+
callbacks.delete(callback);
|
|
44
|
+
if (callbacks.size === 0) {
|
|
45
|
+
pendingPortalsRef.current.delete(name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
[],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const value = useMemo(
|
|
53
|
+
() => ({
|
|
54
|
+
registerHost,
|
|
55
|
+
getHost,
|
|
56
|
+
registerPendingPortal,
|
|
57
|
+
unregisterPendingPortal,
|
|
58
|
+
}),
|
|
59
|
+
[registerHost, getHost, registerPendingPortal, unregisterPendingPortal],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<PortalRegistryContext.Provider value={value}>
|
|
64
|
+
{children}
|
|
65
|
+
</PortalRegistryContext.Provider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/Portal/index.native.tsx`
|
|
3
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
4
|
+
*
|
|
5
|
+
* Changed: import paths only, for this flat directory.
|
|
6
|
+
*/
|
|
7
|
+
export { default } from "./specs/PortalViewNativeComponent";
|