@nuxt/scripts 0.6.3 → 0.6.4
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 +8 -8
- package/dist/client/404.html +8 -8
- package/dist/client/_nuxt/{BeuDC-PU.js → B8kiEHWd.js} +11 -11
- package/dist/client/_nuxt/{zTM8DS5E.js → CE8XWCBP.js} +1 -1
- package/dist/client/_nuxt/{DZ6siU6J.js → DUCgB8kF.js} +1 -1
- package/dist/client/_nuxt/{Cg8NGlPg.js → DX8FDaDx.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/a56fe5f5-907d-4907-9967-836d6a0f3850.json +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 +8 -8
- package/dist/module.json +1 -1
- package/dist/module.mjs +84 -279
- package/dist/registry.mjs +33 -0
- package/dist/runtime/composables/useScript.js +1 -1
- package/dist/runtime/registry/clarity.js +1 -1
- package/dist/runtime/registry/cloudflare-web-analytics.js +1 -1
- package/dist/runtime/registry/crisp.d.ts +1 -1
- package/dist/runtime/registry/crisp.js +1 -1
- package/dist/runtime/registry/fathom-analytics.d.ts +1 -1
- package/dist/runtime/registry/fathom-analytics.js +1 -1
- package/dist/runtime/registry/google-adsense.d.ts +1 -1
- package/dist/runtime/registry/google-adsense.js +1 -1
- package/dist/runtime/registry/google-analytics.d.ts +13 -0
- package/dist/runtime/registry/google-analytics.js +31 -0
- package/dist/runtime/registry/google-maps.js +1 -1
- package/dist/runtime/registry/google-tag-manager.d.ts +13 -0
- package/dist/runtime/registry/google-tag-manager.js +27 -0
- package/dist/runtime/registry/hotjar.d.ts +1 -1
- package/dist/runtime/registry/hotjar.js +1 -1
- package/dist/runtime/registry/intercom.d.ts +1 -1
- package/dist/runtime/registry/intercom.js +1 -1
- package/dist/runtime/registry/lemon-squeezy.js +1 -1
- package/dist/runtime/registry/matomo-analytics.d.ts +1 -1
- package/dist/runtime/registry/matomo-analytics.js +1 -1
- package/dist/runtime/registry/meta-pixel.d.ts +1 -1
- package/dist/runtime/registry/meta-pixel.js +1 -1
- package/dist/runtime/registry/npm.d.ts +1 -1
- package/dist/runtime/registry/npm.js +1 -1
- package/dist/runtime/registry/plausible-analytics.js +1 -1
- package/dist/runtime/registry/segment.js +1 -1
- package/dist/runtime/registry/stripe.js +1 -1
- package/dist/runtime/registry/vimeo-player.js +1 -1
- package/dist/runtime/registry/x-pixel.d.ts +1 -1
- package/dist/runtime/registry/x-pixel.js +1 -1
- package/dist/runtime/registry/youtube-player.js +1 -1
- package/dist/runtime/types.d.ts +23 -7
- package/dist/runtime/utils.js +5 -1
- package/package.json +10 -9
- package/dist/client/_nuxt/builds/meta/9996546f-d612-4447-9ee7-fc387b136ee4.json +0 -1
- package/dist/client/_nuxt/error-404.DXyehy0d.css +0 -1
- package/dist/client/_nuxt/error-500.a_92Fvyl.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as a,o as s,c as i,a as e,t as o,b as u,w as c,d,e as l,p,f as h}from"./
|
|
1
|
+
import{_ as a,o as s,c as i,a as e,t as o,b as u,w as c,d,e as l,p,f as h}from"./B8kiEHWd.js";import{u as b}from"./DUCgB8kF.js";const f=t=>(p("data-v-b7913e95"),t=t(),h(),t),g={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},x=f(()=>e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),m={class:"max-w-520px text-center z-20"},y=["textContent"],_=["textContent"],k={class:"w-full flex items-center justify-center"},w={__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 n=t;return b({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[],style:[{children:'*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}h1{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,p{margin:0}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(z,S)=>{const r=l;return s(),i("div",g,[x,e("div",m,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:o(t.statusCode)},null,8,y),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:o(t.description)},null,8,_),e("div",k,[u(r,{to:"/",class:"gradient-border text-md sm:text-xl py-2 px-4 sm:py-3 sm:px-6 cursor-pointer"},{default:c(()=>[d(o(t.backHome),1)]),_:1})])])])}}},N=a(w,[["__scopeId","data-v-b7913e95"]]);export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as o,r as u,g as f,h as d,j as v,k as l,l as i,m as h,n as m}from"./
|
|
1
|
+
import{i as o,r as u,g as f,h as d,j as v,k as l,l as i,m as h,n as m}from"./B8kiEHWd.js";function U(t,a={}){const e=a.head||o();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});f(()=>{n.value=s.value?{}:h(a)});const r=t.push(n.value,e);return d(n,c=>{r.patch(c)}),m()&&(v(()=>{r.dispose()}),l(()=>{s.value=!0}),i(()=>{s.value=!1})),r}export{U as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as o}from"./
|
|
1
|
+
import{u as o}from"./DUCgB8kF.js";import{_ as a,o as s,c as i,a as e,t as r,p as u,f as c}from"./B8kiEHWd.js";const l=t=>(u("data-v-4ec72d76"),t=t(),c(),t),d={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},p=l(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),h={class:"max-w-520px text-center"},g=["textContent"],b=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const n=t;return o({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[],style:[{children:'*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(m,x)=>(s(),i("div",d,[p,e("div",h,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:r(t.statusCode)},null,8,g),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:r(t.description)},null,8,b)])]))}},w=a(f,[["__scopeId","data-v-4ec72d76"]]);export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"a56fe5f5-907d-4907-9967-836d6a0f3850","timestamp":1721024892769}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"a56fe5f5-907d-4907-9967-836d6a0f3850","timestamp":1721024892769,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-b7913e95]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-b7913e95]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-b7913e95]{background-color:#ffffff4d}.gradient-border[data-v-b7913e95]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-b7913e95]{background-color:#1414144d}.gradient-border[data-v-b7913e95]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-b7913e95]:before{background-size:400% auto;border-radius:.5rem;bottom:0;content:"";left:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:.5;padding:2px;position:absolute;right:0;top:0;transition:background-position .3s ease-in-out,opacity .2s ease-in-out;width:100%}.gradient-border[data-v-b7913e95]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-b7913e95]{position:fixed}.left-0[data-v-b7913e95]{left:0}.right-0[data-v-b7913e95]{right:0}.z-10[data-v-b7913e95]{z-index:10}.z-20[data-v-b7913e95]{z-index:20}.grid[data-v-b7913e95]{display:grid}.mb-16[data-v-b7913e95]{margin-bottom:4rem}.mb-8[data-v-b7913e95]{margin-bottom:2rem}.max-w-520px[data-v-b7913e95]{max-width:520px}.min-h-screen[data-v-b7913e95]{min-height:100vh}.w-full[data-v-b7913e95]{width:100%}.flex[data-v-b7913e95]{display:flex}.cursor-pointer[data-v-b7913e95]{cursor:pointer}.place-content-center[data-v-b7913e95]{place-content:center}.items-center[data-v-b7913e95]{align-items:center}.justify-center[data-v-b7913e95]{justify-content:center}.overflow-hidden[data-v-b7913e95]{overflow:hidden}.bg-white[data-v-b7913e95]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-b7913e95]{padding-left:1rem;padding-right:1rem}.px-8[data-v-b7913e95]{padding-left:2rem;padding-right:2rem}.py-2[data-v-b7913e95]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-b7913e95]{text-align:center}.text-8xl[data-v-b7913e95]{font-size:6rem;line-height:1}.text-xl[data-v-b7913e95]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-b7913e95]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-b7913e95]{font-weight:300}.font-medium[data-v-b7913e95]{font-weight:500}.leading-tight[data-v-b7913e95]{line-height:1.25}.font-sans[data-v-b7913e95]{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}.antialiased[data-v-b7913e95]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-b7913e95]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-b7913e95]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-b7913e95]{padding-left:0;padding-right:0}.sm\:px-6[data-v-b7913e95]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-b7913e95]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-b7913e95]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-b7913e95]{font-size:1.25rem;line-height:1.75rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-4ec72d76]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-4ec72d76]{position:fixed}.-bottom-1\/2[data-v-4ec72d76]{bottom:-50%}.left-0[data-v-4ec72d76]{left:0}.right-0[data-v-4ec72d76]{right:0}.grid[data-v-4ec72d76]{display:grid}.mb-16[data-v-4ec72d76]{margin-bottom:4rem}.mb-8[data-v-4ec72d76]{margin-bottom:2rem}.h-1\/2[data-v-4ec72d76]{height:50%}.max-w-520px[data-v-4ec72d76]{max-width:520px}.min-h-screen[data-v-4ec72d76]{min-height:100vh}.place-content-center[data-v-4ec72d76]{place-content:center}.overflow-hidden[data-v-4ec72d76]{overflow:hidden}.bg-white[data-v-4ec72d76]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-4ec72d76]{padding-left:2rem;padding-right:2rem}.text-center[data-v-4ec72d76]{text-align:center}.text-8xl[data-v-4ec72d76]{font-size:6rem;line-height:1}.text-xl[data-v-4ec72d76]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-4ec72d76]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-4ec72d76]{font-weight:300}.font-medium[data-v-4ec72d76]{font-weight:500}.leading-tight[data-v-4ec72d76]{line-height:1.25}.font-sans[data-v-4ec72d76]{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}.antialiased[data-v-4ec72d76]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-4ec72d76]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-4ec72d76]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-4ec72d76]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-4ec72d76]{font-size:2.25rem;line-height:2.5rem}}
|
package/dist/client/index.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html><html data-capo=""><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.DvGwvmL9.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/B8kiEHWd.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/BigF1UXR.js">
|
|
7
7
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CowR2XfX.js">
|
|
@@ -257,10 +257,10 @@
|
|
|
257
257
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/B3g-KkBK.js">
|
|
258
258
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/Bxkoe-BC.js">
|
|
259
259
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/Br6ll-O0.js">
|
|
260
|
-
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-404.
|
|
261
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
262
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
263
|
-
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-500.
|
|
264
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
265
|
-
<script type="module" src="/__nuxt-scripts/_nuxt/
|
|
266
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"
|
|
260
|
+
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-404.-RjlvToe.css">
|
|
261
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CE8XWCBP.js">
|
|
262
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DUCgB8kF.js">
|
|
263
|
+
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-500.Bz7LXgZy.css">
|
|
264
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DX8FDaDx.js">
|
|
265
|
+
<script type="module" src="/__nuxt-scripts/_nuxt/B8kiEHWd.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
|
|
266
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"a56fe5f5-907d-4907-9967-836d6a0f3850",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useNuxt, useLogger, addDevServerHandler, createResolver, addTemplate, tryUseNuxt, logger as logger$1,
|
|
1
|
+
import { useNuxt, useLogger, addDevServerHandler, createResolver, addTemplate, tryUseNuxt, logger as logger$1, defineNuxtModule, addImportsDir, addComponentsDir, addImports, addPluginTemplate, addBuildPlugin, hasNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
|
|
3
3
|
import { lt } from 'semver';
|
|
4
4
|
import { resolvePath } from 'mlly';
|
|
5
|
-
import { join, relative
|
|
5
|
+
import { join, relative } from 'pathe';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
|
-
import { pathToFileURL } from 'node:url';
|
|
8
7
|
import { createUnplugin } from 'unplugin';
|
|
9
|
-
import { parseURL, parseQuery, joinURL, hasProtocol } from 'ufo';
|
|
10
8
|
import MagicString from 'magic-string';
|
|
11
9
|
import { walk } from 'estree-walker';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
11
|
+
import { parseURL, parseQuery, joinURL, hasProtocol } from 'ufo';
|
|
12
12
|
import fsp from 'node:fs/promises';
|
|
13
13
|
import { lazyEventHandler, eventHandler, createError } from 'h3';
|
|
14
14
|
import { fetch } from 'ofetch';
|
|
@@ -19,10 +19,7 @@ import { createStorage } from 'unstorage';
|
|
|
19
19
|
import fsDriver from 'unstorage/drivers/fs-lite';
|
|
20
20
|
import { isCI, provider } from 'std-env';
|
|
21
21
|
import { registry } from './registry.mjs';
|
|
22
|
-
import
|
|
23
|
-
import { genTypeImport, genImport } from 'knitwork';
|
|
24
|
-
import { parse } from 'acorn';
|
|
25
|
-
import { transform } from 'esbuild';
|
|
22
|
+
import 'third-party-capital';
|
|
26
23
|
|
|
27
24
|
const DEVTOOLS_UI_ROUTE = "/__nuxt-scripts";
|
|
28
25
|
const DEVTOOLS_UI_LOCAL_PORT = 3300;
|
|
@@ -67,20 +64,39 @@ function setupDevToolsUI(options, resolve, nuxt = useNuxt()) {
|
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
66
|
|
|
67
|
+
function isVue(id, opts = {}) {
|
|
68
|
+
const { search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
69
|
+
if (id.endsWith(".vue") && !search) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (!search) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const query = parseQuery(search);
|
|
76
|
+
if (query.nuxt_component) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (query.macro && (search === "?macro=true" || !opts.type || opts.type.includes("script"))) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const type = "setup" in query ? "script" : query.type;
|
|
83
|
+
if (!("vue" in query) || opts.type && !opts.type.includes(type)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
const JS_RE = /\.(?:[cm]?j|t)sx?$/;
|
|
89
|
+
function isJS(id) {
|
|
90
|
+
const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
91
|
+
return JS_RE.test(pathname);
|
|
92
|
+
}
|
|
93
|
+
|
|
70
94
|
function NuxtScriptBundleTransformer(options) {
|
|
71
95
|
return createUnplugin(() => {
|
|
72
96
|
return {
|
|
73
97
|
name: "nuxt:scripts:bundler-transformer",
|
|
74
98
|
transformInclude(id) {
|
|
75
|
-
|
|
76
|
-
const { type } = parseQuery(search);
|
|
77
|
-
if (pathname.includes("node_modules/@unhead") || pathname.includes("node_modules/vueuse"))
|
|
78
|
-
return false;
|
|
79
|
-
if (pathname.endsWith(".vue") && (type === "script" || !search))
|
|
80
|
-
return true;
|
|
81
|
-
if (pathname.match(/\.((c|m)?j|t)sx?$/g))
|
|
82
|
-
return true;
|
|
83
|
-
return false;
|
|
99
|
+
return isVue(id, { type: ["template", "script"] }) || isJS(id);
|
|
84
100
|
},
|
|
85
101
|
async transform(code, id) {
|
|
86
102
|
if (!code.includes("useScript"))
|
|
@@ -362,269 +378,58 @@ function installNuxtModule(name, options) {
|
|
|
362
378
|
}, { rootDir: nuxt.options.rootDir, searchPaths: nuxt.options.modulesDir, ...options });
|
|
363
379
|
}
|
|
364
380
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const mainScriptOptions = getScriptInputOption(mainScript);
|
|
375
|
-
const imports = /* @__PURE__ */ new Set([
|
|
376
|
-
"import { withQuery } from 'ufo'",
|
|
377
|
-
"import { useRegistryScript } from '#nuxt-scripts-utils'",
|
|
378
|
-
"import type { RegistryScriptInput } from '#nuxt-scripts'",
|
|
379
|
-
"import type { VueScriptInstance } from '@unhead/vue'"
|
|
380
|
-
]);
|
|
381
|
-
const chunks = [];
|
|
382
|
-
const functionBody = [];
|
|
383
|
-
const hasParams = mainScript.params?.length;
|
|
384
|
-
if (input.tpcTypeImport) {
|
|
385
|
-
imports.add(genTypeImport(await resolvePath("third-party-capital", {
|
|
386
|
-
url: import.meta.url
|
|
387
|
-
}), [input.tpcTypeImport]));
|
|
388
|
-
}
|
|
389
|
-
if (hasParams) {
|
|
390
|
-
imports.add(genImport("#nuxt-scripts-validator", ["object", "any"]));
|
|
391
|
-
chunks.push(`const OptionSchema = object({${mainScript.params?.map((p) => `${p}: any()`)}})`);
|
|
392
|
-
}
|
|
393
|
-
chunks.push(`
|
|
394
|
-
declare global {
|
|
395
|
-
interface Window extends ${input.tpcTypeImport} {}
|
|
396
|
-
}`);
|
|
397
|
-
const clientInitCode = [];
|
|
398
|
-
if (input.data.stylesheets) {
|
|
399
|
-
if (!functionBody.includes(INJECTHEAD_CODE)) {
|
|
400
|
-
functionBody.unshift(INJECTHEAD_CODE);
|
|
401
|
-
}
|
|
402
|
-
functionBody.push(`${HEAD_VAR}.push({link: ${JSON.stringify(input.data.stylesheets.map((s) => ({ ref: "stylesheet", href: s })))}})`);
|
|
403
|
-
}
|
|
404
|
-
for (const script of input.data.scripts) {
|
|
405
|
-
if ("code" in script)
|
|
406
|
-
clientInitCode.push(replaceTokenToRuntime(script.code));
|
|
407
|
-
if (script === mainScript)
|
|
408
|
-
continue;
|
|
409
|
-
if ("url" in script) {
|
|
410
|
-
functionBody.push(`${HEAD_VAR}.push({scripts:{ async: true, src: ${script.url} }},${JSON.stringify(getScriptInputOption(script))})`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
chunks.push(`export type Input = RegistryScriptInput${hasParams ? "<typeof OptionSchema>" : ""}`);
|
|
414
|
-
chunks.push(`
|
|
415
|
-
export function ${input.scriptFunctionName}<T extends ${input.tpcTypeImport}>(_options?: Input): T & {
|
|
416
|
-
$script: Promise<T> & VueScriptInstance<T>;
|
|
417
|
-
} {
|
|
418
|
-
${functionBody.join("\n")}
|
|
419
|
-
return useRegistryScript${hasParams ? "<T, typeof OptionSchema>" : ""}('${input.tpcKey}', options => ({
|
|
420
|
-
scriptInput: {
|
|
421
|
-
src: withQuery('${mainScript.url}', {${mainScript.params?.map((p) => `${p}: options?.${p}`)}})
|
|
422
|
-
},
|
|
423
|
-
${nuxt.options.dev ? "schema: OptionSchema," : ""}
|
|
424
|
-
scriptOptions: {
|
|
425
|
-
use: ${input.use.toString()},
|
|
426
|
-
stub: import.meta.client ? undefined : ${input.stub.toString()},
|
|
427
|
-
${mainScriptOptions ? `...(${JSON.stringify(mainScriptOptions)})` : ""}
|
|
428
|
-
},
|
|
429
|
-
${clientInitCode.length ? `clientInit: import.meta.server ? undefined : () => {${clientInitCode.join("\n")}},` : ""}
|
|
430
|
-
}), _options)
|
|
431
|
-
}`);
|
|
432
|
-
chunks.unshift(...Array.from(imports));
|
|
433
|
-
return chunks.join("\n");
|
|
434
|
-
}
|
|
435
|
-
function replaceTokenToRuntime(code) {
|
|
436
|
-
return code.split(";").map((c) => c.replaceAll(/'?\{\{(.*?)\}\}'?/g, "options.$1")).join(";");
|
|
437
|
-
}
|
|
438
|
-
function getScriptInputOption(script) {
|
|
439
|
-
if (script.location === "body") {
|
|
440
|
-
if (script.action === "append") {
|
|
441
|
-
return { tagPosition: "bodyClose" };
|
|
442
|
-
}
|
|
443
|
-
return { tagPosition: "bodyOpen" };
|
|
444
|
-
}
|
|
445
|
-
if (script.action === "append") {
|
|
446
|
-
return { tagPriority: 1 };
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function googleAnalitycsRegistry(scripts) {
|
|
451
|
-
const { dst } = addTemplate({
|
|
452
|
-
getContents() {
|
|
453
|
-
return getTpcScriptContent({
|
|
454
|
-
data: GooglaAnalyticsData,
|
|
455
|
-
scriptFunctionName: "useScriptGoogleAnalytics",
|
|
456
|
-
use: () => {
|
|
457
|
-
return { dataLayer: window.dataLayer, gtag: window.gtag };
|
|
458
|
-
},
|
|
459
|
-
// allow dataLayer to be accessed on the server
|
|
460
|
-
stub: ({ fn }) => {
|
|
461
|
-
return fn === "dataLayer" ? [] : void 0;
|
|
462
|
-
},
|
|
463
|
-
tpcKey: "gtag",
|
|
464
|
-
tpcTypeImport: "GoogleAnalyticsApi"
|
|
465
|
-
});
|
|
466
|
-
},
|
|
467
|
-
filename: "nuxt-scripts/tpc/google-analytics.ts",
|
|
468
|
-
write: true
|
|
469
|
-
});
|
|
470
|
-
addImports({
|
|
471
|
-
from: dst,
|
|
472
|
-
name: "useScriptGoogleAnalytics"
|
|
473
|
-
});
|
|
474
|
-
const registry = {
|
|
475
|
-
label: "Google Tag Manager",
|
|
476
|
-
category: "tracking",
|
|
477
|
-
logo: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#8AB4F8" d="m150.262 245.516l-44.437-43.331l95.433-97.454l46.007 45.091z"/><path fill="#4285F4" d="M150.45 53.938L106.176 8.731L9.36 104.629c-12.48 12.48-12.48 32.713 0 45.207l95.36 95.986l45.09-42.182l-72.654-76.407z"/><path fill="#8AB4F8" d="m246.625 105.37l-96-96c-12.494-12.494-32.756-12.494-45.25 0c-12.495 12.495-12.495 32.757 0 45.252l96 96c12.494 12.494 32.756 12.494 45.25 0c12.495-12.495 12.495-32.757 0-45.251"/><circle cx="127.265" cy="224.731" r="31.273" fill="#246FDB"/></svg>`,
|
|
478
|
-
import: {
|
|
479
|
-
name: "useScriptGoogleAnalytics",
|
|
480
|
-
from: dst
|
|
481
|
-
},
|
|
482
|
-
scriptBundling(options) {
|
|
483
|
-
const data = GoogleAnalytics(options);
|
|
484
|
-
const mainScript = data.scripts?.find(({ key }) => key === "gtag");
|
|
485
|
-
if (mainScript && "url" in mainScript && mainScript.url)
|
|
486
|
-
return mainScript.url;
|
|
487
|
-
return false;
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
scripts.push(registry);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function googleTagManagerRegistry(scripts) {
|
|
494
|
-
const { dst } = addTemplate({
|
|
495
|
-
getContents() {
|
|
496
|
-
return getTpcScriptContent({
|
|
497
|
-
data: GoogleTagManagerData,
|
|
498
|
-
scriptFunctionName: "useScriptGoogleTagManager",
|
|
499
|
-
use: () => {
|
|
500
|
-
return { dataLayer: window.dataLayer, google_tag_manager: window.google_tag_manager };
|
|
501
|
-
},
|
|
502
|
-
stub: ({ fn }) => {
|
|
503
|
-
return fn === "dataLayer" ? [] : void 0;
|
|
504
|
-
},
|
|
505
|
-
tpcKey: "gtm",
|
|
506
|
-
tpcTypeImport: "GoogleTagManagerApi"
|
|
507
|
-
});
|
|
508
|
-
},
|
|
509
|
-
filename: "nuxt-scripts/tpc/google-tag-manager.ts",
|
|
510
|
-
write: true
|
|
511
|
-
});
|
|
512
|
-
addImports({
|
|
513
|
-
from: dst,
|
|
514
|
-
name: "useScriptGoogleTagManager"
|
|
515
|
-
});
|
|
516
|
-
const registry = {
|
|
517
|
-
label: "Google Tag Manager",
|
|
518
|
-
category: "tracking",
|
|
519
|
-
logo: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#8AB4F8" d="m150.262 245.516l-44.437-43.331l95.433-97.454l46.007 45.091z"/><path fill="#4285F4" d="M150.45 53.938L106.176 8.731L9.36 104.629c-12.48 12.48-12.48 32.713 0 45.207l95.36 95.986l45.09-42.182l-72.654-76.407z"/><path fill="#8AB4F8" d="m246.625 105.37l-96-96c-12.494-12.494-32.756-12.494-45.25 0c-12.495 12.495-12.495 32.757 0 45.252l96 96c12.494 12.494 32.756 12.494 45.25 0c12.495-12.495 12.495-32.757 0-45.251"/><circle cx="127.265" cy="224.731" r="31.273" fill="#246FDB"/></svg>`,
|
|
520
|
-
import: {
|
|
521
|
-
name: "useScriptGoogleTagManager",
|
|
522
|
-
from: dst
|
|
523
|
-
},
|
|
524
|
-
scriptBundling(options) {
|
|
525
|
-
const data = GoogleTagManager(options);
|
|
526
|
-
const mainScript = data.scripts?.find(({ key }) => key === "gtm");
|
|
527
|
-
if (mainScript && "url" in mainScript && mainScript.url)
|
|
528
|
-
return mainScript.url;
|
|
529
|
-
return false;
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
scripts.push(registry);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
const SCRIPT_RE = /<script[^>]*>([\s\S]*)<\/script>/;
|
|
536
|
-
const checkScripts = () => createUnplugin(() => {
|
|
537
|
-
return {
|
|
538
|
-
name: "nuxt-scripts:check-scripts",
|
|
539
|
-
enforce: "pre",
|
|
540
|
-
async transform(code, id) {
|
|
541
|
-
if (!code.includes("useScript"))
|
|
542
|
-
return;
|
|
543
|
-
const extName = extname(id);
|
|
544
|
-
if (extName === ".vue") {
|
|
545
|
-
const scriptAst = await extractScriptContentAst(code);
|
|
546
|
-
if (scriptAst) {
|
|
547
|
-
analyzeNodes(id, scriptAst);
|
|
548
|
-
}
|
|
549
|
-
} else if (extName === ".ts" || extName === ".js") {
|
|
550
|
-
if (!code.includes("defineComponent"))
|
|
381
|
+
function NuxtScriptsCheckScripts() {
|
|
382
|
+
return createUnplugin(() => {
|
|
383
|
+
return {
|
|
384
|
+
name: "nuxt-scripts:check-scripts",
|
|
385
|
+
transformInclude(id) {
|
|
386
|
+
return isVue(id, { type: ["script"] });
|
|
387
|
+
},
|
|
388
|
+
async transform(code) {
|
|
389
|
+
if (!code.includes("useScript"))
|
|
551
390
|
return;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
function isAwaitingLoad(name, node) {
|
|
591
|
-
if (node.type === "ExpressionStatement" && node.expression.type === "AwaitExpression") {
|
|
592
|
-
const arg = node.expression.argument;
|
|
593
|
-
if (arg.type === "CallExpression") {
|
|
594
|
-
const callee = arg.callee;
|
|
595
|
-
if (callee.type === "MemberExpression" && callee.object.type === "Identifier" && callee.object.name === name) {
|
|
596
|
-
if (callee.property.type === "Identifier" && callee.property.name === "load") {
|
|
597
|
-
return true;
|
|
391
|
+
const ast = this.parse(code);
|
|
392
|
+
let nameNode;
|
|
393
|
+
let errorNode;
|
|
394
|
+
walk(ast, {
|
|
395
|
+
enter(_node) {
|
|
396
|
+
if (_node.type === "VariableDeclaration" && _node.declarations?.[0]?.id?.type === "ObjectPattern") {
|
|
397
|
+
const objPattern = _node.declarations[0]?.id;
|
|
398
|
+
for (const property of objPattern.properties) {
|
|
399
|
+
if (property.type === "Property" && property.key.type === "Identifier" && property.key.name === "$script" && property.value.type === "Identifier") {
|
|
400
|
+
nameNode = _node;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (nameNode) {
|
|
405
|
+
let sequence = _node.type === "SequenceExpression" ? _node : null;
|
|
406
|
+
let assignmentExpression;
|
|
407
|
+
if (_node.type === "VariableDeclaration") {
|
|
408
|
+
if (_node.declarations[0]?.init?.type === "SequenceExpression") {
|
|
409
|
+
sequence = _node.declarations[0]?.init;
|
|
410
|
+
assignmentExpression = _node.declarations[0]?.init?.expressions?.[0];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (sequence && !assignmentExpression) {
|
|
414
|
+
assignmentExpression = sequence.expressions[0]?.type === "AssignmentExpression" ? sequence.expressions[0] : null;
|
|
415
|
+
}
|
|
416
|
+
if (assignmentExpression) {
|
|
417
|
+
const right = assignmentExpression?.right;
|
|
418
|
+
if (right.callee?.name === "_withAsyncContext") {
|
|
419
|
+
if (right.arguments[0]?.body?.name === "$script" || right.arguments[0]?.body?.callee?.object?.name === "$script") {
|
|
420
|
+
errorNode = nameNode;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
if (errorNode) {
|
|
428
|
+
return this.error(new Error("You can't use a top-level await on $script as it will never resolve."));
|
|
598
429
|
}
|
|
599
430
|
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
async function extractScriptContentAst(code) {
|
|
604
|
-
const scriptCode = code.match(SCRIPT_RE);
|
|
605
|
-
return scriptCode ? parse((await transform(scriptCode[1], { loader: "ts" })).code, {
|
|
606
|
-
ecmaVersion: "latest",
|
|
607
|
-
sourceType: "module"
|
|
608
|
-
}).body : void 0;
|
|
609
|
-
}
|
|
610
|
-
function extractSetupFunction(code) {
|
|
611
|
-
const ast = parse(code, {
|
|
612
|
-
ecmaVersion: "latest",
|
|
613
|
-
sourceType: "module"
|
|
431
|
+
};
|
|
614
432
|
});
|
|
615
|
-
const defaultExport = ast.body.find((node) => node.type === "ExportDefaultDeclaration");
|
|
616
|
-
if (defaultExport && defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.callee.type === "Identifier" && defaultExport.declaration.callee.name === "defineComponent") {
|
|
617
|
-
const arg = defaultExport.declaration.arguments[0];
|
|
618
|
-
if (arg && arg.type === "ObjectExpression") {
|
|
619
|
-
const setupProperty = arg.properties.find((prop) => prop.type === "Property" && prop.key.type === "Identifier" && prop.key.name === "setup");
|
|
620
|
-
if (setupProperty) {
|
|
621
|
-
const setupValue = setupProperty.value;
|
|
622
|
-
if (setupValue.type === "FunctionExpression") {
|
|
623
|
-
return setupValue.body.body;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
433
|
}
|
|
629
434
|
|
|
630
435
|
function templatePlugin(config, registry) {
|
|
@@ -699,7 +504,6 @@ const module = defineNuxtModule({
|
|
|
699
504
|
return;
|
|
700
505
|
}
|
|
701
506
|
}
|
|
702
|
-
addBuildPlugin(checkScripts());
|
|
703
507
|
nuxt.options.alias["#nuxt-scripts-validator"] = resolve(`./runtime/validation/${nuxt.options.dev || nuxt.options._prepare ? "valibot" : "mock"}`);
|
|
704
508
|
nuxt.options.alias["#nuxt-scripts"] = resolve("./runtime/types");
|
|
705
509
|
nuxt.options.alias["#nuxt-scripts-utils"] = resolve("./runtime/utils");
|
|
@@ -719,8 +523,6 @@ const module = defineNuxtModule({
|
|
|
719
523
|
path: resolve("./runtime/components")
|
|
720
524
|
});
|
|
721
525
|
const scripts = registry(resolve);
|
|
722
|
-
googleAnalitycsRegistry(scripts);
|
|
723
|
-
googleTagManagerRegistry(scripts);
|
|
724
526
|
nuxt.hooks.hook("modules:done", async () => {
|
|
725
527
|
const registryScripts = [...scripts];
|
|
726
528
|
await nuxt.hooks.callHook("scripts:registry", registryScripts);
|
|
@@ -771,6 +573,9 @@ ${newScripts.map((i) => {
|
|
|
771
573
|
const scriptMap = /* @__PURE__ */ new Map();
|
|
772
574
|
const { normalizeScriptData } = setupPublicAssetStrategy(config.assets);
|
|
773
575
|
const moduleInstallPromises = /* @__PURE__ */ new Map();
|
|
576
|
+
addBuildPlugin(NuxtScriptsCheckScripts(), {
|
|
577
|
+
dev: true
|
|
578
|
+
});
|
|
774
579
|
addBuildPlugin(NuxtScriptBundleTransformer({
|
|
775
580
|
scripts: registryScriptsWithImport,
|
|
776
581
|
defaultBundle: config.defaultScriptOptions?.bundle,
|
package/dist/registry.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { joinURL, withQuery, withBase } from 'ufo';
|
|
2
|
+
import { GoogleTagManager, GoogleAnalytics } from 'third-party-capital';
|
|
2
3
|
|
|
3
4
|
const registry = (resolve) => {
|
|
4
5
|
resolve = resolve || ((s) => s);
|
|
@@ -219,6 +220,38 @@ const registry = (resolve) => {
|
|
|
219
220
|
// key is based on package name
|
|
220
221
|
from: resolve("./runtime/registry/npm")
|
|
221
222
|
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
label: "Google Tag Manager",
|
|
226
|
+
category: "tracking",
|
|
227
|
+
import: {
|
|
228
|
+
name: "useScriptGoogleTagManager",
|
|
229
|
+
from: resolve("./runtime/registry/google-tag-manager")
|
|
230
|
+
},
|
|
231
|
+
logo: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#8AB4F8" d="m150.262 245.516l-44.437-43.331l95.433-97.454l46.007 45.091z"/><path fill="#4285F4" d="M150.45 53.938L106.176 8.731L9.36 104.629c-12.48 12.48-12.48 32.713 0 45.207l95.36 95.986l45.09-42.182l-72.654-76.407z"/><path fill="#8AB4F8" d="m246.625 105.37l-96-96c-12.494-12.494-32.756-12.494-45.25 0c-12.495 12.495-12.495 32.757 0 45.252l96 96c12.494 12.494 32.756 12.494 45.25 0c12.495-12.495 12.495-32.757 0-45.251"/><circle cx="127.265" cy="224.731" r="31.273" fill="#246FDB"/></svg>`,
|
|
232
|
+
scriptBundling(options) {
|
|
233
|
+
const data = GoogleTagManager(options);
|
|
234
|
+
const mainScript = data.scripts?.find(({ key }) => key === "gtag");
|
|
235
|
+
if (mainScript && "url" in mainScript && mainScript.url)
|
|
236
|
+
return mainScript.url;
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
label: "Google Analytics",
|
|
242
|
+
category: "tracking",
|
|
243
|
+
import: {
|
|
244
|
+
name: "useScriptGoogleAnalytics",
|
|
245
|
+
from: resolve("./runtime/registry/google-analytics")
|
|
246
|
+
},
|
|
247
|
+
logo: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#8AB4F8" d="m150.262 245.516l-44.437-43.331l95.433-97.454l46.007 45.091z"/><path fill="#4285F4" d="M150.45 53.938L106.176 8.731L9.36 104.629c-12.48 12.48-12.48 32.713 0 45.207l95.36 95.986l45.09-42.182l-72.654-76.407z"/><path fill="#8AB4F8" d="m246.625 105.37l-96-96c-12.494-12.494-32.756-12.494-45.25 0c-12.495 12.495-12.495 32.757 0 45.252l96 96c12.494 12.494 32.756 12.494 45.25 0c12.495-12.495 12.495-32.757 0-45.251"/><circle cx="127.265" cy="224.731" r="31.273" fill="#246FDB"/></svg>`,
|
|
248
|
+
scriptBundling(options) {
|
|
249
|
+
const data = GoogleAnalytics(options);
|
|
250
|
+
const mainScript = data.scripts?.find(({ key }) => key === "gtag");
|
|
251
|
+
if (mainScript && "url" in mainScript && mainScript.url)
|
|
252
|
+
return mainScript.url;
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
222
255
|
}
|
|
223
256
|
];
|
|
224
257
|
};
|
|
@@ -14,7 +14,7 @@ export const CloudflareWebAnalyticsOptions = object({
|
|
|
14
14
|
spa: optional(boolean())
|
|
15
15
|
});
|
|
16
16
|
export function useScriptCloudflareWebAnalytics(_options) {
|
|
17
|
-
return useRegistryScript("cloudflareWebAnalytics", (options) => ({
|
|
17
|
+
return useRegistryScript(_options?.key || "cloudflareWebAnalytics", (options) => ({
|
|
18
18
|
scriptInput: {
|
|
19
19
|
"src": "https://static.cloudflareinsights.com/beacon.min.js",
|
|
20
20
|
"data-cf-beacon": JSON.stringify({ token: options.token, spa: options.spa || true }),
|
|
@@ -31,7 +31,7 @@ export declare const CrispOptions: import("valibot").ObjectSchema<{
|
|
|
31
31
|
*/
|
|
32
32
|
readonly cookieExpiry: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
|
|
33
33
|
}, undefined>;
|
|
34
|
-
export type CrispInput = RegistryScriptInput<typeof CrispOptions, false>;
|
|
34
|
+
export type CrispInput = RegistryScriptInput<typeof CrispOptions, false, false, false>;
|
|
35
35
|
export interface CrispApi {
|
|
36
36
|
push: (...args: any[]) => void;
|
|
37
37
|
is: (name: 'chat:opened' | 'chat:closed' | 'chat:visible' | 'chat:hidden' | 'chat:small' | 'chat:large' | 'session:ongoing' | 'website:available' | 'overlay:opened' | 'overlay:closed' | string) => boolean;
|
|
@@ -34,7 +34,7 @@ export const CrispOptions = object({
|
|
|
34
34
|
});
|
|
35
35
|
export function useScriptCrisp(_options) {
|
|
36
36
|
let readyPromise = Promise.resolve();
|
|
37
|
-
return useRegistryScript("crisp", (options) => ({
|
|
37
|
+
return useRegistryScript(_options?.key || "crisp", (options) => ({
|
|
38
38
|
scriptInput: {
|
|
39
39
|
src: "https://client.crisp.chat/l.js"
|
|
40
40
|
// can't be bundled
|
|
@@ -21,7 +21,7 @@ export declare const FathomAnalyticsOptions: import("valibot").ObjectSchema<{
|
|
|
21
21
|
*/
|
|
22
22
|
readonly honorDnt: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
23
23
|
}, undefined>;
|
|
24
|
-
export type FathomAnalyticsInput = RegistryScriptInput<typeof FathomAnalyticsOptions, false>;
|
|
24
|
+
export type FathomAnalyticsInput = RegistryScriptInput<typeof FathomAnalyticsOptions, false, false, false>;
|
|
25
25
|
export interface FathomAnalyticsApi {
|
|
26
26
|
beacon: (ctx: {
|
|
27
27
|
url: string;
|