@trackunit/react-map-adapter-shared 0.0.129-alpha-12adfed37e0.0 → 0.0.130
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 +2 -1
- package/index.cjs.js +34 -0
- package/index.esm.js +33 -1
- package/package.json +4 -4
- package/src/google-map-csp-directives.d.ts +7 -0
- package/src/index.d.ts +2 -0
- package/src/mapbox-map-csp-directives.d.ts +6 -0
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Adapter libraries do not import `@trackunit/react-map`.
|
|
|
26
26
|
- Core map types and interaction types (e.g. viewport, theme, GeoJSON-related types, layer port surface).
|
|
27
27
|
- `defineAdapter`, `AdapterRendererProps`, and related adapter wiring types.
|
|
28
28
|
- Shared constants (e.g. default center/zoom, map cursors), `restrictBounds` helpers, layer port utilities, antimeridian merge, map-specific viewport validation (`validateInitialViewport`), and other adapter-facing helpers.
|
|
29
|
+
- Provider CSP directive factories. These framework-agnostic implementations are re-exported from their corresponding adapter packages; application code should import them from the provider adapter.
|
|
29
30
|
|
|
30
31
|
## Cross-provider parity helpers
|
|
31
32
|
|
|
@@ -54,7 +55,7 @@ If you build a new adapter and hit a provider gap, prefer adding the cross-provi
|
|
|
54
55
|
|
|
55
56
|
## Vendor abstraction
|
|
56
57
|
|
|
57
|
-
This library is the boundary between application code and map providers. The guiding rule: **nothing outside an adapter may import from a provider SDK** (`mapbox-gl`, `@vis.gl/react-google-maps`, Google Maps JS API types, etc.).
|
|
58
|
+
This library is the boundary between application code and map providers. The guiding rule: **nothing outside an adapter may import from a provider SDK** (`mapbox-gl`, `@vis.gl/react-google-maps`, Google Maps JS API types, etc.). Vendor-specific types, API calls, and rendering behaviour belong inside the adapter that wraps that provider.
|
|
58
59
|
|
|
59
60
|
When a map feature is supported by one provider but not another:
|
|
60
61
|
|
package/index.cjs.js
CHANGED
|
@@ -1012,6 +1012,31 @@ const densifyGeodesicFeatures = (features, layerGeodesic, featureStyles, maxSegm
|
|
|
1012
1012
|
return { ...features, features: densified };
|
|
1013
1013
|
};
|
|
1014
1014
|
|
|
1015
|
+
const googleMapCspDirectives = () => ({
|
|
1016
|
+
"connect-src": ["https://*.gstatic.com", "https://*.googleapis.com", "https://*.google.com", "data:", "blob:"],
|
|
1017
|
+
"script-src": [
|
|
1018
|
+
"https://*.gstatic.com",
|
|
1019
|
+
"https://*.googleapis.com",
|
|
1020
|
+
"https://*.google.com",
|
|
1021
|
+
"https://*.googleusercontent.com",
|
|
1022
|
+
"https://*.ggpht.com",
|
|
1023
|
+
"blob:",
|
|
1024
|
+
"'unsafe-eval'",
|
|
1025
|
+
"'wasm-unsafe-eval'",
|
|
1026
|
+
],
|
|
1027
|
+
"img-src": [
|
|
1028
|
+
"https://*.gstatic.com",
|
|
1029
|
+
"https://*.googleapis.com",
|
|
1030
|
+
"https://*.google.com",
|
|
1031
|
+
"https://*.googleusercontent.com",
|
|
1032
|
+
"https://*.ggpht.com",
|
|
1033
|
+
"data:",
|
|
1034
|
+
"blob:",
|
|
1035
|
+
],
|
|
1036
|
+
"frame-src": ["https://*.google.com"],
|
|
1037
|
+
"worker-src": ["blob:"],
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1015
1040
|
const isViewportLike = (value) => {
|
|
1016
1041
|
return typeof value === "object" && value !== null && "type" in value;
|
|
1017
1042
|
};
|
|
@@ -1769,6 +1794,13 @@ const fadeInElement = (el) => {
|
|
|
1769
1794
|
});
|
|
1770
1795
|
};
|
|
1771
1796
|
|
|
1797
|
+
const mapboxMapCspDirectives = () => ({
|
|
1798
|
+
"connect-src": ["https://api.mapbox.com", "https://events.mapbox.com"],
|
|
1799
|
+
"img-src": ["data:", "blob:"],
|
|
1800
|
+
"script-src": ["'wasm-unsafe-eval'"],
|
|
1801
|
+
"worker-src": ["blob:"],
|
|
1802
|
+
});
|
|
1803
|
+
|
|
1772
1804
|
/** Type predicate to narrow a MapEvent to a specific event type */
|
|
1773
1805
|
const isEventOfType = (mapEvent, type) => mapEvent.type === type;
|
|
1774
1806
|
|
|
@@ -2678,6 +2710,7 @@ exports.getAdaptiveDomFeatureIds = getAdaptiveDomFeatureIds;
|
|
|
2678
2710
|
exports.getAnchorRect = getAnchorRect;
|
|
2679
2711
|
exports.getEffectiveRestrictBounds = getEffectiveRestrictBounds;
|
|
2680
2712
|
exports.getHitSurfaceRect = getHitSurfaceRect;
|
|
2713
|
+
exports.googleMapCspDirectives = googleMapCspDirectives;
|
|
2681
2714
|
exports.hasSameFeatureIds = hasSameFeatureIds;
|
|
2682
2715
|
exports.intermediatePoint = intermediatePoint;
|
|
2683
2716
|
exports.isCanvasMarkerMode = isCanvasMarkerMode;
|
|
@@ -2687,6 +2720,7 @@ exports.mapAppearanceSchema = mapAppearanceSchema;
|
|
|
2687
2720
|
exports.mapStateEquals = mapStateEquals;
|
|
2688
2721
|
exports.mapThemeSchema = mapThemeSchema;
|
|
2689
2722
|
exports.mapTypeSchema = mapTypeSchema;
|
|
2723
|
+
exports.mapboxMapCspDirectives = mapboxMapCspDirectives;
|
|
2690
2724
|
exports.mercatorCenterFromBounds = mercatorCenterFromBounds;
|
|
2691
2725
|
exports.mergeAntimeridianFeatures = mergeAntimeridianFeatures;
|
|
2692
2726
|
exports.patchPortalDescriptors = patchPortalDescriptors;
|
package/index.esm.js
CHANGED
|
@@ -1010,6 +1010,31 @@ const densifyGeodesicFeatures = (features, layerGeodesic, featureStyles, maxSegm
|
|
|
1010
1010
|
return { ...features, features: densified };
|
|
1011
1011
|
};
|
|
1012
1012
|
|
|
1013
|
+
const googleMapCspDirectives = () => ({
|
|
1014
|
+
"connect-src": ["https://*.gstatic.com", "https://*.googleapis.com", "https://*.google.com", "data:", "blob:"],
|
|
1015
|
+
"script-src": [
|
|
1016
|
+
"https://*.gstatic.com",
|
|
1017
|
+
"https://*.googleapis.com",
|
|
1018
|
+
"https://*.google.com",
|
|
1019
|
+
"https://*.googleusercontent.com",
|
|
1020
|
+
"https://*.ggpht.com",
|
|
1021
|
+
"blob:",
|
|
1022
|
+
"'unsafe-eval'",
|
|
1023
|
+
"'wasm-unsafe-eval'",
|
|
1024
|
+
],
|
|
1025
|
+
"img-src": [
|
|
1026
|
+
"https://*.gstatic.com",
|
|
1027
|
+
"https://*.googleapis.com",
|
|
1028
|
+
"https://*.google.com",
|
|
1029
|
+
"https://*.googleusercontent.com",
|
|
1030
|
+
"https://*.ggpht.com",
|
|
1031
|
+
"data:",
|
|
1032
|
+
"blob:",
|
|
1033
|
+
],
|
|
1034
|
+
"frame-src": ["https://*.google.com"],
|
|
1035
|
+
"worker-src": ["blob:"],
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1013
1038
|
const isViewportLike = (value) => {
|
|
1014
1039
|
return typeof value === "object" && value !== null && "type" in value;
|
|
1015
1040
|
};
|
|
@@ -1767,6 +1792,13 @@ const fadeInElement = (el) => {
|
|
|
1767
1792
|
});
|
|
1768
1793
|
};
|
|
1769
1794
|
|
|
1795
|
+
const mapboxMapCspDirectives = () => ({
|
|
1796
|
+
"connect-src": ["https://api.mapbox.com", "https://events.mapbox.com"],
|
|
1797
|
+
"img-src": ["data:", "blob:"],
|
|
1798
|
+
"script-src": ["'wasm-unsafe-eval'"],
|
|
1799
|
+
"worker-src": ["blob:"],
|
|
1800
|
+
});
|
|
1801
|
+
|
|
1770
1802
|
/** Type predicate to narrow a MapEvent to a specific event type */
|
|
1771
1803
|
const isEventOfType = (mapEvent, type) => mapEvent.type === type;
|
|
1772
1804
|
|
|
@@ -2618,4 +2650,4 @@ const resolveStrokeColors = (style, shapeType, theme) => {
|
|
|
2618
2650
|
};
|
|
2619
2651
|
};
|
|
2620
2652
|
|
|
2621
|
-
export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, GEODESIC_MAX_SEGMENT_KM, HIT_SURFACE_SELECTOR, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, LAYER_FADE_DURATION_MS, MAP_CURSORS, MAX_ZOOM, MIN_ZOOM, SAFE_AREA_DEFAULT_BUFFER_PX, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mercatorCenterFromBounds, mergeAntimeridianFeatures, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, unwrapLongitudeNear, validateInitialViewport, watchSafeAreaLeave };
|
|
2653
|
+
export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, GEODESIC_MAX_SEGMENT_KM, HIT_SURFACE_SELECTOR, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, LAYER_FADE_DURATION_MS, MAP_CURSORS, MAX_ZOOM, MIN_ZOOM, SAFE_AREA_DEFAULT_BUFFER_PX, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, googleMapCspDirectives, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mapboxMapCspDirectives, mercatorCenterFromBounds, mergeAntimeridianFeatures, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, unwrapLongitudeNear, validateInitialViewport, watchSafeAreaLeave };
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-map-adapter-shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.130",
|
|
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-color-utils": "0.0.107
|
|
11
|
-
"@trackunit/geo-json-utils": "1.15.47
|
|
12
|
-
"@trackunit/ui-design-tokens": "1.15.
|
|
10
|
+
"@trackunit/react-map-color-utils": "0.0.107",
|
|
11
|
+
"@trackunit/geo-json-utils": "1.15.47",
|
|
12
|
+
"@trackunit/ui-design-tokens": "1.15.34",
|
|
13
13
|
"es-toolkit": "^1.39.10",
|
|
14
14
|
"zod": "^3.25.76"
|
|
15
15
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ export * from "./adapterContract";
|
|
|
2
2
|
export * from "./antimeridianMerge";
|
|
3
3
|
export * from "./constants";
|
|
4
4
|
export * from "./geodesicDensify";
|
|
5
|
+
export * from "./google-map-csp-directives";
|
|
5
6
|
export * from "./initialViewportValidation";
|
|
6
7
|
export * from "./interactionTypes";
|
|
7
8
|
export * from "./layerApiTypes";
|
|
8
9
|
export * from "./LayerPort";
|
|
9
10
|
export * from "./layerPortHelpers";
|
|
11
|
+
export * from "./mapbox-map-csp-directives";
|
|
10
12
|
export * from "./mapEventUtils";
|
|
11
13
|
export * from "./mapStateUtils";
|
|
12
14
|
export * from "./primitiveMapTypes";
|