@nuxt/scripts 1.3.3 → 1.3.4

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 (96) hide show
  1. package/dist/devtools-client/200.html +1 -1
  2. package/dist/devtools-client/404.html +1 -1
  3. package/dist/devtools-client/_nuxt/{DAubxma0.js → 8ltZ0o6d.js} +1 -1
  4. package/dist/devtools-client/_nuxt/{CBuBrHyL.js → B8_EBdhg.js} +1 -1
  5. package/dist/devtools-client/_nuxt/CC0GKROJ.js +1 -0
  6. package/dist/devtools-client/_nuxt/{DvC3yV2P.js → CMXzQxJZ.js} +1 -1
  7. package/dist/devtools-client/_nuxt/{xAZ2vgo3.js → CP7c-Js6.js} +4 -4
  8. package/dist/devtools-client/_nuxt/{DzbSCA_w.js → DTP8MRtW.js} +1 -1
  9. package/dist/devtools-client/_nuxt/{DgAtAWdT.js → Dkc7iTdR.js} +1 -1
  10. package/dist/devtools-client/_nuxt/Dl7W1ViV.js +28 -0
  11. package/dist/devtools-client/_nuxt/{WOtyQdps.js → KxC4Q3ev.js} +1 -1
  12. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  13. package/dist/devtools-client/_nuxt/builds/meta/c38edf4f-387c-4148-a34a-ca78a5b40869.json +1 -0
  14. package/dist/devtools-client/_nuxt/error-404.Bq2JQbJs.css +1 -0
  15. package/dist/devtools-client/_nuxt/error-500.5E_FOzlc.css +1 -0
  16. package/dist/devtools-client/_nuxt/{pages.BF1VnccH.css → pages.aU4WirOM.css} +1 -1
  17. package/dist/devtools-client/docs/index.html +1 -1
  18. package/dist/devtools-client/first-party/index.html +1 -1
  19. package/dist/devtools-client/index.html +1 -1
  20. package/dist/devtools-client/registry/index.html +1 -1
  21. package/dist/module.d.mts +1 -1
  22. package/dist/module.d.ts +1 -1
  23. package/dist/module.json +1 -1
  24. package/dist/module.mjs +263 -47
  25. package/dist/registry.mjs +2 -2
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +71 -21
  27. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +2 -1
  28. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +39 -25
  29. package/dist/runtime/components/ScriptCarbonAds.vue +11 -3
  30. package/dist/runtime/components/ScriptCrisp.vue +4 -1
  31. package/dist/runtime/components/ScriptIntercom.vue +4 -1
  32. package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +13 -13
  33. package/dist/runtime/components/ScriptLemonSqueezy.vue +30 -6
  34. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +13 -13
  35. package/dist/runtime/components/ScriptPayPalButtons.vue +8 -1
  36. package/dist/runtime/components/ScriptPayPalMessages.vue +6 -0
  37. package/dist/runtime/components/ScriptStripePricingTable.vue +2 -0
  38. package/dist/runtime/components/ScriptVimeoPlayer.vue +8 -1
  39. package/dist/runtime/composables/useScript.js +121 -44
  40. package/dist/runtime/composables/useScriptEventPage.js +36 -20
  41. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +19 -5
  42. package/dist/runtime/composables/useScriptTriggerInteraction.js +23 -10
  43. package/dist/runtime/composables/useScriptTriggerServiceWorker.js +21 -18
  44. package/dist/runtime/devtools-standalone-bridge.client.js +28 -3
  45. package/dist/runtime/npm-script-proxy.d.ts +7 -0
  46. package/dist/runtime/npm-script-proxy.js +46 -0
  47. package/dist/runtime/npm-script-stub.js +4 -5
  48. package/dist/runtime/registry/posthog.js +11 -3
  49. package/dist/runtime/registry/speedcurve.js +33 -4
  50. package/dist/runtime/registry/usercentrics.js +4 -21
  51. package/dist/runtime/registry/youtube-player.js +16 -5
  52. package/dist/runtime/server/bluesky-embed.js +15 -6
  53. package/dist/runtime/server/google-maps-geocode-proxy.js +10 -5
  54. package/dist/runtime/server/google-static-maps-proxy.js +20 -13
  55. package/dist/runtime/server/gravatar-proxy.js +48 -11
  56. package/dist/runtime/server/instagram-embed-asset.js +1 -1
  57. package/dist/runtime/server/instagram-embed.js +44 -94
  58. package/dist/runtime/server/proxy-handler.d.ts +2 -1
  59. package/dist/runtime/server/proxy-handler.js +183 -23
  60. package/dist/runtime/server/utils/cache-config.d.ts +14 -0
  61. package/dist/runtime/server/utils/cache-config.js +13 -0
  62. package/dist/runtime/server/utils/cached-upstream.d.ts +23 -2
  63. package/dist/runtime/server/utils/cached-upstream.js +212 -15
  64. package/dist/runtime/server/utils/image-proxy.d.ts +3 -2
  65. package/dist/runtime/server/utils/image-proxy.js +26 -16
  66. package/dist/runtime/server/utils/instagram-embed.d.ts +8 -0
  67. package/dist/runtime/server/utils/instagram-embed.js +155 -0
  68. package/dist/runtime/server/utils/network-host.d.ts +21 -0
  69. package/dist/runtime/server/utils/network-host.js +112 -0
  70. package/dist/runtime/server/utils/privacy.js +55 -19
  71. package/dist/runtime/server/utils/proxy-query.d.ts +2 -0
  72. package/dist/runtime/server/utils/proxy-query.js +10 -0
  73. package/dist/runtime/server/utils/sign.d.ts +1 -1
  74. package/dist/runtime/server/utils/sign.js +1 -1
  75. package/dist/runtime/server/utils/withSigning.d.ts +1 -1
  76. package/dist/runtime/server/utils/withSigning.js +3 -3
  77. package/dist/runtime/server/vercel-insights-sink.js +1 -1
  78. package/dist/runtime/server/x-embed.js +8 -4
  79. package/dist/runtime/unhead-features.d.ts +1 -0
  80. package/dist/runtime/unhead-features.js +3 -0
  81. package/dist/runtime/utils/abortable-promise.d.ts +8 -0
  82. package/dist/runtime/utils/abortable-promise.js +63 -0
  83. package/dist/runtime/utils/after-next-paint.d.ts +1 -1
  84. package/dist/runtime/utils/after-next-paint.js +16 -1
  85. package/dist/runtime/utils/usercentrics-consent.d.ts +10 -0
  86. package/dist/runtime/utils/usercentrics-consent.js +88 -0
  87. package/dist/runtime/utils/youtube-readiness.d.ts +7 -0
  88. package/dist/runtime/utils/youtube-readiness.js +45 -0
  89. package/dist/runtime/utils.d.ts +3 -1
  90. package/dist/runtime/utils.js +29 -0
  91. package/package.json +2 -1
  92. package/dist/devtools-client/_nuxt/BGGk5RYW.js +0 -1
  93. package/dist/devtools-client/_nuxt/C8xLTMBy.js +0 -28
  94. package/dist/devtools-client/_nuxt/builds/meta/0c193d7f-fdc4-4ec6-b4c0-7ba4cc94709b.json +0 -1
  95. package/dist/devtools-client/_nuxt/error-404.CIn5oEzb.css +0 -1
  96. package/dist/devtools-client/_nuxt/error-500.B1YZl8g8.css +0 -1
