@nuxt/scripts 0.11.5 → 0.11.7

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/client/200.html +9 -9
  3. package/dist/client/404.html +9 -9
  4. package/dist/client/_nuxt/D3ZVEC_8.js +1 -0
  5. package/dist/client/_nuxt/DmiqYg4r.js +21 -0
  6. package/dist/client/_nuxt/_5UZfQdF.js +1 -0
  7. package/dist/client/_nuxt/builds/latest.json +1 -1
  8. package/dist/client/_nuxt/builds/meta/93bac187-07c5-4a76-83a2-cefcf05c0b88.json +1 -0
  9. package/dist/client/_nuxt/{entry.CJckMUzn.css → entry.DExDtQtx.css} +1 -1
  10. package/dist/client/_nuxt/error-404.CpID9NZX.css +1 -0
  11. package/dist/client/_nuxt/error-500.BzWA0Bp3.css +1 -0
  12. package/dist/client/_nuxt/{Bo1SWr6k.js → z8Iwlb2L.js} +1 -1
  13. package/dist/client/index.html +9 -9
  14. package/dist/module.json +3 -3
  15. package/dist/registry.mjs +27 -0
  16. package/dist/runtime/components/ScriptAriaLoadingIndicator.vue.d.ts +2 -0
  17. package/dist/runtime/components/ScriptCarbonAds.vue +41 -57
  18. package/dist/runtime/components/ScriptCarbonAds.vue.d.ts +32 -0
  19. package/dist/runtime/components/ScriptCrisp.vue +43 -63
  20. package/dist/runtime/components/ScriptCrisp.vue.d.ts +44 -0
  21. package/dist/runtime/components/ScriptGoogleAdsense.vue +37 -60
  22. package/dist/runtime/components/ScriptGoogleAdsense.vue.d.ts +37 -0
  23. package/dist/runtime/components/ScriptGoogleMaps.vue +220 -366
  24. package/dist/runtime/components/ScriptGoogleMaps.vue.d.ts +144 -0
  25. package/dist/runtime/components/ScriptIntercom.vue +48 -67
  26. package/dist/runtime/components/ScriptIntercom.vue.d.ts +45 -0
  27. package/dist/runtime/components/ScriptLemonSqueezy.vue +26 -37
  28. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +24 -0
  29. package/dist/runtime/components/ScriptLoadingIndicator.vue +8 -13
  30. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +9 -0
  31. package/dist/runtime/components/ScriptStripePricingTable.vue +41 -53
  32. package/dist/runtime/components/ScriptStripePricingTable.vue.d.ts +35 -0
  33. package/dist/runtime/components/ScriptVimeoPlayer.vue +121 -218
  34. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +127 -0
  35. package/dist/runtime/components/ScriptYouTubePlayer.vue +105 -163
  36. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +66 -0
  37. package/dist/runtime/registry/clarity.d.ts +1 -1
  38. package/dist/runtime/registry/clarity.js +7 -1
  39. package/dist/runtime/registry/rybbit-analytics.d.ts +20 -0
  40. package/dist/runtime/registry/rybbit-analytics.js +32 -0
  41. package/dist/runtime/registry/snapchat-pixel.js +1 -1
  42. package/dist/runtime/types.d.ts +2 -0
  43. package/dist/types.d.mts +2 -2
  44. package/package.json +53 -48
  45. package/dist/client/_nuxt/BojlM8av.js +0 -21
  46. package/dist/client/_nuxt/BwFnCI0m.js +0 -1
  47. package/dist/client/_nuxt/builds/meta/0bd5f801-ad22-4b04-821c-25f180195d78.json +0 -1
  48. package/dist/client/_nuxt/error-404.BiTeRF3j.css +0 -1
  49. package/dist/client/_nuxt/error-500.Be1AE5oK.css +0 -1
  50. package/dist/client/_nuxt/yRslIvSb.js +0 -1
  51. package/dist/module.cjs +0 -5
  52. package/dist/module.d.ts +0 -60
  53. package/dist/registry.d.ts +0 -6
  54. package/dist/types.d.ts +0 -7
