-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
wrap.d.ts
40 lines (32 loc) · 1.91 KB
/
wrap.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {ComponentType} from 'svelte'
import {AsyncSvelteComponent, RoutePrecondition, WrappedComponent} from './Router'
/** Options object for the call to `wrap` */
export interface WrapOptions {
/** Svelte component to load (this is incompatible with `asyncComponent`) */
component?: ComponentType
/** Function that returns a Promise that fulfills with a Svelte component (e.g. `{asyncComponent: () => import('Foo.svelte')}`) */
asyncComponent?: AsyncSvelteComponent
/** Svelte component to be displayed while the async route is loading (as a placeholder); when unset or false-y, no component is shown while component */
loadingComponent?: ComponentType
/** Optional dictionary passed to the `loadingComponent` component as params (for an exported prop called `params`) */
loadingParams?: object
/** Optional object that will be passed to events such as `routeLoading`, `routeLoaded`, `conditionsFailed` */
userData?: object
/** Optional key-value dictionary of static props that will be passed to the component. The props are expanded with {...props}, so the key in the dictionary becomes the name of the prop. */
props?: object
/** Route pre-conditions to add, which will be executed in order */
conditions?: RoutePrecondition[] | RoutePrecondition
}
/**
* Wraps a component to enable multiple capabilities:
*
* 1. Using dynamically-imported component, with (e.g. `{asyncComponent: () => import('Foo.svelte')}`), which also allows bundlers to do code-splitting.
* 2. Adding route pre-conditions (e.g. `{conditions: [...]}`)
* 3. Adding static props that are passed to the component
* 4. Adding custom userData, which is passed to route events (e.g. route loaded events) or to route pre-conditions (e.g. `{userData: {foo: 'bar}}`)
*
* @param args Arguments object
* @returns Wrapped component
*/
export function wrap(args: WrapOptions): WrappedComponent
export default wrap