fuma-translate 1.0.0 → 1.0.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/dist/cli.mjs.map +1 -1
- package/native/native.d.ts +7 -0
- package/native/native.js +593 -0
- package/package.json +10 -10
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\nimport chokidar from \"chokidar\";\nimport { compile, StaticAnalysisError, typegen, type CompileOutput } from \"./compiler
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\nimport chokidar from \"chokidar\";\nimport { compile, StaticAnalysisError, typegen, type CompileOutput } from \"./compiler\";\n\nfunction writeManifest(output: CompileOutput): string {\n return `${JSON.stringify({ translationKeys: [...output.translationKeys].sort() }, null, 2)}\\n`;\n}\n\nconst HELP = `Usage: fuma-translate [options] <glob>...\n\nCompile translation keys from source files.\n\nArguments:\n <glob>... Glob patterns to scan (e.g. src/**/*.tsx)\n\nOptions:\n -o, --out <dir> Output directory (default: .translations)\n -w, --watch Recompile when matching files change\n --no-strict Extract all static t() calls, not only hook-bound ones\n -h, --help Show this help message\n`;\n\nexport interface CompileAndWriteOptions {\n input: string[];\n out: string;\n strict: boolean;\n}\n\nexport interface WatchOptions extends CompileAndWriteOptions {\n onCompiled?: (result: { ok: true; keyCount: number } | { ok: false; error: string }) => void;\n}\n\nexport function getWatchRoots(globs: string[]): string[] {\n const roots = new Set<string>();\n\n for (const pattern of globs) {\n const index = pattern.search(/[*?[{]/);\n const root =\n index === -1 ? dirname(pattern) : pattern.slice(0, index).replace(/[/\\\\]+$/, \"\") || \".\";\n\n roots.add(resolve(root));\n }\n\n return [...roots];\n}\n\nfunction debounce(fn: () => void, ms: number): () => void {\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n return () => {\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(fn, ms);\n };\n}\n\nexport async function compileAndWrite(\n options: CompileAndWriteOptions,\n): Promise<{ keyCount: number }> {\n const output = await compile({ input: options.input, strict: options.strict });\n const outDir = resolve(options.out);\n\n await mkdir(outDir, { recursive: true });\n await writeFile(join(outDir, \"manifest.json\"), writeManifest(output), \"utf8\");\n await writeFile(join(outDir, \"index.ts\"), typegen(output), \"utf8\");\n\n return { keyCount: output.translationKeys.length };\n}\n\nexport async function watchCompile(options: WatchOptions, signal?: AbortSignal): Promise<void> {\n const outDir = resolve(options.out);\n const roots = getWatchRoots(options.input);\n let compiling = false;\n let queued = false;\n\n const run = async () => {\n if (compiling) {\n queued = true;\n return;\n }\n\n compiling = true;\n\n try {\n const { keyCount } = await compileAndWrite(options);\n options.onCompiled?.({ ok: true, keyCount });\n } catch (error) {\n const message = error instanceof StaticAnalysisError ? error.message : String(error);\n\n process.stderr.write(`${message}\\n`);\n options.onCompiled?.({ ok: false, error: message });\n } finally {\n compiling = false;\n\n if (queued) {\n queued = false;\n void run();\n }\n }\n };\n\n const schedule = debounce(() => {\n void run();\n }, 100);\n\n const watcher = chokidar.watch(roots, {\n ignoreInitial: true,\n ignored: (path) => path.startsWith(outDir),\n awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 },\n });\n\n watcher.on(\"all\", schedule);\n\n if (signal) {\n if (signal.aborted) {\n await watcher.close();\n return;\n }\n\n signal.addEventListener(\n \"abort\",\n () => {\n void watcher.close();\n },\n { once: true },\n );\n }\n\n process.stdout.write(`Watching ${options.input.join(\", \")}...\\n`);\n await run();\n}\n\nexport async function main(argv: string[] = process.argv.slice(2)): Promise<number> {\n const { values, positionals } = parseArgs({\n args: argv,\n options: {\n out: { type: \"string\", short: \"o\", default: \".translations\" },\n watch: { type: \"boolean\", short: \"w\", default: false },\n strict: { type: \"boolean\", default: true },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n allowPositionals: true,\n });\n\n if (values.help) {\n process.stdout.write(HELP);\n return 0;\n }\n\n if (positionals.length === 0) {\n process.stderr.write(HELP);\n return 1;\n }\n\n const options: CompileAndWriteOptions = {\n input: positionals,\n out: values.out,\n strict: values.strict,\n };\n\n if (values.watch) {\n await watchCompile(options);\n return 0;\n }\n\n try {\n await compileAndWrite(options);\n return 0;\n } catch (error) {\n if (error instanceof StaticAnalysisError) {\n process.stderr.write(`${error.message}\\n`);\n return 1;\n }\n\n throw error;\n }\n}\n\nconst entry = process.argv[1] ? resolve(process.argv[1]) : \"\";\nconst isMain = entry === fileURLToPath(import.meta.url);\n\nif (isMain) {\n main().then((code) => {\n process.exitCode = code;\n });\n}\n"],"mappings":"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"}
|
package/native/native.js
ADDED
|
@@ -0,0 +1,593 @@
|
|
|
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('./fuma-translate.android-arm64.node')
|
|
78
|
+
} catch (e) {
|
|
79
|
+
loadErrors.push(e)
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const binding = require('@fuma-translate/binding-android-arm64')
|
|
83
|
+
const bindingPackageVersion = require('@fuma-translate/binding-android-arm64/package.json').version
|
|
84
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.android-arm-eabi.node')
|
|
94
|
+
} catch (e) {
|
|
95
|
+
loadErrors.push(e)
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const binding = require('@fuma-translate/binding-android-arm-eabi')
|
|
99
|
+
const bindingPackageVersion = require('@fuma-translate/binding-android-arm-eabi/package.json').version
|
|
100
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.win32-x64-gnu.node')
|
|
115
|
+
} catch (e) {
|
|
116
|
+
loadErrors.push(e)
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const binding = require('@fuma-translate/binding-win32-x64-gnu')
|
|
120
|
+
const bindingPackageVersion = require('@fuma-translate/binding-win32-x64-gnu/package.json').version
|
|
121
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.win32-x64-msvc.node')
|
|
131
|
+
} catch (e) {
|
|
132
|
+
loadErrors.push(e)
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const binding = require('@fuma-translate/binding-win32-x64-msvc')
|
|
136
|
+
const bindingPackageVersion = require('@fuma-translate/binding-win32-x64-msvc/package.json').version
|
|
137
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.win32-ia32-msvc.node')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadErrors.push(e)
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const binding = require('@fuma-translate/binding-win32-ia32-msvc')
|
|
153
|
+
const bindingPackageVersion = require('@fuma-translate/binding-win32-ia32-msvc/package.json').version
|
|
154
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.win32-arm64-msvc.node')
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const binding = require('@fuma-translate/binding-win32-arm64-msvc')
|
|
169
|
+
const bindingPackageVersion = require('@fuma-translate/binding-win32-arm64-msvc/package.json').version
|
|
170
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.darwin-universal.node')
|
|
183
|
+
} catch (e) {
|
|
184
|
+
loadErrors.push(e)
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const binding = require('@fuma-translate/binding-darwin-universal')
|
|
188
|
+
const bindingPackageVersion = require('@fuma-translate/binding-darwin-universal/package.json').version
|
|
189
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.darwin-x64.node')
|
|
199
|
+
} catch (e) {
|
|
200
|
+
loadErrors.push(e)
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const binding = require('@fuma-translate/binding-darwin-x64')
|
|
204
|
+
const bindingPackageVersion = require('@fuma-translate/binding-darwin-x64/package.json').version
|
|
205
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.darwin-arm64.node')
|
|
215
|
+
} catch (e) {
|
|
216
|
+
loadErrors.push(e)
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const binding = require('@fuma-translate/binding-darwin-arm64')
|
|
220
|
+
const bindingPackageVersion = require('@fuma-translate/binding-darwin-arm64/package.json').version
|
|
221
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.freebsd-x64.node')
|
|
235
|
+
} catch (e) {
|
|
236
|
+
loadErrors.push(e)
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
const binding = require('@fuma-translate/binding-freebsd-x64')
|
|
240
|
+
const bindingPackageVersion = require('@fuma-translate/binding-freebsd-x64/package.json').version
|
|
241
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.freebsd-arm64.node')
|
|
251
|
+
} catch (e) {
|
|
252
|
+
loadErrors.push(e)
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
const binding = require('@fuma-translate/binding-freebsd-arm64')
|
|
256
|
+
const bindingPackageVersion = require('@fuma-translate/binding-freebsd-arm64/package.json').version
|
|
257
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-x64-musl.node')
|
|
272
|
+
} catch (e) {
|
|
273
|
+
loadErrors.push(e)
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const binding = require('@fuma-translate/binding-linux-x64-musl')
|
|
277
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-x64-musl/package.json').version
|
|
278
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-x64-gnu.node')
|
|
288
|
+
} catch (e) {
|
|
289
|
+
loadErrors.push(e)
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
const binding = require('@fuma-translate/binding-linux-x64-gnu')
|
|
293
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-x64-gnu/package.json').version
|
|
294
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-arm64-musl.node')
|
|
306
|
+
} catch (e) {
|
|
307
|
+
loadErrors.push(e)
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
const binding = require('@fuma-translate/binding-linux-arm64-musl')
|
|
311
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-arm64-musl/package.json').version
|
|
312
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-arm64-gnu.node')
|
|
322
|
+
} catch (e) {
|
|
323
|
+
loadErrors.push(e)
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
const binding = require('@fuma-translate/binding-linux-arm64-gnu')
|
|
327
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-arm64-gnu/package.json').version
|
|
328
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-arm-musleabihf.node')
|
|
340
|
+
} catch (e) {
|
|
341
|
+
loadErrors.push(e)
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
const binding = require('@fuma-translate/binding-linux-arm-musleabihf')
|
|
345
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-arm-musleabihf/package.json').version
|
|
346
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-arm-gnueabihf.node')
|
|
356
|
+
} catch (e) {
|
|
357
|
+
loadErrors.push(e)
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
const binding = require('@fuma-translate/binding-linux-arm-gnueabihf')
|
|
361
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-arm-gnueabihf/package.json').version
|
|
362
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-loong64-musl.node')
|
|
374
|
+
} catch (e) {
|
|
375
|
+
loadErrors.push(e)
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
const binding = require('@fuma-translate/binding-linux-loong64-musl')
|
|
379
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-loong64-musl/package.json').version
|
|
380
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-loong64-gnu.node')
|
|
390
|
+
} catch (e) {
|
|
391
|
+
loadErrors.push(e)
|
|
392
|
+
}
|
|
393
|
+
try {
|
|
394
|
+
const binding = require('@fuma-translate/binding-linux-loong64-gnu')
|
|
395
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-loong64-gnu/package.json').version
|
|
396
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-riscv64-musl.node')
|
|
408
|
+
} catch (e) {
|
|
409
|
+
loadErrors.push(e)
|
|
410
|
+
}
|
|
411
|
+
try {
|
|
412
|
+
const binding = require('@fuma-translate/binding-linux-riscv64-musl')
|
|
413
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-riscv64-musl/package.json').version
|
|
414
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-riscv64-gnu.node')
|
|
424
|
+
} catch (e) {
|
|
425
|
+
loadErrors.push(e)
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
const binding = require('@fuma-translate/binding-linux-riscv64-gnu')
|
|
429
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-riscv64-gnu/package.json').version
|
|
430
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-ppc64-gnu.node')
|
|
441
|
+
} catch (e) {
|
|
442
|
+
loadErrors.push(e)
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
const binding = require('@fuma-translate/binding-linux-ppc64-gnu')
|
|
446
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-ppc64-gnu/package.json').version
|
|
447
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.linux-s390x-gnu.node')
|
|
457
|
+
} catch (e) {
|
|
458
|
+
loadErrors.push(e)
|
|
459
|
+
}
|
|
460
|
+
try {
|
|
461
|
+
const binding = require('@fuma-translate/binding-linux-s390x-gnu')
|
|
462
|
+
const bindingPackageVersion = require('@fuma-translate/binding-linux-s390x-gnu/package.json').version
|
|
463
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.openharmony-arm64.node')
|
|
477
|
+
} catch (e) {
|
|
478
|
+
loadErrors.push(e)
|
|
479
|
+
}
|
|
480
|
+
try {
|
|
481
|
+
const binding = require('@fuma-translate/binding-openharmony-arm64')
|
|
482
|
+
const bindingPackageVersion = require('@fuma-translate/binding-openharmony-arm64/package.json').version
|
|
483
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.openharmony-x64.node')
|
|
493
|
+
} catch (e) {
|
|
494
|
+
loadErrors.push(e)
|
|
495
|
+
}
|
|
496
|
+
try {
|
|
497
|
+
const binding = require('@fuma-translate/binding-openharmony-x64')
|
|
498
|
+
const bindingPackageVersion = require('@fuma-translate/binding-openharmony-x64/package.json').version
|
|
499
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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('./fuma-translate.openharmony-arm.node')
|
|
509
|
+
} catch (e) {
|
|
510
|
+
loadErrors.push(e)
|
|
511
|
+
}
|
|
512
|
+
try {
|
|
513
|
+
const binding = require('@fuma-translate/binding-openharmony-arm')
|
|
514
|
+
const bindingPackageVersion = require('@fuma-translate/binding-openharmony-arm/package.json').version
|
|
515
|
+
if (bindingPackageVersion !== '1.0.1' && 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.1 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
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
533
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
534
|
+
// 'true' → force WASI fallback even if native loaded
|
|
535
|
+
// 'error' → force WASI and throw if no WASI binding is found
|
|
536
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
537
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
538
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
539
|
+
const forceWasi =
|
|
540
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
541
|
+
|
|
542
|
+
if (!nativeBinding || forceWasi) {
|
|
543
|
+
let wasiBinding = null
|
|
544
|
+
let wasiBindingError = null
|
|
545
|
+
try {
|
|
546
|
+
wasiBinding = require('./fuma-translate.wasi.cjs')
|
|
547
|
+
nativeBinding = wasiBinding
|
|
548
|
+
} catch (err) {
|
|
549
|
+
if (forceWasi) {
|
|
550
|
+
wasiBindingError = err
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (!nativeBinding || forceWasi) {
|
|
554
|
+
try {
|
|
555
|
+
wasiBinding = require('@fuma-translate/binding-wasm32-wasi')
|
|
556
|
+
nativeBinding = wasiBinding
|
|
557
|
+
} catch (err) {
|
|
558
|
+
if (forceWasi) {
|
|
559
|
+
if (!wasiBindingError) {
|
|
560
|
+
wasiBindingError = err
|
|
561
|
+
} else {
|
|
562
|
+
wasiBindingError.cause = err
|
|
563
|
+
}
|
|
564
|
+
loadErrors.push(err)
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
569
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
570
|
+
error.cause = wasiBindingError
|
|
571
|
+
throw error
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
if (!nativeBinding) {
|
|
576
|
+
if (loadErrors.length > 0) {
|
|
577
|
+
throw new Error(
|
|
578
|
+
`Cannot find native binding. ` +
|
|
579
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
580
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
581
|
+
{
|
|
582
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
583
|
+
cur.cause = err
|
|
584
|
+
return cur
|
|
585
|
+
}),
|
|
586
|
+
},
|
|
587
|
+
)
|
|
588
|
+
}
|
|
589
|
+
throw new Error(`Failed to load native binding`)
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const { compileSync } = nativeBinding
|
|
593
|
+
export { compileSync }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fuma-translate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "The build-time package to implement multilingual in your JavaScript app",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fuma Nama",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
"node": ">=22"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
|
-
"@fuma-translate/binding-darwin-arm64": "1.0.
|
|
69
|
-
"@fuma-translate/binding-linux-arm64-gnu": "1.0.
|
|
70
|
-
"@fuma-translate/binding-linux-arm64-musl": "1.0.
|
|
71
|
-
"@fuma-translate/binding-win32-arm64-msvc": "1.0.
|
|
72
|
-
"@fuma-translate/binding-darwin-x64": "1.0.
|
|
73
|
-
"@fuma-translate/binding-linux-x64-gnu": "1.0.
|
|
74
|
-
"@fuma-translate/binding-linux-x64-musl": "1.0.
|
|
75
|
-
"@fuma-translate/binding-win32-x64-msvc": "1.0.
|
|
76
|
-
"@fuma-translate/binding-wasm32-wasi": "1.0.
|
|
68
|
+
"@fuma-translate/binding-darwin-arm64": "1.0.1",
|
|
69
|
+
"@fuma-translate/binding-linux-arm64-gnu": "1.0.1",
|
|
70
|
+
"@fuma-translate/binding-linux-arm64-musl": "1.0.1",
|
|
71
|
+
"@fuma-translate/binding-win32-arm64-msvc": "1.0.1",
|
|
72
|
+
"@fuma-translate/binding-darwin-x64": "1.0.1",
|
|
73
|
+
"@fuma-translate/binding-linux-x64-gnu": "1.0.1",
|
|
74
|
+
"@fuma-translate/binding-linux-x64-musl": "1.0.1",
|
|
75
|
+
"@fuma-translate/binding-win32-x64-msvc": "1.0.1",
|
|
76
|
+
"@fuma-translate/binding-wasm32-wasi": "1.0.1"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"types:check": "tsc --noEmit",
|