@nuxt/scripts 1.0.0-beta.15 → 1.0.0-beta.18

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 (110) hide show
  1. package/README.md +3 -3
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/{C4oLgKn5.js → BW6d1nfL.js} +1 -1
  5. package/dist/client/_nuxt/{C4LyqEA2.js → C8R4dwAP.js} +1 -1
  6. package/dist/client/_nuxt/{CSWa0Nc-.js → DI7VRsfF.js} +1 -1
  7. package/dist/client/_nuxt/{CAywURt7.js → NbccNBFl.js} +13 -13
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/e9af4ec4-4502-4171-9264-54123d0ae2ea.json +1 -0
  10. package/dist/client/_nuxt/error-404.Cqp3ffuH.css +1 -0
  11. package/dist/client/_nuxt/error-500.B9hH8BAi.css +1 -0
  12. package/dist/client/index.html +1 -1
  13. package/dist/module.json +1 -1
  14. package/dist/module.mjs +75 -8
  15. package/dist/registry.mjs +22 -0
  16. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +1 -1
  17. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +1 -1
  18. package/dist/runtime/components/ScriptGravatar.d.vue.ts +22 -0
  19. package/dist/runtime/components/ScriptGravatar.vue +46 -0
  20. package/dist/runtime/components/ScriptGravatar.vue.d.ts +22 -0
  21. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +1 -1
  22. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
  23. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +42 -31
  24. package/dist/runtime/components/ScriptPayPalButtons.vue +43 -76
  25. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +42 -31
  26. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +36 -22
  27. package/dist/runtime/components/ScriptPayPalMessages.vue +41 -47
  28. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +36 -22
  29. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +1 -1
  30. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +1 -1
  31. package/dist/runtime/registry/clarity.d.ts +2 -7
  32. package/dist/runtime/registry/clarity.js +2 -7
  33. package/dist/runtime/registry/cloudflare-web-analytics.d.ts +2 -13
  34. package/dist/runtime/registry/cloudflare-web-analytics.js +2 -14
  35. package/dist/runtime/registry/crisp.d.ts +2 -32
  36. package/dist/runtime/registry/crisp.js +2 -33
  37. package/dist/runtime/registry/databuddy-analytics.d.ts +2 -35
  38. package/dist/runtime/registry/databuddy-analytics.js +2 -45
  39. package/dist/runtime/registry/fathom-analytics.d.ts +2 -22
  40. package/dist/runtime/registry/fathom-analytics.js +2 -23
  41. package/dist/runtime/registry/google-adsense.d.ts +2 -10
  42. package/dist/runtime/registry/google-adsense.js +2 -11
  43. package/dist/runtime/registry/google-analytics.d.ts +2 -4
  44. package/dist/runtime/registry/google-analytics.js +2 -7
  45. package/dist/runtime/registry/google-maps.d.ts +2 -8
  46. package/dist/runtime/registry/google-maps.js +2 -8
  47. package/dist/runtime/registry/google-recaptcha.d.ts +2 -6
  48. package/dist/runtime/registry/google-recaptcha.js +2 -10
  49. package/dist/runtime/registry/google-sign-in.d.ts +2 -13
  50. package/dist/runtime/registry/google-sign-in.js +2 -22
  51. package/dist/runtime/registry/google-tag-manager.d.ts +2 -27
  52. package/dist/runtime/registry/google-tag-manager.js +2 -25
  53. package/dist/runtime/registry/gravatar.d.ts +25 -0
  54. package/dist/runtime/registry/gravatar.js +32 -0
  55. package/dist/runtime/registry/hotjar.d.ts +2 -4
  56. package/dist/runtime/registry/hotjar.js +2 -5
  57. package/dist/runtime/registry/instagram-embed.d.ts +2 -17
  58. package/dist/runtime/registry/instagram-embed.js +2 -18
  59. package/dist/runtime/registry/intercom.d.ts +2 -10
  60. package/dist/runtime/registry/intercom.js +2 -12
  61. package/dist/runtime/registry/matomo-analytics.d.ts +2 -11
  62. package/dist/runtime/registry/matomo-analytics.js +2 -11
  63. package/dist/runtime/registry/meta-pixel.d.ts +2 -4
  64. package/dist/runtime/registry/meta-pixel.js +2 -4
  65. package/dist/runtime/registry/npm.d.ts +2 -6
  66. package/dist/runtime/registry/npm.js +2 -7
  67. package/dist/runtime/registry/paypal.d.ts +4 -25
  68. package/dist/runtime/registry/paypal.js +3 -66
  69. package/dist/runtime/registry/plausible-analytics.js +5 -6
  70. package/dist/runtime/registry/posthog.d.ts +10 -12
  71. package/dist/runtime/registry/posthog.js +2 -11
  72. package/dist/runtime/registry/reddit-pixel.d.ts +2 -4
  73. package/dist/runtime/registry/reddit-pixel.js +2 -4
  74. package/dist/runtime/registry/rybbit-analytics.d.ts +2 -14
  75. package/dist/runtime/registry/rybbit-analytics.js +2 -16
  76. package/dist/runtime/registry/schemas.d.ts +940 -0
  77. package/dist/runtime/registry/schemas.js +895 -0
  78. package/dist/runtime/registry/segment.d.ts +2 -5
  79. package/dist/runtime/registry/segment.js +2 -5
  80. package/dist/runtime/registry/snapchat-pixel.d.ts +2 -31
  81. package/dist/runtime/registry/snapchat-pixel.js +2 -20
  82. package/dist/runtime/registry/stripe.d.ts +2 -3
  83. package/dist/runtime/registry/stripe.js +2 -4
  84. package/dist/runtime/registry/tiktok-pixel.d.ts +2 -5
  85. package/dist/runtime/registry/tiktok-pixel.js +2 -6
  86. package/dist/runtime/registry/umami-analytics.d.ts +2 -31
  87. package/dist/runtime/registry/umami-analytics.js +2 -36
  88. package/dist/runtime/registry/vercel-analytics.d.ts +29 -0
  89. package/dist/runtime/registry/vercel-analytics.js +84 -0
  90. package/dist/runtime/registry/x-embed.d.ts +2 -16
  91. package/dist/runtime/registry/x-embed.js +2 -17
  92. package/dist/runtime/registry/x-pixel.d.ts +2 -5
  93. package/dist/runtime/registry/x-pixel.js +2 -5
  94. package/dist/runtime/server/gravatar-proxy.d.ts +2 -0
  95. package/dist/runtime/server/gravatar-proxy.js +62 -0
  96. package/dist/runtime/types.d.ts +9 -3
  97. package/dist/runtime/utils.d.ts +2 -2
  98. package/dist/runtime/utils.js +3 -2
  99. package/dist/shared/{scripts.DLRgvHQg.mjs → scripts.Bg4pl9Yo.mjs} +22 -0
  100. package/dist/stats.mjs +152 -94
  101. package/dist/types-source.d.mts +11 -367
  102. package/dist/types-source.d.ts +11 -367
  103. package/dist/types-source.mjs +225 -460
  104. package/package.json +4 -4
  105. package/dist/client/_nuxt/builds/meta/0f5f1d62-f186-4aef-a618-dcef5ec637c1.json +0 -1
  106. package/dist/client/_nuxt/error-404.B57D-jUQ.css +0 -1
  107. package/dist/client/_nuxt/error-500.DTHUW7BI.css +0 -1
  108. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +0 -52
  109. package/dist/runtime/components/ScriptPayPalMarks.vue +0 -71
  110. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +0 -52
