react-native-nitro-modules 0.9.2 → 0.11.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.
Files changed (119) hide show
  1. package/NitroModules.podspec +2 -0
  2. package/README.md +4 -4
  3. package/android/CMakeLists.txt +3 -0
  4. package/android/build.gradle +26 -2
  5. package/android/src/main/cpp/JNIOnLoad.cpp +5 -5
  6. package/android/src/main/cpp/turbomodule/JNitroModules.cpp +39 -0
  7. package/android/src/main/cpp/turbomodule/JNitroModules.hpp +37 -0
  8. package/android/src/main/java/com/margelo/nitro/NitroModules.kt +69 -0
  9. package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.kt +34 -0
  10. package/android/src/main/java/com/margelo/nitro/core/HybridObject.kt +6 -2
  11. package/android/src/newarch/NitroModulesSpec.kt +6 -0
  12. package/android/src/oldarch/NitroModulesSpec.kt +9 -0
  13. package/cpp/core/BoxedHybridObject.cpp +29 -0
  14. package/cpp/core/BoxedHybridObject.hpp +36 -0
  15. package/cpp/core/HybridFunction.hpp +12 -3
  16. package/cpp/entrypoint/HybridNitroModulesProxy.cpp +55 -0
  17. package/cpp/entrypoint/HybridNitroModulesProxy.hpp +48 -0
  18. package/cpp/entrypoint/InstallNitro.cpp +28 -0
  19. package/cpp/entrypoint/InstallNitro.hpp +41 -0
  20. package/cpp/jsi/JSIConverter+HostObject.hpp +73 -0
  21. package/cpp/jsi/JSIConverter+HybridObject.hpp +1 -1
  22. package/cpp/jsi/JSIConverter.hpp +1 -0
  23. package/cpp/templates/FutureType.hpp +1 -1
  24. package/cpp/templates/TypeIndex.hpp +29 -0
  25. package/cpp/utils/NitroDefines.hpp +5 -0
  26. package/ios/core/AnyMapHolder.hpp +8 -0
  27. package/ios/core/AnyMapHolder.swift +65 -39
  28. package/ios/core/HybridObjectSpec.swift +1 -1
  29. package/ios/platform/NitroLogger.mm +0 -1
  30. package/ios/turbomodule/NativeNitroModules+NewArch.mm +67 -0
  31. package/ios/turbomodule/NativeNitroModules+OldArch.mm +68 -0
  32. package/ios/turbomodule/NativeNitroModules.h +22 -0
  33. package/lib/BoxedHybridObject.d.ts +12 -0
  34. package/lib/BoxedHybridObject.js +1 -0
  35. package/lib/ModuleNotFoundError.js +3 -13
  36. package/lib/NitroModules.d.ts +1 -48
  37. package/lib/NitroModules.js +2 -67
  38. package/lib/NitroModulesProxy.d.ts +58 -0
  39. package/lib/NitroModulesProxy.js +1 -0
  40. package/lib/commonjs/BoxedHybridObject.js +6 -0
  41. package/lib/commonjs/BoxedHybridObject.js.map +1 -0
  42. package/lib/commonjs/ModuleNotFoundError.js +3 -15
  43. package/lib/commonjs/ModuleNotFoundError.js.map +1 -1
  44. package/lib/commonjs/NitroModules.js +11 -72
  45. package/lib/commonjs/NitroModules.js.map +1 -1
  46. package/lib/commonjs/NitroModulesProxy.js +6 -0
  47. package/lib/commonjs/NitroModulesProxy.js.map +1 -0
  48. package/lib/commonjs/turbomodule/NativeNitroModules.js +36 -0
  49. package/lib/commonjs/turbomodule/NativeNitroModules.js.map +1 -0
  50. package/lib/commonjs/turbomodule/NativeNitroModules.web.js +17 -0
  51. package/lib/commonjs/turbomodule/NativeNitroModules.web.js.map +1 -0
  52. package/lib/module/BoxedHybridObject.js +4 -0
  53. package/lib/module/BoxedHybridObject.js.map +1 -0
  54. package/lib/module/ModuleNotFoundError.js +3 -15
  55. package/lib/module/ModuleNotFoundError.js.map +1 -1
  56. package/lib/module/NitroModules.js +2 -72
  57. package/lib/module/NitroModules.js.map +1 -1
  58. package/lib/module/NitroModulesProxy.js +4 -0
  59. package/lib/module/NitroModulesProxy.js.map +1 -0
  60. package/lib/module/turbomodule/NativeNitroModules.js +31 -0
  61. package/lib/module/turbomodule/NativeNitroModules.js.map +1 -0
  62. package/lib/{NitroModulesTurboModule.web.js → module/turbomodule/NativeNitroModules.web.js} +9 -1
  63. package/lib/module/turbomodule/NativeNitroModules.web.js.map +1 -0
  64. package/lib/tsconfig.tsbuildinfo +1 -1
  65. package/lib/turbomodule/NativeNitroModules.d.ts +7 -0
  66. package/lib/turbomodule/NativeNitroModules.js +27 -0
  67. package/lib/turbomodule/NativeNitroModules.web.d.ts +2 -0
  68. package/lib/turbomodule/NativeNitroModules.web.js +9 -0
  69. package/lib/typescript/AnyMap.d.ts +20 -0
  70. package/lib/typescript/BoxedHybridObject.d.ts +13 -0
  71. package/lib/typescript/BoxedHybridObject.d.ts.map +1 -0
  72. package/lib/typescript/HybridObject.d.ts +99 -0
  73. package/lib/typescript/ModuleNotFoundError.d.ts +7 -0
  74. package/lib/typescript/ModuleNotFoundError.d.ts.map +1 -1
  75. package/lib/typescript/NitroModules.d.ts +2 -0
  76. package/lib/typescript/NitroModules.d.ts.map +1 -1
  77. package/lib/typescript/NitroModulesProxy.d.ts +59 -0
  78. package/lib/typescript/NitroModulesProxy.d.ts.map +1 -0
  79. package/lib/typescript/__tests__/index.test.d.ts +1 -0
  80. package/lib/typescript/index.d.ts +4 -0
  81. package/lib/typescript/turbomodule/NativeNitroModules.d.ts +8 -0
  82. package/lib/typescript/turbomodule/NativeNitroModules.d.ts.map +1 -0
  83. package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts +3 -0
  84. package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts.map +1 -0
  85. package/package.json +9 -1
  86. package/src/BoxedHybridObject.ts +13 -0
  87. package/src/ModuleNotFoundError.ts +3 -19
  88. package/src/NitroModules.ts +2 -76
  89. package/src/NitroModulesProxy.ts +61 -0
  90. package/src/turbomodule/NativeNitroModules.ts +48 -0
  91. package/src/turbomodule/NativeNitroModules.web.ts +16 -0
  92. package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.java +0 -30
  93. package/cpp/turbomodule/NativeNitroModules.cpp +0 -131
  94. package/cpp/turbomodule/NativeNitroModules.h +0 -8
  95. package/cpp/turbomodule/NativeNitroModules.hpp +0 -39
  96. package/cpp/turbomodule/RegisterNativeNitroModules.cpp +0 -33
  97. package/cpp/turbomodule/RegisterNativeNitroModules.hpp +0 -21
  98. package/ios/turbomodule/NitroModuleOnLoad.mm +0 -32
  99. package/lib/NativeNitroModules.d.ts +0 -17
  100. package/lib/NativeNitroModules.js +0 -22
  101. package/lib/NativeNitroModules.web.d.ts +0 -4
  102. package/lib/NativeNitroModules.web.js +0 -3
  103. package/lib/NitroModulesTurboModule.d.ts +0 -17
  104. package/lib/NitroModulesTurboModule.js +0 -23
  105. package/lib/NitroModulesTurboModule.web.d.ts +0 -1
  106. package/lib/commonjs/NitroModulesTurboModule.js +0 -34
  107. package/lib/commonjs/NitroModulesTurboModule.js.map +0 -1
  108. package/lib/commonjs/NitroModulesTurboModule.web.js +0 -11
  109. package/lib/commonjs/NitroModulesTurboModule.web.js.map +0 -1
  110. package/lib/module/NitroModulesTurboModule.js +0 -30
  111. package/lib/module/NitroModulesTurboModule.js.map +0 -1
  112. package/lib/module/NitroModulesTurboModule.web.js +0 -7
  113. package/lib/module/NitroModulesTurboModule.web.js.map +0 -1
  114. package/lib/typescript/NitroModulesTurboModule.d.ts +0 -18
  115. package/lib/typescript/NitroModulesTurboModule.d.ts.map +0 -1
  116. package/lib/typescript/NitroModulesTurboModule.web.d.ts +0 -2
  117. package/lib/typescript/NitroModulesTurboModule.web.d.ts.map +0 -1
  118. package/src/NitroModulesTurboModule.ts +0 -49
  119. package/src/NitroModulesTurboModule.web.ts +0 -7
