@nuxt/scripts 1.0.5 → 1.1.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 (73) 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/{xOsbuyp3.js → 1wb58MKb.js} +1 -1
  4. package/dist/devtools-client/_nuxt/{CApasjik.js → BbLmrp_o.js} +1 -1
  5. package/dist/devtools-client/_nuxt/{zmRZ2I-R.js → Cx46cS8a.js} +1 -1
  6. package/dist/devtools-client/_nuxt/{CTPc9yIZ.js → D-M51CV3.js} +1 -1
  7. package/dist/devtools-client/_nuxt/D4HTNcLU.js +188 -0
  8. package/dist/devtools-client/_nuxt/{Dj5q49Yv.js → DU3BlAm5.js} +1 -1
  9. package/dist/devtools-client/_nuxt/{CbCcQNvm.js → DiaY4J4_.js} +1 -1
  10. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  11. package/dist/devtools-client/_nuxt/builds/meta/0b4ab733-07a6-40b2-b25e-aca95fa55188.json +1 -0
  12. package/dist/devtools-client/_nuxt/error-404.D2T48gBS.css +1 -0
  13. package/dist/devtools-client/_nuxt/error-500.sMTZJbsP.css +1 -0
  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.d.mts +7 -1
  19. package/dist/module.d.ts +7 -1
  20. package/dist/module.json +1 -1
  21. package/dist/module.mjs +266 -34
  22. package/dist/registry.mjs +76 -5
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +50 -7
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.d.vue.ts +2 -2
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue.d.ts +2 -2
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +2 -2
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +2 -2
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +2 -2
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +2 -2
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +2 -2
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +2 -2
  32. package/dist/runtime/components/ScriptCalendlyInlineWidget.d.vue.ts +59 -0
  33. package/dist/runtime/components/ScriptCalendlyInlineWidget.vue +79 -0
  34. package/dist/runtime/components/ScriptCalendlyInlineWidget.vue.d.ts +59 -0
  35. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +1 -1
  36. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +1 -1
  37. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +1 -1
  38. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +1 -1
  39. package/dist/runtime/composables/useScript.js +48 -0
  40. package/dist/runtime/debug.d.ts +1 -0
  41. package/dist/runtime/debug.js +1 -0
  42. package/dist/runtime/devtools-standalone-bridge.client.js +3 -1
  43. package/dist/runtime/logger.js +4 -0
  44. package/dist/runtime/registry/_gcm-consent.d.ts +14 -0
  45. package/dist/runtime/registry/_gcm-consent.js +24 -0
  46. package/dist/runtime/registry/ahrefs-analytics.d.ts +39 -0
  47. package/dist/runtime/registry/ahrefs-analytics.js +18 -0
  48. package/dist/runtime/registry/calendly.d.ts +76 -0
  49. package/dist/runtime/registry/calendly.js +63 -0
  50. package/dist/runtime/registry/google-analytics.d.ts +5 -6
  51. package/dist/runtime/registry/google-analytics.js +9 -12
  52. package/dist/runtime/registry/google-tag-manager.d.ts +5 -6
  53. package/dist/runtime/registry/google-tag-manager.js +18 -20
  54. package/dist/runtime/registry/linkedin-insight.d.ts +35 -0
  55. package/dist/runtime/registry/linkedin-insight.js +49 -0
  56. package/dist/runtime/registry/schemas.d.ts +165 -6
  57. package/dist/runtime/registry/schemas.js +125 -7
  58. package/dist/runtime/registry/tiktok-pixel.d.ts +28 -2
  59. package/dist/runtime/registry/tiktok-pixel.js +18 -1
  60. package/dist/runtime/registry/usercentrics.d.ts +85 -0
  61. package/dist/runtime/registry/usercentrics.js +54 -0
  62. package/dist/runtime/server/proxy-handler.js +13 -4
  63. package/dist/runtime/types.d.ts +40 -1
  64. package/dist/runtime/utils.d.ts +8 -2
  65. package/dist/runtime/utils.js +5 -1
  66. package/dist/stats.mjs +19 -0
  67. package/dist/types-source.mjs +280 -15
  68. package/dist/types.d.mts +1 -1
  69. package/package.json +11 -8
  70. package/dist/devtools-client/_nuxt/BNvWpYaC.js +0 -188
  71. package/dist/devtools-client/_nuxt/builds/meta/caa75c14-abb0-4d9e-8f1a-440e91f4b1eb.json +0 -1
  72. package/dist/devtools-client/_nuxt/error-404.upckUYZO.css +0 -1
  73. package/dist/devtools-client/_nuxt/error-500.DS4SeCFl.css +0 -1
