@advenue/react-native 0.6.0 → 0.6.1
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/index.cjs +762 -0
- package/dist/index.d.cts +346 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +84 -12
- package/package.json +8 -4
- package/scripts/check-dist.mjs +31 -0
- package/src/native-require.cjs +23 -0
- package/src/native-require.d.cts +4 -0
- package/src/native.ts +15 -13
package/src/native.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
import { requireExpoModulesCore, requireReactNative } from './native-require.cjs';
|
|
1
2
|
import type { AdvenueAndroidNativeModule, AdvenueIosNativeModule } from './native-types';
|
|
2
3
|
|
|
3
|
-
declare function require(id: string): unknown;
|
|
4
|
-
|
|
5
4
|
type ExpoModulesCore = {
|
|
6
5
|
requireNativeModule<T>(name: string): T;
|
|
7
6
|
};
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Lazy access to the native modules that ship inside this package (ios/ and
|
|
11
|
-
* android/, registered via expo-module.config.json).
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* android/, registered via expo-module.config.json). Host-module resolution
|
|
11
|
+
* goes through native-require.cjs so Metro sees literal requires (see the
|
|
12
|
+
* comment there); `requireNativeModule` throws when the native side isn't
|
|
13
|
+
* built (Expo Go, web, missing pods), so calls stay inside try/catch.
|
|
15
14
|
*/
|
|
16
15
|
export function getIosNative(): AdvenueIosNativeModule | null {
|
|
17
16
|
try {
|
|
18
|
-
const core =
|
|
19
|
-
return core.requireNativeModule<AdvenueIosNativeModule>('AdvenueIos');
|
|
17
|
+
const core = requireExpoModulesCore() as ExpoModulesCore | null;
|
|
18
|
+
return core ? core.requireNativeModule<AdvenueIosNativeModule>('AdvenueIos') : null;
|
|
20
19
|
} catch {
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
@@ -24,8 +23,8 @@ export function getIosNative(): AdvenueIosNativeModule | null {
|
|
|
24
23
|
|
|
25
24
|
export function getAndroidNative(): AdvenueAndroidNativeModule | null {
|
|
26
25
|
try {
|
|
27
|
-
const core =
|
|
28
|
-
return core.requireNativeModule<AdvenueAndroidNativeModule>('AdvenueAndroid');
|
|
26
|
+
const core = requireExpoModulesCore() as ExpoModulesCore | null;
|
|
27
|
+
return core ? core.requireNativeModule<AdvenueAndroidNativeModule>('AdvenueAndroid') : null;
|
|
29
28
|
} catch {
|
|
30
29
|
return null;
|
|
31
30
|
}
|
|
@@ -38,7 +37,8 @@ export function getAndroidNative(): AdvenueAndroidNativeModule | null {
|
|
|
38
37
|
*/
|
|
39
38
|
export function getPlatformOS(): string | null {
|
|
40
39
|
try {
|
|
41
|
-
|
|
40
|
+
const rn = requireReactNative() as { Platform: { OS: string } } | null;
|
|
41
|
+
return rn?.Platform.OS ?? null;
|
|
42
42
|
} catch {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
@@ -60,7 +60,8 @@ export interface AppStateLike {
|
|
|
60
60
|
*/
|
|
61
61
|
export function getAppState(): AppStateLike | null {
|
|
62
62
|
try {
|
|
63
|
-
|
|
63
|
+
const rn = requireReactNative() as { AppState: AppStateLike } | null;
|
|
64
|
+
return rn?.AppState ?? null;
|
|
64
65
|
} catch {
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
@@ -88,7 +89,8 @@ export interface LinkingLike {
|
|
|
88
89
|
*/
|
|
89
90
|
export function getLinking(): LinkingLike | null {
|
|
90
91
|
try {
|
|
91
|
-
|
|
92
|
+
const rn = requireReactNative() as { Linking: LinkingLike } | null;
|
|
93
|
+
return rn?.Linking ?? null;
|
|
92
94
|
} catch {
|
|
93
95
|
return null;
|
|
94
96
|
}
|