minimal-piral 0.15.0-beta.4630 → 0.15.0-beta.4670
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/{index.b77a5c.js → index.8da693.js} +140 -31
- package/app/index.8da693.js.map +1 -0
- package/app/index.d.ts +514 -512
- package/app/index.html +1 -1
- package/app/index.js +1 -1
- package/files.tar +0 -0
- package/files_once.tar +0 -0
- package/package.json +5 -5
- package/app/index.b77a5c.js.map +0 -1
package/app/index.d.ts
CHANGED
|
@@ -1,571 +1,573 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as ReactRouter from 'react-router';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Gets the metadata of the current pilet.
|
|
11
|
-
*/
|
|
12
|
-
meta: PiletMetadata;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The emitter for Piral app shell events.
|
|
17
|
-
*/
|
|
18
|
-
export interface EventEmitter {
|
|
19
|
-
/**
|
|
20
|
-
* Attaches a new event listener.
|
|
21
|
-
* @param type The type of the event to listen for.
|
|
22
|
-
* @param callback The callback to trigger.
|
|
23
|
-
*/
|
|
24
|
-
on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
25
|
-
/**
|
|
26
|
-
* Detaches an existing event listener.
|
|
27
|
-
* @param type The type of the event to listen for.
|
|
28
|
-
* @param callback The callback to trigger.
|
|
29
|
-
*/
|
|
30
|
-
off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
31
|
-
/**
|
|
32
|
-
* Emits a new event with the given type.
|
|
33
|
-
* @param type The type of the event to emit.
|
|
34
|
-
* @param arg The payload of the event.
|
|
35
|
-
*/
|
|
36
|
-
emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Custom Pilet API parts defined outside of piral-core.
|
|
41
|
-
*/
|
|
42
|
-
export interface PiletCustomApi {}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Defines the Pilet API from piral-core.
|
|
46
|
-
* This interface will be consumed by pilet developers so that their pilet can interact with the piral instance.
|
|
47
|
-
*/
|
|
48
|
-
export interface PiletCoreApi {
|
|
49
|
-
/**
|
|
50
|
-
* Gets a shared data value.
|
|
51
|
-
* @param name The name of the data to retrieve.
|
|
52
|
-
*/
|
|
53
|
-
getData<TKey extends string>(name: TKey): SharedData[TKey];
|
|
54
|
-
/**
|
|
55
|
-
* Sets the data using a given name. The name needs to be used exclusively by the current pilet.
|
|
56
|
-
* Using the name occupied by another pilet will result in no change.
|
|
57
|
-
* @param name The name of the data to store.
|
|
58
|
-
* @param value The value of the data to store.
|
|
59
|
-
* @param options The optional configuration for storing this piece of data.
|
|
60
|
-
* @returns True if the data could be set, otherwise false.
|
|
61
|
-
*/
|
|
62
|
-
setData<TKey extends string>(name: TKey, value: SharedData[TKey], options?: DataStoreOptions): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Registers a route for predefined page component.
|
|
65
|
-
* The route needs to be unique and can contain params.
|
|
66
|
-
* Params are following the path-to-regexp notation, e.g., :id for an id parameter.
|
|
67
|
-
* @param route The route to register.
|
|
68
|
-
* @param Component The component to render the page.
|
|
69
|
-
* @param meta The optional metadata to use.
|
|
70
|
-
*/
|
|
71
|
-
registerPage(route: string, Component: AnyComponent<PageComponentProps>, meta?: PiralPageMeta): RegistrationDisposer;
|
|
72
|
-
/**
|
|
73
|
-
* Unregisters the page identified by the given route.
|
|
74
|
-
* @param route The route that was previously registered.
|
|
75
|
-
*/
|
|
76
|
-
unregisterPage(route: string): void;
|
|
77
|
-
/**
|
|
78
|
-
* Registers an extension component with a predefined extension component.
|
|
79
|
-
* The name must refer to the extension slot.
|
|
80
|
-
* @param name The global name of the extension slot.
|
|
81
|
-
* @param Component The component to be rendered.
|
|
82
|
-
* @param defaults Optionally, sets the default values for the expected data.
|
|
83
|
-
*/
|
|
84
|
-
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
|
|
85
|
-
/**
|
|
86
|
-
* Unregisters a global extension component.
|
|
87
|
-
* Only previously registered extension components can be unregistered.
|
|
88
|
-
* @param name The name of the extension slot to unregister from.
|
|
89
|
-
* @param Component The registered extension component to unregister.
|
|
90
|
-
*/
|
|
91
|
-
unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>): void;
|
|
92
|
-
/**
|
|
93
|
-
* React component for displaying extensions for a given name.
|
|
94
|
-
* @param props The extension's rendering props.
|
|
95
|
-
* @return The created React element.
|
|
96
|
-
*/
|
|
97
|
-
Extension<TName>(props: ExtensionSlotProps<TName>): React.ReactElement | null;
|
|
98
|
-
/**
|
|
99
|
-
* Renders an extension in a plain DOM component.
|
|
100
|
-
* @param element The DOM element or shadow root as a container for rendering the extension.
|
|
101
|
-
* @param props The extension's rendering props.
|
|
102
|
-
* @return The disposer to clear the extension.
|
|
103
|
-
*/
|
|
104
|
-
renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Describes the metadata of a pilet available in its API.
|
|
109
|
-
*/
|
|
110
|
-
export interface PiletMetadata {
|
|
111
|
-
/**
|
|
112
|
-
* The name of the pilet, i.e., the package id.
|
|
113
|
-
*/
|
|
114
|
-
name: string;
|
|
115
|
-
/**
|
|
116
|
-
* The version of the pilet. Should be semantically versioned.
|
|
117
|
-
*/
|
|
118
|
-
version: string;
|
|
119
|
-
/**
|
|
120
|
-
* Provides the version of the specification for this pilet.
|
|
121
|
-
*/
|
|
122
|
-
spec: string;
|
|
123
|
-
/**
|
|
124
|
-
* Provides some custom metadata for the pilet.
|
|
125
|
-
*/
|
|
126
|
-
custom?: any;
|
|
127
|
-
/**
|
|
128
|
-
* Optionally indicates the global require reference, if any.
|
|
129
|
-
*/
|
|
130
|
-
requireRef?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Additional shared dependencies from the pilet.
|
|
133
|
-
*/
|
|
134
|
-
dependencies: Record<string, string>;
|
|
135
|
-
/**
|
|
136
|
-
* Provides some configuration to be used in the pilet.
|
|
137
|
-
*/
|
|
138
|
-
config: Record<string, any>;
|
|
139
|
-
/**
|
|
140
|
-
* The URL of the main script of the pilet.
|
|
141
|
-
*/
|
|
142
|
-
link: string;
|
|
143
|
-
/**
|
|
144
|
-
* The base path to the pilet. Can be used to make resource requests
|
|
145
|
-
* and override the public path.
|
|
146
|
-
*/
|
|
147
|
-
basePath: string;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Listener for Piral app shell events.
|
|
152
|
-
*/
|
|
153
|
-
export interface Listener<T> {
|
|
154
|
-
(arg: T): void;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* The map of known Piral app shell events.
|
|
159
|
-
*/
|
|
160
|
-
export interface PiralEventMap extends PiralCustomEventMap {
|
|
161
|
-
"unload-pilet": PiralUnloadPiletEvent;
|
|
162
|
-
[custom: string]: any;
|
|
163
|
-
"store-data": PiralStoreDataEvent;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Defines the shape of the data store for storing shared data.
|
|
4
|
+
/**
|
|
5
|
+
* Defines the API accessible from pilets.
|
|
6
|
+
*/
|
|
7
|
+
export interface PiletApi extends EventEmitter, PiletCustomApi, PiletCoreApi {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the metadata of the current pilet.
|
|
168
10
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
11
|
+
meta: PiletMetadata;
|
|
12
|
+
}
|
|
172
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The emitter for Piral app shell events.
|
|
16
|
+
*/
|
|
17
|
+
export interface EventEmitter {
|
|
173
18
|
/**
|
|
174
|
-
*
|
|
19
|
+
* Attaches a new event listener.
|
|
20
|
+
* @param type The type of the event to listen for.
|
|
21
|
+
* @param callback The callback to trigger.
|
|
175
22
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
23
|
+
on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
24
|
+
/**
|
|
25
|
+
* Detaches an existing event listener.
|
|
26
|
+
* @param type The type of the event to listen for.
|
|
27
|
+
* @param callback The callback to trigger.
|
|
28
|
+
*/
|
|
29
|
+
off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
178
30
|
/**
|
|
179
|
-
*
|
|
31
|
+
* Emits a new event with the given type.
|
|
32
|
+
* @param type The type of the event to emit.
|
|
33
|
+
* @param arg The payload of the event.
|
|
180
34
|
*/
|
|
181
|
-
|
|
35
|
+
emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
|
|
36
|
+
}
|
|
182
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Custom Pilet API parts defined outside of piral-core.
|
|
40
|
+
*/
|
|
41
|
+
export interface PiletCustomApi {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Defines the Pilet API from piral-core.
|
|
45
|
+
* This interface will be consumed by pilet developers so that their pilet can interact with the piral instance.
|
|
46
|
+
*/
|
|
47
|
+
export interface PiletCoreApi {
|
|
48
|
+
/**
|
|
49
|
+
* Gets a shared data value.
|
|
50
|
+
* @param name The name of the data to retrieve.
|
|
51
|
+
*/
|
|
52
|
+
getData<TKey extends string>(name: TKey): SharedData[TKey];
|
|
53
|
+
/**
|
|
54
|
+
* Sets the data using a given name. The name needs to be used exclusively by the current pilet.
|
|
55
|
+
* Using the name occupied by another pilet will result in no change.
|
|
56
|
+
* @param name The name of the data to store.
|
|
57
|
+
* @param value The value of the data to store.
|
|
58
|
+
* @param options The optional configuration for storing this piece of data.
|
|
59
|
+
* @returns True if the data could be set, otherwise false.
|
|
60
|
+
*/
|
|
61
|
+
setData<TKey extends string>(name: TKey, value: SharedData[TKey], options?: DataStoreOptions): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Registers a route for predefined page component.
|
|
64
|
+
* The route needs to be unique and can contain params.
|
|
65
|
+
* Params are following the path-to-regexp notation, e.g., :id for an id parameter.
|
|
66
|
+
* @param route The route to register.
|
|
67
|
+
* @param Component The component to render the page.
|
|
68
|
+
* @param meta The optional metadata to use.
|
|
69
|
+
*/
|
|
70
|
+
registerPage(route: string, Component: AnyComponent<PageComponentProps>, meta?: PiralPageMeta): RegistrationDisposer;
|
|
71
|
+
/**
|
|
72
|
+
* Unregisters the page identified by the given route.
|
|
73
|
+
* @param route The route that was previously registered.
|
|
74
|
+
*/
|
|
75
|
+
unregisterPage(route: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Registers an extension component with a predefined extension component.
|
|
78
|
+
* The name must refer to the extension slot.
|
|
79
|
+
* @param name The global name of the extension slot.
|
|
80
|
+
* @param Component The component to be rendered.
|
|
81
|
+
* @param defaults Optionally, sets the default values for the expected data.
|
|
82
|
+
*/
|
|
83
|
+
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
|
|
183
84
|
/**
|
|
184
|
-
*
|
|
85
|
+
* Unregisters a global extension component.
|
|
86
|
+
* Only previously registered extension components can be unregistered.
|
|
87
|
+
* @param name The name of the extension slot to unregister from.
|
|
88
|
+
* @param Component The registered extension component to unregister.
|
|
185
89
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
90
|
+
unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>): void;
|
|
91
|
+
/**
|
|
92
|
+
* React component for displaying extensions for a given name.
|
|
93
|
+
* @param props The extension's rendering props.
|
|
94
|
+
* @return The created React element.
|
|
95
|
+
*/
|
|
96
|
+
Extension<TName>(props: ExtensionSlotProps<TName>): React.ReactElement | null;
|
|
97
|
+
/**
|
|
98
|
+
* Renders an extension in a plain DOM component.
|
|
99
|
+
* @param element The DOM element or shadow root as a container for rendering the extension.
|
|
100
|
+
* @param props The extension's rendering props.
|
|
101
|
+
* @return The disposer to clear the extension.
|
|
102
|
+
*/
|
|
103
|
+
renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
|
|
104
|
+
}
|
|
192
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Describes the metadata of a pilet available in its API.
|
|
108
|
+
*/
|
|
109
|
+
export interface PiletMetadata {
|
|
110
|
+
/**
|
|
111
|
+
* The name of the pilet, i.e., the package id.
|
|
112
|
+
*/
|
|
113
|
+
name: string;
|
|
114
|
+
/**
|
|
115
|
+
* The version of the pilet. Should be semantically versioned.
|
|
116
|
+
*/
|
|
117
|
+
version: string;
|
|
193
118
|
/**
|
|
194
|
-
*
|
|
119
|
+
* Provides the version of the specification for this pilet.
|
|
195
120
|
*/
|
|
196
|
-
|
|
121
|
+
spec: string;
|
|
122
|
+
/**
|
|
123
|
+
* Provides some custom metadata for the pilet.
|
|
124
|
+
*/
|
|
125
|
+
custom?: any;
|
|
126
|
+
/**
|
|
127
|
+
* Optionally indicates the global require reference, if any.
|
|
128
|
+
*/
|
|
129
|
+
requireRef?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Additional shared dependencies from the pilet.
|
|
132
|
+
*/
|
|
133
|
+
dependencies: Record<string, string>;
|
|
134
|
+
/**
|
|
135
|
+
* Provides some configuration to be used in the pilet.
|
|
136
|
+
*/
|
|
137
|
+
config: Record<string, any>;
|
|
138
|
+
/**
|
|
139
|
+
* The URL of the main script of the pilet.
|
|
140
|
+
*/
|
|
141
|
+
link: string;
|
|
142
|
+
/**
|
|
143
|
+
* The base path to the pilet. Can be used to make resource requests
|
|
144
|
+
* and override the public path.
|
|
145
|
+
*/
|
|
146
|
+
basePath: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Listener for Piral app shell events.
|
|
151
|
+
*/
|
|
152
|
+
export interface Listener<T> {
|
|
153
|
+
(arg: T): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The map of known Piral app shell events.
|
|
158
|
+
*/
|
|
159
|
+
export interface PiralEventMap extends PiralCustomEventMap {
|
|
160
|
+
"unload-pilet": PiralUnloadPiletEvent;
|
|
161
|
+
[custom: string]: any;
|
|
162
|
+
"store-data": PiralStoreDataEvent;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Defines the shape of the data store for storing shared data.
|
|
167
|
+
*/
|
|
168
|
+
export interface SharedData<TValue = any> {
|
|
169
|
+
[key: string]: TValue;
|
|
170
|
+
}
|
|
197
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Defines the options to be used for storing data.
|
|
174
|
+
*/
|
|
175
|
+
export type DataStoreOptions = DataStoreTarget | CustomDataStoreOptions;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Possible shapes for a component.
|
|
179
|
+
*/
|
|
180
|
+
export type AnyComponent<T> = React.ComponentType<T> | FirstParametersOf<ComponentConverters<T>>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The props used by a page component.
|
|
184
|
+
*/
|
|
185
|
+
export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {
|
|
198
186
|
/**
|
|
199
|
-
* The
|
|
187
|
+
* The meta data registered with the page.
|
|
200
188
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
189
|
+
meta: PiralPageMeta;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The meta data registered for a page.
|
|
194
|
+
*/
|
|
195
|
+
export interface PiralPageMeta extends PiralCustomPageMeta, PiralCustomPageMeta {}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The shape of an implicit unregister function.
|
|
199
|
+
*/
|
|
200
|
+
export interface RegistrationDisposer {
|
|
201
|
+
(): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Shorthand for the definition of an extension component.
|
|
206
|
+
*/
|
|
207
|
+
export type AnyExtensionComponent<TName> = TName extends keyof PiralExtensionSlotMap ? AnyComponent<ExtensionComponentProps<TName>> : TName extends string ? AnyComponent<ExtensionComponentProps<any>> : AnyComponent<ExtensionComponentProps<TName>>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Gives the extension params shape for the given extension slot name.
|
|
211
|
+
*/
|
|
212
|
+
export type ExtensionParams<TName> = TName extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[TName] : TName extends string ? any : TName;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The props for defining an extension slot.
|
|
216
|
+
*/
|
|
217
|
+
export type ExtensionSlotProps<TName = string> = BaseExtensionSlotProps<TName extends string ? TName : string, ExtensionParams<TName>>;
|
|
204
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Can be implemented by functions to be used for disposal purposes.
|
|
221
|
+
*/
|
|
222
|
+
export interface Disposable {
|
|
223
|
+
(): void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Custom events defined outside of piral-core.
|
|
228
|
+
*/
|
|
229
|
+
export interface PiralCustomEventMap {}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Gets fired when a pilet gets unloaded.
|
|
233
|
+
*/
|
|
234
|
+
export interface PiralUnloadPiletEvent {
|
|
205
235
|
/**
|
|
206
|
-
*
|
|
236
|
+
* The name of the pilet to be unloaded.
|
|
207
237
|
*/
|
|
208
|
-
|
|
238
|
+
name: string;
|
|
239
|
+
}
|
|
209
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Gets fired when a data item gets stored in piral.
|
|
243
|
+
*/
|
|
244
|
+
export interface PiralStoreDataEvent<TValue = any> {
|
|
245
|
+
/**
|
|
246
|
+
* The name of the item that was stored.
|
|
247
|
+
*/
|
|
248
|
+
name: string;
|
|
249
|
+
/**
|
|
250
|
+
* The storage target of the item.
|
|
251
|
+
*/
|
|
252
|
+
target: string;
|
|
253
|
+
/**
|
|
254
|
+
* The value that was stored.
|
|
255
|
+
*/
|
|
256
|
+
value: TValue;
|
|
257
|
+
/**
|
|
258
|
+
* The owner of the item.
|
|
259
|
+
*/
|
|
260
|
+
owner: string;
|
|
210
261
|
/**
|
|
211
|
-
*
|
|
262
|
+
* The expiration of the item.
|
|
212
263
|
*/
|
|
213
|
-
|
|
264
|
+
expires: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Defines the potential targets when storing data.
|
|
269
|
+
*/
|
|
270
|
+
export type DataStoreTarget = "memory" | "local" | "remote";
|
|
214
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Defines the custom options for storing data.
|
|
274
|
+
*/
|
|
275
|
+
export interface CustomDataStoreOptions {
|
|
215
276
|
/**
|
|
216
|
-
* The
|
|
277
|
+
* The target data store. By default the data is only stored in memory.
|
|
217
278
|
*/
|
|
218
|
-
|
|
279
|
+
target?: DataStoreTarget;
|
|
280
|
+
/**
|
|
281
|
+
* Optionally determines when the data expires.
|
|
282
|
+
*/
|
|
283
|
+
expires?: "never" | Date | number;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export type FirstParametersOf<T> = {
|
|
287
|
+
[K in keyof T]: T[K] extends (arg: any) => any ? FirstParameter<T[K]> : never;
|
|
288
|
+
}[keyof T];
|
|
219
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Mapping of available component converters.
|
|
292
|
+
*/
|
|
293
|
+
export interface ComponentConverters<TProps> extends PiralCustomComponentConverters<TProps> {
|
|
220
294
|
/**
|
|
221
|
-
*
|
|
295
|
+
* Converts the HTML component to a framework-independent component.
|
|
296
|
+
* @param component The vanilla JavaScript component to be converted.
|
|
222
297
|
*/
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
298
|
+
html(component: HtmlComponent<TProps>): ForeignComponent<TProps>;
|
|
299
|
+
}
|
|
226
300
|
|
|
301
|
+
/**
|
|
302
|
+
* The props that every registered page component obtains.
|
|
303
|
+
*/
|
|
304
|
+
export interface RouteBaseProps<UrlParams = any, UrlState = any> extends ReactRouter.RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Custom meta data to include for pages.
|
|
308
|
+
*/
|
|
309
|
+
export interface PiralCustomPageMeta {}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* The props of an extension component.
|
|
313
|
+
*/
|
|
314
|
+
export interface ExtensionComponentProps<T> extends BaseComponentProps {
|
|
315
|
+
/**
|
|
316
|
+
* The provided parameters for showing the extension.
|
|
317
|
+
*/
|
|
318
|
+
params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
|
|
227
319
|
/**
|
|
228
|
-
*
|
|
320
|
+
* The optional children to receive, if any.
|
|
229
321
|
*/
|
|
230
|
-
|
|
322
|
+
children?: React.ReactNode;
|
|
323
|
+
}
|
|
231
324
|
|
|
325
|
+
/**
|
|
326
|
+
* The mapping of the existing (known) extension slots.
|
|
327
|
+
*/
|
|
328
|
+
export interface PiralExtensionSlotMap extends PiralCustomExtensionSlotMap {}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* The basic props for defining an extension slot.
|
|
332
|
+
*/
|
|
333
|
+
export interface BaseExtensionSlotProps<TName, TParams> {
|
|
334
|
+
/**
|
|
335
|
+
* The children to transport, if any.
|
|
336
|
+
*/
|
|
337
|
+
children?: React.ReactNode;
|
|
338
|
+
/**
|
|
339
|
+
* Defines what should be rendered when no components are available
|
|
340
|
+
* for the specified extension.
|
|
341
|
+
*/
|
|
342
|
+
empty?(): React.ReactNode;
|
|
343
|
+
/**
|
|
344
|
+
* Determines if the `render` function should be called in case no
|
|
345
|
+
* components are available for the specified extension.
|
|
346
|
+
*
|
|
347
|
+
* If true, `empty` will be called and returned from the slot.
|
|
348
|
+
* If false, `render` will be called with the result of calling `empty`.
|
|
349
|
+
* The result of calling `render` will then be returned from the slot.
|
|
350
|
+
*/
|
|
351
|
+
emptySkipsRender?: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Defines the order of the components to render.
|
|
354
|
+
* May be more convient than using `render` w.r.t. ordering extensions
|
|
355
|
+
* by their supplied metadata.
|
|
356
|
+
* @param extensions The registered extensions.
|
|
357
|
+
* @returns The ordered extensions.
|
|
358
|
+
*/
|
|
359
|
+
order?(extensions: Array<ExtensionRegistration>): Array<ExtensionRegistration>;
|
|
360
|
+
/**
|
|
361
|
+
* Defines how the provided nodes should be rendered.
|
|
362
|
+
* @param nodes The rendered extension nodes.
|
|
363
|
+
* @returns The rendered nodes, i.e., an ReactElement.
|
|
364
|
+
*/
|
|
365
|
+
render?(nodes: Array<React.ReactNode>): React.ReactElement<any, any> | null;
|
|
232
366
|
/**
|
|
233
|
-
*
|
|
367
|
+
* The custom parameters for the given extension.
|
|
234
368
|
*/
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
369
|
+
params?: TParams;
|
|
370
|
+
/**
|
|
371
|
+
* The name of the extension to render.
|
|
372
|
+
*/
|
|
373
|
+
name: TName;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Custom component converters defined outside of piral-core.
|
|
380
|
+
*/
|
|
381
|
+
export interface PiralCustomComponentConverters<TProps> {}
|
|
241
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Definition of a vanilla JavaScript component.
|
|
385
|
+
*/
|
|
386
|
+
export interface HtmlComponent<TProps> {
|
|
242
387
|
/**
|
|
243
|
-
*
|
|
388
|
+
* Renders a component into the provided element using the given props and context.
|
|
244
389
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
* The storage target of the item.
|
|
252
|
-
*/
|
|
253
|
-
target: string;
|
|
254
|
-
/**
|
|
255
|
-
* The value that was stored.
|
|
256
|
-
*/
|
|
257
|
-
value: TValue;
|
|
258
|
-
/**
|
|
259
|
-
* The owner of the item.
|
|
260
|
-
*/
|
|
261
|
-
owner: string;
|
|
262
|
-
/**
|
|
263
|
-
* The expiration of the item.
|
|
264
|
-
*/
|
|
265
|
-
expires: number;
|
|
266
|
-
}
|
|
390
|
+
component: ForeignComponent<TProps>;
|
|
391
|
+
/**
|
|
392
|
+
* The type of the HTML component.
|
|
393
|
+
*/
|
|
394
|
+
type: "html";
|
|
395
|
+
}
|
|
267
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Generic definition of a framework-independent component.
|
|
399
|
+
*/
|
|
400
|
+
export interface ForeignComponent<TProps> {
|
|
401
|
+
/**
|
|
402
|
+
* Called when the component is mounted.
|
|
403
|
+
* @param element The container hosting the element.
|
|
404
|
+
* @param props The props to transport.
|
|
405
|
+
* @param ctx The associated context.
|
|
406
|
+
* @param locals The local state of this component instance.
|
|
407
|
+
*/
|
|
408
|
+
mount(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
|
|
268
409
|
/**
|
|
269
|
-
*
|
|
410
|
+
* Called when the component should be updated.
|
|
411
|
+
* @param element The container hosting the element.
|
|
412
|
+
* @param props The props to transport.
|
|
413
|
+
* @param ctx The associated context.
|
|
414
|
+
* @param locals The local state of this component instance.
|
|
270
415
|
*/
|
|
271
|
-
|
|
416
|
+
update?(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
|
|
417
|
+
/**
|
|
418
|
+
* Called when a component is unmounted.
|
|
419
|
+
* @param element The container that was hosting the element.
|
|
420
|
+
* @param locals The local state of this component instance.
|
|
421
|
+
*/
|
|
422
|
+
unmount?(element: HTMLElement, locals: Record<string, any>): void;
|
|
423
|
+
}
|
|
272
424
|
|
|
425
|
+
/**
|
|
426
|
+
* The props that every registered component obtains.
|
|
427
|
+
*/
|
|
428
|
+
export interface BaseComponentProps {
|
|
273
429
|
/**
|
|
274
|
-
*
|
|
430
|
+
* The currently used pilet API.
|
|
275
431
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
* The target data store. By default the data is only stored in memory.
|
|
279
|
-
*/
|
|
280
|
-
target?: DataStoreTarget;
|
|
281
|
-
/**
|
|
282
|
-
* Optionally determines when the data expires.
|
|
283
|
-
*/
|
|
284
|
-
expires?: "never" | Date | number;
|
|
285
|
-
}
|
|
432
|
+
piral: PiletApi;
|
|
433
|
+
}
|
|
286
434
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
435
|
+
/**
|
|
436
|
+
* Custom extension slots outside of piral-core.
|
|
437
|
+
*/
|
|
438
|
+
export interface PiralCustomExtensionSlotMap {}
|
|
290
439
|
|
|
440
|
+
/**
|
|
441
|
+
* The interface modeling the registration of a pilet extension component.
|
|
442
|
+
*/
|
|
443
|
+
export interface ExtensionRegistration extends BaseRegistration {
|
|
444
|
+
/**
|
|
445
|
+
* The wrapped registered extension component.
|
|
446
|
+
*/
|
|
447
|
+
component: WrappedComponent<ExtensionComponentProps<string>>;
|
|
291
448
|
/**
|
|
292
|
-
*
|
|
449
|
+
* The original extension component that has been registered.
|
|
293
450
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
451
|
+
reference: any;
|
|
452
|
+
/**
|
|
453
|
+
* The default params (i.e., meta) of the extension.
|
|
454
|
+
*/
|
|
455
|
+
defaults: any;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* The context to be transported into the generic components.
|
|
460
|
+
*/
|
|
461
|
+
export interface ComponentContext {
|
|
462
|
+
navigation: NavigationApi;
|
|
463
|
+
publicPath: string;
|
|
464
|
+
}
|
|
301
465
|
|
|
466
|
+
/**
|
|
467
|
+
* The base type for pilet component registration in the global state context.
|
|
468
|
+
*/
|
|
469
|
+
export interface BaseRegistration {
|
|
302
470
|
/**
|
|
303
|
-
* The
|
|
471
|
+
* The pilet registering the component.
|
|
304
472
|
*/
|
|
305
|
-
|
|
473
|
+
pilet: string;
|
|
474
|
+
}
|
|
306
475
|
|
|
476
|
+
export type WrappedComponent<TProps> = React.ComponentType<React.PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
|
|
477
|
+
|
|
478
|
+
export interface NavigationApi {
|
|
479
|
+
/**
|
|
480
|
+
* Pushes a new location onto the history stack.
|
|
481
|
+
*/
|
|
482
|
+
push(target: string, state?: any): void;
|
|
483
|
+
/**
|
|
484
|
+
* Replaces the current location with another.
|
|
485
|
+
*/
|
|
486
|
+
replace(target: string, state?: any): void;
|
|
487
|
+
/**
|
|
488
|
+
* Changes the current index in the history stack by a given delta.
|
|
489
|
+
*/
|
|
490
|
+
go(n: number): void;
|
|
307
491
|
/**
|
|
308
|
-
*
|
|
492
|
+
* Prevents changes to the history stack from happening.
|
|
493
|
+
* This is useful when you want to prevent the user navigating
|
|
494
|
+
* away from the current page, for example when they have some
|
|
495
|
+
* unsaved data on the current page.
|
|
496
|
+
* @param blocker The function being called with a transition request.
|
|
497
|
+
* @returns The disposable for stopping the block.
|
|
309
498
|
*/
|
|
310
|
-
|
|
499
|
+
block(blocker: NavigationBlocker): Disposable;
|
|
500
|
+
/**
|
|
501
|
+
* Starts listening for location changes and calls the given
|
|
502
|
+
* callback with an Update when it does.
|
|
503
|
+
* @param listener The function being called when the route changes.
|
|
504
|
+
* @returns The disposable for stopping the block.
|
|
505
|
+
*/
|
|
506
|
+
listen(listener: NavigationListener): Disposable;
|
|
507
|
+
/**
|
|
508
|
+
* Gets the current path.
|
|
509
|
+
*/
|
|
510
|
+
path: string;
|
|
511
|
+
/**
|
|
512
|
+
* The original router behind the navigation.
|
|
513
|
+
*/
|
|
514
|
+
router: any;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
518
|
+
|
|
519
|
+
export interface NavigationBlocker {
|
|
520
|
+
(tx: NavigationTransition): void;
|
|
521
|
+
}
|
|
311
522
|
|
|
523
|
+
export interface NavigationListener {
|
|
524
|
+
(update: NavigationUpdate): void;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export interface NavigationTransition extends NavigationUpdate {
|
|
528
|
+
retry(): void;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export interface NavigationUpdate {
|
|
532
|
+
action: NavigationAction;
|
|
533
|
+
location: NavigationLocation;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export type NavigationAction = "POP" | "PUSH" | "REPLACE";
|
|
537
|
+
|
|
538
|
+
export interface NavigationLocation {
|
|
539
|
+
/**
|
|
540
|
+
* The fully qualified URL incl. the origin and base path.
|
|
541
|
+
*/
|
|
542
|
+
href: string;
|
|
543
|
+
/**
|
|
544
|
+
* The location.pathname property is a string that contains an initial "/"
|
|
545
|
+
* followed by the remainder of the URL up to the ?.
|
|
546
|
+
*/
|
|
547
|
+
pathname: string;
|
|
548
|
+
/**
|
|
549
|
+
* The location.search property is a string that contains an initial "?"
|
|
550
|
+
* followed by the key=value pairs in the query string. If there are no
|
|
551
|
+
* parameters, this value may be the empty string (i.e. '').
|
|
552
|
+
*/
|
|
553
|
+
search: string;
|
|
554
|
+
/**
|
|
555
|
+
* The location.hash property is a string that contains an initial "#"
|
|
556
|
+
* followed by fragment identifier of the URL. If there is no fragment
|
|
557
|
+
* identifier, this value may be the empty string (i.e. '').
|
|
558
|
+
*/
|
|
559
|
+
hash: string;
|
|
560
|
+
/**
|
|
561
|
+
* The location.state property is a user-supplied State object that is
|
|
562
|
+
* associated with this location. This can be a useful place to store
|
|
563
|
+
* any information you do not want to put in the URL, e.g. session-specific
|
|
564
|
+
* data.
|
|
565
|
+
*/
|
|
566
|
+
state: unknown;
|
|
312
567
|
/**
|
|
313
|
-
* The
|
|
568
|
+
* The location.key property is a unique string associated with this location.
|
|
569
|
+
* On the initial location, this will be the string default. On all subsequent
|
|
570
|
+
* locations, this string will be a unique identifier.
|
|
314
571
|
*/
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* The provided parameters for showing the extension.
|
|
318
|
-
*/
|
|
319
|
-
params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
|
|
320
|
-
/**
|
|
321
|
-
* The optional children to receive, if any.
|
|
322
|
-
*/
|
|
323
|
-
children?: React.ReactNode;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* The mapping of the existing (known) extension slots.
|
|
328
|
-
*/
|
|
329
|
-
export interface PiralExtensionSlotMap extends PiralCustomExtensionSlotMap {}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* The basic props for defining an extension slot.
|
|
333
|
-
*/
|
|
334
|
-
export interface BaseExtensionSlotProps<TName, TParams> {
|
|
335
|
-
/**
|
|
336
|
-
* The children to transport, if any.
|
|
337
|
-
*/
|
|
338
|
-
children?: React.ReactNode;
|
|
339
|
-
/**
|
|
340
|
-
* Defines what should be rendered when no components are available
|
|
341
|
-
* for the specified extension.
|
|
342
|
-
*/
|
|
343
|
-
empty?(): React.ReactNode;
|
|
344
|
-
/**
|
|
345
|
-
* Determines if the `render` function should be called in case no
|
|
346
|
-
* components are available for the specified extension.
|
|
347
|
-
*
|
|
348
|
-
* If true, `empty` will be called and returned from the slot.
|
|
349
|
-
* If false, `render` will be called with the result of calling `empty`.
|
|
350
|
-
* The result of calling `render` will then be returned from the slot.
|
|
351
|
-
*/
|
|
352
|
-
emptySkipsRender?: boolean;
|
|
353
|
-
/**
|
|
354
|
-
* Defines the order of the components to render.
|
|
355
|
-
* May be more convient than using `render` w.r.t. ordering extensions
|
|
356
|
-
* by their supplied metadata.
|
|
357
|
-
* @param extensions The registered extensions.
|
|
358
|
-
* @returns The ordered extensions.
|
|
359
|
-
*/
|
|
360
|
-
order?(extensions: Array<ExtensionRegistration>): Array<ExtensionRegistration>;
|
|
361
|
-
/**
|
|
362
|
-
* Defines how the provided nodes should be rendered.
|
|
363
|
-
* @param nodes The rendered extension nodes.
|
|
364
|
-
* @returns The rendered nodes, i.e., an ReactElement.
|
|
365
|
-
*/
|
|
366
|
-
render?(nodes: Array<React.ReactNode>): React.ReactElement<any, any> | null;
|
|
367
|
-
/**
|
|
368
|
-
* The custom parameters for the given extension.
|
|
369
|
-
*/
|
|
370
|
-
params?: TParams;
|
|
371
|
-
/**
|
|
372
|
-
* The name of the extension to render.
|
|
373
|
-
*/
|
|
374
|
-
name: TName;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Custom component converters defined outside of piral-core.
|
|
381
|
-
*/
|
|
382
|
-
export interface PiralCustomComponentConverters<TProps> {}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Definition of a vanilla JavaScript component.
|
|
386
|
-
*/
|
|
387
|
-
export interface HtmlComponent<TProps> {
|
|
388
|
-
/**
|
|
389
|
-
* Renders a component into the provided element using the given props and context.
|
|
390
|
-
*/
|
|
391
|
-
component: ForeignComponent<TProps>;
|
|
392
|
-
/**
|
|
393
|
-
* The type of the HTML component.
|
|
394
|
-
*/
|
|
395
|
-
type: "html";
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Generic definition of a framework-independent component.
|
|
400
|
-
*/
|
|
401
|
-
export interface ForeignComponent<TProps> {
|
|
402
|
-
/**
|
|
403
|
-
* Called when the component is mounted.
|
|
404
|
-
* @param element The container hosting the element.
|
|
405
|
-
* @param props The props to transport.
|
|
406
|
-
* @param ctx The associated context.
|
|
407
|
-
* @param locals The local state of this component instance.
|
|
408
|
-
*/
|
|
409
|
-
mount(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
|
|
410
|
-
/**
|
|
411
|
-
* Called when the component should be updated.
|
|
412
|
-
* @param element The container hosting the element.
|
|
413
|
-
* @param props The props to transport.
|
|
414
|
-
* @param ctx The associated context.
|
|
415
|
-
* @param locals The local state of this component instance.
|
|
416
|
-
*/
|
|
417
|
-
update?(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
|
|
418
|
-
/**
|
|
419
|
-
* Called when a component is unmounted.
|
|
420
|
-
* @param element The container that was hosting the element.
|
|
421
|
-
* @param locals The local state of this component instance.
|
|
422
|
-
*/
|
|
423
|
-
unmount?(element: HTMLElement, locals: Record<string, any>): void;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* The props that every registered component obtains.
|
|
428
|
-
*/
|
|
429
|
-
export interface BaseComponentProps {
|
|
430
|
-
/**
|
|
431
|
-
* The currently used pilet API.
|
|
432
|
-
*/
|
|
433
|
-
piral: PiletApi;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Custom extension slots outside of piral-core.
|
|
438
|
-
*/
|
|
439
|
-
export interface PiralCustomExtensionSlotMap {}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* The interface modeling the registration of a pilet extension component.
|
|
443
|
-
*/
|
|
444
|
-
export interface ExtensionRegistration extends BaseRegistration {
|
|
445
|
-
/**
|
|
446
|
-
* The wrapped registered extension component.
|
|
447
|
-
*/
|
|
448
|
-
component: WrappedComponent<ExtensionComponentProps<string>>;
|
|
449
|
-
/**
|
|
450
|
-
* The original extension component that has been registered.
|
|
451
|
-
*/
|
|
452
|
-
reference: any;
|
|
453
|
-
/**
|
|
454
|
-
* The default params (i.e., meta) of the extension.
|
|
455
|
-
*/
|
|
456
|
-
defaults: any;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* The context to be transported into the generic components.
|
|
461
|
-
*/
|
|
462
|
-
export interface ComponentContext {
|
|
463
|
-
navigation: NavigationApi;
|
|
464
|
-
publicPath: string;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* The base type for pilet component registration in the global state context.
|
|
469
|
-
*/
|
|
470
|
-
export interface BaseRegistration {
|
|
471
|
-
/**
|
|
472
|
-
* The pilet registering the component.
|
|
473
|
-
*/
|
|
474
|
-
pilet: string;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
export type WrappedComponent<TProps> = React.ComponentType<React.PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
|
|
478
|
-
|
|
479
|
-
export interface NavigationApi {
|
|
480
|
-
/**
|
|
481
|
-
* Pushes a new location onto the history stack.
|
|
482
|
-
*/
|
|
483
|
-
push(target: string, state?: any): void;
|
|
484
|
-
/**
|
|
485
|
-
* Replaces the current location with another.
|
|
486
|
-
*/
|
|
487
|
-
replace(target: string, state?: any): void;
|
|
488
|
-
/**
|
|
489
|
-
* Changes the current index in the history stack by a given delta.
|
|
490
|
-
*/
|
|
491
|
-
go(n: number): void;
|
|
492
|
-
/**
|
|
493
|
-
* Prevents changes to the history stack from happening.
|
|
494
|
-
* This is useful when you want to prevent the user navigating
|
|
495
|
-
* away from the current page, for example when they have some
|
|
496
|
-
* unsaved data on the current page.
|
|
497
|
-
* @param blocker The function being called with a transition request.
|
|
498
|
-
* @returns The disposable for stopping the block.
|
|
499
|
-
*/
|
|
500
|
-
block(blocker: NavigationBlocker): Disposable;
|
|
501
|
-
/**
|
|
502
|
-
* Starts listening for location changes and calls the given
|
|
503
|
-
* callback with an Update when it does.
|
|
504
|
-
* @param listener The function being called when the route changes.
|
|
505
|
-
* @returns The disposable for stopping the block.
|
|
506
|
-
*/
|
|
507
|
-
listen(listener: NavigationListener): Disposable;
|
|
508
|
-
/**
|
|
509
|
-
* The original router behind the navigation.
|
|
510
|
-
*/
|
|
511
|
-
router: any;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
515
|
-
|
|
516
|
-
export interface NavigationBlocker {
|
|
517
|
-
(tx: NavigationTransition): void;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
export interface NavigationListener {
|
|
521
|
-
(update: NavigationUpdate): void;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
export interface NavigationTransition extends NavigationUpdate {
|
|
525
|
-
retry(): void;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
export interface NavigationUpdate {
|
|
529
|
-
action: NavigationAction;
|
|
530
|
-
location: NavigationLocation;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
export type NavigationAction = "POP" | "PUSH" | "REPLACE";
|
|
534
|
-
|
|
535
|
-
export interface NavigationLocation {
|
|
536
|
-
/**
|
|
537
|
-
* The fully qualified URL incl. the origin and base path.
|
|
538
|
-
*/
|
|
539
|
-
href: string;
|
|
540
|
-
/**
|
|
541
|
-
* The location.pathname property is a string that contains an initial "/"
|
|
542
|
-
* followed by the remainder of the URL up to the ?.
|
|
543
|
-
*/
|
|
544
|
-
pathname: string;
|
|
545
|
-
/**
|
|
546
|
-
* The location.search property is a string that contains an initial "?"
|
|
547
|
-
* followed by the key=value pairs in the query string. If there are no
|
|
548
|
-
* parameters, this value may be the empty string (i.e. '').
|
|
549
|
-
*/
|
|
550
|
-
search: string;
|
|
551
|
-
/**
|
|
552
|
-
* The location.hash property is a string that contains an initial "#"
|
|
553
|
-
* followed by fragment identifier of the URL. If there is no fragment
|
|
554
|
-
* identifier, this value may be the empty string (i.e. '').
|
|
555
|
-
*/
|
|
556
|
-
hash: string;
|
|
557
|
-
/**
|
|
558
|
-
* The location.state property is a user-supplied State object that is
|
|
559
|
-
* associated with this location. This can be a useful place to store
|
|
560
|
-
* any information you do not want to put in the URL, e.g. session-specific
|
|
561
|
-
* data.
|
|
562
|
-
*/
|
|
563
|
-
state: unknown;
|
|
564
|
-
/**
|
|
565
|
-
* The location.key property is a unique string associated with this location.
|
|
566
|
-
* On the initial location, this will be the string default. On all subsequent
|
|
567
|
-
* locations, this string will be a unique identifier.
|
|
568
|
-
*/
|
|
569
|
-
key: string;
|
|
570
|
-
}
|
|
572
|
+
key: string;
|
|
571
573
|
}
|