frontend-hamroun 1.2.84 → 1.2.85
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/templates/basic-app/build.d.ts +2 -0
- package/templates/basic-app/build.d.ts.map +1 -0
- package/templates/basic-app/dev.d.ts +2 -0
- package/templates/basic-app/dev.d.ts.map +1 -0
- package/templates/basic-app/esbuild.config.d.ts +2 -0
- package/templates/basic-app/esbuild.config.d.ts.map +1 -0
- package/templates/basic-app/postcss.config.d.ts +8 -0
- package/templates/basic-app/postcss.config.d.ts.map +1 -0
- package/templates/basic-app/server.d.ts +2 -0
- package/templates/basic-app/server.d.ts.map +1 -0
- package/templates/basic-app/src/App.d.ts +2 -0
- package/templates/basic-app/src/App.d.ts.map +1 -0
- package/templates/basic-app/src/App.js +148 -0
- package/templates/basic-app/src/client.d.ts +2 -0
- package/templates/basic-app/src/client.d.ts.map +1 -0
- package/templates/basic-app/src/client.js +6 -0
- package/templates/basic-app/src/components/Counter.d.ts +4 -0
- package/templates/basic-app/src/components/Counter.d.ts.map +1 -0
- package/templates/basic-app/src/components/Counter.js +9 -0
- package/templates/basic-app/src/jsx-shim.d.ts +8 -0
- package/templates/basic-app/src/jsx-shim.d.ts.map +1 -0
- package/templates/basic-app/src/main.d.ts +2 -0
- package/templates/basic-app/src/main.d.ts.map +1 -0
- package/templates/basic-app/src/main.js +57 -0
- package/templates/basic-app/src/server.d.ts +2 -0
- package/templates/basic-app/src/server.d.ts.map +1 -0
- package/templates/basic-app/tailwind.config.d.ts +9 -0
- package/templates/basic-app/tailwind.config.d.ts.map +1 -0
- package/templates/basic-app/vite.config.d.ts +3 -0
- package/templates/basic-app/vite.config.d.ts.map +1 -0
- package/templates/basic-app/vite.config.js +7 -0
- package/templates/complete-app/api/hello.d.ts +1 -0
- package/templates/complete-app/api/hello.d.ts.map +1 -0
- package/templates/complete-app/client.d.ts +2 -0
- package/templates/complete-app/client.d.ts.map +1 -0
- package/templates/complete-app/lib/frontend-hamroun.d.ts +18 -0
- package/templates/complete-app/lib/frontend-hamroun.d.ts.map +1 -0
- package/templates/complete-app/pages/about.d.ts +7 -0
- package/templates/complete-app/pages/about.d.ts.map +1 -0
- package/templates/complete-app/pages/index.d.ts +7 -0
- package/templates/complete-app/pages/index.d.ts.map +1 -0
- package/templates/complete-app/pages/wasm-demo.d.ts +7 -0
- package/templates/complete-app/pages/wasm-demo.d.ts.map +1 -0
- package/templates/complete-app/public/client.d.ts +17 -0
- package/templates/complete-app/public/client.d.ts.map +1 -0
- package/templates/complete-app/server.d.ts +2 -0
- package/templates/complete-app/server.d.ts.map +1 -0
- package/templates/complete-app/server.js +236 -218
- package/templates/complete-app/src/App.d.ts +2 -0
- package/templates/complete-app/src/App.d.ts.map +1 -0
- package/templates/complete-app/src/App.js +27 -0
- package/templates/complete-app/src/client.d.ts +2 -0
- package/templates/complete-app/src/client.d.ts.map +1 -0
- package/templates/complete-app/src/client.js +52 -0
- package/templates/complete-app/src/pages/index.d.ts +2 -0
- package/templates/complete-app/src/pages/index.d.ts.map +1 -0
- package/templates/complete-app/src/pages/index.js +19 -0
- package/templates/complete-app/src/server.d.ts +2 -0
- package/templates/complete-app/src/server.d.ts.map +1 -0
- package/templates/complete-app/src/server.js +192 -0
- package/templates/complete-app/vite.config.d.ts +3 -0
- package/templates/complete-app/vite.config.d.ts.map +1 -0
- package/templates/complete-app/vite.config.js +29 -57
- package/templates/fullstack-app/api/hello.d.ts +4 -0
- package/templates/fullstack-app/api/hello.d.ts.map +1 -0
- package/templates/fullstack-app/api/hello.js +14 -11
- package/templates/fullstack-app/api/users/[id].d.ts +5 -0
- package/templates/fullstack-app/api/users/[id].d.ts.map +1 -0
- package/templates/fullstack-app/api/users/[id].js +52 -0
- package/templates/fullstack-app/api/users/index.d.ts +4 -0
- package/templates/fullstack-app/api/users/index.d.ts.map +1 -0
- package/templates/fullstack-app/api/users/index.js +25 -0
- package/templates/fullstack-app/build/main.d.ts +211 -0
- package/templates/fullstack-app/build/main.d.ts.map +1 -0
- package/templates/fullstack-app/build.d.ts +2 -0
- package/templates/fullstack-app/build.d.ts.map +1 -0
- package/templates/fullstack-app/build.js +190 -0
- package/templates/fullstack-app/postcss.config.d.ts +5 -0
- package/templates/fullstack-app/postcss.config.d.ts.map +1 -0
- package/templates/fullstack-app/process-tailwind.d.ts +2 -0
- package/templates/fullstack-app/process-tailwind.d.ts.map +1 -0
- package/templates/fullstack-app/public/route-handler.d.ts +1 -0
- package/templates/fullstack-app/public/route-handler.d.ts.map +1 -0
- package/templates/fullstack-app/server.d.ts +2 -0
- package/templates/fullstack-app/server.d.ts.map +1 -0
- package/templates/fullstack-app/server.js +428 -266
- package/templates/fullstack-app/src/client.d.ts +2 -0
- package/templates/fullstack-app/src/client.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/ClientHome.d.ts +1 -0
- package/templates/fullstack-app/src/components/ClientHome.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/ClientHome.js +1 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.d.ts +7 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.js +12 -0
- package/templates/fullstack-app/src/components/Layout.d.ts +7 -0
- package/templates/fullstack-app/src/components/Layout.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/Layout.js +4 -0
- package/templates/fullstack-app/src/components/StateDemo.d.ts +2 -0
- package/templates/fullstack-app/src/components/StateDemo.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/StateDemo.js +86 -0
- package/templates/fullstack-app/src/components/UserList.d.ts +11 -0
- package/templates/fullstack-app/src/components/UserList.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/UserList.js +7 -0
- package/templates/fullstack-app/src/config.d.ts +29 -0
- package/templates/fullstack-app/src/config.d.ts.map +1 -0
- package/templates/fullstack-app/src/config.js +36 -0
- package/templates/fullstack-app/src/data/api.d.ts +35 -0
- package/templates/fullstack-app/src/data/api.d.ts.map +1 -0
- package/templates/fullstack-app/src/data/api.js +173 -0
- package/templates/fullstack-app/src/main.d.ts +7 -0
- package/templates/fullstack-app/src/main.d.ts.map +1 -0
- package/templates/fullstack-app/src/main.js +130 -0
- package/templates/fullstack-app/src/middleware.d.ts +10 -0
- package/templates/fullstack-app/src/middleware.d.ts.map +1 -0
- package/templates/fullstack-app/src/middleware.js +14 -0
- package/templates/fullstack-app/src/pages/404.d.ts +4 -0
- package/templates/fullstack-app/src/pages/404.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/404.js +4 -0
- package/templates/fullstack-app/src/pages/[id].d.ts +1 -0
- package/templates/fullstack-app/src/pages/[id].d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/[id].js +1 -0
- package/templates/fullstack-app/src/pages/_app.d.ts +6 -0
- package/templates/fullstack-app/src/pages/_app.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/_app.js +6 -0
- package/templates/fullstack-app/src/pages/_document.d.ts +7 -0
- package/templates/fullstack-app/src/pages/_document.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/_document.js +4 -0
- package/templates/fullstack-app/src/pages/_error.d.ts +4 -0
- package/templates/fullstack-app/src/pages/_error.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/_error.js +8 -0
- package/templates/fullstack-app/src/pages/about/index.d.ts +5 -0
- package/templates/fullstack-app/src/pages/about/index.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/about/index.js +6 -0
- package/templates/fullstack-app/src/pages/about.d.ts +10 -0
- package/templates/fullstack-app/src/pages/about.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/about.js +21 -0
- package/templates/fullstack-app/src/pages/api/users/[id].d.ts +6 -0
- package/templates/fullstack-app/src/pages/api/users/[id].d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/api/users/[id].js +51 -0
- package/templates/fullstack-app/src/pages/api/users/index.d.ts +4 -0
- package/templates/fullstack-app/src/pages/api/users/index.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/api/users/index.js +33 -0
- package/templates/fullstack-app/src/pages/index.d.ts +21 -0
- package/templates/fullstack-app/src/pages/index.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/index.js +66 -0
- package/templates/fullstack-app/src/pages/users/[id].d.ts +38 -0
- package/templates/fullstack-app/src/pages/users/[id].d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/users/[id].js +79 -0
- package/templates/fullstack-app/src/pages/users.d.ts +14 -0
- package/templates/fullstack-app/src/pages/users.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/users.js +14 -0
- package/templates/fullstack-app/src/pages/wasm-demo.d.ts +1 -0
- package/templates/fullstack-app/src/pages/wasm-demo.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/wasm-demo.js +2 -0
- package/templates/fullstack-app/src/router.d.ts +22 -0
- package/templates/fullstack-app/src/router.d.ts.map +1 -0
- package/templates/fullstack-app/src/router.js +210 -0
- package/templates/fullstack-app/tailwind.config.d.ts +3 -0
- package/templates/fullstack-app/tailwind.config.d.ts.map +1 -0
- package/templates/fullstack-app/vite.config.d.ts +3 -0
- package/templates/fullstack-app/vite.config.d.ts.map +1 -0
- package/templates/ssr-template/dist/client/assets/main-D-VH3xOb.d.ts +2 -0
- package/templates/ssr-template/dist/client/assets/main-D-VH3xOb.d.ts.map +1 -0
- package/templates/ssr-template/dist/client.d.ts +85 -0
- package/templates/ssr-template/dist/client.d.ts.map +1 -0
- package/templates/ssr-template/dist/server.d.ts +2 -0
- package/templates/ssr-template/dist/server.d.ts.map +1 -0
- package/templates/ssr-template/esbuild.config.d.ts +2 -0
- package/templates/ssr-template/esbuild.config.d.ts.map +1 -0
- package/templates/ssr-template/jsx-shim.d.ts +2 -0
- package/templates/ssr-template/jsx-shim.d.ts.map +1 -0
- package/templates/ssr-template/src/App.d.ts +2 -0
- package/templates/ssr-template/src/App.d.ts.map +1 -0
- package/templates/ssr-template/src/App.js +625 -0
- package/templates/ssr-template/src/client.d.ts +2 -0
- package/templates/ssr-template/src/client.d.ts.map +1 -0
- package/templates/ssr-template/src/client.js +3 -0
- package/templates/ssr-template/src/server.d.ts +2 -0
- package/templates/ssr-template/src/server.d.ts.map +1 -0
- package/templates/ssr-template/src/server.js +29 -0
- package/templates/ssr-template/vite.config.d.ts +3 -0
- package/templates/ssr-template/vite.config.d.ts.map +1 -0
- package/templates/ssr-template/vite.config.js +30 -0
- package/templates/wasm/build-wasm.d.ts +2 -0
- package/templates/wasm/build-wasm.d.ts.map +1 -0
- package/templates/wasm/dist/assets/index-BNqTDBdE.d.ts +30 -0
- package/templates/wasm/dist/assets/index-BNqTDBdE.d.ts.map +1 -0
- package/templates/wasm/dist/wasm_exec.d.ts +1 -0
- package/templates/wasm/dist/wasm_exec.d.ts.map +1 -0
- package/templates/wasm/esbuild.config.d.ts +2 -0
- package/templates/wasm/esbuild.config.d.ts.map +1 -0
- package/templates/wasm/go/wasm_exec.d.ts +1 -0
- package/templates/wasm/go/wasm_exec.d.ts.map +1 -0
- package/templates/wasm/jsx-shim.d.ts +5 -0
- package/templates/wasm/jsx-shim.d.ts.map +1 -0
- package/templates/wasm/public/wasm_exec.d.ts +1 -0
- package/templates/wasm/public/wasm_exec.d.ts.map +1 -0
- package/templates/wasm/src/App.d.ts +2 -0
- package/templates/wasm/src/App.d.ts.map +1 -0
- package/templates/wasm/src/App.js +381 -0
- package/templates/wasm/src/client.d.ts +2 -0
- package/templates/wasm/src/client.d.ts.map +1 -0
- package/templates/wasm/src/client.js +210 -0
- package/templates/wasm/src/index.d.ts +2 -0
- package/templates/wasm/src/index.d.ts.map +1 -0
- package/templates/wasm/src/index.js +20 -0
- package/templates/wasm/src/server.d.ts +2 -0
- package/templates/wasm/src/server.d.ts.map +1 -0
- package/templates/wasm/src/server.js +131 -0
- package/templates/wasm/vite.config.d.ts +3 -0
- package/templates/wasm/vite.config.d.ts.map +1 -0
- package/templates/wasm/vite.config.js +36 -0
- package/templates/wasm/wasm-loader.d.ts +6 -0
- package/templates/wasm/wasm-loader.d.ts.map +1 -0
@@ -0,0 +1,210 @@
|
|
1
|
+
import { jsx } from 'frontend-hamroun';
|
2
|
+
// Define router class for handling routes
|
3
|
+
export class Router {
|
4
|
+
constructor() {
|
5
|
+
this.routes = {};
|
6
|
+
this.notFoundComponent = null;
|
7
|
+
}
|
8
|
+
// Register a component for a specific route
|
9
|
+
register(path, component) {
|
10
|
+
const normalizedPath = path === '/' ? 'index' : path.replace(/^\//, '');
|
11
|
+
this.routes[normalizedPath] = component;
|
12
|
+
console.log(`[Router] Registered component for path: ${normalizedPath}`);
|
13
|
+
return this;
|
14
|
+
}
|
15
|
+
// Set the not found component
|
16
|
+
setNotFound(component) {
|
17
|
+
this.notFoundComponent = component;
|
18
|
+
return this;
|
19
|
+
}
|
20
|
+
// Get the not found component
|
21
|
+
getNotFound() {
|
22
|
+
return this.notFoundComponent;
|
23
|
+
}
|
24
|
+
// Get all registered routes
|
25
|
+
getAllRoutes() {
|
26
|
+
return this.routes;
|
27
|
+
}
|
28
|
+
// Find component for a given path
|
29
|
+
async resolve(path) {
|
30
|
+
const normalizedPath = path === '/' ? 'index' : path.replace(/^\//, '');
|
31
|
+
console.log(`[Router] Resolving component for path: ${normalizedPath}`);
|
32
|
+
// Check for exact match first
|
33
|
+
if (this.routes[normalizedPath]) {
|
34
|
+
return this.routes[normalizedPath];
|
35
|
+
}
|
36
|
+
// Check for nested routes (e.g., "users/123" should match a "users/[id]" route)
|
37
|
+
const pathSegments = normalizedPath.split('/');
|
38
|
+
const registeredRoutes = Object.keys(this.routes);
|
39
|
+
// Try to find dynamic route matches
|
40
|
+
for (const route of registeredRoutes) {
|
41
|
+
const routeSegments = route.split('/');
|
42
|
+
// Skip routes with different segment count
|
43
|
+
if (routeSegments.length !== pathSegments.length)
|
44
|
+
continue;
|
45
|
+
let isMatch = true;
|
46
|
+
const params = {};
|
47
|
+
// Compare each segment
|
48
|
+
for (let i = 0; i < routeSegments.length; i++) {
|
49
|
+
const routeSegment = routeSegments[i];
|
50
|
+
const pathSegment = pathSegments[i];
|
51
|
+
// Handle dynamic segments (e.g., [id])
|
52
|
+
if (routeSegment.startsWith('[') && routeSegment.endsWith(']')) {
|
53
|
+
const paramName = routeSegment.slice(1, -1);
|
54
|
+
params[paramName] = pathSegment;
|
55
|
+
}
|
56
|
+
// Regular segment, must match exactly
|
57
|
+
else if (routeSegment !== pathSegment) {
|
58
|
+
isMatch = false;
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
if (isMatch) {
|
63
|
+
console.log(`[Router] Found dynamic route match: ${route}`);
|
64
|
+
// Return the component with params
|
65
|
+
return this.routes[route];
|
66
|
+
}
|
67
|
+
}
|
68
|
+
// If no match found yet, try to dynamically import the component
|
69
|
+
try {
|
70
|
+
let component = null;
|
71
|
+
let resolvedPath = normalizedPath;
|
72
|
+
// Next.js-style dynamic route resolution
|
73
|
+
try {
|
74
|
+
// First, try direct file match (e.g., ./pages/users.tsx)
|
75
|
+
// Focus on .tsx since that's what this project uses
|
76
|
+
try {
|
77
|
+
console.log(`[Router] Trying direct import: ./pages/${resolvedPath}.tsx`);
|
78
|
+
const directModule = await import(/* @vite-ignore */ `./pages/${resolvedPath}.tsx`)
|
79
|
+
.catch(() => null);
|
80
|
+
if (directModule) {
|
81
|
+
component = directModule.default || directModule;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
catch (e) {
|
85
|
+
console.warn(`[Router] Error importing ./pages/${resolvedPath}.tsx:`, e);
|
86
|
+
}
|
87
|
+
// Next, try index file in directory (e.g., ./pages/about/index.tsx)
|
88
|
+
if (!component && !resolvedPath.endsWith('index')) {
|
89
|
+
try {
|
90
|
+
console.log(`[Router] Trying index file: ./pages/${resolvedPath}/index.tsx`);
|
91
|
+
const indexModule = await import(/* @vite-ignore */ `./pages/${resolvedPath}/index.tsx`)
|
92
|
+
.catch(() => null);
|
93
|
+
if (indexModule) {
|
94
|
+
component = indexModule.default || indexModule;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
catch (e) {
|
98
|
+
console.warn(`[Router] Error importing ./pages/${resolvedPath}/index.tsx:`, e);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
catch (routeError) {
|
103
|
+
console.warn(`[Router] Error resolving Next.js style route:`, routeError);
|
104
|
+
}
|
105
|
+
// Register and return component if found
|
106
|
+
if (component) {
|
107
|
+
this.routes[normalizedPath] = component;
|
108
|
+
return component;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
catch (error) {
|
112
|
+
console.warn(`[Router] Error importing component for ${normalizedPath}:`, error);
|
113
|
+
}
|
114
|
+
// If we reach here, no component was found
|
115
|
+
console.warn(`[Router] No component found for path: ${normalizedPath}`);
|
116
|
+
return this.notFoundComponent;
|
117
|
+
}
|
118
|
+
// Auto-discover components in the pages directory
|
119
|
+
async discoverRoutes() {
|
120
|
+
console.log('[Router] Auto-discovering routes from pages directory...');
|
121
|
+
try {
|
122
|
+
// Use a more conventional approach instead of relying on import.meta.glob
|
123
|
+
await this.tryLoadCoreRoutes();
|
124
|
+
console.log('[Router] Route discovery complete. Available routes:', Object.keys(this.routes));
|
125
|
+
return this.routes;
|
126
|
+
}
|
127
|
+
catch (error) {
|
128
|
+
console.error('[Router] Error discovering routes:', error);
|
129
|
+
await this.tryLoadCoreRoutes();
|
130
|
+
return this.routes;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
// Fallback method to load core routes
|
134
|
+
async tryLoadCoreRoutes() {
|
135
|
+
// First try the auto-discovery approach with dynamic imports
|
136
|
+
const pageModules = [
|
137
|
+
{ path: './pages/index', route: 'index' },
|
138
|
+
{ path: './pages/about/index', route: 'about' },
|
139
|
+
{ path: './pages/users', route: 'users' }
|
140
|
+
];
|
141
|
+
// Try importing each module dynamically - focus on .tsx files
|
142
|
+
for (const { path, route } of pageModules) {
|
143
|
+
if (!this.routes[route]) {
|
144
|
+
try {
|
145
|
+
console.log(`[Router] Attempting to load route: ${route}`);
|
146
|
+
// Only try .tsx imports since that's what the project uses
|
147
|
+
const module = await import(/* @vite-ignore */ `${path}.tsx`)
|
148
|
+
.catch(() => null);
|
149
|
+
if (module && module.default) {
|
150
|
+
this.routes[route] = module.default;
|
151
|
+
console.log(`[Router] Registered route: ${route}`);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
catch (error) {
|
155
|
+
console.warn(`[Router] Could not load route: ${route}`, error);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
// Create and export a router instance
|
162
|
+
export const router = new Router();
|
163
|
+
// NotFound component as fallback (using jsx function instead of JSX syntax)
|
164
|
+
export const NotFound = ({ initialState }) => {
|
165
|
+
return jsx('div', { className: 'container mx-auto px-4 py-12 max-w-4xl' }, [
|
166
|
+
jsx('div', { className: 'bg-white shadow-lg rounded-lg overflow-hidden p-8' }, [
|
167
|
+
jsx('h1', { className: 'text-3xl font-bold text-gray-800 mb-4' }, ['Page Not Found']),
|
168
|
+
jsx('p', { className: 'text-gray-600 mb-6' }, [`No component found for path: ${initialState?.route || 'unknown'}`]),
|
169
|
+
jsx('a', { href: '/', className: 'text-blue-600 hover:text-blue-800 hover:underline transition-colors' }, ['Go to Home']),
|
170
|
+
jsx('div', { className: 'mt-8 p-6 bg-gray-50 rounded-lg border border-gray-200' }, [
|
171
|
+
jsx('h3', { className: 'text-lg font-medium text-gray-700 mb-3' }, ['Available Routes']),
|
172
|
+
jsx('ul', { className: 'space-y-2' }, [
|
173
|
+
jsx('li', {}, [jsx('a', { href: '/', className: 'text-blue-600 hover:text-blue-800 hover:underline' }, ['Home'])]),
|
174
|
+
jsx('li', {}, [jsx('a', { href: '/about', className: 'text-blue-600 hover:text-blue-800 hover:underline' }, ['About'])]),
|
175
|
+
jsx('li', {}, [jsx('a', { href: '/users', className: 'text-blue-600 hover:text-blue-800 hover:underline' }, ['Users'])])
|
176
|
+
])
|
177
|
+
])
|
178
|
+
])
|
179
|
+
]);
|
180
|
+
};
|
181
|
+
// Set NotFound as the default fallback
|
182
|
+
router.setNotFound(NotFound);
|
183
|
+
// Improved router initialization with auto-discovery
|
184
|
+
export async function initializeRouter() {
|
185
|
+
try {
|
186
|
+
console.log('[Router] Initializing router with auto-discovery...');
|
187
|
+
// Auto-discover routes
|
188
|
+
await router.discoverRoutes();
|
189
|
+
// Register fallback pages for key routes if they weren't discovered
|
190
|
+
const routes = router.getAllRoutes();
|
191
|
+
if (!routes['index']) {
|
192
|
+
router.register('index', ({ initialState }) => jsx('div', {}, [
|
193
|
+
jsx('h1', {}, ['Welcome']),
|
194
|
+
jsx('p', {}, ['This is the home page.'])
|
195
|
+
]));
|
196
|
+
}
|
197
|
+
if (!routes['about']) {
|
198
|
+
router.register('about', ({ initialState }) => jsx('div', {}, [
|
199
|
+
jsx('h1', {}, ['About']),
|
200
|
+
jsx('p', {}, ['This is the about page.'])
|
201
|
+
]));
|
202
|
+
}
|
203
|
+
console.log('[Router] Router initialized with routes:', Object.keys(router.getAllRoutes()));
|
204
|
+
return router;
|
205
|
+
}
|
206
|
+
catch (error) {
|
207
|
+
console.error('[Router] Error initializing router:', error);
|
208
|
+
return router;
|
209
|
+
}
|
210
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tailwind.config.d.ts","sourceRoot":"","sources":["tailwind.config.js"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["vite.config.js"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"main-D-VH3xOb.d.ts","sourceRoot":"","sources":["main-D-VH3xOb.js"],"names":[],"mappings":""}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
declare function batchUpdates(fn: any): void;
|
2
|
+
declare function batchUpdates(fn: any): void;
|
3
|
+
declare function setRenderCallback(callback: any, element: any, container: any): void;
|
4
|
+
declare function setRenderCallback(callback: any, element: any, container: any): void;
|
5
|
+
declare function prepareRender(): any;
|
6
|
+
declare function prepareRender(): any;
|
7
|
+
declare function finishRender(): void;
|
8
|
+
declare function finishRender(): void;
|
9
|
+
declare function useState(initial: any): any[];
|
10
|
+
declare function useState(initial: any): any[];
|
11
|
+
declare function useEffect(callback: any, deps: any): void;
|
12
|
+
declare function useEffect(callback: any, deps: any): void;
|
13
|
+
declare function useMemo(factory: any, deps: any): any;
|
14
|
+
declare function useMemo(factory: any, deps: any): any;
|
15
|
+
declare function rerender(rendererId: any): Promise<void>;
|
16
|
+
declare function rerender(rendererId: any): Promise<void>;
|
17
|
+
declare function useErrorBoundary(): any[];
|
18
|
+
declare function useErrorBoundary(): any[];
|
19
|
+
declare function jsx(type: any, props: any, ...children: any[]): {
|
20
|
+
type: any;
|
21
|
+
props: any;
|
22
|
+
};
|
23
|
+
declare function jsx(type: any, props: any, ...args: any[]): {
|
24
|
+
type: any;
|
25
|
+
props: any;
|
26
|
+
};
|
27
|
+
declare function jsx(type: any, props: any, ...args: any[]): {
|
28
|
+
type: any;
|
29
|
+
props: any;
|
30
|
+
};
|
31
|
+
declare function createElement(vnode: any): Promise<any>;
|
32
|
+
declare function createElement(vnode: any): any;
|
33
|
+
declare function hydrate(element: any, container: any): void;
|
34
|
+
declare function hydrate(element: any, container: any): Promise<void>;
|
35
|
+
declare function hydrate(element: any, container: any): Promise<void>;
|
36
|
+
declare function render(element: any, container: any): Promise<void>;
|
37
|
+
declare function render(element: any, container: any): Promise<void>;
|
38
|
+
declare function TodoItem({ todo, onToggle, onDelete }: {
|
39
|
+
todo: any;
|
40
|
+
onToggle: any;
|
41
|
+
onDelete: any;
|
42
|
+
}): {
|
43
|
+
type: any;
|
44
|
+
props: any;
|
45
|
+
};
|
46
|
+
declare function ThemeToggleButton({ theme, onToggle }: {
|
47
|
+
theme: any;
|
48
|
+
onToggle: any;
|
49
|
+
}): {
|
50
|
+
type: any;
|
51
|
+
props: any;
|
52
|
+
};
|
53
|
+
declare function AppFooter({ theme, isBrowser }: {
|
54
|
+
theme: any;
|
55
|
+
isBrowser: any;
|
56
|
+
}): {
|
57
|
+
type: any;
|
58
|
+
props: any;
|
59
|
+
};
|
60
|
+
declare function App({ Component, pageProps, initialState: initialState2 }: {
|
61
|
+
Component: any;
|
62
|
+
pageProps: any;
|
63
|
+
initialState: any;
|
64
|
+
}): {
|
65
|
+
type: any;
|
66
|
+
props: any;
|
67
|
+
};
|
68
|
+
declare function App(): {
|
69
|
+
type: any;
|
70
|
+
props: any;
|
71
|
+
};
|
72
|
+
declare var isBatching: boolean;
|
73
|
+
declare var queue: any[];
|
74
|
+
declare var currentRender: number;
|
75
|
+
declare var states: Map<any, any>;
|
76
|
+
declare var stateIndices: Map<any, any>;
|
77
|
+
declare var effects: Map<any, any>;
|
78
|
+
declare var memos: Map<any, any>;
|
79
|
+
declare var globalRenderCallback: null;
|
80
|
+
declare var globalContainer: null;
|
81
|
+
declare var currentElement: null;
|
82
|
+
declare var isServer: boolean;
|
83
|
+
declare var serverStates: Map<any, any>;
|
84
|
+
declare var isHydrating: boolean;
|
85
|
+
//# sourceMappingURL=client.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["client.js"],"names":[],"mappings":";AAGA,6CAeC;;AAWD,sFAIC;;AACD,sCAIC;;AACD,sCAKC;;AACD,+CAyCC;;AACD,2DAmBC;;AACD,uDAiBC;;AACD,0DAgBC;;AACD,2CAGC;;;;;;;;;AACD;;;EAOC;;AACD,gDAqEC;;;AAED,sEAOC;;AACD,qEAeC;AAGD;;;;;;;EAkBC;AACD;;;;;;EAUC;AACD;;;;;;EAEC;;;;;;;;;AACD;;;EAupBC;AAl7BD,gCAAuB;AACvB,yBAAe;AAiBf,kCAAsB;AACtB,kCAAuC;AACvC,wCAA6C;AAC7C,mCAAwC;AACxC,iCAAsC;AACtC,uCAAgC;AAChC,kCAA2B;AAC3B,iCAA0B;AAC1B,8BAA6C;AAC7C,wCAA6C;AAoM7C,iCAAwB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["server.js"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"esbuild.config.d.ts","sourceRoot":"","sources":["esbuild.config.js"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-shim.d.ts","sourceRoot":"","sources":["jsx-shim.js"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["App.tsx"],"names":[],"mappings":"AAwFA,wBAAgB,GAAG,gBAyxBlB"}
|