@@ -0,0 +1,54 @@
1
+ import { useHead } from "@unhead/vue";
2
+ import { useRegistryScript } from "../utils.js";
3
+ import { UsercentricsOptions } from "./schemas.js";
4
+ export { UsercentricsOptions };
5
+ export function useScriptUsercentrics(_options) {
6
+ const instance = useRegistryScript("usercentrics", (options) => {
7
+ if (import.meta.client && options.autoblocker) {
8
+ useHead({
9
+ script: [{
10
+ src: "https://web.cmp.usercentrics.eu/modules/autoblocker.js",
11
+ tagPosition: "head",
12
+ tagPriority: "high"
13
+ }]
14
+ });
15
+ }
16
+ return {
17
+ scriptInput: {
18
+ "src": "https://web.cmp.usercentrics.eu/ui/loader.js",
19
+ "id": "usercentrics-cmp",
20
+ "data-ruleset-id": options.rulesetId,
21
+ "data-language": options.language,
22
+ "crossorigin": false
23
+ },
24
+ schema: import.meta.dev ? UsercentricsOptions : void 0,
25
+ scriptOptions: {
26
+ use() {
27
+ return { ucCmp: window.__ucCmp };
28
+ }
29
+ }
30
+ };
31
+ }, _options);
32
+ if (import.meta.client && !instance.consent) {
33
+ const whenReady = () => new Promise((resolve) => {
34
+ const onReady = () => {
35
+ window.removeEventListener("UC_CMP_API_READY", onReady);
36
+ resolve(window.__ucCmp);
37
+ };
38
+ window.addEventListener("UC_CMP_API_READY", onReady);
39
+ });
40
+ instance.consent = {
41
+ whenReady,
42
+ onConsentChange(cb) {
43
+ const handler = (e) => cb(e.detail, e);
44
+ window.addEventListener("UC_UI_CMP_EVENT", handler);
45
+ return () => window.removeEventListener("UC_UI_CMP_EVENT", handler);
46
+ },
47
+ showFirstLayer: () => window.__ucCmp?.showFirstLayer?.(),
48
+ showSecondLayer: () => window.__ucCmp?.showSecondLayer?.(),
49
+ acceptAll: () => window.__ucCmp?.acceptAllConsents?.(),
50
+ denyAll: () => window.__ucCmp?.denyAllConsents?.()
51
+ };
52
+ }
53
+ return instance;
54
+ }
@@ -230,7 +230,11 @@ export default defineEventHandler(async (event) => {
230
230
  });
231
231
  log("[proxy] Fetching:", targetUrl);
232
232
  const controller = new AbortController();
233
- const timeoutId = setTimeout(() => controller.abort(), 15e3);
233
+ let timedOut = false;
234
+ const timeoutId = setTimeout(() => {
235
+ timedOut = true;
236
+ controller.abort();
237
+ }, 15e3);
234
238
  let fetchBody;
