@flow-os/router 0.0.51-dev.1772057566 → 0.0.52

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.
@@ -1,23 +1,24 @@
1
- export default function NotFound(path: string) {
2
- return (
3
- <div
4
- role="alert"
5
- style={{
6
- minHeight: '100vh',
7
- display: 'flex',
8
- flexDirection: 'column',
9
- alignItems: 'center',
10
- justifyContent: 'center',
11
- gap: '0.5rem',
12
- }}
13
- >
14
- <h1 style={{ margin: 0, fontSize: '2rem' }}>404</h1>
15
- <p style={{ margin: 0, color: 'var(--muted, #666)' }}>
16
- {path ? `Page not found: ${path}` : 'Page not found'}
17
- </p>
18
- <a href="/" style={{ marginTop: '1rem' }}>
19
- Back to home
20
- </a>
21
- </div>
22
- );
23
- }
1
+ export default function NotFound(params: Record<string, string>) {
2
+ const path = params['404'] ?? params.rest ?? '/';
3
+ return (
4
+ <div
5
+ role="alert"
6
+ style={{
7
+ minHeight: '100vh',
8
+ display: 'flex',
9
+ flexDirection: 'column',
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ gap: '0.5rem',
13
+ }}
14
+ >
15
+ <h1 style={{ margin: 0, fontSize: '2rem' }}>404</h1>
16
+ <p style={{ margin: 0, color: 'var(--muted, #666)' }}>
17
+ {path && path !== '/' ? `Page not found: /${path}` : 'Page not found'}
18
+ </p>
19
+ <a href="/" style={{ marginTop: '1rem' }}>
20
+ Back to home
21
+ </a>
22
+ </div>
23
+ );
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flow-os/router",
3
- "version": "0.0.51-dev.1772057566",
3
+ "version": "0.0.52",
4
4
  "license": "PolyForm-Shield-1.0.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -38,29 +38,15 @@ export interface RouterAPI {
38
38
  start(): void;
39
39
  }
40
40
 
41
- const NOT_FOUND_PATTERN = '404';
42
-
43
41
  export function createRouter(
44
42
  modules: Record<string, () => Promise<RouteModule>>,
45
43
  container: HTMLElement,
46
44
  options: RouterOptions = {}
47
45
  ): RouterAPI {
48
46
  const allEntries = buildRouteEntries(modules);
49
- const routes = allEntries.filter((e) => e.pattern !== NOT_FOUND_PATTERN);
50
- const notFoundLoader = allEntries.find((e) => e.pattern === NOT_FOUND_PATTERN)?.loader ?? null;
51
-
52
- const notFound: Node | ((path: string) => Node | Promise<Node>) =
53
- options.notFound ??
54
- (notFoundLoader
55
- ? (path) =>
56
- notFoundLoader().then((mod) => {
57
- const def = mod.default;
58
- return typeof def === 'function' ? (def as (p: string) => Node)(path) : (def as unknown as Node);
59
- })
60
- : defaultNotFound);
61
- const fullPageNotFound = Boolean(
62
- options.appRoot && options.getLayout && (options.notFound != null || notFoundLoader != null)
63
- );
47
+ const routes = allEntries;
48
+ const notFound: Node | ((path: string) => Node | Promise<Node>) = options.notFound ?? defaultNotFound;
49
+ const fullPageNotFound = Boolean(options.appRoot && options.getLayout && options.notFound != null);
64
50
 
65
51
  function getContainer(): HTMLElement | null {
66
52
  return document.getElementById(APP_ID);