@trackunit/react-map-adapter-mapbox 0.0.69-alpha-0874090e5e0.0 → 0.0.70
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/index.cjs.js +20 -0
- package/index.esm.js +20 -1
- package/package.json +3 -3
- package/src/index.d.ts +1 -0
- package/src/useMapboxAccessTokenOverride.d.ts +14 -0
package/index.cjs.js
CHANGED
|
@@ -2909,6 +2909,26 @@ const mapboxAdapter = reactMapAdapterShared.defineAdapter((config) => ({
|
|
|
2909
2909
|
Renderer: MapboxRenderer,
|
|
2910
2910
|
}));
|
|
2911
2911
|
|
|
2912
|
+
/**
|
|
2913
|
+
* Keeps the credential GL JS uses for style, tile, font and sprite requests in step with
|
|
2914
|
+
* `accessToken`, replacing the one the adapter was constructed with.
|
|
2915
|
+
*
|
|
2916
|
+
* GL JS resolves the token per request from a module-level global rather than capturing it when the
|
|
2917
|
+
* map is created, so a live map picks up a new value without being recreated. That is what makes it
|
|
2918
|
+
* possible to rotate a short-lived token — as the MCP map app does — without tearing down the map and
|
|
2919
|
+
* losing the user's viewport. Callers that only need an initial credential should pass `accessToken`
|
|
2920
|
+
* through `mapboxAdapter` instead; this exists for rotation.
|
|
2921
|
+
*
|
|
2922
|
+
* The credential is global to GL JS, so a page rendering two maps from different tokens cannot use
|
|
2923
|
+
* this to give them one each.
|
|
2924
|
+
*/
|
|
2925
|
+
const useMapboxAccessTokenOverride = (accessToken) => {
|
|
2926
|
+
react.useEffect(() => {
|
|
2927
|
+
mapboxgl.accessToken = accessToken;
|
|
2928
|
+
}, [accessToken]);
|
|
2929
|
+
};
|
|
2930
|
+
|
|
2912
2931
|
exports.MapboxAdapterInstance = MapboxAdapterInstance;
|
|
2913
2932
|
exports.MapboxRenderer = MapboxRenderer;
|
|
2914
2933
|
exports.mapboxAdapter = mapboxAdapter;
|
|
2934
|
+
exports.useMapboxAccessTokenOverride = useMapboxAccessTokenOverride;
|
package/index.esm.js
CHANGED
|
@@ -2907,4 +2907,23 @@ const mapboxAdapter = defineAdapter((config) => ({
|
|
|
2907
2907
|
Renderer: MapboxRenderer,
|
|
2908
2908
|
}));
|
|
2909
2909
|
|
|
2910
|
-
|
|
2910
|
+
/**
|
|
2911
|
+
* Keeps the credential GL JS uses for style, tile, font and sprite requests in step with
|
|
2912
|
+
* `accessToken`, replacing the one the adapter was constructed with.
|
|
2913
|
+
*
|
|
2914
|
+
* GL JS resolves the token per request from a module-level global rather than capturing it when the
|
|
2915
|
+
* map is created, so a live map picks up a new value without being recreated. That is what makes it
|
|
2916
|
+
* possible to rotate a short-lived token — as the MCP map app does — without tearing down the map and
|
|
2917
|
+
* losing the user's viewport. Callers that only need an initial credential should pass `accessToken`
|
|
2918
|
+
* through `mapboxAdapter` instead; this exists for rotation.
|
|
2919
|
+
*
|
|
2920
|
+
* The credential is global to GL JS, so a page rendering two maps from different tokens cannot use
|
|
2921
|
+
* this to give them one each.
|
|
2922
|
+
*/
|
|
2923
|
+
const useMapboxAccessTokenOverride = (accessToken) => {
|
|
2924
|
+
useEffect(() => {
|
|
2925
|
+
mapboxgl.accessToken = accessToken;
|
|
2926
|
+
}, [accessToken]);
|
|
2927
|
+
};
|
|
2928
|
+
|
|
2929
|
+
export { MapboxAdapterInstance, MapboxRenderer, mapboxAdapter, useMapboxAccessTokenOverride };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-map-adapter-mapbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.70",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/react-map-adapter-shared": "0.0.82
|
|
11
|
-
"@trackunit/geo-json-utils": "1.15.4
|
|
10
|
+
"@trackunit/react-map-adapter-shared": "0.0.82",
|
|
11
|
+
"@trackunit/geo-json-utils": "1.15.4",
|
|
12
12
|
"mapbox-gl": "^3.18.1",
|
|
13
13
|
"supercluster": "^8.0.1",
|
|
14
14
|
"es-toolkit": "^1.39.10",
|
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps the credential GL JS uses for style, tile, font and sprite requests in step with
|
|
3
|
+
* `accessToken`, replacing the one the adapter was constructed with.
|
|
4
|
+
*
|
|
5
|
+
* GL JS resolves the token per request from a module-level global rather than capturing it when the
|
|
6
|
+
* map is created, so a live map picks up a new value without being recreated. That is what makes it
|
|
7
|
+
* possible to rotate a short-lived token — as the MCP map app does — without tearing down the map and
|
|
8
|
+
* losing the user's viewport. Callers that only need an initial credential should pass `accessToken`
|
|
9
|
+
* through `mapboxAdapter` instead; this exists for rotation.
|
|
10
|
+
*
|
|
11
|
+
* The credential is global to GL JS, so a page rendering two maps from different tokens cannot use
|
|
12
|
+
* this to give them one each.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useMapboxAccessTokenOverride: (accessToken: string) => void;
|