@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.
- package/{AbstractMapboxControl.d.ts → dist/AbstractMapboxControl.d.ts} +1 -1
- package/{AbstractMapboxControl.js → dist/AbstractMapboxControl.js} +1 -1
- package/dist/AbstractMapboxControl.js.map +1 -0
- package/{AbstractMapboxMapChild.d.ts → dist/AbstractMapboxMapChild.d.ts} +3 -2
- package/{AbstractMapboxMapChild.js → dist/AbstractMapboxMapChild.js} +2 -2
- package/dist/AbstractMapboxMapChild.js.map +1 -0
- package/{MapboxCluster.d.ts → dist/MapboxCluster.d.ts} +1 -1
- package/{MapboxCluster.js → dist/MapboxCluster.js} +2 -2
- package/dist/MapboxCluster.js.map +1 -0
- package/{MapboxClusterItem.d.ts → dist/MapboxClusterItem.d.ts} +3 -2
- package/{MapboxClusterItem.js → dist/MapboxClusterItem.js} +2 -2
- package/dist/MapboxClusterItem.js.map +1 -0
- package/{MapboxFullscreenControl.d.ts → dist/MapboxFullscreenControl.d.ts} +1 -1
- package/{MapboxFullscreenControl.js → dist/MapboxFullscreenControl.js} +2 -2
- package/dist/MapboxFullscreenControl.js.map +1 -0
- package/{MapboxGeocoder.d.ts → dist/MapboxGeocoder.d.ts} +1 -1
- package/{MapboxGeocoder.js → dist/MapboxGeocoder.js} +1 -1
- package/dist/MapboxGeocoder.js.map +1 -0
- package/{MapboxGeolocateControl.d.ts → dist/MapboxGeolocateControl.d.ts} +1 -1
- package/{MapboxGeolocateControl.js → dist/MapboxGeolocateControl.js} +2 -2
- package/dist/MapboxGeolocateControl.js.map +1 -0
- package/{MapboxImage.d.ts → dist/MapboxImage.d.ts} +1 -1
- package/{MapboxImage.js → dist/MapboxImage.js} +1 -1
- package/dist/MapboxImage.js.map +1 -0
- package/{MapboxImages.d.ts → dist/MapboxImages.d.ts} +1 -1
- package/{MapboxImages.js → dist/MapboxImages.js} +1 -1
- package/dist/MapboxImages.js.map +1 -0
- package/{MapboxLayer.d.ts → dist/MapboxLayer.d.ts} +1 -1
- package/{MapboxLayer.js → dist/MapboxLayer.js} +1 -1
- package/dist/MapboxLayer.js.map +1 -0
- package/{MapboxMap.d.ts → dist/MapboxMap.d.ts} +3 -2
- package/{MapboxMap.js → dist/MapboxMap.js} +2 -2
- package/dist/MapboxMap.js.map +1 -0
- package/{MapboxMarker.d.ts → dist/MapboxMarker.d.ts} +1 -1
- package/{MapboxMarker.js → dist/MapboxMarker.js} +1 -1
- package/dist/MapboxMarker.js.map +1 -0
- package/{MapboxNavigationControl.d.ts → dist/MapboxNavigationControl.d.ts} +1 -1
- package/{MapboxNavigationControl.js → dist/MapboxNavigationControl.js} +2 -2
- package/dist/MapboxNavigationControl.js.map +1 -0
- package/{MapboxPopup.d.ts → dist/MapboxPopup.d.ts} +1 -1
- package/{MapboxPopup.js → dist/MapboxPopup.js} +1 -1
- package/dist/MapboxPopup.js.map +1 -0
- package/{MapboxSource.d.ts → dist/MapboxSource.d.ts} +1 -1
- package/{MapboxSource.js → dist/MapboxSource.js} +1 -1
- package/dist/MapboxSource.js.map +1 -0
- package/{StoreLocator.d.ts → dist/StoreLocator.d.ts} +3 -2
- package/{StoreLocator.js → dist/StoreLocator.js} +3 -3
- package/dist/StoreLocator.js.map +1 -0
- package/dist/autoload.js +7 -0
- package/dist/autoload.js.map +1 -0
- package/{catalog.d.ts → dist/catalog.d.ts} +1 -1
- package/dist/catalog.js.map +1 -0
- package/{dependencies.d.ts → dist/dependencies.d.ts} +1 -1
- package/{dependencies.js → dist/dependencies.js} +1 -1
- package/dist/dependencies.js.map +1 -0
- package/{manifest.d.ts → dist/manifest.d.ts} +1 -1
- package/{manifest.js → dist/manifest.js} +1 -1
- package/dist/manifest.js.map +1 -0
- package/{scripts → dist/scripts}/manifest-types.d.ts +1 -1
- package/{utils.d.ts → dist/utils.d.ts} +1 -1
- package/{utils.js → dist/utils.js} +1 -1
- package/dist/utils.js.map +1 -0
- package/package.json +109 -20
- package/AbstractMapboxControl.js.map +0 -1
- package/AbstractMapboxMapChild.js.map +0 -1
- package/MapboxCluster.js.map +0 -1
- package/MapboxClusterItem.js.map +0 -1
- package/MapboxFullscreenControl.js.map +0 -1
- package/MapboxGeocoder.js.map +0 -1
- package/MapboxGeolocateControl.js.map +0 -1
- package/MapboxImage.js.map +0 -1
- package/MapboxImages.js.map +0 -1
- package/MapboxLayer.js.map +0 -1
- package/MapboxMap.js.map +0 -1
- package/MapboxMarker.js.map +0 -1
- package/MapboxNavigationControl.js.map +0 -1
- package/MapboxPopup.js.map +0 -1
- package/MapboxSource.js.map +0 -1
- package/StoreLocator.js.map +0 -1
- package/autoload.js +0 -7
- package/autoload.js.map +0 -1
- package/catalog.js.map +0 -1
- package/dependencies.js.map +0 -1
- package/manifest.js.map +0 -1
- package/utils.js.map +0 -1
- /package/{autoload.d.ts → dist/autoload.d.ts} +0 -0
- /package/{catalog.js → dist/catalog.js} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{index.js.map → dist/index.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxGeolocateControl.js","names":[],"sources":["../MapboxGeolocateControl.ts"],"sourcesContent":["import { withExtraConfig } from '@studiometa/js-toolkit';\nimport type { GeolocateControlOptions } from 'mapbox-gl';\nimport {\n AbstractMapboxControl,\n type AbstractMapboxControlProps,\n} from './AbstractMapboxControl.js';\nimport { getMapboxGl } from './dependencies.js';\n\nexport interface MapboxGeolocateControlProps extends AbstractMapboxControlProps {\n $options: AbstractMapboxControlProps['$options'] & Omit<GeolocateControlOptions, 'geolocation'>;\n}\n\n/**\n * Add a geolocate control to the map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxGeolocateControl extends withExtraConfig(AbstractMapboxControl, {\n name: 'MapboxGeolocateControl',\n options: {\n positionOptions: Object,\n fitBoundsOptions: Object,\n trackUserLocation: Boolean,\n showAccuracyCircle: Boolean,\n showUserLocation: Boolean,\n showUserHeading: Boolean,\n },\n}) {\n /**\n * Create the mapbox GeolocateControl instance.\n * @protected\n */\n createControl(options: GeolocateControlOptions) {\n return new (getMapboxGl().GeolocateControl)(options);\n }\n}\n\nexport default MapboxGeolocateControl;\n"],"mappings":";;;;;;;;AAgBA,IAAa,yBAAb,cAA4C,gBAAgB,uBAAuB;CACjF,MAAM;CACN,SAAS;EACP,iBAAiB;EACjB,kBAAkB;EAClB,mBAAmB;EACnB,oBAAoB;EACpB,kBAAkB;EAClB,iBAAiB;EAClB;CACF,CAAC,CAAC;;;;;CAKD,cAAc,SAAkC;AAC9C,SAAO,KAAK,aAAa,EAAC,iBAAkB,QAAQ"}
|
package/MapboxImage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxImage.js","names":[],"sources":["../MapboxImage.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport {\n addMapboxImage,\n claimMapboxOwnership,\n getMapboxOwner,\n releaseMapboxOwnership,\n type MapboxImageOptions,\n} from './utils.js';\n\nexport interface MapboxImageProps extends AbstractMapboxMapChildProps {\n $options: {\n name: string;\n url: string;\n /**\n * The image options forwarded to `map.addImage`.\n * @see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addimage\n */\n options: MapboxImageOptions;\n };\n}\n\n/**\n * Load and register a single image against the map sprite.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxImage<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxImageProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxImage',\n emits: ['map-ready'],\n options: {\n name: String,\n url: String,\n options: {\n type: Object,\n default: () => ({ pixelRatio: 1, sdf: false }),\n },\n },\n };\n\n /**\n * Whether this instance owns the sprite under its name. Only a sprite this\n * instance owns may be removed on teardown; a pre-existing sprite declared\n * outside the family is left untouched, and a sprite a newer sibling has since\n * adopted (a same-name `Fetch` swap) is left to that sibling.\n * @private\n */\n __owned = false;\n\n /**\n * The `kind:name` ownership key for this sprite.\n * @private\n */\n get __ownershipKey(): string {\n return `image:${this.$options.name}`;\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.whenMapReady(async (map) => {\n const { name, url, options } = this.$options;\n const { image, added } = await addMapboxImage(map, { name, url, options });\n\n // The component may have been destroyed — or the map removed/replaced —\n // while the image was loading. Undo the add (only when THIS call added it,\n // and only while the map is still current & alive; a removed map took its\n // sprites with it) and bail before emitting so no orphan sprite survives.\n if (!this.$isMounted || this.__readyMap !== map) {\n if (added && this.__readyMap === map && map.hasImage(name)) {\n map.removeImage(name);\n }\n return;\n }\n\n // Own the sprite when we added it, or adopt it from a family sibling — a\n // same-name `Fetch` swap that added the sprite before this instance\n // mounted — so the outgoing instance's teardown does not remove the sprite\n // this mounted replacement now depends on. An unowned external sprite is\n // left untouched (and unclaimed).\n if (added || getMapboxOwner(map, this.__ownershipKey)) {\n // Sprites expose no object identity, so liveness can only probe\n // `hasImage`: enough to drop the entry after a `setStyle` wipe or an\n // external `removeImage`, and to re-own on a `style.load` re-injection.\n claimMapboxOwnership(map, this.__ownershipKey, this, () => map.hasImage(name));\n this.__owned = true;\n }\n\n this.$emit('map-ready', { name, image, options });\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n const { name } = this.$options;\n const map = this.__readyMap;\n\n // Only remove a sprite this instance still owns: a newer sibling may have\n // adopted the name, and a removed map is already gone (`__readyMap` is unset).\n if (\n this.__owned &&\n getMapboxOwner(map as object, this.__ownershipKey) === this &&\n map?.hasImage(name)\n ) {\n map.removeImage(name);\n releaseMapboxOwnership(map, this.__ownershipKey, this);\n }\n }\n}\n\nexport default MapboxImage;\n"],"mappings":";;;;;;;AA6BA,IAAa,cAAb,cAAkE,uBAEhE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,YAAY;EACpB,SAAS;GACP,MAAM;GACN,KAAK;GACL,SAAS;IACP,MAAM;IACN,gBAAgB;KAAE,YAAY;KAAG,KAAK;KAAO;IAC9C;GACF;EACF;;;;;;;;CASD,UAAU;;;;;CAMV,IAAI,iBAAyB;AAC3B,SAAO,SAAS,KAAK,SAAS;;;;;CAMhC,UAAU;AACR,OAAK,aAAa,OAAO,QAAQ;GAC/B,MAAM,EAAE,MAAM,KAAK,YAAY,KAAK;GACpC,MAAM,EAAE,OAAO,UAAU,MAAM,eAAe,KAAK;IAAE;IAAM;IAAK;IAAS,CAAC;AAM1E,OAAI,CAAC,KAAK,cAAc,KAAK,eAAe,KAAK;AAC/C,QAAI,SAAS,KAAK,eAAe,OAAO,IAAI,SAAS,KAAK,CACxD,KAAI,YAAY,KAAK;AAEvB;;AAQF,OAAI,SAAS,eAAe,KAAK,KAAK,eAAe,EAAE;AAIrD,yBAAqB,KAAK,KAAK,gBAAgB,YAAY,IAAI,SAAS,KAAK,CAAC;AAC9E,SAAK,UAAU;;AAGjB,QAAK,MAAM,aAAa;IAAE;IAAM;IAAO;IAAS,CAAC;IACjD;;;;;CAMJ,gBAAgB;EACd,MAAM,EAAE,SAAS,KAAK;EACtB,MAAM,MAAM,KAAK;AAIjB,MACE,KAAK,WACL,eAAe,KAAe,KAAK,eAAe,KAAK,QACvD,KAAK,SAAS,KAAK,EACnB;AACA,OAAI,YAAY,KAAK;AACrB,0BAAuB,KAAK,KAAK,gBAAgB,KAAK"}
|
package/MapboxImages.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxImages.js","names":[],"sources":["../MapboxImages.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport type { Map } from 'mapbox-gl';\nimport {\n addMapboxImage,\n claimMapboxOwnership,\n getMapboxOwner,\n releaseMapboxOwnership,\n type MapboxImageDefinition,\n} from './utils.js';\n\nexport interface MapboxImagesProps extends AbstractMapboxMapChildProps {\n $options: {\n /**\n * A list of images to register against the map sprite.\n * @see ./MapboxImage.ts\n */\n sources: MapboxImageDefinition[];\n };\n}\n\n/**\n * Load and register a list of images against the map sprite.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxImages<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxImagesProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxImages',\n emits: ['map-ready'],\n options: {\n sources: {\n type: Array,\n default: () => [],\n },\n },\n };\n\n /**\n * The names of the sprites this instance owns. Only these may be removed on\n * teardown; pre-existing sprites (registered by someone else) are left\n * untouched, and a sprite a newer sibling has since adopted is left to it.\n * @private\n */\n __ownedNames: string[] = [];\n\n /**\n * The `kind:name` ownership key for the given sprite.\n * @private\n * @param {string} name\n * @returns {string}\n */\n __ownershipKey(name: string): string {\n return `image:${name}`;\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.whenMapReady(async (map) => {\n const { sources } = this.$options;\n const images = await Promise.all(\n sources.map(async (source) => {\n const { image, added } = await addMapboxImage(map, source);\n // Take ownership incrementally, as each image settles, rather than\n // after the whole batch: if a later entry rejects, `Promise.all`\n // rejects, but the sprites already added stay owned and removable on\n // teardown instead of orphaned.\n this.__adopt(map, source.name, added);\n return image;\n }),\n );\n\n // The component may have been destroyed — or the map removed/replaced —\n // while the images were loading. Remove the ones we own (only while the\n // map is still current & alive) and bail before emitting to avoid orphans.\n if (!this.$isMounted || this.__readyMap !== map) {\n if (this.__readyMap === map) {\n this.__removeOwned(map);\n }\n return;\n }\n\n this.$emit('map-ready', images);\n });\n }\n\n /**\n * Own a sprite this instance added, or adopt one from a family sibling (a\n * same-name `Fetch` swap), so the outgoing instance's teardown does not remove\n * a sprite this replacement now depends on.\n * @private\n * @param {Map} map\n * @param {string} name\n * @param {boolean} added\n */\n __adopt(map: Map, name: string, added: boolean) {\n if (added || getMapboxOwner(map, this.__ownershipKey(name))) {\n // Sprites expose no object identity, so liveness can only probe\n // `hasImage`: enough to drop the entry after a `setStyle` wipe or an\n // external `removeImage`, and to re-own on a `style.load` re-injection.\n claimMapboxOwnership(map, this.__ownershipKey(name), this, () => map.hasImage(name));\n if (!this.__ownedNames.includes(name)) {\n this.__ownedNames.push(name);\n }\n }\n }\n\n /**\n * Remove every sprite this instance still owns from the given map, releasing\n * ownership as it goes.\n * @private\n * @param {Map | undefined} map\n */\n __removeOwned(map?: Map) {\n for (const name of this.__ownedNames) {\n const key = this.__ownershipKey(name);\n if (getMapboxOwner(map as object, key) === this && map?.hasImage(name)) {\n map.removeImage(name);\n releaseMapboxOwnership(map, key, this);\n }\n }\n this.__ownedNames = [];\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n this.__removeOwned(this.__readyMap);\n }\n}\n\nexport default MapboxImages;\n"],"mappings":";;;;;;;AA4BA,IAAa,eAAb,cAAmE,uBAEjE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,YAAY;EACpB,SAAS,EACP,SAAS;GACP,MAAM;GACN,eAAe,EAAE;GAClB,EACF;EACF;;;;;;;CAQD,eAAyB,EAAE;;;;;;;CAQ3B,eAAe,MAAsB;AACnC,SAAO,SAAS;;;;;CAMlB,UAAU;AACR,OAAK,aAAa,OAAO,QAAQ;GAC/B,MAAM,EAAE,YAAY,KAAK;GACzB,MAAM,SAAS,MAAM,QAAQ,IAC3B,QAAQ,IAAI,OAAO,WAAW;IAC5B,MAAM,EAAE,OAAO,UAAU,MAAM,eAAe,KAAK,OAAO;AAK1D,SAAK,QAAQ,KAAK,OAAO,MAAM,MAAM;AACrC,WAAO;KACP,CACH;AAKD,OAAI,CAAC,KAAK,cAAc,KAAK,eAAe,KAAK;AAC/C,QAAI,KAAK,eAAe,IACtB,MAAK,cAAc,IAAI;AAEzB;;AAGF,QAAK,MAAM,aAAa,OAAO;IAC/B;;;;;;;;;;;CAYJ,QAAQ,KAAU,MAAc,OAAgB;AAC9C,MAAI,SAAS,eAAe,KAAK,KAAK,eAAe,KAAK,CAAC,EAAE;AAI3D,wBAAqB,KAAK,KAAK,eAAe,KAAK,EAAE,YAAY,IAAI,SAAS,KAAK,CAAC;AACpF,OAAI,CAAC,KAAK,aAAa,SAAS,KAAK,CACnC,MAAK,aAAa,KAAK,KAAK;;;;;;;;;CAWlC,cAAc,KAAW;AACvB,OAAK,MAAM,QAAQ,KAAK,cAAc;GACpC,MAAM,MAAM,KAAK,eAAe,KAAK;AACrC,OAAI,eAAe,KAAe,IAAI,KAAK,QAAQ,KAAK,SAAS,KAAK,EAAE;AACtE,QAAI,YAAY,KAAK;AACrB,2BAAuB,KAAK,KAAK,KAAK;;;AAG1C,OAAK,eAAe,EAAE;;;;;CAMxB,gBAAgB;AACd,OAAK,cAAc,KAAK,WAAW"}
|
package/MapboxLayer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxLayer.js","names":[],"sources":["../MapboxLayer.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport type { LayerSpecification, Map, MapSourceDataEvent } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport { claimMapboxOwnership, getMapboxOwner, releaseMapboxOwnership } from './utils.js';\n\nexport interface MapboxLayerProps extends AbstractMapboxMapChildProps {\n $options: {\n id: string;\n layer: LayerSpecification;\n beforeId: string;\n };\n}\n\n/**\n * Add a layer to the map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxLayer<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxLayerProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxLayer',\n options: {\n id: String,\n layer: Object,\n beforeId: String,\n },\n };\n\n /**\n * Whether this instance owns the layer under its id. Only a layer this\n * instance owns may be removed on teardown; a layer declared outside the\n * family, or one a newer sibling has since adopted, is left untouched.\n * @private\n */\n __added = false;\n\n /**\n * The `kind:id` ownership key for this layer.\n * @private\n */\n get __ownershipKey(): string {\n return `layer:${this.$options.id}`;\n }\n\n /**\n * The source id this layer references, when it references one by string.\n * @private\n */\n get __sourceId(): string | undefined {\n const { source } = this.$options.layer as { source?: unknown };\n return typeof source === 'string' ? source : undefined;\n }\n\n /**\n * Add (or re-add) the layer whenever its referenced source becomes available\n * and the layer is not currently on the map.\n *\n * This is a *standing* recovery watch, not a one-shot: it stays subscribed for\n * the layer's whole life so the layer re-commits itself if its source\n * disappears and comes back — e.g. a sibling `MapboxSource` teardown removes\n * this still-mounted layer to drop its source, then the source is re-added\n * later (H7, PR #567 review). Committing once and unsubscribing (the previous\n * behaviour) left such a layer gone for good.\n *\n * It is kept cheap: `sourcedata` fires often, so the handler early-returns\n * unless this layer is actually missing, and — when the event identifies a\n * source — ignores events for any source other than this layer's. The commit\n * itself is deferred to a microtask because mutating the style from within\n * mapbox-gl's render loop can leave a layer half-initialized and crash the\n * symbol placement pass.\n * @private\n * @param {MapSourceDataEvent} [event]\n */\n __handleSourceData = (event?: MapSourceDataEvent) => {\n const map = this.__readyMap;\n const { id } = this.$options;\n\n // Ignore events for an unrelated source when the event tells us which one it\n // is: this gates the standing watch to this layer's source id.\n if (event?.sourceId && this.__sourceId && event.sourceId !== this.__sourceId) {\n return;\n }\n\n if (!map || map.getLayer(id) || !this.__sourceIsAvailable(map)) {\n return;\n }\n\n queueMicrotask(() => {\n // Re-check under the microtask: the map may have been removed/replaced, the\n // component destroyed, or the layer committed by another path in between.\n if (this.$isMounted && this.__readyMap === map && !map.getLayer(id)) {\n this.__commitLayer(map);\n }\n });\n };\n\n /**\n * Add the layer to the map, or adopt an existing one.\n *\n * When the id is free the layer is added and ownership claimed. When a layer\n * with this id already exists, re-adding it would throw a duplicate-id error,\n * so it is left in place; ownership is only taken over from a sibling\n * `MapboxLayer` (e.g. a `Fetch` swap), never from an externally declared layer.\n * @private\n * @param {Map} map\n */\n __commitLayer(map: Map): void {\n const { beforeId, id, layer } = this.$options;\n // `$options.layer` returns a freshly parsed object, so re-apply the id.\n layer.id = id;\n\n if (map.getLayer(id)) {\n // The id is taken. Only adopt it from another family instance (e.g. a\n // `Fetch` swap that mounted the replacement before the original tore\n // down); an externally declared layer stays untouched. Adopt AND refresh:\n // the incoming definition may differ in source/type/paint/layout/filter/\n // zoom range/beforeId, so re-add it (we own it) rather than leaving Mapbox\n // rendering the outgoing definition — matching how `MapboxSource` refreshes\n // its data on adopt.\n if (getMapboxOwner(map, this.__ownershipKey)) {\n map.removeLayer(id);\n map.addLayer(layer, beforeId);\n const added = map.getLayer(id);\n claimMapboxOwnership(map, this.__ownershipKey, this, () => map.getLayer(id) === added);\n this.__added = true;\n }\n return;\n }\n\n map.addLayer(layer, beforeId);\n // Own the id, keyed to the very layer object just added: the liveness probe\n // reports the entry stale the moment this layer is removed (a `setStyle`\n // wipe, a sibling source teardown, an external `removeLayer`) or replaced\n // under the same id, so it can never misclassify a stranger's later layer.\n const added = map.getLayer(id);\n claimMapboxOwnership(map, this.__ownershipKey, this, () => map.getLayer(id) === added);\n this.__added = true;\n }\n\n /**\n * Whether the source referenced by the layer is available on the map.\n *\n * Layers referencing an inline source object — or no source at all, like a\n * `background` layer — are always considered available.\n * @private\n * @param {Map} map\n * @returns {boolean}\n */\n __sourceIsAvailable(map: Map): boolean {\n const { source } = this.$options.layer as { source?: unknown };\n return typeof source !== 'string' || Boolean(map.getSource(source));\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.whenMapReady((map) => {\n // Install (or re-install, on a `style.load` re-injection) the standing\n // recovery watch exactly once. `off` before `on` keeps a single\n // subscription when `whenMapReady`'s callback re-runs after a `setStyle`.\n map.off('sourcedata', this.__handleSourceData);\n map.on('sourcedata', this.__handleSourceData);\n\n // The referenced source may be declared by a sibling `MapboxSource` that\n // has not mounted yet — sibling mount order is not guaranteed. Adding a\n // layer before its source silently fails, so commit now when the source is\n // available and otherwise let the standing watch commit once it arrives.\n if (this.__sourceIsAvailable(map)) {\n this.__commitLayer(map);\n }\n });\n }\n\n /**\n * Flush the standing `sourcedata` recovery watch against the map being\n * removed, while it is still referenceable — `__onDestroyed` runs later with\n * `__readyMap` already cleared and could not reach the map to unsubscribe.\n * @protected\n * @param {Map} map\n */\n __onMapRemove(map: Map) {\n map.off('sourcedata', this.__handleSourceData);\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n const map = this.__readyMap;\n const { id } = this.$options;\n\n map?.off('sourcedata', this.__handleSourceData);\n\n // Only remove a layer 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?.getLayer(id)\n ) {\n map.removeLayer(id);\n releaseMapboxOwnership(map, this.__ownershipKey, this);\n }\n }\n}\n\nexport default MapboxLayer;\n"],"mappings":";;;;;;;AAoBA,IAAa,cAAb,cAAkE,uBAEhE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,SAAS;GACP,IAAI;GACJ,OAAO;GACP,UAAU;GACX;EACF;;;;;;;CAQD,UAAU;;;;;CAMV,IAAI,iBAAyB;AAC3B,SAAO,SAAS,KAAK,SAAS;;;;;;CAOhC,IAAI,aAAiC;EACnC,MAAM,EAAE,WAAW,KAAK,SAAS;AACjC,SAAO,OAAO,WAAW,WAAW,SAAS,KAAA;;;;;;;;;;;;;;;;;;;;;;CAuB/C,sBAAsB,UAA+B;EACnD,MAAM,MAAM,KAAK;EACjB,MAAM,EAAE,OAAO,KAAK;AAIpB,MAAI,OAAO,YAAY,KAAK,cAAc,MAAM,aAAa,KAAK,WAChE;AAGF,MAAI,CAAC,OAAO,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK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S,GAAG,EACjB;AACA,OAAI,YAAY,GAAG;AACnB,0BAAuB,KAAK,KAAK,gBAAgB,KAAK"}
|
package/MapboxMap.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxMap.js","names":[],"sources":["../MapboxMap.ts"],"sourcesContent":["import { Base, type BaseConfig, type BaseProps } from '@studiometa/js-toolkit';\nimport type { Map, MapOptions } from 'mapbox-gl';\nimport { resolveMapboxGl } from './dependencies.js';\nimport { MAPBOX_MAP_CONNECTED } from './AbstractMapboxMapChild.js';\n\nconst FORWARDED_MAP_EVENTS = [\n 'click',\n 'dblclick',\n 'mouseenter',\n 'mouseleave',\n 'mousemove',\n 'movestart',\n 'move',\n 'moveend',\n 'zoomstart',\n 'zoom',\n 'zoomend',\n 'rotatestart',\n 'rotate',\n 'rotateend',\n 'pitchstart',\n 'pitch',\n 'pitchend',\n 'dragstart',\n 'drag',\n 'dragend',\n 'idle',\n 'render',\n 'resize',\n 'remove',\n 'error',\n] as const;\n\nexport interface MapboxMapProps extends BaseProps {\n $refs: {\n container: HTMLElement;\n };\n $options: {\n accessToken: string;\n zoom: number;\n center: [number, number];\n mapOptions: Partial<Omit<MapOptions, 'container'>>;\n };\n}\n\n/**\n * Display a Mapbox GL map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxMap<T extends BaseProps = BaseProps> extends Base<T & MapboxMapProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxMap',\n emits: ['map-load', ...FORWARDED_MAP_EVENTS.map((event) => `map-${event}`)],\n refs: ['container'],\n options: {\n accessToken: String,\n zoom: Number,\n center: {\n type: Array,\n default: () => [0, 0],\n },\n // Any other `mapbox-gl` `Map` option — including `style`, `pitch`,\n // `bearing`, `bounds`, ... — spread as-is into the `Map` constructor. The\n // convenience options above act as overridable defaults, while `container`\n // is always resolved from the component and can not be overridden.\n mapOptions: {\n type: Object,\n default: () => ({}),\n },\n },\n // `MapboxMap` no longer declares its children. Each child component\n // (markers, popups, controls, sources, layers, clusters, ...) is registered\n // globally and resolves this map on its own via `$closest('MapboxMap')`,\n // then waits for readiness through `AbstractMapboxMapChild.whenMapReady`.\n // This makes the whole family dynamic-DOM-native: a child appended under a\n // map at any time mounts and injects itself, and cleans up when removed.\n };\n\n /**\n * Is the map loaded?\n */\n isLoaded = false;\n\n /**\n * Map instance, or `undefined` until it is built in `mounted()` and once it is\n * cleared on teardown.\n * @private\n */\n __map: Map | undefined;\n\n /**\n * Off handles for every forwarding listener attached to the map, flushed on\n * teardown so a retained reference to a removed `Map` does not keep this\n * component (and its `$emit` closures) alive.\n * @private\n */\n __offMapListeners: Array<() => void> = [];\n\n /**\n * The mapbox Map instance, or `undefined` until it has been built.\n *\n * The map is built in `mounted()` after `mapbox-gl` resolves (it may be\n * injected or lazily imported), so this getter returns `undefined` while that\n * resolution is still pending. Children read it after the map announces itself\n * through `MAPBOX_MAP_CONNECTED`, which only fires once the instance exists.\n */\n get map(): Map | undefined {\n return this.__map;\n }\n\n /**\n * Mounted hook.\n *\n * Resolves `mapbox-gl` (injected or lazily imported), builds the map, then\n * announces it so children can inject themselves.\n */\n async mounted() {\n const mapboxgl = await resolveMapboxGl();\n\n // The component may have been destroyed while `mapbox-gl` was resolving: bail\n // out before building a map that nothing would ever tear down.\n if (!this.$isMounted) {\n return;\n }\n\n const map = new mapboxgl.Map({\n accessToken: this.$options.accessToken,\n zoom: this.$options.zoom,\n center: this.$options.center,\n ...this.$options.mapOptions,\n container: this.$refs.container ?? this.$el,\n });\n this.__map = map;\n\n const onLoad = () => {\n this.isLoaded = true;\n this.$emit('map-load', map);\n };\n map.on('load', onLoad);\n this.__offMapListeners.push(() => this.__map?.off('load', onLoad));\n\n for (const event of FORWARDED_MAP_EVENTS) {\n const handler = (e: unknown) => {\n this.$emit(`map-${event}`, e);\n };\n map.on(event, handler);\n this.__offMapListeners.push(() => this.__map?.off(event, handler));\n }\n\n // Announce this map so any child that mounted before it — and is waiting on\n // `MAPBOX_MAP_CONNECTED` — can resolve and inject itself now. This also fires\n // on a remount, letting still-mounted children re-inject on the new map.\n document.dispatchEvent(new CustomEvent(MAPBOX_MAP_CONNECTED, { detail: this }));\n }\n\n /**\n * Destroyed hook.\n */\n destroyed() {\n // Flush the forwarding listeners before removing the map so neither the map\n // nor this component leaks through a retained `Map` reference.\n for (const off of this.__offMapListeners) {\n off();\n }\n this.__offMapListeners = [];\n\n this.__map?.remove();\n this.__map = undefined;\n this.isLoaded = false;\n }\n}\n\nexport default MapboxMap;\n"],"mappings":";;;;AAKA,MAAM,uBAAuB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;AAkBD,IAAa,YAAb,cAAgE,KAAyB;;;;CAIvF,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,YAAY,GAAG,qBAAqB,KAAK,UAAU,OAAO,QAAQ,CAAC;EAC3E,MAAM,CAAC,YAAY;EACnB,SAAS;GACP,aAAa;GACb,MAAM;GACN,QAAQ;IACN,MAAM;IACN,eAAe,CAAC,GAAG,EAAE;IACtB;GAKD,YAAY;IACV,MAAM;IACN,gBAAgB,EAAE;IACnB;GACF;EAOF;;;;CAKD,WAAW;;;;;;CAOX;;;;;;;CAQA,oBAAuC,EAAE;;;;;;;;;CAUzC,IAAI,MAAuB;AACzB,SAAO,KAAK;;;;;;;;CASd,MAAM,UAAU;EACd,MAAM,WAAW,MAAM,iBAAiB;AAIxC,MAAI,CAAC,KAAK,WACR;EAGF,MAAM,MAAM,IAAI,SAAS,IAAI;GAC3B,aAAa,KAAK,SAAS;GAC3B,MAAM,KAAK,SAAS;GACpB,QAAQ,KAAK,SAAS;GACtB,GAAG,KAAK,SAAS;GACjB,WAAW,KAAK,MAAM,aAAa,KAAK;GACzC,CAAC;AACF,OAAK,QAAQ;EAEb,MAAM,eAAe;AACnB,QAAK,WAAW;AAChB,QAAK,MAAM,YAAY,IAAI;;AAE7B,MAAI,GAAG,QAAQ,OAAO;AACtB,OAAK,kBAAkB,WAAW,KAAK,OAAO,IAAI,QAAQ,OAAO,CAAC;AAElE,OAAK,MAAM,SAAS,sBAAsB;GACxC,MAAM,WAAW,MAAe;AAC9B,SAAK,MAAM,OAAO,SAAS,EAAE;;AAE/B,OAAI,GAAG,OAAO,QAAQ;AACtB,QAAK,kBAAkB,WAAW,KAAK,OAAO,IAAI,OAAO,QAAQ,CAAC;;AAMpE,WAAS,cAAc,IAAI,YAAY,sBAAsB,EAAE,QAAQ,MAAM,CAAC,CAAC;;;;;CAMjF,YAAY;AAGV,OAAK,MAAM,OAAO,KAAK,kBACrB,MAAK;AAEP,OAAK,oBAAoB,EAAE;AAE3B,OAAK,OAAO,QAAQ;AACpB,OAAK,QAAQ,KAAA;AACb,OAAK,WAAW"}
|
package/MapboxMarker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxMarker.js","names":[],"sources":["../MapboxMarker.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport type { Marker, MarkerOptions } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport { getMapboxGl } from './dependencies.js';\nimport { MapboxPopup } from './MapboxPopup.js';\n\nexport interface MapboxMarkerProps extends AbstractMapboxMapChildProps {\n $options: {\n lngLat: [number, number];\n markerOptions: MarkerOptions;\n };\n}\n\n/**\n * Add a marker to Mapbox map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxMarker<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxMarkerProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxMarker',\n options: {\n lngLat: {\n type: Array,\n default: () => [0, 0],\n },\n // Marker options. (https://docs.mapbox.com/mapbox-gl-js/api/markers#marker)\n markerOptions: Object,\n },\n };\n\n /**\n * Marker instance.\n * @private\n */\n __marker: Marker;\n\n /**\n * The mapbox Marker instance.\n */\n get marker() {\n if (!this.__marker) {\n this.__marker = new (getMapboxGl().Marker)(this.$options.markerOptions);\n }\n\n return this.__marker;\n }\n\n /**\n * The optional child popup component instance.\n */\n get popup() {\n return this.$query<MapboxPopup>('MapboxPopup')[0];\n }\n\n /**\n * Attach a child `MapboxPopup`'s popup to this marker.\n *\n * Called from either side of the wiring, whichever mounts last: the marker\n * pulls its child popup on ready, and the popup pushes itself here when it\n * mounts after the marker (a dynamic append to an already-loaded map, where\n * the marker mounted first and found no popup to query yet). Setting the same\n * popup twice is idempotent.\n * @param {MapboxPopup} popupComponent\n */\n setChildPopup(popupComponent: MapboxPopup) {\n this.marker.setPopup(popupComponent.popup);\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.whenMapReady((map) => {\n this.marker.setLngLat(this.$options.lngLat).addTo(map);\n\n // Pull the optional child popup if it has already mounted. When it mounts\n // *after* the marker instead (dynamic append), the popup pushes itself via\n // `setChildPopup`, so either mount order wires the pair.\n if (this.popup) {\n this.setChildPopup(this.popup);\n }\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n this.__marker?.remove();\n this.__marker = undefined;\n }\n}\n\nexport default MapboxMarker;\n"],"mappings":";;;;;;;AAoBA,IAAa,eAAb,cAAmE,uBAEjE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,SAAS;GACP,QAAQ;IACN,MAAM;IACN,eAAe,CAAC,GAAG,EAAE;IACtB;GAED,eAAe;GAChB;EACF;;;;;CAMD;;;;CAKA,IAAI,SAAS;AACX,MAAI,CAAC,KAAK,SACR,MAAK,WAAW,KAAK,aAAa,EAAC,OAAQ,KAAK,SAAS,cAAc;AAGzE,SAAO,KAAK;;;;;CAMd,IAAI,QAAQ;AACV,SAAO,KAAK,OAAoB,cAAc,CAAC;;;;;;;;;;;;CAajD,cAAc,gBAA6B;AACzC,OAAK,OAAO,SAAS,eAAe,MAAM;;;;;CAM5C,UAAU;AACR,OAAK,cAAc,QAAQ;AACzB,QAAK,OAAO,UAAU,KAAK,SAAS,OAAO,CAAC,MAAM,IAAI;AAKtD,OAAI,KAAK,MACP,MAAK,cAAc,KAAK,MAAM;IAEhC;;;;;CAMJ,gBAAgB;AACd,OAAK,UAAU,QAAQ;AACvB,OAAK,WAAW,KAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxNavigationControl.js","names":[],"sources":["../MapboxNavigationControl.ts"],"sourcesContent":["import { withExtraConfig } from '@studiometa/js-toolkit';\nimport type { NavigationControlOptions } from 'mapbox-gl';\nimport {\n AbstractMapboxControl,\n type AbstractMapboxControlProps,\n} from './AbstractMapboxControl.js';\nimport { getMapboxGl } from './dependencies.js';\n\nexport interface MapboxNavigationControlProps extends AbstractMapboxControlProps {\n $options: AbstractMapboxControlProps['$options'] & {\n showCompass: boolean;\n showZoom: boolean;\n visualizePitch: boolean;\n };\n}\n\n/**\n * Add a navigation control to the map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxNavigationControl extends withExtraConfig(AbstractMapboxControl, {\n name: 'MapboxNavigationControl',\n options: {\n showCompass: Boolean,\n showZoom: Boolean,\n visualizePitch: Boolean,\n },\n}) {\n /**\n * Create the mapbox NavigationControl instance.\n * @protected\n */\n createControl(options: NavigationControlOptions) {\n return new (getMapboxGl().NavigationControl)(options);\n }\n}\n\nexport default MapboxNavigationControl;\n"],"mappings":";;;;;;;;AAoBA,IAAa,0BAAb,cAA6C,gBAAgB,uBAAuB;CAClF,MAAM;CACN,SAAS;EACP,aAAa;EACb,UAAU;EACV,gBAAgB;EACjB;CACF,CAAC,CAAC;;;;;CAKD,cAAc,SAAmC;AAC/C,SAAO,KAAK,aAAa,EAAC,kBAAmB,QAAQ"}
|
package/MapboxPopup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxPopup.js","names":[],"sources":["../MapboxPopup.ts"],"sourcesContent":["import { type BaseConfig, type BaseProps } from '@studiometa/js-toolkit';\nimport type { Popup, PopupOptions } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport { getMapboxGl } from './dependencies.js';\nimport type { MapboxMarker } from './MapboxMarker.js';\n\nexport interface MapboxPopupProps extends AbstractMapboxMapChildProps {\n $options: {\n lngLat: [number, number];\n /**\n * Popup options.\n * @see https://docs.mapbox.com/mapbox-gl-js/api/markers#popup\n */\n popupOptions: PopupOptions;\n };\n}\n\n/**\n * Display a popup on a MapboxMap map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap\n */\nexport class MapboxPopup<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxPopupProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxPopup',\n options: {\n lngLat: {\n type: Array,\n default: () => [0, 0],\n },\n popupOptions: Object,\n },\n };\n\n /**\n * Popup instance.\n * @private\n */\n __popup: Popup;\n\n /**\n * Whether this component hid its own source element (to avoid rendering the\n * content twice). Tracked so teardown restores the original visibility only\n * when it was the one to change it.\n * @private\n */\n __didHide = false;\n\n /**\n * The mapbox Popup instance.\n */\n get popup() {\n if (!this.__popup) {\n this.__popup = new (getMapboxGl().Popup)(this.$options.popupOptions);\n }\n\n return this.__popup;\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.whenMapReady((map) => {\n const { popup, $el, $options } = this;\n\n popup.setLngLat($options.lngLat);\n\n const content = $el.innerHTML.trim();\n if (content) {\n popup.setHTML(content);\n // Hide the source markup so the content is not rendered twice: once in\n // the popup and once in the document. Remember we did so — only when it\n // was visible — to restore it on teardown.\n if (!$el.hidden) {\n $el.hidden = true;\n this.__didHide = true;\n }\n }\n\n // When inside a marker, hand the popup to it rather than adding it to the\n // map directly (the marker owns its popup via `setPopup`). Pushing to the\n // marker — instead of letting the marker pull us — also covers the dynamic\n // append case where the marker mounted first and found no popup to query.\n const marker = this.$closest<MapboxMarker>('MapboxMarker');\n if (marker) {\n marker.setChildPopup(this);\n } else {\n popup.addTo(map);\n }\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n this.__popup?.remove();\n this.__popup = undefined;\n\n // Restore the source element's visibility only if this component hid it, so\n // a reused or remounted element keeps its original state.\n if (this.__didHide) {\n this.$el.hidden = false;\n this.__didHide = false;\n }\n }\n}\n\nexport default MapboxPopup;\n"],"mappings":";;;;;;;AAwBA,IAAa,cAAb,cAAkE,uBAEhE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,SAAS;GACP,QAAQ;IACN,MAAM;IACN,eAAe,CAAC,GAAG,EAAE;IACtB;GACD,cAAc;GACf;EACF;;;;;CAMD;;;;;;;CAQA,YAAY;;;;CAKZ,IAAI,QAAQ;AACV,MAAI,CAAC,KAAK,QACR,MAAK,UAAU,KAAK,aAAa,EAAC,MAAO,KAAK,SAAS,aAAa;AAGtE,SAAO,KAAK;;;;;CAMd,UAAU;AACR,OAAK,cAAc,QAAQ;GACzB,MAAM,EAAE,OAAO,KAAK,aAAa;AAEjC,SAAM,UAAU,SAAS,OAAO;GAEhC,MAAM,UAAU,IAAI,UAAU,MAAM;AACpC,OAAI,SAAS;AACX,UAAM,QAAQ,QAAQ;AAItB,QAAI,CAAC,IAAI,QAAQ;AACf,SAAI,SAAS;AACb,UAAK,YAAY;;;GAQrB,MAAM,SAAS,KAAK,SAAuB,eAAe;AAC1D,OAAI,OACF,QAAO,cAAc,KAAK;OAE1B,OAAM,MAAM,IAAI;IAElB;;;;;CAMJ,gBAAgB;AACd,OAAK,SAAS,QAAQ;AACtB,OAAK,UAAU,KAAA;AAIf,MAAI,KAAK,WAAW;AAClB,QAAK,IAAI,SAAS;AAClB,QAAK,YAAY"}
|
package/MapboxSource.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxSource.js","names":[],"sources":["../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"}
|
package/StoreLocator.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StoreLocator.js","names":[],"sources":["../StoreLocator.ts"],"sourcesContent":["import { Base, type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport { nextTick } from '@studiometa/js-toolkit/utils';\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":";;;;;;;;;;;;AAgBA,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAY;AACV,OAAK,MAAM,OAAO,KAAK,aACrB,MAAK;AAEP,OAAK,MAAM,OAAO,KAAK,cACrB,MAAK;AAEP,OAAK,eAAe,EAAE;AACtB,OAAK,gBAAgB,EAAE;AAEvB,OAAK,gBAAgB;AACrB,OAAK,eAAe,KAAA;AACpB,OAAK,kBAAkB;AACvB,OAAK,iBAAiB,KAAA;AACtB,OAAK,qBAAqB;AAC1B,OAAK,oBAAoB,KAAA;AACzB,OAAK,yBAAyB;AAC9B,OAAK,wBAAwB,KAAA;AAE7B,OAAK,OAAO,IAAI,WAAW,KAAK,gBAAgB;AAChD,OAAK,IAAI,oBAAoB,SAAS,KAAK,kBAAkB;AAE7D,OAAK,SAAS,QAAQ;AACtB,OAAK,UAAU,KAAA;AACf,OAAK,aAAa,KAAA;AAClB,OAAK,QAAQ,KAAA;AACb,OAAK,YAAY,KAAA;AACjB,OAAK,aAAa,KAAA;AAClB,OAAK,WAAW;AAChB,OAAK,iBAAiB;AACtB,OAAK,kBAAkB"}
|
package/autoload.js
DELETED
package/autoload.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autoload.js","names":[],"sources":["../autoload.ts"],"sourcesContent":["import { registerManifest } from '@studiometa/js-toolkit';\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"}
|
package/catalog.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","names":[],"sources":["../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"}
|
package/dependencies.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","names":[],"sources":["../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"}
|
package/manifest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[],"sources":["../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,OAAO,uBAAuB,MAAM,EAAE,qBAAqB,eAAe;EACvF;CACD,wBAAwB;EACtB,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YACE,OAAO,+BAA+B,MACnC,EAAE,6BAA6B,uBACjC;EACJ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
|
package/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../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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