=
- TComponent extends new () => {
- $props: infer P
- }
- ? Omit
- : never
-
-export async function html(component: Component, props: any) {
- let Root
- if (props)
- Root = createApp(h(component, props))
- else
- Root = createApp(component)
- let strComponent = await renderToString(Root)
- //
- const regex = /<\/div>/gi
- const matchs = strComponent.matchAll(regex)
- for (const match of matchs) {
- const [collection, name] = match[1].split(':')
- const width = match[3] || 48
- const height = match[4] || 48
- let icon = await $fetch(`${process.env.ICONIFY_API}/${collection}:${name}.svg`, { responseType: 'text' })
- if (icon) {
- icon = icon.replace(/width="(\d+(em)?)" height="(\d+(em)?)"/, (_) => {
- return `width="${width}" height="${height}"`
- })
- strComponent = strComponent.replaceAll(match[0], icon)
- // console.log(strComponent)
- }
- }
- return _html(replaceHtmlReservedCharacters(strComponent))
-}
-
-export async function satori(component: T, options: SatoriOptions & {
- props?: ExtractComponentProps
-}) {
- const markup = await html(component, options.props)
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-expect-error
- const result = await _satori(markup, options)
- return result
-}
diff --git a/server/nuxt3/server/utils/webCard/twemoji.ts b/server/nuxt3/server/utils/webCard/twemoji.ts
deleted file mode 100644
index 62604ad..0000000
--- a/server/nuxt3/server/utils/webCard/twemoji.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Modified version of https://unpkg.com/twemoji@13.1.0/dist/twemoji.esm.js.
- */
-
-/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */
-import { $fetch } from 'ofetch'
-
-const U200D = String.fromCharCode(8205)
-const UFE0Fg = /\uFE0F/g
-
-export function getIconCode(char: string) {
- return toCodePoint(!char.includes(U200D) ? char.replace(UFE0Fg, '') : char)
-}
-
-function toCodePoint(unicodeSurrogates: string) {
- const r = []
- let c = 0
- let p = 0
- let i = 0
-
- while (i < unicodeSurrogates.length) {
- c = unicodeSurrogates.charCodeAt(i++)
- if (p) {
- r.push((65536 + ((p - 55296) << 10) + (c - 56320)).toString(16))
- p = 0
- }
- else if (c >= 55296 && c <= 56319) {
- p = c
- }
- else {
- r.push(c.toString(16))
- }
- }
- return r.join('-')
-}
-
-type EmojiAPI = (code: string) => string
-type EmojiAPIString = string
-type EmojiType = 'twemoji' | 'openmoji' | 'blobmoji' | 'noto' | 'fluent' | 'fluentFlat'
-
-export const apis: Record = {
- twemoji: (code: string) =>
- `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${
- code.toLowerCase()
- }.svg`,
- openmoji: 'https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/',
- blobmoji: 'https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/',
- noto: 'https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/',
- fluent: (code: string) =>
- `https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${
- code.toLowerCase()
- }_color.svg`,
- fluentFlat: (code: string) =>
- `https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${
- code.toLowerCase()
- }_flat.svg`,
-}
-
-const emojiCache: Record> = {}
-
-export function loadEmoji(type: EmojiType, code: string) {
- const key = `${type}:${code}`
- if (key in emojiCache)
- return emojiCache[key]
-
- if (!type || !apis[type])
- type = 'twemoji'
-
- const api = apis[type]
- if (typeof api === 'function')
- return (emojiCache[key] = $fetch(api(code), { responseType: 'text' }))
-
- return (emojiCache[key] = $fetch(`${api}${code.toUpperCase()}.svg`, { responseType: 'text' }))
-}