- Extract 4756 source files from cli.js.map (57MB) - Set up Bun build system with bun:bundle feature flag shim - Configure 90+ compile-time feature flags matching production defaults - Inject MACRO constants (VERSION, BUILD_TIME, etc.) - Create stubs for private packages (color-diff-napi, modifiers-napi, etc.) - Install all public dependencies via pnpm - Patch commander v14 to allow multi-char short flags (-d2e) - Build output: dist/cli.js (22MB), verified working
26 lines
1.3 KiB
JavaScript
26 lines
1.3 KiB
JavaScript
const path = require("path");
|
|
|
|
// Discriminated union: { isSupported: false } on non-darwin,
|
|
// { isSupported: true, ...nativeFns } on darwin. Cross-platform consumers
|
|
// (claude-cli-internal) require() unconditionally and narrow on isSupported.
|
|
if (process.platform !== "darwin") {
|
|
module.exports = { isSupported: false };
|
|
} else {
|
|
// COMPUTER_USE_INPUT_NODE_PATH: escape hatch for bundlers. Bun's --compile
|
|
// embeds the .node as an asset, not in a node_modules tree — __dirname is
|
|
// the exe dir and ../prebuilds/ doesn't exist. The consuming build bakes
|
|
// this var to the embedded asset's path. Unset → normal node_modules layout.
|
|
//
|
|
// key()/keys() dispatch enigo work onto DispatchQueue.main via
|
|
// dispatch2::run_on_main, then block a tokio worker on a channel. Under
|
|
// Electron (CFRunLoop drains the main queue) this works; under libuv
|
|
// (Node/bun) the main queue never drains and the promise hangs. Consumers
|
|
// running under libuv must pump CFRunLoop while key()/keys() are pending —
|
|
// e.g. claude-cli-internal borrows @ant/computer-use-swift's _drainMainRunLoop.
|
|
const native = require(
|
|
process.env.COMPUTER_USE_INPUT_NODE_PATH ??
|
|
path.resolve(__dirname, "../prebuilds/computer-use-input.node"),
|
|
);
|
|
module.exports = { isSupported: true, ...native };
|
|
}
|