@nuxt/scripts 1.0.4 → 1.0.5

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 (47) hide show
  1. package/dist/devtools-client/200.html +1 -1
  2. package/dist/devtools-client/404.html +1 -1
  3. package/dist/devtools-client/_nuxt/BNvWpYaC.js +188 -0
  4. package/dist/devtools-client/_nuxt/{DxyiGojb.js → CApasjik.js} +1 -1
  5. package/dist/devtools-client/_nuxt/{13TuIchK.js → CTPc9yIZ.js} +1 -1
  6. package/dist/devtools-client/_nuxt/{CWELSfs5.js → CbCcQNvm.js} +1 -1
  7. package/dist/devtools-client/_nuxt/{32RpwIYg.js → Dj5q49Yv.js} +1 -1
  8. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  9. package/dist/devtools-client/_nuxt/builds/meta/caa75c14-abb0-4d9e-8f1a-440e91f4b1eb.json +1 -0
  10. package/dist/devtools-client/_nuxt/error-404.upckUYZO.css +1 -0
  11. package/dist/devtools-client/_nuxt/error-500.DS4SeCFl.css +1 -0
  12. package/dist/devtools-client/_nuxt/{NMrm-PBR.js → xOsbuyp3.js} +1 -1
  13. package/dist/devtools-client/_nuxt/{C0p4l2Wy.js → zmRZ2I-R.js} +1 -1
  14. package/dist/devtools-client/docs/index.html +1 -1
  15. package/dist/devtools-client/first-party/index.html +1 -1
  16. package/dist/devtools-client/index.html +1 -1
  17. package/dist/devtools-client/registry/index.html +1 -1
  18. package/dist/module.json +1 -1
  19. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +1 -1
  20. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +3 -3
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +1 -1
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +4 -2
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue +1 -1
  24. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +1 -1
  25. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +1 -1
  26. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +1 -1
  27. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +1 -1
  28. package/dist/runtime/composables/useScript.js +1 -1
  29. package/dist/runtime/registry/google-analytics.js +1 -1
  30. package/dist/runtime/registry/google-recaptcha.js +1 -1
  31. package/dist/runtime/registry/google-sign-in.d.ts +27 -2
  32. package/dist/runtime/registry/google-sign-in.js +96 -1
  33. package/dist/runtime/registry/google-tag-manager.js +1 -1
  34. package/dist/runtime/registry/intercom.d.ts +1 -1
  35. package/dist/runtime/registry/paypal.d.ts +1 -1
  36. package/dist/runtime/registry/posthog.d.ts +1 -1
  37. package/dist/runtime/registry/snapchat-pixel.d.ts +1 -1
  38. package/dist/runtime/registry/stripe.d.ts +1 -1
  39. package/dist/runtime/registry/vimeo-player.d.ts +1 -1
  40. package/dist/runtime/registry/youtube-player.d.ts +1 -1
  41. package/dist/runtime/utils.d.ts +1 -1
  42. package/dist/types-source.mjs +5 -0
  43. package/package.json +3 -3
  44. package/dist/devtools-client/_nuxt/BQOW0dqa.js +0 -188
  45. package/dist/devtools-client/_nuxt/builds/meta/41edb1f4-fb21-4848-be40-543a397dc212.json +0 -1
  46. package/dist/devtools-client/_nuxt/error-404.CmHnDJ22.css +0 -1
  47. package/dist/devtools-client/_nuxt/error-500.C0mC5XzU.css +0 -1
@@ -1,6 +1,6 @@
1
- import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
1
  import type { Components, PageTypes, SdkInstance } from '@paypal/paypal-js/sdk-v6';
3
2
  import type { HTMLAttributes, ReservedProps } from 'vue';
3
+ import type { ElementScriptTrigger } from '#nuxt-scripts/types';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,6 +1,6 @@
1
- import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
1
  import type { PageTypes, PayPalMessagesOptions, PayPalMessagesSession } from '@paypal/paypal-js/sdk-v6';
3
2
  import type { HTMLAttributes, ReservedProps } from 'vue';