@@ -1,48 +1 @@
1
- import type { HybridObject } from './HybridObject';
2
- /**
3
- * A lazy proxy for initializing Nitro Modules HybridObjects.
4
- */
5
- export declare const NitroModules: {
6
- /**
7
- * Create a new instance of the `HybridObject` {@linkcode T}.
8
- *
9
- * {@linkcode T} has to be registered beforehand under the name {@linkcode name}
10
- * in the native Nitro Modules `HybridObjectRegistry`.
11
- *
12
- * @param name The name of the `HybridObject` under which it was registered at.
13
- * @returns An instance of {@linkcode T}
14
- * @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
15
- */
16
- createHybridObject<T extends HybridObject<any>>(name: string): T;
17
- /**
18
- * Get a list of all registered Hybrid Objects.
19
- */
20
- getAllHybridObjectNames(): string[];
21
- /**
22
- * Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
23
- */
24
- hasHybridObject(name: string): boolean;
25
- /**
26
- * Returns whether the given {@linkcode object} has a `NativeState` or not.
27
- *
28
- * This can be a quick way to check if an object is a valid {@linkcode HybridObject},
29
- * and has not yet been disposed.
30
- * @example
31
- * ```ts
32
- * const someObject = NitroModules.createHybridObject<Some>('Some')
33
- * console.log(NitroModules.hasNativeState(someObject)) // -> true
34
- * someObject.dispose()
35
- * console.log(NitroModules.hasNativeState(someObject)) // -> false
36
- * ```
37
- */
38
- hasNativeState(object: object): boolean;
39
- /**
40
- * Forcefully removes the `NativeState` of the given {@linkcode object}.
41
- */
42
- removeNativeState(object: object): void;
43
- /**
44
- * Gets the current build type configuration as defined in the `NITRO_DEBUG`
45
- * preprocessor flag.
46
- */
47
- readonly buildType: "debug" | "release";
48
- };
1
+ export * from './turbomodule/NativeNitroModules';
@@ -1,67 +1,2 @@
1
- import { getNativeNitroModules } from './NitroModulesTurboModule';
2
- /**
3
- * A lazy proxy for initializing Nitro Modules HybridObjects.
4
- */
5
- export const NitroModules = {
6
- /**
7
- * Create a new instance of the `HybridObject` {@linkcode T}.
8
- *
9
- * {@linkcode T} has to be registered beforehand under the name {@linkcode name}
10
- * in the native Nitro Modules `HybridObjectRegistry`.
11
- *
12
- * @param name The name of the `HybridObject` under which it was registered at.
13
- * @returns An instance of {@linkcode T}
14
- * @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
15
- */
16
- createHybridObject(name) {
17
- const nitro = getNativeNitroModules();
18
- const instance = nitro.createHybridObject(name);
19
- return instance;
20
- },
21
- /**
22
- * Get a list of all registered Hybrid Objects.
23
- */
24
- getAllHybridObjectNames() {
25
- const nitro = getNativeNitroModules();
26
- return nitro.getAllHybridObjectNames();
27
- },
28
- /**
29
- * Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
30
- */
31
- hasHybridObject(name) {
32
- const nitro = getNativeNitroModules();
33
- return nitro.hasHybridObject(name);
34
- },
35
- /**
36
- * Returns whether the given {@linkcode object} has a `NativeState` or not.
37
- *
38
- * This can be a quick way to check if an object is a valid {@linkcode HybridObject},
39
- * and has not yet been disposed.
40
- * @example
41
- * ```ts
42
- * const someObject = NitroModules.createHybridObject<Some>('Some')
43
- * console.log(NitroModules.hasNativeState(someObject)) // -> true
44
- * someObject.dispose()
45
- * console.log(NitroModules.hasNativeState(someObject)) // -> false
46
- * ```
47
- */
48
- hasNativeState(object) {
49
- const nitro = getNativeNitroModules();
50
- return nitro.hasNativeState(object);
51
- },
52
- /**
53
- * Forcefully removes the `NativeState` of the given {@linkcode object}.
54
- */
55
- removeNativeState(object) {
56
- const nitro = getNativeNitroModules();
57
- nitro.removeNativeState(object);
58
- },
59
- /**
60
- * Gets the current build type configuration as defined in the `NITRO_DEBUG`
61
- * preprocessor flag.
62
- */
63
- get buildType() {
64
- const nitro = getNativeNitroModules();
65
- return nitro.buildType;
66
- },
67
- };
1
+ // Re-exports the platform specific `NitroModulesProxy` (or a stub-implementation if not found)
2
+ export * from './turbomodule/NativeNitroModules';
@@ -0,0 +1,58 @@
1
+ import type { HybridObject } from './HybridObject';
2
+ import type { BoxedHybridObject } from './BoxedHybridObject';
3
+ /**
4
+ * The Proxy class that acts as a main entry point for Nitro Modules in React Native.
5
+ *
6
+ * This is a `HybridObject` on the native side as well, and is expected to be
7
+ * installed into the runtime's `global` via the NativeModule/TurboModule's `install()` function.
8
+ */
9
+ export interface NitroModulesProxy extends HybridObject {
10
+ /**
11
+ * Create a new instance of the `HybridObject` {@linkcode T}.
12
+ *
13
+ * {@linkcode T} has to be registered beforehand under the name {@linkcode name}
14
+ * in the native Nitro Modules `HybridObjectRegistry`.
15
+ *
16
+ * @param name The name of the `HybridObject` under which it was registered at.
17
+ * @returns An instance of {@linkcode T}
18
+ * @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
19
+ */
20
+ createHybridObject<T extends HybridObject>(name: string): T;
21
+ /**
22
+ * Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
23
+ */
24
+ hasHybridObject(name: string): boolean;
25
+ /**
26
+ * Get a list of all registered Hybrid Objects.
27
+ */
28
+ getAllHybridObjectNames(): string[];
29
+ /**
30
+ * Gets the current build type configuration as defined in the `NITRO_DEBUG`
31
+ * preprocessor flag.
32
+ */
33
+ buildType: 'debug' | 'release';
34
+ /**
35
+ * Boxes the given {@linkcode hybridObject} into a {@linkcode BoxedHybridObject<T>}, which can
36
+ * later be unboxed in a separate Runtime.
37
+ *
38
+ * While Nitro is runtime-agnostic and all `HybridObject`s can be used from a any Runtime,
39
+ * some threading/worklet libraries (like [react-native-worklets-core](https://github.com/margelo/react-native-worklets-core))
40
+ * do not yet support copying over `HybridObject`s as they use newer JSI APIs like `jsi::NativeState`.
41
+ *
42
+ * While those APIs are not yet available, you can still use every Nitro Hybrid Object in a separate
43
+ * Runtime/Worklet context by just boxing it yourself:
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const something = NitroModules.createHybridObject<Something>('Something')
48
+ * const boxed = NitroModules.box(something)
49
+ * const context = Worklets.createContext('DummyContext')
50
+ * context.runAsync(() => {
51
+ * 'worklet'
52
+ * const unboxed = boxed.unbox()
53
+ * console.log(unboxed.name) // --> "Something"
54
+ * })
55
+ * ```
56
+ */
57
+ box<T extends HybridObject>(obj: T): BoxedHybridObject<T>;
58
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=BoxedHybridObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["BoxedHybridObject.ts"],"mappings":"","ignoreList":[]}
@@ -25,28 +25,16 @@ function getFrameworkType() {
25
25
  }
