react-native-nitro-modules 0.13.0 → 0.14.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.
Files changed (44) hide show
  1. package/android/CMakeLists.txt +13 -1
  2. package/android/build.gradle +1 -1
  3. package/cpp/core/HybridFunction.hpp +1 -1
  4. package/cpp/utils/NitroDefines.hpp +0 -8
  5. package/lib/Constructor.d.ts +17 -0
  6. package/lib/Constructor.js +61 -0
  7. package/lib/SyncCallback.d.ts +19 -0
  8. package/lib/SyncCallback.js +1 -0
  9. package/lib/commonjs/Constructor.js +71 -0
  10. package/lib/commonjs/Constructor.js.map +1 -0
  11. package/lib/commonjs/index.js +11 -0
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/index.d.ts +1 -0
  14. package/lib/index.js +1 -0
  15. package/lib/module/Constructor.js +67 -0
  16. package/lib/module/Constructor.js.map +1 -0
  17. package/lib/module/index.js +1 -0
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/tsconfig.tsbuildinfo +1 -1
  20. package/lib/typescript/Constructor.d.ts +18 -0
  21. package/lib/typescript/Constructor.d.ts.map +1 -0
  22. package/lib/typescript/index.d.ts +1 -0
  23. package/lib/typescript/index.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/Constructor.ts +69 -0
  26. package/src/index.ts +1 -0
  27. package/lib/typescript/AnyMap.d.ts +0 -20
  28. package/lib/typescript/AnyMap.d.ts.map +0 -1
  29. package/lib/typescript/BoxedHybridObject.d.ts +0 -13
  30. package/lib/typescript/BoxedHybridObject.d.ts.map +0 -1
  31. package/lib/typescript/HybridObject.d.ts +0 -99
  32. package/lib/typescript/HybridObject.d.ts.map +0 -1
  33. package/lib/typescript/ModuleNotFoundError.d.ts +0 -7
  34. package/lib/typescript/ModuleNotFoundError.d.ts.map +0 -1
  35. package/lib/typescript/NitroModules.d.ts +0 -2
  36. package/lib/typescript/NitroModules.d.ts.map +0 -1
  37. package/lib/typescript/NitroModulesProxy.d.ts +0 -59
  38. package/lib/typescript/NitroModulesProxy.d.ts.map +0 -1
  39. package/lib/typescript/__tests__/index.test.d.ts +0 -1
  40. package/lib/typescript/__tests__/index.test.d.ts.map +0 -1
  41. package/lib/typescript/turbomodule/NativeNitroModules.d.ts +0 -8
  42. package/lib/typescript/turbomodule/NativeNitroModules.d.ts.map +0 -1
  43. package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts +0 -3
  44. package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts.map +0 -1
