@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 CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let node_module = require(/* turbopackOptional: true */ "node:module");
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, node_module.createRequire)(require(/* turbopackOptional: true */ "url").pathToFileURL(__filename).href);
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 */ "node:fs");
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 (typeof ((_process$report = process.report) === null || _process$report === void 0 ? void 0 : _process$report.getReport) === "function") {
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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
- var _process$config, _process$config2;
85
- if (((_process$config = process.config) === null || _process$config === void 0 || (_process$config = _process$config.variables) === null || _process$config === void 0 ? void 0 : _process$config.shlib_suffix) === "dll.a" || ((_process$config2 = process.config) === null || _process$config2 === void 0 || (_process$config2 = _process$config2.variables) === null || _process$config2 === void 0 ? void 0 : _process$config2.node_target_type) === "shared_library") {
86
- try {
87
- return require$1(/* turbopackOptional: true */ "../core.win32-x64-gnu.node");
88
- } catch (e) {
89
- loadErrors.push(e);
90
- }
91
- try {
92
- const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/core.win32-x64-gnu.node");
93
- const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/package.json").version;
94
- if (bindingPackageVersion !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
95
- return binding;
96
- } catch (e) {
97
- loadErrors.push(e);
98
- }
99
- } else {
100
- try {
101
- return require$1(/* turbopackOptional: true */ "../core.win32-x64-msvc.node");
102
- } catch (e) {
103
- loadErrors.push(e);
104
- }
105
- try {
106
- const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/core.win32-x64-msvc.node");
107
- const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/package.json").version;
108
- if (bindingPackageVersion !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
109
- return binding;
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
- } else if (process.arch === "ia32") {
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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 !== "1.8.6" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.8.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
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) throw 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.", { cause: loadErrors.reduce((err, cur) => {
463
- cur.cause = err;
464
- return cur;
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
- var Renderer = class extends Renderer$1 {
472
- fontsMark = /* @__PURE__ */ new Set();
473
- fontBuffersMark = /* @__PURE__ */ new WeakSet();
474
- persistentImageSrcMark = /* @__PURE__ */ new Set();
475
- pendingPersistentImages = /* @__PURE__ */ new Map();
476
- async putPersistentImage(source, signal) {
477
- if (!this.isNewPersistentImage(source.src)) return this.pendingPersistentImages.get(source.src);
478
- const pending = resolveImageLoader(source).then(async (resolved) => {
479
- if (signal === null || signal === void 0 ? void 0 : signal.aborted) return;
480
- await super.putPersistentImage(resolved, signal);
481
- this.persistentImageSrcMark.add(source.src);
482
- }).finally(() => {
483
- this.pendingPersistentImages.delete(source.src);
484
- });
485
- this.pendingPersistentImages.set(source.src, pending);
486
- return pending;
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
- async loadFonts(fonts, signal) {
489
- const batchFontsMark = /* @__PURE__ */ new Set();
490
- const batchFontBuffersMark = /* @__PURE__ */ new WeakSet();
491
- const targetFonts = fonts.filter((font) => {
492
- const key = createFontKey(font);
493
- if (isBuffer(key)) {
494
- if (this.fontBuffersMark.has(key) || batchFontBuffersMark.has(key)) return false;
495
- batchFontBuffersMark.add(key);
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 loadFont(data, signal) {
508
- if (!this.isNewFont(data)) return 0;
509
- const resolved = await resolveFontLoader(data);
510
- const loadedCount = await super.loadFont(resolved, signal);
511
- this.checkAndMarkFont(data);
512
- return loadedCount;
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
- loadFontSync(font) {
515
- if (!this.isNewFont(font)) return;
516
- const resolved = resolveSyncFontLoader(font);
517
- super.loadFontSync(resolved);
518
- this.checkAndMarkFont(font);
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
- clearImageStore() {
521
- super.clearImageStore();
522
- this.persistentImageSrcMark.clear();
523
- this.pendingPersistentImages.clear();
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
- checkAndMarkFont(font) {
526
- const key = createFontKey(font);
527
- if (isBuffer(key)) {
528
- const isNew = !this.fontBuffersMark.has(key);
529
- this.fontBuffersMark.add(key);
530
- return isNew;
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
- isNewFont(font) {
537
- const key = createFontKey(font);
538
- return isBuffer(key) ? !this.fontBuffersMark.has(key) : !this.fontsMark.has(key);
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
- isNewPersistentImage(src) {
541
- return !this.persistentImageSrcMark.has(src) && !this.pendingPersistentImages.has(src);
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 createFontKey(font) {
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
- return `${(_font$name = font.name) !== null && _font$name !== void 0 ? _font$name : ""}-${(_font$style = font.style) !== null && _font$style !== void 0 ? _font$style : ""}-${(_font$weight = font.weight) !== null && _font$weight !== void 0 ? _font$weight : ""}`;
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
- async function resolveImageLoader(source) {
558
- if (typeof source.data === "function") return {
559
- ...source,
560
- data: await source.data()
561
- };
562
- return source;
563
- }
564
- function resolveSyncFontLoader(font) {
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;