UNPKG

rsbuild-plugin-react-router

Version:
28 lines (27 loc) 1.82 kB
import { type FSWatcher } from 'node:fs'; import type { RsbuildConfig } from '@rsbuild/core'; import type { Route } from './types.js'; type RouteManifestSnapshotEntry = Pick<Route, 'caseSensitive' | 'file' | 'id' | 'index' | 'parentId' | 'path'>; type RouteManifestSnapshotEntryPair = readonly [ string, RouteManifestSnapshotEntry ]; type RouteManifestSnapshotEntries = Record<string, RouteManifestSnapshotEntry> | ReadonlyArray<RouteManifestSnapshotEntryPair>; type WatchFilesConfig = NonNullable<NonNullable<RsbuildConfig['dev']>['watchFiles']>; export type WatchFileConfig = Exclude<WatchFilesConfig, readonly unknown[]> | Extract<WatchFilesConfig, readonly unknown[]>[number]; type DirectoryWatcher = Pick<FSWatcher, 'close'>; type WatchDirectoryEntry = (directory: string, onChange: () => void, onError: (error: unknown) => void) => DirectoryWatcher; export declare const mergeWatchFiles: (existing: WatchFilesConfig | undefined, additions: WatchFileConfig[]) => WatchFilesConfig; export declare const getRouteRestartMarkerPath: (outputClientPath: string) => string; export declare const createRouteManifestSnapshot: (routes: RouteManifestSnapshotEntries) => Set<string>; export declare const ensureDevRestartMarker: (restartMarkerPath: string) => Promise<void>; export declare const createRouteTopologyWatcher: ({ watchDirectory, getRouteTopology, initialRouteTopology, restartMarkerPath, onError, onRouteTopologyChange, watchDirectoryEntry: watchDirectoryOverride, }: { watchDirectory: string; getRouteTopology: () => Promise<Set<string>>; initialRouteTopology?: Set<string>; restartMarkerPath: string; onError: (error: unknown) => void; onRouteTopologyChange?: () => void | Promise<void>; watchDirectoryEntry?: WatchDirectoryEntry; }) => Promise<() => Promise<void>>; export {};