@chaosity/location-client-react 0.8.0 → 0.9.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/README.md +20 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,6 +8,16 @@ React bindings for [@chaosity/location-client](https://www.npmjs.com/package/@ch
|
|
|
8
8
|
npm install @chaosity/location-client-react @chaosity/location-client
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
`maplibre-gl` is an optional peer, needed by `useMapLanguage` and the map
|
|
12
|
+
examples, at 6.4.1 or a later 6.x release. Earlier releases carry
|
|
13
|
+
[GHSA-jrc7-96c5-q579](https://github.com/advisories/GHSA-jrc7-96c5-q579), an
|
|
14
|
+
XSS in the attribution control, and `@chaosity/location-client` 0.11.0 is the
|
|
15
|
+
first core whose own peer admits 6. Under a bundler, MapLibre 6 runs its worker
|
|
16
|
+
from a file your application serves, so a map needs `setWorkerUrl` once before
|
|
17
|
+
it is built. The examples below serve it from `public/maplibre/`, and
|
|
18
|
+
[The MapLibre worker](https://github.com/chaosity-io/location-service-client#the-maplibre-worker)
|
|
19
|
+
in `@chaosity/location-client`'s README has the copy script and the Vite form.
|
|
20
|
+
|
|
11
21
|
## Quick Start
|
|
12
22
|
|
|
13
23
|
### 1. Create a Server Action to fetch config
|
|
@@ -86,6 +96,9 @@ React hook that keeps map label language in sync. Automatically reapplies after
|
|
|
86
96
|
|
|
87
97
|
```tsx
|
|
88
98
|
import { useMapLanguage } from '@chaosity/location-client-react'
|
|
99
|
+
import * as maplibregl from 'maplibre-gl'
|
|
100
|
+
|
|
101
|
+
maplibregl.setWorkerUrl('/maplibre/maplibre-gl-worker.mjs')
|
|
89
102
|
|
|
90
103
|
function MapComponent() {
|
|
91
104
|
const [mapInstance, setMapInstance] = useState<maplibregl.Map | null>(null)
|
|
@@ -260,8 +273,14 @@ import {
|
|
|
260
273
|
fetchMapStyle,
|
|
261
274
|
createTransformRequest,
|
|
262
275
|
} from '@chaosity/location-client'
|
|
263
|
-
import maplibregl from 'maplibre-gl'
|
|
276
|
+
import * as maplibregl from 'maplibre-gl'
|
|
277
|
+
import 'maplibre-gl/dist/maplibre-gl.css'
|
|
264
278
|
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder'
|
|
279
|
+
import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css'
|
|
280
|
+
|
|
281
|
+
// Once, before the first map: the worker file the application serves (see
|
|
282
|
+
// Installation).
|
|
283
|
+
maplibregl.setWorkerUrl('/maplibre/maplibre-gl-worker.mjs')
|
|
265
284
|
|
|
266
285
|
export default function MapComponent() {
|
|
267
286
|
const mapContainer = useRef<HTMLDivElement>(null)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaosity/location-client-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "React bindings for Chaosity Location Service client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@chaosity/location-client": ">=0.10.0",
|
|
42
|
-
"maplibre-gl": "^
|
|
42
|
+
"maplibre-gl": "^6.4.1",
|
|
43
43
|
"react": "^19.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@chaosity/location-client": "^0.
|
|
51
|
+
"@chaosity/location-client": "^0.11.0",
|
|
52
52
|
"@eslint/js": "^10.0.1",
|
|
53
53
|
"@testing-library/react": "^16.0.0",
|
|
54
54
|
"@testing-library/user-event": "^14.0.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"eslint": "^10.1.0",
|
|
59
59
|
"happy-dom": "^20.11.6",
|
|
60
60
|
"husky": "^9.0.0",
|
|
61
|
-
"maplibre-gl": "^
|
|
61
|
+
"maplibre-gl": "^6.4.1",
|
|
62
62
|
"prettier": "^3.8.1",
|
|
63
63
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
64
64
|
"react": "^19.0.0",
|