@fontmin-rs/binding 0.1.0-beta.1
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/LICENSE +21 -0
- package/package.json +62 -0
- package/src-js/bindings.js +832 -0
- package/src-js/index.d.ts +154 -0
- package/src-js/index.js +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-PRESENT ntnyq <https://github.com/ntnyq>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fontmin-rs/binding",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "Native binding for fontmin-rs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/fontmin-rs/fontmin-rs.git"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src-js",
|
|
12
|
+
"!src-js/*.node"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "src-js/index.js",
|
|
16
|
+
"types": "src-js/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./src-js/index.d.ts",
|
|
20
|
+
"default": "./src-js/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"vitest": "^4.1.10"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"@fontmin-rs/binding-darwin-arm64": "0.1.0-beta.1",
|
|
32
|
+
"@fontmin-rs/binding-darwin-x64": "0.1.0-beta.1",
|
|
33
|
+
"@fontmin-rs/binding-linux-arm64-gnu": "0.1.0-beta.1",
|
|
34
|
+
"@fontmin-rs/binding-linux-arm64-musl": "0.1.0-beta.1",
|
|
35
|
+
"@fontmin-rs/binding-linux-x64-gnu": "0.1.0-beta.1",
|
|
36
|
+
"@fontmin-rs/binding-linux-x64-musl": "0.1.0-beta.1",
|
|
37
|
+
"@fontmin-rs/binding-win32-arm64-msvc": "0.1.0-beta.1",
|
|
38
|
+
"@fontmin-rs/binding-win32-x64-msvc": "0.1.0-beta.1"
|
|
39
|
+
},
|
|
40
|
+
"napi": {
|
|
41
|
+
"binaryName": "fontmin_rs",
|
|
42
|
+
"packageName": "@fontmin-rs/binding",
|
|
43
|
+
"targets": [
|
|
44
|
+
"x86_64-apple-darwin",
|
|
45
|
+
"aarch64-apple-darwin",
|
|
46
|
+
"x86_64-pc-windows-msvc",
|
|
47
|
+
"aarch64-pc-windows-msvc",
|
|
48
|
+
"x86_64-unknown-linux-gnu",
|
|
49
|
+
"x86_64-unknown-linux-musl",
|
|
50
|
+
"aarch64-unknown-linux-gnu",
|
|
51
|
+
"aarch64-unknown-linux-musl"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"artifacts": "node ../../scripts/copy-native-artifacts.mjs",
|
|
56
|
+
"build": "napi build --esm --platform --js bindings.js --dts index.d.ts --output-dir src-js --release",
|
|
57
|
+
"build:debug": "napi build --esm --platform --js bindings.js --dts index.d.ts --output-dir src-js",
|
|
58
|
+
"build:npm-dir": "napi create-npm-dirs --npm-dir ../../npm && pnpm run artifacts",
|
|
59
|
+
"build:release": "pnpm run build",
|
|
60
|
+
"test": "vitest --dir tests"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
import { createRequire } from 'module'
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
const __dirname = new URL('.', import.meta.url).pathname
|
|
9
|
+
|
|
10
|
+
const { readFileSync } = require('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 (process.report && 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')
|
|
61
|
+
.execSync('ldd --version', { encoding: 'utf8' })
|
|
62
|
+
.includes('musl')
|
|
63
|
+
} catch (e) {
|
|
64
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function requireNative() {
|
|
70
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
71
|
+
try {
|
|
72
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
73
|
+
} catch (err) {
|
|
74
|
+
loadErrors.push(err)
|
|
75
|
+
}
|
|
76
|
+
} else if (process.platform === 'android') {
|
|
77
|
+
if (process.arch === 'arm64') {
|
|
78
|
+
try {
|
|
79
|
+
return require('./fontmin_rs.android-arm64.node')
|
|
80
|
+
} catch (e) {
|
|
81
|
+
loadErrors.push(e)
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const binding = require('@fontmin-rs/binding-android-arm64')
|
|
85
|
+
const bindingPackageVersion =
|
|
86
|
+
require('@fontmin-rs/binding-android-arm64/package.json').version
|
|
87
|
+
if (
|
|
88
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
89
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
90
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
91
|
+
) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
return binding
|
|
97
|
+
} catch (e) {
|
|
98
|
+
loadErrors.push(e)
|
|
99
|
+
}
|
|
100
|
+
} else if (process.arch === 'arm') {
|
|
101
|
+
try {
|
|
102
|
+
return require('./fontmin_rs.android-arm-eabi.node')
|
|
103
|
+
} catch (e) {
|
|
104
|
+
loadErrors.push(e)
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const binding = require('@fontmin-rs/binding-android-arm-eabi')
|
|
108
|
+
const bindingPackageVersion =
|
|
109
|
+
require('@fontmin-rs/binding-android-arm-eabi/package.json').version
|
|
110
|
+
if (
|
|
111
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
112
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
113
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
114
|
+
) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
return binding
|
|
120
|
+
} catch (e) {
|
|
121
|
+
loadErrors.push(e)
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
loadErrors.push(
|
|
125
|
+
new Error(`Unsupported architecture on Android ${process.arch}`),
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
} else if (process.platform === 'win32') {
|
|
129
|
+
if (process.arch === 'x64') {
|
|
130
|
+
if (
|
|
131
|
+
(process.config &&
|
|
132
|
+
process.config.variables &&
|
|
133
|
+
process.config.variables.shlib_suffix === 'dll.a') ||
|
|
134
|
+
(process.config &&
|
|
135
|
+
process.config.variables &&
|
|
136
|
+
process.config.variables.node_target_type === 'shared_library')
|
|
137
|
+
) {
|
|
138
|
+
try {
|
|
139
|
+
return require('./fontmin_rs.win32-x64-gnu.node')
|
|
140
|
+
} catch (e) {
|
|
141
|
+
loadErrors.push(e)
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const binding = require('@fontmin-rs/binding-win32-x64-gnu')
|
|
145
|
+
const bindingPackageVersion =
|
|
146
|
+
require('@fontmin-rs/binding-win32-x64-gnu/package.json').version
|
|
147
|
+
if (
|
|
148
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
149
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
150
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
151
|
+
) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
return binding
|
|
157
|
+
} catch (e) {
|
|
158
|
+
loadErrors.push(e)
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
try {
|
|
162
|
+
return require('./fontmin_rs.win32-x64-msvc.node')
|
|
163
|
+
} catch (e) {
|
|
164
|
+
loadErrors.push(e)
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const binding = require('@fontmin-rs/binding-win32-x64-msvc')
|
|
168
|
+
const bindingPackageVersion =
|
|
169
|
+
require('@fontmin-rs/binding-win32-x64-msvc/package.json').version
|
|
170
|
+
if (
|
|
171
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
172
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
173
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
174
|
+
) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
return binding
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadErrors.push(e)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} else if (process.arch === 'ia32') {
|
|
185
|
+
try {
|
|
186
|
+
return require('./fontmin_rs.win32-ia32-msvc.node')
|
|
187
|
+
} catch (e) {
|
|
188
|
+
loadErrors.push(e)
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const binding = require('@fontmin-rs/binding-win32-ia32-msvc')
|
|
192
|
+
const bindingPackageVersion =
|
|
193
|
+
require('@fontmin-rs/binding-win32-ia32-msvc/package.json').version
|
|
194
|
+
if (
|
|
195
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
196
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
197
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
198
|
+
) {
|
|
199
|
+
throw new Error(
|
|
200
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
return binding
|
|
204
|
+
} catch (e) {
|
|
205
|
+
loadErrors.push(e)
|
|
206
|
+
}
|
|
207
|
+
} else if (process.arch === 'arm64') {
|
|
208
|
+
try {
|
|
209
|
+
return require('./fontmin_rs.win32-arm64-msvc.node')
|
|
210
|
+
} catch (e) {
|
|
211
|
+
loadErrors.push(e)
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const binding = require('@fontmin-rs/binding-win32-arm64-msvc')
|
|
215
|
+
const bindingPackageVersion =
|
|
216
|
+
require('@fontmin-rs/binding-win32-arm64-msvc/package.json').version
|
|
217
|
+
if (
|
|
218
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
219
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
220
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
221
|
+
) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
return binding
|
|
227
|
+
} catch (e) {
|
|
228
|
+
loadErrors.push(e)
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
loadErrors.push(
|
|
232
|
+
new Error(`Unsupported architecture on Windows: ${process.arch}`),
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
} else if (process.platform === 'darwin') {
|
|
236
|
+
try {
|
|
237
|
+
return require('./fontmin_rs.darwin-universal.node')
|
|
238
|
+
} catch (e) {
|
|
239
|
+
loadErrors.push(e)
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
const binding = require('@fontmin-rs/binding-darwin-universal')
|
|
243
|
+
const bindingPackageVersion =
|
|
244
|
+
require('@fontmin-rs/binding-darwin-universal/package.json').version
|
|
245
|
+
if (
|
|
246
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
247
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
248
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
249
|
+
) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
return binding
|
|
255
|
+
} catch (e) {
|
|
256
|
+
loadErrors.push(e)
|
|
257
|
+
}
|
|
258
|
+
if (process.arch === 'x64') {
|
|
259
|
+
try {
|
|
260
|
+
return require('./fontmin_rs.darwin-x64.node')
|
|
261
|
+
} catch (e) {
|
|
262
|
+
loadErrors.push(e)
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
const binding = require('@fontmin-rs/binding-darwin-x64')
|
|
266
|
+
const bindingPackageVersion =
|
|
267
|
+
require('@fontmin-rs/binding-darwin-x64/package.json').version
|
|
268
|
+
if (
|
|
269
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
270
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
271
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
272
|
+
) {
|
|
273
|
+
throw new Error(
|
|
274
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
return binding
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
} else if (process.arch === 'arm64') {
|
|
282
|
+
try {
|
|
283
|
+
return require('./fontmin_rs.darwin-arm64.node')
|
|
284
|
+
} catch (e) {
|
|
285
|
+
loadErrors.push(e)
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
const binding = require('@fontmin-rs/binding-darwin-arm64')
|
|
289
|
+
const bindingPackageVersion =
|
|
290
|
+
require('@fontmin-rs/binding-darwin-arm64/package.json').version
|
|
291
|
+
if (
|
|
292
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
293
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
294
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
295
|
+
) {
|
|
296
|
+
throw new Error(
|
|
297
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
return binding
|
|
301
|
+
} catch (e) {
|
|
302
|
+
loadErrors.push(e)
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
loadErrors.push(
|
|
306
|
+
new Error(`Unsupported architecture on macOS: ${process.arch}`),
|
|
307
|
+
)
|
|
308
|
+
}
|
|
309
|
+
} else if (process.platform === 'freebsd') {
|
|
310
|
+
if (process.arch === 'x64') {
|
|
311
|
+
try {
|
|
312
|
+
return require('./fontmin_rs.freebsd-x64.node')
|
|
313
|
+
} catch (e) {
|
|
314
|
+
loadErrors.push(e)
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
const binding = require('@fontmin-rs/binding-freebsd-x64')
|
|
318
|
+
const bindingPackageVersion =
|
|
319
|
+
require('@fontmin-rs/binding-freebsd-x64/package.json').version
|
|
320
|
+
if (
|
|
321
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
322
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
323
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
324
|
+
) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
return binding
|
|
330
|
+
} catch (e) {
|
|
331
|
+
loadErrors.push(e)
|
|
332
|
+
}
|
|
333
|
+
} else if (process.arch === 'arm64') {
|
|
334
|
+
try {
|
|
335
|
+
return require('./fontmin_rs.freebsd-arm64.node')
|
|
336
|
+
} catch (e) {
|
|
337
|
+
loadErrors.push(e)
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
const binding = require('@fontmin-rs/binding-freebsd-arm64')
|
|
341
|
+
const bindingPackageVersion =
|
|
342
|
+
require('@fontmin-rs/binding-freebsd-arm64/package.json').version
|
|
343
|
+
if (
|
|
344
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
345
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
346
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
347
|
+
) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
return binding
|
|
353
|
+
} catch (e) {
|
|
354
|
+
loadErrors.push(e)
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
loadErrors.push(
|
|
358
|
+
new Error(`Unsupported architecture on FreeBSD: ${process.arch}`),
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
} else if (process.platform === 'linux') {
|
|
362
|
+
if (process.arch === 'x64') {
|
|
363
|
+
if (isMusl()) {
|
|
364
|
+
try {
|
|
365
|
+
return require('./fontmin_rs.linux-x64-musl.node')
|
|
366
|
+
} catch (e) {
|
|
367
|
+
loadErrors.push(e)
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
const binding = require('@fontmin-rs/binding-linux-x64-musl')
|
|
371
|
+
const bindingPackageVersion =
|
|
372
|
+
require('@fontmin-rs/binding-linux-x64-musl/package.json').version
|
|
373
|
+
if (
|
|
374
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
375
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
376
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
377
|
+
) {
|
|
378
|
+
throw new Error(
|
|
379
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
380
|
+
)
|
|
381
|
+
}
|
|
382
|
+
return binding
|
|
383
|
+
} catch (e) {
|
|
384
|
+
loadErrors.push(e)
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
try {
|
|
388
|
+
return require('./fontmin_rs.linux-x64-gnu.node')
|
|
389
|
+
} catch (e) {
|
|
390
|
+
loadErrors.push(e)
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const binding = require('@fontmin-rs/binding-linux-x64-gnu')
|
|
394
|
+
const bindingPackageVersion =
|
|
395
|
+
require('@fontmin-rs/binding-linux-x64-gnu/package.json').version
|
|
396
|
+
if (
|
|
397
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
398
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
399
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
400
|
+
) {
|
|
401
|
+
throw new Error(
|
|
402
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
return binding
|
|
406
|
+
} catch (e) {
|
|
407
|
+
loadErrors.push(e)
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
} else if (process.arch === 'arm64') {
|
|
411
|
+
if (isMusl()) {
|
|
412
|
+
try {
|
|
413
|
+
return require('./fontmin_rs.linux-arm64-musl.node')
|
|
414
|
+
} catch (e) {
|
|
415
|
+
loadErrors.push(e)
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
const binding = require('@fontmin-rs/binding-linux-arm64-musl')
|
|
419
|
+
const bindingPackageVersion =
|
|
420
|
+
require('@fontmin-rs/binding-linux-arm64-musl/package.json').version
|
|
421
|
+
if (
|
|
422
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
423
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
424
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
425
|
+
) {
|
|
426
|
+
throw new Error(
|
|
427
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
428
|
+
)
|
|
429
|
+
}
|
|
430
|
+
return binding
|
|
431
|
+
} catch (e) {
|
|
432
|
+
loadErrors.push(e)
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
try {
|
|
436
|
+
return require('./fontmin_rs.linux-arm64-gnu.node')
|
|
437
|
+
} catch (e) {
|
|
438
|
+
loadErrors.push(e)
|
|
439
|
+
}
|
|
440
|
+
try {
|
|
441
|
+
const binding = require('@fontmin-rs/binding-linux-arm64-gnu')
|
|
442
|
+
const bindingPackageVersion =
|
|
443
|
+
require('@fontmin-rs/binding-linux-arm64-gnu/package.json').version
|
|
444
|
+
if (
|
|
445
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
446
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
447
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
448
|
+
) {
|
|
449
|
+
throw new Error(
|
|
450
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
return binding
|
|
454
|
+
} catch (e) {
|
|
455
|
+
loadErrors.push(e)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} else if (process.arch === 'arm') {
|
|
459
|
+
if (isMusl()) {
|
|
460
|
+
try {
|
|
461
|
+
return require('./fontmin_rs.linux-arm-musleabihf.node')
|
|
462
|
+
} catch (e) {
|
|
463
|
+
loadErrors.push(e)
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
const binding = require('@fontmin-rs/binding-linux-arm-musleabihf')
|
|
467
|
+
const bindingPackageVersion =
|
|
468
|
+
require('@fontmin-rs/binding-linux-arm-musleabihf/package.json').version
|
|
469
|
+
if (
|
|
470
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
471
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
472
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
473
|
+
) {
|
|
474
|
+
throw new Error(
|
|
475
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
476
|
+
)
|
|
477
|
+
}
|
|
478
|
+
return binding
|
|
479
|
+
} catch (e) {
|
|
480
|
+
loadErrors.push(e)
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
try {
|
|
484
|
+
return require('./fontmin_rs.linux-arm-gnueabihf.node')
|
|
485
|
+
} catch (e) {
|
|
486
|
+
loadErrors.push(e)
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
const binding = require('@fontmin-rs/binding-linux-arm-gnueabihf')
|
|
490
|
+
const bindingPackageVersion =
|
|
491
|
+
require('@fontmin-rs/binding-linux-arm-gnueabihf/package.json').version
|
|
492
|
+
if (
|
|
493
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
494
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
495
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
496
|
+
) {
|
|
497
|
+
throw new Error(
|
|
498
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
499
|
+
)
|
|
500
|
+
}
|
|
501
|
+
return binding
|
|
502
|
+
} catch (e) {
|
|
503
|
+
loadErrors.push(e)
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
} else if (process.arch === 'loong64') {
|
|
507
|
+
if (isMusl()) {
|
|
508
|
+
try {
|
|
509
|
+
return require('./fontmin_rs.linux-loong64-musl.node')
|
|
510
|
+
} catch (e) {
|
|
511
|
+
loadErrors.push(e)
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
const binding = require('@fontmin-rs/binding-linux-loong64-musl')
|
|
515
|
+
const bindingPackageVersion =
|
|
516
|
+
require('@fontmin-rs/binding-linux-loong64-musl/package.json').version
|
|
517
|
+
if (
|
|
518
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
519
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
520
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
521
|
+
) {
|
|
522
|
+
throw new Error(
|
|
523
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
524
|
+
)
|
|
525
|
+
}
|
|
526
|
+
return binding
|
|
527
|
+
} catch (e) {
|
|
528
|
+
loadErrors.push(e)
|
|
529
|
+
}
|
|
530
|
+
} else {
|
|
531
|
+
try {
|
|
532
|
+
return require('./fontmin_rs.linux-loong64-gnu.node')
|
|
533
|
+
} catch (e) {
|
|
534
|
+
loadErrors.push(e)
|
|
535
|
+
}
|
|
536
|
+
try {
|
|
537
|
+
const binding = require('@fontmin-rs/binding-linux-loong64-gnu')
|
|
538
|
+
const bindingPackageVersion =
|
|
539
|
+
require('@fontmin-rs/binding-linux-loong64-gnu/package.json').version
|
|
540
|
+
if (
|
|
541
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
542
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
543
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
544
|
+
) {
|
|
545
|
+
throw new Error(
|
|
546
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
547
|
+
)
|
|
548
|
+
}
|
|
549
|
+
return binding
|
|
550
|
+
} catch (e) {
|
|
551
|
+
loadErrors.push(e)
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
} else if (process.arch === 'riscv64') {
|
|
555
|
+
if (isMusl()) {
|
|
556
|
+
try {
|
|
557
|
+
return require('./fontmin_rs.linux-riscv64-musl.node')
|
|
558
|
+
} catch (e) {
|
|
559
|
+
loadErrors.push(e)
|
|
560
|
+
}
|
|
561
|
+
try {
|
|
562
|
+
const binding = require('@fontmin-rs/binding-linux-riscv64-musl')
|
|
563
|
+
const bindingPackageVersion =
|
|
564
|
+
require('@fontmin-rs/binding-linux-riscv64-musl/package.json').version
|
|
565
|
+
if (
|
|
566
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
567
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
568
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
569
|
+
) {
|
|
570
|
+
throw new Error(
|
|
571
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
return binding
|
|
575
|
+
} catch (e) {
|
|
576
|
+
loadErrors.push(e)
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
try {
|
|
580
|
+
return require('./fontmin_rs.linux-riscv64-gnu.node')
|
|
581
|
+
} catch (e) {
|
|
582
|
+
loadErrors.push(e)
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
const binding = require('@fontmin-rs/binding-linux-riscv64-gnu')
|
|
586
|
+
const bindingPackageVersion =
|
|
587
|
+
require('@fontmin-rs/binding-linux-riscv64-gnu/package.json').version
|
|
588
|
+
if (
|
|
589
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
590
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
591
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
592
|
+
) {
|
|
593
|
+
throw new Error(
|
|
594
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
595
|
+
)
|
|
596
|
+
}
|
|
597
|
+
return binding
|
|
598
|
+
} catch (e) {
|
|
599
|
+
loadErrors.push(e)
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
} else if (process.arch === 'ppc64') {
|
|
603
|
+
try {
|
|
604
|
+
return require('./fontmin_rs.linux-ppc64-gnu.node')
|
|
605
|
+
} catch (e) {
|
|
606
|
+
loadErrors.push(e)
|
|
607
|
+
}
|
|
608
|
+
try {
|
|
609
|
+
const binding = require('@fontmin-rs/binding-linux-ppc64-gnu')
|
|
610
|
+
const bindingPackageVersion =
|
|
611
|
+
require('@fontmin-rs/binding-linux-ppc64-gnu/package.json').version
|
|
612
|
+
if (
|
|
613
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
614
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
615
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
616
|
+
) {
|
|
617
|
+
throw new Error(
|
|
618
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
619
|
+
)
|
|
620
|
+
}
|
|
621
|
+
return binding
|
|
622
|
+
} catch (e) {
|
|
623
|
+
loadErrors.push(e)
|
|
624
|
+
}
|
|
625
|
+
} else if (process.arch === 's390x') {
|
|
626
|
+
try {
|
|
627
|
+
return require('./fontmin_rs.linux-s390x-gnu.node')
|
|
628
|
+
} catch (e) {
|
|
629
|
+
loadErrors.push(e)
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
const binding = require('@fontmin-rs/binding-linux-s390x-gnu')
|
|
633
|
+
const bindingPackageVersion =
|
|
634
|
+
require('@fontmin-rs/binding-linux-s390x-gnu/package.json').version
|
|
635
|
+
if (
|
|
636
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
637
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
638
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
639
|
+
) {
|
|
640
|
+
throw new Error(
|
|
641
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
642
|
+
)
|
|
643
|
+
}
|
|
644
|
+
return binding
|
|
645
|
+
} catch (e) {
|
|
646
|
+
loadErrors.push(e)
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
loadErrors.push(
|
|
650
|
+
new Error(`Unsupported architecture on Linux: ${process.arch}`),
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
} else if (process.platform === 'openharmony') {
|
|
654
|
+
if (process.arch === 'arm64') {
|
|
655
|
+
try {
|
|
656
|
+
return require('./fontmin_rs.openharmony-arm64.node')
|
|
657
|
+
} catch (e) {
|
|
658
|
+
loadErrors.push(e)
|
|
659
|
+
}
|
|
660
|
+
try {
|
|
661
|
+
const binding = require('@fontmin-rs/binding-openharmony-arm64')
|
|
662
|
+
const bindingPackageVersion =
|
|
663
|
+
require('@fontmin-rs/binding-openharmony-arm64/package.json').version
|
|
664
|
+
if (
|
|
665
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
666
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
667
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
668
|
+
) {
|
|
669
|
+
throw new Error(
|
|
670
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
671
|
+
)
|
|
672
|
+
}
|
|
673
|
+
return binding
|
|
674
|
+
} catch (e) {
|
|
675
|
+
loadErrors.push(e)
|
|
676
|
+
}
|
|
677
|
+
} else if (process.arch === 'x64') {
|
|
678
|
+
try {
|
|
679
|
+
return require('./fontmin_rs.openharmony-x64.node')
|
|
680
|
+
} catch (e) {
|
|
681
|
+
loadErrors.push(e)
|
|
682
|
+
}
|
|
683
|
+
try {
|
|
684
|
+
const binding = require('@fontmin-rs/binding-openharmony-x64')
|
|
685
|
+
const bindingPackageVersion =
|
|
686
|
+
require('@fontmin-rs/binding-openharmony-x64/package.json').version
|
|
687
|
+
if (
|
|
688
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
689
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
690
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
691
|
+
) {
|
|
692
|
+
throw new Error(
|
|
693
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
694
|
+
)
|
|
695
|
+
}
|
|
696
|
+
return binding
|
|
697
|
+
} catch (e) {
|
|
698
|
+
loadErrors.push(e)
|
|
699
|
+
}
|
|
700
|
+
} else if (process.arch === 'arm') {
|
|
701
|
+
try {
|
|
702
|
+
return require('./fontmin_rs.openharmony-arm.node')
|
|
703
|
+
} catch (e) {
|
|
704
|
+
loadErrors.push(e)
|
|
705
|
+
}
|
|
706
|
+
try {
|
|
707
|
+
const binding = require('@fontmin-rs/binding-openharmony-arm')
|
|
708
|
+
const bindingPackageVersion =
|
|
709
|
+
require('@fontmin-rs/binding-openharmony-arm/package.json').version
|
|
710
|
+
if (
|
|
711
|
+
bindingPackageVersion !== '0.1.0-beta.1' &&
|
|
712
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
713
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
714
|
+
) {
|
|
715
|
+
throw new Error(
|
|
716
|
+
`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
717
|
+
)
|
|
718
|
+
}
|
|
719
|
+
return binding
|
|
720
|
+
} catch (e) {
|
|
721
|
+
loadErrors.push(e)
|
|
722
|
+
}
|
|
723
|
+
} else {
|
|
724
|
+
loadErrors.push(
|
|
725
|
+
new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`),
|
|
726
|
+
)
|
|
727
|
+
}
|
|
728
|
+
} else {
|
|
729
|
+
loadErrors.push(
|
|
730
|
+
new Error(
|
|
731
|
+
`Unsupported OS: ${process.platform}, architecture: ${process.arch}`,
|
|
732
|
+
),
|
|
733
|
+
)
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
nativeBinding = requireNative()
|
|
738
|
+
|
|
739
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
740
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
741
|
+
// 'true' → force WASI fallback even if native loaded
|
|
742
|
+
// 'error' → force WASI and throw if no WASI binding is found
|
|
743
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
744
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
745
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
746
|
+
const forceWasi =
|
|
747
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
748
|
+
process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
749
|
+
|
|
750
|
+
if (!nativeBinding || forceWasi) {
|
|
751
|
+
let wasiBinding = null
|
|
752
|
+
let wasiBindingError = null
|
|
753
|
+
try {
|
|
754
|
+
wasiBinding = require('./fontmin_rs.wasi.cjs')
|
|
755
|
+
nativeBinding = wasiBinding
|
|
756
|
+
} catch (err) {
|
|
757
|
+
if (forceWasi) {
|
|
758
|
+
wasiBindingError = err
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (!nativeBinding || forceWasi) {
|
|
762
|
+
try {
|
|
763
|
+
wasiBinding = require('@fontmin-rs/binding-wasm32-wasi')
|
|
764
|
+
nativeBinding = wasiBinding
|
|
765
|
+
} catch (err) {
|
|
766
|
+
if (forceWasi) {
|
|
767
|
+
if (!wasiBindingError) {
|
|
768
|
+
wasiBindingError = err
|
|
769
|
+
} else {
|
|
770
|
+
wasiBindingError.cause = err
|
|
771
|
+
}
|
|
772
|
+
loadErrors.push(err)
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
777
|
+
const error = new Error(
|
|
778
|
+
'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
779
|
+
)
|
|
780
|
+
error.cause = wasiBindingError
|
|
781
|
+
throw error
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (!nativeBinding) {
|
|
786
|
+
if (loadErrors.length > 0) {
|
|
787
|
+
const error = new Error(
|
|
788
|
+
`Cannot find native binding. ` +
|
|
789
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
790
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
791
|
+
)
|
|
792
|
+
// assign instead of the `new Error(message, { cause })` options form,
|
|
793
|
+
// which Node < 16.9 silently ignores
|
|
794
|
+
error.cause = loadErrors.reduce((err, cur) => {
|
|
795
|
+
cur.cause = err
|
|
796
|
+
return cur
|
|
797
|
+
})
|
|
798
|
+
throw error
|
|
799
|
+
}
|
|
800
|
+
throw new Error(`Failed to load native binding`)
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
const {
|
|
804
|
+
eotToTtf,
|
|
805
|
+
generateFontFaceCss,
|
|
806
|
+
inspectFont,
|
|
807
|
+
otfToTtf,
|
|
808
|
+
subsetTtf,
|
|
809
|
+
svgFontToTtf,
|
|
810
|
+
svgsToTtf,
|
|
811
|
+
ttfToEot,
|
|
812
|
+
ttfToSvg,
|
|
813
|
+
ttfToWoff,
|
|
814
|
+
ttfToWoff2,
|
|
815
|
+
validateWoff2,
|
|
816
|
+
woff2ToTtf,
|
|
817
|
+
woffToTtf,
|
|
818
|
+
} = nativeBinding
|
|
819
|
+
export { eotToTtf }
|
|
820
|
+
export { generateFontFaceCss }
|
|
821
|
+
export { inspectFont }
|
|
822
|
+
export { otfToTtf }
|
|
823
|
+
export { subsetTtf }
|
|
824
|
+
export { svgFontToTtf }
|
|
825
|
+
export { svgsToTtf }
|
|
826
|
+
export { ttfToEot }
|
|
827
|
+
export { ttfToSvg }
|
|
828
|
+
export { ttfToWoff }
|
|
829
|
+
export { ttfToWoff2 }
|
|
830
|
+
export { validateWoff2 }
|
|
831
|
+
export { woff2ToTtf }
|
|
832
|
+
export { woffToTtf }
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare function eotToTtf(input: Buffer): Buffer
|
|
4
|
+
|
|
5
|
+
export declare function generateFontFaceCss(
|
|
6
|
+
sources: Array<JsCssFontSource>,
|
|
7
|
+
options?: JsCssOptions | undefined | null,
|
|
8
|
+
): string
|
|
9
|
+
|
|
10
|
+
export declare function inspectFont(input: Buffer): JsFontInfo
|
|
11
|
+
|
|
12
|
+
export interface JsCssFontSource {
|
|
13
|
+
fileName: string
|
|
14
|
+
format: string
|
|
15
|
+
contents?: Buffer
|
|
16
|
+
glyphs?: Array<JsCssGlyph>
|
|
17
|
+
unicodeRanges?: Array<string>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface JsCssGlyph {
|
|
21
|
+
name?: string
|
|
22
|
+
unicode: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface JsCssOptions {
|
|
26
|
+
fontFamily?: string
|
|
27
|
+
fontPath?: string
|
|
28
|
+
base64?: boolean
|
|
29
|
+
glyph?: boolean
|
|
30
|
+
iconPrefix?: string
|
|
31
|
+
asFileName?: boolean
|
|
32
|
+
local?: boolean
|
|
33
|
+
fontDisplay?: string
|
|
34
|
+
target?: string
|
|
35
|
+
unicodeRanges?: Array<string>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface JsEotOptions {
|
|
39
|
+
version?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface JsFontInfo {
|
|
43
|
+
format: string
|
|
44
|
+
size: number
|
|
45
|
+
metadata: JsFontMetadata
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface JsFontMetadata {
|
|
49
|
+
familyName?: string
|
|
50
|
+
subfamilyName?: string
|
|
51
|
+
fullName?: string
|
|
52
|
+
postScriptName?: string
|
|
53
|
+
glyphCount: number
|
|
54
|
+
unitsPerEm: number
|
|
55
|
+
ascender: number
|
|
56
|
+
descender: number
|
|
57
|
+
tables: Array<string>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface JsOtf2TtfOptions {
|
|
61
|
+
preserveHinting?: boolean
|
|
62
|
+
variationCoordinates?: Record<string, number>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface JsSubsetOptions {
|
|
66
|
+
text?: string
|
|
67
|
+
unicodes?: Array<number>
|
|
68
|
+
unicodeRanges?: Array<string>
|
|
69
|
+
basicText?: boolean
|
|
70
|
+
preserveHinting?: boolean
|
|
71
|
+
trim?: boolean
|
|
72
|
+
keepNotdef?: boolean
|
|
73
|
+
keepLayout?: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface JsSvg2TtfOptions {
|
|
77
|
+
normalize?: boolean
|
|
78
|
+
hinting?: boolean
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface JsSvgIcon {
|
|
82
|
+
name: string
|
|
83
|
+
contents: string
|
|
84
|
+
unicode?: number
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface JsSvgOptions {
|
|
88
|
+
fontFamily?: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface JsSvgs2TtfOptions {
|
|
92
|
+
fontName?: string
|
|
93
|
+
startUnicode?: number
|
|
94
|
+
ascent?: number
|
|
95
|
+
descent?: number
|
|
96
|
+
normalize?: boolean
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface JsWoff2Options {
|
|
100
|
+
quality?: number
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface JsWoffOptions {
|
|
104
|
+
deflate?: boolean
|
|
105
|
+
compressionLevel?: number
|
|
106
|
+
metadata?: string
|
|
107
|
+
privateData?: Buffer
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare function otfToTtf(
|
|
111
|
+
input: Buffer,
|
|
112
|
+
options?: JsOtf2TtfOptions | undefined | null,
|
|
113
|
+
): Buffer
|
|
114
|
+
|
|
115
|
+
export declare function subsetTtf(
|
|
116
|
+
input: Buffer,
|
|
117
|
+
options?: JsSubsetOptions | undefined | null,
|
|
118
|
+
): Buffer
|
|
119
|
+
|
|
120
|
+
export declare function svgFontToTtf(
|
|
121
|
+
input: string,
|
|
122
|
+
options?: JsSvg2TtfOptions | undefined | null,
|
|
123
|
+
): Buffer
|
|
124
|
+
|
|
125
|
+
export declare function svgsToTtf(
|
|
126
|
+
inputs: Array<JsSvgIcon>,
|
|
127
|
+
options?: JsSvgs2TtfOptions | undefined | null,
|
|
128
|
+
): Buffer
|
|
129
|
+
|
|
130
|
+
export declare function ttfToEot(
|
|
131
|
+
input: Buffer,
|
|
132
|
+
options?: JsEotOptions | undefined | null,
|
|
133
|
+
): Buffer
|
|
134
|
+
|
|
135
|
+
export declare function ttfToSvg(
|
|
136
|
+
input: Buffer,
|
|
137
|
+
options?: JsSvgOptions | undefined | null,
|
|
138
|
+
): string
|
|
139
|
+
|
|
140
|
+
export declare function ttfToWoff(
|
|
141
|
+
input: Buffer,
|
|
142
|
+
options?: JsWoffOptions | undefined | null,
|
|
143
|
+
): Buffer
|
|
144
|
+
|
|
145
|
+
export declare function ttfToWoff2(
|
|
146
|
+
input: Buffer,
|
|
147
|
+
options?: JsWoff2Options | undefined | null,
|
|
148
|
+
): Buffer
|
|
149
|
+
|
|
150
|
+
export declare function validateWoff2(input: Buffer): void
|
|
151
|
+
|
|
152
|
+
export declare function woff2ToTtf(input: Buffer): Buffer
|
|
153
|
+
|
|
154
|
+
export declare function woffToTtf(input: Buffer): Buffer
|
package/src-js/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'
|
|
2
|
+
|
|
3
|
+
const require = createRequire(import.meta.url)
|
|
4
|
+
const binding = require('./bindings.js')
|
|
5
|
+
|
|
6
|
+
export const {
|
|
7
|
+
eotToTtf,
|
|
8
|
+
generateFontFaceCss,
|
|
9
|
+
inspectFont,
|
|
10
|
+
otfToTtf,
|
|
11
|
+
subsetTtf,
|
|
12
|
+
svgFontToTtf,
|
|
13
|
+
svgsToTtf,
|
|
14
|
+
ttfToEot,
|
|
15
|
+
ttfToSvg,
|
|
16
|
+
ttfToWoff,
|
|
17
|
+
ttfToWoff2,
|
|
18
|
+
validateWoff2,
|
|
19
|
+
woff2ToTtf,
|
|
20
|
+
woffToTtf,
|
|
21
|
+
} = binding
|