@manyducks.co/dolla 0.71.0 → 0.73.0
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/lib/index.d.ts +1 -1
- package/lib/index.js +99 -53
- package/lib/index.js.map +3 -3
- package/lib/stores/router.d.ts +33 -2
- package/package.json +1 -1
package/lib/stores/router.d.ts
CHANGED
|
@@ -1,13 +1,43 @@
|
|
|
1
1
|
import { type History } from "history";
|
|
2
2
|
import { type Markup } from "../markup.js";
|
|
3
|
-
import { type StoreContext } from "../store.js";
|
|
4
|
-
import { type Stringable } from "../types.js";
|
|
3
|
+
import { type Store, type StoreContext } from "../store.js";
|
|
4
|
+
import { type BuiltInStores, type Stringable } from "../types.js";
|
|
5
5
|
import { type View } from "../view.js";
|
|
6
|
+
export interface RouteMatchContext {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the shared instance of `store`.
|
|
9
|
+
*/
|
|
10
|
+
getStore<T extends Store<any, any>>(store: T): ReturnType<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the shared instance of a built-in store.
|
|
13
|
+
*/
|
|
14
|
+
getStore<N extends keyof BuiltInStores>(name: N): BuiltInStores[N];
|
|
15
|
+
/**
|
|
16
|
+
* Redirects the user to a different route instead of matching the current one.
|
|
17
|
+
*/
|
|
18
|
+
redirect(path: string): void;
|
|
19
|
+
}
|
|
6
20
|
export interface Route {
|
|
21
|
+
/**
|
|
22
|
+
* The path or path fragment to match.
|
|
23
|
+
*/
|
|
7
24
|
path: string;
|
|
25
|
+
/**
|
|
26
|
+
* Path to redirect to when this route is matched.
|
|
27
|
+
*/
|
|
8
28
|
redirect?: string;
|
|
29
|
+
/**
|
|
30
|
+
* View to display when this route is matched.
|
|
31
|
+
*/
|
|
9
32
|
view?: View<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Subroutes.
|
|
35
|
+
*/
|
|
10
36
|
routes?: Route[];
|
|
37
|
+
/**
|
|
38
|
+
* Called after the match is identified but before it is acted on. Use this to set state, load data, etc.
|
|
39
|
+
*/
|
|
40
|
+
beforeMatch?: (ctx: RouteMatchContext) => void | Promise<void>;
|
|
11
41
|
}
|
|
12
42
|
export interface RouteConfig {
|
|
13
43
|
pattern: string;
|
|
@@ -15,6 +45,7 @@ export interface RouteConfig {
|
|
|
15
45
|
redirect?: string | ((ctx: RedirectContext) => void);
|
|
16
46
|
pattern?: string;
|
|
17
47
|
layers?: RouteLayer[];
|
|
48
|
+
beforeMatch?: (ctx: RouteMatchContext) => void | Promise<void>;
|
|
18
49
|
};
|
|
19
50
|
}
|
|
20
51
|
export interface RouteLayer {
|