@trackunit/react-map-adapter-shared 0.0.166 → 0.0.168

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
@@ -869,6 +869,7 @@ const mercatorCenterFromBounds = (bounds) => {
869
869
 
870
870
  /** A `DrawValue` with no features. Stable reference, safe for snapshot comparisons. */
871
871
  const EMPTY_DRAW_VALUE = { type: "FeatureCollection", features: [] };
872
+ const NO_DRAW_ERRORS = { engine: null, value: null };
872
873
 
873
874
  // ============================================================================
874
875
  // Constants
@@ -2699,6 +2700,7 @@ exports.LAYER_FADE_DURATION_MS = LAYER_FADE_DURATION_MS;
2699
2700
  exports.MAP_CURSORS = MAP_CURSORS;
2700
2701
  exports.MAX_ZOOM = MAX_ZOOM;
2701
2702
  exports.MIN_ZOOM = MIN_ZOOM;
2703
+ exports.NO_DRAW_ERRORS = NO_DRAW_ERRORS;
2702
2704
  exports.SAFE_AREA_DEFAULT_BUFFER_PX = SAFE_AREA_DEFAULT_BUFFER_PX;
2703
2705
  exports.TRAFFIC_MIN_ZOOM = TRAFFIC_MIN_ZOOM;
2704
2706
  exports.WORLD_BBOX = WORLD_BBOX;
package/index.esm.js CHANGED
@@ -867,6 +867,7 @@ const mercatorCenterFromBounds = (bounds) => {
867
867
 
868
868
  /** A `DrawValue` with no features. Stable reference, safe for snapshot comparisons. */
869
869
  const EMPTY_DRAW_VALUE = { type: "FeatureCollection", features: [] };
870
+ const NO_DRAW_ERRORS = { engine: null, value: null };
870
871
 
871
872
  // ============================================================================
872
873
  // Constants
@@ -2678,4 +2679,4 @@ const resolveStrokeColors = (style, shapeType, theme) => {
2678
2679
  };
2679
2680
  };
2680
2681
 
2681
- export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, EMPTY_DRAW_VALUE, 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, TRAFFIC_MIN_ZOOM, 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 };
2682
+ export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, EMPTY_DRAW_VALUE, 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, NO_DRAW_ERRORS, SAFE_AREA_DEFAULT_BUFFER_PX, TRAFFIC_MIN_ZOOM, 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.166",
3
+ "version": "0.0.168",
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.140",
11
- "@trackunit/geo-json-utils": "1.20.1",
12
- "@trackunit/ui-design-tokens": "1.20.1",
10
+ "@trackunit/react-map-color-utils": "0.0.142",
11
+ "@trackunit/geo-json-utils": "1.21.1",
12
+ "@trackunit/ui-design-tokens": "1.21.1",
13
13
  "es-toolkit": "^1.52.0",
14
14
  "zod": "^3.25.76"
15
15
  },
package/src/DrawPort.d.ts CHANGED
@@ -16,6 +16,48 @@ export type DrawMode = "idle" | "polygon" | "select";
16
16
  export type DrawValue = GeoJsonFeatureCollection;
17
17
  /** A `DrawValue` with no features. Stable reference, safe for snapshot comparisons. */
18
18
  export declare const EMPTY_DRAW_VALUE: DrawValue;
19
+ /**
20
+ * Why the drawing could not do what it was asked (ADR 0030).
21
+ *
22
+ * - `"engine-load-failed"`: the engine chunk or the provider adapter failed to load.
23
+ * The port keeps its mode and value and loads again on the next operation that
24
+ * needs an engine.
25
+ * - `"engine-update-failed"`: a loaded engine threw while applying a mode or value.
26
+ * The committed mode and value are kept.
27
+ * - `"value-rejected"`: the engine could not render some committed features (a
28
+ * self-intersecting ring, a polygon with holes, a non-polygon feature). The
29
+ * committed value is kept exactly as given, so a stored boundary is never
30
+ * overwritten; `rejectedFeatureIndices` names the features, in
31
+ * `getValue().features` order, that are not on the map, and `reasons` gives the
32
+ * engine's wording for each. The indices are recomputed on every verdict: a user
33
+ * edit on the map keeps the rejected features ahead of the drawn ones, so feature
34
+ * order in the value is not preserved across an edit.
35
+ */
36
+ export type DrawEngineError = Readonly<{
37
+ code: "engine-load-failed";
38
+ cause: unknown;
39
+ }> | Readonly<{
40
+ code: "engine-update-failed";
41
+ cause: unknown;
42
+ }>;
43
+ export type DrawValueRejection = Readonly<{
44
+ code: "value-rejected";
45
+ reasons: ReadonlyArray<string>;
46
+ rejectedFeatureIndices: ReadonlyArray<number>;
47
+ }>;
48
+ export type DrawError = DrawEngineError | DrawValueRejection;
49
+ export type DrawErrorCode = DrawError["code"];
50
+ /**
51
+ * The two error slots of a port. They are independent: a transient engine failure
52
+ * never hides or clears the verdict on the committed value, and a consumer can keep
53
+ * showing "this boundary cannot be shown, redraw it" while the engine recovers. The
54
+ * object is replaced only when a slot changes, so it is safe as a snapshot.
55
+ */
56
+ export type DrawErrors = Readonly<{
57
+ engine: DrawEngineError | null;
58
+ value: DrawValueRejection | null;
59
+ }>;
60
+ export declare const NO_DRAW_ERRORS: DrawErrors;
19
61
  /**
20
62
  * Optional adapter capability for interactive polygon drawing (ADR 0030).
21
63
  *
@@ -38,8 +80,10 @@ export type DrawPort = Readonly<{
38
80
  */
39
81
  setMode: (mode: DrawMode) => void;
40
82
  /**
41
- * Replace the committed drawing. Features that are not single-ring polygons are
42
- * dropped. Setting a value equal to the current one is a no-op (no notification).
83
+ * Replace the committed drawing. The value is kept exactly as given: features the
84
+ * engine cannot render stay in it and are reported through `getErrors().value` as
85
+ * `value-rejected`, so a stored boundary is never rewritten by the port. Setting a
86
+ * value equal to the current one is a no-op (no notification).
43
87
  */
44
88
  setValue: (value: DrawValue) => void;
45
89
  /** Current mode snapshot. Stable until `setMode` or the engine changes it. */
@@ -47,7 +91,14 @@ export type DrawPort = Readonly<{
47
91
  /** Current committed drawing snapshot. Stable until it changes. */
48
92
  getValue: () => DrawValue;
49
93
  /**
50
- * Subscribe to mode and value changes. Compatible with
94
+ * The unresolved errors, one slot each. `engine-load-failed` clears when a later
95
+ * load succeeds, `engine-update-failed` on the next successful engine operation,
96
+ * and `value-rejected` when the committed geometry changes. Each slot keeps its
97
+ * object until it changes; a change notifies `subscribe`.
98
+ */
99
+ getErrors: () => DrawErrors;
100
+ /**
101
+ * Subscribe to mode, value and error changes. Compatible with
51
102
  * `useSyncExternalStore(subscribe, getValue)`.
52
103
  */
53
104
  subscribe: (listener: () => void) => () => void;