@nuxt/scripts 0.13.2 → 1.0.0-beta.12

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 (150) hide show
  1. package/README.md +15 -0
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/48AF9EJD.js +1 -0
  5. package/dist/client/_nuxt/Bk6ed9rg.js +1 -0
  6. package/dist/client/_nuxt/C4Cj8gBr.js +162 -0
  7. package/dist/client/_nuxt/{Bje-0OHL.js → DP0kj6Xn.js} +1 -1
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/919b81d8-ed3a-4222-8a40-df0031cc3b99.json +1 -0
  10. package/dist/client/_nuxt/entry.D45OuV0w.css +1 -0
  11. package/dist/client/_nuxt/error-404.B57D-jUQ.css +1 -0
  12. package/dist/client/_nuxt/error-500.DTHUW7BI.css +1 -0
  13. package/dist/client/index.html +1 -1
  14. package/dist/module.d.mts +113 -4
  15. package/dist/module.d.ts +176 -0
  16. package/dist/module.json +1 -1
  17. package/dist/module.mjs +780 -299
  18. package/dist/registry.d.ts +6 -0
  19. package/dist/registry.mjs +94 -18
  20. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +30 -2
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +40 -15
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +30 -2
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +6 -6
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +7 -7
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +6 -6
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +12 -12
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +6 -6
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +21 -9
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +8 -8
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +21 -9
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +11 -5
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +7 -7
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +7 -7
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +7 -7
  35. package/dist/runtime/components/ScriptCrisp.d.vue.ts +1 -1
  36. package/dist/runtime/components/ScriptCrisp.vue +1 -1
  37. package/dist/runtime/components/ScriptCrisp.vue.d.ts +1 -1
  38. package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
  39. package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +53 -0
  40. package/dist/runtime/components/ScriptInstagramEmbed.vue +38 -0
  41. package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +53 -0
  42. package/dist/runtime/components/ScriptIntercom.d.vue.ts +1 -1
  43. package/dist/runtime/components/ScriptIntercom.vue +4 -3
  44. package/dist/runtime/components/ScriptIntercom.vue.d.ts +1 -1
  45. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +2 -2
  46. package/dist/runtime/components/ScriptPayPalButtons.vue +13 -11
  47. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +2 -2
  48. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +2 -2
  49. package/dist/runtime/components/ScriptPayPalMarks.vue +10 -8
  50. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +2 -2
  51. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +2 -2
  52. package/dist/runtime/components/ScriptPayPalMessages.vue +11 -9
  53. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +2 -2
  54. package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
  55. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +2 -2
  56. package/dist/runtime/components/ScriptVimeoPlayer.vue +1 -1
  57. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +2 -2
  58. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +82 -0
  59. package/dist/runtime/components/ScriptXEmbed.vue +76 -0
  60. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +82 -0
  61. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +12 -1
  62. package/dist/runtime/components/ScriptYouTubePlayer.vue +44 -16
  63. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +12 -1
  64. package/dist/runtime/composables/useScript.js +36 -5
  65. package/dist/runtime/composables/useScriptEventPage.js +2 -2
  66. package/dist/runtime/composables/useScriptTriggerConsent.js +1 -1
  67. package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
  68. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
  69. package/dist/runtime/composables/useScriptTriggerServiceWorker.d.ts +7 -0
  70. package/dist/runtime/composables/useScriptTriggerServiceWorker.js +39 -0
  71. package/dist/runtime/npm-script-stub.d.ts +20 -0
  72. package/dist/runtime/npm-script-stub.js +73 -0
  73. package/dist/runtime/registry/clarity.js +21 -25
  74. package/dist/runtime/registry/cloudflare-web-analytics.js +1 -1
  75. package/dist/runtime/registry/crisp.js +1 -1
  76. package/dist/runtime/registry/databuddy-analytics.js +1 -1
  77. package/dist/runtime/registry/fathom-analytics.js +1 -1
  78. package/dist/runtime/registry/google-adsense.js +1 -1
  79. package/dist/runtime/registry/google-analytics.js +2 -2
  80. package/dist/runtime/registry/google-maps.d.ts +1 -1
  81. package/dist/runtime/registry/google-maps.js +1 -1
  82. package/dist/runtime/registry/google-recaptcha.d.ts +27 -0
  83. package/dist/runtime/registry/google-recaptcha.js +45 -0
  84. package/dist/runtime/registry/google-sign-in.d.ts +84 -0
  85. package/dist/runtime/registry/google-sign-in.js +50 -0
  86. package/dist/runtime/registry/google-tag-manager.d.ts +4 -2
  87. package/dist/runtime/registry/google-tag-manager.js +16 -6
  88. package/dist/runtime/registry/hotjar.js +1 -1
  89. package/dist/runtime/registry/instagram-embed.d.ts +23 -0
  90. package/dist/runtime/registry/instagram-embed.js +22 -0
  91. package/dist/runtime/registry/intercom.js +1 -1
  92. package/dist/runtime/registry/lemon-squeezy.d.ts +0 -1
  93. package/dist/runtime/registry/matomo-analytics.js +3 -3
  94. package/dist/runtime/registry/meta-pixel.js +1 -1
  95. package/dist/runtime/registry/npm.js +1 -1
  96. package/dist/runtime/registry/paypal.d.ts +1 -1
  97. package/dist/runtime/registry/paypal.js +2 -2
  98. package/dist/runtime/registry/plausible-analytics.js +21 -13
  99. package/dist/runtime/registry/posthog.d.ts +27 -0
  100. package/dist/runtime/registry/posthog.js +88 -0
  101. package/dist/runtime/registry/reddit-pixel.js +1 -1
  102. package/dist/runtime/registry/rybbit-analytics.js +41 -9
  103. package/dist/runtime/registry/segment.js +1 -1
  104. package/dist/runtime/registry/snapchat-pixel.js +1 -1
  105. package/dist/runtime/registry/stripe.d.ts +1 -1
  106. package/dist/runtime/registry/stripe.js +1 -1
  107. package/dist/runtime/registry/tiktok-pixel.d.ts +44 -0
  108. package/dist/runtime/registry/tiktok-pixel.js +44 -0
  109. package/dist/runtime/registry/umami-analytics.js +1 -1
  110. package/dist/runtime/registry/vimeo-player.d.ts +2 -2
  111. package/dist/runtime/registry/vimeo-player.js +1 -1
  112. package/dist/runtime/registry/x-embed.d.ts +77 -0
  113. package/dist/runtime/registry/x-embed.js +41 -0
  114. package/dist/runtime/registry/x-pixel.js +1 -1
  115. package/dist/runtime/registry/youtube-player.d.ts +7 -7
  116. package/dist/runtime/registry/youtube-player.js +1 -1
  117. package/dist/runtime/server/google-static-maps-proxy.d.ts +2 -0
  118. package/dist/runtime/server/google-static-maps-proxy.js +54 -0
  119. package/dist/runtime/server/instagram-embed-asset.d.ts +2 -0
  120. package/dist/runtime/server/instagram-embed-asset.js +42 -0
  121. package/dist/runtime/server/instagram-embed-image.d.ts +2 -0
  122. package/dist/runtime/server/instagram-embed-image.js +54 -0
  123. package/dist/runtime/server/instagram-embed.d.ts +2 -0
  124. package/dist/runtime/server/instagram-embed.js +91 -0
  125. package/dist/runtime/server/proxy-handler.d.ts +6 -0
  126. package/dist/runtime/server/proxy-handler.js +264 -0
  127. package/dist/runtime/server/utils/privacy.d.ts +141 -0
  128. package/dist/runtime/server/utils/privacy.js +324 -0
  129. package/dist/runtime/server/x-embed-image.d.ts +2 -0
  130. package/dist/runtime/server/x-embed-image.js +53 -0
  131. package/dist/runtime/server/x-embed.d.ts +49 -0
  132. package/dist/runtime/server/x-embed.js +31 -0
  133. package/dist/runtime/types.d.ts +61 -20
  134. package/dist/runtime/utils/pure.d.ts +9 -0
  135. package/dist/runtime/utils/pure.js +0 -0
  136. package/dist/runtime/utils.d.ts +5 -4
  137. package/dist/runtime/utils.js +12 -2
  138. package/dist/shared/scripts.DLRgvHQg.mjs +288 -0
  139. package/dist/stats.d.mts +39 -0
  140. package/dist/stats.d.ts +39 -0
  141. package/dist/stats.mjs +711 -0
  142. package/dist/types.d.mts +1 -1
  143. package/package.json +59 -46
  144. package/dist/client/_nuxt/DMut0W-e.js +0 -162
  145. package/dist/client/_nuxt/builds/meta/5e0206fe-a683-423c-8d59-2596d0b16fee.json +0 -1
  146. package/dist/client/_nuxt/entry.BjfcJo5q.css +0 -1
  147. package/dist/client/_nuxt/error-404.B0ZhSNwd.css +0 -1
  148. package/dist/client/_nuxt/error-500.D4MdgPaC.css +0 -1
  149. package/dist/client/_nuxt/iNmKC7TZ.js +0 -1
  150. package/dist/client/_nuxt/rttsH3SL.js +0 -1
