UNPKG

2.34 kBTypeScriptView Raw
1import { CommandRegistry } from '@lumino/commands';
2import { Token } from '@lumino/coreutils';
3import { IDisposable } from '@lumino/disposable';
4import { ISignal } from '@lumino/signaling';
5import { IRouter } from './tokens';
6/**
7 * A static class that routes URLs within the application.
8 */
9export declare class Router implements IRouter {
10 /**
11 * Create a URL router.
12 */
13 constructor(options: Router.IOptions);
14 /**
15 * The base URL for the router.
16 */
17 readonly base: string;
18 /**
19 * The command registry used by the router.
20 */
21 readonly commands: CommandRegistry;
22 /**
23 * Returns the parsed current URL of the application.
24 */
25 get current(): IRouter.ILocation;
26 /**
27 * A signal emitted when the router routes a route.
28 */
29 get routed(): ISignal<this, IRouter.ILocation>;
30 /**
31 * If a matching rule's command resolves with the `stop` token during routing,
32 * no further matches will execute.
33 */
34 readonly stop: Token<void>;
35 /**
36 * Navigate to a new path within the application.
37 *
38 * @param path - The new path or empty string if redirecting to root.
39 *
40 * @param options - The navigation options.
41 */
42 navigate(path: string, options?: IRouter.INavOptions): void;
43 /**
44 * Register to route a path pattern to a command.
45 *
46 * @param options - The route registration options.
47 *
48 * @returns A disposable that removes the registered rule from the router.
49 */
50 register(options: IRouter.IRegisterOptions): IDisposable;
51 /**
52 * Cause a hard reload of the document.
53 */
54 reload(): void;
55 /**
56 * Route a specific path to an action.
57 *
58 * #### Notes
59 * If a pattern is matched, its command will be invoked with arguments that
60 * match the `IRouter.ILocation` interface.
61 */
62 route(): Promise<void>;
63 private _routed;
64 private _rules;
65}
66/**
67 * A namespace for `Router` class statics.
68 */
69export declare namespace Router {
70 /**
71 * The options for instantiating a JupyterLab URL router.
72 */
73 interface IOptions {
74 /**
75 * The fully qualified base URL for the router.
76 */
77 base: string;
78 /**
79 * The command registry used by the router.
80 */
81 commands: CommandRegistry;
82 }
83}