@nuxt/scripts 0.1.8 → 0.1.10
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/dist/client/200.html +5 -5
- package/dist/client/404.html +5 -5
- package/dist/client/_nuxt/{C1pJ9hYW.js → B3NxZ4PD.js} +1 -1
- package/dist/client/_nuxt/{g1vjzT4-.js → CvC-oELr.js} +3 -3
- package/dist/client/_nuxt/{q7Jwi_Zr.js → RJMmSfsq.js} +1 -1
- package/dist/client/_nuxt/{DXzaZVCR.js → ZTTBuPuP.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/a3528c6a-ce16-4b1c-ac03-cae330707f80.json +1 -0
- package/dist/client/index.html +5 -5
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +108 -33
- package/dist/runtime/registry/cloudflare-turnstile.d.ts +1 -1
- package/dist/runtime/registry/cloudflare-turnstile.mjs +2 -1
- package/dist/runtime/registry/cloudflare-web-analytics.d.ts +3 -2
- package/dist/runtime/registry/cloudflare-web-analytics.mjs +1 -0
- package/dist/runtime/registry/confetti.d.ts +6 -5
- package/dist/runtime/registry/confetti.mjs +1 -1
- package/dist/runtime/registry/facebook-pixel.d.ts +3 -2
- package/dist/runtime/registry/facebook-pixel.mjs +1 -0
- package/dist/runtime/registry/fathom-analytics.d.ts +3 -2
- package/dist/runtime/registry/fathom-analytics.mjs +1 -0
- package/dist/runtime/registry/google-analytics.d.ts +1 -1
- package/dist/runtime/registry/google-analytics.mjs +2 -1
- package/dist/runtime/registry/google-maps.d.ts +1 -0
- package/dist/runtime/registry/google-maps.mjs +4 -0
- package/dist/runtime/registry/google-tag-manager.d.ts +1 -1
- package/dist/runtime/registry/google-tag-manager.mjs +2 -1
- package/dist/runtime/registry/hotjar.d.ts +2 -2
- package/dist/runtime/registry/hotjar.mjs +1 -0
- package/dist/runtime/registry/intercom.d.ts +2 -2
- package/dist/runtime/registry/intercom.mjs +1 -0
- package/dist/runtime/registry/segment.d.ts +2 -2
- package/dist/runtime/registry/segment.mjs +1 -0
- package/dist/runtime/types.d.ts +18 -15
- package/dist/runtime/utils.d.ts +1 -0
- package/dist/runtime/utils.mjs +5 -0
- package/package.json +2 -1
- package/dist/client/_nuxt/builds/meta/455b7639-d5f9-4fc1-8526-80b72d2c69a6.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as u,r as c,f,g as v,h as d,j as l,k as i,l as h,m as p}from"./
|
|
1
|
+
import{i as u,r as c,f,g as v,h as d,j as l,k as i,l as h,m as p}from"./CvC-oELr.js";function g(t,a={}){const e=a.head||u();if(e)return e.ssr?e.push(t,a):m(e,t,a)}function m(t,a,e={}){const s=c(!1),n=c({});f(()=>{n.value=s.value?{}:h(a)});const r=t.push(n.value,e);return v(n,o=>{r.patch(o)}),p()&&(d(()=>{r.dispose()}),l(()=>{s.value=!0}),i(()=>{s.value=!1})),r}const I=(t,a)=>{const e=t.__vccOpts||t;for(const[s,n]of a)e[s]=n;return e};export{I as _,g as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as a,c as n,a as e,t as s,b as r,w as l,d,_ as c,p,e as m}from"./
|
|
1
|
+
import{o as a,c as n,a as e,t as s,b as r,w as l,d,_ as c,p,e as m}from"./CvC-oELr.js";import{_ as f,u as h}from"./RJMmSfsq.js";const x=t=>(p("data-v-05a2b8a3"),t=t(),m(),t),u={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},g=x(()=>e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),b={class:"max-w-520px text-center z-20"},_=["textContent"],w=["textContent"],y={class:"w-full flex items-center justify-center"},S={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Not Found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const o=t;return h({title:`${o.statusCode} - ${o.statusMessage} | ${o.appName}`,script:[],style:[{children:'*,:before,:after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e0e0e0}*{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(14, 165, 233, .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}a{color:inherit;text-decoration:inherit}body{margin:0;font-family:inherit;line-height:inherit}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5}h1,p{margin:0}h1{font-size:inherit;font-weight:inherit}'}]}),(k,N)=>{const i=c;return a(),n("div",u,[g,e("div",b,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,_),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:s(t.description)},null,8,w),e("div",y,[r(i,{to:"/",class:"gradient-border text-md sm:text-xl py-2 px-4 sm:py-3 sm:px-6 cursor-pointer"},{default:l(()=>[d(s(t.backHome),1)]),_:1})])])])}}},C=f(S,[["__scopeId","data-v-05a2b8a3"]]);export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"a3528c6a-ce16-4b1c-ac03-cae330707f80","timestamp":1712109015496}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"a3528c6a-ce16-4b1c-ac03-cae330707f80","timestamp":1712109015496,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html><html><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
3
|
<link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.D91GVkD7.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CvC-oELr.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DXFkqnOI.js">
|
|
6
6
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/D6NljDpC.js">
|
|
7
7
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CowR2XfX.js">
|
|
@@ -230,10 +230,10 @@
|
|
|
230
230
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DggdVF2v.js">
|
|
231
231
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/A1WiD9SJ.js">
|
|
232
232
|
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-404.ORekjfyJ.css">
|
|
233
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
234
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
233
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/ZTTBuPuP.js">
|
|
234
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/RJMmSfsq.js">
|
|
235
235
|
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-500.BIuFL0tW.css">
|
|
236
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
237
|
-
<script type="module" src="/__nuxt-scripts/_nuxt/
|
|
236
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/B3NxZ4PD.js">
|
|
237
|
+
<script type="module" src="/__nuxt-scripts/_nuxt/CvC-oELr.js" crossorigin></script><script>"use strict";(()=>{const a=window,e=document.documentElement,c=window.localStorage,d=["dark","light"],n=c&&c.getItem&&c.getItem("nuxt-color-mode")||"system";let l=n==="system"?f():n;const i=e.getAttribute("data-color-mode-forced");i&&(l=i),r(l),a["__NUXT_COLOR_MODE__"]={preference:n,value:l,getColorScheme:f,addColorScheme:r,removeColorScheme:u};function r(o){const t=""+o+"",s="";e.classList?e.classList.add(t):e.className+=" "+t,s&&e.setAttribute("data-"+s,o)}function u(o){const t=""+o+"",s="";e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp(t,"g"),""),s&&e.removeAttribute("data-"+s)}function m(o){return a.matchMedia("(prefers-color-scheme"+o+")")}function f(){if(a.matchMedia&&m("").media!=="not all"){for(const o of d)if(m(":"+o).matches)return o}return"light"}})();
|
|
238
238
|
</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4,"once":5},{},false,{},{},["Set"]]</script>
|
|
239
239
|
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -49,7 +49,7 @@ interface ModuleHooks {
|
|
|
49
49
|
/**
|
|
50
50
|
* Transform a script before it's registered.
|
|
51
51
|
*/
|
|
52
|
-
'scripts:registry': (registry: RegistryScripts) => Promise<void>;
|
|
52
|
+
'scripts:registry': (registry: RegistryScripts) => void | Promise<void>;
|
|
53
53
|
}
|
|
54
54
|
declare const _default: nuxt_schema.NuxtModule<ModuleOptions>;
|
|
55
55
|
|
package/dist/module.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ interface ModuleHooks {
|
|
|
49
49
|
/**
|
|
50
50
|
* Transform a script before it's registered.
|
|
51
51
|
*/
|
|
52
|
-
'scripts:registry': (registry: RegistryScripts) => Promise<void>;
|
|
52
|
+
'scripts:registry': (registry: RegistryScripts) => void | Promise<void>;
|
|
53
53
|
}
|
|
54
54
|
declare const _default: nuxt_schema.NuxtModule<ModuleOptions>;
|
|
55
55
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useNuxt, useLogger, addDevServerHandler, createResolver, addTemplate, defineNuxtModule, addImportsDir, addImports, addPlugin, addBuildPlugin } from '@nuxt/kit';
|
|
2
|
-
import { readPackageJSON } from 'pkg-types';
|
|
1
|
+
import { useNuxt, useLogger, addDevServerHandler, createResolver, addTemplate, logger as logger$1, defineNuxtModule, addImportsDir, addImports, addPlugin, addBuildPlugin, hasNuxtModule } from '@nuxt/kit';
|
|
2
|
+
import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
|
|
3
3
|
import { parseURL, parseQuery, joinURL, hasProtocol, withQuery, withBase } from 'ufo';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import { pathToFileURL } from 'node:url';
|
|
@@ -15,6 +15,7 @@ import { join, relative } from 'pathe';
|
|
|
15
15
|
import { hash } from 'ohash';
|
|
16
16
|
import { createStorage } from 'unstorage';
|
|
17
17
|
import fsDriver from 'unstorage/drivers/fs-lite';
|
|
18
|
+
import { isCI, provider } from 'std-env';
|
|
18
19
|
|
|
19
20
|
const DEVTOOLS_UI_ROUTE = "/__nuxt-scripts";
|
|
20
21
|
const DEVTOOLS_UI_LOCAL_PORT = 3030;
|
|
@@ -106,6 +107,7 @@ function NuxtScriptAssetBundlerTransformer(options) {
|
|
|
106
107
|
console.warn(`[Nuxt Scripts] Integration ${fnName} not found in registry. Used in ${id}.`);
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
110
|
+
options.moduleDetected(registryNode.module);
|
|
109
111
|
if (!registryNode.transform && !registryNode.src)
|
|
110
112
|
return;
|
|
111
113
|
const optionsNode = node.arguments[0];
|
|
@@ -118,10 +120,13 @@ function NuxtScriptAssetBundlerTransformer(options) {
|
|
|
118
120
|
const srcProperty = node.arguments[0].properties.find(
|
|
119
121
|
(p) => p.key?.name === "src" || p.key?.value === "src"
|
|
120
122
|
);
|
|
121
|
-
if (srcProperty?.value?.value)
|
|
123
|
+
if (srcProperty?.value?.value) {
|
|
122
124
|
scriptSrcNode = srcProperty.value;
|
|
123
|
-
else
|
|
125
|
+
} else {
|
|
124
126
|
src = registryNode.src || registryNode.transform?.(fnArg0);
|
|
127
|
+
if (src === false)
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
125
130
|
scriptKey = registryNode.key;
|
|
126
131
|
}
|
|
127
132
|
}
|
|
@@ -271,7 +276,7 @@ function extendTypes(module, template) {
|
|
|
271
276
|
const nuxt = useNuxt();
|
|
272
277
|
const { resolve } = createResolver(import.meta.url);
|
|
273
278
|
addTemplate({
|
|
274
|
-
filename: `modules/${module}.d.ts`,
|
|
279
|
+
filename: `modules/${module.replace("/", "-")}.d.ts`,
|
|
275
280
|
getContents: async () => {
|
|
276
281
|
const typesPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types"));
|
|
277
282
|
const s = await template({ typesPath });
|
|
@@ -285,6 +290,43 @@ export {}
|
|
|
285
290
|
references.push({ path: resolve(nuxt.options.buildDir, `module/${module}.d.ts`) });
|
|
286
291
|
});
|
|
287
292
|
}
|
|
293
|
+
const isStackblitz = provider === "stackblitz";
|
|
294
|
+
async function promptToInstall(name, installCommand, options) {
|
|
295
|
+
if (await resolvePackageJSON(name, { url: options.searchPaths }).catch(() => null))
|
|
296
|
+
return true;
|
|
297
|
+
logger$1.info(`Package ${name} is missing`);
|
|
298
|
+
if (isCI)
|
|
299
|
+
return false;
|
|
300
|
+
if (options.prompt === true || options.prompt !== false && !isStackblitz) {
|
|
301
|
+
const confirm = await logger$1.prompt(`Do you want to install ${name} package?`, {
|
|
302
|
+
type: "confirm",
|
|
303
|
+
name: "confirm",
|
|
304
|
+
initial: true
|
|
305
|
+
});
|
|
306
|
+
if (!confirm)
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
logger$1.info(`Installing ${name}...`);
|
|
310
|
+
try {
|
|
311
|
+
await installCommand();
|
|
312
|
+
logger$1.success(`Installed ${name}`);
|
|
313
|
+
return true;
|
|
314
|
+
} catch (err) {
|
|
315
|
+
logger$1.error(err);
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const installPrompts = /* @__PURE__ */ new Set();
|
|
320
|
+
function installNuxtModule(name, options) {
|
|
321
|
+
if (installPrompts.has(name))
|
|
322
|
+
return;
|
|
323
|
+
installPrompts.add(name);
|
|
324
|
+
const nuxt = useNuxt();
|
|
325
|
+
return promptToInstall(name, async () => {
|
|
326
|
+
const { runCommand } = await import(String("nuxi"));
|
|
327
|
+
await runCommand("module", ["add", name, "--cwd", nuxt.options.rootDir]);
|
|
328
|
+
}, { rootDir: nuxt.options.rootDir, searchPaths: nuxt.options.modulesDir, ...options });
|
|
329
|
+
}
|
|
288
330
|
|
|
289
331
|
const module = defineNuxtModule({
|
|
290
332
|
meta: {
|
|
@@ -318,12 +360,7 @@ const module = defineNuxtModule({
|
|
|
318
360
|
resolve("./runtime/composables")
|
|
319
361
|
]);
|
|
320
362
|
nuxt.hooks.hook("modules:done", async () => {
|
|
321
|
-
|
|
322
|
-
{
|
|
323
|
-
name: "useScriptCloudflareTurnstile",
|
|
324
|
-
key: "cloudflareTurnstile",
|
|
325
|
-
from: resolve("./runtime/registry/cloudflare-turnstile")
|
|
326
|
-
},
|
|
363
|
+
let registry = [
|
|
327
364
|
{
|
|
328
365
|
name: "useScriptCloudflareWebAnalytics",
|
|
329
366
|
key: "cloudflareWebAnalytics",
|
|
@@ -346,17 +383,8 @@ const module = defineNuxtModule({
|
|
|
346
383
|
name: "useScriptFathomAnalytics",
|
|
347
384
|
key: "fathomAnalytics",
|
|
348
385
|
from: resolve("./runtime/registry/fathom-analytics"),
|
|
349
|
-
src:
|
|
350
|
-
|
|
351
|
-
{
|
|
352
|
-
name: "useScriptGoogleAnalytics",
|
|
353
|
-
key: "googleAnalytics",
|
|
354
|
-
from: resolve("./runtime/registry/google-analytics")
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
name: "useScriptGoogleTagManager",
|
|
358
|
-
key: "googleTagmanager",
|
|
359
|
-
from: resolve("./runtime/registry/google-tag-manager")
|
|
386
|
+
src: false
|
|
387
|
+
// can not be bundled, breaks script
|
|
360
388
|
},
|
|
361
389
|
{
|
|
362
390
|
name: "useScriptHotjar",
|
|
@@ -391,16 +419,62 @@ const module = defineNuxtModule({
|
|
|
391
419
|
transform(options) {
|
|
392
420
|
return withBase(options?.file || "", `https://unpkg.com/${options?.packageName || ""}@${options?.version || "latest"}`);
|
|
393
421
|
}
|
|
422
|
+
},
|
|
423
|
+
// cloudflare turnstile
|
|
424
|
+
{
|
|
425
|
+
name: "useScriptCloudflareTurnstile",
|
|
426
|
+
key: "cloudflareTurnstile",
|
|
427
|
+
from: resolve("./runtime/registry/cloudflare-turnstile"),
|
|
428
|
+
module: "nuxt-turnstile"
|
|
429
|
+
},
|
|
430
|
+
// third-party-capital
|
|
431
|
+
{
|
|
432
|
+
name: "useScriptGoogleAnalytics",
|
|
433
|
+
key: "googleAnalytics",
|
|
434
|
+
from: resolve("./runtime/registry/google-analytics"),
|
|
435
|
+
module: "@nuxt/third-party-capital"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: "useScriptGoogleTagManager",
|
|
439
|
+
key: "googleTagManager",
|
|
440
|
+
from: resolve("./runtime/registry/google-tag-manager"),
|
|
441
|
+
module: "@nuxt/third-party-capital"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: "useScriptGoogleMaps",
|
|
445
|
+
key: "googleMaps",
|
|
446
|
+
from: resolve("./runtime/registry/google-tag-manager"),
|
|
447
|
+
module: "@nuxt/third-party-capital"
|
|
394
448
|
}
|
|
395
|
-
]
|
|
449
|
+
];
|
|
450
|
+
registry = registry.map((i) => {
|
|
396
451
|
i.priority = -1;
|
|
452
|
+
i.module = i.module || "@nuxt/scripts";
|
|
397
453
|
return i;
|
|
398
454
|
});
|
|
399
455
|
addImports(registry);
|
|
400
456
|
await nuxt.hooks.callHook("scripts:registry", registry);
|
|
457
|
+
extendTypes(name, async ({ typesPath }) => {
|
|
458
|
+
return `
|
|
459
|
+
declare module '#app' {
|
|
460
|
+
interface NuxtApp {
|
|
461
|
+
${nuxt.options.dev ? `_scripts: (import('#nuxt-scripts').NuxtAppScript)[]` : ""}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
declare module '#nuxt-scripts' {
|
|
465
|
+
type NuxtUseScriptOptions = Omit<import('${typesPath}').NuxtUseScriptOptions, 'use' | 'beforeInit'>
|
|
466
|
+
interface ScriptRegistry {
|
|
467
|
+
${registry.filter((i) => i.key && i.module !== "@nuxt/scripts").map((i) => {
|
|
468
|
+
const ucFirstKey = i.key.substring(0, 1).toUpperCase() + i.key.substring(1);
|
|
469
|
+
return ` ${i.key}?: import('${i.from}').${ucFirstKey}Input | [import('${i.from}').${ucFirstKey}Input, NuxtUseScriptOptions]`;
|
|
470
|
+
}).join("\n")}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
`;
|
|
474
|
+
});
|
|
401
475
|
if (config.globals?.length || Object.keys(config.register || {}).length) {
|
|
402
476
|
const template = addTemplate({
|
|
403
|
-
filename: `modules/${name}.mjs`,
|
|
477
|
+
filename: `modules/${name.replace("/", "-")}.mjs`,
|
|
404
478
|
write: true,
|
|
405
479
|
getContents() {
|
|
406
480
|
const imports = ["useScript", "defineNuxtPlugin"];
|
|
@@ -428,9 +502,14 @@ ${(config.globals || []).map((g) => !Array.isArray(g) ? ` useScript("${g.toSt
|
|
|
428
502
|
}
|
|
429
503
|
const scriptMap = /* @__PURE__ */ new Map();
|
|
430
504
|
const { normalizeScriptData } = setupPublicAssetStrategy(config.assets);
|
|
505
|
+
const moduleInstallPromises = /* @__PURE__ */ new Map();
|
|
431
506
|
addBuildPlugin(NuxtScriptAssetBundlerTransformer({
|
|
432
507
|
registry,
|
|
433
508
|
defaultBundle: config.defaultScriptOptions?.assetStrategy === "bundle",
|
|
509
|
+
moduleDetected(module) {
|
|
510
|
+
if (module !== "@nuxt/scripts" && !moduleInstallPromises.has(module) && !hasNuxtModule(module))
|
|
511
|
+
moduleInstallPromises.set(module, () => installNuxtModule(module));
|
|
512
|
+
},
|
|
434
513
|
resolveScript(src) {
|
|
435
514
|
if (scriptMap.has(src))
|
|
436
515
|
return scriptMap.get(src);
|
|
@@ -439,15 +518,11 @@ ${(config.globals || []).map((g) => !Array.isArray(g) ? ` useScript("${g.toSt
|
|
|
439
518
|
return url;
|
|
440
519
|
}
|
|
441
520
|
}));
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
${nuxt.options.dev ? `_scripts: (import('#nuxt-scripts').NuxtAppScript)[]` : ""}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
`;
|
|
521
|
+
nuxt.hooks.hook("build:done", async () => {
|
|
522
|
+
const initPromise = Array.from(moduleInstallPromises.values());
|
|
523
|
+
for (const p of initPromise)
|
|
524
|
+
await p?.();
|
|
525
|
+
});
|
|
451
526
|
});
|
|
452
527
|
if (nuxt.options.dev)
|
|
453
528
|
setupDevToolsUI(config, resolve);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useScriptCloudflareTurnstile():
|
|
1
|
+
export declare function useScriptCloudflareTurnstile(): any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mockFallbackScript } from "../utils.mjs";
|
|
1
2
|
export function useScriptCloudflareTurnstile() {
|
|
2
|
-
|
|
3
|
+
return mockFallbackScript("useScriptCloudflareTurnstile", "nuxt-turnstile");
|
|
3
4
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Input } from 'valibot';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
|
|
3
3
|
export interface CloudflareWebAnalyticsApi {
|
|
4
4
|
__cfBeacon: {
|
|
5
5
|
load: 'single';
|
|
@@ -30,4 +30,5 @@ export declare const CloudflareWebAnalyticsOptions: import("valibot").ObjectSche
|
|
|
30
30
|
token: string;
|
|
31
31
|
spa?: boolean | undefined;
|
|
32
32
|
}>;
|
|
33
|
-
export
|
|
33
|
+
export type CloudflareWebAnalyticsInput = Input<typeof CloudflareWebAnalyticsOptions>;
|
|
34
|
+
export declare function useScriptCloudflareWebAnalytics<T extends CloudflareWebAnalyticsApi>(options?: CloudflareWebAnalyticsInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
|
|
@@ -20,6 +20,7 @@ export function useScriptCloudflareWebAnalytics(options, _scriptOptions) {
|
|
|
20
20
|
const scriptOptions = _scriptOptions || {};
|
|
21
21
|
scriptOptions.beforeInit = () => {
|
|
22
22
|
import.meta.dev && validateScriptInputSchema(CloudflareWebAnalyticsOptions, options);
|
|
23
|
+
scriptOptions.beforeInit?.();
|
|
23
24
|
};
|
|
24
25
|
return useScript({
|
|
25
26
|
"src": "https://static.cloudflareinsights.com/beacon.min.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Input } from 'valibot';
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
2
|
+
import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
|
|
3
|
+
export interface ConfettiApi {
|
|
4
4
|
addConfetti: (options?: {
|
|
5
5
|
emojis: string[];
|
|
6
6
|
}) => void;
|
|
@@ -8,15 +8,16 @@ export interface JSConfettiApi {
|
|
|
8
8
|
declare global {
|
|
9
9
|
interface Window {
|
|
10
10
|
JSConfetti: {
|
|
11
|
-
new ():
|
|
11
|
+
new (): ConfettiApi;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const ConfettiOptions: import("valibot").ObjectSchema<Pick<{
|
|
16
16
|
packageName: import("valibot").StringSchema<string>;
|
|
17
17
|
file: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
|
|
18
18
|
version: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
|
|
19
19
|
}, "version">, undefined, {
|
|
20
20
|
version?: string | undefined;
|
|
21
21
|
}>;
|
|
22
|
-
export
|
|
22
|
+
export type ConfettiInput = Input<typeof ConfettiOptions>;
|
|
23
|
+
export declare function useScriptConfetti(options: ConfettiInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pick } from "valibot";
|
|
2
2
|
import { NpmOptions, useScriptNpm } from "./npm.mjs";
|
|
3
|
-
export const
|
|
3
|
+
export const ConfettiOptions = pick(NpmOptions, ["version"]);
|
|
4
4
|
export function useScriptConfetti(options, _scriptOptions = {}) {
|
|
5
5
|
return useScriptNpm({
|
|
6
6
|
packageName: "js-confetti",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Input } from 'valibot';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
|
|
3
3
|
type StandardEvents = 'AddPaymentInfo' | 'AddToCart' | 'AddToWishlist' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'InitiateCheckout' | 'Lead' | 'Purchase' | 'Schedule' | 'Search' | 'StartTrial' | 'SubmitApplication' | 'Subscribe' | 'ViewContent';
|
|
4
4
|
interface EventObjectProperties {
|
|
5
5
|
content_category?: string;
|
|
@@ -38,5 +38,6 @@ export declare const FacebookPixelOptions: import("valibot").ObjectSchema<{
|
|
|
38
38
|
}, undefined, {
|
|
39
39
|
id: string | number;
|
|
40
40
|
}>;
|
|
41
|
-
export
|
|
41
|
+
export type FacebookPixelInput = Input<typeof FacebookPixelOptions>;
|
|
42
|
+
export declare function useScriptFacebookPixel<T extends FacebookPixelApi>(options?: FacebookPixelInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
|
|
42
43
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Input } from 'valibot';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NuxtUseScriptIntegrationOptions } from '#nuxt-scripts';
|
|
3
3
|
export declare const FathomAnalyticsOptions: import("valibot").ObjectSchema<{
|
|
4
4
|
site: import("valibot").StringSchema<string>;
|
|
5
5
|
src: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
|
|
@@ -15,6 +15,7 @@ export declare const FathomAnalyticsOptions: import("valibot").ObjectSchema<{
|
|
|
15
15
|
'data-canonical'?: boolean | undefined;
|
|
16
16
|
'data-honor-dnt'?: boolean | undefined;
|
|
17
17
|
}>;
|
|
18
|
+
export type FathomAnalyticsInput = Input<typeof FathomAnalyticsOptions>;
|
|
18
19
|
export interface FathomAnalyticsApi {
|
|
19
20
|
trackPageview: (ctx?: {
|
|
20
21
|
url: string;
|
|
@@ -29,4 +30,4 @@ declare global {
|
|
|
29
30
|
fathom: FathomAnalyticsApi;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
export declare function useScriptFathomAnalytics<T extends FathomAnalyticsApi>(options?:
|
|
33
|
+
export declare function useScriptFathomAnalytics<T extends FathomAnalyticsApi>(options?: FathomAnalyticsInput, _scriptOptions?: Omit<NuxtUseScriptIntegrationOptions, 'assetStrategy'>): any;
|
|
@@ -13,6 +13,7 @@ export function useScriptFathomAnalytics(options, _scriptOptions) {
|
|
|
13
13
|
const scriptOptions = _scriptOptions || {};
|
|
14
14
|
scriptOptions.beforeInit = () => {
|
|
15
15
|
import.meta.dev && validateScriptInputSchema(FathomAnalyticsOptions, options);
|
|
16
|
+
scriptOptions.beforeInit?.();
|
|
16
17
|
};
|
|
17
18
|
return useScript({
|
|
18
19
|
src: "https://cdn.usefathom.com/script.js",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useScriptGoogleAnalytics():
|
|
1
|
+
export declare function useScriptGoogleAnalytics(): any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mockFallbackScript } from "../utils.mjs";
|
|
1
2
|
export function useScriptGoogleAnalytics() {
|
|
2
|
-
|
|
3
|
+
return mockFallbackScript("useScriptGoogleMaps", "@nuxtjs/third-party-capital");
|
|
3
4
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useScriptGoogleMaps(): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useScriptGoogleTagManager():
|
|
1
|
+
export declare function useScriptGoogleTagManager(): any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mockFallbackScript } from "../utils.mjs";
|
|
1
2
|
export function useScriptGoogleTagManager() {
|
|
2
|
-
|
|
3
|
+
return mockFallbackScript("useScriptGoogleTagManager", "@nuxtjs/third-party-capital");
|
|
3
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NuxtUseScriptIntegrationOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
|
|
2
2
|
export interface HotjarApi {
|
|
3
3
|
hj: ((event: 'identify', userId: string, attributes?: Record<string, any>) => void) & ((event: 'stateChange', path: string) => void) & ((event: 'event', eventName: string) => void) & ((event: string, arg?: string) => void) & ((...params: any[]) => void) & {
|
|
4
4
|
q: any[];
|
|
@@ -20,4 +20,4 @@ export declare const HotjarOptions: import("valibot").ObjectSchema<{
|
|
|
20
20
|
sv?: number | undefined;
|
|
21
21
|
}>;
|
|
22
22
|
export type HotjarInput = ScriptDynamicSrcInput<typeof HotjarOptions>;
|
|
23
|
-
export declare function useScriptHotjar<T extends HotjarApi>(options?: HotjarInput, _scriptOptions?:
|
|
23
|
+
export declare function useScriptHotjar<T extends HotjarApi>(options?: HotjarInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Input } from 'valibot';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NuxtUseScriptIntegrationOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
|
|
3
3
|
export declare const IntercomOptions: import("valibot").ObjectSchema<{
|
|
4
4
|
app_id: import("valibot").StringSchema<string>;
|
|
5
5
|
api_base: import("valibot").OptionalSchema<import("valibot").UnionSchema<(import("valibot").LiteralSchema<"https://api-iam.intercom.io", "https://api-iam.intercom.io"> | import("valibot").LiteralSchema<"https://api-iam.eu.intercom.io", "https://api-iam.eu.intercom.io"> | import("valibot").LiteralSchema<"https://api-iam.au.intercom.io", "https://api-iam.au.intercom.io">)[], "https://api-iam.intercom.io" | "https://api-iam.eu.intercom.io" | "https://api-iam.au.intercom.io">, undefined, "https://api-iam.intercom.io" | "https://api-iam.eu.intercom.io" | "https://api-iam.au.intercom.io" | undefined>;
|
|
@@ -28,4 +28,4 @@ declare global {
|
|
|
28
28
|
intercomSettings?: IntercomInput;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
export declare function useScriptIntercom<T extends IntercomApi>(options?: IntercomInput, _scriptOptions?:
|
|
31
|
+
export declare function useScriptIntercom<T extends IntercomApi>(options?: IntercomInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
|
|
@@ -18,6 +18,7 @@ export function useScriptIntercom(options, _scriptOptions) {
|
|
|
18
18
|
import.meta.dev && validateScriptInputSchema(IntercomOptions, options);
|
|
19
19
|
if (import.meta.client)
|
|
20
20
|
window.intercomSettings = options;
|
|
21
|
+
scriptOptions.beforeInit?.();
|
|
21
22
|
};
|
|
22
23
|
return useScript({
|
|
23
24
|
key: "intercom",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NuxtUseScriptIntegrationOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
|
|
2
2
|
export declare const SegmentOptions: import("valibot").ObjectSchema<{
|
|
3
3
|
writeKey: import("valibot").StringSchema<string>;
|
|
4
4
|
analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
|
|
@@ -21,4 +21,4 @@ declare global {
|
|
|
21
21
|
interface Window extends SegmentApi {
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
export declare function useScriptSegment<T extends SegmentApi>(options?: SegmentInput, _scriptOptions?:
|
|
24
|
+
export declare function useScriptSegment<T extends SegmentApi>(options?: SegmentInput, _scriptOptions?: NuxtUseScriptIntegrationOptions): any;
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ import type { UseScriptInput, VueScriptInstance } from '@unhead/vue';
|
|
|
3
3
|
import type { ComputedRef, Ref } from 'vue';
|
|
4
4
|
import type { Input, ObjectSchema } from 'valibot';
|
|
5
5
|
import type { Import } from 'unimport';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
6
|
+
import type { SegmentInput } from './registry/segment';
|
|
7
|
+
import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics';
|
|
8
|
+
import type { FacebookPixelInput } from './registry/facebook-pixel';
|
|
9
|
+
import type { FathomAnalyticsInput } from './registry/fathom-analytics';
|
|
10
|
+
import type { HotjarInput } from './registry/hotjar';
|
|
11
|
+
import type { IntercomInput } from './registry/intercom';
|
|
12
|
+
import type { ConfettiInput } from './registry/confetti';
|
|
12
13
|
export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'> & {
|
|
13
14
|
/**
|
|
14
15
|
* The trigger to load the script:
|
|
@@ -30,6 +31,7 @@ export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'>
|
|
|
30
31
|
*/
|
|
31
32
|
beforeInit?: () => void;
|
|
32
33
|
};
|
|
34
|
+
export type NuxtUseScriptIntegrationOptions = Omit<NuxtUseScriptOptions, 'use'>;
|
|
33
35
|
export type NuxtUseScriptInput = UseScriptInput;
|
|
34
36
|
export interface TrackedPage {
|
|
35
37
|
title?: string;
|
|
@@ -60,21 +62,22 @@ export interface NuxtAppScript {
|
|
|
60
62
|
at: number;
|
|
61
63
|
}[];
|
|
62
64
|
}
|
|
63
|
-
export type ScriptRegistryEntry<T
|
|
65
|
+
export type ScriptRegistryEntry<T> = T | [T, NuxtUseScriptOptions<T>];
|
|
64
66
|
export interface ScriptRegistry {
|
|
65
|
-
cloudflareWebAnalytics?: ScriptRegistryEntry<
|
|
66
|
-
confetti?: ScriptRegistryEntry<
|
|
67
|
-
facebookPixel?: ScriptRegistryEntry<
|
|
68
|
-
fathomAnalytics?: ScriptRegistryEntry<
|
|
69
|
-
hotjar?: ScriptRegistryEntry<
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
cloudflareWebAnalytics?: ScriptRegistryEntry<CloudflareWebAnalyticsInput>;
|
|
68
|
+
confetti?: ScriptRegistryEntry<ConfettiInput>;
|
|
69
|
+
facebookPixel?: ScriptRegistryEntry<FacebookPixelInput>;
|
|
70
|
+
fathomAnalytics?: ScriptRegistryEntry<FathomAnalyticsInput>;
|
|
71
|
+
hotjar?: ScriptRegistryEntry<HotjarInput>;
|
|
72
|
+
intercom?: ScriptRegistryEntry<IntercomInput>;
|
|
73
|
+
segment?: ScriptRegistryEntry<SegmentInput>;
|
|
72
74
|
}
|
|
73
75
|
export type ScriptDynamicSrcInput<T extends ObjectSchema<any>> = Input<T> & {
|
|
74
76
|
src?: string;
|
|
75
77
|
};
|
|
76
78
|
export type RegistryScripts = (Import & {
|
|
77
|
-
src?: string;
|
|
79
|
+
src?: string | false;
|
|
80
|
+
module?: '@nuxt/scripts' | string;
|
|
78
81
|
key?: string;
|
|
79
82
|
transform?: (options: any) => string;
|
|
80
83
|
})[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mockFallbackScript(name: string, module: string): any;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useScript } from "#imports";
|
|
2
|
+
export function mockFallbackScript(name, module) {
|
|
3
|
+
console.error(`${name} is provided by ${module}. Check your console to install it or run 'npx nuxi@latest module add ${module}'`);
|
|
4
|
+
return useScript("", { trigger: "manual" });
|
|
5
|
+
}
|