@ethercorps/sveltekit-og 4.0.0-next.2 → 4.0.0-next.4

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.
@@ -12,20 +12,18 @@ export async function createVNode(element, componentOptions) {
12
12
  }
13
13
  export async function createSvg(element, imageOptions, componentOptions) {
14
14
  const [satori, vnodes] = await Promise.all([useSatori(), createVNode(element, componentOptions)]);
15
- if (!Object.hasOwn(imageOptions, 'fonts')) {
16
- imageOptions['fonts'] = await default_fonts();
15
+ const satoriOptions = structuredClone(imageOptions);
16
+ if (!Object.hasOwn(satoriOptions, 'fonts')) {
17
+ satoriOptions['fonts'] = await default_fonts();
17
18
  }
18
- // Add dynamic emoji loading handler
19
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
- // @ts-ignore
21
- imageOptions['loadAdditionalAsset'] = loadDynamicAsset({
19
+ satoriOptions['loadAdditionalAsset'] = loadDynamicAsset({
22
20
  emoji: imageOptions.emoji
23
21
  });
24
- if (imageOptions.debug) {
22
+ if (satoriOptions.debug) {
25
23
  console.info('VNode proivided to satori:', vnodes, '\n');
26
24
  console.info('Options proivided to satori:', imageOptions, '\n');
27
25
  }
28
- return satori(vnodes, imageOptions);
26
+ return satori(vnodes, satoriOptions);
29
27
  }
30
28
  export async function createPng(element, imageOptions, componentOptions) {
31
29
  const svg = await createSvg(element, imageOptions, componentOptions);
@@ -1,10 +1,11 @@
1
1
  import type { SatoriOptions } from 'satori';
2
2
  import type { ImageOptions } from '../types.js';
3
+ import type { EmojiType } from './emoji.js';
3
4
  export declare function default_fonts(): Promise<SatoriOptions['fonts']>;
4
5
  export declare const DEFAULT_FORMAT = "png";
5
6
  export declare const DEFAULT_WIDTH = 1200;
6
7
  export declare const DEFAULT_HEIGHT = 630;
7
- export declare const DEFAULT_EMOJI_PROVIDER = "twemoji";
8
+ export declare const DEFAULT_EMOJI_PROVIDER: EmojiType;
8
9
  export declare const DEFAULT_STATUS_CODE = 200;
9
10
  export declare const DEFAULT_STATUS_TEXT = "Success";
10
11
  export declare const DEFAULT_OPTIONS: ImageOptions;
@@ -1,3 +1,13 @@
1
+ declare const emoji_apis: {
2
+ readonly twemoji: (code: string) => string;
3
+ readonly openmoji: "https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/";
4
+ readonly blobmoji: "https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/";
5
+ readonly noto: "https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/";
6
+ readonly fluent: (code: string) => string;
7
+ readonly fluentFlat: (code: string) => string;
8
+ };
1
9
  export declare const loadDynamicAsset: ({ emoji }: {
2
- emoji: any;
10
+ emoji: EmojiType;
3
11
  }) => (...args: any[]) => Promise<string | undefined>;
12
+ export type EmojiType = keyof typeof emoji_apis;
13
+ export {};
@@ -32,10 +32,10 @@ const emoji_apis = {
32
32
  fluentFlat: (code) => "https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/" + code.toLowerCase() + "_flat.svg"
33
33
  };
34
34
  function loadEmoji(code, type) {
35
- if (!type || !apis[type]) {
35
+ if (!type || !emoji_apis[type]) {
36
36
  type = DEFAULT_EMOJI_PROVIDER;
37
37
  }
38
- const api = apis[type];
38
+ const api = emoji_apis[type];
39
39
  if (typeof api === "function") {
40
40
  return fetch(api(code));
41
41
  }
@@ -48,6 +48,8 @@ export const loadDynamicAsset = ({ emoji }) => {
48
48
  }
49
49
  };
50
50
  return async (...args) => {
51
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
+ // @ts-ignore
51
53
  return await fn(...args);
52
54
  };
53
55
  };
package/dist/plugin.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { unwasm } from "unwasm/plugin";
2
- import { isNode } from 'std-env';
3
2
  export function rollupWasm(options) {
4
3
  return unwasm({
5
- esmImport: !isNode,
4
+ esmImport: true,
6
5
  lazy: true,
7
6
  ...options
8
7
  });
@@ -1,6 +1,8 @@
1
1
  import { Resvg as _Resvg, initWasm } from '@resvg/resvg-wasm'
2
2
 
3
3
  export default {
4
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
+ // @ts-ignore
4
6
  initWasmPromise: initWasm(import('./resvg.wasm?module').then(r => r.default || r)),
5
7
  Resvg: _Resvg,
6
8
  }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { SatoriOptions } from 'satori/wasm';
2
+ import type { EmojiType } from './helpers/emoji.js';
2
3
  export type ImageOptions = {
3
4
  /**
4
5
  * Width of the image
@@ -14,7 +15,7 @@ export type ImageOptions = {
14
15
  * Emoji provider
15
16
  * @default twemoji
16
17
  * */
17
- emoji?: 'twemoji' | 'blobmoji' | 'noto' | 'openmoji' | 'fluent' | 'fluentFlat';
18
+ emoji?: EmojiType;
18
19
  /**
19
20
  * Fonts used for your text
20
21
  * @default `helpers/defaults.js`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethercorps/sveltekit-og",
3
- "version": "4.0.0-next.2",
3
+ "version": "4.0.0-next.4",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",