@nuxt/scripts 0.1.12 → 0.3.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 (151) hide show
  1. package/README.md +10 -200
  2. package/dist/client/200.html +63 -54
  3. package/dist/client/404.html +63 -54
  4. package/dist/client/_nuxt/8T3kBMJO.js +31 -0
  5. package/dist/client/_nuxt/B5NHDIr7.js +353 -0
  6. package/dist/client/_nuxt/{Bz4xi2rU.js → B6ZnTe72.js} +1 -1
  7. package/dist/client/_nuxt/{B6nY7VDA.js → B6bHXiXE.js} +1 -1
  8. package/dist/client/_nuxt/BAMIS8DD.js +1 -0
  9. package/dist/client/_nuxt/{A1WiD9SJ.js → BGq4KZyx.js} +1 -1
  10. package/dist/client/_nuxt/BVGdgKAv.js +1 -0
  11. package/dist/client/_nuxt/{wORFcijT.js → BXR915QZ.js} +1 -1
  12. package/dist/client/_nuxt/{DCj4DH6i.js → BYdKNJ10.js} +1 -1
  13. package/dist/client/_nuxt/BZfs-ost.js +1 -0
  14. package/dist/client/_nuxt/{DCdPDLy4.js → BacI6-DX.js} +1 -1
  15. package/dist/client/_nuxt/{DCk2z-Tu.js → BdfWgkoX.js} +1 -1
  16. package/dist/client/_nuxt/BscxmKrE.js +8 -0
  17. package/dist/client/_nuxt/C3qJFuQy.js +3 -0
  18. package/dist/client/_nuxt/C6XIsc4F.js +1 -0
  19. package/dist/client/_nuxt/C9UBdavN.js +1 -0
  20. package/dist/client/_nuxt/CA9nliXM.js +1 -0
  21. package/dist/client/_nuxt/CDJL3WWm.js +1 -0
  22. package/dist/client/_nuxt/{BsfQk1vf.js → CEfge3mM.js} +1 -1
  23. package/dist/client/_nuxt/{CQTpvb7m.js → CHCTrc3a.js} +1 -1
  24. package/dist/client/_nuxt/{DZ3fVoEH.js → CSPeAESR.js} +1 -1
  25. package/dist/client/_nuxt/CX2EUjC8.js +301 -0
  26. package/dist/client/_nuxt/{DCAtC51B.js → CarfVElc.js} +1 -1
  27. package/dist/client/_nuxt/{BgBwMnrY.js → CcYwH0AH.js} +1 -1
  28. package/dist/client/_nuxt/Cgl53LJQ.js +1 -0
  29. package/dist/client/_nuxt/{RgJsN3zu.js → ChMCFiS0.js} +1 -1
  30. package/dist/client/_nuxt/{CW3w6uup.js → CovTDKFE.js} +1 -1
  31. package/dist/client/_nuxt/{DfUNg_8t.js → CqYeW6XZ.js} +1 -1
  32. package/dist/client/_nuxt/{CL7Ixq1B.js → CrgTADc5.js} +1 -1
  33. package/dist/client/_nuxt/CuJfdYLG.js +1 -0
  34. package/dist/client/_nuxt/CudBhkk3.js +1 -0
  35. package/dist/client/_nuxt/D71BffLY.js +1 -0
  36. package/dist/client/_nuxt/{7fd6vGzb.js → DBeuZS66.js} +1 -1
  37. package/dist/client/_nuxt/{Bd7iooY8.js → DGDuLtS6.js} +1 -1
  38. package/dist/client/_nuxt/{j8KhMG0x.js → DGxQkqYo.js} +1 -1
  39. package/dist/client/_nuxt/DIt5FBMJ.js +1 -0
  40. package/dist/client/_nuxt/DOakR0z3.js +1 -0
  41. package/dist/client/_nuxt/{CUVblut_.js → DR5YgmI2.js} +1 -1
  42. package/dist/client/_nuxt/DS9ZWoKD.js +1 -0
  43. package/dist/client/_nuxt/{D-pQtGOP.js → DVLwECkk.js} +1 -1
  44. package/dist/client/_nuxt/DZLoTQm4.js +1 -0
  45. package/dist/client/_nuxt/{ZQC2c-5V.js → D_T9yQUo.js} +3 -3
  46. package/dist/client/_nuxt/Db2-y2xY.js +1 -0
  47. package/dist/client/_nuxt/{CRWwmX0L.js → Di3qjVs2.js} +1 -1
  48. package/dist/client/_nuxt/{DXpYegZJ.js → Djqq6n-7.js} +1 -1
  49. package/dist/client/_nuxt/Dkb1Nx48.js +1 -0
  50. package/dist/client/_nuxt/{BBv1LFm6.js → DtT2Dbx_.js} +1 -1
  51. package/dist/client/_nuxt/{DywwDckn.js → Du6_OKDb.js} +1 -1
  52. package/dist/client/_nuxt/{IHMnEr_d.js → G-Jz5hiA.js} +1 -1
  53. package/dist/client/_nuxt/HrnDn_2Q.js +1 -0
  54. package/dist/client/_nuxt/{CPHkTjfH.js → JgH_6NEN.js} +1 -1
  55. package/dist/client/_nuxt/Ksn5IXup.js +1 -0
  56. package/dist/client/_nuxt/{wPLeKH6q.js → Lpdzc9s2.js} +1 -1
  57. package/dist/client/_nuxt/{DggdVF2v.js → V_y36BGi.js} +1 -1
  58. package/dist/client/_nuxt/{BILqrcpa.js → YdT6Gj0u.js} +1 -1
  59. package/dist/client/_nuxt/alpzPJ78.js +1 -0
  60. package/dist/client/_nuxt/builds/latest.json +1 -1
  61. package/dist/client/_nuxt/builds/meta/ccc94de9-89fa-400b-88f2-8fc2599e191f.json +1 -0
  62. package/dist/client/_nuxt/{Bdb36Id5.js → dIHJ9UdL.js} +1 -1
  63. package/dist/client/_nuxt/error-404.BRldFSII.css +1 -0
  64. package/dist/client/_nuxt/error-500.D8yw_IbC.css +1 -0
  65. package/dist/client/_nuxt/o5b8QYQO.js +3 -0
  66. package/dist/client/_nuxt/{doGI2cFk.js → wKgfcFVx.js} +1 -1
  67. package/dist/client/index.html +63 -54
  68. package/dist/module.d.mts +2 -6
  69. package/dist/module.d.ts +2 -6
  70. package/dist/module.json +6 -2
  71. package/dist/module.mjs +68 -137
  72. package/dist/registry.d.mts +13 -0
  73. package/dist/registry.d.ts +13 -0
  74. package/dist/registry.mjs +214 -0
  75. package/dist/runtime/components/GoogleMaps.vue +130 -0
  76. package/dist/runtime/components/LemonSqueezyButton.vue +28 -0
  77. package/dist/runtime/components/StripePricingTableEmbed.vue +33 -0
  78. package/dist/runtime/components/VimeoEmbed.vue +161 -0
  79. package/dist/runtime/components/YouTubeEmbed.vue +79 -0
  80. package/dist/runtime/composables/createConsentScriptTrigger.d.ts +6 -0
  81. package/dist/runtime/composables/{createScriptConsentTrigger.mjs → createConsentScriptTrigger.mjs} +1 -1
  82. package/dist/runtime/composables/useAnalyticsPageEvent.d.ts +4 -1
  83. package/dist/runtime/composables/useElementScriptTrigger.d.ts +3 -0
  84. package/dist/runtime/composables/useElementScriptTrigger.mjs +9 -0
  85. package/dist/runtime/composables/useScript.d.ts +2 -2
  86. package/dist/runtime/composables/useScript.mjs +1 -2
  87. package/dist/runtime/registry/cloudflare-web-analytics.d.ts +11 -7
  88. package/dist/runtime/registry/cloudflare-web-analytics.mjs +16 -18
  89. package/dist/runtime/registry/facebook-pixel.d.ts +6 -5
  90. package/dist/runtime/registry/facebook-pixel.mjs +15 -17
  91. package/dist/runtime/registry/fathom-analytics.d.ts +39 -14
  92. package/dist/runtime/registry/fathom-analytics.mjs +40 -21
  93. package/dist/runtime/registry/google-analytics.d.ts +21 -1
  94. package/dist/runtime/registry/google-analytics.mjs +30 -3
  95. package/dist/runtime/registry/google-maps.d.ts +23 -1
  96. package/dist/runtime/registry/google-maps.mjs +40 -3
  97. package/dist/runtime/registry/google-tag-manager.d.ts +21 -1
  98. package/dist/runtime/registry/google-tag-manager.mjs +29 -3
  99. package/dist/runtime/registry/hotjar.d.ts +5 -3
  100. package/dist/runtime/registry/hotjar.mjs +14 -18
  101. package/dist/runtime/registry/intercom.d.ts +5 -3
  102. package/dist/runtime/registry/intercom.mjs +19 -16
  103. package/dist/runtime/registry/lemon-squeezy.d.ts +68 -0
  104. package/dist/runtime/registry/lemon-squeezy.mjs +21 -0
  105. package/dist/runtime/registry/matomo-analytics.d.ts +24 -0
  106. package/dist/runtime/registry/matomo-analytics.mjs +33 -0
  107. package/dist/runtime/registry/npm.d.ts +7 -3
  108. package/dist/runtime/registry/npm.mjs +10 -11
  109. package/dist/runtime/registry/plausible-analytics.d.ts +22 -0
  110. package/dist/runtime/registry/plausible-analytics.mjs +35 -0
  111. package/dist/runtime/registry/segment.d.ts +5 -3
  112. package/dist/runtime/registry/segment.mjs +34 -34
  113. package/dist/runtime/registry/stripe.d.ts +18 -0
  114. package/dist/runtime/registry/stripe.mjs +27 -0
  115. package/dist/runtime/registry/vimeo-player.d.ts +15 -0
  116. package/dist/runtime/registry/vimeo-player.mjs +45 -0
  117. package/dist/runtime/registry/x-pixel.d.ts +41 -0
  118. package/dist/runtime/registry/x-pixel.mjs +28 -0
  119. package/dist/runtime/registry/youtube-iframe.d.ts +15 -0
  120. package/dist/runtime/registry/youtube-iframe.mjs +54 -0
  121. package/dist/runtime/types.d.ts +31 -17
  122. package/dist/runtime/utils.d.ts +16 -1
  123. package/dist/runtime/utils.mjs +30 -1
  124. package/package.json +40 -25
  125. package/dist/client/_nuxt/BG_OyJVq.js +0 -1
  126. package/dist/client/_nuxt/BIMuYTWL.js +0 -3
  127. package/dist/client/_nuxt/BSyl5yf0.js +0 -1
  128. package/dist/client/_nuxt/BswfO-CF.js +0 -1
  129. package/dist/client/_nuxt/C3YqBJkQ.js +0 -1
  130. package/dist/client/_nuxt/CGQbO34C.js +0 -1
  131. package/dist/client/_nuxt/CKtB_0Vj.js +0 -36
  132. package/dist/client/_nuxt/CrjQeCwm.js +0 -1
  133. package/dist/client/_nuxt/D4LhxNOI.js +0 -1
  134. package/dist/client/_nuxt/D4k753MY.js +0 -1
  135. package/dist/client/_nuxt/D75a3hZQ.js +0 -1
  136. package/dist/client/_nuxt/DnhXxWz-.js +0 -1
  137. package/dist/client/_nuxt/DzPyIVdT.js +0 -9
  138. package/dist/client/_nuxt/TQ9oWRfF.js +0 -1
  139. package/dist/client/_nuxt/WoBtJUue.js +0 -1
  140. package/dist/client/_nuxt/bmJ2objS.js +0 -1
  141. package/dist/client/_nuxt/builds/meta/7bb27f9d-e4a9-494c-83a3-01bc2df7d17d.json +0 -1
  142. package/dist/client/_nuxt/error-404.ORekjfyJ.css +0 -1
  143. package/dist/client/_nuxt/error-500.BIuFL0tW.css +0 -1
  144. package/dist/client/_nuxt/yr0V4Txy.js +0 -1
  145. package/dist/runtime/composables/createScriptConsentTrigger.d.ts +0 -6
  146. package/dist/runtime/composables/validateScriptInputSchema.d.ts +0 -2
  147. package/dist/runtime/composables/validateScriptInputSchema.mjs +0 -14
  148. package/dist/runtime/registry/cloudflare-turnstile.d.ts +0 -1
  149. package/dist/runtime/registry/cloudflare-turnstile.mjs +0 -4
  150. package/dist/runtime/registry/confetti.d.ts +0 -23
  151. package/dist/runtime/registry/confetti.mjs +0 -15
