@maplibre/maplibre-react-native 10.0.0-alpha.5 → 10.0.0-alpha.7

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 (54) hide show
  1. package/.eslintrc.js +3 -1
  2. package/.yarn/sdks/eslint/bin/eslint.js +8 -1
  3. package/.yarn/sdks/eslint/lib/api.js +8 -1
  4. package/.yarn/sdks/eslint/lib/unsupported-api.js +8 -1
  5. package/.yarn/sdks/prettier/bin/prettier.cjs +8 -1
  6. package/.yarn/sdks/prettier/index.cjs +8 -1
  7. package/.yarn/sdks/typescript/bin/tsc +8 -1
  8. package/.yarn/sdks/typescript/bin/tsserver +8 -1
  9. package/.yarn/sdks/typescript/lib/tsc.js +8 -1
  10. package/.yarn/sdks/typescript/lib/tsserver.js +20 -6
  11. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +20 -6
  12. package/.yarn/sdks/typescript/lib/typescript.js +8 -1
  13. package/CHANGELOG.md +57 -48
  14. package/CONTRIBUTING.md +10 -9
  15. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerViewManager.java +5 -3
  16. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapView.java +7 -7
  17. package/docs/Camera.md +3 -3
  18. package/docs/MapView.md +9 -33
  19. package/docs/UserLocation.md +10 -2
  20. package/docs/docs.json +17 -32
  21. package/docs/offlineManager.md +246 -0
  22. package/javascript/Maplibre.ts +5 -1
  23. package/javascript/components/BackgroundLayer.tsx +27 -20
  24. package/javascript/components/Callout.tsx +40 -40
  25. package/javascript/components/Camera.tsx +421 -478
  26. package/javascript/components/CircleLayer.tsx +29 -22
  27. package/javascript/components/FillExtrusionLayer.tsx +23 -23
  28. package/javascript/components/FillLayer.tsx +22 -19
  29. package/javascript/components/HeatmapLayer.tsx +21 -19
  30. package/javascript/components/ImageSource.tsx +25 -32
  31. package/javascript/components/Images.tsx +36 -35
  32. package/javascript/components/Light.tsx +20 -47
  33. package/javascript/components/LineLayer.tsx +23 -20
  34. package/javascript/components/MapView.tsx +604 -554
  35. package/javascript/components/MarkerView.tsx +23 -38
  36. package/javascript/components/NativeUserLocation.tsx +3 -5
  37. package/javascript/components/PointAnnotation.tsx +111 -87
  38. package/javascript/components/RasterLayer.tsx +21 -18
  39. package/javascript/components/RasterSource.tsx +39 -42
  40. package/javascript/components/ShapeSource.tsx +287 -239
  41. package/javascript/components/Style.tsx +1 -1
  42. package/javascript/components/SymbolLayer.tsx +34 -28
  43. package/javascript/components/UserLocation.tsx +164 -151
  44. package/javascript/components/VectorSource.tsx +128 -117
  45. package/javascript/components/annotations/Annotation.tsx +105 -79
  46. package/javascript/{components/AbstractLayer.tsx → hooks/useAbstractLayer.ts} +54 -37
  47. package/javascript/hooks/useAbstractSource.ts +34 -0
  48. package/javascript/hooks/useNativeBridge.ts +125 -0
  49. package/javascript/hooks/useNativeRef.ts +13 -0
  50. package/javascript/hooks/useOnce.ts +12 -0
  51. package/javascript/utils/Logger.ts +3 -3
  52. package/package.json +2 -1
  53. package/javascript/components/AbstractSource.tsx +0 -27
  54. package/javascript/components/NativeBridgeComponent.tsx +0 -117
@@ -1,117 +0,0 @@
1
- import {runNativeCommand, isAndroid, NativeArg} from '../utils';
2
-
3
- import {Component, SyntheticEvent} from 'react';
4
-
5
- export type RNMLEvent<PayloadType = {[key: string]: string}> = {
6
- payload: PayloadType;
7
- type: string;
8
- };
9
-
10
- let callbackIncrement = 0;
11
-
12
- const NativeBridgeComponent = <
13
- Props extends object,
14
- BaseComponent extends new (...args: any[]) => Component<Props>,
15
- >(
16
- B: BaseComponent,
17
- nativeModuleName: string,
18
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type,@typescript-eslint/explicit-module-boundary-types
19
- ) => {
20
- const NativeBridge = class extends B {
21
- _nativeModuleName: string;
22
- _onAndroidCallback: (e: any) => void;
23
- _callbackMap: Map<string, any>;
24
- _preRefMapMethodQueue: any[];
25
-
26
- constructor(...args: any[]) {
27
- super(...args);
28
-
29
- this._nativeModuleName = nativeModuleName;
30
- this._onAndroidCallback = this._onAndroidCallback0.bind(this);
31
- this._callbackMap = new Map();
32
- this._preRefMapMethodQueue = [];
33
- }
34
-
35
- _addAddAndroidCallback<ReturnType>(
36
- id: string,
37
- resolve: (value: ReturnType) => void,
38
- reject: (error: Error) => void,
39
- ): void {
40
- this._callbackMap.set(id, {resolve, reject});
41
- }
42
-
43
- _removeAndroidCallback(id: string): void {
44
- this._callbackMap.delete(id);
45
- }
46
-
47
- _onAndroidCallback0(e: SyntheticEvent<Element, RNMLEvent>): void {
48
- const callbackID = e.nativeEvent.type;
49
- const callback = this._callbackMap.get(callbackID);
50
-
51
- if (!callback) {
52
- return;
53
- }
54
-
55
- this._callbackMap.delete(callbackID);
56
- const {payload} = e.nativeEvent;
57
- if (payload.error) {
58
- callback.reject.call(null, new Error(payload.error));
59
- } else {
60
- callback.resolve.call(null, payload);
61
- }
62
- }
63
-
64
- async _runPendingNativeCommands<RefType extends Component>(
65
- nativeRef: RefType | null | undefined,
66
- ): Promise<void> {
67
- if (nativeRef) {
68
- while (this._preRefMapMethodQueue.length > 0) {
69
- const item = this._preRefMapMethodQueue.pop();
70
-
71
- if (item && item.method && item.resolver) {
72
- const res = await this._runNativeCommand(
73
- item.method.name,
74
- nativeRef,
75
- item.method.args,
76
- );
77
- item.resolver(res);
78
- }
79
- }
80
- }
81
- }
82
-
83
- _runNativeCommand<RefType extends Component, ReturnType = NativeArg>(
84
- methodName: string,
85
- nativeRef: RefType | undefined | null,
86
- args: NativeArg[] = [],
87
- ): Promise<ReturnType> {
88
- if (!nativeRef) {
89
- return new Promise(resolve => {
90
- this._preRefMapMethodQueue.push({
91
- method: {name: methodName, args},
92
- resolver: resolve,
93
- });
94
- });
95
- }
96
-
97
- if (isAndroid()) {
98
- return new Promise((resolve, reject) => {
99
- callbackIncrement += 1;
100
- const callbackID = `${methodName}_${callbackIncrement}`;
101
- this._addAddAndroidCallback(callbackID, resolve, reject);
102
- args.unshift(callbackID);
103
- runNativeCommand(this._nativeModuleName, methodName, nativeRef, args);
104
- });
105
- }
106
- return runNativeCommand(
107
- this._nativeModuleName,
108
- methodName,
109
- nativeRef,
110
- args,
111
- );
112
- }
113
- };
114
- return NativeBridge;
115
- };
116
-
117
- export default NativeBridgeComponent;