235
239
  if (passthroughBody) {
236
240
  fetchBody = getRequestWebStream(event);
@@ -252,9 +256,14 @@ export default defineEventHandler(async (event) => {
252
256
  } catch (err) {
253
257
  log("[proxy] Upstream error:", err);
254
258
  throw createError({
255
- statusCode: 502,
256
- statusMessage: "Bad Gateway",
257
- message: `Proxy upstream request failed: ${targetUrl}`
259
+ statusCode: timedOut ? 504 : 502,
260
+ statusMessage: timedOut ? "Gateway Timeout" : "Bad Gateway",
261
+ message: `Proxy upstream request failed: ${targetUrl}`,
262
+ cause: err,
263
+ data: {
264
+ errorName: err?.name,
265
+ errorCode: timedOut ? "TIMEOUT" : err?.code
266
+ }
258
267
  });
259
268
  } finally {
260
269
  clearTimeout(timeoutId);
@@ -3,8 +3,10 @@ import type { Script } from '@unhead/vue/types';
3
3
  import type { Import } from 'unimport';
4
4
  import type { InferInput, ObjectEntries, ObjectSchema, UnionSchema, ValiError } from 'valibot';
5
5
  import type { ComputedRef, Ref } from 'vue';
6
+ import type { AhrefsAnalyticsInput } from './registry/ahrefs-analytics.js';
6
7
  import type { BingUetInput } from './registry/bing-uet.js';
7
8
  import type { BlueskyEmbedInput } from './registry/bluesky-embed.js';
9
+ import type { CalendlyInput } from './registry/calendly.js';
8
10
  import type { ClarityInput } from './registry/clarity.js';
9
11
  import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics.js';
10
12
  import type { CrispInput } from './registry/crisp.js';
@@ -21,6 +23,7 @@ import type { HotjarInput } from './registry/hotjar.js';
21
23
  import type { InstagramEmbedInput } from './registry/instagram-embed.js';
22
24
  import type { IntercomInput } from './registry/intercom.js';
23
25
  import type { LemonSqueezyInput } from './registry/lemon-squeezy.js';
26
+ import type { LinkedInInsightInput } from './registry/linkedin-insight.js';
24
27
  import type { MatomoAnalyticsInput } from './registry/matomo-analytics.js';
25
28
  import type { MetaPixelInput } from './registry/meta-pixel.js';
26
29
  import type { MixpanelAnalyticsInput } from './registry/mixpanel-analytics.js';
@@ -35,6 +38,7 @@ import type { SnapTrPixelInput } from './registry/snapchat-pixel.js';
35
38
  import type { StripeInput } from './registry/stripe.js';
36
39
  import type { TikTokPixelInput } from './registry/tiktok-pixel.js';
37
40
  import type { UmamiAnalyticsInput } from './registry/umami-analytics.js';
41
+ import type { UsercentricsInput } from './registry/usercentrics.js';
38
42
  import type { VercelAnalyticsInput } from './registry/vercel-analytics.js';
39
43
  import type { VimeoPlayerInput } from './registry/vimeo-player.js';
40
44
  import type { XEmbedInput } from './registry/x-embed.js';
@@ -61,6 +65,20 @@ export interface ConsentState {
61
65
  functionality_storage?: ConsentCategoryValue;
62
66
  personalization_storage?: ConsentCategoryValue;
63
67
  security_storage?: ConsentCategoryValue;
68
+ /** Region/subdivision codes (ISO 3166-1 alpha-2 or `XX-YY`) this default applies to. */
69
+ region?: string[];
70
+ /** Milliseconds to wait for `consent.update()` before firing queued tags. */
71
+ wait_for_update?: number;
72
+ }
73
+ /**
74
+ * Auto-attached `consent` API on scripts that adhere to the GCMv2 Consent Mode
75
+ * contract (Google Analytics, Google Tag Manager, …).
76
+ */
77
+ export interface GcmConsentApi {
78
+ /** Push `['consent','default', state]` (or equivalent gtag call) with GCMv2 partial state. */
79
+ default: (state: ConsentState) => void;
80
+ /** Push `['consent','update', state]` (or equivalent gtag call) with GCMv2 partial state. */
81
+ update: (state: ConsentState) => void;
64
82
  }
65
83
  export type UseScriptContext<T extends Record<symbol | string, any>, C = unknown> = VueScriptInstance<T> & {
66
84
  /**
@@ -138,6 +156,13 @@ export type NuxtUseScriptOptions<T extends Record<symbol | string, any> = {}> =
138
156
  * @internal
139
157
  */
140
158
  registryMeta?: Record<string, string>;
159
+ /**
160
+ * Source location (file:line:col) the script was registered from, captured
161
+ * via dev-only stack-trace parsing in `useRegistryScript`. Surfaced in
162
+ * debug logs and Nuxt DevTools.
163
+ * @internal
164
+ */
165
+ loadedFrom?: string;
141
166
  /**
142
167
  * Known third-party domains this script communicates with.
143
168
  * @internal
@@ -208,9 +233,11 @@ export interface NuxtDevToolsScriptInstance {
208
233
  networkRequests: NuxtDevToolsNetworkRequest[];
209
234
  }
210
235
  export interface ScriptRegistry {
236
+ ahrefsAnalytics?: AhrefsAnalyticsInput;
211
237
  bingUet?: BingUetInput;
212
238
  blueskyEmbed?: BlueskyEmbedInput;
213
239
  carbonAds?: true;
240
+ calendly?: CalendlyInput;
214
241
  crisp?: CrispInput;
215
242
  clarity?: ClarityInput;
216
243
  cloudflareWebAnalytics?: CloudflareWebAnalyticsInput;
@@ -228,6 +255,7 @@ export interface ScriptRegistry {
228
255
  googleTagManager?: GoogleTagManagerInput;
229
256
  hotjar?: HotjarInput;
230
257
  intercom?: IntercomInput;
258
+ linkedinInsight?: LinkedInInsightInput;
231
259
  paypal?: PayPalInput;
232
260
  posthog?: PostHogInput;
233
261
  matomoAnalytics?: MatomoAnalyticsInput;
@@ -244,6 +272,7 @@ export interface ScriptRegistry {
244
272
  vercelAnalytics?: VercelAnalyticsInput;
245
273
  vimeoPlayer?: VimeoPlayerInput;
246
274
  umamiAnalytics?: UmamiAnalyticsInput;
275
+ usercentrics?: UsercentricsInput;
247
276
  gravatar?: GravatarInput;
248
277
  npm?: NpmInput;
249
278
  [key: `${string}-npm`]: NpmInput;
@@ -252,7 +281,7 @@ export interface ScriptRegistry {
252
281
  * Built-in registry script keys — not affected by module augmentation.
253
282
  * Use this to type-check records that must enumerate all built-in scripts (logos, meta, etc.).
254
283
  */
255
- export type BuiltInRegistryScriptKey = 'bingUet' | 'blueskyEmbed' | 'carbonAds' | 'crisp' | 'clarity' | 'cloudflareWebAnalytics' | 'databuddyAnalytics' | 'metaPixel' | 'fathomAnalytics' | 'instagramEmbed' | 'plausibleAnalytics' | 'googleAdsense' | 'googleAnalytics' | 'googleMaps' | 'googleRecaptcha' | 'googleSignIn' | 'lemonSqueezy' | 'googleTagManager' | 'hotjar' | 'intercom' | 'paypal' | 'posthog' | 'matomoAnalytics' | 'mixpanelAnalytics' | 'rybbitAnalytics' | 'redditPixel' | 'segment' | 'stripe' | 'tiktokPixel' | 'xEmbed' | 'xPixel' | 'snapchatPixel' | 'youtubePlayer' | 'vercelAnalytics' | 'vimeoPlayer' | 'umamiAnalytics' | 'gravatar' | 'npm';
284
+ export type BuiltInRegistryScriptKey = 'ahrefsAnalytics' | 'bingUet' | 'blueskyEmbed' | 'calendly' | 'carbonAds' | 'crisp' | 'clarity' | 'cloudflareWebAnalytics' | 'databuddyAnalytics' | 'metaPixel' | 'fathomAnalytics' | 'instagramEmbed' | 'plausibleAnalytics' | 'googleAdsense' | 'googleAnalytics' | 'googleMaps' | 'googleRecaptcha' | 'googleSignIn' | 'lemonSqueezy' | 'googleTagManager' | 'hotjar' | 'intercom' | 'linkedinInsight' | 'paypal' | 'posthog' | 'matomoAnalytics' | 'mixpanelAnalytics' | 'rybbitAnalytics' | 'redditPixel' | 'segment' | 'stripe' | 'tiktokPixel' | 'xEmbed' | 'xPixel' | 'snapchatPixel' | 'youtubePlayer' | 'vercelAnalytics' | 'vimeoPlayer' | 'umamiAnalytics' | 'usercentrics' | 'gravatar' | 'npm';
256
285
  /**
257
286
  * Union of all explicit registry script keys (excludes npm pattern).
258
287
  * Includes both built-in and augmented keys.
@@ -382,6 +411,16 @@ export type SdkPatch = {
382
411
  separator: string;
383
412
  fromDomain: string;
384
413
  appendPath?: string;
414
+ }
415
+ /**
416
+ * Replace `new URL(<expr>).origin` with `self.location.origin + "<proxyPath>"`.
417
+ * Used by SDKs that derive their API host as `new URL(currentScript.src).origin + "/api/..."`.
418
+ * When bundled, the script src origin is the Nuxt origin, so the derived endpoint
419
+ * lands on a 404 instead of the proxy. This patch redirects it through the proxy.
420
+ */
421
+ | {
422
+ type: 'replace-new-url-origin';
423
+ fromDomain: string;
385
424
  };
386
425
  /**
387
426
  * Partytown capability config. When present, the script can run in a
@@ -1,6 +1,7 @@
1
1
  import type { UseScriptInput } from '@unhead/vue';
2
2
  import type { ObjectSchema, UnionSchema } from 'valibot';
3
- import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
3
+ import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, RegistryScriptKey, ScriptRegistry, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
4
+ import type { GcmConsentContract } from './registry/_gcm-consent.js';
4
5
  export type MaybePromise<T> = Promise<T> | T;
5
6
  type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
6
7
  scriptInput?: UseScriptInput & {
@@ -12,8 +13,13 @@ type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
12
13
  schema?: O extends ObjectSchema<any, any> | UnionSchema<any, any> ? O : undefined;
13
14
  clientInit?: () => void | Promise<any>;
14
15
  scriptMode?: 'external' | 'npm';
16
+ /**
17
+ * Opt-in: this script consumes GCMv2 Consent Mode. `useRegistryScript` auto-attaches
18
+ * a `consent: { default, update }` API + dev validation against the canonical schema.
19
+ */
20
+ gcmConsent?: GcmConsentContract;
15
21
  });
16
- export declare function scriptRuntimeConfig<T extends keyof ScriptRegistry>(key: T): ScriptRegistry[T];
22
+ export declare function scriptRuntimeConfig<T extends RegistryScriptKey>(key: T): ScriptRegistry[T];
17
23
  export declare function scriptsPrefix(): string;
18
24
  export declare function requireRegistryEndpoint(componentName: string, registryKey: string): void;
19
25
  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>>;
@@ -4,6 +4,7 @@ import { parseQuery, parseURL, withQuery } from "ufo";
4
4
  import { parse } from "valibot";
5
5
  import { useScript } from "./composables/useScript.js";
6
6
  import { createNpmScriptStub } from "./npm-script-stub.js";
7
+ import { attachGcmConsent } from "./registry/_gcm-consent.js";
7
8
  const URL_MATCH_RE = /https?:\/\/[^/]+\/_nuxt\/(.+\.vue)(?:\?[^)]*)?:(\d+):(\d+)/;
8
9
  const URL_PAREN_MATCH_RE = /\(https?:\/\/[^/]+\/_nuxt\/(.+\.vue)(?:\?[^)]*)?:(\d+):(\d+)\)/;
