@voltkit/volt-native 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +207 -0
- package/index.js +610 -0
- package/loader/musl.js +60 -0
- package/loader/native-loader-helpers.js +55 -0
- package/loader/native-loader-targets.js +184 -0
- package/loader/native-loader.js +32 -0
- package/loader/wasi-loader.js +43 -0
- package/package.json +37 -0
- package/volt-native.linux-x64-gnu.node +0 -0
- package/volt-native.win32-x64-msvc.node +0 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** JavaScript-facing application class. */
|
|
4
|
+
export declare class VoltApp {
|
|
5
|
+
/** Create a new VoltApp from a JSON configuration object. */
|
|
6
|
+
constructor(config: any)
|
|
7
|
+
/** Queue a window for creation. The window will be created when `run()` is called. */
|
|
8
|
+
createWindow(config: any): void
|
|
9
|
+
/** Register an event callback. The callback receives a JSON string with event details. */
|
|
10
|
+
onEvent(callback: ((err: Error | null, arg: string) => any)): void
|
|
11
|
+
/**
|
|
12
|
+
* Run the application event loop runtime.
|
|
13
|
+
*
|
|
14
|
+
* On non-macOS platforms this starts a split runtime:
|
|
15
|
+
* - native loop on a dedicated thread
|
|
16
|
+
* - Node bridge callback dispatch on a dedicated thread
|
|
17
|
+
*
|
|
18
|
+
* On macOS, tao/wry main-thread requirements keep the native loop on the
|
|
19
|
+
* current thread.
|
|
20
|
+
*/
|
|
21
|
+
run(): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** JavaScript-facing global shortcut manager. */
|
|
25
|
+
export declare class VoltGlobalShortcut {
|
|
26
|
+
/** Create a new global shortcut manager. */
|
|
27
|
+
constructor()
|
|
28
|
+
/**
|
|
29
|
+
* Register a global shortcut with an accelerator string (e.g., "CmdOrCtrl+Shift+P").
|
|
30
|
+
* The callback receives the accelerator string when triggered.
|
|
31
|
+
*/
|
|
32
|
+
register(accelerator: string, callback: ((err: Error | null, arg: string) => any)): void
|
|
33
|
+
/** Unregister a previously registered global shortcut. */
|
|
34
|
+
unregister(accelerator: string): void
|
|
35
|
+
/** Unregister all global shortcuts. */
|
|
36
|
+
unregisterAll(): void
|
|
37
|
+
/** Check if a shortcut is registered. */
|
|
38
|
+
isRegistered(accelerator: string): boolean
|
|
39
|
+
/** Get all registered accelerator strings. */
|
|
40
|
+
getRegistered(): Array<string>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** JavaScript-facing IPC handler registry. */
|
|
44
|
+
export declare class VoltIpc {
|
|
45
|
+
/** Create a new IPC handler registry. */
|
|
46
|
+
constructor()
|
|
47
|
+
/**
|
|
48
|
+
* Register an IPC handler. The callback receives JSON args string and should
|
|
49
|
+
* return a JSON result string.
|
|
50
|
+
*/
|
|
51
|
+
handle(channel: string, callback: ((err: Error | null, arg: string) => string)): void
|
|
52
|
+
/** Remove a registered IPC handler. */
|
|
53
|
+
removeHandler(channel: string): void
|
|
54
|
+
/** Process a raw IPC message from the WebView. Returns the response JSON string. */
|
|
55
|
+
processMessage(raw: string): string
|
|
56
|
+
/** Register a callback to receive event emission requests (for relaying to WebView). */
|
|
57
|
+
onEmit(callback: ((err: Error | null, arg: string) => any)): void
|
|
58
|
+
/**
|
|
59
|
+
* Emit an event to all registered WebView windows.
|
|
60
|
+
* Returns the JavaScript code to evaluate in the WebView.
|
|
61
|
+
*/
|
|
62
|
+
emitEvent(event: string, data: string): string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** JavaScript-facing menu builder. */
|
|
66
|
+
export declare class VoltMenu {
|
|
67
|
+
/** Create a new menu from a JSON template array. */
|
|
68
|
+
constructor(template: any)
|
|
69
|
+
/**
|
|
70
|
+
* Build and set this menu as the application menu bar.
|
|
71
|
+
* Must be called from the main thread (event loop context).
|
|
72
|
+
*/
|
|
73
|
+
setAsAppMenu(): void
|
|
74
|
+
/** Get the number of top-level menu items. */
|
|
75
|
+
itemCount(): number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** JavaScript-facing system tray class. */
|
|
79
|
+
export declare class VoltTray {
|
|
80
|
+
/** Create a new system tray icon from a JSON configuration. */
|
|
81
|
+
constructor(config: any)
|
|
82
|
+
/** Set the tray tooltip text. */
|
|
83
|
+
setTooltip(tooltip: string): void
|
|
84
|
+
/** Set the tray icon from an image file path. */
|
|
85
|
+
setIcon(iconPath: string): void
|
|
86
|
+
/** Set the tray visibility. */
|
|
87
|
+
setVisible(visible: boolean): void
|
|
88
|
+
/** Register a click callback. Receives a JSON string with event details. */
|
|
89
|
+
onClick(callback: ((err: Error | null, arg: string) => any)): void
|
|
90
|
+
/** Destroy the tray icon and clean up resources. */
|
|
91
|
+
destroy(): void
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Read an image from the system clipboard. */
|
|
95
|
+
export declare function clipboardReadImage(): VoltImageData
|
|
96
|
+
|
|
97
|
+
/** Read text from the system clipboard. */
|
|
98
|
+
export declare function clipboardReadText(): string
|
|
99
|
+
|
|
100
|
+
/** Write an image to the system clipboard. */
|
|
101
|
+
export declare function clipboardWriteImage(data: VoltImageData): void
|
|
102
|
+
|
|
103
|
+
/** Write text to the system clipboard. */
|
|
104
|
+
export declare function clipboardWriteText(text: string): void
|
|
105
|
+
|
|
106
|
+
/** Show a message dialog. Returns true if user confirmed, false otherwise. */
|
|
107
|
+
export declare function dialogShowMessage(options: any): boolean
|
|
108
|
+
|
|
109
|
+
/** Show an open file/folder dialog. Returns selected paths, or empty array if cancelled. */
|
|
110
|
+
export declare function dialogShowOpen(options: any): Array<string>
|
|
111
|
+
|
|
112
|
+
/** Show a save file dialog. Returns the selected path, or null if cancelled. */
|
|
113
|
+
export declare function dialogShowSave(options: any): string | null
|
|
114
|
+
|
|
115
|
+
/** Create a directory (and parents). Path is relative to the base scope directory. */
|
|
116
|
+
export declare function fsMkdir(baseDir: string, path: string): void
|
|
117
|
+
|
|
118
|
+
/** List entries in a directory. Path is relative to the base scope directory. */
|
|
119
|
+
export declare function fsReadDir(baseDir: string, path: string): Array<string>
|
|
120
|
+
|
|
121
|
+
/** Read a file as raw bytes. Path is relative to the base scope directory. */
|
|
122
|
+
export declare function fsReadFile(baseDir: string, path: string): Buffer
|
|
123
|
+
|
|
124
|
+
/** Read a file as a UTF-8 string. Path is relative to the base scope directory. */
|
|
125
|
+
export declare function fsReadFileText(baseDir: string, path: string): string
|
|
126
|
+
|
|
127
|
+
/** Remove a file or directory. Path is relative to the base scope directory. */
|
|
128
|
+
export declare function fsRemove(baseDir: string, path: string): void
|
|
129
|
+
|
|
130
|
+
/** Get file/directory metadata. Path is relative to the base scope directory. */
|
|
131
|
+
export declare function fsStat(baseDir: string, path: string): VoltFileInfo
|
|
132
|
+
|
|
133
|
+
/** Write data to a file. Path is relative to the base scope directory. */
|
|
134
|
+
export declare function fsWriteFile(baseDir: string, path: string, data: Buffer): void
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Show a native OS notification.
|
|
138
|
+
* Accepts a JSON object with `title` (required), `body` (optional), and `icon` (optional).
|
|
139
|
+
*/
|
|
140
|
+
export declare function notificationShow(options: any): void
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Open a URL in the default system application.
|
|
144
|
+
* Only http, https, and mailto schemes are allowed.
|
|
145
|
+
*/
|
|
146
|
+
export declare function shellOpenExternal(url: string): void
|
|
147
|
+
|
|
148
|
+
/** Apply a downloaded update by replacing the current binary. */
|
|
149
|
+
export declare function updaterApply(data: Buffer): void
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Check for available updates.
|
|
153
|
+
* Returns update info if available, or null if up to date.
|
|
154
|
+
*/
|
|
155
|
+
export declare function updaterCheck(config: any): Promise<any | null>
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Download an update and verify its SHA-256 checksum and Ed25519 signature.
|
|
159
|
+
* Returns the verified binary data as a Buffer.
|
|
160
|
+
*/
|
|
161
|
+
export declare function updaterDownloadAndVerify(config: any, info: any): Promise<Buffer>
|
|
162
|
+
|
|
163
|
+
/** File metadata returned by fs_stat. */
|
|
164
|
+
export interface VoltFileInfo {
|
|
165
|
+
/** File size in bytes. */
|
|
166
|
+
size: number
|
|
167
|
+
/** Whether the path is a file. */
|
|
168
|
+
isFile: boolean
|
|
169
|
+
/** Whether the path is a directory. */
|
|
170
|
+
isDir: boolean
|
|
171
|
+
/** Whether the file is read-only. */
|
|
172
|
+
readonly: boolean
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Image data returned from clipboard operations. */
|
|
176
|
+
export interface VoltImageData {
|
|
177
|
+
/** Raw RGBA pixel data. */
|
|
178
|
+
rgba: Buffer
|
|
179
|
+
/** Image width in pixels. */
|
|
180
|
+
width: number
|
|
181
|
+
/** Image height in pixels. */
|
|
182
|
+
height: number
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Close a window by its JS ID. */
|
|
186
|
+
export declare function windowClose(jsId: string): void
|
|
187
|
+
|
|
188
|
+
/** Get the number of tracked windows. */
|
|
189
|
+
export declare function windowCount(): number
|
|
190
|
+
|
|
191
|
+
/** Execute a JavaScript string in a window's webview. */
|
|
192
|
+
export declare function windowEvalScript(jsId: string, script: string): void
|
|
193
|
+
|
|
194
|
+
/** Focus a window by its JS ID. */
|
|
195
|
+
export declare function windowFocus(jsId: string): void
|
|
196
|
+
|
|
197
|
+
/** Maximize a window by its JS ID. */
|
|
198
|
+
export declare function windowMaximize(jsId: string): void
|
|
199
|
+
|
|
200
|
+
/** Minimize a window by its JS ID. */
|
|
201
|
+
export declare function windowMinimize(jsId: string): void
|
|
202
|
+
|
|
203
|
+
/** Restore a window by its JS ID. */
|
|
204
|
+
export declare function windowRestore(jsId: string): void
|
|
205
|
+
|
|
206
|
+
/** Show a window by its JS ID. */
|
|
207
|
+
export declare function windowShow(jsId: string): void
|
package/index.js
ADDED
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { readFileSync } = require('node:fs')
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
|
+
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
let report = null
|
|
36
|
+
if (typeof process.report?.getReport === 'function') {
|
|
37
|
+
process.report.excludeNetwork = true
|
|
38
|
+
report = process.report.getReport()
|
|
39
|
+
}
|
|
40
|
+
if (!report) {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
47
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isMuslFromChildProcess = () => {
|
|
55
|
+
try {
|
|
56
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function requireNative() {
|
|
64
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
|
+
try {
|
|
66
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
loadErrors.push(err)
|
|
69
|
+
}
|
|
70
|
+
} else if (process.platform === 'android') {
|
|
71
|
+
if (process.arch === 'arm64') {
|
|
72
|
+
try {
|
|
73
|
+
return require('./volt-native.android-arm64.node')
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadErrors.push(e)
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const binding = require('@voltkit/volt-native-android-arm64')
|
|
79
|
+
const bindingPackageVersion = require('@voltkit/volt-native-android-arm64/package.json').version
|
|
80
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
|
+
}
|
|
83
|
+
return binding
|
|
84
|
+
} catch (e) {
|
|
85
|
+
loadErrors.push(e)
|
|
86
|
+
}
|
|
87
|
+
} else if (process.arch === 'arm') {
|
|
88
|
+
try {
|
|
89
|
+
return require('./volt-native.android-arm-eabi.node')
|
|
90
|
+
} catch (e) {
|
|
91
|
+
loadErrors.push(e)
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const binding = require('@voltkit/volt-native-android-arm-eabi')
|
|
95
|
+
const bindingPackageVersion = require('@voltkit/volt-native-android-arm-eabi/package.json').version
|
|
96
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
|
+
}
|
|
99
|
+
return binding
|
|
100
|
+
} catch (e) {
|
|
101
|
+
loadErrors.push(e)
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
105
|
+
}
|
|
106
|
+
} else if (process.platform === 'win32') {
|
|
107
|
+
if (process.arch === 'x64') {
|
|
108
|
+
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
109
|
+
try {
|
|
110
|
+
return require('./volt-native.win32-x64-gnu.node')
|
|
111
|
+
} catch (e) {
|
|
112
|
+
loadErrors.push(e)
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const binding = require('@voltkit/volt-native-win32-x64-gnu')
|
|
116
|
+
const bindingPackageVersion = require('@voltkit/volt-native-win32-x64-gnu/package.json').version
|
|
117
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
|
+
}
|
|
120
|
+
return binding
|
|
121
|
+
} catch (e) {
|
|
122
|
+
loadErrors.push(e)
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
try {
|
|
126
|
+
return require('./volt-native.win32-x64-msvc.node')
|
|
127
|
+
} catch (e) {
|
|
128
|
+
loadErrors.push(e)
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const binding = require('@voltkit/volt-native-win32-x64-msvc')
|
|
132
|
+
const bindingPackageVersion = require('@voltkit/volt-native-win32-x64-msvc/package.json').version
|
|
133
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
|
+
}
|
|
136
|
+
return binding
|
|
137
|
+
} catch (e) {
|
|
138
|
+
loadErrors.push(e)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else if (process.arch === 'ia32') {
|
|
142
|
+
try {
|
|
143
|
+
return require('./volt-native.win32-ia32-msvc.node')
|
|
144
|
+
} catch (e) {
|
|
145
|
+
loadErrors.push(e)
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const binding = require('@voltkit/volt-native-win32-ia32-msvc')
|
|
149
|
+
const bindingPackageVersion = require('@voltkit/volt-native-win32-ia32-msvc/package.json').version
|
|
150
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
|
+
}
|
|
153
|
+
return binding
|
|
154
|
+
} catch (e) {
|
|
155
|
+
loadErrors.push(e)
|
|
156
|
+
}
|
|
157
|
+
} else if (process.arch === 'arm64') {
|
|
158
|
+
try {
|
|
159
|
+
return require('./volt-native.win32-arm64-msvc.node')
|
|
160
|
+
} catch (e) {
|
|
161
|
+
loadErrors.push(e)
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const binding = require('@voltkit/volt-native-win32-arm64-msvc')
|
|
165
|
+
const bindingPackageVersion = require('@voltkit/volt-native-win32-arm64-msvc/package.json').version
|
|
166
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
|
+
}
|
|
169
|
+
return binding
|
|
170
|
+
} catch (e) {
|
|
171
|
+
loadErrors.push(e)
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
175
|
+
}
|
|
176
|
+
} else if (process.platform === 'darwin') {
|
|
177
|
+
try {
|
|
178
|
+
return require('./volt-native.darwin-universal.node')
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadErrors.push(e)
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const binding = require('@voltkit/volt-native-darwin-universal')
|
|
184
|
+
const bindingPackageVersion = require('@voltkit/volt-native-darwin-universal/package.json').version
|
|
185
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
|
+
}
|
|
188
|
+
return binding
|
|
189
|
+
} catch (e) {
|
|
190
|
+
loadErrors.push(e)
|
|
191
|
+
}
|
|
192
|
+
if (process.arch === 'x64') {
|
|
193
|
+
try {
|
|
194
|
+
return require('./volt-native.darwin-x64.node')
|
|
195
|
+
} catch (e) {
|
|
196
|
+
loadErrors.push(e)
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const binding = require('@voltkit/volt-native-darwin-x64')
|
|
200
|
+
const bindingPackageVersion = require('@voltkit/volt-native-darwin-x64/package.json').version
|
|
201
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
|
+
}
|
|
204
|
+
return binding
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadErrors.push(e)
|
|
207
|
+
}
|
|
208
|
+
} else if (process.arch === 'arm64') {
|
|
209
|
+
try {
|
|
210
|
+
return require('./volt-native.darwin-arm64.node')
|
|
211
|
+
} catch (e) {
|
|
212
|
+
loadErrors.push(e)
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const binding = require('@voltkit/volt-native-darwin-arm64')
|
|
216
|
+
const bindingPackageVersion = require('@voltkit/volt-native-darwin-arm64/package.json').version
|
|
217
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
|
+
}
|
|
220
|
+
return binding
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadErrors.push(e)
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
226
|
+
}
|
|
227
|
+
} else if (process.platform === 'freebsd') {
|
|
228
|
+
if (process.arch === 'x64') {
|
|
229
|
+
try {
|
|
230
|
+
return require('./volt-native.freebsd-x64.node')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const binding = require('@voltkit/volt-native-freebsd-x64')
|
|
236
|
+
const bindingPackageVersion = require('@voltkit/volt-native-freebsd-x64/package.json').version
|
|
237
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
|
+
}
|
|
240
|
+
return binding
|
|
241
|
+
} catch (e) {
|
|
242
|
+
loadErrors.push(e)
|
|
243
|
+
}
|
|
244
|
+
} else if (process.arch === 'arm64') {
|
|
245
|
+
try {
|
|
246
|
+
return require('./volt-native.freebsd-arm64.node')
|
|
247
|
+
} catch (e) {
|
|
248
|
+
loadErrors.push(e)
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const binding = require('@voltkit/volt-native-freebsd-arm64')
|
|
252
|
+
const bindingPackageVersion = require('@voltkit/volt-native-freebsd-arm64/package.json').version
|
|
253
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
|
+
}
|
|
256
|
+
return binding
|
|
257
|
+
} catch (e) {
|
|
258
|
+
loadErrors.push(e)
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
262
|
+
}
|
|
263
|
+
} else if (process.platform === 'linux') {
|
|
264
|
+
if (process.arch === 'x64') {
|
|
265
|
+
if (isMusl()) {
|
|
266
|
+
try {
|
|
267
|
+
return require('./volt-native.linux-x64-musl.node')
|
|
268
|
+
} catch (e) {
|
|
269
|
+
loadErrors.push(e)
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
const binding = require('@voltkit/volt-native-linux-x64-musl')
|
|
273
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-x64-musl/package.json').version
|
|
274
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
|
+
}
|
|
277
|
+
return binding
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
try {
|
|
283
|
+
return require('./volt-native.linux-x64-gnu.node')
|
|
284
|
+
} catch (e) {
|
|
285
|
+
loadErrors.push(e)
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
const binding = require('@voltkit/volt-native-linux-x64-gnu')
|
|
289
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-x64-gnu/package.json').version
|
|
290
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
|
+
}
|
|
293
|
+
return binding
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadErrors.push(e)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} else if (process.arch === 'arm64') {
|
|
299
|
+
if (isMusl()) {
|
|
300
|
+
try {
|
|
301
|
+
return require('./volt-native.linux-arm64-musl.node')
|
|
302
|
+
} catch (e) {
|
|
303
|
+
loadErrors.push(e)
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const binding = require('@voltkit/volt-native-linux-arm64-musl')
|
|
307
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-arm64-musl/package.json').version
|
|
308
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
|
+
}
|
|
311
|
+
return binding
|
|
312
|
+
} catch (e) {
|
|
313
|
+
loadErrors.push(e)
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
try {
|
|
317
|
+
return require('./volt-native.linux-arm64-gnu.node')
|
|
318
|
+
} catch (e) {
|
|
319
|
+
loadErrors.push(e)
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const binding = require('@voltkit/volt-native-linux-arm64-gnu')
|
|
323
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-arm64-gnu/package.json').version
|
|
324
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
|
+
}
|
|
327
|
+
return binding
|
|
328
|
+
} catch (e) {
|
|
329
|
+
loadErrors.push(e)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} else if (process.arch === 'arm') {
|
|
333
|
+
if (isMusl()) {
|
|
334
|
+
try {
|
|
335
|
+
return require('./volt-native.linux-arm-musleabihf.node')
|
|
336
|
+
} catch (e) {
|
|
337
|
+
loadErrors.push(e)
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
const binding = require('@voltkit/volt-native-linux-arm-musleabihf')
|
|
341
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-arm-musleabihf/package.json').version
|
|
342
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
|
+
}
|
|
345
|
+
return binding
|
|
346
|
+
} catch (e) {
|
|
347
|
+
loadErrors.push(e)
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
try {
|
|
351
|
+
return require('./volt-native.linux-arm-gnueabihf.node')
|
|
352
|
+
} catch (e) {
|
|
353
|
+
loadErrors.push(e)
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
const binding = require('@voltkit/volt-native-linux-arm-gnueabihf')
|
|
357
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-arm-gnueabihf/package.json').version
|
|
358
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
|
+
}
|
|
361
|
+
return binding
|
|
362
|
+
} catch (e) {
|
|
363
|
+
loadErrors.push(e)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else if (process.arch === 'loong64') {
|
|
367
|
+
if (isMusl()) {
|
|
368
|
+
try {
|
|
369
|
+
return require('./volt-native.linux-loong64-musl.node')
|
|
370
|
+
} catch (e) {
|
|
371
|
+
loadErrors.push(e)
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const binding = require('@voltkit/volt-native-linux-loong64-musl')
|
|
375
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-loong64-musl/package.json').version
|
|
376
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
|
+
}
|
|
379
|
+
return binding
|
|
380
|
+
} catch (e) {
|
|
381
|
+
loadErrors.push(e)
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
try {
|
|
385
|
+
return require('./volt-native.linux-loong64-gnu.node')
|
|
386
|
+
} catch (e) {
|
|
387
|
+
loadErrors.push(e)
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
const binding = require('@voltkit/volt-native-linux-loong64-gnu')
|
|
391
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-loong64-gnu/package.json').version
|
|
392
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
|
+
}
|
|
395
|
+
return binding
|
|
396
|
+
} catch (e) {
|
|
397
|
+
loadErrors.push(e)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} else if (process.arch === 'riscv64') {
|
|
401
|
+
if (isMusl()) {
|
|
402
|
+
try {
|
|
403
|
+
return require('./volt-native.linux-riscv64-musl.node')
|
|
404
|
+
} catch (e) {
|
|
405
|
+
loadErrors.push(e)
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
const binding = require('@voltkit/volt-native-linux-riscv64-musl')
|
|
409
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-riscv64-musl/package.json').version
|
|
410
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
|
+
}
|
|
413
|
+
return binding
|
|
414
|
+
} catch (e) {
|
|
415
|
+
loadErrors.push(e)
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
try {
|
|
419
|
+
return require('./volt-native.linux-riscv64-gnu.node')
|
|
420
|
+
} catch (e) {
|
|
421
|
+
loadErrors.push(e)
|
|
422
|
+
}
|
|
423
|
+
try {
|
|
424
|
+
const binding = require('@voltkit/volt-native-linux-riscv64-gnu')
|
|
425
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-riscv64-gnu/package.json').version
|
|
426
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
|
+
}
|
|
429
|
+
return binding
|
|
430
|
+
} catch (e) {
|
|
431
|
+
loadErrors.push(e)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} else if (process.arch === 'ppc64') {
|
|
435
|
+
try {
|
|
436
|
+
return require('./volt-native.linux-ppc64-gnu.node')
|
|
437
|
+
} catch (e) {
|
|
438
|
+
loadErrors.push(e)
|
|
439
|
+
}
|
|
440
|
+
try {
|
|
441
|
+
const binding = require('@voltkit/volt-native-linux-ppc64-gnu')
|
|
442
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-ppc64-gnu/package.json').version
|
|
443
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
|
+
}
|
|
446
|
+
return binding
|
|
447
|
+
} catch (e) {
|
|
448
|
+
loadErrors.push(e)
|
|
449
|
+
}
|
|
450
|
+
} else if (process.arch === 's390x') {
|
|
451
|
+
try {
|
|
452
|
+
return require('./volt-native.linux-s390x-gnu.node')
|
|
453
|
+
} catch (e) {
|
|
454
|
+
loadErrors.push(e)
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
const binding = require('@voltkit/volt-native-linux-s390x-gnu')
|
|
458
|
+
const bindingPackageVersion = require('@voltkit/volt-native-linux-s390x-gnu/package.json').version
|
|
459
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
|
+
}
|
|
462
|
+
return binding
|
|
463
|
+
} catch (e) {
|
|
464
|
+
loadErrors.push(e)
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
468
|
+
}
|
|
469
|
+
} else if (process.platform === 'openharmony') {
|
|
470
|
+
if (process.arch === 'arm64') {
|
|
471
|
+
try {
|
|
472
|
+
return require('./volt-native.openharmony-arm64.node')
|
|
473
|
+
} catch (e) {
|
|
474
|
+
loadErrors.push(e)
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
const binding = require('@voltkit/volt-native-openharmony-arm64')
|
|
478
|
+
const bindingPackageVersion = require('@voltkit/volt-native-openharmony-arm64/package.json').version
|
|
479
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
|
+
}
|
|
482
|
+
return binding
|
|
483
|
+
} catch (e) {
|
|
484
|
+
loadErrors.push(e)
|
|
485
|
+
}
|
|
486
|
+
} else if (process.arch === 'x64') {
|
|
487
|
+
try {
|
|
488
|
+
return require('./volt-native.openharmony-x64.node')
|
|
489
|
+
} catch (e) {
|
|
490
|
+
loadErrors.push(e)
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
const binding = require('@voltkit/volt-native-openharmony-x64')
|
|
494
|
+
const bindingPackageVersion = require('@voltkit/volt-native-openharmony-x64/package.json').version
|
|
495
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
|
+
}
|
|
498
|
+
return binding
|
|
499
|
+
} catch (e) {
|
|
500
|
+
loadErrors.push(e)
|
|
501
|
+
}
|
|
502
|
+
} else if (process.arch === 'arm') {
|
|
503
|
+
try {
|
|
504
|
+
return require('./volt-native.openharmony-arm.node')
|
|
505
|
+
} catch (e) {
|
|
506
|
+
loadErrors.push(e)
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
const binding = require('@voltkit/volt-native-openharmony-arm')
|
|
510
|
+
const bindingPackageVersion = require('@voltkit/volt-native-openharmony-arm/package.json').version
|
|
511
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
|
+
}
|
|
514
|
+
return binding
|
|
515
|
+
} catch (e) {
|
|
516
|
+
loadErrors.push(e)
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
520
|
+
}
|
|
521
|
+
} else {
|
|
522
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
nativeBinding = requireNative()
|
|
527
|
+
|
|
528
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
529
|
+
let wasiBinding = null
|
|
530
|
+
let wasiBindingError = null
|
|
531
|
+
try {
|
|
532
|
+
wasiBinding = require('./volt-native.wasi.cjs')
|
|
533
|
+
nativeBinding = wasiBinding
|
|
534
|
+
} catch (err) {
|
|
535
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
536
|
+
wasiBindingError = err
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
540
|
+
try {
|
|
541
|
+
wasiBinding = require('@voltkit/volt-native-wasm32-wasi')
|
|
542
|
+
nativeBinding = wasiBinding
|
|
543
|
+
} catch (err) {
|
|
544
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
+
if (!wasiBindingError) {
|
|
546
|
+
wasiBindingError = err
|
|
547
|
+
} else {
|
|
548
|
+
wasiBindingError.cause = err
|
|
549
|
+
}
|
|
550
|
+
loadErrors.push(err)
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
555
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
556
|
+
error.cause = wasiBindingError
|
|
557
|
+
throw error
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (!nativeBinding) {
|
|
562
|
+
if (loadErrors.length > 0) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
`Cannot find native binding. ` +
|
|
565
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
566
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
567
|
+
{
|
|
568
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
569
|
+
cur.cause = err
|
|
570
|
+
return cur
|
|
571
|
+
}),
|
|
572
|
+
},
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
throw new Error(`Failed to load native binding`)
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
module.exports = nativeBinding
|
|
579
|
+
module.exports.VoltApp = nativeBinding.VoltApp
|
|
580
|
+
module.exports.VoltGlobalShortcut = nativeBinding.VoltGlobalShortcut
|
|
581
|
+
module.exports.VoltIpc = nativeBinding.VoltIpc
|
|
582
|
+
module.exports.VoltMenu = nativeBinding.VoltMenu
|
|
583
|
+
module.exports.VoltTray = nativeBinding.VoltTray
|
|
584
|
+
module.exports.clipboardReadImage = nativeBinding.clipboardReadImage
|
|
585
|
+
module.exports.clipboardReadText = nativeBinding.clipboardReadText
|
|
586
|
+
module.exports.clipboardWriteImage = nativeBinding.clipboardWriteImage
|
|
587
|
+
module.exports.clipboardWriteText = nativeBinding.clipboardWriteText
|
|
588
|
+
module.exports.dialogShowMessage = nativeBinding.dialogShowMessage
|
|
589
|
+
module.exports.dialogShowOpen = nativeBinding.dialogShowOpen
|
|
590
|
+
module.exports.dialogShowSave = nativeBinding.dialogShowSave
|
|
591
|
+
module.exports.fsMkdir = nativeBinding.fsMkdir
|
|
592
|
+
module.exports.fsReadDir = nativeBinding.fsReadDir
|
|
593
|
+
module.exports.fsReadFile = nativeBinding.fsReadFile
|
|
594
|
+
module.exports.fsReadFileText = nativeBinding.fsReadFileText
|
|
595
|
+
module.exports.fsRemove = nativeBinding.fsRemove
|
|
596
|
+
module.exports.fsStat = nativeBinding.fsStat
|
|
597
|
+
module.exports.fsWriteFile = nativeBinding.fsWriteFile
|
|
598
|
+
module.exports.notificationShow = nativeBinding.notificationShow
|
|
599
|
+
module.exports.shellOpenExternal = nativeBinding.shellOpenExternal
|
|
600
|
+
module.exports.updaterApply = nativeBinding.updaterApply
|
|
601
|
+
module.exports.updaterCheck = nativeBinding.updaterCheck
|
|
602
|
+
module.exports.updaterDownloadAndVerify = nativeBinding.updaterDownloadAndVerify
|
|
603
|
+
module.exports.windowClose = nativeBinding.windowClose
|
|
604
|
+
module.exports.windowCount = nativeBinding.windowCount
|
|
605
|
+
module.exports.windowEvalScript = nativeBinding.windowEvalScript
|
|
606
|
+
module.exports.windowFocus = nativeBinding.windowFocus
|
|
607
|
+
module.exports.windowMaximize = nativeBinding.windowMaximize
|
|
608
|
+
module.exports.windowMinimize = nativeBinding.windowMinimize
|
|
609
|
+
module.exports.windowRestore = nativeBinding.windowRestore
|
|
610
|
+
module.exports.windowShow = nativeBinding.windowShow
|
package/loader/musl.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const { readFileSync } = require('node:fs')
|
|
5
|
+
|
|
6
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
7
|
+
|
|
8
|
+
const isMuslFromFilesystem = () => {
|
|
9
|
+
try {
|
|
10
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
11
|
+
} catch {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const isMuslFromReport = () => {
|
|
17
|
+
let report = null
|
|
18
|
+
if (typeof process.report?.getReport === 'function') {
|
|
19
|
+
process.report.excludeNetwork = true
|
|
20
|
+
report = process.report.getReport()
|
|
21
|
+
}
|
|
22
|
+
if (!report) {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
29
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const isMuslFromChildProcess = () => {
|
|
37
|
+
try {
|
|
38
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const isMusl = () => {
|
|
45
|
+
let musl = false
|
|
46
|
+
if (process.platform === 'linux') {
|
|
47
|
+
musl = isMuslFromFilesystem()
|
|
48
|
+
if (musl === null) {
|
|
49
|
+
musl = isMuslFromReport()
|
|
50
|
+
}
|
|
51
|
+
if (musl === null) {
|
|
52
|
+
musl = isMuslFromChildProcess()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return musl
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
isMusl,
|
|
60
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const EXPECTED_NATIVE_BINDING_VERSION = '0.1.0'
|
|
5
|
+
|
|
6
|
+
const shouldEnforceVersionCheck = () =>
|
|
7
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
8
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
9
|
+
|
|
10
|
+
const createVersionMismatchError = (bindingPackageVersion) =>
|
|
11
|
+
new Error(
|
|
12
|
+
`Native binding package version mismatch, expected ${EXPECTED_NATIVE_BINDING_VERSION} but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
function tryLoadExplicitPath(localRequire, loadErrors, libraryPath) {
|
|
16
|
+
try {
|
|
17
|
+
return localRequire(libraryPath)
|
|
18
|
+
} catch (error) {
|
|
19
|
+
loadErrors.push(error)
|
|
20
|
+
return undefined
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function tryLoadTarget(localRequire, loadErrors, target) {
|
|
25
|
+
try {
|
|
26
|
+
return localRequire(target.localPath)
|
|
27
|
+
} catch (error) {
|
|
28
|
+
loadErrors.push(error)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const binding = localRequire(target.packageName)
|
|
33
|
+
const bindingPackageVersion = localRequire(
|
|
34
|
+
`${target.packageName}/package.json`,
|
|
35
|
+
).version
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
bindingPackageVersion !== EXPECTED_NATIVE_BINDING_VERSION &&
|
|
39
|
+
shouldEnforceVersionCheck()
|
|
40
|
+
) {
|
|
41
|
+
throw createVersionMismatchError(bindingPackageVersion)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return binding
|
|
45
|
+
} catch (error) {
|
|
46
|
+
loadErrors.push(error)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
tryLoadExplicitPath,
|
|
54
|
+
tryLoadTarget,
|
|
55
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const createTarget = (suffix) => ({
|
|
5
|
+
localPath: `./volt-native.${suffix}.node`,
|
|
6
|
+
packageName: `@voltkit/volt-native-${suffix}`,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const TARGETS = {
|
|
10
|
+
android: {
|
|
11
|
+
arm64: createTarget('android-arm64'),
|
|
12
|
+
arm: createTarget('android-arm-eabi'),
|
|
13
|
+
},
|
|
14
|
+
win32: {
|
|
15
|
+
x64: {
|
|
16
|
+
gnu: createTarget('win32-x64-gnu'),
|
|
17
|
+
msvc: createTarget('win32-x64-msvc'),
|
|
18
|
+
},
|
|
19
|
+
ia32: createTarget('win32-ia32-msvc'),
|
|
20
|
+
arm64: createTarget('win32-arm64-msvc'),
|
|
21
|
+
},
|
|
22
|
+
darwin: {
|
|
23
|
+
universal: createTarget('darwin-universal'),
|
|
24
|
+
x64: createTarget('darwin-x64'),
|
|
25
|
+
arm64: createTarget('darwin-arm64'),
|
|
26
|
+
},
|
|
27
|
+
freebsd: {
|
|
28
|
+
x64: createTarget('freebsd-x64'),
|
|
29
|
+
arm64: createTarget('freebsd-arm64'),
|
|
30
|
+
},
|
|
31
|
+
linux: {
|
|
32
|
+
x64: {
|
|
33
|
+
gnu: createTarget('linux-x64-gnu'),
|
|
34
|
+
musl: createTarget('linux-x64-musl'),
|
|
35
|
+
},
|
|
36
|
+
arm64: {
|
|
37
|
+
gnu: createTarget('linux-arm64-gnu'),
|
|
38
|
+
musl: createTarget('linux-arm64-musl'),
|
|
39
|
+
},
|
|
40
|
+
arm: {
|
|
41
|
+
gnu: createTarget('linux-arm-gnueabihf'),
|
|
42
|
+
musl: createTarget('linux-arm-musleabihf'),
|
|
43
|
+
},
|
|
44
|
+
loong64: {
|
|
45
|
+
gnu: createTarget('linux-loong64-gnu'),
|
|
46
|
+
musl: createTarget('linux-loong64-musl'),
|
|
47
|
+
},
|
|
48
|
+
riscv64: {
|
|
49
|
+
gnu: createTarget('linux-riscv64-gnu'),
|
|
50
|
+
musl: createTarget('linux-riscv64-musl'),
|
|
51
|
+
},
|
|
52
|
+
ppc64: {
|
|
53
|
+
default: createTarget('linux-ppc64-gnu'),
|
|
54
|
+
},
|
|
55
|
+
s390x: {
|
|
56
|
+
default: createTarget('linux-s390x-gnu'),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
openharmony: {
|
|
60
|
+
arm64: createTarget('openharmony-arm64'),
|
|
61
|
+
x64: createTarget('openharmony-x64'),
|
|
62
|
+
arm: createTarget('openharmony-arm'),
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isWindowsGnuRuntime = () =>
|
|
67
|
+
process.config?.variables?.shlib_suffix === 'dll.a' ||
|
|
68
|
+
process.config?.variables?.node_target_type === 'shared_library'
|
|
69
|
+
|
|
70
|
+
const resolveDarwinTargets = (arch) => {
|
|
71
|
+
const targets = [TARGETS.darwin.universal]
|
|
72
|
+
|
|
73
|
+
if (arch === 'x64') {
|
|
74
|
+
targets.push(TARGETS.darwin.x64)
|
|
75
|
+
return { targets }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (arch === 'arm64') {
|
|
79
|
+
targets.push(TARGETS.darwin.arm64)
|
|
80
|
+
return { targets }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
targets,
|
|
85
|
+
unsupportedError: new Error(`Unsupported architecture on macOS: ${arch}`),
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const resolveLinuxTarget = (arch, isMusl) => {
|
|
90
|
+
const variant = TARGETS.linux[arch]
|
|
91
|
+
if (!variant) {
|
|
92
|
+
return {
|
|
93
|
+
targets: [],
|
|
94
|
+
unsupportedError: new Error(`Unsupported architecture on Linux: ${arch}`),
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (variant.default) {
|
|
99
|
+
return { targets: [variant.default] }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const target = isMusl() ? variant.musl : variant.gnu
|
|
103
|
+
return { targets: [target] }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function resolveNativeTargets(isMusl) {
|
|
107
|
+
const platform = process.platform
|
|
108
|
+
const arch = process.arch
|
|
109
|
+
|
|
110
|
+
if (platform === 'android') {
|
|
111
|
+
const target = TARGETS.android[arch]
|
|
112
|
+
if (!target) {
|
|
113
|
+
return {
|
|
114
|
+
targets: [],
|
|
115
|
+
unsupportedError: new Error(`Unsupported architecture on Android ${arch}`),
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return { targets: [target] }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (platform === 'win32') {
|
|
123
|
+
if (arch === 'x64') {
|
|
124
|
+
return {
|
|
125
|
+
targets: [
|
|
126
|
+
isWindowsGnuRuntime() ? TARGETS.win32.x64.gnu : TARGETS.win32.x64.msvc,
|
|
127
|
+
],
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const target = TARGETS.win32[arch]
|
|
132
|
+
if (!target) {
|
|
133
|
+
return {
|
|
134
|
+
targets: [],
|
|
135
|
+
unsupportedError: new Error(`Unsupported architecture on Windows: ${arch}`),
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return { targets: [target] }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (platform === 'darwin') {
|
|
143
|
+
return resolveDarwinTargets(arch)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (platform === 'freebsd') {
|
|
147
|
+
const target = TARGETS.freebsd[arch]
|
|
148
|
+
if (!target) {
|
|
149
|
+
return {
|
|
150
|
+
targets: [],
|
|
151
|
+
unsupportedError: new Error(`Unsupported architecture on FreeBSD: ${arch}`),
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return { targets: [target] }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (platform === 'linux') {
|
|
159
|
+
return resolveLinuxTarget(arch, isMusl)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (platform === 'openharmony') {
|
|
163
|
+
const target = TARGETS.openharmony[arch]
|
|
164
|
+
if (!target) {
|
|
165
|
+
return {
|
|
166
|
+
targets: [],
|
|
167
|
+
unsupportedError: new Error(`Unsupported architecture on OpenHarmony: ${arch}`),
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return { targets: [target] }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
targets: [],
|
|
176
|
+
unsupportedError: new Error(
|
|
177
|
+
`Unsupported OS: ${platform}, architecture: ${arch}`,
|
|
178
|
+
),
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = {
|
|
183
|
+
resolveNativeTargets,
|
|
184
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const { tryLoadExplicitPath, tryLoadTarget } = require('./native-loader-helpers')
|
|
5
|
+
const { resolveNativeTargets } = require('./native-loader-targets')
|
|
6
|
+
|
|
7
|
+
function requireNative(localRequire, loadErrors, isMusl) {
|
|
8
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
9
|
+
return tryLoadExplicitPath(
|
|
10
|
+
localRequire,
|
|
11
|
+
loadErrors,
|
|
12
|
+
process.env.NAPI_RS_NATIVE_LIBRARY_PATH,
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { targets, unsupportedError } = resolveNativeTargets(isMusl)
|
|
17
|
+
|
|
18
|
+
for (const target of targets) {
|
|
19
|
+
const binding = tryLoadTarget(localRequire, loadErrors, target)
|
|
20
|
+
if (binding) {
|
|
21
|
+
return binding
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (unsupportedError) {
|
|
26
|
+
loadErrors.push(unsupportedError)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
requireNative,
|
|
32
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
function loadWasiFallback(nativeBinding, loadErrors, localRequire) {
|
|
5
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
6
|
+
let wasiBinding = null
|
|
7
|
+
let wasiBindingError = null
|
|
8
|
+
try {
|
|
9
|
+
wasiBinding = localRequire('./volt-native.wasi.cjs')
|
|
10
|
+
nativeBinding = wasiBinding
|
|
11
|
+
} catch (err) {
|
|
12
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
13
|
+
wasiBindingError = err
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
17
|
+
try {
|
|
18
|
+
wasiBinding = localRequire('@voltkit/volt-native-wasm32-wasi')
|
|
19
|
+
nativeBinding = wasiBinding
|
|
20
|
+
} catch (err) {
|
|
21
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
22
|
+
if (!wasiBindingError) {
|
|
23
|
+
wasiBindingError = err
|
|
24
|
+
} else {
|
|
25
|
+
wasiBindingError.cause = err
|
|
26
|
+
}
|
|
27
|
+
loadErrors.push(err)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
32
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
33
|
+
error.cause = wasiBindingError
|
|
34
|
+
throw error
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return nativeBinding
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
loadWasiFallback,
|
|
43
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voltkit/volt-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "BSL-1.1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/voltkithq/Volt"
|
|
8
|
+
},
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
14
|
+
"loader/*.js",
|
|
15
|
+
"*.node"
|
|
16
|
+
],
|
|
17
|
+
"napi": {
|
|
18
|
+
"binaryName": "volt-native",
|
|
19
|
+
"targets": [
|
|
20
|
+
"x86_64-unknown-linux-gnu",
|
|
21
|
+
"x86_64-apple-darwin",
|
|
22
|
+
"aarch64-apple-darwin",
|
|
23
|
+
"x86_64-pc-windows-msvc"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">= 20"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"lint": "eslint index.js --max-warnings 0",
|
|
31
|
+
"build": "napi build --platform --release --features devtools",
|
|
32
|
+
"build:debug": "napi build --platform --features devtools"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@napi-rs/cli": "^3.4.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
Binary file
|
|
Binary file
|