nuxt-og-image 2.0.0-beta.7 → 2.0.0-beta.9

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 (35) hide show
  1. package/dist/client/200.html +2 -2
  2. package/dist/client/404.html +2 -2
  3. package/dist/client/_nuxt/{IconCSS.a041aca0.js → IconCSS.ef0613e7.js} +1 -1
  4. package/dist/client/_nuxt/{ImageLoader.9bf39d71.js → ImageLoader.a4418cab.js} +1 -1
  5. package/dist/client/_nuxt/entry.09f25aaf.css +1 -0
  6. package/dist/client/_nuxt/entry.fc9150b0.js +5 -0
  7. package/dist/client/_nuxt/{error-404.1ff52902.js → error-404.02537f9e.js} +1 -1
  8. package/dist/client/_nuxt/{error-500.f7d30da5.js → error-500.a60bf0b5.js} +1 -1
  9. package/dist/client/_nuxt/{error-component.cf7543e5.js → error-component.8148b615.js} +2 -2
  10. package/dist/client/_nuxt/{index.3f356409.js → index.80f38ec7.js} +1 -1
  11. package/dist/client/_nuxt/{options.56a3e5f9.js → options.cc3fd02b.js} +1 -1
  12. package/dist/client/_nuxt/{png.37f3e77b.js → png.62758167.js} +1 -1
  13. package/dist/client/_nuxt/{shiki.3a930bb8.js → shiki.aace8ca2.js} +1 -1
  14. package/dist/client/_nuxt/{svg.186c6bd1.js → svg.853cdaad.js} +1 -1
  15. package/dist/client/_nuxt/{vnodes.a799f183.js → vnodes.69b24963.js} +1 -1
  16. package/dist/client/index.html +2 -2
  17. package/dist/client/options/index.html +2 -2
  18. package/dist/client/png/index.html +2 -2
  19. package/dist/client/svg/index.html +2 -2
  20. package/dist/client/vnodes/index.html +2 -2
  21. package/dist/module.json +1 -1
  22. package/dist/module.mjs +24 -24
  23. package/dist/runtime/browserUtil.mjs +5 -2
  24. package/dist/runtime/nitro/middleware/playground.mjs +4 -3
  25. package/dist/runtime/nitro/renderers/browser.mjs +3 -1
  26. package/dist/runtime/nitro/routes/html.mjs +11 -8
  27. package/dist/runtime/nitro/routes/options.mjs +4 -2
  28. package/dist/runtime/nitro/routes/svg.mjs +3 -1
  29. package/dist/runtime/nitro/routes/vnode.mjs +3 -1
  30. package/dist/runtime/nitro/utils-pure.d.ts +2 -1
  31. package/dist/runtime/nitro/utils.d.ts +1 -1
  32. package/dist/runtime/nitro/utils.mjs +6 -5
  33. package/package.json +14 -13
  34. package/dist/client/_nuxt/entry.74018bda.js +0 -5
  35. package/dist/client/_nuxt/entry.7a8c1ab2.css +0 -1
@@ -1,9 +1,11 @@
1
1
  import { createError, defineEventHandler, getHeaders, getQuery } from "h3";
2
+ import { withoutBase } from "ufo";
2
3
  import { extractOgImageOptions, useHostname } from "../utils.mjs";