@@ -5,10 +5,11 @@ export { MAP_INJECTION_KEY } from "./useGoogleMapsResource";
5
5
  <script setup>
6
6
  import { defu } from "defu";
7
7
  import { tryUseNuxtApp, useHead, useRuntimeConfig } from "nuxt/app";
8
- import { computed, nextTick, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, useAttrs, useTemplateRef, watch } from "vue";
8
+ import { computed, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, toRaw, useAttrs, useTemplateRef, watch } from "vue";
9
9
  import { useScriptTriggerElement } from "#nuxt-scripts/composables/useScriptTriggerElement";
10
10
  import { useScriptGoogleMaps } from "#nuxt-scripts/registry/google-maps";
11
11
  import { scriptRuntimeConfig, scriptsPrefix } from "#nuxt-scripts/utils";
12
+ import { createAbortablePromise } from "../../utils/abortable-promise";
12
13
  import ScriptAriaLoadingIndicator from "../ScriptAriaLoadingIndicator.vue";
13
14
  import { defineDeprecatedAlias, MAP_INJECTION_KEY, waitForMapsReady, warnDeprecatedTopLevelMapProps } from "./useGoogleMapsResource";
14
15
  const props = defineProps({
@@ -48,6 +49,8 @@ const currentColorScheme = computed(() => {
48
49
  return currentColorMode.value === "dark" ? "DARK" : "LIGHT";
49
50
  });
50
51
  const mapsApi = shallowRef();
52
+ const lifecycleController = new AbortController();
53
+ let isUnmounted = false;
51
54
  if (import.meta.dev) {
52
55
  if (!apiKey)
53
56
  throw new Error("GoogleMaps requires an API key. Enable it in your nuxt.config:\n\n scripts: {\n registry: {\n googleMaps: true\n }\n }\n\nThen set NUXT_PUBLIC_SCRIPTS_GOOGLE_MAPS_API_KEY in your .env file.\n\nAlternatively, pass `api-key` directly on the <ScriptGoogleMaps> component (note: this exposes the key client-side).");
@@ -144,7 +147,8 @@ async function resolveQueryToLatLng(query) {
144
147
  const endpoints = runtimeConfig.public["nuxt-scripts"]?.endpoints;
145
148
  if (endpoints?.googleMaps) {
146
149
  const data = await $fetch(`${scriptsPrefix()}/proxy/google-maps-geocode`, {
147
- params: { address: query }
150
+ params: { address: query },
151
+ signal: lifecycleController.signal
148
152
  });
149
153
  if (data.status === "OK" && data.results?.[0]?.geometry?.location) {
150
154
  const loc = data.results[0].geometry.location;
@@ -154,7 +158,7 @@ async function resolveQueryToLatLng(query) {
154
158
  }
155
159
  throw new Error(`No location found for ${query}`);
156
160
  }
157
- await waitForMapsReady({ mapsApi, map, status, load });
161
+ await waitForMapsReady({ mapsApi, map, status, load, signal: lifecycleController.signal });
158
162
  const placesService = new mapsApi.value.places.PlacesService(map.value);
159
163
  const result = await new Promise((resolve, reject) => {
160
164
  placesService.findPlaceFromQuery(
@@ -178,14 +182,22 @@ const libraries = /* @__PURE__ */ new Map();
178
182
  function importLibrary(key) {
179
183
  if (libraries.has(key))
180
184
  return libraries.get(key);
181
- const p = mapsApi.value?.importLibrary(key) || new Promise((resolve) => {
182
- const stop = watch(mapsApi, (api) => {
185
+ const p = createAbortablePromise((resolve, reject) => {
186
+ let stop = () => {
187
+ };
188
+ stop = watch(mapsApi, (api) => {
183
189
  if (api) {
184
- const p2 = api.importLibrary(key);
185
- resolve(p2);
186
- stop();
190
+ try {
191
+ resolve(api.importLibrary(key));
192
+ } catch (error) {
193
+ reject(error);
194
+ }
187
195
  }
188
196
  }, { immediate: true });
197
+ return () => stop();
198
+ }, {
199
+ signal: lifecycleController.signal,
200
+ abortMessage: `Google Maps library import "${key}" was aborted`
189
201
  });
190
202
  const cached = Promise.resolve(p).catch((err) => {
191
203
  libraries.delete(key);
@@ -251,13 +263,15 @@ onMounted(() => {
251
263
  const zoom = map.value.getZoom();
252
264
  if (center)
253
265
  centerOverride.value = { lat: center.lat(), lng: center.lng() };
254
- map.value.unbindAll();
266
+ const previousMap = map.value;
267
+ mapsApi.value.event.clearInstanceListeners(previousMap);
268
+ previousMap.unbindAll();
255
269
  map.value = void 0;
256
270
  slotMounted.value = false;
257
271
  if (mapEl.value)
258
272
  mapEl.value.innerHTML = "";
259
273
  await nextTick();
260
- if (!mapEl.value || !mapsApi.value)
274
+ if (isUnmounted || !mapEl.value || !mapsApi.value)
261
275
  return;
262
276
  const _options = {
263
277
  ...options.value,
@@ -276,40 +290,66 @@ onMounted(() => {
276
290
  watch([() => getCenterWatchKey(props.center), () => getCenterWatchKey(props.mapOptions?.center)], () => {
277
291
  centerOverride.value = void 0;
278
292
  });
279
- watch([controlledCenterKey, isMapReady, map], async () => {
280
- if (!map.value) {
293
+ watch([controlledCenterKey, isMapReady, map], async (_, __, onCleanup) => {
294
+ const currentMap = map.value;
295
+ if (!currentMap) {
281
296
  return;
282
297
  }
298
+ let stale = false;
299
+ onCleanup(() => {
300
+ stale = true;
301
+ });
283
302
  let center = toRaw(options.value.center);
284
303
  if (center) {
285
304
  if (isLocationQuery(center) && isMapReady.value) {
286
- center = await resolveQueryToLatLng(center);
305
+ try {
306
+ center = await resolveQueryToLatLng(center);
307
+ } catch (error) {
308
+ if (error?.name === "AbortError")
309
+ return;
310
+ throw error;
311
+ }
287
312
  }
288
- const current = map.value.getCenter();
313
+ if (stale || isUnmounted || map.value !== currentMap)
314
+ return;
315
+ const current = currentMap.getCenter();
289
316
  if (current) {
290
317
  const newLat = typeof center.lat === "function" ? center.lat() : center.lat;
291
318
  const newLng = typeof center.lng === "function" ? center.lng() : center.lng;
292
319
  if (current.lat() === newLat && current.lng() === newLng)
293
320
  return;
294
321
  }
295
- map.value.setCenter(center);
322
+ currentMap.setCenter(center);
296
323
  }
297
324
  }, {
298
325
  immediate: true
299
326
  });
300
327
  onLoaded(async (instance) => {
301
- mapsApi.value = await instance.maps;
328
+ const api = await instance.maps;
329
+ if (isUnmounted || !mapEl.value)
330
+ return;
331
+ mapsApi.value = api;
302
332
  const center = options.value.center;
303
333
  const _options = {
304
334
  ...options.value,
305
335
  // @ts-expect-error broken
306
336
  center: !center || isLocationQuery(center) ? void 0 : center
307
337
  };
308
- map.value = new mapsApi.value.Map(mapEl.value, _options);
338
+ map.value = new api.Map(mapEl.value, _options);
309
339
  if (center && isLocationQuery(center)) {
310
- centerOverride.value = await resolveQueryToLatLng(center);
311
- if (centerOverride.value)
312
- map.value?.setCenter(centerOverride.value);
340
+ let resolvedCenter;
341
+ try {
342
+ resolvedCenter = await resolveQueryToLatLng(center);
343
+ } catch (error) {
344
+ if (error?.name === "AbortError")
345
+ return;
346
+ throw error;
347
+ }
348
+ if (isUnmounted)
349
+ return;
350
+ centerOverride.value = resolvedCenter;
351
+ if (resolvedCenter)
352
+ map.value?.setCenter(resolvedCenter);
313
353
  }
314
354
  isMapReady.value = true;
315
355
  });
@@ -356,11 +396,21 @@ const rootAttrs = computed(() => {
356
396
  });
357
397
  });
358
398
  onBeforeUnmount(() => {
359
- map.value?.unbindAll();
399
+ isUnmounted = true;
400
+ lifecycleController.abort();
401
+ if (map.value && mapsApi.value) {
402
+ mapsApi.value.event.clearInstanceListeners(map.value);
403
+ map.value.unbindAll();
404
+ }
360
405
  map.value = void 0;
406
+ activeInfoWindow?.close();
407
+ activeInfoWindow = void 0;
361
408
  libraries.clear();
362
409
  queryToLatLngCache.clear();
363
410
  });
411
+ onUnmounted(() => {
412
+ mapsApi.value = void 0;
413
+ });
364
414
  </script>
365
415
 
366
416
  <template>
@@ -69,11 +69,12 @@ export declare function warnDeprecatedTopLevelMapProps(props: {
69
69
  * Runs the watcher inside a detached effect scope so it is safe to call from
70
70
  * any context (component setup, exposed methods, tests).
71
71
  */
72
- export declare function waitForMapsReady({ mapsApi, map, status, load, }: {
72
+ export declare function waitForMapsReady({ mapsApi, map, status, load, signal, }: {
73
73
  mapsApi: ShallowRef<typeof google.maps | undefined>;
74
74
  map: ShallowRef<google.maps.Map | undefined>;
75
75
  status: Ref<string>;
76
76
  load: () => Promise<unknown> | unknown;
77
+ signal?: AbortSignal;
77
78
  }): Promise<void>;
78
79
  /**
79
80
  * Composable for safely managing Google Maps resource lifecycle.
@@ -1,5 +1,6 @@
1
1
  import { whenever } from "@vueuse/core";
2
2
  import { effectScope, inject, onUnmounted, ref, shallowRef, watch } from "vue";
3
+ import { createAbortablePromise, createAbortError } from "../../utils/abortable-promise.js";
3
4
  export const MAP_INJECTION_KEY = Symbol("map");
4
5
  export const MARKER_INJECTION_KEY = Symbol("marker");
5
6
  export function bindGoogleMapsEvents(instance, emit, config) {
@@ -52,38 +53,45 @@ export async function waitForMapsReady({
52
53
  mapsApi,
53
54
  map,
54
55
  status,
55
- load
56
+ load,
57
+ signal
56
58
  }) {
59
+ const abortMessage = "Google Maps readiness wait was aborted";
60
+ const throwIfAborted = () => {
61
+ if (signal?.aborted)
62
+ throw createAbortError(abortMessage);
63
+ };
64
+ throwIfAborted();
57
65
  if (mapsApi.value && map.value)
58
66
  return;
59
67
  if (status.value === "error")
60
68
  throw new Error("Google Maps script failed to load");
61
- await load();
69
+ await createAbortablePromise((resolve, reject) => {
70
+ Promise.resolve(load()).then(() => resolve(), reject);
71
+ }, { signal, abortMessage });
72
+ throwIfAborted();
62
73
  if (mapsApi.value && map.value)
63
74
  return;
64
75
  if (status.value === "error")
65
76
  throw new Error("Google Maps script failed to load");
66
77
  const scope = effectScope(true);
67
- try {
68
- await new Promise((resolve, reject) => {
69
- scope.run(() => {
70
- watch(
71
- [mapsApi, map, status],
72
- ([api, m, s]) => {
73
- if (api && m) {
74
- resolve();
75
- return;
76
- }
77
- if (s === "error")
78
- reject(new Error("Google Maps script failed to load"));
79
- },
80
- { immediate: true }
81
- );
82
- });
78
+ await createAbortablePromise((resolve, reject) => {
79
+ scope.run(() => {
80
+ watch(
81
+ [mapsApi, map, status],
82
+ ([api, m, s]) => {
83
+ if (api && m) {
84
+ resolve();
85
+ return;
86
+ }
87
+ if (s === "error")
88
+ reject(new Error("Google Maps script failed to load"));
89
+ },
90
+ { immediate: true }
91
+ );
83
92
  });
84
- } finally {
85
- scope.stop();
86
- }
93
+ return () => scope.stop();
94
+ }, { signal, abortMessage });
87
95
  }
88
96
  export function useGoogleMapsResource({
89
97
  ready,
@@ -96,10 +104,16 @@ export function useGoogleMapsResource({
96
104
  whenever(
97
105
  () => mapContext?.map.value && mapContext.mapsApi.value && (!ready || ready()),
98
106
  () => {
99
- Promise.resolve(create({
100
- map: mapContext.map.value,
101
- mapsApi: mapContext.mapsApi.value
102
- })).then((result) => {
107
+ let creation;
108
+ try {
109
+ creation = Promise.resolve(create({
110
+ map: mapContext.map.value,
111
+ mapsApi: mapContext.mapsApi.value
112
+ }));
113
+ } catch (error) {
114
+ creation = Promise.reject(error);
115
+ }
116
+ creation.then((result) => {
103
117
  if (isUnmounted.value) {
104
118
  if (cleanup && mapContext?.mapsApi.value) {
105
119
  cleanup(result, { mapsApi: mapContext.mapsApi.value });
@@ -13,12 +13,14 @@ defineSlots();
13
13
  const attrId = `_carbonads_js`;
14
14
  const carbonadsEl = ref(import.meta.client ? document.getElementById(attrId) : null);
15
15
  const status = ref("awaitingLoad");
16
+ let scriptEl;
16
17
  function loadCarbon() {
17
18
  if (!carbonadsEl.value) {
18
19
  return;
19
20
  }
20
21
  status.value = "loading";
21
22
  const script = document.createElement("script");
23
+ scriptEl = script;
22
24
  script.setAttribute("src", withQuery("https://cdn.carbonads.com/carbon.js", {
23
25
  serve: props.serve,
24
26
  placement: props.placement,
@@ -44,7 +46,10 @@ onMounted(() => {
44
46
  if (trigger === "onNuxtReady") {
45
47
  loadCarbon();
46
48
  } else {
47
- trigger.then(loadCarbon);
49
+ trigger.then((triggered) => {
50
+ if (triggered)
51
+ loadCarbon();
52
+ });
48
53
  }
49
54
  });
50
55
  const rootAttrs = computed(() => {
@@ -53,8 +58,11 @@ const rootAttrs = computed(() => {
53
58
  };
54
59
  });
55
60
  onBeforeUnmount(() => {
56
- if (carbonadsEl.value) {
57
- carbonadsEl.value.remove();
61
+ if (scriptEl) {
62
+ scriptEl.onload = null;
63
+ scriptEl.onerror = null;
64
+ scriptEl.remove();
65
+ scriptEl = void 0;
58
66
  }
59
67
  });
60
68
  </script>
@@ -38,11 +38,13 @@ let observer;
38
38
  onMounted(() => {
39
39
  watch(status, (status2) => {
40
40
  if (status2 === "loaded") {
41
+ observer?.disconnect();
41
42
  observer = new MutationObserver(() => {
42
43
  if (document.getElementById("crisp-chatbox")) {
43
44
  isReady.value = true;
44
45
  emits("ready", crisp);
45
- observer.disconnect();
46
+ observer?.disconnect();
47
+ observer = void 0;
46
48
  }
47
49
  });
48
50
  observer.observe(document.body, { childList: true, subtree: true });
@@ -53,6 +55,7 @@ onMounted(() => {
53
55
  });
54
56
  onBeforeUnmount(() => {
55
57
  observer?.disconnect();
58
+ observer = void 0;
56
59
  });
57
60
  const rootAttrs = computed(() => {
58
61
  return {
@@ -45,11 +45,13 @@ let observer;
45
45
  onMounted(() => {
46
46
  watch(status, (status2) => {
47
47
  if (status2 === "loading") {
48
+ observer?.disconnect();
48
49
  observer = new MutationObserver(() => {
49
50
  if (document.getElementById("intercom-frame")) {
50
51
  isReady.value = true;
51
52
  emits("ready", intercom);
52
- observer.disconnect();
53
+ observer?.disconnect();
54
+ observer = void 0;
53
55
  }
54
56
  });
55
57
  observer.observe(document.body, { childList: true, subtree: true });
@@ -60,6 +62,7 @@ onMounted(() => {
60
62
  });
61
63
  onBeforeUnmount(() => {
62
64
  observer?.disconnect();
65
+ observer = void 0;
63
66
  });
64
67
  const rootAttrs = computed(() => {
65
68
  return {
@@ -1,22 +1,22 @@
1
1
  import type { ElementScriptTrigger } from '../types.js';
2
- type __VLS_Props = {
2
+ import type { LemonSqueezyApi } from '../registry/lemon-squeezy.js';
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
5
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
3
6
  trigger?: ElementScriptTrigger;
4
- };
5
- type __VLS_Slots = {
6
- default?: () => any;
7
- };
8
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- ready: (args_0: import("../types.js").UseScriptContext<import("../registry/lemon-squeezy.js").LemonSqueezyApi>) => any;
7
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ ready: (args_0: import("../types.js").UseScriptContext<LemonSqueezyApi>) => any;
10
9
  lemonSqueezyEvent: (args_0: never) => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
- onReady?: ((args_0: import("../types.js").UseScriptContext<import("../registry/lemon-squeezy.js").LemonSqueezyApi>) => any) | undefined;
10
+ }, string, import("vue").PublicProps, Readonly<{
11
+ trigger?: ElementScriptTrigger;
12
+ }> & Readonly<{
13
+ onReady?: ((args_0: import("../types.js").UseScriptContext<LemonSqueezyApi>) => any) | undefined;
13
14
  onLemonSqueezyEvent?: ((args_0: never) => any) | undefined;
14
15
  }>, {
15
16
  trigger: ElementScriptTrigger;
16
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
18
- declare const _default: typeof __VLS_export;
19
- export default _default;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
18
+ default?: () => any;
19
+ }>;
20
20
  type __VLS_WithSlots<T, S> = T & {
21
21
  new (): {
22
22
  $slots: S;
@@ -1,5 +1,25 @@
1
+ <script>
2
+ const lemonSqueezyHandlers = /* @__PURE__ */ new Map();
3
+ const dispatchLemonSqueezyEvent = (event) => {
4
+ for (const handler of [...lemonSqueezyHandlers.values()])
5
+ handler(event);
6
+ };
7
+ function registerLemonSqueezyHandler(owner, handler, setup) {
8
+ lemonSqueezyHandlers.set(owner, handler);
9
+ setup({ eventHandler: dispatchLemonSqueezyEvent });
10
+ }
11
+ function unregisterLemonSqueezyHandler(owner) {
12
+ const removed = lemonSqueezyHandlers.delete(owner);
13
+ if (!removed || lemonSqueezyHandlers.size > 0)
14
+ return;
15
+ if (import.meta.client && typeof window.LemonSqueezy?.Setup === "function")
16
+ window.LemonSqueezy.Setup({ eventHandler() {
17
+ } });
18
+ }
19
+ </script>
20
+
1
21
  <script setup>
2
- import { computed, onMounted, ref } from "vue";
22
+ import { computed, onBeforeUnmount, onMounted, ref } from "vue";
3
23
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
4
24
  import { useScriptLemonSqueezy } from "../registry/lemon-squeezy";
5
25
  const props = defineProps({
@@ -8,6 +28,8 @@ const props = defineProps({
8
28
  const emits = defineEmits(["ready", "lemonSqueezyEvent"]);
9
29
  defineSlots();
10
30
  const rootEl = ref(null);
31
+ const owner = /* @__PURE__ */ Symbol("ScriptLemonSqueezy");
32
+ let disposed = false;
11
33
  const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
12
34
  const instance = useScriptLemonSqueezy({
13
35
  scriptOptions: {
@@ -19,15 +41,17 @@ onMounted(() => {
19
41
  a.classList.add("lemonsqueezy-button");
20
42
  });
21
43
  instance.onLoaded(({ Setup, Refresh }) => {
22
- Setup({
23
- eventHandler(event) {
24
- emits("lemonSqueezyEvent", event);
25
- }
26
- });
44
+ if (disposed)
45
+ return;
46
+ registerLemonSqueezyHandler(owner, (event) => emits("lemonSqueezyEvent", event), Setup);
27
47
  Refresh();
28
48
  emits("ready", instance);
29
49
  });
30
50
  });
51
+ onBeforeUnmount(() => {
52
+ disposed = true;
53
+ unregisterLemonSqueezyHandler(owner);
54
+ });
31
55
  const rootAttrs = computed(() => {
32
56
  return {
33
57
  ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
@@ -1,22 +1,22 @@
1
1
  import type { ElementScriptTrigger } from '../types.js';
2
- type __VLS_Props = {
2
+ import type { LemonSqueezyApi } from '../registry/lemon-squeezy.js';
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
5
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
3
6
  trigger?: ElementScriptTrigger;
4
- };
5
- type __VLS_Slots = {
6
- default?: () => any;
7
- };
8
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- ready: (args_0: import("../types.js").UseScriptContext<import("../registry/lemon-squeezy.js").LemonSqueezyApi>) => any;
7
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ ready: (args_0: import("../types.js").UseScriptContext<LemonSqueezyApi>) => any;
10
9
  lemonSqueezyEvent: (args_0: never) => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
- onReady?: ((args_0: import("../types.js").UseScriptContext<import("../registry/lemon-squeezy.js").LemonSqueezyApi>) => any) | undefined;
10
+ }, string, import("vue").PublicProps, Readonly<{
11
+ trigger?: ElementScriptTrigger;
12
+ }> & Readonly<{
13
+ onReady?: ((args_0: import("../types.js").UseScriptContext<LemonSqueezyApi>) => any) | undefined;
13
14
  onLemonSqueezyEvent?: ((args_0: never) => any) | undefined;
14
15
  }>, {
15
16
  trigger: ElementScriptTrigger;
16
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
18
- declare const _default: typeof __VLS_export;
19
- export default _default;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
18
+ default?: () => any;
19
+ }>;
20
20
  type __VLS_WithSlots<T, S> = T & {
21
21
  new (): {
22
22
  $slots: S;
@@ -22,6 +22,7 @@ const rootEl = ref(null);
22
22
  const ready = ref(false);
23
23
  const failed = ref(false);
24
24
  const sdkInstance = shallowRef();
25
+ let disposed = false;
25
26
  const { onLoaded, status } = useScriptPayPal({
26
27
  ...props.clientToken ? { clientToken: props.clientToken } : { clientId: props.clientId },
27
28
  ...props.paypalScriptOptions
@@ -39,10 +40,15 @@ onMounted(() => {
39
40
  ...props.partnerAttributionId && { partnerAttributionId: props.partnerAttributionId }
40
41
  };
41
42
  try {
42
- sdkInstance.value = await paypal.createInstance(instanceOptions);
43
+ const instance = await paypal.createInstance(instanceOptions);
44
+ if (disposed)
45
+ return;
46
+ sdkInstance.value = instance;
43
47
  ready.value = true;
44
48
  emit("ready", sdkInstance.value);
45
49
  } catch (err) {
50
+ if (disposed)
51
+ return;
46
52
  sdkInstance.value = void 0;
47
53
  failed.value = true;
48
54
  emit("error", err);
@@ -50,6 +56,7 @@ onMounted(() => {
50
56
  });
51
57
  });
52
58
  onBeforeUnmount(() => {
59
+ disposed = true;
53
60
  sdkInstance.value = void 0;
54
61
  });
55
62
  defineExpose({
@@ -22,6 +22,7 @@ const rootEl = ref(null);
22
22
  const ready = ref(false);
23
23
  const failed = ref(false);
24
24
  const messagesSession = shallowRef();
25
+ let disposed = false;
25
26
  const { onLoaded, status } = useScriptPayPal({
26
27
  ...props.clientToken ? { clientToken: props.clientToken } : { clientId: props.clientId },
27
28
  ...props.paypalScriptOptions
@@ -41,10 +42,14 @@ onMounted(() => {
41
42
  };
42
43
  try {
43
44
  const instance = await paypal.createInstance(instanceOptions);
45
+ if (disposed)
46
+ return;
44
47
  messagesSession.value = instance.createPayPalMessages(props.messagesOptions);
45
48
  ready.value = true;
46
49
  emit("ready", messagesSession.value);
47
50
  } catch (err) {
51
+ if (disposed)
52
+ return;
48
53
  messagesSession.value = void 0;
49
54
  failed.value = true;
50
55
  emit("error", err);
@@ -52,6 +57,7 @@ onMounted(() => {
52
57
  });
53
58
  });
54
59
  onBeforeUnmount(() => {
60
+ disposed = true;
55
61
  messagesSession.value = void 0;
56
62
  });
57
63
  defineExpose({
@@ -22,6 +22,8 @@ const { onLoaded, status } = instance;
22
22
  const pricingTable = ref();
23
23
  onMounted(() => {
24
24
  onLoaded(() => {
25
+ if (!rootEl.value)
26
+ return;
25
27
  const StripePricingTable = window.customElements.get("stripe-pricing-table");
26
28
  const stripePricingTable = new StripePricingTable();
27
29
  stripePricingTable.setAttribute("publishable-key", props.publishableKey);
@@ -205,7 +205,14 @@ const placeholderAttrs = computed(() => {
205
205
  }
206
206
  });
207
207
  });
208
- onBeforeUnmount(() => player?.unload());
208
+ onBeforeUnmount(() => {
209
+ const currentPlayer = player;
210
+ player = void 0;
211
+ void currentPlayer?.destroy().catch((error) => {
212
+ if (import.meta.dev)
213
+ console.warn("[nuxt-scripts] Vimeo player cleanup failed:", error);
214
+ });
215
+ });
209
216
  </script>
210
217
 
211
218
  <template>