UNPKG

reboost

Version:

A super fast dev server for rapid web development

76 lines (75 loc) 2.51 kB
declare type DependentTree = { file: string; dependents: DependentTree[]; }; export interface ReboostPrivateObject { Hot_Map: HotMapType; Hot_Data_Map: Map<string, any>; setDependencies(file: string, dependencies: string[]): void; dependentTreeFor(file: string): DependentTree; } declare type AcceptCB = { /** * @param module The updated module */ (module: any): void; }; declare type DisposeCB = { /** * @param data A object that you can use to pass the data to the updated module */ (data: Record<string, any>): void; }; export interface HandlerObject { accept?: AcceptCB; dispose?: DisposeCB; } export declare type HotMapType = Map<string, { declined: boolean; listeners: Map<string, HandlerObject>; }>; export declare class Hot { private filePath; constructor(filePath: string); private callSetter; private resolveDependency; /** The data passed from the disposal callbacks */ get data(): Record<string, any>; /** The id of the module, it can be used as a key to store data about the module */ get id(): string; /** * Sets accept listener for the module itself * @param callback The callback which will be triggered on module update */ accept(callback: AcceptCB): void; /** * Sets accept listener for a dependency of the module * @param dependency Path to the dependency * @param callback The callback which will be triggered on module update */ accept(dependency: string, callback: AcceptCB): void; /** * Sets dispose listener for the module itself * @param callback The callback which will triggered on module disposal */ dispose(callback: DisposeCB): void; /** * Sets dispose listener for a dependency of the module * @param dependency Path to the dependency * @param callback The callback which will triggered on module disposal */ dispose(dependency: string, callback: DisposeCB): void; /** Marks the module itself as not Hot Reload-able */ decline(): void; /** * Marks the dependency of the module as not Hot Reload-able * @param dependency Path to the dependency */ decline(dependency: string): void; /** Invalidates the Hot Reload phase and causes a full page reload */ invalidate(): void; private get self(); private selfAccept; private selfDispose; } export {};