vite-plugin-react18-pages
Version:
<p> <a href="https://www.npmjs.com/package/vite-plugin-react-pages" target="_blank" rel="noopener"><img src="https://img.shields.io/npm/v/vite-plugin-react-pages.svg" alt="npm package" /></a> </p>
71 lines • 3.12 kB
TypeScript
import { PendingState } from './utils';
export declare class VirtualModuleGraph {
/**
* the module inside this graph may be virtule module or real fs module
*/
private readonly modules;
/**
* Serialize the update works (instead of doing them concurrently)
* to make the result more predictable.
*
* If there is already a queuing update with same updaterId,
* it won't schedule a new one.
*
* Before executing an updater, it will automatically cleanup the effects of
* previous update with same updaterId.
* Example:
* When find module1 for the first time:
* the updater set data for module2 and module3 (upstreamModule is module1)
* Then, when observe that module1 is updated:
* the updater set data for module2 (upstreamModule is module1)
* At this time, the data in module3 should be automatically cleanup!
* So the updater(users) don't need to manually delete the old data in module3.
*/
private updateQueue;
/** track updateQueue empty state (isPending means not empty) */
updateQueueEmptyState: PendingState;
getModuleIds(filter?: (moduleId: string) => boolean): string[];
getModuleData(moduleId: string): any[];
getModules(filter?: (moduleId: string) => boolean): {
[id: string]: any[];
};
/**
* This is the only way to update virtule modules
*/
scheduleUpdate(updaterId: string, updater: Update['updater']): void;
addModuleListener(handler: ModuleListener, filter?: (moduleId: string) => boolean): () => void;
/**
* listen to virtule module updates.
* users can scheduleUpdate in these listeners, creating dependency chain of
* virtule modules.
* (.i.e when a virtule module changes, it will update another virtule module)
*
* users will reveive new module data and previous module data,
* so users can diff them to decide whether the module has "really" changed.
* if users think they are the same, the can skip updating other virtule modules.
* VirtualModuleGraph works on a very low level. It don't know what module data means. So it send updates event to users very often and let users to interpret module data.
*
* @return unsubscribe function
*/
private _addModuleListener;
private moduleUpdateListeners;
private callModuleUpdateListeners;
updateExecutingState: PendingState;
private executeUpdates;
private executeUpdates_Inner;
private createUpdateAPIs;
private ensureModule;
}
export declare type ModuleListener = (moduleId: string, data: any[], prevData: any[]) => void;
export interface VirtuleModuleAPIs {
addModuleData(moduleId: string, data: any, upstreamModuleId: string): void;
getModuleData(moduleId: string): any[];
deleteModule(moduleId: string): void;
}
declare class Update {
updaterId: string;
updater: (apis: VirtuleModuleAPIs) => void | Promise<void>;
constructor(updaterId: string, updater: (apis: VirtuleModuleAPIs) => void | Promise<void>);
}
export {};
//# sourceMappingURL=VirtualModules.d.ts.map