@rlch/takumi-core 0.0.0-stage → 2.14.0-rlch.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -2
- package/dist/export.cjs +586 -0
- package/dist/export.d.cts +302 -0
- package/dist/export.d.mts +302 -0
- package/dist/export.mjs +584 -0
- package/index.d.ts +344 -0
- package/not-available.js +3 -0
- package/package.json +106 -4
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://takumi.kane.tw/logo.svg" alt="Takumi" width="64" />
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
# @takumi-rs/core
|
|
5
|
+
|
|
6
|
+
**Native Node.js bindings for [Takumi](https://github.com/kane50613/takumi), a Rust image rendering engine.**
|
|
7
|
+
|
|
8
|
+
Render node trees as Open Graph images, banners, and animations in Node.js or Bun. For JSX, HTML, and automatic resource loading, use [`takumi-js`](https://www.npmjs.com/package/takumi-js).
|
|
9
|
+
|
|
10
|
+
[Documentation](https://takumi.kane.tw/docs/) · [Playground](https://takumi.kane.tw/playground)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @takumi-rs/core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { Renderer } from "@takumi-rs/core";
|
|
24
|
+
|
|
25
|
+
const renderer = new Renderer();
|
|
26
|
+
|
|
27
|
+
const png = await renderer.render(
|
|
28
|
+
{
|
|
29
|
+
type: "container",
|
|
30
|
+
children: [{ type: "text", text: "Hello from Takumi" }],
|
|
31
|
+
},
|
|
32
|
+
{ width: 1200, height: 630 },
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`render` takes a node tree and returns a PNG `Buffer`. Build the tree by hand, or generate it from JSX and HTML with [`@takumi-rs/helpers`](https://npmjs.com/package/@takumi-rs/helpers).
|
|
37
|
+
|
|
38
|
+
## Fonts
|
|
39
|
+
|
|
40
|
+
Pass fonts through the render options. A separate registration step is optional:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { readFile } from "node:fs/promises";
|
|
44
|
+
|
|
45
|
+
const png = await renderer.render(node, {
|
|
46
|
+
width: 1200,
|
|
47
|
+
height: 630,
|
|
48
|
+
fonts: [await readFile("./Inter.ttf")],
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Renderer
|
|
53
|
+
|
|
54
|
+
| Method | Returns | Description |
|
|
55
|
+
| :----------------------- | :---------------- | :-------------------------------- |
|
|
56
|
+
| `render(node, opts?)` | `Promise<Buffer>` | Raster image (PNG, JPEG, WebP, …) |
|
|
57
|
+
| `renderSvg(node, opts?)` | `Promise<string>` | Vector SVG document |
|
|
58
|
+
| `renderAnimation(opts)` | `Promise<Buffer>` | Animated WebP, APNG, or GIF |
|
|
59
|
+
| `measure(node, opts?)` | `Promise<...>` | Layout without rasterizing |
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
- Integration guide: <https://takumi.kane.tw/docs/integration>
|
|
64
|
+
- API reference: <https://takumi.kane.tw/docs/reference>
|
|
65
|
+
- Repository: <https://github.com/kane50613/takumi>
|
|
66
|
+
|
|
67
|
+
For WebAssembly runtimes (Cloudflare Workers, browsers, edge), use [@takumi-rs/wasm](https://npmjs.com/package/@takumi-rs/wasm).
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT or Apache-2.0
|
package/dist/export.cjs
ADDED
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let module$1 = require(/* turbopackOptional: true */ "module");
|
|
3
|
+
let _takumi_rs_helpers_renderer = require(/* turbopackOptional: true */ "@takumi-rs/helpers/renderer");
|
|
4
|
+
//#region index.js
|
|
5
|
+
const require$1 = (0, module$1.createRequire)(require(/* turbopackOptional: true */ "url").pathToFileURL(__filename).href);
|
|
6
|
+
const { readFileSync } = require$1(/* turbopackOptional: true */ "fs");
|
|
7
|
+
let nativeBinding = null;
|
|
8
|
+
const loadErrors = [];
|
|
9
|
+
const isMusl = () => {
|
|
10
|
+
let musl = false;
|
|
11
|
+
if (process.platform === "linux") {
|
|
12
|
+
musl = isMuslFromFilesystem();
|
|
13
|
+
if (musl === null) musl = isMuslFromReport();
|
|
14
|
+
if (musl === null) musl = isMuslFromChildProcess();
|
|
15
|
+
}
|
|
16
|
+
return musl;
|
|
17
|
+
};
|
|
18
|
+
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
19
|
+
const isMuslFromFilesystem = () => {
|
|
20
|
+
try {
|
|
21
|
+
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const isMuslFromReport = () => {
|
|
27
|
+
let report = null;
|
|
28
|
+
if (process.report && typeof process.report.getReport === "function") {
|
|
29
|
+
process.report.excludeNetwork = true;
|
|
30
|
+
report = process.report.getReport();
|
|
31
|
+
}
|
|
32
|
+
if (!report) return null;
|
|
33
|
+
if (report.header && report.header.glibcVersionRuntime) return false;
|
|
34
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
35
|
+
if (report.sharedObjects.some(isFileMusl)) return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
const isMuslFromChildProcess = () => {
|
|
40
|
+
try {
|
|
41
|
+
return require$1(/* turbopackOptional: true */ "child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
function requireNative() {
|
|
47
|
+
if (process.env.TAKUMI_CORE_TARGET) try {
|
|
48
|
+
return require$1(/* turbopackOptional: true */ process.env.TAKUMI_CORE_TARGET);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
loadErrors.push(err);
|
|
51
|
+
}
|
|
52
|
+
else if (process.platform === "android") {
|
|
53
|
+
if (process.arch === "arm64") {
|
|
54
|
+
try {
|
|
55
|
+
return require$1(/* turbopackOptional: true */ "../core.android-arm64.node");
|
|
56
|
+
} catch (e) {
|
|
57
|
+
loadErrors.push(e);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/core.android-arm64.node");
|
|
61
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm64/package.json").version;
|
|
62
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
63
|
+
return binding;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
loadErrors.push(e);
|
|
66
|
+
}
|
|
67
|
+
} else if (process.arch === "arm") {
|
|
68
|
+
try {
|
|
69
|
+
return require$1(/* turbopackOptional: true */ "../core.android-arm-eabi.node");
|
|
70
|
+
} catch (e) {
|
|
71
|
+
loadErrors.push(e);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/core.android-arm-eabi.node");
|
|
75
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-android-arm-eabi/package.json").version;
|
|
76
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
77
|
+
return binding;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
loadErrors.push(e);
|
|
80
|
+
}
|
|
81
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
|
|
82
|
+
} else if (process.platform === "win32") {
|
|
83
|
+
if (process.arch === "x64") {
|
|
84
|
+
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") {
|
|
85
|
+
try {
|
|
86
|
+
return require$1(/* turbopackOptional: true */ "../core.win32-x64-gnu.node");
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadErrors.push(e);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/core.win32-x64-gnu.node");
|
|
92
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-gnu/package.json").version;
|
|
93
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
94
|
+
return binding;
|
|
95
|
+
} catch (e) {
|
|
96
|
+
loadErrors.push(e);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
try {
|
|
100
|
+
return require$1(/* turbopackOptional: true */ "../core.win32-x64-msvc.node");
|
|
101
|
+
} catch (e) {
|
|
102
|
+
loadErrors.push(e);
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/core.win32-x64-msvc.node");
|
|
106
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-x64-msvc/package.json").version;
|
|
107
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
108
|
+
return binding;
|
|
109
|
+
} catch (e) {
|
|
110
|
+
loadErrors.push(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} else if (process.arch === "ia32") {
|
|
114
|
+
try {
|
|
115
|
+
return require$1(/* turbopackOptional: true */ "../core.win32-ia32-msvc.node");
|
|
116
|
+
} catch (e) {
|
|
117
|
+
loadErrors.push(e);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/core.win32-ia32-msvc.node");
|
|
121
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-ia32-msvc/package.json").version;
|
|
122
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
123
|
+
return binding;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
loadErrors.push(e);
|
|
126
|
+
}
|
|
127
|
+
} else if (process.arch === "arm64") {
|
|
128
|
+
try {
|
|
129
|
+
return require$1(/* turbopackOptional: true */ "../core.win32-arm64-msvc.node");
|
|
130
|
+
} catch (e) {
|
|
131
|
+
loadErrors.push(e);
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/core.win32-arm64-msvc.node");
|
|
135
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-win32-arm64-msvc/package.json").version;
|
|
136
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
137
|
+
return binding;
|
|
138
|
+
} catch (e) {
|
|
139
|
+
loadErrors.push(e);
|
|
140
|
+
}
|
|
141
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
|
|
142
|
+
} else if (process.platform === "darwin") {
|
|
143
|
+
try {
|
|
144
|
+
return require$1(/* turbopackOptional: true */ "../core.darwin-universal.node");
|
|
145
|
+
} catch (e) {
|
|
146
|
+
loadErrors.push(e);
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/core.darwin-universal.node");
|
|
150
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-universal/package.json").version;
|
|
151
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
152
|
+
return binding;
|
|
153
|
+
} catch (e) {
|
|
154
|
+
loadErrors.push(e);
|
|
155
|
+
}
|
|
156
|
+
if (process.arch === "x64") {
|
|
157
|
+
try {
|
|
158
|
+
return require$1(/* turbopackOptional: true */ "../core.darwin-x64.node");
|
|
159
|
+
} catch (e) {
|
|
160
|
+
loadErrors.push(e);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/core.darwin-x64.node");
|
|
164
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-x64/package.json").version;
|
|
165
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
166
|
+
return binding;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
loadErrors.push(e);
|
|
169
|
+
}
|
|
170
|
+
} else if (process.arch === "arm64") {
|
|
171
|
+
try {
|
|
172
|
+
return require$1(/* turbopackOptional: true */ "../core.darwin-arm64.node");
|
|
173
|
+
} catch (e) {
|
|
174
|
+
loadErrors.push(e);
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/core.darwin-arm64.node");
|
|
178
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-darwin-arm64/package.json").version;
|
|
179
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
180
|
+
return binding;
|
|
181
|
+
} catch (e) {
|
|
182
|
+
loadErrors.push(e);
|
|
183
|
+
}
|
|
184
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
|
|
185
|
+
} else if (process.platform === "freebsd") {
|
|
186
|
+
if (process.arch === "x64") {
|
|
187
|
+
try {
|
|
188
|
+
return require$1(/* turbopackOptional: true */ "../core.freebsd-x64.node");
|
|
189
|
+
} catch (e) {
|
|
190
|
+
loadErrors.push(e);
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/core.freebsd-x64.node");
|
|
194
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-x64/package.json").version;
|
|
195
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
196
|
+
return binding;
|
|
197
|
+
} catch (e) {
|
|
198
|
+
loadErrors.push(e);
|
|
199
|
+
}
|
|
200
|
+
} else if (process.arch === "arm64") {
|
|
201
|
+
try {
|
|
202
|
+
return require$1(/* turbopackOptional: true */ "../core.freebsd-arm64.node");
|
|
203
|
+
} catch (e) {
|
|
204
|
+
loadErrors.push(e);
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/core.freebsd-arm64.node");
|
|
208
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-freebsd-arm64/package.json").version;
|
|
209
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
210
|
+
return binding;
|
|
211
|
+
} catch (e) {
|
|
212
|
+
loadErrors.push(e);
|
|
213
|
+
}
|
|
214
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
|
|
215
|
+
} else if (process.platform === "linux") {
|
|
216
|
+
if (process.arch === "x64") {
|
|
217
|
+
if (isMusl()) {
|
|
218
|
+
try {
|
|
219
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-x64-musl.node");
|
|
220
|
+
} catch (e) {
|
|
221
|
+
loadErrors.push(e);
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/core.linux-x64-musl.node");
|
|
225
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-musl/package.json").version;
|
|
226
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
227
|
+
return binding;
|
|
228
|
+
} catch (e) {
|
|
229
|
+
loadErrors.push(e);
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
try {
|
|
233
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-x64-gnu.node");
|
|
234
|
+
} catch (e) {
|
|
235
|
+
loadErrors.push(e);
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/core.linux-x64-gnu.node");
|
|
239
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-x64-gnu/package.json").version;
|
|
240
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
241
|
+
return binding;
|
|
242
|
+
} catch (e) {
|
|
243
|
+
loadErrors.push(e);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} else if (process.arch === "arm64") {
|
|
247
|
+
if (isMusl()) {
|
|
248
|
+
try {
|
|
249
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-arm64-musl.node");
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadErrors.push(e);
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/core.linux-arm64-musl.node");
|
|
255
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-musl/package.json").version;
|
|
256
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
257
|
+
return binding;
|
|
258
|
+
} catch (e) {
|
|
259
|
+
loadErrors.push(e);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
try {
|
|
263
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-arm64-gnu.node");
|
|
264
|
+
} catch (e) {
|
|
265
|
+
loadErrors.push(e);
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/core.linux-arm64-gnu.node");
|
|
269
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm64-gnu/package.json").version;
|
|
270
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
271
|
+
return binding;
|
|
272
|
+
} catch (e) {
|
|
273
|
+
loadErrors.push(e);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} else if (process.arch === "arm") {
|
|
277
|
+
if (isMusl()) {
|
|
278
|
+
try {
|
|
279
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-arm-musleabihf.node");
|
|
280
|
+
} catch (e) {
|
|
281
|
+
loadErrors.push(e);
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/core.linux-arm-musleabihf.node");
|
|
285
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-musleabihf/package.json").version;
|
|
286
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
287
|
+
return binding;
|
|
288
|
+
} catch (e) {
|
|
289
|
+
loadErrors.push(e);
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
try {
|
|
293
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-arm-gnueabihf.node");
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadErrors.push(e);
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/core.linux-arm-gnueabihf.node");
|
|
299
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-arm-gnueabihf/package.json").version;
|
|
300
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
301
|
+
return binding;
|
|
302
|
+
} catch (e) {
|
|
303
|
+
loadErrors.push(e);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} else if (process.arch === "loong64") {
|
|
307
|
+
if (isMusl()) {
|
|
308
|
+
try {
|
|
309
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-loong64-musl.node");
|
|
310
|
+
} catch (e) {
|
|
311
|
+
loadErrors.push(e);
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/core.linux-loong64-musl.node");
|
|
315
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-musl/package.json").version;
|
|
316
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
317
|
+
return binding;
|
|
318
|
+
} catch (e) {
|
|
319
|
+
loadErrors.push(e);
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
try {
|
|
323
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-loong64-gnu.node");
|
|
324
|
+
} catch (e) {
|
|
325
|
+
loadErrors.push(e);
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/core.linux-loong64-gnu.node");
|
|
329
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-loong64-gnu/package.json").version;
|
|
330
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
331
|
+
return binding;
|
|
332
|
+
} catch (e) {
|
|
333
|
+
loadErrors.push(e);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
} else if (process.arch === "riscv64") {
|
|
337
|
+
if (isMusl()) {
|
|
338
|
+
try {
|
|
339
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-riscv64-musl.node");
|
|
340
|
+
} catch (e) {
|
|
341
|
+
loadErrors.push(e);
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/core.linux-riscv64-musl.node");
|
|
345
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-musl/package.json").version;
|
|
346
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
347
|
+
return binding;
|
|
348
|
+
} catch (e) {
|
|
349
|
+
loadErrors.push(e);
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
try {
|
|
353
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-riscv64-gnu.node");
|
|
354
|
+
} catch (e) {
|
|
355
|
+
loadErrors.push(e);
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/core.linux-riscv64-gnu.node");
|
|
359
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-riscv64-gnu/package.json").version;
|
|
360
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
361
|
+
return binding;
|
|
362
|
+
} catch (e) {
|
|
363
|
+
loadErrors.push(e);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else if (process.arch === "ppc64") {
|
|
367
|
+
try {
|
|
368
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-ppc64-gnu.node");
|
|
369
|
+
} catch (e) {
|
|
370
|
+
loadErrors.push(e);
|
|
371
|
+
}
|
|
372
|
+
try {
|
|
373
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/core.linux-ppc64-gnu.node");
|
|
374
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-ppc64-gnu/package.json").version;
|
|
375
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
376
|
+
return binding;
|
|
377
|
+
} catch (e) {
|
|
378
|
+
loadErrors.push(e);
|
|
379
|
+
}
|
|
380
|
+
} else if (process.arch === "s390x") {
|
|
381
|
+
try {
|
|
382
|
+
return require$1(/* turbopackOptional: true */ "../core.linux-s390x-gnu.node");
|
|
383
|
+
} catch (e) {
|
|
384
|
+
loadErrors.push(e);
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/core.linux-s390x-gnu.node");
|
|
388
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-linux-s390x-gnu/package.json").version;
|
|
389
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
390
|
+
return binding;
|
|
391
|
+
} catch (e) {
|
|
392
|
+
loadErrors.push(e);
|
|
393
|
+
}
|
|
394
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
|
|
395
|
+
} else if (process.platform === "openharmony") {
|
|
396
|
+
if (process.arch === "arm64") {
|
|
397
|
+
try {
|
|
398
|
+
return require$1(/* turbopackOptional: true */ "../core.openharmony-arm64.node");
|
|
399
|
+
} catch (e) {
|
|
400
|
+
loadErrors.push(e);
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/core.openharmony-arm64.node");
|
|
404
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm64/package.json").version;
|
|
405
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
406
|
+
return binding;
|
|
407
|
+
} catch (e) {
|
|
408
|
+
loadErrors.push(e);
|
|
409
|
+
}
|
|
410
|
+
} else if (process.arch === "x64") {
|
|
411
|
+
try {
|
|
412
|
+
return require$1(/* turbopackOptional: true */ "../core.openharmony-x64.node");
|
|
413
|
+
} catch (e) {
|
|
414
|
+
loadErrors.push(e);
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/core.openharmony-x64.node");
|
|
418
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-x64/package.json").version;
|
|
419
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
420
|
+
return binding;
|
|
421
|
+
} catch (e) {
|
|
422
|
+
loadErrors.push(e);
|
|
423
|
+
}
|
|
424
|
+
} else if (process.arch === "arm") {
|
|
425
|
+
try {
|
|
426
|
+
return require$1(/* turbopackOptional: true */ "../core.openharmony-arm.node");
|
|
427
|
+
} catch (e) {
|
|
428
|
+
loadErrors.push(e);
|
|
429
|
+
}
|
|
430
|
+
try {
|
|
431
|
+
const binding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/core.openharmony-arm.node");
|
|
432
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-openharmony-arm/package.json").version;
|
|
433
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3" && 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.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
434
|
+
return binding;
|
|
435
|
+
} catch (e) {
|
|
436
|
+
loadErrors.push(e);
|
|
437
|
+
}
|
|
438
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
|
|
439
|
+
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
|
|
440
|
+
}
|
|
441
|
+
function createLoadErrorChain(errors) {
|
|
442
|
+
return errors.reduce((previous, current) => {
|
|
443
|
+
let message;
|
|
444
|
+
try {
|
|
445
|
+
message = current && typeof current.message === "string" ? current.message : String(current);
|
|
446
|
+
} catch {
|
|
447
|
+
message = "Unknown error";
|
|
448
|
+
}
|
|
449
|
+
const error = new Error(message);
|
|
450
|
+
error.cause = previous;
|
|
451
|
+
return error;
|
|
452
|
+
}, null);
|
|
453
|
+
}
|
|
454
|
+
const __napiWasiFlavors = ["wasm32-wasi"];
|
|
455
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR;
|
|
456
|
+
const __napiWasiFlavorRequested = typeof __napiWasiFlavor === "string" && __napiWasiFlavor.length > 0;
|
|
457
|
+
if (__napiWasiFlavorRequested && __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1) throw new Error("Unsupported WASI flavor \"" + __napiWasiFlavor + "\". Available flavors: " + __napiWasiFlavors.join(", "));
|
|
458
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === "error";
|
|
459
|
+
const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || forceWasiError || __napiWasiFlavorRequested;
|
|
460
|
+
if (!forceWasi) nativeBinding = requireNative();
|
|
461
|
+
if (!nativeBinding || forceWasi) {
|
|
462
|
+
let wasiBinding = null;
|
|
463
|
+
let wasiBindingLoaded = false;
|
|
464
|
+
const wasiBindingErrors = [];
|
|
465
|
+
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
466
|
+
try {
|
|
467
|
+
require$1.resolve(specifier);
|
|
468
|
+
} catch (resolveError) {
|
|
469
|
+
if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
|
|
470
|
+
if (isPackage) {
|
|
471
|
+
try {
|
|
472
|
+
require$1.resolve(specifier + "/package.json");
|
|
473
|
+
} catch (packageError) {
|
|
474
|
+
if (packageError && packageError.code === "MODULE_NOT_FOUND") return resolveError;
|
|
475
|
+
throw resolveError;
|
|
476
|
+
}
|
|
477
|
+
throw resolveError;
|
|
478
|
+
}
|
|
479
|
+
return resolveError;
|
|
480
|
+
}
|
|
481
|
+
if (localArtifacts) {
|
|
482
|
+
let artifactError = null;
|
|
483
|
+
for (let i = 0; i < localArtifacts.length; i++) try {
|
|
484
|
+
require$1.resolve(localArtifacts[i]);
|
|
485
|
+
return null;
|
|
486
|
+
} catch (resolveError) {
|
|
487
|
+
if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
|
|
488
|
+
artifactError = resolveError;
|
|
489
|
+
}
|
|
490
|
+
return artifactError;
|
|
491
|
+
}
|
|
492
|
+
return null;
|
|
493
|
+
};
|
|
494
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
|
|
495
|
+
let candidateError = null;
|
|
496
|
+
let candidateFailed = false;
|
|
497
|
+
try {
|
|
498
|
+
candidateError = __napiWasiResolveCandidate("./core.wasi.cjs", false, ["./core.wasm32-wasi.debug.wasm", "./core.wasm32-wasi.wasm"]);
|
|
499
|
+
candidateFailed = candidateError !== null;
|
|
500
|
+
if (!candidateFailed) {
|
|
501
|
+
wasiBinding = require$1(/* turbopackOptional: true */ "./core.wasi.cjs");
|
|
502
|
+
nativeBinding = wasiBinding;
|
|
503
|
+
wasiBindingLoaded = true;
|
|
504
|
+
}
|
|
505
|
+
} catch (err) {
|
|
506
|
+
candidateError = err;
|
|
507
|
+
candidateFailed = true;
|
|
508
|
+
}
|
|
509
|
+
if (candidateFailed) {
|
|
510
|
+
wasiBindingErrors.push(candidateError);
|
|
511
|
+
loadErrors.push(candidateError);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
|
|
515
|
+
let candidateError = null;
|
|
516
|
+
let candidateFailed = false;
|
|
517
|
+
try {
|
|
518
|
+
candidateError = __napiWasiResolveCandidate("@takumi-rs/core-wasm32-wasi", true, void 0);
|
|
519
|
+
candidateFailed = candidateError !== null;
|
|
520
|
+
if (!candidateFailed) {
|
|
521
|
+
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
522
|
+
const bindingPackageVersion = require$1(/* turbopackOptional: true */ "@takumi-rs/core-wasm32-wasi/package.json").version;
|
|
523
|
+
if (bindingPackageVersion !== "2.14.0-rlch.3") throw new Error(`WASI binding package version mismatch, expected 2.14.0-rlch.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
524
|
+
}
|
|
525
|
+
wasiBinding = require$1(/* turbopackOptional: true */ "@takumi-rs/core-wasm32-wasi/core.wasm32-wasi.node");
|
|
526
|
+
nativeBinding = wasiBinding;
|
|
527
|
+
wasiBindingLoaded = true;
|
|
528
|
+
}
|
|
529
|
+
} catch (err) {
|
|
530
|
+
candidateError = err;
|
|
531
|
+
candidateFailed = true;
|
|
532
|
+
}
|
|
533
|
+
if (candidateFailed) {
|
|
534
|
+
wasiBindingErrors.push(candidateError);
|
|
535
|
+
loadErrors.push(candidateError);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (!wasiBindingLoaded && forceWasi && !forceWasiError && !__napiWasiFlavorRequested) nativeBinding = requireNative();
|
|
539
|
+
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
540
|
+
const error = /* @__PURE__ */ new Error(__napiWasiFlavorRequested ? "WASI binding for flavor \"" + __napiWasiFlavor + "\" not found" : "WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
|
|
541
|
+
error.cause = createLoadErrorChain(wasiBindingErrors);
|
|
542
|
+
throw error;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (!nativeBinding) {
|
|
546
|
+
if (loadErrors.length > 0) {
|
|
547
|
+
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.");
|
|
548
|
+
error.cause = createLoadErrorChain(loadErrors);
|
|
549
|
+
throw error;
|
|
550
|
+
}
|
|
551
|
+
throw new Error(`Failed to load native binding`);
|
|
552
|
+
}
|
|
553
|
+
const { Renderer: Renderer$1, AnimationOutputFormat, DitheringAlgorithm, ImageCacheMode, OutputFormat, setGlyphCacheMaxBytes } = nativeBinding;
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/export.ts
|
|
556
|
+
var Renderer = class {
|
|
557
|
+
inner;
|
|
558
|
+
fonts;
|
|
559
|
+
constructor(options) {
|
|
560
|
+
this.inner = new Renderer$1(options);
|
|
561
|
+
this.fonts = new _takumi_rs_helpers_renderer.FontRegistry((font) => this.inner.registerFont(font));
|
|
562
|
+
}
|
|
563
|
+
async render(node, options) {
|
|
564
|
+
const { options: opts, signal } = await (0, _takumi_rs_helpers_renderer.prepareRenderInput)(this.fonts, options ?? {}, node);
|
|
565
|
+
return this.inner.render(node, opts, signal);
|
|
566
|
+
}
|
|
567
|
+
async renderSvg(node, options) {
|
|
568
|
+
const { options: opts, signal } = await (0, _takumi_rs_helpers_renderer.prepareRenderInput)(this.fonts, options ?? {}, node);
|
|
569
|
+
return this.inner.renderSvg(node, opts, signal);
|
|
570
|
+
}
|
|
571
|
+
async measure(node, options) {
|
|
572
|
+
const { options: opts, signal } = await (0, _takumi_rs_helpers_renderer.prepareRenderInput)(this.fonts, options ?? {}, node);
|
|
573
|
+
return this.inner.measure(node, opts, signal);
|
|
574
|
+
}
|
|
575
|
+
async renderAnimation(options) {
|
|
576
|
+
const nodes = options.scenes.map((scene) => scene.node);
|
|
577
|
+
const { options: opts, signal } = await (0, _takumi_rs_helpers_renderer.prepareRenderInput)(this.fonts, options, nodes);
|
|
578
|
+
return this.inner.renderAnimation(opts, signal);
|
|
579
|
+
}
|
|
580
|
+
registerFont(font) {
|
|
581
|
+
return this.fonts.register(font);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
//#endregion
|
|
585
|
+
exports.Renderer = Renderer;
|
|
586
|
+
exports.setGlyphCacheMaxBytes = setGlyphCacheMaxBytes;
|