@nuxt/scripts 1.0.6 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) 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/B-0LGYiZ.js +188 -0
  4. package/dist/devtools-client/_nuxt/BHdEFiuu.js +1 -0
  5. package/dist/devtools-client/_nuxt/CZLtBO2f.js +1 -0
  6. package/dist/devtools-client/_nuxt/CpUjVpvL.js +1 -0
  7. package/dist/devtools-client/_nuxt/CpodaK4k.js +1 -0
  8. package/dist/devtools-client/_nuxt/DkOU4Aaf.js +1 -0
  9. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  10. package/dist/devtools-client/_nuxt/builds/meta/7cf30d77-8399-4375-9a20-302132331b02.json +1 -0
  11. package/dist/devtools-client/_nuxt/d96VI30H.js +1 -0
  12. package/dist/devtools-client/_nuxt/{entry.XOvcedFq.css → entry.DFx-MLUa.css} +1 -1
  13. package/dist/devtools-client/_nuxt/error-404.aORtIbIE.css +1 -0
  14. package/dist/devtools-client/_nuxt/error-500.FkAdJQFV.css +1 -0
  15. package/dist/devtools-client/_nuxt/{first-party.C8Ha4JLM.css → first-party.D_SBdnka.css} +1 -1
  16. package/dist/devtools-client/_nuxt/index.DIj4bh55.css +1 -0
  17. package/dist/devtools-client/_nuxt/{registry.B9lnjF_b.css → registry.CDbTq1x3.css} +1 -1
  18. package/dist/devtools-client/docs/index.html +1 -1
  19. package/dist/devtools-client/first-party/index.html +1 -1
  20. package/dist/devtools-client/index.html +1 -1
  21. package/dist/devtools-client/registry/index.html +1 -1
  22. package/dist/module.d.mts +12 -2
  23. package/dist/module.d.ts +12 -2
  24. package/dist/module.json +1 -1
  25. package/dist/module.mjs +271 -35
  26. package/dist/registry.mjs +76 -5
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +36 -5
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.d.vue.ts +2 -2
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue.d.ts +2 -2
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +2 -2
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +2 -2
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +2 -2
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +2 -2
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +2 -2
  35. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +2 -2
  36. package/dist/runtime/components/ScriptCalendlyInlineWidget.d.vue.ts +59 -0
  37. package/dist/runtime/components/ScriptCalendlyInlineWidget.vue +79 -0
  38. package/dist/runtime/components/ScriptCalendlyInlineWidget.vue.d.ts +59 -0
  39. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +1 -1
  40. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +1 -1
  41. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +1 -1
  42. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +1 -1
  43. package/dist/runtime/composables/useScript.js +48 -0
  44. package/dist/runtime/debug.d.ts +1 -0
  45. package/dist/runtime/debug.js +1 -0
  46. package/dist/runtime/devtools-standalone-bridge.client.js +3 -1
  47. package/dist/runtime/logger.js +4 -0
  48. package/dist/runtime/registry/_gcm-consent.d.ts +14 -0
  49. package/dist/runtime/registry/_gcm-consent.js +24 -0
  50. package/dist/runtime/registry/ahrefs-analytics.d.ts +39 -0
  51. package/dist/runtime/registry/ahrefs-analytics.js +18 -0
  52. package/dist/runtime/registry/calendly.d.ts +76 -0
  53. package/dist/runtime/registry/calendly.js +63 -0
  54. package/dist/runtime/registry/google-analytics.d.ts +5 -6
  55. package/dist/runtime/registry/google-analytics.js +4 -10
  56. package/dist/runtime/registry/google-tag-manager.d.ts +5 -6
  57. package/dist/runtime/registry/google-tag-manager.js +13 -18
  58. package/dist/runtime/registry/linkedin-insight.d.ts +35 -0
  59. package/dist/runtime/registry/linkedin-insight.js +49 -0
  60. package/dist/runtime/registry/schemas.d.ts +124 -0
  61. package/dist/runtime/registry/schemas.js +115 -2
  62. package/dist/runtime/registry/tiktok-pixel.d.ts +79 -14
  63. package/dist/runtime/registry/tiktok-pixel.js +62 -28
  64. package/dist/runtime/registry/usercentrics.d.ts +85 -0
  65. package/dist/runtime/registry/usercentrics.js +54 -0
  66. package/dist/runtime/server/proxy-handler.js +13 -4
  67. package/dist/runtime/types.d.ts +36 -1
  68. package/dist/runtime/utils.d.ts +8 -2
  69. package/dist/runtime/utils.js +5 -1
  70. package/dist/stats.mjs +19 -0
  71. package/dist/types-source.mjs +291 -11
  72. package/dist/types.d.mts +1 -1
  73. package/package.json +9 -6
  74. package/dist/devtools-client/_nuxt/CZp-OuKP.js +0 -1
  75. package/dist/devtools-client/_nuxt/Djr8-0jV.js +0 -1
  76. package/dist/devtools-client/_nuxt/DtB6K90V.js +0 -188
  77. package/dist/devtools-client/_nuxt/DyyF3uw_.js +0 -1
  78. package/dist/devtools-client/_nuxt/GzJXdFDa.js +0 -1
  79. package/dist/devtools-client/_nuxt/W-xcwSaJ.js +0 -1
  80. package/dist/devtools-client/_nuxt/YlRaZkPa.js +0 -1
  81. package/dist/devtools-client/_nuxt/builds/meta/57f43375-6c5e-40af-a5bc-9479e5286aac.json +0 -1
  82. package/dist/devtools-client/_nuxt/error-404.DsZYSkA7.css +0 -1
  83. package/dist/devtools-client/_nuxt/error-500.Cqipl6_j.css +0 -1
  84. package/dist/devtools-client/_nuxt/index.DZD1lwyI.css +0 -1
