mirror of
https://gitverse.ru/anarchic/claude-code
synced 2026-05-05 16:02:38 +00:00
new initial commit (history rewritten)
This commit is contained in:
commit
c1996f2e3b
1907 changed files with 514172 additions and 0 deletions
23
utils/computerUse/swiftLoader.ts
Normal file
23
utils/computerUse/swiftLoader.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import type { ComputerUseAPI } from '@ant/computer-use-swift'
|
||||
|
||||
let cached: ComputerUseAPI | undefined
|
||||
|
||||
/**
|
||||
* Package's js/index.js reads COMPUTER_USE_SWIFT_NODE_PATH (baked by
|
||||
* build-with-plugins.ts on darwin targets, unset otherwise — falls through to
|
||||
* the node_modules prebuilds/ path). We cache the loaded native module.
|
||||
*
|
||||
* The four @MainActor methods (captureExcluding, captureRegion,
|
||||
* apps.listInstalled, resolvePrepareCapture) dispatch to DispatchQueue.main
|
||||
* and will hang under libuv unless CFRunLoop is pumped — call sites wrap
|
||||
* these in drainRunLoop().
|
||||
*/
|
||||
export function requireComputerUseSwift(): ComputerUseAPI {
|
||||
if (process.platform !== 'darwin') {
|
||||
throw new Error('@ant/computer-use-swift is macOS-only')
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
return (cached ??= require('@ant/computer-use-swift') as ComputerUseAPI)
|
||||
}
|
||||
|
||||
export type { ComputerUseAPI }
|
||||
Loading…
Add table
Add a link
Reference in a new issue