@takumi-rs/core 1.0.0-beta.11 → 1.0.0-beta.12
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/export.d.ts +1 -0
- package/export.mjs +74 -0
- package/not-available.js +3 -0
- package/package.json +20 -23
- package/index.d.ts +0 -220
- package/index.js +0 -587
package/export.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index";
|
package/export.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const loadModule = (specifier) =>
|
|
6
|
+
Function("require", "specifier", "return require(specifier)")(require, specifier);
|
|
7
|
+
|
|
8
|
+
function resolveTarget() {
|
|
9
|
+
switch (process.platform) {
|
|
10
|
+
case "darwin":
|
|
11
|
+
switch (process.arch) {
|
|
12
|
+
case "arm64":
|
|
13
|
+
return "darwin-arm64";
|
|
14
|
+
case "x64":
|
|
15
|
+
return "darwin-x64";
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case "linux":
|
|
19
|
+
switch (process.arch) {
|
|
20
|
+
case "arm64":
|
|
21
|
+
return process.report?.getReport().header.glibcVersionRuntime
|
|
22
|
+
? "linux-arm64-gnu"
|
|
23
|
+
: "linux-arm64-musl";
|
|
24
|
+
case "x64":
|
|
25
|
+
return process.report?.getReport().header.glibcVersionRuntime
|
|
26
|
+
? "linux-x64-gnu"
|
|
27
|
+
: "linux-x64-musl";
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case "win32":
|
|
31
|
+
if (process.arch === "x64") {
|
|
32
|
+
return "win32-x64-msvc";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return "win32-arm64-msvc";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function loadNativeModule() {
|
|
42
|
+
if (process.env.TAKUMI_CORE_TARGET) {
|
|
43
|
+
return loadModule(process.env.TAKUMI_CORE_TARGET);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const target = resolveTarget();
|
|
47
|
+
if (!target) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
return loadModule(`@takumi-rs/core-${target}`);
|
|
53
|
+
} catch {}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
return loadModule(fileURLToPath(new URL(`./core.${target}.node`, import.meta.url)));
|
|
57
|
+
} catch {}
|
|
58
|
+
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const nativeModule = loadNativeModule();
|
|
63
|
+
|
|
64
|
+
if (!nativeModule) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
"@takumi-rs/core is only available in Node.js runtimes. Use @takumi-rs/wasm or a higher-level package that falls back to WASM automatically.",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { Renderer, extractResourceUrls } = nativeModule;
|
|
71
|
+
|
|
72
|
+
export default nativeModule;
|
|
73
|
+
|
|
74
|
+
export { Renderer, extractResourceUrls };
|
package/not-available.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.12",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"css",
|
|
6
6
|
"image",
|
|
@@ -20,35 +20,32 @@
|
|
|
20
20
|
"url": "git+https://github.com/kane50613/takumi.git"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"export.d.ts",
|
|
24
|
+
"export.mjs",
|
|
25
|
+
"not-available.js",
|
|
25
26
|
"README.md"
|
|
26
27
|
],
|
|
27
28
|
"type": "module",
|
|
28
|
-
"main": "
|
|
29
|
-
"types": "
|
|
29
|
+
"main": "export.mjs",
|
|
30
|
+
"types": "export.d.ts",
|
|
30
31
|
"exports": {
|
|
31
32
|
".": {
|
|
32
|
-
"types": "./
|
|
33
|
-
"import": "./index.js",
|
|
34
|
-
"require": "./index.js"
|
|
35
|
-
},
|
|
36
|
-
"./auto": {
|
|
37
|
-
"types": "./index.d.ts",
|
|
33
|
+
"types": "./export.d.ts",
|
|
38
34
|
"workerd": "./not-available.js",
|
|
39
35
|
"browser": "./not-available.js",
|
|
40
|
-
"node": "./
|
|
41
|
-
"
|
|
36
|
+
"node": "./export.mjs",
|
|
37
|
+
"import": "./export.mjs",
|
|
38
|
+
"default": "./export.mjs"
|
|
42
39
|
}
|
|
43
40
|
},
|
|
44
41
|
"scripts": {
|
|
45
42
|
"build": "napi build --release --no-const-enum --platform --esm --strip",
|
|
46
|
-
"prepublishOnly": "jq '.dependencies[\"@takumi-rs/helpers\"] = .version' package.json > tmp.json && mv tmp.json package.json && bun artifacts &&
|
|
43
|
+
"prepublishOnly": "jq '.dependencies[\"@takumi-rs/helpers\"] = .version' package.json > tmp.json && mv tmp.json package.json && bun artifacts && napi prepublish -t npm --no-gh-release",
|
|
47
44
|
"artifacts": "napi create-npm-dirs && napi artifacts && napi version",
|
|
48
45
|
"bench": "bun tests/bench/index.tsx"
|
|
49
46
|
},
|
|
50
47
|
"dependencies": {
|
|
51
|
-
"@takumi-rs/helpers": "1.0.0-beta.
|
|
48
|
+
"@takumi-rs/helpers": "1.0.0-beta.12"
|
|
52
49
|
},
|
|
53
50
|
"devDependencies": {
|
|
54
51
|
"@napi-rs/cli": "3.5.1",
|
|
@@ -78,13 +75,13 @@
|
|
|
78
75
|
"node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
|
|
79
76
|
},
|
|
80
77
|
"optionalDependencies": {
|
|
81
|
-
"@takumi-rs/core-darwin-x64": "1.0.0-beta.
|
|
82
|
-
"@takumi-rs/core-darwin-arm64": "1.0.0-beta.
|
|
83
|
-
"@takumi-rs/core-linux-arm64-gnu": "1.0.0-beta.
|
|
84
|
-
"@takumi-rs/core-linux-arm64-musl": "1.0.0-beta.
|
|
85
|
-
"@takumi-rs/core-win32-arm64-msvc": "1.0.0-beta.
|
|
86
|
-
"@takumi-rs/core-linux-x64-gnu": "1.0.0-beta.
|
|
87
|
-
"@takumi-rs/core-linux-x64-musl": "1.0.0-beta.
|
|
88
|
-
"@takumi-rs/core-win32-x64-msvc": "1.0.0-beta.
|
|
78
|
+
"@takumi-rs/core-darwin-x64": "1.0.0-beta.12",
|
|
79
|
+
"@takumi-rs/core-darwin-arm64": "1.0.0-beta.12",
|
|
80
|
+
"@takumi-rs/core-linux-arm64-gnu": "1.0.0-beta.12",
|
|
81
|
+
"@takumi-rs/core-linux-arm64-musl": "1.0.0-beta.12",
|
|
82
|
+
"@takumi-rs/core-win32-arm64-msvc": "1.0.0-beta.12",
|
|
83
|
+
"@takumi-rs/core-linux-x64-gnu": "1.0.0-beta.12",
|
|
84
|
+
"@takumi-rs/core-linux-x64-musl": "1.0.0-beta.12",
|
|
85
|
+
"@takumi-rs/core-win32-x64-msvc": "1.0.0-beta.12"
|
|
89
86
|
}
|
|
90
87
|
}
|
package/index.d.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import type { Node } from "@takumi-rs/helpers";
|
|
2
|
-
|
|
3
|
-
export type { ContainerNode, ImageNode, NodeMetadata, TextNode } from "@takumi-rs/helpers";
|
|
4
|
-
|
|
5
|
-
export type { Node };
|
|
6
|
-
|
|
7
|
-
export interface FontDetails {
|
|
8
|
-
/**
|
|
9
|
-
* The name of the font. If not provided, the name in the font file will be used.
|
|
10
|
-
*/
|
|
11
|
-
name?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The font data.
|
|
14
|
-
*/
|
|
15
|
-
data: Uint8Array | ArrayBuffer;
|
|
16
|
-
/**
|
|
17
|
-
* The weight of the font. If not provided, the weight in the font file will be used.
|
|
18
|
-
*/
|
|
19
|
-
weight?: number;
|
|
20
|
-
/**
|
|
21
|
-
* The style of the font. If not provided, the style in the font file will be used.
|
|
22
|
-
*/
|
|
23
|
-
style?: "normal" | "italic" | "oblique" | `oblique ${number}deg` | (string & {});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type Font = FontDetails | Uint8Array | ArrayBuffer;
|
|
27
|
-
|
|
28
|
-
export type Keyframes = Record<string, Record<string, Record<string, unknown>>>;
|
|
29
|
-
/** The main renderer for Takumi image rendering engine (Node.js version). */
|
|
30
|
-
export declare class Renderer {
|
|
31
|
-
/** Creates a new Renderer instance. */
|
|
32
|
-
constructor(options?: ConstructRendererOptions | undefined | null)
|
|
33
|
-
/** Puts a persistent image into the renderer's internal store asynchronously. */
|
|
34
|
-
putPersistentImage(source: ImageSource, signal?: AbortSignal): Promise<void>
|
|
35
|
-
/** Loads a font synchronously. */
|
|
36
|
-
loadFontSync(font: Font): void
|
|
37
|
-
/** Loads a font into the renderer asynchronously. */
|
|
38
|
-
loadFont(data: Font, signal?: AbortSignal): Promise<number>
|
|
39
|
-
/** Loads multiple fonts into the renderer asynchronously. */
|
|
40
|
-
loadFonts(fonts: Font[], signal?: AbortSignal): Promise<number>
|
|
41
|
-
/** Clears the renderer's internal image store. */
|
|
42
|
-
clearImageStore(): void
|
|
43
|
-
/** Renders a node tree into an image buffer asynchronously. */
|
|
44
|
-
render(source: Node, options?: RenderOptions, signal?: AbortSignal): Promise<Buffer>
|
|
45
|
-
/** Measures a node tree and returns layout information asynchronously. */
|
|
46
|
-
measure(source: Node, options?: RenderOptions, signal?: AbortSignal): Promise<MeasuredNode>
|
|
47
|
-
/** Renders a sequential scene animation into a buffer asynchronously. */
|
|
48
|
-
renderAnimation(options: RenderAnimationOptions, signal?: AbortSignal): Promise<Buffer>
|
|
49
|
-
/** Encodes a precomputed frame sequence into an animated image buffer asynchronously. */
|
|
50
|
-
encodeFrames(source: AnimationFrameSource[], options: EncodeFramesOptions, signal?: AbortSignal): Promise<Buffer>
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Represents a single frame in a precomputed animation sequence. */
|
|
54
|
-
export interface AnimationFrameSource {
|
|
55
|
-
/** The node tree to render for this frame. */
|
|
56
|
-
node: Node
|
|
57
|
-
/** The duration of this frame in milliseconds. */
|
|
58
|
-
durationMs: number
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Output format for animated images. */
|
|
62
|
-
export type AnimationOutputFormat = /** Animated WebP format. */
|
|
63
|
-
'webp'|
|
|
64
|
-
/** Animated PNG format. */
|
|
65
|
-
'apng'|
|
|
66
|
-
/** Animated GIF format. */
|
|
67
|
-
'gif';
|
|
68
|
-
|
|
69
|
-
/** Represents a single scene in a sequential animation timeline. */
|
|
70
|
-
export interface AnimationSceneSource {
|
|
71
|
-
/** The node tree to render for this scene. */
|
|
72
|
-
node: Node
|
|
73
|
-
/** The duration of this scene in milliseconds. */
|
|
74
|
-
durationMs: number
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Options for constructing a Renderer instance. */
|
|
78
|
-
export interface ConstructRendererOptions {
|
|
79
|
-
/** The images that needs to be preloaded into the renderer. */
|
|
80
|
-
persistentImages?: Array<ImageSource>
|
|
81
|
-
/** The fonts being used. */
|
|
82
|
-
fonts?: Font[] | undefined
|
|
83
|
-
/**
|
|
84
|
-
* Whether to load the default fonts.
|
|
85
|
-
* If `fonts` are provided, this will be `false` by default.
|
|
86
|
-
*/
|
|
87
|
-
loadDefaultFonts?: boolean
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type DitheringAlgorithm = 'none'|
|
|
91
|
-
'ordered-bayer'|
|
|
92
|
-
'floyd-steinberg';
|
|
93
|
-
|
|
94
|
-
/** Options for encoding a precomputed frame sequence. */
|
|
95
|
-
export interface EncodeFramesOptions {
|
|
96
|
-
/** Whether to draw debug borders around layout elements. */
|
|
97
|
-
drawDebugBorder?: boolean
|
|
98
|
-
/** The width of each frame in pixels. */
|
|
99
|
-
width: number
|
|
100
|
-
/** The height of each frame in pixels. */
|
|
101
|
-
height: number
|
|
102
|
-
/** The output animation format (WebP, APNG, or GIF). */
|
|
103
|
-
format?: AnimationOutputFormat
|
|
104
|
-
/** The quality of WebP format (0-100). Ignored for APNG and GIF. */
|
|
105
|
-
quality?: number
|
|
106
|
-
/** The fetched resources to use. */
|
|
107
|
-
fetchedResources?: Array<ImageSource>
|
|
108
|
-
/** CSS stylesheets to apply before rendering. */
|
|
109
|
-
stylesheets?: Array<string>
|
|
110
|
-
/**
|
|
111
|
-
* The device pixel ratio.
|
|
112
|
-
* @default 1.0
|
|
113
|
-
*/
|
|
114
|
-
devicePixelRatio?: number
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** Collects the fetch task urls from the node. */
|
|
118
|
-
export declare function extractResourceUrls(node: Node): Array<string>
|
|
119
|
-
|
|
120
|
-
/** An image source with its URL and raw data. */
|
|
121
|
-
export interface ImageSource {
|
|
122
|
-
/** The source URL of the image. */
|
|
123
|
-
src: string
|
|
124
|
-
/** The raw image data (Uint8Array or ArrayBuffer). */
|
|
125
|
-
data: Uint8Array | ArrayBuffer
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** Represents a node that has been measured, including its layout information. */
|
|
129
|
-
export interface MeasuredNode {
|
|
130
|
-
/** The measured width of the node. */
|
|
131
|
-
width: number
|
|
132
|
-
/** The measured height of the node. */
|
|
133
|
-
height: number
|
|
134
|
-
/** The transformation matrix of the node. */
|
|
135
|
-
transform: [number, number, number, number, number, number]
|
|
136
|
-
/** The children of the node. */
|
|
137
|
-
children: Array<MeasuredNode>
|
|
138
|
-
/** The text runs within the node. */
|
|
139
|
-
runs: Array<MeasuredTextRun>
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Represents a single run of text in a measured node. */
|
|
143
|
-
export interface MeasuredTextRun {
|
|
144
|
-
/** The text content of the run. */
|
|
145
|
-
text: string
|
|
146
|
-
/** The inline x-coordinate of the run. */
|
|
147
|
-
x: number
|
|
148
|
-
/** The inline y-coordinate of the run. */
|
|
149
|
-
y: number
|
|
150
|
-
/** The width of the run. */
|
|
151
|
-
width: number
|
|
152
|
-
/** The height of the run. */
|
|
153
|
-
height: number
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** Output format for static images. */
|
|
157
|
-
export type OutputFormat = /** WebP format. */
|
|
158
|
-
'webp'|
|
|
159
|
-
/** PNG format. */
|
|
160
|
-
'png'|
|
|
161
|
-
/** JPEG format. */
|
|
162
|
-
'jpeg'|
|
|
163
|
-
/** Raw pixels format. */
|
|
164
|
-
'raw';
|
|
165
|
-
|
|
166
|
-
/** Options for rendering a sequential scene animation. */
|
|
167
|
-
export interface RenderAnimationOptions {
|
|
168
|
-
/** The scenes to render sequentially. */
|
|
169
|
-
scenes: Array<AnimationSceneSource>
|
|
170
|
-
/** Whether to draw debug borders around layout elements. */
|
|
171
|
-
drawDebugBorder?: boolean
|
|
172
|
-
/** The width of each frame in pixels. */
|
|
173
|
-
width: number
|
|
174
|
-
/** The height of each frame in pixels. */
|
|
175
|
-
height: number
|
|
176
|
-
/** The output animation format (WebP, APNG, or GIF). */
|
|
177
|
-
format?: AnimationOutputFormat
|
|
178
|
-
/** The quality of WebP format (0-100). Ignored for APNG and GIF. */
|
|
179
|
-
quality?: number
|
|
180
|
-
/** Frames per second for timeline sampling. */
|
|
181
|
-
fps: number
|
|
182
|
-
/** The fetched resources to use. */
|
|
183
|
-
fetchedResources?: Array<ImageSource>
|
|
184
|
-
/** CSS stylesheets to apply before rendering. */
|
|
185
|
-
stylesheets?: Array<string>
|
|
186
|
-
/**
|
|
187
|
-
* The device pixel ratio.
|
|
188
|
-
* @default 1.0
|
|
189
|
-
*/
|
|
190
|
-
devicePixelRatio?: number
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/** Options for rendering an image. */
|
|
194
|
-
export interface RenderOptions {
|
|
195
|
-
/** The width of the image. If not provided, the width will be automatically calculated based on the content. */
|
|
196
|
-
width?: number
|
|
197
|
-
/** The height of the image. If not provided, the height will be automatically calculated based on the content. */
|
|
198
|
-
height?: number
|
|
199
|
-
/** The format of the image. */
|
|
200
|
-
format?: OutputFormat
|
|
201
|
-
/** The quality of JPEG format (0-100). */
|
|
202
|
-
quality?: number
|
|
203
|
-
/** Whether to draw debug borders. */
|
|
204
|
-
drawDebugBorder?: boolean
|
|
205
|
-
/** The fetched resources to use. */
|
|
206
|
-
fetchedResources?: Array<ImageSource>
|
|
207
|
-
/** CSS stylesheets to apply before rendering. */
|
|
208
|
-
stylesheets?: Array<string>
|
|
209
|
-
/** Structured keyframes to register alongside stylesheets. */
|
|
210
|
-
keyframes?: { name: string; keyframes: { offsets: number[]; declarations: Record<string, unknown> }[] }[] | Keyframes
|
|
211
|
-
/**
|
|
212
|
-
* The device pixel ratio.
|
|
213
|
-
* @default 1.0
|
|
214
|
-
*/
|
|
215
|
-
devicePixelRatio?: number
|
|
216
|
-
/** The animation timeline time in milliseconds. */
|
|
217
|
-
timeMs?: number
|
|
218
|
-
/** The output dithering algorithm. */
|
|
219
|
-
dithering?: DitheringAlgorithm
|
|
220
|
-
}
|
package/index.js
DELETED
|
@@ -1,587 +0,0 @@
|
|
|
1
|
-
// prettier-ignore
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
import { createRequire } from 'node:module'
|
|
7
|
-
const require = createRequire(import.meta.url)
|
|
8
|
-
const __dirname = new URL('.', import.meta.url).pathname
|
|
9
|
-
|
|
10
|
-
const { readFileSync } = require('node:fs')
|
|
11
|
-
let nativeBinding = null
|
|
12
|
-
const loadErrors = []
|
|
13
|
-
|
|
14
|
-
const isMusl = () => {
|
|
15
|
-
let musl = false
|
|
16
|
-
if (process.platform === 'linux') {
|
|
17
|
-
musl = isMuslFromFilesystem()
|
|
18
|
-
if (musl === null) {
|
|
19
|
-
musl = isMuslFromReport()
|
|
20
|
-
}
|
|
21
|
-
if (musl === null) {
|
|
22
|
-
musl = isMuslFromChildProcess()
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return musl
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
29
|
-
|
|
30
|
-
const isMuslFromFilesystem = () => {
|
|
31
|
-
try {
|
|
32
|
-
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
33
|
-
} catch {
|
|
34
|
-
return null
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const isMuslFromReport = () => {
|
|
39
|
-
let report = null
|
|
40
|
-
if (typeof process.report?.getReport === 'function') {
|
|
41
|
-
process.report.excludeNetwork = true
|
|
42
|
-
report = process.report.getReport()
|
|
43
|
-
}
|
|
44
|
-
if (!report) {
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
if (report.header && report.header.glibcVersionRuntime) {
|
|
48
|
-
return false
|
|
49
|
-
}
|
|
50
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
51
|
-
if (report.sharedObjects.some(isFileMusl)) {
|
|
52
|
-
return true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return false
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const isMuslFromChildProcess = () => {
|
|
59
|
-
try {
|
|
60
|
-
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
61
|
-
} catch (e) {
|
|
62
|
-
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
63
|
-
return false
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function requireNative() {
|
|
68
|
-
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
69
|
-
try {
|
|
70
|
-
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
loadErrors.push(err)
|
|
73
|
-
}
|
|
74
|
-
} else if (process.platform === 'android') {
|
|
75
|
-
if (process.arch === 'arm64') {
|
|
76
|
-
try {
|
|
77
|
-
return require('./core.android-arm64.node')
|
|
78
|
-
} catch (e) {
|
|
79
|
-
loadErrors.push(e)
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
const binding = require('@takumi-rs/core-android-arm64')
|
|
83
|
-
const bindingPackageVersion = require('@takumi-rs/core-android-arm64/package.json').version
|
|
84
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
86
|
-
}
|
|
87
|
-
return binding
|
|
88
|
-
} catch (e) {
|
|
89
|
-
loadErrors.push(e)
|
|
90
|
-
}
|
|
91
|
-
} else if (process.arch === 'arm') {
|
|
92
|
-
try {
|
|
93
|
-
return require('./core.android-arm-eabi.node')
|
|
94
|
-
} catch (e) {
|
|
95
|
-
loadErrors.push(e)
|
|
96
|
-
}
|
|
97
|
-
try {
|
|
98
|
-
const binding = require('@takumi-rs/core-android-arm-eabi')
|
|
99
|
-
const bindingPackageVersion = require('@takumi-rs/core-android-arm-eabi/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
|
-
}
|
|
103
|
-
return binding
|
|
104
|
-
} catch (e) {
|
|
105
|
-
loadErrors.push(e)
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
109
|
-
}
|
|
110
|
-
} else if (process.platform === 'win32') {
|
|
111
|
-
if (process.arch === 'x64') {
|
|
112
|
-
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
113
|
-
try {
|
|
114
|
-
return require('./core.win32-x64-gnu.node')
|
|
115
|
-
} catch (e) {
|
|
116
|
-
loadErrors.push(e)
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
const binding = require('@takumi-rs/core-win32-x64-gnu')
|
|
120
|
-
const bindingPackageVersion = require('@takumi-rs/core-win32-x64-gnu/package.json').version
|
|
121
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
122
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
123
|
-
}
|
|
124
|
-
return binding
|
|
125
|
-
} catch (e) {
|
|
126
|
-
loadErrors.push(e)
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
try {
|
|
130
|
-
return require('./core.win32-x64-msvc.node')
|
|
131
|
-
} catch (e) {
|
|
132
|
-
loadErrors.push(e)
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
const binding = require('@takumi-rs/core-win32-x64-msvc')
|
|
136
|
-
const bindingPackageVersion = require('@takumi-rs/core-win32-x64-msvc/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
|
-
}
|
|
140
|
-
return binding
|
|
141
|
-
} catch (e) {
|
|
142
|
-
loadErrors.push(e)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} else if (process.arch === 'ia32') {
|
|
146
|
-
try {
|
|
147
|
-
return require('./core.win32-ia32-msvc.node')
|
|
148
|
-
} catch (e) {
|
|
149
|
-
loadErrors.push(e)
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const binding = require('@takumi-rs/core-win32-ia32-msvc')
|
|
153
|
-
const bindingPackageVersion = require('@takumi-rs/core-win32-ia32-msvc/package.json').version
|
|
154
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
155
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
156
|
-
}
|
|
157
|
-
return binding
|
|
158
|
-
} catch (e) {
|
|
159
|
-
loadErrors.push(e)
|
|
160
|
-
}
|
|
161
|
-
} else if (process.arch === 'arm64') {
|
|
162
|
-
try {
|
|
163
|
-
return require('./core.win32-arm64-msvc.node')
|
|
164
|
-
} catch (e) {
|
|
165
|
-
loadErrors.push(e)
|
|
166
|
-
}
|
|
167
|
-
try {
|
|
168
|
-
const binding = require('@takumi-rs/core-win32-arm64-msvc')
|
|
169
|
-
const bindingPackageVersion = require('@takumi-rs/core-win32-arm64-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
|
-
}
|
|
173
|
-
return binding
|
|
174
|
-
} catch (e) {
|
|
175
|
-
loadErrors.push(e)
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
179
|
-
}
|
|
180
|
-
} else if (process.platform === 'darwin') {
|
|
181
|
-
try {
|
|
182
|
-
return require('./core.darwin-universal.node')
|
|
183
|
-
} catch (e) {
|
|
184
|
-
loadErrors.push(e)
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
const binding = require('@takumi-rs/core-darwin-universal')
|
|
188
|
-
const bindingPackageVersion = require('@takumi-rs/core-darwin-universal/package.json').version
|
|
189
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
190
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
191
|
-
}
|
|
192
|
-
return binding
|
|
193
|
-
} catch (e) {
|
|
194
|
-
loadErrors.push(e)
|
|
195
|
-
}
|
|
196
|
-
if (process.arch === 'x64') {
|
|
197
|
-
try {
|
|
198
|
-
return require('./core.darwin-x64.node')
|
|
199
|
-
} catch (e) {
|
|
200
|
-
loadErrors.push(e)
|
|
201
|
-
}
|
|
202
|
-
try {
|
|
203
|
-
const binding = require('@takumi-rs/core-darwin-x64')
|
|
204
|
-
const bindingPackageVersion = require('@takumi-rs/core-darwin-x64/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
|
-
}
|
|
208
|
-
return binding
|
|
209
|
-
} catch (e) {
|
|
210
|
-
loadErrors.push(e)
|
|
211
|
-
}
|
|
212
|
-
} else if (process.arch === 'arm64') {
|
|
213
|
-
try {
|
|
214
|
-
return require('./core.darwin-arm64.node')
|
|
215
|
-
} catch (e) {
|
|
216
|
-
loadErrors.push(e)
|
|
217
|
-
}
|
|
218
|
-
try {
|
|
219
|
-
const binding = require('@takumi-rs/core-darwin-arm64')
|
|
220
|
-
const bindingPackageVersion = require('@takumi-rs/core-darwin-arm64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
|
-
}
|
|
224
|
-
return binding
|
|
225
|
-
} catch (e) {
|
|
226
|
-
loadErrors.push(e)
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
230
|
-
}
|
|
231
|
-
} else if (process.platform === 'freebsd') {
|
|
232
|
-
if (process.arch === 'x64') {
|
|
233
|
-
try {
|
|
234
|
-
return require('./core.freebsd-x64.node')
|
|
235
|
-
} catch (e) {
|
|
236
|
-
loadErrors.push(e)
|
|
237
|
-
}
|
|
238
|
-
try {
|
|
239
|
-
const binding = require('@takumi-rs/core-freebsd-x64')
|
|
240
|
-
const bindingPackageVersion = require('@takumi-rs/core-freebsd-x64/package.json').version
|
|
241
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
243
|
-
}
|
|
244
|
-
return binding
|
|
245
|
-
} catch (e) {
|
|
246
|
-
loadErrors.push(e)
|
|
247
|
-
}
|
|
248
|
-
} else if (process.arch === 'arm64') {
|
|
249
|
-
try {
|
|
250
|
-
return require('./core.freebsd-arm64.node')
|
|
251
|
-
} catch (e) {
|
|
252
|
-
loadErrors.push(e)
|
|
253
|
-
}
|
|
254
|
-
try {
|
|
255
|
-
const binding = require('@takumi-rs/core-freebsd-arm64')
|
|
256
|
-
const bindingPackageVersion = require('@takumi-rs/core-freebsd-arm64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
|
-
}
|
|
260
|
-
return binding
|
|
261
|
-
} catch (e) {
|
|
262
|
-
loadErrors.push(e)
|
|
263
|
-
}
|
|
264
|
-
} else {
|
|
265
|
-
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
266
|
-
}
|
|
267
|
-
} else if (process.platform === 'linux') {
|
|
268
|
-
if (process.arch === 'x64') {
|
|
269
|
-
if (isMusl()) {
|
|
270
|
-
try {
|
|
271
|
-
return require('./core.linux-x64-musl.node')
|
|
272
|
-
} catch (e) {
|
|
273
|
-
loadErrors.push(e)
|
|
274
|
-
}
|
|
275
|
-
try {
|
|
276
|
-
const binding = require('@takumi-rs/core-linux-x64-musl')
|
|
277
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-x64-musl/package.json').version
|
|
278
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
279
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
280
|
-
}
|
|
281
|
-
return binding
|
|
282
|
-
} catch (e) {
|
|
283
|
-
loadErrors.push(e)
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
try {
|
|
287
|
-
return require('./core.linux-x64-gnu.node')
|
|
288
|
-
} catch (e) {
|
|
289
|
-
loadErrors.push(e)
|
|
290
|
-
}
|
|
291
|
-
try {
|
|
292
|
-
const binding = require('@takumi-rs/core-linux-x64-gnu')
|
|
293
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-x64-gnu/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
|
-
}
|
|
297
|
-
return binding
|
|
298
|
-
} catch (e) {
|
|
299
|
-
loadErrors.push(e)
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
} else if (process.arch === 'arm64') {
|
|
303
|
-
if (isMusl()) {
|
|
304
|
-
try {
|
|
305
|
-
return require('./core.linux-arm64-musl.node')
|
|
306
|
-
} catch (e) {
|
|
307
|
-
loadErrors.push(e)
|
|
308
|
-
}
|
|
309
|
-
try {
|
|
310
|
-
const binding = require('@takumi-rs/core-linux-arm64-musl')
|
|
311
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-arm64-musl/package.json').version
|
|
312
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
313
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
314
|
-
}
|
|
315
|
-
return binding
|
|
316
|
-
} catch (e) {
|
|
317
|
-
loadErrors.push(e)
|
|
318
|
-
}
|
|
319
|
-
} else {
|
|
320
|
-
try {
|
|
321
|
-
return require('./core.linux-arm64-gnu.node')
|
|
322
|
-
} catch (e) {
|
|
323
|
-
loadErrors.push(e)
|
|
324
|
-
}
|
|
325
|
-
try {
|
|
326
|
-
const binding = require('@takumi-rs/core-linux-arm64-gnu')
|
|
327
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-arm64-gnu/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
|
-
}
|
|
331
|
-
return binding
|
|
332
|
-
} catch (e) {
|
|
333
|
-
loadErrors.push(e)
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
} else if (process.arch === 'arm') {
|
|
337
|
-
if (isMusl()) {
|
|
338
|
-
try {
|
|
339
|
-
return require('./core.linux-arm-musleabihf.node')
|
|
340
|
-
} catch (e) {
|
|
341
|
-
loadErrors.push(e)
|
|
342
|
-
}
|
|
343
|
-
try {
|
|
344
|
-
const binding = require('@takumi-rs/core-linux-arm-musleabihf')
|
|
345
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-arm-musleabihf/package.json').version
|
|
346
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
347
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
348
|
-
}
|
|
349
|
-
return binding
|
|
350
|
-
} catch (e) {
|
|
351
|
-
loadErrors.push(e)
|
|
352
|
-
}
|
|
353
|
-
} else {
|
|
354
|
-
try {
|
|
355
|
-
return require('./core.linux-arm-gnueabihf.node')
|
|
356
|
-
} catch (e) {
|
|
357
|
-
loadErrors.push(e)
|
|
358
|
-
}
|
|
359
|
-
try {
|
|
360
|
-
const binding = require('@takumi-rs/core-linux-arm-gnueabihf')
|
|
361
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-arm-gnueabihf/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
|
-
}
|
|
365
|
-
return binding
|
|
366
|
-
} catch (e) {
|
|
367
|
-
loadErrors.push(e)
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
} else if (process.arch === 'loong64') {
|
|
371
|
-
if (isMusl()) {
|
|
372
|
-
try {
|
|
373
|
-
return require('./core.linux-loong64-musl.node')
|
|
374
|
-
} catch (e) {
|
|
375
|
-
loadErrors.push(e)
|
|
376
|
-
}
|
|
377
|
-
try {
|
|
378
|
-
const binding = require('@takumi-rs/core-linux-loong64-musl')
|
|
379
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-loong64-musl/package.json').version
|
|
380
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
381
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
382
|
-
}
|
|
383
|
-
return binding
|
|
384
|
-
} catch (e) {
|
|
385
|
-
loadErrors.push(e)
|
|
386
|
-
}
|
|
387
|
-
} else {
|
|
388
|
-
try {
|
|
389
|
-
return require('./core.linux-loong64-gnu.node')
|
|
390
|
-
} catch (e) {
|
|
391
|
-
loadErrors.push(e)
|
|
392
|
-
}
|
|
393
|
-
try {
|
|
394
|
-
const binding = require('@takumi-rs/core-linux-loong64-gnu')
|
|
395
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-loong64-gnu/package.json').version
|
|
396
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
397
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
|
-
}
|
|
399
|
-
return binding
|
|
400
|
-
} catch (e) {
|
|
401
|
-
loadErrors.push(e)
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
} else if (process.arch === 'riscv64') {
|
|
405
|
-
if (isMusl()) {
|
|
406
|
-
try {
|
|
407
|
-
return require('./core.linux-riscv64-musl.node')
|
|
408
|
-
} catch (e) {
|
|
409
|
-
loadErrors.push(e)
|
|
410
|
-
}
|
|
411
|
-
try {
|
|
412
|
-
const binding = require('@takumi-rs/core-linux-riscv64-musl')
|
|
413
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-riscv64-musl/package.json').version
|
|
414
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
415
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
416
|
-
}
|
|
417
|
-
return binding
|
|
418
|
-
} catch (e) {
|
|
419
|
-
loadErrors.push(e)
|
|
420
|
-
}
|
|
421
|
-
} else {
|
|
422
|
-
try {
|
|
423
|
-
return require('./core.linux-riscv64-gnu.node')
|
|
424
|
-
} catch (e) {
|
|
425
|
-
loadErrors.push(e)
|
|
426
|
-
}
|
|
427
|
-
try {
|
|
428
|
-
const binding = require('@takumi-rs/core-linux-riscv64-gnu')
|
|
429
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-riscv64-gnu/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
|
-
}
|
|
433
|
-
return binding
|
|
434
|
-
} catch (e) {
|
|
435
|
-
loadErrors.push(e)
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
} else if (process.arch === 'ppc64') {
|
|
439
|
-
try {
|
|
440
|
-
return require('./core.linux-ppc64-gnu.node')
|
|
441
|
-
} catch (e) {
|
|
442
|
-
loadErrors.push(e)
|
|
443
|
-
}
|
|
444
|
-
try {
|
|
445
|
-
const binding = require('@takumi-rs/core-linux-ppc64-gnu')
|
|
446
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-ppc64-gnu/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
|
-
}
|
|
450
|
-
return binding
|
|
451
|
-
} catch (e) {
|
|
452
|
-
loadErrors.push(e)
|
|
453
|
-
}
|
|
454
|
-
} else if (process.arch === 's390x') {
|
|
455
|
-
try {
|
|
456
|
-
return require('./core.linux-s390x-gnu.node')
|
|
457
|
-
} catch (e) {
|
|
458
|
-
loadErrors.push(e)
|
|
459
|
-
}
|
|
460
|
-
try {
|
|
461
|
-
const binding = require('@takumi-rs/core-linux-s390x-gnu')
|
|
462
|
-
const bindingPackageVersion = require('@takumi-rs/core-linux-s390x-gnu/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
|
-
}
|
|
466
|
-
return binding
|
|
467
|
-
} catch (e) {
|
|
468
|
-
loadErrors.push(e)
|
|
469
|
-
}
|
|
470
|
-
} else {
|
|
471
|
-
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
472
|
-
}
|
|
473
|
-
} else if (process.platform === 'openharmony') {
|
|
474
|
-
if (process.arch === 'arm64') {
|
|
475
|
-
try {
|
|
476
|
-
return require('./core.openharmony-arm64.node')
|
|
477
|
-
} catch (e) {
|
|
478
|
-
loadErrors.push(e)
|
|
479
|
-
}
|
|
480
|
-
try {
|
|
481
|
-
const binding = require('@takumi-rs/core-openharmony-arm64')
|
|
482
|
-
const bindingPackageVersion = require('@takumi-rs/core-openharmony-arm64/package.json').version
|
|
483
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
484
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
485
|
-
}
|
|
486
|
-
return binding
|
|
487
|
-
} catch (e) {
|
|
488
|
-
loadErrors.push(e)
|
|
489
|
-
}
|
|
490
|
-
} else if (process.arch === 'x64') {
|
|
491
|
-
try {
|
|
492
|
-
return require('./core.openharmony-x64.node')
|
|
493
|
-
} catch (e) {
|
|
494
|
-
loadErrors.push(e)
|
|
495
|
-
}
|
|
496
|
-
try {
|
|
497
|
-
const binding = require('@takumi-rs/core-openharmony-x64')
|
|
498
|
-
const bindingPackageVersion = require('@takumi-rs/core-openharmony-x64/package.json').version
|
|
499
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
500
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
501
|
-
}
|
|
502
|
-
return binding
|
|
503
|
-
} catch (e) {
|
|
504
|
-
loadErrors.push(e)
|
|
505
|
-
}
|
|
506
|
-
} else if (process.arch === 'arm') {
|
|
507
|
-
try {
|
|
508
|
-
return require('./core.openharmony-arm.node')
|
|
509
|
-
} catch (e) {
|
|
510
|
-
loadErrors.push(e)
|
|
511
|
-
}
|
|
512
|
-
try {
|
|
513
|
-
const binding = require('@takumi-rs/core-openharmony-arm')
|
|
514
|
-
const bindingPackageVersion = require('@takumi-rs/core-openharmony-arm/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '1.0.0-beta.11' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.0-beta.11 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
|
-
}
|
|
518
|
-
return binding
|
|
519
|
-
} catch (e) {
|
|
520
|
-
loadErrors.push(e)
|
|
521
|
-
}
|
|
522
|
-
} else {
|
|
523
|
-
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
524
|
-
}
|
|
525
|
-
} else {
|
|
526
|
-
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
nativeBinding = requireNative()
|
|
531
|
-
|
|
532
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
533
|
-
let wasiBinding = null
|
|
534
|
-
let wasiBindingError = null
|
|
535
|
-
try {
|
|
536
|
-
wasiBinding = require('./core.wasi.cjs')
|
|
537
|
-
nativeBinding = wasiBinding
|
|
538
|
-
} catch (err) {
|
|
539
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
540
|
-
wasiBindingError = err
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
544
|
-
try {
|
|
545
|
-
wasiBinding = require('@takumi-rs/core-wasm32-wasi')
|
|
546
|
-
nativeBinding = wasiBinding
|
|
547
|
-
} catch (err) {
|
|
548
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
549
|
-
if (!wasiBindingError) {
|
|
550
|
-
wasiBindingError = err
|
|
551
|
-
} else {
|
|
552
|
-
wasiBindingError.cause = err
|
|
553
|
-
}
|
|
554
|
-
loadErrors.push(err)
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
559
|
-
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
560
|
-
error.cause = wasiBindingError
|
|
561
|
-
throw error
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
if (!nativeBinding) {
|
|
566
|
-
if (loadErrors.length > 0) {
|
|
567
|
-
throw new Error(
|
|
568
|
-
`Cannot find native binding. ` +
|
|
569
|
-
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
570
|
-
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
571
|
-
{
|
|
572
|
-
cause: loadErrors.reduce((err, cur) => {
|
|
573
|
-
cur.cause = err
|
|
574
|
-
return cur
|
|
575
|
-
}),
|
|
576
|
-
},
|
|
577
|
-
)
|
|
578
|
-
}
|
|
579
|
-
throw new Error(`Failed to load native binding`)
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const { Renderer, AnimationOutputFormat, DitheringAlgorithm, extractResourceUrls, OutputFormat } = nativeBinding
|
|
583
|
-
export { Renderer }
|
|
584
|
-
export { AnimationOutputFormat }
|
|
585
|
-
export { DitheringAlgorithm }
|
|
586
|
-
export { extractResourceUrls }
|
|
587
|
-
export { OutputFormat }
|