@devwareng/vanilla-ts 1.9.98 → 1.9.99

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 CHANGED
@@ -42,7 +42,9 @@ type Route = {
42
42
  component: (DOM: HTMLElement, params: Record<string,string>) => Promise<any>;
43
43
  };
44
44
 
45
- ${p?`export const NotFound: Route['component'] = useTSLazy(() => import("../pages/${t.relative(r,p.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:'export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div class="p-4 animate__animated animate__fadeIn"><h1>404 - Page Not Found</h1></div>`)\n}'}
45
+ ${p?`export const NotFound: Route['component'] = useTSLazy(() => import("../pages/${t.relative(r,p.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:`export const NotFound: Route['component'] = async (DOM, params) => {
46
+ return useTSElements(DOM, html\`<div class="p-4 animate__animated animate__fadeIn"><h1>404 - Page Not Found</h1></div>\`)
47
+ }`}
46
48
 
47
49
  export const routeTree: Route[] = [
48
50
  ${_}
@@ -70,11 +72,10 @@ export async function createRouter(DOM: HTMLElement) {
70
72
  async function navigate(path: string, pushState: boolean = true) {
71
73
  const match = matchRoute(path);
72
74
  if (match) {
73
- // TS knows component always accepts params
74
75
  await match.component(DOM, match.params);
75
76
  if (pushState) history.pushState({}, "", path);
76
77
  } else {
77
- NotFound(DOM);
78
+ await NotFound(DOM, {}); // always provide params
78
79
  }
79
80
  }
80
81
 
package/dist/index.js CHANGED
@@ -42,7 +42,9 @@ type Route = {
42
42
  component: (DOM: HTMLElement, params: Record<string,string>) => Promise<any>;
43
43
  };
44
44
 
45
- ${u?`export const NotFound: Route['component'] = useTSLazy(() => import("../pages/${e.relative(r,u.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:'export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div class="p-4 animate__animated animate__fadeIn"><h1>404 - Page Not Found</h1></div>`)\n}'}
45
+ ${u?`export const NotFound: Route['component'] = useTSLazy(() => import("../pages/${e.relative(r,u.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:`export const NotFound: Route['component'] = async (DOM, params) => {
46
+ return useTSElements(DOM, html\`<div class="p-4 animate__animated animate__fadeIn"><h1>404 - Page Not Found</h1></div>\`)
47
+ }`}
46
48
 
47
49
  export const routeTree: Route[] = [
48
50
  ${h}
@@ -70,11 +72,10 @@ export async function createRouter(DOM: HTMLElement) {
70
72
  async function navigate(path: string, pushState: boolean = true) {
71
73
  const match = matchRoute(path);
72
74
  if (match) {
73
- // TS knows component always accepts params
74
75
  await match.component(DOM, match.params);
75
76
  if (pushState) history.pushState({}, "", path);
76
77
  } else {
77
- NotFound(DOM);
78
+ await NotFound(DOM, {}); // always provide params
78
79
  }
79
80
  }
80
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devwareng/vanilla-ts",
3
- "version": "1.9.98",
3
+ "version": "1.9.99",
4
4
  "description": "Framework-less TypeScript hooks for SPA development.",
5
5
  "author": "Waren Arapoc Gador",
6
6
  "license": "MIT",