olova 2.0.61 → 2.0.63
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/CHANGELOG.md +5 -0
- package/README.md +42 -61
- package/dist/compiler.d.ts +44 -0
- package/dist/compiler.js +2139 -0
- package/dist/compiler.js.map +1 -0
- package/dist/core.d.ts +4 -0
- package/dist/core.js +859 -0
- package/dist/core.js.map +1 -0
- package/dist/global.d.ts +15 -0
- package/dist/global.js +226 -0
- package/dist/global.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2302 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +89 -0
- package/dist/runtime.js +633 -0
- package/dist/runtime.js.map +1 -0
- package/dist/signals-core-BdfWh1Yt.d.ts +43 -0
- package/dist/vite.d.ts +5 -0
- package/dist/vite.js +2302 -0
- package/dist/vite.js.map +1 -0
- package/package.json +83 -65
- package/dist/chunk-D7SIC5TC.js +0 -367
- package/dist/chunk-D7SIC5TC.js.map +0 -1
- package/dist/entry-server.cjs +0 -120
- package/dist/entry-server.cjs.map +0 -1
- package/dist/entry-server.js +0 -115
- package/dist/entry-server.js.map +0 -1
- package/dist/entry-worker.cjs +0 -133
- package/dist/entry-worker.cjs.map +0 -1
- package/dist/entry-worker.js +0 -127
- package/dist/entry-worker.js.map +0 -1
- package/dist/main.cjs +0 -18
- package/dist/main.cjs.map +0 -1
- package/dist/main.js +0 -16
- package/dist/main.js.map +0 -1
- package/dist/olova.cjs +0 -1680
- package/dist/olova.cjs.map +0 -1
- package/dist/olova.d.cts +0 -72
- package/dist/olova.d.ts +0 -72
- package/dist/olova.js +0 -1321
- package/dist/olova.js.map +0 -1
- package/dist/performance.cjs +0 -386
- package/dist/performance.cjs.map +0 -1
- package/dist/performance.js +0 -3
- package/dist/performance.js.map +0 -1
- package/dist/router.cjs +0 -646
- package/dist/router.cjs.map +0 -1
- package/dist/router.d.cts +0 -113
- package/dist/router.d.ts +0 -113
- package/dist/router.js +0 -632
- package/dist/router.js.map +0 -1
- package/main.tsx +0 -76
- package/olova.ts +0 -619
- package/src/entry-server.tsx +0 -165
- package/src/entry-worker.tsx +0 -201
- package/src/generator/index.ts +0 -409
- package/src/hydration/flight.ts +0 -320
- package/src/hydration/index.ts +0 -12
- package/src/hydration/types.ts +0 -225
- package/src/logger.ts +0 -182
- package/src/main.tsx +0 -24
- package/src/performance.ts +0 -488
- package/src/plugin/index.ts +0 -204
- package/src/router/ErrorBoundary.tsx +0 -145
- package/src/router/Link.tsx +0 -117
- package/src/router/OlovaRouter.tsx +0 -354
- package/src/router/Outlet.tsx +0 -8
- package/src/router/context.ts +0 -117
- package/src/router/index.ts +0 -29
- package/src/router/matching.ts +0 -63
- package/src/router/router.tsx +0 -23
- package/src/router/search-params.ts +0 -29
- package/src/scanner/index.ts +0 -114
- package/src/types/index.ts +0 -190
- package/src/utils/export.ts +0 -85
- package/src/utils/index.ts +0 -4
- package/src/utils/naming.ts +0 -54
- package/src/utils/path.ts +0 -45
- package/tsup.config.ts +0 -35
package/src/generator/index.ts
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import type { ErrorWithExport, LayoutWithExport, LoadingWithExport, MiddlewareWithExport, NotFoundWithExport, RouteWithExport } from '../types';
|
|
3
|
-
import { getRouteName as getPascalCaseName } from '../utils';
|
|
4
|
-
|
|
5
|
-
function stripImportExtension(filePath: string): string {
|
|
6
|
-
return filePath.replace(/\.tsx?$/, '');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function pathToRouteId(routePath: string): string {
|
|
10
|
-
if (routePath === '/') return '_root';
|
|
11
|
-
return routePath
|
|
12
|
-
.replace(/^\//, '')
|
|
13
|
-
.replace(/\//g, '_')
|
|
14
|
-
.replace(/:/g, '$')
|
|
15
|
-
.replace(/\*/g, '$catchall');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function extractParamNames(routePath: string): string[] {
|
|
19
|
-
const params: string[] = [];
|
|
20
|
-
for (const segment of routePath.split('/')) {
|
|
21
|
-
if (segment.startsWith(':')) params.push(segment.slice(1));
|
|
22
|
-
else if (segment === '*') params.push('*');
|
|
23
|
-
}
|
|
24
|
-
return params;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function generateParamType(routePath: string): string | null {
|
|
28
|
-
const params = extractParamNames(routePath);
|
|
29
|
-
if (params.length === 0) return null;
|
|
30
|
-
const fields = params.map(p =>
|
|
31
|
-
p === '*' ? "'*': string" : `${p}: string`
|
|
32
|
-
);
|
|
33
|
-
return `{ ${fields.join('; ')} }`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function generateRouteTree(
|
|
37
|
-
routes: RouteWithExport[],
|
|
38
|
-
notFoundPages: NotFoundWithExport[],
|
|
39
|
-
layouts: LayoutWithExport[],
|
|
40
|
-
loadingPages: LoadingWithExport[],
|
|
41
|
-
errorPages: ErrorWithExport[],
|
|
42
|
-
middlewares: MiddlewareWithExport[],
|
|
43
|
-
srcDir: string,
|
|
44
|
-
packageName: string = 'olovastart'
|
|
45
|
-
): string {
|
|
46
|
-
// Collision-free naming: track used names and append index on conflict
|
|
47
|
-
const usedNames = new Map<string, number>();
|
|
48
|
-
const getUniqueName = (baseName: string): string => {
|
|
49
|
-
const count = usedNames.get(baseName) || 0;
|
|
50
|
-
usedNames.set(baseName, count + 1);
|
|
51
|
-
return count === 0 ? baseName : `${baseName}${count}`;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const getRouteName = (filePath: string, suffix: string = ''): string => {
|
|
55
|
-
const relPath = path.relative(srcDir, filePath);
|
|
56
|
-
const pathNoExt = relPath.replace(/\.(tsx?|mdx)$/, '');
|
|
57
|
-
|
|
58
|
-
if (pathNoExt === '' || pathNoExt === '.' || pathNoExt === 'index') {
|
|
59
|
-
return getUniqueName('Root' + suffix);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const name = getPascalCaseName(pathNoExt);
|
|
63
|
-
if (!name) return getUniqueName('Root' + suffix);
|
|
64
|
-
|
|
65
|
-
if (suffix && name.toLowerCase().endsWith(suffix.toLowerCase())) {
|
|
66
|
-
return getUniqueName(name);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return getUniqueName(name + suffix);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Find closest matching entry by path prefix (most specific wins)
|
|
73
|
-
const findClosestEntry = <T extends { path: string }>(routePath: string, entries: T[]): T | null => {
|
|
74
|
-
let best: T | null = null;
|
|
75
|
-
for (const entry of entries) {
|
|
76
|
-
const ep = entry.path;
|
|
77
|
-
if (ep === '/' || routePath === ep || routePath.startsWith(ep + '/')) {
|
|
78
|
-
if (!best || ep.length > best.path.length) best = entry;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return best;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// ── Imports ──────────────────────────────────────────────────────────────
|
|
85
|
-
|
|
86
|
-
const routeNames: { moduleName: string; lazyName: string; eager: boolean }[] = [];
|
|
87
|
-
|
|
88
|
-
const routeImports = routes.map((route) => {
|
|
89
|
-
const relativePath = stripImportExtension('./app/' + path.relative(srcDir, route.component).replace(/\\/g, '/'));
|
|
90
|
-
// ALWAYS eager import for SSG - lazy() doesn't work with renderToString
|
|
91
|
-
const moduleName = getRouteName(route.component, 'RouteModule');
|
|
92
|
-
const lazyName = getRouteName(route.component, 'Route');
|
|
93
|
-
routeNames.push({ moduleName, lazyName, eager: true });
|
|
94
|
-
return `import * as ${moduleName} from '${relativePath}';`;
|
|
95
|
-
}).join('\n');
|
|
96
|
-
|
|
97
|
-
const notFoundNames: string[] = [];
|
|
98
|
-
const notFoundImports = notFoundPages.map((nf) => {
|
|
99
|
-
const relativePath = stripImportExtension('./app/' + path.relative(srcDir, nf.filePath).replace(/\\/g, '/'));
|
|
100
|
-
if (nf.hasMetadata) {
|
|
101
|
-
const moduleName = getRouteName(nf.filePath, 'NotFoundModule');
|
|
102
|
-
notFoundNames.push(moduleName);
|
|
103
|
-
return `import * as ${moduleName} from '${relativePath}';`;
|
|
104
|
-
}
|
|
105
|
-
const importName = getRouteName(nf.filePath, 'NotFound');
|
|
106
|
-
notFoundNames.push(importName);
|
|
107
|
-
if (nf.hasDefault) return `import ${importName} from '${relativePath}';`;
|
|
108
|
-
if (nf.namedExport) return `import { ${nf.namedExport} as ${importName} } from '${relativePath}';`;
|
|
109
|
-
return `import ${importName} from '${relativePath}';`;
|
|
110
|
-
}).join('\n');
|
|
111
|
-
|
|
112
|
-
const layoutNames: string[] = [];
|
|
113
|
-
const layoutImports = layouts.map((layout) => {
|
|
114
|
-
const relativePath = stripImportExtension('./app/' + path.relative(srcDir, layout.filePath).replace(/\\/g, '/'));
|
|
115
|
-
if (layout.hasMetadata) {
|
|
116
|
-
const moduleName = getRouteName(layout.filePath, 'LayoutModule');
|
|
117
|
-
layoutNames.push(moduleName);
|
|
118
|
-
return `import * as ${moduleName} from '${relativePath}';`;
|
|
119
|
-
}
|
|
120
|
-
const importName = getRouteName(layout.filePath, 'Layout');
|
|
121
|
-
layoutNames.push(importName);
|
|
122
|
-
if (layout.hasDefault) return `import ${importName} from '${relativePath}';`;
|
|
123
|
-
if (layout.namedExport) return `import { ${layout.namedExport} as ${importName} } from '${relativePath}';`;
|
|
124
|
-
return `import ${importName} from '${relativePath}';`;
|
|
125
|
-
}).join('\n');
|
|
126
|
-
|
|
127
|
-
const loadingNames: string[] = [];
|
|
128
|
-
const loadingImports = loadingPages.map((lp) => {
|
|
129
|
-
const relativePath = stripImportExtension('./app/' + path.relative(srcDir, lp.filePath).replace(/\\/g, '/'));
|
|
130
|
-
const importName = getRouteName(lp.filePath, 'Loading');
|
|
131
|
-
loadingNames.push(importName);
|
|
132
|
-
if (lp.hasDefault) return `import ${importName} from '${relativePath}';`;
|
|
133
|
-
if (lp.namedExport) return `import { ${lp.namedExport} as ${importName} } from '${relativePath}';`;
|
|
134
|
-
return `import ${importName} from '${relativePath}';`;
|
|
135
|
-
}).join('\n');
|
|
136
|
-
|
|
137
|
-
const errorNames: string[] = [];
|
|
138
|
-
const errorImports = errorPages.map((ep) => {
|
|
139
|
-
const relativePath = stripImportExtension('./app/' + path.relative(srcDir, ep.filePath).replace(/\\/g, '/'));
|
|
140
|
-
const importName = getRouteName(ep.filePath, 'Error');
|
|
141
|
-
errorNames.push(importName);
|
|
142
|
-
if (ep.hasDefault) return `import ${importName} from '${relativePath}';`;
|
|
143
|
-
if (ep.namedExport) return `import { ${ep.namedExport} as ${importName} } from '${relativePath}';`;
|
|
144
|
-
return `import ${importName} from '${relativePath}';`;
|
|
145
|
-
}).join('\n');
|
|
146
|
-
|
|
147
|
-
const middlewareNames: string[] = [];
|
|
148
|
-
const middlewareImports = middlewares.map((mw) => {
|
|
149
|
-
const relativePath = stripImportExtension('./app/' + path.relative(srcDir, mw.filePath).replace(/\\/g, '/'));
|
|
150
|
-
const importName = getRouteName(mw.filePath, 'Middleware');
|
|
151
|
-
middlewareNames.push(importName);
|
|
152
|
-
if (mw.hasDefault) return `import ${importName} from '${relativePath}';`;
|
|
153
|
-
if (mw.namedExport) return `import { ${mw.namedExport} as ${importName} } from '${relativePath}';`;
|
|
154
|
-
return `import ${importName} from '${relativePath}';`;
|
|
155
|
-
}).join('\n');
|
|
156
|
-
|
|
157
|
-
// ── Route objects ────────────────────────────────────────────────────────
|
|
158
|
-
|
|
159
|
-
const routeObjects = routes.map((route, index) => {
|
|
160
|
-
const { moduleName, lazyName, eager } = routeNames[index];
|
|
161
|
-
const component = eager ? `${moduleName}.default` : lazyName;
|
|
162
|
-
const routeId = pathToRouteId(route.path);
|
|
163
|
-
|
|
164
|
-
const fields: string[] = [
|
|
165
|
-
`id: '${routeId}'`,
|
|
166
|
-
`path: '${route.path}'`,
|
|
167
|
-
`component: ${component}`,
|
|
168
|
-
];
|
|
169
|
-
|
|
170
|
-
if (route.params && route.params.length > 0) {
|
|
171
|
-
fields.push(`params: [${route.params.map(p => `'${p}'`).join(', ')}]`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (route.metadataSource) {
|
|
175
|
-
fields.push(`metadata: ${route.metadataSource}`);
|
|
176
|
-
} else if (route.hasMetadata) {
|
|
177
|
-
fields.push(`metadata: ${moduleName}.metadata`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (route.hasGetStaticPaths) {
|
|
181
|
-
fields.push(`getStaticPaths: ${moduleName}.getStaticPaths`);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (route.hasLoader) {
|
|
185
|
-
fields.push(`loader: ${moduleName}.loader`);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const closestLoading = findClosestEntry(route.path, loadingPages);
|
|
189
|
-
if (closestLoading) {
|
|
190
|
-
const idx = loadingPages.indexOf(closestLoading);
|
|
191
|
-
fields.push(`loading: ${loadingNames[idx]}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const closestError = findClosestEntry(route.path, errorPages);
|
|
195
|
-
if (closestError) {
|
|
196
|
-
const idx = errorPages.indexOf(closestError);
|
|
197
|
-
fields.push(`error: ${errorNames[idx]}`);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return ` {\n ${fields.join(',\n ')}\n }`;
|
|
201
|
-
}).join(',\n');
|
|
202
|
-
|
|
203
|
-
// ── 404 pages ────────────────────────────────────────────────────────────
|
|
204
|
-
|
|
205
|
-
const notFoundObjects = notFoundPages.map((nf, index) => {
|
|
206
|
-
const name = notFoundNames[index];
|
|
207
|
-
const isModule = nf.hasMetadata;
|
|
208
|
-
const component = isModule ? `${name}.default` : name;
|
|
209
|
-
const fields: string[] = [
|
|
210
|
-
`pathPrefix: '${nf.pathPrefix}'`,
|
|
211
|
-
`component: ${component}`,
|
|
212
|
-
];
|
|
213
|
-
if (isModule) fields.push(`metadata: ${name}.metadata`);
|
|
214
|
-
return ` {\n ${fields.join(',\n ')}\n }`;
|
|
215
|
-
}).join(',\n');
|
|
216
|
-
|
|
217
|
-
// ── Layouts with children ────────────────────────────────────────────────
|
|
218
|
-
|
|
219
|
-
const layoutObjects = layouts.map((layout, index) => {
|
|
220
|
-
const name = layoutNames[index];
|
|
221
|
-
const isModule = layout.hasMetadata;
|
|
222
|
-
const component = isModule ? `${name}.default` : name;
|
|
223
|
-
|
|
224
|
-
// Populate children: routes whose path is within this layout's scope
|
|
225
|
-
const childRouteIds = routes
|
|
226
|
-
.filter(r => {
|
|
227
|
-
if (layout.path === '/') return true;
|
|
228
|
-
return r.path === layout.path || r.path.startsWith(layout.path + '/');
|
|
229
|
-
})
|
|
230
|
-
.map(r => `'${pathToRouteId(r.path)}'`);
|
|
231
|
-
|
|
232
|
-
const fields: string[] = [
|
|
233
|
-
`path: '${layout.path}'`,
|
|
234
|
-
`layout: ${component}`,
|
|
235
|
-
`children: [${childRouteIds.join(', ')}]`,
|
|
236
|
-
];
|
|
237
|
-
if (isModule) fields.push(`metadata: ${name}.metadata`);
|
|
238
|
-
return ` {\n ${fields.join(',\n ')}\n }`;
|
|
239
|
-
}).join(',\n');
|
|
240
|
-
|
|
241
|
-
// ── Middleware map ───────────────────────────────────────────────────────
|
|
242
|
-
|
|
243
|
-
const middlewareEntries = middlewares.map((mw, index) => {
|
|
244
|
-
return ` '${mw.path}': ${middlewareNames[index]}`;
|
|
245
|
-
}).join(',\n');
|
|
246
|
-
|
|
247
|
-
// ── Type-safe param types per route ──────────────────────────────────────
|
|
248
|
-
|
|
249
|
-
const routeParamTypes = routes
|
|
250
|
-
.filter(r => r.params && r.params.length > 0)
|
|
251
|
-
.map(r => {
|
|
252
|
-
const paramType = generateParamType(r.path);
|
|
253
|
-
return paramType ? ` '${r.path}': ${paramType};` : null;
|
|
254
|
-
})
|
|
255
|
-
.filter(Boolean)
|
|
256
|
-
.join('\n');
|
|
257
|
-
|
|
258
|
-
// ── Type-safe route href builder type ────────────────────────────────────
|
|
259
|
-
|
|
260
|
-
const routePaths = routes.length > 0 ? routes.map(r => `'${r.path}'`).join(' | ') : 'never';
|
|
261
|
-
const routeIds = routes.length > 0 ? routes.map(r => `'${pathToRouteId(r.path)}'`).join(' | ') : 'never';
|
|
262
|
-
|
|
263
|
-
// ── Route manifest ───────────────────────────────────────────────────────
|
|
264
|
-
|
|
265
|
-
const manifestEntries = routes.map(r => {
|
|
266
|
-
const paramNames = extractParamNames(r.path);
|
|
267
|
-
const isDynamic = paramNames.length > 0;
|
|
268
|
-
const hasCatchAll = r.path.includes('*');
|
|
269
|
-
return ` '${pathToRouteId(r.path)}': { id: '${pathToRouteId(r.path)}', path: '${r.path}', params: [${paramNames.map(p => `'${p}'`).join(', ')}], isDynamic: ${isDynamic}, hasCatchAll: ${hasCatchAll}, hasMetadata: ${r.hasMetadata}, hasGetStaticPaths: ${r.hasGetStaticPaths} }`;
|
|
270
|
-
}).join(',\n');
|
|
271
|
-
|
|
272
|
-
// ── Assemble output ──────────────────────────────────────────────────────
|
|
273
|
-
|
|
274
|
-
const allImports = [
|
|
275
|
-
routeImports, notFoundImports, layoutImports,
|
|
276
|
-
loadingImports, errorImports, middlewareImports,
|
|
277
|
-
].filter(Boolean).join('\n');
|
|
278
|
-
|
|
279
|
-
return `/* prettier-ignore-start */
|
|
280
|
-
|
|
281
|
-
/* eslint-disable */
|
|
282
|
-
|
|
283
|
-
// @ts-nocheck
|
|
284
|
-
|
|
285
|
-
// noinspection JSUnusedGlobalSymbols
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* This file was automatically generated by Olova Router.
|
|
289
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source route files
|
|
290
|
-
* and regenerate this file by running the dev server or build command.
|
|
291
|
-
*
|
|
292
|
-
* @generated Olova Route Tree
|
|
293
|
-
* @routes ${routes.length}
|
|
294
|
-
* @layouts ${layouts.length}
|
|
295
|
-
* @404s ${notFoundPages.length}
|
|
296
|
-
* @loading ${loadingPages.length}
|
|
297
|
-
* @errors ${errorPages.length}
|
|
298
|
-
* @middleware ${middlewares.length}
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
import { lazy } from 'react';
|
|
302
|
-
import {
|
|
303
|
-
createLink,
|
|
304
|
-
OlovaRouter,
|
|
305
|
-
Outlet,
|
|
306
|
-
redirect,
|
|
307
|
-
useIsNavigating,
|
|
308
|
-
useNavigationEvent,
|
|
309
|
-
useParams,
|
|
310
|
-
usePathname,
|
|
311
|
-
useRedirect,
|
|
312
|
-
useRouter,
|
|
313
|
-
useSearchParams,
|
|
314
|
-
useSelectedLayoutSegment,
|
|
315
|
-
useSelectedLayoutSegments,
|
|
316
|
-
} from '${packageName}/router';
|
|
317
|
-
${allImports}
|
|
318
|
-
|
|
319
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
320
|
-
* Route Definitions
|
|
321
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
322
|
-
|
|
323
|
-
export const routes = [
|
|
324
|
-
${routeObjects}
|
|
325
|
-
];
|
|
326
|
-
|
|
327
|
-
export const notFoundPages = [
|
|
328
|
-
${notFoundObjects}
|
|
329
|
-
];
|
|
330
|
-
|
|
331
|
-
export const layouts = [
|
|
332
|
-
${layoutObjects}
|
|
333
|
-
];
|
|
334
|
-
${middlewares.length > 0 ? `
|
|
335
|
-
export const middlewares = {
|
|
336
|
-
${middlewareEntries}
|
|
337
|
-
};
|
|
338
|
-
` : `
|
|
339
|
-
export const middlewares = {};
|
|
340
|
-
`}
|
|
341
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
342
|
-
* Route Manifest (build-time introspection, sitemap generation, etc.)
|
|
343
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
344
|
-
|
|
345
|
-
export const routeManifest = {
|
|
346
|
-
${manifestEntries}
|
|
347
|
-
} as const;
|
|
348
|
-
|
|
349
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
350
|
-
* Type-Safe Route Types
|
|
351
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
352
|
-
|
|
353
|
-
export type RoutePaths = ${routePaths};
|
|
354
|
-
|
|
355
|
-
export type RouteIds = ${routeIds};
|
|
356
|
-
|
|
357
|
-
export interface RouteParams {
|
|
358
|
-
${routeParamTypes || ' // No dynamic routes'}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export type ParamsFor<P extends RoutePaths> = P extends keyof RouteParams ? RouteParams[P] : Record<string, never>;
|
|
362
|
-
|
|
363
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
364
|
-
* Route Lookup Helpers
|
|
365
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
366
|
-
|
|
367
|
-
const _routeById = new Map(routes.map(r => [r.id, r]));
|
|
368
|
-
|
|
369
|
-
export function getRouteById(id: RouteIds) {
|
|
370
|
-
return _routeById.get(id);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
export function getRouteByPath(path: RoutePaths) {
|
|
374
|
-
return routes.find(r => r.path === path);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
378
|
-
* Exports
|
|
379
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
380
|
-
|
|
381
|
-
export const Link = createLink<RoutePaths>();
|
|
382
|
-
|
|
383
|
-
export {
|
|
384
|
-
OlovaRouter,
|
|
385
|
-
Outlet,
|
|
386
|
-
redirect,
|
|
387
|
-
useIsNavigating,
|
|
388
|
-
useNavigationEvent,
|
|
389
|
-
useParams,
|
|
390
|
-
usePathname,
|
|
391
|
-
useRedirect,
|
|
392
|
-
useRouter,
|
|
393
|
-
useSearchParams,
|
|
394
|
-
useSelectedLayoutSegment,
|
|
395
|
-
useSelectedLayoutSegments,
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
export type {
|
|
399
|
-
NavigateOptions,
|
|
400
|
-
NotFoundPageConfig,
|
|
401
|
-
SearchParams,
|
|
402
|
-
SetSearchParamsOptions,
|
|
403
|
-
LayoutRoute,
|
|
404
|
-
Metadata,
|
|
405
|
-
} from '${packageName}/router';
|
|
406
|
-
|
|
407
|
-
/* prettier-ignore-end */
|
|
408
|
-
`;
|
|
409
|
-
}
|