@nuxt/scripts 0.4.6 → 0.4.8

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 (59) hide show
  1. package/dist/client/200.html +13 -13
  2. package/dist/client/404.html +13 -13
  3. package/dist/client/_nuxt/{D6NljDpC.js → BigF1UXR.js} +1 -1
  4. package/dist/client/_nuxt/Bn0B8vkx.js +1 -0
  5. package/dist/client/_nuxt/BvCdDh2R.js +1 -0
  6. package/dist/client/_nuxt/BvlfuC5v.js +31 -0
  7. package/dist/client/_nuxt/{Gn7Sk0ke.js → DMNuDhJC.js} +1 -1
  8. package/dist/client/_nuxt/DOHBU7tp.js +1 -0
  9. package/dist/client/_nuxt/builds/latest.json +1 -1
  10. package/dist/client/_nuxt/builds/meta/ed70e2f7-3856-4e68-bd3e-1ebb17fef5ec.json +1 -0
  11. package/dist/client/_nuxt/entry.8LvBfYHJ.css +1 -0
  12. package/dist/client/_nuxt/error-404.Dbi768NS.css +1 -0
  13. package/dist/client/_nuxt/error-500.C23YdqXl.css +1 -0
  14. package/dist/client/_nuxt/{ixTSYuOP.js → jmWmhCGR.js} +1 -1
  15. package/dist/client/index.html +13 -13
  16. package/dist/module.d.mts +7 -2
  17. package/dist/module.d.ts +7 -2
  18. package/dist/module.json +2 -2
  19. package/dist/module.mjs +179 -7
  20. package/dist/registry.mjs +19 -24
  21. package/dist/runtime/components/ScriptCarbonAds.vue +70 -0
  22. package/dist/runtime/components/ScriptGoogleMaps.vue +1 -1
  23. package/dist/runtime/components/ScriptVimeoPlayer.vue +3 -6
  24. package/dist/runtime/composables/useAnalyticsPageEvent.d.ts +1 -4
  25. package/dist/runtime/composables/useElementScriptTrigger.js +0 -1
  26. package/dist/runtime/registry/clarity.d.ts +44 -0
  27. package/dist/runtime/registry/clarity.js +30 -0
  28. package/dist/runtime/registry/cloudflare-web-analytics.d.ts +3 -6
  29. package/dist/runtime/registry/cloudflare-web-analytics.js +2 -2
  30. package/dist/runtime/registry/fathom-analytics.d.ts +6 -12
  31. package/dist/runtime/registry/google-adsense.d.ts +2 -4
  32. package/dist/runtime/registry/google-maps.d.ts +9 -10
  33. package/dist/runtime/registry/hotjar.d.ts +3 -6
  34. package/dist/runtime/registry/intercom.d.ts +11 -20
  35. package/dist/runtime/registry/matomo-analytics.d.ts +5 -10
  36. package/dist/runtime/registry/meta-pixel.d.ts +2 -4
  37. package/dist/runtime/registry/npm.d.ts +5 -10
  38. package/dist/runtime/registry/plausible-analytics.d.ts +3 -6
  39. package/dist/runtime/registry/segment.d.ts +3 -6
  40. package/dist/runtime/registry/stripe.d.ts +2 -4
  41. package/dist/runtime/registry/vimeo-player.d.ts +2 -1
  42. package/dist/runtime/registry/x-pixel.d.ts +3 -6
  43. package/dist/runtime/types.d.ts +8 -8
  44. package/dist/runtime/utils.d.ts +3 -3
  45. package/dist/types.d.mts +1 -0
  46. package/dist/types.d.ts +1 -0
  47. package/package.json +23 -19
  48. package/dist/client/_nuxt/B6ZnTe72.js +0 -1
  49. package/dist/client/_nuxt/BB1wM0JV.js +0 -1
  50. package/dist/client/_nuxt/D3J95Otb.js +0 -31
  51. package/dist/client/_nuxt/MN12aA4C.js +0 -1
  52. package/dist/client/_nuxt/builds/meta/e7e8b021-1e94-4c86-ad2e-d6ac965b2190.json +0 -1
  53. package/dist/client/_nuxt/entry.D91GVkD7.css +0 -1
  54. package/dist/client/_nuxt/error-404.BRldFSII.css +0 -1
  55. package/dist/client/_nuxt/error-500.D8yw_IbC.css +0 -1
  56. package/dist/runtime/registry/google-analytics.d.ts +0 -23
  57. package/dist/runtime/registry/google-analytics.js +0 -38
  58. package/dist/runtime/registry/google-tag-manager.d.ts +0 -21
  59. package/dist/runtime/registry/google-tag-manager.js +0 -30
