@fusion.dev/helix-map 0.249.0 → 0.249.2

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.
@@ -23,6 +23,13 @@ export interface MapDriver {
23
23
  * there is hidden, and stays in the frame's walk.
24
24
  */
25
25
  behind?(place: MapPlace): boolean;
26
+ /**
27
+ * Calls `unreached` when the renderer cannot reach its tile source, as when
28
+ * a content blocker cancels the request, and returns what stops the
29
+ * listening. A source that answered with an error of its own, a tile that
30
+ * does not exist, is not unreached.
31
+ */
32
+ failed?(unreached: () => void): () => void;
26
33
  /**
27
34
  * The renderer's credits as it writes them, which is markup, and a way to
28
35
  * hear them change. `stop` ends the listening and puts back anything the
@@ -776,6 +776,7 @@ export const connectMap = (frame, driver, options = {}) => {
776
776
  snapshot.style.display = 'none';
777
777
  };
778
778
  const snapshots = [...frame.querySelectorAll(':scope > [data-helix-map-snapshot]')];
779
+ const stopFailing = driver.failed?.(() => frame.fail?.());
779
780
  const stopWaiting = driver.ready?.(() => {
780
781
  place();
781
782
  frame.drawn?.();
@@ -945,6 +946,7 @@ export const connectMap = (frame, driver, options = {}) => {
945
946
  clearTimeout(looking);
946
947
  stopWaiting?.();
947
948
  frame.drawn?.(false);
949
+ frame.fail?.(false);
948
950
  if (gestured !== 'free') {
949
951
  driver.gestures?.('free');
950
952
  }
@@ -1006,6 +1008,7 @@ export const connectMap = (frame, driver, options = {}) => {
1006
1008
  focusable.setAttribute('tabindex', tabindex);
1007
1009
  }
1008
1010
  }
1011
+ stopFailing?.();
1009
1012
  listening?.stop();
1010
1013
  credit?.remove();
1011
1014
  },
@@ -2,6 +2,12 @@ import type { MapDriver, MapLayerSpec, MapPadding } from '../connect-map/connect
2
2
  import { type MapColors } from '../style/map-colors.js';
3
3
  /** What MapLibre hands a listener, as far as the driver reads it. */
4
4
  interface MapLibreEvent {
5
+ /** On `error`: what went wrong, with `status` 0 for a request that never got an answer. */
6
+ error?: {
7
+ status?: number;
8
+ };
9
+ /** On `error`: the source it was loading, absent for the style's own glyphs and sprites. */
10
+ sourceId?: string;
5
11
  /** On `styleimagemissing`: the image a layer names and the style has not got. */
6
12
  id?: string;
7
13
  /** On a press or a move: where the pointer is, in the map's box. */
@@ -222,8 +228,8 @@ export interface MapLibreMap {
222
228
  enable(): void;
223
229
  isEnabled(): boolean;
224
230
  };
225
- off(type: 'click' | 'idle' | 'load' | 'mousemove' | 'move' | 'resize' | 'sourcedata' | 'moveend' | 'render' | 'styledata' | 'styleimagemissing', listener: (event?: MapLibreEvent) => void): unknown;
226
- on(type: 'click' | 'idle' | 'load' | 'mousemove' | 'move' | 'resize' | 'sourcedata' | 'moveend' | 'render' | 'styledata' | 'styleimagemissing', listener: (event?: MapLibreEvent) => void): unknown;
231
+ off(type: 'click' | 'error' | 'idle' | 'load' | 'mousemove' | 'move' | 'resize' | 'sourcedata' | 'moveend' | 'render' | 'styledata' | 'styleimagemissing', listener: (event?: MapLibreEvent) => void): unknown;
232
+ on(type: 'click' | 'error' | 'idle' | 'load' | 'mousemove' | 'move' | 'resize' | 'sourcedata' | 'moveend' | 'render' | 'styledata' | 'styleimagemissing', listener: (event?: MapLibreEvent) => void): unknown;
227
233
  removeLayer(id: string): unknown;
228
234
  removeSource(id: string): unknown;
229
235
  panBy(offset: [number, number], options?: MapLibreAnimation): unknown;
@@ -317,6 +317,15 @@ export const mapLibreDriver = (map) => ({
317
317
  },
318
318
  };
319
319
  },
320
+ failed: (unreached) => {
321
+ const heard = (event) => {
322
+ if (event?.sourceId !== undefined && event.error?.status === 0) {
323
+ unreached();
324
+ }
325
+ };
326
+ map.on('error', heard);
327
+ return () => map.off('error', heard);
328
+ },
320
329
  fit: ({ northEast, southWest }, padding, motion) => {
321
330
  map.fitBounds([
322
331
  [southWest.lng, southWest.lat],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fusion.dev/helix-map",
3
3
  "description": "Connects the Helix Map frame to a map renderer: MapLibre, Leaflet, or a driver of your own.",
4
- "version": "0.249.0",
4
+ "version": "0.249.2",
5
5
  "license": "MIT",
6
6
  "author": "Fusion Development Group",
7
7
  "repository": {
@@ -44,14 +44,14 @@
44
44
  },
45
45
  "bugs": "https://github.com/project-fusion/fusion/issues",
46
46
  "dependencies": {
47
- "@fusion.dev/helix-core": "0.249.0",
48
- "@fusion.dev/helix-icons": "0.249.0",
47
+ "@fusion.dev/helix-core": "0.249.2",
48
+ "@fusion.dev/helix-icons": "0.249.2",
49
49
  "@mapbox/vector-tile": "^3.0.0",
50
50
  "pbf": "^5.1.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@fusion.dev/helix-headless": "0.249.0",
54
- "@fusion.dev/helix-testing": "0.249.0",
53
+ "@fusion.dev/helix-headless": "0.249.2",
54
+ "@fusion.dev/helix-testing": "0.249.2",
55
55
  "@maplibre/maplibre-gl-style-spec": "^26.8.0",
56
56
  "@types/bun": "^1.4.4",
57
57
  "@types/leaflet": "^1.9.20",