@tamagui/native-portal 2.0.0-1768952492255
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components.cjs +66 -0
- package/dist/cjs/components.js +41 -0
- package/dist/cjs/components.js.map +6 -0
- package/dist/cjs/components.native.js +75 -0
- package/dist/cjs/components.native.js.map +1 -0
- package/dist/cjs/index.cjs +31 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +34 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/setup.cjs +64 -0
- package/dist/cjs/setup.js +50 -0
- package/dist/cjs/setup.js.map +6 -0
- package/dist/cjs/setup.native.js +72 -0
- package/dist/cjs/setup.native.js.map +1 -0
- package/dist/cjs/state.cjs +36 -0
- package/dist/cjs/state.js +28 -0
- package/dist/cjs/state.js.map +6 -0
- package/dist/cjs/state.native.js +39 -0
- package/dist/cjs/state.native.js.map +1 -0
- package/dist/esm/components.js +26 -0
- package/dist/esm/components.js.map +6 -0
- package/dist/esm/components.mjs +41 -0
- package/dist/esm/components.mjs.map +1 -0
- package/dist/esm/components.native.js +47 -0
- package/dist/esm/components.native.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +4 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/setup.js +34 -0
- package/dist/esm/setup.js.map +6 -0
- package/dist/esm/setup.mjs +41 -0
- package/dist/esm/setup.mjs.map +1 -0
- package/dist/esm/setup.native.js +46 -0
- package/dist/esm/setup.native.js.map +1 -0
- package/dist/esm/state.js +12 -0
- package/dist/esm/state.js.map +6 -0
- package/dist/esm/state.mjs +12 -0
- package/dist/esm/state.mjs.map +1 -0
- package/dist/esm/state.native.js +12 -0
- package/dist/esm/state.native.js.map +1 -0
- package/package.json +69 -0
- package/src/components.tsx +55 -0
- package/src/index.ts +12 -0
- package/src/setup.ts +50 -0
- package/src/state.ts +15 -0
- package/types/components.d.ts +28 -0
- package/types/components.d.ts.map +11 -0
- package/types/index.d.ts +6 -0
- package/types/index.d.ts.map +11 -0
- package/types/setup.d.ts +10 -0
- package/types/setup.d.ts.map +11 -0
- package/types/state.d.ts +8 -0
- package/types/state.d.ts.map +11 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getNativePortalState } from "./state.mjs";
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
function NativePortal({
|
|
4
|
+
hostName = "root",
|
|
5
|
+
children
|
|
6
|
+
}) {
|
|
7
|
+
if (getNativePortalState().type !== "teleport") return null;
|
|
8
|
+
const {
|
|
9
|
+
Portal
|
|
10
|
+
} = globalThis.__tamagui_teleport;
|
|
11
|
+
return /* @__PURE__ */jsx(Portal, {
|
|
12
|
+
hostName,
|
|
13
|
+
children
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function NativePortalHost({
|
|
17
|
+
name
|
|
18
|
+
}) {
|
|
19
|
+
if (getNativePortalState().type !== "teleport") return null;
|
|
20
|
+
const {
|
|
21
|
+
PortalHost
|
|
22
|
+
} = globalThis.__tamagui_teleport;
|
|
23
|
+
return /* @__PURE__ */jsx(PortalHost, {
|
|
24
|
+
name
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function NativePortalProvider({
|
|
28
|
+
children
|
|
29
|
+
}) {
|
|
30
|
+
if (getNativePortalState().type !== "teleport") return /* @__PURE__ */jsx(Fragment, {
|
|
31
|
+
children
|
|
32
|
+
});
|
|
33
|
+
const {
|
|
34
|
+
PortalProvider
|
|
35
|
+
} = globalThis.__tamagui_teleport;
|
|
36
|
+
return /* @__PURE__ */jsx(PortalProvider, {
|
|
37
|
+
children
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export { NativePortal, NativePortalHost, NativePortalProvider };
|
|
41
|
+
//# sourceMappingURL=components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getNativePortalState","Fragment","jsx","NativePortal","hostName","children","type","Portal","globalThis","__tamagui_teleport","NativePortalHost","name","PortalHost","NativePortalProvider","PortalProvider"],"sources":["../../src/components.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,oBAAA,QAA4B;AA4B5B,SAqB+BC,QAAA,EArB/BC,GAAA;AARF,SAASC,aAAa;EAC3BC,QAAA,GAAW;EACXC;AACF,GAAiC;EAE/B,IADcL,oBAAA,CAAqB,EACzBM,IAAA,KAAS,YAAY,OAAO;EAEtC,MAAM;IAAEC;EAAO,IAAKC,UAAA,CAAmBC,kBAAA;EACvC,OAAO,eAAAP,GAAA,CAACK,MAAA;IAAOH,QAAA;IAAqBC;EAAA,CAAS;AAC/C;AAMO,SAASK,iBAAiB;EAAEC;AAAK,GAAqC;EAE3E,IADcX,oBAAA,CAAqB,EACzBM,IAAA,KAAS,YAAY,OAAO;EAEtC,MAAM;IAAEM;EAAW,IAAKJ,UAAA,CAAmBC,kBAAA;EAC3C,OAAO,eAAAP,GAAA,CAACU,UAAA;IAAWD;EAAA,CAAY;AACjC;AAMO,SAASE,qBAAqB;EAAER;AAAS,GAAyC;EAEvF,IADcL,oBAAA,CAAqB,EACzBM,IAAA,KAAS,YAAY,OAAO,eAAAJ,GAAA,CAAAD,QAAA;IAAGI;EAAA,CAAS;EAElD,MAAM;IAAES;EAAe,IAAKN,UAAA,CAAmBC,kBAAA;EAC/C,OAAO,eAAAP,GAAA,CAACY,cAAA;IAAgBT;EAAA,CAAS;AACnC","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { getNativePortalState } from "./state.native.js";
|
|
3
|
+
function NativePortal(param) {
|
|
4
|
+
var {
|
|
5
|
+
hostName = "root",
|
|
6
|
+
children
|
|
7
|
+
} = param,
|
|
8
|
+
state = getNativePortalState();
|
|
9
|
+
if (state.type !== "teleport") return null;
|
|
10
|
+
var {
|
|
11
|
+
Portal
|
|
12
|
+
} = globalThis.__tamagui_teleport;
|
|
13
|
+
return /* @__PURE__ */_jsx(Portal, {
|
|
14
|
+
hostName,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function NativePortalHost(param) {
|
|
19
|
+
var {
|
|
20
|
+
name
|
|
21
|
+
} = param,
|
|
22
|
+
state = getNativePortalState();
|
|
23
|
+
if (state.type !== "teleport") return null;
|
|
24
|
+
var {
|
|
25
|
+
PortalHost
|
|
26
|
+
} = globalThis.__tamagui_teleport;
|
|
27
|
+
return /* @__PURE__ */_jsx(PortalHost, {
|
|
28
|
+
name
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function NativePortalProvider(param) {
|
|
32
|
+
var {
|
|
33
|
+
children
|
|
34
|
+
} = param,
|
|
35
|
+
state = getNativePortalState();
|
|
36
|
+
if (state.type !== "teleport") return /* @__PURE__ */_jsx(_Fragment, {
|
|
37
|
+
children
|
|
38
|
+
});
|
|
39
|
+
var {
|
|
40
|
+
PortalProvider
|
|
41
|
+
} = globalThis.__tamagui_teleport;
|
|
42
|
+
return /* @__PURE__ */_jsx(PortalProvider, {
|
|
43
|
+
children
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export { NativePortal, NativePortalHost, NativePortalProvider };
|
|
47
|
+
//# sourceMappingURL=components.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","Fragment","_Fragment","getNativePortalState","NativePortal","param","hostName","children","state","type","Portal","globalThis","__tamagui_teleport","NativePortalHost","name","PortalHost","NativePortalProvider"],"sources":["../../src/components.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAA4B;AA4B5B,SAqB+BC,oBArB/B;AARF,SAASC,aAAaC,KAAA;EAC3B;MAAAC,QAAW;MAAAC;IAAA,IAAAF,KAAA;IAAAG,KAAA,GAAAL,oBAAA;EACX,IAAAK,KAAA,CAAAC,IAAA;EACF,IAAiC;IAAAC;EAAA,IAAAC,UAAA,CAAAC,kBAAA;EAE/B,OADc,eAAAZ,IACJ,CAAAU,MAAA,EAAS;IAEnBJ,QAAQ;IACRC;EACF;AAMO;AAEL,SADcM,iBAAAR,KACJ;EAEV;MAAMS;IAAE,IAAAT,KAAW;IAAAG,KAAK,GAAAL,oBAAmB;EAC3C,IAAAK,KAAO,CAAAC,IAAA,eAAC,aAAW;EACrB;IAAAM;EAAA,IAAAJ,UAAA,CAAAC,kBAAA;EAMO,OAAS,eAAAZ,IAAA,CAAqBe,UAAE,EAAS;IAE9CD;EAEA;AACA;AACF,SAAAE,qBAAAX,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getNativePortalState, setNativePortalState } from "./state";
|
|
2
|
+
import { NativePortal, NativePortalHost, NativePortalProvider } from "./components";
|
|
3
|
+
export {
|
|
4
|
+
NativePortal,
|
|
5
|
+
NativePortalHost,
|
|
6
|
+
NativePortalProvider,
|
|
7
|
+
getNativePortalState,
|
|
8
|
+
setNativePortalState
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getNativePortalState, setNativePortalState } from "./state.mjs";
|
|
2
|
+
import { NativePortal, NativePortalHost, NativePortalProvider } from "./components.mjs";
|
|
3
|
+
export { NativePortal, NativePortalHost, NativePortalProvider, getNativePortalState, setNativePortalState };
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getNativePortalState","setNativePortalState","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAGA,SAASA,oBAAA,EAAsBC,oBAAA,QAA4B;AAG3D,SAASC,YAAA,EAAcC,gBAAA,EAAkBC,oBAAA,QAA4B","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getNativePortalState, setNativePortalState } from "./state.native.js";
|
|
2
|
+
import { NativePortal, NativePortalHost, NativePortalProvider } from "./components.native.js";
|
|
3
|
+
export { NativePortal, NativePortalHost, NativePortalProvider, getNativePortalState, setNativePortalState };
|
|
4
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getNativePortalState","setNativePortalState","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAGA,SAASA,oBAAA,EAAsBC,oBAAA,QAA4B;AAG3D,SAASC,YAAA,EAAcC,gBAAA,EAAkBC,oBAAA,QAA4B","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { setNativePortalState } from "./state";
|
|
2
|
+
const IS_FABRIC = typeof global < "u" && !!(global._IS_FABRIC ?? global.nativeFabricUIManager), setupNativePortal = () => {
|
|
3
|
+
const g = globalThis;
|
|
4
|
+
if (!g.__tamagui_native_portal_setup) {
|
|
5
|
+
g.__tamagui_native_portal_setup = !0;
|
|
6
|
+
try {
|
|
7
|
+
const teleport = require("react-native-teleport");
|
|
8
|
+
if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {
|
|
9
|
+
g.__tamagui_teleport = teleport, setNativePortalState({ enabled: !0, type: "teleport" });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
} catch {
|
|
13
|
+
}
|
|
14
|
+
if (IS_FABRIC) {
|
|
15
|
+
try {
|
|
16
|
+
const mod = require("react-native/Libraries/Renderer/shims/ReactFabric");
|
|
17
|
+
g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal, setNativePortalState({ enabled: !0, type: "legacy" });
|
|
18
|
+
} catch (err) {
|
|
19
|
+
console.info("Note: error importing fabric portal, native portals disabled", err);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const mod = require("react-native/Libraries/Renderer/shims/ReactNative");
|
|
25
|
+
g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal, setNativePortalState({ enabled: !0, type: "legacy" });
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.info("Note: error importing native portal, native portals disabled", err);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
setupNativePortal
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/setup.ts"],
|
|
4
|
+
"mappings": "AAAA,SAAS,4BAA4B;AAErC,MAAM,YACJ,OAAO,SAAW,OAClB,GAAS,OAAe,cAAe,OAAe,wBAS3C,oBAAoB,MAAY;AAC3C,QAAM,IAAI;AACV,MAAI,GAAE,+BACN;AAAA,MAAE,gCAAgC;AAGlC,QAAI;AACF,YAAM,WAAW,QAAQ,uBAAuB;AAChD,UAAI,UAAU,UAAU,UAAU,cAAc,UAAU,gBAAgB;AACxE,UAAE,qBAAqB,UACvB,qBAAqB,EAAE,SAAS,IAAM,MAAM,WAAW,CAAC;AACxD;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IAER;AAGA,QAAI,WAAW;AACb,UAAI;AACF,cAAM,MAAM,QAAQ,mDAAmD;AACvE,UAAE,0BAA0B,KAAK,SAAS,gBAAgB,IAAI,cAC9D,qBAAqB,EAAE,SAAS,IAAM,MAAM,SAAS,CAAC;AAAA,MACxD,SAAS,KAAK;AACZ,gBAAQ,KAAK,gEAAgE,GAAG;AAAA,MAClF;AACA;AAAA,IACF;AAEA,QAAI;AACF,YAAM,MAAM,QAAQ,mDAAmD;AACvE,QAAE,0BAA0B,KAAK,SAAS,gBAAgB,IAAI,cAC9D,qBAAqB,EAAE,SAAS,IAAM,MAAM,SAAS,CAAC;AAAA,IACxD,SAAS,KAAK;AACZ,cAAQ,KAAK,gEAAgE,GAAG;AAAA,IAClF;AAAA;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { setNativePortalState } from "./state.mjs";
|
|
2
|
+
const IS_FABRIC = typeof global < "u" && !!(global._IS_FABRIC ?? global.nativeFabricUIManager),
|
|
3
|
+
setupNativePortal = () => {
|
|
4
|
+
const g = globalThis;
|
|
5
|
+
if (!g.__tamagui_native_portal_setup) {
|
|
6
|
+
g.__tamagui_native_portal_setup = !0;
|
|
7
|
+
try {
|
|
8
|
+
const teleport = require("react-native-teleport");
|
|
9
|
+
if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {
|
|
10
|
+
g.__tamagui_teleport = teleport, setNativePortalState({
|
|
11
|
+
enabled: !0,
|
|
12
|
+
type: "teleport"
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
} catch {}
|
|
17
|
+
if (IS_FABRIC) {
|
|
18
|
+
try {
|
|
19
|
+
const mod = require("react-native/Libraries/Renderer/shims/ReactFabric");
|
|
20
|
+
g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal, setNativePortalState({
|
|
21
|
+
enabled: !0,
|
|
22
|
+
type: "legacy"
|
|
23
|
+
});
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.info("Note: error importing fabric portal, native portals disabled", err);
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const mod = require("react-native/Libraries/Renderer/shims/ReactNative");
|
|
31
|
+
g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal, setNativePortalState({
|
|
32
|
+
enabled: !0,
|
|
33
|
+
type: "legacy"
|
|
34
|
+
});
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.info("Note: error importing native portal, native portals disabled", err);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export { setupNativePortal };
|
|
41
|
+
//# sourceMappingURL=setup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["setNativePortalState","IS_FABRIC","global","_IS_FABRIC","nativeFabricUIManager","setupNativePortal","g","globalThis","__tamagui_native_portal_setup","teleport","require","Portal","PortalHost","PortalProvider","__tamagui_teleport","enabled","type","mod","__tamagui_portal_create","default","createPortal","err","console","info"],"sources":["../../src/setup.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,oBAAA,QAA4B;AAErC,MAAMC,SAAA,GACJ,OAAOC,MAAA,GAAW,OAClB,GAASA,MAAA,CAAeC,UAAA,IAAeD,MAAA,CAAeE,qBAAA;EAS3CC,iBAAA,GAAoBA,CAAA,KAAY;IAC3C,MAAMC,CAAA,GAAIC,UAAA;IACV,IAAI,CAAAD,CAAA,CAAEE,6BAAA,EACN;MAAAF,CAAA,CAAEE,6BAAA,GAAgC;MAGlC,IAAI;QACF,MAAMC,QAAA,GAAWC,OAAA,CAAQ,uBAAuB;QAChD,IAAID,QAAA,EAAUE,MAAA,IAAUF,QAAA,EAAUG,UAAA,IAAcH,QAAA,EAAUI,cAAA,EAAgB;UACxEP,CAAA,CAAEQ,kBAAA,GAAqBL,QAAA,EACvBT,oBAAA,CAAqB;YAAEe,OAAA,EAAS;YAAMC,IAAA,EAAM;UAAW,CAAC;UACxD;QACF;MACF,QAAQ,CAER;MAGA,IAAIf,SAAA,EAAW;QACb,IAAI;UACF,MAAMgB,GAAA,GAAMP,OAAA,CAAQ,mDAAmD;UACvEJ,CAAA,CAAEY,uBAAA,GAA0BD,GAAA,EAAKE,OAAA,EAASC,YAAA,IAAgBH,GAAA,CAAIG,YAAA,EAC9DpB,oBAAA,CAAqB;YAAEe,OAAA,EAAS;YAAMC,IAAA,EAAM;UAAS,CAAC;QACxD,SAASK,GAAA,EAAK;UACZC,OAAA,CAAQC,IAAA,CAAK,gEAAgEF,GAAG;QAClF;QACA;MACF;MAEA,IAAI;QACF,MAAMJ,GAAA,GAAMP,OAAA,CAAQ,mDAAmD;QACvEJ,CAAA,CAAEY,uBAAA,GAA0BD,GAAA,EAAKE,OAAA,EAASC,YAAA,IAAgBH,GAAA,CAAIG,YAAA,EAC9DpB,oBAAA,CAAqB;UAAEe,OAAA,EAAS;UAAMC,IAAA,EAAM;QAAS,CAAC;MACxD,SAASK,GAAA,EAAK;QACZC,OAAA,CAAQC,IAAA,CAAK,gEAAgEF,GAAG;MAClF;IAAA;EACF","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { setNativePortalState } from "./state.native.js";
|
|
2
|
+
var _global__IS_FABRIC,
|
|
3
|
+
IS_FABRIC = typeof global < "u" && !!((_global__IS_FABRIC = global._IS_FABRIC) !== null && _global__IS_FABRIC !== void 0 ? _global__IS_FABRIC : global.nativeFabricUIManager),
|
|
4
|
+
setupNativePortal = function () {
|
|
5
|
+
var g = globalThis;
|
|
6
|
+
if (!g.__tamagui_native_portal_setup) {
|
|
7
|
+
g.__tamagui_native_portal_setup = !0;
|
|
8
|
+
try {
|
|
9
|
+
var teleport = require("react-native-teleport");
|
|
10
|
+
if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {
|
|
11
|
+
g.__tamagui_teleport = teleport, setNativePortalState({
|
|
12
|
+
enabled: !0,
|
|
13
|
+
type: "teleport"
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
} catch {}
|
|
18
|
+
if (IS_FABRIC) {
|
|
19
|
+
try {
|
|
20
|
+
var _mod_default,
|
|
21
|
+
mod = require("react-native/Libraries/Renderer/shims/ReactFabric"),
|
|
22
|
+
_mod_default_createPortal;
|
|
23
|
+
g.__tamagui_portal_create = (_mod_default_createPortal = mod == null || (_mod_default = mod.default) === null || _mod_default === void 0 ? void 0 : _mod_default.createPortal) !== null && _mod_default_createPortal !== void 0 ? _mod_default_createPortal : mod.createPortal, setNativePortalState({
|
|
24
|
+
enabled: !0,
|
|
25
|
+
type: "legacy"
|
|
26
|
+
});
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.info("Note: error importing fabric portal, native portals disabled", err);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
var _mod_default1,
|
|
34
|
+
mod1 = require("react-native/Libraries/Renderer/shims/ReactNative"),
|
|
35
|
+
_mod_default_createPortal1;
|
|
36
|
+
g.__tamagui_portal_create = (_mod_default_createPortal1 = mod1 == null || (_mod_default1 = mod1.default) === null || _mod_default1 === void 0 ? void 0 : _mod_default1.createPortal) !== null && _mod_default_createPortal1 !== void 0 ? _mod_default_createPortal1 : mod1.createPortal, setNativePortalState({
|
|
37
|
+
enabled: !0,
|
|
38
|
+
type: "legacy"
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.info("Note: error importing native portal, native portals disabled", err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export { setupNativePortal };
|
|
46
|
+
//# sourceMappingURL=setup.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["setNativePortalState","_global__IS_FABRIC","IS_FABRIC","global","_IS_FABRIC","nativeFabricUIManager","setupNativePortal","g","globalThis","__tamagui_native_portal_setup","teleport","require","Portal","PortalHost","PortalProvider","__tamagui_teleport","enabled","type","_mod_default","mod","_mod_default_createPortal","__tamagui_portal_create","default","createPortal","err","console","info","_mod_default1","mod1","_mod_default_createPortal1"],"sources":["../../src/setup.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,oBAAA,QAA4B;AAErC,IAAAC,kBACE;EAAAC,SAAO,GAAW,OAClBC,MAAS,GAAe,WAAAF,kBAA8B,GAAAE,MAAA,CAAAC,UAS3C,cAAAH,kBAAgC,cAAAA,kBAAA,GAAAE,MAAA,CAAAE,qBAAA;EAAAC,iBAAA,YAAAA,CAAA;IAC3C,IAAAC,CAAA,GAAMC,UAAI;IACV,IAAI,CAAAD,CAAA,CAAEE,6BAAA,EACN;MAAAF,CAAA,CAAEE,6BAAA,GAAgC;MAGlC,IAAI;QACF,IAAAC,QAAM,GAAAC,OAAW,wBAAQ;QACzB,IAAID,QAAA,EAAUE,MAAA,IAAUF,QAAA,EAAUG,UAAA,IAAcH,QAAA,EAAUI,cAAA,EAAgB;UACxEP,CAAA,CAAEQ,kBAAA,GAAqBL,QAAA,EACvBV,oBAAA,CAAqB;YACrBgB,OAAA;YACFC,IAAA;UACF;UAEA;QAGA;MACE,QAAI,CACF;MACA,IAAAf,SAAE;QAEJ;UACE,IAAAgB,YAAa;YAAAC,GAAA,GAAAR,OAAA,oDAAmE;YAAAS,yBAAA;UAClFb,CAAA,CAAAc,uBAAA,IAAAD,yBAAA,GAAAD,GAAA,aAAAD,YAAA,GAAAC,GAAA,CAAAG,OAAA,cAAAJ,YAAA,uBAAAA,YAAA,CAAAK,YAAA,cAAAH,yBAAA,cAAAA,yBAAA,GAAAD,GAAA,CAAAI,YAAA,EAAAvB,oBAAA;YACAgB,OAAA;YACFC,IAAA;UAEI;QACF,SAAMO,GAAM;UACVC,OAAA,CAAAC,IAAA,+DACF,EAAAF,GAAA;QACF;QACE;MACF;MAAA;QACF,IAAAG,aAAA;UAAAC,IAAA,GAAAjB,OAAA;UAAAkB,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
let state = { enabled: !1, type: null };
|
|
2
|
+
function setNativePortalState(newState) {
|
|
3
|
+
state = newState;
|
|
4
|
+
}
|
|
5
|
+
function getNativePortalState() {
|
|
6
|
+
return state;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
getNativePortalState,
|
|
10
|
+
setNativePortalState
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
let state = {
|
|
2
|
+
enabled: !1,
|
|
3
|
+
type: null
|
|
4
|
+
};
|
|
5
|
+
function setNativePortalState(newState) {
|
|
6
|
+
state = newState;
|
|
7
|
+
}
|
|
8
|
+
function getNativePortalState() {
|
|
9
|
+
return state;
|
|
10
|
+
}
|
|
11
|
+
export { getNativePortalState, setNativePortalState };
|
|
12
|
+
//# sourceMappingURL=state.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["state","enabled","type","setNativePortalState","newState","getNativePortalState"],"sources":["../../src/state.ts"],"sourcesContent":[null],"mappings":"AAKA,IAAIA,KAAA,GAA2B;EAAEC,OAAA,EAAS;EAAOC,IAAA,EAAM;AAAK;AAErD,SAASC,qBAAqBC,QAAA,EAA6B;EAChEJ,KAAA,GAAQI,QAAA;AACV;AAEO,SAASC,qBAAA,EAA0C;EACxD,OAAOL,KAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var state = {
|
|
2
|
+
enabled: !1,
|
|
3
|
+
type: null
|
|
4
|
+
};
|
|
5
|
+
function setNativePortalState(newState) {
|
|
6
|
+
state = newState;
|
|
7
|
+
}
|
|
8
|
+
function getNativePortalState() {
|
|
9
|
+
return state;
|
|
10
|
+
}
|
|
11
|
+
export { getNativePortalState, setNativePortalState };
|
|
12
|
+
//# sourceMappingURL=state.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["state","enabled","type","setNativePortalState","newState"],"sources":["../../src/state.ts"],"sourcesContent":[null],"mappings":"AAKA,IAAIA,KAAA,GAA2B;EAExBC,OAAS;EACdC,IAAA;AACF;AAEO,SAASC,qBAAAC,QAA0C;EACxDJ,KAAA,GAAOI,QAAA;AACT","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/native-portal",
|
|
3
|
+
"version": "2.0.0-1768952492255",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"types": "./types/index.d.ts",
|
|
7
|
+
"main": "dist/cjs",
|
|
8
|
+
"module": "dist/esm",
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tamagui-build",
|
|
16
|
+
"watch": "tamagui-build --watch",
|
|
17
|
+
"lint": "biome check src",
|
|
18
|
+
"lint:fix": "biome check --write src",
|
|
19
|
+
"clean": "tamagui-build clean",
|
|
20
|
+
"clean:build": "tamagui-build clean:build"
|
|
21
|
+
},
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
"setup": [
|
|
25
|
+
"./types/setup.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
"./package.json": "./package.json",
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./types/index.d.ts",
|
|
33
|
+
"module": "./dist/esm/index.mjs",
|
|
34
|
+
"import": "./dist/esm/index.mjs",
|
|
35
|
+
"require": "./dist/cjs/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./setup": {
|
|
38
|
+
"react-native": {
|
|
39
|
+
"types": "./types/setup.d.ts",
|
|
40
|
+
"module": "./dist/esm/setup.mjs",
|
|
41
|
+
"import": "./dist/esm/setup.mjs",
|
|
42
|
+
"require": "./dist/cjs/setup.cjs"
|
|
43
|
+
},
|
|
44
|
+
"types": "./types/setup.d.ts",
|
|
45
|
+
"module": "./dist/esm/setup.mjs",
|
|
46
|
+
"import": "./dist/esm/setup.mjs",
|
|
47
|
+
"require": "./dist/cjs/setup.cjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@tamagui/build": "2.0.0-1768952492255",
|
|
52
|
+
"react": "*",
|
|
53
|
+
"react-native": "0.81.5",
|
|
54
|
+
"react-native-teleport": "^0.5.6"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": "*",
|
|
58
|
+
"react-native": "*",
|
|
59
|
+
"react-native-teleport": ">=0.5.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"react-native-teleport": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { getNativePortalState } from './state'
|
|
3
|
+
|
|
4
|
+
// types matching react-native-teleport's API
|
|
5
|
+
export type NativePortalProps = {
|
|
6
|
+
hostName?: string
|
|
7
|
+
children: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type NativePortalHostProps = {
|
|
11
|
+
name: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type NativePortalProviderProps = {
|
|
15
|
+
children: ReactNode
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Renders children into a teleport Portal when available.
|
|
20
|
+
* Returns null when teleport is not set up (allows fallback handling by caller).
|
|
21
|
+
*/
|
|
22
|
+
export function NativePortal({
|
|
23
|
+
hostName = 'root',
|
|
24
|
+
children,
|
|
25
|
+
}: NativePortalProps): ReactNode {
|
|
26
|
+
const state = getNativePortalState()
|
|
27
|
+
if (state.type !== 'teleport') return null
|
|
28
|
+
|
|
29
|
+
const { Portal } = (globalThis as any).__tamagui_teleport
|
|
30
|
+
return <Portal hostName={hostName}>{children}</Portal>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Renders a teleport PortalHost when available.
|
|
35
|
+
* Returns null when teleport is not set up.
|
|
36
|
+
*/
|
|
37
|
+
export function NativePortalHost({ name }: NativePortalHostProps): ReactNode {
|
|
38
|
+
const state = getNativePortalState()
|
|
39
|
+
if (state.type !== 'teleport') return null
|
|
40
|
+
|
|
41
|
+
const { PortalHost } = (globalThis as any).__tamagui_teleport
|
|
42
|
+
return <PortalHost name={name} />
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Wraps children with teleport PortalProvider when available.
|
|
47
|
+
* Returns children as-is when teleport is not set up.
|
|
48
|
+
*/
|
|
49
|
+
export function NativePortalProvider({ children }: NativePortalProviderProps): ReactNode {
|
|
50
|
+
const state = getNativePortalState()
|
|
51
|
+
if (state.type !== 'teleport') return <>{children}</>
|
|
52
|
+
|
|
53
|
+
const { PortalProvider } = (globalThis as any).__tamagui_teleport
|
|
54
|
+
return <PortalProvider>{children}</PortalProvider>
|
|
55
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// safe exports - no react-native or react-native-teleport imports
|
|
2
|
+
// for setup, import from '@tamagui/native-portal/setup' on native only
|
|
3
|
+
|
|
4
|
+
export { getNativePortalState, setNativePortalState } from './state'
|
|
5
|
+
export type { NativePortalState } from './state'
|
|
6
|
+
|
|
7
|
+
export { NativePortal, NativePortalHost, NativePortalProvider } from './components'
|
|
8
|
+
export type {
|
|
9
|
+
NativePortalProps,
|
|
10
|
+
NativePortalHostProps,
|
|
11
|
+
NativePortalProviderProps,
|
|
12
|
+
} from './components'
|
package/src/setup.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { setNativePortalState } from './state'
|
|
2
|
+
|
|
3
|
+
const IS_FABRIC =
|
|
4
|
+
typeof global !== 'undefined' &&
|
|
5
|
+
Boolean((global as any)._IS_FABRIC ?? (global as any).nativeFabricUIManager)
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sets up native portal support for React Native.
|
|
9
|
+
* Call this function early in your app (e.g., in index.js) to enable native portals.
|
|
10
|
+
*
|
|
11
|
+
* If react-native-teleport is installed, it will be used automatically (recommended).
|
|
12
|
+
* Otherwise falls back to legacy RN shims approach.
|
|
13
|
+
*/
|
|
14
|
+
export const setupNativePortal = (): void => {
|
|
15
|
+
const g = globalThis as any
|
|
16
|
+
if (g.__tamagui_native_portal_setup) return
|
|
17
|
+
g.__tamagui_native_portal_setup = true
|
|
18
|
+
|
|
19
|
+
// try teleport first (preferred)
|
|
20
|
+
try {
|
|
21
|
+
const teleport = require('react-native-teleport')
|
|
22
|
+
if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {
|
|
23
|
+
g.__tamagui_teleport = teleport
|
|
24
|
+
setNativePortalState({ enabled: true, type: 'teleport' })
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
// teleport not installed, try legacy
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// fall back to legacy RN shims approach
|
|
32
|
+
if (IS_FABRIC) {
|
|
33
|
+
try {
|
|
34
|
+
const mod = require('react-native/Libraries/Renderer/shims/ReactFabric')
|
|
35
|
+
g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal
|
|
36
|
+
setNativePortalState({ enabled: true, type: 'legacy' })
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.info(`Note: error importing fabric portal, native portals disabled`, err)
|
|
39
|
+
}
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const mod = require('react-native/Libraries/Renderer/shims/ReactNative')
|
|
45
|
+
g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal
|
|
46
|
+
setNativePortalState({ enabled: true, type: 'legacy' })
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.info(`Note: error importing native portal, native portals disabled`, err)
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/state.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type NativePortalState = {
|
|
2
|
+
enabled: boolean
|
|
3
|
+
type: 'teleport' | 'legacy' | null
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let state: NativePortalState = { enabled: false, type: null }
|
|
7
|
+
|
|
8
|
+
export function setNativePortalState(newState: NativePortalState) {
|
|
9
|
+
state = newState
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getNativePortalState(): NativePortalState {
|
|
13
|
+
return state
|
|
14
|
+
}
|
|
15
|
+
// retrigger ci
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type NativePortalProps = {
|
|
3
|
+
hostName?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export type NativePortalHostProps = {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
export type NativePortalProviderProps = {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Renders children into a teleport Portal when available.
|
|
14
|
+
* Returns null when teleport is not set up (allows fallback handling by caller).
|
|
15
|
+
*/
|
|
16
|
+
export declare function NativePortal({ hostName, children }: NativePortalProps): ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Renders a teleport PortalHost when available.
|
|
19
|
+
* Returns null when teleport is not set up.
|
|
20
|
+
*/
|
|
21
|
+
export declare function NativePortalHost({ name }: NativePortalHostProps): ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Wraps children with teleport PortalProvider when available.
|
|
24
|
+
* Returns children as-is when teleport is not set up.
|
|
25
|
+
*/
|
|
26
|
+
export declare function NativePortalProvider({ children }: NativePortalProviderProps): ReactNode;
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAAA,cAAc,iBAAiB;AAI/B,YAAY,oBAAoB;CAC9B;CACA,UAAU;;AAGZ,YAAY,wBAAwB;CAClC;;AAGF,YAAY,4BAA4B;CACtC,UAAU;;;;;;AAOZ,OAAO,iBAAS,aAAa,EAC3B,UACA,YACC,oBAAoB;;;;;AAYvB,OAAO,iBAAS,iBAAiB,EAAE,QAAQ,wBAAwB;;;;;AAYnE,OAAO,iBAAS,qBAAqB,EAAE,YAAY,4BAA4B",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/components.tsx"
|
|
6
|
+
],
|
|
7
|
+
"sourcesContent": [
|
|
8
|
+
"import type { ReactNode } from 'react'\nimport { getNativePortalState } from './state'\n\n// types matching react-native-teleport's API\nexport type NativePortalProps = {\n hostName?: string\n children: ReactNode\n}\n\nexport type NativePortalHostProps = {\n name: string\n}\n\nexport type NativePortalProviderProps = {\n children: ReactNode\n}\n\n/**\n * Renders children into a teleport Portal when available.\n * Returns null when teleport is not set up (allows fallback handling by caller).\n */\nexport function NativePortal({\n hostName = 'root',\n children,\n}: NativePortalProps): ReactNode {\n const state = getNativePortalState()\n if (state.type !== 'teleport') return null\n\n const { Portal } = (globalThis as any).__tamagui_teleport\n return <Portal hostName={hostName}>{children}</Portal>\n}\n\n/**\n * Renders a teleport PortalHost when available.\n * Returns null when teleport is not set up.\n */\nexport function NativePortalHost({ name }: NativePortalHostProps): ReactNode {\n const state = getNativePortalState()\n if (state.type !== 'teleport') return null\n\n const { PortalHost } = (globalThis as any).__tamagui_teleport\n return <PortalHost name={name} />\n}\n\n/**\n * Wraps children with teleport PortalProvider when available.\n * Returns children as-is when teleport is not set up.\n */\nexport function NativePortalProvider({ children }: NativePortalProviderProps): ReactNode {\n const state = getNativePortalState()\n if (state.type !== 'teleport') return <>{children}</>\n\n const { PortalProvider } = (globalThis as any).__tamagui_teleport\n return <PortalProvider>{children}</PortalProvider>\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"version": 3
|
|
11
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getNativePortalState, setNativePortalState } from "./state";
|
|
2
|
+
export type { NativePortalState } from "./state";
|
|
3
|
+
export { NativePortal, NativePortalHost, NativePortalProvider } from "./components";
|
|
4
|
+
export type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps } from "./components";
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAGA,SAAS,sBAAsB,4BAA4B;AAC3D,cAAc,yBAAyB;AAEvC,SAAS,cAAc,kBAAkB,4BAA4B;AACrE,cACE,mBACA,uBACA,iCACK",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/index.ts"
|
|
6
|
+
],
|
|
7
|
+
"sourcesContent": [
|
|
8
|
+
"// safe exports - no react-native or react-native-teleport imports\n// for setup, import from '@tamagui/native-portal/setup' on native only\n\nexport { getNativePortalState, setNativePortalState } from './state'\nexport type { NativePortalState } from './state'\n\nexport { NativePortal, NativePortalHost, NativePortalProvider } from './components'\nexport type {\n NativePortalProps,\n NativePortalHostProps,\n NativePortalProviderProps,\n} from './components'\n"
|
|
9
|
+
],
|
|
10
|
+
"version": 3
|
|
11
|
+
}
|
package/types/setup.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets up native portal support for React Native.
|
|
3
|
+
* Call this function early in your app (e.g., in index.js) to enable native portals.
|
|
4
|
+
*
|
|
5
|
+
* If react-native-teleport is installed, it will be used automatically (recommended).
|
|
6
|
+
* Otherwise falls back to legacy RN shims approach.
|
|
7
|
+
*/
|
|
8
|
+
export declare const setupNativePortal: () => void;
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": ";;;;;;;AAaA,OAAO,cAAM",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/setup.ts"
|
|
6
|
+
],
|
|
7
|
+
"sourcesContent": [
|
|
8
|
+
"import { setNativePortalState } from './state'\n\nconst IS_FABRIC =\n typeof global !== 'undefined' &&\n Boolean((global as any)._IS_FABRIC ?? (global as any).nativeFabricUIManager)\n\n/**\n * Sets up native portal support for React Native.\n * Call this function early in your app (e.g., in index.js) to enable native portals.\n *\n * If react-native-teleport is installed, it will be used automatically (recommended).\n * Otherwise falls back to legacy RN shims approach.\n */\nexport const setupNativePortal = (): void => {\n const g = globalThis as any\n if (g.__tamagui_native_portal_setup) return\n g.__tamagui_native_portal_setup = true\n\n // try teleport first (preferred)\n try {\n const teleport = require('react-native-teleport')\n if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {\n g.__tamagui_teleport = teleport\n setNativePortalState({ enabled: true, type: 'teleport' })\n return\n }\n } catch {\n // teleport not installed, try legacy\n }\n\n // fall back to legacy RN shims approach\n if (IS_FABRIC) {\n try {\n const mod = require('react-native/Libraries/Renderer/shims/ReactFabric')\n g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal\n setNativePortalState({ enabled: true, type: 'legacy' })\n } catch (err) {\n console.info(`Note: error importing fabric portal, native portals disabled`, err)\n }\n return\n }\n\n try {\n const mod = require('react-native/Libraries/Renderer/shims/ReactNative')\n g.__tamagui_portal_create = mod?.default?.createPortal ?? mod.createPortal\n setNativePortalState({ enabled: true, type: 'legacy' })\n } catch (err) {\n console.info(`Note: error importing native portal, native portals disabled`, err)\n }\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"version": 3
|
|
11
|
+
}
|
package/types/state.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type NativePortalState = {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
type: "teleport" | "legacy" | null;
|
|
4
|
+
};
|
|
5
|
+
export declare function setNativePortalState(newState: NativePortalState);
|
|
6
|
+
export declare function getNativePortalState(): NativePortalState;
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=state.d.ts.map
|