@marp-team/marp-cli
Version:
A CLI interface for Marp and Marpit based converters
52 lines (51 loc) • 1.76 kB
TypeScript
import { type FSWatcher } from 'chokidar';
import { WebSocketServer } from 'ws';
import type { ServerOptions } from 'ws';
import { Converter, ConvertedCallback } from './converter';
import { File } from './file';
export declare class Watcher {
chokidar: FSWatcher;
readonly converter: Converter;
readonly events: Watcher.Events;
readonly finder: Watcher.Options['finder'];
readonly mode: Watcher.WatchMode;
private constructor();
private log;
private convert;
private delete;
static watch(watchPath: string[], opts: Watcher.Options): Watcher;
}
export type WatchNotifierEntrypointType = 'static' | 'server';
export declare class WatchNotifier {
listeners: Map<string, Set<any>>;
private wss?;
private portNumber?;
static readonly webSocketEntrypoint = ".__marp-cli-watch-notifier__";
get server(): WebSocketServer | undefined;
port(): Promise<number>;
register(fn: string, entrypointType?: WatchNotifierEntrypointType): Promise<string>;
entrypoint(identifier: string, entrypointType?: WatchNotifierEntrypointType): Promise<string>;
sendTo(fn: string, command: string): boolean;
start(opts?: ServerOptions): Promise<void>;
stop(): Promise<boolean>;
static sha256(fn: string): string;
}
export declare const notifier: WatchNotifier;
declare const _default: typeof Watcher.watch;
export default _default;
export declare namespace Watcher {
enum WatchMode {
Convert = 0,
Notify = 1
}
interface Options {
converter: Converter;
events: Watcher.Events;
finder: () => Promise<File[]>;
mode: WatchMode;
}
interface Events {
onConverted: ConvertedCallback;
onError: (e: Error) => void;
}
}