Download packages/pi-tui/src/native-module-path.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/pi-tui/src/native-module-path.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/pi-tui/src/native-module-path.ts
-
curl -L -o native-module-path.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/pi-tui/src/native-module-path.ts
1.05 kB
| import { createRequire } from "node:module"; | |
| import { dirname, join } from "node:path"; | |
| import { fileURLToPath } from "node:url"; | |
| const moduleRequire = createRequire(import.meta.url); | |
| const TUI_PACKAGE_NAME = "@moonshot-ai/pi-tui"; | |
| export interface NativeModuleCandidateOptions { | |
| moduleUrl?: string; | |
| execPath?: string; | |
| resolvePackage?: (specifier: string) => string; | |
| } | |
| export function getNativeModuleCandidates(nativePath: string, options: NativeModuleCandidateOptions = {}): string[] { | |
| const moduleDir = dirname(fileURLToPath(options.moduleUrl ?? import.meta.url)); | |
| const candidates: string[] = []; | |
| try { | |
| const packageEntry = (options.resolvePackage ?? moduleRequire.resolve)(TUI_PACKAGE_NAME); | |
| candidates.push(join(dirname(packageEntry), "..", nativePath)); | |
| } catch { | |
| // Standalone binaries do not have an installed TUI package. | |
| } | |
| candidates.push( | |
| join(moduleDir, "..", nativePath), | |
| join(moduleDir, nativePath), | |
| join(dirname(options.execPath ?? process.execPath), nativePath), | |
| ); | |
| return Array.from(new Set(candidates)); | |
| } | |