@studiometa/ui-mapbox 0.0.1 → 1.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/AbstractMapboxControl.d.ts +53 -0
  2. package/AbstractMapboxControl.js +70 -0
  3. package/AbstractMapboxControl.js.map +1 -0
  4. package/AbstractMapboxMapChild.d.ts +229 -0
  5. package/AbstractMapboxMapChild.js +336 -0
  6. package/AbstractMapboxMapChild.js.map +1 -0
  7. package/LICENSE.md +110 -0
  8. package/MapboxCluster.d.ts +208 -0
  9. package/MapboxCluster.js +418 -0
  10. package/MapboxCluster.js.map +1 -0
  11. package/MapboxClusterItem.d.ts +130 -0
  12. package/MapboxClusterItem.js +182 -0
  13. package/MapboxClusterItem.js.map +1 -0
  14. package/MapboxFullscreenControl.d.ts +21 -0
  15. package/MapboxFullscreenControl.js +21 -0
  16. package/MapboxFullscreenControl.js.map +1 -0
  17. package/MapboxGeocoder.d.ts +64 -0
  18. package/MapboxGeocoder.js +80 -0
  19. package/MapboxGeocoder.js.map +1 -0
  20. package/MapboxGeolocateControl.d.ts +23 -0
  21. package/MapboxGeolocateControl.js +31 -0
  22. package/MapboxGeolocateControl.js.map +1 -0
  23. package/MapboxImage.d.ts +49 -0
  24. package/MapboxImage.js +83 -0
  25. package/MapboxImage.js.map +1 -0
  26. package/MapboxImages.d.ts +66 -0
  27. package/MapboxImages.js +95 -0
  28. package/MapboxImages.js.map +1 -0
  29. package/MapboxLayer.d.ts +99 -0
  30. package/MapboxLayer.js +148 -0
  31. package/MapboxLayer.js.map +1 -0
  32. package/MapboxMap.d.ts +64 -0
  33. package/MapboxMap.js +131 -0
  34. package/MapboxMap.js.map +1 -0
  35. package/MapboxMarker.d.ts +56 -0
  36. package/MapboxMarker.js +73 -0
  37. package/MapboxMarker.js.map +1 -0
  38. package/MapboxNavigationControl.d.ts +27 -0
  39. package/MapboxNavigationControl.js +28 -0
  40. package/MapboxNavigationControl.js.map +1 -0
  41. package/MapboxPopup.d.ts +51 -0
  42. package/MapboxPopup.js +76 -0
  43. package/MapboxPopup.js.map +1 -0
  44. package/MapboxSource.d.ts +68 -0
  45. package/MapboxSource.js +104 -0
  46. package/MapboxSource.js.map +1 -0
  47. package/README.md +85 -0
  48. package/StoreLocator.d.ts +323 -0
  49. package/StoreLocator.js +538 -0
  50. package/StoreLocator.js.map +1 -0
  51. package/catalog.d.ts +7 -0
  52. package/catalog.js +68 -0
  53. package/catalog.js.map +1 -0
  54. package/dependencies.d.ts +85 -0
  55. package/dependencies.js +84 -0
  56. package/dependencies.js.map +1 -0
  57. package/index.d.ts +18 -0
  58. package/index.js +19 -0
  59. package/index.js.map +1 -0
  60. package/manifest.d.ts +6 -0
  61. package/manifest.js +133 -0
  62. package/manifest.js.map +1 -0
  63. package/package.json +43 -3
  64. package/utils.d.ts +112 -0
  65. package/utils.js +143 -0
  66. package/utils.js.map +1 -0
  67. package/Claude-of-Duty/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  68. package/alfred-projects-cache.tsv +0 -137
  69. package/claude-501/-Users-titouanmathis--dotfiles/298a49f7-c4b3-4a50-9707-a9c0d0733e95/scratchpad/pptest/config.json +0 -1
  70. package/claude-501/-Users-titouanmathis--dotfiles/298a49f7-c4b3-4a50-9707-a9c0d0733e95/scratchpad/pptest/stub/herdr +0 -8
  71. package/claude-501/-Users-titouanmathis--dotfiles/7d127a50-a71a-411a-bc1f-15b070f909f9/tasks/bg1cckto6.output +0 -4
  72. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/after.toml +0 -298
  73. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/before.toml +0 -298
  74. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/extracted.txt +0 -36
  75. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/final.log +0 -496
  76. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/guard.sh +0 -18
  77. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/lock.check +0 -917
  78. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/mise-registry.json +0 -3827
  79. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/mise.lock.before +0 -917
  80. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/.config/mise/conf.d/extra.toml +0 -2
  81. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/.config/mise/mise.lock +0 -47
  82. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/mise.lock +0 -47
  83. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/mise.toml +0 -2
  84. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/.github/workflows/mise-check.yml +0 -188
  85. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/.github/workflows/renovate.yml +0 -62
  86. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/mise.lock +0 -917
  87. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/mise.toml +0 -291
  88. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/probe.log +0 -4974
  89. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/probe2.log +0 -22
  90. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/probe3.log +0 -4916
  91. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/renovate.json +0 -62
  92. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/renovate-local.log +0 -670
  93. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/symtest/link/mise.lock +0 -47
  94. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/symtest/real/source.toml +0 -4
  95. package/claude-501/-Users-titouanmathis-Lab--studiometa-automations/d6c27f69-577a-468b-9bb3-a45c03a66143/scratchpad/cookie.txt +0 -1
  96. package/gitlab-docs-read.md +0 -8
  97. package/gitlab-instance-limits.txt +0 -8
  98. package/piab-501/piab-devops-019fcbcc991d-59c77b27-fresh-47da8bd318.config +0 -1
  99. package/pins-new.txt +0 -36
  100. package/pins-old.txt +0 -36
  101. package/reply +0 -0
  102. package/zsh0IBbcP +0 -0
  103. package/zsh2LqT39 +0 -0
  104. package/zsh6KJGTP +0 -0
  105. package/zshN1hNdy +0 -0
  106. package/zshNjWSYH +0 -11
  107. package/zshNvB745 +0 -0
  108. package/zshOXC0uH +0 -0
  109. package/zshPG9CFU +0 -0
  110. package/zshVOeZsK +0 -0
  111. package/zshVqIgQS +0 -0
  112. package/zshXTrFg8 +0 -0
  113. package/zshaUGubs +0 -11
  114. package/zshbzOT6d +0 -1
  115. package/zshnbtbGK +0 -0
  116. package/zshpQi1EI +0 -2
  117. package/zshwhMjOD +0 -1
