@maplibre/maplibre-react-native 10.0.0-alpha.21 → 10.0.0-alpha.22
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/.eslintrc.js +5 -0
- package/.git-blame-ignore-revs +3 -0
- package/CHANGELOG.md +13 -0
- package/app.plugin.js +1 -1
- package/babel.config.js +6 -3
- package/javascript/components/HeadingIndicator.tsx +0 -1
- package/javascript/components/MapView.tsx +2 -3
- package/javascript/types/png.d.ts +1 -0
- package/jest-setup.ts +113 -0
- package/jest.config.js +8 -0
- package/package.json +22 -62
- package/react-native.config.js +1 -1
- package/scripts/.eslintrc.js +3 -0
- package/scripts/{autogenerate.js → generate-docs.js} +144 -137
- package/scripts/templates/MaplibreStyles.ts.ejs +5 -5
- package/scripts/templates/RCTMLNStyle.h.ejs +2 -2
- package/scripts/templates/RCTMLNStyle.m.ejs +6 -6
- package/scripts/templates/RCTMLNStyleFactory.java.ejs +8 -8
- package/scripts/{autogenHelpers → utils}/DocJSONBuilder.js +70 -70
- package/scripts/{autogenHelpers → utils}/JSDocNodeTree.js +33 -30
- package/scripts/utils/MarkdownBuilder.js +37 -0
- package/scripts/utils/template-globals.js +528 -0
- package/tsconfig.json +2 -2
- package/scripts/autogenHelpers/MarkdownBuilder.js +0 -29
- package/scripts/autogenHelpers/globals.js +0 -508
- package/setup-jest.js +0 -108
package/.eslintrc.js
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ PR Title ([#123](link to my pr))
|
|
|
6
6
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## 10.0.0-alpha.22
|
|
10
|
+
|
|
11
|
+
chore: configure jest to use with ts
|
|
12
|
+
([#470](https://github.com/maplibre/maplibre-react-native/pull/470))
|
|
13
|
+
|
|
14
|
+
refactor: switch many examples to TypeScript
|
|
15
|
+
([#469](https://github.com/maplibre/maplibre-react-native/pull/469))
|
|
16
|
+
|
|
17
|
+
chore: eslint formatting and improve scripts
|
|
18
|
+
([#467](https://github.com/maplibre/maplibre-react-native/pull/467))
|
|
19
|
+
|
|
20
|
+
fix: allow resetting contentInset with 0 ([#468](https://github.com/maplibre/maplibre-react-native/pull/468))
|
|
21
|
+
|
|
9
22
|
## 10.0.0-alpha.21
|
|
10
23
|
|
|
11
24
|
fix: Call requestProgress when getting pack status on IOS + example improvement [#445](https://github.com/maplibre/maplibre-react-native/pull/445)
|
package/app.plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require(
|
|
1
|
+
module.exports = require("./plugin/build/withMapLibre");
|
package/babel.config.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
plugins: [
|
|
2
|
+
presets: ["module:metro-react-native-babel-preset"],
|
|
3
|
+
plugins: [
|
|
4
|
+
["@babel/plugin-proposal-class-properties", { loose: true }],
|
|
5
|
+
["@babel/plugin-transform-private-methods", { loose: true }],
|
|
6
|
+
],
|
|
4
7
|
env: {
|
|
5
8
|
production: {
|
|
6
|
-
plugins: [
|
|
9
|
+
plugins: ["transform-remove-console"],
|
|
7
10
|
},
|
|
8
11
|
},
|
|
9
12
|
};
|
|
@@ -760,7 +760,7 @@ const MapView = memo(
|
|
|
760
760
|
};
|
|
761
761
|
|
|
762
762
|
const contentInsetValue = useMemo(() => {
|
|
763
|
-
if (
|
|
763
|
+
if (props.contentInset === undefined) {
|
|
764
764
|
return;
|
|
765
765
|
}
|
|
766
766
|
|
|
@@ -812,7 +812,7 @@ const MapView = memo(
|
|
|
812
812
|
surfaceView,
|
|
813
813
|
regionWillChangeDebounceTime,
|
|
814
814
|
regionDidChangeDebounceTime,
|
|
815
|
-
contentInsetValue,
|
|
815
|
+
contentInset: contentInsetValue,
|
|
816
816
|
style: styles.matchParent,
|
|
817
817
|
};
|
|
818
818
|
}, [
|
|
@@ -825,7 +825,6 @@ const MapView = memo(
|
|
|
825
825
|
surfaceView,
|
|
826
826
|
regionWillChangeDebounceTime,
|
|
827
827
|
regionDidChangeDebounceTime,
|
|
828
|
-
contentInsetValue,
|
|
829
828
|
props,
|
|
830
829
|
contentInsetValue,
|
|
831
830
|
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.png";
|
package/jest-setup.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* eslint-disable no-undef, import/no-extraneous-dependencies */
|
|
2
|
+
import "@testing-library/react-native/extend-expect";
|
|
3
|
+
import { NativeModules } from "react-native";
|
|
4
|
+
|
|
5
|
+
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
|
|
6
|
+
jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
|
|
7
|
+
|
|
8
|
+
function keyMirror(keys: string[]) {
|
|
9
|
+
const obj: Record<string, string> = {};
|
|
10
|
+
keys.forEach((key) => (obj[key] = key));
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Mock of what the native code puts on the JS object
|
|
15
|
+
NativeModules.MLNModule = {
|
|
16
|
+
// constants
|
|
17
|
+
UserTrackingModes: keyMirror([
|
|
18
|
+
"None",
|
|
19
|
+
"Follow",
|
|
20
|
+
"FollowWithCourse",
|
|
21
|
+
"FollowWithHeading",
|
|
22
|
+
]),
|
|
23
|
+
StyleURL: keyMirror(["Default"]),
|
|
24
|
+
EventTypes: keyMirror([
|
|
25
|
+
"MapClick",
|
|
26
|
+
"MapLongClick",
|
|
27
|
+
"RegionWillChange",
|
|
28
|
+
"RegionIsChanging",
|
|
29
|
+
"RegionDidChange",
|
|
30
|
+
"WillStartLoadingMap",
|
|
31
|
+
"DidFinishLoadingMap",
|
|
32
|
+
"DidFailLoadingMap",
|
|
33
|
+
"WillStartRenderingFrame",
|
|
34
|
+
"DidFinishRenderingFrame",
|
|
35
|
+
"DidFinishRenderingFrameFully",
|
|
36
|
+
"DidFinishLoadingStyle",
|
|
37
|
+
"SetCameraComplete",
|
|
38
|
+
]),
|
|
39
|
+
CameraModes: keyMirror(["Flight", "Ease", "None"]),
|
|
40
|
+
StyleSource: keyMirror(["DefaultSourceID"]),
|
|
41
|
+
InterpolationMode: keyMirror([
|
|
42
|
+
"Exponential",
|
|
43
|
+
"Categorical",
|
|
44
|
+
"Interval",
|
|
45
|
+
"Identity",
|
|
46
|
+
]),
|
|
47
|
+
LineJoin: keyMirror(["Bevel", "Round", "Miter"]),
|
|
48
|
+
LineCap: keyMirror(["Butt", "Round", "Square"]),
|
|
49
|
+
LineTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
50
|
+
CirclePitchScale: keyMirror(["Map", "Viewport"]),
|
|
51
|
+
CircleTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
52
|
+
FillExtrusionTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
53
|
+
FillTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
54
|
+
IconRotationAlignment: keyMirror(["Auto", "Map", "Viewport"]),
|
|
55
|
+
IconTextFit: keyMirror(["None", "Width", "Height", "Both"]),
|
|
56
|
+
IconTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
57
|
+
SymbolPlacement: keyMirror(["Line", "Point"]),
|
|
58
|
+
TextAnchor: keyMirror([
|
|
59
|
+
"Center",
|
|
60
|
+
"Left",
|
|
61
|
+
"Right",
|
|
62
|
+
"Top",
|
|
63
|
+
"Bottom",
|
|
64
|
+
"TopLeft",
|
|
65
|
+
"TopRight",
|
|
66
|
+
"BottomLeft",
|
|
67
|
+
"BottomRight",
|
|
68
|
+
]),
|
|
69
|
+
TextJustify: keyMirror(["Center", "Left", "Right"]),
|
|
70
|
+
TextPitchAlignment: keyMirror(["Auto", "Map", "Viewport"]),
|
|
71
|
+
TextRotationAlignment: keyMirror(["Auto", "Map", "Viewport"]),
|
|
72
|
+
TextTransform: keyMirror(["None", "Lowercase", "Uppercase"]),
|
|
73
|
+
TextTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
74
|
+
LightAnchor: keyMirror(["Map", "Viewport"]),
|
|
75
|
+
OfflinePackDownloadState: keyMirror(["Inactive", "Active", "Complete"]),
|
|
76
|
+
OfflineCallbackName: keyMirror(["Progress", "Error"]),
|
|
77
|
+
|
|
78
|
+
// methods
|
|
79
|
+
setAccessToken: jest.fn(),
|
|
80
|
+
getAccessToken: () => Promise.resolve("test-token"),
|
|
81
|
+
setConnected: jest.fn(),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
NativeModules.MLNOfflineModule = {
|
|
85
|
+
createPack: (packOptions: any) => {
|
|
86
|
+
return Promise.resolve({
|
|
87
|
+
bounds: packOptions.bounds,
|
|
88
|
+
metadata: JSON.stringify({ name: packOptions.name }),
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
getPacks: () => Promise.resolve([]),
|
|
92
|
+
deletePack: () => Promise.resolve(),
|
|
93
|
+
getPackStatus: () => Promise.resolve({}),
|
|
94
|
+
pausePackDownload: () => Promise.resolve(),
|
|
95
|
+
resumePackDownload: () => Promise.resolve(),
|
|
96
|
+
setPackObserver: () => Promise.resolve(),
|
|
97
|
+
setTileCountLimit: jest.fn(),
|
|
98
|
+
setProgressEventThrottle: jest.fn(),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
NativeModules.MLNSnapshotModule = {
|
|
102
|
+
takeSnap: () => {
|
|
103
|
+
return Promise.resolve("file://test.png");
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
NativeModules.MLNLocationModule = {
|
|
108
|
+
getLastKnownLocation: jest.fn(),
|
|
109
|
+
setMinDisplacement: jest.fn(),
|
|
110
|
+
start: jest.fn(),
|
|
111
|
+
stop: jest.fn(),
|
|
112
|
+
pause: jest.fn(),
|
|
113
|
+
};
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: "@testing-library/react-native",
|
|
3
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
|
|
4
|
+
setupFilesAfterEnv: ["./jest-setup.ts"],
|
|
5
|
+
setupFiles: ["./__tests__/__mocks__/react-native.mock.js"],
|
|
6
|
+
modulePathIgnorePatterns: ["__tests__/__mocks__", "fixtures"],
|
|
7
|
+
collectCoverageFrom: ["javascript/**/*.{ts,tsx,js,jsx}"],
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplibre/maplibre-react-native",
|
|
3
3
|
"description": "A MapLibre GL Native plugin for creating maps in React Native",
|
|
4
|
-
"version": "10.0.0-alpha.
|
|
4
|
+
"version": "10.0.0-alpha.22",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -21,20 +21,19 @@
|
|
|
21
21
|
"url": "https://github.com/maplibre/maplibre-react-native"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"
|
|
25
|
-
"generate
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"lint": "eslint .",
|
|
30
|
-
"lint:fix": "eslint . --fix",
|
|
31
|
-
"lint:
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"postpack": "pinst --enable"
|
|
37
|
-
"typescript:check": "tsc -p ./tsconfig.json --noEmit"
|
|
24
|
+
"generate": "yarn generate:fetch-style-spec && yarn generate:docs",
|
|
25
|
+
"generate:fetch-style-spec": "./scripts/download-style-spec.sh",
|
|
26
|
+
"generate:docs": "yarn node ./scripts/generate-docs",
|
|
27
|
+
"test": "jest",
|
|
28
|
+
"lint": "yarn lint:eslint && yarn lint:tsc",
|
|
29
|
+
"lint:eslint": "eslint .",
|
|
30
|
+
"lint:eslint:fix": "eslint . --fix",
|
|
31
|
+
"lint:tsc": "tsc --project . --noEmit && tsc --project ./packages/examples",
|
|
32
|
+
"plugin:build": "tsc --build plugin",
|
|
33
|
+
"plugin:lint": "eslint plugin/src/*",
|
|
34
|
+
"plugin:test": "jest plugin",
|
|
35
|
+
"prepack": "pinst --disable && yarn plugin:build",
|
|
36
|
+
"postpack": "pinst --enable"
|
|
38
37
|
},
|
|
39
38
|
"peerDependenciesMeta": {
|
|
40
39
|
"@expo/config-plugins": {
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"react-native": ">=0.59.9"
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"@mapbox/geo-viewport": ">=
|
|
49
|
+
"@mapbox/geo-viewport": ">=0.4.0",
|
|
51
50
|
"@turf/along": "6.5.0",
|
|
52
51
|
"@turf/distance": "6.5.0",
|
|
53
52
|
"@turf/helpers": "6.5.0",
|
|
@@ -68,23 +67,18 @@
|
|
|
68
67
|
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
69
68
|
"@babel/runtime": "7.17.2",
|
|
70
69
|
"@expo/config-plugins": "^7.2.5",
|
|
71
|
-
"@react-native/eslint-config": "^0.73.2",
|
|
72
|
-
"@react-native/eslint-plugin": "^0.74.0",
|
|
73
70
|
"@react-native/metro-config": "^0.72.7",
|
|
74
71
|
"@sinonjs/fake-timers": "^11.2.2",
|
|
75
72
|
"@testing-library/react-native": "^12.4.3",
|
|
76
73
|
"@tsconfig/node14": "^14.1.0",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
78
|
-
"@typescript-eslint/parser": "^7.
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
75
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
79
76
|
"babel-jest": "^29.6.0",
|
|
80
77
|
"documentation": "^14.0.0",
|
|
81
78
|
"ejs": "^3.1.3",
|
|
82
79
|
"ejs-lint": "^2.0.0",
|
|
83
|
-
"eslint": "^8.57.
|
|
84
|
-
"eslint-config-prettier": "^9.1.0",
|
|
80
|
+
"eslint": "^8.57.1",
|
|
85
81
|
"eslint-config-universe": "13.0.0",
|
|
86
|
-
"eslint-plugin-import": "^2.29.1",
|
|
87
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
88
82
|
"expo-module-scripts": "^3.1.0",
|
|
89
83
|
"husky": "^9.0.10",
|
|
90
84
|
"jest": "^29.7.0",
|
|
@@ -93,53 +87,19 @@
|
|
|
93
87
|
"metro-react-native-babel-preset": "^0.76.7",
|
|
94
88
|
"node-dir": "0.1.17",
|
|
95
89
|
"pinst": "^3.0.0",
|
|
96
|
-
"prettier": "
|
|
97
|
-
"react": "
|
|
90
|
+
"prettier": "3.3.3",
|
|
91
|
+
"react": "18.2.0",
|
|
98
92
|
"react-docgen": "rnmapbox/react-docgen#rnmapbox-dist",
|
|
99
|
-
"react-native": "0.
|
|
100
|
-
"react-test-renderer": "
|
|
93
|
+
"react-native": "0.74.6",
|
|
94
|
+
"react-test-renderer": "18.2.0",
|
|
101
95
|
"typescript": "^5.3.3"
|
|
102
96
|
},
|
|
103
97
|
"resolutions": {
|
|
104
98
|
"typescript": "5.5.3"
|
|
105
99
|
},
|
|
106
|
-
"jest": {
|
|
107
|
-
"preset": "react-native",
|
|
108
|
-
"collectCoverageFrom": [
|
|
109
|
-
"javascript/**/*.js"
|
|
110
|
-
],
|
|
111
|
-
"setupFiles": [
|
|
112
|
-
"./setup-jest.js",
|
|
113
|
-
"./__tests__/__mocks__/react-native.mock.js"
|
|
114
|
-
],
|
|
115
|
-
"modulePathIgnorePatterns": [
|
|
116
|
-
"example",
|
|
117
|
-
"__tests__/__mocks__",
|
|
118
|
-
"fixtures"
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
100
|
"lint-staged": {
|
|
122
101
|
"*.{js,jsx,ts,tsx}": "yarn lint"
|
|
123
102
|
},
|
|
124
|
-
"eslintConfig": {
|
|
125
|
-
"root": true,
|
|
126
|
-
"extends": [
|
|
127
|
-
"prettier",
|
|
128
|
-
"universe/native"
|
|
129
|
-
],
|
|
130
|
-
"ignorePatterns": [
|
|
131
|
-
"node_modules/*",
|
|
132
|
-
"*.js",
|
|
133
|
-
"**/dist/*.js",
|
|
134
|
-
"/plugin/build"
|
|
135
|
-
],
|
|
136
|
-
"plugins": [
|
|
137
|
-
"prettier"
|
|
138
|
-
],
|
|
139
|
-
"rules": {
|
|
140
|
-
"prettier/prettier": "error"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
103
|
"packageManager": "yarn@4.1.0",
|
|
144
104
|
"workspaces": [
|
|
145
105
|
"apps/*",
|
package/react-native.config.js
CHANGED