3
- import { getRouteRules, useRuntimeConfig } from "#internal/nitro";
4
+ import { getRouteRules } from "#internal/nitro";
5
+ import { useRuntimeConfig } from "#imports";
4
6
  export default defineEventHandler(async (e) => {
5
7
  const query = getQuery(e);
6
- const path = query.path || "/";
8
+ const path = withoutBase(query.path || "/", useRuntimeConfig().app.baseURL);
7
9
  const fetchOptions = process.dev || process.env.prerender ? {
8
10
  headers: getHeaders(e)
9
11
  } : {
@@ -2,8 +2,10 @@ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
2
  import { withBase } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
5
+ import { useRuntimeConfig } from "#imports";
5
6
  export default defineEventHandler(async (e) => {
6
- const path = getQuery(e).path || "/";
7
+ const query = getQuery(e);
8
+ const path = withBase(query.path || "/", useRuntimeConfig().app.baseURL);
7
9
  const options = await fetchOptions(e, path);
8
10
  setHeader(e, "Content-Type", "image/svg+xml");
9
11
  const provider = await useProvider(options.provider);
@@ -2,8 +2,10 @@ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
2
  import { withBase } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
5
+ import { useRuntimeConfig } from "#imports";
5
6
  export default defineEventHandler(async (e) => {
6
- const path = getQuery(e).path || "/";
7
+ const query = getQuery(e);
8
+ const path = withBase(query.path || "/", useRuntimeConfig().app.baseURL);
7
9
  const options = await fetchOptions(e, path);
8
10
  setHeader(e, "Content-Type", "application/json");
9
11
  const provider = await useProvider(options.provider);
@@ -1,3 +1,4 @@
1
+ import type { OgImageOptions } from '../../types';
1
2
  export declare function decodeHtml(html: string): string;
2
- export declare function extractOgImageOptions(html: string): false | Record<string, any>;
3
+ export declare function extractOgImageOptions(html: string): OgImageOptions | false;
3
4
  export declare function stripOgImageOptions(html: string): string;
@@ -11,7 +11,7 @@ export declare function renderIsland(payload: OgImageOptions): Promise<{
11
11
  html: string;
12
12
  head: any;
13
13
  }>;
14
- export declare function useHostname(e: H3Event): any;
14
+ export declare function useHostname(e: H3Event): string;
15
15
  export declare function readPublicAsset(file: string, encoding?: BufferEncoding): Promise<string | Buffer | undefined>;
16
16
  export declare function readPublicAssetBase64(file: string): Promise<string | undefined>;
17
17
  export * from './utils-pure';
@@ -1,6 +1,7 @@
1
1
  import { existsSync, promises as fsp } from "node:fs";
2
2
  import { getHeaders, getQuery, getRequestHeader } from "h3";
3
3
  import { join } from "pathe";
4
+ import { withBase } from "ufo";
4
5
  import { useRuntimeConfig } from "#internal/nitro";
5
6
  export function wasmLoader(key, fallback, baseUrl) {
6
7
  let promise;
@@ -60,18 +61,18 @@ export function renderIsland(payload) {
60
61
  }
61
62
  export function useHostname(e) {
62
63
  const config = useRuntimeConfig()["nuxt-og-image"];
64
+ const base = useRuntimeConfig().app.baseURL;
63
65
  if (!process.dev && config.siteUrl)
64
- return config.siteUrl;
66
+ return withBase(base, config.siteUrl);
65
67
  const host = getRequestHeader(e, "host") || process.env.NITRO_HOST || process.env.HOST || "localhost";
66
68
  const protocol = getRequestHeader(e, "x-forwarded-proto") || "http";
67
69
  const useHttp = process.env.NODE_ENV === "development" || host.includes("127.0.0.1") || host.includes("localhost") || protocol === "http";
68
70
  const port = host.includes(":") ? host.split(":").pop() : process.env.NITRO_PORT || process.env.PORT;
69
- const base = useRuntimeConfig().app.baseURL;
70
- return `http${useHttp ? "" : "s"}://${host.includes(":") ? host.split(":")[0] : host}${port ? `:${port}` : ""}${base}`;
71
+ return withBase(base, `http${useHttp ? "" : "s"}://${host.includes(":") ? host.split(":")[0] : host}${port ? `:${port}` : ""}`);
71
72
  }
72
- const r = (base, key) => {
73
+ function r(base, key) {
73
74
  return join(base, key.replace(/:/g, "/"));
74
- };
75
+ }
75
76
  export async function readPublicAsset(file, encoding) {
76
77
  const { assetDirs } = useRuntimeConfig()["nuxt-og-image"];
77
78
  for (const assetDir of assetDirs) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.7",
5
- "packageManager": "pnpm@7.8.0",
4
+ "version": "2.0.0-beta.9",
5
+ "packageManager": "pnpm@8.1.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
8
8
  "homepage": "https://github.com/harlan-zw/nuxt-og-image#readme",
@@ -26,7 +26,7 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@nuxt/kit": "3.3.1",
29
+ "@nuxt/kit": "3.3.3",
30
30
  "@types/fs-extra": "^11.0.1",
31
31
  "birpc": "^0.2.10",
32
32
  "chalk": "^5.2.0",
@@ -37,10 +37,11 @@
37
37
  "flatted": "^3.2.7",
38
38
  "fs-extra": "^11.1.1",
39
39
  "launch-editor": "^2.6.0",
40
+ "ofetch": "^1.0.1",
40
41
  "ohash": "^1.0.0",
41
42
  "pathe": "^1.1.0",
42
- "playwright-core": "^1.31.2",
43
- "radix3": "^1.0.0",
43
+ "playwright-core": "^1.32.1",
44
+ "radix3": "^1.0.1",
44
45
  "satori": "0.4.4",
45
46
  "satori-html": "^0.3.2",
46
47
  "sirv": "^2.0.2",
@@ -53,18 +54,18 @@
53
54
  "yoga-wasm-web": "^0.3.3"
54
55
  },
55
56
  "devDependencies": {
56
- "@antfu/eslint-config": "^0.37.0",
57
- "@nuxt/devtools-edge": "0.2.5-27992993.59d3c52",
57
+ "@antfu/eslint-config": "^0.38.2",
58
+ "@nuxt/devtools-edge": "0.3.1-28002813.ab4e03d",
58
59
  "@nuxt/module-builder": "^0.2.1",
59
- "@nuxt/test-utils": "3.3.1",
60
+ "@nuxt/test-utils": "3.3.3",
60
61
  "@nuxtjs/eslint-config-typescript": "^12.0.0",
61
62
  "@types/ws": "^8.5.4",
62
- "bumpp": "^9.0.0",
63
- "eslint": "8.36.0",
63
+ "bumpp": "^9.1.0",
64
+ "eslint": "8.37.0",
64
65
  "jest-image-snapshot": "^6.1.0",
65
- "nuxt": "^3.3.1",
66
- "puppeteer": "^19.7.5",
67
- "vitest": "^0.29.7"
66
+ "nuxt": "^3.3.3",
67
+ "puppeteer": "^19.8.2",
68
+ "vitest": "^0.29.8"
68
69
  },
69
70
  "scripts": {
70
71
  "build": "pnpm dev:prepare && pnpm build:module && pnpm build:client",