@nuxt/scripts 0.8.4 → 0.9.0
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/{Ba8BmHI-.js → B4xshqWg.js} +1 -1
- package/dist/client/_nuxt/BCEZfd-g.js +32 -0
- package/dist/client/_nuxt/{CL9amlOg.js → SzB1dTOE.js} +1 -1
- package/dist/client/_nuxt/{CQ_lMUWv.js → bLAdrJK6.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/8c4abb90-402d-41b4-86bd-96fe410ff3e7.json +1 -0
- package/dist/client/_nuxt/error-404.40FRd8h-.css +1 -0
- package/dist/client/_nuxt/error-500.C7IaxGA9.css +1 -0
- package/dist/client/index.html +8 -8
- package/dist/module.d.mts +6 -0
- package/dist/module.d.ts +6 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +165 -125
- package/dist/registry.mjs +1 -1
- package/dist/runtime/components/ScriptGoogleAdsense.vue +0 -1
- package/dist/runtime/components/ScriptGoogleMaps.vue +3 -2
- package/dist/runtime/components/ScriptVimeoPlayer.vue +1 -0
- package/dist/runtime/components/ScriptYouTubePlayer.vue +1 -1
- package/dist/runtime/registry/google-adsense.d.ts +1 -1
- package/dist/runtime/registry/vimeo-player.d.ts +2 -1
- package/dist/runtime/registry/youtube-player.d.ts +15 -4
- package/dist/runtime/registry/youtube-player.js +1 -1
- package/dist/runtime/utils.d.ts +2 -1
- package/dist/types.d.mts +0 -4
- package/dist/types.d.ts +0 -4
- package/package.json +26 -26
- package/dist/client/_nuxt/builds/meta/663d447b-1805-44f3-9c37-fee30740d200.json +0 -1
- package/dist/client/_nuxt/error-404.Dh7DYMRz.css +0 -1
- package/dist/client/_nuxt/error-500.W3BiwNt2.css +0 -1
- package/dist/client/_nuxt/qH8ZJPJc.js +0 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as a}from"./
|
|
1
|
+
import{u as a}from"./bLAdrJK6.js";import{_ as s,o as i,c as u,a as t,t as o}from"./BCEZfd-g.js";const l={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},c={class:"max-w-520px text-center"},d=["textContent"],p=["textContent"],g={__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(e){const n=e;return a({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: }'}]}),(b,r)=>(i(),u("div",l,[r[0]||(r[0]=t("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),t("div",c,[t("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:o(e.statusCode)},null,8,d),t("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:o(e.description)},null,8,p)])]))}},m=s(g,[["__scopeId","data-v-6652892c"]]);export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as f,r as u,f as o,g as d,h as v,j as l,k as i,l as h,m}from"./
|
|
1
|
+
import{i as f,r as u,f as o,g as d,h as v,j as l,k as i,l as h,m}from"./BCEZfd-g.js";function U(t,a={}){const e=a.head||f();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});o(()=>{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
|
-
{"id":"
|
|
1
|
+
{"id":"8c4abb90-402d-41b4-86bd-96fe410ff3e7","timestamp":1726401496414}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"8c4abb90-402d-41b4-86bd-96fe410ff3e7","timestamp":1726401496414,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-a285bd2b]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-a285bd2b]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-a285bd2b]{background-color:#ffffff4d}.gradient-border[data-v-a285bd2b]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-a285bd2b]{background-color:#1414144d}.gradient-border[data-v-a285bd2b]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-a285bd2b]: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-a285bd2b]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-a285bd2b]{position:fixed}.left-0[data-v-a285bd2b]{left:0}.right-0[data-v-a285bd2b]{right:0}.z-10[data-v-a285bd2b]{z-index:10}.z-20[data-v-a285bd2b]{z-index:20}.grid[data-v-a285bd2b]{display:grid}.mb-16[data-v-a285bd2b]{margin-bottom:4rem}.mb-8[data-v-a285bd2b]{margin-bottom:2rem}.max-w-520px[data-v-a285bd2b]{max-width:520px}.min-h-screen[data-v-a285bd2b]{min-height:100vh}.w-full[data-v-a285bd2b]{width:100%}.flex[data-v-a285bd2b]{display:flex}.cursor-pointer[data-v-a285bd2b]{cursor:pointer}.place-content-center[data-v-a285bd2b]{place-content:center}.items-center[data-v-a285bd2b]{align-items:center}.justify-center[data-v-a285bd2b]{justify-content:center}.overflow-hidden[data-v-a285bd2b]{overflow:hidden}.bg-white[data-v-a285bd2b]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-a285bd2b]{padding-left:1rem;padding-right:1rem}.px-8[data-v-a285bd2b]{padding-left:2rem;padding-right:2rem}.py-2[data-v-a285bd2b]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-a285bd2b]{text-align:center}.text-8xl[data-v-a285bd2b]{font-size:6rem;line-height:1}.text-xl[data-v-a285bd2b]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-a285bd2b]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-a285bd2b]{font-weight:300}.font-medium[data-v-a285bd2b]{font-weight:500}.leading-tight[data-v-a285bd2b]{line-height:1.25}.font-sans[data-v-a285bd2b]{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-a285bd2b]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-a285bd2b]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-a285bd2b]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-a285bd2b]{padding-left:0;padding-right:0}.sm\:px-6[data-v-a285bd2b]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-a285bd2b]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-a285bd2b]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-a285bd2b]{font-size:1.25rem;line-height:1.75rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-6652892c]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-6652892c]{position:fixed}.-bottom-1\/2[data-v-6652892c]{bottom:-50%}.left-0[data-v-6652892c]{left:0}.right-0[data-v-6652892c]{right:0}.grid[data-v-6652892c]{display:grid}.mb-16[data-v-6652892c]{margin-bottom:4rem}.mb-8[data-v-6652892c]{margin-bottom:2rem}.h-1\/2[data-v-6652892c]{height:50%}.max-w-520px[data-v-6652892c]{max-width:520px}.min-h-screen[data-v-6652892c]{min-height:100vh}.place-content-center[data-v-6652892c]{place-content:center}.overflow-hidden[data-v-6652892c]{overflow:hidden}.bg-white[data-v-6652892c]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-6652892c]{padding-left:2rem;padding-right:2rem}.text-center[data-v-6652892c]{text-align:center}.text-8xl[data-v-6652892c]{font-size:6rem;line-height:1}.text-xl[data-v-6652892c]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-6652892c]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-6652892c]{font-weight:300}.font-medium[data-v-6652892c]{font-weight:500}.leading-tight[data-v-6652892c]{line-height:1.25}.font-sans[data-v-6652892c]{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-6652892c]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-6652892c]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-6652892c]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-6652892c]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-6652892c]{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.BAZUAl3s.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/BCEZfd-g.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.40FRd8h-.css">
|
|
261
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/B4xshqWg.js">
|
|
262
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/bLAdrJK6.js">
|
|
263
|
+
<link rel="prefetch" as="style" href="/__nuxt-scripts/_nuxt/error-500.C7IaxGA9.css">
|
|
264
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/SzB1dTOE.js">
|
|
265
|
+
<script type="module" src="/__nuxt-scripts/_nuxt/BCEZfd-g.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"serverRendered":1},false]</script>
|
|
266
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"8c4abb90-402d-41b4-86bd-96fe410ff3e7",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -27,6 +27,12 @@ interface ModuleOptions {
|
|
|
27
27
|
* TODO Make configurable in future.
|
|
28
28
|
*/
|
|
29
29
|
strategy?: 'public';
|
|
30
|
+
/**
|
|
31
|
+
* Fallback to src if bundle fails to load.
|
|
32
|
+
* The default behavior is to stop the bundling process if a script fails to be downloaded.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
fallbackOnSrcOnBundleFail?: boolean;
|
|
30
36
|
};
|
|
31
37
|
/**
|
|
32
38
|
* Whether the module is enabled.
|
package/dist/module.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ interface ModuleOptions {
|
|
|
27
27
|
* TODO Make configurable in future.
|
|
28
28
|
*/
|
|
29
29
|
strategy?: 'public';
|
|
30
|
+
/**
|
|
31
|
+
* Fallback to src if bundle fails to load.
|
|
32
|
+
* The default behavior is to stop the bundling process if a script fails to be downloaded.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
fallbackOnSrcOnBundleFail?: boolean;
|
|
30
36
|
};
|
|
31
37
|
/**
|
|
32
38
|
* Whether the module is enabled.
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { useNuxt, useLogger, addDevServerHandler, createResolver, addTemplate,
|
|
1
|
+
import { useNuxt, useLogger, addDevServerHandler, tryUseNuxt, createResolver, addTemplate, 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
5
|
import { join, relative } from 'pathe';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
|
+
import fsp from 'node:fs/promises';
|
|
7
8
|
import { createUnplugin } from 'unplugin';
|
|
8
9
|
import MagicString from 'magic-string';
|
|
9
|
-
import { walk } from 'estree-walker';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import fsp from 'node:fs/promises';
|
|
13
|
-
import { lazyEventHandler, eventHandler, createError } from 'h3';
|
|
14
|
-
import { fetch } from 'ofetch';
|
|
10
|
+
import { asyncWalk, walk } from 'estree-walker';
|
|
11
|
+
import { joinURL, parseURL, parseQuery, hasProtocol } from 'ufo';
|
|
12
|
+
import { hash } from 'ohash';
|
|
15
13
|
import { colors } from 'consola/utils';
|
|
14
|
+
import { lazyEventHandler, eventHandler, createError } from 'h3';
|
|
15
|
+
import { fetch as fetch$1 } from 'ofetch';
|
|
16
16
|
import { defu } from 'defu';
|
|
17
|
-
import { hash } from 'ohash';
|
|
18
17
|
import { createStorage } from 'unstorage';
|
|
19
18
|
import fsDriver from 'unstorage/drivers/fs-lite';
|
|
19
|
+
import { pathToFileURL } from 'node:url';
|
|
20
20
|
import { isCI, provider } from 'std-env';
|
|
21
21
|
import { registry } from './registry.mjs';
|
|
22
22
|
import 'third-party-capital';
|
|
@@ -64,6 +64,62 @@ function setupDevToolsUI(options, resolve, nuxt = useNuxt()) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const logger = useLogger("@nuxt/scripts");
|
|
68
|
+
|
|
69
|
+
const renderedScript = /* @__PURE__ */ new Map();
|
|
70
|
+
const ONE_YEAR_IN_SECONDS = 60 * 60 * 24 * 365;
|
|
71
|
+
const storage = createStorage({
|
|
72
|
+
driver: fsDriver({
|
|
73
|
+
base: "node_modules/.cache/nuxt/scripts"
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
function setupPublicAssetStrategy(options = {}) {
|
|
77
|
+
const assetsBaseURL = options.prefix || "/_scripts";
|
|
78
|
+
const nuxt = useNuxt();
|
|
79
|
+
addDevServerHandler({
|
|
80
|
+
route: assetsBaseURL,
|
|
81
|
+
handler: lazyEventHandler(async () => {
|
|
82
|
+
return eventHandler(async (event) => {
|
|
83
|
+
const filename = event.path.slice(1);
|
|
84
|
+
const scriptDescriptor = renderedScript.get(join(assetsBaseURL, event.path.slice(1)));
|
|
85
|
+
if (!scriptDescriptor || scriptDescriptor instanceof Error)
|
|
86
|
+
throw createError({ statusCode: 404 });
|
|
87
|
+
const key = `data:scripts:${filename}`;
|
|
88
|
+
let res = await storage.getItemRaw(key);
|
|
89
|
+
if (!res) {
|
|
90
|
+
res = await fetch$1(scriptDescriptor.src).then((r) => r.arrayBuffer()).then((r) => Buffer.from(r));
|
|
91
|
+
await storage.setItemRaw(key, res);
|
|
92
|
+
}
|
|
93
|
+
return res;
|
|
94
|
+
});
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
if (nuxt.options.dev) {
|
|
98
|
+
nuxt.options.routeRules ||= {};
|
|
99
|
+
nuxt.options.routeRules[joinURL(assetsBaseURL, "**")] = {
|
|
100
|
+
cache: {
|
|
101
|
+
maxAge: ONE_YEAR_IN_SECONDS
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
nuxt.options.nitro.publicAssets ||= [];
|
|
106
|
+
const cacheDir = join(nuxt.options.buildDir, "cache", "scripts");
|
|
107
|
+
nuxt.options.nitro.publicAssets.push();
|
|
108
|
+
nuxt.options.nitro = defu(nuxt.options.nitro, {
|
|
109
|
+
publicAssets: [{
|
|
110
|
+
dir: cacheDir,
|
|
111
|
+
maxAge: ONE_YEAR_IN_SECONDS,
|
|
112
|
+
baseURL: assetsBaseURL
|
|
113
|
+
}],
|
|
114
|
+
prerender: {
|
|
115
|
+
ignore: [assetsBaseURL]
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
renderedScript
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
67
123
|
function isVue(id, opts = {}) {
|
|
68
124
|
const { search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
69
125
|
if (id.endsWith(".vue") && !search) {
|
|
@@ -91,7 +147,83 @@ function isJS(id) {
|
|
|
91
147
|
return JS_RE.test(pathname);
|
|
92
148
|
}
|
|
93
149
|
|
|
94
|
-
function
|
|
150
|
+
function normalizeScriptData(src, assetsBaseURL = "/_scripts") {
|
|
151
|
+
if (hasProtocol(src, { acceptRelative: true })) {
|
|
152
|
+
src = src.replace(/^\/\//, "https://");
|
|
153
|
+
const url = parseURL(src);
|
|
154
|
+
const file = [
|
|
155
|
+
`${hash(url)}.js`
|
|
156
|
+
// force an extension
|
|
157
|
+
].filter(Boolean).join("-");
|
|
158
|
+
const nuxt = tryUseNuxt();
|
|
159
|
+
return { url: joinURL(joinURL(nuxt?.options.app.baseURL || "", assetsBaseURL), file), filename: file };
|
|
160
|
+
}
|
|
161
|
+
return { url: src };
|
|
162
|
+
}
|
|
163
|
+
async function downloadScript(opts, renderedScript) {
|
|
164
|
+
const { src, url, filename } = opts;
|
|
165
|
+
if (src === url || !filename) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const scriptContent = renderedScript.get(src);
|
|
169
|
+
let res = scriptContent instanceof Error ? void 0 : scriptContent?.content;
|
|
170
|
+
if (!res) {
|
|
171
|
+
if (await storage.hasItem(`data:scripts:${filename}`)) {
|
|
172
|
+
const res2 = await storage.getItemRaw(`data:scripts:${filename}`);
|
|
173
|
+
renderedScript.set(url, {
|
|
174
|
+
content: res2,
|
|
175
|
+
size: res2.length / 1024,
|
|
176
|
+
encoding: "utf-8",
|
|
177
|
+
src,
|
|
178
|
+
filename
|
|
179
|
+
});
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
let encoding;
|
|
183
|
+
let size = 0;
|
|
184
|
+
res = await fetch(src).then((r) => {
|
|
185
|
+
if (!r.ok) {
|
|
186
|
+
throw new Error(`Failed to fetch ${src}`);
|
|
187
|
+
}
|
|
188
|
+
encoding = r.headers.get("content-encoding");
|
|
189
|
+
const contentLength = r.headers.get("content-length");
|
|
190
|
+
size = contentLength ? Number(contentLength) / 1024 : 0;
|
|
191
|
+
return r.arrayBuffer();
|
|
192
|
+
}).then((r) => Buffer.from(r));
|
|
193
|
+
storage.setItemRaw(`data:scripts:${filename}`, res);
|
|
194
|
+
renderedScript.set(url, {
|
|
195
|
+
content: res,
|
|
196
|
+
size,
|
|
197
|
+
encoding,
|
|
198
|
+
src,
|
|
199
|
+
filename
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function NuxtScriptBundleTransformer(options = {
|
|
204
|
+
renderedScript: /* @__PURE__ */ new Map()
|
|
205
|
+
}) {
|
|
206
|
+
const nuxt = useNuxt();
|
|
207
|
+
const { renderedScript = /* @__PURE__ */ new Map() } = options;
|
|
208
|
+
const cacheDir = join(nuxt.options.buildDir, "cache", "scripts");
|
|
209
|
+
nuxt.hooks.hook("build:done", async () => {
|
|
210
|
+
const scripts = [...renderedScript];
|
|
211
|
+
if (!scripts.length) {
|
|
212
|
+
logger.debug("[bundle-script-transformer] No scripts to bundle...");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
logger.info("[bundle-script-transformer] Bundling scripts...");
|
|
216
|
+
if (!nuxt.options.dev) {
|
|
217
|
+
await fsp.rm(cacheDir, { recursive: true, force: true });
|
|
218
|
+
await fsp.mkdir(cacheDir, { recursive: true });
|
|
219
|
+
}
|
|
220
|
+
await Promise.all(scripts.map(async ([url, content]) => {
|
|
221
|
+
if (content instanceof Error || !content.filename)
|
|
222
|
+
return;
|
|
223
|
+
await fsp.writeFile(join(nuxt.options.buildDir, "cache", "scripts", content.filename), content.content);
|
|
224
|
+
logger.info(colors.gray(` \u251C\u2500 ${url} \u2192 ${joinURL(content.src)} (${content.size.toFixed(2)} kB ${content.encoding})`));
|
|
225
|
+
}));
|
|
226
|
+
});
|
|
95
227
|
return createUnplugin(() => {
|
|
96
228
|
return {
|
|
97
229
|
name: "nuxt:scripts:bundler-transformer",
|
|
@@ -103,8 +235,8 @@ function NuxtScriptBundleTransformer(options) {
|
|
|
103
235
|
return;
|
|
104
236
|
const ast = this.parse(code);
|
|
105
237
|
const s = new MagicString(code);
|
|
106
|
-
|
|
107
|
-
enter(_node) {
|
|
238
|
+
await asyncWalk(ast, {
|
|
239
|
+
async enter(_node) {
|
|
108
240
|
const calleeName = _node.callee?.name;
|
|
109
241
|
if (!calleeName)
|
|
110
242
|
return;
|
|
@@ -183,15 +315,26 @@ function NuxtScriptBundleTransformer(options) {
|
|
|
183
315
|
});
|
|
184
316
|
canBundle = bundleOption ? bundleOption.value.value : canBundle;
|
|
185
317
|
if (canBundle) {
|
|
186
|
-
const
|
|
187
|
-
|
|
318
|
+
const { url: _url, filename } = normalizeScriptData(src, options.assetsBaseURL);
|
|
319
|
+
let url = _url;
|
|
320
|
+
try {
|
|
321
|
+
await downloadScript({ src, url, filename }, renderedScript);
|
|
322
|
+
} catch (e) {
|
|
323
|
+
if (options.fallbackOnSrcOnBundleFail) {
|
|
324
|
+
logger.warn(`[Nuxt Scripts: Bundle Transformer] Failed to bundle ${src}. Fallback to remote loading.`);
|
|
325
|
+
url = src;
|
|
326
|
+
} else {
|
|
327
|
+
throw e;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (src === url) {
|
|
188
331
|
if (src && src.startsWith("/"))
|
|
189
332
|
console.warn(`[Nuxt Scripts: Bundle Transformer] Relative scripts are already bundled. Skipping bundling for \`${src}\`.`);
|
|
190
333
|
else
|
|
191
334
|
console.warn(`[Nuxt Scripts: Bundle Transformer] Failed to bundle ${src}.`);
|
|
192
335
|
}
|
|
193
336
|
if (scriptSrcNode) {
|
|
194
|
-
s.overwrite(scriptSrcNode.start, scriptSrcNode.end, `'${
|
|
337
|
+
s.overwrite(scriptSrcNode.start, scriptSrcNode.end, `'${url}'`);
|
|
195
338
|
} else {
|
|
196
339
|
const optionsNode = node.arguments[0];
|
|
197
340
|
const scriptInputProperty = optionsNode.properties.find(
|
|
@@ -204,12 +347,12 @@ function NuxtScriptBundleTransformer(options) {
|
|
|
204
347
|
(p) => p.key?.name === "src" || p.key?.value === "src"
|
|
205
348
|
);
|
|
206
349
|
if (srcProperty)
|
|
207
|
-
s.overwrite(srcProperty.value.start, srcProperty.value.end, `'${
|
|
350
|
+
s.overwrite(srcProperty.value.start, srcProperty.value.end, `'${url}'`);
|
|
208
351
|
else
|
|
209
|
-
s.appendRight(scriptInput.end, `, src: '${
|
|
352
|
+
s.appendRight(scriptInput.end, `, src: '${url}'`);
|
|
210
353
|
}
|
|
211
354
|
} else {
|
|
212
|
-
s.appendRight(node.arguments[0].start + 1, ` scriptInput: { src: '${
|
|
355
|
+
s.appendRight(node.arguments[0].start + 1, ` scriptInput: { src: '${url}' }, `);
|
|
213
356
|
}
|
|
214
357
|
}
|
|
215
358
|
}
|
|
@@ -229,105 +372,6 @@ function NuxtScriptBundleTransformer(options) {
|
|
|
229
372
|
});
|
|
230
373
|
}
|
|
231
374
|
|
|
232
|
-
const logger = useLogger("@nuxt/scripts");
|
|
233
|
-
|
|
234
|
-
const ONE_YEAR_IN_SECONDS = 60 * 60 * 24 * 365;
|
|
235
|
-
function setupPublicAssetStrategy(options = {}) {
|
|
236
|
-
const assetsBaseURL = options.prefix || "/_scripts";
|
|
237
|
-
const nuxt = useNuxt();
|
|
238
|
-
const renderedScriptSrc = /* @__PURE__ */ new Map();
|
|
239
|
-
const storage = createStorage({
|
|
240
|
-
driver: fsDriver({
|
|
241
|
-
base: "node_modules/.cache/nuxt/scripts"
|
|
242
|
-
})
|
|
243
|
-
});
|
|
244
|
-
function normalizeScriptData(src) {
|
|
245
|
-
if (hasProtocol(src, { acceptRelative: true })) {
|
|
246
|
-
src = src.replace(/^\/\//, "https://");
|
|
247
|
-
const url = parseURL(src);
|
|
248
|
-
const file = [
|
|
249
|
-
`${hash(url)}.js`
|
|
250
|
-
// force an extension
|
|
251
|
-
].filter(Boolean).join("-");
|
|
252
|
-
renderedScriptSrc.set(file, src);
|
|
253
|
-
return joinURL(assetsBaseURL, file);
|
|
254
|
-
}
|
|
255
|
-
return src;
|
|
256
|
-
}
|
|
257
|
-
addDevServerHandler({
|
|
258
|
-
route: assetsBaseURL,
|
|
259
|
-
handler: lazyEventHandler(async () => {
|
|
260
|
-
return eventHandler(async (event) => {
|
|
261
|
-
const filename = event.path.slice(1);
|
|
262
|
-
const url = renderedScriptSrc.get(event.path.slice(1));
|
|
263
|
-
if (!url)
|
|
264
|
-
throw createError({ statusCode: 404 });
|
|
265
|
-
const key = `data:scripts:${filename}`;
|
|
266
|
-
let res = await storage.getItemRaw(key);
|
|
267
|
-
if (!res) {
|
|
268
|
-
res = await fetch(url).then((r) => r.arrayBuffer()).then((r) => Buffer.from(r));
|
|
269
|
-
await storage.setItemRaw(key, res);
|
|
270
|
-
}
|
|
271
|
-
return res;
|
|
272
|
-
});
|
|
273
|
-
})
|
|
274
|
-
});
|
|
275
|
-
if (nuxt.options.dev) {
|
|
276
|
-
nuxt.options.routeRules ||= {};
|
|
277
|
-
nuxt.options.routeRules[joinURL(assetsBaseURL, "**")] = {
|
|
278
|
-
cache: {
|
|
279
|
-
maxAge: ONE_YEAR_IN_SECONDS
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
nuxt.options.nitro.publicAssets ||= [];
|
|
284
|
-
const cacheDir = join(nuxt.options.buildDir, "cache", "scripts");
|
|
285
|
-
nuxt.options.nitro.publicAssets.push();
|
|
286
|
-
nuxt.options.nitro = defu(nuxt.options.nitro, {
|
|
287
|
-
publicAssets: [{
|
|
288
|
-
dir: cacheDir,
|
|
289
|
-
maxAge: ONE_YEAR_IN_SECONDS,
|
|
290
|
-
baseURL: assetsBaseURL
|
|
291
|
-
}],
|
|
292
|
-
prerender: {
|
|
293
|
-
ignore: [assetsBaseURL]
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
nuxt.hook("nitro:init", async (nitro) => {
|
|
297
|
-
if (nuxt.options.dev)
|
|
298
|
-
return;
|
|
299
|
-
nitro.hooks.hook("rollup:before", async () => {
|
|
300
|
-
await fsp.rm(cacheDir, { recursive: true, force: true });
|
|
301
|
-
await fsp.mkdir(cacheDir, { recursive: true });
|
|
302
|
-
let banner = false;
|
|
303
|
-
for (const [filename, url] of renderedScriptSrc) {
|
|
304
|
-
const key = `data:scripts:${filename}`;
|
|
305
|
-
let res = await storage.getItemRaw(key);
|
|
306
|
-
if (!res) {
|
|
307
|
-
if (!banner) {
|
|
308
|
-
banner = true;
|
|
309
|
-
logger.info("Downloading scripts...");
|
|
310
|
-
}
|
|
311
|
-
let encoding;
|
|
312
|
-
let size = 0;
|
|
313
|
-
res = await fetch(url).then((r) => {
|
|
314
|
-
encoding = r.headers.get("content-encoding");
|
|
315
|
-
const contentLength = r.headers.get("content-length");
|
|
316
|
-
size = contentLength ? Number(contentLength) / 1024 : 0;
|
|
317
|
-
return r.arrayBuffer();
|
|
318
|
-
}).then((r) => Buffer.from(r));
|
|
319
|
-
logger.log(colors.gray(` \u251C\u2500 ${url} \u2192 ${joinURL(assetsBaseURL, filename)} (${size.toFixed(2)} kB ${encoding})`));
|
|
320
|
-
await storage.setItemRaw(key, res);
|
|
321
|
-
}
|
|
322
|
-
await fsp.writeFile(join(cacheDir, filename), res);
|
|
323
|
-
}
|
|
324
|
-
if (banner)
|
|
325
|
-
logger.success("Scripts downloaded and cached.");
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
return { normalizeScriptData };
|
|
329
|
-
}
|
|
330
|
-
|
|
331
375
|
function extendTypes(module, template) {
|
|
332
376
|
const nuxt = useNuxt();
|
|
333
377
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -504,6 +548,7 @@ const module = defineNuxtModule({
|
|
|
504
548
|
nuxt.options.alias["#nuxt-scripts-validator"] = resolve(`./runtime/validation/${nuxt.options.dev || nuxt.options._prepare ? "valibot" : "mock"}`);
|
|
505
549
|
nuxt.options.alias["#nuxt-scripts"] = resolve("./runtime/types");
|
|
506
550
|
nuxt.options.alias["#nuxt-scripts-utils"] = resolve("./runtime/utils");
|
|
551
|
+
logger.level = config.debug || nuxt.options.debug ? 4 : 3;
|
|
507
552
|
if (!config.enabled) {
|
|
508
553
|
logger.debug("The module is disabled, skipping setup.");
|
|
509
554
|
return;
|
|
@@ -583,8 +628,7 @@ ${newScripts.map((i) => {
|
|
|
583
628
|
}
|
|
584
629
|
});
|
|
585
630
|
}
|
|
586
|
-
const
|
|
587
|
-
const { normalizeScriptData } = setupPublicAssetStrategy(config.assets);
|
|
631
|
+
const { renderedScript } = setupPublicAssetStrategy(config.assets);
|
|
588
632
|
const moduleInstallPromises = /* @__PURE__ */ new Map();
|
|
589
633
|
addBuildPlugin(NuxtScriptsCheckScripts(), {
|
|
590
634
|
dev: true
|
|
@@ -596,13 +640,9 @@ ${newScripts.map((i) => {
|
|
|
596
640
|
if (nuxt.options.dev && module !== "@nuxt/scripts" && !moduleInstallPromises.has(module) && !hasNuxtModule(module))
|
|
597
641
|
moduleInstallPromises.set(module, () => installNuxtModule(module));
|
|
598
642
|
},
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
const url = normalizeScriptData(src);
|
|
603
|
-
scriptMap.set(src, url);
|
|
604
|
-
return url;
|
|
605
|
-
}
|
|
643
|
+
assetsBaseURL: config.assets?.prefix,
|
|
644
|
+
fallbackOnSrcOnBundleFail: config.assets?.fallbackOnSrcOnBundleFail,
|
|
645
|
+
renderedScript
|
|
606
646
|
}));
|
|
607
647
|
nuxt.hooks.hook("build:done", async () => {
|
|
608
648
|
const initPromise = Array.from(moduleInstallPromises.values());
|
package/dist/registry.mjs
CHANGED
|
@@ -65,7 +65,7 @@ const registry = (resolve) => {
|
|
|
65
65
|
label: "Meta Pixel",
|
|
66
66
|
src: "https://connect.facebook.net/en_US/fbevents.js",
|
|
67
67
|
category: "tracking",
|
|
68
|
-
logo: `<svg xmlns="http://www.w3.org/2000/svg" width="
|
|
68
|
+
logo: `<svg xmlns="http://www.w3.org/2000/svg" width="47.91" height="32" viewBox="0 0 256 171"><defs><linearGradient id="logosMetaIcon0" x1="13.878%" x2="89.144%" y1="55.934%" y2="58.694%"><stop offset="0%" stop-color="#0064E1"/><stop offset="40%" stop-color="#0064E1"/><stop offset="83%" stop-color="#0073EE"/><stop offset="100%" stop-color="#0082FB"/></linearGradient><linearGradient id="logosMetaIcon1" x1="54.315%" x2="54.315%" y1="82.782%" y2="39.307%"><stop offset="0%" stop-color="#0082FB"/><stop offset="100%" stop-color="#0064E0"/></linearGradient></defs><path fill="#0081FB" d="M27.651 112.136c0 9.775 2.146 17.28 4.95 21.82c3.677 5.947 9.16 8.466 14.751 8.466c7.211 0 13.808-1.79 26.52-19.372c10.185-14.092 22.186-33.874 30.26-46.275l13.675-21.01c9.499-14.591 20.493-30.811 33.1-41.806C161.196 4.985 172.298 0 183.47 0c18.758 0 36.625 10.87 50.3 31.257C248.735 53.584 256 81.707 256 110.729c0 17.253-3.4 29.93-9.187 39.946c-5.591 9.686-16.488 19.363-34.818 19.363v-27.616c15.695 0 19.612-14.422 19.612-30.927c0-23.52-5.484-49.623-17.564-68.273c-8.574-13.23-19.684-21.313-31.907-21.313c-13.22 0-23.859 9.97-35.815 27.75c-6.356 9.445-12.882 20.956-20.208 33.944l-8.066 14.289c-16.203 28.728-20.307 35.271-28.408 46.07c-14.2 18.91-26.324 26.076-42.287 26.076c-18.935 0-30.91-8.2-38.325-20.556C2.973 139.413 0 126.202 0 111.148z"/><path fill="url(#logosMetaIcon0)" d="M21.802 33.206C34.48 13.666 52.774 0 73.757 0C85.91 0 97.99 3.597 110.605 13.897c13.798 11.261 28.505 29.805 46.853 60.368l6.58 10.967c15.881 26.459 24.917 40.07 30.205 46.49c6.802 8.243 11.565 10.7 17.752 10.7c15.695 0 19.612-14.422 19.612-30.927l24.393-.766c0 17.253-3.4 29.93-9.187 39.946c-5.591 9.686-16.488 19.363-34.818 19.363c-11.395 0-21.49-2.475-32.654-13.007c-8.582-8.083-18.615-22.443-26.334-35.352l-22.96-38.352C118.528 64.08 107.96 49.73 101.845 43.23c-6.578-6.988-15.036-15.428-28.532-15.428c-10.923 0-20.2 7.666-27.963 19.39z"/><path fill="url(#logosMetaIcon1)" d="M73.312 27.802c-10.923 0-20.2 7.666-27.963 19.39c-10.976 16.568-17.698 41.245-17.698 64.944c0 9.775 2.146 17.28 4.95 21.82L9.027 149.482C2.973 139.413 0 126.202 0 111.148C0 83.772 7.514 55.24 21.802 33.206C34.48 13.666 52.774 0 73.757 0z"/></svg>`,
|
|
69
69
|
import: {
|
|
70
70
|
name: "useScriptMetaPixel",
|
|
71
71
|
from: resolve("./runtime/registry/meta-pixel")
|
|
@@ -147,7 +147,9 @@ function resetMapMarkerMap(_marker: google.maps.marker.AdvancedMarkerElement | P
|
|
|
147
147
|
})
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
async function createAdvancedMapMarker(_options
|
|
150
|
+
async function createAdvancedMapMarker(_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) {
|
|
151
|
+
if (!_options)
|
|
152
|
+
return
|
|
151
153
|
const key = hash(_options)
|
|
152
154
|
if (mapMarkers.value.has(key))
|
|
153
155
|
return mapMarkers.value.get(key)
|
|
@@ -285,7 +287,6 @@ onMounted(() => {
|
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
289
|
for (const k of toAdd) {
|
|
288
|
-
// @ts-expect-error broken
|
|
289
290
|
createAdvancedMapMarker(nextMap.get(k))
|
|
290
291
|
}
|
|
291
292
|
}, {
|
|
@@ -59,7 +59,7 @@ if (props.trigger === 'mousedown' && trigger instanceof Promise) {
|
|
|
59
59
|
}
|
|
60
60
|
onMounted(() => {
|
|
61
61
|
onLoaded(async (instance) => {
|
|
62
|
-
const YouTube
|
|
62
|
+
const YouTube = instance.YT instanceof Promise ? await instance.YT : instance.YT
|
|
63
63
|
await new Promise<void>((resolve) => {
|
|
64
64
|
if (typeof YT.Player === 'undefined')
|
|
65
65
|
YouTube.ready(resolve)
|
|
@@ -23,4 +23,4 @@ declare global {
|
|
|
23
23
|
*
|
|
24
24
|
* A 3P wrapper for Google Analytics that takes an options input to feed into third-party-capital({@link https://github.com/GoogleChromeLabs/third-party-capital}), which returns instructions for nuxt-scripts.
|
|
25
25
|
*/
|
|
26
|
-
export declare function useScriptGoogleAdsense<T extends GoogleAdsenseApi>(_options?: GoogleAdsenseInput): import("
|
|
26
|
+
export declare function useScriptGoogleAdsense<T extends GoogleAdsenseApi>(_options?: GoogleAdsenseInput): import("../composables/useScript").UseScriptContext<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type Vimeo from '@vimeo/player';
|
|
2
|
+
import type { UseScriptContext } from '@unhead/vue';
|
|
2
3
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
4
|
type Constructor<T extends new (...args: any) => any> = T extends new (...args: infer A) => infer R ? new (...args: A) => R : never;
|
|
4
5
|
export interface VimeoPlayerApi {
|
|
@@ -11,5 +12,5 @@ declare global {
|
|
|
11
12
|
interface Window extends VimeoPlayerApi {
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
export declare function useScriptVimeoPlayer<T extends VimeoPlayerApi>(_options?: VimeoPlayerInput):
|
|
15
|
+
export declare function useScriptVimeoPlayer<T extends VimeoPlayerApi>(_options?: VimeoPlayerInput): UseScriptContext<T>;
|
|
15
16
|
export {};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import type { UseScriptContext } from '@unhead/vue';
|
|
2
|
+
import type { MaybePromise } from '../utils.js';
|
|
1
3
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
2
4
|
export interface YouTubePlayerApi {
|
|
3
|
-
YT:
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
YT: MaybePromise<{
|
|
6
|
+
Player: YT.Player;
|
|
7
|
+
PlayerState: YT.PlayerState;
|
|
8
|
+
get(k: string): any;
|
|
9
|
+
loaded: 0 | 1;
|
|
10
|
+
loading: 0 | 1;
|
|
11
|
+
ready(f: () => void): void;
|
|
12
|
+
scan(): void;
|
|
13
|
+
setConfig(config: YT.PlayerOptions): void;
|
|
14
|
+
subscribe<EventName extends keyof YT.Events>(event: EventName, listener: YT.Events[EventName], context?: any): void;
|
|
15
|
+
unsubscribe<EventName extends keyof YT.Events>(event: EventName, listener: YT.Events[EventName], context?: any): void;
|
|
16
|
+
}>;
|
|
6
17
|
}
|
|
7
18
|
declare global {
|
|
8
19
|
interface Window extends YouTubePlayerApi {
|
|
@@ -10,4 +21,4 @@ declare global {
|
|
|
10
21
|
}
|
|
11
22
|
}
|
|
12
23
|
export type YouTubePlayerInput = RegistryScriptInput;
|
|
13
|
-
export declare function useScriptYouTubePlayer<T extends YouTubePlayerApi>(_options: YouTubePlayerInput):
|
|
24
|
+
export declare function useScriptYouTubePlayer<T extends YouTubePlayerApi>(_options: YouTubePlayerInput): UseScriptContext<T>;
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InferInput, ObjectSchema } from 'valibot';
|
|
2
2
|
import type { UseScriptInput } from '@unhead/vue';
|
|
3
3
|
import type { EmptyOptionsSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry } from '#nuxt-scripts';
|
|
4
|
+
export type MaybePromise<T> = Promise<T> | T;
|
|
4
5
|
type OptionsFn<O extends ObjectSchema<any, any>> = (options: InferInput<O>) => ({
|
|
5
6
|
scriptInput?: UseScriptInput;
|
|
6
7
|
scriptOptions?: NuxtUseScriptOptions;
|
|
@@ -8,5 +9,5 @@ type OptionsFn<O extends ObjectSchema<any, any>> = (options: InferInput<O>) => (
|
|
|
8
9
|
clientInit?: () => void;
|
|
9
10
|
});
|
|
10
11
|
export declare function scriptRuntimeConfig<T extends keyof ScriptRegistry>(key: T): ScriptRegistry[T];
|
|
11
|
-
export declare function useRegistryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any, any> = EmptyOptionsSchema, U = {}>(registryKey: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): import("
|
|
12
|
+
export declare function useRegistryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any, any> = EmptyOptionsSchema, U = {}>(registryKey: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): import("./composables/useScript").UseScriptContext<T>;
|
|
12
13
|
export {};
|
package/dist/types.d.mts
CHANGED