@nuxt/scripts 0.11.13 → 0.12.1

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 (109) hide show
  1. package/dist/client/200.html +1 -1
  2. package/dist/client/404.html +1 -1
  3. package/dist/client/_nuxt/B1l158TM.js +179 -0
  4. package/dist/client/_nuxt/CEpyMuZa.js +1 -0
  5. package/dist/client/_nuxt/CVO1_9PV.js +1 -0
  6. package/dist/client/_nuxt/Cp-IABpG.js +1 -0
  7. package/dist/client/_nuxt/D0r3Knsf.js +1 -0
  8. package/dist/client/_nuxt/DlfHMoPT.js +1 -0
  9. package/dist/client/_nuxt/DyLGGY9L.js +1 -0
  10. package/dist/client/_nuxt/builds/latest.json +1 -1
  11. package/dist/client/_nuxt/builds/meta/ab2a05b7-9c93-484e-ae04-bd1f39e5f3c1.json +1 -0
  12. package/dist/client/_nuxt/entry.Bb8Z00UZ.css +1 -0
  13. package/dist/client/_nuxt/error-404.pWWosX5v.css +1 -0
  14. package/dist/client/_nuxt/error-500.DHpVpAn4.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 +6 -0
  18. package/dist/module.json +1 -1
  19. package/dist/module.mjs +167 -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 +85 -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 +62 -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/ScriptGoogleAdsense.d.vue.ts +37 -0
  58. package/dist/runtime/components/ScriptIntercom.d.vue.ts +45 -0
  59. package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +24 -0
  60. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +9 -0
  61. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
  62. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +72 -0
  63. package/dist/runtime/components/ScriptPayPalButtons.vue +116 -0
  64. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +72 -0
  65. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +51 -0
  66. package/dist/runtime/components/ScriptPayPalMarks.vue +69 -0
  67. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +51 -0
  68. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +67 -0
  69. package/dist/runtime/components/ScriptPayPalMessages.vue +90 -0
  70. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +67 -0
  71. package/dist/runtime/components/ScriptStripePricingTable.d.vue.ts +35 -0
  72. package/dist/runtime/components/ScriptStripePricingTable.vue +1 -1
  73. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +127 -0
  74. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +2 -2
  75. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +66 -0
  76. package/dist/runtime/composables/useScript.js +35 -2
  77. package/dist/runtime/composables/useScriptEventPage.js +6 -2
  78. package/dist/runtime/composables/useScriptTriggerIdleTimeout.d.ts +10 -0
  79. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +22 -0
  80. package/dist/runtime/composables/useScriptTriggerInteraction.d.ts +15 -0
  81. package/dist/runtime/composables/useScriptTriggerInteraction.js +35 -0
  82. package/dist/runtime/logger.d.ts +1 -0
  83. package/dist/runtime/logger.js +6 -0
  84. package/dist/runtime/registry/databuddy-analytics.d.ts +77 -0
  85. package/dist/runtime/registry/databuddy-analytics.js +103 -0
  86. package/dist/runtime/registry/google-analytics.d.ts +1 -1
  87. package/dist/runtime/registry/google-analytics.js +5 -5
  88. package/dist/runtime/registry/google-tag-manager.js +3 -5
  89. package/dist/runtime/registry/matomo-analytics.d.ts +1 -0
  90. package/dist/runtime/registry/matomo-analytics.js +27 -4
  91. package/dist/runtime/registry/paypal.d.ts +34 -0
  92. package/dist/runtime/registry/paypal.js +86 -0
  93. package/dist/runtime/registry/reddit-pixel.d.ts +18 -0
  94. package/dist/runtime/registry/reddit-pixel.js +36 -0
  95. package/dist/runtime/registry/stripe.d.ts +2 -2
  96. package/dist/runtime/registry/stripe.js +1 -1
  97. package/dist/runtime/types.d.ts +18 -7
  98. package/dist/runtime/utils.d.ts +5 -2
  99. package/dist/runtime/utils.js +49 -19
  100. package/package.json +26 -19
  101. package/dist/client/_nuxt/1mHV-1pA.js +0 -1
  102. package/dist/client/_nuxt/7VVldQq3.js +0 -1
  103. package/dist/client/_nuxt/CQGAJOTU.js +0 -21
  104. package/dist/client/_nuxt/CYHtqd0e.js +0 -1
  105. package/dist/client/_nuxt/builds/meta/8ed6dba0-c6c1-426f-804b-f7cbe9d62b69.json +0 -1
  106. package/dist/client/_nuxt/entry.tbizjOMR.css +0 -1
  107. package/dist/client/_nuxt/error-404.CDmSTChJ.css +0 -1
  108. package/dist/client/_nuxt/error-500.DpcyFY5F.css +0 -1
  109. package/dist/runtime/components/ScriptGoogleMaps.vue.d.ts +0 -145
