@rnmapbox/maps 10.1.12 → 10.1.14
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/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +13 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotationCoordinator.kt +39 -40
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/CameraStop.kt +9 -15
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/CameraUpdateItem.kt +1 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCamera.kt +15 -13
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt +4 -3
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraModule.kt +51 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXVIewportManager.kt +2 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/constants/CameraMode.java +3 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt +1046 -987
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXModule.kt +1 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/utils/ViewTagResolver.kt +10 -2
- package/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXCameraModuleSpec.java +41 -0
- package/ios/RNMBX/RNMBXCamera.swift +49 -54
- package/ios/RNMBX/RNMBXCameraModule.h +18 -0
- package/ios/RNMBX/RNMBXCameraModule.mm +67 -0
- package/lib/commonjs/components/Camera.js +14 -15
- package/lib/commonjs/components/Camera.js.map +1 -1
- package/lib/commonjs/components/Viewport.js +2 -43
- package/lib/commonjs/components/Viewport.js.map +1 -1
- package/lib/commonjs/specs/NativeRNMBXCameraModule.js +10 -0
- package/lib/commonjs/specs/NativeRNMBXCameraModule.js.map +1 -0
- package/lib/commonjs/utils/NativeCommands.js +50 -0
- package/lib/commonjs/utils/NativeCommands.js.map +1 -0
- package/lib/module/components/Camera.js +15 -16
- package/lib/module/components/Camera.js.map +1 -1
- package/lib/module/components/Viewport.js +1 -42
- package/lib/module/components/Viewport.js.map +1 -1
- package/lib/module/specs/NativeRNMBXCameraModule.js +6 -0
- package/lib/module/specs/NativeRNMBXCameraModule.js.map +1 -0
- package/lib/module/utils/NativeCommands.js +43 -0
- package/lib/module/utils/NativeCommands.js.map +1 -0
- package/lib/typescript/src/components/Camera.d.ts.map +1 -1
- package/lib/typescript/src/components/Viewport.d.ts +0 -3
- package/lib/typescript/src/components/Viewport.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXCameraModule.d.ts +27 -0
- package/lib/typescript/src/specs/NativeRNMBXCameraModule.d.ts.map +1 -0
- package/lib/typescript/src/utils/NativeCommands.d.ts +25 -0
- package/lib/typescript/src/utils/NativeCommands.d.ts.map +1 -0
- package/package.json +1 -1
- package/setup-jest.js +4 -0
- package/src/components/Camera.tsx +22 -10
- package/src/components/Viewport.tsx +2 -94
- package/src/specs/NativeRNMBXCameraModule.ts +36 -0
- package/src/utils/NativeCommands.ts +89 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { NodeHandle, findNodeHandle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type NativeArg =
|
|
4
|
+
| string
|
|
5
|
+
| number
|
|
6
|
+
| boolean
|
|
7
|
+
| null
|
|
8
|
+
| { [k: string]: NativeArg }
|
|
9
|
+
| NativeArg[]
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
11
|
+
| Function
|
|
12
|
+
| GeoJSON.Geometry
|
|
13
|
+
| undefined;
|
|
14
|
+
|
|
15
|
+
type FunctionKeys<T> = keyof {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
17
|
+
[K in keyof T as T[K] extends Function ? K : never]: T[K];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type RefType = React.Component;
|
|
21
|
+
|
|
22
|
+
export class NativeCommands<Spec extends object> {
|
|
23
|
+
module: Spec;
|
|
24
|
+
|
|
25
|
+
preRefMethodQueue: Array<{
|
|
26
|
+
method: { name: FunctionKeys<Spec>; args: NativeArg[] };
|
|
27
|
+
resolver: (value: unknown) => void;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
nativeRef: RefType | undefined;
|
|
31
|
+
|
|
32
|
+
constructor(module: Spec) {
|
|
33
|
+
this.module = module;
|
|
34
|
+
this.preRefMethodQueue = [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async setNativeRef(nativeRef: RefType) {
|
|
38
|
+
if (nativeRef) {
|
|
39
|
+
this.nativeRef = nativeRef;
|
|
40
|
+
while (this.preRefMethodQueue.length > 0) {
|
|
41
|
+
const item = this.preRefMethodQueue.pop();
|
|
42
|
+
|
|
43
|
+
if (item && item.method && item.resolver) {
|
|
44
|
+
const res = await this._call(
|
|
45
|
+
item.method.name,
|
|
46
|
+
nativeRef,
|
|
47
|
+
item.method.args,
|
|
48
|
+
);
|
|
49
|
+
item.resolver(res);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
call<T>(name: FunctionKeys<Spec>, args: NativeArg[]): Promise<T> {
|
|
56
|
+
if (this.nativeRef) {
|
|
57
|
+
return this._call(name, this.nativeRef, args);
|
|
58
|
+
} else {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
this.preRefMethodQueue.push({
|
|
61
|
+
method: { name, args },
|
|
62
|
+
resolver: resolve as (args: unknown) => void,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_call<T>(
|
|
69
|
+
name: FunctionKeys<Spec>,
|
|
70
|
+
nativeRef: RefType,
|
|
71
|
+
args: NativeArg[],
|
|
72
|
+
): Promise<T> {
|
|
73
|
+
const handle = findNodeHandle(nativeRef);
|
|
74
|
+
if (handle) {
|
|
75
|
+
return (
|
|
76
|
+
this.module[name] as (
|
|
77
|
+
arg0: NodeHandle,
|
|
78
|
+
...args: NativeArg[]
|
|
79
|
+
) => Promise<T>
|
|
80
|
+
)(handle, ...args);
|
|
81
|
+
} else {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Could not find handle for native ref ${module} when trying to invoke ${String(
|
|
84
|
+
name,
|
|
85
|
+
)}`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|