react-native-nitro-modules 0.4.0 → 0.5.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 (34) hide show
  1. package/NitroModules.podspec +3 -1
  2. package/README.md +32 -1
  3. package/android/gradle.properties +1 -1
  4. package/cpp/core/ArrayBuffer.cpp +88 -0
  5. package/cpp/core/ArrayBuffer.hpp +31 -70
  6. package/cpp/jsi/JSIConverter+Function.hpp +3 -3
  7. package/cpp/jsi/JSIConverter+Promise.hpp +2 -1
  8. package/ios/core/ArrayBufferHolder.hpp +78 -0
  9. package/ios/core/ArrayBufferHolder.swift +48 -0
  10. package/ios/core/Promise.swift +162 -0
  11. package/ios/core/PromiseHolder.hpp +82 -0
  12. package/ios/turbomodule/NitroModuleOnLoad.mm +5 -0
  13. package/ios/utils/ClosureWrapper.swift +45 -0
  14. package/lib/tsconfig.tsbuildinfo +1 -1
  15. package/package.json +1 -1
  16. package/ios/core/HybridContext.cpp +0 -8
  17. package/ios/core/Promise.cpp +0 -10
  18. package/ios/core/Promise.hpp +0 -43
  19. package/lib/typescript/AnyMap.d.ts +0 -17
  20. package/lib/typescript/AnyMap.d.ts.map +0 -1
  21. package/lib/typescript/HybridObject.d.ts +0 -83
  22. package/lib/typescript/HybridObject.d.ts.map +0 -1
  23. package/lib/typescript/ModuleNotFoundError.d.ts +0 -7
  24. package/lib/typescript/ModuleNotFoundError.d.ts.map +0 -1
  25. package/lib/typescript/NativeNitroModules.d.ts +0 -15
  26. package/lib/typescript/NativeNitroModules.d.ts.map +0 -1
  27. package/lib/typescript/NativeNitroModules.web.d.ts +0 -5
  28. package/lib/typescript/NativeNitroModules.web.d.ts.map +0 -1
  29. package/lib/typescript/NitroModules.d.ts +0 -26
  30. package/lib/typescript/NitroModules.d.ts.map +0 -1
  31. package/lib/typescript/__tests__/index.test.d.ts +0 -1
  32. package/lib/typescript/__tests__/index.test.d.ts.map +0 -1
  33. package/lib/typescript/index.d.ts +0 -4
  34. package/lib/typescript/index.d.ts.map +0 -1
@@ -1,83 +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
- * @example
24
- * ```ts
25
- * interface Photo extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
26
- * readonly width: number
27
- * readonly height: number
28
- * toArrayBuffer(): ArrayBuffer
29
- * saveToFile(path: string): Promise<void>
30
- * }
31
- * ```
32
- */
33
- export interface HybridObject<Platforms extends PlatformSpec = {}> {
34
- /**
35
- * Holds a type-name describing the native `HybridObject` instance.
36
- *
37
- * This is the only property actually present on the actual JavaScript object,
38
- * because all other properties and methods are inherited from a shared Prototype.
39
- *
40
- * Nitro prototypes also have a `__type`.
41
- *
42
- * - For actual HybridObject instances, this is `NativeState<...>`
43
- * - For prototypes this is `Prototype<...>`.
44
- *
45
- * @internal
46
- * @private
47
- * @note This value is available in debug only.
48
- */
49
- readonly __type?: string;
50
- /**
51
- * The `HybridObject`'s name.
52
- */
53
- readonly name: string;
54
- /**
55
- * Returns a string representation of the given `HybridObject`.
56
- *
57
- * Unless overridden by the `HybridObject`, this will return the name of the object.
58
- *
59
- * @example
60
- * ```ts
61
- * const hybridA = SomeModule.getExistingHybridInstance()
62
- * console.log(hybridA.toString()) // [HybridObject HybridA]
63
- * ```
64
- */
65
- toString(): string;
66
- /**
67
- * Returns whether this `HybridObject` is the same object as {@linkcode other}.
68
- *
69
- * While two `HybridObject`s might not be equal when compared with `==`, they might still
70
- * hold the same underlying `HybridObject`, in which case {@linkcode equals | equals(other)}
71
- * will return `true`.
72
- *
73
- * @example
74
- * ```ts
75
- * const hybridA = SomeModule.getExistingHybridInstance()
76
- * const hybridB = SomeModule.getExistingHybridInstance()
77
- * console.log(hybridA === hybridB) // false
78
- * console.log(hybridA.equals(hybridB)) // true
79
- * ```
80
- */
81
- equals(other: HybridObject<Platforms>): boolean;
82
- }
83
- //# 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;;;;;;;;;;;;;;;;;;;;;GAqBG;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;CAChD"}
@@ -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;CAwD5B"}
@@ -1,15 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
- export interface Spec extends TurboModule {
4
- install(): void;
5
- createHybridObject(name: string, args?: UnsafeObject): UnsafeObject;
6
- hasHybridObject(name: string): boolean;
7
- getAllHybridObjectNames(): string[];
8
- }
9
- export declare function getNativeNitroModules(): Spec;
10
- declare global {
11
- var __nitroModulesJSICache: {};
12
- var __nitroDispatcher: {};
13
- }
14
- export declare function isRuntimeAlive(): boolean;
15
- //# sourceMappingURL=NativeNitroModules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeNitroModules.d.ts","sourceRoot":"","sources":["../../src/NativeNitroModules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AAG7E,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,IAAI,IAAI,CAAA;IACf,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CAAA;IACnE,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtC,uBAAuB,IAAI,MAAM,EAAE,CAAA;CACpC;AAGD,wBAAgB,qBAAqB,IAAI,IAAI,CAc5C;AAED,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,sBAAsB,EAAE,EAAE,CAAA;IAC9B,IAAI,iBAAiB,EAAE,EAAE,CAAA;CAC1B;AAED,wBAAgB,cAAc,YAI7B"}
@@ -1,5 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- export interface Spec extends TurboModule {
3
- }
4
- export declare function getNativeNitroModules(): Spec;
5
- //# sourceMappingURL=NativeNitroModules.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeNitroModules.web.d.ts","sourceRoot":"","sources":["../../src/NativeNitroModules.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,WAAW,IAAK,SAAQ,WAAW;CAAG;AAE5C,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C"}
@@ -1,26 +0,0 @@
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
- //# sourceMappingURL=NitroModules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NitroModules.d.ts","sourceRoot":"","sources":["../../src/NitroModules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AASlD;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;;;;OASG;uBACgB,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,QAAQ,MAAM,GAAG,CAAC;IAKhE;;OAEG;+BACwB,MAAM,EAAE;IAInC;;OAEG;0BACmB,MAAM,GAAG,OAAO;CAIvC,CAAA"}
@@ -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,4 +0,0 @@
1
- export * from './HybridObject';
2
- export * from './NitroModules';
3
- export * from './AnyMap';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA"}