@@ -0,0 +1,59 @@
1
+ import type { HTMLAttributes } from 'vue';
2
+ import type { ElementScriptTrigger } from '../types.js';
3
+ interface CalendlyPrefill {
4
+ name?: string;
5
+ email?: string;
6
+ firstName?: string;
7
+ lastName?: string;
8
+ customAnswers?: Record<string, string>;
9
+ }
10
+ interface CalendlyUtm {
11
+ utmCampaign?: string;
12
+ utmSource?: string;
13
+ utmMedium?: string;
14
+ utmContent?: string;
15
+ utmTerm?: string;
16
+ }
17
+ interface CalendlyPageSettings {
18
+ backgroundColor?: string;
19
+ hideEventTypeDetails?: boolean;
20
+ hideLandingPageDetails?: boolean;
21
+ hideGdprBanner?: boolean;
22
+ primaryColor?: string;
23
+ textColor?: string;
24
+ }
25
+ type __VLS_Props = {
26
+ url: string;
27
+ trigger?: ElementScriptTrigger;
28
+ prefill?: CalendlyPrefill;
29
+ utm?: CalendlyUtm;
30
+ pageSettings?: CalendlyPageSettings;
31
+ rootAttrs?: HTMLAttributes;
32
+ aboveTheFold?: boolean;
33
+ minHeight?: string;
34
+ };
35
+ type __VLS_Slots = {
36
+ default?: () => any;
37
+ loading?: () => any;
38
+ awaitingLoad?: () => any;
39
+ error?: () => any;
40
+ };
41
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
42
+ error: () => any;
43
+ ready: (api: {
44
+ Calendly: typeof window.Calendly;
45
+ }) => any;
46
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
47
+ onError?: (() => any) | undefined;
48
+ onReady?: ((api: {
49
+ Calendly: typeof window.Calendly;
50
+ }) => any) | undefined;
51
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
52
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
53
+ declare const _default: typeof __VLS_export;
54
+ export default _default;
55
+ type __VLS_WithSlots<T, S> = T & {
56
+ new (): {
57
+ $slots: S;
58
+ };
59
+ };
@@ -64,8 +64,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
64
64
  onError?: ((error: unknown) => any) | undefined;
65
65
  onReady?: ((instance: SdkInstance<Components[]>) => any) | undefined;
