@nuxt/scripts 0.11.10 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/client/200.html +1 -1
  2. package/dist/client/404.html +1 -1
  3. package/dist/client/_nuxt/C0XnD8hU.js +179 -0
  4. package/dist/client/_nuxt/CVO1_9PV.js +1 -0
  5. package/dist/client/_nuxt/Cp-IABpG.js +1 -0
  6. package/dist/client/_nuxt/D0r3Knsf.js +1 -0
  7. package/dist/client/_nuxt/DDcnVyjk.js +1 -0
  8. package/dist/client/_nuxt/DlfHMoPT.js +1 -0
  9. package/dist/client/_nuxt/DnkQskw_.js +1 -0
  10. package/dist/client/_nuxt/builds/latest.json +1 -1
  11. package/dist/client/_nuxt/builds/meta/639547f1-5b38-4078-9f06-0e97166e98d5.json +1 -0
  12. package/dist/client/_nuxt/entry.Bb8Z00UZ.css +1 -0
  13. package/dist/client/_nuxt/error-404.CImBk2QF.css +1 -0
  14. package/dist/client/_nuxt/error-500.BDZhF_NY.css +1 -0
  15. package/dist/client/_nuxt/n57rOy2v.js +1 -0
  16. package/dist/client/index.html +1 -1
  17. package/dist/module.d.mts +8 -2
  18. package/dist/module.json +3 -3
  19. package/dist/module.mjs +169 -42
  20. package/dist/registry.mjs +30 -0
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +0 -0
  22. package/dist/runtime/components/{ScriptGoogleMaps.vue → GoogleMaps/ScriptGoogleMaps.vue} +17 -13
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +0 -0
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +61 -0
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +86 -0
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +61 -0
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.d.vue.ts +33 -0
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +62 -0
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue.d.ts +33 -0
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +5 -0
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +32 -0
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +5 -0
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +35 -0
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +88 -0
  35. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +35 -0
  36. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +61 -0
  37. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +84 -0
  38. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +61 -0
  39. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +27 -0
  40. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +56 -0
  41. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +27 -0
  42. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +5 -0
  43. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +37 -0
  44. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +5 -0
  45. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +29 -0
  46. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +60 -0
  47. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +29 -0
  48. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +29 -0
  49. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +60 -0
  50. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +29 -0
  51. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +31 -0
  52. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +61 -0
  53. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +31 -0
  54. package/dist/runtime/components/ScriptAriaLoadingIndicator.d.vue.ts +2 -0
  55. package/dist/runtime/components/ScriptCarbonAds.d.vue.ts +32 -0
  56. package/dist/runtime/components/ScriptCrisp.d.vue.ts +44 -0
  57. package/dist/runtime/components/ScriptCrisp.vue.d.ts +3 -1
  58. package/dist/runtime/components/ScriptGoogleAdsense.d.vue.ts +37 -0
  59. package/dist/runtime/components/ScriptGoogleAdsense.vue.d.ts +4 -1
  60. package/dist/runtime/components/ScriptIntercom.d.vue.ts +45 -0
  61. package/dist/runtime/components/ScriptIntercom.vue.d.ts +3 -1
  62. package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +24 -0
  63. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +3 -1
  64. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +9 -0
  65. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +4 -1
  66. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +72 -0
  67. package/dist/runtime/components/ScriptPayPalButtons.vue +116 -0
  68. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +72 -0
  69. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +51 -0
  70. package/dist/runtime/components/ScriptPayPalMarks.vue +69 -0
  71. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +51 -0
  72. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +67 -0
  73. package/dist/runtime/components/ScriptPayPalMessages.vue +90 -0
  74. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +67 -0
  75. package/dist/runtime/components/ScriptStripePricingTable.d.vue.ts +35 -0
  76. package/dist/runtime/components/ScriptStripePricingTable.vue +1 -1
  77. package/dist/runtime/components/ScriptStripePricingTable.vue.d.ts +3 -1
  78. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +127 -0
  79. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +5 -3
  80. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +66 -0
  81. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +9 -1
  82. package/dist/runtime/composables/useScript.js +35 -2
  83. package/dist/runtime/composables/useScriptEventPage.js +6 -2
  84. package/dist/runtime/composables/useScriptTriggerIdleTimeout.d.ts +10 -0
  85. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +22 -0
  86. package/dist/runtime/composables/useScriptTriggerInteraction.d.ts +15 -0
  87. package/dist/runtime/composables/useScriptTriggerInteraction.js +35 -0
  88. package/dist/runtime/logger.d.ts +1 -0
  89. package/dist/runtime/logger.js +6 -0
  90. package/dist/runtime/registry/databuddy-analytics.d.ts +77 -0
  91. package/dist/runtime/registry/databuddy-analytics.js +103 -0
  92. package/dist/runtime/registry/google-analytics.d.ts +1 -1
  93. package/dist/runtime/registry/google-analytics.js +5 -5
  94. package/dist/runtime/registry/google-tag-manager.js +3 -5
  95. package/dist/runtime/registry/matomo-analytics.d.ts +1 -0
  96. package/dist/runtime/registry/matomo-analytics.js +27 -4
  97. package/dist/runtime/registry/paypal.d.ts +34 -0
  98. package/dist/runtime/registry/paypal.js +86 -0
  99. package/dist/runtime/registry/reddit-pixel.d.ts +18 -0
  100. package/dist/runtime/registry/reddit-pixel.js +36 -0
  101. package/dist/runtime/registry/stripe.d.ts +2 -2
  102. package/dist/runtime/registry/stripe.js +1 -1
  103. package/dist/runtime/types.d.ts +18 -7
  104. package/dist/runtime/utils.d.ts +5 -2
  105. package/dist/runtime/utils.js +49 -19
  106. package/package.json +33 -26
  107. package/dist/client/_nuxt/C0osJU87.js +0 -1
  108. package/dist/client/_nuxt/DvGN_dxb.js +0 -1
  109. package/dist/client/_nuxt/DzYp5PzF.js +0 -21
  110. package/dist/client/_nuxt/builds/meta/55b6d2d9-3309-4bdb-b3a7-e1a28ac5a730.json +0 -1
  111. package/dist/client/_nuxt/entry.bAQEPFjX.css +0 -1
  112. package/dist/client/_nuxt/error-404.eZgLTnTW.css +0 -1
  113. package/dist/client/_nuxt/error-500.B1rSPQ5Q.css +0 -1
  114. package/dist/client/_nuxt/o0sZgK8d.js +0 -1
  115. package/dist/runtime/components/ScriptGoogleMaps.vue.d.ts +0 -140
