nuxt-og-image 3.0.0-beta.5 → 3.0.0-beta.50

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 (138) hide show
  1. package/README.md +4 -4
  2. package/dist/client/200.html +5 -5
  3. package/dist/client/404.html +5 -5
  4. package/dist/client/_nuxt/IconCSS.4bbe2613.css +1 -0
  5. package/dist/client/_nuxt/IconCSS.d8f7e776.js +1 -0
  6. package/dist/client/_nuxt/builds/latest.json +1 -1
  7. package/dist/client/_nuxt/builds/meta/f9e0dbe6-38fd-47dd-8f6b-48b4397277f5.json +1 -0
  8. package/dist/client/_nuxt/entry.33a59bbf.css +1 -0
  9. package/dist/client/_nuxt/entry.38814731.js +138 -0
  10. package/dist/client/_nuxt/{error-404.b07f263f.js → error-404.7bf54a75.js} +1 -1
  11. package/dist/client/_nuxt/{error-500.ed41d8f2.js → error-500.f7cb671d.js} +1 -1
  12. package/dist/client/index.html +5 -5
  13. package/dist/module.d.mts +55 -46
  14. package/dist/module.d.ts +55 -46
  15. package/dist/module.json +2 -2
  16. package/dist/module.mjs +306 -162
  17. package/dist/runtime/cache.d.ts +7 -10
  18. package/dist/runtime/cache.mjs +40 -27
  19. package/dist/runtime/components/OgImage/OgImage.d.ts +5 -0
  20. package/dist/runtime/components/OgImage/{index.mjs → OgImage.mjs} +1 -1
  21. package/dist/runtime/components/OgImage/OgImageScreenshot.d.ts +5 -0
  22. package/dist/runtime/components/OgImage/{Screenshot.mjs → OgImageScreenshot.mjs} +1 -1
  23. package/dist/runtime/components/Templates/{Official → Community}/BrandedLogo.vue +3 -2
  24. package/dist/runtime/components/Templates/Community/Nuxt.vue +6 -5
  25. package/dist/runtime/components/Templates/Community/NuxtSeo.vue +137 -0
  26. package/dist/runtime/components/Templates/Community/Pergel.vue +104 -0
  27. package/dist/runtime/components/Templates/{Official → Community}/SimpleBlog.vue +7 -5
  28. package/dist/runtime/components/Templates/Community/UnJs.vue +108 -0
  29. package/dist/runtime/components/Templates/{Official → Community}/Wave.vue +3 -2
  30. package/dist/runtime/components/Templates/{Official → Community}/WithEmoji.vue +3 -2
  31. package/dist/runtime/composables/defineOgImage.d.ts +2 -23
  32. package/dist/runtime/composables/defineOgImage.mjs +33 -117
  33. package/dist/runtime/composables/defineOgImageComponent.d.ts +3 -0
  34. package/dist/runtime/composables/defineOgImageComponent.mjs +8 -0
  35. package/dist/runtime/composables/defineOgImageScreenshot.d.ts +2 -0
  36. package/dist/runtime/composables/defineOgImageScreenshot.mjs +13 -0
  37. package/dist/runtime/core/bindings/css-inline/node.d.ts +2 -5
  38. package/dist/runtime/core/bindings/css-inline/node.mjs +2 -10
  39. package/dist/runtime/core/bindings/resvg/wasm-fs.d.ts +40 -0
  40. package/dist/runtime/core/bindings/resvg/wasm-fs.mjs +6 -0
  41. package/dist/runtime/core/bindings/resvg/wasm.mjs +2 -2
  42. package/dist/runtime/core/bindings/satori/wasm-fs.mjs +13 -0
  43. package/dist/runtime/core/bindings/satori/wasm.d.ts +6 -0
  44. package/dist/runtime/core/bindings/satori/wasm.mjs +14 -0
  45. package/dist/runtime/core/cache/emojis.d.ts +1 -0
  46. package/dist/runtime/core/cache/emojis.mjs +5 -0
  47. package/dist/runtime/core/cache/htmlPayload.d.ts +5 -0
  48. package/dist/runtime/core/cache/htmlPayload.mjs +6 -0
  49. package/dist/runtime/core/cache/prerender.d.ts +1 -1
  50. package/dist/runtime/core/cache/prerender.mjs +1 -1
  51. package/dist/runtime/core/env/assets.d.ts +0 -1
  52. package/dist/runtime/core/env/assets.mjs +0 -4
  53. package/dist/runtime/core/font/fetch.d.ts +2 -3
  54. package/dist/runtime/core/font/fetch.mjs +32 -15
  55. package/dist/runtime/core/html/applyEmojis.d.ts +3 -0
  56. package/dist/runtime/core/html/applyEmojis.mjs +37 -0
  57. package/dist/runtime/core/html/applyInlineCss.d.ts +3 -0
  58. package/dist/runtime/core/html/applyInlineCss.mjs +32 -0
  59. package/dist/runtime/core/html/devIframeTemplate.d.ts +2 -0
  60. package/dist/runtime/core/html/{fetch.mjs → devIframeTemplate.mjs} +33 -42
  61. package/dist/runtime/core/html/fetchIsland.d.ts +3 -0
  62. package/dist/runtime/core/html/fetchIsland.mjs +17 -0
  63. package/dist/runtime/core/options/fetch.d.ts +1 -1
  64. package/dist/runtime/core/options/fetch.mjs +10 -5
  65. package/dist/runtime/core/renderers/chromium/index.mjs +16 -13
  66. package/dist/runtime/core/renderers/chromium/screenshot.d.ts +2 -3
  67. package/dist/runtime/core/renderers/chromium/screenshot.mjs +18 -13
  68. package/dist/runtime/core/renderers/satori/fonts.d.ts +2 -2
  69. package/dist/runtime/core/renderers/satori/fonts.mjs +2 -2
  70. package/dist/runtime/core/renderers/satori/index.d.ts +2 -3
  71. package/dist/runtime/core/renderers/satori/index.mjs +26 -22
  72. package/dist/runtime/core/renderers/satori/instances.d.ts +3 -0
  73. package/dist/runtime/core/renderers/satori/instances.mjs +15 -0
  74. package/dist/runtime/core/renderers/satori/plugins/emojis.mjs +15 -13
  75. package/dist/runtime/core/renderers/satori/plugins/imageSrc.mjs +23 -10
  76. package/dist/runtime/core/renderers/satori/plugins/unocss.d.ts +2 -0
  77. package/dist/runtime/core/renderers/satori/plugins/unocss.mjs +45 -0
  78. package/dist/runtime/core/renderers/satori/utils.d.ts +2 -3
  79. package/dist/runtime/core/renderers/satori/vnodes.d.ts +2 -3
  80. package/dist/runtime/core/renderers/satori/vnodes.mjs +16 -6
  81. package/dist/runtime/core/utils/resolveRendererContext.d.ts +2 -6
  82. package/dist/runtime/core/utils/resolveRendererContext.mjs +47 -29
  83. package/dist/runtime/core/utils/wasm.d.ts +3 -0
  84. package/dist/runtime/core/utils/wasm.mjs +16 -0
  85. package/dist/runtime/nitro/plugins/nuxt-content.mjs +3 -4
  86. package/dist/runtime/nitro/plugins/prerender.d.ts +1 -1
  87. package/dist/runtime/nitro/plugins/prerender.mjs +22 -14
  88. package/dist/runtime/nitro/utils.d.ts +2 -0
  89. package/dist/runtime/nitro/utils.mjs +17 -0
  90. package/dist/runtime/nuxt/plugins/og-image-canonical-urls.server.mjs +31 -0
  91. package/dist/runtime/nuxt/plugins/route-rule-og-image.server.mjs +16 -51
  92. package/dist/runtime/nuxt/utils.d.ts +3 -0
  93. package/dist/runtime/nuxt/utils.mjs +69 -0
  94. package/dist/runtime/server/routes/__og-image__/debug.json.d.ts +2 -3
  95. package/dist/runtime/server/routes/__og-image__/debug.json.mjs +5 -7
  96. package/dist/runtime/server/routes/__og-image__/image.mjs +88 -0
  97. package/dist/runtime/types.d.ts +89 -25
  98. package/dist/runtime/utils.d.ts +4 -0
  99. package/dist/runtime/utils.mjs +11 -0
  100. package/dist/runtime/utils.pure.d.ts +5 -0
  101. package/dist/runtime/utils.pure.mjs +43 -0
  102. package/package.json +30 -31
  103. package/virtual.d.ts +49 -0
  104. package/dist/client/_nuxt/IconCSS.8f429b14.css +0 -1
  105. package/dist/client/_nuxt/IconCSS.b16882c0.js +0 -1
  106. package/dist/client/_nuxt/builds/meta/df74ddc4-3ccb-4ada-8e61-014943e6befc.json +0 -1
  107. package/dist/client/_nuxt/entry.434c2c45.css +0 -1
  108. package/dist/client/_nuxt/entry.d4edd2a5.js +0 -137
  109. package/dist/client/grid.png +0 -0
  110. package/dist/runtime/components/OgImage/Cached.d.ts +0 -5
  111. package/dist/runtime/components/OgImage/Cached.mjs +0 -10
  112. package/dist/runtime/components/OgImage/Dynamic.d.ts +0 -8
  113. package/dist/runtime/components/OgImage/Dynamic.mjs +0 -10
  114. package/dist/runtime/components/OgImage/Screenshot.d.ts +0 -6
  115. package/dist/runtime/components/OgImage/Static.d.ts +0 -8
  116. package/dist/runtime/components/OgImage/Static.mjs +0 -10
  117. package/dist/runtime/components/OgImage/WithoutCache.d.ts +0 -5
  118. package/dist/runtime/components/OgImage/WithoutCache.mjs +0 -10
  119. package/dist/runtime/components/OgImage/index.d.ts +0 -5
  120. package/dist/runtime/components/Templates/Official/Fallback.vue +0 -147
  121. package/dist/runtime/core/bindings/css-inline/mock.d.ts +0 -5
  122. package/dist/runtime/core/bindings/css-inline/mock.mjs +0 -3
  123. package/dist/runtime/core/bindings/satori/yoga-wasm.mjs +0 -7
  124. package/dist/runtime/core/bindings/sharp/wasm.d.ts +0 -2
  125. package/dist/runtime/core/bindings/sharp/wasm.mjs +0 -2
  126. package/dist/runtime/core/html/fetch.d.ts +0 -3
  127. package/dist/runtime/core/options/normalise.d.ts +0 -2
  128. package/dist/runtime/core/options/normalise.mjs +0 -26
  129. package/dist/runtime/nuxt/plugins/nuxt-content-canonical-urls.mjs +0 -29
  130. package/dist/runtime/public-assets/__nuxt_og_image__/browser-provider-not-supported.png +0 -0
  131. package/dist/runtime/server/routes/__og-image__/image-[path]-og.[extension].mjs +0 -45
  132. package/dist/runtime/utilts.d.ts +0 -2
  133. package/dist/runtime/utilts.mjs +0 -8
  134. /package/dist/runtime/core/bindings/satori/{yoga-wasm.d.ts → wasm-fs.d.ts} +0 -0
  135. /package/dist/runtime/nuxt/plugins/{nuxt-content-canonical-urls.d.ts → og-image-canonical-urls.server.d.ts} +0 -0
  136. /package/dist/runtime/{public-assets-optional/inter-font → server/assets}/inter-latin-ext-400-normal.woff +0 -0
  137. /package/dist/runtime/{public-assets-optional/inter-font → server/assets}/inter-latin-ext-700-normal.woff +0 -0
  138. /package/dist/runtime/server/routes/__og-image__/{image-[path]-og.[extension].d.ts → image.d.ts} +0 -0