@@ -0,0 +1,84 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ export interface CredentialResponse {
3
+ credential: string;
4
+ select_by: 'auto' | 'user' | 'user_1tap' | 'user_2tap' | 'btn' | 'btn_confirm' | 'btn_add_session' | 'btn_confirm_add_session';
5
+ clientId?: string;
6
+ }
7
+ export interface IdConfiguration {
8
+ client_id: string;
9
+ auto_select?: boolean;
10
+ callback?: (response: CredentialResponse) => void;
11
+ login_uri?: string;
12
+ native_callback?: (response: CredentialResponse) => void;
13
+ cancel_on_tap_outside?: boolean;
14
+ prompt_parent_id?: string;
15
+ nonce?: string;
16
+ context?: 'signin' | 'signup' | 'use';
17
+ state_cookie_domain?: string;
18
+ ux_mode?: 'popup' | 'redirect';
19
+ allowed_parent_origin?: string | string[];
20
+ intermediate_iframe_close_callback?: () => void;
21
+ itp_support?: boolean;
22
+ login_hint?: string;
23
+ hd?: string;
24
+ use_fedcm_for_prompt?: boolean;
25
+ }
26
+ export interface GsiButtonConfiguration {
27
+ type?: 'standard' | 'icon';
28
+ theme?: 'outline' | 'filled_blue' | 'filled_black';
29
+ size?: 'large' | 'medium' | 'small';
30
+ text?: 'signin_with' | 'signup_with' | 'continue_with' | 'signin';
31
+ shape?: 'rectangular' | 'pill' | 'circle' | 'square';
32
+ logo_alignment?: 'left' | 'center';
33
+ width?: string | number;
34
+ locale?: string;
35
+ click_listener?: () => void;
36
+ use_fedcm?: boolean;
37
+ }
38
+ export type MomentType = 'display' | 'skipped' | 'dismissed';
39
+ export interface MomentNotification {
40
+ isDisplayMoment: () => boolean;
41
+ isDisplayed: () => boolean;
42
+ isNotDisplayed: () => boolean;
43
+ getNotDisplayedReason: () => 'browser_not_supported' | 'invalid_client' | 'missing_client_id' | 'opt_out_or_no_session' | 'secure_http_required' | 'suppressed_by_user' | 'unregistered_origin' | 'unknown_reason';
44
+ isSkippedMoment: () => boolean;
45
+ getSkippedReason: () => 'auto_cancel' | 'user_cancel' | 'tap_outside' | 'issuing_failed';
46
+ isDismissedMoment: () => boolean;
47
+ getDismissedReason: () => 'credential_returned' | 'cancel_called' | 'flow_restarted';
48
+ getMomentType: () => MomentType;
49
+ }
50
+ export interface RevocationResponse {
51
+ successful: boolean;
52
+ error?: string;
53
+ }
54
+ declare namespace google {
55
+ namespace accounts {
56
+ namespace id {
57
+ function initialize(config: IdConfiguration): void;
58
+ function prompt(momentListener?: (notification: MomentNotification) => void): void;
59
+ function renderButton(parent: HTMLElement, options: GsiButtonConfiguration): void;
60
+ function disableAutoSelect(): void;
61
+ function cancel(): void;
62
+ function revoke(hint: string, callback: (response: RevocationResponse) => void): void;
63
+ }
64
+ }
65
+ }
66
+ type AccountsNamespace = typeof google.accounts;
67
+ export interface GoogleSignInApi {
68
+ accounts: AccountsNamespace;
69
+ }
70
+ export declare const GoogleSignInOptions: import("valibot").ObjectSchema<{
71
+ readonly clientId: import("valibot").StringSchema<undefined>;
72
+ readonly autoSelect: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
73
+ readonly context: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"signin", undefined>, import("valibot").LiteralSchema<"signup", undefined>, import("valibot").LiteralSchema<"use", undefined>], undefined>, undefined>;
74
+ readonly useFedcmForPrompt: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
75
+ readonly cancelOnTapOutside: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
76
+ readonly uxMode: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"popup", undefined>, import("valibot").LiteralSchema<"redirect", undefined>], undefined>, undefined>;
77
+ readonly loginUri: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
78
+ readonly itpSupport: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
79
+ readonly allowedParentOrigin: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>], undefined>, undefined>;
80
+ readonly hd: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
81
+ }, undefined>;
82
+ export type GoogleSignInInput = RegistryScriptInput<typeof GoogleSignInOptions>;
83
+ export declare function useScriptGoogleSignIn<T extends GoogleSignInApi>(_options?: GoogleSignInInput): import("#nuxt-scripts/types").UseScriptContext<T>;
84
+ export {};
@@ -0,0 +1,50 @@
1
+ import { array, boolean, literal, object, optional, string, union } from "#nuxt-scripts-validator";
2
+ import { useRegistryScript } from "#nuxt-scripts/utils";
3
+ export const GoogleSignInOptions = object({
4
+ clientId: string(),
5
+ // Auto-select credentials if only one is available
6
+ autoSelect: optional(boolean()),
7
+ // Context for One Tap (signin, signup, or use)
8
+ context: optional(union([literal("signin"), literal("signup"), literal("use")])),
9
+ // FedCM API support (Privacy Sandbox) - mandatory from August 2025
10
+ useFedcmForPrompt: optional(boolean()),
11
+ // Cancel One Tap if user clicks outside
12
+ cancelOnTapOutside: optional(boolean()),
13
+ // UX mode: popup or redirect
14
+ uxMode: optional(union([literal("popup"), literal("redirect")])),
15
+ // Login URI for redirect flow
16
+ loginUri: optional(string()),
17
+ // ITP (Intelligent Tracking Prevention) support
18
+ itpSupport: optional(boolean()),
19
+ // Allowed parent origins for iframe embedding
20
+ allowedParentOrigin: optional(union([string(), array(string())])),
21
+ // Hosted domain - restrict to specific Google Workspace domain
22
+ hd: optional(string())
23
+ });
24
+ export function useScriptGoogleSignIn(_options) {
25
+ return useRegistryScript(_options?.key || "googleSignIn", () => {
26
+ return {
27
+ scriptInput: {
28
+ src: "https://accounts.google.com/gsi/client",
29
+ // Performance best practice: async + defer to prevent render blocking
30
+ defer: true,
31
+ // Google's script doesn't support CORS
32
+ crossorigin: false
33
+ },
34
+ schema: import.meta.dev ? GoogleSignInOptions : void 0,
35
+ scriptOptions: {
36
+ use() {
37
+ return {
38
+ accounts: window.google?.accounts
39
+ };
40
+ }
41
+ },
42
+ clientInit: import.meta.server ? void 0 : () => {
43
+ const w = window;
44
+ w.google = w.google || {};
45
+ w.google.accounts = w.google.accounts || {};
46
+ w.google.accounts.id = w.google.accounts.id || {};
47
+ }
48
+ };
49
+ }, _options);
50
+ }
@@ -1,5 +1,5 @@
1
- import type { GTag } from './google-analytics.js';
2
1
  import type { NuxtUseScriptOptions, RegistryScriptInput, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
2
+ import type { GTag } from './google-analytics.js';
3
3
  /**
4
4
  * Improved DataLayer type that better reflects GTM's capabilities
5
5
  * Can contain either gtag event parameters or custom data objects
@@ -11,7 +11,7 @@ export type DataLayer = Array<DataLayerItem>;
11
11
  */
12
12
  export interface DataLayerPush {
13
13
  (...args: Parameters<GTag>): void;
14
- (obj: Record<string, unknown>): void;
14
+ (obj: Record<string, unknown> | any[]): void;
15
15
  }
16
16
  /**
17
17
  * Improved DataLayer API type with more precise methods
@@ -89,6 +89,8 @@ export declare const GoogleTagManagerOptions: import("valibot").ObjectSchema<{
89
89
  readonly envName: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
90
90
  /** Referrer policy for analytics requests */
91
91
  readonly authReferrerPolicy: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
92
+ /** Default consent settings for GTM */
93
+ readonly defaultConsent: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").StringSchema<undefined>, import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>], undefined>, undefined>, undefined>;
92
94
  }, undefined>;