@@ -1,8 +1,6 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
- export declare const SegmentOptions: import("valibot").ObjectSchema<{
3
- readonly writeKey: import("valibot").StringSchema<undefined>;
4
- readonly analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
5
- }, undefined>;
2
+ import { SegmentOptions } from './schemas.js';
3
+ export { SegmentOptions };
6
4
  export type SegmentInput = RegistryScriptInput<typeof SegmentOptions>;
7
5
  interface AnalyticsApi {
8
6
  track: (event: string, properties?: Record<string, any>) => void;
@@ -30,4 +28,3 @@ declare global {
30
28
  }
31
29
  }
32
30
  export declare function useScriptSegment<T extends SegmentApi>(_options?: SegmentInput): import("#nuxt-scripts/types").UseScriptContext<T>;
33
- export {};
@@ -1,10 +1,7 @@
1
- import { object, optional, string } from "#nuxt-scripts-validator";
2
1
  import { joinURL } from "ufo";
3
2
  import { useRegistryScript } from "../utils.js";
4
- export const SegmentOptions = object({
5
- writeKey: string(),
6
- analyticsKey: optional(string())
7
- });
3
+ import { SegmentOptions } from "./schemas.js";
4
+ export { SegmentOptions };
8
5
  const methods = ["track", "page", "identify", "group", "alias", "reset"];
