@bodhiapp/app-bindings 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -0
- package/index.d.ts +95 -0
- package/index.js +398 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# @bodhiapp/app-bindings
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@bodhiapp%2Fapp-bindings)
|
|
4
|
+
[](https://github.com/BodhiSearch/BodhiApp/actions/workflows/build.yml)
|
|
5
|
+
|
|
6
|
+
Node.js bindings for BodhiApp server functionality, built with NAPI-RS for high-performance native integration.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- ๐ **High Performance**: Native Rust implementation with Node.js bindings
|
|
11
|
+
- ๐ **Cross-Platform**: Supports macOS, Linux, and Windows
|
|
12
|
+
- ๐ฆ **Zero Dependencies**: Self-contained with platform-specific binaries
|
|
13
|
+
- ๐ **Type Safe**: Full TypeScript definitions included
|
|
14
|
+
- ๐งช **Well Tested**: Comprehensive test suite with integration tests
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @bodhiapp/app-bindings
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Supported Platforms
|
|
23
|
+
|
|
24
|
+
This package includes pre-built binaries for the following platforms:
|
|
25
|
+
|
|
26
|
+
| Platform | Architecture | Node.js |
|
|
27
|
+
|----------|-------------|---------|
|
|
28
|
+
| macOS | Apple Silicon (ARM64) | >=22 |
|
|
29
|
+
| Linux | x64 | >=22 |
|
|
30
|
+
| Windows | x64 | >=22 |
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Basic Usage
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
import { /* exported functions */ } from '@bodhiapp/app-bindings';
|
|
38
|
+
|
|
39
|
+
// Example usage will be added based on your actual exports
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### TypeScript Support
|
|
43
|
+
|
|
44
|
+
The package includes full TypeScript definitions:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import type { /* types */ } from '@bodhiapp/app-bindings';
|
|
48
|
+
|
|
49
|
+
// TypeScript intellisense and type checking work out of the box
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
<!-- API documentation will be generated based on your actual exports -->
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
This package is part of the [BodhiApp](https://github.com/BodhiSearch/BodhiApp) project.
|
|
59
|
+
|
|
60
|
+
### Building from Source
|
|
61
|
+
|
|
62
|
+
If you need to build from source:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Clone the repository
|
|
66
|
+
git clone https://github.com/BodhiSearch/BodhiApp.git
|
|
67
|
+
cd BodhiApp/crates/lib_bodhiserver_napi
|
|
68
|
+
|
|
69
|
+
# Install dependencies
|
|
70
|
+
npm install
|
|
71
|
+
|
|
72
|
+
# Build the native module
|
|
73
|
+
npm run build:release
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Testing
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Run unit tests
|
|
80
|
+
npm test
|
|
81
|
+
|
|
82
|
+
# Run integration tests
|
|
83
|
+
npm run test:integration
|
|
84
|
+
|
|
85
|
+
# Run Playwright tests
|
|
86
|
+
npm run test:playwright
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
This package uses [NAPI-RS](https://napi.rs/) to provide Node.js bindings for Rust code. The architecture follows these principles:
|
|
92
|
+
|
|
93
|
+
- **Platform-specific binaries**: Each supported platform gets its own optimized binary
|
|
94
|
+
- **Automatic loading**: The package automatically loads the correct binary for your platform
|
|
95
|
+
- **Fallback handling**: Graceful error handling if binaries are missing
|
|
96
|
+
- **Development support**: Debug builds available for development
|
|
97
|
+
|
|
98
|
+
## Performance
|
|
99
|
+
|
|
100
|
+
The native Rust implementation provides significant performance benefits over pure JavaScript implementations:
|
|
101
|
+
|
|
102
|
+
- **Memory efficiency**: Lower memory usage through Rust's ownership model
|
|
103
|
+
- **CPU performance**: Optimized native code execution
|
|
104
|
+
- **Concurrent processing**: Built-in support for async operations
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
Contributions are welcome! Please see the [main repository](https://github.com/BodhiSearch/BodhiApp) for contribution guidelines.
|
|
109
|
+
|
|
110
|
+
### Development Setup
|
|
111
|
+
|
|
112
|
+
1. **Rust**: Install Rust toolchain (1.70+)
|
|
113
|
+
2. **Node.js**: Install Node.js (22+)
|
|
114
|
+
3. **Platform tools**: Platform-specific build tools may be required
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
MIT License - see the [LICENSE](https://github.com/BodhiSearch/BodhiApp/blob/main/LICENSE) file for details.
|
|
119
|
+
|
|
120
|
+
## Support
|
|
121
|
+
|
|
122
|
+
- **Issues**: [GitHub Issues](https://github.com/BodhiSearch/BodhiApp/issues)
|
|
123
|
+
- **Documentation**: [Project Documentation](https://github.com/BodhiSearch/BodhiApp#readme)
|
|
124
|
+
- **Community**: [Discussions](https://github.com/BodhiSearch/BodhiApp/discussions)
|
|
125
|
+
|
|
126
|
+
## Related Packages
|
|
127
|
+
|
|
128
|
+
This package is part of the BodhiApp ecosystem:
|
|
129
|
+
|
|
130
|
+
- **[BodhiApp](https://github.com/BodhiSearch/BodhiApp)**: Main application repository
|
|
131
|
+
- **Desktop App**: Cross-platform desktop application built with Tauri
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
*Built with โค๏ธ using [NAPI-RS](https://napi.rs/)*
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** The main Bodhi server wrapper for NAPI */
|
|
4
|
+
export declare class BodhiServer {
|
|
5
|
+
/** Create a new Bodhi server instance with the given configuration */
|
|
6
|
+
constructor(config: NapiAppOptions)
|
|
7
|
+
/** Get the server configuration */
|
|
8
|
+
get config(): NapiAppOptions
|
|
9
|
+
/** Get the server URL */
|
|
10
|
+
serverUrl(): string
|
|
11
|
+
/** Get the server host */
|
|
12
|
+
host(): string
|
|
13
|
+
/** Get the server port */
|
|
14
|
+
port(): number
|
|
15
|
+
/** Start the Bodhi server */
|
|
16
|
+
start(): Promise<void>
|
|
17
|
+
/** Stop the Bodhi server */
|
|
18
|
+
stop(): Promise<void>
|
|
19
|
+
/** Check if the server is running */
|
|
20
|
+
isRunning(): Promise<boolean>
|
|
21
|
+
/** Get server ping status */
|
|
22
|
+
ping(): Promise<boolean>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const BODHI_APP_TYPE: string
|
|
26
|
+
|
|
27
|
+
export const BODHI_AUTH_REALM: string
|
|
28
|
+
|
|
29
|
+
export const BODHI_AUTH_URL: string
|
|
30
|
+
|
|
31
|
+
export const BODHI_ENCRYPTION_KEY: string
|
|
32
|
+
|
|
33
|
+
export const BODHI_ENV_TYPE: string
|
|
34
|
+
|
|
35
|
+
export const BODHI_EXEC_LOOKUP_PATH: string
|
|
36
|
+
|
|
37
|
+
export const BODHI_EXEC_VARIANT: string
|
|
38
|
+
|
|
39
|
+
export const BODHI_HOME: string
|
|
40
|
+
|
|
41
|
+
export const BODHI_HOST: string
|
|
42
|
+
|
|
43
|
+
export const BODHI_KEEP_ALIVE_SECS: string
|
|
44
|
+
|
|
45
|
+
export const BODHI_LOG_LEVEL: string
|
|
46
|
+
|
|
47
|
+
export const BODHI_LOG_STDOUT: string
|
|
48
|
+
|
|
49
|
+
export const BODHI_LOGS: string
|
|
50
|
+
|
|
51
|
+
export const BODHI_PORT: string
|
|
52
|
+
|
|
53
|
+
export const BODHI_SCHEME: string
|
|
54
|
+
|
|
55
|
+
export const BODHI_VERSION: string
|
|
56
|
+
|
|
57
|
+
/** Create a new NapiAppOptions with empty configuration */
|
|
58
|
+
export declare export declare function createNapiAppOptions(): NapiAppOptions
|
|
59
|
+
|
|
60
|
+
export const DEFAULT_HOST: string
|
|
61
|
+
|
|
62
|
+
export const DEFAULT_PORT: number
|
|
63
|
+
|
|
64
|
+
export const HF_HOME: string
|
|
65
|
+
|
|
66
|
+
/** Flexible configuration options for the Bodhi server that can be passed across NAPI boundary */
|
|
67
|
+
export interface NapiAppOptions {
|
|
68
|
+
/** Environment variables to set */
|
|
69
|
+
envVars: Record<string, string>
|
|
70
|
+
/** App settings (configurable via settings.yaml) */
|
|
71
|
+
appSettings: Record<string, string>
|
|
72
|
+
/** System settings (immutable) */
|
|
73
|
+
systemSettings: Record<string, string>
|
|
74
|
+
/** OAuth client ID (optional) */
|
|
75
|
+
clientId?: string
|
|
76
|
+
/** OAuth client secret (optional) */
|
|
77
|
+
clientSecret?: string
|
|
78
|
+
/** App status as string (optional) */
|
|
79
|
+
appStatus?: string
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Set an app setting (configurable via settings.yaml) */
|
|
83
|
+
export declare export declare function setAppSetting(config: NapiAppOptions, key: string, value: string): NapiAppOptions
|
|
84
|
+
|
|
85
|
+
/** Set app status */
|
|
86
|
+
export declare export declare function setAppStatus(config: NapiAppOptions, status: string): NapiAppOptions
|
|
87
|
+
|
|
88
|
+
/** Set OAuth client credentials */
|
|
89
|
+
export declare export declare function setClientCredentials(config: NapiAppOptions, clientId: string, clientSecret: string): NapiAppOptions
|
|
90
|
+
|
|
91
|
+
/** Set an environment variable */
|
|
92
|
+
export declare export declare function setEnvVar(config: NapiAppOptions, key: string, value: string): NapiAppOptions
|
|
93
|
+
|
|
94
|
+
/** Set a system setting (immutable) */
|
|
95
|
+
export declare export declare function setSystemSetting(config: NapiAppOptions, key: string, value: string): NapiAppOptions
|
package/index.js
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { createRequire } = require('node:module')
|
|
7
|
+
require = createRequire(__filename)
|
|
8
|
+
|
|
9
|
+
const { readFileSync } = require('node:fs')
|
|
10
|
+
let nativeBinding = null
|
|
11
|
+
const loadErrors = []
|
|
12
|
+
|
|
13
|
+
const isMusl = () => {
|
|
14
|
+
let musl = false
|
|
15
|
+
if (process.platform === 'linux') {
|
|
16
|
+
musl = isMuslFromFilesystem()
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromReport()
|
|
19
|
+
}
|
|
20
|
+
if (musl === null) {
|
|
21
|
+
musl = isMuslFromChildProcess()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return musl
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
28
|
+
|
|
29
|
+
const isMuslFromFilesystem = () => {
|
|
30
|
+
try {
|
|
31
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isMuslFromReport = () => {
|
|
38
|
+
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
|
|
39
|
+
if (!report) {
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
42
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
46
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
47
|
+
return true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const isMuslFromChildProcess = () => {
|
|
54
|
+
try {
|
|
55
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
56
|
+
} catch (e) {
|
|
57
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function requireNative() {
|
|
63
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
64
|
+
try {
|
|
65
|
+
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
loadErrors.push(err);
|
|
68
|
+
}
|
|
69
|
+
} else if (process.platform === 'android') {
|
|
70
|
+
if (process.arch === 'arm64') {
|
|
71
|
+
try {
|
|
72
|
+
return require('./app-bindings.android-arm64.node')
|
|
73
|
+
} catch (e) {
|
|
74
|
+
loadErrors.push(e)
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
return require('@bodhiapp/app-bindings-android-arm64')
|
|
78
|
+
} catch (e) {
|
|
79
|
+
loadErrors.push(e)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
} else if (process.arch === 'arm') {
|
|
83
|
+
try {
|
|
84
|
+
return require('./app-bindings.android-arm-eabi.node')
|
|
85
|
+
} catch (e) {
|
|
86
|
+
loadErrors.push(e)
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return require('@bodhiapp/app-bindings-android-arm-eabi')
|
|
90
|
+
} catch (e) {
|
|
91
|
+
loadErrors.push(e)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
96
|
+
}
|
|
97
|
+
} else if (process.platform === 'win32') {
|
|
98
|
+
if (process.arch === 'x64') {
|
|
99
|
+
try {
|
|
100
|
+
return require('./app-bindings.win32-x64-msvc.node')
|
|
101
|
+
} catch (e) {
|
|
102
|
+
loadErrors.push(e)
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return require('@bodhiapp/app-bindings-win32-x64-msvc')
|
|
106
|
+
} catch (e) {
|
|
107
|
+
loadErrors.push(e)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
} else if (process.arch === 'ia32') {
|
|
111
|
+
try {
|
|
112
|
+
return require('./app-bindings.win32-ia32-msvc.node')
|
|
113
|
+
} catch (e) {
|
|
114
|
+
loadErrors.push(e)
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
return require('@bodhiapp/app-bindings-win32-ia32-msvc')
|
|
118
|
+
} catch (e) {
|
|
119
|
+
loadErrors.push(e)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
} else if (process.arch === 'arm64') {
|
|
123
|
+
try {
|
|
124
|
+
return require('./app-bindings.win32-arm64-msvc.node')
|
|
125
|
+
} catch (e) {
|
|
126
|
+
loadErrors.push(e)
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
return require('@bodhiapp/app-bindings-win32-arm64-msvc')
|
|
130
|
+
} catch (e) {
|
|
131
|
+
loadErrors.push(e)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
} else {
|
|
135
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
136
|
+
}
|
|
137
|
+
} else if (process.platform === 'darwin') {
|
|
138
|
+
try {
|
|
139
|
+
return require('./app-bindings.darwin-universal.node')
|
|
140
|
+
} catch (e) {
|
|
141
|
+
loadErrors.push(e)
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
return require('@bodhiapp/app-bindings-darwin-universal')
|
|
145
|
+
} catch (e) {
|
|
146
|
+
loadErrors.push(e)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (process.arch === 'x64') {
|
|
150
|
+
try {
|
|
151
|
+
return require('./app-bindings.darwin-x64.node')
|
|
152
|
+
} catch (e) {
|
|
153
|
+
loadErrors.push(e)
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
return require('@bodhiapp/app-bindings-darwin-x64')
|
|
157
|
+
} catch (e) {
|
|
158
|
+
loadErrors.push(e)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
} else if (process.arch === 'arm64') {
|
|
162
|
+
try {
|
|
163
|
+
return require('./app-bindings.darwin-arm64.node')
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
return require('@bodhiapp/app-bindings-darwin-arm64')
|
|
169
|
+
} catch (e) {
|
|
170
|
+
loadErrors.push(e)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
} else {
|
|
174
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
175
|
+
}
|
|
176
|
+
} else if (process.platform === 'freebsd') {
|
|
177
|
+
if (process.arch === 'x64') {
|
|
178
|
+
try {
|
|
179
|
+
return require('./app-bindings.freebsd-x64.node')
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadErrors.push(e)
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
return require('@bodhiapp/app-bindings-freebsd-x64')
|
|
185
|
+
} catch (e) {
|
|
186
|
+
loadErrors.push(e)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
} else if (process.arch === 'arm64') {
|
|
190
|
+
try {
|
|
191
|
+
return require('./app-bindings.freebsd-arm64.node')
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadErrors.push(e)
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
return require('@bodhiapp/app-bindings-freebsd-arm64')
|
|
197
|
+
} catch (e) {
|
|
198
|
+
loadErrors.push(e)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
} else {
|
|
202
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
203
|
+
}
|
|
204
|
+
} else if (process.platform === 'linux') {
|
|
205
|
+
if (process.arch === 'x64') {
|
|
206
|
+
if (isMusl()) {
|
|
207
|
+
try {
|
|
208
|
+
return require('./app-bindings.linux-x64-musl.node')
|
|
209
|
+
} catch (e) {
|
|
210
|
+
loadErrors.push(e)
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
return require('@bodhiapp/app-bindings-linux-x64-musl')
|
|
214
|
+
} catch (e) {
|
|
215
|
+
loadErrors.push(e)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
} else {
|
|
219
|
+
try {
|
|
220
|
+
return require('./app-bindings.linux-x64-gnu.node')
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadErrors.push(e)
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
return require('@bodhiapp/app-bindings-linux-x64-gnu')
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
} else if (process.arch === 'arm64') {
|
|
232
|
+
if (isMusl()) {
|
|
233
|
+
try {
|
|
234
|
+
return require('./app-bindings.linux-arm64-musl.node')
|
|
235
|
+
} catch (e) {
|
|
236
|
+
loadErrors.push(e)
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
return require('@bodhiapp/app-bindings-linux-arm64-musl')
|
|
240
|
+
} catch (e) {
|
|
241
|
+
loadErrors.push(e)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
} else {
|
|
245
|
+
try {
|
|
246
|
+
return require('./app-bindings.linux-arm64-gnu.node')
|
|
247
|
+
} catch (e) {
|
|
248
|
+
loadErrors.push(e)
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
return require('@bodhiapp/app-bindings-linux-arm64-gnu')
|
|
252
|
+
} catch (e) {
|
|
253
|
+
loadErrors.push(e)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
} else if (process.arch === 'arm') {
|
|
258
|
+
if (isMusl()) {
|
|
259
|
+
try {
|
|
260
|
+
return require('./app-bindings.linux-arm-musleabihf.node')
|
|
261
|
+
} catch (e) {
|
|
262
|
+
loadErrors.push(e)
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
return require('@bodhiapp/app-bindings-linux-arm-musleabihf')
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadErrors.push(e)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
} else {
|
|
271
|
+
try {
|
|
272
|
+
return require('./app-bindings.linux-arm-gnueabihf.node')
|
|
273
|
+
} catch (e) {
|
|
274
|
+
loadErrors.push(e)
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
return require('@bodhiapp/app-bindings-linux-arm-gnueabihf')
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
} else if (process.arch === 'riscv64') {
|
|
284
|
+
if (isMusl()) {
|
|
285
|
+
try {
|
|
286
|
+
return require('./app-bindings.linux-riscv64-musl.node')
|
|
287
|
+
} catch (e) {
|
|
288
|
+
loadErrors.push(e)
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
return require('@bodhiapp/app-bindings-linux-riscv64-musl')
|
|
292
|
+
} catch (e) {
|
|
293
|
+
loadErrors.push(e)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
} else {
|
|
297
|
+
try {
|
|
298
|
+
return require('./app-bindings.linux-riscv64-gnu.node')
|
|
299
|
+
} catch (e) {
|
|
300
|
+
loadErrors.push(e)
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
return require('@bodhiapp/app-bindings-linux-riscv64-gnu')
|
|
304
|
+
} catch (e) {
|
|
305
|
+
loadErrors.push(e)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
} else if (process.arch === 'ppc64') {
|
|
310
|
+
try {
|
|
311
|
+
return require('./app-bindings.linux-ppc64-gnu.node')
|
|
312
|
+
} catch (e) {
|
|
313
|
+
loadErrors.push(e)
|
|
314
|
+
}
|
|
315
|
+
try {
|
|
316
|
+
return require('@bodhiapp/app-bindings-linux-ppc64-gnu')
|
|
317
|
+
} catch (e) {
|
|
318
|
+
loadErrors.push(e)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
} else if (process.arch === 's390x') {
|
|
322
|
+
try {
|
|
323
|
+
return require('./app-bindings.linux-s390x-gnu.node')
|
|
324
|
+
} catch (e) {
|
|
325
|
+
loadErrors.push(e)
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
return require('@bodhiapp/app-bindings-linux-s390x-gnu')
|
|
329
|
+
} catch (e) {
|
|
330
|
+
loadErrors.push(e)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
} else {
|
|
334
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
nativeBinding = requireNative()
|
|
342
|
+
|
|
343
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
344
|
+
try {
|
|
345
|
+
nativeBinding = require('./app-bindings.wasi.cjs')
|
|
346
|
+
} catch (err) {
|
|
347
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
348
|
+
loadErrors.push(err)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!nativeBinding) {
|
|
352
|
+
try {
|
|
353
|
+
nativeBinding = require('@bodhiapp/app-bindings-wasm32-wasi')
|
|
354
|
+
} catch (err) {
|
|
355
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
356
|
+
loadErrors.push(err)
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (!nativeBinding) {
|
|
363
|
+
if (loadErrors.length > 0) {
|
|
364
|
+
// TODO Link to documentation with potential fixes
|
|
365
|
+
// - The package owner could build/publish bindings for this arch
|
|
366
|
+
// - The user may need to bundle the correct files
|
|
367
|
+
// - The user may need to re-install node_modules to get new packages
|
|
368
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
369
|
+
}
|
|
370
|
+
throw new Error(`Failed to load native binding`)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
module.exports.BodhiServer = nativeBinding.BodhiServer
|
|
374
|
+
module.exports.BODHI_APP_TYPE = nativeBinding.BODHI_APP_TYPE
|
|
375
|
+
module.exports.BODHI_AUTH_REALM = nativeBinding.BODHI_AUTH_REALM
|
|
376
|
+
module.exports.BODHI_AUTH_URL = nativeBinding.BODHI_AUTH_URL
|
|
377
|
+
module.exports.BODHI_ENCRYPTION_KEY = nativeBinding.BODHI_ENCRYPTION_KEY
|
|
378
|
+
module.exports.BODHI_ENV_TYPE = nativeBinding.BODHI_ENV_TYPE
|
|
379
|
+
module.exports.BODHI_EXEC_LOOKUP_PATH = nativeBinding.BODHI_EXEC_LOOKUP_PATH
|
|
380
|
+
module.exports.BODHI_EXEC_VARIANT = nativeBinding.BODHI_EXEC_VARIANT
|
|
381
|
+
module.exports.BODHI_HOME = nativeBinding.BODHI_HOME
|
|
382
|
+
module.exports.BODHI_HOST = nativeBinding.BODHI_HOST
|
|
383
|
+
module.exports.BODHI_KEEP_ALIVE_SECS = nativeBinding.BODHI_KEEP_ALIVE_SECS
|
|
384
|
+
module.exports.BODHI_LOG_LEVEL = nativeBinding.BODHI_LOG_LEVEL
|
|
385
|
+
module.exports.BODHI_LOG_STDOUT = nativeBinding.BODHI_LOG_STDOUT
|
|
386
|
+
module.exports.BODHI_LOGS = nativeBinding.BODHI_LOGS
|
|
387
|
+
module.exports.BODHI_PORT = nativeBinding.BODHI_PORT
|
|
388
|
+
module.exports.BODHI_SCHEME = nativeBinding.BODHI_SCHEME
|
|
389
|
+
module.exports.BODHI_VERSION = nativeBinding.BODHI_VERSION
|
|
390
|
+
module.exports.createNapiAppOptions = nativeBinding.createNapiAppOptions
|
|
391
|
+
module.exports.DEFAULT_HOST = nativeBinding.DEFAULT_HOST
|
|
392
|
+
module.exports.DEFAULT_PORT = nativeBinding.DEFAULT_PORT
|
|
393
|
+
module.exports.HF_HOME = nativeBinding.HF_HOME
|
|
394
|
+
module.exports.setAppSetting = nativeBinding.setAppSetting
|
|
395
|
+
module.exports.setAppStatus = nativeBinding.setAppStatus
|
|
396
|
+
module.exports.setClientCredentials = nativeBinding.setClientCredentials
|
|
397
|
+
module.exports.setEnvVar = nativeBinding.setEnvVar
|
|
398
|
+
module.exports.setSystemSetting = nativeBinding.setSystemSetting
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bodhiapp/app-bindings",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "NAPI-RS bindings for BodhiApp server with integrated tests",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"napi": {
|
|
9
|
+
"binaryName": "app-bindings",
|
|
10
|
+
"targets": [
|
|
11
|
+
"aarch64-apple-darwin"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"artifacts": "napi artifacts",
|
|
16
|
+
"create-npm-dirs": "napi create-npm-dirs",
|
|
17
|
+
"build": "napi build --platform --release",
|
|
18
|
+
"build:debug": "napi build --platform",
|
|
19
|
+
"build:release": "napi build --platform --release",
|
|
20
|
+
"build:release:win": "napi build --platform --release --target x86_64-pc-windows-msvc",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:run": "vitest run",
|
|
23
|
+
"test:config": "vitest run --testNamePattern='Configuration'",
|
|
24
|
+
"test:integration": "vitest run --testNamePattern='Integration'",
|
|
25
|
+
"test:live": "vitest run --testNamePattern='Live Server'",
|
|
26
|
+
"test:playwright": "playwright test --reporter=list",
|
|
27
|
+
"test:playwright:ci": "playwright test",
|
|
28
|
+
"test:playwright:ui": "playwright test --ui",
|
|
29
|
+
"test:playwright:headed": "playwright test --headed",
|
|
30
|
+
"test:all": "npm run test:run && npm run test:playwright",
|
|
31
|
+
"format": "biome format --write .",
|
|
32
|
+
"format:check": "biome format .",
|
|
33
|
+
"lint": "biome lint .",
|
|
34
|
+
"lint:fix": "biome lint --write .",
|
|
35
|
+
"check": "biome check .",
|
|
36
|
+
"check:fix": "biome check --write ."
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@biomejs/biome": "^1.9.4",
|
|
40
|
+
"@napi-rs/cli": "=3.0.0-alpha.68",
|
|
41
|
+
"@playwright/test": "^1.48.2",
|
|
42
|
+
"dotenv": "^16.5.0",
|
|
43
|
+
"vitest": "^2.1.8"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=22"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/BodhiSearch/BodhiApp.git",
|
|
55
|
+
"directory": "crates/lib_bodhiserver_napi"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/BodhiSearch/BodhiApp#readme",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/BodhiSearch/BodhiApp/issues"
|
|
60
|
+
},
|
|
61
|
+
"keywords": [
|
|
62
|
+
"napi",
|
|
63
|
+
"rust",
|
|
64
|
+
"node-addon",
|
|
65
|
+
"bodhi",
|
|
66
|
+
"llm",
|
|
67
|
+
"server"
|
|
68
|
+
],
|
|
69
|
+
"files": [
|
|
70
|
+
"index.d.ts",
|
|
71
|
+
"index.js"
|
|
72
|
+
],
|
|
73
|
+
"optionalDependencies": {
|
|
74
|
+
"@bodhiapp/app-bindings-darwin-arm64": "0.0.1"
|
|
75
|
+
}
|
|
76
|
+
}
|