@@ -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>;
@@ -0,0 +1,86 @@
1
+ import { withQuery } from "ufo";
2
+ import { useRegistryScript } from "../utils.js";
3
+ import { object, string, optional, array, union, boolean } from "#nuxt-scripts-validator";
4
+ export const PayPalOptions = object({
5
+ clientId: string(),
6
+ buyerCountry: optional(string()),
7
+ commit: optional(string()),
8
+ components: optional(union([string(), array(string())])),
9
+ currency: optional(string()),
10
+ debug: optional(union([string(), boolean()])),
11
+ disableFunding: optional(union([string(), array(string())])),
12
+ enableFunding: optional(union([string(), array(string())])),
13
+ integrationDate: optional(string()),
14
+ intent: optional(string()),
15
+ locale: optional(string()),
16
+ /**
17
+ * loadScript() supports an array for merchantId, even though
18
+ * merchant-id technically may not contain multiple values.
19
+ * For an array with a length of > 1 it automatically sets
20
+ * merchantId to "*" and moves the actual values to dataMerchantId
21
+ */
22
+ merchantId: optional(union([string(), array(string())])),
23
+ partnerAttributionId: optional(string()),
24
+ vault: optional(union([string(), boolean()])),
25
+ // own props
26
+ sandbox: optional(boolean())
27
+ });
28
+ export function useScriptPayPal(_options) {
29
+ return useRegistryScript("paypal", (options) => {
30
+ let dataMerchantId = void 0;
31
+ if (Array.isArray(options?.merchantId) && options?.merchantId.length > 1) {
32
+ dataMerchantId = JSON.stringify(options.merchantId);
33
+ options.merchantId = "*";
34
+ }
35
+ if (Array.isArray(options?.components)) {
36
+ options.components = options.components.join(",");
37
+ }
38
+ if (Array.isArray(options?.disableFunding)) {
39
+ options.disableFunding = options.disableFunding.join(",");
40
+ }
41
+ if (Array.isArray(options?.enableFunding)) {
42
+ options.enableFunding = options.enableFunding.join(",");
43
+ }
44
+ if (options?.sandbox === void 0) {
45
+ options.sandbox = import.meta.dev;
46
+ }
47
+ let components = ["buttons", "messages", "marks", "card-fields", "funding-eligibility"].join(",");
48
+ if (options.components) {
49
+ if (Array.isArray(options.components)) {
50
+ components = options.components.join(",");
51
+ } else {
52
+ components = options.components;
53
+ }
54
+ }
55
+ return {
56
+ scriptInput: {
57
+ "src": withQuery(options.sandbox ? "https://www.sandbox.paypal.com/sdk/js" : "https://www.paypal.com/sdk/js", {
58
+ "client-id": options.clientId,
59
+ "buyer-country": options.buyerCountry,
60
+ "commit": options.commit,
61
+ "components": components,
62
+ "currency": options.currency,
63
+ "debug": options.debug,
64
+ "disable-funding": options.disableFunding,
65
+ "enable-funding": options.enableFunding,
66
+ "integration-date": options.integrationDate,
67
+ "intent": options.intent,
68
+ "locale": options.locale,
69
+ "vault": options.vault
70
+ }),
71
+ "data-merchant-id": dataMerchantId,
72
+ "data-partner-attribution-id": options.partnerAttributionId
73
+ // TODO: maybe nuxt specific default
74
+ },
75
+ schema: import.meta.dev ? PayPalOptions : void 0,
76
+ // trigger: 'client',
77
+ scriptOptions: {
78
+ use() {
79
+ return {
80
+ paypal: window.paypal
81
+ };
82
+ }
83
+ }
84
+ };
85
+ }, _options);
86
+ }
@@ -0,0 +1,18 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ type RdtFns = ((event: 'init', id: string) => void) & ((event: 'track', eventName: string) => void);
3
+ export interface RedditPixelApi {
4
+ rdt: RdtFns & {
5
+ sendEvent: (rdt: RedditPixelApi['rdt'], args: unknown[]) => void;
6
+ callQueue: unknown[];
7
+ };
8
+ }
9
+ declare global {
10
+ interface Window extends RedditPixelApi {
11
+ }
12
+ }
13
+ export declare const RedditPixelOptions: import("valibot").ObjectSchema<{
14
+ readonly id: import("valibot").StringSchema<undefined>;
15
+ }, undefined>;
16
+ export type RedditPixelInput = RegistryScriptInput<typeof RedditPixelOptions, true, false, false>;
17
+ export declare function useScriptRedditPixel<T extends RedditPixelApi>(_options?: RedditPixelInput): import("#nuxt-scripts/types").UseScriptContext<T>;
18
+ export {};
@@ -0,0 +1,36 @@
1
+ import { useRegistryScript } from "../utils.js";
2
+ import { object, string } from "#nuxt-scripts-validator";
3
+ export const RedditPixelOptions = object({
4
+ id: string()
5
+ });
6
+ export function useScriptRedditPixel(_options) {
7
+ return useRegistryScript("redditPixel", (options) => {
8
+ return {
9
+ scriptInput: {
10
+ src: "https://www.redditstatic.com/ads/pixel.js",
11
+ async: true
12
+ },
13
+ clientInit: import.meta.server ? void 0 : () => {
14
+ const rdt = function(...args) {
15
+ if (rdt.sendEvent) {
16
+ rdt.sendEvent(rdt, args);
17
+ } else {
18
+ rdt.callQueue.push(args);
19
+ }
20
+ };
21
+ rdt.callQueue = [];
22
+ window.rdt = rdt;
23
+ if (options?.id) {
24
+ rdt("init", options.id);
25
+ rdt("track", "PageVisit");
26
+ }
27
+ },
28
+ schema: import.meta.dev ? RedditPixelOptions : void 0,
29
+ scriptOptions: {
30
+ use() {
31
+ return { rdt: window.rdt };
32
+ }
33
+ }
34
+ };
35
+ }, _options);
36
+ }
@@ -1,10 +1,10 @@
1
- import type { Stripe } from '@stripe/stripe-js';
1
+ import type { StripeConstructor } from '@stripe/stripe-js';
2
2
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
3
  export declare const StripeOptions: import("valibot").ObjectSchema<{
4
4
  readonly advancedFraudSignals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
5
5
  }, undefined>;