3
+ import type { ElementScriptTrigger } from '#nuxt-scripts/types';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,6 +1,6 @@
1
- import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
1
  import type { PageTypes, PayPalMessagesOptions, PayPalMessagesSession } from '@paypal/paypal-js/sdk-v6';
3
2
  import type { HTMLAttributes, ReservedProps } from 'vue';
3
+ import type { ElementScriptTrigger } from '#nuxt-scripts/types';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,8 +1,8 @@
1
- import { resolveTrigger } from "#build/nuxt-scripts-trigger-resolver";
2
1
  import { useScript as _useScript } from "@unhead/vue/scripts";
3
2
  import { defu } from "defu";
4
3
  import { injectHead, onNuxtReady, useHead, useNuxtApp, useRuntimeConfig } from "nuxt/app";
5
4
  import { markRaw, ref } from "vue";
5
+ import { resolveTrigger } from "#build/nuxt-scripts-trigger-resolver";
6
6
  import { logger } from "../logger.js";
7
7
  function resolveProxyPrefix() {
8
8
  const devtoolsConfig = useRuntimeConfig().public["nuxt-scripts-devtools"];
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "#nuxt-scripts/utils";
2
1
  import { withQuery } from "ufo";
2
+ import { useRegistryScript } from "#nuxt-scripts/utils";
3
3
  import { GoogleAnalyticsOptions } from "./schemas.js";
4
4
  export { GoogleAnalyticsOptions };
5
5
  export function useScriptGoogleAnalytics(_options) {
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "#nuxt-scripts/utils";
2
1
  import { withQuery } from "ufo";
2
+ import { useRegistryScript } from "#nuxt-scripts/utils";
3
3
  import { GoogleRecaptchaOptions } from "./schemas.js";
4
4
  export { GoogleRecaptchaOptions };
5
5
  export function useScriptGoogleRecaptcha(_options) {
@@ -1,4 +1,4 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
1
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
2
2
  import { GoogleSignInOptions } from './schemas.js';
3
3
  export interface CredentialResponse {
4
4
  credential: string;
@@ -70,4 +70,29 @@ export interface GoogleSignInApi {
70
70
  }
71
71
  export { GoogleSignInOptions };
72
72
  export type GoogleSignInInput = RegistryScriptInput<typeof GoogleSignInOptions>;
73
- export declare function useScriptGoogleSignIn<T extends GoogleSignInApi>(_options?: GoogleSignInInput): import("#nuxt-scripts/types").UseScriptContext<T>;
73
+ /**
74
+ * Helpers attached to the `useScriptGoogleSignIn()` instance.
75
+ *
76
+ * They merge schema options (passed to `useScriptGoogleSignIn(...)`) with the
77
+ * arguments below, ensure `accounts.id.initialize()` is called at most once
78
+ * across the page lifecycle (avoids the error Google emits on re-init after a
79
+ * button is rendered), and wait for the script to load.
80
+ */
81
+ export interface GoogleSignInHelpers {
82
+ /**
83
+ * Initialize Google Identity Services. Schema options are used as defaults;
84
+ * pass a callback (and any other non-serializable config) here. Subsequent
85
+ * calls are a no-op so this is safe to invoke from a remounting component.
86
+ */
87
+ initialize: (config?: Partial<IdConfiguration>) => void;
88
+ /**
89
+ * Render a personalized Google Sign-In button. Auto-initializes if needed.
90
+ * Safe to re-render on navigation or locale change.
91
+ */
92
+ renderButton: (parent: HTMLElement, config?: GsiButtonConfiguration) => void;
93
+ /**
94
+ * Show the One Tap prompt. Auto-initializes if needed.
95
+ */
96
+ prompt: (listener?: (notification: MomentNotification) => void) => void;
97
+ }
98
+ export declare function useScriptGoogleSignIn<T extends GoogleSignInApi>(_options?: GoogleSignInInput): UseScriptContext<T> & GoogleSignInHelpers;
@@ -2,7 +2,7 @@ import { useRegistryScript } from "#nuxt-scripts/utils";
2
2
  import { GoogleSignInOptions } from "./schemas.js";
3
3
  export { GoogleSignInOptions };
4
4
  export function useScriptGoogleSignIn(_options) {
5
- return useRegistryScript(_options?.key || "googleSignIn", () => {
5
+ const instance = useRegistryScript(_options?.key || "googleSignIn", (options) => {
6
6
  return {
7
7
  scriptInput: {
8
8
  src: "https://accounts.google.com/gsi/client",
@@ -24,7 +24,102 @@ export function useScriptGoogleSignIn(_options) {
24
24
  w.google = w.google || {};
25
25
  w.google.accounts = w.google.accounts || {};
26
26
  w.google.accounts.id = w.google.accounts.id || {};
27
+ const key2 = _options?.key || "googleSignIn";
28
+ w.__nuxtScriptsGsi = w.__nuxtScriptsGsi || {};
29
+ const cached = w.__nuxtScriptsGsi[key2] = w.__nuxtScriptsGsi[key2] || { initialized: false };
30
+ cached.schemaConfig = mapSchemaToIdConfig(options);
31
+ cached.runtimeConfig ||= {};
27
32
  }
28
33
  };
29
34
  }, _options);
35
+ const key = _options?.key || "googleSignIn";
36
+ const getState = () => {
37
+ if (!import.meta.client)
38
+ return null;
39
+ const w = window;
40
+ w.__nuxtScriptsGsi = w.__nuxtScriptsGsi || {};
41
+ const state = w.__nuxtScriptsGsi[key] = w.__nuxtScriptsGsi[key] || {
42
+ initialized: false,
43
+ schemaConfig: mapSchemaToIdConfig(_options),
44
+ runtimeConfig: {}
45
+ };
46
+ state.schemaConfig ||= mapSchemaToIdConfig(_options);
47
+ state.runtimeConfig ||= {};
48
+ return state;
49
+ };
50
+ const ensureInit = (extra) => {
51
+ const state = getState();
52
+ if (!state)
53
+ return false;
54
+ if (state.initialized)
55
+ return true;
56
+ const merged = { ...state.schemaConfig, ...state.runtimeConfig, ...extra };
57
+ if (!merged.client_id)
58
+ return false;
59
+ if (merged.ux_mode !== "redirect" && typeof merged.callback !== "function")
60
+ return false;
61
+ const gid = window.google?.accounts?.id;
62
+ if (!gid)
63
+ return false;
64
+ if (merged.ux_mode !== "redirect") {
65
+ state.callbackProxy ||= (response) => {
66
+ const current = getState()?.runtimeConfig.callback;
67
+ current?.(response);
68
+ };
69
+ merged.callback = state.callbackProxy;
70
+ }
71
+ gid.initialize(merged);
72
+ state.initialized = true;
73
+ return true;
74
+ };
75
+ instance.initialize = (config) => {
76
+ if (!import.meta.client)
77
+ return;
78
+ if (config)
79
+ Object.assign(getState().runtimeConfig, config);
80
+ instance.onLoaded(() => {
81
+ ensureInit();
82
+ });
83
+ };
84
+ instance.renderButton = (parent, config = {}) => {
85
+ instance.onLoaded(({ accounts }) => {
86
+ if (!ensureInit())
87
+ return;
88
+ accounts.id.renderButton(parent, config);
89
+ });
90
+ };
91
+ instance.prompt = (listener) => {
92
+ instance.onLoaded(({ accounts }) => {
93
+ if (!ensureInit())
94
+ return;
95
+ accounts.id.prompt(listener);
96
+ });
97
+ };
98
+ return instance;
99
+ }
100
+ function mapSchemaToIdConfig(options) {
101
+ if (!options)
102
+ return {};
103
+ const cfg = {};
104
+ if (options.clientId)
105
+ cfg.client_id = options.clientId;
106
+ if (options.autoSelect != null)
107
+ cfg.auto_select = options.autoSelect;
108
+ if (options.context)
109
+ cfg.context = options.context;
110
+ if (options.useFedcmForPrompt != null)
111
+ cfg.use_fedcm_for_prompt = options.useFedcmForPrompt;
112
+ if (options.cancelOnTapOutside != null)
113
+ cfg.cancel_on_tap_outside = options.cancelOnTapOutside;
114
+ if (options.uxMode)
115
+ cfg.ux_mode = options.uxMode;
116
+ if (options.loginUri)
117
+ cfg.login_uri = options.loginUri;
118
+ if (options.itpSupport != null)
119
+ cfg.itp_support = options.itpSupport;
120
+ if (options.allowedParentOrigin)
121
+ cfg.allowed_parent_origin = options.allowedParentOrigin;
122
+ if (options.hd)
123
+ cfg.hd = options.hd;
124
+ return cfg;
30
125
  }
@@ -1,5 +1,5 @@
1
- import { useRegistryScript } from "#nuxt-scripts/utils";
2
1
  import { withQuery } from "ufo";
2
+ import { useRegistryScript } from "#nuxt-scripts/utils";
3
3
  import { GoogleTagManagerOptions } from "./schemas.js";
4
4
  export { GoogleTagManagerOptions };
5
5
  export function useScriptGoogleTagManager(options) {
@@ -1,5 +1,5 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
1
  import type { InferInput } from 'valibot';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
3
  import { IntercomOptions } from './schemas.js';
4
4
  export { IntercomOptions };
5
5
  export type IntercomInput = RegistryScriptInput<typeof IntercomOptions, true, false>;
@@ -1,5 +1,5 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
1
  import type { PayPalV6Namespace } from '@paypal/paypal-js/sdk-v6';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
3
  import { PayPalOptions } from './schemas.js';
4
4
  export { PayPalOptions };
5
5
  export interface PayPalApi {
@@ -1,5 +1,5 @@
1
- import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
2
1
  import type { PostHog, PostHogConfig } from 'posthog-js';
2
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
3
3
  import { PostHogOptions } from './schemas.js';
4
4
  export { PostHogOptions };
5
5
  export type PostHogInput = Omit<RegistryScriptInput<typeof PostHogOptions, false, true>, 'config'> & {
@@ -1,5 +1,5 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
1
  import type { InferInput } from 'valibot';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
3
  import { InitObjectPropertiesSchema, SnapTrPixelOptions } from './schemas.js';
4
4
  export { InitObjectPropertiesSchema, SnapTrPixelOptions };
5
5
  type StandardEvents = 'PAGE_VIEW' | 'VIEW_CONTENT' | 'ADD_CART' | 'SIGN_UP' | 'SAVE' | 'START_CHECKOUT' | 'APP_OPEN' | 'ADD_BILLING' | 'SEARCH' | 'SUBSCRIBE' | 'AD_CLICK' | 'AD_VIEW' | 'COMPLETE_TUTORIAL' | 'LEVEL_COMPLETE' | 'INVITE' | 'LOGIN' | 'SHARE' | 'RESERVE' | 'ACHIEVEMENT_UNLOCKED' | 'ADD_TO_WISHLIST' | 'SPENT_CREDITS' | 'RATE' | 'START_TRIAL' | 'LIST_VIEW';
@@ -1,5 +1,5 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
1
  import type { StripeConstructor } from '@stripe/stripe-js';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
3
  import { StripeOptions } from './schemas.js';
4
4
  export { StripeOptions };
5
5
  export type StripeInput = RegistryScriptInput<typeof StripeOptions, false>;
@@ -1,6 +1,6 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
1
  import type { UseScriptContext } from '@unhead/vue';
3
2
  import type Vimeo from '@vimeo/player';
3
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
4
4
  type Constructor<T extends new (...args: any) => any> = T extends new (...args: infer A) => infer R ? new (...args: A) => R : never;
5
5
  export interface VimeoPlayerApi {
6
6
  Vimeo: {
@@ -1,5 +1,5 @@
1
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
1
  import type { UseScriptContext } from '@unhead/vue';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
3
  import type { MaybePromise } from '../utils.js';
4
4
  export interface YouTubePlayerApi {
5
5
  YT: MaybePromise<{
@@ -1,6 +1,6 @@
1
- import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
2
1
  import type { UseScriptInput } from '@unhead/vue';
3
2
  import type { ObjectSchema, UnionSchema } from 'valibot';
3
+ import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
4
4
  export type MaybePromise<T> = Promise<T> | T;
5
5
  type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
6
6
  scriptInput?: UseScriptInput & {
@@ -451,6 +451,11 @@ const types = {
451
451
  name: "GoogleSignInOptions",
452
452
  kind: "const",
453
453
  code: "export const GoogleSignInOptions = object({\n /**\n * Your Google API client ID.\n * @example 'XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com'\n * @see https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid\n */\n clientId: string(),\n /**\n * Auto-select credentials when only one Google account is available.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#auto_select\n */\n autoSelect: optional(boolean()),\n /**\n * The context text for the One Tap prompt.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#context\n */\n context: optional(union([literal('signin'), literal('signup'), literal('use')])),\n /**\n * Enable FedCM (Federated Credential Management) API support. Mandatory from August 2025.\n * @see https://developers.google.com/identity/gsi/web/guides/fedcm-migration\n */\n useFedcmForPrompt: optional(boolean()),\n /**\n * Cancel the One Tap prompt if the user clicks outside.\n * @default true\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#cancel_on_tap_outside\n */\n cancelOnTapOutside: optional(boolean()),\n /**\n * The UX mode for the sign-in flow.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#ux_mode\n */\n uxMode: optional(union([literal('popup'), literal('redirect')])),\n /**\n * The URI to redirect to after sign-in when using redirect UX mode.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_uri\n */\n loginUri: optional(string()),\n /**\n * Enable Intelligent Tracking Prevention (ITP) support for Safari.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#itp_support\n */\n itpSupport: optional(boolean()),\n /**\n * Allowed parent origin(s) for iframe embedding.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#allowed_parent_origin\n */\n allowedParentOrigin: optional(union([string(), array(string())])),\n /**\n * Restrict sign-in to a specific Google Workspace hosted domain.\n * @example 'example.com'\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference#hd\n */\n hd: optional(string()),\n})"
454
+ },
455
+ {
456
+ name: "GoogleSignInHelpers",
457
+ kind: "interface",
458
+ code: "export interface GoogleSignInHelpers {\n /**\n * Initialize Google Identity Services. Schema options are used as defaults;\n * pass a callback (and any other non-serializable config) here. Subsequent\n * calls are a no-op so this is safe to invoke from a remounting component.\n */\n initialize: (config?: Partial<IdConfiguration>) => void\n /**\n * Render a personalized Google Sign-In button. Auto-initializes if needed.\n * Safe to re-render on navigation or locale change.\n */\n renderButton: (parent: HTMLElement, config?: GsiButtonConfiguration) => void\n /**\n * Show the One Tap prompt. Auto-initializes if needed.\n */\n prompt: (listener?: (notification: MomentNotification) => void) => void\n}"
454
459
  }
455
460
  ],
456
461
  "google-tag-manager": [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/scripts",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "description": "Load third-party scripts with better performance, privacy and DX in Nuxt Apps.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -103,7 +103,7 @@
103
103
  },
104
104
  "dependencies": {
105
105
  "@nuxt/devtools-kit": "^3.2.4",
106
- "@nuxt/kit": "^4.4.2",
106
+ "@nuxt/kit": "^4.4.4",
107
107
  "@vueuse/core": "^14.2.1",
108
108
  "@vueuse/shared": "^14.2.1",
109
109
  "consola": "^3.4.2",
@@ -118,7 +118,7 @@
118
118
  "pkg-types": "^2.3.1",
119
119
  "sirv": "^3.0.2",
120
120
  "std-env": "^4.1.0",
121
- "ufo": "^1.6.3",
121
+ "ufo": "^1.6.4",
122
122
  "ultrahtml": "^1.6.0",
123
123
  "unplugin": "^3.0.0",
124
124
  "unstorage": "^1.17.5",