@@ -0,0 +1,182 @@
1
+ import { MAPBOX_CLUSTER_CONNECTED } from "./MapboxCluster.js";
2
+ import { Base } from "@studiometa/js-toolkit";
3
+ //#region MapboxClusterItem.ts
4
+ /**
5
+ * A single entry of a `MapboxCluster`.
6
+ *
7
+ * Unlike the other `@studiometa/ui-mapbox` components, this one is a **rendered**
8
+ * element (e.g. a list `<li>` in a sidebar) and does not extend
9
+ * `AbstractMapboxMapChild`: its DOM lives outside the `MapboxMap` element, so its
10
+ * context is the parent `MapboxCluster` — resolved via `$closest('MapboxCluster')`
11
+ * — rather than a map.
12
+ *
13
+ * It is at once the list item AND the map feature: the cluster derives its
14
+ * GeoJSON source from the set of registered items, so the same markup drives
15
+ * both the sidebar and the clustered points on the map. The child PUSHES itself
16
+ * to the cluster on mount (`register`) and PULLS itself out on destroy
17
+ * (`unregister`), so the cluster never has to query for its children.
18
+ *
19
+ * The component is headless and passive: it never selects itself. The state
20
+ * setters below reflect state as data-attributes on `$el` so the integrator can
21
+ * style the item with plain CSS, and they are driven by whoever coordinates the
22
+ * experience — a [`StoreLocator`](./StoreLocator.js) orchestrator on `moveend`
23
+ * and on selection, if one wraps the cluster:
24
+ *
25
+ * - `data-in-bounds` — present when the item's `lngLat` is inside the current
26
+ * map viewport (list-visibility signal).
27
+ * - `data-active` + `aria-current="true"` — present when the item is selected.
28
+ *
29
+ * Used under a bare `MapboxCluster` (no orchestrator) the item still registers
30
+ * and renders as a clustered point; it just carries no selection affordance of
31
+ * its own — a click is reported by the cluster's `map-item-click` event for a
32
+ * caller to act on.
33
+ *
34
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
35
+ */
36
+ var MapboxClusterItem = class extends Base {
37
+ /**
38
+ * Config.
39
+ */
40
+ static config = {
41
+ name: "MapboxClusterItem",
42
+ emits: ["map-error"],
43
+ options: {
44
+ id: String,
45
+ lngLat: {
46
+ type: Array,
47
+ default: () => [0, 0]
48
+ },
49
+ properties: {
50
+ type: Object,
51
+ default: () => ({})
52
+ }
53
+ }
54
+ };
55
+ /**
56
+ * The parent `MapboxCluster` resolved at mount, cached so the item can still
57
+ * reach it on destroy.
58
+ *
59
+ * `destroyed()` runs *after* the element has been detached from the DOM (e.g.
60
+ * a `Fetch` list swap), and a `$closest` lookup on a disconnected node returns
61
+ * nothing — which would leave the removed item registered and its feature
62
+ * stuck on the map. Caching the reference keeps the unregister path working.
63
+ * @private
64
+ */
65
+ __cluster;
66
+ /**
67
+ * Off handler for the document-level `MAPBOX_CLUSTER_CONNECTED` retry
68
+ * subscription, used when the item mounts before its cluster.
69
+ * @private
70
+ */
71
+ __offClusterConnected;
72
+ /**
73
+ * The item's stable identifier, used to match map features back to the item.
74
+ *
75
+ * Expected to be non-empty and unique within a cluster. Duplicate ids are not
76
+ * rejected, but their behavior is defined rather than undefined: a click on
77
+ * any duplicate resolves to the FIRST registered item carrying that id (see
78
+ * `MapboxCluster.__handleUnclusteredClick`). Integrators wanting a distinct
79
+ * selection per element must give each item a unique id.
80
+ */
81
+ get id() {
82
+ return this.$options.id;
83
+ }
84
+ /**
85
+ * The item's coordinates as a `[lng, lat]` tuple.
86
+ */
87
+ get lngLat() {
88
+ return this.$options.lngLat;
89
+ }
90
+ /**
91
+ * Extra feature properties merged into the item's GeoJSON feature.
92
+ */
93
+ get properties() {
94
+ return this.$options.properties;
95
+ }
96
+ /**
97
+ * The HTML used as the map popup content when this item is selected.
98
+ *
99
+ * Uses the inner HTML of an optional `[data-ref="popup"]` element when present
100
+ * so the sidebar card and the map popup can differ, otherwise falls back to
101
+ * the item's whole inner HTML.
102
+ */
103
+ get popupContent() {
104
+ return (this.$el.querySelector("[data-ref=\"popup\"]") ?? this.$el).innerHTML.trim();
105
+ }
106
+ /**
107
+ * Mounted hook: resolve the parent cluster and register with it.
108
+ */
109
+ mounted() {
110
+ this.__resolveCluster();
111
+ }
112
+ /**
113
+ * Resolve the parent `MapboxCluster` and register, or wait for one to connect.
114
+ *
115
+ * Resolution is retryable: an item eagerly registered under a lazily imported
116
+ * cluster mounts first and finds nothing, so it waits for
117
+ * `MAPBOX_CLUSTER_CONNECTED` and registers once its cluster is up.
118
+ * @private
119
+ */
120
+ __resolveCluster() {
121
+ const cluster = this.$closest("MapboxCluster");
122
+ if (!cluster) {
123
+ this.__waitForConnectedCluster();
124
+ return;
125
+ }
126
+ this.__cluster = cluster;
127
+ cluster.register(this);
128
+ }
129
+ /**
130
+ * Subscribe once to `MAPBOX_CLUSTER_CONNECTED` and retry resolution when a
131
+ * cluster whose element is an ancestor of this item connects.
132
+ * @private
133
+ */
134
+ __waitForConnectedCluster() {
135
+ if (this.__offClusterConnected) return;
136
+ const handler = (event) => {
137
+ if (!event.detail?.$el?.contains(this.$el)) return;
138
+ this.__offClusterConnected?.();
139
+ this.__offClusterConnected = void 0;
140
+ this.__resolveCluster();
141
+ };
142
+ document.addEventListener(MAPBOX_CLUSTER_CONNECTED, handler);
143
+ this.__offClusterConnected = () => document.removeEventListener(MAPBOX_CLUSTER_CONNECTED, handler);
144
+ }
145
+ /**
146
+ * Destroyed hook: unregister from the cached cluster, even if the element has
147
+ * already been detached from the DOM, and drop any pending retry subscription.
148
+ */
149
+ destroyed() {
150
+ try {
151
+ this.__cluster?.unregister(this);
152
+ } catch (err) {
153
+ this.$warn(err);
154
+ this.$emit("map-error", err);
155
+ }
156
+ this.__cluster = void 0;
157
+ this.__offClusterConnected?.();
158
+ this.__offClusterConnected = void 0;
159
+ }
160
+ /**
161
+ * Reflect the "in the current map viewport" state as a `data-in-bounds`
162
+ * attribute. Called by a `StoreLocator` orchestrator on every map `moveend`.
163
+ * @param {boolean} value
164
+ */
165
+ setInBounds(value) {
166
+ this.$el.toggleAttribute("data-in-bounds", value);
167
+ }
168
+ /**
169
+ * Reflect the "selected/active" state as a `data-active` attribute and the
170
+ * `aria-current` state. Called by a `StoreLocator` orchestrator on selection.
171
+ * @param {boolean} value
172
+ */
173
+ setActive(value) {
174
+ this.$el.toggleAttribute("data-active", value);
175
+ if (value) this.$el.setAttribute("aria-current", "true");
176
+ else this.$el.removeAttribute("aria-current");
177
+ }
178
+ };
179
+ //#endregion
180
+ export { MapboxClusterItem, MapboxClusterItem as default };
181
+
182
+ //# sourceMappingURL=MapboxClusterItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapboxClusterItem.js","names":[],"sources":["../MapboxClusterItem.ts"],"sourcesContent":["import { Base, type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport { MAPBOX_CLUSTER_CONNECTED, type MapboxCluster } from './MapboxCluster.js';\n\nexport interface MapboxClusterItemProps extends BaseProps {\n $options: {\n id: string;\n lngLat: [number, number];\n properties: Record<string, unknown>;\n };\n}\n\n/**\n * A single entry of a `MapboxCluster`.\n *\n * Unlike the other `@studiometa/ui-mapbox` components, this one is a **rendered**\n * element (e.g. a list `<li>` in a sidebar) and does not extend\n * `AbstractMapboxMapChild`: its DOM lives outside the `MapboxMap` element, so its\n * context is the parent `MapboxCluster` — resolved via `$closest('MapboxCluster')`\n * — rather than a map.\n *\n * It is at once the list item AND the map feature: the cluster derives its\n * GeoJSON source from the set of registered items, so the same markup drives\n * both the sidebar and the clustered points on the map. The child PUSHES itself\n * to the cluster on mount (`register`) and PULLS itself out on destroy\n * (`unregister`), so the cluster never has to query for its children.\n *\n * The component is headless and passive: it never selects itself. The state\n * setters below reflect state as data-attributes on `$el` so the integrator can\n * style the item with plain CSS, and they are driven by whoever coordinates the\n * experience — a [`StoreLocator`](./StoreLocator.js) orchestrator on `moveend`\n * and on selection, if one wraps the cluster:\n *\n * - `data-in-bounds` — present when the item's `lngLat` is inside the current\n * map viewport (list-visibility signal).\n * - `data-active` + `aria-current=\"true\"` — present when the item is selected.\n *\n * Used under a bare `MapboxCluster` (no orchestrator) the item still registers\n * and renders as a clustered point; it just carries no selection affordance of\n * its own — a click is reported by the cluster's `map-item-click` event for a\n * caller to act on.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxClusterItem<T extends BaseProps = BaseProps> extends Base<\n T & MapboxClusterItemProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxClusterItem',\n emits: ['map-error'],\n options: {\n id: String,\n lngLat: {\n type: Array,\n default: () => [0, 0],\n },\n properties: {\n type: Object,\n default: () => ({}),\n },\n },\n };\n\n /**\n * The parent `MapboxCluster` resolved at mount, cached so the item can still\n * reach it on destroy.\n *\n * `destroyed()` runs *after* the element has been detached from the DOM (e.g.\n * a `Fetch` list swap), and a `$closest` lookup on a disconnected node returns\n * nothing — which would leave the removed item registered and its feature\n * stuck on the map. Caching the reference keeps the unregister path working.\n * @private\n */\n __cluster?: MapboxCluster;\n\n /**\n * Off handler for the document-level `MAPBOX_CLUSTER_CONNECTED` retry\n * subscription, used when the item mounts before its cluster.\n * @private\n */\n __offClusterConnected?: () => void;\n\n /**\n * The item's stable identifier, used to match map features back to the item.\n *\n * Expected to be non-empty and unique within a cluster. Duplicate ids are not\n * rejected, but their behavior is defined rather than undefined: a click on\n * any duplicate resolves to the FIRST registered item carrying that id (see\n * `MapboxCluster.__handleUnclusteredClick`). Integrators wanting a distinct\n * selection per element must give each item a unique id.\n */\n get id(): string {\n return this.$options.id;\n }\n\n /**\n * The item's coordinates as a `[lng, lat]` tuple.\n */\n get lngLat(): [number, number] {\n return this.$options.lngLat;\n }\n\n /**\n * Extra feature properties merged into the item's GeoJSON feature.\n */\n get properties(): Record<string, unknown> {\n return this.$options.properties;\n }\n\n /**\n * The HTML used as the map popup content when this item is selected.\n *\n * Uses the inner HTML of an optional `[data-ref=\"popup\"]` element when present\n * so the sidebar card and the map popup can differ, otherwise falls back to\n * the item's whole inner HTML.\n */\n get popupContent(): string {\n const ref = this.$el.querySelector('[data-ref=\"popup\"]');\n return (ref ?? this.$el).innerHTML.trim();\n }\n\n /**\n * Mounted hook: resolve the parent cluster and register with it.\n */\n mounted() {\n this.__resolveCluster();\n }\n\n /**\n * Resolve the parent `MapboxCluster` and register, or wait for one to connect.\n *\n * Resolution is retryable: an item eagerly registered under a lazily imported\n * cluster mounts first and finds nothing, so it waits for\n * `MAPBOX_CLUSTER_CONNECTED` and registers once its cluster is up.\n * @private\n */\n __resolveCluster() {\n const cluster = this.$closest<MapboxCluster>('MapboxCluster');\n\n if (!cluster) {\n this.__waitForConnectedCluster();\n return;\n }\n\n this.__cluster = cluster;\n cluster.register(this);\n }\n\n /**\n * Subscribe once to `MAPBOX_CLUSTER_CONNECTED` and retry resolution when a\n * cluster whose element is an ancestor of this item connects.\n * @private\n */\n __waitForConnectedCluster() {\n if (this.__offClusterConnected) {\n return;\n }\n\n const handler = (event: Event) => {\n const cluster = (event as CustomEvent<MapboxCluster>).detail;\n\n if (!cluster?.$el?.contains(this.$el)) {\n return;\n }\n\n this.__offClusterConnected?.();\n this.__offClusterConnected = undefined;\n this.__resolveCluster();\n };\n\n document.addEventListener(MAPBOX_CLUSTER_CONNECTED, handler);\n this.__offClusterConnected = () =>\n document.removeEventListener(MAPBOX_CLUSTER_CONNECTED, handler);\n }\n\n /**\n * Destroyed hook: unregister from the cached cluster, even if the element has\n * already been detached from the DOM, and drop any pending retry subscription.\n */\n destroyed() {\n try {\n this.__cluster?.unregister(this);\n } catch (err) {\n this.$warn(err);\n this.$emit('map-error', err);\n }\n\n this.__cluster = undefined;\n this.__offClusterConnected?.();\n this.__offClusterConnected = undefined;\n }\n\n /**\n * Reflect the \"in the current map viewport\" state as a `data-in-bounds`\n * attribute. Called by a `StoreLocator` orchestrator on every map `moveend`.\n * @param {boolean} value\n */\n setInBounds(value: boolean) {\n this.$el.toggleAttribute('data-in-bounds', value);\n }\n\n /**\n * Reflect the \"selected/active\" state as a `data-active` attribute and the\n * `aria-current` state. Called by a `StoreLocator` orchestrator on selection.\n * @param {boolean} value\n */\n setActive(value: boolean) {\n this.$el.toggleAttribute('data-active', value);\n\n if (value) {\n this.$el.setAttribute('aria-current', 'true');\n } else {\n this.$el.removeAttribute('aria-current');\n }\n }\n}\n\nexport default MapboxClusterItem;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,oBAAb,cAAwE,KAEtE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,YAAY;EACpB,SAAS;GACP,IAAI;GACJ,QAAQ;IACN,MAAM;IACN,eAAe,CAAC,GAAG,EAAE;IACtB;GACD,YAAY;IACV,MAAM;IACN,gBAAgB,EAAE;IACnB;GACF;EACF;;;;;;;;;;;CAYD;;;;;;CAOA;;;;;;;;;;CAWA,IAAI,KAAa;AACf,SAAO,KAAK,SAAS;;;;;CAMvB,IAAI,SAA2B;AAC7B,SAAO,KAAK,SAAS;;;;;CAMvB,IAAI,aAAsC;AACxC,SAAO,KAAK,SAAS;;;;;;;;;CAUvB,IAAI,eAAuB;AAEzB,UADY,KAAK,IAAI,cAAc,uBAAqB,IACzC,KAAK,KAAK,UAAU,MAAM;;;;;CAM3C,UAAU;AACR,OAAK,kBAAkB;;;;;;;;;;CAWzB,mBAAmB;EACjB,MAAM,UAAU,KAAK,SAAwB,gBAAgB;AAE7D,MAAI,CAAC,SAAS;AACZ,QAAK,2BAA2B;AAChC;;AAGF,OAAK,YAAY;AACjB,UAAQ,SAAS,KAAK;;;;;;;CAQxB,4BAA4B;AAC1B,MAAI,KAAK,sBACP;EAGF,MAAM,WAAW,UAAiB;AAGhC,OAAI,CAFa,MAAqC,QAExC,KAAK,SAAS,KAAK,IAAI,CACnC;AAGF,QAAK,yBAAyB;AAC9B,QAAK,wBAAwB,KAAA;AAC7B,QAAK,kBAAkB;;AAGzB,WAAS,iBAAiB,0BAA0B,QAAQ;AAC5D,OAAK,8BACH,SAAS,oBAAoB,0BAA0B,QAAQ;;;;;;CAOnE,YAAY;AACV,MAAI;AACF,QAAK,WAAW,WAAW,KAAK;WACzB,KAAK;AACZ,QAAK,MAAM,IAAI;AACf,QAAK,MAAM,aAAa,IAAI;;AAG9B,OAAK,YAAY,KAAA;AACjB,OAAK,yBAAyB;AAC9B,OAAK,wBAAwB,KAAA;;;;;;;CAQ/B,YAAY,OAAgB;AAC1B,OAAK,IAAI,gBAAgB,kBAAkB,MAAM;;;;;;;CAQnD,UAAU,OAAgB;AACxB,OAAK,IAAI,gBAAgB,eAAe,MAAM;AAE9C,MAAI,MACF,MAAK,IAAI,aAAa,gBAAgB,OAAO;MAE7C,MAAK,IAAI,gBAAgB,eAAe"}
@@ -0,0 +1,21 @@
1
+ import { AbstractMapboxControlProps } from "./AbstractMapboxControl.js";
2
+ import * as _studiometa_js_toolkit0 from "@studiometa/js-toolkit";
3
+ import * as mapbox_gl0 from "mapbox-gl";
4
+ import { FullscreenControlOptions } from "mapbox-gl";
5
+
6
+ //#region MapboxFullscreenControl.d.ts
7
+ interface MapboxFullscreenControlProps extends AbstractMapboxControlProps {}
8
+ declare const MapboxFullscreenControl_base: _studiometa_js_toolkit0.BaseDecorator<_studiometa_js_toolkit0.BaseInterface, _studiometa_js_toolkit0.Base<_studiometa_js_toolkit0.BaseProps>>;
9
+ /**
10
+ * Add a fullscreen control to the map.
11
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
12
+ */
13
+ declare class MapboxFullscreenControl extends MapboxFullscreenControl_base {
14
+ /**
15
+ * Create the mapbox FullscreenControl instance.
16
+ * @protected
17
+ */
18
+ createControl(options: FullscreenControlOptions): mapbox_gl0.FullscreenControl;
19
+ }
20
+ //#endregion
21
+ export { MapboxFullscreenControl, MapboxFullscreenControl as default, MapboxFullscreenControlProps };
@@ -0,0 +1,21 @@
1
+ import { AbstractMapboxControl } from "./AbstractMapboxControl.js";
2
+ import { getMapboxGl } from "./dependencies.js";
3
+ import { withExtraConfig } from "@studiometa/js-toolkit";
4
+ //#region MapboxFullscreenControl.ts
5
+ /**
6
+ * Add a fullscreen control to the map.
7
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
8
+ */
9
+ var MapboxFullscreenControl = class extends withExtraConfig(AbstractMapboxControl, { name: "MapboxFullscreenControl" }) {
10
+ /**
11
+ * Create the mapbox FullscreenControl instance.
12
+ * @protected
13
+ */
14
+ createControl(options) {
15
+ return new (getMapboxGl()).FullscreenControl(options);
16
+ }
17
+ };
18
+ //#endregion
19
+ export { MapboxFullscreenControl, MapboxFullscreenControl as default };
20
+
21
+ //# sourceMappingURL=MapboxFullscreenControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapboxFullscreenControl.js","names":[],"sources":["../MapboxFullscreenControl.ts"],"sourcesContent":["import { withExtraConfig } from '@studiometa/js-toolkit';\nimport type { FullscreenControlOptions } from 'mapbox-gl';\nimport {\n AbstractMapboxControl,\n type AbstractMapboxControlProps,\n} from './AbstractMapboxControl.js';\nimport { getMapboxGl } from './dependencies.js';\n\nexport interface MapboxFullscreenControlProps extends AbstractMapboxControlProps {}\n\n/**\n * Add a fullscreen control to the map.\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxFullscreenControl extends withExtraConfig(AbstractMapboxControl, {\n name: 'MapboxFullscreenControl',\n}) {\n /**\n * Create the mapbox FullscreenControl instance.\n * @protected\n */\n createControl(options: FullscreenControlOptions) {\n return new (getMapboxGl().FullscreenControl)(options);\n }\n}\n\nexport default MapboxFullscreenControl;\n"],"mappings":";;;;;;;;AAcA,IAAa,0BAAb,cAA6C,gBAAgB,uBAAuB,EAClF,MAAM,2BACP,CAAC,CAAC;;;;;CAKD,cAAc,SAAmC;AAC/C,SAAO,KAAK,aAAa,EAAC,kBAAmB,QAAQ"}
@@ -0,0 +1,64 @@
1
+ import { AbstractMapboxMapChild, AbstractMapboxMapChildProps } from "./AbstractMapboxMapChild.js";
2
+ import { MapboxGeocoderControl } from "./dependencies.js";
3
+ import { BaseConfig, BaseProps } from "@studiometa/js-toolkit";
4
+ import { Map } from "mapbox-gl";
5
+
6
+ //#region MapboxGeocoder.d.ts
7
+ interface MapboxGeocoderProps extends AbstractMapboxMapChildProps {
8
+ $options: {
9
+ /**
10
+ * Wether to add the geocoder to the map or to the component's root element.
11
+ */
12
+ addToMap: boolean;
13
+ /**
14
+ * All MapboxGeocoder options, except the non serializable ones.
15
+ *
16
+ * Typed structurally (rather than with the optional geocoder peer types) to
17
+ * keep the peer out of the public type surface. Refer to the Mapbox geocoder
18
+ * package documentation (API.md#parameters) for the accepted options.
19
+ */
20
+ options: Record<string, unknown>;
21
+ };
22
+ }
23
+ /**
24
+ * Add a geocoder control to the map.
25
+ *
26
+ * The Mapbox geocoder module is an optional peer dependency and is loaded on
27
+ * demand with a dynamic `import()` when the component mounts, so the rest of the
28
+ * package keeps working without it installed.
29
+ *
30
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
31
+ */
32
+ declare class MapboxGeocoder<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<T & MapboxGeocoderProps> {
33
+ /**
34
+ * Config.
35
+ */
36
+ static config: BaseConfig;
37
+ /**
38
+ * Control instance, created once the lazily imported module resolves.
39
+ * @private
40
+ */
41
+ __control?: MapboxGeocoderControl;
42
+ /**
43
+ * The Mapbox geocoder control instance, if it has been created yet.
44
+ */
45
+ get control(): MapboxGeocoderControl | undefined;
46
+ /**
47
+ * Target element the geocoder is added to: the map when `addToMap` is set,
48
+ * otherwise the component's own root element.
49
+ */
50
+ get target(): Map | HTMLElement | string;
51
+ /**
52
+ * Mounted hook.
53
+ *
54
+ * Lazily loads the optional Mapbox geocoder module, then builds and adds the
55
+ * control once the parent map is ready.
56
+ */
57
+ mounted(): Promise<void>;
58
+ /**
59
+ * Teardown hook.
60
+ */
61
+ __onDestroyed(): void;
62
+ }
63
+ //#endregion
64
+ export { MapboxGeocoder, MapboxGeocoder as default, MapboxGeocoderProps };
@@ -0,0 +1,80 @@
1
+ import { AbstractMapboxMapChild } from "./AbstractMapboxMapChild.js";
2
+ import { getMapboxGl, resolveMapboxGeocoder } from "./dependencies.js";
3
+ //#region MapboxGeocoder.ts
4
+ /**
5
+ * Add a geocoder control to the map.
6
+ *
7
+ * The Mapbox geocoder module is an optional peer dependency and is loaded on
8
+ * demand with a dynamic `import()` when the component mounts, so the rest of the
9
+ * package keeps working without it installed.
10
+ *
11
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
12
+ */
13
+ var MapboxGeocoder = class extends AbstractMapboxMapChild {
14
+ /**
15
+ * Config.
16
+ */
17
+ static config = {
18
+ name: "MapboxGeocoder",
19
+ emits: ["map-result"],
20
+ options: {
21
+ addToMap: Boolean,
22
+ options: Object
23
+ }
24
+ };
25
+ /**
26
+ * Control instance, created once the lazily imported module resolves.
27
+ * @private
28
+ */
29
+ __control;
30
+ /**
31
+ * The Mapbox geocoder control instance, if it has been created yet.
32
+ */
33
+ get control() {
34
+ return this.__control;
35
+ }
36
+ /**
37
+ * Target element the geocoder is added to: the map when `addToMap` is set,
38
+ * otherwise the component's own root element.
39
+ */
40
+ get target() {
41
+ return this.$options.addToMap ? this.map : this.$el;
42
+ }
43
+ /**
44
+ * Mounted hook.
45
+ *
46
+ * Lazily loads the optional Mapbox geocoder module, then builds and adds the
47
+ * control once the parent map is ready.
48
+ */
49
+ async mounted() {
50
+ const GeocoderControlClass = await resolveMapboxGeocoder();
51
+ if (!this.$isMounted) return;
52
+ this.whenMapReady(() => {
53
+ if (this.__control) {
54
+ if (!this.$options.addToMap) this.__control.onRemove();
55
+ this.__control = void 0;
56
+ }
57
+ this.__control = new GeocoderControlClass({
58
+ ...this.$options.options,
59
+ mapboxgl: getMapboxGl(),
60
+ accessToken: this.$options.options.accessToken ?? this.__readyMapboxMap?.$options.accessToken
61
+ });
62
+ this.__control.on?.("result", (event) => this.$emit("map-result", event.result));
63
+ this.__control.addTo(this.target);
64
+ });
65
+ }
66
+ /**
67
+ * Teardown hook.
68
+ */
69
+ __onDestroyed() {
70
+ if (this.__control) {
71
+ if (this.$options.addToMap) this.__readyMap?.removeControl(this.__control);
72
+ else this.__control.onRemove();
73
+ this.__control = void 0;
74
+ }
75
+ }
76
+ };
77
+ //#endregion
78
+ export { MapboxGeocoder, MapboxGeocoder as default };
79
+
80
+ //# sourceMappingURL=MapboxGeocoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapboxGeocoder.js","names":[],"sources":["../MapboxGeocoder.ts"],"sourcesContent":["import { type BaseProps, type BaseConfig } from '@studiometa/js-toolkit';\nimport type { Map, IControl } from 'mapbox-gl';\nimport {\n AbstractMapboxMapChild,\n type AbstractMapboxMapChildProps,\n} from './AbstractMapboxMapChild.js';\nimport {\n getMapboxGl,\n resolveMapboxGeocoder,\n type MapboxGeocoderControl,\n} from './dependencies.js';\n\nexport interface MapboxGeocoderProps extends AbstractMapboxMapChildProps {\n $options: {\n /**\n * Wether to add the geocoder to the map or to the component's root element.\n */\n addToMap: boolean;\n /**\n * All MapboxGeocoder options, except the non serializable ones.\n *\n * Typed structurally (rather than with the optional geocoder peer types) to\n * keep the peer out of the public type surface. Refer to the Mapbox geocoder\n * package documentation (API.md#parameters) for the accepted options.\n */\n options: Record<string, unknown>;\n };\n}\n\n/**\n * Add a geocoder control to the map.\n *\n * The Mapbox geocoder module is an optional peer dependency and is loaded on\n * demand with a dynamic `import()` when the component mounts, so the rest of the\n * package keeps working without it installed.\n *\n * @see https://ui.studiometa.dev/reference/items/MapboxMap/\n */\nexport class MapboxGeocoder<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<\n T & MapboxGeocoderProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'MapboxGeocoder',\n emits: ['map-result'],\n options: {\n addToMap: Boolean,\n options: Object,\n },\n };\n\n /**\n * Control instance, created once the lazily imported module resolves.\n * @private\n */\n __control?: MapboxGeocoderControl;\n\n /**\n * The Mapbox geocoder control instance, if it has been created yet.\n */\n get control(): MapboxGeocoderControl | undefined {\n return this.__control;\n }\n\n /**\n * Target element the geocoder is added to: the map when `addToMap` is set,\n * otherwise the component's own root element.\n */\n get target(): Map | HTMLElement | string {\n return this.$options.addToMap ? this.map : this.$el;\n }\n\n /**\n * Mounted hook.\n *\n * Lazily loads the optional Mapbox geocoder module, then builds and adds the\n * control once the parent map is ready.\n */\n async mounted() {\n const GeocoderControlClass = await resolveMapboxGeocoder();\n\n // The component may have been destroyed while the dynamic import was still\n // resolving. Bail out before creating and adding the control, otherwise it\n // would be attached after `destroyed()` already ran (and saw `__control`\n // undefined), leaking an orphan control.\n if (!this.$isMounted) {\n return;\n }\n\n this.whenMapReady(() => {\n // The ready callback is standing: it re-runs on every map replacement. An\n // element-targeted control (`addToMap` false) lives on `$el`, which\n // survives the map swap, so a previous control must be removed first or\n // each replacement would stack another geocoder onto the element. A\n // map-targeted control went away with its (removed) map, so only its\n // reference needs dropping.\n if (this.__control) {\n if (!this.$options.addToMap) {\n this.__control.onRemove();\n }\n this.__control = undefined;\n }\n\n const options = {\n ...this.$options.options,\n mapboxgl: getMapboxGl(),\n accessToken:\n this.$options.options.accessToken ?? this.__readyMapboxMap?.$options.accessToken,\n };\n this.__control = new GeocoderControlClass(\n options as ConstructorParameters<typeof GeocoderControlClass>[0],\n );\n // Re-emit the control's `result` event as a prefixed component event so\n // consumers (e.g. a `StoreLocator`) can react to a geocoded address.\n this.__control.on?.('result', (event) => this.$emit('map-result', event.result));\n this.__control.addTo(this.target);\n });\n }\n\n /**\n * Teardown hook.\n */\n __onDestroyed() {\n // The control may not exist yet: the dynamic import in `mounted()` might not\n // have resolved, or the geocoder module was never loaded.\n if (this.__control) {\n if (this.$options.addToMap) {\n this.__readyMap?.removeControl(this.__control as unknown as IControl);\n } else {\n this.__control.onRemove();\n }\n this.__control = undefined;\n }\n }\n}\n\nexport default MapboxGeocoder;\n"],"mappings":";;;;;;;;;;;;AAsCA,IAAa,iBAAb,cAAqE,uBAEnE;;;;CAIA,OAAO,SAAqB;EAC1B,MAAM;EACN,OAAO,CAAC,aAAa;EACrB,SAAS;GACP,UAAU;GACV,SAAS;GACV;EACF;;;;;CAMD;;;;CAKA,IAAI,UAA6C;AAC/C,SAAO,KAAK;;;;;;CAOd,IAAI,SAAqC;AACvC,SAAO,KAAK,SAAS,WAAW,KAAK,MAAM,KAAK;;;;;;;;CASlD,MAAM,UAAU;EACd,MAAM,uBAAuB,MAAM,uBAAuB;AAM1D,MAAI,CAAC,KAAK,WACR;AAGF,OAAK,mBAAmB;AAOtB,OAAI,KAAK,WAAW;AAClB,QAAI,CAAC,KAAK,SAAS,SACjB,MAAK,UAAU,UAAU;AAE3B,SAAK,YAAY,KAAA;;AASnB,QAAK,YAAY,IAAI,qBANL;IACd,GAAG,KAAK,SAAS;IACjB,UAAU,aAAa;IACvB,aACE,KAAK,SAAS,QAAQ,eAAe,KAAK,kBAAkB,SAAS;IACxE,CAGA;AAGD,QAAK,UAAU,KAAK,WAAW,UAAU,KAAK,MAAM,cAAc,MAAM,OAAO,CAAC;AAChF,QAAK,UAAU,MAAM,KAAK,OAAO;IACjC;;;;;CAMJ,gBAAgB;AAGd,MAAI,KAAK,WAAW;AAClB,OAAI,KAAK,SAAS,SAChB,MAAK,YAAY,cAAc,KAAK,UAAiC;OAErE,MAAK,UAAU,UAAU;AAE3B,QAAK,YAAY,KAAA"}
@@ -0,0 +1,23 @@
1
+ import { AbstractMapboxControlProps } from "./AbstractMapboxControl.js";
2
+ import * as _studiometa_js_toolkit0 from "@studiometa/js-toolkit";
3
+ import * as mapbox_gl0 from "mapbox-gl";
4
+ import { GeolocateControlOptions } from "mapbox-gl";
5
+
6
+ //#region MapboxGeolocateControl.d.ts
7
+ interface MapboxGeolocateControlProps extends AbstractMapboxControlProps {
8
+ $options: AbstractMapboxControlProps['$options'] & Omit<GeolocateControlOptions, 'geolocation'>;
9
+ }
10
+ declare const MapboxGeolocateControl_base: _studiometa_js_toolkit0.BaseDecorator<_studiometa_js_toolkit0.BaseInterface, _studiometa_js_toolkit0.Base<_studiometa_js_toolkit0.BaseProps>>;
11
+ /**
12
+ * Add a geolocate control to the map.
13
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
14
+ */
15
+ declare class MapboxGeolocateControl extends MapboxGeolocateControl_base {
16
+ /**
17
+ * Create the mapbox GeolocateControl instance.
18
+ * @protected
19
+ */
20
+ createControl(options: GeolocateControlOptions): mapbox_gl0.GeolocateControl;
21
+ }
22
+ //#endregion
23
+ export { MapboxGeolocateControl, MapboxGeolocateControl as default, MapboxGeolocateControlProps };
@@ -0,0 +1,31 @@
1
+ import { AbstractMapboxControl } from "./AbstractMapboxControl.js";
2
+ import { getMapboxGl } from "./dependencies.js";
3
+ import { withExtraConfig } from "@studiometa/js-toolkit";
4
+ //#region MapboxGeolocateControl.ts
5
+ /**
6
+ * Add a geolocate control to the map.
7
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
8
+ */
9
+ var MapboxGeolocateControl = class extends withExtraConfig(AbstractMapboxControl, {
10
+ name: "MapboxGeolocateControl",
11
+ options: {
12
+ positionOptions: Object,
13
+ fitBoundsOptions: Object,
14
+ trackUserLocation: Boolean,
15
+ showAccuracyCircle: Boolean,
16
+ showUserLocation: Boolean,
17
+ showUserHeading: Boolean
18
+ }
19
+ }) {
20
+ /**
21
+ * Create the mapbox GeolocateControl instance.
22
+ * @protected
23
+ */
24
+ createControl(options) {
25
+ return new (getMapboxGl()).GeolocateControl(options);
26
+ }
27
+ };
28
+ //#endregion
29
+ export { MapboxGeolocateControl, MapboxGeolocateControl as default };
30
+
31
+ //# sourceMappingURL=MapboxGeolocateControl.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,49 @@
1
+ import { AbstractMapboxMapChild, AbstractMapboxMapChildProps } from "./AbstractMapboxMapChild.js";
2
+ import { MapboxImageOptions } from "./utils.js";
3
+ import { BaseConfig, BaseProps } from "@studiometa/js-toolkit";
4
+
5
+ //#region MapboxImage.d.ts
6
+ interface MapboxImageProps extends AbstractMapboxMapChildProps {
7
+ $options: {
8
+ name: string;
9
+ url: string;
10
+ /**
11
+ * The image options forwarded to `map.addImage`.
12
+ * @see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addimage
13
+ */
14
+ options: MapboxImageOptions;
15
+ };
16
+ }
17
+ /**
18
+ * Load and register a single image against the map sprite.
19
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
20
+ */
21
+ declare class MapboxImage<T extends BaseProps = BaseProps> extends AbstractMapboxMapChild<T & MapboxImageProps> {
22
+ /**
23
+ * Config.
24
+ */
25
+ static config: BaseConfig;
26
+ /**
27
+ * Whether this instance owns the sprite under its name. Only a sprite this
28
+ * instance owns may be removed on teardown; a pre-existing sprite declared
29
+ * outside the family is left untouched, and a sprite a newer sibling has since
30
+ * adopted (a same-name `Fetch` swap) is left to that sibling.
31
+ * @private
32
+ */
33
+ __owned: boolean;
34
+ /**
35
+ * The `kind:name` ownership key for this sprite.
36
+ * @private
37
+ */
38
+ get __ownershipKey(): string;
39
+ /**
40
+ * Mounted hook.
41
+ */
42
+ mounted(): void;
43
+ /**
44
+ * Teardown hook.
45
+ */
46
+ __onDestroyed(): void;
47
+ }
48
+ //#endregion
49
+ export { MapboxImage, MapboxImage as default, MapboxImageProps };
package/MapboxImage.js ADDED
@@ -0,0 +1,83 @@
1
+ import { AbstractMapboxMapChild } from "./AbstractMapboxMapChild.js";
2
+ import { addMapboxImage, claimMapboxOwnership, getMapboxOwner, releaseMapboxOwnership } from "./utils.js";
3
+ //#region MapboxImage.ts
4
+ /**
5
+ * Load and register a single image against the map sprite.
6
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
7
+ */
8
+ var MapboxImage = class extends AbstractMapboxMapChild {
9
+ /**
10
+ * Config.
11
+ */
12
+ static config = {
13
+ name: "MapboxImage",
14
+ emits: ["map-ready"],
15
+ options: {
16
+ name: String,
17
+ url: String,
18
+ options: {
19
+ type: Object,
20
+ default: () => ({
21
+ pixelRatio: 1,
22
+ sdf: false
23
+ })
24
+ }
25
+ }
26
+ };
27
+ /**
28
+ * Whether this instance owns the sprite under its name. Only a sprite this
29
+ * instance owns may be removed on teardown; a pre-existing sprite declared
30
+ * outside the family is left untouched, and a sprite a newer sibling has since
31
+ * adopted (a same-name `Fetch` swap) is left to that sibling.
32
+ * @private
33
+ */
34
+ __owned = false;
35
+ /**
36
+ * The `kind:name` ownership key for this sprite.
37
+ * @private
38
+ */
39
+ get __ownershipKey() {
40
+ return `image:${this.$options.name}`;
41
+ }
42
+ /**
43
+ * Mounted hook.
44
+ */
45
+ mounted() {
46
+ this.whenMapReady(async (map) => {
47
+ const { name, url, options } = this.$options;
48
+ const { image, added } = await addMapboxImage(map, {
49
+ name,
50
+ url,
51
+ options
52
+ });
53
+ if (!this.$isMounted || this.__readyMap !== map) {
54
+ if (added && this.__readyMap === map && map.hasImage(name)) map.removeImage(name);
55
+ return;
56
+ }
57
+ if (added || getMapboxOwner(map, this.__ownershipKey)) {
58
+ claimMapboxOwnership(map, this.__ownershipKey, this, () => map.hasImage(name));
59
+ this.__owned = true;
60
+ }
61
+ this.$emit("map-ready", {
62
+ name,
63
+ image,
64
+ options
65
+ });
66
+ });
67
+ }
68
+ /**
69
+ * Teardown hook.
70
+ */
71
+ __onDestroyed() {
72
+ const { name } = this.$options;
73
+ const map = this.__readyMap;
74
+ if (this.__owned && getMapboxOwner(map, this.__ownershipKey) === this && map?.hasImage(name)) {
75
+ map.removeImage(name);
76
+ releaseMapboxOwnership(map, this.__ownershipKey, this);
77
+ }
78
+ }
79
+ };
80
+ //#endregion
81
+ export { MapboxImage, MapboxImage as default };
82
+
83
+ //# sourceMappingURL=MapboxImage.js.map
@@ -0,0 +1 @@
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"}