@@ -1,124 +1,40 @@
1
1
  import { defu } from "defu";
2
2
  import { appendHeader } from "h3";
3
- import { getOgImagePath } from "../utilts.mjs";
4
- import { normaliseOptions } from "../core/options/normalise.mjs";
5
- import { useRouter, useRuntimeConfig, useServerHead, withSiteUrl } from "#imports";
6
- export function defineOgImageScreenshot(options = {}) {
7
- const router = useRouter();
8
- const route = router.currentRoute.value?.path || "";
9
- return defineOgImage({
10
- alt: `Web page screenshot${route ? ` of ${route}` : ""}.`,
11
- renderer: "chromium",
12
- extension: "jpeg",
13
- component: "PageScreenshot",
14
- // this is an alias
15
- cache: true,
16
- ...options
17
- });
18
- }
19
- export function defineOgImageStatic(options = {}) {
20
- return defineOgImageCached(options);
21
- }
22
- export function defineOgImageCached(options = {}) {
23
- const { defaults } = useRuntimeConfig()["nuxt-og-image"];
24
- if (!defaults.cacheTtl && !options.cacheTtl)
25
- options.cacheTtl = 60 * 60 * 24 * 1e3 * 7;
26
- return defineOgImage({
27
- cache: true,
28
- ...options
29
- });
30
- }
31
- export function defineOgImageWithoutCache(options = {}) {
32
- return defineOgImage({
33
- ...options,
34
- cache: false,
35
- cacheTtl: 0
36
- });
37
- }
38
- export function defineOgImageDynamic(options = {}) {
39
- return defineOgImageWithoutCache(options);
40
- }
41
- export function defineOgImageComponent(component, props, options = {}) {
42
- defineOgImage({
43
- component,
44
- ...props,
45
- ...options
46
- });
47
- }
3
+ import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
4
+ import { withoutBase } from "ufo";
5
+ import { getOgImagePath, separateProps, useOgImageRuntimeConfig } from "../utils.mjs";
6
+ import { createOgImageMeta, normaliseOptions } from "../nuxt/utils.mjs";
7
+ import { useNuxtApp, useRequestEvent, useRouter, useRuntimeConfig } from "#imports";
48
8
  export function defineOgImage(_options = {}) {
49
- if (import.meta.server) {
50
- if (_options.url) {
51
- const type = _options.url.endsWith(".png") ? "image/png" : "image/jpeg";
52
- const meta2 = [
53
- { property: "og:image", content: _options.url },
54
- { property: "og:image:type", content: type },
55
- { name: "twitter:card", content: "summary_large_image" },
56
- { name: "twitter:image:src", content: _options.url }
57
- ];
58
- if (_options.width) {
59
- meta2.push({ property: "og:image:width", content: _options.width });
60
- meta2.push({ name: "twitter:image:width", content: _options.width });
61
- }
62
- if (_options.height) {
63
- meta2.push({ property: "og:image:height", content: _options.height });
64
- meta2.push({ name: "twitter:image:height", content: _options.height });
65
- }
66
- if (_options.alt) {
67
- meta2.push({ property: "og:image:alt", content: _options.alt });
68
- meta2.push({ name: "twitter:image:alt", content: _options.alt });
69
- }
70
- useServerHead({ meta: meta2 }, {
71
- // after async scripts when capo.js is enabled
72
- tagPriority: 35
73
- });
74
- return;
75
- }
76
- const { defaults } = useRuntimeConfig()["nuxt-og-image"];
77
- const options = normaliseOptions(_options);
78
- const optionsWithDefault = defu(options, defaults);
79
- const path = getOgImagePath(useRouter().currentRoute.value?.path, optionsWithDefault.extension);
80
- const src = withSiteUrl(path);
9
+ if (!import.meta.server)
10
+ return;
11
+ const nuxtApp = useNuxtApp();
12
+ const ogImageInstances = nuxtApp.ssrContext._ogImageInstances || [];
13
+ const basePath = useRouter().currentRoute.value?.path || "/";
14
+ const _routeRulesMatcher = toRouteMatcher(
15
+ createRadixRouter({ routes: useRuntimeConfig().nitro?.routeRules })
16
+ );
17
+ const routeRules = defu({}, ..._routeRulesMatcher.matchAll(
18
+ withoutBase(basePath.split("?")[0], useRuntimeConfig().app.baseURL)
19
+ ).reverse()).ogImage;
20
+ if (!_options || nuxtApp.ssrContext?.event.context._nitro?.routeRules?.ogImage === false || typeof routeRules !== "undefined" && routeRules === false) {
21
+ ogImageInstances.forEach((e) => {
22
+ e.dispose();
23
+ });
24
+ nuxtApp.ssrContext._ogImageInstances = void 0;
25
+ return;
26
+ }
27
+ const options = normaliseOptions({
28
+ ..._options
29
+ });
30
+ const { defaults } = useOgImageRuntimeConfig();
31
+ const resolvedOptions = normaliseOptions(defu(separateProps(_options), separateProps(routeRules), defaults));
32
+ if (_options.url) {
33
+ createOgImageMeta(null, options, resolvedOptions, nuxtApp.ssrContext);
34
+ } else {
35
+ const path = getOgImagePath(basePath, resolvedOptions);
81
36
  if (import.meta.prerender)
82
37
  appendHeader(useRequestEvent(), "x-nitro-prerender", path);
83
- const meta = [
84
- { property: "og:image", content: src },
85
- { property: "og:image:width", content: optionsWithDefault.width },
86
- { property: "og:image:height", content: optionsWithDefault.height },
87
- { property: "og:image:type", content: `image/${optionsWithDefault.extension}` }
88
- ];
89
- if (optionsWithDefault.alt)
90
- meta.push({ property: "og:image:alt", content: optionsWithDefault.alt });
91
- meta.push(...[
92
- { name: "twitter:card", content: "summary_large_image" },
93
- { name: "twitter:image:src", content: src },
94
- { name: "twitter:image:width", content: optionsWithDefault.width },
95
- { name: "twitter:image:height", content: optionsWithDefault.height }
96
- ]);
97
- if (optionsWithDefault.alt)
98
- meta.push({ name: "twitter:image:alt", content: optionsWithDefault.alt });
99
- useServerHead({
100
- meta,
101
- script: [
102
- {
103
- id: "nuxt-og-image-options",
104
- type: "application/json",
105
- processTemplateParams: true,
106
- innerHTML: () => {
107
- const payload = {
108
- title: "%s"
109
- };
110
- Object.entries(options).forEach(([key, val]) => {
111
- payload[key.replace(/-([a-z])/g, (g) => g[1].toUpperCase())] = val;
112
- });
113
- return payload;
114
- },
115
- // we want this to be last in our head
116
- tagPosition: "bodyClose"
117
- }
118
- ]
119
- }, {
120
- // after async scripts when capo.js is enabled
121
- tagPriority: 35
122
- });
38
+ createOgImageMeta(path, options, resolvedOptions, nuxtApp.ssrContext);
123
39
  }
124
40
  }
@@ -0,0 +1,3 @@
1
+ import type { ExtractComponentProps, OgImageOptions } from '../types';
2
+ import type { OgImageComponents } from '#nuxt-og-image/components';
3
+ export declare function defineOgImageComponent<T extends keyof OgImageComponents>(component: T, props?: Partial<ExtractComponentProps<OgImageComponents[T]>>, options?: OgImageOptions): void;
@@ -0,0 +1,8 @@
1
+ import { defineOgImage } from "./defineOgImage.mjs";
2
+ export function defineOgImageComponent(component, props = {}, options = {}) {
3
+ return defineOgImage({
4
+ ...options,
5
+ component,
6
+ props
7
+ });
8
+ }
@@ -0,0 +1,2 @@
1
+ import type { OgImagePageScreenshotOptions } from '../types';
2
+ export declare function defineOgImageScreenshot(options?: OgImagePageScreenshotOptions): any;
@@ -0,0 +1,13 @@
1
+ import { defineOgImage, useRouter } from "#imports";
2
+ export function defineOgImageScreenshot(options = {}) {
3
+ const router = useRouter();
4
+ const route = router.currentRoute.value?.path || "/";
5
+ return defineOgImage({
6
+ alt: `Web page screenshot${route ? ` of ${route}` : ""}.`,
7
+ renderer: "chromium",
8
+ extension: "jpeg",
9
+ component: "PageScreenshot",
10
+ // this is an alias
11
+ ...options
12
+ });
13
+ }
@@ -1,5 +1,2 @@
1
- declare function nodeFn(html: string, options: any): string;
2
- declare namespace nodeFn {
3
- var __mock: boolean;
4
- }
5
- export default nodeFn;
1
+ import cssInline from 'css-inline';
2
+ export default cssInline;
@@ -1,10 +1,2 @@
1
- import { inline } from "css-inline";
2
- function nodeFn(html, options) {
3
- return inline(html, {
4
- ...options,
5
- load_remote_stylesheets: false,
6
- keep_style_tags: false
7
- });
8
- }
9
- nodeFn.__mock = false;
10
- export default nodeFn;
1
+ import cssInline from "css-inline";
2
+ export default cssInline;
@@ -0,0 +1,40 @@
1
+ declare const _default: {
2
+ initWasmPromise: Promise<void>;
3
+ Resvg: new (svg: string | Uint8Array, options?: import("@resvg/resvg-wasm").ResvgRenderOptions | undefined) => {
4
+ free(): void;
5
+ render(): {
6
+ free(): void;
7
+ asPng(): Uint8Array;
8
+ readonly height: number;
9
+ readonly pixels: Uint8Array;
10
+ readonly width: number;
11
+ };
12
+ toString(): string;
13
+ innerBBox(): {
14
+ free(): void;
15
+ height: number;
16
+ width: number;
17
+ x: number;
18
+ y: number;
19
+ } | undefined;
20
+ getBBox(): {
21
+ free(): void;
22
+ height: number;
23
+ width: number;
24
+ x: number;
25
+ y: number;
26
+ } | undefined;
27
+ cropByBBox(bbox: {
28
+ free(): void;
29
+ height: number;
30
+ width: number;
31
+ x: number;
32
+ y: number;
33
+ }): void;
34
+ imagesToResolve(): any[];
35
+ resolveImage(href: string, buffer: Uint8Array): void;
36
+ readonly height: number;
37
+ readonly width: number;
38
+ };
39
+ };
40
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { Resvg as _Resvg, initWasm } from "@resvg/resvg-wasm";
2
+ import { readWasmFile } from "../../utils/wasm.mjs";
3
+ export default {
4
+ initWasmPromise: initWasm(readWasmFile("@resvg/resvg-wasm/index_bg.wasm")),
5
+ Resvg: _Resvg
6
+ };
@@ -1,6 +1,6 @@
1
1
  import { Resvg as _Resvg, initWasm } from "@resvg/resvg-wasm";
2
- import ReSVGWasm from "@resvg/resvg-wasm/index_bg.wasm";
2
+ import { importWasm } from "../../utils/wasm.mjs";
3
3
  export default {
4
- initWasmPromise: initWasm(ReSVGWasm),
4
+ initWasmPromise: initWasm(importWasm(import("@resvg/resvg-wasm/index_bg.wasm"))),
5
5
  Resvg: _Resvg
6
6
  };
@@ -0,0 +1,13 @@
1
+ import _satori, { init } from "satori/wasm";
2
+ import initYoga from "yoga-wasm-web";
3
+ import { readWasmFile } from "../../utils/wasm.mjs";
4
+ const wasm = readWasmFile("yoga-wasm-web/dist/yoga.wasm").then(async (yoga) => await initYoga(yoga));
5
+ export default {
6
+ initWasmPromise: new Promise((resolve) => {
7
+ wasm.then((yoga) => {
8
+ init(yoga);
9
+ resolve();
10
+ });
11
+ }),
12
+ satori: _satori
13
+ };
@@ -0,0 +1,6 @@
1
+ import _satori from 'satori/wasm';
2
+ declare const _default: {
3
+ initWasmPromise: Promise<void>;
4
+ satori: typeof _satori;
5
+ };
6
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import _satori from "satori/wasm";
2
+ import initYoga from "yoga-wasm-web";
3
+ import { init } from "satori";
4
+ import { importWasm } from "../../utils/wasm.mjs";
5
+ const wasm = importWasm(import("yoga-wasm-web/dist/yoga.wasm")).then(async (yoga) => await initYoga(yoga));
6
+ export default {
7
+ initWasmPromise: new Promise((resolve) => {
8
+ wasm.then((yoga) => {
9
+ init(yoga);
10
+ resolve();
11
+ });
12
+ }),
13
+ satori: _satori
14
+ };
@@ -0,0 +1 @@
1
+ export declare const emojiCache: import("unstorage/dist/shared/unstorage.745f9650").a<string>;
@@ -0,0 +1,5 @@
1
+ import { createStorage } from "unstorage";
2
+ import lruCacheDriver from "unstorage/drivers/lru-cache";
3
+ export const emojiCache = createStorage({
4
+ driver: lruCacheDriver({ max: 1e3 })
5
+ });
@@ -0,0 +1,5 @@
1
+ import type { OgImageOptions } from '../../types';
2
+ export declare const htmlPayloadCache: import("unstorage/dist/shared/unstorage.745f9650").a<{
3
+ expiresAt: number;
4
+ value: OgImageOptions;
5
+ }>;
@@ -0,0 +1,6 @@
1
+ import { createStorage } from "unstorage";
2
+ import lruCacheDriver from "unstorage/drivers/lru-cache";
3
+ export const htmlPayloadCache = createStorage({
4
+ // short cache time so we don't need many entries at runtime
5
+ driver: lruCacheDriver({ max: import.meta.prerender ? 1e3 : 50 })
6
+ });
@@ -1,6 +1,6 @@
1
1
  import type { Browser } from 'playwright-core';
2
2
  import type { OgImageOptions } from '../../types';
3
- export declare const prerenderCache: import("unstorage/dist/shared/unstorage.745f9650").a<OgImageOptions> | undefined;
3
+ export declare const prerenderOptionsCache: import("unstorage/dist/shared/unstorage.745f9650").a<OgImageOptions<"NuxtSeo">> | undefined;
4
4
  export declare const prerenderChromiumContext: {
5
5
  browser?: Browser;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { createStorage } from "unstorage";
2
2
  import lruCacheDriver from "unstorage/drivers/lru-cache";
3
- export const prerenderCache = import.meta.prerender ? createStorage({
3
+ export const prerenderOptionsCache = import.meta.prerender ? createStorage({
4
4
  driver: lruCacheDriver({ max: 1e3 })
5
5
  }) : void 0;
6
6
  export const prerenderChromiumContext = { browser: void 0 };
@@ -1,2 +1 @@
1
- export declare function base64ToArrayBuffer(base64: string): ArrayBuffer;
2
1
  export declare function toBase64Image(fileName: string, data: string | ArrayBuffer): string;
@@ -1,8 +1,4 @@
1
1
  import { Buffer } from "node:buffer";
2
- export function base64ToArrayBuffer(base64) {
3
- const buffer = Buffer.from(base64, "base64");
4
- return new Uint8Array(buffer).buffer;
5
- }
6
2
  export function toBase64Image(fileName, data) {
7
3
  const base64 = typeof data === "string" ? data : Buffer.from(data).toString("base64");
8
4
  let type = "image/jpeg";
@@ -1,3 +1,2 @@
1
- import type { H3Event } from 'h3';
2
- import type { FontConfig } from '../../types';
3
- export declare function loadFont(e: H3Event, font: FontConfig): Promise<any>;
1
+ import type { FontConfig, OgImageRenderEventContext } from '../../types';
2
+ export declare function loadFont({ e }: OgImageRenderEventContext, font: FontConfig): Promise<any>;
@@ -1,29 +1,46 @@
1
- import { Buffer } from "node:buffer";
2
- import { base64ToArrayBuffer } from "../env/assets.mjs";
1
+ import { createError } from "h3";
3
2
  import { fontCache } from "./cache.mjs";
4
3
  import { useNitroOrigin, useStorage } from "#imports";
5
- export async function loadFont(e, font) {
6
- const fontKey = `${font.name}:${font.weight}`;
7
- const storageKey = `assets:nuxt-og-image:font:${fontKey}`;
4
+ import { assets } from "#internal/nitro/virtual/server-assets";
5
+ export async function loadFont({ e }, font) {
6
+ const fontKey = font.key || `${font.name}:${font.weight}`;
8
7
  if (fontCache[fontKey])
9
8
  return fontCache[fontKey];
10
- const [name, weight] = fontKey.split(":");
9
+ const { name, weight } = font;
11
10
  let data;
12
- if (await useStorage().hasItem(storageKey))
13
- data = base64ToArrayBuffer(await useStorage().getItem(storageKey));
11
+ if (import.meta.dev || import.meta.prerender) {
12
+ if (font.key && await assets.hasItem(font.key))
13
+ data = await assets.getItemRaw(font.key);
14
+ }
14
15
  if (!data) {
15
16
  if (font.path) {
16
- data = await e.$fetch(font.path, {
17
- baseURL: useNitroOrigin(e),
18
- responseType: "arrayBuffer"
19
- });
17
+ if (import.meta.dev || import.meta.prerender) {
18
+ const key = `root:public${font.path.replace("./", ":").replace("/", ":")}`;
19
+ if (await useStorage().hasItem(key))
20
+ data = await useStorage().getItemRaw(key);
21
+ if (!data) {
22
+ data = await e.$fetch(font.path, {
23
+ responseType: "arrayBuffer"
24
+ });
25
+ }
26
+ } else {
27
+ data = await e.$fetch(font.path, {
28
+ baseURL: useNitroOrigin(e),
29
+ responseType: "arrayBuffer"
30
+ });
31
+ }
20
32
  } else {
21
33
  data = await e.$fetch(`/__og-image__/font/${name}/${weight}.ttf`, {
22
34
  responseType: "arrayBuffer"
23
35
  });
24
36
  }
25
37
  }
26
- fontCache[fontKey] = { name, weight: Number(weight), data, style: "normal" };
27
- await useStorage().setItem(storageKey, Buffer.from(data).toString("base64"));
28
- return fontCache[fontKey];
38
+ if (data) {
39
+ fontCache[fontKey] = { name, weight: Number(weight), data, style: "normal" };
40
+ return fontCache[fontKey];
41
+ }
42
+ return createError({
43
+ statusCode: 500,
44
+ statusMessage: `Failed to fetch font: ${fontKey}`
45
+ });
29
46
  }
@@ -0,0 +1,3 @@
1
+ import type { NuxtIslandResponse } from 'nuxt/dist/core/runtime/nitro/renderer';
2
+ import type { OgImageRenderEventContext } from '../../types';
3
+ export declare function applyEmojis(ctx: OgImageRenderEventContext, island: NuxtIslandResponse): Promise<string | boolean>;
@@ -0,0 +1,37 @@
1
+ import defaultCharMap from "@iconify-json/noto/chars.json";
2
+ import { emojiCache } from "../cache/emojis.mjs";
3
+ const RE_MATCH_EMOJIS = /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
4
+ export async function applyEmojis(ctx, island) {
5
+ const html = island.html;
6
+ const matches = html.match(RE_MATCH_EMOJIS);
7
+ if (!matches)
8
+ return html;
9
+ const replacements = await Promise.all(matches.map(async (match) => {
10
+ const unicode = match.codePointAt(0).toString(16);
11
+ const emoji = defaultCharMap[unicode];
12
+ if (emoji) {
13
+ const key = ["1", ctx.options.emojis, emoji].join(":");
14
+ let svg;
15
+ if (await emojiCache.hasItem(key))
16
+ svg = await emojiCache.getItem(key);
17
+ if (!svg) {
18
+ svg = await ctx.e.$fetch(`https://api.iconify.design/${ctx.options.emojis}/${emoji}.svg`, {
19
+ responseType: "text"
20
+ });
21
+ if (svg === "404")
22
+ svg = void 0;
23
+ if (svg)
24
+ await emojiCache.setItem(key, svg);
25
+ }
26
+ if (svg)
27
+ return `
28
+ ${svg.replace("<svg ", '<svg data-emoji style="margin: 0 .05em 0 .15em; vertical-align: -0.1em;" ')}
29
+ `;
30
+ return match;
31
+ }
32
+ }));
33
+ const finalHtml = html.replace(RE_MATCH_EMOJIS, () => replacements.shift());
34
+ const modified = finalHtml !== island.html;
35
+ island.html = finalHtml;
36
+ return modified;
37
+ }
@@ -0,0 +1,3 @@
1
+ import type { NuxtIslandResponse } from 'nuxt/dist/core/runtime/nitro/renderer';
2
+ import type { OgImageRenderEventContext } from '../../types';
3
+ export declare function applyInlineCss({ e }: OgImageRenderEventContext, island: NuxtIslandResponse): Promise<boolean>;
@@ -0,0 +1,32 @@
1
+ import { useCssInline } from "../renderers/satori/instances.mjs";
2
+ import { useNitroOrigin } from "#imports";
3
+ import cssInline from "#nuxt-og-image/bindings/css-inline";
4
+ export async function applyInlineCss({ e }, island) {
5
+ let html = island.html;
6
+ const componentInlineStyles = island.head.link.filter((l) => l.href.startsWith("/_nuxt/components"));
7
+ const usingInlineCss = !!componentInlineStyles.length;
8
+ if (!cssInline.__unenv__ && componentInlineStyles.length) {
9
+ const css = island.head.style.map((s) => s.innerHTML).join("\n");
10
+ const linksToCss = (await Promise.all(
11
+ componentInlineStyles.map((l) => {
12
+ return e.$fetch(`${l.href}&hmr=false`, {
13
+ responseType: "text",
14
+ baseURL: useNitroOrigin(e)
15
+ }).then((res) => {
16
+ return res.trim().split("\n").filter((l2) => !l2.startsWith("//")).join("\n").trim();
17
+ });
18
+ })
19
+ )).join("\n");
20
+ const cssToInline = `${linksToCss}${css}`;
21
+ const cssInline2 = await useCssInline();
22
+ html = cssInline2.inline(island.html, {
23
+ load_remote_stylesheets: false,
24
+ extra_css: cssToInline
25
+ });
26
+ const classes = cssToInline.match(/\.([a-zA-Z0-9-_]+)/g)?.map((c) => c.replace(".", ""));
27
+ if (classes)
28
+ html = html.replace(new RegExp(`class="(${classes.join("|")})"`, "g"), "");
29
+ island.html = html;
30
+ }
31
+ return usingInlineCss;
32
+ }
@@ -0,0 +1,2 @@
1
+ import type { OgImageRenderEventContext } from '../../types';
2
+ export declare function devIframeTemplate(ctx: OgImageRenderEventContext): Promise<string>;