koishi-plugin-vercel-satori-png-service 0.1.2 → 0.1.5

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/index.js CHANGED
@@ -283,13 +283,9 @@ async function render(satori2, resvg2, opts, defaultFonts, element) {
283
283
  __name(render, "render");
284
284
 
285
285
  // src/Satori.ts
286
- var initialized = false;
287
286
  var fontData;
288
287
  var satori;
289
288
  var initSatori = /* @__PURE__ */ __name(async () => {
290
- if (initialized) {
291
- return;
292
- }
293
289
  satori = (await import("satori")).default;
294
290
  const require2 = (0, import_node_module.createRequire)("file:///" + __filename);
295
291
  const reSvgWasm = import_node_path.default.join(
@@ -300,7 +296,6 @@ var initSatori = /* @__PURE__ */ __name(async () => {
300
296
  fontData = await import_promises.default.readFile(
301
297
  require2.resolve("../noto-sans-v27-latin-regular.ttf")
302
298
  );
303
- initialized = true;
304
299
  }, "initSatori");
305
300
  var createNodejsStream = /* @__PURE__ */ __name(async (element, options) => {
306
301
  const fonts = [
@@ -318,6 +313,7 @@ var createNodejsStream = /* @__PURE__ */ __name(async (element, options) => {
318
313
  // src/index.ts
319
314
  var serviceName = "vercelSatoriPngService";
320
315
  var AsyncFunction = (async () => 0).constructor;
316
+ var initialized = false;
321
317
  var VercelSatoriPngService = class extends import_koishi.Service {
322
318
  static {
323
319
  __name(this, "VercelSatoriPngService");
@@ -331,7 +327,11 @@ var VercelSatoriPngService = class extends import_koishi.Service {
331
327
  this._config = config;
332
328
  }
333
329
  async start() {
330
+ if (initialized) {
331
+ return;
332
+ }
334
333
  await initSatori();
334
+ initialized = true;
335
335
  }
336
336
  async jsxToReactElement(jsxCode, data) {
337
337
  const hCode = (0, import_sucrase.transform)(jsxCode, {
@@ -396,7 +396,7 @@ var VercelSatoriPngService = class extends import_koishi.Service {
396
396
  }
397
397
  };
398
398
  ((VercelSatoriPngService2) => {
399
- VercelSatoriPngService2.usage = 'html to ReactElement <a target="_blank" href="https://www.npmjs.com/package/html-react-parser">html-react-parser</a> \njsx to ReactElement <a target="_blank" href="https://www.npmjs.com/package/sucrase">sucrase</a> \nReactElement to png <a target="_blank" href="https://www.npmjs.com/package/@vercel/og">@vercel/og</a> \n<a target="_blank" href="https://og-playground.vercel.app/">og-playground</a> \n<a target="_blank" href="https://github.com/vercel/satori#overview">vercel/satori</a> \n';
399
+ VercelSatoriPngService2.usage = 'html to ReactElement <a target="_blank" href="https://www.npmjs.com/package/html-react-parser">html-react-parser</a> \njsx to ReactElement <a target="_blank" href="https://www.npmjs.com/package/sucrase">sucrase</a> \nReactElement to svg <a target="_blank" href="https://github.com/vercel/satori#overview">vercel/satori</a> \n<a target="_blank" href="https://og-playground.vercel.app/">og-playground</a> \nsvg to png <a target="_blank" href="https://www.npmjs.com/package/@resvg/resvg-wasm">@resvg/resvg-wasm</a>';
400
400
  VercelSatoriPngService2.Config = import_koishi.Schema.object({});
401
401
  })(VercelSatoriPngService || (VercelSatoriPngService = {}));
402
402
  var src_default = VercelSatoriPngService;
package/lib/og.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { EmojiType } from "./emoji";
2
+ import * as Resvg from "@resvg/resvg-wasm";
3
+ import type Satori from "satori";
2
4
  import type { SatoriOptions } from "satori";
3
5
  import type { ReactElement } from "react";
4
6
  export type ImageOptions = {
@@ -39,4 +41,4 @@ export type ImageOptions = {
39
41
  emoji?: EmojiType;
40
42
  };
41
43
  export type Font = ImageOptions["fonts"][number];
42
- export default function render(satori: any, resvg: any, opts: ImageOptions, defaultFonts: Font[], element: ReactElement): Promise<any>;
44
+ export default function render(satori: typeof Satori, resvg: typeof Resvg, opts: ImageOptions, defaultFonts: Font[], element: ReactElement<any, any>): Promise<Uint8Array<ArrayBufferLike>>;
Binary file
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.2",
4
+ "version": "0.1.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "scripts": {
@@ -12,7 +12,8 @@
12
12
  },
13
13
  "files": [
14
14
  "lib",
15
- "dist"
15
+ "dist",
16
+ "noto-sans-v27-latin-regular.ttf"
16
17
  ],
17
18
  "contributors": [
18
19
  "pgnqukezrdxmhjso"