@jdxcode/aube-node 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 CHANGED
@@ -1,3 +1,84 @@
1
- # @jdxcode/aube-node
1
+ # aube Node-API bindings
2
2
 
3
- Placeholder release reserving this name for [aube](https://github.com/jdx/aube)'s embedding packages. The real packages are published by aube's release automation.
3
+ `@jdxcode/aube-node` embeds aube's installer in JavaScript hosts, including
4
+ Node.js, Bun, Electron, and compiled Bun executables.
5
+
6
+ ```ts
7
+ import { install } from "@jdxcode/aube-node"
8
+
9
+ const result = await install(projectDirectory, {
10
+ add: [
11
+ { name: "react", version: "19.1.0" },
12
+ { name: "typescript", version: "5.9.3", dev: true },
13
+ ],
14
+ signal: abortController.signal,
15
+ onEvent(event) {
16
+ switch (event.kind) {
17
+ case "phase":
18
+ console.log(event.phase)
19
+ break
20
+ case "progress":
21
+ console.log(event.resolved, event.downloaded)
22
+ break
23
+ case "output":
24
+ console.log(event.level, event.code, event.message)
25
+ break
26
+ }
27
+ },
28
+ })
29
+
30
+ console.log(result.durationMs)
31
+ ```
32
+
33
+ The addon creates an empty package manifest when needed, saves added packages
34
+ at exact versions, and installs declared dependencies. Added entries with
35
+ `dev: true` are saved to `devDependencies`. Root and dependency lifecycle
36
+ scripts are always skipped. Registry/auth settings and dependency-section
37
+ omission come from the project's `.npmrc`; `omit=dev` and `omit=optional` are
38
+ honored.
39
+
40
+ Independent projects install concurrently using invocation-scoped state.
41
+ Operations targeting the same workspace serialize on its project lock.
42
+ `onEvent` uses a non-blocking Node-API thread-safe function, and `signal`
43
+ cooperatively cancels at a safe install boundary.
44
+
45
+ Rejected promises are `AubeError` objects with a stable `code` and a
46
+ human-readable `diagnostic`. Published `ERR_AUBE_*` values follow aube's
47
+ [error-code stability policy](https://github.com/jdx/aube/blob/main/docs/error-codes.md).
48
+
49
+ ## Compiled Bun executables
50
+
51
+ Add `bunPlugin({ os, arch, libc })` from `@jdxcode/aube-node/bun-plugin` to each
52
+ target's `Bun.build` plugins. The plugin resolves the root import to the
53
+ selected native platform package so each executable embeds one addon.
54
+
55
+ Cross-compilation hosts must install every optional platform package before
56
+ building targets for other operating systems and architectures:
57
+
58
+ ```sh
59
+ bun install --os="*" --cpu="*" @jdxcode/aube-node@$AUBE_NODE_VERSION
60
+ ```
61
+
62
+ ## Compatibility and stability
63
+
64
+ - The addon targets Node-API 8.
65
+ - Node.js 18 and newer are supported.
66
+ - Bun 1.3.11 is exercised by direct and compiled-executable smoke tests.
67
+ - macOS arm64/x64, Windows arm64/x64, Linux glibc arm64/x64, and Linux musl
68
+ arm64/x64 packages are published.
69
+ - Package versions track the aube workspace version.
70
+ - The TypeScript API follows semantic versioning; stable error identifiers are
71
+ not removed or repurposed.
72
+
73
+ ## Development
74
+
75
+ Run the direct Bun and compiled-executable smoke tests from the repository
76
+ root:
77
+
78
+ ```sh
79
+ crates/aube-node/poc/run.sh
80
+ ```
81
+
82
+ CI also installs the generated npm tarballs in Node and Bun consumers and
83
+ type-checks the public declarations. For support, use
84
+ [GitHub Discussions](https://github.com/jdx/aube/discussions).
@@ -0,0 +1,22 @@
1
+ export type AubeNodeTarget = {
2
+ os: "darwin" | "linux" | "win32"
3
+ arch: "arm64" | "x64"
4
+ libc?: "glibc" | "musl"
5
+ }
6
+
7
+ export type AubeNodeBunPlugin = {
8
+ name: string
9
+ setup(build: {
10
+ onResolve(
11
+ options: { filter: RegExp },
12
+ callback: () => { path: string; namespace?: string },
13
+ ): void
14
+ onLoad(
15
+ options: { filter: RegExp; namespace: string },
16
+ callback: () => { contents: string; loader: "js" },
17
+ ): void
18
+ }): void
19
+ }
20
+
21
+ export function platformPackage(target: AubeNodeTarget): string
22
+ export function bunPlugin(target: AubeNodeTarget): AubeNodeBunPlugin
package/bun-plugin.js ADDED
@@ -0,0 +1,31 @@
1
+ function platformPackage(target) {
2
+ const { os, arch } = target
3
+ const supported = (os === "darwin" || os === "win32" || os === "linux") && (arch === "arm64" || arch === "x64")
4
+ if (!supported) throw new Error(`Unsupported aube Node-API build target: ${os}-${arch}`)
5
+ const libc = os === "linux" && target.libc === "musl" ? "-musl" : ""
6
+ return `@jdxcode/aube-node-${os}-${arch}${libc}`
7
+ }
8
+
9
+ function bunPlugin(target) {
10
+ const packageName = platformPackage(target)
11
+ const addon = require.resolve(packageName)
12
+ return {
13
+ name: "aube-node-platform",
14
+ setup(build) {
15
+ build.onResolve({ filter: /^@jdxcode\/aube-node$/ }, () => ({
16
+ path: "aube-node-platform",
17
+ namespace: "aube-node",
18
+ }))
19
+ build.onLoad({ filter: /.*/, namespace: "aube-node" }, () => ({
20
+ contents: [
21
+ `const addon = require(${JSON.stringify(addon)})`,
22
+ "export const install = addon.install",
23
+ "export default addon",
24
+ ].join("\n"),
25
+ loader: "js",
26
+ }))
27
+ },
28
+ }
29
+ }
30
+
31
+ module.exports = { bunPlugin, platformPackage }
package/index.d.ts ADDED
@@ -0,0 +1,34 @@
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 interface AubeError extends Error {
15
+ code: string
16
+ diagnostic: string
17
+ }
18
+
19
+ export type InstallInput = {
20
+ add?: { name: string; version?: string; dev?: boolean }[]
21
+ force?: boolean
22
+ offline?: boolean
23
+ onEvent?: (event: InstallEvent) => void
24
+ signal?: AbortSignal
25
+ }
26
+ export type InstallResult = {
27
+ projectDir: string
28
+ added: string[]
29
+ resolved: number
30
+ reused: number
31
+ downloaded: number
32
+ durationMs: number
33
+ }
34
+ export function install(projectDir: string, input?: InstallInput): Promise<InstallResult>
package/index.js CHANGED
@@ -1 +1,31 @@
1
- throw new Error("@jdxcode/aube-node 0.0.1-placeholder is a placeholder published to reserve the package name; install a real release instead: https://github.com/jdx/aube")
1
+ const fs = require("node:fs")
2
+ const childProcess = require("node:child_process")
3
+
4
+ function isMusl() {
5
+ if (fs.existsSync("/etc/alpine-release")) return true
6
+ try {
7
+ if (process.report.getReport().header.glibcVersionRuntime) return false
8
+ } catch (_) {}
9
+ try {
10
+ return childProcess.execFileSync("ldd", ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] })
11
+ .toLowerCase().includes("musl")
12
+ } catch (error) {
13
+ return `${error.stdout || ""}\n${error.stderr || ""}`.toLowerCase().includes("musl")
14
+ }
15
+ }
16
+
17
+ function load() {
18
+ const key = `${process.platform}-${process.arch}`
19
+ if (key === "darwin-arm64") return require("@jdxcode/aube-node-darwin-arm64")
20
+ if (key === "darwin-x64") return require("@jdxcode/aube-node-darwin-x64")
21
+ if (key === "win32-arm64") return require("@jdxcode/aube-node-win32-arm64")
22
+ if (key === "win32-x64") return require("@jdxcode/aube-node-win32-x64")
23
+ if (key === "linux-arm64" && isMusl()) return require("@jdxcode/aube-node-linux-arm64-musl")
24
+ if (key === "linux-arm64") return require("@jdxcode/aube-node-linux-arm64")
25
+ if (key === "linux-x64" && isMusl()) return require("@jdxcode/aube-node-linux-x64-musl")
26
+ if (key === "linux-x64") return require("@jdxcode/aube-node-linux-x64")
27
+ throw new Error(`Unsupported aube Node-API platform: ${key}`)
28
+ }
29
+
30
+ const addon = load()
31
+ exports.install = addon.install
package/package.json CHANGED
@@ -1,8 +1,40 @@
1
1
  {
2
2
  "name": "@jdxcode/aube-node",
3
- "version": "0.0.1-placeholder",
4
- "description": "Placeholder reserving the name for aube's first embedding release. Do not install; see https://github.com/jdx/aube",
3
+ "version": "1.28.0",
4
+ "description": "Node-API 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
+ "./bun-plugin": {
15
+ "types": "./bun-plugin.d.ts",
16
+ "default": "./bun-plugin.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "bun-plugin.js",
23
+ "bun-plugin.d.ts",
24
+ "README.md"
25
+ ],
26
+ "preferUnplugged": true,
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "optionalDependencies": {
31
+ "@jdxcode/aube-node-darwin-arm64": "1.28.0",
32
+ "@jdxcode/aube-node-darwin-x64": "1.28.0",
33
+ "@jdxcode/aube-node-linux-arm64": "1.28.0",
34
+ "@jdxcode/aube-node-linux-x64": "1.28.0",
35
+ "@jdxcode/aube-node-linux-arm64-musl": "1.28.0",
36
+ "@jdxcode/aube-node-linux-x64-musl": "1.28.0",
37
+ "@jdxcode/aube-node-win32-arm64": "1.28.0",
38
+ "@jdxcode/aube-node-win32-x64": "1.28.0"
39
+ }
8
40
  }