@nuxt/scripts 0.11.10 → 0.12.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 (115) hide show
  1. package/dist/client/200.html +1 -1
  2. package/dist/client/404.html +1 -1
  3. package/dist/client/_nuxt/C0XnD8hU.js +179 -0
  4. package/dist/client/_nuxt/CVO1_9PV.js +1 -0
  5. package/dist/client/_nuxt/Cp-IABpG.js +1 -0
  6. package/dist/client/_nuxt/D0r3Knsf.js +1 -0
  7. package/dist/client/_nuxt/DDcnVyjk.js +1 -0
  8. package/dist/client/_nuxt/DlfHMoPT.js +1 -0
  9. package/dist/client/_nuxt/DnkQskw_.js +1 -0
  10. package/dist/client/_nuxt/builds/latest.json +1 -1
  11. package/dist/client/_nuxt/builds/meta/639547f1-5b38-4078-9f06-0e97166e98d5.json +1 -0
  12. package/dist/client/_nuxt/entry.Bb8Z00UZ.css +1 -0
  13. package/dist/client/_nuxt/error-404.CImBk2QF.css +1 -0
  14. package/dist/client/_nuxt/error-500.BDZhF_NY.css +1 -0
  15. package/dist/client/_nuxt/n57rOy2v.js +1 -0
  16. package/dist/client/index.html +1 -1
  17. package/dist/module.d.mts +8 -2
  18. package/dist/module.json +3 -3
  19. package/dist/module.mjs +169 -42
  20. package/dist/registry.mjs +30 -0
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +0 -0
  22. package/dist/runtime/components/{ScriptGoogleMaps.vue → GoogleMaps/ScriptGoogleMaps.vue} +17 -13
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +0 -0
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +61 -0
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +86 -0
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +61 -0
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.d.vue.ts +33 -0
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +62 -0
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue.d.ts +33 -0
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +5 -0
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +32 -0
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +5 -0
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +35 -0
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +88 -0
  35. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +35 -0
  36. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +61 -0
  37. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +84 -0
  38. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +61 -0
  39. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +27 -0
  40. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +56 -0
  41. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +27 -0
  42. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +5 -0
  43. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +37 -0
  44. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +5 -0
  45. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +29 -0
  46. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +60 -0
  47. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +29 -0
  48. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +29 -0
  49. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +60 -0
  50. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +29 -0
  51. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +31 -0
  52. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +61 -0
  53. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +31 -0
  54. package/dist/runtime/components/ScriptAriaLoadingIndicator.d.vue.ts +2 -0
  55. package/dist/runtime/components/ScriptCarbonAds.d.vue.ts +32 -0
  56. package/dist/runtime/components/ScriptCrisp.d.vue.ts +44 -0
  57. package/dist/runtime/components/ScriptCrisp.vue.d.ts +3 -1
  58. package/dist/runtime/components/ScriptGoogleAdsense.d.vue.ts +37 -0
  59. package/dist/runtime/components/ScriptGoogleAdsense.vue.d.ts +4 -1
  60. package/dist/runtime/components/ScriptIntercom.d.vue.ts +45 -0
  61. package/dist/runtime/components/ScriptIntercom.vue.d.ts +3 -1
  62. package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +24 -0
  63. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +3 -1
  64. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +9 -0
  65. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +4 -1
  66. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +72 -0
  67. package/dist/runtime/components/ScriptPayPalButtons.vue +116 -0
  68. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +72 -0
  69. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +51 -0
  70. package/dist/runtime/components/ScriptPayPalMarks.vue +69 -0
  71. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +51 -0
  72. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +67 -0
  73. package/dist/runtime/components/ScriptPayPalMessages.vue +90 -0
  74. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +67 -0
  75. package/dist/runtime/components/ScriptStripePricingTable.d.vue.ts +35 -0
  76. package/dist/runtime/components/ScriptStripePricingTable.vue +1 -1
  77. package/dist/runtime/components/ScriptStripePricingTable.vue.d.ts +3 -1
  78. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +127 -0
  79. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +5 -3
  80. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +66 -0
  81. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +9 -1
  82. package/dist/runtime/composables/useScript.js +35 -2
  83. package/dist/runtime/composables/useScriptEventPage.js +6 -2
  84. package/dist/runtime/composables/useScriptTriggerIdleTimeout.d.ts +10 -0
  85. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +22 -0
  86. package/dist/runtime/composables/useScriptTriggerInteraction.d.ts +15 -0
  87. package/dist/runtime/composables/useScriptTriggerInteraction.js +35 -0
  88. package/dist/runtime/logger.d.ts +1 -0
  89. package/dist/runtime/logger.js +6 -0
  90. package/dist/runtime/registry/databuddy-analytics.d.ts +77 -0
  91. package/dist/runtime/registry/databuddy-analytics.js +103 -0
  92. package/dist/runtime/registry/google-analytics.d.ts +1 -1
  93. package/dist/runtime/registry/google-analytics.js +5 -5
  94. package/dist/runtime/registry/google-tag-manager.js +3 -5
  95. package/dist/runtime/registry/matomo-analytics.d.ts +1 -0
  96. package/dist/runtime/registry/matomo-analytics.js +27 -4
  97. package/dist/runtime/registry/paypal.d.ts +34 -0
  98. package/dist/runtime/registry/paypal.js +86 -0
  99. package/dist/runtime/registry/reddit-pixel.d.ts +18 -0
  100. package/dist/runtime/registry/reddit-pixel.js +36 -0
  101. package/dist/runtime/registry/stripe.d.ts +2 -2
  102. package/dist/runtime/registry/stripe.js +1 -1
  103. package/dist/runtime/types.d.ts +18 -7
  104. package/dist/runtime/utils.d.ts +5 -2
  105. package/dist/runtime/utils.js +49 -19
  106. package/package.json +33 -26
  107. package/dist/client/_nuxt/C0osJU87.js +0 -1
  108. package/dist/client/_nuxt/DvGN_dxb.js +0 -1
  109. package/dist/client/_nuxt/DzYp5PzF.js +0 -21
  110. package/dist/client/_nuxt/builds/meta/55b6d2d9-3309-4bdb-b3a7-e1a28ac5a730.json +0 -1
  111. package/dist/client/_nuxt/entry.bAQEPFjX.css +0 -1
  112. package/dist/client/_nuxt/error-404.eZgLTnTW.css +0 -1
  113. package/dist/client/_nuxt/error-500.B1rSPQ5Q.css +0 -1
  114. package/dist/client/_nuxt/o0sZgK8d.js +0 -1
  115. package/dist/runtime/components/ScriptGoogleMaps.vue.d.ts +0 -140
