@nuxt/scripts 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/client/200.html +7 -6
  2. package/dist/client/404.html +7 -6
  3. package/dist/client/_nuxt/BG_OyJVq.js +1 -0
  4. package/dist/client/_nuxt/{ZXwHJetA.js → BVIyUFBp.js} +3 -3
  5. package/dist/client/_nuxt/{7b-muJBz.js → CV_REd8b.js} +1 -1
  6. package/dist/client/_nuxt/{CFDTW01f.js → D1ek2jBE.js} +1 -1
  7. package/dist/client/_nuxt/DnLUQrgA.js +1 -0
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/b5db882d-dfbd-4edf-87b5-38d1f0a456e3.json +1 -0
  10. package/dist/client/_nuxt/{LZrVsJnT.js → vqIOxd68.js} +1 -1
  11. package/dist/client/index.html +7 -6
  12. package/dist/module.d.mts +3 -6
  13. package/dist/module.d.ts +3 -6
  14. package/dist/module.json +1 -1
  15. package/dist/module.mjs +112 -44
  16. package/dist/runtime/composables/validateScriptInputSchema.d.ts +0 -5
  17. package/dist/runtime/composables/validateScriptInputSchema.mjs +9 -7
  18. package/dist/runtime/registry/cloudflare-web-analytics.mjs +3 -5
  19. package/dist/runtime/registry/facebook-pixel.mjs +3 -4
  20. package/dist/runtime/registry/fathom-analytics.mjs +3 -6
  21. package/dist/runtime/registry/hotjar.d.ts +3 -3
  22. package/dist/runtime/registry/hotjar.mjs +2 -3
  23. package/dist/runtime/registry/intercom.d.ts +4 -3
  24. package/dist/runtime/registry/intercom.mjs +3 -3
  25. package/dist/runtime/registry/npm.d.ts +3 -3
  26. package/dist/runtime/registry/npm.mjs +4 -8
  27. package/dist/runtime/registry/segment.d.ts +3 -3
  28. package/dist/runtime/registry/segment.mjs +2 -3
  29. package/dist/runtime/types.d.ts +12 -1
  30. package/package.json +6 -6
  31. package/dist/client/_nuxt/CkMwVfOK.js +0 -1
  32. package/dist/client/_nuxt/builds/meta/f0a0fb88-29eb-404a-b0c9-7ad64c942608.json +0 -1