93
95
  export type GoogleTagManagerInput = RegistryScriptInput<typeof GoogleTagManagerOptions>;
94
96
  /**
@@ -1,6 +1,6 @@
1
- import { withQuery } from "ufo";
1
+ import { boolean, literal, number, object, optional, record, string, union } from "#nuxt-scripts-validator";
2
2
  import { useRegistryScript } from "#nuxt-scripts/utils";
3
- import { object, string, optional, boolean, union, literal } from "#nuxt-scripts-validator";
3
+ import { withQuery } from "ufo";
4
4
  export const GoogleTagManagerOptions = object({
5
5
  /** GTM container ID (format: GTM-XXXXXX) */
6
6
  id: string(),
@@ -21,10 +21,12 @@ export const GoogleTagManagerOptions = object({
21
21
  /** Environment name for environment-specific container */
22
22
  envName: optional(string()),
23
23
  /** Referrer policy for analytics requests */
24
- authReferrerPolicy: optional(string())
24
+ authReferrerPolicy: optional(string()),
25
+ /** Default consent settings for GTM */
26
+ defaultConsent: optional(record(string(), union([string(), number()])))
25
27
  });
26
28
  export function useScriptGoogleTagManager(options) {
27
- return useRegistryScript(
29
+ const instance = useRegistryScript(
28
30
  options?.key || "googleTagManager",
29
31
  (opts) => {
30
32
  const dataLayerName = opts?.l ?? opts?.dataLayer ?? "dataLayer";
@@ -54,11 +56,13 @@ export function useScriptGoogleTagManager(options) {
54
56
  },
55
57
  clientInit: import.meta.server ? void 0 : () => {
56
58
  window[dataLayerName] = window[dataLayerName] || [];
57
- function gtag() {
58
- window[dataLayerName].push(arguments);
59
+ function gtag(...args) {
60
+ window[dataLayerName].push(args);
59
61
  }
60
62
  window.gtag = gtag;
61
63
  options?.onBeforeGtmStart?.(gtag);
64
+ if (opts.defaultConsent)
65
+ gtag("consent", "default", opts.defaultConsent);
62
66
  window[dataLayerName].push({
63
67
  "gtm.start": (/* @__PURE__ */ new Date()).getTime(),
64
68
  "event": "gtm.js"
@@ -68,4 +72,10 @@ export function useScriptGoogleTagManager(options) {
68
72
  },
69
73
  options
70
74
  );
75
+ if (import.meta.client && options?.onBeforeGtmStart) {
76
+ const gtag = window.gtag;
77
+ if (gtag)
78
+ options.onBeforeGtmStart(gtag);
79
+ }
80
+ return instance;
71
81
  }
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "../utils.js";
2
1
  import { number, object, optional } from "#nuxt-scripts-validator";
2
+ import { useRegistryScript } from "../utils.js";
3
3
  export const HotjarOptions = object({
4
4
  id: number(),
5
5
  sv: optional(number())
@@ -0,0 +1,23 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ export declare const InstagramEmbedOptions: import("valibot").ObjectSchema<{
3
+ /**
4
+ * The Instagram post URL to embed
5
+ * e.g., https://www.instagram.com/p/ABC123/
6
+ */
7
+ readonly postUrl: import("valibot").StringSchema<undefined>;
8
+ /**
9
+ * Whether to include captions in the embed
10
+ * @default true
11
+ */
12
+ readonly captions: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
13
+ /**
14
+ * Custom API endpoint for fetching embed HTML
15
+ * @default '/api/_scripts/instagram-embed'
16
+ */
17
+ readonly apiEndpoint: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
18
+ }, undefined>;
19
+ export type InstagramEmbedInput = RegistryScriptInput<typeof InstagramEmbedOptions, false, false, false>;
20
+ /**
21
+ * Extract the post shortcode from an Instagram URL
22
+ */
23
+ export declare function extractInstagramShortcode(url: string): string | undefined;
@@ -0,0 +1,22 @@
1
+ import { boolean, object, optional, string } from "#nuxt-scripts-validator";
2
+ export const InstagramEmbedOptions = object({
3
+ /**
4
+ * The Instagram post URL to embed
5
+ * e.g., https://www.instagram.com/p/ABC123/
6
+ */
7
+ postUrl: string(),
8
+ /**
9
+ * Whether to include captions in the embed
10
+ * @default true
11
+ */
12
+ captions: optional(boolean()),
13
+ /**
14
+ * Custom API endpoint for fetching embed HTML
15
+ * @default '/api/_scripts/instagram-embed'
16
+ */
17
+ apiEndpoint: optional(string())
18
+ });
19
+ export function extractInstagramShortcode(url) {
20
+ const match = url.match(/instagram\.com\/(?:p|reel|tv)\/([^/?]+)/);
21
+ return match?.[1];
22
+ }
@@ -1,6 +1,6 @@
1
+ import { literal, number, object, optional, string, union } from "#nuxt-scripts-validator";
1
2
  import { joinURL } from "ufo";
2
3
  import { useRegistryScript } from "../utils.js";
3
- import { literal, number, object, optional, string, union } from "#nuxt-scripts-validator";
4
4
  export const IntercomOptions = object({
5
5
  app_id: string(),
6
6
  api_base: optional(union([literal("https://api-iam.intercom.io"), literal("https://api-iam.eu.intercom.io"), literal("https://api-iam.au.intercom.io")])),
@@ -21,7 +21,6 @@ export type LemonSqueezyEventPayload = {
21
21
  export interface LemonSqueezyApi {
22
22
  /**
23
23
  * Initialises Lemon.js on your page.
24
- * @param options - An object with a single property, eventHandler, which is a function that will be called when Lemon.js emits an event.
25
24
  */
26
25
  Setup: (options: {
27
26
  eventHandler: (event: LemonSqueezyEventPayload) => void;
@@ -1,8 +1,8 @@
1
+ import { boolean, number, object, optional, string, union } from "#nuxt-scripts-validator";
1
2
  import { withBase, withHttps, withoutProtocol, withoutTrailingSlash } from "ufo";
2
- import { useRegistryScript } from "../utils.js";
3
3
  import { useScriptEventPage } from "../composables/useScriptEventPage.js";
4
- import { boolean, object, optional, string, number, union } from "#nuxt-scripts-validator";
5
4
  import { logger } from "../logger.js";
5
+ import { useRegistryScript } from "../utils.js";
6
6
  export const MatomoAnalyticsOptions = object({
7
7
  matomoUrl: optional(string()),
8
8
  siteId: optional(union([string(), number()])),
@@ -46,7 +46,7 @@ export function useScriptMatomoAnalytics(_options) {
46
46
  _paq.push(["disableCookies"]);
47
47
  }
48
48
  if (options?.trackerUrl || options?.matomoUrl) {
49
- _paq.push(["setTrackerUrl", options?.trackerUrl ? withHttps(options.trackerUrl) : withBase(`/matomo.php`, withHttps(options?.matomoUrl || ""))]);
49
+ _paq.push(["setTrackerUrl", options?.trackerUrl ?? withBase(`/matomo.php`, options?.matomoUrl || "")]);
50
50
  } else if (normalizedCloudId) {
51
51
  _paq.push(["setTrackerUrl", withBase(`/matomo.php`, withHttps(normalizedCloudId))]);
52
52
  }
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "../utils.js";
2
1
  import { number, object, string, union } from "#nuxt-scripts-validator";
2
+ import { useRegistryScript } from "../utils.js";
3
3
  export const MetaPixelOptions = object({
4
4
  id: union([string(), number()])
5
5
  });
@@ -1,6 +1,6 @@
1
+ import { literal, object, optional, string, union } from "#nuxt-scripts-validator";
1
2
  import { withBase } from "ufo";
2
3
  import { useRegistryScript } from "../utils.js";
3
- import { object, optional, string, union, literal } from "#nuxt-scripts-validator";
4
4
  const PROVIDERS = ["jsdelivr", "cdnjs", "unpkg"];
5
5
  const providerValidator = union(PROVIDERS.map((provider) => literal(provider)));
6
6
  export const NpmOptions = object({
@@ -1,5 +1,5 @@
1
- import type { PayPalNamespace } from '@paypal/paypal-js';
2
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import type { PayPalNamespace } from '@paypal/paypal-js';
3
3
  export interface PayPalApi {
4
4
  paypal: PayPalNamespace;
5
5
  }
@@ -1,6 +1,6 @@
1
+ import { array, boolean, object, optional, string, union } from "#nuxt-scripts-validator";
1
2
  import { withQuery } from "ufo";
2
3
  import { useRegistryScript } from "../utils.js";
3
- import { object, string, optional, array, union, boolean } from "#nuxt-scripts-validator";
4
4
  export const PayPalOptions = object({
5
5
  clientId: string(),
6
6
  buyerCountry: optional(string()),
@@ -27,7 +27,7 @@ export const PayPalOptions = object({
27
27
  });
28
28
  export function useScriptPayPal(_options) {
29
29
  return useRegistryScript("paypal", (options) => {
30
- let dataMerchantId = void 0;
30
+ let dataMerchantId;
31
31
  if (Array.isArray(options?.merchantId) && options?.merchantId.length > 1) {
32
32
  dataMerchantId = JSON.stringify(options.merchantId);
33
33
  options.merchantId = "*";
@@ -1,6 +1,6 @@
1
- import { useRegistryScript } from "../utils.js";
2
1
  import { any, array, boolean, literal, object, optional, record, string, union } from "#nuxt-scripts-validator";
3
2
  import { logger } from "../logger.js";
3
+ import { useRegistryScript } from "../utils.js";
4
4
  const extensions = [
5
5
  literal("hash"),
6
6
  literal("outbound-links"),
@@ -55,12 +55,18 @@ export function useScriptPlausibleAnalytics(_options) {
55
55
  scriptSrc = "https://plausible.io/js/script.js";
56
56
  }
57
57
  const initOptions = {};
58
- if (options?.customProperties) initOptions.customProperties = options.customProperties;
59
- if (options?.endpoint) initOptions.endpoint = options.endpoint;
60
- if (options?.fileDownloads) initOptions.fileDownloads = options.fileDownloads;
61
- if (options?.hashBasedRouting !== void 0) initOptions.hashBasedRouting = options.hashBasedRouting;
62
- if (options?.autoCapturePageviews !== void 0) initOptions.autoCapturePageviews = options.autoCapturePageviews;
63
- if (options?.captureOnLocalhost !== void 0) initOptions.captureOnLocalhost = options.captureOnLocalhost;
58
+ if (options?.customProperties)
59
+ initOptions.customProperties = options.customProperties;
60
+ if (options?.endpoint)
61
+ initOptions.endpoint = options.endpoint;
62
+ if (options?.fileDownloads)
63
+ initOptions.fileDownloads = options.fileDownloads;
64
+ if (options?.hashBasedRouting !== void 0)
65
+ initOptions.hashBasedRouting = options.hashBasedRouting;
66
+ if (options?.autoCapturePageviews !== void 0)
67
+ initOptions.autoCapturePageviews = options.autoCapturePageviews;
68
+ if (options?.captureOnLocalhost !== void 0)
69
+ initOptions.captureOnLocalhost = options.captureOnLocalhost;
64
70
  const scriptInput = !useNewScript && options?.domain ? {
65
71
  "src": scriptSrc,
66
72
  "data-domain": options.domain
@@ -74,13 +80,15 @@ export function useScriptPlausibleAnalytics(_options) {
74
80
  use() {
75
81
  return { plausible: window.plausible };
76
82
  },
77
- clientInit() {
78
- window.plausible = window.plausible || function() {
79
- (plausible.q = plausible.q || []).push(arguments);
80
- }, plausible.init = plausible.init || function(i) {
81
- plausible.o = i || {};
83
+ clientInit: import.meta.server ? void 0 : () => {
84
+ const w = window;
85
+ w.plausible = w.plausible || function(...args) {
86
+ (w.plausible.q = w.plausible.q || []).push(args);
87
+ };
88
+ w.plausible.init = w.plausible.init || function(i) {
89
+ w.plausible.o = i || {};
82
90
  };
83
- window.plausible.init(initOptions);
91
+ w.plausible.init(initOptions);
84
92
  }
85
93
  }
86
94
  };
@@ -0,0 +1,27 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import type { PostHog } from 'posthog-js';
3
+ export declare const PostHogOptions: import("valibot").ObjectSchema<{
4
+ readonly apiKey: import("valibot").StringSchema<undefined>;
5
+ readonly region: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"us", undefined>, import("valibot").LiteralSchema<"eu", undefined>], undefined>, undefined>;
6
+ readonly apiHost: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
7
+ readonly autocapture: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
8
+ readonly capturePageview: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"history_change", undefined>], undefined>, undefined>;
9
+ readonly capturePageleave: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
10
+ readonly disableSessionRecording: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
11
+ readonly config: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").StringSchema<undefined>, import("valibot").AnySchema, undefined>, undefined>;
12
+ }, undefined>;
13
+ export type PostHogInput = RegistryScriptInput<typeof PostHogOptions, false, true>;
14
+ export interface PostHogApi {
15
+ posthog: PostHog;
16
+ }
17
+ declare global {
18
+ interface Window {
19
+ posthog?: PostHog;
20
+ __posthogInitPromise?: Promise<PostHog | undefined>;
21
+ _posthogQueue?: {
22
+ prop: string | symbol;
23
+ args: any[];
24
+ }[];
25
+ }
26
+ }
27
+ export declare function useScriptPostHog<T extends PostHogApi>(_options?: PostHogInput): import("#nuxt-scripts/types").UseScriptContext<T>;
@@ -0,0 +1,88 @@
1
+ import { any, boolean, literal, object, optional, record, string, union } from "#nuxt-scripts-validator";
2
+ import { logger } from "../logger.js";
3
+ import { useRegistryScript } from "../utils.js";
4
+ export const PostHogOptions = object({
5
+ apiKey: string(),
6
+ region: optional(union([literal("us"), literal("eu")])),
7
+ apiHost: optional(string()),
8
+ autocapture: optional(boolean()),
9
+ capturePageview: optional(union([boolean(), literal("history_change")])),
10
+ capturePageleave: optional(boolean()),
11
+ disableSessionRecording: optional(boolean()),
12
+ config: optional(record(string(), any()))
13
+ });
14
+ export function useScriptPostHog(_options) {
15
+ return useRegistryScript("posthog", (options) => {
16
+ return {
17
+ scriptMode: "npm",
18
+ // Use NPM mode - no external script tag
19
+ schema: import.meta.dev ? PostHogOptions : void 0,
20
+ scriptOptions: {
21
+ use() {
22
+ if (import.meta.server)
23
+ return { posthog: {} };
24
+ if (window.posthog)
25
+ return { posthog: window.posthog };
26
+ const posthog = new Proxy({}, {
27
+ get(_, prop) {
28
+ if (window.posthog)
29
+ return window.posthog[prop];
30
+ if (prop === "then")
31
+ return void 0;
32
+ return (...args) => {
33
+ if (window.posthog)
34
+ return window.posthog[prop](...args);
35
+ window._posthogQueue = window._posthogQueue || [];
36
+ window._posthogQueue.push({ prop, args });
37
+ };
38
+ }
39
+ });
40
+ return { posthog };
41
+ }
42
+ },
43
+ clientInit: import.meta.server ? void 0 : async () => {
44
+ if (window.__posthogInitPromise || window.posthog)
45
+ return;
46
+ if (!options?.apiKey) {
47
+ logger.warn("PostHog apiKey is required");
48
+ return;
49
+ }
50
+ const region = options?.region || "us";
51
+ let apiHost = options?.apiHost || (region === "eu" ? "https://eu.i.posthog.com" : "https://us.i.posthog.com");
52
+ if (apiHost.startsWith("/"))
53
+ apiHost = window.location.origin + apiHost;
54
+ window.__posthogInitPromise = import("posthog-js").then(({ default: posthog }) => {
55
+ const config = {
56
+ api_host: apiHost,
57
+ ...options?.config
58
+ };
59
+ if (typeof options?.autocapture === "boolean")
60
+ config.autocapture = options.autocapture;
61
+ if (typeof options?.capturePageview === "boolean" || options?.capturePageview === "history_change")
62
+ config.capture_pageview = options.capturePageview;
63
+ if (typeof options?.capturePageleave === "boolean")
64
+ config.capture_pageleave = options.capturePageleave;
65
+ if (typeof options?.disableSessionRecording === "boolean")
66
+ config.disable_session_recording = options.disableSessionRecording;
67
+ const instance = posthog.init(options.apiKey, config);
68
+ if (!instance) {
69
+ logger.error("PostHog init returned undefined - initialization failed");
70
+ delete window._posthogQueue;
71
+ return void 0;
72
+ }
73
+ window.posthog = instance;
74
+ if (window._posthogQueue && window._posthogQueue.length > 0) {
75
+ window._posthogQueue.forEach((q) => window.posthog[q.prop]?.(...q.args));
76
+ delete window._posthogQueue;
77
+ }
78
+ return window.posthog;
79
+ }).catch((e) => {
80
+ logger.error("Failed to load posthog-js:", e);
81
+ delete window._posthogQueue;
82
+ return void 0;
83
+ });
84
+ return window.__posthogInitPromise;
85
+ }
86
+ };
87
+ }, _options);
88
+ }
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "../utils.js";
2
1
  import { object, string } from "#nuxt-scripts-validator";
2
+ import { useRegistryScript } from "../utils.js";
3
3
  export const RedditPixelOptions = object({
4
4
  id: string()
5
5
  });
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "../utils.js";
2
1
  import { array, boolean, number, object, optional, string, union } from "#nuxt-scripts-validator";
2
+ import { useRegistryScript } from "../utils.js";
3
3
  export const RybbitAnalyticsOptions = object({
4
4
  siteId: union([string(), number()]),
5
5
  // required
@@ -15,7 +15,41 @@ export const RybbitAnalyticsOptions = object({
15
15
  debounce: optional(number()),
16
16
  apiKey: optional(string())
17
17
  });
18
+ const RYBBIT_QUEUE_KEY = Symbol.for("nuxt-scripts.rybbit-queue");
19
+ function getRybbitState() {
20
+ if (!import.meta.client)
21
+ return;
22
+ const g = globalThis;
23
+ if (!g[RYBBIT_QUEUE_KEY]) {
24
+ g[RYBBIT_QUEUE_KEY] = { queue: [], flushed: false };
25
+ }
26
+ return g[RYBBIT_QUEUE_KEY];
27
+ }
18
28
  export function useScriptRybbitAnalytics(_options) {
29
+ const isRybbitReady = () => import.meta.client && typeof window !== "undefined" && window.rybbit && typeof window.rybbit.event === "function";
30
+ const flushQueue = () => {
31
+ const state = getRybbitState();
32
+ if (!state || state.flushed || !isRybbitReady())
33
+ return;
34
+ state.flushed = true;
35
+ while (state.queue.length > 0) {
36
+ const [method, ...args] = state.queue.shift();
37
+ const fn = window.rybbit[method];
38
+ if (typeof fn === "function") {
39
+ fn.apply(window.rybbit, args);
40
+ }
41
+ }
42
+ };
43
+ const callOrQueue = (method, ...args) => {
44
+ if (isRybbitReady()) {
45
+ const fn = window.rybbit[method];
46
+ if (typeof fn === "function") {
47
+ fn.apply(window.rybbit, args);
48
+ }
49
+ } else {
50
+ getRybbitState()?.queue.push([method, ...args]);
51
+ }
52
+ };
19
53
  return useRegistryScript("rybbitAnalytics", (options) => {
20
54
  return {
21
55
  scriptInput: {
@@ -36,15 +70,13 @@ export function useScriptRybbitAnalytics(_options) {
36
70
  schema: import.meta.dev ? RybbitAnalyticsOptions : void 0,
37
71
  scriptOptions: {
38
72
  use() {
39
- if (typeof window.rybbit === "undefined") {
40
- return null;
41
- }
73
+ flushQueue();
42
74
  return {
43
- pageview: window.rybbit.pageview,
44
- event: window.rybbit.event,
45
- identify: window.rybbit.identify,
46
- clearUserId: window.rybbit.clearUserId,
47
- getUserId: window.rybbit.getUserId,
75
+ pageview: () => callOrQueue("pageview"),
76
+ event: (name, properties) => callOrQueue("event", name, properties),
77
+ identify: (userId) => callOrQueue("identify", userId),
78
+ clearUserId: () => callOrQueue("clearUserId"),
79
+ getUserId: () => window.rybbit?.getUserId?.() ?? null,
48
80
  rybbit: window.rybbit
49
81
  };
50
82
  }
@@ -1,6 +1,6 @@
1
+ import { object, optional, string } from "#nuxt-scripts-validator";
1
2
  import { joinURL } from "ufo";
2
3
  import { useRegistryScript } from "../utils.js";
3
- import { object, optional, string } from "#nuxt-scripts-validator";
4
4
  export const SegmentOptions = object({
5
5
  writeKey: string(),
6
6
  analyticsKey: optional(string())
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "../utils.js";
2
1
  import { boolean, object, optional, string } from "#nuxt-scripts-validator";
2
+ import { useRegistryScript } from "../utils.js";
3
3
  export const InitObjectPropertiesSchema = object({
4
4
  user_email: optional(string()),
5
5
  ip_address: optional(string()),
@@ -1,5 +1,5 @@
1
- import type { StripeConstructor } from '@stripe/stripe-js';
2
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import type { StripeConstructor } from '@stripe/stripe-js';
3
3
  export declare const StripeOptions: import("valibot").ObjectSchema<{
4
4
  readonly advancedFraudSignals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
5
5
  }, undefined>;
@@ -1,6 +1,6 @@
1
+ import { boolean, object, optional } from "#nuxt-scripts-validator";
1
2
  import { withQuery } from "ufo";
2
3
  import { useRegistryScript } from "../utils.js";
3
- import { boolean, object, optional } from "#nuxt-scripts-validator";
4
4
  export const StripeOptions = object({
5
5
  advancedFraudSignals: optional(boolean())
6
6
  });