@trackunit/react-map-adapter-shared 0.0.12 → 0.0.16

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 CHANGED
@@ -2522,26 +2522,6 @@ const attachSafeAreaHoverListeners = (el, onEnter, onLeave, state) => {
2522
2522
  });
2523
2523
  };
2524
2524
 
2525
- // TODO (next PR): shapeStyleDefaults computes visual defaults for shapes — a map consumer
2526
- // concern, not an adapter concern. Make these injectable from react-map's createMapComponent
2527
- // so adapters don't need to know about default visual styles.
2528
- const SHAPE_STYLE_DEFAULTS = {
2529
- polygon: {
2530
- fillOpacity: 0.05,
2531
- strokeWidth: 1,
2532
- strokeOpacity: 1,
2533
- },
2534
- line: {
2535
- strokeWidth: 1,
2536
- strokeOpacity: 1,
2537
- },
2538
- point: {
2539
- fillOpacity: 0.2,
2540
- strokeWidth: 1,
2541
- strokeOpacity: 1,
2542
- pointRadius: 5,
2543
- },
2544
- };
2545
2525
  // ============================================================================
2546
2526
  // Interaction style constants
2547
2527
  // ============================================================================
@@ -2623,7 +2603,6 @@ exports.MAP_CURSORS = MAP_CURSORS;
2623
2603
  exports.MAX_ZOOM = MAX_ZOOM;
2624
2604
  exports.MIN_ZOOM = MIN_ZOOM;
2625
2605
  exports.SAFE_AREA_DEFAULT_BUFFER_PX = SAFE_AREA_DEFAULT_BUFFER_PX;
2626
- exports.SHAPE_STYLE_DEFAULTS = SHAPE_STYLE_DEFAULTS;
2627
2606
  exports.WORLD_BBOX = WORLD_BBOX;
2628
2607
  exports.allocSafeAreaDebugId = allocSafeAreaDebugId;
2629
2608
  exports.anchorFromBottomCenter = anchorFromBottomCenter;
package/index.esm.js CHANGED
@@ -2520,26 +2520,6 @@ const attachSafeAreaHoverListeners = (el, onEnter, onLeave, state) => {
2520
2520
  });
2521
2521
  };
2522
2522
 
2523
- // TODO (next PR): shapeStyleDefaults computes visual defaults for shapes — a map consumer
2524
- // concern, not an adapter concern. Make these injectable from react-map's createMapComponent
2525
- // so adapters don't need to know about default visual styles.
2526
- const SHAPE_STYLE_DEFAULTS = {
2527
- polygon: {
2528
- fillOpacity: 0.05,
2529
- strokeWidth: 1,
2530
- strokeOpacity: 1,
2531
- },
2532
- line: {
2533
- strokeWidth: 1,
2534
- strokeOpacity: 1,
2535
- },
2536
- point: {
2537
- fillOpacity: 0.2,
2538
- strokeWidth: 1,
2539
- strokeOpacity: 1,
2540
- pointRadius: 5,
2541
- },
2542
- };
2543
2523
  // ============================================================================
2544
2524
  // Interaction style constants
2545
2525
  // ============================================================================
@@ -2602,4 +2582,4 @@ const resolveStrokeColors = (style, shapeType, theme) => {
2602
2582
  };
2603
2583
  };
2604
2584
 
2605
- 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, SHAPE_STYLE_DEFAULTS, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, colorWithOpacity, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, darkenColor, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, lightenColor, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mercatorCenterFromBounds, mergeAntimeridianFeatures, mixColor, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resetColorUtilsForTesting, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, validateInitialViewport, watchSafeAreaLeave };
2585
+ 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, colorWithOpacity, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, darkenColor, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, lightenColor, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mercatorCenterFromBounds, mergeAntimeridianFeatures, mixColor, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resetColorUtilsForTesting, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, validateInitialViewport, watchSafeAreaLeave };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@trackunit/react-map-adapter-shared",
3
- "version": "0.0.12",
3
+ "version": "0.0.16",
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/geo-json-utils": "1.14.32",
11
- "@trackunit/ui-design-tokens": "1.13.30",
10
+ "@trackunit/geo-json-utils": "1.14.35",
11
+ "@trackunit/ui-design-tokens": "1.13.32",
12
12
  "es-toolkit": "^1.39.10",