@@ -1 +1 @@
1
- import{_ as i,u as a}from"./CFDTW01f.js";import{o as r,c as n,a as e,t as s,p as l,e as d}from"./ZXwHJetA.js";const c=t=>(l("data-v-c967d9a9"),t=t(),d(),t),p={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},h=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),f={class:"max-w-520px text-center"},m=["textContent"],g=["textContent"],x={__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 o=t;return a({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}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}'}]}),(b,u)=>(r(),n("div",p,[h,e("div",f,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,m),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,g)])]))}},y=i(x,[["__scopeId","data-v-c967d9a9"]]);export{y as default};
1
+ import{_ as i,u as a}from"./D1ek2jBE.js";import{o as r,c as n,a as e,t as s,p as l,e as d}from"./BVIyUFBp.js";const c=t=>(l("data-v-c967d9a9"),t=t(),d(),t),p={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},h=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),f={class:"max-w-520px text-center"},m=["textContent"],g=["textContent"],x={__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 o=t;return a({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}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}'}]}),(b,u)=>(r(),n("div",p,[h,e("div",f,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,m),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,g)])]))}},y=i(x,[["__scopeId","data-v-c967d9a9"]]);export{y as default};
@@ -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"./ZXwHJetA.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
+ 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"./BVIyUFBp.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};
@@ -0,0 +1 @@
1
+ const t=Object.freeze({displayName:"TSV",fileTypes:["tsv","tab"],name:"tsv",patterns:[{captures:{1:{name:"rainbow1"},2:{name:"keyword.rainbow2"},3:{name:"entity.name.function.rainbow3"},4:{name:"comment.rainbow4"},5:{name:"string.rainbow5"},6:{name:"variable.parameter.rainbow6"},7:{name:"constant.numeric.rainbow7"},8:{name:"entity.name.type.rainbow8"},9:{name:"markup.bold.rainbow9"},10:{name:"invalid.rainbow10"}},match:"([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)",name:"rainbowgroup"}],scopeName:"text.tsv"});var a=[t];export{a as default};
@@ -1 +1 @@
1
- {"id":"f0a0fb88-29eb-404a-b0c9-7ad64c942608","timestamp":1711884560577}
1
+ {"id":"b5db882d-dfbd-4edf-87b5-38d1f0a456e3","timestamp":1711951597713}
@@ -0,0 +1 @@
1
+ {"id":"b5db882d-dfbd-4edf-87b5-38d1f0a456e3","timestamp":1711951597713,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -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"./ZXwHJetA.js";import{_ as f,u as h}from"./CFDTW01f.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
+ 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"./BVIyUFBp.js";import{_ as f,u as h}from"./D1ek2jBE.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,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/ZXwHJetA.js">
4
+ <link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/BVIyUFBp.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">
@@ -88,7 +88,7 @@
88
88
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DUdlC5k_.js">
89
89
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/C5gCGmDW.js">
90
90
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DAGYewaG.js">
91
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CkMwVfOK.js">
91
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/BG_OyJVq.js">
92
92
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DZqG9GXz.js">
93
93
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DmDrTTlz.js">
94
94
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/BR6CMsBL.js">
@@ -167,6 +167,7 @@
167
167
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/C_8Fx7bH.js">
168
168
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/7fd6vGzb.js">
169
169
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/BT9ZzGyQ.js">
170
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DnLUQrgA.js">
170
171
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DCdPDLy4.js">
171
172
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/I4qd5QHW.js">
172
173
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/C2TBxDwV.js">
@@ -229,10 +230,10 @@
229
230
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DggdVF2v.js">
230
231
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/A1WiD9SJ.js">
231
232
  <link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-404.ORekjfyJ.css">
232
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/LZrVsJnT.js">
233
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CFDTW01f.js">
233
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/vqIOxd68.js">
234
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/D1ek2jBE.js">
234
235
  <link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-500.BIuFL0tW.css">
235
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/7b-muJBz.js">
236
- <script type="module" src="/__nuxt-scripts/_nuxt/ZXwHJetA.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"}})();
236
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CV_REd8b.js">
237
+ <script type="module" src="/__nuxt-scripts/_nuxt/BVIyUFBp.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"}})();
237
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>
238
239
  <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as nuxt_schema from 'nuxt/schema';
2
- import { Import } from 'unimport';
3
- import { ScriptRegistry, NuxtUseScriptOptions, NuxtUseScriptInput } from '#nuxt-scripts';
2
+ import { ScriptRegistry, NuxtUseScriptOptions, NuxtUseScriptInput, RegistryScripts } from '#nuxt-scripts';
4
3
 
