@devwaren/vanilla-ts 1.0.20 → 1.0.21
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.cjs +5 -9
- package/dist/index.js +5 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,10 +36,10 @@ import { useTSElements, useTSParams, html } from "@devwaren/vanilla-ts";
|
|
|
36
36
|
import type { Module, Component } from "./types";
|
|
37
37
|
|
|
38
38
|
// -----------------------------
|
|
39
|
-
${E?`export const NotFound = async (DOM: HTMLElement) => {
|
|
39
|
+
${E?`export const NotFound: import("../gen/types").Component = async (DOM: HTMLElement) => {
|
|
40
40
|
const mod: import("../gen/types").Module = await import("../pages/${t.relative(s,E.file).replace(/\\/g,"/").replace(/\\.ts$/,"")}");
|
|
41
41
|
return mod.default(DOM);
|
|
42
|
-
};`:
|
|
42
|
+
};`:'export const NotFound: import("../gen/types").Component = (DOM: HTMLElement) =>\n useTSElements(DOM, html`<h1>404 - Page Not Found</h1>`);'}
|
|
43
43
|
|
|
44
44
|
// -----------------------------
|
|
45
45
|
export const routeTree: { path: string; name: string; component: () => Promise<Module> }[] = [
|
|
@@ -52,8 +52,7 @@ function matchRoute(pathname: string) {
|
|
|
52
52
|
const routeSegments = r.path.split("/").filter(Boolean);
|
|
53
53
|
const pathSegments = pathname.split("/").filter(Boolean);
|
|
54
54
|
|
|
55
|
-
if (routeSegments.length !== pathSegments.length && !routeSegments.includes("*"))
|
|
56
|
-
continue;
|
|
55
|
+
if (routeSegments.length !== pathSegments.length && !routeSegments.includes("*")) continue;
|
|
57
56
|
|
|
58
57
|
let matched = true;
|
|
59
58
|
const params: Record<string, string> = {};
|
|
@@ -102,15 +101,12 @@ export async function createRouter(DOM: HTMLElement) {
|
|
|
102
101
|
componentLoader = matched.route.component;
|
|
103
102
|
params = matched.params;
|
|
104
103
|
} else {
|
|
105
|
-
componentLoader = async () => ({ default: NotFound });
|
|
104
|
+
componentLoader = async () => ({ default: NotFound as Component });
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
if (push) history.pushState(null, "", url.pathname + url.search);
|
|
109
108
|
|
|
110
|
-
useTSParams.getState().setFromPatternValues(
|
|
111
|
-
Object.keys(params),
|
|
112
|
-
Object.values(params)
|
|
113
|
-
);
|
|
109
|
+
useTSParams.getState().setFromPatternValues(Object.keys(params), Object.values(params));
|
|
114
110
|
|
|
115
111
|
const query: Record<string, string> = {};
|
|
116
112
|
url.searchParams.forEach((v, k) => { query[k] = v; });
|
package/dist/index.js
CHANGED
|
@@ -36,10 +36,10 @@ import { useTSElements, useTSParams, html } from "@devwaren/vanilla-ts";
|
|
|
36
36
|
import type { Module, Component } from "./types";
|
|
37
37
|
|
|
38
38
|
// -----------------------------
|
|
39
|
-
${h?`export const NotFound = async (DOM: HTMLElement) => {
|
|
39
|
+
${h?`export const NotFound: import("../gen/types").Component = async (DOM: HTMLElement) => {
|
|
40
40
|
const mod: import("../gen/types").Module = await import("../pages/${e.relative(r,h.file).replace(/\\/g,"/").replace(/\\.ts$/,"")}");
|
|
41
41
|
return mod.default(DOM);
|
|
42
|
-
};`:
|
|
42
|
+
};`:'export const NotFound: import("../gen/types").Component = (DOM: HTMLElement) =>\n useTSElements(DOM, html`<h1>404 - Page Not Found</h1>`);'}
|
|
43
43
|
|
|
44
44
|
// -----------------------------
|
|
45
45
|
export const routeTree: { path: string; name: string; component: () => Promise<Module> }[] = [
|
|
@@ -52,8 +52,7 @@ function matchRoute(pathname: string) {
|
|
|
52
52
|
const routeSegments = r.path.split("/").filter(Boolean);
|
|
53
53
|
const pathSegments = pathname.split("/").filter(Boolean);
|
|
54
54
|
|
|
55
|
-
if (routeSegments.length !== pathSegments.length && !routeSegments.includes("*"))
|
|
56
|
-
continue;
|
|
55
|
+
if (routeSegments.length !== pathSegments.length && !routeSegments.includes("*")) continue;
|
|
57
56
|
|
|
58
57
|
let matched = true;
|
|
59
58
|
const params: Record<string, string> = {};
|
|
@@ -102,15 +101,12 @@ export async function createRouter(DOM: HTMLElement) {
|
|
|
102
101
|
componentLoader = matched.route.component;
|
|
103
102
|
params = matched.params;
|
|
104
103
|
} else {
|
|
105
|
-
componentLoader = async () => ({ default: NotFound });
|
|
104
|
+
componentLoader = async () => ({ default: NotFound as Component });
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
if (push) history.pushState(null, "", url.pathname + url.search);
|
|
109
108
|
|
|
110
|
-
useTSParams.getState().setFromPatternValues(
|
|
111
|
-
Object.keys(params),
|
|
112
|
-
Object.values(params)
|
|
113
|
-
);
|
|
109
|
+
useTSParams.getState().setFromPatternValues(Object.keys(params), Object.values(params));
|
|
114
110
|
|
|
115
111
|
const query: Record<string, string> = {};
|
|
116
112
|
url.searchParams.forEach((v, k) => { query[k] = v; });
|