@nuxt/scripts 0.6.3 → 0.6.5
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 +73 -73
- package/dist/client/200.html +9 -9
- package/dist/client/404.html +9 -9
- package/dist/client/_nuxt/BA8oXX6l.js +31 -0
- package/dist/client/_nuxt/{zTM8DS5E.js → D3k5CjNA.js} +1 -1
- package/dist/client/_nuxt/{Cg8NGlPg.js → D6UD5WyS.js} +1 -1
- package/dist/client/_nuxt/{DZ6siU6J.js → D9Ze639F.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/a5c6ec68-62ae-43af-96d0-bdd9f64f38b1.json +1 -0
- package/dist/client/_nuxt/entry.Cts5wDvr.css +1 -0
- package/dist/client/_nuxt/error-404.-RjlvToe.css +1 -0
- package/dist/client/_nuxt/error-500.Bz7LXgZy.css +1 -0
- package/dist/client/index.html +9 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +84 -279
- package/dist/registry.mjs +33 -0
- package/dist/runtime/components/ScriptCarbonAds.vue +71 -71
- package/dist/runtime/components/ScriptCrisp.vue +84 -84
- package/dist/runtime/components/ScriptGoogleAdsense.vue +69 -69
- package/dist/runtime/components/ScriptGoogleMaps.vue +265 -265
- package/dist/runtime/components/ScriptIntercom.vue +93 -93
- package/dist/runtime/components/ScriptLemonSqueezy.vue +45 -45
- package/dist/runtime/components/ScriptLoadingIndicator.vue +22 -22
- package/dist/runtime/components/ScriptStripePricingTable.vue +68 -68
- package/dist/runtime/components/ScriptVimeoPlayer.vue +256 -256
- package/dist/runtime/components/ScriptYouTubePlayer.vue +171 -170
- package/dist/runtime/composables/useScript.js +3 -3
- package/dist/runtime/composables/useScriptEventPage.d.ts +1 -1
- package/dist/runtime/registry/crisp.d.ts +1 -1
- package/dist/runtime/registry/fathom-analytics.d.ts +1 -1
- package/dist/runtime/registry/google-adsense.d.ts +1 -1
- package/dist/runtime/registry/google-analytics.d.ts +19 -0
- package/dist/runtime/registry/google-analytics.js +40 -0
- package/dist/runtime/registry/google-tag-manager.d.ts +23 -0
- package/dist/runtime/registry/google-tag-manager.js +33 -0
- package/dist/runtime/registry/hotjar.d.ts +1 -1
- package/dist/runtime/registry/intercom.d.ts +1 -1
- package/dist/runtime/registry/matomo-analytics.d.ts +1 -1
- package/dist/runtime/registry/meta-pixel.d.ts +1 -1
- package/dist/runtime/registry/npm.d.ts +1 -1
- package/dist/runtime/registry/x-pixel.d.ts +1 -1
- package/dist/runtime/types.d.ts +41 -9
- package/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.js +20 -4
- package/package.json +12 -11
- package/dist/client/_nuxt/BeuDC-PU.js +0 -31
- package/dist/client/_nuxt/builds/meta/9996546f-d612-4447-9ee7-fc387b136ee4.json +0 -1
- package/dist/client/_nuxt/entry.DvGwvmL9.css +0 -1
- package/dist/client/_nuxt/error-404.DXyehy0d.css +0 -1
- package/dist/client/_nuxt/error-500.a_92Fvyl.css +0 -1
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UseScriptOptions, DataKeys, SchemaAugmentations, ScriptBase } from '@unhead/schema';
|
|
2
|
-
import type { UseScriptInput, VueScriptInstance
|
|
2
|
+
import type { UseScriptInput, VueScriptInstance } from '@unhead/vue';
|
|
3
3
|
import type { ComputedRef, Ref } from 'vue';
|
|
4
4
|
import type { InferInput, ObjectSchema } from 'valibot';
|
|
5
5
|
import type { Import } from 'unimport';
|
|
@@ -21,8 +21,8 @@ import type { LemonSqueezyInput } from './registry/lemon-squeezy.js';
|
|
|
21
21
|
import type { GoogleAdsenseInput } from './registry/google-adsense.js';
|
|
22
22
|
import type { ClarityInput } from './registry/clarity.js';
|
|
23
23
|
import type { CrispInput } from './registry/crisp.js';
|
|
24
|
-
import type {
|
|
25
|
-
import type {
|
|
24
|
+
import type { GoogleAnalyticsInput } from './registry/google-analytics.js';
|
|
25
|
+
import type { GoogleTagManagerInput } from './registry/google-tag-manager.js';
|
|
26
26
|
export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'> & {
|
|
27
27
|
/**
|
|
28
28
|
* The trigger to load the script:
|
|
@@ -44,6 +44,25 @@ export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'>
|
|
|
44
44
|
* loading the actual script and not getting warnings.
|
|
45
45
|
*/
|
|
46
46
|
skipValidation?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
performanceMarkFeature?: string;
|
|
51
|
+
/**
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
devtools?: {
|
|
55
|
+
/**
|
|
56
|
+
* Key used to map to the registry script for Nuxt DevTools.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
registryKey?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Extra metadata to show with the registry script
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
registryMeta?: Record<string, string>;
|
|
65
|
+
};
|
|
47
66
|
};
|
|
48
67
|
export type NuxtUseScriptOptionsSerializable = Omit<NuxtUseScriptOptions, 'use' | 'skipValidation' | 'stub' | 'trigger' | 'eventContext' | 'beforeInit'> & {
|
|
49
68
|
trigger?: 'client' | 'server' | 'onNuxtReady';
|
|
@@ -65,8 +84,9 @@ export interface ConsentScriptTriggerOptions {
|
|
|
65
84
|
*/
|
|
66
85
|
postConsentTrigger?: NuxtUseScriptOptions['trigger'];
|
|
67
86
|
}
|
|
68
|
-
export interface
|
|
69
|
-
|
|
87
|
+
export interface NuxtDevToolsScriptInstance {
|
|
88
|
+
registryKey?: string;
|
|
89
|
+
registryMeta?: Record<string, string>;
|
|
70
90
|
src: string;
|
|
71
91
|
$script: VueScriptInstance<any>;
|
|
72
92
|
events: {
|
|
@@ -106,10 +126,22 @@ export type NuxtConfigScriptRegistry<T extends keyof ScriptRegistry = keyof Scri
|
|
|
106
126
|
}>;
|
|
107
127
|
declare const emptyOptions: ObjectSchema<{}, undefined>;
|
|
108
128
|
export type EmptyOptionsSchema = typeof emptyOptions;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
type ScriptInput = ScriptBase & DataKeys & SchemaAugmentations['script'];
|
|
130
|
+
export type RegistryScriptInput<T extends ObjectSchema<any, any> = EmptyOptionsSchema, Bundelable extends boolean = true, Usable extends boolean = false, CanBypassOptions extends boolean = true> = (InferInput<T> & {
|
|
131
|
+
/**
|
|
132
|
+
* A unique key to use for the script, this can be used to load multiple of the same script with different options.
|
|
133
|
+
*/
|
|
134
|
+
key?: string;
|
|
135
|
+
scriptInput?: ScriptInput;
|
|
136
|
+
scriptOptions?: Omit<NuxtUseScriptOptions, Bundelable extends true ? '' : 'bundle' | Usable extends true ? '' : 'use'>;
|
|
137
|
+
}) | Partial<InferInput<T>> & (CanBypassOptions extends true ? {
|
|
138
|
+
/**
|
|
139
|
+
* A unique key to use for the script, this can be used to load multiple of the same script with different options.
|
|
140
|
+
*/
|
|
141
|
+
key?: string;
|
|
142
|
+
scriptInput: Required<Pick<ScriptInput, 'src'>> & ScriptInput;
|
|
143
|
+
scriptOptions?: Omit<NuxtUseScriptOptions, Bundelable extends true ? '' : 'bundle' | Usable extends true ? '' : 'use'>;
|
|
144
|
+
} : never);
|
|
113
145
|
export interface RegistryScript {
|
|
114
146
|
import?: Import;
|
|
115
147
|
scriptBundling?: false | ((options?: any) => string | false);
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type OptionsFn<O extends ObjectSchema<any, any>> = (options: InferInput<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, any> = EmptyOptionsSchema>(
|
|
11
|
+
export declare function useRegistryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any, any> = EmptyOptionsSchema>(registryKey: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): T & {
|
|
12
12
|
$script: Promise<T> & VueScriptInstance<T>;
|
|
13
13
|
};
|
|
14
14
|
export {};
|
package/dist/runtime/utils.js
CHANGED
|
@@ -15,15 +15,31 @@ function validateScriptInputSchema(key, schema, options) {
|
|
|
15
15
|
export function scriptRuntimeConfig(key) {
|
|
16
16
|
return (useRuntimeConfig().public.scripts || {})[key];
|
|
17
17
|
}
|
|
18
|
-
export function useRegistryScript(
|
|
19
|
-
const scriptConfig = scriptRuntimeConfig(
|
|
18
|
+
export function useRegistryScript(registryKey, optionsFn, _userOptions) {
|
|
19
|
+
const scriptConfig = scriptRuntimeConfig(registryKey);
|
|
20
20
|
const userOptions = Object.assign(_userOptions || {}, typeof scriptConfig === "object" ? scriptConfig : {});
|
|
21
21
|
const options = optionsFn(userOptions);
|
|
22
|
-
const scriptInput = defu(userOptions.scriptInput, options.scriptInput, { key });
|
|
22
|
+
const scriptInput = defu(userOptions.scriptInput, options.scriptInput, { key: registryKey });
|
|
23
23
|
const scriptOptions = Object.assign(userOptions?.scriptOptions || {}, options.scriptOptions || {});
|
|
24
|
+
if (import.meta.dev) {
|
|
25
|
+
scriptOptions.devtools = defu(scriptOptions.devtools, { registryKey });
|
|
26
|
+
if (options.schema) {
|
|
27
|
+
const registryMeta = {};
|
|
28
|
+
for (const k in options.schema.entries) {
|
|
29
|
+
if (options.schema.entries[k].type !== "optional") {
|
|
30
|
+
registryMeta[k] = String(userOptions[k]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
scriptOptions.devtools.registryMeta = registryMeta;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
24
36
|
const init = scriptOptions.beforeInit;
|
|
25
37
|
scriptOptions.beforeInit = () => {
|
|
26
|
-
import.meta.dev && !scriptOptions.skipValidation && options.schema
|
|
38
|
+
if (import.meta.dev && !scriptOptions.skipValidation && options.schema) {
|
|
39
|
+
if (!userOptions.scriptInput?.src) {
|
|
40
|
+
validateScriptInputSchema(registryKey, options.schema, userOptions);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
27
43
|
init?.();
|
|
28
44
|
if (import.meta.client) {
|
|
29
45
|
options.clientInit?.();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/scripts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.5",
|
|
5
5
|
"packageManager": "pnpm@9.5.0",
|
|
6
6
|
"description": "Load third-party scripts with better performance, privacy and DX in Nuxt Apps.",
|
|
7
7
|
"author": {
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"lint": "eslint .",
|
|
49
49
|
"lint:fix": "eslint . --fix",
|
|
50
50
|
"test": "vitest",
|
|
51
|
-
"test:types": "npx nuxi typecheck"
|
|
51
|
+
"test:types": "npx nuxi typecheck",
|
|
52
|
+
"script:generate-tpc": "bun ./scripts/generateTpcScripts.ts && pnpm lint:fix"
|
|
52
53
|
},
|
|
53
54
|
"build": {
|
|
54
55
|
"externals": [
|
|
@@ -59,8 +60,8 @@
|
|
|
59
60
|
"third-party-capital",
|
|
60
61
|
"knitwork",
|
|
61
62
|
"estree-walker",
|
|
62
|
-
"#build/nuxt-scripts
|
|
63
|
-
"#build/nuxt-scripts
|
|
63
|
+
"#build/modules/nuxt-scripts-gtm",
|
|
64
|
+
"#build/modules/nuxt-scripts-ga",
|
|
64
65
|
"@vimeo/player",
|
|
65
66
|
"esbuild"
|
|
66
67
|
]
|
|
@@ -73,9 +74,8 @@
|
|
|
73
74
|
"@types/stripe-v3": "^3.1.33",
|
|
74
75
|
"@types/vimeo__player": "^2.18.3",
|
|
75
76
|
"@types/youtube": "^0.0.50",
|
|
76
|
-
"@unhead/vue": "^1.9.
|
|
77
|
+
"@unhead/vue": "^1.9.16",
|
|
77
78
|
"@vueuse/core": "^10.11.0",
|
|
78
|
-
"acorn": "^8.12.1",
|
|
79
79
|
"consola": "^3.2.3",
|
|
80
80
|
"defu": "^6.1.4",
|
|
81
81
|
"h3": "^1.12.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"shiki": "^1.10.3",
|
|
90
90
|
"sirv": "^2.0.4",
|
|
91
91
|
"std-env": "^3.7.0",
|
|
92
|
-
"third-party-capital": "^1.
|
|
92
|
+
"third-party-capital": "^2.1.1",
|
|
93
93
|
"ufo": "^1.5.3",
|
|
94
94
|
"unimport": "^3.7.2",
|
|
95
95
|
"unplugin": "^1.11.0",
|
|
@@ -103,11 +103,11 @@
|
|
|
103
103
|
"@nuxt/test-utils": "3.13.1",
|
|
104
104
|
"@types/semver": "^7.5.8",
|
|
105
105
|
"@typescript-eslint/typescript-estree": "^7.16.0",
|
|
106
|
-
"@unhead/schema": "^1.9.
|
|
106
|
+
"@unhead/schema": "^1.9.16",
|
|
107
107
|
"acorn-loose": "^8.4.0",
|
|
108
108
|
"bumpp": "^9.4.1",
|
|
109
109
|
"changelogen": "^0.5.5",
|
|
110
|
-
"eslint": "9.
|
|
110
|
+
"eslint": "9.7.0",
|
|
111
111
|
"eslint-plugin-n": "^17.9.0",
|
|
112
112
|
"knitwork": "^1.1.0",
|
|
113
113
|
"nuxt": "^3.12.3",
|
|
@@ -123,6 +123,7 @@
|
|
|
123
123
|
"nuxt": "^3.12.3",
|
|
124
124
|
"nuxt-scripts-devtools": "workspace:*",
|
|
125
125
|
"vue": "^3.4.31",
|
|
126
|
-
"vue-router": "^4.4.0"
|
|
126
|
+
"vue-router": "^4.4.0",
|
|
127
|
+
"shiki": "1.10.3"
|
|
127
128
|
}
|
|
128
|
-
}
|
|
129
|
+
}
|