@nuxt/scripts 0.1.12 → 0.3.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 (151) hide show
  1. package/README.md +10 -200
  2. package/dist/client/200.html +63 -54
  3. package/dist/client/404.html +63 -54
  4. package/dist/client/_nuxt/8T3kBMJO.js +31 -0
  5. package/dist/client/_nuxt/B5NHDIr7.js +353 -0
  6. package/dist/client/_nuxt/{Bz4xi2rU.js → B6ZnTe72.js} +1 -1
  7. package/dist/client/_nuxt/{B6nY7VDA.js → B6bHXiXE.js} +1 -1
  8. package/dist/client/_nuxt/BAMIS8DD.js +1 -0
  9. package/dist/client/_nuxt/{A1WiD9SJ.js → BGq4KZyx.js} +1 -1
  10. package/dist/client/_nuxt/BVGdgKAv.js +1 -0
  11. package/dist/client/_nuxt/{wORFcijT.js → BXR915QZ.js} +1 -1
  12. package/dist/client/_nuxt/{DCj4DH6i.js → BYdKNJ10.js} +1 -1
  13. package/dist/client/_nuxt/BZfs-ost.js +1 -0
  14. package/dist/client/_nuxt/{DCdPDLy4.js → BacI6-DX.js} +1 -1
  15. package/dist/client/_nuxt/{DCk2z-Tu.js → BdfWgkoX.js} +1 -1
  16. package/dist/client/_nuxt/BscxmKrE.js +8 -0
  17. package/dist/client/_nuxt/C3qJFuQy.js +3 -0
  18. package/dist/client/_nuxt/C6XIsc4F.js +1 -0
  19. package/dist/client/_nuxt/C9UBdavN.js +1 -0
  20. package/dist/client/_nuxt/CA9nliXM.js +1 -0
  21. package/dist/client/_nuxt/CDJL3WWm.js +1 -0
  22. package/dist/client/_nuxt/{BsfQk1vf.js → CEfge3mM.js} +1 -1
  23. package/dist/client/_nuxt/{CQTpvb7m.js → CHCTrc3a.js} +1 -1
  24. package/dist/client/_nuxt/{DZ3fVoEH.js → CSPeAESR.js} +1 -1
  25. package/dist/client/_nuxt/CX2EUjC8.js +301 -0
  26. package/dist/client/_nuxt/{DCAtC51B.js → CarfVElc.js} +1 -1
  27. package/dist/client/_nuxt/{BgBwMnrY.js → CcYwH0AH.js} +1 -1
  28. package/dist/client/_nuxt/Cgl53LJQ.js +1 -0
  29. package/dist/client/_nuxt/{RgJsN3zu.js → ChMCFiS0.js} +1 -1
  30. package/dist/client/_nuxt/{CW3w6uup.js → CovTDKFE.js} +1 -1
  31. package/dist/client/_nuxt/{DfUNg_8t.js → CqYeW6XZ.js} +1 -1
  32. package/dist/client/_nuxt/{CL7Ixq1B.js → CrgTADc5.js} +1 -1
  33. package/dist/client/_nuxt/CuJfdYLG.js +1 -0
  34. package/dist/client/_nuxt/CudBhkk3.js +1 -0
  35. package/dist/client/_nuxt/D71BffLY.js +1 -0
  36. package/dist/client/_nuxt/{7fd6vGzb.js → DBeuZS66.js} +1 -1
  37. package/dist/client/_nuxt/{Bd7iooY8.js → DGDuLtS6.js} +1 -1
  38. package/dist/client/_nuxt/{j8KhMG0x.js → DGxQkqYo.js} +1 -1
  39. package/dist/client/_nuxt/DIt5FBMJ.js +1 -0
  40. package/dist/client/_nuxt/DOakR0z3.js +1 -0
  41. package/dist/client/_nuxt/{CUVblut_.js → DR5YgmI2.js} +1 -1
  42. package/dist/client/_nuxt/DS9ZWoKD.js +1 -0
  43. package/dist/client/_nuxt/{D-pQtGOP.js → DVLwECkk.js} +1 -1
  44. package/dist/client/_nuxt/DZLoTQm4.js +1 -0
  45. package/dist/client/_nuxt/{ZQC2c-5V.js → D_T9yQUo.js} +3 -3
  46. package/dist/client/_nuxt/Db2-y2xY.js +1 -0
  47. package/dist/client/_nuxt/{CRWwmX0L.js → Di3qjVs2.js} +1 -1
  48. package/dist/client/_nuxt/{DXpYegZJ.js → Djqq6n-7.js} +1 -1
  49. package/dist/client/_nuxt/Dkb1Nx48.js +1 -0
  50. package/dist/client/_nuxt/{BBv1LFm6.js → DtT2Dbx_.js} +1 -1
  51. package/dist/client/_nuxt/{DywwDckn.js → Du6_OKDb.js} +1 -1
  52. package/dist/client/_nuxt/{IHMnEr_d.js → G-Jz5hiA.js} +1 -1
  53. package/dist/client/_nuxt/HrnDn_2Q.js +1 -0
  54. package/dist/client/_nuxt/{CPHkTjfH.js → JgH_6NEN.js} +1 -1
  55. package/dist/client/_nuxt/Ksn5IXup.js +1 -0
  56. package/dist/client/_nuxt/{wPLeKH6q.js → Lpdzc9s2.js} +1 -1
  57. package/dist/client/_nuxt/{DggdVF2v.js → V_y36BGi.js} +1 -1
  58. package/dist/client/_nuxt/{BILqrcpa.js → YdT6Gj0u.js} +1 -1
  59. package/dist/client/_nuxt/alpzPJ78.js +1 -0
  60. package/dist/client/_nuxt/builds/latest.json +1 -1
  61. package/dist/client/_nuxt/builds/meta/ccc94de9-89fa-400b-88f2-8fc2599e191f.json +1 -0
  62. package/dist/client/_nuxt/{Bdb36Id5.js → dIHJ9UdL.js} +1 -1
  63. package/dist/client/_nuxt/error-404.BRldFSII.css +1 -0
  64. package/dist/client/_nuxt/error-500.D8yw_IbC.css +1 -0
  65. package/dist/client/_nuxt/o5b8QYQO.js +3 -0
  66. package/dist/client/_nuxt/{doGI2cFk.js → wKgfcFVx.js} +1 -1
  67. package/dist/client/index.html +63 -54
  68. package/dist/module.d.mts +2 -6
  69. package/dist/module.d.ts +2 -6
  70. package/dist/module.json +6 -2
  71. package/dist/module.mjs +68 -137
  72. package/dist/registry.d.mts +13 -0
  73. package/dist/registry.d.ts +13 -0
  74. package/dist/registry.mjs +214 -0
  75. package/dist/runtime/components/GoogleMaps.vue +130 -0
  76. package/dist/runtime/components/LemonSqueezyButton.vue +28 -0
  77. package/dist/runtime/components/StripePricingTableEmbed.vue +33 -0
  78. package/dist/runtime/components/VimeoEmbed.vue +161 -0
  79. package/dist/runtime/components/YouTubeEmbed.vue +79 -0
  80. package/dist/runtime/composables/createConsentScriptTrigger.d.ts +6 -0
  81. package/dist/runtime/composables/{createScriptConsentTrigger.mjs → createConsentScriptTrigger.mjs} +1 -1
  82. package/dist/runtime/composables/useAnalyticsPageEvent.d.ts +4 -1
  83. package/dist/runtime/composables/useElementScriptTrigger.d.ts +3 -0
  84. package/dist/runtime/composables/useElementScriptTrigger.mjs +9 -0
  85. package/dist/runtime/composables/useScript.d.ts +2 -2
  86. package/dist/runtime/composables/useScript.mjs +1 -2
  87. package/dist/runtime/registry/cloudflare-web-analytics.d.ts +11 -7
  88. package/dist/runtime/registry/cloudflare-web-analytics.mjs +16 -18
  89. package/dist/runtime/registry/facebook-pixel.d.ts +6 -5
  90. package/dist/runtime/registry/facebook-pixel.mjs +15 -17
  91. package/dist/runtime/registry/fathom-analytics.d.ts +39 -14
  92. package/dist/runtime/registry/fathom-analytics.mjs +40 -21
  93. package/dist/runtime/registry/google-analytics.d.ts +21 -1
  94. package/dist/runtime/registry/google-analytics.mjs +30 -3
  95. package/dist/runtime/registry/google-maps.d.ts +23 -1
  96. package/dist/runtime/registry/google-maps.mjs +40 -3
  97. package/dist/runtime/registry/google-tag-manager.d.ts +21 -1
  98. package/dist/runtime/registry/google-tag-manager.mjs +29 -3
  99. package/dist/runtime/registry/hotjar.d.ts +5 -3
  100. package/dist/runtime/registry/hotjar.mjs +14 -18
  101. package/dist/runtime/registry/intercom.d.ts +5 -3
  102. package/dist/runtime/registry/intercom.mjs +19 -16
  103. package/dist/runtime/registry/lemon-squeezy.d.ts +68 -0
  104. package/dist/runtime/registry/lemon-squeezy.mjs +21 -0
  105. package/dist/runtime/registry/matomo-analytics.d.ts +24 -0
  106. package/dist/runtime/registry/matomo-analytics.mjs +33 -0
  107. package/dist/runtime/registry/npm.d.ts +7 -3
  108. package/dist/runtime/registry/npm.mjs +10 -11
  109. package/dist/runtime/registry/plausible-analytics.d.ts +22 -0
  110. package/dist/runtime/registry/plausible-analytics.mjs +35 -0
  111. package/dist/runtime/registry/segment.d.ts +5 -3
  112. package/dist/runtime/registry/segment.mjs +34 -34
  113. package/dist/runtime/registry/stripe.d.ts +18 -0
  114. package/dist/runtime/registry/stripe.mjs +27 -0
  115. package/dist/runtime/registry/vimeo-player.d.ts +15 -0
  116. package/dist/runtime/registry/vimeo-player.mjs +45 -0
  117. package/dist/runtime/registry/x-pixel.d.ts +41 -0
  118. package/dist/runtime/registry/x-pixel.mjs +28 -0
  119. package/dist/runtime/registry/youtube-iframe.d.ts +15 -0
  120. package/dist/runtime/registry/youtube-iframe.mjs +54 -0
  121. package/dist/runtime/types.d.ts +31 -17
  122. package/dist/runtime/utils.d.ts +16 -1
  123. package/dist/runtime/utils.mjs +30 -1
  124. package/package.json +40 -25
  125. package/dist/client/_nuxt/BG_OyJVq.js +0 -1
  126. package/dist/client/_nuxt/BIMuYTWL.js +0 -3
  127. package/dist/client/_nuxt/BSyl5yf0.js +0 -1
  128. package/dist/client/_nuxt/BswfO-CF.js +0 -1
  129. package/dist/client/_nuxt/C3YqBJkQ.js +0 -1
  130. package/dist/client/_nuxt/CGQbO34C.js +0 -1
  131. package/dist/client/_nuxt/CKtB_0Vj.js +0 -36
  132. package/dist/client/_nuxt/CrjQeCwm.js +0 -1
  133. package/dist/client/_nuxt/D4LhxNOI.js +0 -1
  134. package/dist/client/_nuxt/D4k753MY.js +0 -1
  135. package/dist/client/_nuxt/D75a3hZQ.js +0 -1
  136. package/dist/client/_nuxt/DnhXxWz-.js +0 -1
  137. package/dist/client/_nuxt/DzPyIVdT.js +0 -9
  138. package/dist/client/_nuxt/TQ9oWRfF.js +0 -1
  139. package/dist/client/_nuxt/WoBtJUue.js +0 -1
  140. package/dist/client/_nuxt/bmJ2objS.js +0 -1
  141. package/dist/client/_nuxt/builds/meta/7bb27f9d-e4a9-494c-83a3-01bc2df7d17d.json +0 -1
  142. package/dist/client/_nuxt/error-404.ORekjfyJ.css +0 -1
  143. package/dist/client/_nuxt/error-500.BIuFL0tW.css +0 -1
  144. package/dist/client/_nuxt/yr0V4Txy.js +0 -1
  145. package/dist/runtime/composables/createScriptConsentTrigger.d.ts +0 -6
  146. package/dist/runtime/composables/validateScriptInputSchema.d.ts +0 -2
  147. package/dist/runtime/composables/validateScriptInputSchema.mjs +0 -14
  148. package/dist/runtime/registry/cloudflare-turnstile.d.ts +0 -1
  149. package/dist/runtime/registry/cloudflare-turnstile.mjs +0 -4
  150. package/dist/runtime/registry/confetti.d.ts +0 -23
  151. package/dist/runtime/registry/confetti.mjs +0 -15