@@ -0,0 +1,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;
@@ -2,7 +2,11 @@ import type { ObjectSchema } from 'valibot';
2
2
  import type { UseScriptInput } from '@unhead/vue';
3
3
  import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, UseFunctionType, ScriptRegistry, UseScriptContext } from '#nuxt-scripts/types';
4
4
  export type MaybePromise<T> = Promise<T> | T;
5
- type OptionsFn<O> = (options: InferIfSchema<O>) => ({
5
+ type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
6
+ scriptInput?: UseScriptInput & {
7
+ src?: string;
8
+ };
9
+ }) => ({
6
10
  scriptInput?: UseScriptInput;
7
11
  scriptOptions?: NuxtUseScriptOptions;
8
12
  schema?: O extends ObjectSchema<any, any> ? O : undefined;
@@ -10,5 +14,4 @@ type OptionsFn<O> = (options: InferIfSchema<O>) => ({
10
14
  });
11
15
  export declare function scriptRuntimeConfig<T extends keyof ScriptRegistry>(key: T): ScriptRegistry[T];
12
16
  export declare function useRegistryScript<T extends Record<string | symbol, any>, O = EmptyOptionsSchema>(registryKey: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): UseScriptContext<UseFunctionType<NuxtUseScriptOptions<T>, T>>;
13
- export declare function pick(obj: Record<string, any>, keys: string[]): Record<string, any>;
14
17
  export {};
@@ -2,15 +2,16 @@ import { defu } from "defu";
2
2
  import { useRuntimeConfig } from "nuxt/app";
3
3
  import { useScript } from "./composables/useScript.js";
4
4
  import { parse } from "#nuxt-scripts-validator";
5
+ import { parseURL, withQuery, parseQuery } from "ufo";
5
6
  function validateScriptInputSchema(key, schema, options) {
6
7
  if (import.meta.dev) {
7
8
  try {
8
9
  parse(schema, options);
9
10
  } catch (_e) {
10
- const e = _e;
11
- console.error(e.issues.map((i) => `${key}.${i.path?.map((i2) => i2.key).join(",")}: ${i.message}`).join("\n"));
11
+ return _e;
12
12
  }
13
13
  }
14
+ return null;
14
15
  }
15
16
  export function scriptRuntimeConfig(key) {
16
17
  return (useRuntimeConfig().public.scripts || {})[key];
@@ -18,11 +19,47 @@ export function scriptRuntimeConfig(key) {
18
19
  export function useRegistryScript(registryKey, optionsFn, _userOptions) {
19
20
  const scriptConfig = scriptRuntimeConfig(registryKey);
20
21
  const userOptions = Object.assign(_userOptions || {}, typeof scriptConfig === "object" ? scriptConfig : {});
21
- const options = optionsFn(userOptions);
22
- const scriptInput = defu(userOptions.scriptInput, options.scriptInput, { key: registryKey });
22
+ const options = optionsFn(userOptions, { scriptInput: userOptions.scriptInput });
23
+ let finalScriptInput = options.scriptInput;
24
+ const userSrc = userOptions.scriptInput?.src;
25
+ const optionsSrc = options.scriptInput?.src;
26
+ if (userSrc && optionsSrc && typeof optionsSrc === "string" && typeof userSrc === "string") {
27
+ const defaultUrl = parseURL(optionsSrc);
28
+ const customUrl = parseURL(userSrc);
29
+ const defaultQuery = parseQuery(defaultUrl.search || "");
30
+ const customQuery = parseQuery(customUrl.search || "");
31
+ const mergedQuery = { ...defaultQuery, ...customQuery };
32
+ const baseUrl = customUrl.href?.split("?")[0] || userSrc;
33
+ finalScriptInput = {
34
+ ...options.scriptInput || {},
35
+ src: withQuery(baseUrl, mergedQuery)
36
+ };
37
+ }
38
+ const scriptInput = defu(finalScriptInput, userOptions.scriptInput, { key: registryKey });
23
39
  const scriptOptions = Object.assign(userOptions?.scriptOptions || {}, options.scriptOptions || {});
24
40
  if (import.meta.dev) {
25
- scriptOptions.devtools = defu(scriptOptions.devtools, { registryKey });
41
+ const error = new Error("Stack trace for component location");
42
+ const stack = error.stack?.split("\n");
43
+ const callerLine = stack?.find(
44
+ (line) => line.includes(".vue") && !line.includes("useRegistryScript") && !line.includes("node_modules")
45
+ );
46
+ let loadedFrom = "unknown";
47
+ if (callerLine) {
48
+ const urlMatch = callerLine.match(/https?:\/\/[^/]+\/_nuxt\/(.+\.vue)(?:\?[^)]*)?:(\d+):(\d+)/) || callerLine.match(/\(https?:\/\/[^/]+\/_nuxt\/(.+\.vue)(?:\?[^)]*)?:(\d+):(\d+)\)/);
49
+ if (urlMatch) {
50
+ const [, filePath, line, column] = urlMatch;
51
+ loadedFrom = `./${filePath}:${line}:${column}`;
52
+ } else {
53
+ const vueMatch = callerLine.match(/([^/\s]+\.vue):(\d+):(\d+)/);
54
+ if (vueMatch) {
55
+ const [, fileName, line, column] = vueMatch;
56
+ loadedFrom = `./${fileName}:${line}:${column}`;
57
+ } else {
58
+ loadedFrom = callerLine.trim().replace(/^\s*at\s+/, "");
59
+ }
60
+ }
61
+ }
62
+ scriptOptions.devtools = defu(scriptOptions.devtools, { registryKey, loadedFrom });
26
63
  if (options.schema) {
27
64
  const registryMeta = {};
28
65
  for (const k in options.schema.entries) {
@@ -34,12 +71,14 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
34
71
  }
35
72
  }
36
73
  const init = scriptOptions.beforeInit;
37
- scriptOptions.beforeInit = () => {
38
- if (import.meta.dev && !scriptOptions.skipValidation && options.schema) {
39
- if (!userOptions.scriptInput?.src) {
40
- validateScriptInputSchema(registryKey, options.schema, userOptions);
74
+ if (import.meta.dev) {
75
+ scriptOptions._validate = () => {
76
+ if (!userOptions.scriptInput?.src && !scriptOptions.skipValidation && options.schema) {
77
+ return validateScriptInputSchema(registryKey, options.schema, userOptions);
41
78
  }
42
- }
79
+ };
80
+ }
81
+ scriptOptions.beforeInit = () => {
43
82
  init?.();
44
83
  if (import.meta.client) {
45
84
  options.clientInit?.();
@@ -47,12 +86,3 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
47
86
  };
48
87
  return useScript(scriptInput, scriptOptions);
49
88
  }
50
- export function pick(obj, keys) {
51
- const res = {};
52
- for (const k of keys) {
53
- if (k in obj) {
54
- res[k] = obj[k];
55
- }
56
- }
57
- return res;
58
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/scripts",
3
3
  "type": "module",
4
- "version": "0.11.10",
4
+ "version": "0.12.0",
5
5
  "description": "Load third-party scripts with better performance, privacy and DX in Nuxt Apps.",
6
6
  "author": {
7
7
  "website": "https://harlanzw.com",
@@ -54,6 +54,8 @@
54
54
  ]
55
55
  },
56
56
  "peerDependencies": {
57
+ "@googlemaps/markerclusterer": "^2.6.2",
58
+ "@paypal/paypal-js": "^8.1.2",
57
59
  "@stripe/stripe-js": "^7.0.0",
58
60
  "@types/google.maps": "^3.58.1",
59
61
  "@types/vimeo__player": "^2.18.3",
@@ -64,6 +66,9 @@
64
66
  "@stripe/stripe-js": {
65
67
  "optional": true
66
68
  },
69
+ "@paypal/paypal-js": {
70
+ "optional": true
71
+ },
67
72
  "@types/google.maps": {
68
73
  "optional": true
69
74
  },
@@ -75,47 +80,49 @@
75
80
  }
76
81
  },
77
82
  "dependencies": {
78
- "@nuxt/kit": "^4.0.0",
79
- "@vueuse/core": "^13.5.0",
83
+ "@nuxt/kit": "^4.1.2",
84
+ "@vueuse/core": "^13.9.0",
80
85
  "consola": "^3.4.2",
81
86
  "defu": "^6.1.4",
82
- "h3": "^1.15.3",
83
- "magic-string": "^0.30.17",
87
+ "h3": "^1.15.4",
88
+ "magic-string": "^0.30.19",
84
89
  "ofetch": "^1.4.1",
85
90
  "ohash": "^2.0.11",
86
91
  "pathe": "^2.0.3",
87
- "pkg-types": "^2.2.0",
88
- "sirv": "^3.0.1",
92
+ "pkg-types": "^2.3.0",
93
+ "sirv": "^3.0.2",
89
94
  "std-env": "^3.9.0",
90
95
  "ufo": "^1.6.1",
91
- "unplugin": "^2.3.5",
92
- "unstorage": "^1.16.1",
96
+ "unplugin": "^2.3.10",
97
+ "unstorage": "^1.17.1",
93
98
  "valibot": "^1.1.0"
94
99
  },
95
100
  "devDependencies": {
96
- "@nuxt/devtools-kit": "^2.6.2",
97
- "@nuxt/devtools-ui-kit": "^2.6.2",
98
- "@nuxt/eslint-config": "^1.5.2",
99
- "@nuxt/module-builder": "^1.0.1",
101
+ "@nuxt/devtools-kit": "^2.6.5",
102
+ "@nuxt/devtools-ui-kit": "^2.6.5",
103
+ "@nuxt/eslint-config": "^1.9.0",
104
+ "@nuxt/module-builder": "^1.0.2",
100
105
  "@nuxt/test-utils": "3.19.2",
101
- "@types/semver": "^7.7.0",
102
- "@typescript-eslint/typescript-estree": "^8.37.0",
106
+ "@paypal/paypal-js": "^8.4.2",
107
+ "@types/semver": "^7.7.1",
108
+ "@typescript-eslint/typescript-estree": "^8.44.1",
109
+ "@vue/test-utils": "^2.4.6",
103
110
  "acorn-loose": "^8.5.2",
104
- "bumpp": "^10.2.0",
111
+ "bumpp": "^10.2.3",
105
112
  "changelogen": "^0.6.2",
106
- "eslint": "9.31.0",
107
- "eslint-plugin-n": "^17.21.0",
113
+ "eslint": "^9.36.0",
114
+ "eslint-plugin-n": "^17.23.1",
108
115
  "happy-dom": "^18.0.1",
109
116
  "knitwork": "^1.2.0",
110
- "nuxt": "^4.0.0",
111
- "playwright-core": "^1.54.1",
112
- "shiki": "3.8.0",
113
- "typescript": "5.8.3",
117
+ "nuxt": "^4.1.2",
118
+ "playwright-core": "^1.55.1",
119
+ "shiki": "^3.13.0",
120
+ "typescript": "5.9.2",
114
121
  "vitest": "^3.2.4",
115
- "vue": "^3.5.17",
122
+ "vue": "^3.5.21",
116
123
  "vue-router": "^4.5.1",
117
- "vue-tsc": "^3.0.1",
118
- "@nuxt/scripts": "0.11.10"
124
+ "vue-tsc": "^3.0.8",
125
+ "@nuxt/scripts": "0.12.0"
119
126
  },
120
127
  "resolutions": {
121
128
  "@nuxt/scripts": "workspace:*"
@@ -130,7 +137,7 @@
130
137
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground && pnpm run prepare:fixtures",
131
138
  "typecheck": "vue-tsc --noEmit",
132
139
  "bump": "bumpp package.json --commit --push --tag",
133
- "release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\" && pnpm publish",
140
+ "release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\"",
134
141
  "lint": "eslint .",
135
142
  "lint:fix": "eslint . --fix",
136
143
  "test": "pnpm dev:prepare && vitest --run",
@@ -1 +0,0 @@
1
- import{_ as s,c as a,o as i,a as t,t as n,b as u,w as c,d as l,e as d}from"./DzYp5PzF.js";import{u as f}from"./o0sZgK8d.js";const p={class:"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide"},m={class:"max-w-520px text-center"},h=["textContent"],b=["textContent"],g=["textContent"],x={class:"flex items-center justify-center w-full"},y={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Page not found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(e){const r=e;return f({title:`${r.statusCode} - ${r.statusMessage} | ${r.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(k,w)=>{const o=d;return i(),a("div",p,[t("div",m,[t("h1",{class:"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]",textContent:n(e.statusCode)},null,8,h),t("h2",{class:"font-semibold mb-2 sm:text-3xl text-2xl",textContent:n(e.statusMessage)},null,8,b),t("p",{class:"mb-4 px-2 text-[#64748B] text-md",textContent:n(e.description)},null,8,g),t("div",x,[u(o,{to:"/",class:"font-medium hover:text-[#00DC82] text-sm underline underline-offset-3"},{default:c(()=>[l(n(e.backHome),1)]),_:1})])])])}}},v=s(y,[["__scopeId","data-v-a79bffc7"]]);export{v as default};
@@ -1 +0,0 @@
1
- import{_ as o,c as s,o as a,a as t,t as r}from"./DzYp5PzF.js";import{u as i}from"./o0sZgK8d.js";const u={class:"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide"},l={class:"max-w-520px text-center"},c=["textContent"],d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Internal server error"},description:{type:String,default:"This page is temporarily unavailable."},refresh:{type:String,default:"Refresh this page"}},setup(e){const n=e;return i({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(g,h)=>(a(),s("div",u,[t("div",l,[t("h1",{class:"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]",textContent:r(e.statusCode)},null,8,c),t("h2",{class:"font-semibold mb-2 sm:text-3xl text-2xl",textContent:r(e.statusMessage)},null,8,d),t("p",{class:"mb-4 px-2 text-[#64748B] text-md",textContent:r(e.description)},null,8,p)])]))}},x=o(f,[["__scopeId","data-v-b4ff6067"]]);export{x as default};