@nuxt/scripts 1.0.0-beta.21 → 1.0.0-beta.23
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 +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/{BlmrFwhD.js → B7aPLMNo.js} +1 -1
- package/dist/client/_nuxt/{DvbTvDd0.js → BNNMZFwZ.js} +21 -21
- package/dist/client/_nuxt/{BwCYQWJt.js → Bh9fd9qr.js} +1 -1
- package/dist/client/_nuxt/{ZrewjUYk.js → UTi7FhVv.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/39ee5395-65bb-4a46-82e0-e68853f94418.json +1 -0
- package/dist/client/_nuxt/error-404.DMdWw4vT.css +1 -0
- package/dist/client/_nuxt/error-500.CROTF27X.css +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +2 -2
- package/dist/module.d.ts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +60 -52
- package/dist/registry.mjs +30 -4
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +3 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +14 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +3 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +2 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptBlueskyEmbed.d.vue.ts +87 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue +85 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue.d.ts +87 -0
- package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptInstagramEmbed.vue +4 -1
- package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptXEmbed.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptXEmbed.vue +5 -2
- package/dist/runtime/components/ScriptXEmbed.vue.d.ts +2 -2
- package/dist/runtime/registry/bluesky-embed.d.ts +116 -0
- package/dist/runtime/registry/bluesky-embed.js +72 -0
- package/dist/runtime/registry/gravatar.js +2 -2
- package/dist/runtime/registry/schemas.d.ts +20 -3
- package/dist/runtime/registry/schemas.js +20 -3
- package/dist/runtime/registry/x-embed.js +1 -1
- package/dist/runtime/server/bluesky-embed-image.d.ts +2 -0
- package/dist/runtime/server/bluesky-embed-image.js +7 -0
- package/dist/runtime/server/bluesky-embed.d.ts +16 -0
- package/dist/runtime/server/bluesky-embed.js +59 -0
- package/dist/runtime/server/google-maps-geocode-proxy.d.ts +2 -0
- package/dist/runtime/server/google-maps-geocode-proxy.js +34 -0
- package/dist/runtime/server/google-static-maps-proxy.js +1 -12
- package/dist/runtime/server/gravatar-proxy.js +1 -16
- package/dist/runtime/server/instagram-embed-asset.js +8 -42
- package/dist/runtime/server/instagram-embed-image.js +6 -54
- package/dist/runtime/server/instagram-embed.d.ts +16 -0
- package/dist/runtime/server/instagram-embed.js +171 -42
- package/dist/runtime/server/utils/image-proxy.d.ts +12 -0
- package/dist/runtime/server/utils/image-proxy.js +70 -0
- package/dist/runtime/server/x-embed-image.js +5 -49
- package/dist/runtime/types.d.ts +11 -0
- package/dist/runtime/utils.d.ts +1 -0
- package/dist/runtime/utils.js +11 -2
- package/dist/stats.mjs +1 -1
- package/dist/types-source.d.mts +0 -2
- package/dist/types-source.d.ts +0 -2
- package/dist/types-source.mjs +1960 -941
- package/package.json +8 -7
- package/dist/client/_nuxt/builds/meta/6660a023-888d-415f-b66d-ce774e6f8f11.json +0 -1
- package/dist/client/_nuxt/error-404.CHeaW3dp.css +0 -1
- package/dist/client/_nuxt/error-500.DvOvWme_.css +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
3
|
+
const AMP_RE = /&/g;
|
|
4
|
+
export function createImageProxyHandler(config) {
|
|
5
|
+
const {
|
|
6
|
+
accept = "image/webp,image/jpeg,image/png,image/*,*/*;q=0.8",
|
|
7
|
+
userAgent,
|
|
8
|
+
cacheMaxAge = 3600,
|
|
9
|
+
contentType = "image/jpeg",
|
|
10
|
+
followRedirects = true,
|
|
11
|
+
decodeAmpersands = false
|
|
12
|
+
} = config;
|
|
13
|
+
return defineEventHandler(async (event) => {
|
|
14
|
+
const query = getQuery(event);
|
|
15
|
+
let url = query.url;
|
|
16
|
+
if (decodeAmpersands && url)
|
|
17
|
+
url = url.replace(AMP_RE, "&");
|
|
18
|
+
if (!url) {
|
|
19
|
+
throw createError({
|
|
20
|
+
statusCode: 400,
|
|
21
|
+
statusMessage: "Image URL is required"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
let parsedUrl;
|
|
25
|
+
try {
|
|
26
|
+
parsedUrl = new URL(url);
|
|
27
|
+
} catch {
|
|
28
|
+
throw createError({
|
|
29
|
+
statusCode: 400,
|
|
30
|
+
statusMessage: "Invalid image URL"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
34
|
+
throw createError({
|
|
35
|
+
statusCode: 400,
|
|
36
|
+
statusMessage: "Invalid URL scheme"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const domainAllowed = typeof config.allowedDomains === "function" ? config.allowedDomains(parsedUrl.hostname) : config.allowedDomains.includes(parsedUrl.hostname);
|
|
40
|
+
if (!domainAllowed) {
|
|
41
|
+
throw createError({
|
|
42
|
+
statusCode: 403,
|
|
43
|
+
statusMessage: "Domain not allowed"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const headers = { Accept: accept };
|
|
47
|
+
if (userAgent)
|
|
48
|
+
headers["User-Agent"] = userAgent;
|
|
49
|
+
const response = await $fetch.raw(url, {
|
|
50
|
+
timeout: 5e3,
|
|
51
|
+
redirect: followRedirects ? "follow" : "manual",
|
|
52
|
+
ignoreResponseError: !followRedirects,
|
|
53
|
+
headers
|
|
54
|
+
}).catch((error) => {
|
|
55
|
+
throw createError({
|
|
56
|
+
statusCode: error.statusCode || 500,
|
|
57
|
+
statusMessage: error.statusMessage || "Failed to fetch image"
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
if (!followRedirects && response.status >= 300 && response.status < 400) {
|
|
61
|
+
throw createError({
|
|
62
|
+
statusCode: 403,
|
|
63
|
+
statusMessage: "Redirects not allowed"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
setHeader(event, "Content-Type", response.headers.get("content-type") || contentType);
|
|
67
|
+
setHeader(event, "Cache-Control", `public, max-age=${cacheMaxAge}, s-maxage=${cacheMaxAge}`);
|
|
68
|
+
return response._data;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -1,53 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const query = getQuery(event);
|
|
5
|
-
const url = query.url;
|
|
6
|
-
if (!url) {
|
|
7
|
-
throw createError({
|
|
8
|
-
statusCode: 400,
|
|
9
|
-
statusMessage: "Image URL is required"
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
let parsedUrl;
|
|
13
|
-
try {
|
|
14
|
-
parsedUrl = new URL(url);
|
|
15
|
-
} catch {
|
|
16
|
-
throw createError({
|
|
17
|
-
statusCode: 400,
|
|
18
|
-
statusMessage: "Invalid image URL"
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
22
|
-
throw createError({
|
|
23
|
-
statusCode: 400,
|
|
24
|
-
statusMessage: "Invalid URL scheme"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const allowedDomains = [
|
|
1
|
+
import { createImageProxyHandler } from "./utils/image-proxy.js";
|
|
2
|
+
export default createImageProxyHandler({
|
|
3
|
+
allowedDomains: [
|
|
28
4
|
"pbs.twimg.com",
|
|
29
5
|
"abs.twimg.com",
|
|
30
6
|
"video.twimg.com"
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
throw createError({
|
|
34
|
-
statusCode: 403,
|
|
35
|
-
statusMessage: "Domain not allowed"
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
const response = await $fetch.raw(url, {
|
|
39
|
-
timeout: 5e3,
|
|
40
|
-
headers: {
|
|
41
|
-
"Accept": "image/webp,image/jpeg,image/png,image/*,*/*;q=0.8",
|
|
42
|
-
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
|
|
43
|
-
}
|
|
44
|
-
}).catch((error) => {
|
|
45
|
-
throw createError({
|
|
46
|
-
statusCode: error.statusCode || 500,
|
|
47
|
-
statusMessage: error.statusMessage || "Failed to fetch image"
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
setHeader(event, "Content-Type", response.headers.get("content-type") || "image/jpeg");
|
|
51
|
-
setHeader(event, "Cache-Control", "public, max-age=3600, s-maxage=3600");
|
|
52
|
-
return response._data;
|
|
7
|
+
],
|
|
8
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
|
|
53
9
|
});
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Script } from '@unhead/vue/types';
|
|
|
3
3
|
import type { Import } from 'unimport';
|
|
4
4
|
import type { InferInput, ObjectSchema, UnionSchema, ValiError } from 'valibot';
|
|
5
5
|
import type { ComputedRef, Ref } from 'vue';
|
|
6
|
+
import type { BlueskyEmbedInput } from './registry/bluesky-embed.js';
|
|
6
7
|
import type { ClarityInput } from './registry/clarity.js';
|
|
7
8
|
import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics.js';
|
|
8
9
|
import type { CrispInput } from './registry/crisp.js';
|
|
@@ -155,6 +156,7 @@ export interface NuxtDevToolsScriptInstance {
|
|
|
155
156
|
}[];
|
|
156
157
|
}
|
|
157
158
|
export interface ScriptRegistry {
|
|
159
|
+
blueskyEmbed?: BlueskyEmbedInput;
|
|
158
160
|
crisp?: CrispInput;
|
|
159
161
|
clarity?: ClarityInput;
|
|
160
162
|
cloudflareWebAnalytics?: CloudflareWebAnalyticsInput;
|
|
@@ -214,6 +216,11 @@ export type RegistryScriptInput<T = EmptyOptionsSchema, Bundelable extends boole
|
|
|
214
216
|
scriptInput: Required<Pick<ScriptInput, 'src'>> & ScriptInput;
|
|
215
217
|
scriptOptions?: Omit<NuxtUseScriptOptions, Bundelable extends true ? '' : 'bundle' | Usable extends true ? '' : 'use'>;
|
|
216
218
|
} : never);
|
|
219
|
+
export interface RegistryScriptServerHandler {
|
|
220
|
+
route: string;
|
|
221
|
+
handler: string;
|
|
222
|
+
middleware?: boolean;
|
|
223
|
+
}
|
|
217
224
|
export interface RegistryScript {
|
|
218
225
|
/**
|
|
219
226
|
* The config key used in `scripts.registry` in nuxt.config (e.g., 'googleAnalytics', 'plausibleAnalytics').
|
|
@@ -240,6 +247,10 @@ export interface RegistryScript {
|
|
|
240
247
|
light: string;
|
|
241
248
|
dark: string;
|
|
242
249
|
};
|
|
250
|
+
/**
|
|
251
|
+
* Server handlers (routes/middleware) to register when this script is enabled via registry config.
|
|
252
|
+
*/
|
|
253
|
+
serverHandlers?: RegistryScriptServerHandler[];
|
|
243
254
|
}
|
|
244
255
|
export type ElementScriptTrigger = 'immediate' | 'visible' | string | string[] | false;
|
|
245
256
|
export type RegistryScripts = RegistryScript[];
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
|
|
|
14
14
|
scriptMode?: 'external' | 'npm';
|
|
15
15
|
});
|
|
16
16
|
export declare function scriptRuntimeConfig<T extends keyof ScriptRegistry>(key: T): ScriptRegistry[T];
|
|
17
|
+
export declare function requireRegistryEndpoint(componentName: string, registryKey: string): void;
|
|
17
18
|
export declare function useRegistryScript<T extends Record<string | symbol, any>, O = EmptyOptionsSchema>(registryKey: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): UseScriptContext<UseFunctionType<NuxtUseScriptOptions<T>, T>>;
|
|
18
19
|
export * from './utils/pure.js';
|
package/dist/runtime/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parse } from "#nuxt-scripts-validator";
|
|
2
2
|
import { defu } from "defu";
|
|
3
|
-
import { useRuntimeConfig } from "nuxt/app";
|
|
3
|
+
import { createError, useRuntimeConfig } from "nuxt/app";
|
|
4
4
|
import { parseQuery, parseURL, withQuery } from "ufo";
|
|
5
5
|
import { useScript } from "./composables/useScript.js";
|
|
6
6
|
import { createNpmScriptStub } from "./npm-script-stub.js";
|
|
@@ -21,6 +21,15 @@ function validateScriptInputSchema(key, schema, options) {
|
|
|
21
21
|
export function scriptRuntimeConfig(key) {
|
|
22
22
|
return (useRuntimeConfig().public.scripts || {})[key];
|
|
23
23
|
}
|
|
24
|
+
export function requireRegistryEndpoint(componentName, registryKey) {
|
|
25
|
+
const endpoints = useRuntimeConfig().public["nuxt-scripts"]?.endpoints;
|
|
26
|
+
if (!endpoints?.[registryKey]) {
|
|
27
|
+
throw createError({
|
|
28
|
+
message: `${componentName} requires \`scripts.registry.${registryKey}\` to be enabled in nuxt.config`,
|
|
29
|
+
fatal: import.meta.dev
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
export function useRegistryScript(registryKey, optionsFn, _userOptions) {
|
|
25
34
|
const scriptConfig = scriptRuntimeConfig(registryKey);
|
|
26
35
|
const userOptions = Object.assign(_userOptions || {}, typeof scriptConfig === "object" ? scriptConfig : {});
|
|
@@ -49,7 +58,7 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
|
|
|
49
58
|
};
|
|
50
59
|
}
|
|
51
60
|
const scriptInput = defu(finalScriptInput, userOptions.scriptInput, { key: registryKey });
|
|
52
|
-
const scriptOptions =
|
|
61
|
+
const scriptOptions = { ...userOptions?.scriptOptions, ...options.scriptOptions };
|
|
53
62
|
if (import.meta.dev) {
|
|
54
63
|
const error = new Error("Stack trace for component location");
|
|
55
64
|
const stack = error.stack?.split("\n");
|
package/dist/stats.mjs
CHANGED
|
@@ -734,7 +734,7 @@ function deriveMetaKey(importName, label) {
|
|
|
734
734
|
async function getScriptStats() {
|
|
735
735
|
const { registry } = await import('./registry.mjs');
|
|
736
736
|
const entries = await registry();
|
|
737
|
-
const proxyConfigs = getAllProxyConfigs("/_scripts");
|
|
737
|
+
const proxyConfigs = getAllProxyConfigs("/_scripts/assets");
|
|
738
738
|
const sizes = scriptSizes;
|
|
739
739
|
return entries.map((entry) => {
|
|
740
740
|
const metaKey = deriveMetaKey(entry.import?.name, entry.label);
|
package/dist/types-source.d.mts
CHANGED