@@ -1,483 +1,337 @@
1
- <script lang="ts" setup>
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-nocheck
4
-
5
- /// <reference types="google.maps" />
6
- import { computed, onBeforeUnmount, onMounted, ref, watch, toRaw } from 'vue'
7
- import type { HTMLAttributes, ImgHTMLAttributes, Ref, ReservedProps } from 'vue'
8
- import { withQuery } from 'ufo'
9
- import type { QueryObject } from 'ufo'
10
- import { defu } from 'defu'
11
- import { hash } from 'ohash'
12
- import { useHead } from 'nuxt/app'
13
- import type { ElementScriptTrigger } from '../types'
14
- import { scriptRuntimeConfig } from '../utils'
15
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
16
- import { useScriptGoogleMaps } from '../registry/google-maps'
17
- import ScriptAriaLoadingIndicator from './ScriptAriaLoadingIndicator.vue'
18
-
19
- interface PlaceholderOptions {
20
- width?: string | number
21
- height?: string | number
22
- center?: string
23
- zoom?: number
24
- size?: string
25
- scale?: number
26
- format?: 'png' | 'jpg' | 'gif' | 'png8' | 'png32' | 'jpg-baseline'
27
- maptype?: 'roadmap' | 'satellite' | 'terrain' | 'hybrid'
28
- language?: string
29
- region?: string
30
- markers?: string
31
- path?: string
32
- visible?: string
33
- style?: string
34
- map_id?: string
35
- key?: string
36
- signature?: string
37
- }
38
-
39
- const props = withDefaults(defineProps<{
40
- /**
41
- * Defines the trigger event to load the script.
42
- */
43
- trigger?: ElementScriptTrigger
44
- /**
45
- * Is Google Maps being rendered above the fold?
46
- * This will load the placeholder image with higher priority.
47
- */
48
- aboveTheFold?: boolean
49
- /**
50
- * Defines the Google Maps API key. Must have access to the Static Maps API as well.
51
- */
52
- apiKey?: string
53
- /**
54
- * A latitude / longitude of where to focus the map.
55
- */
56
- center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`
57
- /**
58
- * Should a marker be displayed on the map where the centre is.
59
- */
60
- centerMarker?: boolean
61
- /**
62
- * Options for the map.
63
- */
64
- mapOptions?: google.maps.MapOptions
65
- /**
66
- * Defines the region of the map.
67
- */
68
- region?: string
69
- /**
70
- * Defines the language of the map
71
- */
72
- language?: string
73
- /**
74
- * Defines the version of google maps js API
75
- */
76
- version?: string
77
- /**
78
- * Defines the width of the map.
79
- */
80
- width?: number | string
81
- /**
82
- * Defines the height of the map
83
- */
84
- height?: number | string
85
- /**
86
- * Customize the placeholder image attributes.
87
- *
88
- * @see https://developers.google.com/maps/documentation/maps-static/start.
89
- */
90
- placeholderOptions?: PlaceholderOptions
91
- /**
92
- * Customize the placeholder image attributes.
93
- */
94
- placeholderAttrs?: ImgHTMLAttributes & ReservedProps & Record<string, unknown>
95
- /**
96
- * Customize the root element attributes.
97
- */
98
- rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>
99
- /**
100
- * Extra Markers to add to the map.
101
- */
102
- markers?: (`${string},${string}` | google.maps.marker.AdvancedMarkerElementOptions)[]
103
- }>(), {
104
- // @ts-expect-error untyped
105
- trigger: ['mouseenter', 'mouseover', 'mousedown'],
106
- width: 640,
107
- height: 400,
108
- })
109
-
110
- const emits = defineEmits<{
111
- // our emit
112
- ready: [e: typeof googleMaps]
113
- error: []
114
- }>()
115
-
116
- const apiKey = props.apiKey || scriptRuntimeConfig('googleMaps')?.apiKey
117
-
118
- const mapsApi = ref<typeof google.maps | undefined>()
119
-
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, onMounted, ref, watch, toRaw } from "vue";
3
+ import { withQuery } from "ufo";
4
+ import { defu } from "defu";
5
+ import { hash } from "ohash";
6
+ import { useHead } from "nuxt/app";
7
+ import { scriptRuntimeConfig } from "../utils";
8
+ import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
9
+ import { useScriptGoogleMaps } from "../registry/google-maps";
10
+ import ScriptAriaLoadingIndicator from "./ScriptAriaLoadingIndicator.vue";
11
+ const props = defineProps({
12
+ trigger: { type: [String, Array, Boolean], required: false, default: ["mouseenter", "mouseover", "mousedown"] },
13
+ aboveTheFold: { type: Boolean, required: false },
14
+ apiKey: { type: String, required: false },
15
+ center: { type: null, required: false },
16
+ centerMarker: { type: Boolean, required: false },
17
+ mapOptions: { type: null, required: false },
18
+ region: { type: String, required: false },
19
+ language: { type: String, required: false },
20
+ version: { type: String, required: false },
21
+ width: { type: [Number, String], required: false, default: 640 },
22
+ height: { type: [Number, String], required: false, default: 400 },
23
+ placeholderOptions: { type: Object, required: false },
24
+ placeholderAttrs: { type: Object, required: false },
25
+ rootAttrs: { type: Object, required: false },
26
+ markers: { type: Array, required: false }
27
+ });
28
+ const emits = defineEmits(["ready", "error"]);
29
+ const apiKey = props.apiKey || scriptRuntimeConfig("googleMaps")?.apiKey;
30
+ const mapsApi = ref();
120
31
  if (import.meta.dev && !apiKey)
121
- throw new Error('GoogleMaps requires an API key. Please provide `apiKey` on the <ScriptGoogleMaps> or globally via `runtimeConfig.public.scripts.googleMaps.apiKey`.')
122
-
123
- // TODO allow a null center may need to be resolved via an API function
124
-
125
- const rootEl = ref<HTMLElement>()
126
- const mapEl = ref<HTMLElement>()
127
-
128
- const centerOverride = ref()
129
-
130
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
32
+ throw new Error("GoogleMaps requires an API key. Please provide `apiKey` on the <ScriptGoogleMaps> or globally via `runtimeConfig.public.scripts.googleMaps.apiKey`.");
33
+ const rootEl = ref();
34
+ const mapEl = ref();
35
+ const centerOverride = ref();
36
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
131
37
  const { load, status, onLoaded } = useScriptGoogleMaps({
132
38
  apiKey: props.apiKey,
133
39
  scriptOptions: {
134
- trigger,
40
+ trigger
135
41
  },
136
42
  region: props.region,
137
43
  language: props.language,
138
- v: props.version,
139
- })
140
-
44
+ v: props.version
45
+ });
141
46
  const options = computed(() => {
142
47
  return defu({ center: centerOverride.value }, props.mapOptions, {
143
48
  center: props.center,
144
49
  zoom: 15,
145
- mapId: props.mapOptions?.styles ? undefined : 'map',
146
- })
147
- })
148
- const ready = ref(false)
149
-
150
- const map: Ref<google.maps.Map | undefined> = ref()
151
- const mapMarkers: Ref<Map<string, Promise<google.maps.marker.AdvancedMarkerElement>>> = ref(new Map())
152
-
153
- function isLocationQuery(s: string | any) {
154
- return typeof s === 'string' && (s.split(',').length > 2 || s.includes('+'))
50
+ mapId: props.mapOptions?.styles ? void 0 : "map"
51
+ });
52
+ });
53
+ const ready = ref(false);
54
+ const map = ref();
55
+ const mapMarkers = ref(/* @__PURE__ */ new Map());
56
+ function isLocationQuery(s) {
57
+ return typeof s === "string" && (s.split(",").length > 2 || s.includes("+"));
155
58
  }
156
-
157
- function resetMapMarkerMap(_marker: google.maps.marker.AdvancedMarkerElement | Promise<google.maps.marker.AdvancedMarkerElement>) {
158
- // eslint-disable-next-line no-async-promise-executor
159
- return new Promise<void>(async (resolve) => {
160
- const marker = _marker instanceof Promise ? await _marker : _marker
59
+ function resetMapMarkerMap(_marker) {
60
+ return new Promise(async (resolve) => {
61
+ const marker = _marker instanceof Promise ? await _marker : _marker;
161
62
  if (marker) {
162
- // @ts-expect-error broken type
163
- marker.setMap(null)
63
+ marker.setMap(null);
164
64
  }
165
- resolve()
166
- })
65
+ resolve();
66
+ });
167
67
  }
168
-
169
- function normalizeAdvancedMapMarkerOptions(_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) {
170
- const opts = typeof _options === 'string'
171
- ? {
172
- position: {
173
- lat: Number.parseFloat(_options.split(',')[0] || '0'),
174
- lng: Number.parseFloat(_options.split(',')[1] || '0'),
175
- },
176
- }
177
- : _options
68
+ function normalizeAdvancedMapMarkerOptions(_options) {
69
+ const opts = typeof _options === "string" ? {
70
+ position: {
71
+ lat: Number.parseFloat(_options.split(",")[0] || "0"),
72
+ lng: Number.parseFloat(_options.split(",")[1] || "0")
73
+ }
74
+ } : _options;
178
75
  if (!opts.position) {
179
- // set default
180
76
  opts.position = {
181
77
  lat: 0,
182
- lng: 0,
183
- }
78
+ lng: 0
79
+ };
184
80
  }
185
- return opts
81
+ return opts;
186
82
  }
187
-
188
- async function createAdvancedMapMarker(_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) {
83
+ async function createAdvancedMapMarker(_options) {
189
84
  if (!_options)
190
- return
191
- const normalizedOptions = normalizeAdvancedMapMarkerOptions(_options)
192
- const key = hash({ position: normalizedOptions.position })
85
+ return;
86
+ const normalizedOptions = normalizeAdvancedMapMarkerOptions(_options);
87
+ const key = hash({ position: normalizedOptions.position });
193
88
  if (mapMarkers.value.has(key))
194
- return mapMarkers.value.get(key)
195
- // eslint-disable-next-line no-async-promise-executor
196
- const p = new Promise<google.maps.marker.AdvancedMarkerElement>(async (resolve) => {
197
- const lib = await importLibrary('marker')
89
+ return mapMarkers.value.get(key);
90
+ const p = new Promise(async (resolve) => {
91
+ const lib = await importLibrary("marker");
198
92
  const mapMarkerOptions = defu(toRaw(normalizedOptions), {
199
- map: toRaw(map.value!),
93
+ map: toRaw(map.value),
200
94
  // @ts-expect-error unified API for maps and markers
201
- position: normalizedOptions.location,
202
- })
203
- resolve(new lib.AdvancedMarkerElement(mapMarkerOptions))
204
- })
205
- mapMarkers.value.set(key, p)
206
- return p
95
+ position: normalizedOptions.location
96
+ });
97
+ resolve(new lib.AdvancedMarkerElement(mapMarkerOptions));
98
+ });
99
+ mapMarkers.value.set(key, p);
100
+ return p;
207
101
  }
208
-
209
- const queryToLatLngCache = new Map<string, google.maps.LatLng>()
210
-
211
- async function resolveQueryToLatLang(query: string) {
212
- if (query && typeof query === 'object')
213
- return Promise.resolve(query)
102
+ const queryToLatLngCache = /* @__PURE__ */ new Map();
103
+ async function resolveQueryToLatLang(query) {
104
+ if (query && typeof query === "object")
105
+ return Promise.resolve(query);
214
106
  if (queryToLatLngCache.has(query)) {
215
- return Promise.resolve(queryToLatLngCache.get(query))
107
+ return Promise.resolve(queryToLatLngCache.get(query));
216
108
  }
217
- // only if the query is a string we need to do a lookup
218
- // eslint-disable-next-line no-async-promise-executor
219
- return new Promise<google.maps.LatLng>(async (resolve, reject) => {
109
+ return new Promise(async (resolve, reject) => {
220
110
  if (!mapsApi.value) {
221
- await load()
222
- // await new promise, watch until mapsApi is set
223
- await new Promise<void>((resolve) => {
111
+ await load();
112
+ await new Promise((resolve2) => {
224
113
  const _ = watch(mapsApi, () => {
225
- _()
226
- resolve()
227
- })
228
- })
114
+ _();
115
+ resolve2();
116
+ });
117
+ });
229
118
  }
230
- const placesService = new mapsApi.value!.places.PlacesService(map.value!)
119
+ const placesService = new mapsApi.value.places.PlacesService(map.value);
231
120
  placesService.findPlaceFromQuery({
232
121
  query,
233
- fields: ['name', 'geometry'],
234
- }, (results, status) => {
235
- if (status === 'OK' && results?.[0]?.geometry?.location)
236
- return resolve(results[0].geometry.location)
237
- return reject(new Error(`No location found for ${query}`))
238
- })
122
+ fields: ["name", "geometry"]
123
+ }, (results, status2) => {
124
+ if (status2 === "OK" && results?.[0]?.geometry?.location)
125
+ return resolve(results[0].geometry.location);
126
+ return reject(new Error(`No location found for ${query}`));
127
+ });
239
128
  }).then((res) => {
240
- queryToLatLngCache.set(query, res)
241
- return res
242
- })
129
+ queryToLatLngCache.set(query, res);
130
+ return res;
131
+ });
243
132
  }
244
-
245
- const libraries = new Map<string, any>()
246
-
247
- function importLibrary(key: 'marker'): Promise<google.maps.MarkerLibrary>
248
- function importLibrary(key: 'places'): Promise<google.maps.PlacesLibrary>
249
- function importLibrary(key: 'geometry'): Promise<google.maps.GeometryLibrary>
250
- function importLibrary(key: 'drawing'): Promise<google.maps.DrawingLibrary>
251
- function importLibrary(key: 'visualization'): Promise<google.maps.VisualizationLibrary>
252
- function importLibrary(key: string): Promise<any>
253
- function importLibrary<T>(key: string): Promise<T> {
133
+ const libraries = /* @__PURE__ */ new Map();
134
+ function importLibrary(key) {
254
135
  if (libraries.has(key))
255
- return libraries.get(key)
136
+ return libraries.get(key);
256
137
  const p = mapsApi.value?.importLibrary(key) || new Promise((resolve) => {
257
138
  const stop = watch(mapsApi, (api) => {
258
139
  if (api) {
259
- const p = api.importLibrary(key)
260
- resolve(p)
261
- stop()
140
+ const p2 = api.importLibrary(key);
141
+ resolve(p2);
142
+ stop();
262
143
  }
263
- }, { immediate: true })
264
- })
265
- libraries.set(key, p)
266
- return p as any as Promise<T>
144
+ }, { immediate: true });
145
+ });
146
+ libraries.set(key, p);
147
+ return p;
267
148
  }
268
-
269
149
  const googleMaps = {
270
150
  googleMaps: mapsApi,
271
151
  map,
272
152
  createAdvancedMapMarker,
273
153
  resolveQueryToLatLang,
274
- importLibrary,
275
- } as const
276
-
277
- defineExpose(googleMaps)
278
-
154
+ importLibrary
155
+ };
156
+ defineExpose(googleMaps);
279
157
  onMounted(() => {
280
158
  watch(ready, (v) => {
281
159
  if (v) {
282
- emits('ready', googleMaps)
160
+ emits("ready", googleMaps);
283
161
  }
284
- })
162
+ });
285
163
  watch(status, (v) => {
286
- if (v === 'error') {
287
- emits('error')
164
+ if (v === "error") {
165
+ emits("error");
288
166
  }
289
- })
167
+ });
290
168
  watch(options, () => {
291
- map.value?.setOptions(options.value)
292
- })
169
+ map.value?.setOptions(options.value);
170
+ });
293
171
  watch([() => props.markers, map], async () => {
294
172
  if (!map.value) {
295
- return
173
+ return;
296
174
  }
297
- // mapMarkers is a map where we hash the next array entry as the map key
298
- // we need to do a diff to see what we remove or add
299
- const nextMap = new Map((props.markers || []).map(m => [hash({ position: normalizeAdvancedMapMarkerOptions(m).position }), m]))
300
- // compare idsToMatch in nextMap, if we're missing an id, we need to remove it
175
+ const nextMap = new Map((props.markers || []).map((m) => [hash({ position: normalizeAdvancedMapMarkerOptions(m).position }), m]));
301
176
  const toRemove = new Set([
302
- ...mapMarkers.value.keys(),
303
- ].filter(k => !nextMap.has(k)))
304
- // compare to existing
305
- const toAdd = new Set([...nextMap.keys()].filter(k => !mapMarkers.value.has(k)))
306
- // do a diff of next and prev
307
- const centerHash = hash({ position: options.value.center })
177
+ ...mapMarkers.value.keys()
178
+ ].filter((k) => !nextMap.has(k)));
179
+ const toAdd = new Set([...nextMap.keys()].filter((k) => !mapMarkers.value.has(k)));
180
+ const centerHash = hash({ position: options.value.center });
308
181
  for (const key of toRemove) {
309
182
  if (key === centerHash) {
310
- continue
183
+ continue;
311
184
  }
312
- const marker = await mapMarkers.value.get(key)
185
+ const marker = await mapMarkers.value.get(key);
313
186
  if (marker) {
314
- resetMapMarkerMap(marker)
315
- .then(() => {
316
- mapMarkers.value.delete(key)
317
- })
187
+ resetMapMarkerMap(marker).then(() => {
188
+ mapMarkers.value.delete(key);
189
+ });
318
190
  }
319
191
  }
320
192
  for (const k of toAdd) {
321
- createAdvancedMapMarker(nextMap.get(k))
193
+ createAdvancedMapMarker(nextMap.get(k));
322
194
  }
323
195
  }, {
324
196
  immediate: true,
325
- deep: true,
326
- })
197
+ deep: true
198
+ });
327
199
  watch([() => options.value.center, ready, map], async (next, prev) => {
328
200
  if (!map.value) {
329
- return
201
+ return;
330
202
  }
331
- let center = toRaw(next[0])
203
+ let center = toRaw(next[0]);
332
204
  if (center) {
333
205
  if (isLocationQuery(center) && ready.value) {
334
- // need to resolve center from query
335
- center = await resolveQueryToLatLang(center as string)
206
+ center = await resolveQueryToLatLang(center);
336
207
  }
337
- map.value!.setCenter(center as google.maps.LatLng)
338
- if (typeof props.centerMarker === 'undefined' || props.centerMarker) {
208
+ map.value.setCenter(center);
209
+ if (typeof props.centerMarker === "undefined" || props.centerMarker) {
339
210
  if (options.value.mapId) {
340
- // not allowed to use advanced markers with styles
341
- return
211
+ return;
342
212
  }
343
213
  if (prev[0]) {
344
- const prevCenterHash = hash({ position: prev[0] })
214
+ const prevCenterHash = hash({ position: prev[0] });
345
215
  if (mapMarkers.value.has(prevCenterHash)) {
346
- resetMapMarkerMap(mapMarkers.value.get(prevCenterHash)!)
347
- .then(() => {
348
- mapMarkers.value.delete(prevCenterHash)
349
- })
216
+ resetMapMarkerMap(mapMarkers.value.get(prevCenterHash)).then(() => {
217
+ mapMarkers.value.delete(prevCenterHash);
218
+ });
350
219
  }
351
220
  }
352
- createAdvancedMapMarker({ position: center })
221
+ createAdvancedMapMarker({ position: center });
353
222
  }
354
223
  }
355
224
  }, {
356
- immediate: true,
357
- })
225
+ immediate: true
226
+ });
358
227
  onLoaded(async (instance) => {
359
- mapsApi.value = await instance.maps
360
- // may need to transform the center before we can init the map
361
- const center = options.value.center as string
362
- const _options: google.maps.MapOptions = {
228
+ mapsApi.value = await instance.maps;
229
+ const center = options.value.center;
230
+ const _options = {
363
231
  ...options.value,
364
232
  // @ts-expect-error broken
365
- center: !center || isLocationQuery(center) ? undefined : center,
366
- }
367
- map.value = new mapsApi.value!.Map(mapEl.value!, _options)
233
+ center: !center || isLocationQuery(center) ? void 0 : center
234
+ };
235
+ map.value = new mapsApi.value.Map(mapEl.value, _options);
368
236
  if (center && isLocationQuery(center)) {
369
- // need to resolve center
370
- centerOverride.value = await resolveQueryToLatLang(center)
371
- map.value?.setCenter(centerOverride.value)
237
+ centerOverride.value = await resolveQueryToLatLang(center);
238
+ map.value?.setCenter(centerOverride.value);
372
239
  }
373
- ready.value = true
374
- })
375
- })
376
-
240
+ ready.value = true;
241
+ });
242
+ });
377
243
  if (import.meta.server) {
378
244
  useHead({
379
245
  link: [
380
246
  {
381
- rel: props.aboveTheFold ? 'preconnect' : 'dns-prefetch',
382
- href: 'https://maps.googleapis.com',
383
- },
384
- ],
385
- })
247
+ rel: props.aboveTheFold ? "preconnect" : "dns-prefetch",
248
+ href: "https://maps.googleapis.com"
249
+ }
250
+ ]
251
+ });
386
252
  }
387
-
388
- function transformMapStyles(styles: google.maps.MapTypeStyle[]) {
253
+ function transformMapStyles(styles) {
389
254
  return styles.map((style) => {
390
- const feature = style.featureType ? `feature:${style.featureType}` : ''
391
- const element = style.elementType ? `element:${style.elementType}` : ''
255
+ const feature = style.featureType ? `feature:${style.featureType}` : "";
256
+ const element = style.elementType ? `element:${style.elementType}` : "";
392
257
  const rules = (style.stylers || []).map((styler) => {
393
258
  return Object.entries(styler).map(([key, value]) => {
394
- if (key === 'color' && typeof value === 'string') {
395
- value = value.replace('#', '0x')
259
+ if (key === "color" && typeof value === "string") {
260
+ value = value.replace("#", "0x");
396
261
  }
397
- return `${key}:${value}`
398
- }).join('|')
399
- }).filter(Boolean).join('|')
400
- return [feature, element, rules].filter(Boolean).join('|')
401
- }).filter(Boolean)
262
+ return `${key}:${value}`;
263
+ }).join("|");
264
+ }).filter(Boolean).join("|");
265
+ return [feature, element, rules].filter(Boolean).join("|");
266
+ }).filter(Boolean);
402
267
  }
403
-
404
268
  const placeholder = computed(() => {
405
- let center = options.value.center
406
- if (center && typeof center === 'object') {
407
- center = `${center.lat},${center.lng}`
269
+ let center = options.value.center;
270
+ if (center && typeof center === "object") {
271
+ center = `${center.lat},${center.lng}`;
408
272
  }
409
- // @ts-expect-error lazy type
410
- const placeholderOptions: PlaceholderOptions = defu(props.placeholderOptions, {
273
+ const placeholderOptions = defu(props.placeholderOptions, {
411
274
  // only map option values
412
275
  zoom: options.value.zoom,
413
- center,
276
+ center
414
277
  }, {
415
278
  size: `${props.width}x${props.height}`,
416
279
  key: apiKey,
417
- scale: 2, // we assume a high DPI to avoid hydration issues
418
- style: props.mapOptions?.styles ? transformMapStyles(props.mapOptions.styles) : undefined,
280
+ scale: 2,
281
+ // we assume a high DPI to avoid hydration issues
282
+ style: props.mapOptions?.styles ? transformMapStyles(props.mapOptions.styles) : void 0,
419
283
  markers: [
420
- ...(props.markers || []),
421
- center,
422
- ]
423
- .filter(Boolean)
424
- .map((m) => {
425
- if (typeof m === 'object' && m.location) {
426
- m = m.location
427
- }
428
- if (typeof m === 'object' && m.lat) {
429
- return `${m.lat},${m.lng}`
430
- }
431
- return m
432
- })
433
- .join('|'),
434
- })
435
- return withQuery('https://maps.googleapis.com/maps/api/staticmap', placeholderOptions as QueryObject)
436
- })
437
-
284
+ ...props.markers || [],
285
+ (typeof props.centerMarker === "undefined" || props.centerMarker) && center
286
+ ].filter(Boolean).map((m) => {
287
+ if (typeof m === "object" && m.location) {
288
+ m = m.location;
289
+ }
290
+ if (typeof m === "object" && m.lat) {
291
+ return `${m.lat},${m.lng}`;
292
+ }
293
+ return m;
294
+ }).join("|")
295
+ });
296
+ return withQuery("https://maps.googleapis.com/maps/api/staticmap", placeholderOptions);
297
+ });
438
298
  const placeholderAttrs = computed(() => {
439
299
  return defu(props.placeholderAttrs, {
440
300
  src: placeholder.value,
441
- alt: 'Google Maps Static Map',
442
- loading: props.aboveTheFold ? 'eager' : 'lazy',
301
+ alt: "Google Maps Static Map",
302
+ loading: props.aboveTheFold ? "eager" : "lazy",
443
303
  style: {
444
- cursor: 'pointer',
445
- width: '100%',
446
- objectFit: 'cover',
447
- height: '100%',
448
- },
449
- } satisfies ImgHTMLAttributes)
450
- })
451
-
304
+ cursor: "pointer",
305
+ width: "100%",
306
+ objectFit: "cover",
307
+ height: "100%"
308
+ }
309
+ });
310
+ });
452
311
  const rootAttrs = computed(() => {
453
312
  return defu(props.rootAttrs, {
454
- 'aria-busy': status.value === 'loading',
455
- 'aria-label': status.value === 'awaitingLoad'
456
- ? 'Google Maps Static Map'
457
- : status.value === 'loading'
458
- ? 'Google Maps Map Embed Loading'
459
- : 'Google Maps Embed',
460
- 'aria-live': 'polite',
461
- 'role': 'application',
462
- 'style': {
463
- cursor: 'pointer',
464
- position: 'relative',
465
- maxWidth: '100%',
313
+ "aria-busy": status.value === "loading",
314
+ "aria-label": status.value === "awaitingLoad" ? "Google Maps Static Map" : status.value === "loading" ? "Google Maps Map Embed Loading" : "Google Maps Embed",
315
+ "aria-live": "polite",
316
+ "role": "application",
317
+ "style": {
318
+ cursor: "pointer",
319
+ position: "relative",
320
+ maxWidth: "100%",
466
321
  width: `${props.width}px`,
467
322
  height: `'auto'`,
468
- aspectRatio: `${props.width}/${props.height}`,
323
+ aspectRatio: `${props.width}/${props.height}`
469
324
  },
470
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
471
- }) as HTMLAttributes
472
- })
473
-
325
+ ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
326
+ });
327
+ });
474
328
  onBeforeUnmount(async () => {
475
- await Promise.all([...mapMarkers.value.entries()].map(([,marker]) => resetMapMarkerMap(marker)))
476
- mapMarkers.value.clear()
477
- map.value?.unbindAll()
478
- map.value = undefined
479
- mapEl.value?.firstChild?.remove()
480
- })
329
+ await Promise.all([...mapMarkers.value.entries()].map(([, marker]) => resetMapMarkerMap(marker)));
330
+ mapMarkers.value.clear();
331
+ map.value?.unbindAll();
332
+ map.value = void 0;
333
+ mapEl.value?.firstChild?.remove();
334
+ });
481
335
  </script>
482
336
 
483
337
  <template>