6
6
  export type StripeInput = RegistryScriptInput<typeof StripeOptions, false>;
7
7
  export interface StripeApi {
8
- Stripe: Stripe;
8
+ Stripe: StripeConstructor;
9
9
  }
10
10
  export declare function useScriptStripe<T extends StripeApi>(_options?: StripeInput): import("#nuxt-scripts/types").UseScriptContext<T>;
@@ -8,7 +8,7 @@ export function useScriptStripe(_options) {
8
8
  return useRegistryScript("stripe", (options) => ({
9
9
  scriptInput: {
10
10
  src: withQuery(
11
- `https://js.stripe.com/v3/`,
11
+ `https://js.stripe.com/basil/stripe.js`,
12
12
  typeof options?.advancedFraudSignals === "boolean" && !options?.advancedFraudSignals ? { advancedFraudSignals: false } : {}
13
13
  ),
14
14
  // opt-out of privacy defaults
@@ -1,7 +1,7 @@
1
1
  import type { Script } from '@unhead/vue/types';
2
2
  import type { UseScriptInput, VueScriptInstance, UseScriptOptions } from '@unhead/vue';
3
3
  import type { ComputedRef, Ref } from 'vue';
4
- import type { InferInput, ObjectSchema } from 'valibot';
4
+ import type { InferInput, ObjectSchema, ValiError } from 'valibot';
5
5
  import type { Import } from 'unimport';
6
6
  import type { SegmentInput } from './registry/segment.js';
7
7
  import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics.js';
@@ -26,6 +26,8 @@ import type { GoogleAnalyticsInput } from './registry/google-analytics.js';
26
26
  import type { GoogleTagManagerInput } from './registry/google-tag-manager.js';
27
27
  import type { UmamiAnalyticsInput } from './registry/umami-analytics.js';
28
28
  import type { RybbitAnalyticsInput } from './registry/rybbit-analytics.js';
29
+ import type { RedditPixelInput } from './registry/reddit-pixel.js';
30
+ import type { PayPalInput } from './registry/paypal.js';
29
31
  export type WarmupStrategy = false | 'preload' | 'preconnect' | 'dns-prefetch';
30
32
  export type UseScriptContext<T extends Record<symbol | string, any>> = VueScriptInstance<T>;
31
33
  export type NuxtUseScriptOptions<T extends Record<symbol | string, any> = {}> = Omit<UseScriptOptions<T>, 'trigger'> & {
@@ -41,9 +43,12 @@ export type NuxtUseScriptOptions<T extends Record<symbol | string, any> = {}> =
41
43
  * performance by avoiding the extra DNS lookup and reducing the number of requests. It also
42
44
  * improves privacy by not sharing the user's IP address with third-party servers.
43
45
  * - `true` - Bundle the script as an asset.
46
+ * - `'force'` - Bundle the script and force download, bypassing cache. Useful for development.
44
47
  * - `false` - Do not bundle the script. (default)
48
+ *
49
+ * Note: Using 'force' may significantly increase build time as scripts will be re-downloaded on every build.
45
50
  */
46
- bundle?: boolean;
51
+ bundle?: boolean | 'force';
47
52
  /**
48
53
  * Skip any schema validation for the script input. This is useful for loading the script stubs for development without
49
54
  * loading the actual script and not getting warnings.
@@ -59,10 +64,6 @@ export type NuxtUseScriptOptions<T extends Record<symbol | string, any> = {}> =
59
64
  * to `false` if the origin is the same.
60
65
  */
61
66
  warmupStrategy?: WarmupStrategy;
62
- /**
63
- * @internal
64
- */
65
- performanceMarkFeature?: string;
66
67
  /**
67
68
  * @internal
68
69
  */
@@ -78,9 +79,17 @@ export type NuxtUseScriptOptions<T extends Record<symbol | string, any> = {}> =
78
79
  */
79
80
  registryMeta?: Record<string, string>;
80
81
  };
82
+ /**
83
+ * @internal
84
+ */
85
+ _validate?: () => ValiError<any> | null | undefined;
81
86
  };
82
87
  export type NuxtUseScriptOptionsSerializable = Omit<NuxtUseScriptOptions, 'use' | 'skipValidation' | 'stub' | 'trigger' | 'eventContext' | 'beforeInit'> & {
83
- trigger?: 'client' | 'server' | 'onNuxtReady';
88
+ trigger?: 'client' | 'server' | 'onNuxtReady' | {
89
+ idleTimeout: number;
90
+ } | {
91
+ interaction: string[];
92
+ };
84
93
  };
85
94
  export type NuxtUseScriptInput = UseScriptInput;
86
95
  export interface TrackedPage {
@@ -128,8 +137,10 @@ export interface ScriptRegistry {
128
137
  googleTagManager?: GoogleTagManagerInput;
129
138
  hotjar?: HotjarInput;
130
139
  intercom?: IntercomInput;
140
+ paypal?: PayPalInput;
131
141
  matomoAnalytics?: MatomoAnalyticsInput;
132
142
  rybbitAnalytics?: RybbitAnalyticsInput;
143
+ redditPixel?: RedditPixelInput;
133
144
  segment?: SegmentInput;
134
145
  stripe?: StripeInput;
135
146
  xPixel?: XPixelInput;