@@ -0,0 +1,70 @@
1
+ <script setup lang="ts">
2
+ import { withQuery } from 'ufo'
3
+ import { onBeforeUnmount, onMounted, ref, useElementScriptTrigger } from '#imports'
4
+ import type { ElementScriptTrigger } from '#nuxt-scripts'
5
+
6
+ const props = defineProps<{
7
+ serve: string
8
+ placement: string
9
+ /**
10
+ * Defines the trigger event to load the script.
11
+ */
12
+ trigger?: ElementScriptTrigger
13
+ }>()
14
+
15
+ const emit = defineEmits<{
16
+ error: [error: string | Event]
17
+ load: []
18
+ }>()
19
+
20
+ const attrId = `_carbonads_js`
21
+ const carbonadsEl = ref<HTMLElement | null>(import.meta.client ? document.getElementById(attrId) : null)
22
+ // syncs to useScript status
23
+ const status = ref('awaitingLoad')
24
+
25
+ function loadCarbon() {
26
+ if (!carbonadsEl.value) {
27
+ return
28
+ }
29
+ status.value = 'loading'
30
+ const script = document.createElement('script')
31
+ script.setAttribute('type', 'text/javascript')
32
+ script.setAttribute('src', withQuery('https://cdn.carbonads.com/carbon.js', {
33
+ serve: props.serve,
34
+ placement: props.placement,
35
+ }))
36
+ script.setAttribute('id', attrId)
37
+ script.onerror = (err) => {
38
+ status.value = 'error'
39
+ emit('error', err)
40
+ }
41
+ script.onload = () => {
42
+ status.value = 'loaded'
43
+ emit('load')
44
+ }
45
+ carbonadsEl.value.appendChild(script)
46
+ }
47
+
48
+ onMounted(() => {
49
+ if (!props.trigger) {
50
+ loadCarbon()
51
+ }
52
+ else {
53
+ useElementScriptTrigger({ trigger: props.trigger, el: carbonadsEl })
54
+ }
55
+ })
56
+
57
+ onBeforeUnmount(() => {
58
+ if (carbonadsEl.value) {
59
+ carbonadsEl.value.remove()
60
+ }
61
+ })
62
+ </script>
63
+
64
+ <template>
65
+ <div ref="carbonadsEl">
66
+ <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
67
+ <slot v-else-if="status === 'loading'" name="loading" />
68
+ <slot v-else-if="status === 'error'" name="error" />
69
+ </div>
70
+ </template>
@@ -144,7 +144,7 @@ onMounted(() => {
144
144
  })
145
145
  // create the map
