@jdxcode/aube-ffi 0.0.1-placeholder → 1.28.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/README.md +24 -2
- package/aube.h +64 -0
- package/index.d.ts +20 -0
- package/index.js +34 -1
- package/package.json +31 -3
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# aube C ABI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@jdxcode/aube-ffi` distributes aube's C ABI for Bun FFI, Deno FFI,
|
|
4
|
+
Node.js FFI loaders, Python `ctypes`, and native applications. The root npm
|
|
5
|
+
package selects one of eight platform packages and exports `libraryPath`,
|
|
6
|
+
`headerPath`, and `target`.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @jdxcode/aube-ffi
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The same libraries and `aube.h` are attached to GitHub releases for hosts that
|
|
13
|
+
do not consume npm packages.
|
|
14
|
+
|
|
15
|
+
The ABI uses asynchronous operation handles. `aube_install` and `aube_add`
|
|
16
|
+
return immediately; `aube_cancel` requests cooperative cancellation and
|
|
17
|
+
`aube_wait` blocks until the result is available. Event callbacks run on
|
|
18
|
+
aube-managed threads and must be thread-safe. Strings returned by the library
|
|
19
|
+
must be released with `aube_string_free`.
|
|
20
|
+
A callback-driven host should call `aube_wait` after its terminal event to
|
|
21
|
+
release the completed operation handle without blocking.
|
|
22
|
+
|
|
23
|
+
See the [C ABI embedding guide](https://aube.jdx.dev/embedding/ffi) for schemas,
|
|
24
|
+
ownership rules, and examples. For support, use
|
|
25
|
+
[GitHub Discussions](https://github.com/jdx/aube/discussions).
|
package/aube.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#ifndef AUBE_H
|
|
2
|
+
#define AUBE_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#if defined(_WIN32)
|
|
7
|
+
#define AUBE_API __declspec(dllimport)
|
|
8
|
+
#else
|
|
9
|
+
#define AUBE_API
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#ifdef __cplusplus
|
|
13
|
+
extern "C" {
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
/* Called from aube-managed threads. The callback and ctx must remain valid and
|
|
17
|
+
* thread-safe until aube_wait returns for the operation. event_json is borrowed
|
|
18
|
+
* and valid only for the duration of the callback. The callback must return
|
|
19
|
+
* normally: it must not throw, panic, or unwind across this C boundary, and it
|
|
20
|
+
* must not call aube_wait for its active operation. */
|
|
21
|
+
typedef void (*aube_event_cb)(const char *event_json, void *ctx);
|
|
22
|
+
|
|
23
|
+
/* host_json: {"name":"host","version":"1.0.0","defaults":{...}}
|
|
24
|
+
* Call before starting operations. The first operation seals standalone host
|
|
25
|
+
* defaults when init has not run. Returns 0 on success, -1 for invalid input,
|
|
26
|
+
* and -2 when a panic is caught. */
|
|
27
|
+
AUBE_API int32_t aube_init(const char *host_json);
|
|
28
|
+
|
|
29
|
+
/* options_json must contain projectDir. Returns immediately with an operation
|
|
30
|
+
* handle. Inputs are copied before return. Boundary failures are represented
|
|
31
|
+
* by a completed handle; call aube_wait to retrieve the structured error. */
|
|
32
|
+
AUBE_API uint64_t aube_install(
|
|
33
|
+
const char *options_json,
|
|
34
|
+
aube_event_cb callback,
|
|
35
|
+
void *ctx);
|
|
36
|
+
|
|
37
|
+
/* packages_json is a JSON array of package specifier strings. Returns a
|
|
38
|
+
* completed handle containing a structured error for boundary failures. */
|
|
39
|
+
AUBE_API uint64_t aube_add(
|
|
40
|
+
const char *project_dir,
|
|
41
|
+
const char *packages_json,
|
|
42
|
+
const char *options_json,
|
|
43
|
+
aube_event_cb callback,
|
|
44
|
+
void *ctx);
|
|
45
|
+
|
|
46
|
+
/* Blocks until completion and consumes the handle. Returns owned UTF-8 JSON:
|
|
47
|
+
* {"ok":true} or {"ok":false,"code":"ERR_AUBE_*","message":"..."}.
|
|
48
|
+
* Returns NULL only if an internal result cannot be represented as a C string;
|
|
49
|
+
* treat that as ERR_AUBE_FFI_RUNTIME. Free a non-null result with
|
|
50
|
+
* aube_string_free. */
|
|
51
|
+
AUBE_API char *aube_wait(uint64_t handle);
|
|
52
|
+
|
|
53
|
+
/* Returns 0 when cancellation was requested, -1 for an unknown handle, and -2
|
|
54
|
+
* when a panic is caught. */
|
|
55
|
+
AUBE_API int32_t aube_cancel(uint64_t handle);
|
|
56
|
+
|
|
57
|
+
/* Frees any string returned by this library. Null is accepted. */
|
|
58
|
+
AUBE_API void aube_string_free(char *value);
|
|
59
|
+
|
|
60
|
+
#ifdef __cplusplus
|
|
61
|
+
}
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#endif
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type InstallEvent =
|
|
2
|
+
| { kind: "phase"; phase: "resolving" | "fetching" | "linking" | "complete" }
|
|
3
|
+
| {
|
|
4
|
+
kind: "progress"
|
|
5
|
+
resolved: number
|
|
6
|
+
total: number
|
|
7
|
+
reused: number
|
|
8
|
+
downloaded: number
|
|
9
|
+
downloadedBytes: number
|
|
10
|
+
estimatedBytes?: number
|
|
11
|
+
}
|
|
12
|
+
| { kind: "output"; level: "info" | "warning" | "error"; code?: string; message: string }
|
|
13
|
+
|
|
14
|
+
export type AubeResult =
|
|
15
|
+
| { ok: true }
|
|
16
|
+
| { ok: false; code: `ERR_AUBE_${string}`; message: string }
|
|
17
|
+
|
|
18
|
+
export const libraryPath: string
|
|
19
|
+
export const headerPath: string
|
|
20
|
+
export const target: string
|
package/index.js
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
const fs = require("node:fs")
|
|
2
|
+
const path = require("node:path")
|
|
3
|
+
const childProcess = require("node:child_process")
|
|
4
|
+
|
|
5
|
+
function isMusl() {
|
|
6
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
7
|
+
try {
|
|
8
|
+
if (process.report.getReport().header.glibcVersionRuntime) return false
|
|
9
|
+
} catch (_) {}
|
|
10
|
+
try {
|
|
11
|
+
return childProcess.execFileSync("ldd", ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] })
|
|
12
|
+
.toLowerCase().includes("musl")
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return `${error.stdout || ""}\n${error.stderr || ""}`.toLowerCase().includes("musl")
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function platformPackage() {
|
|
19
|
+
const key = `${process.platform}-${process.arch}`
|
|
20
|
+
if (key === "darwin-arm64") return "@jdxcode/aube-ffi-darwin-arm64"
|
|
21
|
+
if (key === "darwin-x64") return "@jdxcode/aube-ffi-darwin-x64"
|
|
22
|
+
if (key === "win32-arm64") return "@jdxcode/aube-ffi-win32-arm64"
|
|
23
|
+
if (key === "win32-x64") return "@jdxcode/aube-ffi-win32-x64"
|
|
24
|
+
if (key === "linux-arm64" && isMusl()) return "@jdxcode/aube-ffi-linux-arm64-musl"
|
|
25
|
+
if (key === "linux-arm64") return "@jdxcode/aube-ffi-linux-arm64"
|
|
26
|
+
if (key === "linux-x64" && isMusl()) return "@jdxcode/aube-ffi-linux-x64-musl"
|
|
27
|
+
if (key === "linux-x64") return "@jdxcode/aube-ffi-linux-x64"
|
|
28
|
+
throw new Error(`Unsupported aube FFI platform: ${key}`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const platform = require(platformPackage())
|
|
32
|
+
exports.libraryPath = platform.libraryPath
|
|
33
|
+
exports.headerPath = path.join(__dirname, "aube.h")
|
|
34
|
+
exports.target = platform.target
|
package/package.json
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdxcode/aube-ffi",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.28.0",
|
|
4
|
+
"description": "C ABI bindings for embedding the aube package manager",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/jdx/aube",
|
|
7
|
-
"main": "index.js"
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./aube.h": "./aube.h"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.js",
|
|
18
|
+
"index.d.ts",
|
|
19
|
+
"aube.h",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"preferUnplugged": true,
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"@jdxcode/aube-ffi-darwin-arm64": "1.28.0",
|
|
28
|
+
"@jdxcode/aube-ffi-darwin-x64": "1.28.0",
|
|
29
|
+
"@jdxcode/aube-ffi-linux-arm64": "1.28.0",
|
|
30
|
+
"@jdxcode/aube-ffi-linux-x64": "1.28.0",
|
|
31
|
+
"@jdxcode/aube-ffi-linux-arm64-musl": "1.28.0",
|
|
32
|
+
"@jdxcode/aube-ffi-linux-x64-musl": "1.28.0",
|
|
33
|
+
"@jdxcode/aube-ffi-win32-arm64": "1.28.0",
|
|
34
|
+
"@jdxcode/aube-ffi-win32-x64": "1.28.0"
|
|
35
|
+
}
|
|
8
36
|
}
|