@studiometa/ui-mapbox 1.10.0-beta.5 → 1.10.0

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.
Files changed (90) hide show
  1. package/{AbstractMapboxControl.d.ts → dist/AbstractMapboxControl.d.ts} +1 -1
  2. package/{AbstractMapboxControl.js → dist/AbstractMapboxControl.js} +1 -1
  3. package/dist/AbstractMapboxControl.js.map +1 -0
  4. package/{AbstractMapboxMapChild.d.ts → dist/AbstractMapboxMapChild.d.ts} +3 -2
  5. package/{AbstractMapboxMapChild.js → dist/AbstractMapboxMapChild.js} +2 -2
  6. package/dist/AbstractMapboxMapChild.js.map +1 -0
  7. package/{MapboxCluster.d.ts → dist/MapboxCluster.d.ts} +1 -1
  8. package/{MapboxCluster.js → dist/MapboxCluster.js} +2 -2
  9. package/dist/MapboxCluster.js.map +1 -0
  10. package/{MapboxClusterItem.d.ts → dist/MapboxClusterItem.d.ts} +3 -2
  11. package/{MapboxClusterItem.js → dist/MapboxClusterItem.js} +2 -2
  12. package/dist/MapboxClusterItem.js.map +1 -0
  13. package/{MapboxFullscreenControl.d.ts → dist/MapboxFullscreenControl.d.ts} +1 -1
  14. package/{MapboxFullscreenControl.js → dist/MapboxFullscreenControl.js} +2 -2
  15. package/dist/MapboxFullscreenControl.js.map +1 -0
  16. package/{MapboxGeocoder.d.ts → dist/MapboxGeocoder.d.ts} +1 -1
  17. package/{MapboxGeocoder.js → dist/MapboxGeocoder.js} +1 -1
  18. package/dist/MapboxGeocoder.js.map +1 -0
  19. package/{MapboxGeolocateControl.d.ts → dist/MapboxGeolocateControl.d.ts} +1 -1
  20. package/{MapboxGeolocateControl.js → dist/MapboxGeolocateControl.js} +2 -2
  21. package/dist/MapboxGeolocateControl.js.map +1 -0
  22. package/{MapboxImage.d.ts → dist/MapboxImage.d.ts} +1 -1
  23. package/{MapboxImage.js → dist/MapboxImage.js} +1 -1
  24. package/dist/MapboxImage.js.map +1 -0
  25. package/{MapboxImages.d.ts → dist/MapboxImages.d.ts} +1 -1
  26. package/{MapboxImages.js → dist/MapboxImages.js} +1 -1
  27. package/dist/MapboxImages.js.map +1 -0
  28. package/{MapboxLayer.d.ts → dist/MapboxLayer.d.ts} +1 -1
  29. package/{MapboxLayer.js → dist/MapboxLayer.js} +1 -1
  30. package/dist/MapboxLayer.js.map +1 -0
  31. package/{MapboxMap.d.ts → dist/MapboxMap.d.ts} +3 -2
  32. package/{MapboxMap.js → dist/MapboxMap.js} +2 -2
  33. package/dist/MapboxMap.js.map +1 -0
  34. package/{MapboxMarker.d.ts → dist/MapboxMarker.d.ts} +1 -1
  35. package/{MapboxMarker.js → dist/MapboxMarker.js} +1 -1
  36. package/dist/MapboxMarker.js.map +1 -0
  37. package/{MapboxNavigationControl.d.ts → dist/MapboxNavigationControl.d.ts} +1 -1
  38. package/{MapboxNavigationControl.js → dist/MapboxNavigationControl.js} +2 -2
  39. package/dist/MapboxNavigationControl.js.map +1 -0
  40. package/{MapboxPopup.d.ts → dist/MapboxPopup.d.ts} +1 -1
  41. package/{MapboxPopup.js → dist/MapboxPopup.js} +1 -1
  42. package/dist/MapboxPopup.js.map +1 -0
  43. package/{MapboxSource.d.ts → dist/MapboxSource.d.ts} +1 -1
  44. package/{MapboxSource.js → dist/MapboxSource.js} +1 -1
  45. package/dist/MapboxSource.js.map +1 -0
  46. package/{StoreLocator.d.ts → dist/StoreLocator.d.ts} +3 -2
  47. package/{StoreLocator.js → dist/StoreLocator.js} +3 -3
  48. package/dist/StoreLocator.js.map +1 -0
  49. package/dist/autoload.js +7 -0
  50. package/dist/autoload.js.map +1 -0
  51. package/{catalog.d.ts → dist/catalog.d.ts} +1 -1
  52. package/dist/catalog.js.map +1 -0
  53. package/{dependencies.d.ts → dist/dependencies.d.ts} +1 -1
  54. package/{dependencies.js → dist/dependencies.js} +1 -1
  55. package/dist/dependencies.js.map +1 -0
  56. package/{manifest.d.ts → dist/manifest.d.ts} +1 -1
  57. package/{manifest.js → dist/manifest.js} +1 -1
  58. package/dist/manifest.js.map +1 -0
  59. package/{scripts → dist/scripts}/manifest-types.d.ts +1 -1
  60. package/{utils.d.ts → dist/utils.d.ts} +1 -1
  61. package/{utils.js → dist/utils.js} +1 -1
  62. package/dist/utils.js.map +1 -0
  63. package/package.json +109 -20
  64. package/AbstractMapboxControl.js.map +0 -1
  65. package/AbstractMapboxMapChild.js.map +0 -1
  66. package/MapboxCluster.js.map +0 -1
  67. package/MapboxClusterItem.js.map +0 -1
  68. package/MapboxFullscreenControl.js.map +0 -1
  69. package/MapboxGeocoder.js.map +0 -1
  70. package/MapboxGeolocateControl.js.map +0 -1
  71. package/MapboxImage.js.map +0 -1
  72. package/MapboxImages.js.map +0 -1
  73. package/MapboxLayer.js.map +0 -1
  74. package/MapboxMap.js.map +0 -1
  75. package/MapboxMarker.js.map +0 -1
  76. package/MapboxNavigationControl.js.map +0 -1
  77. package/MapboxPopup.js.map +0 -1
  78. package/MapboxSource.js.map +0 -1
  79. package/StoreLocator.js.map +0 -1
  80. package/autoload.js +0 -7
  81. package/autoload.js.map +0 -1
  82. package/catalog.js.map +0 -1
  83. package/dependencies.js.map +0 -1
  84. package/manifest.js.map +0 -1
  85. package/utils.js.map +0 -1
  86. /package/{autoload.d.ts → dist/autoload.d.ts} +0 -0
  87. /package/{catalog.js → dist/catalog.js} +0 -0
  88. /package/{index.d.ts → dist/index.d.ts} +0 -0
  89. /package/{index.js → dist/index.js} +0 -0
  90. /package/{index.js.map → dist/index.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapboxSource.js","names":[],"sources":["../src/MapboxSource.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport type { SourceSpecification, GeoJSONSourceSpecification, GeoJSONSource } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport { claimMapboxOwnership, getMapboxOwner, releaseMapboxOwnership } from './utils.js';\n\nexport interface MapboxSourceProps extends AbstractMapboxMapChildProps {\n $refs: {\n geojson?: HTMLScriptElement;\n };\n $options: {\n id: string;\n /**\n * The source specification, e.g. `{ type: 'geojson', data }`.\n * @see https://docs.mapbox.com/style-spec/reference/sources/\n */\n source: SourceSpecification;\n };\n}\n\n/**\n * Add a source to the map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxSource<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxSourceProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxSource',\n refs: ['geojson'],\n options: {\n id: String,\n source: Object,\n },\n };\n\n /**\n * Resolve the source specification.\n *\n * When a `geojson` ref — a `<script data-ref=\"geojson\" type=\"application/json\">`\n * element — is present, its content is parsed as inline GeoJSON and injected\n * as the source spec's `data`. Otherwise the `source` option is used as is.\n */\n get source(): SourceSpecification {\n const { source } = this.$options;\n const script = this.$refs.geojson;\n const content = script?.textContent?.trim();\n\n // Only inject inline data when the script ref holds actual content. A\n // missing, empty or whitespace-only ref is treated as \"no inline data\" and\n // the `source` option is used as is instead of injecting `data: null`.\n if (!content) {\n return source;\n }\n\n try {\n const data = JSON.parse(content) as GeoJSONSourceSpecification['data'];\n return { ...source, data } as SourceSpecification;\n } catch (err) {\n this.$warn('Invalid JSON in the `geojson` ref:', err);\n return source;\n }\n }\n\n /**\n * Whether this instance owns the source under its id. Only a source this\n * instance owns — along with the layers tied to it — may be removed on\n * teardown; a source declared by someone else outside the family is left\n * untouched, and a source a newer sibling has since adopted is left to that\n * sibling.\n * @private\n */\n __added = false;\n\n /**\n * The `kind:id` ownership key for this source.\n * @private\n */\n get __ownershipKey(): string {\n return `source:${this.$options.id}`;\n }\n\n /**\n * Mounted hook.\n *\n * Adopt-or-add: when the id is free, add the source and claim ownership. When\n * a source with this id already exists, adding it again would throw a\n * duplicate-id error, so instead update its data (for GeoJSON) and — when the\n * existing source belongs to a sibling `MapboxSource` (e.g. a `Fetch` swap\n * mounted the replacement before the original tore down) — take over\n * ownership. A source declared outside the family is left untouched and not\n * owned.\n */\n mounted() {\n this.whenMapReady((map) => {\n const { id } = this.$options;\n const { source } = this;\n\n if (!map.getSource(id)) {\n map.addSource(id, source);\n // Own the id, keyed to the very source object just added: the liveness\n // probe reports the entry stale the moment this source is removed (a\n // `setStyle` wipe, an external `removeSource`) or replaced under the same\n // id, so it can never misclassify a stranger's later source (H6).\n const added = map.getSource(id);\n claimMapboxOwnership(map, this.__ownershipKey, this, () => map.getSource(id) === added);\n this.__added = true;\n return;\n }\n\n // The id is taken. Only adopt it from another family instance; an\n // externally declared source stays untouched. `getMapboxOwner` validates\n // the existing owner's liveness, so a stale entry left by a wiped/removed\n // source does not read as owned and is not adopted here.\n if (getMapboxOwner(map, this.__ownershipKey)) {\n if (source.type === 'geojson' && 'data' in source) {\n const existing = map.getSource<GeoJSONSource>(id);\n existing?.setData(source.data as GeoJSONSourceSpecification['data']);\n }\n\n const existing = map.getSource(id);\n claimMapboxOwnership(map, this.__ownershipKey, this, () => map.getSource(id) === existing);\n this.__added = true;\n }\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n const map = this.__readyMap;\n const { id } = this.$options;\n\n // Only remove a source this instance still owns: a newer sibling may have\n // adopted the id, and a removed map is already gone (`__readyMap` is unset).\n if (\n this.__added &&\n getMapboxOwner(map as object, this.__ownershipKey) === this &&\n map?.getSource(id)\n ) {\n // Remove every layer tied to the source before removing the source itself,\n // otherwise Mapbox throws because layers still reference a missing source.\n //\n // H7 (PR #567 review): this also removes layers owned by still-mounted\n // `MapboxLayer` instances. Those layers now keep a standing `sourcedata`\n // recovery watch (see `MapboxLayer.__handleSourceData`), so when a source\n // with the same id is later re-added they re-commit themselves rather than\n // vanishing permanently. The removal here is unavoidable (Mapbox rejects\n // removing a source still referenced by a layer); recovery is the layer's\n // job. The common `Fetch` swap (source AND layers replaced together) is\n // likewise fine: the replacement layers re-commit on their own.\n for (const layer of map.getStyle().layers) {\n if ('source' in layer && layer.source === id) {\n map.removeLayer(layer.id);\n }\n }\n\n map.removeSource(id);\n releaseMapboxOwnership(map, this.__ownershipKey, this);\n }\n }\n}\n\nexport default MapboxSource;\n"],"mappings":";;;;;;;AA0BA,IAAa,eAAb,cAAmE,uBAEjE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,MAAM,CAAC,UAAU;EACjB,SAAS;GACP,IAAI;GACJ,QAAQ;GACT;EACF;;;;;;;;CASD,IAAI,SAA8B;EAChC,MAAM,EAAE,WAAW,KAAK;EAExB,MAAM,UADS,KAAK,MAAM,SACF,aAAa,MAAM;AAK3C,MAAI,CAAC,QACH,QAAO;AAGT,MAAI;GACF,MAAM,OAAO,KAAK,MAAM,QAAQ;AAChC,UAAO;IAAE,GAAG;IAAQ;IAAM;WACnB,KAAK;AACZ,QAAK,MAAM,sCAAsC,IAAI;AACrD,UAAO;;;;;;;;;;;CAYX,UAAU;;;;;CAMV,IAAI,iBAAyB;AAC3B,SAAO,UAAU,KAAK,SAAS;;;;;;;;;;;;;CAcjC,UAAU;AACR,OAAK,cAAc,QAAQ;GACzB,MAAM,EAAE,OAAO,KAAK;GACpB,MAAM,EAAE,WAAW;AAEnB,OAAI,CAAC,IAAI,UAAU,GAAG,EAAE;AACtB,QAAI,UAAU,IAAI,OAAO;IAKzB,MAAM,QAAQ,IAAI,UAAU,GAAG;AAC/B,yBAAqB,KAAK,KAAK,gBAAgB,YAAY,IAAI,UAAU,GAAG,KAAK,MAAM;AACvF,SAAK,UAAU;AACf;;AAOF,OAAI,eAAe,KAAK,KAAK,eAAe,EAAE;AAC5C,QAAI,OAAO,SAAS,aAAa,UAAU,OACxB,KAAI,UAAyB,GAAG,EACvC,QAAQ,OAAO,KAA2C;IAGtE,MAAM,WAAW,IAAI,UAAU,GAAG;AAClC,yBAAqB,KAAK,KAAK,gBAAgB,YAAY,IAAI,UAAU,GAAG,KAAK,SAAS;AAC1F,SAAK,UAAU;;IAEjB;;;;;CAMJ,gBAAgB;EACd,MAAM,MAAM,KAAK;EACjB,MAAM,EAAE,OAAO,KAAK;AAIpB,MACE,KAAK,WACL,eAAe,KAAe,KAAK,eAAe,KAAK,QACvD,KAAK,UAAU,GAAG,EAClB;AAYA,QAAK,MAAM,SAAS,IAAI,UAAU,CAAC,OACjC,KAAI,YAAY,SAAS,MAAM,WAAW,GACxC,KAAI,YAAY,MAAM,GAAG;AAI7B,OAAI,aAAa,GAAG;AACpB,0BAAuB,KAAK,KAAK,gBAAgB,KAAK"}
@@ -2,10 +2,11 @@ import { MapboxMap } from "./MapboxMap.js";
2
2
  import { MapboxClusterItem } from "./MapboxClusterItem.js";
3
3
  import { MapboxCluster } from "./MapboxCluster.js";
4
4
  import { MapboxGeocoder } from "./MapboxGeocoder.js";
5
- import { Base, BaseConfig, BaseProps } from "@studiometa/js-toolkit";
5
+ import { BaseConfig, BaseProps } from "@studiometa/js-toolkit";
6
6
  import { LngLatBoundsLike, Map, Popup } from "mapbox-gl";
7
+ import { Base } from "@studiometa/js-toolkit/Base";
7
8
 
8
- //#region StoreLocator.d.ts
9
+ //#region src/StoreLocator.d.ts
9
10
  interface StoreLocatorProps extends BaseProps {
10
11
  $options: {
11
12
  itemZoomLevel: number;
@@ -1,9 +1,9 @@
1
1
  import { MAPBOX_MAP_CONNECTED } from "./AbstractMapboxMapChild.js";
2
2
  import { MAPBOX_CLUSTER_CONNECTED } from "./MapboxCluster.js";
3
3
  import { getMapboxGl } from "./dependencies.js";
4
- import { Base } from "@studiometa/js-toolkit";
5
- import { nextTick } from "@studiometa/js-toolkit/utils";
6
- //#region StoreLocator.ts
4
+ import { Base } from "@studiometa/js-toolkit/Base";
5
+ import { nextTick } from "@studiometa/js-toolkit/utils/nextTick";
6
+ //#region src/StoreLocator.ts
7
7
  /**
8
8
  * Maximum number of `nextTick` retries used to wire the `MapboxCluster` and the
9
9
  * optional `MapboxGeocoder`. They are mounted asynchronously (the geocoder even
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoreLocator.js","names":[],"sources":["../src/StoreLocator.ts"],"sourcesContent":["import { Base } from '@studiometa/js-toolkit/Base';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\nimport { nextTick } from '@studiometa/js-toolkit/utils/nextTick';\nimport type { Map, LngLatLike, LngLatBoundsLike, Popup } from 'mapbox-gl';\nimport { getMapboxGl } from './dependencies.js';\nimport { MapboxMap } from './MapboxMap.js';\nimport { MAPBOX_MAP_CONNECTED } from './AbstractMapboxMapChild.js';\nimport { MAPBOX_CLUSTER_CONNECTED, type MapboxCluster } from './MapboxCluster.js';\nimport type { MapboxClusterItem } from './MapboxClusterItem.js';\nimport type { MapboxGeocoder } from './MapboxGeocoder.js';\n\n/**\n * Maximum number of `nextTick` retries used to wire the `MapboxCluster` and the\n * optional `MapboxGeocoder`. They are mounted asynchronously (the geocoder even\n * lazy-imports its module), so they may not be queryable yet on the `map-load`\n * event: we poll a few ticks before giving up.\n */\nconst WIRE_CHILDREN_MAX_ATTEMPTS = 10;\n\nexport interface StoreLocatorProps extends BaseProps {\n $options: {\n itemZoomLevel: number;\n noSort: boolean;\n fitOnUpdate: boolean;\n popupOptions: Record<string, unknown>;\n };\n}\n\n/**\n * Coordinate a \"find a store near you\" experience on top of a `MapboxMap`.\n *\n * `StoreLocator` is a thin **orchestrator**: it owns no map rendering and no item\n * registry of its own. It wraps a `MapboxMap` containing a\n * [`MapboxCluster`](./MapboxCluster.js) of\n * [`MapboxClusterItem`](./MapboxClusterItem.js)s (the declarative clustered map +\n * list source driver) plus an optional\n * [`MapboxGeocoder`](./MapboxGeocoder.js), and layers the search UX on top:\n * selection, viewport filtering and address search. The cluster keeps owning the\n * data (it derives the source from the registered items); the orchestrator only\n * reads that item set and reacts to it.\n *\n * Each store has three independent states, each with its own source of truth:\n *\n * 1. **Registered** — the item exists in the DOM. Owned by the `MapboxCluster`,\n * it drives the **map data** and only changes when the item set changes (e.g.\n * a `Fetch` swaps the list). The orchestrator is notified through the\n * cluster's `map-update` event.\n * 2. **In bounds** — the item's `lngLat` is inside the current viewport. Drives\n * **list visibility + distance sort only**, recomputed on map `moveend`, and\n * never touches the map data.\n * 3. **Selected** — the chosen item. Drives fly-to, the popup, `active` styling\n * and the `map-select` event.\n *\n * The orchestrator requires its `MapboxCluster` (and `MapboxMap`) to live within\n * its own subtree; it resolves them with `$query`, retries a few ticks for\n * asynchronously-mounted children, and — like the map children — subscribes to\n * the `MAPBOX_MAP_CONNECTED` / `MAPBOX_CLUSTER_CONNECTED` events so a late or\n * replaced map/cluster (re)binds instead of stranding the orchestrator on a\n * destroyed instance, and to the map's own `remove` event so a removed map is\n * never called into. Register each component independently (e.g. with\n * `registerComponent`, optionally behind a lazy `importWhen*` helper):\n * `StoreLocator`, `MapboxMap`, `MapboxCluster` and `MapboxClusterItem`.\n * Registration order does not matter because children resolve their map through\n * the connected-event retry, and the orchestrator declares no child components\n * so nothing is ever double-mounted.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class StoreLocator<T extends BaseProps = BaseProps> extends Base<T & StoreLocatorProps> {\n /**\n * Config.\n *\n * No child components are declared: `MapboxMap`, `MapboxCluster`,\n * `MapboxClusterItem` and `MapboxGeocoder` are each registered independently\n * (e.g. with `registerComponent`, optionally behind a lazy `importWhen*`\n * helper) and mount on their own. The orchestrator discovers them through\n * `$query` once available — declaring them here would double-mount them.\n */\n static config: BaseConfig = {\n name: 'StoreLocator',\n emits: ['map-select', 'map-deselect', 'map-filter'],\n options: {\n itemZoomLevel: {\n type: Number,\n default: 14,\n },\n // Boolean options default to `false`, so sorting is ON by default;\n // `data-option-no-sort` disables the distance sort.\n noSort: Boolean,\n // Fit the map bounds to the item set whenever it changes.\n fitOnUpdate: Boolean,\n // Options forwarded to the `mapboxgl.Popup` opened on selection.\n popupOptions: {\n type: Object,\n default: () => ({}),\n },\n },\n };\n\n /**\n * Whether the underlying map has finished loading.\n */\n isLoaded = false;\n\n /**\n * The Mapbox `Map` instance cached at load, so every listener and teardown\n * path reaches it without a fresh `$query` (which returns nothing once the\n * element is detached).\n * @private\n */\n __map?: Map;\n\n /**\n * The child `MapboxCluster`, cached at wire-time for detach-safe teardown.\n * @private\n */\n __cluster?: MapboxCluster;\n\n /**\n * The optional child `MapboxGeocoder`, cached at wire-time.\n * @private\n */\n __geocoder?: MapboxGeocoder;\n\n /**\n * The currently selected item, if any.\n * @private\n */\n __selected?: MapboxClusterItem;\n\n /**\n * The popup opened for the selected item, created lazily.\n * @private\n */\n __popup?: Popup;\n\n /**\n * Unsubscribe callbacks for the `MapboxCluster` listeners, flushed both on\n * destroy and when the cluster is replaced (so the orchestrator re-wires onto\n * the new instance rather than staying subscribed to the destroyed one).\n * @private\n */\n __offCluster: Array<() => void> = [];\n\n /**\n * Unsubscribe callbacks for the `MapboxGeocoder` listeners, flushed on destroy.\n * @private\n */\n __offGeocoder: Array<() => void> = [];\n\n /**\n * Off handle for the pending `map-load` subscription.\n * @private\n */\n __offMapLoad?: () => void;\n\n /**\n * Off handle for the ready map's own `remove` subscription, used to drop the\n * cached map the moment it is removed so no listener/teardown ever calls a\n * method on a dead map.\n * @private\n */\n __offMapRemove?: () => void;\n\n /**\n * Off handle for the standing document-level `MAPBOX_MAP_CONNECTED` retry\n * subscription, so a map that mounts (or a replacement that mounts after the\n * previous was removed) rebinds the orchestrator.\n * @private\n */\n __offMapConnected?: () => void;\n\n /**\n * Off handle for the standing document-level `MAPBOX_CLUSTER_CONNECTED` retry\n * subscription, so a cluster that mounts late — or replaces the wired one — is\n * (re)wired instead of stranding the orchestrator on a destroyed instance.\n * @private\n */\n __offClusterConnected?: () => void;\n\n /**\n * Whether the `MapboxCluster` listeners are already attached.\n * @private\n */\n __clusterWired = false;\n\n /**\n * Whether the `MapboxGeocoder` `map-result` listener is already attached.\n * @private\n */\n __geocoderWired = false;\n\n /**\n * The closest child `MapboxMap` component.\n */\n get mapboxMap() {\n const mapboxMap = this.$query<MapboxMap>('MapboxMap')[0];\n\n if (!mapboxMap) {\n this.$warn('Can not find a child MapboxMap component.');\n }\n\n return mapboxMap;\n }\n\n /**\n * The child `MapboxCluster`, discovered in the subtree.\n */\n get cluster(): MapboxCluster | undefined {\n return this.__cluster ?? this.$query<MapboxCluster>('MapboxCluster')[0];\n }\n\n /**\n * The optional child `MapboxGeocoder`, discovered in the subtree.\n */\n get geocoder(): MapboxGeocoder | undefined {\n return this.__geocoder ?? this.$query<MapboxGeocoder>('MapboxGeocoder')[0];\n }\n\n /**\n * The Mapbox `Map` instance. Only valid once the map has loaded.\n */\n get map() {\n return this.__map ?? this.mapboxMap?.map;\n }\n\n /**\n * The registered items, read from the cluster (their single source of truth).\n */\n get items(): readonly MapboxClusterItem[] {\n return this.__cluster?.items ?? [];\n }\n\n /**\n * Select an item: deactivate the previous one, fly to the item, open its\n * popup, mark it active and emit a `map-select` event.\n * @param {MapboxClusterItem} item\n */\n selectItem(item: MapboxClusterItem) {\n if (this.__selected && this.__selected !== item) {\n this.__selected.setActive(false);\n }\n\n item.setActive(true);\n this.__selected = item;\n\n this.__map?.flyTo({\n center: item.lngLat as LngLatLike,\n zoom: this.$options.itemZoomLevel,\n });\n\n this.__openPopup(item);\n this.$emit('map-select', item);\n }\n\n /**\n * Clear the current selection, close the popup and emit a `map-deselect` event.\n */\n deselect() {\n if (this.__selected) {\n this.__selected.setActive(false);\n this.__selected = undefined;\n }\n\n this.__popup?.remove();\n this.$emit('map-deselect');\n }\n\n /**\n * Open (or move) the selection popup on the given item, using its popup\n * content. A content-less item closes any open popup instead.\n *\n * NOTE: closing this popup through Mapbox's own close-button UI does NOT clear\n * the selection — `data-active`/`aria-current`/`__selected` stay set by design.\n * Popup visibility and selection are independent: dismissing the popup does not\n * deselect the store. Call `deselect()` explicitly to clear the selection.\n * @private\n * @param {MapboxClusterItem} item\n */\n __openPopup(item: MapboxClusterItem) {\n const map = this.__map;\n\n if (!map) {\n return;\n }\n\n const content = item.popupContent;\n\n if (!content) {\n this.__popup?.remove();\n return;\n }\n\n if (!this.__popup) {\n this.__popup = new (getMapboxGl().Popup)(this.$options.popupOptions);\n }\n\n this.__popup.setLngLat(item.lngLat as LngLatLike).setHTML(content).addTo(map);\n }\n\n /**\n * Fit the map to the whole item set (when `fitOnUpdate`) then recompute the\n * in-view list. Runs on an item-set change (the cluster's `map-update` event) and\n * when the cluster is first wired.\n * @private\n */\n __refresh() {\n if (this.$options.fitOnUpdate && this.items.length > 0) {\n this.__map?.fitBounds(this.__getItemsBounds(), { padding: 40 });\n }\n\n this.__filterItemsInView();\n }\n\n /**\n * Compute the bounding box of the whole registered item set as a\n * `[[minLng, minLat], [maxLng, maxLat]]` tuple.\n * @private\n * @returns {LngLatBoundsLike}\n */\n __getItemsBounds(): LngLatBoundsLike {\n let minLng = Infinity;\n let minLat = Infinity;\n let maxLng = -Infinity;\n let maxLat = -Infinity;\n\n for (const item of this.items) {\n const [lng, lat] = item.lngLat;\n minLng = Math.min(minLng, lng);\n minLat = Math.min(minLat, lat);\n maxLng = Math.max(maxLng, lng);\n maxLat = Math.max(maxLat, lat);\n }\n\n return [\n [minLng, minLat],\n [maxLng, maxLat],\n ];\n }\n\n /**\n * Recompute the visible/sorted list = registered ∩ in-bounds, distance-sorted.\n *\n * Reflects the in-bounds state on every item, reorders the in-view items in\n * their shared parent list (so DOM order matches distance) and emits `map-filter`\n * with the in-view items. Never touches the map data.\n * @private\n */\n __filterItemsInView() {\n const map = this.__map;\n\n if (!map) {\n return;\n }\n\n const bounds = map.getBounds();\n const center = map.getCenter();\n const inView: MapboxClusterItem[] = [];\n\n for (const item of this.items) {\n const isInBounds = Boolean(bounds?.contains(item.lngLat as LngLatLike));\n item.setInBounds(isInBounds);\n\n if (isInBounds) {\n inView.push(item);\n }\n }\n\n if (!this.$options.noSort && center) {\n const { LngLat } = getMapboxGl();\n inView.sort(\n (a, b) =>\n center.distanceTo(new LngLat(a.lngLat[0], a.lngLat[1])) -\n center.distanceTo(new LngLat(b.lngLat[0], b.lngLat[1])),\n );\n }\n\n this.__reorderList(inView);\n this.$emit('map-filter', inView);\n }\n\n /**\n * Reorder the in-view items so their DOM order matches the distance sort.\n * Appending a connected node moves it, keeping the list free of duplicates.\n * Items are reordered inside their own shared parent — the sidebar list\n * element — which is resolved per item so no `list` ref is required (a ref\n * declared on the sidebar would not bind anyway: the items live inside the\n * nested `MapboxCluster`, outside this orchestrator's ref scope).\n * @private\n * @param {MapboxClusterItem[]} items\n */\n __reorderList(items: MapboxClusterItem[]) {\n for (const item of items) {\n item.$el.parentElement?.append(item.$el);\n }\n }\n\n /**\n * Handle the cluster's `map-item-click`: select the item behind the clicked\n * unclustered point, if one was resolved.\n * @private\n */\n __handleItemClick = (event: Event) => {\n const [item] = (event as CustomEvent).detail ?? [];\n\n if (item) {\n this.selectItem(item as MapboxClusterItem);\n }\n };\n\n /**\n * Handle a click anywhere in the sidebar: resolve the nearest\n * `MapboxClusterItem` element back to its instance and select it. Delegated on\n * the root so it survives `Fetch`/facet list swaps.\n * @private\n */\n __handleListClick = (event: Event) => {\n const target = event.target as Element | null;\n const el = target?.closest?.('[data-component=\"MapboxClusterItem\"]');\n\n if (!el) {\n return;\n }\n\n const item = this.items.find((candidate) => candidate.$el === el);\n\n if (item) {\n this.selectItem(item);\n }\n };\n\n /**\n * Handle the cluster's `map-update` (the item set changed): re-fit and re-filter.\n * Drops a stale selection whose item is no longer registered.\n * @private\n */\n __handleClusterUpdate = () => {\n // The selected store may have been removed by the swap. Run the full\n // deselect cleanup — not just clearing `__selected` — so its popup is\n // removed from the map and `map-deselect` is emitted, instead of leaving the\n // removed store's popup stranded while the locator claims nothing is\n // selected.\n if (this.__selected && !this.items.includes(this.__selected)) {\n this.deselect();\n }\n\n this.__refresh();\n };\n\n /**\n * Handle a `MapboxGeocoder` `map-result`: frame the map on the geocoded location.\n * @private\n */\n __handleGeocoderResult = (event: Event) => {\n const [result] = (event as CustomEvent).detail ?? [];\n const map = this.__map;\n\n if (!map || !result) {\n return;\n }\n\n if (Array.isArray(result.bbox)) {\n const [minLng, minLat, maxLng, maxLat] = result.bbox;\n map.fitBounds([\n [minLng, minLat],\n [maxLng, maxLat],\n ]);\n } else if (result.center) {\n map.flyTo({ center: result.center as LngLatLike });\n }\n };\n\n /**\n * Recompute the in-view list whenever the viewport settles.\n * @private\n */\n __handleMoveEnd = () => {\n this.__filterItemsInView();\n };\n\n /**\n * React to the map being ready: cache it, subscribe to its `remove`, bind the\n * viewport listener and wire the children.\n *\n * Idempotent for the same map (a re-entrant `map-load` or connected event does\n * not double-bind `moveend`), and rebinds cleanly onto a replacement map.\n * @private\n */\n __handleMapLoad = () => {\n const map = this.mapboxMap?.map;\n\n if (!map) {\n return;\n }\n\n // Rebinding onto a replacement: drop the viewport listener from the previous\n // map before caching and binding the new one.\n if (this.__map && this.__map !== map) {\n this.__map.off('moveend', this.__handleMoveEnd);\n }\n\n this.isLoaded = true;\n this.__map = map;\n this.__bindMapRemove(map);\n map.off('moveend', this.__handleMoveEnd);\n map.on('moveend', this.__handleMoveEnd);\n this.__wireChildren();\n };\n\n /**\n * Subscribe once to the ready map's own `remove` event so a map removed while\n * the orchestrator stays mounted drops the cached (now dead) map instead of\n * calling `flyTo`/`getBounds`/`fitBounds`/`off` on it. A replacement map\n * announces itself through `MAPBOX_MAP_CONNECTED` and rebinds the orchestrator.\n * @private\n * @param {Map} map\n */\n __bindMapRemove(map: Map) {\n this.__offMapRemove?.();\n this.__offMapRemove = undefined;\n\n // Degrade gracefully for minimal map doubles without an event emitter.\n if (typeof map?.on !== 'function') {\n return;\n }\n\n const handler = () => {\n this.__offMapRemove?.();\n this.__offMapRemove = undefined;\n this.__map?.off('moveend', this.__handleMoveEnd);\n this.__map = undefined;\n this.isLoaded = false;\n };\n\n map.on('remove', handler);\n this.__offMapRemove = () => map.off('remove', handler);\n }\n\n /**\n * Resolve the child `MapboxMap` and bind to it — now if it is already loaded,\n * otherwise once on `map-load`. When none exists yet the standing\n * `MAPBOX_MAP_CONNECTED` subscription rebinds later.\n * @private\n */\n __bindMap() {\n const { mapboxMap } = this;\n\n if (!mapboxMap) {\n return;\n }\n\n if (mapboxMap.isLoaded) {\n this.__handleMapLoad();\n } else {\n this.__offMapLoad?.();\n this.__offMapLoad = mapboxMap.$on('map-load', this.__handleMapLoad, { once: true });\n }\n }\n\n /**\n * Subscribe once to `MAPBOX_MAP_CONNECTED` and (re)bind when a `MapboxMap`\n * inside this orchestrator connects — a late-mounted map, or a replacement for\n * one that was removed. Ignores maps outside this subtree (several independent\n * locators/maps can share a page).\n * @private\n */\n __waitForConnectedMap() {\n if (this.__offMapConnected) {\n return;\n }\n\n const handler = (event: Event) => {\n const mapboxMap = (event as CustomEvent<MapboxMap>).detail;\n\n // The map lives *inside* the orchestrator: filter to descendants.\n if (!mapboxMap?.$el || !this.$el.contains(mapboxMap.$el)) {\n return;\n }\n\n // Already bound to this exact, loaded map: nothing to do.\n if (this.__map && this.__map === mapboxMap.map) {\n return;\n }\n\n this.__bindMap();\n };\n\n document.addEventListener(MAPBOX_MAP_CONNECTED, handler);\n this.__offMapConnected = () => document.removeEventListener(MAPBOX_MAP_CONNECTED, handler);\n }\n\n /**\n * Subscribe once to `MAPBOX_CLUSTER_CONNECTED` and (re)wire when a\n * `MapboxCluster` inside this orchestrator connects. A cluster that replaces\n * the wired one drops the stale wiring and re-wires onto the new instance, so\n * list clicks, viewport filtering and selection keep working after a swap.\n * @private\n */\n __waitForConnectedCluster() {\n if (this.__offClusterConnected) {\n return;\n }\n\n const handler = (event: Event) => {\n const cluster = (event as CustomEvent<MapboxCluster>).detail;\n\n if (!cluster?.$el || !this.$el.contains(cluster.$el)) {\n return;\n }\n\n if (this.__cluster && this.__cluster !== cluster) {\n // A replacement cluster: drop the stale wiring and re-wire onto it.\n this.__unwireCluster();\n }\n\n if (!this.__clusterWired) {\n this.__wireChildren();\n }\n };\n\n document.addEventListener(MAPBOX_CLUSTER_CONNECTED, handler);\n this.__offClusterConnected = () =>\n document.removeEventListener(MAPBOX_CLUSTER_CONNECTED, handler);\n }\n\n /**\n * Detach the current cluster listeners and reset the wiring flag so\n * `__wireChildren` binds afresh onto a replacement cluster.\n * @private\n */\n __unwireCluster() {\n for (const off of this.__offCluster) {\n off();\n }\n this.__offCluster = [];\n this.__clusterWired = false;\n this.__cluster = undefined;\n }\n\n /**\n * Attach the `MapboxCluster`/`MapboxGeocoder` listeners once those children\n * are available. Both mount asynchronously (the geocoder even lazy-imports its\n * module), so we poll a bounded number of ticks until *each* is wired — the\n * cluster is required, the geocoder optional. A locator missing the geocoder\n * simply polls to the attempt cap (bounded and harmless). The standing\n * connected-event subscriptions cover anything that mounts after the cap.\n * @private\n * @param {number} attempt\n */\n __wireChildren(attempt = 0) {\n const { cluster, geocoder } = this;\n\n // The cluster becomes queryable as soon as it is constructed, but its\n // GeoJSON source is only added from its `mounted()` hook. Observing\n // `$isMounted` guarantees the source is ready before we wire and refresh.\n if (cluster && cluster.$isMounted && !this.__clusterWired) {\n this.__clusterWired = true;\n this.__cluster = cluster;\n this.__offCluster.push(cluster.$on('map-item-click', this.__handleItemClick));\n this.__offCluster.push(cluster.$on('map-update', this.__handleClusterUpdate));\n // Catch up on the cluster's current item set: it may have emitted its\n // seeded `map-update` before we subscribed.\n this.__refresh();\n }\n\n if (geocoder && !this.__geocoderWired) {\n this.__geocoderWired = true;\n this.__geocoder = geocoder;\n this.__offGeocoder.push(geocoder.$on('map-result', this.__handleGeocoderResult));\n }\n\n if ((!this.__clusterWired || !this.__geocoderWired) && attempt < WIRE_CHILDREN_MAX_ATTEMPTS) {\n nextTick(() => {\n if (this.$isMounted) {\n this.__wireChildren(attempt + 1);\n }\n });\n }\n }\n\n /**\n * Mounted hook: bind the delegated sidebar click, resolve and bind the map,\n * and install the standing connected-event subscriptions so a late or replaced\n * map/cluster (re)binds instead of stranding the orchestrator.\n */\n mounted() {\n this.$el.addEventListener('click', this.__handleListClick);\n\n this.__bindMap();\n this.__waitForConnectedMap();\n this.__waitForConnectedCluster();\n }\n\n /**\n * Destroyed hook: detach every listener, close the popup and clear the cached\n * references — even when the element has already been detached from the DOM.\n */\n destroyed() {\n for (const off of this.__offCluster) {\n off();\n }\n for (const off of this.__offGeocoder) {\n off();\n }\n this.__offCluster = [];\n this.__offGeocoder = [];\n\n this.__offMapLoad?.();\n this.__offMapLoad = undefined;\n this.__offMapRemove?.();\n this.__offMapRemove = undefined;\n this.__offMapConnected?.();\n this.__offMapConnected = undefined;\n this.__offClusterConnected?.();\n this.__offClusterConnected = undefined;\n\n this.__map?.off('moveend', this.__handleMoveEnd);\n this.$el.removeEventListener('click', this.__handleListClick);\n\n this.__popup?.remove();\n this.__popup = undefined;\n this.__selected = undefined;\n this.__map = undefined;\n this.__cluster = undefined;\n this.__geocoder = undefined;\n this.isLoaded = false;\n this.__clusterWired = false;\n this.__geocoderWired = false;\n }\n}\n\nexport default StoreLocator;\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDnC,IAAa,eAAb,cAAmE,KAA4B;;;;;;;;;;CAU7F,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO;GAAC;GAAc;GAAgB;GAAa;EACnD,SAAS;GACP,eAAe;IACb,MAAM;IACN,SAAS;IACV;GAGD,QAAQ;GAER,aAAa;GAEb,cAAc;IACZ,MAAM;IACN,gBAAgB,EAAE;IACnB;GACF;EACF;;;;CAKD,WAAW;;;;;;;CAQX;;;;;CAMA;;;;;CAMA;;;;;CAMA;;;;;CAMA;;;;;;;CAQA,eAAkC,EAAE;;;;;CAMpC,gBAAmC,EAAE;;;;;CAMrC;;;;;;;CAQA;;;;;;;CAQA;;;;;;;CAQA;;;;;CAMA,iBAAiB;;;;;CAMjB,kBAAkB;;;;CAKlB,IAAI,YAAY;EACd,MAAM,YAAY,KAAK,OAAkB,YAAY,CAAC;AAEtD,MAAI,CAAC,UACH,MAAK,MAAM,4CAA4C;AAGzD,SAAO;;;;;CAMT,IAAI,UAAqC;AACvC,SAAO,KAAK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@
1
+ import { manifest } from "./manifest.js";
2
+ import { registerManifest } from "@studiometa/js-toolkit/registerManifest";
3
+ //#region src/autoload.ts
4
+ if (typeof document !== "undefined") registerManifest(manifest);
5
+ //#endregion
6
+
7
+ //# sourceMappingURL=autoload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoload.js","names":[],"sources":["../src/autoload.ts"],"sourcesContent":["import { registerManifest } from '@studiometa/js-toolkit/registerManifest';\nimport { manifest } from './manifest.js';\n\n// Side-effect entry: importing this module registers the `@studiometa/ui-mapbox` manifest with the\n// shared js-toolkit autoload runtime and ensures the autoloader starts. There is nothing to export\n// — `import` is the contract. Importing it alongside `@studiometa/ui/autoload` coalesces into a\n// single loader over the composed set.\nif (typeof document !== 'undefined') {\n registerManifest(manifest);\n}\n"],"mappings":";;;AAOA,IAAI,OAAO,aAAa,YACtB,kBAAiB,SAAS"}
@@ -1,6 +1,6 @@
1
1
  import { ComponentCatalog } from "./scripts/manifest-types.js";
2
2
 
3
- //#region catalog.d.ts
3
+ //#region src/catalog.d.ts
4
4
  /** The autoload catalog for every declarative `@studiometa/ui-mapbox` component. */
5
5
  declare const catalog: ComponentCatalog;
6
6
  //#endregion
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../src/catalog.ts"],"sourcesContent":["import type { ComponentCatalog, CuratedComponentMetadata } from '../../../scripts/manifest-types.js';\n\n// Mapbox GL and the optional geocoder are external (import-map resolved) and no longer served by\n// the CDN, so these components declare neither a CDN-served stylesheet nor a bundled integration\n// chunk — consumers load the Mapbox JavaScript and CSS from the source their import map points at.\nconst components: readonly CuratedComponentMetadata[] = [\n { token: 'MapboxCluster', group: 'mapbox' },\n { token: 'MapboxClusterItem', group: 'mapbox' },\n { token: 'MapboxFullscreenControl', group: 'mapbox' },\n { token: 'MapboxGeocoder', group: 'mapbox' },\n { token: 'MapboxGeolocateControl', group: 'mapbox' },\n { token: 'MapboxImage', group: 'mapbox' },\n { token: 'MapboxImages', group: 'mapbox' },\n { token: 'MapboxLayer', group: 'mapbox' },\n { token: 'MapboxMap', group: 'mapbox' },\n { token: 'MapboxMarker', group: 'mapbox' },\n { token: 'MapboxNavigationControl', group: 'mapbox' },\n { token: 'MapboxPopup', group: 'mapbox' },\n { token: 'MapboxSource', group: 'mapbox' },\n { token: 'StoreLocator', group: 'mapbox' },\n];\n\n/** The autoload catalog for every declarative `@studiometa/ui-mapbox` component. */\nexport const catalog: ComponentCatalog = {\n packageName: '@studiometa/ui-mapbox',\n strategy: 'visible',\n components,\n abstractExports: ['AbstractMapboxControl', 'AbstractMapboxMapChild'],\n};\n"],"mappings":";AAuBA,MAAa,UAA4B;CACvC,aAAa;CACb,UAAU;CACV,YArBsD;EACtD;GAAE,OAAO;GAAiB,OAAO;GAAU;EAC3C;GAAE,OAAO;GAAqB,OAAO;GAAU;EAC/C;GAAE,OAAO;GAA2B,OAAO;GAAU;EACrD;GAAE,OAAO;GAAkB,OAAO;GAAU;EAC5C;GAAE,OAAO;GAA0B,OAAO;GAAU;EACpD;GAAE,OAAO;GAAe,OAAO;GAAU;EACzC;GAAE,OAAO;GAAgB,OAAO;GAAU;EAC1C;GAAE,OAAO;GAAe,OAAO;GAAU;EACzC;GAAE,OAAO;GAAa,OAAO;GAAU;EACvC;GAAE,OAAO;GAAgB,OAAO;GAAU;EAC1C;GAAE,OAAO;GAA2B,OAAO;GAAU;EACrD;GAAE,OAAO;GAAe,OAAO;GAAU;EACzC;GAAE,OAAO;GAAgB,OAAO;GAAU;EAC1C;GAAE,OAAO;GAAgB,OAAO;GAAU;EAC3C;CAOC,iBAAiB,CAAC,yBAAyB,yBAAyB;CACrE"}
@@ -1,6 +1,6 @@
1
1
  import mapboxgl from "mapbox-gl";
2
2
 
3
- //#region dependencies.d.ts
3
+ //#region src/dependencies.d.ts
4
4
  /**
5
5
  * The `mapbox-gl` default export namespace (`Map`, `Marker`, `Popup`, `LngLat`,
6
6
  * the `*Control` constructors, ...). This is the shape every component consumes,
@@ -1,4 +1,4 @@
1
- //#region dependencies.ts
1
+ //#region src/dependencies.ts
2
2
  let mapboxGlInstance;
3
3
  let mapboxGlPromise;
4
4
  let mapboxGlProvided = false;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","names":[],"sources":["../src/dependencies.ts"],"sourcesContent":["import type mapboxgl from 'mapbox-gl';\n\n/**\n * The `mapbox-gl` default export namespace (`Map`, `Marker`, `Popup`, `LngLat`,\n * the `*Control` constructors, ...). This is the shape every component consumes,\n * whether it was injected with {@link provideMapboxGl} or resolved through the\n * fallback dynamic import.\n */\nexport type MapboxGl = typeof mapboxgl;\n\n/**\n * Structural shape of the optional Mapbox geocoder control instances this\n * package builds. Declared locally so the optional `@mapbox/mapbox-gl-geocoder`\n * peer never leaks into the public type surface (and therefore never into the\n * emitted declarations), which would break consumers who install\n * `@studiometa/ui-mapbox` without the optional geocoder peer.\n */\nexport interface MapboxGeocoderControl {\n addTo(target: unknown): void;\n onRemove(): void;\n /**\n * Subscribe to a geocoder control event. Declared optional so the structural\n * type stays satisfiable by minimal test doubles and older control versions.\n */\n on?(type: string, callback: (event: { result: unknown }) => void): void;\n}\n\n/**\n * Structural constructor type for the optional Mapbox geocoder control, kept out\n * of the public peer type surface for the same reason as {@link MapboxGeocoderControl}.\n */\nexport interface MapboxGeocoderConstructor {\n new (options: Record<string, unknown>): MapboxGeocoderControl;\n}\n\nlet mapboxGlInstance: MapboxGl | undefined;\nlet mapboxGlPromise: Promise<MapboxGl> | undefined;\nlet mapboxGlProvided = false;\n\nlet geocoderConstructor: MapboxGeocoderConstructor | undefined;\nlet geocoderPromise: Promise<MapboxGeocoderConstructor> | undefined;\nlet geocoderProvided = false;\n\n/**\n * Inject the `mapbox-gl` module the components should use.\n *\n * Call once, before the components mount (e.g. right before `createApp`). Once\n * provided, `@studiometa/ui-mapbox` never imports `mapbox-gl` by specifier — it\n * uses this instance — so a host can supply its own build (a specific version, a\n * self-hosted worker for strict CSP, an import-map or CDN module).\n *\n * @param {MapboxGl} instance The `mapbox-gl` default export namespace.\n */\nexport function provideMapboxGl(instance: MapboxGl): void {\n mapboxGlProvided = true;\n mapboxGlInstance = instance;\n mapboxGlPromise = Promise.resolve(instance);\n}\n\n/**\n * Inject the optional Mapbox geocoder control constructor the `MapboxGeocoder`\n * component should use, so the optional `@mapbox/mapbox-gl-geocoder` peer is\n * never imported by specifier either.\n *\n * @param {MapboxGeocoderConstructor} constructor The geocoder control constructor.\n */\nexport function provideMapboxGeocoder(constructor: MapboxGeocoderConstructor): void {\n geocoderProvided = true;\n geocoderConstructor = constructor;\n geocoderPromise = Promise.resolve(constructor);\n}\n\n/**\n * Resolve the `mapbox-gl` namespace: the injected instance when one was provided\n * through {@link provideMapboxGl}, otherwise a lazily loaded `import('mapbox-gl')`.\n *\n * The result is memoized, so `mapbox-gl` loads at most once and repeated calls\n * are cheap. The resolved instance is also cached for {@link getMapboxGl}.\n *\n * @returns {Promise<MapboxGl>}\n */\nexport function resolveMapboxGl(): Promise<MapboxGl> {\n if (!mapboxGlPromise) {\n mapboxGlPromise = import('mapbox-gl').then((module) => {\n const instance = ((module as { default?: MapboxGl }).default ?? module) as MapboxGl;\n // A provideMapboxGl() call may have won the race while this import was in\n // flight: never let the fallback overwrite an injected instance. Returning\n // the authoritative instance also keeps callers that awaited this promise\n // before the injection consistent with the provided one.\n if (!mapboxGlProvided) {\n mapboxGlInstance = instance;\n }\n return mapboxGlInstance as MapboxGl;\n });\n }\n\n return mapboxGlPromise;\n}\n\n/**\n * Resolve the optional Mapbox geocoder control constructor: the injected one\n * when provided through {@link provideMapboxGeocoder}, otherwise a lazily loaded\n * `import('@mapbox/mapbox-gl-geocoder')`. Memoized like {@link resolveMapboxGl}.\n *\n * @returns {Promise<MapboxGeocoderConstructor>}\n */\nexport function resolveMapboxGeocoder(): Promise<MapboxGeocoderConstructor> {\n if (!geocoderPromise) {\n geocoderPromise = import('@mapbox/mapbox-gl-geocoder').then((module) => {\n // Cast through `unknown`: the peer's real constructor signature is narrower\n // than the structural `MapboxGeocoderConstructor` kept out of the public\n // type surface, so the two do not directly overlap.\n const constructor = (module as unknown as { default: MapboxGeocoderConstructor }).default;\n // Same race guard as resolveMapboxGl(): a provideMapboxGeocoder() call that\n // landed while this import was in flight must not be overwritten.\n if (!geocoderProvided) {\n geocoderConstructor = constructor;\n }\n return geocoderConstructor as MapboxGeocoderConstructor;\n });\n }\n\n return geocoderPromise;\n}\n\n/**\n * Synchronously read the resolved `mapbox-gl` namespace.\n *\n * Only valid after {@link resolveMapboxGl} (or {@link provideMapboxGl}) has run;\n * it throws otherwise. Components read it on synchronous hot paths (building a\n * control, marker, popup or `LngLat`) that are only ever reached once the map —\n * and therefore `mapbox-gl` — is ready.\n *\n * @returns {MapboxGl}\n */\nexport function getMapboxGl(): MapboxGl {\n if (!mapboxGlInstance) {\n throw new Error(\n '[@studiometa/ui-mapbox] mapbox-gl has not been resolved yet. Await resolveMapboxGl() (or call provideMapboxGl()) before reading it synchronously.',\n );\n }\n\n return mapboxGlInstance;\n}\n"],"mappings":";AAmCA,IAAI;AACJ,IAAI;AACJ,IAAI,mBAAmB;AAEvB,IAAI;AACJ,IAAI;AACJ,IAAI,mBAAmB;;;;;;;;;;;AAYvB,SAAgB,gBAAgB,UAA0B;AACxD,oBAAmB;AACnB,oBAAmB;AACnB,mBAAkB,QAAQ,QAAQ,SAAS;;;;;;;;;AAU7C,SAAgB,sBAAsB,aAA8C;AAClF,oBAAmB;AACnB,uBAAsB;AACtB,mBAAkB,QAAQ,QAAQ,YAAY;;;;;;;;;;;AAYhD,SAAgB,kBAAqC;AACnD,KAAI,CAAC,gBACH,mBAAkB,OAAO,aAAa,MAAM,WAAW;EACrD,MAAM,WAAa,OAAkC,WAAW;AAKhE,MAAI,CAAC,iBACH,oBAAmB;AAErB,SAAO;GACP;AAGJ,QAAO;;;;;;;;;AAUT,SAAgB,wBAA4D;AAC1E,KAAI,CAAC,gBACH,mBAAkB,OAAO,8BAA8B,MAAM,WAAW;EAItE,MAAM,cAAe,OAA6D;AAGlF,MAAI,CAAC,iBACH,uBAAsB;AAExB,SAAO;GACP;AAGJ,QAAO;;;;;;;;;;;;AAaT,SAAgB,cAAwB;AACtC,KAAI,CAAC,iBACH,OAAM,IAAI,MACR,oJACD;AAGH,QAAO"}
@@ -1,6 +1,6 @@
1
1
  import { ComponentManifest } from "@studiometa/js-toolkit";
2
2
 
3
- //#region manifest.d.ts
3
+ //#region src/manifest.d.ts
4
4
  declare const manifest: ComponentManifest;
5
5
  //#endregion
6
6
  export { manifest };
@@ -1,4 +1,4 @@
1
- //#region manifest.ts
1
+ //#region src/manifest.ts
2
2
  const manifest = {
3
3
  MapboxCluster: {
4
4
  token: "MapboxCluster",
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["// This file is generated by scripts/generate-manifests.ts. Do not edit.\nimport type { ComponentManifest } from '@studiometa/js-toolkit';\n\nexport const manifest: ComponentManifest = {\n MapboxCluster: {\n token: 'MapboxCluster',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxCluster',\n exportName: 'MapboxCluster',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxCluster.js').then(({ MapboxCluster }) => MapboxCluster),\n },\n MapboxClusterItem: {\n token: 'MapboxClusterItem',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxClusterItem',\n exportName: 'MapboxClusterItem',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxClusterItem.js').then(({ MapboxClusterItem }) => MapboxClusterItem),\n },\n MapboxFullscreenControl: {\n token: 'MapboxFullscreenControl',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxFullscreenControl',\n exportName: 'MapboxFullscreenControl',\n strategy: 'visible',\n group: 'mapbox',\n load: () =>\n import('./MapboxFullscreenControl.js').then(\n ({ MapboxFullscreenControl }) => MapboxFullscreenControl,\n ),\n },\n MapboxGeocoder: {\n token: 'MapboxGeocoder',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxGeocoder',\n exportName: 'MapboxGeocoder',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxGeocoder.js').then(({ MapboxGeocoder }) => MapboxGeocoder),\n },\n MapboxGeolocateControl: {\n token: 'MapboxGeolocateControl',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxGeolocateControl',\n exportName: 'MapboxGeolocateControl',\n strategy: 'visible',\n group: 'mapbox',\n load: () =>\n import('./MapboxGeolocateControl.js').then(\n ({ MapboxGeolocateControl }) => MapboxGeolocateControl,\n ),\n },\n MapboxImage: {\n token: 'MapboxImage',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxImage',\n exportName: 'MapboxImage',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxImage.js').then(({ MapboxImage }) => MapboxImage),\n },\n MapboxImages: {\n token: 'MapboxImages',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxImages',\n exportName: 'MapboxImages',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxImages.js').then(({ MapboxImages }) => MapboxImages),\n },\n MapboxLayer: {\n token: 'MapboxLayer',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxLayer',\n exportName: 'MapboxLayer',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxLayer.js').then(({ MapboxLayer }) => MapboxLayer),\n },\n MapboxMap: {\n token: 'MapboxMap',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxMap',\n exportName: 'MapboxMap',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxMap.js').then(({ MapboxMap }) => MapboxMap),\n },\n MapboxMarker: {\n token: 'MapboxMarker',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxMarker',\n exportName: 'MapboxMarker',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxMarker.js').then(({ MapboxMarker }) => MapboxMarker),\n },\n MapboxNavigationControl: {\n token: 'MapboxNavigationControl',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxNavigationControl',\n exportName: 'MapboxNavigationControl',\n strategy: 'visible',\n group: 'mapbox',\n load: () =>\n import('./MapboxNavigationControl.js').then(\n ({ MapboxNavigationControl }) => MapboxNavigationControl,\n ),\n },\n MapboxPopup: {\n token: 'MapboxPopup',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxPopup',\n exportName: 'MapboxPopup',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxPopup.js').then(({ MapboxPopup }) => MapboxPopup),\n },\n MapboxSource: {\n token: 'MapboxSource',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'MapboxSource',\n exportName: 'MapboxSource',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./MapboxSource.js').then(({ MapboxSource }) => MapboxSource),\n },\n StoreLocator: {\n token: 'StoreLocator',\n packageName: '@studiometa/ui-mapbox',\n subpath: 'StoreLocator',\n exportName: 'StoreLocator',\n strategy: 'visible',\n group: 'mapbox',\n load: () => import('./StoreLocator.js').then(({ StoreLocator }) => StoreLocator),\n },\n};\n"],"mappings":";AAGA,MAAa,WAA8B;CACzC,eAAe;EACb,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY,OAAO,sBAAsB,MAAM,EAAE,oBAAoB,cAAc;EACpF;CACD,mBAAmB;EACjB,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY,OAAO,0BAA0B,MAAM,EAAE,wBAAwB,kBAAkB;EAChG;CACD,yBAAyB;EACvB,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YACE,OAAO,gCAAgC,MACpC,EAAE,8BAA8B,wBAClC;EACJ;CACD,gBAAgB;EACd,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY,O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qBAAqB,MAAM,EAAE,mBAAmB,aAAa;EACjF;CACD,cAAc;EACZ,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY,OAAO,qBAAqB,MAAM,EAAE,mBAAmB,aAAa;EACjF;CACF"}
@@ -7,7 +7,7 @@ import { ComponentLoadStrategy } from "@studiometa/js-toolkit";
7
7
  * The runtime manifest types (`ComponentManifest`, `ComponentManifestEntry`,
8
8
  * `ComponentLoadStrategy`) now live in `@studiometa/js-toolkit`. These two authoring types are
9
9
  * repository-local tooling contracts: they describe the hand-authored catalogs the generator reads
10
- * (`packages/ui/catalog.ts`, `packages/ui-mapbox/catalog.ts`), never a published runtime surface.
10
+ * (`packages/ui/catalog.ts`, `packages/ui-mapbox/src/catalog.ts`), never a published runtime surface.
11
11
  */
12
12
  /**
13
13
  * Curated authoring metadata for a single component, consumed by the manifest generator. The
@@ -1,6 +1,6 @@
1
1
  import { Map } from "mapbox-gl";
2
2
 
3
- //#region utils.d.ts
3
+ //#region src/utils.d.ts
4
4
  /**
5
5
  * Claim ownership of an id-addressed contribution on a map for the given owner,
6
6
  * taking over from any previous owner of the same id.
@@ -1,4 +1,4 @@
1
- //#region utils.ts
1
+ //#region src/utils.ts
2
2
  /**
3
3
  * Per-map ownership registry for id-addressed contributions (sources, layers,
4
4
  * sprites).
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Map } from 'mapbox-gl';\n\n/**\n * A single ownership entry: the owning component instance plus a liveness probe.\n * @private\n */\ninterface MapboxOwnershipEntry {\n /**\n * The owning component instance.\n */\n owner: unknown;\n /**\n * Whether the resource this owner added is *still the one on the live map*.\n *\n * Returns `false` once the resource has been removed (a `setStyle` wipe, an\n * external `removeSource`/`removeLayer`) or replaced by a different resource\n * under the same id (external re-add). This is what keeps the registry honest\n * without a separate reset pass: a stale entry is detected on read and pruned.\n */\n isLive: () => boolean;\n}\n\n/**\n * Per-map ownership registry for id-addressed contributions (sources, layers,\n * sprites).\n *\n * Keyed weakly by the Mapbox `Map` instance (so the entry drops with the map),\n * then by a `kind:id` string, to an ownership entry. Authored ids\n * (`MapboxSource`/`MapboxLayer`) are shared, so during a `Fetch` swap the new\n * instance mounts — and adopts the id — before the old instance tears down. The\n * registry lets ownership pass from the outgoing instance to the incoming one so\n * the outgoing teardown never deletes the contribution the incoming one now\n * owns, and lets an externally declared id (owned by nobody) stay untouched.\n *\n * H6 (PR #567 review) — staleness is validated on read, not merely on release.\n * An entry used to clear only when its owner *released* it during teardown, so a\n * resource that disappeared another way (a full `map.setStyle()` replacement, an\n * external `removeSource`/`removeLayer`) left a dangling entry that could\n * misclassify a later same-id resource as family-owned. Each entry now carries\n * an `isLive` probe checked in `getMapboxOwner`: when the owner's resource is no\n * longer the one on the map, the entry is pruned and reported as unowned. This\n * makes the registry self-healing across `setStyle` (owners re-claim with a\n * fresh probe as they re-inject) and external removal (the stale entry drops on\n * next read), with no concurrency-fragile \"clear the whole map on style reload\"\n * pass — which would race sibling re-injections claiming under the same style\n * load.\n *\n * REMAINING EDGE (documented, source/layer are robust): sprite liveness can only\n * probe `map.hasImage(name)` — Mapbox exposes no sprite object identity — so an\n * external `removeImage` followed by an external re-add under the same name reads\n * as live again and can still be misclassified. Sources and layers use object\n * identity (`getSource`/`getLayer` returning the very object the owner added), so\n * their external re-add is caught. The image edge needs a browser-validated\n * sprite-identity signal and is left as a follow-up.\n * @private\n */\nconst ownershipRegistry = new WeakMap<object, globalThis.Map<string, MapboxOwnershipEntry>>();\n\n/**\n * Claim ownership of an id-addressed contribution on a map for the given owner,\n * taking over from any previous owner of the same id.\n *\n * @param {object} map The Mapbox map instance the contribution lives on.\n * @param {string} key The `kind:id` ownership key.\n * @param {unknown} owner The claiming component instance.\n * @param {() => boolean} isLive Probe reporting whether the resource this owner\n * added is still the one on the live map. Checked on every `getMapboxOwner`\n * read so a resource that was wiped by `setStyle` or removed/replaced\n * externally is not mistaken for a live family-owned contribution.\n */\nexport function claimMapboxOwnership(\n map: object,\n key: string,\n owner: unknown,\n isLive: () => boolean,\n): void {\n let owners = ownershipRegistry.get(map);\n\n if (!owners) {\n owners = new globalThis.Map();\n ownershipRegistry.set(map, owners);\n }\n\n owners.set(key, { owner, isLive });\n}\n\n/**\n * The current owner of an id-addressed contribution, if any.\n *\n * Validates the entry's liveness before reporting it: if the owner's resource is\n * no longer on the live map (removed by `setStyle`, an external\n * `removeSource`/`removeLayer`, or replaced by a different resource under the\n * same id), the stale entry is pruned and `undefined` is returned so the caller\n * treats the id as unowned — never adopting or deleting a stranger's resource.\n *\n * @param {object} map The Mapbox map instance the contribution lives on.\n * @param {string} key The `kind:id` ownership key.\n * @returns {unknown} The owning instance, or `undefined` when nobody owns it.\n */\nexport function getMapboxOwner(map: object, key: string): unknown {\n const owners = ownershipRegistry.get(map);\n const entry = owners?.get(key);\n\n if (!entry) {\n return undefined;\n }\n\n if (!entry.isLive()) {\n owners!.delete(key);\n return undefined;\n }\n\n return entry.owner;\n}\n\n/**\n * Release ownership of an id-addressed contribution, but only when the given\n * owner is still the current one — a newer instance may already have taken over.\n *\n * @param {object} map The Mapbox map instance the contribution lives on.\n * @param {string} key The `kind:id` ownership key.\n * @param {unknown} owner The instance releasing the id.\n */\nexport function releaseMapboxOwnership(map: object, key: string, owner: unknown): void {\n const owners = ownershipRegistry.get(map);\n\n if (owners?.get(key)?.owner === owner) {\n owners.delete(key);\n }\n}\n\n/**\n * The kind of image the Mapbox `loadImage` method resolves with.\n */\nexport type MapboxImage = ImageBitmap | HTMLImageElement | ImageData;\n\n/**\n * The options accepted by the Mapbox `addImage` method.\n *\n * Derived from the method signature as the underlying `StyleImageMetadata`\n * type is not part of the public `mapbox-gl` exports.\n */\nexport type MapboxImageOptions = NonNullable<Parameters<Map['addImage']>[2]>;\n\n/**\n * Describe a single image to register against a map sprite.\n */\nexport interface MapboxImageDefinition {\n /**\n * The id of the image once registered in the map sprite.\n */\n name: string;\n /**\n * The URL of the image file, must be in png, webp or jpg format.\n */\n url: string;\n /**\n * The image options forwarded to `map.addImage`.\n */\n options?: MapboxImageOptions;\n}\n\n/**\n * Load an image from an external URL with the Mapbox `loadImage` method.\n *\n * The installed `mapbox-gl` version still exposes a callback based\n * `loadImage`, so we wrap it into a promise to keep the components async.\n *\n * @param {Map} map The Mapbox map instance.\n * @param {string} url The URL of the image to load.\n * @returns {Promise<MapboxImage>}\n */\nexport function loadMapboxImage(map: Map, url: string): Promise<MapboxImage> {\n return new Promise((resolve, reject) => {\n map.loadImage(url, (error, image) => {\n if (error || !image) {\n reject(error ?? new Error(`Failed to load the image at \"${url}\".`));\n return;\n }\n\n resolve(image);\n });\n });\n}\n\n/**\n * The result of registering an image against a map sprite.\n */\nexport interface AddMapboxImageResult {\n /**\n * The image loaded from the URL.\n */\n image: MapboxImage;\n /**\n * Whether this call actually added the image to the map sprite. It is `false`\n * when the sprite already existed (registered by someone else), signalling to\n * callers that they do not own it and must not remove it on teardown.\n */\n added: boolean;\n}\n\n/**\n * Load and register a single image against the map sprite.\n *\n * The image is only added when it is not already registered to avoid the\n * \"An image with this name already exists\" error thrown by Mapbox. The returned\n * `added` flag reports whether this call owns the sprite so callers can restrict\n * teardown to the sprites they actually added.\n *\n * @param {Map} map The Mapbox map instance.\n * @param {MapboxImageDefinition} definition The image definition to register.\n * @returns {Promise<AddMapboxImageResult>}\n */\nexport async function addMapboxImage(\n map: Map,\n { name, url, options }: MapboxImageDefinition,\n): Promise<AddMapboxImageResult> {\n const image = await loadMapboxImage(map, url);\n\n let added = false;\n if (!map.hasImage(name)) {\n map.addImage(name, image, options);\n added = true;\n }\n\n return { image, added };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAM,oCAAoB,IAAI,SAA+D;;;;;;;;;;;;;AAc7F,SAAgB,qBACd,KACA,KACA,OACA,QACM;CACN,IAAI,SAAS,kBAAkB,IAAI,IAAI;AAEvC,KAAI,CAAC,QAAQ;AACX,WAAS,IAAI,WAAW,KAAK;AAC7B,oBAAkB,IAAI,KAAK,OAAO;;AAGpC,QAAO,IAAI,KAAK;EAAE;EAAO;EAAQ,CAAC;;;;;;;;;;;;;;;AAgBpC,SAAgB,eAAe,KAAa,KAAsB;CAChE,MAAM,SAAS,kBAAkB,IAAI,IAAI;CACzC,MAAM,QAAQ,QAAQ,IAAI,IAAI;AAE9B,KAAI,CAAC,MACH;AAGF,KAAI,CAAC,MAAM,QAAQ,EAAE;AACnB,SAAQ,OAAO,IAAI;AACnB;;AAGF,QAAO,MAAM;;;;;;;;;;AAWf,SAAgB,uBAAuB,KAAa,KAAa,OAAsB;CACrF,MAAM,SAAS,kBAAkB,IAAI,IAAI;AAEzC,KAAI,QAAQ,IAAI,IAAI,EAAE,UAAU,MAC9B,QAAO,OAAO,IAAI;;;;;;;;;;;;AA6CtB,SAAgB,gBAAgB,KAAU,KAAmC;AAC3E,QAAO,IAAI,SAAS,SAAS,WAAW;AACtC,MAAI,UAAU,MAAM,OAAO,UAAU;AACnC,OAAI,SAAS,CAAC,OAAO;AACnB,WAAO,yBAAS,IAAI,MAAM,gCAAgC,IAAI,IAAI,CAAC;AACnE;;AAGF,WAAQ,MAAM;IACd;GACF;;;;;;;;;;;;;;AA+BJ,eAAsB,eACpB,KACA,EAAE,MAAM,KAAK,WACkB;CAC/B,MAAM,QAAQ,MAAM,gBAAgB,KAAK,IAAI;CAE7C,IAAI,QAAQ;AACZ,KAAI,CAAC,IAAI,SAAS,KAAK,EAAE;AACvB,MAAI,SAAS,MAAM,OAAO,QAAQ;AAClC,UAAQ;;AAGV,QAAO;EAAE;EAAO;EAAO"}
package/package.json CHANGED
@@ -1,37 +1,121 @@
1
1
  {
2
2
  "name": "@studiometa/ui-mapbox",
3
- "version": "1.10.0-beta.5",
3
+ "version": "1.10.0",
4
4
  "description": "Vanilla js-toolkit components to build Mapbox GL maps declaratively",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "type": "module",
9
9
  "sideEffects": [
10
- "./autoload.ts",
11
- "./autoload.js"
10
+ "./dist/autoload.js"
12
11
  ],
13
- "main": "index.js",
14
- "types": "index.d.ts",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
15
14
  "exports": {
16
15
  ".": {
17
- "types": "./index.d.ts",
18
- "import": "./index.js"
16
+ "typescript": "./src/index.ts",
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
19
  },
20
20
  "./autoload": {
21
- "types": "./autoload.d.ts",
22
- "import": "./autoload.js"
21
+ "typescript": "./src/autoload.ts",
22
+ "types": "./dist/autoload.d.ts",
23
+ "import": "./dist/autoload.js"
23
24
  },
24
- "./autoload.js": {
25
- "types": "./autoload.d.ts",
26
- "import": "./autoload.js"
25
+ "./manifest": {
26
+ "typescript": "./src/manifest.ts",
27
+ "types": "./dist/manifest.d.ts",
28
+ "import": "./dist/manifest.js"
27
29
  },
28
- "./*.js": {
29
- "types": "./*.d.ts",
30
- "import": "./*.js"
30
+ "./AbstractMapboxControl": {
31
+ "typescript": "./src/AbstractMapboxControl.ts",
32
+ "types": "./dist/AbstractMapboxControl.d.ts",
33
+ "import": "./dist/AbstractMapboxControl.js"
34
+ },
35
+ "./AbstractMapboxMapChild": {
36
+ "typescript": "./src/AbstractMapboxMapChild.ts",
37
+ "types": "./dist/AbstractMapboxMapChild.d.ts",
38
+ "import": "./dist/AbstractMapboxMapChild.js"
39
+ },
40
+ "./MapboxCluster": {
41
+ "typescript": "./src/MapboxCluster.ts",
42
+ "types": "./dist/MapboxCluster.d.ts",
43
+ "import": "./dist/MapboxCluster.js"
44
+ },
45
+ "./MapboxClusterItem": {
46
+ "typescript": "./src/MapboxClusterItem.ts",
47
+ "types": "./dist/MapboxClusterItem.d.ts",
48
+ "import": "./dist/MapboxClusterItem.js"
49
+ },
50
+ "./MapboxFullscreenControl": {
51
+ "typescript": "./src/MapboxFullscreenControl.ts",
52
+ "types": "./dist/MapboxFullscreenControl.d.ts",
53
+ "import": "./dist/MapboxFullscreenControl.js"
54
+ },
55
+ "./MapboxGeocoder": {
56
+ "typescript": "./src/MapboxGeocoder.ts",
57
+ "types": "./dist/MapboxGeocoder.d.ts",
58
+ "import": "./dist/MapboxGeocoder.js"
59
+ },
60
+ "./MapboxGeolocateControl": {
61
+ "typescript": "./src/MapboxGeolocateControl.ts",
62
+ "types": "./dist/MapboxGeolocateControl.d.ts",
63
+ "import": "./dist/MapboxGeolocateControl.js"
64
+ },
65
+ "./MapboxImage": {
66
+ "typescript": "./src/MapboxImage.ts",
67
+ "types": "./dist/MapboxImage.d.ts",
68
+ "import": "./dist/MapboxImage.js"
69
+ },
70
+ "./MapboxImages": {
71
+ "typescript": "./src/MapboxImages.ts",
72
+ "types": "./dist/MapboxImages.d.ts",
73
+ "import": "./dist/MapboxImages.js"
74
+ },
75
+ "./MapboxLayer": {
76
+ "typescript": "./src/MapboxLayer.ts",
77
+ "types": "./dist/MapboxLayer.d.ts",
78
+ "import": "./dist/MapboxLayer.js"
79
+ },
80
+ "./MapboxMap": {
81
+ "typescript": "./src/MapboxMap.ts",
82
+ "types": "./dist/MapboxMap.d.ts",
83
+ "import": "./dist/MapboxMap.js"
84
+ },
85
+ "./MapboxMarker": {
86
+ "typescript": "./src/MapboxMarker.ts",
87
+ "types": "./dist/MapboxMarker.d.ts",
88
+ "import": "./dist/MapboxMarker.js"
89
+ },
90
+ "./MapboxNavigationControl": {
91
+ "typescript": "./src/MapboxNavigationControl.ts",
92
+ "types": "./dist/MapboxNavigationControl.d.ts",
93
+ "import": "./dist/MapboxNavigationControl.js"
94
+ },
95
+ "./MapboxPopup": {
96
+ "typescript": "./src/MapboxPopup.ts",
97
+ "types": "./dist/MapboxPopup.d.ts",
98
+ "import": "./dist/MapboxPopup.js"
99
+ },
100
+ "./MapboxSource": {
101
+ "typescript": "./src/MapboxSource.ts",
102
+ "types": "./dist/MapboxSource.d.ts",
103
+ "import": "./dist/MapboxSource.js"
104
+ },
105
+ "./StoreLocator": {
106
+ "typescript": "./src/StoreLocator.ts",
107
+ "types": "./dist/StoreLocator.d.ts",
108
+ "import": "./dist/StoreLocator.js"
109
+ },
110
+ "./dependencies": {
111
+ "typescript": "./src/dependencies.ts",
112
+ "types": "./dist/dependencies.d.ts",
113
+ "import": "./dist/dependencies.js"
31
114
  },
32
115
  "./*": {
33
- "types": "./*.d.ts",
34
- "import": "./*.js"
116
+ "typescript": "./src/*.ts",
117
+ "types": "./dist/*.d.ts",
118
+ "import": "./dist/*.js"
35
119
  }
36
120
  },
37
121
  "scripts": {
@@ -57,7 +141,7 @@
57
141
  "homepage": "https://github.com/studiometa/ui#readme",
58
142
  "peerDependencies": {
59
143
  "@mapbox/mapbox-gl-geocoder": "^5.0.0",
60
- "@studiometa/js-toolkit": "^3.9.0-beta.0",
144
+ "@studiometa/js-toolkit": "^3.9.0",
61
145
  "mapbox-gl": "^3.0.0"
62
146
  },
63
147
  "peerDependenciesMeta": {
@@ -67,9 +151,14 @@
67
151
  },
68
152
  "devDependencies": {
69
153
  "@mapbox/mapbox-gl-geocoder": "^5.1.0",
70
- "@studiometa/js-toolkit": "^3.9.0-beta.0",
154
+ "@studiometa/js-toolkit": "^3.9.0",
71
155
  "@types/mapbox__mapbox-gl-geocoder": "^5.0.0",
72
156
  "mapbox-gl": "^3.13.0",
73
157
  "tsdown": "0.21.5"
74
- }
158
+ },
159
+ "files": [
160
+ "dist",
161
+ "README.md",
162
+ "LICENSE.md"
163
+ ]
75
164
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractMapboxControl.js","names":[],"sources":["../AbstractMapboxControl.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport type { ControlPosition, IControl } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\n\nexport interface AbstractMapboxControlProps extends AbstractMapboxMapChildProps {\n $options: {\n position: ControlPosition;\n };\n}\n\n/**\n * Base class for the Mapbox controls added to the map via `map.addControl`.\n *\n * It centralizes the shared `position` option, the lazy control instantiation\n * and the add/remove lifecycle. Concrete controls only need to implement the\n * `createControl` method to build their specific `mapboxgl.*Control` instance.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class AbstractMapboxControl<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & AbstractMapboxControlProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AbstractMapboxControl',\n options: {\n position: {\n type: String,\n default: 'top-right',\n },\n },\n };\n\n /**\n * Control instance.\n * @private\n */\n __control: IControl;\n\n /**\n * The mapbox control instance.\n */\n get control() {\n if (!this.__control) {\n const {\n position: _position,\n name: _name,\n debug: _debug,\n log: _log,\n ...options\n } = this.$options;\n this.__control = this.createControl(options);\n }\n\n return this.__control;\n }\n\n /**\n * Create the concrete mapbox control instance.\n *\n * Subclasses must implement this method to return their specific\n * `mapboxgl.*Control` instance built from the given options.\n *\n * @protected\n */\n createControl(_options: Record<string, unknown>): IControl {\n throw new Error('The `createControl` method must be implemented.');\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.whenMapReady((map) => {\n map.addControl(this.control, this.$options.position);\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n if (this.__control) {\n this.__readyMap?.removeControl(this.__control);\n this.__control = undefined;\n }\n }\n}\n\nexport default AbstractMapboxControl;\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,wBAAb,cAA4E,uBAE1E;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,SAAS,EACP,UAAU;GACR,MAAM;GACN,SAAS;GACV,EACF;EACF;;;;;CAMD;;;;CAKA,IAAI,UAAU;AACZ,MAAI,CAAC,KAAK,WAAW;GACnB,MAAM,EACJ,UAAU,WACV,MAAM,OACN,OAAO,QACP,KAAK,MACL,GAAG,YACD,KAAK;AACT,QAAK,YAAY,KAAK,cAAc,QAAQ;;AAG9C,SAAO,KAAK;;;;;;;;;;CAWd,cAAc,UAA6C;AACzD,QAAM,IAAI,MAAM,kDAAkD;;;;;CAMpE,UAAU;AACR,OAAK,cAAc,QAAQ;AACzB,OAAI,WAAW,KAAK,SAAS,KAAK,SAAS,SAAS;IACpD;;;;;CAMJ,gBAAgB;AACd,MAAI,KAAK,WAAW;AAClB,QAAK,YAAY,cAAc,KAAK,UAAU;AAC9C,QAAK,YAAY,KAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractMapboxMapChild.js","names":[],"sources":["../AbstractMapboxMapChild.ts"],"sourcesContent":["import { Base, type BaseConfig, type BaseProps } from '@studiometa/js-toolkit';\nimport type { Map } from 'mapbox-gl';\nimport type { MapboxMap } from './MapboxMap.js';\n\nexport interface AbstractMapboxMapChildProps extends BaseProps {}\n\n/**\n * Document-level event a `MapboxMap` dispatches when its instance mounts, so a\n * child that mounted *before* its map (e.g. an eagerly registered child under a\n * lazily imported map) can retry resolving its parent and inject itself once the\n * map is connected. The dispatching `MapboxMap` instance travels in `detail`.\n */\nexport const MAPBOX_MAP_CONNECTED = 'mapbox-map:connected';\n\n/**\n * Base class for every component living inside a `MapboxMap`.\n *\n * Children are self-sufficient and dynamic-DOM-native: they resolve their\n * parent `MapboxMap` on their own via `$closest`, wait for the map to be ready\n * with `whenMapReady`, then inject their contribution. Each component is\n * registered independently (e.g. with `registerComponent`, optionally behind a\n * lazy `importWhen*` helper); registration order does not matter because a child\n * resolves its map through the connected-event retry. Once registered,\n * js-toolkit's document-wide `MutationObserver` mounts them whenever their\n * element enters the DOM —\n * statically, `Fetch`-injected or `appendChild`-ed — and terminates them when it\n * leaves, at which point they remove their contribution again.\n *\n * The base hardens three things every child inherits, rather than relying on\n * per-subclass discipline:\n *\n * 1. **Guarded injection & teardown** — mapbox-gl throws readily (a duplicate\n * source id, any style-touching call after `map.remove()`), and js-toolkit's\n * global queue runs lifecycle hooks with no try/catch: a single synchronous\n * throw wedges the queue and freezes every mount/destroy on the page. The\n * ready callback and the subclass teardown (`__onDestroyed`) are both run\n * inside a try/catch that routes to `$warn` + a `map-error` event and never\n * rethrows.\n * 2. **Dead-map safety** — once ready, the child subscribes to the map's own\n * `remove` event; when it fires the cached map reference is dropped so no\n * teardown ever calls a method on a removed map (which throws `TypeError`).\n * 3. **Retryable, standing resolution** — resolution is not one-shot: a child\n * with no map yet waits for `MAPBOX_MAP_CONNECTED`, and a map destroy →\n * remount re-injects the child on the new map's next load.\n * 4. **Style-reload re-injection** — a `map.setStyle()` wipes the whole style\n * (every source/layer/sprite) while the map instance and the still-mounted\n * children survive, so the declarative resources would silently vanish. Once\n * ready, the child subscribes to the map's `style.load` — fired once per\n * style load, the Mapbox-recommended hook for re-adding custom sources/layers\n * when switching base style — and re-runs its injection so it re-adds its\n * contribution onto the fresh style (H7, PR #567 review). The re-run reuses\n * the same containment as the first injection and is guarded on the resource\n * already being present, so it never double-injects.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class AbstractMapboxMapChild<T extends BaseProps = BaseProps> extends Base<\n T & AbstractMapboxMapChildProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AbstractMapboxMapChild',\n emits: ['map-error'],\n };\n\n /**\n * The parent `MapboxMap` resolved at ready-time.\n *\n * `destroyed()` runs *after* the element has been detached from the DOM (e.g.\n * a `Fetch` list swap, or the parent map itself being removed), and a\n * `$closest` lookup on a disconnected node returns nothing — a real bug that\n * would leave the child's contribution stuck on the map. Caching the resolved\n * references at ready-time keeps every teardown path working through the\n * detach.\n * @private\n */\n __readyMapboxMap?: MapboxMap;\n\n /**\n * The Mapbox `Map` instance resolved at ready-time, cached for teardown. It is\n * dropped as soon as the map's `remove` event fires so teardown never touches\n * a removed map.\n * @private\n */\n __readyMap?: Map;\n\n /**\n * The injection callback registered through `whenMapReady`, kept so it can be\n * re-run against a new map when the current one is destroyed and remounted.\n *\n * The callback may be synchronous or `async`: a returned promise is awaited\n * inside the same containment as a synchronous body, so a rejection routes to\n * `$warn` + the `map-error` event instead of surfacing as an unhandled rejection.\n * @private\n */\n __readyCallback?: (map: Map) => void | Promise<void>;\n\n /**\n * Off handler for a still-pending `map-load` subscription, flushed on destroy\n * so a child removed before the map finished loading leaves no listener behind.\n * @private\n */\n __offMapReady?: () => void;\n\n /**\n * Off handler for the ready map's `remove` subscription.\n * @private\n */\n __offMapRemove?: () => void;\n\n /**\n * Off handler for the ready map's `style.load` re-injection subscription.\n * @private\n */\n __offStyleReload?: () => void;\n\n /**\n * Off handler for the document-level `MAPBOX_MAP_CONNECTED` retry subscription.\n * @private\n */\n __offConnected?: () => void;\n\n /**\n * The closest parent `MapboxMap` component instance.\n */\n get mapboxMap() {\n const mapboxMap = this.$closest<MapboxMap>('MapboxMap');\n\n if (!mapboxMap) {\n this.$warn(\n 'Can not find the parent map, does this component has a parent MapboxMap component?',\n );\n }\n\n return mapboxMap;\n }\n\n /**\n * The Mapbox `Map` instance of the closest parent `MapboxMap` component.\n */\n get map() {\n return this.mapboxMap?.map;\n }\n\n /**\n * Run a callback once the parent map is ready — now, on the next `map-load`,\n * or once a `MapboxMap` connects if none exists yet.\n *\n * The callback is stored so it can be re-run on a fresh map after a destroy →\n * remount. It is wrapped so a throw never propagates into the global queue, is\n * never fired after the child has been destroyed, and the resolved\n * map/`MapboxMap` are cached before it runs so teardown can reach them even\n * once the element is detached.\n *\n * The callback may be `async`: a subclass that awaits (image loading, cluster\n * expansion, ...) must additionally guard against the map changing under it by\n * checking `this.__readyMap === map` after every `await`, since the map it was\n * handed can be removed — or replaced by another — while the promise is in\n * flight. A rejected promise is contained here, never rethrown.\n *\n * @param {(map: Map) => void | Promise<void>} cb The work to run against the ready map.\n */\n whenMapReady(cb: (map: Map) => void | Promise<void>): void {\n this.__readyCallback = cb;\n this.__resolveMap();\n }\n\n /**\n * Resolve the parent `MapboxMap` and bind to it, or wait for one to connect.\n * @private\n */\n __resolveMap(): void {\n const mapboxMap = this.$closest<MapboxMap>('MapboxMap');\n\n if (!mapboxMap) {\n this.__waitForConnectedMap();\n return;\n }\n\n this.__bindToMap(mapboxMap);\n }\n\n /**\n * Subscribe once to `MAPBOX_MAP_CONNECTED` and retry resolution when a map\n * whose element is an ancestor of this child connects.\n * @private\n */\n __waitForConnectedMap(): void {\n if (this.__offConnected) {\n return;\n }\n\n const handler = (event: Event) => {\n const mapboxMap = (event as CustomEvent<MapboxMap>).detail;\n\n // Ignore maps that are not an ancestor of this child: several independent\n // maps can live on the same page.\n if (!mapboxMap?.$el?.contains(this.$el)) {\n return;\n }\n\n this.__offConnected?.();\n this.__offConnected = undefined;\n this.__resolveMap();\n };\n\n document.addEventListener(MAPBOX_MAP_CONNECTED, handler);\n this.__offConnected = () => document.removeEventListener(MAPBOX_MAP_CONNECTED, handler);\n }\n\n /**\n * Bind to a resolved `MapboxMap`: run the ready callback now if its map is\n * already loaded, otherwise once on `map-load`.\n * @private\n * @param {MapboxMap} mapboxMap\n */\n __bindToMap(mapboxMap: MapboxMap): void {\n // Resolve the concrete map now and subscribe to its `remove` immediately.\n // Binding the remove handler here rather than after load means a map removed\n // *while its load is still pending* re-resolves the child onto a replacement\n // instead of stranding it: the pending `map-load` subscription is flushed and\n // the child parks on `MAPBOX_MAP_CONNECTED` again.\n const map = mapboxMap.map;\n\n // The parent's `MapboxMap` instance may exist while its concrete map is not\n // built yet: it resolves `mapbox-gl` asynchronously in `mounted()` before\n // creating the map. Keep waiting on `MAPBOX_MAP_CONNECTED`, which the map\n // dispatches once its instance exists, and bind then.\n if (!map) {\n this.__waitForConnectedMap();\n return;\n }\n\n // Drop any stale pending subscription before (re)binding.\n this.__offMapReady?.();\n this.__offMapReady = undefined;\n\n this.__bindMapRemove(map);\n this.__bindStyleReload(map);\n\n const run = () => {\n // The child may have been destroyed while waiting for the map to load: do\n // not inject anything into a map the child no longer belongs to.\n if (!this.$isMounted) {\n return;\n }\n\n this.__readyMapboxMap = mapboxMap;\n this.__readyMap = map;\n this.__runReadyCallback(map);\n };\n\n if (mapboxMap.isLoaded) {\n run();\n } else {\n this.__offMapReady = mapboxMap.$on(\n 'map-load',\n () => {\n this.__offMapReady = undefined;\n run();\n },\n { once: true },\n );\n }\n }\n\n /**\n * Run the ready callback inside a uniform containment for both synchronous\n * throws and rejected promises: a synchronous body is wrapped in `try/catch`,\n * and an `async` body's returned promise is awaited so its rejection routes to\n * `$warn` + the `map-error` event instead of becoming an unhandled rejection.\n * Neither path ever rethrows into the global lifecycle queue.\n * @private\n * @param {Map} map\n */\n __runReadyCallback(map: Map): void {\n let result: void | Promise<void>;\n\n try {\n result = this.__readyCallback?.(map);\n } catch (err) {\n this.__handleError(err);\n return;\n }\n\n if (result && typeof (result as Promise<void>).then === 'function') {\n Promise.resolve(result).catch((err) => this.__handleError(err));\n }\n }\n\n /**\n * Subscribe once to the map's own `remove` event so teardown never runs\n * against a removed map, and so the child re-injects on a remounted map.\n * @private\n * @param {Map} map\n */\n __bindMapRemove(map: Map): void {\n this.__offMapRemove?.();\n this.__offMapRemove = undefined;\n\n // Degrade gracefully for minimal map doubles without an event emitter: a\n // real mapbox map always exposes `on`/`off`.\n if (typeof map?.on !== 'function') {\n return;\n }\n\n const handler = () => {\n this.__offMapRemove?.();\n this.__offMapRemove = undefined;\n\n // Let the subclass flush any map-scoped listener while the map is still\n // referenceable: once `__readyMap` is cleared its teardown can no longer\n // reach the map to `off` them.\n try {\n this.__onMapRemove(map);\n } catch (err) {\n this.__handleError(err);\n }\n\n // A map removed before it finished loading still has a pending `map-load`\n // subscription on the (now dead) `MapboxMap`: flush it so the child does\n // not try to bind on a load that will never come.\n this.__offMapReady?.();\n this.__offMapReady = undefined;\n // The style-reload watch was bound to the now-dead map: drop it too so no\n // `style.load` re-injection ever fires against a removed map.\n this.__offStyleReload?.();\n this.__offStyleReload = undefined;\n this.__readyMap = undefined;\n this.__readyMapboxMap = undefined;\n\n // The map went away, not the child: wait for a new one to connect and\n // re-run the injection against it.\n if (this.$isMounted && this.__readyCallback) {\n this.__waitForConnectedMap();\n }\n };\n\n map.on('remove', handler);\n this.__offMapRemove = () => map.off('remove', handler);\n }\n\n /**\n * Subscribe to the map's `style.load` so the child re-runs its injection after\n * a `setStyle` replaces the whole style, re-adding the source/layer/sprite it\n * would otherwise have silently lost.\n *\n * `style.load` fires once per style load — Mapbox's own recommended hook for\n * re-adding custom sources and layers when switching base style — so it does\n * not need the `styledata` de-duplication a broader `styledata` handler would.\n * The handler bails until the child has actually finished its first injection\n * on this map (`__readyMap === map`): at the *initial* style load `__readyMap`\n * is not set yet (the first injection runs on `map-load`), so this never\n * double-injects on mount and only re-injects on a genuine later `setStyle`.\n * @private\n * @param {Map} map\n */\n __bindStyleReload(map: Map): void {\n this.__offStyleReload?.();\n this.__offStyleReload = undefined;\n\n // Degrade gracefully for minimal map doubles without an event emitter.\n if (typeof map?.on !== 'function') {\n return;\n }\n\n const handler = () => {\n // Only re-inject once the first injection has run against this very map,\n // and only while still mounted with work to do. Re-runs against a map the\n // child no longer owns (removed/replaced) are the `remove` path's job.\n if (!this.$isMounted || !this.__readyCallback || this.__readyMap !== map) {\n return;\n }\n\n // Reuse the first-injection containment. Each subclass callback guards on\n // whether its resource is already present (`getSource`/`getLayer`/\n // `hasImage`), so re-running is safe and re-claims ownership with a fresh\n // liveness probe against the new style.\n this.__runReadyCallback(map);\n };\n\n map.on('style.load', handler);\n this.__offStyleReload = () => map.off('style.load', handler);\n }\n\n /**\n * Contain an error raised by a guarded injection or teardown: warn and emit an\n * `map-error` event, but never rethrow into the global queue.\n * @private\n * @param {unknown} err\n */\n __handleError(err: unknown): void {\n this.$warn(err);\n this.$emit('map-error', err);\n }\n\n /**\n * Hook run when the ready map fires its own `remove` event, while the map is\n * still referenceable (before `__readyMap` is cleared).\n *\n * Subclasses that attach map-scoped listeners (a layer waiting on\n * `sourcedata`, a cluster's per-layer click/hover handlers) override this to\n * `off` them against the map they were bound to — the removed map — since\n * their `__onDestroyed` runs later with `__readyMap` already `undefined` and\n * could not reach the map to unsubscribe.\n * @protected\n * @param {Map} _map The map being removed.\n */\n __onMapRemove(_map: Map) {}\n\n /**\n * Teardown hook implemented by subclasses instead of `destroyed()`.\n *\n * It runs inside the base's guard (see `destroyed`) so a throwing teardown — a\n * style-touching mapbox call, most often — can never wedge the global queue.\n * Implementations read the cached `__readyMap`, which is already `undefined`\n * when the map has been removed, and must not call `super`.\n * @protected\n */\n __onDestroyed() {}\n\n /**\n * Destroyed hook.\n *\n * Runs the guarded subclass teardown, then flushes every base subscription\n * (`map-load`, the map's `remove`, the connected retry). Subclasses override\n * `__onDestroyed` rather than this method.\n */\n destroyed() {\n try {\n this.__onDestroyed();\n } catch (err) {\n this.__handleError(err);\n }\n\n this.__offMapReady?.();\n this.__offMapReady = undefined;\n this.__offMapRemove?.();\n this.__offMapRemove = undefined;\n this.__offStyleReload?.();\n this.__offStyleReload = undefined;\n this.__offConnected?.();\n this.__offConnected = undefined;\n this.__readyCallback = undefined;\n }\n}\n\nexport default AbstractMapboxMapChild;\n"],"mappings":";;;;;;;;AAYA,MAAa,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CpC,IAAa,yBAAb,cAA6E,KAE3E;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,YAAY;EACrB;;;;;;;;;;;;CAaD;;;;;;;CAQA;;;;;;;;;;CAWA;;;;;;CAOA;;;;;CAMA;;;;;CAMA;;;;;CAMA;;;;CAKA,IAAI,YAAY;EACd,MAAM,YAAY,KAAK,SAAoB,YAAY;AAEvD,MAAI,CAAC,UACH,MAAK,MACH,qFACD;AAGH,SAAO;;;;;CAMT,IAAI,MAAM;AACR,SAAO,KAAK,WAAW;;;;;;;;;;;;;;;;;;;;CAqBzB,aAAa,IAA8C;AACzD,OAAK,kBAAkB;AACvB,OAAK,cAAc;;;;;;CAOrB,eAAqB;EACnB,MAAM,YAAY,KAAK,SAAoB,YAAY;AAEvD,MAAI,CAAC,WAAW;AACd,QAAK,uBAAuB;A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cAAc,IAAI;YAChB,KAAK;AACZ,SAAK,cAAc,IAAI;;AAMzB,QAAK,iBAAiB;AACtB,QAAK,gBAAgB,KAAA;AAGrB,QAAK,oBAAoB;AACzB,QAAK,mBAAmB,KAAA;AACxB,QAAK,aAAa,KAAA;AAClB,QAAK,mBAAmB,KAAA;AAIxB,OAAI,KAAK,cAAc,KAAK,gBAC1B,MAAK,uBAAuB;;AAIhC,MAAI,GAAG,UAAU,QAAQ;AACzB,OAAK,uBAAuB,IAAI,IAAI,UAAU,QAAQ;;;;;;;;;;;;;;;;;CAkBxD,kBAAkB,KAAgB;AAChC,OAAK,oBAAoB;AACzB,OAAK,mBAAmB,KAAA;AAGxB,MAAI,OAAO,KAAK,OAAO,WACrB;EAGF,MAAM,gBAAgB;AAIpB,OAAI,CAAC,KAAK,cAAc,CAAC,KAAK,mBAAmB,KAAK,eAAe,IACnE;AAOF,QAAK,mBAAmB,IAAI;;AAG9B,MAAI,GAAG,cAAc,QAAQ;AAC7B,OAAK,yBAAyB,IAAI,IAAI,cAAc,QAAQ;;;;;;;;CAS9D,cAAc,KAAoB;AAChC,OAAK,MAAM,IAAI;AACf,OAAK,MAAM,aAAa,IAAI;;;;;;;;;;;;;;CAe9B,cAAc,MAAW;;;;;;;;;;CAWzB,gBAAgB;;;;;;;;CAShB,YAAY;AACV,MAAI;AACF,QAAK,eAAe;WACb,KAAK;AACZ,QAAK,cAAc,IAAI;;AAGzB,OAAK,iBAAiB;AACtB,OAAK,gBAAgB,KAAA;AACrB,OAAK,kBAAkB;AACvB,OAAK,iBAAiB,KAAA;AACtB,OAAK,oBAAoB;AACzB,OAAK,mBAAmB,KAAA;AACxB,OAAK,kBAAkB;AACvB,OAAK,iBAAiB,KAAA;AACtB,OAAK,kBAAkB,KAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MapboxCluster.js","names":[],"sources":["../MapboxCluster.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport { debounce } from '@studiometa/js-toolkit/utils';\nimport type {\n Map,\n CircleLayerSpecification,\n SymbolLayerSpecification,\n LayerSpecification,\n FilterSpecification,\n GeoJSONSourceSpecification,\n GeoJSONSource,\n MapMouseEvent,\n LngLatLike,\n} from 'mapbox-gl';\nimport type { FeatureCollection, Point } from 'geojson';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport type { MapboxClusterItem } from './MapboxClusterItem.js';\n\n/**\n * Document-level event a `MapboxCluster` dispatches when its instance mounts, so\n * a `MapboxClusterItem` that mounted *before* its cluster can retry resolving it\n * and register itself once the cluster is connected. The dispatching\n * `MapboxCluster` instance travels in `detail`.\n */\nexport const MAPBOX_CLUSTER_CONNECTED = 'mapbox-cluster:connected';\n\n/**\n * Module level counter used to generate a unique base id per instance.\n */\nlet clusterCount = 0;\n\n/**\n * Generate the next unique cluster base id.\n * @returns {string}\n */\nfunction nextClusterId(): string {\n const id = `mb-cluster-${clusterCount}`;\n clusterCount += 1;\n return id;\n}\n\nexport interface MapboxClusterProps extends AbstractMapboxMapChildProps {\n $options: {\n clusterMaxZoom: number;\n clusterRadius: number;\n clusterMinPoints: number;\n clusterProperties: Record<string, unknown>;\n clustersLayout: CircleLayerSpecification['layout'];\n clustersPaint: CircleLayerSpecification['paint'];\n clusterCountLayout: SymbolLayerSpecification['layout'];\n clusterCountPaint: SymbolLayerSpecification['paint'];\n unclusteredPointLayerType: string;\n unclusteredPointLayout: Record<string, unknown>;\n unclusteredPointPaint: Record<string, unknown>;\n };\n}\n\n/**\n * A clustered GeoJSON **source driver** whose features ARE its rendered items.\n *\n * `MapboxCluster` merges the map source and the sidebar list of a classic\n * \"store locator\" into a single declarative unit: `MapboxClusterItem`s (rendered\n * list entries living outside the map) push themselves into the cluster's\n * registry, and the cluster derives its clustered GeoJSON source from that\n * registry. Items self-register, the cluster rebuilds (debounced) on every\n * registry change, gated on `whenMapReady`, and nothing observes or `$query`s.\n *\n * The cluster is deliberately **thin**: it owns only the map data and the\n * clustering interaction (a clustered source, the three layers and the\n * click-to-zoom on clusters). It does **not** select, fly to, filter by viewport\n * or open popups — those search-UX concerns belong to the optional\n * [`StoreLocator`](./StoreLocator.js) orchestrator, which drives them on top of a\n * cluster. Used standalone, a `MapboxCluster` still renders a working clustered\n * map + list (points render, clusters zoom on click); it simply reports a click\n * on an unclustered point through the `map-item-click` event and lets the caller\n * decide what it means.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxCluster<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxClusterProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxCluster',\n emits: ['map-cluster-click', 'map-item-click', 'map-update'],\n options: {\n clusterMaxZoom: {\n type: Number,\n default: 14,\n },\n clusterRadius: {\n type: Number,\n default: 50,\n },\n clusterMinPoints: {\n type: Number,\n default: 2,\n },\n clusterProperties: {\n type: Object,\n default: () => ({}),\n },\n clustersLayout: {\n type: Object,\n default: () => ({}),\n },\n clustersPaint: {\n type: Object,\n default: () => ({\n 'circle-color': '#000',\n 'circle-radius': 40,\n }),\n },\n clusterCountLayout: {\n type: Object,\n default: () => ({\n 'text-field': ['get', 'point_count_abbreviated'],\n }),\n },\n clusterCountPaint: {\n type: Object,\n default: () => ({\n 'text-color': 'white',\n }),\n },\n unclusteredPointLayerType: {\n type: String,\n default: 'circle',\n },\n unclusteredPointLayout: {\n type: Object,\n default: () => ({}),\n },\n unclusteredPointPaint: {\n type: Object,\n default: () => ({\n 'circle-color': '#000',\n 'circle-radius': 4,\n }),\n },\n },\n };\n\n /**\n * Unique base id for this instance.\n * @private\n */\n __id = nextClusterId();\n\n /**\n * Live registry of the mounted `MapboxClusterItem`s, in registration order.\n * @private\n */\n __items: MapboxClusterItem[] = [];\n\n /**\n * The registered `MapboxClusterItem`s, in registration order.\n *\n * Read-only surface for an orchestrator (e.g. `StoreLocator`) that needs to\n * iterate the item set for viewport filtering, distance sorting or selection —\n * the cluster owns the registry, consumers only read it. A defensive copy is\n * returned so a consumer can not splice the live registry (which would corrupt\n * click resolution and source generation without scheduling a rebuild).\n */\n get items(): readonly MapboxClusterItem[] {\n return [...this.__items];\n }\n\n /**\n * Derive an id for the given suffix from the instance base id.\n * @private\n * @param {string} suffix\n * @returns {string}\n */\n __getId(suffix: string): string {\n return `${this.__id}-${suffix}`;\n }\n\n /**\n * The GeoJSON `FeatureCollection` derived from the whole registered item set.\n *\n * This is the single source of truth pushed to the map source and only changes\n * when the item set changes — panning must never rebuild it.\n */\n get featureCollection(): FeatureCollection<Point, Record<string, unknown>> {\n return {\n type: 'FeatureCollection',\n features: this.__items.map((item) => ({\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: item.lngLat,\n },\n properties: {\n ...item.properties,\n id: item.id,\n },\n })),\n };\n }\n\n /**\n * Register an item and schedule a coalesced rebuild so a batch of\n * registrations (e.g. a `Fetch` list swap) results in a single map update.\n * @param {MapboxClusterItem} item\n */\n register(item: MapboxClusterItem) {\n if (!this.__items.includes(item)) {\n this.__items.push(item);\n this.__scheduleRebuild();\n }\n }\n\n /**\n * Unregister an item and schedule a coalesced rebuild.\n * @param {MapboxClusterItem} item\n */\n unregister(item: MapboxClusterItem) {\n const index = this.__items.indexOf(item);\n\n if (index > -1) {\n this.__items.splice(index, 1);\n this.__scheduleRebuild();\n }\n }\n\n /**\n * Replace the live source data directly, bypassing the item registry.\n *\n * Kept for manual/imperative control; the common path is to let registered\n * items drive the data. Safe to call before mount or after teardown.\n *\n * NOTE: this bypasses the registry-is-source invariant, so anything pushed\n * here is transient — the next registry rebuild (any item mount/unmount, or a\n * debounced `__scheduleRebuild`) derives the source from `featureCollection`\n * again and silently overwrites it. Use it only for one-off imperative\n * overlays that do not need to survive an item-set change.\n *\n * @param {GeoJSONSourceSpecification['data']} data\n */\n setData(data: GeoJSONSourceSpecification['data']) {\n const source = this.__readyMap?.getSource<GeoJSONSource>(this.__getId('source'));\n\n if (source && typeof source.setData === 'function') {\n source.setData(data);\n }\n }\n\n /**\n * Coalesce rebuilds into a single trailing call, so a batch of registrations\n * spanning multiple ticks results in one map data update.\n * @private\n */\n __scheduleRebuild = debounce(() => {\n if (this.$isMounted) {\n this.__rebuild();\n }\n }, 100);\n\n /**\n * Push the derived feature collection to the source and announce the change.\n * No-op until the map is ready (the initial build happens in `whenMapReady`).\n * @private\n */\n __rebuild() {\n const map = this.__readyMap;\n\n if (!map) {\n return;\n }\n\n this.setData(this.featureCollection as GeoJSONSourceSpecification['data']);\n // Let an orchestrator react to the new item set (fit the map, refilter the\n // list). The cluster itself never fits or filters — it only reports.\n this.$emit('map-update', this.items);\n }\n\n /**\n * Click handler for the clusters layer, zooming on the clicked cluster.\n * @private\n */\n __handleClustersClick = (event: MapMouseEvent) => {\n const map = this.__readyMap;\n\n if (!map) {\n return;\n }\n\n const feature = map.queryRenderedFeatures(event.point, {\n layers: [this.__getId('clusters')],\n })[0];\n\n if (!feature) {\n return;\n }\n\n const clusterId = feature.properties?.cluster_id as number;\n\n this.$emit('map-cluster-click', clusterId, event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const source = map.getSource<GeoJSONSource>(this.__getId('source'));\n\n source?.getClusterExpansionZoom(clusterId, (error, zoom) => {\n // The expansion zoom resolves asynchronously: the map may have been\n // removed (or replaced) in the meantime, in which case the base cleared\n // `__readyMap`. Bail unless the captured map is still the current one so\n // `easeTo` never runs against a dead map.\n if (\n this.__readyMap !== map ||\n error ||\n zoom === null ||\n zoom === undefined ||\n feature.geometry.type !== 'Point'\n ) {\n return;\n }\n\n map.easeTo({\n center: feature.geometry.coordinates as LngLatLike,\n zoom,\n });\n });\n };\n\n /**\n * Set the map canvas cursor, guarding against a missing map.\n * @private\n * @param {string} cursor\n */\n __setCursor(cursor: string) {\n const canvas = this.__readyMap?.getCanvas();\n\n if (canvas) {\n canvas.style.cursor = cursor;\n }\n }\n\n /**\n * Set a pointer cursor when entering the clusters layer.\n * @private\n */\n __handleClustersMouseenter = () => {\n this.__setCursor('pointer');\n };\n\n /**\n * Reset the cursor when leaving the clusters layer.\n * @private\n */\n __handleClustersMouseleave = () => {\n this.__setCursor('');\n };\n\n /**\n * Report a click on an unclustered point: resolve the feature back to the\n * registered item behind it and emit `map-item-click`. The cluster makes no\n * decision about what a click means — an orchestrator (e.g. `StoreLocator`)\n * listens and selects, opens a popup, etc.\n * @private\n */\n __handleUnclusteredClick = (event: MapMouseEvent) => {\n const feature = event.features?.[0];\n const id = feature?.properties?.id;\n const item =\n id === undefined || id === null\n ? undefined\n : this.__items.find((candidate) => candidate.id === String(id));\n\n this.$emit('map-item-click', item, feature, event);\n };\n\n /**\n * Set a pointer cursor when entering an unclustered point.\n * @private\n */\n __handleUnclusteredMouseenter = () => {\n this.__setCursor('pointer');\n };\n\n /**\n * Reset the cursor when leaving an unclustered point.\n * @private\n */\n __handleUnclusteredMouseleave = () => {\n this.__setCursor('');\n };\n\n /**\n * Mounted hook: build the source and layers, wire the clustering interaction\n * and announce the initial item set — all once the map is ready.\n */\n mounted() {\n // Announce the cluster so any `MapboxClusterItem` that mounted before it —\n // and is waiting on `MAPBOX_CLUSTER_CONNECTED` — can register now. Items\n // register independently of map readiness, so this fires outside the\n // `whenMapReady` gate.\n document.dispatchEvent(new CustomEvent(MAPBOX_CLUSTER_CONNECTED, { detail: this }));\n\n this.whenMapReady((map) => this.__inject(map));\n }\n\n /**\n * Build the clustered source and its three layers and wire the clustering\n * interaction — idempotently, so it can run both on first readiness and on a\n * `style.load` re-injection after a `setStyle` wiped the style (H7, PR #567\n * review).\n *\n * A `setStyle` clears sources and layers but leaves layer-scoped map listeners\n * attached (they live on the map's event emitter, not the style), so this\n * guards `addSource`/`addLayer` against an already-present resource and\n * detaches every listener before re-attaching it — re-running never duplicates\n * a listener nor throws a duplicate-id error.\n * @private\n * @param {Map} map\n */\n __inject(map: Map) {\n const {\n clusterMaxZoom,\n clusterRadius,\n clusterMinPoints,\n clusterProperties,\n clustersLayout,\n clustersPaint,\n clusterCountLayout,\n clusterCountPaint,\n unclusteredPointLayerType,\n unclusteredPointLayout,\n unclusteredPointPaint,\n } = this.$options;\n\n const sourceId = this.__getId('source');\n const clustersId = this.__getId('clusters');\n const clusterCountId = this.__getId('cluster-count');\n const unclusteredPointId = this.__getId('unclustered-point');\n const clustersFilter = ['has', 'point_count'] as FilterSpecification;\n const unclusteredFilter = ['!', ['has', 'point_count']] as FilterSpecification;\n\n const source: GeoJSONSourceSpecification = {\n type: 'geojson',\n cluster: true,\n // Seed the source with the currently-registered items. Items registered\n // before the map was ready are already in `__items`, so the first render\n // is correct without waiting for a debounced rebuild.\n data: this.featureCollection,\n clusterMaxZoom,\n clusterRadius,\n clusterMinPoints,\n clusterProperties,\n };\n\n const clustersLayer: CircleLayerSpecification = {\n id: clustersId,\n type: 'circle',\n source: sourceId,\n filter: clustersFilter,\n layout: clustersLayout,\n paint: clustersPaint,\n };\n\n const clusterCountLayer: SymbolLayerSpecification = {\n id: clusterCountId,\n type: 'symbol',\n source: sourceId,\n filter: clustersFilter,\n layout: clusterCountLayout,\n paint: clusterCountPaint,\n };\n\n const unclusteredPointLayer = {\n id: unclusteredPointId,\n type: unclusteredPointLayerType,\n source: sourceId,\n filter: unclusteredFilter,\n layout: unclusteredPointLayout,\n paint: unclusteredPointPaint,\n } as unknown as LayerSpecification;\n\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, source);\n }\n for (const layer of [clustersLayer, clusterCountLayer, unclusteredPointLayer]) {\n if (!map.getLayer(layer.id)) {\n map.addLayer(layer);\n }\n }\n\n // Detach before attaching so a re-injection never doubles a listener.\n this.__offClusterListeners(map);\n map.on('click', clustersId, this.__handleClustersClick);\n map.on('mouseenter', clustersId, this.__handleClustersMouseenter);\n map.on('mouseleave', clustersId, this.__handleClustersMouseleave);\n map.on('click', unclusteredPointId, this.__handleUnclusteredClick);\n map.on('mouseenter', unclusteredPointId, this.__handleUnclusteredMouseenter);\n map.on('mouseleave', unclusteredPointId, this.__handleUnclusteredMouseleave);\n\n // Announce the seeded item set so an orchestrator can run its first fit +\n // viewport filter against a cluster that was already populated at load.\n this.$emit('map-update', this.items);\n }\n\n /**\n * Detach every map-scoped listener wired in `mounted`.\n * @private\n * @param {Map} map\n */\n __offClusterListeners(map: Map) {\n const clustersId = this.__getId('clusters');\n const unclusteredPointId = this.__getId('unclustered-point');\n\n map.off('click', clustersId, this.__handleClustersClick);\n map.off('mouseenter', clustersId, this.__handleClustersMouseenter);\n map.off('mouseleave', clustersId, this.__handleClustersMouseleave);\n map.off('click', unclusteredPointId, this.__handleUnclusteredClick);\n map.off('mouseenter', unclusteredPointId, this.__handleUnclusteredMouseenter);\n map.off('mouseleave', unclusteredPointId, this.__handleUnclusteredMouseleave);\n }\n\n /**\n * Flush the per-layer listeners against the map being removed, while it is\n * still referenceable — `__onDestroyed` runs later with `__readyMap` already\n * cleared and could not reach the map to unsubscribe.\n * @protected\n * @param {Map} map\n */\n __onMapRemove(map: Map) {\n this.__offClusterListeners(map);\n }\n\n /**\n * Teardown hook: tear down listeners, layers and source.\n */\n __onDestroyed() {\n const map = this.__readyMap;\n\n if (map) {\n const clustersId = this.__getId('clusters');\n const clusterCountId = this.__getId('cluster-count');\n const unclusteredPointId = this.__getId('unclustered-point');\n const sourceId = this.__getId('source');\n\n this.__offClusterListeners(map);\n\n for (const id of [clustersId, clusterCountId, unclusteredPointId]) {\n if (map.getLayer(id)) {\n map.removeLayer(id);\n }\n }\n\n if (map.getSource(sourceId)) {\n map.removeSource(sourceId);\n }\n }\n\n this.__items = [];\n }\n}\n\nexport default MapboxCluster;\n"],"mappings":";;;;;;;;;AA0BA,MAAa,2BAA2B;;;;AAKxC,IAAI,eAAe;;;;;AAMnB,SAAS,gBAAwB;CAC/B,MAAM,KAAK,cAAc;AACzB,iBAAgB;AAChB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyCT,IAAa,gBAAb,cAAoE,uBAElE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM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;IAAgB;IAAmB,CAC/D,KAAI,IAAI,SAAS,GAAG,CAClB,KAAI,YAAY,GAAG;AAIvB,OAAI,IAAI,UAAU,SAAS,CACzB,KAAI,aAAa,SAAS;;AAI9B,OAAK,UAAU,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MapboxClusterItem.js","names":[],"sources":["../MapboxClusterItem.ts"],"sourcesContent":["import { Base, type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport { MAPBOX_CLUSTER_CONNECTED, type MapboxCluster } from './MapboxCluster.js';\n\nexport interface MapboxClusterItemProps extends BaseProps {\n $options: {\n id: string;\n lngLat: [number, number];\n properties: Record<string, unknown>;\n };\n}\n\n/**\n * A single entry of a `MapboxCluster`.\n *\n * Unlike the other `@studiometa/ui-mapbox` components, this one is a **rendered**\n * element (e.g. a list `<li>` in a sidebar) and does not extend\n * `AbstractMapboxMapChild`: its DOM lives outside the `MapboxMap` element, so its\n * context is the parent `MapboxCluster` — resolved via `$closest('MapboxCluster')`\n * — rather than a map.\n *\n * It is at once the list item AND the map feature: the cluster derives its\n * GeoJSON source from the set of registered items, so the same markup drives\n * both the sidebar and the clustered points on the map. The child PUSHES itself\n * to the cluster on mount (`register`) and PULLS itself out on destroy\n * (`unregister`), so the cluster never has to query for its children.\n *\n * The component is headless and passive: it never selects itself. The state\n * setters below reflect state as data-attributes on `$el` so the integrator can\n * style the item with plain CSS, and they are driven by whoever coordinates the\n * experience — a [`StoreLocator`](./StoreLocator.js) orchestrator on `moveend`\n * and on selection, if one wraps the cluster:\n *\n * - `data-in-bounds` — present when the item's `lngLat` is inside the current\n * map viewport (list-visibility signal).\n * - `data-active` + `aria-current=\"true\"` — present when the item is selected.\n *\n * Used under a bare `MapboxCluster` (no orchestrator) the item still registers\n * and renders as a clustered point; it just carries no selection affordance of\n * its own — a click is reported by the cluster's `map-item-click` event for a\n * caller to act on.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxClusterItem<T extends BaseProps = BaseProps> extends Base<\n T & MapboxClusterItemProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxClusterItem',\n emits: ['map-error'],\n options: {\n id: String,\n lngLat: {\n type: Array,\n default: () => [0, 0],\n },\n properties: {\n type: Object,\n default: () => ({}),\n },\n },\n };\n\n /**\n * The parent `MapboxCluster` resolved at mount, cached so the item can still\n * reach it on destroy.\n *\n * `destroyed()` runs *after* the element has been detached from the DOM (e.g.\n * a `Fetch` list swap), and a `$closest` lookup on a disconnected node returns\n * nothing — which would leave the removed item registered and its feature\n * stuck on the map. Caching the reference keeps the unregister path working.\n * @private\n */\n __cluster?: MapboxCluster;\n\n /**\n * Off handler for the document-level `MAPBOX_CLUSTER_CONNECTED` retry\n * subscription, used when the item mounts before its cluster.\n * @private\n */\n __offClusterConnected?: () => void;\n\n /**\n * The item's stable identifier, used to match map features back to the item.\n *\n * Expected to be non-empty and unique within a cluster. Duplicate ids are not\n * rejected, but their behavior is defined rather than undefined: a click on\n * any duplicate resolves to the FIRST registered item carrying that id (see\n * `MapboxCluster.__handleUnclusteredClick`). Integrators wanting a distinct\n * selection per element must give each item a unique id.\n */\n get id(): string {\n return this.$options.id;\n }\n\n /**\n * The item's coordinates as a `[lng, lat]` tuple.\n */\n get lngLat(): [number, number] {\n return this.$options.lngLat;\n }\n\n /**\n * Extra feature properties merged into the item's GeoJSON feature.\n */\n get properties(): Record<string, unknown> {\n return this.$options.properties;\n }\n\n /**\n * The HTML used as the map popup content when this item is selected.\n *\n * Uses the inner HTML of an optional `[data-ref=\"popup\"]` element when present\n * so the sidebar card and the map popup can differ, otherwise falls back to\n * the item's whole inner HTML.\n */\n get popupContent(): string {\n const ref = this.$el.querySelector('[data-ref=\"popup\"]');\n return (ref ?? this.$el).innerHTML.trim();\n }\n\n /**\n * Mounted hook: resolve the parent cluster and register with it.\n */\n mounted() {\n this.__resolveCluster();\n }\n\n /**\n * Resolve the parent `MapboxCluster` and register, or wait for one to connect.\n *\n * Resolution is retryable: an item eagerly registered under a lazily imported\n * cluster mounts first and finds nothing, so it waits for\n * `MAPBOX_CLUSTER_CONNECTED` and registers once its cluster is up.\n * @private\n */\n __resolveCluster() {\n const cluster = this.$closest<MapboxCluster>('MapboxCluster');\n\n if (!cluster) {\n this.__waitForConnectedCluster();\n return;\n }\n\n this.__cluster = cluster;\n cluster.register(this);\n }\n\n /**\n * Subscribe once to `MAPBOX_CLUSTER_CONNECTED` and retry resolution when a\n * cluster whose element is an ancestor of this item connects.\n * @private\n */\n __waitForConnectedCluster() {\n if (this.__offClusterConnected) {\n return;\n }\n\n const handler = (event: Event) => {\n const cluster = (event as CustomEvent<MapboxCluster>).detail;\n\n if (!cluster?.$el?.contains(this.$el)) {\n return;\n }\n\n this.__offClusterConnected?.();\n this.__offClusterConnected = undefined;\n this.__resolveCluster();\n };\n\n document.addEventListener(MAPBOX_CLUSTER_CONNECTED, handler);\n this.__offClusterConnected = () =>\n document.removeEventListener(MAPBOX_CLUSTER_CONNECTED, handler);\n }\n\n /**\n * Destroyed hook: unregister from the cached cluster, even if the element has\n * already been detached from the DOM, and drop any pending retry subscription.\n */\n destroyed() {\n try {\n this.__cluster?.unregister(this);\n } catch (err) {\n this.$warn(err);\n this.$emit('map-error', err);\n }\n\n this.__cluster = undefined;\n this.__offClusterConnected?.();\n this.__offClusterConnected = undefined;\n }\n\n /**\n * Reflect the \"in the current map viewport\" state as a `data-in-bounds`\n * attribute. Called by a `StoreLocator` orchestrator on every map `moveend`.\n * @param {boolean} value\n */\n setInBounds(value: boolean) {\n this.$el.toggleAttribute('data-in-bounds', value);\n }\n\n /**\n * Reflect the \"selected/active\" state as a `data-active` attribute and the\n * `aria-current` state. Called by a `StoreLocator` orchestrator on selection.\n * @param {boolean} value\n */\n setActive(value: boolean) {\n this.$el.toggleAttribute('data-active', value);\n\n if (value) {\n this.$el.setAttribute('aria-current', 'true');\n } else {\n this.$el.removeAttribute('aria-current');\n }\n }\n}\n\nexport default MapboxClusterItem;\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9B,OAAK,wBAAwB,KAAA;;;;;;;CAQ/B,YAAY,OAAgB;AAC1B,OAAK,IAAI,gBAAgB,kBAAkB,MAAM;;;;;;;CAQnD,UAAU,OAAgB;AACxB,OAAK,IAAI,gBAAgB,eAAe,MAAM;AAE9C,MAAI,MACF,MAAK,IAAI,aAAa,gBAAgB,OAAO;MAE7C,MAAK,IAAI,gBAAgB,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MapboxFullscreenControl.js","names":[],"sources":["../MapboxFullscreenControl.ts"],"sourcesContent":["import { withExtraConfig } from '@studiometa/js-toolkit';\nimport type { FullscreenControlOptions } from 'mapbox-gl';\nimport {\n AbstractMapboxControl,\n type AbstractMapboxControlProps,\n} from './AbstractMapboxControl.js';\nimport { getMapboxGl } from './dependencies.js';\n\nexport interface MapboxFullscreenControlProps extends AbstractMapboxControlProps {}\n\n/**\n * Add a fullscreen control to the map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxFullscreenControl extends withExtraConfig(AbstractMapboxControl, {\n name: 'MapboxFullscreenControl',\n}) {\n /**\n * Create the mapbox FullscreenControl instance.\n * @protected\n */\n createControl(options: FullscreenControlOptions) {\n return new (getMapboxGl().FullscreenControl)(options);\n }\n}\n\nexport default MapboxFullscreenControl;\n"],"mappings":";;;;;;;;AAcA,IAAa,0BAAb,cAA6C,gBAAgB,uBAAuB,EAClF,MAAM,2BACP,CAAC,CAAC;;;;;CAKD,cAAc,SAAmC;AAC/C,SAAO,KAAK,aAAa,EAAC,kBAAmB,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MapboxGeocoder.js","names":[],"sources":["../MapboxGeocoder.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport type { Map, IControl } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport {\n getMapboxGl,\n resolveMapboxGeocoder,\n type MapboxGeocoderControl,\n} from './dependencies.js';\n\nexport interface MapboxGeocoderProps extends AbstractMapboxMapChildProps {\n $options: {\n /**\n * Wether to add the geocoder to the map or to the component's root element.\n */\n addToMap: boolean;\n /**\n * All MapboxGeocoder options, except the non serializable ones.\n *\n * Typed structurally (rather than with the optional geocoder peer types) to\n * keep the peer out of the public type surface. Refer to the Mapbox geocoder\n * package documentation (API.md#parameters) for the accepted options.\n */\n options: Record<string, unknown>;\n };\n}\n\n/**\n * Add a geocoder control to the map.\n *\n * The Mapbox geocoder module is an optional peer dependency and is loaded on\n * demand with a dynamic `import()` when the component mounts, so the rest of the\n * package keeps working without it installed.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxGeocoder<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxGeocoderProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxGeocoder',\n emits: ['map-result'],\n options: {\n addToMap: Boolean,\n options: Object,\n },\n };\n\n /**\n * Control instance, created once the lazily imported module resolves.\n * @private\n */\n __control?: MapboxGeocoderControl;\n\n /**\n * The Mapbox geocoder control instance, if it has been created yet.\n */\n get control(): MapboxGeocoderControl | undefined {\n return this.__control;\n }\n\n /**\n * Target element the geocoder is added to: the map when `addToMap` is set,\n * otherwise the component's own root element.\n */\n get target(): Map | HTMLElement | string {\n return this.$options.addToMap ? this.map : this.$el;\n }\n\n /**\n * Mounted hook.\n *\n * Lazily loads the optional Mapbox geocoder module, then builds and adds the\n * control once the parent map is ready.\n */\n async mounted() {\n const GeocoderControlClass = await resolveMapboxGeocoder();\n\n // The component may have been destroyed while the dynamic import was still\n // resolving. Bail out before creating and adding the control, otherwise it\n // would be attached after `destroyed()` already ran (and saw `__control`\n // undefined), leaking an orphan control.\n if (!this.$isMounted) {\n return;\n }\n\n this.whenMapReady(() => {\n // The ready callback is standing: it re-runs on every map replacement. An\n // element-targeted control (`addToMap` false) lives on `$el`, which\n // survives the map swap, so a previous control must be removed first or\n // each replacement would stack another geocoder onto the element. A\n // map-targeted control went away with its (removed) map, so only its\n // reference needs dropping.\n if (this.__control) {\n if (!this.$options.addToMap) {\n this.__control.onRemove();\n }\n this.__control = undefined;\n }\n\n const options = {\n ...this.$options.options,\n mapboxgl: getMapboxGl(),\n accessToken:\n this.$options.options.accessToken ?? this.__readyMapboxMap?.$options.accessToken,\n };\n this.__control = new GeocoderControlClass(\n options as ConstructorParameters<typeof GeocoderControlClass>[0],\n );\n // Re-emit the control's `result` event as a prefixed component event so\n // consumers (e.g. a `StoreLocator`) can react to a geocoded address.\n this.__control.on?.('result', (event) => this.$emit('map-result', event.result));\n this.__control.addTo(this.target);\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n // The control may not exist yet: the dynamic import in `mounted()` might not\n // have resolved, or the geocoder module was never loaded.\n if (this.__control) {\n if (this.$options.addToMap) {\n this.__readyMap?.removeControl(this.__control as unknown as IControl);\n } else {\n this.__control.onRemove();\n }\n this.__control = undefined;\n }\n }\n}\n\nexport default MapboxGeocoder;\n"],"mappings":";;;;;;;;;;;;AAsCA,IAAa,iBAAb,cAAqE,uBAEnE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,aAAa;EACrB,SAAS;GACP,UAAU;GACV,SAAS;GACV;EACF;;;;;CAMD;;;;CAKA,IAAI,UAA6C;AAC/C,SAAO,KAAK;;;;;;CAOd,IAAI,SAAqC;AACvC,SAAO,KAAK,SAAS,WAAW,KAAK,MAAM,KAAK;;;;;;;;CASlD,MAAM,UAAU;EACd,MAAM,uBAAuB,MAAM,uBAAuB;AAM1D,MAAI,CAAC,KAAK,WACR;AAGF,OAAK,mBAAmB;AAOtB,OAAI,KAAK,WAAW;AAClB,QAAI,CAAC,KAAK,SAAS,SACjB,MAAK,UAAU,UAAU;AAE3B,SAAK,YAAY,KAAA;;AASnB,QAAK,YAAY,IAAI,qBANL;IACd,GAAG,KAAK,SAAS;IACjB,UAAU,aAAa;IACvB,aACE,KAAK,SAAS,QAAQ,eAAe,KAAK,kBAAkB,SAAS;IACxE,CAGA;AAGD,QAAK,UAAU,KAAK,WAAW,UAAU,KAAK,MAAM,cAAc,MAAM,OAAO,CAAC;AAChF,QAAK,UAAU,MAAM,KAAK,OAAO;IACjC;;;;;CAMJ,gBAAgB;AAGd,MAAI,KAAK,WAAW;AAClB,OAAI,KAAK,SAAS,SAChB,MAAK,YAAY,cAAc,KAAK,UAAiC;OAErE,MAAK,UAAU,UAAU;AAE3B,QAAK,YAAY,KAAA"}