13
13
  "zod": "^3.25.76"
14
14
  },
@@ -1,5 +1,6 @@
1
1
  import type { GeoJsonBbox } from "@trackunit/geo-json-utils";
2
2
  import type { Entity } from "./interactionTypes";
3
+ import type { ShapeStyleDefaults } from "./shapeStyleDefaults";
3
4
  import type { AdaptiveMarkerResolution, ClusterConfig, ClusterRenderConfig, ClusterRenderState, DomRenderState, GeoJsonFeatureCollection, GeoJsonGeometry, RenderConfig, RouteStyle, ShapeInteractiveMode, ShapeStyle } from "./layerApiTypes";
4
5
  type ReactNode = import("react").ReactNode;
5
6
  /**
@@ -231,6 +232,13 @@ export type LayerPort = Readonly<{
231
232
  * @returns Unsubscribe function.
232
233
  */
233
234
  onSourceReady: (configId: string, callback: () => void) => () => void;
235
+ /**
236
+ * Injects the per-shape-type visual defaults from the map consumer.
237
+ *
238
+ * Called by `createMapComponent` before any snapshot is sent, so adapters
239
+ * always receive the consumer-owned defaults rather than hard-coding them.
240
+ */
241
+ setShapeStyleDefaults: (defaults: ShapeStyleDefaults) => void;
234
242
  /**
235
243
  * Subscription for DOM-rendered individual markers (including adaptive DOM
236
244
  * features). `<Layers>` routes these descriptors to `markerRender`.
@@ -1,23 +1,31 @@
1
- import type { MapTheme } from "./primitiveMapTypes";
2
1
  import type { ShapeType } from "./interactionTypes";
3
2
  import type { ShapeStyle, ShapeStyleOverrides } from "./layerApiTypes";
4
- export declare const SHAPE_STYLE_DEFAULTS: {
5
- readonly polygon: {
6
- readonly fillOpacity: 0.05;
7
- readonly strokeWidth: 1;
8
- readonly strokeOpacity: 1;
9
- };
10
- readonly line: {
11
- readonly strokeWidth: 1;
12
- readonly strokeOpacity: 1;
13
- };
14
- readonly point: {
15
- readonly fillOpacity: 0.2;
16
- readonly strokeWidth: 1;
17
- readonly strokeOpacity: 1;
18
- readonly pointRadius: 5;
19
- };
20
- };
3
+ import type { MapTheme } from "./primitiveMapTypes";
4
+ /**
5
+ * Per-shape-type visual defaults injected by the map consumer via `createMapComponent`.
6
+ * Adapters receive these via `LayerPort.setShapeStyleDefaults` rather than importing
7
+ * hardcoded values directly.
8
+ *
9
+ * Each shape type exposes the required numeric fields adapters use as fallbacks so
10
+ * TypeScript can infer non-nullable numbers without extra guards.
11
+ */
12
+ export type ShapeStyleDefaults = Readonly<{
13
+ polygon: Readonly<{
14
+ fillOpacity: number;
15
+ strokeWidth: number;
16
+ strokeOpacity: number;
17
+ }>;
18
+ line: Readonly<{
19
+ strokeWidth: number;
20
+ strokeOpacity: number;
21
+ }>;
22
+ point: Readonly<{
23
+ fillOpacity: number;
24
+ strokeWidth: number;
25
+ strokeOpacity: number;
26
+ pointRadius: number;
27
+ }>;
28
+ }>;
21
29
  /**
22
30
  * Resolve the visual style for a hovered shape.
23
31
  *