9
10
  const VUE_MATCH_RE = /([^/\s]+\.vue):(\d+):(\d+)/;
@@ -111,5 +112,8 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
111
112
  options.clientInit?.();
112
113
  }
113
114
  };
114
- return useScript(scriptInput, scriptOptions);
115
+ const instance = useScript(scriptInput, scriptOptions);
116
+ if (import.meta.client && options.gcmConsent)
117
+ attachGcmConsent(instance, options.gcmConsent, String(registryKey));
118
+ return instance;
115
119
  }
package/dist/stats.mjs CHANGED
@@ -4,6 +4,11 @@ import '../dist/runtime/registry/schemas.js';
4
4
 
5
5
  const scriptMeta = {
6
6
  // Analytics
7
+ ahrefsAnalytics: {
8
+ urls: ["https://analytics.ahrefs.com/analytics.js"],
9
+ trackedData: ["page-views", "events"],
10
+ testId: "test-ahrefs-key"
11
+ },
7
12
  plausibleAnalytics: {
8
13
  urls: ["https://plausible.io/js/script.js"],
9
14
  trackedData: ["page-views", "events", "conversions"]
@@ -84,6 +89,11 @@ const scriptMeta = {
84
89
  trackedData: ["page-views", "conversions", "retargeting", "audiences"],
85
90
  testId: "a2_ilz4u0kbdr3v"
86
91
  },
92
+ linkedinInsight: {
93
+ urls: ["https://snap.licdn.com/li.lms-analytics/insight.min.js"],
94
+ trackedData: ["page-views", "conversions", "retargeting", "audiences"],
95
+ testId: "111143"
96
+ },
87
97
  googleAdsense: {
88
98
  urls: ["https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"],
89
99
  trackedData: ["page-views", "retargeting", "audiences"]
@@ -154,6 +164,10 @@ const scriptMeta = {
154
164
  trackedData: []
155
165
  },
156
166
  // Utility
167
+ calendly: {
168
+ urls: ["https://assets.calendly.com/assets/external/widget.js"],
169
+ trackedData: []
170
+ },
157
171
  googleRecaptcha: {
158
172
  urls: ["https://www.google.com/recaptcha/api.js"],
159
173
  trackedData: []
@@ -175,6 +189,11 @@ const scriptMeta = {
175
189
  urls: ["https://platform.twitter.com/widgets.js"],
176
190
  trackedData: []
177
191
  },
192
+ // CMP / Consent
193
+ usercentrics: {
194
+ urls: ["https://web.cmp.usercentrics.eu/ui/loader.js", "https://web.cmp.usercentrics.eu/modules/autoblocker.js"],
195
+ trackedData: []
196
+ },
178
197
  // Identity
179
198
  gravatar: {
180
199
  urls: ["https://secure.gravatar.com/js/gprofiles.js"],