πŸ“„ File detail

utils/computerUse/swiftLoader.ts

🧩 .tsπŸ“ 24 linesπŸ’Ύ 925 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes requireComputerUseSwift β€” mainly functions, hooks, or classes. Dependencies touch @ant.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

import type { ComputerUseAPI } from '@ant/computer-use-swift' let cached: ComputerUseAPI | undefined /**

πŸ“€ Exports (heuristic)

  • requireComputerUseSwift

πŸ“š External import roots

Package roots from from "…" (relative paths omitted).

  • @ant

πŸ–₯️ Source preview

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 }