@takumi-rs/core 1.8.6 → 2.0.0-beta.0
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 +153 -154
- package/dist/export.d.cts +329 -0
- package/dist/export.d.mts +329 -0
- package/dist/export.mjs +152 -153
- package/index.d.ts +106 -33
- package/package.json +32 -22
- package/dist/export.d.ts +0 -32
package/dist/export.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
let
|
|
2
|
+
let module$1 = require(/* turbopackOptional: true */ "module");
|
|
3
3
|
let _takumi_rs_helpers = require(/* turbopackOptional: true */ "@takumi-rs/helpers");
|
|
4
4
|
//#region index.js
|
|
5
|
-
const require$1 = (0,
|
|
5
|
+
const require$1 = (0, module$1.createRequire)(require(/* turbopackOptional: true */ "url").pathToFileURL(__filename).href);
|
|
6
6
|
new URL(".", require(/* turbopackOptional: true */ "url").pathToFileURL(__filename).href).pathname;
|
|
7
|
-
const { readFileSync } = require$1(/* turbopackOptional: true */ "
|
|
7
|
+
const { readFileSync } = require$1(/* turbopackOptional: true */ "fs");
|
|
8
8
|
let nativeBinding = null;
|
|
9
9
|
const loadErrors = [];
|
|
10
10
|
const isMusl = () => {
|
|
@@ -25,9 +25,8 @@ const isMuslFromFilesystem = () => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
const isMuslFromReport = () => {
|
|
28
|
-
var _process$report;
|
|
29
28
|
let report = null;
|
|
30
|
-
if (
|
|
29
|
+
if (process.report && typeof process.report.getReport === "function") {
|
|
31
30
|
process.report.excludeNetwork = true;
|
|
32
31
|
report = process.report.getReport();
|
|
33
32
|
}
|
|
@@ -60,7 +59,7 @@ function requireNative() {
|
|
|
60
59
|
try {
|
|
61
60
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/core.android-arm64.node");
|
|
62
61
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/package.json").version;
|
|
63
|
-
if (bindingPackageVersion !== "
|
|
62
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
64
63
|
return binding;
|
|
65
64
|
} catch (e) {
|
|
66
65
|
loadErrors.push(e);
|
|
@@ -74,44 +73,42 @@ function requireNative() {
|
|
|
74
73
|
try {
|
|
75
74
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/core.android-arm-eabi.node");
|
|
76
75
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/package.json").version;
|
|
77
|
-
if (bindingPackageVersion !== "
|
|
76
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
78
77
|
return binding;
|
|
79
78
|
} catch (e) {
|
|
80
79
|
loadErrors.push(e);
|
|
81
80
|
}
|
|
82
81
|
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
|
|
83
|
-
else if (process.platform === "win32") if (process.arch === "x64") {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} catch (e) {
|
|
111
|
-
loadErrors.push(e);
|
|
112
|
-
}
|
|
82
|
+
else if (process.platform === "win32") if (process.arch === "x64") if (process.config && process.config.variables && process.config.variables.shlib_suffix === "dll.a" || process.config && process.config.variables && process.config.variables.node_target_type === "shared_library") {
|
|
83
|
+
try {
|
|
84
|
+
return require$1(/* turbopackOptional: true */ "../core.win32-x64-gnu.node");
|
|
85
|
+
} catch (e) {
|
|
86
|
+
loadErrors.push(e);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/core.win32-x64-gnu.node");
|
|
90
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/package.json").version;
|
|
91
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
92
|
+
return binding;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
loadErrors.push(e);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
try {
|
|
98
|
+
return require$1(/* turbopackOptional: true */ "../core.win32-x64-msvc.node");
|
|
99
|
+
} catch (e) {
|
|
100
|
+
loadErrors.push(e);
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/core.win32-x64-msvc.node");
|
|
104
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/package.json").version;
|
|
105
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
106
|
+
return binding;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
loadErrors.push(e);
|
|
113
109
|
}
|
|
114
|
-
}
|
|
110
|
+
}
|
|
111
|
+
else if (process.arch === "ia32") {
|
|
115
112
|
try {
|
|
116
113
|
return require$1(/* turbopackOptional: true */ "../core.win32-ia32-msvc.node");
|
|
117
114
|
} catch (e) {
|
|
@@ -120,7 +117,7 @@ function requireNative() {
|
|
|
120
117
|
try {
|
|
121
118
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/core.win32-ia32-msvc.node");
|
|
122
119
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/package.json").version;
|
|
123
|
-
if (bindingPackageVersion !== "
|
|
120
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
124
121
|
return binding;
|
|
125
122
|
} catch (e) {
|
|
126
123
|
loadErrors.push(e);
|
|
@@ -134,7 +131,7 @@ function requireNative() {
|
|
|
134
131
|
try {
|
|
135
132
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/core.win32-arm64-msvc.node");
|
|
136
133
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/package.json").version;
|
|
137
|
-
if (bindingPackageVersion !== "
|
|
134
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
138
135
|
return binding;
|
|
139
136
|
} catch (e) {
|
|
140
137
|
loadErrors.push(e);
|
|
@@ -149,7 +146,7 @@ function requireNative() {
|
|
|
149
146
|
try {
|
|
150
147
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/core.darwin-universal.node");
|
|
151
148
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/package.json").version;
|
|
152
|
-
if (bindingPackageVersion !== "
|
|
149
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
153
150
|
return binding;
|
|
154
151
|
} catch (e) {
|
|
155
152
|
loadErrors.push(e);
|
|
@@ -163,7 +160,7 @@ function requireNative() {
|
|
|
163
160
|
try {
|
|
164
161
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/core.darwin-x64.node");
|
|
165
162
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/package.json").version;
|
|
166
|
-
if (bindingPackageVersion !== "
|
|
163
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
167
164
|
return binding;
|
|
168
165
|
} catch (e) {
|
|
169
166
|
loadErrors.push(e);
|
|
@@ -177,7 +174,7 @@ function requireNative() {
|
|
|
177
174
|
try {
|
|
178
175
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/core.darwin-arm64.node");
|
|
179
176
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/package.json").version;
|
|
180
|
-
if (bindingPackageVersion !== "
|
|
177
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
181
178
|
return binding;
|
|
182
179
|
} catch (e) {
|
|
183
180
|
loadErrors.push(e);
|
|
@@ -192,7 +189,7 @@ function requireNative() {
|
|
|
192
189
|
try {
|
|
193
190
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/core.freebsd-x64.node");
|
|
194
191
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/package.json").version;
|
|
195
|
-
if (bindingPackageVersion !== "
|
|
192
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
196
193
|
return binding;
|
|
197
194
|
} catch (e) {
|
|
198
195
|
loadErrors.push(e);
|
|
@@ -206,7 +203,7 @@ function requireNative() {
|
|
|
206
203
|
try {
|
|
207
204
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/core.freebsd-arm64.node");
|
|
208
205
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/package.json").version;
|
|
209
|
-
if (bindingPackageVersion !== "
|
|
206
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
210
207
|
return binding;
|
|
211
208
|
} catch (e) {
|
|
212
209
|
loadErrors.push(e);
|
|
@@ -221,7 +218,7 @@ function requireNative() {
|
|
|
221
218
|
try {
|
|
222
219
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/core.linux-x64-musl.node");
|
|
223
220
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/package.json").version;
|
|
224
|
-
if (bindingPackageVersion !== "
|
|
221
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
225
222
|
return binding;
|
|
226
223
|
} catch (e) {
|
|
227
224
|
loadErrors.push(e);
|
|
@@ -235,7 +232,7 @@ function requireNative() {
|
|
|
235
232
|
try {
|
|
236
233
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/core.linux-x64-gnu.node");
|
|
237
234
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/package.json").version;
|
|
238
|
-
if (bindingPackageVersion !== "
|
|
235
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
239
236
|
return binding;
|
|
240
237
|
} catch (e) {
|
|
241
238
|
loadErrors.push(e);
|
|
@@ -250,7 +247,7 @@ function requireNative() {
|
|
|
250
247
|
try {
|
|
251
248
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/core.linux-arm64-musl.node");
|
|
252
249
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/package.json").version;
|
|
253
|
-
if (bindingPackageVersion !== "
|
|
250
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
254
251
|
return binding;
|
|
255
252
|
} catch (e) {
|
|
256
253
|
loadErrors.push(e);
|
|
@@ -264,7 +261,7 @@ function requireNative() {
|
|
|
264
261
|
try {
|
|
265
262
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/core.linux-arm64-gnu.node");
|
|
266
263
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/package.json").version;
|
|
267
|
-
if (bindingPackageVersion !== "
|
|
264
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
268
265
|
return binding;
|
|
269
266
|
} catch (e) {
|
|
270
267
|
loadErrors.push(e);
|
|
@@ -279,7 +276,7 @@ function requireNative() {
|
|
|
279
276
|
try {
|
|
280
277
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/core.linux-arm-musleabihf.node");
|
|
281
278
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/package.json").version;
|
|
282
|
-
if (bindingPackageVersion !== "
|
|
279
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
283
280
|
return binding;
|
|
284
281
|
} catch (e) {
|
|
285
282
|
loadErrors.push(e);
|
|
@@ -293,7 +290,7 @@ function requireNative() {
|
|
|
293
290
|
try {
|
|
294
291
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/core.linux-arm-gnueabihf.node");
|
|
295
292
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/package.json").version;
|
|
296
|
-
if (bindingPackageVersion !== "
|
|
293
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
297
294
|
return binding;
|
|
298
295
|
} catch (e) {
|
|
299
296
|
loadErrors.push(e);
|
|
@@ -308,7 +305,7 @@ function requireNative() {
|
|
|
308
305
|
try {
|
|
309
306
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/core.linux-loong64-musl.node");
|
|
310
307
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/package.json").version;
|
|
311
|
-
if (bindingPackageVersion !== "
|
|
308
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
312
309
|
return binding;
|
|
313
310
|
} catch (e) {
|
|
314
311
|
loadErrors.push(e);
|
|
@@ -322,7 +319,7 @@ function requireNative() {
|
|
|
322
319
|
try {
|
|
323
320
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/core.linux-loong64-gnu.node");
|
|
324
321
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/package.json").version;
|
|
325
|
-
if (bindingPackageVersion !== "
|
|
322
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
326
323
|
return binding;
|
|
327
324
|
} catch (e) {
|
|
328
325
|
loadErrors.push(e);
|
|
@@ -337,7 +334,7 @@ function requireNative() {
|
|
|
337
334
|
try {
|
|
338
335
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/core.linux-riscv64-musl.node");
|
|
339
336
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/package.json").version;
|
|
340
|
-
if (bindingPackageVersion !== "
|
|
337
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
341
338
|
return binding;
|
|
342
339
|
} catch (e) {
|
|
343
340
|
loadErrors.push(e);
|
|
@@ -351,7 +348,7 @@ function requireNative() {
|
|
|
351
348
|
try {
|
|
352
349
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/core.linux-riscv64-gnu.node");
|
|
353
350
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/package.json").version;
|
|
354
|
-
if (bindingPackageVersion !== "
|
|
351
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
355
352
|
return binding;
|
|
356
353
|
} catch (e) {
|
|
357
354
|
loadErrors.push(e);
|
|
@@ -366,7 +363,7 @@ function requireNative() {
|
|
|
366
363
|
try {
|
|
367
364
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/core.linux-ppc64-gnu.node");
|
|
368
365
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/package.json").version;
|
|
369
|
-
if (bindingPackageVersion !== "
|
|
366
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
370
367
|
return binding;
|
|
371
368
|
} catch (e) {
|
|
372
369
|
loadErrors.push(e);
|
|
@@ -380,7 +377,7 @@ function requireNative() {
|
|
|
380
377
|
try {
|
|
381
378
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/core.linux-s390x-gnu.node");
|
|
382
379
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/package.json").version;
|
|
383
|
-
if (bindingPackageVersion !== "
|
|
380
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
384
381
|
return binding;
|
|
385
382
|
} catch (e) {
|
|
386
383
|
loadErrors.push(e);
|
|
@@ -395,7 +392,7 @@ function requireNative() {
|
|
|
395
392
|
try {
|
|
396
393
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/core.openharmony-arm64.node");
|
|
397
394
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/package.json").version;
|
|
398
|
-
if (bindingPackageVersion !== "
|
|
395
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
399
396
|
return binding;
|
|
400
397
|
} catch (e) {
|
|
401
398
|
loadErrors.push(e);
|
|
@@ -409,7 +406,7 @@ function requireNative() {
|
|
|
409
406
|
try {
|
|
410
407
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/core.openharmony-x64.node");
|
|
411
408
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/package.json").version;
|
|
412
|
-
if (bindingPackageVersion !== "
|
|
409
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
413
410
|
return binding;
|
|
414
411
|
} catch (e) {
|
|
415
412
|
loadErrors.push(e);
|
|
@@ -423,7 +420,7 @@ function requireNative() {
|
|
|
423
420
|
try {
|
|
424
421
|
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/core.openharmony-arm.node");
|
|
425
422
|
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/package.json").version;
|
|
426
|
-
if (bindingPackageVersion !== "
|
|
423
|
+
if (bindingPackageVersion !== "2.0.0-beta.0" && 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-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
427
424
|
return binding;
|
|
428
425
|
} catch (e) {
|
|
429
426
|
loadErrors.push(e);
|
|
@@ -459,117 +456,119 @@ if (!nativeBinding || forceWasi) {
|
|
|
459
456
|
}
|
|
460
457
|
}
|
|
461
458
|
if (!nativeBinding) {
|
|
462
|
-
if (loadErrors.length > 0)
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
459
|
+
if (loadErrors.length > 0) {
|
|
460
|
+
const error = /* @__PURE__ */ new Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.");
|
|
461
|
+
error.cause = loadErrors.reduce((err, cur) => {
|
|
462
|
+
cur.cause = err;
|
|
463
|
+
return cur;
|
|
464
|
+
});
|
|
465
|
+
throw error;
|
|
466
|
+
}
|
|
466
467
|
throw new Error(`Failed to load native binding`);
|
|
467
468
|
}
|
|
468
|
-
const { Renderer: Renderer$1, AnimationOutputFormat, DitheringAlgorithm, OutputFormat } = nativeBinding;
|
|
469
|
+
const { Renderer: Renderer$1, AnimationOutputFormat, DitheringAlgorithm, ImageCacheMode, OutputFormat } = nativeBinding;
|
|
469
470
|
//#endregion
|
|
470
471
|
//#region src/export.ts
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
this.
|
|
486
|
-
return
|
|
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
|
+
var Renderer = class {
|
|
482
|
+
fontMapping = /* @__PURE__ */ new Map();
|
|
483
|
+
inner = new Renderer$1();
|
|
484
|
+
async prepareFonts(fonts) {
|
|
485
|
+
if (!fonts) return;
|
|
486
|
+
const families = await Promise.all(fonts.map(this.registerFont.bind(this)));
|
|
487
|
+
return [...new Set(families.flat().map((f) => f.name))];
|
|
487
488
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
return true;
|
|
497
|
-
}
|
|
498
|
-
if (this.fontsMark.has(key) || batchFontsMark.has(key)) return false;
|
|
499
|
-
batchFontsMark.add(key);
|
|
500
|
-
return true;
|
|
501
|
-
});
|
|
502
|
-
const resolvedFonts = await Promise.all(targetFonts.map(resolveFontLoader));
|
|
503
|
-
const loadedCount = await super.loadFonts(resolvedFonts, signal);
|
|
504
|
-
targetFonts.forEach((font) => this.checkAndMarkFont(font));
|
|
505
|
-
return loadedCount;
|
|
489
|
+
/** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
|
|
490
|
+
* the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
|
|
491
|
+
async resolveResources(fonts, images, fontFamilies) {
|
|
492
|
+
const registeredFamilies = await this.prepareFonts(fonts);
|
|
493
|
+
return {
|
|
494
|
+
images: images ? await resolveImageLoaders(images) : void 0,
|
|
495
|
+
fontFamilies: fontFamilies !== null && fontFamilies !== void 0 ? fontFamilies : registeredFamilies
|
|
496
|
+
};
|
|
506
497
|
}
|
|
507
|
-
async
|
|
508
|
-
|
|
509
|
-
const resolved = await
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
498
|
+
async render(node, options) {
|
|
499
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options !== null && options !== void 0 ? options : {};
|
|
500
|
+
const resolved = await this.resolveResources(fonts, images, fontFamilies);
|
|
501
|
+
return this.inner.render(node, {
|
|
502
|
+
...rest,
|
|
503
|
+
...resolved
|
|
504
|
+
}, signal);
|
|
513
505
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
const resolved =
|
|
517
|
-
|
|
518
|
-
|
|
506
|
+
async renderSvg(node, options) {
|
|
507
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options !== null && options !== void 0 ? options : {};
|
|
508
|
+
const resolved = await this.resolveResources(fonts, images, fontFamilies);
|
|
509
|
+
return this.inner.renderSvg(node, {
|
|
510
|
+
...rest,
|
|
511
|
+
...resolved
|
|
512
|
+
}, signal);
|
|
519
513
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
this.
|
|
523
|
-
this.
|
|
514
|
+
async measure(node, options) {
|
|
515
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options !== null && options !== void 0 ? options : {};
|
|
516
|
+
const resolved = await this.resolveResources(fonts, images, fontFamilies);
|
|
517
|
+
return this.inner.measure(node, {
|
|
518
|
+
...rest,
|
|
519
|
+
...resolved
|
|
520
|
+
}, signal);
|
|
524
521
|
}
|
|
525
|
-
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
const isNew = !this.fontsMark.has(key);
|
|
533
|
-
this.fontsMark.add(key);
|
|
534
|
-
return isNew;
|
|
522
|
+
async renderAnimation(options) {
|
|
523
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options;
|
|
524
|
+
const resolved = await this.resolveResources(fonts, images, fontFamilies);
|
|
525
|
+
return this.inner.renderAnimation({
|
|
526
|
+
...rest,
|
|
527
|
+
...resolved
|
|
528
|
+
}, signal);
|
|
535
529
|
}
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
530
|
+
async encodeFrames(frames, options) {
|
|
531
|
+
const { fonts, fontFamilies, signal, images, ...rest } = options;
|
|
532
|
+
const resolved = await this.resolveResources(fonts, images, fontFamilies);
|
|
533
|
+
return this.inner.encodeFrames(frames, {
|
|
534
|
+
...rest,
|
|
535
|
+
...resolved
|
|
536
|
+
}, signal);
|
|
539
537
|
}
|
|
540
|
-
|
|
541
|
-
|
|
538
|
+
async registerFont(font) {
|
|
539
|
+
const key = createFontKey(font);
|
|
540
|
+
const cached = this.fontMapping.get(key);
|
|
541
|
+
if (cached) return cached;
|
|
542
|
+
const extracted = extractFontBuffer(font);
|
|
543
|
+
if (isBuffer(extracted)) {
|
|
544
|
+
const binded = this.inner.registerFont(extracted);
|
|
545
|
+
this.fontMapping.set(key, Promise.resolve(binded));
|
|
546
|
+
return binded;
|
|
547
|
+
}
|
|
548
|
+
const promise = extracted.then(this.inner.registerFont.bind(this.inner)).catch((error) => {
|
|
549
|
+
this.fontMapping.delete(key);
|
|
550
|
+
throw error;
|
|
551
|
+
});
|
|
552
|
+
this.fontMapping.set(key, promise);
|
|
553
|
+
return promise;
|
|
542
554
|
}
|
|
543
555
|
};
|
|
544
|
-
function
|
|
545
|
-
var _font$name, _font$style, _font$weight;
|
|
546
|
-
if ("key" in font && font.key) return font.key;
|
|
556
|
+
function extractFontBuffer(font) {
|
|
547
557
|
if (isBuffer(font)) return font;
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
async function resolveFontLoader(font) {
|
|
551
|
-
if ("data" in font && typeof font.data === "function") return {
|
|
552
|
-
...font,
|
|
553
|
-
data: await font.data()
|
|
554
|
-
};
|
|
555
|
-
return font;
|
|
558
|
+
if (typeof font.data !== "function") return font.data;
|
|
559
|
+
return font.data();
|
|
556
560
|
}
|
|
557
|
-
|
|
558
|
-
if (
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
if ("data" in font && typeof font.data === "function") return {
|
|
566
|
-
...font,
|
|
567
|
-
data: font.data()
|
|
568
|
-
};
|
|
569
|
-
return font;
|
|
561
|
+
function createFontKey(font) {
|
|
562
|
+
if (isBuffer(font)) return font;
|
|
563
|
+
if ("key" in font && font.key) return font.key;
|
|
564
|
+
if (typeof font.data === "function") {
|
|
565
|
+
var _font$name, _font$weight, _font$style;
|
|
566
|
+
return `${(_font$name = font.name) !== null && _font$name !== void 0 ? _font$name : ""}:${(_font$weight = font.weight) !== null && _font$weight !== void 0 ? _font$weight : ""}:${(_font$style = font.style) !== null && _font$style !== void 0 ? _font$style : ""}`;
|
|
567
|
+
}
|
|
568
|
+
return font.data;
|
|
570
569
|
}
|
|
571
570
|
function isBuffer(data) {
|
|
572
|
-
return data instanceof Uint8Array || data instanceof ArrayBuffer;
|
|
571
|
+
return data instanceof Uint8Array || data instanceof ArrayBuffer || typeof Buffer !== "undefined" && Buffer.isBuffer(data);
|
|
573
572
|
}
|
|
574
573
|
//#endregion
|
|
575
574
|
exports.Renderer = Renderer;
|