26
26
  class ModuleNotFoundError extends Error {
27
27
  constructor(cause) {
28
- // TurboModule not found, something went wrong!
29
- if (global.__turboModuleProxy == null) {
30
- // TurboModules are not available/new arch is not enabled.
31
- const message = 'Failed to get NitroModules: NitroModules require the new architecture to be enabled!';
32
- const suggestions = [];
33
- suggestions.push('Enable the new architecture in your app to use NitroModules. (See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md)');
34
- const error = messageWithSuggestions(message, suggestions);
35
- super(error, {
36
- cause: cause
37
- });
38
- return;
39
- }
40
28
  const framework = getFrameworkType();
41
29
  if (framework === 'expo-go') {
42
30
  super('NitroModules are not supported in Expo Go! Use EAS (`expo prebuild`) or eject to a bare workflow instead.');
43
31
  return;
44
32
  }
45
- const message = 'Failed to get NitroModules: The native "NitroModules" TurboModule could not be found.';
33
+ const message = 'Failed to get NitroModules: The native "NitroModules" Turbo/Native-Module could not be found.';
46
34
  const suggestions = [];
47
35
  suggestions.push('Make sure react-native-nitro-modules/NitroModules is correctly autolinked (run `npx react-native config` to verify)');
48
- suggestions.push('Make sure you enabled the new architecture (TurboModules) and CodeGen properly generated the "NativeNitroModules"/NitroModulesCxx specs. See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md');
49
- suggestions.push('Make sure you are using react-native 0.74.0 or higher, because NitroModules are built with C++ TurboModules.');
36
+ suggestions.push('Make sure you enabled the new architecture (TurboModules) and CodeGen properly generated the "NativeNitroModules"/NitroModules specs. See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md');
37
+ suggestions.push('Make sure you are using react-native 0.74.0 or higher.');
50
38
  suggestions.push('Make sure you rebuilt the app.');
51
39
  if (framework === 'expo') {
52
40
  suggestions.push('Make sure you ran `expo prebuild`.');
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","BULLET_POINT","messageWithSuggestions","message","suggestions","join","getFrameworkType","ExpoConstants","NativeModules","NativeUnimoduleProxy","modulesConstants","ExponentConstants","appOwnership","ModuleNotFoundError","Error","constructor","cause","global","__turboModuleProxy","push","error","framework","Platform","OS","exports"],"sourceRoot":"../../src","sources":["ModuleNotFoundError.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,MAAMC,YAAY,GAAG,MAAM;AAE3B,SAASC,sBAAsBA,CAC7BC,OAAe,EACfC,WAAqB,EACb;EACR,OAAOD,OAAO,GAAGF,YAAY,GAAGG,WAAW,CAACC,IAAI,CAACJ,YAAY,CAAC;AAChE;AAEA,SAASK,gBAAgBA,CAAA,EAAwC;EAC/D;EACA,MAAMC,aAAa,GACjBC,0BAAa,CAACC,oBAAoB,EAAEC,gBAAgB,EAAEC,iBAAiB;EACzE,IAAIJ,aAAa,IAAI,IAAI,EAAE;IACzB,IAAIA,aAAa,CAACK,YAAY,KAAK,MAAM,EAAE;MACzC;MACA,OAAO,SAAS;IAClB,CAAC,MAAM;MACL;MACA,OAAO,MAAM;IACf;EACF;EACA,OAAO,cAAc;AACvB;AAEO,MAAMC,mBAAmB,SAASC,KAAK,CAAC;EAC7CC,WAAWA,CAACC,KAAe,EAAE;IAC3B;IACA,IAAIC,MAAM,CAACC,kBAAkB,IAAI,IAAI,EAAE;MACrC;MACA,MAAMf,OAAO,GACX,sFAAsF;MACxF,MAAMC,WAAqB,GAAG,EAAE;MAChCA,WAAW,CAACe,IAAI,CACd,2JACF,CAAC;MACD,MAAMC,KAAK,GAAGlB,sBAAsB,CAACC,OAAO,EAAEC,WAAW,CAAC;MAC1D,KAAK,CAACgB,KAAK,EAAE;QAAEJ,KAAK,EAAEA;MAAM,CAAC,CAAC;MAC9B;IACF;IAEA,MAAMK,SAAS,GAAGf,gBAAgB,CAAC,CAAC;IACpC,IAAIe,SAAS,KAAK,SAAS,EAAE;MAC3B,KAAK,CACH,2GACF,CAAC;MACD;IACF;IAEA,MAAMlB,OAAO,GACX,uFAAuF;IACzF,MAAMC,WAAqB,GAAG,EAAE;IAChCA,WAAW,CAACe,IAAI,CACd,qHACF,CAAC;IACDf,WAAW,CAACe,IAAI,CACd,qOACF,CAAC;IACDf,WAAW,CAACe,IAAI,CACd,8GACF,CAAC;IACDf,WAAW,CAACe,IAAI,CAAC,gCAAgC,CAAC;IAClD,IAAIE,SAAS,KAAK,MAAM,EAAE;MACxBjB,WAAW,CAACe,IAAI,CAAC,oCAAoC,CAAC;IACxD;IACA,QAAQG,qBAAQ,CAACC,EAAE;MACjB,KAAK,KAAK;MACV,KAAK,OAAO;QACVnB,WAAW,CAACe,IAAI,CACd,wDACF,CAAC;QACD;MACF,KAAK,SAAS;QACZf,WAAW,CAACe,IAAI,CAAC,6BAA6B,CAAC;QAC/C;MACF;QACE,MAAM,IAAIL,KAAK,CAAC,yCAAyCQ,qBAAQ,CAACC,EAAE,GAAG,CAAC;IAC5E;IAEA,MAAMH,KAAK,GAAGlB,sBAAsB,CAACC,OAAO,EAAEC,WAAW,CAAC;IAC1D,KAAK,CAACgB,KAAK,EAAE;MAAEJ,KAAK,EAAEA;IAAM,CAAC,CAAC;EAChC;AACF;AAACQ,OAAA,CAAAX,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","BULLET_POINT","messageWithSuggestions","message","suggestions","join","getFrameworkType","ExpoConstants","NativeModules","NativeUnimoduleProxy","modulesConstants","ExponentConstants","appOwnership","ModuleNotFoundError","Error","constructor","cause","framework","push","Platform","OS","error","exports"],"sourceRoot":"../../src","sources":["ModuleNotFoundError.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,MAAMC,YAAY,GAAG,MAAM;AAE3B,SAASC,sBAAsBA,CAC7BC,OAAe,EACfC,WAAqB,EACb;EACR,OAAOD,OAAO,GAAGF,YAAY,GAAGG,WAAW,CAACC,IAAI,CAACJ,YAAY,CAAC;AAChE;AAEA,SAASK,gBAAgBA,CAAA,EAAwC;EAC/D;EACA,MAAMC,aAAa,GACjBC,0BAAa,CAACC,oBAAoB,EAAEC,gBAAgB,EAAEC,iBAAiB;EACzE,IAAIJ,aAAa,IAAI,IAAI,EAAE;IACzB,IAAIA,aAAa,CAACK,YAAY,KAAK,MAAM,EAAE;MACzC;MACA,OAAO,SAAS;IAClB,CAAC,MAAM;MACL;MACA,OAAO,MAAM;IACf;EACF;EACA,OAAO,cAAc;AACvB;AAEO,MAAMC,mBAAmB,SAASC,KAAK,CAAC;EAC7CC,WAAWA,CAACC,KAAe,EAAE;IAC3B,MAAMC,SAAS,GAAGX,gBAAgB,CAAC,CAAC;IACpC,IAAIW,SAAS,KAAK,SAAS,EAAE;MAC3B,KAAK,CACH,2GACF,CAAC;MACD;IACF;IAEA,MAAMd,OAAO,GACX,+FAA+F;IACjG,MAAMC,WAAqB,GAAG,EAAE;IAChCA,WAAW,CAACc,IAAI,CACd,qHACF,CAAC;IACDd,WAAW,CAACc,IAAI,CACd,kOACF,CAAC;IACDd,WAAW,CAACc,IAAI,CAAC,wDAAwD,CAAC;IAC1Ed,WAAW,CAACc,IAAI,CAAC,gCAAgC,CAAC;IAClD,IAAID,SAAS,KAAK,MAAM,EAAE;MACxBb,WAAW,CAACc,IAAI,CAAC,oCAAoC,CAAC;IACxD;IACA,QAAQC,qBAAQ,CAACC,EAAE;MACjB,KAAK,KAAK;MACV,KAAK,OAAO;QACVhB,WAAW,CAACc,IAAI,CACd,wDACF,CAAC;QACD;MACF,KAAK,SAAS;QACZd,WAAW,CAACc,IAAI,CAAC,6BAA6B,CAAC;QAC/C;MACF;QACE,MAAM,IAAIJ,KAAK,CAAC,yCAAyCK,qBAAQ,CAACC,EAAE,GAAG,CAAC;IAC5E;IAEA,MAAMC,KAAK,GAAGnB,sBAAsB,CAACC,OAAO,EAAEC,WAAW,CAAC;IAC1D,KAAK,CAACiB,KAAK,EAAE;MAAEL,KAAK,EAAEA;IAAM,CAAC,CAAC;EAChC;AACF;AAACM,OAAA,CAAAT,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -3,76 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.NitroModules = void 0;
7
- var _NitroModulesTurboModule = require("./NitroModulesTurboModule");
8
- // TODO: Do we wanna support such constructors?
9
- // @ts-expect-error
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
-
12
- /**
13
- * A lazy proxy for initializing Nitro Modules HybridObjects.
14
- */
15
- const NitroModules = exports.NitroModules = {
16
- /**
17
- * Create a new instance of the `HybridObject` {@linkcode T}.
18
- *
19
- * {@linkcode T} has to be registered beforehand under the name {@linkcode name}
20
- * in the native Nitro Modules `HybridObjectRegistry`.
21
- *
22
- * @param name The name of the `HybridObject` under which it was registered at.
23
- * @returns An instance of {@linkcode T}
24
- * @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
25
- */
26
- createHybridObject(name) {
27
- const nitro = (0, _NitroModulesTurboModule.getNativeNitroModules)();
28
- const instance = nitro.createHybridObject(name);
29
- return instance;
30
- },
31
- /**
32
- * Get a list of all registered Hybrid Objects.
33
- */
34
- getAllHybridObjectNames() {
35
- const nitro = (0, _NitroModulesTurboModule.getNativeNitroModules)();
36
- return nitro.getAllHybridObjectNames();
37
- },
38
- /**
39
- * Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
40
- */
41
- hasHybridObject(name) {
42
- const nitro = (0, _NitroModulesTurboModule.getNativeNitroModules)();
43
- return nitro.hasHybridObject(name);
44
- },
45
- /**
46
- * Returns whether the given {@linkcode object} has a `NativeState` or not.
47
- *
48
- * This can be a quick way to check if an object is a valid {@linkcode HybridObject},
49
- * and has not yet been disposed.
50
- * @example
51
- * ```ts
52
- * const someObject = NitroModules.createHybridObject<Some>('Some')
53
- * console.log(NitroModules.hasNativeState(someObject)) // -> true
54
- * someObject.dispose()
55
- * console.log(NitroModules.hasNativeState(someObject)) // -> false
56
- * ```
57
- */
58
- hasNativeState(object) {
59
- const nitro = (0, _NitroModulesTurboModule.getNativeNitroModules)();
60
- return nitro.hasNativeState(object);
61
- },
62
- /**
63
- * Forcefully removes the `NativeState` of the given {@linkcode object}.
64
- */
65
- removeNativeState(object) {
66
- const nitro = (0, _NitroModulesTurboModule.getNativeNitroModules)();
67
- nitro.removeNativeState(object);
68
- },
69
- /**
70
- * Gets the current build type configuration as defined in the `NITRO_DEBUG`
71
- * preprocessor flag.
72
- */
73
- get buildType() {
74
- const nitro = (0, _NitroModulesTurboModule.getNativeNitroModules)();
75
- return nitro.buildType;
76
- }
77
- };
6
+ var _NativeNitroModules = require("./turbomodule/NativeNitroModules");
7
+ Object.keys(_NativeNitroModules).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _NativeNitroModules[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _NativeNitroModules[key];
14
+ }
15
+ });
16
+ });
78
17
  //# sourceMappingURL=NitroModules.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_NitroModulesTurboModule","require","NitroModules","exports","createHybridObject","name","nitro","getNativeNitroModules","instance","getAllHybridObjectNames","hasHybridObject","hasNativeState","object","removeNativeState","buildType"],"sourceRoot":"../../src","sources":["NitroModules.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,kBAAkBA,CAA8BC,IAAY,EAAK;IAC/D,MAAMC,KAAK,GAAG,IAAAC,8CAAqB,EAAC,CAAC;IACrC,MAAMC,QAAQ,GAAGF,KAAK,CAACF,kBAAkB,CAACC,IAAI,CAAC;IAC/C,OAAOG,QAAQ;EACjB,CAAC;EACD;AACF;AACA;EACEC,uBAAuBA,CAAA,EAAa;IAClC,MAAMH,KAAK,GAAG,IAAAC,8CAAqB,EAAC,CAAC;IACrC,OAAOD,KAAK,CAACG,uBAAuB,CAAC,CAAC;EACxC,CAAC;EACD;AACF;AACA;EACEC,eAAeA,CAACL,IAAY,EAAW;IACrC,MAAMC,KAAK,GAAG,IAAAC,8CAAqB,EAAC,CAAC;IACrC,OAAOD,KAAK,CAACI,eAAe,CAACL,IAAI,CAAC;EACpC,CAAC;EACD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEM,cAAcA,CAACC,MAAc,EAAW;IACtC,MAAMN,KAAK,GAAG,IAAAC,8CAAqB,EAAC,CAAC;IACrC,OAAOD,KAAK,CAACK,cAAc,CAACC,MAAM,CAAC;EACrC,CAAC;EACD;AACF;AACA;EACEC,iBAAiBA,CAACD,MAAc,EAAQ;IACtC,MAAMN,KAAK,GAAG,IAAAC,8CAAqB,EAAC,CAAC;IACrCD,KAAK,CAACO,iBAAiB,CAACD,MAAM,CAAC;EACjC,CAAC;EACD;AACF;AACA;AACA;EACE,IAAIE,SAASA,CAAA,EAAwB;IACnC,MAAMR,KAAK,GAAG,IAAAC,8CAAqB,EAAC,CAAC;IACrC,OAAOD,KAAK,CAACQ,SAAS;EACxB;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_NativeNitroModules","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["NitroModules.ts"],"mappings":";;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,mBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,mBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,mBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=NitroModulesProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroModulesProxy.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NitroModules = void 0;
