@thepassle/app-tools 0.9.1 → 0.9.2
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/package.json +1 -1
- package/router/index.js +14 -0
- package/types/router/index.d.ts +19 -5
package/package.json
CHANGED
package/router/index.js
CHANGED
|
@@ -77,12 +77,17 @@ export class Router extends EventTarget {
|
|
|
77
77
|
return new URL('./', document.baseURI);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @template RenderResult
|
|
82
|
+
* @returns {RenderResult}
|
|
83
|
+
*/
|
|
80
84
|
render() {
|
|
81
85
|
log(`Rendering route ${this.context.url.pathname}${this.context.url.search}`, { context: this.context, route: this.route });
|
|
82
86
|
return this.route?.render?.(this.context);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
/**
|
|
90
|
+
* @private
|
|
86
91
|
* @param {URL} url
|
|
87
92
|
* @returns {Route | null}
|
|
88
93
|
*/
|
|
@@ -106,14 +111,23 @@ export class Router extends EventTarget {
|
|
|
106
111
|
return null;
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
109
117
|
_notifyUrlChanged() {
|
|
110
118
|
this.dispatchEvent(new RouteEvent(this.context));
|
|
111
119
|
}
|
|
112
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
113
124
|
_onPopState = () => {
|
|
114
125
|
this.navigate(new URL(window.location.href), { backNav: true });
|
|
115
126
|
}
|
|
116
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
117
131
|
_onAnchorClick = (e) => {
|
|
118
132
|
if (
|
|
119
133
|
e.defaultPrevented ||
|
package/types/router/index.d.ts
CHANGED
|
@@ -23,15 +23,29 @@ export class Router extends EventTarget {
|
|
|
23
23
|
get url(): URL;
|
|
24
24
|
get fallback(): URL;
|
|
25
25
|
get baseUrl(): URL;
|
|
26
|
-
render(): RenderResult;
|
|
27
26
|
/**
|
|
27
|
+
* @template RenderResult
|
|
28
|
+
* @returns {RenderResult}
|
|
29
|
+
*/
|
|
30
|
+
render<RenderResult>(): RenderResult;
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
28
33
|
* @param {URL} url
|
|
29
34
|
* @returns {Route | null}
|
|
30
35
|
*/
|
|
31
|
-
_matchRoute
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
private _matchRoute;
|
|
37
|
+
/**
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
private _notifyUrlChanged;
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private _onPopState;
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
private _onAnchorClick;
|
|
35
49
|
/**
|
|
36
50
|
* @param {string | URL} url The URL to navigate to.
|
|
37
51
|
* @param {{
|