66
66
  }>, {
67
- trigger: ElementScriptTrigger;
68
67
  clientId: string;
68
+ trigger: ElementScriptTrigger;
69
69
  components: Components[];
70
70
  paypalScriptOptions: Partial<PayPalInput>;
71
71
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -64,8 +64,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
64
64
  onError?: ((error: unknown) => any) | undefined;
65
65
  onReady?: ((instance: SdkInstance<Components[]>) => any) | undefined;
66
66
  }>, {
67
- trigger: ElementScriptTrigger;
68
67
  clientId: string;
68
+ trigger: ElementScriptTrigger;
69
69
  components: Components[];
70
70
  paypalScriptOptions: Partial<PayPalInput>;
71
71
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -62,8 +62,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
62
62
  onError?: ((error: unknown) => any) | undefined;
63
63
  onReady?: ((session: PayPalMessagesSession) => any) | undefined;
64
64
  }>, {
65
- trigger: ElementScriptTrigger;
66
65
  clientId: string;
66
+ trigger: ElementScriptTrigger;
67
67
  paypalScriptOptions: Partial<PayPalInput>;
68
68
  messagesOptions: PayPalMessagesOptions;
69
69
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -62,8 +62,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
62
62
  onError?: ((error: unknown) => any) | undefined;
63
63
  onReady?: ((session: PayPalMessagesSession) => any) | undefined;
64
64
  }>, {
65
- trigger: ElementScriptTrigger;
66
65
  clientId: string;
66
+ trigger: ElementScriptTrigger;
67
67
  paypalScriptOptions: Partial<PayPalInput>;
68
68
  messagesOptions: PayPalMessagesOptions;
69
69
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -3,6 +3,7 @@ import { defu } from "defu";
3
3
  import { injectHead, onNuxtReady, useHead, useNuxtApp, useRuntimeConfig } from "nuxt/app";
4
4
  import { markRaw, ref } from "vue";
5
5
  import { resolveTrigger } from "#build/nuxt-scripts-trigger-resolver";
6
+ import { debugEnabled } from "../debug.js";
6
7
  import { logger } from "../logger.js";
7
8
  function resolveProxyPrefix() {
8
9
  const devtoolsConfig = useRuntimeConfig().public["nuxt-scripts-devtools"];
@@ -227,6 +228,53 @@ export function useScript(input, options) {
227
228
  return reloaded.load();
228
229
  };
229
230
  nuxtApp.$scripts[id] = instance;
231
+ if (import.meta.client && debugEnabled) {
232
+ const registryKey = options?.devtools?.registryKey;
233
+ const src = input?.src;
234
+ const trigger = options?.trigger;
235
+ const loadedFrom = options?.devtools?.loadedFrom;
236
+ const ctx = {
237
+ id: instance.id,
238
+ ...registryKey ? { registryKey } : {},
239
+ ...src ? { src } : {},
240
+ ...loadedFrom ? { loadedFrom } : {}
241
+ };
242
+ const log = logger.withTag(registryKey || instance.id);
243
+ const t0 = performance.now();
244
+ let tLoadStart = 0;
245
+ log.debug("registered", {
246
+ ...ctx,
247
+ trigger: typeof trigger === "object" ? trigger instanceof Promise ? "promise" : JSON.stringify(trigger) : trigger
248
+ });
249
+ options.head.hooks.hook("script:updated", (entry) => {
250
+ if (entry.script.id !== instance.id)
251
+ return;
252
+ const status = entry.script.status;
253
+ const elapsed = Math.round(performance.now() - t0);
254
+ if (status === "loading")
255
+ tLoadStart = performance.now();
256
+ const payload = { ...ctx, status, elapsedMs: elapsed };
257
+ if (status === "loaded" && tLoadStart)
258
+ payload.loadMs = Math.round(performance.now() - tLoadStart);
259
+ const fn = status === "error" ? log.warn : log.debug;
260
+ fn(`status: ${status}`, payload);
261
+ });
262
+ const _origLoad = instance.load;
263
+ instance.load = () => {
264
+ log.debug("load() called", ctx);
265
+ return _origLoad();
266
+ };
267
+ const _origRemove = instance.remove;
268
+ instance.remove = () => {
269
+ log.debug("remove() called", ctx);
270
+ return _origRemove();
271
+ };
272
+ const _origReload = instance.reload;
273
+ instance.reload = async () => {
274
+ log.debug("reload() called", ctx);
275
+ return _origReload();
276
+ };
277
+ }
230
278
  if (import.meta.dev && import.meta.client) {
231
279
  let syncScripts = function() {
232
280
  nuxtApp._scripts[instance.id] = payload;
@@ -0,0 +1 @@
1
+ export declare const debugEnabled: boolean;
@@ -0,0 +1 @@
1
+ export const debugEnabled = typeof __NUXT_SCRIPTS_DEBUG__ !== "undefined" && __NUXT_SCRIPTS_DEBUG__;
@@ -20,7 +20,9 @@ export default defineNuxtPlugin(() => {
20
20
  firstPartyData,
21
21
  route: route ? { path: route.path, fullPath: route.fullPath, query: route.query } : null
22
22
  })
23
- }).catch(() => {
23
+ }).catch((error) => {
24
+ if (import.meta.dev)
25
+ console.warn("[nuxt-scripts] Failed to sync standalone devtools state:", error);
24
26
  });
25
27
  }
26
28
  nuxtApp.hooks.hook("scripts:updated", (ctx) => {
@@ -1,5 +1,9 @@
1
1
  import { createConsola } from "consola";
2
+ import { debugEnabled } from "./debug.js";
2
3
  export const logger = createConsola({
4
+ // 4 = debug, 3 = info (consola defaults). Lift the threshold so `logger.debug`
5
+ // fires when debug is opted-in at build time or in dev.
6
+ level: debugEnabled ? 4 : 3,
3
7
  defaults: {
4
8
  tag: "nuxt-scripts"
5
9
  }
@@ -0,0 +1,14 @@
1
+ import type { ConsentState, GcmConsentApi, UseScriptContext } from '../types.js';
2
+ import { logger } from '../logger.js';
3
+ export type { GcmConsentApi };
4
+ /**
5
+ * GCMv2 consent contract returned by registry scripts (GA, GTM, future Google Ads, …).
6
+ * `useRegistryScript` wires the `consent.default/update` API when present.
7
+ */
8
+ export interface GcmConsentContract {
9
+ /** Forward a `consent`,`<action>`, `<state>` call to the script's transport (dataLayer or gtag). */
10
+ push: (proxy: any, action: 'default' | 'update', state: ConsentState) => void;
11
+ }
12
+ /** Validate a partial GCMv2 consent state. Logs each issue via the registry-scoped logger. */
13
+ export declare function validateConsentState(log: typeof logger, state: ConsentState, source: string): void;
14
+ export declare function attachGcmConsent(instance: UseScriptContext<any, GcmConsentApi>, contract: GcmConsentContract, registryKey: string): void;
@@ -0,0 +1,24 @@
1
+ import { safeParse, strictObject } from "valibot";
2
+ import { logger } from "../logger.js";
3
+ import { gcmConsentState } from "./schemas.js";
4
+ const gcmConsentStateStrict = strictObject(gcmConsentState.entries);
5
+ export function validateConsentState(log, state, source) {
6
+ const result = safeParse(gcmConsentStateStrict, state);
7
+ if (result.success)
8
+ return;
9
+ for (const issue of result.issues)
10
+ log.warn(`${source}: ${issue.message} (path: ${issue.path?.map((p) => p.key).join(".") || "<root>"})`);
11
+ }
12
+ export function attachGcmConsent(instance, contract, registryKey) {
13
+ if (instance.consent)
14
+ return;
15
+ const log = logger.withTag(registryKey);
16
+ const push = (action, state) => {
17
+ validateConsentState(log, state, `consent.${action}()`);
18
+ contract.push(instance.proxy, action, state);
19
+ };
20
+ instance.consent = {
21
+ default: (state) => push("default", state),
22
+ update: (state) => push("update", state)
23
+ };
24
+ }
@@ -0,0 +1,39 @@
1
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
2
+ import { AhrefsAnalyticsOptions } from './schemas.js';
3
+ export { AhrefsAnalyticsOptions };
4
+ export type AhrefsAnalyticsInput = RegistryScriptInput<typeof AhrefsAnalyticsOptions, true, false>;
5
+ export interface AhrefsAnalyticsSendEventOptions {
6
+ /** Custom dimensions sent under `props`. */
7
+ props?: Record<string, string>;
8
+ /** Arbitrary metadata sent under `meta`. */
9
+ meta?: Record<string, unknown>;
10
+ /** Optional callback invoked once the beacon request completes. */
11
+ callback?: (result?: {
12
+ status?: number;
13
+ }) => void;
14
+ }
15
+ export interface AhrefsAnalyticsInstance {
16
+ /**
17
+ * Manually send an event to Ahrefs Analytics. The script auto-fires
18
+ * page-view events on initial load and on `history.pushState`/`popstate`,
19
+ * so SPA navigations are tracked without calling this.
20
+ */
21
+ sendEvent: (name: string, options?: AhrefsAnalyticsSendEventOptions) => void;
22
+ }
23
+ export interface AhrefsAnalyticsApi {
24
+ AhrefsAnalytics: AhrefsAnalyticsInstance;
25
+ }
26
+ declare global {
27
+ interface Window extends AhrefsAnalyticsApi {
28
+ }
29
+ }
30
+ /**
31
+ * Load Ahrefs Web Analytics and expose its `sendEvent` API.
32
+ *
33
+ * The script attaches `window.AhrefsAnalytics` once loaded, fires an initial
34
+ * page-view, and tracks SPA navigations natively by patching
35
+ * `history.pushState` and listening to `popstate`.
36
+ *
37
+ * @see https://ahrefs.com/web-analytics
38
+ */
39
+ export declare function useScriptAhrefsAnalytics<T extends AhrefsAnalyticsApi>(_options?: AhrefsAnalyticsInput): UseScriptContext<T>;
@@ -0,0 +1,18 @@
1
+ import { useRegistryScript } from "../utils.js";
2
+ import { AhrefsAnalyticsOptions } from "./schemas.js";
3
+ export { AhrefsAnalyticsOptions };
4
+ export function useScriptAhrefsAnalytics(_options) {
5
+ return useRegistryScript("ahrefsAnalytics", (options) => ({
6
+ scriptInput: {
7
+ "src": "https://analytics.ahrefs.com/analytics.js",
8
+ "data-key": options.key,
9
+ "crossorigin": false
10
+ },
11
+ schema: import.meta.dev ? AhrefsAnalyticsOptions : void 0,
12
+ scriptOptions: {
13
+ use() {
14
+ return { AhrefsAnalytics: window.AhrefsAnalytics };
15
+ }
16
+ }
17
+ }), _options);
18
+ }
@@ -0,0 +1,76 @@
1
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
2
+ import { CalendlyOptions } from './schemas.js';
3
+ export { CalendlyOptions };
4
+ export type CalendlyInput = RegistryScriptInput<typeof CalendlyOptions, true, false>;
5
+ interface CalendlyPrefill {
6
+ name?: string;
7
+ email?: string;
8
+ firstName?: string;
9
+ lastName?: string;
10
+ customAnswers?: Record<string, string>;
11
+ }
12
+ interface CalendlyUtm {
13
+ utmCampaign?: string;
14
+ utmSource?: string;
15
+ utmMedium?: string;
16
+ utmContent?: string;
17
+ utmTerm?: string;
18
+ }
19
+ interface CalendlyPageSettings {
20
+ backgroundColor?: string;
21
+ hideEventTypeDetails?: boolean;
22
+ hideLandingPageDetails?: boolean;
23
+ hideGdprBanner?: boolean;
24
+ primaryColor?: string;
25
+ textColor?: string;
26
+ }
27
+ export interface CalendlyInlineWidgetOptions {
28
+ url: string;
29
+ parentElement: HTMLElement;
30
+ prefill?: CalendlyPrefill;
31
+ utm?: CalendlyUtm;
32
+ pageSettings?: CalendlyPageSettings;
33
+ }
34
+ export interface CalendlyPopupWidgetOptions {
35
+ url: string;
36
+ rootElement?: HTMLElement;
37
+ text?: string;
38
+ color?: string;
39
+ textColor?: string;
40
+ branding?: boolean;
41
+ prefill?: CalendlyPrefill;
42
+ utm?: CalendlyUtm;
43
+ pageSettings?: CalendlyPageSettings;
44
+ }
45
+ export interface CalendlyBadgeWidgetOptions {
46
+ url: string;
47
+ text?: string;
48
+ color?: string;
49
+ textColor?: string;
50
+ branding?: boolean;
51
+ prefill?: CalendlyPrefill;
52
+ utm?: CalendlyUtm;
53
+ pageSettings?: CalendlyPageSettings;
54
+ }
55
+ export interface CalendlyApi {
56
+ Calendly: {
57
+ initInlineWidget: (options: CalendlyInlineWidgetOptions) => void;
58
+ initPopupWidget: (options: CalendlyPopupWidgetOptions) => void;
59
+ initBadgeWidget: (options: CalendlyBadgeWidgetOptions) => void;
60
+ showPopupWidget: (url: string) => void;
61
+ closePopupWidget: () => void;
62
+ initPopupWidgetWithText: (options: CalendlyPopupWidgetOptions) => void;
63
+ q?: unknown[];
64
+ };
65
+ }
66
+ declare global {
67
+ interface Window extends CalendlyApi {
68
+ }
69
+ }
70
+ /**
71
+ * Load the Calendly widget script and expose a typed `Calendly` proxy for
72
+ * inline, popup, and badge bookings.
73
+ *
74
+ * @see https://help.calendly.com/hc/en-us/articles/223147027
75
+ */
76
+ export declare function useScriptCalendly<T extends CalendlyApi>(_options?: CalendlyInput): UseScriptContext<T>;
@@ -0,0 +1,63 @@
1
+ import { useHead } from "@unhead/vue";
2
+ import { useRegistryScript } from "../utils.js";
3
+ import { CalendlyOptions } from "./schemas.js";
4
+ export { CalendlyOptions };
5
+ const CALENDLY_CSS_KEY = "nuxt-scripts-calendly-css";
6
+ const CALENDLY_CLOSE_ICON = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
7
+ '<svg width="22" height="22" xmlns="http://www.w3.org/2000/svg"><path d="M11.192 9.071l7.779-7.778a1.5 1.5 0 0 1 2.12 2.121l-7.777 7.778 7.778 7.779a1.5 1.5 0 1 1-2.121 2.12l-7.779-7.777-7.778 7.778a1.5 1.5 0 1 1-2.121-2.121l7.778-7.779-7.778-7.778a1.5 1.5 0 0 1 2.121-2.121l7.778 7.778z" fill="#FFF" fill-rule="nonzero"/></svg>'
8
+ )}`;
9
+ const CALENDLY_CSS = `.calendly-badge-widget,.calendly-badge-widget *,.calendly-inline-widget,.calendly-inline-widget *,.calendly-overlay,.calendly-overlay *{font-size:16px;line-height:1.2em}.calendly-badge-widget iframe,.calendly-inline-widget iframe,.calendly-overlay iframe{display:inline;height:100%;width:100%}.calendly-popup-content{position:relative}.calendly-popup-content.calendly-mobile{-webkit-overflow-scrolling:touch;overflow-y:auto}.calendly-overlay{background-color:#a5a5a5;background-color:rgba(31,31,31,.4);bottom:0;left:0;overflow:hidden;position:fixed;right:0;top:0;z-index:9999}.calendly-overlay .calendly-close-overlay{bottom:0;left:0;position:absolute;right:0;top:0}.calendly-overlay .calendly-popup{box-sizing:border-box;height:90%;left:50%;max-height:700px!important;max-width:1000px;min-width:900px;position:absolute;top:50%;transform:translateY(-50%) translateX(-50%);width:80%}@media (max-width:975px){.calendly-overlay .calendly-popup{bottom:0;height:auto;left:0;max-height:none;min-width:0;position:fixed;right:0;top:50px;transform:none;width:100%}}.calendly-overlay .calendly-popup .calendly-popup-content{height:100%}.calendly-overlay .calendly-popup-close{background:url(${CALENDLY_CLOSE_ICON}) no-repeat;background-size:contain;color:#fff;cursor:pointer;height:19px;position:absolute;right:25px;top:25px;width:19px}@media (max-width:975px){.calendly-overlay .calendly-popup-close{right:15px;top:15px}}.calendly-badge-widget{bottom:15px;position:fixed;right:20px;z-index:9998}.calendly-badge-widget .calendly-badge-content{border-radius:25px;box-shadow:0 2px 5px rgba(0,0,0,.25);color:#fff;cursor:pointer;display:table-cell;font-family:sans-serif;font-size:14px;font-weight:700;height:45px;padding:0 30px;text-align:center;vertical-align:middle;width:auto}.calendly-badge-widget .calendly-badge-content.calendly-white{color:#666a73}.calendly-badge-widget .calendly-badge-content span{display:block;font-size:12px}.calendly-spinner{left:0;position:absolute;right:0;text-align:center;top:50%;transform:translateY(-50%);z-index:-1}.calendly-spinner>div{animation:calendly-bouncedelay 1.4s ease-in-out infinite;animation-fill-mode:both;background-color:#e1e1e1;border-radius:50%;display:inline-block;height:18px;vertical-align:middle;width:18px}.calendly-spinner .calendly-bounce1{animation-delay:-.32s}.calendly-spinner .calendly-bounce2{animation-delay:-.16s}@keyframes calendly-bouncedelay{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}`;
10
+ function ensureCalendlyStylesheet() {
11
+ if (import.meta.server)
12
+ return;
13
+ useHead({
14
+ style: [
15
+ {
16
+ key: CALENDLY_CSS_KEY,
17
+ innerHTML: CALENDLY_CSS
18
+ }
19
+ ]
20
+ });
21
+ }
22
+ export function useScriptCalendly(_options) {
23
+ ensureCalendlyStylesheet();
24
+ return useRegistryScript("calendly", () => ({
25
+ scriptInput: {
26
+ src: "https://assets.calendly.com/assets/external/widget.js",
27
+ crossorigin: false
28
+ },
29
+ schema: import.meta.dev ? CalendlyOptions : void 0,
30
+ scriptOptions: {
31
+ use() {
32
+ return { Calendly: window.Calendly };
33
+ }
34
+ },
35
+ clientInit: import.meta.server ? void 0 : () => {
36
+ if (window.Calendly)
37
+ return;
38
+ const queue = [];
39
+ const stub = {
40
+ q: queue,
41
+ initInlineWidget(...args) {
42
+ queue.push(["initInlineWidget", ...args]);
43
+ },
44
+ initPopupWidget(...args) {
45
+ queue.push(["initPopupWidget", ...args]);
46
+ },
47
+ initBadgeWidget(...args) {
48
+ queue.push(["initBadgeWidget", ...args]);
49
+ },
50
+ initPopupWidgetWithText(...args) {
51
+ queue.push(["initPopupWidgetWithText", ...args]);
52
+ },
53
+ showPopupWidget(...args) {
54
+ queue.push(["showPopupWidget", ...args]);
55
+ },
56
+ closePopupWidget(...args) {
57
+ queue.push(["closePopupWidget", ...args]);
58
+ }
59
+ };
60
+ window.Calendly = stub;
61
+ }
62
+ }), _options);
63
+ }
@@ -1,4 +1,5 @@
1
- import type { ConsentState, RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
1
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
2
+ import type { GcmConsentApi } from './_gcm-consent.js';
2
3
  import { GoogleAnalyticsOptions } from './schemas.js';
3
4
  export type GtagCustomParams = Record<string, any>;
4
5
  export type ConsentStatus = 'granted' | 'denied';
@@ -58,10 +59,8 @@ export interface GoogleAnalyticsApi {
58
59
  }
59
60
  export { GoogleAnalyticsOptions };
60
61
  export type GoogleAnalyticsInput = RegistryScriptInput<typeof GoogleAnalyticsOptions>;
61
- export interface GoogleAnalyticsConsent {
62
- /** Send `gtag('consent','update', state)` with GCMv2 partial state. */
63
- update: (state: ConsentState) => void;
64
- }
62
+ /** @deprecated Use {@link GcmConsentApi} from `#nuxt-scripts/types` instead. */
63
+ export type GoogleAnalyticsConsent = GcmConsentApi;
65
64
  export declare function useScriptGoogleAnalytics<T extends GoogleAnalyticsApi>(_options?: GoogleAnalyticsInput & {
66
65
  onBeforeGtagStart?: (gtag: GTag) => void;
67
- }): UseScriptContext<T, GoogleAnalyticsConsent>;
66
+ }): UseScriptContext<T, GcmConsentApi>;
@@ -3,7 +3,7 @@ import { useRegistryScript } from "#nuxt-scripts/utils";
3
3
  import { GoogleAnalyticsOptions } from "./schemas.js";
4
4
  export { GoogleAnalyticsOptions };
5
5
  export function useScriptGoogleAnalytics(_options) {
6
- const instance = useRegistryScript(_options?.key || "googleAnalytics", (options) => {
6
+ return useRegistryScript(_options?.key || "googleAnalytics", (options) => {
7
7
  const dataLayerName = options?.l ?? "dataLayer";
8
8
  const w = import.meta.client ? window : {};
9
9
  return {
@@ -19,6 +19,9 @@ export function useScriptGoogleAnalytics(_options) {
19
19
  };
20
20
  }
21
21
  },
22
+ gcmConsent: {
23
+ push: (proxy, action, state) => proxy.gtag("consent", action, state)
24
+ },
22
25
  clientInit: import.meta.server ? void 0 : () => {
23
26
  w[dataLayerName] = w[dataLayerName] || [];
24
27
  w.gtag = function() {
@@ -37,13 +40,4 @@ export function useScriptGoogleAnalytics(_options) {
37
40
  }
38
41
  };
39
42
  }, _options);
40
- if (import.meta.client && !instance.consent) {
41
- instance.consent = {
42
- update: (state) => {
43
- ;
44
- instance.proxy.gtag("consent", "update", state);
45
- }
46
- };
47
- }
48
- return instance;
49
43
  }
@@ -1,4 +1,5 @@
1
- import type { ConsentState, NuxtUseScriptOptions, RegistryScriptInput, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
1
+ import type { NuxtUseScriptOptions, RegistryScriptInput, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
2
+ import type { GcmConsentApi } from './_gcm-consent.js';
2
3
  import type { GTag } from './google-analytics.js';
3
4
  import { GoogleTagManagerOptions } from './schemas.js';
4
5
  /**
@@ -68,10 +69,8 @@ declare global {
68
69
  }
69
70
  export { GoogleTagManagerOptions };
70
71
  export type GoogleTagManagerInput = RegistryScriptInput<typeof GoogleTagManagerOptions>;
71
- export interface GoogleTagManagerConsent {
72
- /** Push `['consent','update', state]` onto dataLayer with GCMv2 partial state. */
73
- update: (state: ConsentState) => void;
74
- }
72
+ /** @deprecated Use {@link GcmConsentApi} from `#nuxt-scripts/types` instead. */
73
+ export type GoogleTagManagerConsent = GcmConsentApi;
75
74
  /**
76
75
  * Hook to use Google Tag Manager in Nuxt applications
77
76
  */
@@ -81,4 +80,4 @@ export declare function useScriptGoogleTagManager<T extends GoogleTagManagerApi>
81
80
  * Allows for custom initialization or configuration
82
81
  */
83
82
  onBeforeGtmStart?: (gtag: DataLayerPush) => void;
84
- }): UseScriptContext<UseFunctionType<NuxtUseScriptOptions<T>, T>, GoogleTagManagerConsent>;
83
+ }): UseScriptContext<UseFunctionType<NuxtUseScriptOptions<T>, T>, GcmConsentApi>;
@@ -3,7 +3,7 @@ import { useRegistryScript } from "#nuxt-scripts/utils";
3
3
  import { GoogleTagManagerOptions } from "./schemas.js";
4
4
  export { GoogleTagManagerOptions };
5
5
  export function useScriptGoogleTagManager(options) {
6
- const instance = useRegistryScript(
6
+ return useRegistryScript(
7
7
  options?.key || "googleTagManager",
8
8
  (opts) => {
9
9
  const dataLayerName = opts?.l ?? opts?.dataLayer ?? "dataLayer";
@@ -31,10 +31,20 @@ export function useScriptGoogleTagManager(options) {
31
31
  };
32
32
  }
33
33
  },
34
+ gcmConsent: {
35
+ // Match the gtag.js contract: enqueue an `Arguments` object, not a plain Array,
36
+ // so GTM/Tag Assistant/Analytics Debugger recognise the consent command. See #770/#771.
37
+ push: (_proxy, action, state) => {
38
+ const dl = window[dataLayerName] = window[dataLayerName] || [];
39
+ (function(..._args) {
40
+ dl.push(arguments);
41
+ })("consent", action, state);
42
+ }
43
+ },
34
44
  clientInit: import.meta.server ? void 0 : () => {
35
45
  window[dataLayerName] = window[dataLayerName] || [];
36
- function gtag(...args) {
37
- window[dataLayerName].push(args);
46
+ function gtag(..._args) {
47
+ window[dataLayerName].push(arguments);
38
48
  }
39
49
  window.gtag = gtag;
40
50
  if (opts.defaultConsent) {
@@ -52,19 +62,4 @@ export function useScriptGoogleTagManager(options) {
52
62
  },
53
63
  options
54
64
  );
55
- if (import.meta.client && options?.onBeforeGtmStart) {
56
- const gtag = window.gtag;
57
- if (gtag)
58
- options.onBeforeGtmStart(gtag);
59
- }
60
- const typed = instance;
61
- if (import.meta.client && !typed.consent) {
62
- typed.consent = {
63
- update: (state) => {
64
- ;
65
- typed.proxy.dataLayer.push(["consent", "update", state]);
66
- }
67
- };
68
- }
69
- return typed;
70
65
  }
@@ -0,0 +1,35 @@
1
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
2
+ import { LinkedInInsightOptions } from './schemas.js';
3
+ export { LinkedInInsightOptions };
4
+ export type LinkedInInsightInput = RegistryScriptInput<typeof LinkedInInsightOptions, true, false>;
5
+ interface LintrkTrackParams {
6
+ conversion_id?: number;
7
+ event_id?: string;
8
+ commandCallback?: () => void;
9
+ [key: string]: any;
10
+ }
11
+ interface LintrkUserData {
12
+ /** Plain email; the script SHA-256 hashes it before sending. */
13
+ email: string;
14
+ }
15
+ type LintrkFns = ((cmd: 'track', params?: LintrkTrackParams) => void) & ((cmd: 'setUserData', data: LintrkUserData) => void) & ((cmd: (string & {}), ...args: any[]) => void);
16
+ export interface LinkedInInsightApi {
17
+ lintrk: LintrkFns & {
18
+ q?: unknown[];
19
+ };
20
+ }
21
+ declare global {
22
+ interface Window extends LinkedInInsightApi {
23
+ _linkedin_partner_id?: string;
24
+ _linkedin_data_partner_ids?: string[];
25
+ _linkedin_event_id?: string;
26
+ _wait_for_lintrk?: boolean;
27
+ }
28
+ }
29
+ /**
30
+ * Load the LinkedIn Insight Tag and expose a typed `lintrk` proxy.
31
+ *
32
+ * @see https://www.linkedin.com/help/lms/answer/a418880
33
+ * @see https://learn.microsoft.com/en-us/linkedin/marketing/conversions/deduplication
34
+ */
35
+ export declare function useScriptLinkedInInsight<T extends LinkedInInsightApi>(_options?: LinkedInInsightInput): UseScriptContext<T>;
@@ -0,0 +1,49 @@
1
+ import { useScriptEventPage } from "../composables/useScriptEventPage.js";
2
+ import { useRegistryScript } from "../utils.js";
3
+ import { LinkedInInsightOptions } from "./schemas.js";
4
+ export { LinkedInInsightOptions };
5
+ export function useScriptLinkedInInsight(_options) {
6
+ let enableAutoSpaTracking = false;
7
+ const instance = useRegistryScript("linkedinInsight", (options) => {
8
+ enableAutoSpaTracking = !!options.enableAutoSpaTracking;
9
+ return {
10
+ scriptInput: {
11
+ src: "https://snap.licdn.com/li.lms-analytics/insight.min.js",
12
+ crossorigin: false
13
+ },
14
+ schema: import.meta.dev ? LinkedInInsightOptions : void 0,
15
+ scriptOptions: {
16
+ use() {
17
+ return { lintrk: window.lintrk };
18
+ }
19
+ },
20
+ clientInit: import.meta.server ? void 0 : () => {
21
+ const ids = Array.isArray(options.id) ? options.id : [options.id];
22
+ if (options.eventId)
23
+ window._linkedin_event_id = options.eventId;
24
+ if (options.enableAutoSpaTracking)
25
+ window._wait_for_lintrk = true;
26
+ window._linkedin_partner_id = ids[0];
27
+ window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
28
+ for (const id of ids) {
29
+ if (!window._linkedin_data_partner_ids.includes(id))
30
+ window._linkedin_data_partner_ids.push(id);
31
+ }
32
+ if (!window.lintrk) {
33
+ const lintrk = function(cmd, ...args) {
34
+ ;
35
+ lintrk.q.push([cmd, ...args]);
36
+ };
37
+ lintrk.q = [];
38
+ window.lintrk = lintrk;
39
+ }
40
+ }
41
+ };
42
+ }, _options);
43
+ if (import.meta.client && enableAutoSpaTracking) {
44
+ useScriptEventPage(() => {
45
+ window.lintrk?.("track");
46
+ });
47
+ }
48
+ return instance;
49
+ }