7
+ exports.isRuntimeAlive = isRuntimeAlive;
8
+ var _reactNative = require("react-native");
9
+ var _ModuleNotFoundError = require("../ModuleNotFoundError");
10
+ // 1. Get (and initialize) the TurboModule
11
+ let turboModule;
12
+ try {
13
+ turboModule = _reactNative.TurboModuleRegistry.getEnforcing('NitroModules');
14
+ } catch (e) {
15
+ throw new _ModuleNotFoundError.ModuleNotFoundError(e);
16
+ }
17
+
18
+ // 2. Install Dispatcher and install `NitroModulesProxy` into the Runtime's `global`
19
+ const errorMessage = turboModule.install();
20
+ if (errorMessage != null) {
21
+ throw new Error(`Failed to install Nitro: ${errorMessage}`);
22
+ }
23
+
24
+ // 3. Find `NitroModulesProxy` in `global`
25
+ // @ts-expect-error
26
+ const NitroModules = exports.NitroModules = global.NitroModulesProxy;
27
+ if (NitroModules == null) {
28
+ const cause = new Error('NitroModules was installed, but `global.NitroModulesProxy` was null!');
29
+ throw new _ModuleNotFoundError.ModuleNotFoundError(cause);
30
+ }
31
+ function isRuntimeAlive() {
32
+ const cache = global.__nitroModulesJSICache;
33
+ const dispatcher = global.__nitroDispatcher;
34
+ return cache != null && dispatcher != null;
35
+ }
36
+ //# sourceMappingURL=NativeNitroModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_ModuleNotFoundError","turboModule","TurboModuleRegistry","getEnforcing","e","ModuleNotFoundError","errorMessage","install","Error","NitroModules","exports","global","NitroModulesProxy","cause","isRuntimeAlive","cache","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../../src","sources":["turbomodule/NativeNitroModules.ts"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAYA;AACA,IAAIE,WAA6B;AACjC,IAAI;EACFA,WAAW,GAAGC,gCAAmB,CAACC,YAAY,CAAO,cAAc,CAAC;AACtE,CAAC,CAAC,OAAOC,CAAC,EAAE;EACV,MAAM,IAAIC,wCAAmB,CAACD,CAAC,CAAC;AAClC;;AAEA;AACA,MAAME,YAAY,GAAGL,WAAW,CAACM,OAAO,CAAC,CAAC;AAC1C,IAAID,YAAY,IAAI,IAAI,EAAE;EACxB,MAAM,IAAIE,KAAK,CAAC,4BAA4BF,YAAY,EAAE,CAAC;AAC7D;;AAEA;AACA;AACO,MAAMG,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAGE,MAAM,CAACC,iBAAsC;AACzE,IAAIH,YAAY,IAAI,IAAI,EAAE;EACxB,MAAMI,KAAK,GAAG,IAAIL,KAAK,CACrB,sEACF,CAAC;EACD,MAAM,IAAIH,wCAAmB,CAACQ,KAAK,CAAC;AACtC;AAOO,SAASC,cAAcA,CAAA,EAAG;EAC/B,MAAMC,KAAK,GAAGJ,MAAM,CAACK,sBAAsB;EAC3C,MAAMC,UAAU,GAAGN,MAAM,CAACO,iBAAiB;EAC3C,OAAOH,KAAK,IAAI,IAAI,IAAIE,UAAU,IAAI,IAAI;AAC5C","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NitroModules = void 0;
7
+ exports.isRuntimeAlive = isRuntimeAlive;
8
+ var _reactNative = require("react-native");
9
+ const NitroModules = exports.NitroModules = new Proxy({}, {
10
+ get: () => {
11
+ throw new Error(`Native NitroModules are not available on ${_reactNative.Platform.OS}! Make sure you're not calling getNativeNitroModules() in a ${_reactNative.Platform.OS} (.${_reactNative.Platform.OS}.ts) environment.`);
12
+ }
13
+ });
14
+ function isRuntimeAlive() {
15
+ return false;
16
+ }
17
+ //# sourceMappingURL=NativeNitroModules.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","NitroModules","exports","Proxy","get","Error","Platform","OS","isRuntimeAlive"],"sourceRoot":"../../../src","sources":["turbomodule/NativeNitroModules.web.ts"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAIE,KAAK,CACnC,CAAC,CAAC,EACF;EACEC,GAAG,EAAEA,CAAA,KAAM;IACT,MAAM,IAAIC,KAAK,CACb,4CAA4CC,qBAAQ,CAACC,EAAE,+DAA+DD,qBAAQ,CAACC,EAAE,MAAMD,qBAAQ,CAACC,EAAE,mBACpJ,CAAC;EACH;AACF,CACF,CAAC;AAEM,SAASC,cAAcA,CAAA,EAAY;EACxC,OAAO,KAAK;AACd","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=BoxedHybridObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["BoxedHybridObject.ts"],"mappings":"","ignoreList":[]}
@@ -21,28 +21,16 @@ function getFrameworkType() {
21
21
  }