146
146
  $script.then(async (instance) => {
147
- const maps = await instance.maps
147
+ const maps = await instance.maps as any as typeof google.maps // some weird type issue here
148
148
  const _map = new maps.Map(mapEl.value!, options.value)
149
149
  const placesService = new maps.places.PlacesService(_map)
150
150
 
@@ -12,7 +12,7 @@ const props = withDefaults(defineProps<{
12
12
  rootAttrs?: HTMLAttributes
13
13
  aboveTheFold?: boolean
14
14
  // copied from @types/vimeo__player
15
- id: number | undefined
15
+ id?: number | undefined
16
16
  url?: string | undefined
17
17
  autopause?: boolean | undefined
18
18
  autoplay?: boolean | undefined
@@ -51,7 +51,7 @@ const emits = defineEmits<TEmits>()
51
51
 
52
52
  type EventMap<E extends keyof Vimeo.EventMap> = [event: Vimeo.EventMap[E], player: Vimeo]
53
53
 
54
- // eslint-disable-next-line ts/consistent-type-definitions
54
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
55
55
  type TEmits = {
56
56
  play: EventMap<'play'>
57
57
  playing: EventMap<'playing'>
@@ -169,10 +169,7 @@ defineExpose({
169
169
  onMounted(() => {
170
170
  $script.then(async ({ Vimeo }) => {
171
171
  // filter props for false values
172
- player = new Vimeo.Player(elVimeo.value, {
173
- ...props,
174
- url: encodeURI(`https://vimeo.com/${props.id}`),
175
- })
172
+ player = new Vimeo.Player(elVimeo.value, props)
176
173
  if (clickTriggered) {
177
174
  player!.play()
178
175
  clickTriggered = false
@@ -1,5 +1,2 @@
1
1
  import type { TrackedPage } from '#nuxt-scripts';
2
- export declare function useAnalyticsPageEvent(onChange?: (payload: TrackedPage) => void): import("#imports").Ref<{
3
- title?: string | undefined;
4
- path: string;
5
- }>;
2
+ export declare function useAnalyticsPageEvent(onChange?: (payload: TrackedPage) => void): import("#imports").Ref<TrackedPage>;
@@ -35,7 +35,6 @@ export function useElementScriptTrigger(options) {
35
35
  return new Promise((resolve) => {
36
36
  const _ = useEventListener(
37
37
  typeof el !== "undefined" ? el : document.body,
38
- // @ts-expect-error untyped
39
38
  trigger,
40
39
  () => {
41
40
  resolve();
@@ -0,0 +1,44 @@
1
+ import type { RegistryScriptInput } from '#nuxt-scripts';
2
+ /**
3
+ * <script type="text/javascript">
4
+ * (function(c,l,a,r,i,t,y){
5
+ * c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
6
+ * t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
7
+ * y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
8
+ * })(window, document, "clarity", "script", "mpy5c6k7xi");
9
+ * </script>
10
+ */
11
+ type ClarityFunctions = ((fn: 'start', options: {
12
+ content: boolean;
13
+ cookies: string[];
14
+ dob: number;
15
+ expire: number;
16
+ projectId: string;
17
+ upload: string;
18
+ }) => void) & ((fn: 'identify', id: string, session?: string, page?: string, userHint?: string) => Promise<{
19
+ id: string;
20
+ session: string;
21
+ page: string;
22
+ userHint: string;
23
+ }>) & ((fn: 'consent') => void) & ((fn: 'set', key: any, value: any) => void) & ((fn: 'event', value: any) => void) & ((fn: 'upgrade', upgradeReason: any) => void) & ((fn: string, ...args: any[]) => void);
24
+ export interface ClarityApi {
25
+ clarity: ClarityFunctions & {
26
+ q: any[];
27
+ v: string;
28
+ };
29
+ }
30
+ declare global {
31
+ interface Window extends ClarityApi {
32
+ }
33
+ }
34
+ export declare const ClarityOptions: import("valibot").ObjectSchema<{
35
+ /**
36
+ * The Clarity token.
37
+ */
38
+ readonly id: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 10, undefined>]>;
39
+ }, undefined>;
40
+ export type ClarityInput = RegistryScriptInput<typeof ClarityOptions>;
41
+ export declare function useScriptClarity<T extends ClarityApi>(_options?: ClarityInput): T & {
42
+ $script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
43
+ };
44
+ export {};
@@ -0,0 +1,30 @@
1
+ import { useRegistryScript } from "../utils.js";
2
+ import { minLength, object, string, pipe } from "#nuxt-scripts-validator";
3
+ export const ClarityOptions = object({
4
+ /**
5
+ * The Clarity token.
6
+ */
7
+ id: pipe(string(), minLength(10))
8
+ });
9
+ export function useScriptClarity(_options) {
10
+ return useRegistryScript(
11
+ "clarity",
12
+ (options) => ({
13
+ scriptInput: {
14
+ src: `https://www.clarity.ms/tag/${options.id}`
15
+ },
16
+ schema: import.meta.dev ? ClarityOptions : void 0,
17
+ scriptOptions: {
18
+ use() {
19
+ return { clarity: window.clarity };
20
+ }
21
+ },
22
+ clientInit: import.meta.server ? void 0 : () => {
23
+ window.clarity = window.clarity || function(...params) {
24
+ (window.clarity.q = window.clarity.q || []).push(params);
25
+ };
26
+ }
27
+ }),
28
+ _options
29
+ );
30
+ }
@@ -20,18 +20,15 @@ export declare const CloudflareWebAnalyticsOptions: import("valibot").ObjectSche
20
20
  /**
21
21
  * The Cloudflare Web Analytics token.
22
22
  */
23
- token: import("valibot").StringSchema<string>;
23
+ readonly token: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 32, undefined>]>;
24
24
  /**
25
25
  * Cloudflare Web Analytics enables measuring SPAs automatically by overriding the History API’s pushState function
26
26
  * and listening to the onpopstate. Hash-based router is not supported.
27
27
  *
28
28
  * @default true
29
29
  */
30
- spa: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
31
- }, undefined, {
32
- token: string;
33
- spa?: boolean | undefined;
34
- }>;
30
+ readonly spa: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
31
+ }, undefined>;
35
32
  export type CloudflareWebAnalyticsInput = RegistryScriptInput<typeof CloudflareWebAnalyticsOptions>;
36
33
  export declare function useScriptCloudflareWebAnalytics<T extends CloudflareWebAnalyticsApi>(_options?: CloudflareWebAnalyticsInput): T & {
37
34
  $script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
@@ -1,10 +1,10 @@
1
1
  import { useRegistryScript } from "../utils.js";
2
- import { boolean, minLength, object, optional, string } from "#nuxt-scripts-validator";
2
+ import { boolean, minLength, object, optional, pipe, string } from "#nuxt-scripts-validator";
3
3
  export const CloudflareWebAnalyticsOptions = object({
4
4
  /**
5
5
  * The Cloudflare Web Analytics token.
6
6
  */
7
- token: string([minLength(32)]),
7
+ token: pipe(string(), minLength(32)),
8
8
  /**
9
9
  * Cloudflare Web Analytics enables measuring SPAs automatically by overriding the History API’s pushState function
10
10
  * and listening to the onpopstate. Hash-based router is not supported.
@@ -3,30 +3,24 @@ export declare const FathomAnalyticsOptions: import("valibot").ObjectSchema<{
3
3
  /**
4
4
  * The Fathom Analytics site ID.
5
5
  */
6
- site: import("valibot").StringSchema<string>;
6
+ readonly site: import("valibot").StringSchema<undefined>;
7
7
  /**
8
8
  * The Fathom Analytics tracking mode.
9
9
  */
10
- spa: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"auto", "auto"> | import("valibot").LiteralSchema<"history", "history"> | import("valibot").LiteralSchema<"hash", "hash">)[], "auto" | "history" | "hash">, undefined, "auto" | "history" | "hash" | undefined>;
10
+ readonly spa: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"auto", undefined>, import("valibot").LiteralSchema<"history", undefined>, import("valibot").LiteralSchema<"hash", undefined>], undefined>, never>;
11
11
  /**
12
12
  * Automatically track page views.
13
13
  */
14
- auto: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
14
+ readonly auto: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
15
15
  /**
16
16
  * Enable canonical URL tracking.
17
17
  */
18
- canonical: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
18
+ readonly canonical: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
19
19
  /**
20
20
  * Honor Do Not Track requests.
21
21
  */
22
- honorDnt: import("valibot").OptionalSchema<import("valibot").BooleanSchema<boolean>, undefined, boolean | undefined>;
23
- }, undefined, {
24
- site: string;
25
- spa?: "auto" | "history" | "hash" | undefined;
26
- auto?: boolean | undefined;
27
- canonical?: boolean | undefined;
28
- honorDnt?: boolean | undefined;
29
- }>;
22
+ readonly honorDnt: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
23
+ }, undefined>;
30
24
  export type FathomAnalyticsInput = RegistryScriptInput<typeof FathomAnalyticsOptions, false>;
31
25
  export interface FathomAnalyticsApi {
32
26
  beacon: (ctx: {
@@ -3,10 +3,8 @@ export declare const GoogleAdsenseOptions: import("valibot").ObjectSchema<{
3
3
  /**
4
4
  * The Google Adsense ID.
5
5
  */
6
- client: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
7
- }, undefined, {
8
- client?: string | undefined;
9
- }>;
6
+ readonly client: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
7
+ }, undefined>;
10
8
  export type GoogleAdsenseInput = RegistryScriptInput<typeof GoogleAdsenseOptions>;
11
9
  export interface GoogleAdsenseApi {
12
10
  /**
@@ -8,21 +8,20 @@ declare namespace google {
8
8
  }
9
9
  }
10
10
  export declare const GoogleMapsOptions: import("valibot").ObjectSchema<{
11
- apiKey: import("valibot").StringSchema<string>;
12
- libraries: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<string>, string[]>, undefined, string[] | undefined>;
13
- v: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"weekly", "weekly"> | import("valibot").LiteralSchema<"beta", "beta"> | import("valibot").LiteralSchema<"alpha", "alpha">)[], "weekly" | "beta" | "alpha">, undefined, "weekly" | "beta" | "alpha" | undefined>;
14
- }, undefined, {
15
- apiKey: string;
16
- libraries?: string[] | undefined;
17
- v?: "weekly" | "beta" | "alpha" | undefined;
18
- }>;
11
+ readonly apiKey: import("valibot").StringSchema<undefined>;
12
+ readonly libraries: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, never>;
13
+ readonly v: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"weekly", undefined>, import("valibot").LiteralSchema<"beta", undefined>, import("valibot").LiteralSchema<"alpha", undefined>], undefined>, never>;
14
+ }, undefined>;
19
15
  export type GoogleMapsInput = RegistryScriptInput<typeof GoogleMapsOptions>;
16
+ type MapsNamespace = typeof google.maps;
20
17
  export interface GoogleMapsApi {
21
- maps: typeof window.google.maps;
18
+ maps: MapsNamespace | Promise<MapsNamespace>;
22
19
  }
23
20
  declare global {
24
21
  interface Window {
25
- google: typeof google;
22
+ google: {
23
+ maps: MapsNamespace;
24
+ };
26
25
  }
27
26
  }
28
27
  export declare function useScriptGoogleMaps<T extends GoogleMapsApi>(_options?: GoogleMapsInput): T & {
@@ -13,12 +13,9 @@ declare global {
13
13
  }
14
14
  }
15
15
  export declare const HotjarOptions: import("valibot").ObjectSchema<{
16
- id: import("valibot").NumberSchema<number>;
17
- sv: import("valibot").OptionalSchema<import("valibot").NumberSchema<number>, undefined, number | undefined>;
18
- }, undefined, {
19
- id: number;
20
- sv?: number | undefined;
21
- }>;
16
+ readonly id: import("valibot").NumberSchema<undefined>;
17
+ readonly sv: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
18
+ }, undefined>;
22
19
  export type HotjarInput = RegistryScriptInput<typeof HotjarOptions>;
23
20
  export declare function useScriptHotjar<T extends HotjarApi>(_options?: HotjarInput): T & {
24
21
  $script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
@@ -1,27 +1,18 @@
1
- import { type Input } from '#nuxt-scripts-validator';
1
+ import { type InferInput } from '#nuxt-scripts-validator';
2
2
  import type { RegistryScriptInput } from '#nuxt-scripts';
3
3
  export declare const IntercomOptions: import("valibot").ObjectSchema<{
4
- app_id: import("valibot").StringSchema<string>;
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>;
6
- name: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
7
- email: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
8
- user_id: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
9
- alignment: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"left", "left"> | import("valibot").LiteralSchema<"right", "right">)[], "left" | "right">, undefined, "left" | "right" | undefined>;
10
- horizontal_padding: import("valibot").OptionalSchema<import("valibot").NumberSchema<number>, undefined, number | undefined>;
11
- vertical_padding: import("valibot").OptionalSchema<import("valibot").NumberSchema<number>, undefined, number | undefined>;
12
- }, undefined, {
13
- app_id: string;
14
- name?: string | undefined;
15
- api_base?: "https://api-iam.intercom.io" | "https://api-iam.eu.intercom.io" | "https://api-iam.au.intercom.io" | undefined;
16
- email?: string | undefined;
17
- user_id?: string | undefined;
18
- alignment?: "left" | "right" | undefined;
19
- horizontal_padding?: number | undefined;
20
- vertical_padding?: number | undefined;
21
- }>;
4
+ readonly app_id: import("valibot").StringSchema<undefined>;
5
+ readonly api_base: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"https://api-iam.intercom.io", undefined>, import("valibot").LiteralSchema<"https://api-iam.eu.intercom.io", undefined>, import("valibot").LiteralSchema<"https://api-iam.au.intercom.io", undefined>], undefined>, never>;
6
+ readonly name: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
7
+ readonly email: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
8
+ readonly user_id: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
9
+ readonly alignment: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"left", undefined>, import("valibot").LiteralSchema<"right", undefined>], undefined>, never>;
10
+ readonly horizontal_padding: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
11
+ readonly vertical_padding: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
12
+ }, undefined>;
22
13
  export type IntercomInput = RegistryScriptInput<typeof IntercomOptions>;
23
14
  export interface IntercomApi {
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);
15
+ Intercom: ((event: 'boot', data?: InferInput<typeof IntercomOptions>) => void) & ((event: 'shutdown') => void) & ((event: 'update', options?: InferInput<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
16
  }
26
17
  declare global {
27
18
  interface Window extends IntercomApi {
@@ -1,15 +1,10 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts';
2
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
- }>;
3
+ readonly matomoUrl: import("valibot").StringSchema<undefined>;
4
+ readonly siteId: import("valibot").StringSchema<undefined>;
5
+ readonly trackPageView: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
6
+ readonly enableLinkTracking: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
7
+ }, undefined>;
13
8
  export type MatomoAnalyticsInput = RegistryScriptInput<typeof MatomoAnalyticsOptions, false>;
14
9
  interface MatomoAnalyticsApi {
15
10
  _paq: unknown[];
@@ -33,10 +33,8 @@ declare global {
33
33
  }
34
34
  }
35
35
  export declare const MetaPixelOptions: import("valibot").ObjectSchema<{
36
- id: import("valibot").UnionSchema<(import("valibot").StringSchema<string> | import("valibot").NumberSchema<number>)[], string | number>;
37
- }, undefined, {
38
- id: string | number;
39
- }>;
36
+ readonly id: import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>], undefined>;
37
+ }, undefined>;
40
38
  export type MetaPixelInput = RegistryScriptInput<typeof MetaPixelOptions>;
41
39
  export declare function useScriptMetaPixel<T extends MetaPixelApi>(_options?: MetaPixelInput): T & {
42
40
  $script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
@@ -1,15 +1,10 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts';
2
2
  export declare const NpmOptions: import("valibot").ObjectSchema<{
3
- packageName: import("valibot").StringSchema<string>;
4
- file: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
5
- version: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
6
- type: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
7
- }, undefined, {
8
- packageName: string;
9
- file?: string | undefined;
10
- version?: string | undefined;
11
- type?: string | undefined;
12
- }>;
3
+ readonly packageName: import("valibot").StringSchema<undefined>;
4
+ readonly file: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
5
+ readonly version: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
6
+ readonly type: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
7
+ }, undefined>;
13
8
  export type NpmInput = RegistryScriptInput<typeof NpmOptions>;
14
9
  export declare function useScriptNpm<T extends Record<string | symbol, any>>(_options: NpmInput): T & {
15
10
  $script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
@@ -1,11 +1,8 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts';
2
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
- }>;
3
+ readonly domain: import("valibot").StringSchema<undefined>;
4
+ readonly extension: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").UnionSchema<(import("valibot").LiteralSchema<"hash", undefined> | import("valibot").LiteralSchema<"outbound-links", undefined> | import("valibot").LiteralSchema<"file-downloads", undefined> | import("valibot").LiteralSchema<"tagged-events", undefined> | import("valibot").LiteralSchema<"revenue", undefined> | import("valibot").LiteralSchema<"pageview-props", undefined> | import("valibot").LiteralSchema<"compat", undefined> | import("valibot").LiteralSchema<"local", undefined> | import("valibot").LiteralSchema<"manual", undefined>)[], undefined>, import("valibot").ArraySchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"hash", undefined> | import("valibot").LiteralSchema<"outbound-links", undefined> | import("valibot").LiteralSchema<"file-downloads", undefined> | import("valibot").LiteralSchema<"tagged-events", undefined> | import("valibot").LiteralSchema<"revenue", undefined> | import("valibot").LiteralSchema<"pageview-props", undefined> | import("valibot").LiteralSchema<"compat", undefined> | import("valibot").LiteralSchema<"local", undefined> | import("valibot").LiteralSchema<"manual", undefined>)[], undefined>, undefined>], undefined>, never>;
5
+ }, undefined>;
9
6
  export type PlausibleAnalyticsInput = RegistryScriptInput<typeof PlausibleAnalyticsOptions, false>;
10
7
  export interface PlausibleAnalyticsApi {
11
8
  plausible: ((event: '404', options: Record<string, any>) => void) & ((event: 'event', options: Record<string, any>) => void) & ((...params: any[]) => void) & {
@@ -1,11 +1,8 @@
1
1
  import type { RegistryScriptInput } from '#nuxt-scripts';
2
2
  export declare const SegmentOptions: import("valibot").ObjectSchema<{
3
- writeKey: import("valibot").StringSchema<string>;
4
- analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
5
- }, undefined, {
6
- writeKey: string;
7
- analyticsKey?: string | undefined;
8
- }>;
3
+ readonly writeKey: import("valibot").StringSchema<undefined>;
4
+ readonly analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
5
+ }, undefined>;
9
6
  export type SegmentInput = RegistryScriptInput<typeof SegmentOptions>;
10
7
  interface AnalyticsApi {
11
8
  track: (event: string, properties?: Record<string, any>) => void;
@@ -1,10 +1,8 @@
1
1
  /// <reference types="stripe-v3" />
2
2
  import type { RegistryScriptInput } from '#nuxt-scripts';
3
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
- }>;
4
+ readonly advancedFraudSignals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
5
+ }, undefined>;
8
6
  export type StripeInput = RegistryScriptInput<typeof StripeOptions, false>;
9
7
  export interface StripeApi {
10
8
  Stripe: stripe.StripeStatic;
@@ -1,8 +1,9 @@
1
+ import type Vimeo from 'vimeo__player';
1
2
  import type { RegistryScriptInput } from '#nuxt-scripts';
2
3
  type Constructor<T extends new (...args: any) => any> = T extends new (...args: infer A) => infer R ? new (...args: A) => R : never;
3
4
  export interface VimeoPlayerApi {
4
5
  Vimeo: {
5
- Player: Constructor<typeof window.Vimeo>;
6
+ Player: Constructor<typeof Vimeo>;
6
7
  };
7
8
  }
8
9
  export type VimeoPlayerInput = RegistryScriptInput;
@@ -28,12 +28,9 @@ declare global {
28
28
  }
29
29
  }
30
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
- }>;
31
+ readonly id: import("valibot").StringSchema<undefined>;
32
+ readonly version: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
33
+ }, undefined>;
37
34
  export type XPixelInput = RegistryScriptInput<typeof XPixelOptions>;
38
35
  export declare function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput): T & {
39
36
  $script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
@@ -1,7 +1,7 @@
1
1
  import type { UseScriptOptions } from '@unhead/schema';
2
2
  import type { UseScriptInput, VueScriptInstance } from '@unhead/vue';
3
3
  import type { ComputedRef, Ref } from 'vue';
4
- import type { Input, ObjectSchema } from 'valibot';
4
+ import type { InferInput, ObjectSchema } from 'valibot';
5
5
  import type { Import } from 'unimport';
6
6
  import type { SegmentInput } from './registry/segment.js';
7
7
  import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics.js';
@@ -9,9 +9,7 @@ import type { MetaPixelInput } from './registry/meta-pixel.js';
9
9
  import type { FathomAnalyticsInput } from './registry/fathom-analytics.js';
10
10
  import type { HotjarInput } from './registry/hotjar.js';
11
11
  import type { IntercomInput } from './registry/intercom.js';
12
- import type { GoogleAnalyticsInput } from './registry/google-analytics.js';
13
12
  import type { GoogleMapsInput } from './registry/google-maps.js';
14
- import type { GoogleTagManagerInput } from './registry/google-tag-manager.js';
15
13
  import type { MatomoAnalyticsInput } from './registry/matomo-analytics.js';
16
14
  import type { StripeInput } from './registry/stripe.js';
17
15
  import type { VimeoPlayerInput } from './registry/vimeo-player.js';
@@ -20,6 +18,8 @@ import type { YouTubePlayerInput } from './registry/youtube-player.js';
20
18
  import type { PlausibleAnalyticsInput } from './registry/plausible-analytics.js';
21
19
  import type { NpmInput } from './registry/npm.js';
22
20
  import type { LemonSqueezyInput } from './registry/lemon-squeezy.js';
21
+ import type { InferInput as GoogleTagManagerInput } from '#build/nuxt-scripts/tpc/google-tag-manager';
22
+ import type { InferInput as GoogleAnalyticsInput } from '#build/nuxt-scripts/tpc/google-analytics';
23
23
  export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'> & {
24
24
  /**
25
25
  * The trigger to load the script:
@@ -94,15 +94,15 @@ export interface ScriptRegistry {
94
94
  }
95
95
  export type NuxtConfigScriptRegistryEntry<T> = true | 'mock' | T | [T, NuxtUseScriptOptions<T>];
96
96
  export type NuxtConfigScriptRegistry<T extends keyof ScriptRegistry = keyof ScriptRegistry> = Partial<Record<T, NuxtConfigScriptRegistryEntry<ScriptRegistry[T]>>>;
97
- declare const emptyOptions: ObjectSchema<{}, undefined, {}>;
97
+ declare const emptyOptions: ObjectSchema<{}, undefined>;
98
98
  export type EmptyOptionsSchema = typeof emptyOptions;
99
- export type RegistryScriptInput<T extends ObjectSchema<any> = EmptyOptionsSchema, Bundelable extends boolean = true> = Input<T> & {
99
+ export type RegistryScriptInput<T extends ObjectSchema<any, any> = EmptyOptionsSchema, Bundelable extends boolean = true> = InferInput<T> & {
100
100
  scriptInput?: UseScriptInput;
101
101
  scriptOptions?: Bundelable extends true ? Omit<NuxtUseScriptOptions, 'use'> : Omit<NuxtUseScriptOptions, 'bundle' | 'use'>;
102
102
  };
103
103
  export interface RegistryScript {
104
- import: Import;
105
- scriptBundling?: false | ((options?: any) => string);
104
+ import?: Import;
105
+ scriptBundling?: false | ((options?: any) => string | false);
106
106
  label?: string;
107
107
  src?: string | false;
108
108
  category?: string;
@@ -111,6 +111,6 @@ export interface RegistryScript {
111
111
  dark: string;
112
112
  };
113
113
  }
114
- export type ElementScriptTrigger = 'immediate' | 'visible' | keyof GlobalEventHandlersEventMap | (keyof GlobalEventHandlersEventMap)[] | false;
114
+ export type ElementScriptTrigger = 'immediate' | 'visible' | string | string[] | false;
115
115
  export type RegistryScripts = RegistryScript[];
116
116
  export {};
@@ -1,14 +1,14 @@
1
- import type { Input, ObjectSchema } from 'valibot';
1
+ import type { InferInput, ObjectSchema } from 'valibot';
2
2
  import type { UseScriptInput, VueScriptInstance } from '@unhead/vue';
3
3
  import type { EmptyOptionsSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry } from '#nuxt-scripts';
4
- type OptionsFn<O extends ObjectSchema<any>> = (options: Input<O>) => ({
4
+ type OptionsFn<O extends ObjectSchema<any, any>> = (options: InferInput<O>) => ({
5
5
  scriptInput?: UseScriptInput;
6
6
  scriptOptions?: NuxtUseScriptOptions;
7
7
  schema?: O;
8
8
  clientInit?: () => void;
9
9
  });
10
10
  export declare function scriptRuntimeConfig<T extends keyof ScriptRegistry>(key: T): ScriptRegistry[T];
11
- export declare function useRegistryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any> = EmptyOptionsSchema>(key: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): T & {
11
+ export declare function useRegistryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any, any> = EmptyOptionsSchema>(key: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): T & {
12
12
  $script: Promise<T> & VueScriptInstance<T>;
13
13
  };
14
14
  export {};
package/dist/types.d.mts CHANGED
@@ -2,6 +2,7 @@
2
2
  import type { ModuleOptions, ModuleHooks } from './module.js'
3
3
 
4
4
 
5
+
5
6
  declare module '@nuxt/schema' {
6
7
  interface NuxtConfig { ['scripts']?: Partial<ModuleOptions> }
7
8
  interface NuxtOptions { ['scripts']?: ModuleOptions }