@manyducks.co/dolla 2.0.0-alpha.9 → 3.0.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/README.md +132 -573
- package/dist/core/context.d.ts +23 -0
- package/dist/core/debug.d.ts +19 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/markup/helpers.d.ts +34 -0
- package/dist/core/markup/html.d.ts +3 -0
- package/dist/core/markup/html.test.d.ts +1 -0
- package/dist/core/markup/nodes/dom.d.ts +14 -0
- package/dist/core/markup/nodes/dynamic.d.ts +16 -0
- package/dist/core/markup/nodes/element.d.ts +14 -0
- package/dist/core/markup/nodes/portal.d.ts +15 -0
- package/dist/core/markup/nodes/repeat.d.ts +21 -0
- package/dist/core/markup/nodes/view.d.ts +17 -0
- package/dist/core/markup/scheduler.d.ts +1 -0
- package/dist/core/markup/types.d.ts +62 -0
- package/dist/core/markup/utils.d.ts +22 -0
- package/dist/core/markup/utils.test.d.ts +1 -0
- package/dist/core/ref.d.ts +13 -0
- package/dist/core/root.d.ts +36 -0
- package/dist/core/signals.d.ts +70 -0
- package/dist/core/signals.test.d.ts +1 -0
- package/dist/core/symbols.d.ts +2 -0
- package/dist/core-BLkJ-xuh.js +242 -0
- package/dist/core-BLkJ-xuh.js.map +1 -0
- package/dist/http/index.d.ts +43 -0
- package/dist/http.js +90 -0
- package/dist/http.js.map +1 -0
- package/dist/index.js +4 -1428
- package/dist/jsx-dev-runtime.d.ts +4 -2
- package/dist/jsx-dev-runtime.js +12 -16
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +5 -3
- package/dist/jsx-runtime.js +17 -18
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/router/index.d.ts +4 -0
- package/dist/router/matcher.test.d.ts +1 -0
- package/dist/router/router.d.ts +23 -0
- package/dist/router/router.test.d.ts +1 -0
- package/dist/router/store.d.ts +12 -0
- package/dist/router/types.d.ts +152 -0
- package/dist/router/utils.d.ts +99 -0
- package/dist/router/utils.test.d.ts +1 -0
- package/dist/router.js +429 -0
- package/dist/router.js.map +1 -0
- package/dist/signals-CMJPGr_M.js +354 -0
- package/dist/signals-CMJPGr_M.js.map +1 -0
- package/dist/translate/index.d.ts +82 -0
- package/dist/translate.js +125 -0
- package/dist/translate.js.map +1 -0
- package/dist/types.d.ts +83 -29
- package/dist/utils.d.ts +46 -12
- package/dist/utils.test.d.ts +1 -0
- package/dist/view-cBN-hn_T.js +360 -0
- package/dist/view-cBN-hn_T.js.map +1 -0
- package/dist/virtual/index.d.ts +1 -0
- package/dist/virtual/list.d.ts +53 -0
- package/index.d.ts +2 -2
- package/package.json +34 -17
- package/build.js +0 -34
- package/dist/index.d.ts +0 -21
- package/dist/index.js.map +0 -1
- package/dist/markup.d.ts +0 -108
- package/dist/modules/dolla.d.ts +0 -111
- package/dist/modules/http.d.ts +0 -57
- package/dist/modules/i18n.d.ts +0 -59
- package/dist/modules/render.d.ts +0 -17
- package/dist/modules/router.d.ts +0 -152
- package/dist/nodes/cond.d.ts +0 -26
- package/dist/nodes/html.d.ts +0 -31
- package/dist/nodes/observer.d.ts +0 -29
- package/dist/nodes/outlet.d.ts +0 -22
- package/dist/nodes/portal.d.ts +0 -19
- package/dist/nodes/repeat.d.ts +0 -34
- package/dist/nodes/text.d.ts +0 -19
- package/dist/passthrough-9kwwjgWk.js +0 -1279
- package/dist/passthrough-9kwwjgWk.js.map +0 -1
- package/dist/routing.d.ts +0 -79
- package/dist/state.d.ts +0 -101
- package/dist/typeChecking.d.ts +0 -191
- package/dist/view.d.ts +0 -65
- package/dist/views/default-crash-view.d.ts +0 -18
- package/dist/views/passthrough.d.ts +0 -5
- package/notes/context-vars.md +0 -21
- package/notes/readme-scratch.md +0 -222
- package/notes/route-middleware.md +0 -42
- package/notes/scratch.md +0 -233
- package/notes/views.md +0 -195
- package/tests/state.test.js +0 -135
- package/vite.config.js +0 -28
- /package/dist/{routing.test.d.ts → core/context.test.d.ts} +0 -0
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export function jsxDEV(element: any, props: any, key: any, isStaticChildren: any, source: any, self: any): import("./
|
|
2
|
-
export {
|
|
1
|
+
export function jsxDEV(element: any, props: any, key: any, isStaticChildren: any, source: any, self: any): import("./core/index.js").Markup<any>;
|
|
2
|
+
export function Fragment({ children }: {
|
|
3
|
+
children: any;
|
|
4
|
+
}): any;
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { i as e } from "./view-cBN-hn_T.js";
|
|
2
|
+
//#region src/jsx-dev-runtime.js
|
|
3
|
+
var t = ({ children: e }) => e;
|
|
4
|
+
function n(t, n, r, i, a, o) {
|
|
5
|
+
return e(t, r == null ? n : {
|
|
6
|
+
...n,
|
|
7
|
+
key: r
|
|
8
|
+
});
|
|
6
9
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return t;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
m as Fragment,
|
|
15
|
-
d as jsxDEV
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as Fragment, n as jsxDEV };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime.js","sources":["../src/jsx-dev-runtime.js"],"sourcesContent":["import { createMarkup } from \"./markup.
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/jsx-dev-runtime.js"],"sourcesContent":["import { createMarkup } from \"./core/markup/utils.js\";\n\nexport const Fragment = ({ children }) => children;\n\nexport function jsxDEV(element, props, key, isStaticChildren, source, self) {\n // TODO: Take additional dev arguments and use them for better debugging.\n return createMarkup(element, key != null ? { ...props, key } : props);\n}\n"],"mappings":";;AAEA,IAAa,KAAY,EAAE,kBAAe;AAE1C,SAAgB,EAAO,GAAS,GAAO,GAAK,GAAkB,GAAQ,GAAM;AAE1E,QAAO,EAAa,GAAS,KAAO,OAA2B,IAApB;EAAE,GAAG;EAAO;EAAK,CAAS"}
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSX function for elements with dynamic children.
|
|
3
3
|
*/
|
|
4
|
-
export function jsx(element: any, props: any, key: any): import("./
|
|
4
|
+
export function jsx(element: any, props: any, key: any): import("./core/index.js").Markup<any>;
|
|
5
5
|
/**
|
|
6
6
|
* JSX function for elements with static children.
|
|
7
7
|
*/
|
|
8
|
-
export function jsxs(element: any, props: any, key: any): import("./
|
|
9
|
-
export {
|
|
8
|
+
export function jsxs(element: any, props: any, key: any): import("./core/index.js").Markup<any>;
|
|
9
|
+
export function Fragment({ children }: {
|
|
10
|
+
children: any;
|
|
11
|
+
}): any;
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { i as e } from "./view-cBN-hn_T.js";
|
|
2
|
+
//#region src/jsx-runtime.js
|
|
3
|
+
var t = ({ children: e }) => e;
|
|
4
|
+
function n(t, n, r) {
|
|
5
|
+
return e(t, r == null ? n : {
|
|
6
|
+
...n,
|
|
7
|
+
key: r
|
|
8
|
+
});
|
|
5
9
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
10
|
+
function r(t, n, r) {
|
|
11
|
+
return e(t, r == null ? n : {
|
|
12
|
+
...n,
|
|
13
|
+
key: r
|
|
14
|
+
});
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return r;
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
l as Fragment,
|
|
17
|
-
d as jsx,
|
|
18
|
-
f as jsxs
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=jsx-runtime.js.map
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as Fragment, n as jsx, r as jsxs };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
package/dist/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","sources":["../src/jsx-runtime.js"],"sourcesContent":["import { createMarkup } from \"./markup.
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.js"],"sourcesContent":["import { createMarkup } from \"./core/markup/utils.js\";\n\nexport const Fragment = ({ children }) => children;\n\n/**\n * JSX function for elements with dynamic children.\n */\nexport function jsx(element, props, key) {\n return createMarkup(element, key != null ? { ...props, key } : props);\n}\n\n/**\n * JSX function for elements with static children.\n */\nexport function jsxs(element, props, key) {\n return createMarkup(element, key != null ? { ...props, key } : props);\n}\n"],"mappings":";;AAEA,IAAa,KAAY,EAAE,kBAAe;AAK1C,SAAgB,EAAI,GAAS,GAAO,GAAK;AACvC,QAAO,EAAa,GAAS,KAAO,OAA2B,IAApB;EAAE,GAAG;EAAO;EAAK,CAAS;;AAMvE,SAAgB,EAAK,GAAS,GAAO,GAAK;AACxC,QAAO,EAAa,GAAS,KAAO,OAA2B,IAApB;EAAE,GAAG;EAAO;EAAK,CAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Context } from "../core/context.js";
|
|
2
|
+
import { DollaPlugin } from "../core/index.js";
|
|
3
|
+
import { DynamicNode } from "../core/markup/nodes/dynamic.js";
|
|
4
|
+
import type { LazyLoader, LazyView, RouterOptions } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Lazy loads a view when its route is first matched.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* {
|
|
10
|
+
* path: "/users",
|
|
11
|
+
* view: lazy(() => import("./views/users.js"))
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export declare function lazy(load: LazyLoader): LazyView;
|
|
15
|
+
export declare function createRouterPlugin(options: RouterOptions): DollaPlugin;
|
|
16
|
+
/**
|
|
17
|
+
* Displays the router's content.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Outlet(this: Context): DynamicNode;
|
|
20
|
+
export declare class RedirectError extends Error {
|
|
21
|
+
redirectPath: string;
|
|
22
|
+
constructor(redirectPath: string);
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Context, type Getter, type Setter } from "../core";
|
|
2
|
+
import type { Router } from "./types";
|
|
3
|
+
import { type HistoryAdapter, type Match } from "./utils";
|
|
4
|
+
export interface RouterStoreProps {
|
|
5
|
+
currentMatch: Getter<Match>;
|
|
6
|
+
setCurrentMatch: Setter<Match>;
|
|
7
|
+
progress: Getter<number>;
|
|
8
|
+
history: HistoryAdapter;
|
|
9
|
+
updateRoute: () => void;
|
|
10
|
+
guards: Set<() => boolean | Promise<boolean>>;
|
|
11
|
+
}
|
|
12
|
+
export declare function RouterStore(this: Context, { currentMatch, setCurrentMatch, progress, history, updateRoute, guards }: RouterStoreProps): Router;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Setter, Getter, MarkupNode, Renderable, View } from "../core";
|
|
2
|
+
import type { Context } from "../core/context";
|
|
3
|
+
import type { Match } from "./utils";
|
|
4
|
+
export type Stringable = {
|
|
5
|
+
toString(): string;
|
|
6
|
+
};
|
|
7
|
+
export type LazyLoader<Props = any> = () => Promise<{
|
|
8
|
+
default: View<Props>;
|
|
9
|
+
} | View<Props>>;
|
|
10
|
+
export interface LazyView<Props = any> {
|
|
11
|
+
_lazy: true;
|
|
12
|
+
load: LazyLoader<Props>;
|
|
13
|
+
}
|
|
14
|
+
export interface Route<Data = any> {
|
|
15
|
+
/**
|
|
16
|
+
* The path or path fragment to match.
|
|
17
|
+
*/
|
|
18
|
+
path: string;
|
|
19
|
+
/**
|
|
20
|
+
* Path to redirect to when this route is matched, or a callback function that returns such path.
|
|
21
|
+
*/
|
|
22
|
+
redirect?: string | ((match: Match) => string) | ((match: Match) => Promise<string>);
|
|
23
|
+
preload?: (match: Match) => Data | Promise<Data>;
|
|
24
|
+
/**
|
|
25
|
+
* View to display when this route is matched.
|
|
26
|
+
*/
|
|
27
|
+
view?: View<{
|
|
28
|
+
data?: Data;
|
|
29
|
+
children: Renderable;
|
|
30
|
+
}> | LazyView<{
|
|
31
|
+
data?: Data;
|
|
32
|
+
children: Renderable;
|
|
33
|
+
}>;
|
|
34
|
+
errorView?: View<{
|
|
35
|
+
error: Error;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Subroutes.
|
|
39
|
+
*/
|
|
40
|
+
routes?: Route[];
|
|
41
|
+
/**
|
|
42
|
+
* Arbitrary data you'd like to store on this route.
|
|
43
|
+
* This object is accessible via `match.meta` on the `$router` API while the route is active.
|
|
44
|
+
*
|
|
45
|
+
* In the case of nested routes, data from all layers will be merged into a single data object.
|
|
46
|
+
*/
|
|
47
|
+
meta?: Record<string | symbol, any>;
|
|
48
|
+
}
|
|
49
|
+
export interface RouteLayer {
|
|
50
|
+
id: string;
|
|
51
|
+
pattern: string;
|
|
52
|
+
view: View<any> | LazyView<any>;
|
|
53
|
+
errorView?: View<{
|
|
54
|
+
error: Error;
|
|
55
|
+
}>;
|
|
56
|
+
preload?: (match: Match) => any | Promise<any>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An active route layer whose markup has been initialized into a view.
|
|
60
|
+
*/
|
|
61
|
+
export interface ActiveLayer {
|
|
62
|
+
id: string;
|
|
63
|
+
key: string;
|
|
64
|
+
node: MarkupNode;
|
|
65
|
+
context: Context;
|
|
66
|
+
slot: Getter<MarkupNode | undefined>;
|
|
67
|
+
setSlot: Setter<MarkupNode | undefined>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A log for a single step in the route resolution process.
|
|
71
|
+
*/
|
|
72
|
+
export interface JourneyStep {
|
|
73
|
+
kind: "match" | "redirect" | "miss";
|
|
74
|
+
message: string;
|
|
75
|
+
}
|
|
76
|
+
export interface NavigateOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Preserve existing query params (if any) when navigating. Defaults to false.
|
|
79
|
+
* If true, all existing query params are preserved and merged with new ones.
|
|
80
|
+
* If an array of strings is passed only those keys will be preserved, then merged with any new ones.
|
|
81
|
+
*/
|
|
82
|
+
preserveQuery?: boolean | string[];
|
|
83
|
+
}
|
|
84
|
+
export interface RouterOptions {
|
|
85
|
+
routes: Route[];
|
|
86
|
+
/**
|
|
87
|
+
* When true, the router will construct routes like "https://www.example.com/#/sub/route" which work without any backend intervention.
|
|
88
|
+
*/
|
|
89
|
+
hash?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Persist query params between pages when navigating. Pass an array to specify a list of params that will be preserved.
|
|
92
|
+
* By default all query params are cleared when navigating to a new URL (equivalent to `false`).
|
|
93
|
+
*/
|
|
94
|
+
preserveQuery?: boolean | string[];
|
|
95
|
+
}
|
|
96
|
+
export interface Router {
|
|
97
|
+
/**
|
|
98
|
+
* The current path as it is displayed in the URL bar (e.g. `/users/123/edit`).
|
|
99
|
+
*/
|
|
100
|
+
path: Getter<string>;
|
|
101
|
+
/**
|
|
102
|
+
* The route pattern that was matched (e.g. `/users/{#id}/edit`), or undefined if no route is currently matched.
|
|
103
|
+
*/
|
|
104
|
+
pattern: Getter<string | undefined>;
|
|
105
|
+
/**
|
|
106
|
+
* The extracted route parameters from the path. (e.g. `{ id: "123" }`)
|
|
107
|
+
*/
|
|
108
|
+
params: Getter<Record<string, string>>;
|
|
109
|
+
/**
|
|
110
|
+
* The current query params.
|
|
111
|
+
*/
|
|
112
|
+
query: Getter<Record<string, string>>;
|
|
113
|
+
/**
|
|
114
|
+
* The contents of the `meta` fields of all matched route layers.
|
|
115
|
+
*/
|
|
116
|
+
meta: Getter<Record<string, string>>;
|
|
117
|
+
/**
|
|
118
|
+
* Represents the loading progress of the current navigation from 0 to 1.
|
|
119
|
+
* Returns 0 when no navigation is pending.
|
|
120
|
+
*/
|
|
121
|
+
progress: Getter<number>;
|
|
122
|
+
/**
|
|
123
|
+
* Update query params without changing the route.
|
|
124
|
+
*/
|
|
125
|
+
setQuery(params: Record<string, Stringable>): Record<string, string>;
|
|
126
|
+
/**
|
|
127
|
+
* Go back in the page history. Equivalent to hitting the back button.
|
|
128
|
+
* Steps is the number of times to hit the back button. The default is 1.
|
|
129
|
+
*/
|
|
130
|
+
back(steps?: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Go forward in the page history. Equivalent to hitting the forward button.
|
|
133
|
+
* Steps is the number of times to hit the forward button. The default is 1.
|
|
134
|
+
*/
|
|
135
|
+
forward(steps?: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Push a new route into the page history and navigate to it.
|
|
138
|
+
*/
|
|
139
|
+
push(path: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Replace the current route in the page history and navigate to it.
|
|
142
|
+
*/
|
|
143
|
+
replace(path: string): void;
|
|
144
|
+
/**
|
|
145
|
+
* Prevents attempted navigations if the condition returns true.
|
|
146
|
+
*/
|
|
147
|
+
block(guard: () => boolean | Promise<boolean>): () => void;
|
|
148
|
+
/**
|
|
149
|
+
* Contains `true` when the current route matches `path`.
|
|
150
|
+
*/
|
|
151
|
+
isActive(path: string, exact?: boolean): Getter<boolean>;
|
|
152
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { JourneyStep, Route, RouteLayer, Stringable } from "./types.js";
|
|
2
|
+
export interface Match {
|
|
3
|
+
/**
|
|
4
|
+
* The path string that triggered this match.
|
|
5
|
+
*/
|
|
6
|
+
path: string;
|
|
7
|
+
/**
|
|
8
|
+
* The pattern satisfied by `path`.
|
|
9
|
+
*/
|
|
10
|
+
pattern: string;
|
|
11
|
+
/**
|
|
12
|
+
* Named params as parsed from `path`.
|
|
13
|
+
*/
|
|
14
|
+
params: Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Query params as parsed from `path`.
|
|
17
|
+
*/
|
|
18
|
+
query: Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Freeform data you wish to store with this route.
|
|
21
|
+
* Merged `data` from all matched layers are available on the router's `match.meta`.
|
|
22
|
+
*/
|
|
23
|
+
meta: Record<any, any>;
|
|
24
|
+
}
|
|
25
|
+
export interface RouteMatch extends Match {
|
|
26
|
+
layers: RouteLayer[];
|
|
27
|
+
redirect?: string | ((match: Match) => string) | ((match: Match) => Promise<string>);
|
|
28
|
+
}
|
|
29
|
+
export type RoutePayload = {
|
|
30
|
+
pattern: string;
|
|
31
|
+
meta: Record<any, any>;
|
|
32
|
+
layers?: RouteLayer[];
|
|
33
|
+
redirect?: string | ((match: Match) => string) | ((match: Match) => Promise<string>);
|
|
34
|
+
};
|
|
35
|
+
export type RouteMatchOptions = {
|
|
36
|
+
willMatch?: (route: RoutePayload) => boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Separates a URL path into multiple fragments.
|
|
40
|
+
*
|
|
41
|
+
* @param path - A path string (e.g. `"/api/users/5"`)
|
|
42
|
+
* @returns an array of fragments (e.g. `["api", "users", "5"]`)
|
|
43
|
+
*/
|
|
44
|
+
export declare function splitPath(path: string): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Joins multiple URL path fragments into a single string.
|
|
47
|
+
*
|
|
48
|
+
* @param parts - One or more URL fragments (e.g. `["api", "users", 5]`)
|
|
49
|
+
* @returns a joined path (e.g. `"api/users/5"`)
|
|
50
|
+
*/
|
|
51
|
+
export declare function joinPath(parts: {
|
|
52
|
+
toString(): string;
|
|
53
|
+
}[]): string;
|
|
54
|
+
export declare function resolvePath(base: string, part?: string | null): string;
|
|
55
|
+
export declare function parseQueryParams(query: string): Record<string, string>;
|
|
56
|
+
export declare function mergeQueryParams(previous: Record<string, string>, current: Record<string, Stringable>, preserve?: boolean | string[]): URLSearchParams;
|
|
57
|
+
export declare class RouteNode {
|
|
58
|
+
staticChildren: Map<string, RouteNode>;
|
|
59
|
+
numericChild: RouteNode | null;
|
|
60
|
+
paramChild: RouteNode | null;
|
|
61
|
+
wildcardChild: RouteNode | null;
|
|
62
|
+
route?: RoutePayload;
|
|
63
|
+
paramName?: string;
|
|
64
|
+
numericName?: string;
|
|
65
|
+
}
|
|
66
|
+
export declare function buildRouteTree(routes: Route[]): RouteNode;
|
|
67
|
+
export declare function matchRoute(rootNode: RouteNode, url: string, options?: RouteMatchOptions): RouteMatch | undefined;
|
|
68
|
+
export interface ResolvedRoute {
|
|
69
|
+
match?: RouteMatch;
|
|
70
|
+
journey: JourneyStep[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Takes a URL and finds a match, following redirects.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveRoute(rootNode: RouteNode, path: string, journey?: JourneyStep[]): Promise<ResolvedRoute>;
|
|
76
|
+
/**
|
|
77
|
+
* Intercepts links within the root node.
|
|
78
|
+
*
|
|
79
|
+
* This is adapted from https://github.com/choojs/nanohref/blob/master/index.js
|
|
80
|
+
*
|
|
81
|
+
* @param root - Element under which to intercept link clicks
|
|
82
|
+
* @param callback - Function to call when a click event is intercepted
|
|
83
|
+
* @param _window - (optional) Override for global window object
|
|
84
|
+
*/
|
|
85
|
+
export declare function catchLinks(root: Element, callback: (href: string, anchor: HTMLAnchorElement) => void, _window?: Window & typeof globalThis): () => void;
|
|
86
|
+
export declare function expandOptionalPaths(path: string): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Replace route pattern param placeholders with real matched values.
|
|
89
|
+
*/
|
|
90
|
+
export declare function replaceParams(path: string, params: Record<string, string | number>): string;
|
|
91
|
+
export interface HistoryAdapter {
|
|
92
|
+
getPath(): string;
|
|
93
|
+
getSearch(): string;
|
|
94
|
+
getKey(): string;
|
|
95
|
+
getIndex(): number;
|
|
96
|
+
push(url: string): void;
|
|
97
|
+
replace(url: string): void;
|
|
98
|
+
}
|
|
99
|
+
export declare function createHistoryAdapter(useHash: boolean): HistoryAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|