koishi-plugin-vercel-satori-png-service 0.1.1 → 0.1.3
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 +6 -6
- package/noto-sans-v27-latin-regular.ttf +0 -0
- package/package.json +3 -2
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(
|
|
@@ -298,9 +294,8 @@ var initSatori = /* @__PURE__ */ __name(async () => {
|
|
|
298
294
|
);
|
|
299
295
|
await resvg.initWasm(await import_promises.default.readFile(reSvgWasm));
|
|
300
296
|
fontData = await import_promises.default.readFile(
|
|
301
|
-
require2.resolve("
|
|
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, {
|
|
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.
|
|
4
|
+
"version": "0.1.3",
|
|
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"
|