koishi-plugin-vercel-satori-png-service 0.1.6 → 0.1.8

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/lib/Satori.d.ts CHANGED
@@ -35,7 +35,7 @@ export declare const getResvg: () => new (svg: Uint8Array | string, options?: re
35
35
  width: number;
36
36
  x: number;
37
37
  y: number;
38
- }): void;
38
+ }, padding?: number | undefined, square?: boolean | undefined): void;
39
39
  imagesToResolve(): any[];
40
40
  resolveImage(href: string, buffer: Uint8Array): void;
41
41
  readonly height: number;
package/lib/emoji.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Modified version of https://unpkg.com/twemoji@13.1.0/dist/twemoji.esm.js.
3
+ */
4
+ export declare function getIconCode(char: string): string;
5
+ declare const apis: {
6
+ twemoji: (code: any) => string;
7
+ openmoji: string;
8
+ blobmoji: string;
9
+ noto: string;
10
+ fluent: (code: any) => string;
11
+ fluentFlat: (code: any) => string;
12
+ };
13
+ export type EmojiType = keyof typeof apis;
14
+ export declare function loadEmoji(code: string, type?: EmojiType): Promise<Response>;
15
+ export {};
package/lib/index.d.ts CHANGED
@@ -53,7 +53,7 @@ declare class VercelSatoriPngService extends Service {
53
53
  width: number;
54
54
  x: number;
55
55
  y: number;
56
- }): void;
56
+ }, padding?: number | undefined, square?: boolean | undefined): void;
57
57
  imagesToResolve(): any[];
58
58
  resolveImage(href: string, buffer: Uint8Array): void;
59
59
  readonly height: number;
package/lib/index.js CHANGED
@@ -253,8 +253,6 @@ var loadDynamicAsset = /* @__PURE__ */ __name(({ emoji }) => {
253
253
  function mergeOptions(opts) {
254
254
  return Object.assign(
255
255
  {
256
- width: 1200,
257
- height: 630,
258
256
  debug: false
259
257
  },
260
258
  opts
@@ -413,12 +411,13 @@ var VercelSatoriPngService = class extends import_koishi.Service {
413
411
  return options;
414
412
  }
415
413
  async jsxToPng(jsxCode, options, data) {
416
- const reactElement = await this.jsxToReactElement(jsxCode, data);
417
- return createNodejsStream(reactElement, this.buildOptions(options));
414
+ return this.reactElementToPng(
415
+ await this.jsxToReactElement(jsxCode, data),
416
+ options
417
+ );
418
418
  }
419
419
  htmlToPng(htmlCode, options) {
420
- const reactElement = this.htmlToReactElement(htmlCode);
421
- return createNodejsStream(reactElement, this.buildOptions(options));
420
+ return this.reactElementToPng(this.htmlToReactElement(htmlCode), options);
422
421
  }
423
422
  async reactElementToPng(reactElement, options) {
424
423
  return createNodejsStream(reactElement, this.buildOptions(options));
@@ -0,0 +1,28 @@
1
+ export declare class FontDetector {
2
+ private rangesByLang;
3
+ detect(text: string, fonts: string[]): Promise<{
4
+ [lang: string]: string;
5
+ }>;
6
+ private detectSegment;
7
+ private load;
8
+ private addDetectors;
9
+ }
10
+ export declare const languageFontMap: {
11
+ 'ja-JP': string;
12
+ 'ko-KR': string;
13
+ 'zh-CN': string;
14
+ 'zh-TW': string;
15
+ 'zh-HK': string;
16
+ 'th-TH': string;
17
+ 'bn-IN': string;
18
+ 'ar-AR': string;
19
+ 'ta-IN': string;
20
+ 'ml-IN': string;
21
+ 'he-IL': string;
22
+ 'te-IN': string;
23
+ devanagari: string;
24
+ kannada: string;
25
+ symbol: string[];
26
+ math: string;
27
+ unknown: string;
28
+ };
package/lib/og.d.ts CHANGED
@@ -8,14 +8,12 @@ export type ImageOptions = {
8
8
  * The width of the image.
9
9
  *
10
10
  * @type {number}
11
- * @default 1200
12
11
  */
13
12
  width?: number;
14
13
  /**
15
14
  * The height of the image.
16
15
  *
17
16
  * @type {number}
18
- * @default 630
19
17
  */
20
18
  height?: number;
21
19
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-vercel-satori-png-service",
3
3
  "description": "Use Vercel Satori and Resvg.js to convert html to png",
4
- "version": "0.1.6",
4
+ "version": "0.1.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "scripts": {
@@ -37,14 +37,14 @@
37
37
  "vercelSatoriPngService"
38
38
  ],
39
39
  "peerDependencies": {
40
- "koishi": "^4.18.8"
40
+ "koishi": "^4.18.10"
41
41
  },
42
42
  "dependencies": {
43
- "@resvg/resvg-wasm": "^2.6.2",
44
- "html-react-parser": "^5.2.5",
45
- "react": "^19.2.0-canary-f9ae0a4c-20250527",
43
+ "@resvg/resvg-wasm": "^2.6.3-alpha.2",
44
+ "html-react-parser": "^5.2.11",
45
+ "react": "^19.3.0-canary-fd524fe0-20251121",
46
46
  "satori": "^0.16.2",
47
- "sucrase": "^3.35.0"
47
+ "sucrase": "^3.35.1"
48
48
  },
49
49
  "koishi": {
50
50
  "service": {