9
6
  export function useScriptSegment(_options) {
10
7
  return useRegistryScript("segment", (options) => {
@@ -1,5 +1,7 @@
1
1
  import type { InferInput } from '#nuxt-scripts-validator';
2
2
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
3
+ import { InitObjectPropertiesSchema, SnapTrPixelOptions } from './schemas.js';
4
+ export { InitObjectPropertiesSchema, SnapTrPixelOptions };
3
5
  type StandardEvents = 'PAGE_VIEW' | 'VIEW_CONTENT' | 'ADD_CART' | 'SIGN_UP' | 'SAVE' | 'START_CHECKOUT' | 'APP_OPEN' | 'ADD_BILLING' | 'SEARCH' | 'SUBSCRIBE' | 'AD_CLICK' | 'AD_VIEW' | 'COMPLETE_TUTORIAL' | 'LEVEL_COMPLETE' | 'INVITE' | 'LOGIN' | 'SHARE' | 'RESERVE' | 'ACHIEVEMENT_UNLOCKED' | 'ADD_TO_WISHLIST' | 'SPENT_CREDITS' | 'RATE' | 'START_TRIAL' | 'LIST_VIEW';
4
6
  interface EventObjectProperties {
5
7
  price?: number;
@@ -20,20 +22,6 @@ interface EventObjectProperties {
20
22
  event_tag?: string;
21
23
  [key: string]: any;
22
24
  }
23
- export declare const InitObjectPropertiesSchema: import("valibot").ObjectSchema<{
24
- readonly user_email: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
25
- readonly ip_address: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
26
- readonly user_phone_number: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
27
- readonly user_hashed_email: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
28
- readonly user_hashed_phone_number: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
29
- readonly firstname: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
30
- readonly lastname: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
31
- readonly geo_city: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
32
- readonly geo_region: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
33
- readonly geo_postal_code: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
34
- readonly geo_country: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
35
- readonly age: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
36
- }, undefined>;
37
25
  type InitObjectProperties = InferInput<typeof InitObjectPropertiesSchema>;
38
26
  type SnapTrFns = ((event: 'track', eventName: StandardEvents | '', data?: EventObjectProperties) => void) & ((event: 'init', id: string, data?: Record<string, any>) => void) & ((event: 'init', id: string, data?: InitObjectProperties) => void) & ((event: string, ...params: any[]) => void);
39
27
  export interface SnapPixelApi {
@@ -50,22 +38,5 @@ declare global {
50
38
  interface Window extends SnapPixelApi {
51
39
  }
52
40
  }
53
- export declare const SnapTrPixelOptions: import("valibot").ObjectSchema<{
54
- readonly user_email: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
55
- readonly ip_address: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
56
- readonly user_phone_number: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
57
- readonly user_hashed_email: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
58
- readonly user_hashed_phone_number: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
59
- readonly firstname: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
60
- readonly lastname: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
61
- readonly geo_city: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
62
- readonly geo_region: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
63
- readonly geo_postal_code: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
64
- readonly geo_country: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
65
- readonly age: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
66
- readonly id: import("valibot").StringSchema<undefined>;
67
- readonly trackPageView: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
68
- }, undefined>;
69
41
  export type SnapTrPixelInput = RegistryScriptInput<typeof SnapTrPixelOptions, true, false, false>;
70
42
  export declare function useScriptSnapchatPixel<T extends SnapPixelApi>(_options?: SnapTrPixelInput): import("#nuxt-scripts/types").UseScriptContext<T>;
71
- export {};
@@ -1,24 +1,6 @@
1
- import { boolean, object, optional, string } from "#nuxt-scripts-validator";
2
1
  import { useRegistryScript } from "../utils.js";
3
- export const InitObjectPropertiesSchema = object({
4
- user_email: optional(string()),
5
- ip_address: optional(string()),
6
- user_phone_number: optional(string()),
7
- user_hashed_email: optional(string()),
8
- user_hashed_phone_number: optional(string()),
9
- firstname: optional(string()),
10
- lastname: optional(string()),
11
- geo_city: optional(string()),
12
- geo_region: optional(string()),
13
- geo_postal_code: optional(string()),
14
- geo_country: optional(string()),
15
- age: optional(string())
16
- });
17
- export const SnapTrPixelOptions = object({
18
- id: string(),
19
- trackPageView: optional(boolean()),
20
- ...InitObjectPropertiesSchema?.entries || {}
21
- });
2
+ import { InitObjectPropertiesSchema, SnapTrPixelOptions } from "./schemas.js";
3
+ export { InitObjectPropertiesSchema, SnapTrPixelOptions };
22
4
  export function useScriptSnapchatPixel(_options) {
23
5
  return useRegistryScript("snapchatPixel", (options) => ({
24
6
  scriptInput: {
@@ -1,8 +1,7 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
2
  import type { StripeConstructor } from '@stripe/stripe-js';
3
- export declare const StripeOptions: import("valibot").ObjectSchema<{
4
- readonly advancedFraudSignals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
5
- }, undefined>;
3
+ import { StripeOptions } from './schemas.js';
4
+ export { StripeOptions };
6
5
  export type StripeInput = RegistryScriptInput<typeof StripeOptions, false>;
7
6
  export interface StripeApi {
8
7
  Stripe: StripeConstructor;
@@ -1,9 +1,7 @@
1
- import { boolean, object, optional } from "#nuxt-scripts-validator";
2
1
  import { withQuery } from "ufo";
3
2
  import { useRegistryScript } from "../utils.js";
4
- export const StripeOptions = object({
5
- advancedFraudSignals: optional(boolean())
6
- });
3
+ import { StripeOptions } from "./schemas.js";
4
+ export { StripeOptions };
7
5
  export function useScriptStripe(_options) {
8
6
  return useRegistryScript("stripe", (options) => ({
9
7
  scriptInput: {
@@ -1,4 +1,5 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import { TikTokPixelOptions } from './schemas.js';
2
3
  type StandardEvents = 'ViewContent' | 'ClickButton' | 'Search' | 'AddToWishlist' | 'AddToCart' | 'InitiateCheckout' | 'AddPaymentInfo' | 'CompletePayment' | 'PlaceAnOrder' | 'Contact' | 'Download' | 'SubmitForm' | 'CompleteRegistration' | 'Subscribe';
3
4
  interface EventProperties {
4
5
  content_id?: string;
@@ -35,10 +36,6 @@ declare global {
35
36
  TiktokAnalyticsObject: string;
36
37
  }
37
38
  }
38
- export declare const TikTokPixelOptions: import("valibot").ObjectSchema<{
39
- readonly id: import("valibot").StringSchema<undefined>;
40
- readonly trackPageView: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
41
- }, undefined>;
39
+ export { TikTokPixelOptions };
42
40
  export type TikTokPixelInput = RegistryScriptInput<typeof TikTokPixelOptions, true, false, false>;
43
41
  export declare function useScriptTikTokPixel<T extends TikTokPixelApi>(_options?: TikTokPixelInput): import("#nuxt-scripts/types").UseScriptContext<T>;
44
- export {};
@@ -1,11 +1,7 @@
1
- import { boolean, object, optional, string } from "#nuxt-scripts-validator";
2
1
  import { withQuery } from "ufo";
3
2
  import { useRegistryScript } from "../utils.js";
4
- export const TikTokPixelOptions = object({
5
- id: string(),
6
- trackPageView: optional(boolean())
7
- // default true
8
- });
3
+ import { TikTokPixelOptions } from "./schemas.js";
4
+ export { TikTokPixelOptions };
9
5
  export function useScriptTikTokPixel(_options) {
10
6
  return useRegistryScript("tiktokPixel", (options) => ({
11
7
  scriptInput: {
@@ -1,35 +1,6 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
- export declare const UmamiAnalyticsOptions: import("valibot").ObjectSchema<{
3
- readonly websiteId: import("valibot").StringSchema<undefined>;
4
- /**
5
- * By default, Umami will send data to wherever the script is located.
6
- * You can override this to send data to another location.
7
- */
8
- readonly hostUrl: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
9
- /**
10
- * By default, Umami tracks all pageviews and events for you automatically.
11
- * You can disable this behavior and track events yourself using the tracker functions.
12
- * https://umami.is/docs/tracker-functions
13
- */
14
- readonly autoTrack: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
15
- /**
16
- * If you want the tracker to only run on specific domains, you can add them to your tracker script.
17
- * This is a comma delimited list of domain names.
18
- * Helps if you are working in a staging/development environment.
19
- */
20
- readonly domains: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, undefined>;
21
- /**
22
- * If you want the tracker to collect events under a specific tag.
23
- * Events can be filtered in the dashboard by a specific tag.
24
- */
25
- readonly tag: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
26
- /**
27
- * Function that will be called before data is sent to Umami.
28
- * The function takes two parameters: type and payload.
29
- * Return the payload to continue sending, or return a falsy value to cancel.
30
- */
31
- readonly beforeSend: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").CustomSchema<(type: string, payload: Record<string, any>) => Record<string, any> | null | false, undefined>, import("valibot").StringSchema<undefined>], undefined>, undefined>;
32
- }, undefined>;
2
+ import { UmamiAnalyticsOptions } from './schemas.js';
3
+ export { UmamiAnalyticsOptions };
33
4
  export type UmamiAnalyticsInput = RegistryScriptInput<typeof UmamiAnalyticsOptions, false>;
34
5
  export interface UmamiAnalyticsApi {
35
6
  track: ((payload?: Record<string, any>) => void) & ((event_name: string, event_data: Record<string, any>) => void);
@@ -1,40 +1,6 @@
1
- import { array, boolean, custom, object, optional, string, union } from "#nuxt-scripts-validator";
2
1
  import { useRegistryScript } from "../utils.js";
3
- export const UmamiAnalyticsOptions = object({
4
- websiteId: string(),
5
- // required
6
- /**
7
- * By default, Umami will send data to wherever the script is located.
8
- * You can override this to send data to another location.
9
- */
10
- hostUrl: optional(string()),
11
- /**
12
- * By default, Umami tracks all pageviews and events for you automatically.
13
- * You can disable this behavior and track events yourself using the tracker functions.
14
- * https://umami.is/docs/tracker-functions
15
- */
16
- autoTrack: optional(boolean()),
17
- /**
18
- * If you want the tracker to only run on specific domains, you can add them to your tracker script.
19
- * This is a comma delimited list of domain names.
20
- * Helps if you are working in a staging/development environment.
21
- */
22
- domains: optional(array(string())),
23
- /**
24
- * If you want the tracker to collect events under a specific tag.
25
- * Events can be filtered in the dashboard by a specific tag.
26
- */
27
- tag: optional(string()),
28
- /**
29
- * Function that will be called before data is sent to Umami.
30
- * The function takes two parameters: type and payload.
31
- * Return the payload to continue sending, or return a falsy value to cancel.
32
- */
33
- beforeSend: optional(union([
34
- custom((input) => typeof input === "function"),
35
- string()
36
- ]))
37
- });
2
+ import { UmamiAnalyticsOptions } from "./schemas.js";
3
+ export { UmamiAnalyticsOptions };
38
4
  export function useScriptUmamiAnalytics(_options) {
39
5
  return useRegistryScript("umamiAnalytics", (options) => {
40
6
  const domains = Array.isArray(options?.domains) ? options.domains.join(",") : options?.domains;
@@ -0,0 +1,29 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import { VercelAnalyticsOptions } from './schemas.js';
3
+ export { VercelAnalyticsOptions };
4
+ export type AllowedPropertyValues = string | number | boolean | null;
5
+ export type VercelAnalyticsMode = 'auto' | 'development' | 'production';
6
+ export interface BeforeSendEvent {
7
+ type: 'pageview' | 'event';
8
+ url: string;
9
+ }
10
+ export type BeforeSend = (event: BeforeSendEvent) => BeforeSendEvent | null;
11
+ export type VercelAnalyticsInput = RegistryScriptInput<typeof VercelAnalyticsOptions, false, false, false> & {
12
+ beforeSend?: BeforeSend;
13
+ };
14
+ export interface VercelAnalyticsApi {
15
+ va: (event: string, properties?: unknown) => void;
16
+ track: (name: string, properties?: Record<string, AllowedPropertyValues>) => void;
17
+ pageview: (options?: {
18
+ route?: string | null;
19
+ path?: string;
20
+ }) => void;
21
+ }
22
+ declare global {
23
+ interface Window {
24
+ va?: (event: string, properties?: unknown) => void;
25
+ vaq?: [string, unknown?][];
26
+ vam?: VercelAnalyticsMode;
27
+ }
28
+ }
29
+ export declare function useScriptVercelAnalytics<T extends VercelAnalyticsApi>(_options?: VercelAnalyticsInput): import("#nuxt-scripts/types").UseScriptContext<T>;
@@ -0,0 +1,84 @@
1
+ import { useRegistryScript } from "../utils.js";
2
+ import { VercelAnalyticsOptions } from "./schemas.js";
3
+ export { VercelAnalyticsOptions };
4
+ function parseProperties(properties, options) {
5
+ let props = properties;
6
+ const errorProperties = [];
7
+ for (const [key, value] of Object.entries(properties)) {
8
+ if (typeof value === "object" && value !== null) {
9
+ if (options.strip) {
10
+ const { [key]: _, ...rest } = props;
11
+ props = rest;
12
+ } else {
13
+ errorProperties.push(key);
14
+ }
15
+ }
16
+ }
17
+ if (errorProperties.length > 0 && !options.strip) {
18
+ throw new Error(
19
+ `The following properties are not valid: ${errorProperties.join(", ")}. Only strings, numbers, booleans, and null are allowed.`
20
+ );
21
+ }
22
+ return props;
23
+ }
24
+ export function useScriptVercelAnalytics(_options) {
25
+ const beforeSend = _options?.beforeSend;
26
+ return useRegistryScript("vercelAnalytics", (options) => {
27
+ const scriptInput = {
28
+ "src": import.meta.dev ? "https://va.vercel-scripts.com/v1/script.debug.js" : "https://va.vercel-scripts.com/v1/script.js",
29
+ "defer": true,
30
+ "data-sdkn": "@nuxt/scripts"
31
+ };
32
+ if (options?.dsn)
33
+ scriptInput["data-dsn"] = options.dsn;
34
+ if (options?.disableAutoTrack)
35
+ scriptInput["data-disable-auto-track"] = "1";
36
+ if (options?.endpoint)
37
+ scriptInput["data-endpoint"] = options.endpoint;
38
+ if (import.meta.dev && options?.debug === false)
39
+ scriptInput["data-debug"] = "false";
40
+ return {
41
+ scriptInput,
42
+ schema: import.meta.dev ? VercelAnalyticsOptions : void 0,
43
+ scriptOptions: {
44
+ // Load on client hydration for accurate web vitals
45
+ trigger: "client",
46
+ use: () => ({
47
+ va: (...args) => window.va?.(...args),
48
+ track(name, properties) {
49
+ if (!properties) {
50
+ window.va?.("event", { name });
51
+ return;
52
+ }
53
+ try {
54
+ const props = parseProperties(properties, { strip: !import.meta.dev });
55
+ window.va?.("event", { name, data: props });
56
+ } catch (err) {
57
+ if (err instanceof Error && import.meta.dev)
58
+ console.error(err);
59
+ }
60
+ },
61
+ pageview(opts) {
62
+ window.va?.("pageview", opts);
63
+ }
64
+ })
65
+ },
66
+ clientInit: import.meta.server ? void 0 : () => {
67
+ if (window.va)
68
+ return;
69
+ window.va = function(...params) {
70
+ ;
71
+ (window.vaq = window.vaq || []).push(params);
72
+ };
73
+ if (options?.mode === "auto" || !options?.mode) {
74
+ window.vam = import.meta.dev ? "development" : "production";
75
+ } else {
76
+ window.vam = options.mode;
77
+ }
78
+ if (beforeSend) {
79
+ window.va("beforeSend", beforeSend);
80
+ }
81
+ }
82
+ };
83
+ }, _options);
84
+ }
@@ -1,4 +1,6 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import { XEmbedOptions } from './schemas.js';
3
+ export { XEmbedOptions };
2
4
  export interface XEmbedTweetData {
3
5
  id_str: string;
4
6
  text: string;
@@ -46,22 +48,6 @@ export interface XEmbedTweetData {
46
48
  };
47
49
  };
48
50
  }
49
- export declare const XEmbedOptions: import("valibot").ObjectSchema<{
50
- /**
51
- * The tweet ID to embed
52
- */
53
- readonly tweetId: import("valibot").StringSchema<undefined>;
54
- /**
55
- * Optional: Custom API endpoint for fetching tweet data
56
- * @default '/api/_scripts/x-embed'
57
- */
58
- readonly apiEndpoint: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
59
- /**
60
- * Optional: Custom image proxy endpoint
61
- * @default '/api/_scripts/x-embed-image'
62
- */
63
- readonly imageProxyEndpoint: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
64
- }, undefined>;
65
51
  export type XEmbedInput = RegistryScriptInput<typeof XEmbedOptions, false, false, false>;
66
52
  /**
67
53
  * Proxy an X/Twitter image URL through the server
@@ -1,20 +1,5 @@
1
- import { object, optional, string } from "#nuxt-scripts-validator";
2
- export const XEmbedOptions = object({
3
- /**
4
- * The tweet ID to embed
5
- */
6
- tweetId: string(),
7
- /**
8
- * Optional: Custom API endpoint for fetching tweet data
9
- * @default '/api/_scripts/x-embed'
10
- */
11
- apiEndpoint: optional(string()),
12
- /**
13
- * Optional: Custom image proxy endpoint
14
- * @default '/api/_scripts/x-embed-image'
15
- */
16
- imageProxyEndpoint: optional(string())
17
- });
1
+ import { XEmbedOptions } from "./schemas.js";
2
+ export { XEmbedOptions };
18
3
  export function proxyXImageUrl(url, proxyEndpoint = "/api/_scripts/x-embed-image") {
19
4
  const separator = proxyEndpoint.includes("?") ? "&" : "?";
20
5
  return `${proxyEndpoint}${separator}url=${encodeURIComponent(url)}`;
@@ -1,4 +1,5 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import { XPixelOptions } from './schemas.js';
2
3
  interface ContentProperties {
3
4
  content_type?: string | null;
4
5
  content_id?: string | number | null;
@@ -27,10 +28,6 @@ declare global {
27
28
  interface Window extends XPixelApi {
28
29
  }
29
30
  }
30
- export declare const XPixelOptions: import("valibot").ObjectSchema<{
31
- readonly id: import("valibot").StringSchema<undefined>;
32
- readonly version: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
33
- }, undefined>;
31
+ export { XPixelOptions };
34
32
  export type XPixelInput = RegistryScriptInput<typeof XPixelOptions, true, false, false>;
35
33
  export declare function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput): import("#nuxt-scripts/types").UseScriptContext<T>;
36
- export {};
@@ -1,9 +1,6 @@
1
- import { object, optional, string } from "#nuxt-scripts-validator";
2
1
  import { useRegistryScript } from "../utils.js";
3
- export const XPixelOptions = object({
4
- id: string(),
5
- version: optional(string())
6
- });
2
+ import { XPixelOptions } from "./schemas.js";
3
+ export { XPixelOptions };
7
4
  export function useScriptXPixel(_options) {
8
5
  return useRegistryScript("xPixel", (options) => {
9
6
  return {
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<ArrayBuffer | undefined>>;
2
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ import { createError, defineEventHandler, getHeader, getQuery, setHeader } from "h3";
3
+ import { $fetch } from "ofetch";
4
+ import { withQuery } from "ufo";
5
+ export default defineEventHandler(async (event) => {
6
+ const runtimeConfig = useRuntimeConfig();
7
+ const proxyConfig = runtimeConfig.public["nuxt-scripts"]?.gravatarProxy;
8
+ const referer = getHeader(event, "referer");
9
+ const host = getHeader(event, "host");
10
+ if (referer && host) {
11
+ let refererHost;
12
+ try {
13
+ refererHost = new URL(referer).host;
14
+ } catch {
15
+ }
16
+ if (refererHost && refererHost !== host) {
17
+ throw createError({
18
+ statusCode: 403,
19
+ statusMessage: "Invalid referer"
20
+ });
21
+ }
22
+ }
23
+ const query = getQuery(event);
24
+ let hash = query.hash;
25
+ const email = query.email;
26
+ if (!hash && email) {
27
+ const encoder = new TextEncoder();
28
+ const data = encoder.encode(email.trim().toLowerCase());
29
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
30
+ hash = Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
31
+ }
32
+ if (!hash) {
33
+ throw createError({
34
+ statusCode: 400,
35
+ statusMessage: "Either hash or email parameter is required"
36
+ });
37
+ }
38
+ const size = query.s || "80";
39
+ const defaultImg = query.d || "mp";
40
+ const rating = query.r || "g";
41
+ const gravatarUrl = withQuery(`https://www.gravatar.com/avatar/${hash}`, {
42
+ s: size,
43
+ d: defaultImg,
44
+ r: rating
45
+ });
46
+ const response = await $fetch.raw(gravatarUrl, {
47
+ responseType: "arrayBuffer",
48
+ headers: {
49
+ "User-Agent": "Nuxt Scripts Gravatar Proxy"
50
+ }
51
+ }).catch((error) => {
52
+ throw createError({
53
+ statusCode: error.statusCode || 500,
54
+ statusMessage: error.statusMessage || "Failed to fetch Gravatar avatar"
55
+ });
56
+ });
57
+ const cacheMaxAge = proxyConfig?.cacheMaxAge ?? 3600;
58
+ setHeader(event, "Content-Type", response.headers.get("content-type") || "image/jpeg");
59
+ setHeader(event, "Cache-Control", `public, max-age=${cacheMaxAge}, s-maxage=${cacheMaxAge}`);
60
+ setHeader(event, "Vary", "Accept-Encoding");
61
+ return response._data;
62
+ });
@@ -1,7 +1,7 @@
1
1
  import type { UseScriptInput, UseScriptOptions, VueScriptInstance } from '@unhead/vue';
2
2
  import type { Script } from '@unhead/vue/types';
3
3
  import type { Import } from 'unimport';
4
- import type { InferInput, ObjectSchema, ValiError } from 'valibot';
4
+ import type { InferInput, ObjectSchema, UnionSchema, ValiError } from 'valibot';
5
5
  import type { ComputedRef, Ref } from 'vue';
6
6
  import type { ClarityInput } from './registry/clarity.js';
7
7
  import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics.js';
@@ -12,7 +12,9 @@ import type { GoogleAdsenseInput } from './registry/google-adsense.js';
12
12
  import type { GoogleAnalyticsInput } from './registry/google-analytics.js';
13
13
  import type { GoogleMapsInput } from './registry/google-maps.js';
14
14
  import type { GoogleRecaptchaInput } from './registry/google-recaptcha.js';
15
+ import type { GoogleSignInInput } from './registry/google-sign-in.js';
15
16
  import type { GoogleTagManagerInput } from './registry/google-tag-manager.js';
17
+ import type { GravatarInput } from './registry/gravatar.js';
16
18
  import type { HotjarInput } from './registry/hotjar.js';
17
19
  import type { IntercomInput } from './registry/intercom.js';
18
20
  import type { LemonSqueezyInput } from './registry/lemon-squeezy.js';
@@ -29,6 +31,7 @@ import type { SnapTrPixelInput } from './registry/snapchat-pixel.js';
29
31
  import type { StripeInput } from './registry/stripe.js';
30
32
  import type { TikTokPixelInput } from './registry/tiktok-pixel.js';
31
33
  import type { UmamiAnalyticsInput } from './registry/umami-analytics.js';
34
+ import type { VercelAnalyticsInput } from './registry/vercel-analytics.js';
32
35
  import type { VimeoPlayerInput } from './registry/vimeo-player.js';
33
36
  import type { XPixelInput } from './registry/x-pixel.js';
34
37
  import type { YouTubePlayerInput } from './registry/youtube-player.js';
@@ -163,6 +166,7 @@ export interface ScriptRegistry {
163
166
  googleAnalytics?: GoogleAnalyticsInput;
164
167
  googleMaps?: GoogleMapsInput;
165
168
  googleRecaptcha?: GoogleRecaptchaInput;
169
+ googleSignIn?: GoogleSignInInput;
166
170
  lemonSqueezy?: LemonSqueezyInput;
167
171
  googleTagManager?: GoogleTagManagerInput;
168
172
  hotjar?: HotjarInput;
@@ -178,21 +182,23 @@ export interface ScriptRegistry {
178
182
  xPixel?: XPixelInput;
179
183
  snapchatPixel?: SnapTrPixelInput;
180
184
  youtubePlayer?: YouTubePlayerInput;
185
+ vercelAnalytics?: VercelAnalyticsInput;
181
186
  vimeoPlayer?: VimeoPlayerInput;
182
187
  umamiAnalytics?: UmamiAnalyticsInput;
188
+ gravatar?: GravatarInput;
183
189
  [key: `${string}-npm`]: NpmInput;
184
190
  }
185
191
  export type NuxtConfigScriptRegistryEntry<T> = true | 'mock' | T | [T, NuxtUseScriptOptionsSerializable];
186
192
  export type NuxtConfigScriptRegistry<T extends keyof ScriptRegistry = keyof ScriptRegistry> = Partial<{
187
193
  [key in T]: NuxtConfigScriptRegistryEntry<ScriptRegistry[key]>;
188
- }>;
194
+ }> & Record<string & {}, NuxtConfigScriptRegistryEntry<any>>;
189
195
  export type UseFunctionType<T, U> = T extends {
190
196
  use: infer V;
191
197
  } ? V extends (...args: any) => any ? ReturnType<V> : U : U;
192
198
  declare const _emptyOptions: ObjectSchema<{}, undefined>;
193
199
  export type EmptyOptionsSchema = typeof _emptyOptions;
194
200
  type ScriptInput = Script;
195
- export type InferIfSchema<T> = T extends ObjectSchema<any, any> ? InferInput<T> : T;
201
+ export type InferIfSchema<T> = T extends ObjectSchema<any, any> | UnionSchema<any, any> ? InferInput<T> : T;
196
202
  export type RegistryScriptInput<T = EmptyOptionsSchema, Bundelable extends boolean = true, Usable extends boolean = false, CanBypassOptions extends boolean = true> = (InferIfSchema<T> & {
197
203
  /**
198
204
  * A unique key to use for the script, this can be used to load multiple of the same script with different options.
@@ -1,6 +1,6 @@
1
1
  import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
2
2
  import type { UseScriptInput } from '@unhead/vue';
3
- import type { ObjectSchema } from 'valibot';
3
+ import type { ObjectSchema, UnionSchema } from 'valibot';
4
4
  export type MaybePromise<T> = Promise<T> | T;
5
5
  type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
6
6
  scriptInput?: UseScriptInput & {
@@ -9,7 +9,7 @@ type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
9
9
  }) => ({
10
10
  scriptInput?: UseScriptInput;
11
11
  scriptOptions?: NuxtUseScriptOptions;
12
- schema?: O extends ObjectSchema<any, any> ? O : undefined;
12
+ schema?: O extends ObjectSchema<any, any> | UnionSchema<any, any> ? O : undefined;
13
13
  clientInit?: () => void | Promise<any>;
14
14
  scriptMode?: 'external' | 'npm';
15
15
  });
@@ -71,8 +71,9 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
71
71
  scriptOptions.devtools = defu(scriptOptions.devtools, { registryKey, loadedFrom });
72
72
  if (options.schema) {
73
73
  const registryMeta = {};
74
- for (const k in options.schema.entries) {
75
- if (options.schema.entries[k].type !== "optional") {
74
+ const entries = "entries" in options.schema ? options.schema.entries : void 0;
75
+ for (const k in entries) {
76
+ if (entries[k]?.type !== "optional") {
76
77
  registryMeta[k] = String(userOptions[k]);
77
78
  }
78
79
  }
@@ -261,6 +261,28 @@ function buildProxyConfig(collectPrefix) {
261
261
  routes: {
262
262
  [`${collectPrefix}/crisp/**`]: { proxy: "https://client.crisp.chat/**" }
263
263
  }
264
+ },
265
+ vercelAnalytics: {
266
+ // Vercel Analytics: trusted first-party analytics — minimal privacy needed
267
+ privacy: { ip: false, userAgent: false, language: false, screen: false, timezone: false, hardware: false },
268
+ rewrite: [
269
+ { from: "va.vercel-scripts.com", to: `${collectPrefix}/vercel` }
270
+ ],
271
+ routes: {
272
+ [`${collectPrefix}/vercel/**`]: { proxy: "https://va.vercel-scripts.com/**" }
273
+ }
274
+ },
275
+ gravatar: {
276
+ // Gravatar: avatar proxy — IP anonymized, rest not needed
277
+ privacy: { ip: true, userAgent: false, language: false, screen: false, timezone: false, hardware: false },
278
+ rewrite: [
279
+ { from: "secure.gravatar.com", to: `${collectPrefix}/gravatar` },
280
+ { from: "gravatar.com/avatar", to: `${collectPrefix}/gravatar-avatar` }
281
+ ],
282
+ routes: {
283
+ [`${collectPrefix}/gravatar/**`]: { proxy: "https://secure.gravatar.com/**" },
284
+ [`${collectPrefix}/gravatar-avatar/**`]: { proxy: "https://gravatar.com/avatar/**" }
285
+ }
264
286
  }
265
287
  };
266
288
  }