1 | import { ServerConnection, ServiceManager } from '@jupyterlab/services';
|
2 | import { ITranslator } from '@jupyterlab/translation';
|
3 | import { CommandRegistry } from '@lumino/commands';
|
4 | import { ReadonlyPartialJSONObject, Token } from '@lumino/coreutils';
|
5 | import { IDisposable } from '@lumino/disposable';
|
6 | import { ISignal } from '@lumino/signaling';
|
7 | /**
|
8 | * A token for which a plugin can provide to respond to connection failures
|
9 | * to the application server.
|
10 | */
|
11 | export declare const IConnectionLost: Token<IConnectionLost>;
|
12 | /**
|
13 | * A function that handles a connection to the server being lost.
|
14 | *
|
15 | * #### Notes
|
16 | * The default implementation shows a simple dialog upon connection
|
17 | * failures, but it may be overridden by extensions to perform other
|
18 | * actions.
|
19 | */
|
20 | export declare type IConnectionLost = (manager: ServiceManager.IManager, err: ServerConnection.NetworkError, translator?: ITranslator) => Promise<void>;
|
21 | /**
|
22 | * The URL Router token.
|
23 | */
|
24 | export declare const IRouter: Token<IRouter>;
|
25 | /**
|
26 | * A static class that routes URLs within the application.
|
27 | */
|
28 | export interface IRouter {
|
29 | /**
|
30 | * The base URL for the router.
|
31 | */
|
32 | readonly base: string;
|
33 | /**
|
34 | * The command registry used by the router.
|
35 | */
|
36 | readonly commands: CommandRegistry;
|
37 | /**
|
38 | * The parsed current URL of the application.
|
39 | */
|
40 | readonly current: IRouter.ILocation;
|
41 | /**
|
42 | * A signal emitted when the router routes a route.
|
43 | */
|
44 | readonly routed: ISignal<IRouter, IRouter.ILocation>;
|
45 | /**
|
46 | * If a matching rule's command resolves with the `stop` token during routing,
|
47 | * no further matches will execute.
|
48 | */
|
49 | readonly stop: Token<void>;
|
50 | /**
|
51 | * Navigate to a new path within the application.
|
52 | *
|
53 | * @param path - The new path or empty string if redirecting to root.
|
54 | *
|
55 | * @param options - The navigation options.
|
56 | */
|
57 | navigate(path: string, options?: IRouter.INavOptions): void;
|
58 | /**
|
59 | * Register a rule that maps a path pattern to a command.
|
60 | *
|
61 | * @param options - The route registration options.
|
62 | *
|
63 | * @returns A disposable that removes the registered rule from the router.
|
64 | */
|
65 | register(options: IRouter.IRegisterOptions): IDisposable;
|
66 | /**
|
67 | * Cause a hard reload of the document.
|
68 | */
|
69 | reload(): void;
|
70 | /**
|
71 | * Route a specific path to an action.
|
72 | *
|
73 | * @param url - The URL string that will be routed.
|
74 | *
|
75 | * #### Notes
|
76 | * If a pattern is matched, its command will be invoked with arguments that
|
77 | * match the `IRouter.ILocation` interface.
|
78 | */
|
79 | route(url: string): void;
|
80 | }
|
81 | /**
|
82 | * A namespace for the `IRouter` specification.
|
83 | */
|
84 | export declare namespace IRouter {
|
85 | /**
|
86 | * The parsed location currently being routed.
|
87 | */
|
88 | interface ILocation extends ReadonlyPartialJSONObject {
|
89 | /**
|
90 | * The location hash.
|
91 | */
|
92 | hash: string;
|
93 | /**
|
94 | * The path that matched a routing pattern.
|
95 | */
|
96 | path: string;
|
97 | /**
|
98 | * The request being routed with the router `base` omitted.
|
99 | *
|
100 | * #### Notes
|
101 | * This field includes the query string and hash, if they exist.
|
102 | */
|
103 | request: string;
|
104 | /**
|
105 | * The search element, including leading question mark (`'?'`), if any,
|
106 | * of the path.
|
107 | */
|
108 | search?: string;
|
109 | }
|
110 | /**
|
111 | * The options passed into a navigation request.
|
112 | */
|
113 | interface INavOptions {
|
114 | /**
|
115 | * Whether the navigation should be hard URL change instead of an HTML
|
116 | * history API change.
|
117 | */
|
118 | hard?: boolean;
|
119 | /**
|
120 | * Should the routing stage be skipped when navigating? This will simply rewrite the URL
|
121 | * and push the new state to the history API, no routing commands will be triggered.
|
122 | */
|
123 | skipRouting?: boolean;
|
124 | }
|
125 | /**
|
126 | * The specification for registering a route with the router.
|
127 | */
|
128 | interface IRegisterOptions {
|
129 | /**
|
130 | * The command string that will be invoked upon matching.
|
131 | */
|
132 | command: string;
|
133 | /**
|
134 | * The regular expression that will be matched against URLs.
|
135 | */
|
136 | pattern: RegExp;
|
137 | /**
|
138 | * The rank order of the registered rule. A lower rank denotes a higher
|
139 | * priority. The default rank is `100`.
|
140 | */
|
141 | rank?: number;
|
142 | }
|
143 | }
|