22
22
  export class ModuleNotFoundError extends Error {
23
23
  constructor(cause) {
24
- // TurboModule not found, something went wrong!
25
- if (global.__turboModuleProxy == null) {
26
- // TurboModules are not available/new arch is not enabled.
27
- const message = 'Failed to get NitroModules: NitroModules require the new architecture to be enabled!';
28
- const suggestions = [];
29
- suggestions.push('Enable the new architecture in your app to use NitroModules. (See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md)');
30
- const error = messageWithSuggestions(message, suggestions);
31
- super(error, {
32
- cause: cause
33
- });
34
- return;
35
- }
36
24
  const framework = getFrameworkType();
37
25
  if (framework === 'expo-go') {
38
26
  super('NitroModules are not supported in Expo Go! Use EAS (`expo prebuild`) or eject to a bare workflow instead.');
39
27
  return;
40
28
  }
41
- const message = 'Failed to get NitroModules: The native "NitroModules" TurboModule could not be found.';
29
+ const message = 'Failed to get NitroModules: The native "NitroModules" Turbo/Native-Module could not be found.';
42
30
  const suggestions = [];
43
31
  suggestions.push('Make sure react-native-nitro-modules/NitroModules is correctly autolinked (run `npx react-native config` to verify)');
44
- suggestions.push('Make sure you enabled the new architecture (TurboModules) and CodeGen properly generated the "NativeNitroModules"/NitroModulesCxx specs. See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md');
45
- suggestions.push('Make sure you are using react-native 0.74.0 or higher, because NitroModules are built with C++ TurboModules.');
32
+ suggestions.push('Make sure you enabled the new architecture (TurboModules) and CodeGen properly generated the "NativeNitroModules"/NitroModules specs. See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md');
33
+ suggestions.push('Make sure you are using react-native 0.74.0 or higher.');
46
34
  suggestions.push('Make sure you rebuilt the app.');
47
35
  if (framework === 'expo') {
48
36
  suggestions.push('Make sure you ran `expo prebuild`.');
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","BULLET_POINT","messageWithSuggestions","message","suggestions","join","getFrameworkType","ExpoConstants","NativeUnimoduleProxy","modulesConstants","ExponentConstants","appOwnership","ModuleNotFoundError","Error","constructor","cause","global","__turboModuleProxy","push","error","framework","OS"],"sourceRoot":"../../src","sources":["ModuleNotFoundError.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAOtD,MAAMC,YAAY,GAAG,MAAM;AAE3B,SAASC,sBAAsBA,CAC7BC,OAAe,EACfC,WAAqB,EACb;EACR,OAAOD,OAAO,GAAGF,YAAY,GAAGG,WAAW,CAACC,IAAI,CAACJ,YAAY,CAAC;AAChE;AAEA,SAASK,gBAAgBA,CAAA,EAAwC;EAC/D;EACA,MAAMC,aAAa,GACjBR,aAAa,CAACS,oBAAoB,EAAEC,gBAAgB,EAAEC,iBAAiB;EACzE,IAAIH,aAAa,IAAI,IAAI,EAAE;IACzB,IAAIA,aAAa,CAACI,YAAY,KAAK,MAAM,EAAE;MACzC;MACA,OAAO,SAAS;IAClB,CAAC,MAAM;MACL;MACA,OAAO,MAAM;IACf;EACF;EACA,OAAO,cAAc;AACvB;AAEA,OAAO,MAAMC,mBAAmB,SAASC,KAAK,CAAC;EAC7CC,WAAWA,CAACC,KAAe,EAAE;IAC3B;IACA,IAAIC,MAAM,CAACC,kBAAkB,IAAI,IAAI,EAAE;MACrC;MACA,MAAMd,OAAO,GACX,sFAAsF;MACxF,MAAMC,WAAqB,GAAG,EAAE;MAChCA,WAAW,CAACc,IAAI,CACd,2JACF,CAAC;MACD,MAAMC,KAAK,GAAGjB,sBAAsB,CAACC,OAAO,EAAEC,WAAW,CAAC;MAC1D,KAAK,CAACe,KAAK,EAAE;QAAEJ,KAAK,EAAEA;MAAM,CAAC,CAAC;MAC9B;IACF;IAEA,MAAMK,SAAS,GAAGd,gBAAgB,CAAC,CAAC;IACpC,IAAIc,SAAS,KAAK,SAAS,EAAE;MAC3B,KAAK,CACH,2GACF,CAAC;MACD;IACF;IAEA,MAAMjB,OAAO,GACX,uFAAuF;IACzF,MAAMC,WAAqB,GAAG,EAAE;IAChCA,WAAW,CAACc,IAAI,CACd,qHACF,CAAC;IACDd,WAAW,CAACc,IAAI,CACd,qOACF,CAAC;IACDd,WAAW,CAACc,IAAI,CACd,8GACF,CAAC;IACDd,WAAW,CAACc,IAAI,CAAC,gCAAgC,CAAC;IAClD,IAAIE,SAAS,KAAK,MAAM,EAAE;MACxBhB,WAAW,CAACc,IAAI,CAAC,oCAAoC,CAAC;IACxD;IACA,QAAQlB,QAAQ,CAACqB,EAAE;MACjB,KAAK,KAAK;MACV,KAAK,OAAO;QACVjB,WAAW,CAACc,IAAI,CACd,wDACF,CAAC;QACD;MACF,KAAK,SAAS;QACZd,WAAW,CAACc,IAAI,CAAC,6BAA6B,CAAC;QAC/C;MACF;QACE,MAAM,IAAIL,KAAK,CAAC,yCAAyCb,QAAQ,CAACqB,EAAE,GAAG,CAAC;IAC5E;IAEA,MAAMF,KAAK,GAAGjB,sBAAsB,CAACC,OAAO,EAAEC,WAAW,CAAC;IAC1D,KAAK,CAACe,KAAK,EAAE;MAAEJ,KAAK,EAAEA;IAAM,CAAC,CAAC;EAChC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","BULLET_POINT","messageWithSuggestions","message","suggestions","join","getFrameworkType","ExpoConstants","NativeUnimoduleProxy","modulesConstants","ExponentConstants","appOwnership","ModuleNotFoundError","Error","constructor","cause","framework","push","OS","error"],"sourceRoot":"../../src","sources":["ModuleNotFoundError.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAOtD,MAAMC,YAAY,GAAG,MAAM;AAE3B,SAASC,sBAAsBA,CAC7BC,OAAe,EACfC,WAAqB,EACb;EACR,OAAOD,OAAO,GAAGF,YAAY,GAAGG,WAAW,CAACC,IAAI,CAACJ,YAAY,CAAC;AAChE;AAEA,SAASK,gBAAgBA,CAAA,EAAwC;EAC/D;EACA,MAAMC,aAAa,GACjBR,aAAa,CAACS,oBAAoB,EAAEC,gBAAgB,EAAEC,iBAAiB;EACzE,IAAIH,aAAa,IAAI,IAAI,EAAE;IACzB,IAAIA,aAAa,CAACI,YAAY,KAAK,MAAM,EAAE;MACzC;MACA,OAAO,SAAS;IAClB,CAAC,MAAM;MACL;MACA,OAAO,MAAM;IACf;EACF;EACA,OAAO,cAAc;AACvB;AAEA,OAAO,MAAMC,mBAAmB,SAASC,KAAK,CAAC;EAC7CC,WAAWA,CAACC,KAAe,EAAE;IAC3B,MAAMC,SAAS,GAAGV,gBAAgB,CAAC,CAAC;IACpC,IAAIU,SAAS,KAAK,SAAS,EAAE;MAC3B,KAAK,CACH,2GACF,CAAC;MACD;IACF;IAEA,MAAMb,OAAO,GACX,+FAA+F;IACjG,MAAMC,WAAqB,GAAG,EAAE;IAChCA,WAAW,CAACa,IAAI,CACd,qHACF,CAAC;IACDb,WAAW,CAACa,IAAI,CACd,kOACF,CAAC;IACDb,WAAW,CAACa,IAAI,CAAC,wDAAwD,CAAC;IAC1Eb,WAAW,CAACa,IAAI,CAAC,gCAAgC,CAAC;IAClD,IAAID,SAAS,KAAK,MAAM,EAAE;MACxBZ,WAAW,CAACa,IAAI,CAAC,oCAAoC,CAAC;IACxD;IACA,QAAQjB,QAAQ,CAACkB,EAAE;MACjB,KAAK,KAAK;MACV,KAAK,OAAO;QACVd,WAAW,CAACa,IAAI,CACd,wDACF,CAAC;QACD;MACF,KAAK,SAAS;QACZb,WAAW,CAACa,IAAI,CAAC,6BAA6B,CAAC;QAC/C;MACF;QACE,MAAM,IAAIJ,KAAK,CAAC,yCAAyCb,QAAQ,CAACkB,EAAE,GAAG,CAAC;IAC5E;IAEA,MAAMC,KAAK,GAAGjB,sBAAsB,CAACC,OAAO,EAAEC,WAAW,CAAC;IAC1D,KAAK,CAACe,KAAK,EAAE;MAAEJ,KAAK,EAAEA;IAAM,CAAC,CAAC;EAChC;AACF","ignoreList":[]}
@@ -1,75 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import { getNativeNitroModules } from './NitroModulesTurboModule';
4
-
5
- // TODO: Do we wanna support such constructors?
6
- // @ts-expect-error
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
-
9
- /**
10
- * A lazy proxy for initializing Nitro Modules HybridObjects.
11
- */
12
- export const NitroModules = {
13
- /**
14
- * Create a new instance of the `HybridObject` {@linkcode T}.
15
- *
16
- * {@linkcode T} has to be registered beforehand under the name {@linkcode name}
17
- * in the native Nitro Modules `HybridObjectRegistry`.
18
- *
19
- * @param name The name of the `HybridObject` under which it was registered at.
20
- * @returns An instance of {@linkcode T}
21
- * @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
22
- */
23
- createHybridObject(name) {
24
- const nitro = getNativeNitroModules();
25
- const instance = nitro.createHybridObject(name);
26
- return instance;
27
- },
28
- /**
29
- * Get a list of all registered Hybrid Objects.
30
- */
31
- getAllHybridObjectNames() {
32
- const nitro = getNativeNitroModules();
33
- return nitro.getAllHybridObjectNames();
34
- },
35
- /**
36
- * Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
37
- */
38
- hasHybridObject(name) {
39
- const nitro = getNativeNitroModules();
40
- return nitro.hasHybridObject(name);
41
- },
42
- /**
43
- * Returns whether the given {@linkcode object} has a `NativeState` or not.
44
- *
45
- * This can be a quick way to check if an object is a valid {@linkcode HybridObject},
46
- * and has not yet been disposed.
47
- * @example
48
- * ```ts
49
- * const someObject = NitroModules.createHybridObject<Some>('Some')
50
- * console.log(NitroModules.hasNativeState(someObject)) // -> true
51
- * someObject.dispose()
52
- * console.log(NitroModules.hasNativeState(someObject)) // -> false
53
- * ```
54
- */
55
- hasNativeState(object) {
56
- const nitro = getNativeNitroModules();
57
- return nitro.hasNativeState(object);
58
- },
59
- /**
60
- * Forcefully removes the `NativeState` of the given {@linkcode object}.
61
- */
62
- removeNativeState(object) {
63
- const nitro = getNativeNitroModules();
64
- nitro.removeNativeState(object);
65
- },
66
- /**
67
- * Gets the current build type configuration as defined in the `NITRO_DEBUG`
68
- * preprocessor flag.
69
- */
70
- get buildType() {
71
- const nitro = getNativeNitroModules();
72
- return nitro.buildType;
73
- }
74
- };
3
+ // Re-exports the platform specific `NitroModulesProxy` (or a stub-implementation if not found)
4
+ export * from './turbomodule/NativeNitroModules';
75
5
  //# sourceMappingURL=NitroModules.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getNativeNitroModules","NitroModules","createHybridObject","name","nitro","instance","getAllHybridObjectNames","hasHybridObject","hasNativeState","object","removeNativeState","buildType"],"sourceRoot":"../../src","sources":["NitroModules.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,2BAA2B;;AAGjE;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,kBAAkBA,CAA8BC,IAAY,EAAK;IAC/D,MAAMC,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,MAAMK,QAAQ,GAAGD,KAAK,CAACF,kBAAkB,CAACC,IAAI,CAAC;IAC/C,OAAOE,QAAQ;EACjB,CAAC;EACD;AACF;AACA;EACEC,uBAAuBA,CAAA,EAAa;IAClC,MAAMF,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,OAAOI,KAAK,CAACE,uBAAuB,CAAC,CAAC;EACxC,CAAC;EACD;AACF;AACA;EACEC,eAAeA,CAACJ,IAAY,EAAW;IACrC,MAAMC,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,OAAOI,KAAK,CAACG,eAAe,CAACJ,IAAI,CAAC;EACpC,CAAC;EACD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,cAAcA,CAACC,MAAc,EAAW;IACtC,MAAML,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,OAAOI,KAAK,CAACI,cAAc,CAACC,MAAM,CAAC;EACrC,CAAC;EACD;AACF;AACA;EACEC,iBAAiBA,CAACD,MAAc,EAAQ;IACtC,MAAML,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrCI,KAAK,CAACM,iBAAiB,CAACD,MAAM,CAAC;EACjC,CAAC;EACD;AACF;AACA;AACA;EACE,IAAIE,SAASA,CAAA,EAAwB;IACnC,MAAMP,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,OAAOI,KAAK,CAACO,SAAS;EACxB;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroModules.ts"],"mappings":";;AAAA;AACA,cAAc,kCAAkC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=NitroModulesProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroModulesProxy.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ import { ModuleNotFoundError } from '../ModuleNotFoundError';
5
+ // 1. Get (and initialize) the TurboModule
6
+ let turboModule;
7
+ try {
8
+ turboModule = TurboModuleRegistry.getEnforcing('NitroModules');
9
+ } catch (e) {
10
+ throw new ModuleNotFoundError(e);
11
+ }
12
+
13
+ // 2. Install Dispatcher and install `NitroModulesProxy` into the Runtime's `global`
14
+ const errorMessage = turboModule.install();
15
+ if (errorMessage != null) {
16
+ throw new Error(`Failed to install Nitro: ${errorMessage}`);
17
+ }
18
+
19
+ // 3. Find `NitroModulesProxy` in `global`
20
+ // @ts-expect-error
21
+ export const NitroModules = global.NitroModulesProxy;
22
+ if (NitroModules == null) {
23
+ const cause = new Error('NitroModules was installed, but `global.NitroModulesProxy` was null!');
24
+ throw new ModuleNotFoundError(cause);
25
+ }
26
+ export function isRuntimeAlive() {
27
+ const cache = global.__nitroModulesJSICache;
28
+ const dispatcher = global.__nitroDispatcher;
29
+ return cache != null && dispatcher != null;
30
+ }
31
+ //# sourceMappingURL=NativeNitroModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","ModuleNotFoundError","turboModule","getEnforcing","e","errorMessage","install","Error","NitroModules","global","NitroModulesProxy","cause","isRuntimeAlive","cache","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../../src","sources":["turbomodule/NativeNitroModules.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAClD,SAASC,mBAAmB,QAAQ,wBAAwB;AAY5D;AACA,IAAIC,WAA6B;AACjC,IAAI;EACFA,WAAW,GAAGF,mBAAmB,CAACG,YAAY,CAAO,cAAc,CAAC;AACtE,CAAC,CAAC,OAAOC,CAAC,EAAE;EACV,MAAM,IAAIH,mBAAmB,CAACG,CAAC,CAAC;AAClC;;AAEA;AACA,MAAMC,YAAY,GAAGH,WAAW,CAACI,OAAO,CAAC,CAAC;AAC1C,IAAID,YAAY,IAAI,IAAI,EAAE;EACxB,MAAM,IAAIE,KAAK,CAAC,4BAA4BF,YAAY,EAAE,CAAC;AAC7D;;AAEA;AACA;AACA,OAAO,MAAMG,YAAY,GAAGC,MAAM,CAACC,iBAAsC;AACzE,IAAIF,YAAY,IAAI,IAAI,EAAE;EACxB,MAAMG,KAAK,GAAG,IAAIJ,KAAK,CACrB,sEACF,CAAC;EACD,MAAM,IAAIN,mBAAmB,CAACU,KAAK,CAAC;AACtC;AAOA,OAAO,SAASC,cAAcA,CAAA,EAAG;EAC/B,MAAMC,KAAK,GAAGJ,MAAM,CAACK,sBAAsB;EAC3C,MAAMC,UAAU,GAAGN,MAAM,CAACO,iBAAiB;EAC3C,OAAOH,KAAK,IAAI,IAAI,IAAIE,UAAU,IAAI,IAAI;AAC5C","ignoreList":[]}
@@ -1,4 +1,12 @@
1
+ "use strict";
2
+
1
3
  import { Platform } from 'react-native';
2
- export function getNativeNitroModules() {
4
+ export const NitroModules = new Proxy({}, {
5
+ get: () => {
3
6
  throw new Error(`Native NitroModules are not available on ${Platform.OS}! Make sure you're not calling getNativeNitroModules() in a ${Platform.OS} (.${Platform.OS}.ts) environment.`);
7
+ }
8
+ });
9
+ export function isRuntimeAlive() {
10
+ return false;
4
11
  }
12
+ //# sourceMappingURL=NativeNitroModules.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","NitroModules","Proxy","get","Error","OS","isRuntimeAlive"],"sourceRoot":"../../../src","sources":["turbomodule/NativeNitroModules.web.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,YAAY,GAAG,IAAIC,KAAK,CACnC,CAAC,CAAC,EACF;EACEC,GAAG,EAAEA,CAAA,KAAM;IACT,MAAM,IAAIC,KAAK,CACb,4CAA4CJ,QAAQ,CAACK,EAAE,+DAA+DL,QAAQ,CAACK,EAAE,MAAML,QAAQ,CAACK,EAAE,mBACpJ,CAAC;EACH;AACF,CACF,CAAC;AAED,OAAO,SAASC,cAAcA,CAAA,EAAY;EACxC,OAAO,KAAK;AACd","ignoreList":[]}