NapCatQQ/packages/napcat-pty/index.ts
手瓜一十雪 4360775eff
refactor: 整体重构 (#1381)
* feat: pnpm new

* Refactor build and release workflows, update dependencies

Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
2025-11-13 15:39:42 +08:00

32 lines
1.3 KiB
TypeScript

import type { ITerminal, IPtyOpenOptions, IPtyForkOptions, IWindowsPtyForkOptions } from '@homebridge/node-pty-prebuilt-multiarch/src/interfaces';
import type { ArgvOrCommandLine } from './node_modules/@homebridge/node-pty-prebuilt-multiarch/src/types';
// import type { ArgvOrCommandLine } from '@homebridge/node-pty-prebuilt-multiarch/src/types';
import { WindowsTerminal } from './windowsTerminal';
import { UnixTerminal } from './unixTerminal';
import { fileURLToPath } from 'node:url';
import path, { dirname } from 'node:path';
let terminalCtor: typeof WindowsTerminal | typeof UnixTerminal;
if (process.platform === 'win32') {
terminalCtor = WindowsTerminal;
} else {
terminalCtor = UnixTerminal;
}
export function spawn (file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal {
// eslint-disable-next-line new-cap
return new terminalCtor(file, args, opt);
}
export function open (options: IPtyOpenOptions): ITerminal {
return terminalCtor.open(options) as ITerminal;
}
export function require_dlopen (modulename: string) {
const module = { exports: {} };
const import__dirname = dirname(fileURLToPath(import.meta.url));
process.dlopen(module, path.join(import__dirname, modulename));
return module.exports as any;
}