@@ -0,0 +1,79 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, watch } from 'vue'
3
+ import type YT from 'youtube'
4
+ import type { ElementScriptTrigger } from '../composables/useElementScriptTrigger'
5
+ import { useElementScriptTrigger, useScriptYouTubeIframe } from '#imports'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ trigger?: ElementScriptTrigger
9
+ videoId: string
10
+ playerVars?: YT.PlayerVars
11
+ width?: number
12
+ height?: number
13
+ }>(), {
14
+ playerVars: { autoplay: 1, playsinline: 1 },
15
+ width: 640,
16
+ height: 480,
17
+ })
18
+
19
+ const emits = defineEmits<{
20
+ onReady: [e: YT.PlayerEvent]
21
+ onStateChange: [e: YT.PlayerEvent]
22
+ onPlaybackQualityChange: [e: YT.PlayerEvent]
23
+ onPlaybackRateChange: [e: YT.PlayerEvent]
24
+ onError: [e: YT.PlayerEvent]
25
+ onApiChange: [e: YT.PlayerEvent]
26
+ }>()
27
+ const events: (keyof YT.Events)[] = [
28
+ 'onReady',
29
+ 'onStateChange',
30
+ 'onPlaybackQualityChange',
31
+ 'onPlaybackRateChange',
32
+ 'onError',
33
+ 'onApiChange',
34
+ ]
35
+ const elYoutube = ref()
36
+
37
+ const ready = ref(false)
38
+ const { $script } = useScriptYouTubeIframe({
39
+ scriptOptions: {
40
+ trigger: useElementScriptTrigger(props.trigger, elYoutube.value),
41
+ },
42
+ })
43
+
44
+ let player: YT.Player
45
+ $script.then(async (instance) => {
46
+ const YT = await instance.YT
47
+ await new Promise<void>((resolve) => {
48
+ if (typeof YT.Player === 'undefined')
49
+ YT.ready(resolve)
50
+ else
51
+ resolve()
52
+ })
53
+ player = new YT.Player(elYoutube.value, {
54
+ ...props,
55
+ events: Object.fromEntries(events.map(event => [event, (e: any) => {
56
+ // @ts-expect-error untyped
57
+ emits(event, e)
58
+ }])),
59
+ })
60
+ })
61
+
62
+ defineExpose({
63
+ player,
64
+ })
65
+
66
+ watch(() => props.videoId, () => {
67
+ player?.loadVideoById(props.videoId)
68
+ })
69
+
70
+ const poster = computed(() => `https://i.ytimg.com/vi_webp/${props.videoId}/sddefault.webp`)
71
+ </script>
72
+
73
+ <template>
74
+ <div ref="elYoutube" :style="{ width: `${width}px`, height: `${height}px`, position: 'relative' }">
75
+ <slot :poster="poster">
76
+ <img v-if="!ready" :src="poster" title="" :width="width" :height="height">
77
+ </slot>
78
+ </div>
79
+ </template>
@@ -0,0 +1,6 @@
1
+ import type { ConsentPromiseOptions } from '../types';
2
+ type CreateConsentScriptTriggerApi = {
3
+ accept: () => void;
4
+ } & Promise<void>;
5
+ export declare function createConsentScriptTrigger(options?: ConsentPromiseOptions): CreateConsentScriptTriggerApi;
6
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { isRef, onNuxtReady, ref, requestIdleCallback, toValue, tryUseNuxtApp, watch } from "#imports";
2
- export function createScriptConsentTrigger(options) {
2
+ export function createConsentScriptTrigger(options) {
3
3
  if (import.meta.server)
4
4
  return new Promise(() => {
5
5
  });
@@ -1,2 +1,5 @@
1
1
  import type { TrackedPage } from '#nuxt-scripts';
2
- export declare function useAnalyticsPageEvent(onChange?: (payload: TrackedPage) => void): any;
2
+ export declare function useAnalyticsPageEvent(onChange?: (payload: TrackedPage) => void): import("#imports").Ref<{
3
+ title?: string | undefined;
4
+ path: string;
5
+ }>;
@@ -0,0 +1,3 @@
1
+ import type { Ref } from 'vue';
2
+ export type ElementScriptTrigger = 'visible' | 'mouseover' | false;
3
+ export declare function useElementScriptTrigger(trigger: ElementScriptTrigger | undefined, el?: HTMLElement | Ref<HTMLElement | undefined> | null): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { useElementHover, useElementVisibility, watchOnce } from "@vueuse/core";
2
+ import { ref } from "vue";
3
+ export function useElementScriptTrigger(trigger, el) {
4
+ if (import.meta.server || !el)
5
+ return new Promise(() => {
6
+ });
7
+ const activeRef = trigger ? trigger === "mouseover" ? useElementHover(el) : useElementVisibility(el) : ref(false);
8
+ return trigger ? new Promise((resolve) => watchOnce([activeRef], () => resolve())) : Promise.resolve();
9
+ }
@@ -1,5 +1,5 @@
1
1
  import { type UseScriptInput, type VueScriptInstance } from '@unhead/vue';
2
2
  import type { NuxtUseScriptOptions } from '#nuxt-scripts';
3
- export declare function useScript<T>(input: UseScriptInput, options?: NuxtUseScriptOptions): T & {
4
- $script: VueScriptInstance<T>;
3
+ export declare function useScript<T extends Record<string | symbol, any>>(input: UseScriptInput, options?: NuxtUseScriptOptions): T & {
4
+ $script: VueScriptInstance<T> & Promise<T>;
5
5
  };
@@ -6,11 +6,10 @@ export function useScript(input, options) {
6
6
  input = typeof input === "string" ? { src: input } : input;
7
7
  options = defu(options, useRuntimeConfig().public["nuxt-scripts"]?.defaultScriptOptions);
8
8
  if (options.trigger === "onNuxtReady")
9
- options.trigger = new Promise((resolve) => onNuxtReady(resolve));
9
+ options.trigger = onNuxtReady;
10
10
  const nuxtApp = useNuxtApp();
11
11
  const id = input.key || input.src || hashCode(typeof input.innerHTML === "string" ? input.innerHTML : "");
12
12
  if (!nuxtApp.scripts?.[id]) {
13
- options.beforeInit?.();
14
13
  if (import.meta.client) {
15
14
  performance?.mark?.("mark_feature_usage", {
16
15
  detail: {
@@ -1,12 +1,16 @@
1
- import { type Input } from 'valibot';
2
- import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
+ /**
3
+ * Sample:
4
+ * <!-- Cloudflare Web Analytics -->
5
+ * <script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "12ee46bf598b45c2868bbc07a3073f58"}'></script>
6
+ * <!-- End Cloudflare Web Analytics -->
7
+ */
3
8
  export interface CloudflareWebAnalyticsApi {
4
9
  __cfBeacon: {
5
10
  load: 'single';
6
11
  spa: boolean;
7
12
  token: string;
8
13
  };
9
- __cfRl?: unknown;
10
14
  }
11
15
  declare global {
12
16
  interface Window extends CloudflareWebAnalyticsApi {
@@ -15,8 +19,6 @@ declare global {
15
19
  export declare const CloudflareWebAnalyticsOptions: import("valibot").ObjectSchema<{
16
20
  /**
17
21
  * The Cloudflare Web Analytics token.
18
- *
19
- * Required when used for the first time.
20
22
  */
21
23
  token: import("valibot").StringSchema<string>;
22
24
  /**
@@ -30,5 +32,7 @@ export declare const CloudflareWebAnalyticsOptions: import("valibot").ObjectSche
30
32
  token: string;
31
33
  spa?: boolean | undefined;
32
34
  }>;
33
- export type CloudflareWebAnalyticsInput = Input<typeof CloudflareWebAnalyticsOptions>;
34
- export declare function useScriptCloudflareWebAnalytics<T extends CloudflareWebAnalyticsApi>(options?: CloudflareWebAnalyticsInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
35
+ export type CloudflareWebAnalyticsInput = RegistryScriptInput<typeof CloudflareWebAnalyticsOptions>;
36
+ export declare function useScriptCloudflareWebAnalytics<T extends CloudflareWebAnalyticsApi>(_options?: CloudflareWebAnalyticsInput): T & {
37
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
38
+ };
@@ -1,13 +1,11 @@
1
1
  import { boolean, minLength, object, optional, string } from "valibot";
2
2
  import { defu } from "defu";
3
- import { useScript, validateScriptInputSchema } from "#imports";
3
+ import { registryScript } from "../utils.mjs";
4
4
  export const CloudflareWebAnalyticsOptions = object({
5
5
  /**
6
6
  * The Cloudflare Web Analytics token.
7
- *
8
- * Required when used for the first time.
9
7
  */
10
- token: string([minLength(33)]),
8
+ token: string([minLength(32)]),
11
9
  /**
12
10
  * Cloudflare Web Analytics enables measuring SPAs automatically by overriding the History API’s pushState function
13
11
  * and listening to the onpopstate. Hash-based router is not supported.
@@ -16,19 +14,19 @@ export const CloudflareWebAnalyticsOptions = object({
16
14
  */
17
15
  spa: optional(boolean())
18
16
  });
19
- export function useScriptCloudflareWebAnalytics(options, _scriptOptions) {
20
- const scriptOptions = _scriptOptions || {};
21
- scriptOptions.beforeInit = () => {
22
- import.meta.dev && validateScriptInputSchema(CloudflareWebAnalyticsOptions, options);
23
- _scriptOptions?.beforeInit?.();
24
- };
25
- return useScript({
26
- "src": "https://static.cloudflareinsights.com/beacon.min.js",
27
- "data-cf-beacon": JSON.stringify(defu(options, { spa: true }))
28
- }, {
29
- ...scriptOptions,
30
- use() {
31
- return { __cfBeacon: window.__cfBeacon, __cfRl: window.__cfRl };
17
+ export function useScriptCloudflareWebAnalytics(_options) {
18
+ return registryScript("cloudflareWebAnalytics", (options) => ({
19
+ scriptInput: {
20
+ "src": "https://static.cloudflareinsights.com/beacon.min.js",
21
+ "data-cf-beacon": JSON.stringify(defu(options, { spa: true }))
22
+ },
23
+ schema: import.meta.dev ? CloudflareWebAnalyticsOptions : void 0,
24
+ scriptOptions: {
25
+ // we want to load earlier so that the web vitals reports are correct
26
+ trigger: "client",
27
+ use() {
28
+ return { __cfBeacon: window.__cfBeacon };
29
+ }
32
30
  }
33
- });
31
+ }), _options);
34
32
  }
@@ -1,5 +1,4 @@
1
- import { type Input } from 'valibot';
2
- import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
2
  type StandardEvents = 'AddPaymentInfo' | 'AddToCart' | 'AddToWishlist' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'InitiateCheckout' | 'Lead' | 'Purchase' | 'Schedule' | 'Search' | 'StartTrial' | 'SubmitApplication' | 'Subscribe' | 'ViewContent';
4
3
  interface EventObjectProperties {
5
4
  content_category?: string;
@@ -34,10 +33,12 @@ declare global {
34
33
  }
35
34
  }
36
35
  export declare const FacebookPixelOptions: import("valibot").ObjectSchema<{
37
- id: import("valibot").UnionSchema<(import("valibot").StringSchema<string> | import("valibot").NumberSchema<number>)[], string | number>;
36
+ id: import("valibot").UnionSchema<(import("valibot").NumberSchema<number> | import("valibot").StringSchema<string>)[], string | number>;
38
37
  }, undefined, {
39
38
  id: string | number;
40
39
  }>;
41
- export type FacebookPixelInput = Input<typeof FacebookPixelOptions>;
42
- export declare function useScriptFacebookPixel<T extends FacebookPixelApi>(options?: FacebookPixelInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
40
+ export type FacebookPixelInput = RegistryScriptInput<typeof FacebookPixelOptions>;
41
+ export declare function useScriptFacebookPixel<T extends FacebookPixelApi>(_options?: FacebookPixelInput): T & {
42
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
43
+ };
43
44
  export {};
@@ -1,13 +1,21 @@
1
1
  import { number, object, string, union } from "valibot";
2
- import { useScript, validateScriptInputSchema } from "#imports";
2
+ import { registryScript } from "../utils.mjs";
3
+ import { FacebookPixelScriptResolver } from "../../registry";
3
4
  export const FacebookPixelOptions = object({
4
5
  id: union([string(), number()])
5
6
  });
6
- export function useScriptFacebookPixel(options, _scriptOptions) {
7
- const scriptOptions = _scriptOptions || {};
8
- scriptOptions.beforeInit = () => {
9
- import.meta.dev && validateScriptInputSchema(FacebookPixelOptions, options);
10
- if (import.meta.client) {
7
+ export function useScriptFacebookPixel(_options) {
8
+ return registryScript("facebookPixel", (options) => ({
9
+ scriptInput: {
10
+ src: FacebookPixelScriptResolver()
11
+ },
12
+ schema: FacebookPixelOptions,
13
+ scriptOptions: {
14
+ use() {
15
+ return { fbq: window.fbq };
16
+ }
17
+ },
18
+ clientInit: import.meta.server ? void 0 : () => {
11
19
  const fbq = window.fbq = function(...params) {
12
20
  fbq.callMethod ? fbq.callMethod(...params) : fbq.queue.push(params);
13
21
  };
@@ -20,15 +28,5 @@ export function useScriptFacebookPixel(options, _scriptOptions) {
20
28
  fbq("init", options?.id);
21
29
  fbq("track", "PageView");
22
30
  }
23
- _scriptOptions?.beforeInit?.();
24
- };
25
- return useScript({
26
- key: "facebookPixel",
27
- src: "https://connect.facebook.net/en_US/fbevents.js"
28
- }, {
29
- ...scriptOptions,
30
- use() {
31
- return { fbq: window.fbq };
32
- }
33
- });
31
+ }), _options);
34
32
  }
@@ -1,26 +1,49 @@
1
- import { type Input } from 'valibot';
2
- import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
2
  export declare const FathomAnalyticsOptions: import("valibot").ObjectSchema<{
3
+ /**
4
+ * The Fathom Analytics site ID.
5
+ */
4
6
  site: import("valibot").StringSchema<string>;
5
- src: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
6
- 'data-spa': import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"auto", "auto"> | import("valibot").LiteralSchema<"history", "history"> | import("valibot").LiteralSchema<"hash", "hash">)[], "auto" | "history" | "hash">, undefined, "auto" | "history" | "hash" | undefined>;
7
- 'data-auto': import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
8
- 'data-canonical': import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
9
- 'data-honor-dnt': import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
7
+ /**
8
+ * The Fathom Analytics tracking mode.
9
+ */
10
+ spa: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"hash", "hash"> | import("valibot").LiteralSchema<"auto", "auto"> | import("valibot").LiteralSchema<"history", "history">)[], "auto" | "hash" | "history">, undefined, "auto" | "hash" | "history" | undefined>;
11
+ /**
12
+ * Automatically track page views.
13
+ */
14
+ auto: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
15
+ /**
16
+ * Enable canonical URL tracking.
17
+ */
18
+ canonical: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
19
+ /**
20
+ * Honor Do Not Track requests.
21
+ */
22
+ honorDnt: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
10
23
  }, undefined, {
11
24
  site: string;
12
- src?: string | undefined;
13
- 'data-spa'?: "auto" | "history" | "hash" | undefined;
14
- 'data-auto'?: boolean | undefined;
15
- 'data-canonical'?: boolean | undefined;
16
- 'data-honor-dnt'?: boolean | undefined;
25
+ auto?: boolean | undefined;
26
+ spa?: "auto" | "hash" | "history" | undefined;
27
+ canonical?: boolean | undefined;
28
+ honorDnt?: boolean | undefined;
17
29
  }>;
18
- export type FathomAnalyticsInput = Input<typeof FathomAnalyticsOptions>;
30
+ export type FathomAnalyticsInput = RegistryScriptInput<typeof FathomAnalyticsOptions, false>;
19
31
  export interface FathomAnalyticsApi {
32
+ beacon: (ctx: {
33
+ url: string;
34
+ referrer?: string;
35
+ }) => void;
36
+ blockTrackingForMe: () => void;
37
+ enableTrackingForMe: () => void;
38
+ isTrackingEnabled: () => boolean;
39
+ send: (type: string, data: unknown) => void;
40
+ setSite: (siteId: string) => void;
41
+ sideId: string;
20
42
  trackPageview: (ctx?: {
21
43
  url: string;
22
44
  referrer?: string;
23
45
  }) => void;
46
+ trackGoal: (goalId: string, cents: number) => void;
24
47
  trackEvent: (eventName: string, value: {
25
48
  _value: number;
26
49
  }) => void;
@@ -30,4 +53,6 @@ declare global {
30
53
  fathom: FathomAnalyticsApi;
31
54
  }
32
55
  }
33
- export declare function useScriptFathomAnalytics<T extends FathomAnalyticsApi>(options?: FathomAnalyticsInput, _scriptOptions?: Omit<NuxtUseScriptIntegrationOptions, 'assetStrategy'>): any;
56
+ export declare function useScriptFathomAnalytics<T extends FathomAnalyticsApi>(_options?: FathomAnalyticsInput): T & {
57
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
58
+ };
@@ -1,25 +1,44 @@
1
1
  import { boolean, literal, object, optional, string, union } from "valibot";
2
- import { useScript, validateScriptInputSchema } from "#imports";
2
+ import { registryScript } from "../utils.mjs";
3
3
  export const FathomAnalyticsOptions = object({
4
- "site": string(),
5
- // site is required
6
- "src": optional(string()),
7
- "data-spa": optional(union([literal("auto"), literal("history"), literal("hash")])),
8
- "data-auto": optional(boolean()),
9
- "data-canonical": optional(boolean()),
10
- "data-honor-dnt": optional(boolean())
4
+ /**
5
+ * The Fathom Analytics site ID.
6
+ */
7
+ site: string(),
8
+ /**
9
+ * The Fathom Analytics tracking mode.
10
+ */
11
+ spa: optional(union([literal("auto"), literal("history"), literal("hash")])),
12
+ /**
13
+ * Automatically track page views.
14
+ */
15
+ auto: optional(boolean()),
16
+ /**
17
+ * Enable canonical URL tracking.
18
+ */
19
+ canonical: optional(boolean()),
20
+ /**
21
+ * Honor Do Not Track requests.
22
+ */
23
+ honorDnt: optional(boolean())
11
24
  });
12
- export function useScriptFathomAnalytics(options, _scriptOptions) {
13
- const scriptOptions = _scriptOptions || {};
14
- scriptOptions.beforeInit = () => {
15
- import.meta.dev && validateScriptInputSchema(FathomAnalyticsOptions, options);
16
- _scriptOptions?.beforeInit?.();
17
- };
18
- return useScript({
19
- src: "https://cdn.usefathom.com/script.js",
20
- ...options
21
- }, {
22
- ...scriptOptions,
23
- use: () => window.fathom
24
- });
25
+ export function useScriptFathomAnalytics(_options) {
26
+ return registryScript("fathomAnalytics", (options) => ({
27
+ scriptInput: {
28
+ src: "https://cdn.usefathom.com/script.js",
29
+ // can't be bundled
30
+ // append the data attr's
31
+ ...Object.entries(options).filter(([key]) => ["site", "spa", "auto", "canonical", "honorDnt"].includes(key)).reduce((acc, [_key, value]) => {
32
+ const key = _key === "honourDnt" ? "honor-dnt" : _key;
33
+ acc[`data-${key}`] = value;
34
+ return acc;
35
+ }, {})
36
+ },
37
+ schema: import.meta.dev ? FathomAnalyticsOptions : void 0,
38
+ scriptOptions: {
39
+ use() {
40
+ return window.fathom;
41
+ }
42
+ }
43
+ }), _options);
25
44
  }
@@ -1 +1,21 @@
1
- export declare function useScriptGoogleAnalytics(): any;
1
+ import type { GoogleAnalyticsApi } from 'third-party-capital';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
+ declare const GoogleAnalyticsOptions: import("valibot").ObjectSchema<{
4
+ id: import("valibot").StringSchema<string>;
5
+ }, undefined, {
6
+ id: string;
7
+ }>;
8
+ export type GoogleAnalyticsInput = RegistryScriptInput<typeof GoogleAnalyticsOptions>;
9
+ declare global {
10
+ interface Window extends GoogleAnalyticsApi {
11
+ }
12
+ }
13
+ /**
14
+ * useScriptGoogleAnalytics
15
+ *
16
+ * A 3P wrapper for Google Analytics that takes an options input to feed into third-party-capital({@link https://github.com/GoogleChromeLabs/third-party-capital}), which returns instructions for nuxt-scripts.
17
+ */
18
+ export declare function useScriptGoogleAnalytics<T extends GoogleAnalyticsApi>(_options?: GoogleAnalyticsInput): T & {
19
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
20
+ };
21
+ export {};
@@ -1,4 +1,31 @@
1
- import { mockFallbackScript } from "../utils.mjs";
2
- export function useScriptGoogleAnalytics() {
3
- return mockFallbackScript("useScriptGoogleMaps", "@nuxtjs/third-party-capital");
1
+ import { object, string } from "valibot";
2
+ import { registryScript } from "../utils.mjs";
3
+ import { GoogleAnalyticsScriptResolver } from "../../registry";
4
+ const GoogleAnalyticsOptions = object({
5
+ id: string()
6
+ });
7
+ export function useScriptGoogleAnalytics(_options) {
8
+ return registryScript("googleAnalytics", (options) => ({
9
+ scriptInput: {
10
+ src: GoogleAnalyticsScriptResolver(options)
11
+ },
12
+ schema: GoogleAnalyticsOptions,
13
+ scriptOptions: {
14
+ use() {
15
+ return { dataLayer: window.dataLayer, gtag: window.gtag };
16
+ },
17
+ // allow dataLayer to be accessed on the server
18
+ stub: import.meta.client ? void 0 : ({ fn }) => {
19
+ return fn === "dataLayer" ? [] : void 0;
20
+ }
21
+ },
22
+ clientInit: import.meta.server ? void 0 : () => {
23
+ window.dataLayer = window.dataLayer || [];
24
+ window.gtag = function gtag(...p) {
25
+ window.dataLayer.push(p);
26
+ };
27
+ window.gtag("js", /* @__PURE__ */ new Date());
28
+ window.gtag("config", options?.id);
29
+ }
30
+ }), _options);
4
31
  }
@@ -1 +1,23 @@
1
- export declare function useScriptGoogleMaps(): any;
1
+ import type google from 'google.maps';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
+ export declare const GoogleMapsOptions: import("valibot").ObjectSchema<{
4
+ apiKey: import("valibot").StringSchema<string>;
5
+ libraries: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<string>, string[]>, undefined, string[] | undefined>;
6
+ v: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"weekly", "weekly"> | import("valibot").LiteralSchema<"beta", "beta"> | import("valibot").LiteralSchema<"alpha", "alpha">)[], "weekly" | "beta" | "alpha">, undefined, "weekly" | "beta" | "alpha" | undefined>;
7
+ }, undefined, {
8
+ apiKey: string;
9
+ libraries?: string[] | undefined;
10
+ v?: "weekly" | "beta" | "alpha" | undefined;
11
+ }>;
12
+ export type GoogleMapsInput = RegistryScriptInput<typeof GoogleMapsOptions>;
13
+ export interface GoogleMapsApi {
14
+ maps: google.maps;
15
+ }
16
+ declare global {
17
+ interface Window {
18
+ google: typeof google;
19
+ }
20
+ }
21
+ export declare function useScriptGoogleMaps<T extends GoogleMapsApi>(_options?: GoogleMapsInput): T & {
22
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
23
+ };
@@ -1,4 +1,41 @@
1
- import { mockFallbackScript } from "../utils.mjs";
2
- export function useScriptGoogleMaps() {
3
- return mockFallbackScript("useScriptGoogleMaps", "@nuxtjs/third-party-capital");
1
+ import { array, literal, object, optional, string, union } from "valibot";
2
+ import { withQuery } from "ufo";
3
+ import { registryScript } from "../utils.mjs";
4
+ export const GoogleMapsOptions = object({
5
+ apiKey: string(),
6
+ libraries: optional(array(string())),
7
+ v: optional(union([literal("weekly"), literal("beta"), literal("alpha")]))
8
+ });
9
+ export function useScriptGoogleMaps(_options) {
10
+ let readyPromise = Promise.resolve();
11
+ return registryScript("googleMaps", (options) => {
12
+ const libraries = options?.libraries || ["places"];
13
+ return {
14
+ scriptInput: {
15
+ src: withQuery(`https://maps.googleapis.com/maps/api/js`, {
16
+ libraries: libraries.join(","),
17
+ key: options?.apiKey,
18
+ loading: "async",
19
+ callback: "google.maps.__ib__"
20
+ })
21
+ },
22
+ clientInit: import.meta.server ? void 0 : () => {
23
+ window.google = window.google || {};
24
+ window.google.maps = window.google.maps || {};
25
+ readyPromise = new Promise((resolve) => {
26
+ window.google.maps.__ib__ = resolve;
27
+ });
28
+ },
29
+ schema: GoogleMapsOptions,
30
+ scriptOptions: {
31
+ use() {
32
+ return {
33
+ maps: readyPromise.then(() => {
34
+ return window.google.maps;
35
+ })
36
+ };
37
+ }
38
+ }
39
+ };
40
+ }, _options);
4
41
  }
@@ -1 +1,21 @@
1
- export declare function useScriptGoogleTagManager(): any;
1
+ import type { GoogleTagManagerApi } from 'third-party-capital';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
+ declare const GoogleTagManagerOptions: import("valibot").ObjectSchema<{
4
+ id: import("valibot").StringSchema<string>;
5
+ }, undefined, {
6
+ id: string;
7
+ }>;
8
+ export type GoogleTagManagerInput = RegistryScriptInput<typeof GoogleTagManagerOptions>;
9
+ declare global {
10
+ interface Window extends GoogleTagManagerApi {
11
+ }
12
+ }
13
+ /**
14
+ * useScriptGoogleTagManager
15
+ *
16
+ * A 3P wrapper for Google Tag Manager that takes an options input to feed into third-party-capital({@link https://github.com/GoogleChromeLabs/third-party-capital}), which returns instructions for nuxt-scripts.
17
+ */
18
+ export declare function useScriptGoogleTagManager<T extends GoogleTagManagerApi>(options?: GoogleTagManagerInput): T & {
19
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
20
+ };
21
+ export {};
@@ -1,4 +1,30 @@
1
- import { mockFallbackScript } from "../utils.mjs";
2
- export function useScriptGoogleTagManager() {
3
- return mockFallbackScript("useScriptGoogleTagManager", "@nuxtjs/third-party-capital");
1
+ import { object, string } from "valibot";
2
+ import { withQuery } from "ufo";
3
+ import { registryScript } from "../utils.mjs";
4
+ const GoogleTagManagerOptions = object({
5
+ id: string()
6
+ });
7
+ export function useScriptGoogleTagManager(options) {
8
+ return registryScript("googleTagManager", (options2) => ({
9
+ scriptInput: {
10
+ async: true,
11
+ src: withQuery("https://www.googletagmanager.com/gtm.js", {
12
+ id: options2?.id
13
+ })
14
+ },
15
+ schema: GoogleTagManagerOptions,
16
+ scriptOptions: {
17
+ use() {
18
+ return { dataLayer: window.dataLayer, google_tag_manager: window.google_tag_manager };
19
+ },
20
+ // allow dataLayer to be accessed on the server
21
+ stub: import.meta.client ? void 0 : ({ fn }) => {
22
+ return fn === "dataLayer" ? [] : void 0;
23
+ }
24
+ },
25
+ clientInit: import.meta.server ? void 0 : () => {
26
+ window.dataLayer = window.dataLayer || [];
27
+ window.dataLayer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), "event": "gtm.js" });
28
+ }
29
+ }), options);
4
30
  }
@@ -1,4 +1,4 @@
1
- import type { NuxtUseScriptIntegrationOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
2
  export interface HotjarApi {
3
3
  hj: ((event: 'identify', userId: string, attributes?: Record<string, any>) => void) & ((event: 'stateChange', path: string) => void) & ((event: 'event', eventName: string) => void) & ((event: string, arg?: string) => void) & ((...params: any[]) => void) & {
4
4
  q: any[];
@@ -19,5 +19,7 @@ export declare const HotjarOptions: import("valibot").ObjectSchema<{
19
19
  id: number;
20
20
  sv?: number | undefined;
21
21
  }>;
22
- export type HotjarInput = ScriptDynamicSrcInput<typeof HotjarOptions>;
23
- export declare function useScriptHotjar<T extends HotjarApi>(options?: HotjarInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
22
+ export type HotjarInput = RegistryScriptInput<typeof HotjarOptions>;
23
+ export declare function useScriptHotjar<T extends HotjarApi>(_options?: HotjarInput): T & {
24
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
25
+ };