@@ -1,13 +0,0 @@
1
- import type { HybridObject } from './HybridObject';
2
- /**
3
- * Represents a boxed {@linkcode HybridObject} that can later be unboxed again.
4
- * This is implemented as a `jsi::HostObject`.
5
- */
6
- export interface BoxedHybridObject<T extends HybridObject> {
7
- /**
8
- * Unboxes the {@linkcode HybridObject}.
9
- * This can be called from a different Runtime than the one it was boxed in.
10
- */
11
- unbox(): T;
12
- }
13
- //# sourceMappingURL=BoxedHybridObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BoxedHybridObject.d.ts","sourceRoot":"","sources":["../../src/BoxedHybridObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,YAAY;IACvD;;;OAGG;IACH,KAAK,IAAI,CAAC,CAAA;CACX"}
@@ -1,99 +0,0 @@
1
- /**
2
- * Describes the languages this component will be implemented in.
3
- *
4
- * By default, everything has a C++ base, and can optionally be bridged down
5
- * to platform-specific languages like Swift or Kotlin
6
- */
7
- export interface PlatformSpec {
8
- ios?: 'swift' | 'c++';
9
- android?: 'kotlin' | 'c++';
10
- }
11
- /**
12
- * Represents a Nitro `HybridObject` which is implemented in a native language like
13
- * C++, Swift or Kotlin.
14
- * Every Nitro `HybridObject` has a C++ base, and can optionally be bridged down to Swift or Kotlin.
15
- *
16
- * `HybridObject`s use the Nitro Tunnel for efficient, low-overhead JS <-> Native communication.
17
- *
18
- * All `HybridObject`s are implemented using `NativeState`, and inherit their properties
19
- * and methods from their prototype, so the actual JS object is empty.
20
- *
21
- * @type Platforms: The type of platforms this HybridObject will be implemented in. By default, it is
22
- * a C++ `HybridObject`.
23
- * @default { ios: 'c++', android: 'c++' }
24
- * @example
25
- * ```ts
26
- * interface Photo extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
27
- * readonly width: number
28
- * readonly height: number
29
- * toArrayBuffer(): ArrayBuffer
30
- * saveToFile(path: string): Promise<void>
31
- * }
32
- * ```
33
- */
34
- export interface HybridObject<Platforms extends PlatformSpec = {}> {
35
- /**
36
- * Holds a type-name describing the native `HybridObject` instance.
37
- *
38
- * This is the only property actually present on the actual JavaScript object,
39
- * because all other properties and methods are inherited from a shared Prototype.
40
- *
41
- * Nitro prototypes also have a `__type`.
42
- *
43
- * - For actual HybridObject instances, this is `NativeState<...>`
44
- * - For prototypes this is `Prototype<...>`.
45
- *
46
- * @internal
47
- * @private
48
- * @note This value is available in debug only.
49
- */
50
- readonly __type?: string;
51
- /**
52
- * The `HybridObject`'s name.
53
- */
54
- readonly name: string;
55
- /**
56
- * Returns a string representation of the given `HybridObject`.
57
- *
58
- * Unless overridden by the `HybridObject`, this will return the name of the object.
59
- *
60
- * @example
61
- * ```ts
62
- * const hybridA = SomeModule.getExistingHybridInstance()
63
- * console.log(hybridA.toString()) // [HybridObject HybridA]
64
- * ```
65
- */
66
- toString(): string;
67
- /**
68
- * Returns whether this `HybridObject` is the same object as {@linkcode other}.
69
- *
70
- * While two `HybridObject`s might not be equal when compared with `==`, they might still
71
- * hold the same underlying `HybridObject`, in which case {@linkcode equals | equals(other)}
72
- * will return `true`.
73
- *
74
- * @example
75
- * ```ts
76
- * const hybridA = SomeModule.getExistingHybridInstance()
77
- * const hybridB = SomeModule.getExistingHybridInstance()
78
- * console.log(hybridA === hybridB) // false
79
- * console.log(hybridA.equals(hybridB)) // true
80
- * ```
81
- */
82
- equals(other: HybridObject<Platforms>): boolean;
83
- /**
84
- * Disposes any resources this {@linkcode HybridObject} might hold natively,
85
- * and finally releases this {@linkcode HybridObject}'s `NativeState`.
86
- *
87
- * After calling {@linkcode dispose()}, this object can no longer be used.
88
- *
89
- * Eagerly disposing a {@linkcode HybridObject} could be beneficial for a queue-/handler-architecture
90
- * where a bunch of Hybrid Objects are allocated, and later deallocated once a callback (e.g. a render function)
91
- * completes.
92
- *
93
- * @note It is **NOT** required to call {@linkcode dispose()} manually, as the JavaScript
94
- * Garbage Collector automatically disposes and releases any resources when needed.
95
- * It is purely optional to eagerly-, and manually-, call {@linkcode dispose()} here - **use with caution!**
96
- */
97
- dispose(): void;
98
- }
99
- //# sourceMappingURL=HybridObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HybridObject.d.ts","sourceRoot":"","sources":["../../src/HybridObject.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IACrB,OAAO,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,YAAY,CAAC,SAAS,SAAS,YAAY,GAAG,EAAE;IAC/D;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;;;;;;;OAUG;IACH,QAAQ,IAAI,MAAM,CAAA;IAClB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,OAAO,CAAA;IAC/C;;;;;;;;;;;;;OAaG;IACH,OAAO,IAAI,IAAI,CAAA;CAChB"}
@@ -1,7 +0,0 @@
1
- declare global {
2
- var __turboModuleProxy: unknown | undefined;
3
- }
4
- export declare class ModuleNotFoundError extends Error {
5
- constructor(cause?: unknown);
6
- }
7
- //# sourceMappingURL=ModuleNotFoundError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModuleNotFoundError.d.ts","sourceRoot":"","sources":["../../src/ModuleNotFoundError.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAA;CAC5C;AA2BD,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,KAAK,CAAC,EAAE,OAAO;CAwC5B"}
@@ -1,2 +0,0 @@
1
- export * from './turbomodule/NativeNitroModules';
2
- //# sourceMappingURL=NitroModules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NitroModules.d.ts","sourceRoot":"","sources":["../../src/NitroModules.ts"],"names":[],"mappings":"AACA,cAAc,kCAAkC,CAAA"}
@@ -1,59 +0,0 @@
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
- }
59
- //# sourceMappingURL=NitroModulesProxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NitroModulesProxy.d.ts","sourceRoot":"","sources":["../../src/NitroModulesProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD;;;;;;;;;OASG;IACH,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAA;IAC3D;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtC;;OAEG;IACH,uBAAuB,IAAI,MAAM,EAAE,CAAA;IAEnC;;;OAGG;IACH,SAAS,EAAE,OAAO,GAAG,SAAS,CAAA;IAE9B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,GAAG,CAAC,CAAC,SAAS,YAAY,EAAE,GAAG,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;CAC1D"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/index.test.tsx"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import type { NitroModulesProxy } from '../NitroModulesProxy';
2
- export declare const NitroModules: NitroModulesProxy;
3
- declare global {
4
- var __nitroModulesJSICache: {};
5
- var __nitroDispatcher: {};
6
- }
7
- export declare function isRuntimeAlive(): boolean;
8
- //# sourceMappingURL=NativeNitroModules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeNitroModules.d.ts","sourceRoot":"","sources":["../../../src/turbomodule/NativeNitroModules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AA2B7D,eAAO,MAAM,YAAY,EAA+B,iBAAiB,CAAA;AAQzE,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,sBAAsB,EAAE,EAAE,CAAA;IAC9B,IAAI,iBAAiB,EAAE,EAAE,CAAA;CAC1B;AAED,wBAAgB,cAAc,YAI7B"}
@@ -1,3 +0,0 @@
1
- export declare const NitroModules: {};
2
- export declare function isRuntimeAlive(): boolean;
3
- //# sourceMappingURL=NativeNitroModules.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeNitroModules.web.d.ts","sourceRoot":"","sources":["../../../src/turbomodule/NativeNitroModules.web.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,IASxB,CAAA;AAED,wBAAgB,cAAc,IAAI,OAAO,CAExC"}