Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import { openAsBlob } from 'node:fs';
|
|
import { stat } from 'node:fs/promises';
|
|
import { basename, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import type { NamedMediaSource } from '../types/index.js';
|
|
|
|
export {
|
|
createReverseWebSocketServer,
|
|
SnowLumaReverseWebSocketServer,
|
|
type SnowLumaReverseWebSocketSession,
|
|
type ReverseWebSocketServerOptions,
|
|
type ReverseWebSocketServerEvents,
|
|
} from './reverse-websocket-server.js';
|
|
|
|
/** Opens a file-backed source without buffering the entire file in memory.
|
|
* Keep the file unchanged until the send finishes; read failures are propagated. */
|
|
export async function localFile(path: string | URL): Promise<NamedMediaSource> {
|
|
const absolutePath = path instanceof URL ? fileURLToPath(path) : resolve(path);
|
|
const info = await stat(absolutePath);
|
|
|
|
if (!info.isFile()) {
|
|
throw new TypeError('localFile() requires a regular file');
|
|
}
|
|
|
|
return { source: await openAsBlob(absolutePath), filename: basename(absolutePath) };
|
|
}
|