@@ -0,0 +1,66 @@
1
+ import type { HTMLAttributes, ImgHTMLAttributes, Ref } from 'vue';
2
+ import type { ElementScriptTrigger } from '../types.js';
3
+ export type YoutubeThumbnailSize = '1' | '2' | '3' | 'default' | 'mq1' | 'mq2' | 'mq3' | 'mqdefault' | '0' | 'hq1' | 'hq2' | 'hq3' | 'hqdefault' | 'sd1' | 'sd2' | 'sd3' | 'sddefault' | 'hq720' | 'maxresdefault';
4
+ type __VLS_Props = {
5
+ placeholderAttrs?: ImgHTMLAttributes;
6
+ rootAttrs?: HTMLAttributes;
7
+ aboveTheFold?: boolean;
8
+ trigger?: ElementScriptTrigger;
9
+ videoId: string;
10
+ playerVars?: YT.PlayerVars;
11
+ width?: number;
12
+ height?: number;
13
+ /**
14
+ * Whether to use youtube-nocookie.com for embedding.
15
+ *
16
+ * @default false
17
+ */
18
+ cookies?: boolean;
19
+ playerOptions?: YT.PlayerOptions;
20
+ thumbnailSize?: YoutubeThumbnailSize;
21
+ webp?: boolean;
22
+ };
23
+ declare var __VLS_1: {
24
+ placeholder: any;
25
+ }, __VLS_3: {}, __VLS_9: {}, __VLS_11: {}, __VLS_13: {};
26
+ type __VLS_Slots = {} & {
27
+ placeholder?: (props: typeof __VLS_1) => any;
28
+ } & {
29
+ loading?: (props: typeof __VLS_3) => any;
30
+ } & {
31
+ awaitingLoad?: (props: typeof __VLS_9) => any;
32
+ } & {
33
+ error?: (props: typeof __VLS_11) => any;
34
+ } & {
35
+ default?: (props: typeof __VLS_13) => any;
36
+ };
37
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
38
+ player: Ref<YT.Player | undefined, YT.Player | undefined>;
39
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
40
+ error: (e: YT.OnErrorEvent, target: YT.Player) => any;
41
+ ready: (e: YT.PlayerEvent) => any;
42
+ "state-change": (e: YT.OnStateChangeEvent, target: YT.Player) => any;
43
+ "playback-quality-change": (e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any;
44
+ "playback-rate-change": (e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any;
45
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
46
+ onError?: ((e: YT.OnErrorEvent, target: YT.Player) => any) | undefined;
47
+ onReady?: ((e: YT.PlayerEvent) => any) | undefined;
48
+ "onState-change"?: ((e: YT.OnStateChangeEvent, target: YT.Player) => any) | undefined;
49
+ "onPlayback-quality-change"?: ((e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any) | undefined;
50
+ "onPlayback-rate-change"?: ((e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any) | undefined;
51
+ }>, {
52
+ trigger: ElementScriptTrigger;
53
+ width: number;
54
+ height: number;
55
+ playerVars: YT.PlayerVars;
56
+ cookies: boolean;
57
+ thumbnailSize: YoutubeThumbnailSize;
58
+ webp: boolean;
59
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
60
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
61
+ export default _default;
62
+ type __VLS_WithSlots<T, S> = T & {
63
+ new (): {
64
+ $slots: S;
65
+ };
66
+ };
@@ -48,7 +48,15 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
48
48
  "onState-change"?: ((e: YT.OnStateChangeEvent, target: YT.Player) => any) | undefined;
49
49
  "onPlayback-quality-change"?: ((e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any) | undefined;
50
50
  "onPlayback-rate-change"?: ((e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any) | undefined;
51
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
51
+ }>, {
52
+ trigger: ElementScriptTrigger;
53
+ width: number;
54
+ height: number;
55
+ playerVars: YT.PlayerVars;
56
+ cookies: boolean;
57
+ thumbnailSize: YoutubeThumbnailSize;
58
+ webp: boolean;
59
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
52
60
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
53
61
  export default _default;
54
62
  type __VLS_WithSlots<T, S> = T & {
@@ -1,7 +1,8 @@
1
1
  import { defu } from "defu";
2
2
  import { useScript as _useScript } from "@unhead/vue/scripts";
3
3
  import { reactive } from "vue";
4
- import { onNuxtReady, useNuxtApp, useRuntimeConfig, injectHead } from "#imports";
4
+ import { onNuxtReady, useNuxtApp, useRuntimeConfig, injectHead } from "nuxt/app";
5
+ import { logger } from "../logger.js";
5
6
  function useNuxtScriptRuntimeConfig() {
6
7
  return useRuntimeConfig().public["nuxt-scripts"];
7
8
  }
@@ -11,6 +12,10 @@ export function resolveScriptKey(input) {
11
12
  export function useScript(input, options) {
12
13
  input = typeof input === "string" ? { src: input } : input;
13
14
  options = defu(options, useNuxtScriptRuntimeConfig()?.defaultScriptOptions);
15
+ if (import.meta.dev && options.bundle === "unsupported") {
16
+ console.warn("[Nuxt Scripts] Bundling is not supported for dynamic script sources. Static URLs are required for bundling.");
17
+ options.bundle = false;
18
+ }
14
19
  const id = String(resolveScriptKey(input));
15
20
  const nuxtApp = useNuxtApp();
16
21
  options.head = options.head || injectHead();
@@ -19,7 +24,20 @@ export function useScript(input, options) {
19
24
  }
20
25
  nuxtApp.$scripts = nuxtApp.$scripts || reactive({});
21
26
  const exists = !!nuxtApp.$scripts?.[id];
22
- if (options.trigger === "onNuxtReady" || options.trigger === "client") {
27
+ const err = options._validate?.();
28
+ if (import.meta.dev && import.meta.client && err) {
29
+ options.trigger = new Promise(() => {
30
+ });
31
+ if (!exists) {
32
+ let out = `Skipping script \`${id}\` due to invalid options:
33
+ `;
34
+ for (const e of err.issues) {
35
+ out += ` ${e.message}
36
+ `;
37
+ }
38
+ logger.info(out);
39
+ }
40
+ } else if (options.trigger === "onNuxtReady" || options.trigger === "client") {
23
41
  if (!options.warmupStrategy) {
24
42
  options.warmupStrategy = "preload";
25
43
  }
@@ -33,6 +51,13 @@ export function useScript(input, options) {
33
51
  nuxtApp.$scripts[id] = void 0;
34
52
  return _remove();
35
53
  };
54
+ const _load = instance.load;
55
+ instance.load = async () => {
56
+ if (err) {
57
+ return Promise.reject(err);
58
+ }
59
+ return _load();
60
+ };
36
61
  nuxtApp.$scripts[id] = instance;
37
62
  if (import.meta.dev && import.meta.client) {
38
63
  let syncScripts = function() {
@@ -72,6 +97,14 @@ export function useScript(input, options) {
72
97
  syncScripts();
73
98
  });
74
99
  payload.$script = instance;
100
+ if (err) {
101
+ payload.events.push({
102
+ type: "status",
103
+ status: "validation-failed",
104
+ args: err,
105
+ at: Date.now()
106
+ });
107
+ }
75
108
  payload.events.push({
76
109
  type: "status",
77
110
  status: "awaitingLoad",
@@ -1,5 +1,5 @@
1
1
  import { useNuxtApp, useRoute, injectHead } from "nuxt/app";
2
- import { ref } from "vue";
2
+ import { ref, onScopeDispose } from "vue";
3
3
  export function useScriptEventPage(onChange) {
4
4
  const nuxt = useNuxtApp();
5
5
  const route = useRoute();
@@ -13,7 +13,7 @@ export function useScriptEventPage(onChange) {
13
13
  let lastPayload = { path: "", title: "" };
14
14
  let stopDomWatcher = () => {
15
15
  };
16
- nuxt.hooks.hook("page:finish", () => {
16
+ const stopPageFinishHook = nuxt.hooks.hook("page:finish", () => {
17
17
  Promise.race([
18
18
  // possibly no head update is needed
19
19
  new Promise((resolve) => setTimeout(resolve, 100)),
@@ -33,5 +33,9 @@ export function useScriptEventPage(onChange) {
33
33
  }
34
34
  });
35
35
  });
36
+ onScopeDispose(() => {
37
+ stopDomWatcher();
38
+ stopPageFinishHook();
39
+ });
36
40
  return payload;
37
41
  }
@@ -0,0 +1,10 @@
1
+ export interface IdleTimeoutScriptTriggerOptions {
2
+ /**
3
+ * The timeout in milliseconds to wait before loading the script.
4
+ */
5
+ timeout: number;
6
+ }
7
+ /**
8
+ * Create a trigger that loads a script after an idle timeout once Nuxt is ready.
9
+ */
10
+ export declare function useScriptTriggerIdleTimeout(options: IdleTimeoutScriptTriggerOptions): Promise<boolean>;
@@ -0,0 +1,22 @@
1
+ import { tryOnScopeDispose } from "@vueuse/shared";
2
+ import { useTimeoutFn } from "@vueuse/core";
3
+ import { onNuxtReady } from "nuxt/app";
4
+ export function useScriptTriggerIdleTimeout(options) {
5
+ if (import.meta.server) {
6
+ return new Promise(() => {
7
+ });
8
+ }
9
+ const { timeout } = options;
10
+ return new Promise((resolve) => {
11
+ onNuxtReady(() => {
12
+ const { start, stop } = useTimeoutFn(() => {
13
+ resolve(true);
14
+ }, timeout, { immediate: false });
15
+ start();
16
+ tryOnScopeDispose(() => {
17
+ stop();
18
+ resolve(false);
19
+ });
20
+ });
21
+ });
22
+ }
@@ -0,0 +1,15 @@
1
+ export interface InteractionScriptTriggerOptions {
2
+ /**
3
+ * The interaction events to listen for.
4
+ */
5
+ events: string[];
6
+ /**
7
+ * The element to listen for events on.
8
+ * @default document.documentElement
9
+ */
10
+ target?: EventTarget | null;
11
+ }
12
+ /**
13
+ * Create a trigger that loads a script when any of the specified interaction events occur.
14
+ */
15
+ export declare function useScriptTriggerInteraction(options: InteractionScriptTriggerOptions): Promise<boolean>;
@@ -0,0 +1,35 @@
1
+ import { useEventListener } from "@vueuse/core";
2
+ import { tryOnScopeDispose } from "@vueuse/shared";
3
+ import { onNuxtReady } from "nuxt/app";
4
+ export function useScriptTriggerInteraction(options) {
5
+ if (import.meta.server) {
6
+ return new Promise(() => {
7
+ });
8
+ }
9
+ const { events, target = document.documentElement } = options;
10
+ return new Promise((resolve) => {
11
+ onNuxtReady(() => {
12
+ if (!target) {
13
+ resolve(false);
14
+ return;
15
+ }
16
+ const cleanupFns = [];
17
+ events.forEach((event) => {
18
+ const cleanup = useEventListener(
19
+ target,
20
+ event,
21
+ () => {
22
+ cleanupFns.forEach((fn) => fn());
23
+ resolve(true);
24
+ },
25
+ { once: true, passive: true }
26
+ );
27
+ cleanupFns.push(cleanup);
28
+ });
29
+ tryOnScopeDispose(() => {
30
+ cleanupFns.forEach((fn) => fn());
31
+ resolve(false);
32
+ });
33
+ });
34
+ });
35
+ }
@@ -0,0 +1 @@
1
+ export declare const logger: import("consola").ConsolaInstance;
@@ -0,0 +1,6 @@
1
+ import { createConsola } from "consola";
2
+ export const logger = createConsola({
3
+ defaults: {
4
+ tag: "nuxt-scripts"
5
+ }
6
+ });
@@ -0,0 +1,77 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ export declare const DatabuddyAnalyticsOptions: import("valibot").ObjectSchema<{
3
+ readonly clientId: import("valibot").StringSchema<undefined>;
4
+ readonly scriptUrl: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
5
+ readonly apiUrl: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
6
+ readonly disabled: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
7
+ readonly trackScreenViews: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
8
+ readonly trackPerformance: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
9
+ readonly trackSessions: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
10
+ readonly trackWebVitals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
11
+ readonly trackErrors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
12
+ readonly trackOutgoingLinks: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
13
+ readonly trackScrollDepth: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
14
+ readonly trackEngagement: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
15
+ readonly trackInteractions: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
16
+ readonly trackAttributes: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
17
+ readonly trackHashChanges: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
18
+ readonly trackExitIntent: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
19
+ readonly trackBounceRate: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
20
+ readonly enableBatching: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
21
+ readonly batchSize: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
22
+ readonly batchTimeout: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
23
+ readonly enableRetries: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
24
+ readonly maxRetries: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
25
+ readonly initialRetryDelay: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
26
+ readonly samplingRate: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
27
+ readonly sdk: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
28
+ readonly sdkVersion: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
29
+ readonly enableObservability: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
30
+ readonly observabilityService: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
31
+ readonly observabilityEnvironment: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
32
+ readonly observabilityVersion: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
33
+ readonly enableLogging: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
34
+ readonly enableTracing: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
35
+ readonly enableErrorTracking: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
36
+ }, undefined>;
37
+ export type DatabuddyAnalyticsInput = RegistryScriptInput<typeof DatabuddyAnalyticsOptions, false>;
38
+ export interface DatabuddyAnalyticsApi {
39
+ /**
40
+ * Track a custom event.
41
+ * @param eventName Name of the event (use snake_case)
42
+ * @param properties Optional event properties
43
+ */
44
+ track: (eventName: string, properties?: Record<string, any>) => Promise<any> | any | void;
45
+ /**
46
+ * Manually record a page / screen view. Useful for SPA route changes.
47
+ * @param path Optional path to record (defaults to current location)
48
+ * @param properties Optional additional properties for the screen view
49
+ */
50
+ screenView: (path?: string, properties?: Record<string, any>) => void;
51
+ /**
52
+ * Set properties that will be attached to all future events (e.g. user_id).
53
+ * @param properties Key/value map of properties to attach globally
54
+ */
55
+ setGlobalProperties: (properties: Record<string, any>) => void;
56
+ /**
57
+ * Track a custom event alias (compatibility helper present on the global)
58
+ * @param eventName Name of the event
59
+ * @param properties Optional event properties
60
+ */
61
+ trackCustomEvent: (eventName: string, properties?: Record<string, any>) => void;
62
+ /**
63
+ * Clears session and anonymous identifiers (useful on logout).
64
+ */
65
+ clear: () => void;
66
+ /**
67
+ * Force immediate sending of any queued/batched events.
68
+ */
69
+ flush: () => void;
70
+ }
71
+ declare global {
72
+ interface Window {
73
+ databuddy?: DatabuddyAnalyticsApi;
74
+ db?: DatabuddyAnalyticsApi;
75
+ }
76
+ }
77
+ export declare function useScriptDatabuddyAnalytics<T extends DatabuddyAnalyticsApi>(_options?: DatabuddyAnalyticsInput): import("#nuxt-scripts/types").UseScriptContext<T>;
@@ -0,0 +1,103 @@
1
+ import { useRegistryScript } from "../utils.js";
2
+ import { object, optional, string, boolean, number } from "#nuxt-scripts-validator";
3
+ export const DatabuddyAnalyticsOptions = object({
4
+ // Required
5
+ clientId: string(),
6
+ // Advanced
7
+ scriptUrl: optional(string()),
8
+ // defaults to https://cdn.databuddy.cc/databuddy.js
9
+ apiUrl: optional(string()),
10
+ // defaults to https://basket.databuddy.cc
11
+ disabled: optional(boolean()),
12
+ // Core tracking (enabled by default by SDK)
13
+ trackScreenViews: optional(boolean()),
14
+ trackPerformance: optional(boolean()),
15
+ trackSessions: optional(boolean()),
16
+ // Optional tracking
17
+ trackWebVitals: optional(boolean()),
18
+ trackErrors: optional(boolean()),
19
+ trackOutgoingLinks: optional(boolean()),
20
+ trackScrollDepth: optional(boolean()),
21
+ trackEngagement: optional(boolean()),
22
+ trackInteractions: optional(boolean()),
23
+ trackAttributes: optional(boolean()),
24
+ trackHashChanges: optional(boolean()),
25
+ trackExitIntent: optional(boolean()),
26
+ trackBounceRate: optional(boolean()),
27
+ // Performance options
28
+ enableBatching: optional(boolean()),
29
+ batchSize: optional(number()),
30
+ batchTimeout: optional(number()),
31
+ enableRetries: optional(boolean()),
32
+ maxRetries: optional(number()),
33
+ initialRetryDelay: optional(number()),
34
+ samplingRate: optional(number()),
35
+ // SDK metadata
36
+ sdk: optional(string()),
37
+ sdkVersion: optional(string()),
38
+ // Observability & logging (accepted by SDK config)
39
+ enableObservability: optional(boolean()),
40
+ observabilityService: optional(string()),
41
+ observabilityEnvironment: optional(string()),
42
+ observabilityVersion: optional(string()),
43
+ enableLogging: optional(boolean()),
44
+ enableTracing: optional(boolean()),
45
+ enableErrorTracking: optional(boolean())
46
+ });
47
+ export function useScriptDatabuddyAnalytics(_options) {
48
+ return useRegistryScript("databuddyAnalytics", (options) => {
49
+ return {
50
+ scriptInput: {
51
+ // Default CDN script, can be overridden via scriptUrl
52
+ "src": options?.scriptUrl || "https://cdn.databuddy.cc/databuddy.js",
53
+ "data-client-id": options.clientId,
54
+ // Advanced
55
+ "data-api-url": options?.apiUrl,
56
+ "data-disabled": options?.disabled,
57
+ // Core
58
+ "data-track-screen-views": options?.trackScreenViews,
59
+ "data-track-performance": options?.trackPerformance,
60
+ "data-track-sessions": options?.trackSessions,
61
+ // Optional
62
+ "data-track-web-vitals": options?.trackWebVitals,
63
+ "data-track-errors": options?.trackErrors,
64
+ "data-track-outgoing-links": options?.trackOutgoingLinks,
65
+ "data-track-scroll-depth": options?.trackScrollDepth,
66
+ "data-track-engagement": options?.trackEngagement,
67
+ "data-track-interactions": options?.trackInteractions,
68
+ "data-track-attributes": options?.trackAttributes,
69
+ "data-track-hash-changes": options?.trackHashChanges,
70
+ "data-track-exit-intent": options?.trackExitIntent,
71
+ "data-track-bounce-rate": options?.trackBounceRate,
72
+ // Performance tuning
73
+ "data-enable-batching": options?.enableBatching,
74
+ "data-batch-size": options?.batchSize,
75
+ "data-batch-timeout": options?.batchTimeout,
76
+ "data-enable-retries": options?.enableRetries,
77
+ "data-max-retries": options?.maxRetries,
78
+ "data-initial-retry-delay": options?.initialRetryDelay,
79
+ "data-sampling-rate": options?.samplingRate,
80
+ // SDK meta
81
+ "data-sdk": options?.sdk,
82
+ "data-sdk-version": options?.sdkVersion,
83
+ // Observability & logging
84
+ "data-enable-observability": options?.enableObservability,
85
+ "data-observability-service": options?.observabilityService,
86
+ "data-observability-environment": options?.observabilityEnvironment,
87
+ "data-observability-version": options?.observabilityVersion,
88
+ "data-enable-logging": options?.enableLogging,
89
+ "data-enable-tracing": options?.enableTracing,
90
+ "data-enable-error-tracking": options?.enableErrorTracking
91
+ },
92
+ schema: import.meta.dev ? DatabuddyAnalyticsOptions : void 0,
93
+ scriptOptions: {
94
+ use() {
95
+ if (typeof window === "undefined") {
96
+ return null;
97
+ }
98
+ return window.db || window.databuddy || null;
99
+ }
100
+ }
101
+ };
102
+ }, _options);
103
+ }
@@ -56,7 +56,7 @@ export interface GoogleAnalyticsApi {
56
56
  dataLayer: DataLayer;
57
57
  }
58
58
  export declare const GoogleAnalyticsOptions: import("valibot").ObjectSchema<{
59
- readonly id: import("valibot").StringSchema<undefined>;
59
+ readonly id: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
60
60
  readonly l: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
61
61
  }, undefined>;
62
62
  export type GoogleAnalyticsInput = RegistryScriptInput<typeof GoogleAnalyticsOptions>;
@@ -2,7 +2,7 @@ import { withQuery } from "ufo";
2
2
  import { useRegistryScript } from "#nuxt-scripts/utils";
3
3
  import { object, string, optional } from "#nuxt-scripts-validator";
4
4
  export const GoogleAnalyticsOptions = object({
5
- id: string(),
5
+ id: optional(string()),
6
6
  // The GA4 measurement ID (format: G-XXXXXXXX)
7
7
  l: optional(string())
8
8
  // Optional global name for dataLayer (defaults to 'dataLayer')
@@ -22,9 +22,7 @@ export function useScriptGoogleAnalytics(_options) {
22
22
  dataLayer: w[dataLayerName],
23
23
  gtag: w.gtag
24
24
  };
25
- },
26
- performanceMarkFeature: "nuxt-third-parties-ga",
27
- tagPriority: 1
25
+ }
28
26
  },
29
27
  clientInit: import.meta.server ? void 0 : () => {
30
28
  w[dataLayerName] = w[dataLayerName] || [];
@@ -33,7 +31,9 @@ export function useScriptGoogleAnalytics(_options) {
33
31
  };
34
32
  _options?.onBeforeGtagStart?.(w.gtag);
35
33
  w.gtag("js", /* @__PURE__ */ new Date());
36
- w.gtag("config", options?.id);
34
+ if (options?.id) {
35
+ w.gtag("config", options?.id);
36
+ }
37
37
  }
38
38
  };
39
39
  }, _options);
@@ -50,14 +50,12 @@ export function useScriptGoogleTagManager(options) {
50
50
  dataLayer: window[dataLayerName],
51
51
  google_tag_manager: window.google_tag_manager
52
52
  };
53
- },
54
- performanceMarkFeature: "nuxt-third-parties-gtm",
55
- tagPriority: 1
53
+ }
56
54
  },
57
55
  clientInit: import.meta.server ? void 0 : () => {
58
56
  window[dataLayerName] = window[dataLayerName] || [];
59
- function gtag(...args) {
60
- window[dataLayerName].push(args);
57
+ function gtag() {
58
+ window[dataLayerName].push(arguments);
61
59
  }
62
60
  options?.onBeforeGtmStart?.(gtag);
63
61
  window[dataLayerName].push({
@@ -7,6 +7,7 @@ export declare const MatomoAnalyticsOptions: import("valibot").ObjectSchema<{
7
7
  readonly trackPageView: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
8
8
  readonly enableLinkTracking: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
9
9
  readonly disableCookies: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
10
+ readonly watch: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
10
11
  }, undefined>;
11
12
  export type MatomoAnalyticsInput = RegistryScriptInput<typeof MatomoAnalyticsOptions, false, false, false>;
12
13
  interface MatomoAnalyticsApi {
@@ -1,6 +1,8 @@
1
1
  import { withBase, withHttps, withoutProtocol, withoutTrailingSlash } from "ufo";
2
2
  import { useRegistryScript } from "../utils.js";
3
+ import { useScriptEventPage } from "../composables/useScriptEventPage.js";
3
4
  import { boolean, object, optional, string, number, union } from "#nuxt-scripts-validator";
5
+ import { logger } from "../logger.js";
4
6
  export const MatomoAnalyticsOptions = object({
5
7
  matomoUrl: optional(string()),
6
8
  siteId: optional(union([string(), number()])),
@@ -8,7 +10,8 @@ export const MatomoAnalyticsOptions = object({
8
10
  trackerUrl: optional(string()),
9
11
  trackPageView: optional(boolean()),
10
12
  enableLinkTracking: optional(boolean()),
11
- disableCookies: optional(boolean())
13
+ disableCookies: optional(boolean()),
14
+ watch: optional(boolean())
12
15
  });
13
16
  export function useScriptMatomoAnalytics(_options) {
14
17
  return useRegistryScript("matomoAnalytics", (options) => {
@@ -23,7 +26,16 @@ export function useScriptMatomoAnalytics(_options) {
23
26
  schema: import.meta.dev ? MatomoAnalyticsOptions : void 0,
24
27
  scriptOptions: {
25
28
  use() {
26
- return { _paq: window._paq };
29
+ const _paqProxy = {
30
+ push: (...args) => {
31
+ if (window._paq && typeof window._paq.push === "function") {
32
+ return window._paq.push(...args);
33
+ }
34
+ window._paq = window._paq || [];
35
+ return window._paq.push(...args);
36
+ }
37
+ };
38
+ return { _paq: _paqProxy };
27
39
  }
28
40
  },
29
41
  clientInit: import.meta.server ? void 0 : () => {
@@ -39,8 +51,19 @@ export function useScriptMatomoAnalytics(_options) {
39
51
  _paq.push(["setTrackerUrl", withBase(`/matomo.php`, withHttps(normalizedCloudId))]);
40
52
  }
41
53
  _paq.push(["setSiteId", String(options?.siteId) || "1"]);
42
- if (options?.trackPageView) {
43
- _paq.push(["trackPageView"]);
54
+ if (options?.trackPageView !== void 0) {
55
+ if (import.meta.dev) {
56
+ logger.warn("The `trackPageView` option is deprecated. Use `watch: true` (default) for automatic page view tracking, or remove this option entirely.");
57
+ }
58
+ if (options.trackPageView) {
59
+ _paq.push(["trackPageView"]);
60
+ }
61
+ } else if (options?.watch !== false) {
62
+ useScriptEventPage((payload) => {
63
+ window._paq.push(["setDocumentTitle", payload.title]);
64
+ window._paq.push(["setCustomUrl", payload.path]);
65
+ window._paq.push(["trackPageView"]);
66
+ });
44
67
  }
45
68
  }
46
69
  };
@@ -0,0 +1,34 @@
1
+ import type { PayPalNamespace } from '@paypal/paypal-js';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
+ export interface PayPalApi {
4
+ paypal: PayPalNamespace;
5
+ }
6
+ declare global {
7
+ interface Window extends PayPalApi {
8
+ }
9
+ }
10
+ export declare const PayPalOptions: import("valibot").ObjectSchema<{
11
+ readonly clientId: import("valibot").StringSchema<undefined>;
12
+ readonly buyerCountry: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
13
+ readonly commit: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
14
+ readonly components: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>], undefined>, undefined>;
15
+ readonly currency: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
16
+ readonly debug: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>, undefined>;
17
+ readonly disableFunding: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>], undefined>, undefined>;
18
+ readonly enableFunding: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>], undefined>, undefined>;
19
+ readonly integrationDate: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
20
+ readonly intent: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
21
+ readonly locale: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
22
+ /**
23
+ * loadScript() supports an array for merchantId, even though
24
+ * merchant-id technically may not contain multiple values.
25
+ * For an array with a length of > 1 it automatically sets
26
+ * merchantId to "*" and moves the actual values to dataMerchantId
27
+ */
28
+ readonly merchantId: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>], undefined>, undefined>;
29
+ readonly partnerAttributionId: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
30
+ readonly vault: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>, undefined>;
31
+ readonly sandbox: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
32
+ }, undefined>;
33
+ export type PayPalInput = RegistryScriptInput<typeof PayPalOptions>;
34
+ export declare function useScriptPayPal<T extends PayPalApi>(_options?: PayPalInput): import("#nuxt-scripts/types").UseScriptContext<T>;