react-native-nitro-modules 0.21.0 → 0.22.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.
- package/NitroModules.podspec +4 -1
- package/README.md +1 -1
- package/android/CMakeLists.txt +1 -0
- package/android/build.gradle +4 -2
- package/android/gradle.properties +2 -2
- package/android/src/main/cpp/platform/ThreadUtils.cpp +4 -4
- package/android/src/main/cpp/registry/JHybridObjectRegistry.hpp +2 -0
- package/android/src/main/java/com/margelo/nitro/core/HybridObject.kt +10 -9
- package/android/src/main/java/com/margelo/nitro/core/HybridObjectInitializer.java +4 -0
- package/android/src/main/java/com/margelo/nitro/core/HybridObjectRegistry.java +2 -0
- package/android/src/main/java/com/margelo/nitro/views/HybridView.kt +23 -0
- package/cpp/core/HybridFunction.hpp +1 -1
- package/cpp/core/HybridObject.cpp +7 -6
- package/cpp/core/HybridObject.hpp +2 -2
- package/cpp/core/Promise.hpp +1 -1
- package/cpp/entrypoint/HybridNitroModulesProxy.cpp +8 -0
- package/cpp/entrypoint/HybridNitroModulesProxy.hpp +1 -0
- package/cpp/jsi/JSICache.cpp +1 -0
- package/cpp/jsi/JSICache.hpp +6 -0
- package/cpp/jsi/JSIConverter+Exception.hpp +1 -1
- package/cpp/jsi/JSIConverter+HostObject.hpp +1 -1
- package/cpp/jsi/JSIConverter+HybridObject.hpp +1 -1
- package/cpp/jsi/JSIConverter+Tuple.hpp +1 -1
- package/cpp/jsi/JSIConverter+Variant.hpp +1 -1
- package/cpp/jsi/JSIHelpers.hpp +1 -1
- package/cpp/prototype/HybridObjectPrototype.cpp +1 -1
- package/cpp/registry/HybridObjectRegistry.cpp +25 -12
- package/cpp/registry/HybridObjectRegistry.hpp +1 -0
- package/cpp/utils/AssertPromiseState.hpp +1 -1
- package/cpp/utils/BorrowingReference.hpp +4 -2
- package/cpp/utils/NitroDefines.hpp +13 -1
- package/cpp/utils/NitroHash.hpp +17 -0
- package/cpp/utils/{TypeInfo.hpp → NitroTypeInfo.hpp} +1 -1
- package/cpp/utils/OwningReference.hpp +15 -2
- package/cpp/views/CachedProp.hpp +43 -0
- package/ios/core/HybridContext.hpp +1 -1
- package/ios/core/{HybridObjectSpec.swift → HybridObject.swift} +10 -2
- package/ios/utils/RuntimeError.hpp +1 -1
- package/ios/views/HybridView.swift +41 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/views/HybridView.js +17 -0
- package/lib/commonjs/views/HybridView.js.map +1 -0
- package/lib/commonjs/views/getHostComponent.js +22 -0
- package/lib/commonjs/views/getHostComponent.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/views/HybridView.js +30 -0
- package/lib/module/views/HybridView.js.map +1 -0
- package/lib/module/views/getHostComponent.js +15 -0
- package/lib/module/views/getHostComponent.js.map +1 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/NitroModulesProxy.d.ts +7 -0
- package/lib/typescript/NitroModulesProxy.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/views/HybridView.d.ts +35 -0
- package/lib/typescript/views/HybridView.d.ts.map +1 -0
- package/lib/typescript/views/getHostComponent.d.ts +13 -0
- package/lib/typescript/views/getHostComponent.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/NitroModulesProxy.ts +8 -0
- package/src/index.ts +1 -0
- package/src/views/HybridView.ts +37 -0
- package/src/views/getHostComponent.ts +26 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HybridObject } from '../HybridObject'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Describes the languages this view will be implemented in.
|
|
5
|
+
*/
|
|
6
|
+
export interface ViewPlatformSpec {
|
|
7
|
+
ios?: 'swift'
|
|
8
|
+
android?: 'kotlin'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a Nitro `HybridView` which is implemented in a native language
|
|
13
|
+
* like Swift or Kotlin.
|
|
14
|
+
*
|
|
15
|
+
* `HybridViews`s use the Nitro Tunnel for efficient, low-overhead JS <-> Native communication.
|
|
16
|
+
*
|
|
17
|
+
* All `HybridViews`s have a C++ Fabric View base with a backing Shadow Node.
|
|
18
|
+
*
|
|
19
|
+
* - TypeScript Properties (`name: Type`) will be React Props
|
|
20
|
+
* - TypeScript Methods (`name(): Type`) will be Ref Methods
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* export interface Camera extends HybridView {
|
|
25
|
+
* zoom: number
|
|
26
|
+
* flash: boolean
|
|
27
|
+
* takePhoto(): Image
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface HybridView<
|
|
32
|
+
Platforms extends ViewPlatformSpec = { ios: 'swift'; android: 'kotlin' },
|
|
33
|
+
> extends HybridObject<Platforms> {
|
|
34
|
+
/* empty interface for now */
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export * from './getHostComponent'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Platform, type HostComponent } from 'react-native'
|
|
2
|
+
// @ts-expect-error this unfortunately isn't typed or default-exported.
|
|
3
|
+
import * as NativeComponentRegistry from 'react-native/Libraries/NativeComponent/NativeComponentRegistry'
|
|
4
|
+
|
|
5
|
+
export interface ViewConfig<Props> {
|
|
6
|
+
uiViewClassName: string
|
|
7
|
+
supportsRawText?: boolean
|
|
8
|
+
bubblingEventTypes: Record<string, unknown>
|
|
9
|
+
directEventTypes: Record<string, unknown>
|
|
10
|
+
validAttributes: Record<keyof Props, boolean>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Finds and returns a native view (aka {@linkcode HostComponent}) via the given {@linkcode name}.
|
|
15
|
+
*/
|
|
16
|
+
export function getHostComponent<Props>(
|
|
17
|
+
name: string,
|
|
18
|
+
getViewConfig: () => ViewConfig<Props>
|
|
19
|
+
): HostComponent<Props> {
|
|
20
|
+
if (NativeComponentRegistry == null) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`NativeComponentRegistry is not available on ${Platform.OS}!`
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
return NativeComponentRegistry.get<Props>(name, getViewConfig)
|
|
26
|
+
}
|