@@ -1,29 +1,25 @@
1
1
  import { number, object, optional } from "valibot";
2
- import { useScript, validateScriptInputSchema } from "#imports";
2
+ import { registryScript } from "../utils.mjs";
3
3
  export const HotjarOptions = object({
4
4
  id: number(),
5
5
  sv: optional(number())
6
6
  });
7
- export function useScriptHotjar(options, _scriptOptions) {
8
- const scriptOptions = _scriptOptions || {};
9
- scriptOptions.beforeInit = () => {
10
- import.meta.dev && validateScriptInputSchema(HotjarOptions, options);
11
- if (import.meta.client) {
7
+ export function useScriptHotjar(_options) {
8
+ return registryScript("hotjar", (options) => ({
9
+ scriptInput: {
10
+ src: `https://static.hotjar.com/c/hotjar-${options?.id}.js?sv=${options?.sv}`
11
+ },
12
+ schema: HotjarOptions,
13
+ scriptOptions: {
14
+ use() {
15
+ return { hj: window.hj };
16
+ }
17
+ },
18
+ clientInit: import.meta.server ? void 0 : () => {
12
19
  window._hjSettings = window._hjSettings || { hjid: options?.id, hjsv: options?.sv };
13
20
  window.hj = window.hj || function(...params) {
14
21
  (window.hj.q = window.hj.q || []).push(params);
15
22
  };
16
23
  }
17
- _scriptOptions?.beforeInit?.();
18
- };
19
- return useScript({
20
- key: "hotjar",
21
- // requires extra steps to bundle
22
- src: options?.src || `https://static.hotjar.com/c/hotjar-${options?.id}.js?sv=${options?.sv}`
23
- }, {
24
- ...scriptOptions,
25
- use() {
26
- return { hj: window.hj };
27
- }
28
- });
24
+ }), _options);
29
25
  }
@@ -1,5 +1,5 @@
1
1
  import { type Input } from 'valibot';
2
- import type { NuxtUseScriptIntegrationOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
3
  export declare const IntercomOptions: import("valibot").ObjectSchema<{
4
4
  app_id: import("valibot").StringSchema<string>;
5
5
  api_base: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"https://api-iam.intercom.io", "https://api-iam.intercom.io"> | import("valibot").LiteralSchema<"https://api-iam.eu.intercom.io", "https://api-iam.eu.intercom.io"> | import("valibot").LiteralSchema<"https://api-iam.au.intercom.io", "https://api-iam.au.intercom.io">)[], "https://api-iam.intercom.io" | "https://api-iam.eu.intercom.io" | "https://api-iam.au.intercom.io">, undefined, "https://api-iam.intercom.io" | "https://api-iam.eu.intercom.io" | "https://api-iam.au.intercom.io" | undefined>;
@@ -19,7 +19,7 @@ export declare const IntercomOptions: import("valibot").ObjectSchema<{
19
19
  horizontal_padding?: number | undefined;
20
20
  vertical_padding?: number | undefined;
21
21
  }>;
22
- export type IntercomInput = ScriptDynamicSrcInput<typeof IntercomOptions>;
22
+ export type IntercomInput = RegistryScriptInput<typeof IntercomOptions>;
23
23
  export interface IntercomApi {
24
24
  Intercom: ((event: 'boot', data?: Input<typeof IntercomOptions>) => void) & ((event: 'shutdown') => void) & ((event: 'update', options?: Input<typeof IntercomOptions>) => void) & ((event: 'hide') => void) & ((event: 'show') => void) & ((event: 'showSpace', spaceName: 'home' | 'messages' | 'help' | 'news' | 'tasks' | 'tickets' | string) => void) & ((event: 'showMessages') => void) & ((event: 'showNewMessage', content?: string) => void) & ((event: 'onHide', fn: () => void) => void) & ((event: 'onShow', fn: () => void) => void) & ((event: 'onUnreadCountChange', fn: () => void) => void) & ((event: 'trackEvent', eventName: string, metadata?: Record<string, any>) => void) & ((event: 'getVisitorId') => Promise<string>) & ((event: 'startTour', tourId: string | number) => void) & ((event: 'showArticle', articleId: string | number) => void) & ((event: 'showNews', newsItemId: string | number) => void) & ((event: 'startSurvey', surveyId: string | number) => void) & ((event: 'startChecklist', checklistId: string | number) => void) & ((event: 'showTicket', ticketId: string | number) => void) & ((event: 'showConversation', conversationId: string | number) => void) & ((event: 'onUserEmailSupplied', fn: () => void) => void) & ((event: string, ...params: any[]) => void);
25
25
  }
@@ -28,4 +28,6 @@ declare global {
28
28
  intercomSettings?: IntercomInput;
29
29
  }
30
30
  }
31
- export declare function useScriptIntercom<T extends IntercomApi>(options?: IntercomInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
31
+ export declare function useScriptIntercom<T extends IntercomApi>(_options?: IntercomInput): T & {
32
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
33
+ };
@@ -1,6 +1,6 @@
1
1
  import { literal, number, object, optional, string, union } from "valibot";
2
2
  import { joinURL } from "ufo";
3
- import { useScript, validateScriptInputSchema } from "#imports";
3
+ import { registryScript } from "../utils.mjs";
4
4
  export const IntercomOptions = object({
5
5
  app_id: string(),
6
6
  api_base: optional(union([literal("https://api-iam.intercom.io"), literal("https://api-iam.eu.intercom.io"), literal("https://api-iam.au.intercom.io")])),
@@ -12,21 +12,24 @@ export const IntercomOptions = object({
12
12
  horizontal_padding: optional(number()),
13
13
  vertical_padding: optional(number())
14
14
  });
15
- export function useScriptIntercom(options, _scriptOptions) {
16
- const scriptOptions = _scriptOptions || {};
17
- scriptOptions.beforeInit = () => {
18
- import.meta.dev && validateScriptInputSchema(IntercomOptions, options);
19
- if (import.meta.client)
15
+ export function useScriptIntercom(_options) {
16
+ return registryScript("intercom", (options) => ({
17
+ scriptInput: {
18
+ src: joinURL(`https://widget.intercom.io/widget`, options?.app_id || ""),
19
+ // append the data attr's
20
+ ...Object.entries(options).filter(([key]) => key.startsWith("data-")).reduce((acc, [key, value]) => {
21
+ acc[key] = value;
22
+ return acc;
23
+ })
24
+ },
25
+ schema: IntercomOptions,
26
+ scriptOptions: {
27
+ use() {
28
+ return { Intercom: window.Intercom };
29
+ }
30
+ },
31
+ clientInit: import.meta.server ? void 0 : () => {
20
32
  window.intercomSettings = options;
21
- _scriptOptions?.beforeInit?.();
22
- };
23
- return useScript({
24
- key: "intercom",
25
- src: options?.src || joinURL(`https://widget.intercom.io/widget`, options?.app_id || "")
26
- }, {
27
- ...scriptOptions,
28
- use() {
29
- return { Intercom: window.Intercom };
30
33
  }
31
- });
34
+ }), _options);
32
35
  }
@@ -0,0 +1,68 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
+ export declare const LemonSqueezyOptions: import("valibot").ObjectSchema<{}, undefined, {}>;
3
+ export type LemonSqueezyInput = RegistryScriptInput<typeof LemonSqueezyOptions>;
4
+ export interface LemonSqueezyApi {
5
+ /**
6
+ * Initialises Lemon.js on your page.
7
+ * @param options - An object with a single property, eventHandler, which is a function that will be called when Lemon.js emits an event.
8
+ */
9
+ Setup: (options: {
10
+ eventHandler: (event: {
11
+ event: 'Checkout.Success';
12
+ data: Record<string, any>;
13
+ } & {
14
+ event: 'PaymentMethodUpdate.Mounted';
15
+ } & {
16
+ event: 'PaymentMethodUpdate.Closed';
17
+ } & {
18
+ event: 'PaymentMethodUpdate.Updated';
19
+ } & {
20
+ event: string;
21
+ }) => void;
22
+ }) => void;
23
+ /**
24
+ * Refreshes `lemonsqueezy-button` listeners on the page.
25
+ */
26
+ Refresh: () => void;
27
+ Url: {
28
+ /**
29
+ * Opens a given Lemon Squeezy URL, typically these are Checkout or Payment Details Update overlays.
30
+ * @param url - The URL to open.
31
+ */
32
+ Open: (url: string) => void;
33
+ /**
34
+ * Closes the current opened Lemon Squeezy overlay checkout window.
35
+ */
36
+ Close: () => void;
37
+ };
38
+ Affiliate: {
39
+ /**
40
+ * Retrieve the affiliate tracking ID
41
+ */
42
+ GetID: () => string;
43
+ /**
44
+ * Append the affiliate tracking parameter to the given URL
45
+ * @param url - The URL to append the affiliate tracking parameter to.
46
+ */
47
+ Build: (url: string) => string;
48
+ };
49
+ Loader: {
50
+ /**
51
+ * Show the Lemon.js loader.
52
+ */
53
+ Show: () => void;
54
+ /**
55
+ * Hide the Lemon.js loader.
56
+ */
57
+ Hide: () => void;
58
+ };
59
+ }
60
+ declare global {
61
+ interface Window {
62
+ createLemonSqueezy: () => void;
63
+ LemonSqueezy: LemonSqueezyApi;
64
+ }
65
+ }
66
+ export declare function useScriptLemonSqueezy<T extends LemonSqueezyApi>(_options?: LemonSqueezyInput): T & {
67
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
68
+ };
@@ -0,0 +1,21 @@
1
+ import { object } from "valibot";
2
+ import { registryScript } from "../utils.mjs";
3
+ export const LemonSqueezyOptions = object({});
4
+ export function useScriptLemonSqueezy(_options) {
5
+ return registryScript("lemonSqueezy", () => ({
6
+ scriptInput: {
7
+ src: "https://assets.lemonsqueezy.com/lemon.js",
8
+ // @ts-expect-error untyped
9
+ crossorigin: null
10
+ },
11
+ schema: LemonSqueezyOptions,
12
+ scriptOptions: {
13
+ use() {
14
+ if (typeof window.createLemonSqueezy === "undefined")
15
+ return void 0;
16
+ window.createLemonSqueezy();
17
+ return window.LemonSqueezy;
18
+ }
19
+ }
20
+ }), _options);
21
+ }
@@ -0,0 +1,24 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
+ export declare const MatomoAnalyticsOptions: import("valibot").ObjectSchema<{
3
+ matomoUrl: import("valibot").StringSchema<string>;
4
+ siteId: import("valibot").StringSchema<string>;
5
+ trackPageView: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
6
+ enableLinkTracking: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
7
+ }, undefined, {
8
+ matomoUrl: string;
9
+ siteId: string;
10
+ trackPageView?: boolean | undefined;
11
+ enableLinkTracking?: boolean | undefined;
12
+ }>;
13
+ export type MatomoAnalyticsInput = RegistryScriptInput<typeof MatomoAnalyticsOptions, false>;
14
+ interface MatomoAnalyticsApi {
15
+ _paq: unknown[];
16
+ }
17
+ declare global {
18
+ interface Window extends MatomoAnalyticsApi {
19
+ }
20
+ }
21
+ export declare function useScriptMatomoAnalytics<T extends MatomoAnalyticsApi>(_options?: MatomoAnalyticsInput): T & {
22
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
23
+ };
24
+ export {};
@@ -0,0 +1,33 @@
1
+ import { boolean, object, optional, string } from "valibot";
2
+ import { registryScript } from "../utils.mjs";
3
+ export const MatomoAnalyticsOptions = object({
4
+ matomoUrl: string(),
5
+ // site is required
6
+ siteId: string(),
7
+ trackPageView: optional(boolean()),
8
+ enableLinkTracking: optional(boolean())
9
+ });
10
+ export function useScriptMatomoAnalytics(_options) {
11
+ return registryScript("matomoAnalytics", (options) => ({
12
+ scriptInput: {
13
+ src: `https://${options?.matomoUrl}/matomo.js`
14
+ },
15
+ schema: MatomoAnalyticsOptions,
16
+ scriptOptions: {
17
+ use() {
18
+ return { _paq: window._paq };
19
+ },
20
+ // allow _paq to be accessed on the server
21
+ stub: import.meta.client ? void 0 : ({ fn }) => {
22
+ return fn === "_paq" ? [] : void 0;
23
+ },
24
+ clientInit: import.meta.server ? void 0 : () => {
25
+ const _paq = window._paq = window._paq || [];
26
+ options?.trackPageView !== false && _paq.push(["trackPageView"]);
27
+ options?.enableLinkTracking !== false && _paq.push(["enableLinkTracking"]);
28
+ _paq.push(["setTrackerUrl", `//${options?.matomoUrl}/matomo.php`]);
29
+ _paq.push(["setSiteId", options?.siteId]);
30
+ }
31
+ }
32
+ }), _options);
33
+ }
@@ -1,12 +1,16 @@
1
- import type { NuxtUseScriptOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
2
  export declare const NpmOptions: import("valibot").ObjectSchema<{
3
3
  packageName: import("valibot").StringSchema<string>;
4
4
  file: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
5
5
  version: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
6
+ type: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
6
7
  }, undefined, {
7
8
  packageName: string;
9
+ type?: string | undefined;
8
10
  file?: string | undefined;
9
11
  version?: string | undefined;
10
12
  }>;
11
- export type NpmInput = ScriptDynamicSrcInput<typeof NpmOptions>;
12
- export declare function useScriptNpm<T>(options: NpmInput, _scriptOptions?: NuxtUseScriptOptions<T>): any;
13
+ export type NpmInput = RegistryScriptInput<typeof NpmOptions>;
14
+ export declare function useScriptNpm<T extends Record<string | symbol, any>>(_options: NpmInput): T & {
15
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
16
+ };
@@ -1,18 +1,17 @@
1
1
  import { object, optional, string } from "valibot";
2
2
  import { withBase } from "ufo";
3
- import { useScript, validateScriptInputSchema } from "#imports";
3
+ import { registryScript } from "../utils.mjs";
4
4
  export const NpmOptions = object({
5
5
  packageName: string(),
6
6
  file: optional(string()),
7
- version: optional(string())
7
+ version: optional(string()),
8
+ type: optional(string())
8
9
  });
9
- export function useScriptNpm(options, _scriptOptions) {
10
- const scriptOptions = _scriptOptions || {};
11
- scriptOptions.beforeInit = () => {
12
- import.meta.dev && validateScriptInputSchema(NpmOptions, options);
13
- };
14
- return useScript({
15
- key: options.packageName,
16
- src: options.src || withBase(options.file || "", `https://unpkg.com/${options?.packageName}@${options.version || "latest"}`)
17
- }, scriptOptions);
10
+ export function useScriptNpm(_options) {
11
+ return registryScript(`${_options.packageName}-npm`, (options) => ({
12
+ scriptInput: {
13
+ src: withBase(options.file || "", `https://unpkg.com/${options?.packageName}@${options.version || "latest"}`)
14
+ },
15
+ schema: import.meta.dev ? NpmOptions : void 0
16
+ }), _options);
18
17
  }
@@ -0,0 +1,22 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
+ export declare const PlausibleAnalyticsOptions: import("valibot").ObjectSchema<{
3
+ domain: import("valibot").StringSchema<string>;
4
+ extension: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").UnionSchema<(import("valibot").LiteralSchema<"hash", "hash"> | import("valibot").LiteralSchema<"outbound-links", "outbound-links"> | import("valibot").LiteralSchema<"file-downloads", "file-downloads"> | import("valibot").LiteralSchema<"tagged-events", "tagged-events"> | import("valibot").LiteralSchema<"revenue", "revenue"> | import("valibot").LiteralSchema<"pageview-props", "pageview-props"> | import("valibot").LiteralSchema<"compat", "compat"> | import("valibot").LiteralSchema<"local", "local"> | import("valibot").LiteralSchema<"manual", "manual">)[], "manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local"> | import("valibot").ArraySchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"hash", "hash"> | import("valibot").LiteralSchema<"outbound-links", "outbound-links"> | import("valibot").LiteralSchema<"file-downloads", "file-downloads"> | import("valibot").LiteralSchema<"tagged-events", "tagged-events"> | import("valibot").LiteralSchema<"revenue", "revenue"> | import("valibot").LiteralSchema<"pageview-props", "pageview-props"> | import("valibot").LiteralSchema<"compat", "compat"> | import("valibot").LiteralSchema<"local", "local"> | import("valibot").LiteralSchema<"manual", "manual">)[], "manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local">, ("manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local")[]>)[], "manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local" | ("manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local")[]>, undefined, "manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local" | ("manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local")[] | undefined>;
5
+ }, undefined, {
6
+ domain: string;
7
+ extension?: "manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local" | ("manual" | "hash" | "outbound-links" | "file-downloads" | "tagged-events" | "revenue" | "pageview-props" | "compat" | "local")[] | undefined;
8
+ }>;
9
+ export type PlausibleAnalyticsInput = RegistryScriptInput<typeof PlausibleAnalyticsOptions, false>;
10
+ export interface PlausibleAnalyticsApi {
11
+ plausible: ((event: '404', options: Record<string, any>) => void) & ((event: 'event', options: Record<string, any>) => void) & ((...params: any[]) => void) & {
12
+ q: any[];
13
+ };
14
+ }
15
+ declare global {
16
+ interface Window {
17
+ plausible: PlausibleAnalyticsApi;
18
+ }
19
+ }
20
+ export declare function useScriptPlausibleAnalytics<T extends PlausibleAnalyticsApi>(_options?: PlausibleAnalyticsInput): T & {
21
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
22
+ };
@@ -0,0 +1,35 @@
1
+ import { array, literal, object, optional, string, union } from "valibot";
2
+ import { registryScript } from "../utils.mjs";
3
+ import { PlausibleAnalyticsScriptResolver } from "../../registry";
4
+ const extensions = [
5
+ literal("hash"),
6
+ literal("outbound-links"),
7
+ literal("file-downloads"),
8
+ literal("tagged-events"),
9
+ literal("revenue"),
10
+ literal("pageview-props"),
11
+ literal("compat"),
12
+ literal("local"),
13
+ literal("manual")
14
+ ];
15
+ export const PlausibleAnalyticsOptions = object({
16
+ domain: string(),
17
+ // required
18
+ extension: optional(union([union(extensions), array(union(extensions))]))
19
+ });
20
+ export function useScriptPlausibleAnalytics(_options) {
21
+ return registryScript("plausibleAnalytics", (options) => {
22
+ return {
23
+ scriptInput: {
24
+ "src": PlausibleAnalyticsScriptResolver(options),
25
+ "data-domain": options?.domain
26
+ },
27
+ schema: PlausibleAnalyticsOptions,
28
+ scriptOptions: {
29
+ use() {
30
+ return { plausible: window.plausible };
31
+ }
32
+ }
33
+ };
34
+ }, _options);
35
+ }
@@ -1,4 +1,4 @@
1
- import type { NuxtUseScriptIntegrationOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
2
  export declare const SegmentOptions: import("valibot").ObjectSchema<{
3
3
  writeKey: import("valibot").StringSchema<string>;
4
4
  analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
@@ -6,7 +6,7 @@ export declare const SegmentOptions: import("valibot").ObjectSchema<{
6
6
  writeKey: string;
7
7
  analyticsKey?: string | undefined;
8
8
  }>;
9
- export type SegmentInput = ScriptDynamicSrcInput<typeof SegmentOptions>;
9
+ export type SegmentInput = RegistryScriptInput<typeof SegmentOptions>;
10
10
  export interface SegmentApi {
11
11
  analytics: {
12
12
  track: (event: string, properties?: Record<string, any>) => void;
@@ -21,4 +21,6 @@ declare global {
21
21
  interface Window extends SegmentApi {
22
22
  }
23
23
  }
24
- export declare function useScriptSegment<T extends SegmentApi>(options?: SegmentInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
24
+ export declare function useScriptSegment<T extends SegmentApi>(_options?: SegmentInput): T & {
25
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
26
+ };
@@ -1,41 +1,41 @@
1
1
  import { object, optional, string } from "valibot";
2
- import { useScript, validateScriptInputSchema } from "#imports";
2
+ import { registryScript } from "../utils.mjs";
3
+ import { SegmentScriptResolver } from "../../registry";
3
4
  export const SegmentOptions = object({
4
5
  writeKey: string(),
5
6
  analyticsKey: optional(string())
6
7
  });
7
- export function useScriptSegment(options, _scriptOptions) {
8
- const scriptOptions = _scriptOptions || {};
9
- scriptOptions.beforeInit = () => {
10
- import.meta.dev && validateScriptInputSchema(SegmentOptions, options);
11
- if (import.meta.client) {
12
- window.analytics = window.analytics || [];
13
- window.analytics.methods = ["track", "page", "identify", "group", "alias", "reset"];
14
- window.analytics.factory = function(method) {
15
- return function(...params) {
16
- const args = Array.prototype.slice.call(params);
17
- args.unshift(method);
18
- window.analytics.push(args);
19
- return window.analytics;
20
- };
21
- };
22
- for (let i = 0; i < window.analytics.methods.length; i++) {
23
- const key = window.analytics.methods[i];
24
- window.analytics[key] = window.analytics.factory(key);
8
+ export function useScriptSegment(_options) {
9
+ return registryScript("segment", (options) => {
10
+ const analyticsKey = options?.analyticsKey || "analytics";
11
+ return {
12
+ scriptInput: {
13
+ "data-global-segment-analytics-key": analyticsKey,
14
+ "src": SegmentScriptResolver(options)
15
+ },
16
+ schema: SegmentOptions,
17
+ scriptOptions: {
18
+ use() {
19
+ return { analytics: window[analyticsKey] };
20
+ },
21
+ clientInit: import.meta.server ? void 0 : () => {
22
+ window.analytics = window.analytics || [];
23
+ window.analytics.methods = ["track", "page", "identify", "group", "alias", "reset"];
24
+ window.analytics.factory = function(method) {
25
+ return function(...params) {
26
+ const args = Array.prototype.slice.call(params);
27
+ args.unshift(method);
28
+ window.analytics.push(args);
29
+ return window.analytics;
30
+ };
31
+ };
32
+ for (let i = 0; i < window.analytics.methods.length; i++) {
33
+ const key = window.analytics.methods[i];
34
+ window.analytics[key] = window.analytics.factory(key);
35
+ }
36
+ window.analytics.page();
37
+ }
25
38
  }
26
- window.analytics.page();
27
- }
28
- _scriptOptions?.beforeInit?.();
29
- };
30
- const analyticsKey = options?.analyticsKey || "analytics";
31
- return useScript({
32
- "key": "segment",
33
- "data-global-segment-analytics-key": analyticsKey,
34
- "src": options?.src || `https://cdn.segment.com/analytics.js/v1/${options?.writeKey}/analytics.min.js`
35
- }, {
36
- ...scriptOptions,
37
- use() {
38
- return { analytics: window[analyticsKey] };
39
- }
40
- });
39
+ };
40
+ }, _options);
41
41
  }
@@ -0,0 +1,18 @@
1
+ import type { Stripe } from '@types/stripe-v3';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
+ export declare const StripeOptions: import("valibot").ObjectSchema<{
4
+ advancedFraudSignals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
5
+ }, undefined, {
6
+ advancedFraudSignals?: boolean | undefined;
7
+ }>;
8
+ export type StripeInput = RegistryScriptInput<typeof StripeOptions, false>;
9
+ export interface StripeApi {
10
+ Stripe: Stripe;
11
+ }
12
+ declare global {
13
+ interface Window extends StripeApi {
14
+ }
15
+ }
16
+ export declare function useScriptStripe<T extends StripeApi>(_options?: StripeInput): T & {
17
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
18
+ };
@@ -0,0 +1,27 @@
1
+ import { boolean, object, optional } from "valibot";
2
+ import { withQuery } from "ufo";
3
+ import { registryScript } from "../utils.mjs";
4
+ export const StripeOptions = object({
5
+ advancedFraudSignals: optional(boolean())
6
+ });
7
+ export function useScriptStripe(_options) {
8
+ return registryScript("stripe", (options) => ({
9
+ scriptInput: {
10
+ src: withQuery(
11
+ `https://js.stripe.com/v3/`,
12
+ typeof options?.advancedFraudSignals === "boolean" && !options?.advancedFraudSignals ? { advancedFraudSignals: false } : {}
13
+ ),
14
+ // opt-out of privacy defaults
15
+ // @ts-expect-error TODO add types
16
+ crossorigin: null,
17
+ // @ts-expect-error TODO add types
18
+ referrerpolicy: null
19
+ },
20
+ schema: StripeOptions,
21
+ scriptOptions: {
22
+ use() {
23
+ return { Stripe: window.Stripe };
24
+ }
25
+ }
26
+ }), _options);
27
+ }
@@ -0,0 +1,15 @@
1
+ import type VimeoPlayer from 'vimeo__player';
2
+ import type { RegistryScriptInput } from '#nuxt-scripts';
3
+ export interface VimeoPlayerApi {
4
+ Player: VimeoPlayer;
5
+ }
6
+ export declare const VimeoPlayerOptions: import("valibot").ObjectSchema<{}, undefined, {}>;
7
+ export type VimeoPlayerInput = RegistryScriptInput<typeof VimeoPlayerOptions>;
8
+ declare global {
9
+ interface Window {
10
+ Vimeo: VimeoPlayerApi;
11
+ }
12
+ }
13
+ export declare function useScriptVimeoPlayer<T extends VimeoPlayerApi>(_options?: VimeoPlayerInput): T & {
14
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
15
+ };
@@ -0,0 +1,45 @@
1
+ import { object } from "valibot";
2
+ import { registryScript } from "../utils.mjs";
3
+ import { useHead } from "#imports";
4
+ export const VimeoPlayerOptions = object({});
5
+ export function useScriptVimeoPlayer(_options) {
6
+ return registryScript("vimeoPlayer", () => ({
7
+ scriptInput: {
8
+ src: "https://player.vimeo.com/api/player.js"
9
+ },
10
+ schema: VimeoPlayerOptions,
11
+ scriptOptions: {
12
+ use() {
13
+ let Player;
14
+ if (import.meta.client) {
15
+ Player = function(...params) {
16
+ return new window.Vimeo.Player(...params);
17
+ };
18
+ }
19
+ return { Player };
20
+ }
21
+ },
22
+ beforeInit() {
23
+ useHead({
24
+ link: [
25
+ {
26
+ rel: "preconnect",
27
+ href: "https://player.vimeo.com"
28
+ },
29
+ {
30
+ rel: "preconnect",
31
+ href: "https://i.vimeocdn.com"
32
+ },
33
+ {
34
+ rel: "preconnect",
35
+ href: "https://f.vimeocdn.com"
36
+ },
37
+ {
38
+ rel: "preconnect",
39
+ href: "https://fresnel.vimeocdn.com"
40
+ }
41
+ ]
42
+ });
43
+ }
44
+ }), _options);
45
+ }
@@ -0,0 +1,41 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
+ interface ContentProperties {
3
+ content_type?: string | null;
4
+ content_id?: string | number | null;
5
+ content_name?: string | null;
6
+ content_price?: string | number | null;
7
+ num_items?: string | number | null;
8
+ content_group_id?: string | number | null;
9
+ }
10
+ interface EventObjectProperties {
11
+ value?: string | number | null;
12
+ currency?: string | null;
13
+ conversion_id?: string | number | null;
14
+ email_address?: string | null;
15
+ phone_number?: string | null;
16
+ contents: ContentProperties[];
17
+ }
18
+ type TwqFns = ((event: 'event', eventId: string, data?: EventObjectProperties) => void) & ((event: 'config', id: string) => void) & ((event: string, ...params: any[]) => void);
19
+ export interface XPixelApi {
20
+ twq: TwqFns & {
21
+ loaded: boolean;
22
+ version: string;
23
+ queue: any[];
24
+ };
25
+ }
26
+ declare global {
27
+ interface Window extends XPixelApi {
28
+ }
29
+ }
30
+ export declare const XPixelOptions: import("valibot").ObjectSchema<{
31
+ id: import("valibot").StringSchema<string>;
32
+ version: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
33
+ }, undefined, {
34
+ id: string;
35
+ version?: string | undefined;
36
+ }>;
37
+ export type XPixelInput = RegistryScriptInput<typeof XPixelOptions>;
38
+ export declare function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput): T & {
39
+ $script: import("@unhead/vue").VueScriptInstance<T> & Promise<T>;
40
+ };
41
+ export {};