5
4
  interface ModuleOptions {
6
5
  /**
@@ -18,9 +17,7 @@ interface ModuleOptions {
18
17
  /**
19
18
  * Override the static script options for specific scripts based on their provided `key` or `src`.
20
19
  */
21
- overrides?: {
22
- [key: string]: Pick<NuxtUseScriptOptions, 'assetStrategy'>;
23
- };
20
+ overrides?: Record<keyof ScriptRegistry, Pick<NuxtUseScriptOptions, 'assetStrategy'>>;
24
21
  /** Configure the way scripts assets are exposed */
25
22
  assets?: {
26
23
  /**
@@ -52,7 +49,7 @@ interface ModuleHooks {
52
49
  /**
53
50
  * Transform a script before it's registered.
54
51
  */
55
- 'scripts:registry': (registry: Import[]) => Promise<void>;
52
+ 'scripts:registry': (registry: RegistryScripts) => Promise<void>;
56
53
  }
57
54
  declare const _default: nuxt_schema.NuxtModule<ModuleOptions>;
58
55
 
package/dist/module.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as nuxt_schema from 'nuxt/schema';
2
- import { Import } from 'unimport';
3
- import { ScriptRegistry, NuxtUseScriptOptions, NuxtUseScriptInput } from '#nuxt-scripts';
2
+ import { ScriptRegistry, NuxtUseScriptOptions, NuxtUseScriptInput, RegistryScripts } from '#nuxt-scripts';
4
3
 
5
4
  interface ModuleOptions {
6
5
  /**
@@ -18,9 +17,7 @@ interface ModuleOptions {
18
17
  /**
19
18
  * Override the static script options for specific scripts based on their provided `key` or `src`.
20
19
  */
21
- overrides?: {
22
- [key: string]: Pick<NuxtUseScriptOptions, 'assetStrategy'>;
23
- };
20
+ overrides?: Record<keyof ScriptRegistry, Pick<NuxtUseScriptOptions, 'assetStrategy'>>;
24
21
  /** Configure the way scripts assets are exposed */
25
22
  assets?: {
26
23
  /**
@@ -52,7 +49,7 @@ interface ModuleHooks {
52
49
  /**
53
50
  * Transform a script before it's registered.
54
51
  */
55
- 'scripts:registry': (registry: Import[]) => Promise<void>;
52
+ 'scripts:registry': (registry: RegistryScripts) => Promise<void>;
56
53
  }
57
54
  declare const _default: nuxt_schema.NuxtModule<ModuleOptions>;
58
55
 
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.11.1",
6
6
  "bridge": false
7
7
  },
8
- "version": "0.1.6"
8
+ "version": "0.1.7"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { useNuxt, useLogger, addDevServerHandler, createResolver, addTemplate, defineNuxtModule, addImportsDir, addImports, addPlugin, addBuildPlugin } from '@nuxt/kit';
2
2
  import { readPackageJSON } from 'pkg-types';
3
+ import { parseURL, parseQuery, joinURL, hasProtocol, withQuery, withBase } from 'ufo';
3
4
  import { existsSync } from 'node:fs';
4
5
  import { pathToFileURL } from 'node:url';
5
6
  import { createUnplugin } from 'unplugin';
6
- import { parseURL, parseQuery, joinURL, hasProtocol } from 'ufo';
7
7
  import MagicString from 'magic-string';
8
8
  import { walk } from 'estree-walker';
9
9
  import fsp from 'node:fs/promises';
@@ -81,42 +81,80 @@ function NuxtScriptAssetBundlerTransformer(options) {
81
81
  const s = new MagicString(code);
82
82
  walk(ast, {
83
83
  enter(_node) {
84
- if (_node.type === "CallExpression" && _node.callee.type === "Identifier" && _node.callee?.name === "useScript") {
84
+ if (_node.type === "CallExpression" && _node.callee.type === "Identifier" && _node.callee?.name.startsWith("useScript")) {
85
+ const fnName = _node.callee?.name;
85
86
  const node = _node;
86
87
  let scriptKey;
87
- let scriptNode;
88
- if (node.arguments[0].type === "Literal") {
89
- scriptNode = node.arguments[0];
90
- scriptKey = scriptNode.value;
91
- } else if (node.arguments[0].type === "ObjectExpression") {
92
- const srcProperty = node.arguments[0].properties.find(
93
- (p) => p.key?.name === "src" || p.key?.value === "src"
94
- );
95
- const keyProperty = node.arguments[0].properties.find(
96
- (p) => p.key?.name === "key" || p.key?.value === "key"
97
- );
98
- scriptKey = keyProperty?.value?.value || srcProperty?.value;
99
- scriptNode = srcProperty?.value;
88
+ let scriptSrcNode;
89
+ let src;
90
+ if (fnName === "useScript") {
91
+ if (node.arguments[0].type === "Literal") {
92
+ scriptSrcNode = node.arguments[0];
93
+ scriptKey = scriptSrcNode.value;
94
+ } else if (node.arguments[0].type === "ObjectExpression") {
95
+ const srcProperty = node.arguments[0].properties.find(
96
+ (p) => p.key?.name === "src" || p.key?.value === "src"
97
+ );
98
+ const keyProperty = node.arguments[0].properties.find(
99
+ (p) => p.key?.name === "key" || p.key?.value === "key"
100
+ );
101
+ scriptKey = keyProperty?.value?.value || srcProperty?.value;
102
+ scriptSrcNode = srcProperty?.value;
103
+ }
104
+ } else {
105
+ const registryNode = options.registry?.find((i) => i.name === fnName);
106
+ if (!registryNode) {
107
+ console.error(`[Nuxt Scripts] Integration ${fnName} not found in registry`);
108
+ return;
109
+ }
110
+ if (!registryNode.transform && !registryNode.src)
111
+ return;
112
+ const optionsNode = node.arguments[0];
113
+ if (optionsNode?.type === "ObjectExpression") {
114
+ const fnArg0 = {};
115
+ for (const prop of optionsNode.properties) {
116
+ if (prop.value.type === "Literal")
117
+ fnArg0[prop.key.name] = prop.value.value;
118
+ }
119
+ const srcProperty = node.arguments[0].properties.find(
120
+ (p) => p.key?.name === "src" || p.key?.value === "src"
121
+ );
122
+ if (srcProperty?.value?.value)
123
+ scriptSrcNode = srcProperty.value;
124
+ else
125
+ src = registryNode.src || registryNode.transform?.(fnArg0);
126
+ scriptKey = registryNode.key;
127
+ }
100
128
  }
101
- if (scriptNode) {
102
- const src = scriptNode.value;
129
+ if (scriptSrcNode || src) {
130
+ src = src || scriptSrcNode.value;
103
131
  if (src) {
104
- let hasAssetStrategy = false;
132
+ let canBundle = options.defaultBundle;
105
133
  if (node.arguments[1]?.type === "ObjectExpression") {
106
134
  const assetStrategyProperty = node.arguments[1]?.properties.find(
107
135
  (p) => p.key?.name === "assetStrategy" || p.key?.value === "assetStrategy"
108
136
  );
109
137
  if (assetStrategyProperty) {
110
- if (assetStrategyProperty?.value?.value !== "bundle")
138
+ if (assetStrategyProperty?.value?.value !== "bundle") {
139
+ canBundle = false;
111
140
  return;
112
- s.remove(assetStrategyProperty.start, assetStrategyProperty.end + 1);
113
- hasAssetStrategy = true;
141
+ }
142
+ if (node.arguments[1]?.properties.length === 1)
143
+ s.remove(node.arguments[1].start, node.arguments[1].end);
144
+ else
145
+ s.remove(assetStrategyProperty.start, assetStrategyProperty.end);
146
+ canBundle = true;
114
147
  }
115
148
  }
116
- hasAssetStrategy = hasAssetStrategy || options.overrides?.[scriptKey]?.assetStrategy === "bundle";
117
- if (hasAssetStrategy) {
149
+ canBundle = canBundle || options.overrides?.[scriptKey]?.assetStrategy === "bundle";
150
+ if (canBundle) {
118
151
  const newSrc = options.resolveScript(src);
119
- s.overwrite(scriptNode.start, scriptNode.end, `'${newSrc}'`);
152
+ if (scriptSrcNode) {
153
+ s.overwrite(scriptSrcNode.start, scriptSrcNode.end, `'${newSrc}'`);
154
+ } else {
155
+ const lastProperty = node.arguments[0].properties[node.arguments[0].properties.length - 1];
156
+ s.appendRight(lastProperty.end, `, src: '${newSrc}'`);
157
+ }
120
158
  }
121
159
  }
122
160
  }
@@ -284,47 +322,76 @@ const module = defineNuxtModule({
284
322
  const registry = [
285
323
  {
286
324
  name: "useScriptCloudflareTurnstile",
325
+ key: "cloudflareTurnstile",
287
326
  from: resolve("./runtime/registry/cloudflare-turnstile")
288
327
  },
289
328
  {
290
329
  name: "useScriptCloudflareWebAnalytics",
291
- from: resolve("./runtime/registry/cloudflare-web-analytics")
330
+ key: "cloudflareWebAnalytics",
331
+ from: resolve("./runtime/registry/cloudflare-web-analytics"),
332
+ src: "https://static.cloudflareinsights.com/beacon.min.js"
292
333
  },
293
334
  {
294
335
  name: "useScriptConfetti",
295
- from: resolve("./runtime/registry/confetti")
336
+ key: "confetti",
337
+ from: resolve("./runtime/registry/confetti"),
338
+ src: "https://unpkg.com/js-confetti@latest/dist/js-confetti.browser.js"
296
339
  },
297
340
  {
298
341
  name: "useScriptFacebookPixel",
299
- from: resolve("./runtime/registry/facebook-pixel")
342
+ key: "facebookPixel",
343
+ from: resolve("./runtime/registry/facebook-pixel"),
344
+ src: "https://connect.facebook.net/en_US/fbevents.js"
300
345
  },
301
346
  {
302
347
  name: "useScriptFathomAnalytics",
303
- from: resolve("./runtime/registry/fathom-analytics")
348
+ key: "fathomAnalytics",
349
+ from: resolve("./runtime/registry/fathom-analytics"),
350
+ src: "https://cdn.usefathom.com/script.js"
304
351
  },
305
352
  {
306
353
  name: "useScriptGoogleAnalytics",
354
+ key: "googleAnalytics",
307
355
  from: resolve("./runtime/registry/google-analytics")
308
356
  },
309
357
  {
310
358
  name: "useScriptGoogleTagManager",
359
+ key: "googleTagmanager",
311
360
  from: resolve("./runtime/registry/google-tag-manager")
312
361
  },
313
362
  {
314
363
  name: "useScriptHotjar",
315
- from: resolve("./runtime/registry/hotjar")
364
+ from: resolve("./runtime/registry/hotjar"),
365
+ key: "hotjar",
366
+ transform(options) {
367
+ return withQuery(`https://static.hotjar.com/c/hotjar-${options?.id || ""}.js`, {
368
+ sv: options?.sv || "6"
369
+ });
370
+ }
316
371
  },
317
372
  {
318
373
  name: "useScriptIntercom",
319
- from: resolve("./runtime/registry/intercom")
374
+ from: resolve("./runtime/registry/intercom"),
375
+ key: "intercom",
376
+ transform(options) {
377
+ return joinURL(`https://widget.intercom.io/widget`, options?.app_id || "");
378
+ }
320
379
  },
321
380
  {
322
381
  name: "useScriptSegment",
323
- from: resolve("./runtime/registry/segment")
382
+ from: resolve("./runtime/registry/segment"),
383
+ key: "segment",
384
+ transform(options) {
385
+ return joinURL("https://cdn.segment.com/analytics.js/v1", options?.writeKey || "", "analytics.min.js");
386
+ }
324
387
  },
325
388
  {
326
389
  name: "useScriptNpm",
327
- from: resolve("./runtime/registry/npm")
390
+ // key is based on package name
391
+ from: resolve("./runtime/registry/npm"),
392
+ transform(options) {
393
+ return withBase(options?.file || "", `https://unpkg.com/${options?.packageName || ""}@${options?.version || "latest"}`);
394
+ }
328
395
  }
329
396
  ].map((i) => {
330
397
  i.priority = -1;
@@ -360,6 +427,19 @@ ${(config.globals || []).map((g) => !Array.isArray(g) ? ` useScript("${g.toSt
360
427
  src: template.dst
361
428
  });
362
429
  }
430
+ const scriptMap = /* @__PURE__ */ new Map();
431
+ const { normalizeScriptData } = setupPublicAssetStrategy(config.assets);
432
+ addBuildPlugin(NuxtScriptAssetBundlerTransformer({
433
+ registry,
434
+ defaultBundle: config.defaultScriptOptions?.assetStrategy === "bundle",
435
+ resolveScript(src) {
436
+ if (scriptMap.has(src))
437
+ return scriptMap.get(src);
438
+ const url = normalizeScriptData(src);
439
+ scriptMap.set(src, url);
440
+ return url;
441
+ }
442
+ }));
363
443
  });
364
444
  extendTypes(name, async () => {
365
445
  return `
@@ -370,18 +450,6 @@ declare module '#app' {
370
450
  }
371
451
  `;
372
452
  });
373
- const scriptMap = /* @__PURE__ */ new Map();
374
- const { normalizeScriptData } = setupPublicAssetStrategy(config.assets);
375
- addBuildPlugin(NuxtScriptAssetBundlerTransformer({
376
- overrides: config.overrides,
377
- resolveScript(src) {
378
- if (scriptMap.has(src))
379
- return scriptMap.get(src);
380
- const url = normalizeScriptData(src);
381
- scriptMap.set(src, url);
382
- return url;
383
- }
384
- }));
385
453
  if (nuxt.options.dev)
386
454
  setupDevToolsUI(config, resolve);
387
455
  }
@@ -1,7 +1,2 @@
1
1
  import { type BaseSchema, type Input } from 'valibot';
2
- /**
3
- * injectScript
4
- *
5
- * Checks if a script with the 'key' value exists in head.
6
- */
7
2
  export declare function validateScriptInputSchema<T extends BaseSchema<any>>(schema: T, options?: Input<T>): void;
@@ -1,12 +1,14 @@
1
1
  import { parse } from "valibot";
2
2
  import { createError } from "#imports";
3
3
  export function validateScriptInputSchema(schema, options) {
4
- try {
5
- parse(schema, options);
6
- } catch (e) {
7
- createError({
8
- cause: e,
9
- message: "Invalid script options"
10
- });
4
+ if (import.meta.dev) {
5
+ try {
6
+ parse(schema, options);
7
+ } catch (e) {
8
+ createError({
9
+ cause: e,
10
+ message: "Invalid script options"
11
+ });
12
+ }
11
13
  }
12
14
  }
@@ -18,11 +18,9 @@ export const CloudflareWebAnalyticsOptions = object({
18
18
  });
19
19
  export function useScriptCloudflareWebAnalytics(options, _scriptOptions) {
20
20
  const scriptOptions = _scriptOptions || {};
21
- if (import.meta.dev) {
22
- scriptOptions.beforeInit = () => {
23
- validateScriptInputSchema(CloudflareWebAnalyticsOptions, options);
24
- };
25
- }
21
+ scriptOptions.beforeInit = () => {
22
+ import.meta.dev && validateScriptInputSchema(CloudflareWebAnalyticsOptions, options);
23
+ };
26
24
  return useScript({
27
25
  "src": "https://static.cloudflareinsights.com/beacon.min.js",
28
26
  "data-cf-beacon": JSON.stringify(defu(options, { spa: true }))
@@ -6,7 +6,7 @@ export const FacebookPixelOptions = object({
6
6
  export function useScriptFacebookPixel(options, _scriptOptions) {
7
7
  const scriptOptions = _scriptOptions || {};
8
8
  scriptOptions.beforeInit = () => {
9
- validateScriptInputSchema(FacebookPixelOptions, options);
9
+ import.meta.dev && validateScriptInputSchema(FacebookPixelOptions, options);
10
10
  if (import.meta.client) {
11
11
  const fbq = window.fbq = function(...params) {
12
12
  fbq.callMethod ? fbq.callMethod(...params) : fbq.queue.push(params);
@@ -22,9 +22,8 @@ export function useScriptFacebookPixel(options, _scriptOptions) {
22
22
  }
23
23
  };
24
24
  return useScript({
25
- key: "facebook-pixel",
26
- src: "https://connect.facebook.net/en_US/fbevents.js",
27
- defer: true
25
+ key: "facebookPixel",
26
+ src: "https://connect.facebook.net/en_US/fbevents.js"
28
27
  }, {
29
28
  ...scriptOptions,
30
29
  use() {
@@ -11,14 +11,11 @@ export const FathomAnalyticsOptions = object({
11
11
  });
12
12
  export function useScriptFathomAnalytics(options, _scriptOptions) {
13
13
  const scriptOptions = _scriptOptions || {};
14
- if (import.meta.dev) {
15
- scriptOptions.beforeInit = () => {
16
- validateScriptInputSchema(FathomAnalyticsOptions, options);
17
- };
18
- }
14
+ scriptOptions.beforeInit = () => {
15
+ import.meta.dev && validateScriptInputSchema(FathomAnalyticsOptions, options);
16
+ };
19
17
  return useScript({
20
18
  src: "https://cdn.usefathom.com/script.js",
21
- defer: true,
22
19
  ...options
23
20
  }, {
24
21
  ...scriptOptions,
@@ -1,5 +1,4 @@
1
- import { type Input } from 'valibot';
2
- import type { NuxtUseScriptOptions } from '#nuxt-scripts';
1
+ import type { NuxtUseScriptOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
3
2
  export interface HotjarApi {
4
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) & {
5
4
  q: any[];
@@ -20,4 +19,5 @@ export declare const HotjarOptions: import("valibot").ObjectSchema<{
20
19
  id: number;
21
20
  sv?: number | undefined;
22
21
  }>;
23
- export declare function useScriptHotjar<T extends HotjarApi>(options?: Input<typeof HotjarOptions>, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'assetStrategy' | 'beforeInit' | 'use'>): any;
22
+ export type HotjarInput = ScriptDynamicSrcInput<typeof HotjarOptions>;
23
+ export declare function useScriptHotjar<T extends HotjarApi>(options?: HotjarInput, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'assetStrategy' | 'beforeInit' | 'use'>): any;
@@ -7,7 +7,7 @@ export const HotjarOptions = object({
7
7
  export function useScriptHotjar(options, _scriptOptions) {
8
8
  const scriptOptions = _scriptOptions || {};
9
9
  scriptOptions.beforeInit = () => {
10
- validateScriptInputSchema(HotjarOptions, options);
10
+ import.meta.dev && validateScriptInputSchema(HotjarOptions, options);
11
11
  if (import.meta.client) {
12
12
  window._hjSettings = window._hjSettings || { hjid: options?.id, hjsv: options?.sv };
13
13
  window.hj = window.hj || function(...params) {
@@ -18,8 +18,7 @@ export function useScriptHotjar(options, _scriptOptions) {
18
18
  return useScript({
19
19
  key: "hotjar",
20
20
  // requires extra steps to bundle
21
- src: `https://static.hotjar.com/c/hotjar-${options?.id}.js?sv=${options?.sv}`,
22
- defer: true
21
+ src: options?.src || `https://static.hotjar.com/c/hotjar-${options?.id}.js?sv=${options?.sv}`
23
22
  }, {
24
23
  ...scriptOptions,
25
24
  use() {
@@ -1,5 +1,5 @@
1
1
  import { type Input } from 'valibot';
2
- import type { NuxtUseScriptOptions } from '#nuxt-scripts';
2
+ import type { NuxtUseScriptOptions, 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>;
@@ -19,12 +19,13 @@ export declare const IntercomOptions: import("valibot").ObjectSchema<{
19
19
  horizontal_padding?: number | undefined;
20
20
  vertical_padding?: number | undefined;
21
21
  }>;
22
+ export type IntercomInput = ScriptDynamicSrcInput<typeof IntercomOptions>;
22
23
  export interface IntercomApi {
23
24
  Intercom: ((event: 'boot', data?: Input<typeof IntercomOptions>) => void) & ((event: 'shutdown') => void) & ((event: 'update', options?: Input<typeof IntercomOptions>) => void) & ((event: 'hide') => void) & ((event: 'show') => void) & ((event: 'showSpace', spaceName: 'home' | 'messages' | 'help' | 'news' | 'tasks' | 'tickets' | string) => void) & ((event: 'showMessages') => void) & ((event: 'showNewMessage', content?: string) => void) & ((event: 'onHide', fn: () => void) => void) & ((event: 'onShow', fn: () => void) => void) & ((event: 'onUnreadCountChange', fn: () => void) => void) & ((event: 'trackEvent', eventName: string, metadata?: Record<string, any>) => void) & ((event: 'getVisitorId') => Promise<string>) & ((event: 'startTour', tourId: string | number) => void) & ((event: 'showArticle', articleId: string | number) => void) & ((event: 'showNews', newsItemId: string | number) => void) & ((event: 'startSurvey', surveyId: string | number) => void) & ((event: 'startChecklist', checklistId: string | number) => void) & ((event: 'showTicket', ticketId: string | number) => void) & ((event: 'showConversation', conversationId: string | number) => void) & ((event: 'onUserEmailSupplied', fn: () => void) => void) & ((event: string, ...params: any[]) => void);
24
25
  }
25
26
  declare global {
26
27
  interface Window extends IntercomApi {
27
- intercomSettings?: Input<typeof IntercomOptions>;
28
+ intercomSettings?: IntercomInput;
28
29
  }
29
30
  }
30
- export declare function useScriptIntercom<T extends IntercomApi>(options?: Input<typeof IntercomOptions>, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'beforeInit' | 'use'>): any;
31
+ export declare function useScriptIntercom<T extends IntercomApi>(options?: IntercomInput, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'beforeInit' | 'use'>): any;
@@ -1,4 +1,5 @@
1
1
  import { literal, number, object, optional, string, union } from "valibot";
2
+ import { joinURL } from "ufo";
2
3
  import { useScript, validateScriptInputSchema } from "#imports";
3
4
  export const IntercomOptions = object({
4
5
  app_id: string(),
@@ -14,14 +15,13 @@ export const IntercomOptions = object({
14
15
  export function useScriptIntercom(options, _scriptOptions) {
15
16
  const scriptOptions = _scriptOptions || {};
16
17
  scriptOptions.beforeInit = () => {
17
- validateScriptInputSchema(IntercomOptions, options);
18
+ import.meta.dev && validateScriptInputSchema(IntercomOptions, options);
18
19
  if (import.meta.client)
19
20
  window.intercomSettings = options;
20
21
  };
21
22
  return useScript({
22
23
  key: "intercom",
23
- src: `https://widget.intercom.io/widget/${options?.app_id}`,
24
- defer: true
24
+ src: options?.src || joinURL(`https://widget.intercom.io/widget`, options?.app_id || "")
25
25
  }, {
26
26
  ...scriptOptions,
27
27
  use() {
@@ -1,5 +1,4 @@
1
- import { type Input } from 'valibot';
2
- import type { NuxtUseScriptOptions } from '#nuxt-scripts';
1
+ import type { NuxtUseScriptOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
3
2
  export declare const NpmOptions: import("valibot").ObjectSchema<{
4
3
  packageName: import("valibot").StringSchema<string>;
5
4
  file: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
@@ -9,4 +8,5 @@ export declare const NpmOptions: import("valibot").ObjectSchema<{
9
8
  file?: string | undefined;
10
9
  version?: string | undefined;
11
10
  }>;
12
- export declare function useScriptNpm<T>(options: Input<typeof NpmOptions>, _scriptOptions?: NuxtUseScriptOptions<T>): any;
11
+ export type NpmInput = ScriptDynamicSrcInput<typeof NpmOptions>;
12
+ export declare function useScriptNpm<T>(options: NpmInput, _scriptOptions?: NuxtUseScriptOptions<T>): any;
@@ -9,14 +9,10 @@ export const NpmOptions = object({
9
9
  export function useScriptNpm(options, _scriptOptions) {
10
10
  const scriptOptions = _scriptOptions || {};
11
11
  scriptOptions.beforeInit = () => {
12
- validateScriptInputSchema(NpmOptions, options);
12
+ import.meta.dev && validateScriptInputSchema(NpmOptions, options);
13
13
  };
14
14
  return useScript({
15
- src: typeof options === "string" ? options : withBase(options.file || "", `https://unpkg.com/${options?.packageName}@${options.version}`)
16
- }, {
17
- ...scriptOptions,
18
- use() {
19
- return new window.JSConfetti();
20
- }
21
- });
15
+ key: options.packageName,
16
+ src: options.src || withBase(options.file || "", `https://unpkg.com/${options?.packageName}@${options.version || "latest"}`)
17
+ }, scriptOptions);
22
18
  }
@@ -1,5 +1,4 @@
1
- import { type Input } from 'valibot';
2
- import type { NuxtUseScriptOptions } from '#nuxt-scripts';
1
+ import type { NuxtUseScriptOptions, ScriptDynamicSrcInput } from '#nuxt-scripts';
3
2
  export declare const SegmentOptions: import("valibot").ObjectSchema<{
4
3
  writeKey: import("valibot").StringSchema<string>;
5
4
  analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
@@ -7,6 +6,7 @@ export declare const SegmentOptions: import("valibot").ObjectSchema<{
7
6
  writeKey: string;
8
7
  analyticsKey?: string | undefined;
9
8
  }>;
9
+ export type SegmentInput = ScriptDynamicSrcInput<typeof SegmentOptions>;
10
10
  export interface SegmentApi {
11
11
  analytics: {
12
12
  track: (event: string, properties?: Record<string, any>) => void;
@@ -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?: Input<typeof SegmentOptions>, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'beforeInit' | 'use'>): any;
24
+ export declare function useScriptSegment<T extends SegmentApi>(options?: SegmentInput, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'beforeInit' | 'use'>): any;