@takumi-rs/core 2.0.0-rc.1 → 2.0.0-rc.11
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/dist/export.cjs +42 -114
- package/dist/export.d.cts +17 -75
- package/dist/export.d.mts +17 -75
- package/dist/export.mjs +44 -115
- package/index.d.ts +4 -2
- package/package.json +11 -11
package/dist/export.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let module$1 = require(/* turbopackOptional: true */ "module");
|
|
3
3
|
let _takumi_rs_helpers = require(/* turbopackOptional: true */ "@takumi-rs/helpers");
|
|
4
|
+
let _takumi_rs_helpers_renderer = require(/* turbopackOptional: true */ "@takumi-rs/helpers/renderer");
|
|
4
5
|
//#region index.js
|
|
5
6
|
const require$1 = (0, module$1.createRequire)(require(/* turbopackOptional: true */ "url").pathToFileURL(__filename).href);
|
|
6
7
|
new URL(".", require(/* turbopackOptional: true */ "url").pathToFileURL(__filename).href).pathname;
|
|
@@ -59,7 +60,7 @@ function requireNative() {
|
|
|
59
60
|
try {
|
|
60
61
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/core.android-arm64.node");
|
|
61
62
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/package.json").version;
|
|
62
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
63
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
63
64
|
return binding;
|
|
64
65
|
} catch (e) {
|
|
65
66
|
loadErrors.push(e);
|
|
@@ -73,7 +74,7 @@ function requireNative() {
|
|
|
73
74
|
try {
|
|
74
75
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/core.android-arm-eabi.node");
|
|
75
76
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/package.json").version;
|
|
76
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
77
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
77
78
|
return binding;
|
|
78
79
|
} catch (e) {
|
|
79
80
|
loadErrors.push(e);
|
|
@@ -88,7 +89,7 @@ function requireNative() {
|
|
|
88
89
|
try {
|
|
89
90
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/core.win32-x64-gnu.node");
|
|
90
91
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/package.json").version;
|
|
91
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
92
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
92
93
|
return binding;
|
|
93
94
|
} catch (e) {
|
|
94
95
|
loadErrors.push(e);
|
|
@@ -102,7 +103,7 @@ function requireNative() {
|
|
|
102
103
|
try {
|
|
103
104
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/core.win32-x64-msvc.node");
|
|
104
105
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/package.json").version;
|
|
105
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
106
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
106
107
|
return binding;
|
|
107
108
|
} catch (e) {
|
|
108
109
|
loadErrors.push(e);
|
|
@@ -117,7 +118,7 @@ function requireNative() {
|
|
|
117
118
|
try {
|
|
118
119
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/core.win32-ia32-msvc.node");
|
|
119
120
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/package.json").version;
|
|
120
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
121
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
121
122
|
return binding;
|
|
122
123
|
} catch (e) {
|
|
123
124
|
loadErrors.push(e);
|
|
@@ -131,7 +132,7 @@ function requireNative() {
|
|
|
131
132
|
try {
|
|
132
133
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/core.win32-arm64-msvc.node");
|
|
133
134
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/package.json").version;
|
|
134
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
135
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
135
136
|
return binding;
|
|
136
137
|
} catch (e) {
|
|
137
138
|
loadErrors.push(e);
|
|
@@ -146,7 +147,7 @@ function requireNative() {
|
|
|
146
147
|
try {
|
|
147
148
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/core.darwin-universal.node");
|
|
148
149
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/package.json").version;
|
|
149
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
150
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
150
151
|
return binding;
|
|
151
152
|
} catch (e) {
|
|
152
153
|
loadErrors.push(e);
|
|
@@ -160,7 +161,7 @@ function requireNative() {
|
|
|
160
161
|
try {
|
|
161
162
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/core.darwin-x64.node");
|
|
162
163
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/package.json").version;
|
|
163
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
164
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
164
165
|
return binding;
|
|
165
166
|
} catch (e) {
|
|
166
167
|
loadErrors.push(e);
|
|
@@ -174,7 +175,7 @@ function requireNative() {
|
|
|
174
175
|
try {
|
|
175
176
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/core.darwin-arm64.node");
|
|
176
177
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/package.json").version;
|
|
177
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
178
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
178
179
|
return binding;
|
|
179
180
|
} catch (e) {
|
|
180
181
|
loadErrors.push(e);
|
|
@@ -189,7 +190,7 @@ function requireNative() {
|
|
|
189
190
|
try {
|
|
190
191
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/core.freebsd-x64.node");
|
|
191
192
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/package.json").version;
|
|
192
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
193
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
193
194
|
return binding;
|
|
194
195
|
} catch (e) {
|
|
195
196
|
loadErrors.push(e);
|
|
@@ -203,7 +204,7 @@ function requireNative() {
|
|
|
203
204
|
try {
|
|
204
205
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/core.freebsd-arm64.node");
|
|
205
206
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/package.json").version;
|
|
206
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
207
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
207
208
|
return binding;
|
|
208
209
|
} catch (e) {
|
|
209
210
|
loadErrors.push(e);
|
|
@@ -218,7 +219,7 @@ function requireNative() {
|
|
|
218
219
|
try {
|
|
219
220
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/core.linux-x64-musl.node");
|
|
220
221
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/package.json").version;
|
|
221
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
222
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
222
223
|
return binding;
|
|
223
224
|
} catch (e) {
|
|
224
225
|
loadErrors.push(e);
|
|
@@ -232,7 +233,7 @@ function requireNative() {
|
|
|
232
233
|
try {
|
|
233
234
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/core.linux-x64-gnu.node");
|
|
234
235
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/package.json").version;
|
|
235
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
236
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
236
237
|
return binding;
|
|
237
238
|
} catch (e) {
|
|
238
239
|
loadErrors.push(e);
|
|
@@ -247,7 +248,7 @@ function requireNative() {
|
|
|
247
248
|
try {
|
|
248
249
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/core.linux-arm64-musl.node");
|
|
249
250
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/package.json").version;
|
|
250
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
251
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
251
252
|
return binding;
|
|
252
253
|
} catch (e) {
|
|
253
254
|
loadErrors.push(e);
|
|
@@ -261,7 +262,7 @@ function requireNative() {
|
|
|
261
262
|
try {
|
|
262
263
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/core.linux-arm64-gnu.node");
|
|
263
264
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/package.json").version;
|
|
264
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
265
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
265
266
|
return binding;
|
|
266
267
|
} catch (e) {
|
|
267
268
|
loadErrors.push(e);
|
|
@@ -276,7 +277,7 @@ function requireNative() {
|
|
|
276
277
|
try {
|
|
277
278
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/core.linux-arm-musleabihf.node");
|
|
278
279
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/package.json").version;
|
|
279
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
280
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
280
281
|
return binding;
|
|
281
282
|
} catch (e) {
|
|
282
283
|
loadErrors.push(e);
|
|
@@ -290,7 +291,7 @@ function requireNative() {
|
|
|
290
291
|
try {
|
|
291
292
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/core.linux-arm-gnueabihf.node");
|
|
292
293
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/package.json").version;
|
|
293
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
294
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
294
295
|
return binding;
|
|
295
296
|
} catch (e) {
|
|
296
297
|
loadErrors.push(e);
|
|
@@ -305,7 +306,7 @@ function requireNative() {
|
|
|
305
306
|
try {
|
|
306
307
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/core.linux-loong64-musl.node");
|
|
307
308
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/package.json").version;
|
|
308
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
309
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
309
310
|
return binding;
|
|
310
311
|
} catch (e) {
|
|
311
312
|
loadErrors.push(e);
|
|
@@ -319,7 +320,7 @@ function requireNative() {
|
|
|
319
320
|
try {
|
|
320
321
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/core.linux-loong64-gnu.node");
|
|
321
322
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/package.json").version;
|
|
322
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
323
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
323
324
|
return binding;
|
|
324
325
|
} catch (e) {
|
|
325
326
|
loadErrors.push(e);
|
|
@@ -334,7 +335,7 @@ function requireNative() {
|
|
|
334
335
|
try {
|
|
335
336
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/core.linux-riscv64-musl.node");
|
|
336
337
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/package.json").version;
|
|
337
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
338
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
338
339
|
return binding;
|
|
339
340
|
} catch (e) {
|
|
340
341
|
loadErrors.push(e);
|
|
@@ -348,7 +349,7 @@ function requireNative() {
|
|
|
348
349
|
try {
|
|
349
350
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/core.linux-riscv64-gnu.node");
|
|
350
351
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/package.json").version;
|
|
351
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
352
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
352
353
|
return binding;
|
|
353
354
|
} catch (e) {
|
|
354
355
|
loadErrors.push(e);
|
|
@@ -363,7 +364,7 @@ function requireNative() {
|
|
|
363
364
|
try {
|
|
364
365
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/core.linux-ppc64-gnu.node");
|
|
365
366
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/package.json").version;
|
|
366
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
367
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
367
368
|
return binding;
|
|
368
369
|
} catch (e) {
|
|
369
370
|
loadErrors.push(e);
|
|
@@ -377,7 +378,7 @@ function requireNative() {
|
|
|
377
378
|
try {
|
|
378
379
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/core.linux-s390x-gnu.node");
|
|
379
380
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/package.json").version;
|
|
380
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
381
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
381
382
|
return binding;
|
|
382
383
|
} catch (e) {
|
|
383
384
|
loadErrors.push(e);
|
|
@@ -392,7 +393,7 @@ function requireNative() {
|
|
|
392
393
|
try {
|
|
393
394
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/core.openharmony-arm64.node");
|
|
394
395
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/package.json").version;
|
|
395
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
396
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
396
397
|
return binding;
|
|
397
398
|
} catch (e) {
|
|
398
399
|
loadErrors.push(e);
|
|
@@ -406,7 +407,7 @@ function requireNative() {
|
|
|
406
407
|
try {
|
|
407
408
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/core.openharmony-x64.node");
|
|
408
409
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/package.json").version;
|
|
409
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
410
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
410
411
|
return binding;
|
|
411
412
|
} catch (e) {
|
|
412
413
|
loadErrors.push(e);
|
|
@@ -420,7 +421,7 @@ function requireNative() {
|
|
|
420
421
|
try {
|
|
421
422
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/core.openharmony-arm.node");
|
|
422
423
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/package.json").version;
|
|
423
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
424
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
424
425
|
return binding;
|
|
425
426
|
} catch (e) {
|
|
426
427
|
loadErrors.push(e);
|
|
@@ -469,50 +470,14 @@ if (!nativeBinding) {
|
|
|
469
470
|
const { Renderer: Renderer$1, AnimationOutputFormat, DitheringAlgorithm, ImageCacheMode, OutputFormat } = nativeBinding;
|
|
470
471
|
//#endregion
|
|
471
472
|
//#region src/export.ts
|
|
472
|
-
async function resolveImageLoaders(images) {
|
|
473
|
-
const bySrc = /* @__PURE__ */ new Map();
|
|
474
|
-
for (const image of images) bySrc.set(image.src, image);
|
|
475
|
-
return Promise.all([...bySrc.values()].map(async ({ src, data, cache }) => ({
|
|
476
|
-
src,
|
|
477
|
-
data: typeof data === "function" ? await data() : data,
|
|
478
|
-
cache
|
|
479
|
-
})));
|
|
480
|
-
}
|
|
481
473
|
var Renderer = class {
|
|
482
|
-
fontsByKey = /* @__PURE__ */ new Map();
|
|
483
|
-
fontsByData = /* @__PURE__ */ new WeakMap();
|
|
484
474
|
inner = new Renderer$1();
|
|
485
|
-
|
|
486
|
-
return typeof key === "string" ? this.fontsByKey.get(key) : this.fontsByData.get(key);
|
|
487
|
-
}
|
|
488
|
-
setFont(key, family) {
|
|
489
|
-
if (typeof key === "string") this.fontsByKey.set(key, family);
|
|
490
|
-
else this.fontsByData.set(key, family);
|
|
491
|
-
}
|
|
492
|
-
deleteFont(key) {
|
|
493
|
-
if (typeof key === "string") this.fontsByKey.delete(key);
|
|
494
|
-
else this.fontsByData.delete(key);
|
|
495
|
-
}
|
|
496
|
-
async prepareFonts(fonts) {
|
|
497
|
-
if (!fonts) return;
|
|
498
|
-
const families = await Promise.all(fonts.map(this.registerFont.bind(this)));
|
|
499
|
-
return [...new Set(families.flat().map((f) => f.name))];
|
|
500
|
-
}
|
|
501
|
-
/** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
|
|
502
|
-
* the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
|
|
503
|
-
async resolveResources(fonts, images, fontFamilies) {
|
|
504
|
-
const registeredFamilies = await this.prepareFonts(fonts);
|
|
505
|
-
return {
|
|
506
|
-
images: images ? await resolveImageLoaders(images) : void 0,
|
|
507
|
-
fontFamilies: fontFamilies ?? registeredFamilies
|
|
508
|
-
};
|
|
509
|
-
}
|
|
475
|
+
fonts = new _takumi_rs_helpers_renderer.FontRegistry((font) => this.inner.registerFont(font));
|
|
510
476
|
async render(node, options) {
|
|
511
|
-
const { fonts, fontFamilies, signal, images,
|
|
512
|
-
const resolved = await this.resolveResources((0, _takumi_rs_helpers.
|
|
477
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options ?? {};
|
|
478
|
+
const resolved = await this.fonts.resolveResources(fonts && (0, _takumi_rs_helpers.subsetFonts)({
|
|
513
479
|
fonts,
|
|
514
|
-
source: node
|
|
515
|
-
subset
|
|
480
|
+
source: node
|
|
516
481
|
}), images, fontFamilies);
|
|
517
482
|
return this.inner.render(node, {
|
|
518
483
|
...rest,
|
|
@@ -520,11 +485,10 @@ var Renderer = class {
|
|
|
520
485
|
}, signal);
|
|
521
486
|
}
|
|
522
487
|
async renderSvg(node, options) {
|
|
523
|
-
const { fonts, fontFamilies, signal, images,
|
|
524
|
-
const resolved = await this.resolveResources((0, _takumi_rs_helpers.
|
|
488
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options ?? {};
|
|
489
|
+
const resolved = await this.fonts.resolveResources(fonts && (0, _takumi_rs_helpers.subsetFonts)({
|
|
525
490
|
fonts,
|
|
526
|
-
source: node
|
|
527
|
-
subset
|
|
491
|
+
source: node
|
|
528
492
|
}), images, fontFamilies);
|
|
529
493
|
return this.inner.renderSvg(node, {
|
|
530
494
|
...rest,
|
|
@@ -532,11 +496,10 @@ var Renderer = class {
|
|
|
532
496
|
}, signal);
|
|
533
497
|
}
|
|
534
498
|
async measure(node, options) {
|
|
535
|
-
const { fonts, fontFamilies, signal, images,
|
|
536
|
-
const resolved = await this.resolveResources((0, _takumi_rs_helpers.
|
|
499
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options ?? {};
|
|
500
|
+
const resolved = await this.fonts.resolveResources(fonts && (0, _takumi_rs_helpers.subsetFonts)({
|
|
537
501
|
fonts,
|
|
538
|
-
source: node
|
|
539
|
-
subset
|
|
502
|
+
source: node
|
|
540
503
|
}), images, fontFamilies);
|
|
541
504
|
return this.inner.measure(node, {
|
|
542
505
|
...rest,
|
|
@@ -544,55 +507,20 @@ var Renderer = class {
|
|
|
544
507
|
}, signal);
|
|
545
508
|
}
|
|
546
509
|
async renderAnimation(options) {
|
|
547
|
-
const { fonts, fontFamilies, signal, images,
|
|
510
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options;
|
|
548
511
|
const nodes = options.scenes.map((scene) => scene.node);
|
|
549
|
-
const resolved = await this.resolveResources((0, _takumi_rs_helpers.
|
|
512
|
+
const resolved = await this.fonts.resolveResources(fonts && (0, _takumi_rs_helpers.subsetFonts)({
|
|
550
513
|
fonts,
|
|
551
|
-
source: nodes
|
|
552
|
-
subset
|
|
514
|
+
source: nodes
|
|
553
515
|
}), images, fontFamilies);
|
|
554
516
|
return this.inner.renderAnimation({
|
|
555
517
|
...rest,
|
|
556
518
|
...resolved
|
|
557
519
|
}, signal);
|
|
558
520
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const key = createFontKey(loader);
|
|
562
|
-
const cached = this.getFont(key);
|
|
563
|
-
if (cached) return cached;
|
|
564
|
-
const extracted = extractFontBuffer(loader);
|
|
565
|
-
const register = (data) => this.inner.registerFont(isBuffer(loader) ? data : {
|
|
566
|
-
...loader,
|
|
567
|
-
data
|
|
568
|
-
});
|
|
569
|
-
if (isBuffer(extracted)) {
|
|
570
|
-
const binded = register(extracted);
|
|
571
|
-
this.setFont(key, Promise.resolve(binded));
|
|
572
|
-
return binded;
|
|
573
|
-
}
|
|
574
|
-
const promise = extracted.then(register).catch((error) => {
|
|
575
|
-
this.deleteFont(key);
|
|
576
|
-
throw error;
|
|
577
|
-
});
|
|
578
|
-
this.setFont(key, promise);
|
|
579
|
-
return promise;
|
|
521
|
+
registerFont(font) {
|
|
522
|
+
return this.fonts.register(font);
|
|
580
523
|
}
|
|
581
524
|
};
|
|
582
|
-
function extractFontBuffer(font) {
|
|
583
|
-
if (isBuffer(font)) return font;
|
|
584
|
-
if (typeof font.data !== "function") return font.data;
|
|
585
|
-
return font.data();
|
|
586
|
-
}
|
|
587
|
-
function createFontKey(font) {
|
|
588
|
-
if (isBuffer(font)) return font;
|
|
589
|
-
if ("key" in font && font.key) return font.key;
|
|
590
|
-
if (typeof font.data === "function") return `${font.name ?? ""}:${font.weight ?? ""}:${font.style ?? ""}`;
|
|
591
|
-
return font.data;
|
|
592
|
-
}
|
|
593
|
-
function isBuffer(data) {
|
|
594
|
-
return data instanceof Uint8Array || data instanceof ArrayBuffer || typeof Buffer !== "undefined" && Buffer.isBuffer(data);
|
|
595
|
-
}
|
|
596
525
|
//#endregion
|
|
597
526
|
exports.Renderer = Renderer;
|
|
598
|
-
exports.extractResourceUrls = _takumi_rs_helpers.extractResourceUrls;
|
package/dist/export.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ContainerNode, ImageNode, Node, NodeMetadata, TextNode
|
|
1
|
+
import { ContainerNode, ImageNode, Node, NodeMetadata, TextNode } from "@takumi-rs/helpers";
|
|
2
2
|
import { Properties } from "csstype";
|
|
3
|
+
import { AnimationOutputFormatOptions, AnimationOutputFormatOptions as AnimationOutputFormatOptions$1, FontLoader, FontLoader as FontLoader$1, ImageLoader, ImagesInput, ImagesInput as ImagesInput$1, OutputFormatOptions, OutputFormatOptions as OutputFormatOptions$1 } from "@takumi-rs/helpers/renderer";
|
|
3
4
|
|
|
4
5
|
//#region index.d.ts
|
|
5
6
|
type ByteBuf = Uint8Array | ArrayBuffer | Buffer;
|
|
@@ -40,7 +41,7 @@ type Keyframes = KeyframesMap | KeyframesRuleList;
|
|
|
40
41
|
/** Output format for animated images. */
|
|
41
42
|
type AnimationOutputFormat = /** Animated WebP format. */'webp' | /** Animated PNG format. */'apng' | /** Animated GIF format. */'gif';
|
|
42
43
|
/** Represents a single scene in a sequential animation timeline. */
|
|
43
|
-
interface
|
|
44
|
+
interface AnimationScene {
|
|
44
45
|
/** The node tree to render for this scene. */
|
|
45
46
|
node: Node;
|
|
46
47
|
/** The duration of this scene in milliseconds. */
|
|
@@ -107,7 +108,7 @@ interface RegisteredFamily {
|
|
|
107
108
|
/** Options for rendering a sequential scene animation. */
|
|
108
109
|
interface RenderAnimationOptions$1 {
|
|
109
110
|
/** The scenes to render sequentially. */
|
|
110
|
-
scenes: Array<
|
|
111
|
+
scenes: Array<AnimationScene>;
|
|
111
112
|
/** Whether to draw debug borders around layout elements. */
|
|
112
113
|
drawDebugBorder?: boolean;
|
|
113
114
|
/** The width of each frame in pixels. */
|
|
@@ -132,6 +133,8 @@ interface RenderAnimationOptions$1 {
|
|
|
132
133
|
images?: Array<ImageSource>;
|
|
133
134
|
/** CSS stylesheets to apply before rendering. */
|
|
134
135
|
stylesheets?: Array<string>;
|
|
136
|
+
/** Structured keyframes to register alongside stylesheets. */
|
|
137
|
+
keyframes?: Keyframes;
|
|
135
138
|
/**
|
|
136
139
|
* The device pixel ratio.
|
|
137
140
|
* @default 1.0
|
|
@@ -216,90 +219,29 @@ interface SvgRenderOptions$1 {
|
|
|
216
219
|
}
|
|
217
220
|
//#endregion
|
|
218
221
|
//#region src/export.d.ts
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
* file), raw bytes, or a descriptor with a lazy `data()` loader.
|
|
222
|
-
*/
|
|
223
|
-
type FontLoader = string | Font | (Omit<FontDetails, "data"> & {
|
|
224
|
-
data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
|
|
225
|
-
ranges?: [number, number][];
|
|
226
|
-
} & ({
|
|
227
|
-
key: string;
|
|
228
|
-
} | {
|
|
229
|
-
name: string;
|
|
230
|
-
}));
|
|
231
|
-
type ImageLoaderData = ImageSource["data"];
|
|
232
|
-
type ImageLoader = Omit<ImageSource, "data"> & {
|
|
233
|
-
data: ImageLoaderData | (() => ImageLoaderData | Promise<ImageLoaderData>);
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Output format. Format-specific options live on the variant that supports them,
|
|
237
|
-
* so `quality` cannot be paired with PNG/ICO/raw, and `lossless` is WebP-only.
|
|
238
|
-
* For WebP, `lossless` takes precedence over `quality`; omitting both encodes
|
|
239
|
-
* losslessly.
|
|
240
|
-
*/
|
|
241
|
-
type OutputFormatOptions = {
|
|
242
|
-
format?: "png";
|
|
243
|
-
} | {
|
|
244
|
-
format: "jpeg";
|
|
245
|
-
quality?: number;
|
|
246
|
-
} | {
|
|
247
|
-
format: "webp";
|
|
248
|
-
quality?: number;
|
|
249
|
-
lossless?: boolean;
|
|
250
|
-
} | {
|
|
251
|
-
format: "ico";
|
|
252
|
-
} | {
|
|
253
|
-
format: "raw";
|
|
254
|
-
};
|
|
255
|
-
type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality" | "lossless"> & OutputFormatOptions & {
|
|
256
|
-
fonts?: FontLoader[];
|
|
222
|
+
type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality" | "lossless"> & OutputFormatOptions$1 & {
|
|
223
|
+
fonts?: FontLoader$1[];
|
|
257
224
|
signal?: AbortSignal;
|
|
258
|
-
images?:
|
|
259
|
-
subset?: boolean;
|
|
260
|
-
};
|
|
261
|
-
/**
|
|
262
|
-
* Animation output format. `quality` and `lossless` are WebP-only; for WebP,
|
|
263
|
-
* `lossless` takes precedence over `quality`, and omitting both encodes
|
|
264
|
-
* losslessly.
|
|
265
|
-
*/
|
|
266
|
-
type AnimationOutputFormatOptions = {
|
|
267
|
-
format?: "webp";
|
|
268
|
-
quality?: number;
|
|
269
|
-
lossless?: boolean;
|
|
270
|
-
} | {
|
|
271
|
-
format: "apng";
|
|
272
|
-
} | {
|
|
273
|
-
format: "gif";
|
|
225
|
+
images?: ImagesInput$1;
|
|
274
226
|
};
|
|
275
|
-
type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions & {
|
|
276
|
-
fonts?: FontLoader[];
|
|
227
|
+
type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions$1 & {
|
|
228
|
+
fonts?: FontLoader$1[];
|
|
277
229
|
signal?: AbortSignal;
|
|
278
|
-
images?:
|
|
279
|
-
subset?: boolean;
|
|
230
|
+
images?: ImagesInput$1;
|
|
280
231
|
};
|
|
281
232
|
type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
|
|
282
|
-
fonts?: FontLoader[];
|
|
233
|
+
fonts?: FontLoader$1[];
|
|
283
234
|
signal?: AbortSignal;
|
|
284
|
-
images?:
|
|
285
|
-
subset?: boolean;
|
|
235
|
+
images?: ImagesInput$1;
|
|
286
236
|
};
|
|
287
237
|
declare class Renderer {
|
|
288
|
-
private fontsByKey;
|
|
289
|
-
private fontsByData;
|
|
290
238
|
private inner;
|
|
291
|
-
private
|
|
292
|
-
private setFont;
|
|
293
|
-
private deleteFont;
|
|
294
|
-
private prepareFonts;
|
|
295
|
-
/** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
|
|
296
|
-
* the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
|
|
297
|
-
private resolveResources;
|
|
239
|
+
private fonts;
|
|
298
240
|
render(node: Node, options?: RenderOptions): Promise<Buffer>;
|
|
299
241
|
renderSvg(node: Node, options?: SvgRenderOptions): Promise<string>;
|
|
300
242
|
measure(node: Node, options?: RenderOptions): Promise<MeasuredNode>;
|
|
301
243
|
renderAnimation(options: RenderAnimationOptions): Promise<Buffer>;
|
|
302
|
-
registerFont(font: FontLoader): Promise<
|
|
244
|
+
registerFont(font: FontLoader$1): Promise<RegisteredFamily[]>;
|
|
303
245
|
}
|
|
304
246
|
//#endregion
|
|
305
|
-
export { type AnimationOutputFormat, AnimationOutputFormatOptions, type
|
|
247
|
+
export { type AnimationOutputFormat, type AnimationOutputFormatOptions, type AnimationScene, type ByteBuf, type ContainerNode, type DitheringAlgorithm, type Font, type FontDetails, type FontLoader, type ImageCacheMode, type ImageLoader, type ImageNode, type ImageSource, type ImagesInput, type Keyframes, type KeyframesMap, type KeyframesRuleList, type MeasuredNode, type MeasuredTextRun, type Node, type NodeMetadata, type OutputFormat, type OutputFormatOptions, type RegisteredFace, type RegisteredFamily, RenderAnimationOptions, RenderOptions, Renderer, SvgRenderOptions, type TextNode };
|
package/dist/export.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ContainerNode, ImageNode, Node, NodeMetadata, TextNode
|
|
1
|
+
import { ContainerNode, ImageNode, Node, NodeMetadata, TextNode } from "@takumi-rs/helpers";
|
|
2
|
+
import { AnimationOutputFormatOptions, AnimationOutputFormatOptions as AnimationOutputFormatOptions$1, FontLoader, FontLoader as FontLoader$1, ImageLoader, ImagesInput, ImagesInput as ImagesInput$1, OutputFormatOptions, OutputFormatOptions as OutputFormatOptions$1 } from "@takumi-rs/helpers/renderer";
|
|
2
3
|
import { Properties } from "csstype";
|
|
3
4
|
|
|
4
5
|
//#region index.d.ts
|
|
@@ -40,7 +41,7 @@ type Keyframes = KeyframesMap | KeyframesRuleList;
|
|
|
40
41
|
/** Output format for animated images. */
|
|
41
42
|
type AnimationOutputFormat = /** Animated WebP format. */'webp' | /** Animated PNG format. */'apng' | /** Animated GIF format. */'gif';
|
|
42
43
|
/** Represents a single scene in a sequential animation timeline. */
|
|
43
|
-
interface
|
|
44
|
+
interface AnimationScene {
|
|
44
45
|
/** The node tree to render for this scene. */
|
|
45
46
|
node: Node;
|
|
46
47
|
/** The duration of this scene in milliseconds. */
|
|
@@ -107,7 +108,7 @@ interface RegisteredFamily {
|
|
|
107
108
|
/** Options for rendering a sequential scene animation. */
|
|
108
109
|
interface RenderAnimationOptions$1 {
|
|
109
110
|
/** The scenes to render sequentially. */
|
|
110
|
-
scenes: Array<
|
|
111
|
+
scenes: Array<AnimationScene>;
|
|
111
112
|
/** Whether to draw debug borders around layout elements. */
|
|
112
113
|
drawDebugBorder?: boolean;
|
|
113
114
|
/** The width of each frame in pixels. */
|
|
@@ -132,6 +133,8 @@ interface RenderAnimationOptions$1 {
|
|
|
132
133
|
images?: Array<ImageSource>;
|
|
133
134
|
/** CSS stylesheets to apply before rendering. */
|
|
134
135
|
stylesheets?: Array<string>;
|
|
136
|
+
/** Structured keyframes to register alongside stylesheets. */
|
|
137
|
+
keyframes?: Keyframes;
|
|
135
138
|
/**
|
|
136
139
|
* The device pixel ratio.
|
|
137
140
|
* @default 1.0
|
|
@@ -216,90 +219,29 @@ interface SvgRenderOptions$1 {
|
|
|
216
219
|
}
|
|
217
220
|
//#endregion
|
|
218
221
|
//#region src/export.d.ts
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
* file), raw bytes, or a descriptor with a lazy `data()` loader.
|
|
222
|
-
*/
|
|
223
|
-
type FontLoader = string | Font | (Omit<FontDetails, "data"> & {
|
|
224
|
-
data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
|
|
225
|
-
ranges?: [number, number][];
|
|
226
|
-
} & ({
|
|
227
|
-
key: string;
|
|
228
|
-
} | {
|
|
229
|
-
name: string;
|
|
230
|
-
}));
|
|
231
|
-
type ImageLoaderData = ImageSource["data"];
|
|
232
|
-
type ImageLoader = Omit<ImageSource, "data"> & {
|
|
233
|
-
data: ImageLoaderData | (() => ImageLoaderData | Promise<ImageLoaderData>);
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Output format. Format-specific options live on the variant that supports them,
|
|
237
|
-
* so `quality` cannot be paired with PNG/ICO/raw, and `lossless` is WebP-only.
|
|
238
|
-
* For WebP, `lossless` takes precedence over `quality`; omitting both encodes
|
|
239
|
-
* losslessly.
|
|
240
|
-
*/
|
|
241
|
-
type OutputFormatOptions = {
|
|
242
|
-
format?: "png";
|
|
243
|
-
} | {
|
|
244
|
-
format: "jpeg";
|
|
245
|
-
quality?: number;
|
|
246
|
-
} | {
|
|
247
|
-
format: "webp";
|
|
248
|
-
quality?: number;
|
|
249
|
-
lossless?: boolean;
|
|
250
|
-
} | {
|
|
251
|
-
format: "ico";
|
|
252
|
-
} | {
|
|
253
|
-
format: "raw";
|
|
254
|
-
};
|
|
255
|
-
type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality" | "lossless"> & OutputFormatOptions & {
|
|
256
|
-
fonts?: FontLoader[];
|
|
222
|
+
type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality" | "lossless"> & OutputFormatOptions$1 & {
|
|
223
|
+
fonts?: FontLoader$1[];
|
|
257
224
|
signal?: AbortSignal;
|
|
258
|
-
images?:
|
|
259
|
-
subset?: boolean;
|
|
260
|
-
};
|
|
261
|
-
/**
|
|
262
|
-
* Animation output format. `quality` and `lossless` are WebP-only; for WebP,
|
|
263
|
-
* `lossless` takes precedence over `quality`, and omitting both encodes
|
|
264
|
-
* losslessly.
|
|
265
|
-
*/
|
|
266
|
-
type AnimationOutputFormatOptions = {
|
|
267
|
-
format?: "webp";
|
|
268
|
-
quality?: number;
|
|
269
|
-
lossless?: boolean;
|
|
270
|
-
} | {
|
|
271
|
-
format: "apng";
|
|
272
|
-
} | {
|
|
273
|
-
format: "gif";
|
|
225
|
+
images?: ImagesInput$1;
|
|
274
226
|
};
|
|
275
|
-
type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions & {
|
|
276
|
-
fonts?: FontLoader[];
|
|
227
|
+
type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions$1 & {
|
|
228
|
+
fonts?: FontLoader$1[];
|
|
277
229
|
signal?: AbortSignal;
|
|
278
|
-
images?:
|
|
279
|
-
subset?: boolean;
|
|
230
|
+
images?: ImagesInput$1;
|
|
280
231
|
};
|
|
281
232
|
type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
|
|
282
|
-
fonts?: FontLoader[];
|
|
233
|
+
fonts?: FontLoader$1[];
|
|
283
234
|
signal?: AbortSignal;
|
|
284
|
-
images?:
|
|
285
|
-
subset?: boolean;
|
|
235
|
+
images?: ImagesInput$1;
|
|
286
236
|
};
|
|
287
237
|
declare class Renderer {
|
|
288
|
-
private fontsByKey;
|
|
289
|
-
private fontsByData;
|
|
290
238
|
private inner;
|
|
291
|
-
private
|
|
292
|
-
private setFont;
|
|
293
|
-
private deleteFont;
|
|
294
|
-
private prepareFonts;
|
|
295
|
-
/** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
|
|
296
|
-
* the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
|
|
297
|
-
private resolveResources;
|
|
239
|
+
private fonts;
|
|
298
240
|
render(node: Node, options?: RenderOptions): Promise<Buffer>;
|
|
299
241
|
renderSvg(node: Node, options?: SvgRenderOptions): Promise<string>;
|
|
300
242
|
measure(node: Node, options?: RenderOptions): Promise<MeasuredNode>;
|
|
301
243
|
renderAnimation(options: RenderAnimationOptions): Promise<Buffer>;
|
|
302
|
-
registerFont(font: FontLoader): Promise<
|
|
244
|
+
registerFont(font: FontLoader$1): Promise<RegisteredFamily[]>;
|
|
303
245
|
}
|
|
304
246
|
//#endregion
|
|
305
|
-
export { type AnimationOutputFormat, AnimationOutputFormatOptions, type
|
|
247
|
+
export { type AnimationOutputFormat, type AnimationOutputFormatOptions, type AnimationScene, type ByteBuf, type ContainerNode, type DitheringAlgorithm, type Font, type FontDetails, type FontLoader, type ImageCacheMode, type ImageLoader, type ImageNode, type ImageSource, type ImagesInput, type Keyframes, type KeyframesMap, type KeyframesRuleList, type MeasuredNode, type MeasuredTextRun, type Node, type NodeMetadata, type OutputFormat, type OutputFormatOptions, type RegisteredFace, type RegisteredFamily, RenderAnimationOptions, RenderOptions, Renderer, SvgRenderOptions, type TextNode };
|
package/dist/export.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
|
-
import {
|
|
2
|
+
import { subsetFonts } from "@takumi-rs/helpers";
|
|
3
|
+
import { FontRegistry } from "@takumi-rs/helpers/renderer";
|
|
3
4
|
//#region index.js
|
|
4
5
|
const require = createRequire(import.meta.url);
|
|
5
6
|
const { readFileSync } = require(/* turbopackOptional: true */ "fs");
|
|
@@ -57,7 +58,7 @@ function requireNative() {
|
|
|
57
58
|
try {
|
|
58
59
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/core.android-arm64.node");
|
|
59
60
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/package.json").version;
|
|
60
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
61
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
61
62
|
return binding;
|
|
62
63
|
} catch (e) {
|
|
63
64
|
loadErrors.push(e);
|
|
@@ -71,7 +72,7 @@ function requireNative() {
|
|
|
71
72
|
try {
|
|
72
73
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/core.android-arm-eabi.node");
|
|
73
74
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/package.json").version;
|
|
74
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
75
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
75
76
|
return binding;
|
|
76
77
|
} catch (e) {
|
|
77
78
|
loadErrors.push(e);
|
|
@@ -86,7 +87,7 @@ function requireNative() {
|
|
|
86
87
|
try {
|
|
87
88
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/core.win32-x64-gnu.node");
|
|
88
89
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/package.json").version;
|
|
89
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
90
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
90
91
|
return binding;
|
|
91
92
|
} catch (e) {
|
|
92
93
|
loadErrors.push(e);
|
|
@@ -100,7 +101,7 @@ function requireNative() {
|
|
|
100
101
|
try {
|
|
101
102
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/core.win32-x64-msvc.node");
|
|
102
103
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/package.json").version;
|
|
103
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
104
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
104
105
|
return binding;
|
|
105
106
|
} catch (e) {
|
|
106
107
|
loadErrors.push(e);
|
|
@@ -115,7 +116,7 @@ function requireNative() {
|
|
|
115
116
|
try {
|
|
116
117
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/core.win32-ia32-msvc.node");
|
|
117
118
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/package.json").version;
|
|
118
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
119
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
119
120
|
return binding;
|
|
120
121
|
} catch (e) {
|
|
121
122
|
loadErrors.push(e);
|
|
@@ -129,7 +130,7 @@ function requireNative() {
|
|
|
129
130
|
try {
|
|
130
131
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/core.win32-arm64-msvc.node");
|
|
131
132
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/package.json").version;
|
|
132
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
133
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
133
134
|
return binding;
|
|
134
135
|
} catch (e) {
|
|
135
136
|
loadErrors.push(e);
|
|
@@ -144,7 +145,7 @@ function requireNative() {
|
|
|
144
145
|
try {
|
|
145
146
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/core.darwin-universal.node");
|
|
146
147
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/package.json").version;
|
|
147
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
148
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
148
149
|
return binding;
|
|
149
150
|
} catch (e) {
|
|
150
151
|
loadErrors.push(e);
|
|
@@ -158,7 +159,7 @@ function requireNative() {
|
|
|
158
159
|
try {
|
|
159
160
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/core.darwin-x64.node");
|
|
160
161
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/package.json").version;
|
|
161
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
162
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
162
163
|
return binding;
|
|
163
164
|
} catch (e) {
|
|
164
165
|
loadErrors.push(e);
|
|
@@ -172,7 +173,7 @@ function requireNative() {
|
|
|
172
173
|
try {
|
|
173
174
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/core.darwin-arm64.node");
|
|
174
175
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/package.json").version;
|
|
175
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
176
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
176
177
|
return binding;
|
|
177
178
|
} catch (e) {
|
|
178
179
|
loadErrors.push(e);
|
|
@@ -187,7 +188,7 @@ function requireNative() {
|
|
|
187
188
|
try {
|
|
188
189
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/core.freebsd-x64.node");
|
|
189
190
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/package.json").version;
|
|
190
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
191
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
191
192
|
return binding;
|
|
192
193
|
} catch (e) {
|
|
193
194
|
loadErrors.push(e);
|
|
@@ -201,7 +202,7 @@ function requireNative() {
|
|
|
201
202
|
try {
|
|
202
203
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/core.freebsd-arm64.node");
|
|
203
204
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/package.json").version;
|
|
204
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
205
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
205
206
|
return binding;
|
|
206
207
|
} catch (e) {
|
|
207
208
|
loadErrors.push(e);
|
|
@@ -216,7 +217,7 @@ function requireNative() {
|
|
|
216
217
|
try {
|
|
217
218
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/core.linux-x64-musl.node");
|
|
218
219
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/package.json").version;
|
|
219
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
220
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
220
221
|
return binding;
|
|
221
222
|
} catch (e) {
|
|
222
223
|
loadErrors.push(e);
|
|
@@ -230,7 +231,7 @@ function requireNative() {
|
|
|
230
231
|
try {
|
|
231
232
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/core.linux-x64-gnu.node");
|
|
232
233
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/package.json").version;
|
|
233
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
234
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
234
235
|
return binding;
|
|
235
236
|
} catch (e) {
|
|
236
237
|
loadErrors.push(e);
|
|
@@ -245,7 +246,7 @@ function requireNative() {
|
|
|
245
246
|
try {
|
|
246
247
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/core.linux-arm64-musl.node");
|
|
247
248
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/package.json").version;
|
|
248
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
249
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
249
250
|
return binding;
|
|
250
251
|
} catch (e) {
|
|
251
252
|
loadErrors.push(e);
|
|
@@ -259,7 +260,7 @@ function requireNative() {
|
|
|
259
260
|
try {
|
|
260
261
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/core.linux-arm64-gnu.node");
|
|
261
262
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/package.json").version;
|
|
262
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
263
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
263
264
|
return binding;
|
|
264
265
|
} catch (e) {
|
|
265
266
|
loadErrors.push(e);
|
|
@@ -274,7 +275,7 @@ function requireNative() {
|
|
|
274
275
|
try {
|
|
275
276
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/core.linux-arm-musleabihf.node");
|
|
276
277
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/package.json").version;
|
|
277
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
278
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
278
279
|
return binding;
|
|
279
280
|
} catch (e) {
|
|
280
281
|
loadErrors.push(e);
|
|
@@ -288,7 +289,7 @@ function requireNative() {
|
|
|
288
289
|
try {
|
|
289
290
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/core.linux-arm-gnueabihf.node");
|
|
290
291
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/package.json").version;
|
|
291
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
292
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
292
293
|
return binding;
|
|
293
294
|
} catch (e) {
|
|
294
295
|
loadErrors.push(e);
|
|
@@ -303,7 +304,7 @@ function requireNative() {
|
|
|
303
304
|
try {
|
|
304
305
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/core.linux-loong64-musl.node");
|
|
305
306
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/package.json").version;
|
|
306
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
307
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
307
308
|
return binding;
|
|
308
309
|
} catch (e) {
|
|
309
310
|
loadErrors.push(e);
|
|
@@ -317,7 +318,7 @@ function requireNative() {
|
|
|
317
318
|
try {
|
|
318
319
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/core.linux-loong64-gnu.node");
|
|
319
320
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/package.json").version;
|
|
320
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
321
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
321
322
|
return binding;
|
|
322
323
|
} catch (e) {
|
|
323
324
|
loadErrors.push(e);
|
|
@@ -332,7 +333,7 @@ function requireNative() {
|
|
|
332
333
|
try {
|
|
333
334
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/core.linux-riscv64-musl.node");
|
|
334
335
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/package.json").version;
|
|
335
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
336
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
336
337
|
return binding;
|
|
337
338
|
} catch (e) {
|
|
338
339
|
loadErrors.push(e);
|
|
@@ -346,7 +347,7 @@ function requireNative() {
|
|
|
346
347
|
try {
|
|
347
348
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/core.linux-riscv64-gnu.node");
|
|
348
349
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/package.json").version;
|
|
349
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
350
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
350
351
|
return binding;
|
|
351
352
|
} catch (e) {
|
|
352
353
|
loadErrors.push(e);
|
|
@@ -361,7 +362,7 @@ function requireNative() {
|
|
|
361
362
|
try {
|
|
362
363
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/core.linux-ppc64-gnu.node");
|
|
363
364
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/package.json").version;
|
|
364
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
365
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
365
366
|
return binding;
|
|
366
367
|
} catch (e) {
|
|
367
368
|
loadErrors.push(e);
|
|
@@ -375,7 +376,7 @@ function requireNative() {
|
|
|
375
376
|
try {
|
|
376
377
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/core.linux-s390x-gnu.node");
|
|
377
378
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/package.json").version;
|
|
378
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
379
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
379
380
|
return binding;
|
|
380
381
|
} catch (e) {
|
|
381
382
|
loadErrors.push(e);
|
|
@@ -390,7 +391,7 @@ function requireNative() {
|
|
|
390
391
|
try {
|
|
391
392
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/core.openharmony-arm64.node");
|
|
392
393
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/package.json").version;
|
|
393
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
394
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
394
395
|
return binding;
|
|
395
396
|
} catch (e) {
|
|
396
397
|
loadErrors.push(e);
|
|
@@ -404,7 +405,7 @@ function requireNative() {
|
|
|
404
405
|
try {
|
|
405
406
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/core.openharmony-x64.node");
|
|
406
407
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/package.json").version;
|
|
407
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
408
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
408
409
|
return binding;
|
|
409
410
|
} catch (e) {
|
|
410
411
|
loadErrors.push(e);
|
|
@@ -418,7 +419,7 @@ function requireNative() {
|
|
|
418
419
|
try {
|
|
419
420
|
const binding = require(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/core.openharmony-arm.node");
|
|
420
421
|
const bindingPackageVersion = require(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/package.json").version;
|
|
421
|
-
if (bindingPackageVersion !== "2.0.0-rc.
|
|
422
|
+
if (bindingPackageVersion !== "2.0.0-rc.11" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 2.0.0-rc.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
422
423
|
return binding;
|
|
423
424
|
} catch (e) {
|
|
424
425
|
loadErrors.push(e);
|
|
@@ -467,50 +468,14 @@ if (!nativeBinding) {
|
|
|
467
468
|
const { Renderer: Renderer$1, AnimationOutputFormat, DitheringAlgorithm, ImageCacheMode, OutputFormat } = nativeBinding;
|
|
468
469
|
//#endregion
|
|
469
470
|
//#region src/export.ts
|
|
470
|
-
async function resolveImageLoaders(images) {
|
|
471
|
-
const bySrc = /* @__PURE__ */ new Map();
|
|
472
|
-
for (const image of images) bySrc.set(image.src, image);
|
|
473
|
-
return Promise.all([...bySrc.values()].map(async ({ src, data, cache }) => ({
|
|
474
|
-
src,
|
|
475
|
-
data: typeof data === "function" ? await data() : data,
|
|
476
|
-
cache
|
|
477
|
-
})));
|
|
478
|
-
}
|
|
479
471
|
var Renderer = class {
|
|
480
|
-
fontsByKey = /* @__PURE__ */ new Map();
|
|
481
|
-
fontsByData = /* @__PURE__ */ new WeakMap();
|
|
482
472
|
inner = new Renderer$1();
|
|
483
|
-
|
|
484
|
-
return typeof key === "string" ? this.fontsByKey.get(key) : this.fontsByData.get(key);
|
|
485
|
-
}
|
|
486
|
-
setFont(key, family) {
|
|
487
|
-
if (typeof key === "string") this.fontsByKey.set(key, family);
|
|
488
|
-
else this.fontsByData.set(key, family);
|
|
489
|
-
}
|
|
490
|
-
deleteFont(key) {
|
|
491
|
-
if (typeof key === "string") this.fontsByKey.delete(key);
|
|
492
|
-
else this.fontsByData.delete(key);
|
|
493
|
-
}
|
|
494
|
-
async prepareFonts(fonts) {
|
|
495
|
-
if (!fonts) return;
|
|
496
|
-
const families = await Promise.all(fonts.map(this.registerFont.bind(this)));
|
|
497
|
-
return [...new Set(families.flat().map((f) => f.name))];
|
|
498
|
-
}
|
|
499
|
-
/** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
|
|
500
|
-
* the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
|
|
501
|
-
async resolveResources(fonts, images, fontFamilies) {
|
|
502
|
-
const registeredFamilies = await this.prepareFonts(fonts);
|
|
503
|
-
return {
|
|
504
|
-
images: images ? await resolveImageLoaders(images) : void 0,
|
|
505
|
-
fontFamilies: fontFamilies ?? registeredFamilies
|
|
506
|
-
};
|
|
507
|
-
}
|
|
473
|
+
fonts = new FontRegistry((font) => this.inner.registerFont(font));
|
|
508
474
|
async render(node, options) {
|
|
509
|
-
const { fonts, fontFamilies, signal, images,
|
|
510
|
-
const resolved = await this.resolveResources(
|
|
475
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options ?? {};
|
|
476
|
+
const resolved = await this.fonts.resolveResources(fonts && subsetFonts({
|
|
511
477
|
fonts,
|
|
512
|
-
source: node
|
|
513
|
-
subset
|
|
478
|
+
source: node
|
|
514
479
|
}), images, fontFamilies);
|
|
515
480
|
return this.inner.render(node, {
|
|
516
481
|
...rest,
|
|
@@ -518,11 +483,10 @@ var Renderer = class {
|
|
|
518
483
|
}, signal);
|
|
519
484
|
}
|
|
520
485
|
async renderSvg(node, options) {
|
|
521
|
-
const { fonts, fontFamilies, signal, images,
|
|
522
|
-
const resolved = await this.resolveResources(
|
|
486
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options ?? {};
|
|
487
|
+
const resolved = await this.fonts.resolveResources(fonts && subsetFonts({
|
|
523
488
|
fonts,
|
|
524
|
-
source: node
|
|
525
|
-
subset
|
|
489
|
+
source: node
|
|
526
490
|
}), images, fontFamilies);
|
|
527
491
|
return this.inner.renderSvg(node, {
|
|
528
492
|
...rest,
|
|
@@ -530,11 +494,10 @@ var Renderer = class {
|
|
|
530
494
|
}, signal);
|
|
531
495
|
}
|
|
532
496
|
async measure(node, options) {
|
|
533
|
-
const { fonts, fontFamilies, signal, images,
|
|
534
|
-
const resolved = await this.resolveResources(
|
|
497
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options ?? {};
|
|
498
|
+
const resolved = await this.fonts.resolveResources(fonts && subsetFonts({
|
|
535
499
|
fonts,
|
|
536
|
-
source: node
|
|
537
|
-
subset
|
|
500
|
+
source: node
|
|
538
501
|
}), images, fontFamilies);
|
|
539
502
|
return this.inner.measure(node, {
|
|
540
503
|
...rest,
|
|
@@ -542,54 +505,20 @@ var Renderer = class {
|
|
|
542
505
|
}, signal);
|
|
543
506
|
}
|
|
544
507
|
async renderAnimation(options) {
|
|
545
|
-
const { fonts, fontFamilies, signal, images,
|
|
508
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options;
|
|
546
509
|
const nodes = options.scenes.map((scene) => scene.node);
|
|
547
|
-
const resolved = await this.resolveResources(
|
|
510
|
+
const resolved = await this.fonts.resolveResources(fonts && subsetFonts({
|
|
548
511
|
fonts,
|
|
549
|
-
source: nodes
|
|
550
|
-
subset
|
|
512
|
+
source: nodes
|
|
551
513
|
}), images, fontFamilies);
|
|
552
514
|
return this.inner.renderAnimation({
|
|
553
515
|
...rest,
|
|
554
516
|
...resolved
|
|
555
517
|
}, signal);
|
|
556
518
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const key = createFontKey(loader);
|
|
560
|
-
const cached = this.getFont(key);
|
|
561
|
-
if (cached) return cached;
|
|
562
|
-
const extracted = extractFontBuffer(loader);
|
|
563
|
-
const register = (data) => this.inner.registerFont(isBuffer(loader) ? data : {
|
|
564
|
-
...loader,
|
|
565
|
-
data
|
|
566
|
-
});
|
|
567
|
-
if (isBuffer(extracted)) {
|
|
568
|
-
const binded = register(extracted);
|
|
569
|
-
this.setFont(key, Promise.resolve(binded));
|
|
570
|
-
return binded;
|
|
571
|
-
}
|
|
572
|
-
const promise = extracted.then(register).catch((error) => {
|
|
573
|
-
this.deleteFont(key);
|
|
574
|
-
throw error;
|
|
575
|
-
});
|
|
576
|
-
this.setFont(key, promise);
|
|
577
|
-
return promise;
|
|
519
|
+
registerFont(font) {
|
|
520
|
+
return this.fonts.register(font);
|
|
578
521
|
}
|
|
579
522
|
};
|
|
580
|
-
function extractFontBuffer(font) {
|
|
581
|
-
if (isBuffer(font)) return font;
|
|
582
|
-
if (typeof font.data !== "function") return font.data;
|
|
583
|
-
return font.data();
|
|
584
|
-
}
|
|
585
|
-
function createFontKey(font) {
|
|
586
|
-
if (isBuffer(font)) return font;
|
|
587
|
-
if ("key" in font && font.key) return font.key;
|
|
588
|
-
if (typeof font.data === "function") return `${font.name ?? ""}:${font.weight ?? ""}:${font.style ?? ""}`;
|
|
589
|
-
return font.data;
|
|
590
|
-
}
|
|
591
|
-
function isBuffer(data) {
|
|
592
|
-
return data instanceof Uint8Array || data instanceof ArrayBuffer || typeof Buffer !== "undefined" && Buffer.isBuffer(data);
|
|
593
|
-
}
|
|
594
523
|
//#endregion
|
|
595
|
-
export { Renderer
|
|
524
|
+
export { Renderer };
|
package/index.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export type AnimationOutputFormat = /** Animated WebP format. */
|
|
|
68
68
|
'gif';
|
|
69
69
|
|
|
70
70
|
/** Represents a single scene in a sequential animation timeline. */
|
|
71
|
-
export interface
|
|
71
|
+
export interface AnimationScene {
|
|
72
72
|
/** The node tree to render for this scene. */
|
|
73
73
|
node: Node
|
|
74
74
|
/** The duration of this scene in milliseconds. */
|
|
@@ -158,7 +158,7 @@ export interface RegisteredFamily {
|
|
|
158
158
|
/** Options for rendering a sequential scene animation. */
|
|
159
159
|
export interface RenderAnimationOptions {
|
|
160
160
|
/** The scenes to render sequentially. */
|
|
161
|
-
scenes: Array<
|
|
161
|
+
scenes: Array<AnimationScene>
|
|
162
162
|
/** Whether to draw debug borders around layout elements. */
|
|
163
163
|
drawDebugBorder?: boolean
|
|
164
164
|
/** The width of each frame in pixels. */
|
|
@@ -183,6 +183,8 @@ export interface RenderAnimationOptions {
|
|
|
183
183
|
images?: Array<ImageSource>
|
|
184
184
|
/** CSS stylesheets to apply before rendering. */
|
|
185
185
|
stylesheets?: Array<string>
|
|
186
|
+
/** Structured keyframes to register alongside stylesheets. */
|
|
187
|
+
keyframes?: Keyframes
|
|
186
188
|
/**
|
|
187
189
|
* The device pixel ratio.
|
|
188
190
|
* @default 1.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.11",
|
|
4
4
|
"description": "Native Node.js bindings for the Takumi Rust image rendering engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"publish-lint": "attw --pack . && publint --strict ."
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@takumi-rs/helpers": "2.0.0-rc.
|
|
73
|
+
"@takumi-rs/helpers": "2.0.0-rc.11",
|
|
74
74
|
"csstype": "^3.2.3"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@types/bun": "^1.3.14",
|
|
79
79
|
"@types/react": "19.2.17",
|
|
80
80
|
"@types/react-dom": "^19.2.3",
|
|
81
|
-
"lucide-react": "^1.
|
|
81
|
+
"lucide-react": "^1.23.0",
|
|
82
82
|
"mitata": "^1.0.34",
|
|
83
83
|
"react": "^19.2.7",
|
|
84
84
|
"tsdown": "^0.22.3",
|
|
@@ -102,13 +102,13 @@
|
|
|
102
102
|
"node": ">=18"
|
|
103
103
|
},
|
|
104
104
|
"optionalDependencies": {
|
|
105
|
-
"@takumi-rs/core-darwin-x64": "2.0.0-rc.
|
|
106
|
-
"@takumi-rs/core-darwin-arm64": "2.0.0-rc.
|
|
107
|
-
"@takumi-rs/core-linux-arm64-gnu": "2.0.0-rc.
|
|
108
|
-
"@takumi-rs/core-linux-arm64-musl": "2.0.0-rc.
|
|
109
|
-
"@takumi-rs/core-win32-arm64-msvc": "2.0.0-rc.
|
|
110
|
-
"@takumi-rs/core-linux-x64-gnu": "2.0.0-rc.
|
|
111
|
-
"@takumi-rs/core-linux-x64-musl": "2.0.0-rc.
|
|
112
|
-
"@takumi-rs/core-win32-x64-msvc": "2.0.0-rc.
|
|
105
|
+
"@takumi-rs/core-darwin-x64": "2.0.0-rc.11",
|
|
106
|
+
"@takumi-rs/core-darwin-arm64": "2.0.0-rc.11",
|
|
107
|
+
"@takumi-rs/core-linux-arm64-gnu": "2.0.0-rc.11",
|
|
108
|
+
"@takumi-rs/core-linux-arm64-musl": "2.0.0-rc.11",
|
|
109
|
+
"@takumi-rs/core-win32-arm64-msvc": "2.0.0-rc.11",
|
|
110
|
+
"@takumi-rs/core-linux-x64-gnu": "2.0.0-rc.11",
|
|
111
|
+
"@takumi-rs/core-linux-x64-musl": "2.0.0-rc.11",
|
|
112
|
+
"@takumi-rs/core-win32-x64-msvc": "2.0.0-rc.11"
|
|
113
113
|
}
|
|
114
114
|
}
|