@nuxt/scripts 0.3.0 → 0.3.2
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.
- package/README.md +19 -10
- package/dist/client/200.html +5 -5
- package/dist/client/404.html +5 -5
- package/dist/client/_nuxt/{DIt5FBMJ.js → 5Hk8ESNW.js} +1 -1
- package/dist/client/_nuxt/BxcSmj5a.js +31 -0
- package/dist/client/_nuxt/{DOakR0z3.js → DeEC_XNp.js} +1 -1
- package/dist/client/_nuxt/{CovTDKFE.js → TwOttoDL.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/d293267d-837e-425a-bc4b-81773905567b.json +1 -0
- package/dist/client/index.html +5 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/GoogleMaps.vue +1 -1
- package/dist/runtime/components/StripePricingTableEmbed.vue +1 -1
- package/dist/runtime/components/VimeoEmbed.vue +1 -1
- package/dist/runtime/components/YouTubeEmbed.vue +1 -1
- package/dist/runtime/composables/useConsentScriptTrigger.d.ts +13 -0
- package/dist/runtime/composables/{createConsentScriptTrigger.mjs → useConsentScriptTrigger.mjs} +11 -3
- package/dist/runtime/composables/useElementScriptTrigger.d.ts +15 -1
- package/dist/runtime/composables/useElementScriptTrigger.mjs +4 -2
- package/dist/runtime/composables/useScript.d.ts +1 -1
- package/dist/runtime/registry/cloudflare-web-analytics.d.ts +1 -1
- package/dist/runtime/registry/cloudflare-web-analytics.mjs +1 -1
- package/dist/runtime/registry/facebook-pixel.d.ts +1 -1
- package/dist/runtime/registry/facebook-pixel.mjs +2 -2
- package/dist/runtime/registry/fathom-analytics.d.ts +1 -1
- package/dist/runtime/registry/fathom-analytics.mjs +1 -1
- package/dist/runtime/registry/google-analytics.d.ts +1 -1
- package/dist/runtime/registry/google-analytics.mjs +2 -2
- package/dist/runtime/registry/google-maps.d.ts +9 -3
- package/dist/runtime/registry/google-maps.mjs +2 -2
- package/dist/runtime/registry/google-tag-manager.d.ts +1 -1
- package/dist/runtime/registry/google-tag-manager.mjs +2 -2
- package/dist/runtime/registry/hotjar.d.ts +1 -1
- package/dist/runtime/registry/hotjar.mjs +2 -2
- package/dist/runtime/registry/intercom.d.ts +3 -3
- package/dist/runtime/registry/intercom.mjs +2 -2
- package/dist/runtime/registry/lemon-squeezy.d.ts +1 -1
- package/dist/runtime/registry/lemon-squeezy.mjs +2 -2
- package/dist/runtime/registry/matomo-analytics.d.ts +1 -1
- package/dist/runtime/registry/matomo-analytics.mjs +2 -2
- package/dist/runtime/registry/npm.d.ts +1 -1
- package/dist/runtime/registry/npm.mjs +1 -1
- package/dist/runtime/registry/plausible-analytics.d.ts +1 -1
- package/dist/runtime/registry/plausible-analytics.mjs +2 -2
- package/dist/runtime/registry/segment.d.ts +1 -1
- package/dist/runtime/registry/segment.mjs +2 -2
- package/dist/runtime/registry/stripe.d.ts +3 -3
- package/dist/runtime/registry/stripe.mjs +2 -2
- package/dist/runtime/registry/vimeo-player.d.ts +1 -1
- package/dist/runtime/registry/vimeo-player.mjs +2 -2
- package/dist/runtime/registry/x-pixel.d.ts +1 -1
- package/dist/runtime/registry/x-pixel.mjs +2 -2
- package/dist/runtime/registry/youtube-iframe.d.ts +2 -2
- package/dist/runtime/registry/youtube-iframe.mjs +2 -2
- package/dist/runtime/types.d.ts +2 -2
- package/dist/runtime/utils.d.ts +1 -4
- package/dist/runtime/utils.mjs +4 -8
- package/dist/runtime/validation/mock.d.ts +36 -0
- package/dist/runtime/validation/mock.mjs +13 -0
- package/dist/runtime/validation/valibot.d.ts +1 -0
- package/dist/runtime/validation/valibot.mjs +1 -0
- package/package.json +1 -1
- package/dist/client/_nuxt/8T3kBMJO.js +0 -31
- package/dist/client/_nuxt/builds/meta/ccc94de9-89fa-400b-88f2-8fc2599e191f.json +0 -1
- package/dist/runtime/composables/createConsentScriptTrigger.d.ts +0 -6
|
@@ -36,6 +36,6 @@ export declare const XPixelOptions: import("valibot").ObjectSchema<{
|
|
|
36
36
|
}>;
|
|
37
37
|
export type XPixelInput = RegistryScriptInput<typeof XPixelOptions>;
|
|
38
38
|
export declare function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput): T & {
|
|
39
|
-
$script: import("@unhead/vue").VueScriptInstance<T
|
|
39
|
+
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
40
40
|
};
|
|
41
41
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { object, optional, string } from "valibot";
|
|
2
1
|
import { registryScript } from "../utils.mjs";
|
|
2
|
+
import { object, optional, string } from "#nuxt-scripts-validator";
|
|
3
3
|
export const XPixelOptions = object({
|
|
4
4
|
id: string(),
|
|
5
5
|
version: optional(string())
|
|
@@ -9,7 +9,7 @@ export function useScriptXPixel(_options) {
|
|
|
9
9
|
scriptInput: {
|
|
10
10
|
src: "https://static.ads-twitter.com/uwt.js"
|
|
11
11
|
},
|
|
12
|
-
schema: XPixelOptions,
|
|
12
|
+
schema: import.meta.dev ? XPixelOptions : void 0,
|
|
13
13
|
scriptOptions: {
|
|
14
14
|
use() {
|
|
15
15
|
return { twq: window.twq };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="youtube" />
|
|
2
2
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
3
|
export interface YouTubeIframeApi {
|
|
4
4
|
YT: typeof YT;
|
|
@@ -11,5 +11,5 @@ declare global {
|
|
|
11
11
|
export declare const YouTubeIframeOptions: import("valibot").ObjectSchema<{}, undefined, {}>;
|
|
12
12
|
export type YouTubeIFrameInput = RegistryScriptInput<typeof YouTubeIframeOptions>;
|
|
13
13
|
export declare function useScriptYouTubeIframe<T extends YouTubeIframeApi>(_options: YouTubeIFrameInput): T & {
|
|
14
|
-
$script: import("@unhead/vue").VueScriptInstance<T
|
|
14
|
+
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
15
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { object } from "valibot";
|
|
2
1
|
import { registryScript } from "../utils.mjs";
|
|
2
|
+
import { object } from "#nuxt-scripts-validator";
|
|
3
3
|
import { useHead } from "#imports";
|
|
4
4
|
export const YouTubeIframeOptions = object({
|
|
5
5
|
// no options afaik
|
|
@@ -13,7 +13,7 @@ export function useScriptYouTubeIframe(_options) {
|
|
|
13
13
|
// @ts-expect-error TODO add types
|
|
14
14
|
crossorigin: null
|
|
15
15
|
},
|
|
16
|
-
schema: YouTubeIframeOptions,
|
|
16
|
+
schema: import.meta.dev ? YouTubeIframeOptions : void 0,
|
|
17
17
|
scriptOptions: {
|
|
18
18
|
use() {
|
|
19
19
|
return {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface TrackedPage {
|
|
|
39
39
|
title?: string;
|
|
40
40
|
path: string;
|
|
41
41
|
}
|
|
42
|
-
export interface
|
|
42
|
+
export interface ConsentScriptTriggerOptions {
|
|
43
43
|
/**
|
|
44
44
|
* An optional reactive (or promise) reference to the consent state. You can use this to accept the consent for scripts
|
|
45
45
|
* instead of using the accept() method.
|
|
@@ -49,7 +49,7 @@ export interface ConsentPromiseOptions {
|
|
|
49
49
|
* Should the script be loaded on the `requestIdleCallback` callback. This is useful for non-essential scripts that
|
|
50
50
|
* have already been consented to be loaded.
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
postConsentTrigger?: NuxtUseScriptOptions['trigger'];
|
|
53
53
|
}
|
|
54
54
|
export interface NuxtAppScript {
|
|
55
55
|
key: string;
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { Input, ObjectSchema } from 'valibot';
|
|
2
2
|
import type { UseScriptInput } from '@unhead/vue';
|
|
3
3
|
import type { NuxtUseScriptOptions, RegistryScriptInput } from '#nuxt-scripts';
|
|
4
|
-
export declare function mockFallbackScript(name: string, module: string): Record<string | symbol, any> & {
|
|
5
|
-
$script: import("@unhead/vue").VueScriptInstance<Record<string | symbol, any>> & Promise<Record<string | symbol, any>>;
|
|
6
|
-
};
|
|
7
4
|
type OptionsFn<O extends ObjectSchema<any>> = (options: Input<O>) => ({
|
|
8
5
|
scriptInput?: UseScriptInput;
|
|
9
6
|
scriptOptions?: NuxtUseScriptOptions;
|
|
@@ -11,6 +8,6 @@ type OptionsFn<O extends ObjectSchema<any>> = (options: Input<O>) => ({
|
|
|
11
8
|
clientInit?: () => void;
|
|
12
9
|
});
|
|
13
10
|
export declare function registryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any>>(key: string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): T & {
|
|
14
|
-
$script: import("@unhead/vue").VueScriptInstance<T
|
|
11
|
+
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
15
12
|
};
|
|
16
13
|
export {};
|
package/dist/runtime/utils.mjs
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
|
-
import { parse } from "
|
|
2
|
+
import { parse } from "#nuxt-scripts-validator";
|
|
3
3
|
import { createError, useRuntimeConfig, useScript } from "#imports";
|
|
4
|
-
|
|
5
|
-
console.error(`${name} is provided by ${module}. Check your console to install it or run 'npx nuxi@latest module add ${module}'`);
|
|
6
|
-
return useScript("", { trigger: "manual" });
|
|
7
|
-
}
|
|
8
|
-
function validateScriptInputSchema(schema, options) {
|
|
4
|
+
function validateScriptInputSchema(key, schema, options) {
|
|
9
5
|
if (import.meta.dev) {
|
|
10
6
|
try {
|
|
11
7
|
parse(schema, options);
|
|
12
8
|
} catch (e) {
|
|
13
9
|
createError({
|
|
14
10
|
cause: e,
|
|
15
|
-
message:
|
|
11
|
+
message: `Invalid script options for ${key}`
|
|
16
12
|
});
|
|
17
13
|
}
|
|
18
14
|
}
|
|
@@ -26,7 +22,7 @@ export function registryScript(key, optionsFn, _userOptions) {
|
|
|
26
22
|
const scriptOptions = Object.assign(_userOptions?.scriptOptions || {}, options.scriptOptions || {});
|
|
27
23
|
const init = scriptOptions.beforeInit;
|
|
28
24
|
scriptOptions.beforeInit = () => {
|
|
29
|
-
import.meta.dev && options.schema && validateScriptInputSchema(options.schema, userOptions);
|
|
25
|
+
import.meta.dev && options.schema && validateScriptInputSchema(key, options.schema, userOptions);
|
|
30
26
|
init?.();
|
|
31
27
|
import.meta.client && options.clientInit?.();
|
|
32
28
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const parse: (() => void) & {
|
|
2
|
+
__unenv__: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare const object: (() => void) & {
|
|
5
|
+
__unenv__: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const array: (() => void) & {
|
|
8
|
+
__unenv__: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const string: (() => void) & {
|
|
11
|
+
__unenv__: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const number: (() => void) & {
|
|
14
|
+
__unenv__: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const boolean: (() => void) & {
|
|
17
|
+
__unenv__: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const optional: (() => void) & {
|
|
20
|
+
__unenv__: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare const literal: (() => void) & {
|
|
23
|
+
__unenv__: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const union: (() => void) & {
|
|
26
|
+
__unenv__: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare const record: (() => void) & {
|
|
29
|
+
__unenv__: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare const any: (() => void) & {
|
|
32
|
+
__unenv__: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare const minLength: (() => void) & {
|
|
35
|
+
__unenv__: boolean;
|
|
36
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import noop from "unenv/runtime/mock/noop";
|
|
2
|
+
export const parse = noop;
|
|
3
|
+
export const object = noop;
|
|
4
|
+
export const array = noop;
|
|
5
|
+
export const string = noop;
|
|
6
|
+
export const number = noop;
|
|
7
|
+
export const boolean = noop;
|
|
8
|
+
export const optional = noop;
|
|
9
|
+
export const literal = noop;
|
|
10
|
+
export const union = noop;
|
|
11
|
+
export const record = noop;
|
|
12
|
+
export const any = noop;
|
|
13
|
+
export const minLength = noop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'valibot';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "valibot";
|
package/package.json
CHANGED