@wcstack/router 1.3.19 → 1.5.1
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/dist/index.d.ts +136 -2
- package/dist/index.esm.js +291 -163
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +75 -75
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,17 @@ interface IWritableConfig {
|
|
|
12
12
|
enableShadowRoot?: boolean;
|
|
13
13
|
basenameFileExtensions?: string[];
|
|
14
14
|
}
|
|
15
|
+
type BuiltinParamTypes = "int" | "float" | "bool" | "uuid" | "slug" | "isoDate" | "any";
|
|
16
|
+
interface IWcBindableProperty {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly event: string;
|
|
19
|
+
readonly getter?: (event: Event) => any;
|
|
20
|
+
}
|
|
21
|
+
interface IWcBindable {
|
|
22
|
+
readonly protocol: "wc-bindable";
|
|
23
|
+
readonly version: number;
|
|
24
|
+
readonly properties: IWcBindableProperty[];
|
|
25
|
+
}
|
|
15
26
|
|
|
16
27
|
/**
|
|
17
28
|
* Initialize the router with optional configuration.
|
|
@@ -20,5 +31,128 @@ interface IWritableConfig {
|
|
|
20
31
|
*/
|
|
21
32
|
declare function bootstrapRouter(config?: Partial<IWritableConfig>): void;
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
interface IRouteMatchResult {
|
|
35
|
+
routes: IRoute[];
|
|
36
|
+
params: Record<string, string>;
|
|
37
|
+
typedParams: Record<string, any>;
|
|
38
|
+
path: string;
|
|
39
|
+
lastPath: string;
|
|
40
|
+
}
|
|
41
|
+
type GuardHandler = (toPath: string, fromPath: string) => boolean | Promise<boolean>;
|
|
42
|
+
type SegmentType = 'static' | 'param' | 'catch-all';
|
|
43
|
+
interface ISegmentInfo {
|
|
44
|
+
type: SegmentType;
|
|
45
|
+
segmentText: string;
|
|
46
|
+
paramName: string | null;
|
|
47
|
+
pattern: RegExp;
|
|
48
|
+
isIndex?: boolean;
|
|
49
|
+
paramType?: BuiltinParamTypes;
|
|
50
|
+
}
|
|
51
|
+
interface IRouteChildContainer {
|
|
52
|
+
readonly routeChildNodes: IRoute[];
|
|
53
|
+
}
|
|
54
|
+
interface IRoute extends IRouteChildContainer {
|
|
55
|
+
readonly routeParentNode: IRoute | null;
|
|
56
|
+
readonly routerNode: IRouter;
|
|
57
|
+
readonly path: string;
|
|
58
|
+
readonly isRelative: boolean;
|
|
59
|
+
readonly absolutePath: string;
|
|
60
|
+
readonly uuid: string;
|
|
61
|
+
readonly placeHolder: Comment;
|
|
62
|
+
readonly childNodeArray: Node[];
|
|
63
|
+
readonly routes: IRoute[];
|
|
64
|
+
params: Record<string, string>;
|
|
65
|
+
typedParams: Record<string, any>;
|
|
66
|
+
readonly paramNames: string[];
|
|
67
|
+
readonly absoluteParamNames: string[];
|
|
68
|
+
readonly weight: number;
|
|
69
|
+
readonly absoluteWeight: number;
|
|
70
|
+
readonly childIndex: number;
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly fullpath: string;
|
|
73
|
+
readonly segmentCount: number;
|
|
74
|
+
readonly absoluteSegmentCount: number;
|
|
75
|
+
readonly segmentInfos: ISegmentInfo[];
|
|
76
|
+
readonly absoluteSegmentInfos: ISegmentInfo[];
|
|
77
|
+
guardHandler: GuardHandler;
|
|
78
|
+
shouldChange(newParams: Record<string, string>): boolean;
|
|
79
|
+
guardCheck(matchResult: IRouteMatchResult): Promise<void>;
|
|
80
|
+
initialize(routerNode: IRouter, parentRouteNode: IRoute | null): void;
|
|
81
|
+
testAncestorNode(ancestorNode: IRoute): boolean;
|
|
82
|
+
setParams(params: Record<string, string>, typedParams: Record<string, any>): void;
|
|
83
|
+
clearParams(): void;
|
|
84
|
+
}
|
|
85
|
+
interface IRouter extends IRouteChildContainer {
|
|
86
|
+
readonly basename: string;
|
|
87
|
+
readonly outlet: IOutlet;
|
|
88
|
+
readonly template: HTMLTemplateElement;
|
|
89
|
+
fallbackRoute: IRoute | null;
|
|
90
|
+
path: string;
|
|
91
|
+
navigate(path: string): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
interface IOutlet {
|
|
94
|
+
routesNode: IRouter;
|
|
95
|
+
readonly rootNode: HTMLElement | ShadowRoot;
|
|
96
|
+
lastRoutes: IRoute[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface RouteParseOptions {
|
|
100
|
+
isIndex?: boolean;
|
|
101
|
+
isFallback?: boolean;
|
|
102
|
+
hasGuard?: boolean;
|
|
103
|
+
guardFallback?: string | null;
|
|
104
|
+
name?: string;
|
|
105
|
+
}
|
|
106
|
+
declare class RouteCore extends EventTarget {
|
|
107
|
+
static wcBindable: IWcBindable;
|
|
108
|
+
private _target;
|
|
109
|
+
private _parentCore;
|
|
110
|
+
private _path;
|
|
111
|
+
private _name;
|
|
112
|
+
private _isFallbackRoute;
|
|
113
|
+
private _segmentInfos;
|
|
114
|
+
private _absoluteSegmentInfos;
|
|
115
|
+
private _paramNames;
|
|
116
|
+
private _absoluteParamNames;
|
|
117
|
+
private _weight;
|
|
118
|
+
private _absoluteWeight;
|
|
119
|
+
private _segmentCount;
|
|
120
|
+
private _params;
|
|
121
|
+
private _typedParams;
|
|
122
|
+
private _active;
|
|
123
|
+
private _hasGuard;
|
|
124
|
+
private _guardHandler;
|
|
125
|
+
private _guardFallbackPath;
|
|
126
|
+
private _waitForSetGuardHandler;
|
|
127
|
+
private _resolveSetGuardHandler;
|
|
128
|
+
constructor(target?: EventTarget);
|
|
129
|
+
get parentCore(): RouteCore | null;
|
|
130
|
+
set parentCore(value: RouteCore | null);
|
|
131
|
+
get path(): string;
|
|
132
|
+
get name(): string;
|
|
133
|
+
get isFallbackRoute(): boolean;
|
|
134
|
+
get isRelative(): boolean;
|
|
135
|
+
get segmentInfos(): ISegmentInfo[];
|
|
136
|
+
private _checkParentCore;
|
|
137
|
+
get absolutePath(): string;
|
|
138
|
+
get absoluteSegmentInfos(): ISegmentInfo[];
|
|
139
|
+
get params(): Record<string, string>;
|
|
140
|
+
get typedParams(): Record<string, any>;
|
|
141
|
+
get active(): boolean;
|
|
142
|
+
get paramNames(): string[];
|
|
143
|
+
get absoluteParamNames(): string[];
|
|
144
|
+
get weight(): number;
|
|
145
|
+
get absoluteWeight(): number;
|
|
146
|
+
get segmentCount(): number;
|
|
147
|
+
get absoluteSegmentCount(): number;
|
|
148
|
+
parsePath(path: string, options?: RouteParseOptions): void;
|
|
149
|
+
setParams(params: Record<string, string>, typedParams: Record<string, any>): void;
|
|
150
|
+
clearParams(): void;
|
|
151
|
+
shouldChange(newParams: Record<string, string>): boolean;
|
|
152
|
+
get guardHandler(): GuardHandler;
|
|
153
|
+
set guardHandler(value: GuardHandler);
|
|
154
|
+
guardCheck(matchResult: IRouteMatchResult): Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { RouteCore, bootstrapRouter };
|
|
158
|
+
export type { IWritableConfig, IWritableTagNames, RouteParseOptions };
|