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