@teyik0/furin 0.9.0-alpha.0 → 0.9.0-alpha.2
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/README.md +1 -1
- package/dist/adapter/runtime-build.d.ts +7 -3
- package/dist/adapter/vercel.js +31 -6
- package/dist/build/client.d.ts +1 -1
- package/dist/build/entry-template.d.ts +3 -12
- package/dist/build/entry-template.ts +3 -15
- package/dist/build/hydrate.d.ts +6 -1
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +565 -401
- package/dist/build/route-metadata.d.ts +2 -2
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/types.d.ts +10 -4
- package/dist/cli/dev-worker.ts +10 -4
- package/dist/cli/index.js +624 -445
- package/dist/client/chunks/{client-xy6g38kx.js → client-a7spxfnn.js} +24 -5
- package/dist/client/chunks/{client-rjhxgt64.js → client-d9v49jwz.js} +1 -1
- package/dist/client/chunks/{client-k29262a4.js → client-rdxyrw11.js} +1 -1
- package/dist/client/define-route.d.ts +14 -0
- package/dist/client/internal/runtime-types.d.ts +8 -0
- package/dist/client/link.js +20 -17
- package/dist/client/router/link-utils.d.ts +3 -2
- package/dist/client/router/search/index.js +2 -2
- package/dist/client/router/types.d.ts +9 -3
- package/dist/client.js +22 -6
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -1
- package/dist/define-route.d.ts +53 -12
- package/dist/furin.d.ts +13 -3
- package/dist/furin.js +815 -661
- package/dist/plugin/route-config.d.ts +3 -3
- package/dist/plugin/route-manifest.d.ts +46 -0
- package/dist/plugin/route-tree.d.ts +13 -29
- package/dist/routes.d.ts +2 -2
- package/dist/server/dev/runtime.d.ts +2 -1
- package/dist/server/internal.d.ts +6 -0
- package/dist/server/internal.js +97 -114
- package/dist/server/registrations.d.ts +4 -2
- package/dist/server/render/index.d.ts +0 -1
- package/dist/server/render/index.ts +0 -1
- package/dist/server/render/shell.d.ts +1 -13
- package/dist/server/render/shell.ts +1 -90
- package/dist/server/router/defined-route.d.ts +4 -0
- package/dist/server/router/discovery.d.ts +14 -4
- package/dist/server/router/hmr.d.ts +12 -12
- package/dist/server/router/patterns.d.ts +4 -12
- package/dist/server/router/types.d.ts +16 -1
- package/dist/server/static-export.js +128 -158
- package/dist/server/sync/drizzle/index.d.ts +8 -10
- package/dist/shared/not-found.d.ts +1 -1
- package/dist/shared/route-specificity.d.ts +10 -1
- package/package.json +8 -11
- package/src/adapter/package.ts +11 -37
- package/src/adapter/runtime-build.ts +5 -4
- package/src/adapter/static.ts +1 -1
- package/src/adapter/vercel.ts +2 -1
- package/src/build/client.ts +3 -3
- package/src/build/discover-pages-process.ts +1 -1
- package/src/build/elysia-aot.ts +2 -2
- package/src/build/entry-template.ts +3 -15
- package/src/build/hydrate.ts +12 -6
- package/src/build/index.ts +19 -9
- package/src/build/route-metadata.ts +15 -8
- package/src/build/route-types.ts +18 -43
- package/src/build/types.ts +12 -5
- package/src/cli/config.ts +6 -0
- package/src/cli/dev-worker.ts +10 -4
- package/src/cli/dev.ts +41 -26
- package/src/cli/index.ts +30 -14
- package/src/client/define-route.ts +29 -4
- package/src/client/internal/runtime-types.ts +8 -0
- package/src/client/link.tsx +21 -22
- package/src/client/router/context.ts +8 -7
- package/src/client/router/link-utils.ts +16 -8
- package/src/client/router/provider.tsx +5 -0
- package/src/client/router/types.ts +40 -14
- package/src/config.ts +5 -0
- package/src/define-route.ts +85 -16
- package/src/furin.ts +31 -7
- package/src/plugin/dev-routes.ts +8 -17
- package/src/plugin/route-config.ts +77 -62
- package/src/plugin/route-manifest.ts +437 -0
- package/src/plugin/route-modules.ts +6 -1
- package/src/plugin/route-registry.ts +7 -21
- package/src/plugin/route-tree.ts +71 -181
- package/src/routes.ts +2 -2
- package/src/server/dev/runtime.ts +16 -22
- package/src/server/internal.ts +4 -1
- package/src/server/registrations.ts +5 -2
- package/src/server/render/index.ts +0 -1
- package/src/server/render/shell.ts +1 -90
- package/src/server/render/static-params.ts +2 -10
- package/src/server/router/defined-route.ts +8 -0
- package/src/server/router/discovery.ts +237 -196
- package/src/server/router/hmr.ts +45 -63
- package/src/server/router/patterns.ts +41 -117
- package/src/server/router/types.ts +17 -1
- package/src/server/sync/drizzle/index.ts +18 -19
- package/src/shared/not-found.ts +1 -1
- package/src/shared/route-specificity.ts +34 -2
- package/src/shared/utils/index.ts +1 -1
package/dist/furin.js
CHANGED
|
@@ -58,7 +58,7 @@ function segmentSpecificity(segment) {
|
|
|
58
58
|
}
|
|
59
59
|
return segment.startsWith(":") ? 2 : 3;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function compareConcreteSpecificity(a, b) {
|
|
62
62
|
const aSegments = a.split("/").filter(Boolean);
|
|
63
63
|
const bSegments = b.split("/").filter(Boolean);
|
|
64
64
|
const length = Math.max(aSegments.length, bSegments.length);
|
|
@@ -78,6 +78,24 @@ function compareRouteSpecificity(a, b) {
|
|
|
78
78
|
}
|
|
79
79
|
return 0;
|
|
80
80
|
}
|
|
81
|
+
function expandOptionalSegments(pattern) {
|
|
82
|
+
let variants = [[]];
|
|
83
|
+
for (const segment of pattern.split("/").filter(Boolean)) {
|
|
84
|
+
if (segment.startsWith(":") && segment.endsWith("?")) {
|
|
85
|
+
const required = segment.slice(0, -1);
|
|
86
|
+
variants = variants.flatMap((variant) => [variant, [...variant, required]]);
|
|
87
|
+
} else {
|
|
88
|
+
variants = variants.map((variant) => [...variant, segment]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return variants.map((variant) => `/${variant.join("/")}`);
|
|
92
|
+
}
|
|
93
|
+
function mostSpecificVariant(pattern) {
|
|
94
|
+
return expandOptionalSegments(pattern).reduce((best, variant) => compareConcreteSpecificity(variant, best) > 0 ? variant : best);
|
|
95
|
+
}
|
|
96
|
+
function compareRouteSpecificity(a, b) {
|
|
97
|
+
return compareConcreteSpecificity(mostSpecificVariant(a), mostSpecificVariant(b));
|
|
98
|
+
}
|
|
81
99
|
|
|
82
100
|
// src/shared/search-params.ts
|
|
83
101
|
function isObject(value) {
|
|
@@ -188,18 +206,6 @@ function findSearchDefaultsForRouteTarget(to, routes) {
|
|
|
188
206
|
var init_search_params = () => {};
|
|
189
207
|
|
|
190
208
|
// src/server/router/patterns.ts
|
|
191
|
-
import { parse } from "path";
|
|
192
|
-
function collectIntermediateLayoutDirs(pagePath, rootPath) {
|
|
193
|
-
const pageDir = pagePath.slice(0, pagePath.lastIndexOf("/"));
|
|
194
|
-
const pagesDir = rootPath.slice(0, rootPath.lastIndexOf("/"));
|
|
195
|
-
const layoutDirs = [];
|
|
196
|
-
let dir = pageDir;
|
|
197
|
-
while (dir.length > pagesDir.length) {
|
|
198
|
-
layoutDirs.unshift(dir);
|
|
199
|
-
dir = dir.slice(0, dir.lastIndexOf("/"));
|
|
200
|
-
}
|
|
201
|
-
return layoutDirs;
|
|
202
|
-
}
|
|
203
209
|
function resolveRouteRevalidate(page) {
|
|
204
210
|
return page.revalidate ?? page._route.revalidate;
|
|
205
211
|
}
|
|
@@ -239,57 +245,6 @@ function resolveMode(page, routeChain) {
|
|
|
239
245
|
}
|
|
240
246
|
return "ssr";
|
|
241
247
|
}
|
|
242
|
-
function parseDynamicRouteSegment(segment, sourcePath) {
|
|
243
|
-
if (!(segment.startsWith("[") && segment.endsWith("]"))) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
const inner = segment.slice(1, -1);
|
|
247
|
-
const catchAll = inner.startsWith("...");
|
|
248
|
-
const name = catchAll ? inner.slice(3) : inner;
|
|
249
|
-
if (!DYNAMIC_PARAMETER_NAME_RE.test(name)) {
|
|
250
|
-
throw new Error(`[furin] Invalid dynamic parameter ${JSON.stringify(name)} in ${JSON.stringify(sourcePath ?? segment)}. Parameter names must match ${DYNAMIC_PARAMETER_NAME_RE}.`);
|
|
251
|
-
}
|
|
252
|
-
return { catchAll, name };
|
|
253
|
-
}
|
|
254
|
-
function routeSegmentToPattern(segment) {
|
|
255
|
-
const dynamic = parseDynamicRouteSegment(segment, undefined);
|
|
256
|
-
if (!dynamic) {
|
|
257
|
-
return segment;
|
|
258
|
-
}
|
|
259
|
-
return dynamic.catchAll ? "*" : `:${dynamic.name}`;
|
|
260
|
-
}
|
|
261
|
-
function isRouteGroup(segment) {
|
|
262
|
-
return ROUTE_GROUP_RE.test(segment);
|
|
263
|
-
}
|
|
264
|
-
function routePatternKey(pattern) {
|
|
265
|
-
return pattern.replace(DYNAMIC_ROUTE_SEGMENT_RE, "$1:param");
|
|
266
|
-
}
|
|
267
|
-
function filePathToPattern(path) {
|
|
268
|
-
const parts = path.replaceAll("\\", "/").split("/");
|
|
269
|
-
const segments = [];
|
|
270
|
-
const lastIndex = parts.length - 1;
|
|
271
|
-
for (let idx = 0;idx < parts.length; idx += 1) {
|
|
272
|
-
const part = parts[idx];
|
|
273
|
-
if (part === undefined || part.length === 0) {
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
const isFile = idx === lastIndex;
|
|
277
|
-
const name = isFile ? parse(part).name : part;
|
|
278
|
-
if (!isFile && isRouteGroup(name)) {
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (isFile && name === "index") {
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
const dynamic = parseDynamicRouteSegment(name, path);
|
|
285
|
-
if (dynamic) {
|
|
286
|
-
segments.push(dynamic.catchAll ? "*" : `:${dynamic.name}`);
|
|
287
|
-
} else {
|
|
288
|
-
segments.push(name);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return `/${segments.join("/")}`;
|
|
292
|
-
}
|
|
293
248
|
function escapeRegExp(value) {
|
|
294
249
|
return value.replace(REGEX_META_CHARS_RE, "\\$&");
|
|
295
250
|
}
|
|
@@ -304,11 +259,17 @@ function routePatternRegexSource(pattern, sources) {
|
|
|
304
259
|
while (i < pattern.length && pattern[i] !== "/") {
|
|
305
260
|
i += 1;
|
|
306
261
|
}
|
|
307
|
-
|
|
308
|
-
|
|
262
|
+
const name = pattern.slice(start, i);
|
|
263
|
+
if (name.endsWith("?") && source.endsWith("/")) {
|
|
264
|
+
paramNames.push(name.slice(0, -1));
|
|
265
|
+
source = `${source.slice(0, -1)}(?:/${sources.param})?`;
|
|
266
|
+
} else {
|
|
267
|
+
paramNames.push(name);
|
|
268
|
+
source += sources.param;
|
|
269
|
+
}
|
|
309
270
|
} else if (pattern[i] === "*") {
|
|
310
|
-
paramNames.push(
|
|
311
|
-
source
|
|
271
|
+
paramNames.push(SPLAT_PARAM);
|
|
272
|
+
source = source.endsWith("/") ? `${source.slice(0, -1)}(?:/${sources.catchAll})?` : source + sources.catchAll;
|
|
312
273
|
i += 1;
|
|
313
274
|
} else {
|
|
314
275
|
const ch = pattern[i];
|
|
@@ -330,6 +291,25 @@ function buildRouteRegex(pattern) {
|
|
|
330
291
|
regex: new RegExp(`^${source}${pattern === "/" || pattern.endsWith("/") ? "" : "/?"}$`)
|
|
331
292
|
};
|
|
332
293
|
}
|
|
294
|
+
function decodeParam(value) {
|
|
295
|
+
try {
|
|
296
|
+
return decodeURIComponent(value);
|
|
297
|
+
} catch {
|
|
298
|
+
return value;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function matchedParams(paramNames, match) {
|
|
302
|
+
const params = {};
|
|
303
|
+
for (const [index, name] of paramNames.entries()) {
|
|
304
|
+
const value = match[index + 1];
|
|
305
|
+
if (value !== undefined) {
|
|
306
|
+
params[name] = decodeParam(value);
|
|
307
|
+
} else if (name === SPLAT_PARAM) {
|
|
308
|
+
params[name] = "";
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return params;
|
|
312
|
+
}
|
|
333
313
|
function buildRouteMatcher(routes) {
|
|
334
314
|
const compiled = routes.map((route) => {
|
|
335
315
|
const { regex, paramNames } = buildRouteRegex(route.pattern);
|
|
@@ -341,27 +321,13 @@ function buildRouteMatcher(routes) {
|
|
|
341
321
|
if (!match) {
|
|
342
322
|
continue;
|
|
343
323
|
}
|
|
344
|
-
|
|
345
|
-
for (let i = 0;i < candidate.paramNames.length; i += 1) {
|
|
346
|
-
const name = candidate.paramNames[i];
|
|
347
|
-
if (name !== undefined) {
|
|
348
|
-
try {
|
|
349
|
-
params[name] = decodeURIComponent(match[i + 1] ?? "");
|
|
350
|
-
} catch {
|
|
351
|
-
params[name] = match[i + 1] ?? "";
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return { params, route: candidate.route };
|
|
324
|
+
return { params: matchedParams(candidate.paramNames, match), route: candidate.route };
|
|
356
325
|
}
|
|
357
326
|
return null;
|
|
358
327
|
};
|
|
359
328
|
}
|
|
360
|
-
var
|
|
329
|
+
var SPLAT_PARAM = "_splat", REGEX_META_CHARS_RE;
|
|
361
330
|
var init_patterns = __esm(() => {
|
|
362
|
-
DYNAMIC_PARAMETER_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
363
|
-
ROUTE_GROUP_RE = /^\([^()]+\)$/;
|
|
364
|
-
DYNAMIC_ROUTE_SEGMENT_RE = /(^|\/):[^/]+/g;
|
|
365
331
|
REGEX_META_CHARS_RE = /[.*+?^${}()|[\]\\]/g;
|
|
366
332
|
});
|
|
367
333
|
|
|
@@ -654,14 +620,20 @@ function routeHandler(route) {
|
|
|
654
620
|
return renderer(context, route);
|
|
655
621
|
};
|
|
656
622
|
}
|
|
623
|
+
function renameSplatParam(context) {
|
|
624
|
+
if (context.params !== undefined && "*" in context.params) {
|
|
625
|
+
const { "*": splat, ...params } = context.params;
|
|
626
|
+
context.params = { ...params, _splat: splat };
|
|
627
|
+
}
|
|
628
|
+
}
|
|
657
629
|
function registerPlain(route) {
|
|
658
|
-
return new Elysia().get("", routeHandler(route));
|
|
630
|
+
return new Elysia().get("", { transform: renameSplatParam }, routeHandler(route));
|
|
659
631
|
}
|
|
660
632
|
function registerSchema(route, paramsSchema, querySchema) {
|
|
661
|
-
return new Elysia().get("", { params: paramsSchema, query: querySchema }, routeHandler(route));
|
|
633
|
+
return new Elysia().get("", { params: paramsSchema, query: querySchema, transform: renameSplatParam }, routeHandler(route));
|
|
662
634
|
}
|
|
663
635
|
function registerQuery(route, querySchema) {
|
|
664
|
-
return new Elysia().get("", { query: querySchema }, routeHandler(route));
|
|
636
|
+
return new Elysia().get("", { query: querySchema, transform: renameSplatParam }, routeHandler(route));
|
|
665
637
|
}
|
|
666
638
|
function schemaValues(value) {
|
|
667
639
|
return value !== null && typeof value === "object" ? value : {};
|
|
@@ -738,9 +710,20 @@ function schemaFields(paramsSchema, querySchema) {
|
|
|
738
710
|
return querySchema === undefined ? {} : { schemas: { query: querySchema } };
|
|
739
711
|
}
|
|
740
712
|
function terminalFields(runtime) {
|
|
741
|
-
const {
|
|
713
|
+
const {
|
|
714
|
+
errorComponent,
|
|
715
|
+
head,
|
|
716
|
+
loader,
|
|
717
|
+
metadata,
|
|
718
|
+
notFoundComponent,
|
|
719
|
+
paramsSchema,
|
|
720
|
+
querySchema,
|
|
721
|
+
requestLoader
|
|
722
|
+
} = runtime;
|
|
742
723
|
return {
|
|
743
724
|
__type: "FURIN_ROUTE",
|
|
725
|
+
errorComponent,
|
|
726
|
+
notFoundComponent,
|
|
744
727
|
mode: metadata.mode,
|
|
745
728
|
revalidate: metadata.revalidate,
|
|
746
729
|
remountDeps: metadata.remountDeps,
|
|
@@ -758,6 +741,12 @@ class RouteChain {
|
|
|
758
741
|
constructor(runtime) {
|
|
759
742
|
this.runtime = runtime;
|
|
760
743
|
}
|
|
744
|
+
error(component) {
|
|
745
|
+
return new RouteChain({ ...this.runtime, errorComponent: component });
|
|
746
|
+
}
|
|
747
|
+
notFound(component) {
|
|
748
|
+
return new RouteChain({ ...this.runtime, notFoundComponent: component });
|
|
749
|
+
}
|
|
761
750
|
requestLoader(requestLoader) {
|
|
762
751
|
return new RouteChain({
|
|
763
752
|
...this.runtime,
|
|
@@ -805,9 +794,11 @@ class RouteChain {
|
|
|
805
794
|
function configure(options) {
|
|
806
795
|
assertStaticParamsOutsideConfig(options);
|
|
807
796
|
return new RouteChain({
|
|
797
|
+
errorComponent: undefined,
|
|
808
798
|
head: undefined,
|
|
809
799
|
loader: undefined,
|
|
810
800
|
metadata: options,
|
|
801
|
+
notFoundComponent: undefined,
|
|
811
802
|
paramsSchema: options.params,
|
|
812
803
|
querySchema: options.query,
|
|
813
804
|
requestLoader: undefined
|
|
@@ -4903,11 +4894,12 @@ function navigationHrefPolicy(href, currentOrigin) {
|
|
|
4903
4894
|
return url.origin === currentOrigin ? "internal" : "external";
|
|
4904
4895
|
}
|
|
4905
4896
|
function applyLinkParams(to, params) {
|
|
4906
|
-
|
|
4907
|
-
|
|
4897
|
+
const values = params ?? {};
|
|
4898
|
+
let url = to.replaceAll(/\/:([a-zA-Z0-9_]+)\?(?=\/|$)/g, (_match, name) => values[name] === undefined || values[name] === "" ? "" : `/${encodeURIComponent(String(values[name]))}`).replaceAll(/:([a-zA-Z0-9_]+)/g, (match, name) => (name in values) ? encodeURIComponent(String(values[name])) : match);
|
|
4899
|
+
if (url === "") {
|
|
4900
|
+
url = "/";
|
|
4908
4901
|
}
|
|
4909
|
-
|
|
4910
|
-
const wildcard = params["*"];
|
|
4902
|
+
const wildcard = values._splat;
|
|
4911
4903
|
if (wildcard !== undefined && url.includes("/*")) {
|
|
4912
4904
|
const encodedWildcard = String(wildcard).split("/").map(encodeURIComponent).join("/");
|
|
4913
4905
|
url = url.replace("/*", () => `/${encodedWildcard}`);
|
|
@@ -10325,7 +10317,7 @@ function validateRouteChain(chain, root, pagePath) {
|
|
|
10325
10317
|
const hasRoot = chain.some((r) => r === root);
|
|
10326
10318
|
if (!hasRoot) {
|
|
10327
10319
|
const location = pagePath ? `in ${pagePath}` : "";
|
|
10328
|
-
throw new Error(`[furin] Page ${location} must inherit from root route. ` + "Its route chain must end at the root
|
|
10320
|
+
throw new Error(`[furin] Page ${location} must inherit from root route. ` + "Its route chain must end at the root layout.");
|
|
10329
10321
|
}
|
|
10330
10322
|
for (const route of chain) {
|
|
10331
10323
|
if (hasCycle(route)) {
|
|
@@ -10523,6 +10515,7 @@ var init_router = () => {};
|
|
|
10523
10515
|
|
|
10524
10516
|
// src/client/link.tsx
|
|
10525
10517
|
import { createElement as createElement4, useCallback as useCallback3, useEffect as useEffect2, useRef, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
10518
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
10526
10519
|
function resolveLinkHref({ to, params, search, hash }, router2) {
|
|
10527
10520
|
const resolvedTo = applyLinkParams(to, params);
|
|
10528
10521
|
const searchDefaults = findSearchDefaultsForRouteTarget(resolvedTo, router2.searchRoutes);
|
|
@@ -10590,12 +10583,12 @@ function LinkInteractive({
|
|
|
10590
10583
|
if (target !== null) {
|
|
10591
10584
|
prefetch(target, { staleTime: effectiveStaleTime });
|
|
10592
10585
|
}
|
|
10593
|
-
}, [prefetch,
|
|
10586
|
+
}, [prefetch, effectiveStaleTime, router2.basePath]);
|
|
10594
10587
|
useEffect2(() => {
|
|
10595
10588
|
if (effectivePreload === "render") {
|
|
10596
10589
|
triggerPrefetch();
|
|
10597
10590
|
}
|
|
10598
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
10591
|
+
}, [effectivePreload, triggerPrefetch, logicalHref]);
|
|
10599
10592
|
useEffect2(() => {
|
|
10600
10593
|
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
10601
10594
|
return;
|
|
@@ -10608,7 +10601,7 @@ function LinkInteractive({
|
|
|
10608
10601
|
}, { rootMargin: "200px" });
|
|
10609
10602
|
observer.observe(anchorRef.current);
|
|
10610
10603
|
return () => observer.disconnect();
|
|
10611
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
10604
|
+
}, [effectivePreload, triggerPrefetch, logicalHref]);
|
|
10612
10605
|
useEffect2(() => () => {
|
|
10613
10606
|
if (intentTimerRef.current !== null) {
|
|
10614
10607
|
clearTimeout(intentTimerRef.current);
|
|
@@ -10637,7 +10630,7 @@ function LinkInteractive({
|
|
|
10637
10630
|
}
|
|
10638
10631
|
e.preventDefault();
|
|
10639
10632
|
if (typeof window !== "undefined" && router2.navigate === CLIENT_FALLBACK_ROUTER.navigate) {
|
|
10640
|
-
window.location.href
|
|
10633
|
+
window.location.assign(href);
|
|
10641
10634
|
return;
|
|
10642
10635
|
}
|
|
10643
10636
|
router2.navigate(target, { replace, resetScroll: resetScroll ?? true });
|
|
@@ -10661,7 +10654,7 @@ function LinkInteractive({
|
|
|
10661
10654
|
triggerPrefetch();
|
|
10662
10655
|
}
|
|
10663
10656
|
};
|
|
10664
|
-
return
|
|
10657
|
+
return /* @__PURE__ */ jsxDEV2("a", {
|
|
10665
10658
|
"data-furin-link": true,
|
|
10666
10659
|
href,
|
|
10667
10660
|
onClick: handleClick,
|
|
@@ -10672,8 +10665,9 @@ function LinkInteractive({
|
|
|
10672
10665
|
...isActive ? { "data-status": "active" } : {},
|
|
10673
10666
|
...anchorProps,
|
|
10674
10667
|
...extraProps,
|
|
10675
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
10676
|
-
|
|
10668
|
+
...disabled ? { "aria-disabled": true } : {},
|
|
10669
|
+
children: resolvedChildren
|
|
10670
|
+
}, undefined, false, undefined, this);
|
|
10677
10671
|
}
|
|
10678
10672
|
function renderLinkElement(props, router2) {
|
|
10679
10673
|
const { activeHref, href } = resolveLinkHref(props, router2);
|
|
@@ -10742,7 +10736,7 @@ var init_link = __esm(() => {
|
|
|
10742
10736
|
});
|
|
10743
10737
|
|
|
10744
10738
|
// src/client/default-screens.tsx
|
|
10745
|
-
import { jsxDEV as
|
|
10739
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
10746
10740
|
function CornerBracket({ corner }) {
|
|
10747
10741
|
const top = corner === "tl" || corner === "tr";
|
|
10748
10742
|
const left = corner === "tl" || corner === "bl";
|
|
@@ -10753,38 +10747,38 @@ function CornerBracket({ corner }) {
|
|
|
10753
10747
|
[`border${top ? "Top" : "Bottom"}`]: `2px solid ${COLOR_BRACKET}`,
|
|
10754
10748
|
[`border${left ? "Left" : "Right"}`]: `2px solid ${COLOR_BRACKET}`
|
|
10755
10749
|
};
|
|
10756
|
-
return /* @__PURE__ */
|
|
10750
|
+
return /* @__PURE__ */ jsxDEV3("span", {
|
|
10757
10751
|
"aria-hidden": "true",
|
|
10758
10752
|
style
|
|
10759
10753
|
}, undefined, false, undefined, this);
|
|
10760
10754
|
}
|
|
10761
10755
|
function ScreenFrame({ badge, children }) {
|
|
10762
|
-
return /* @__PURE__ */
|
|
10756
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
10763
10757
|
style: PAGE_STYLE,
|
|
10764
10758
|
children: [
|
|
10765
|
-
/* @__PURE__ */
|
|
10759
|
+
/* @__PURE__ */ jsxDEV3("style", {
|
|
10766
10760
|
children: RESET_CSS
|
|
10767
10761
|
}, undefined, false, undefined, this),
|
|
10768
|
-
/* @__PURE__ */
|
|
10762
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10769
10763
|
style: FRAME_STYLE,
|
|
10770
10764
|
children: [
|
|
10771
|
-
/* @__PURE__ */
|
|
10765
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10772
10766
|
corner: "tl"
|
|
10773
10767
|
}, undefined, false, undefined, this),
|
|
10774
|
-
/* @__PURE__ */
|
|
10768
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10775
10769
|
corner: "tr"
|
|
10776
10770
|
}, undefined, false, undefined, this),
|
|
10777
|
-
/* @__PURE__ */
|
|
10771
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10778
10772
|
corner: "bl"
|
|
10779
10773
|
}, undefined, false, undefined, this),
|
|
10780
|
-
/* @__PURE__ */
|
|
10774
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10781
10775
|
corner: "br"
|
|
10782
10776
|
}, undefined, false, undefined, this),
|
|
10783
|
-
/* @__PURE__ */
|
|
10777
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10784
10778
|
style: CARD_STYLE,
|
|
10785
10779
|
children: [
|
|
10786
10780
|
badge,
|
|
10787
|
-
/* @__PURE__ */
|
|
10781
|
+
/* @__PURE__ */ jsxDEV3("hr", {
|
|
10788
10782
|
style: DIVIDER_STYLE
|
|
10789
10783
|
}, undefined, false, undefined, this),
|
|
10790
10784
|
children
|
|
@@ -10796,41 +10790,41 @@ function ScreenFrame({ badge, children }) {
|
|
|
10796
10790
|
}, undefined, true, undefined, this);
|
|
10797
10791
|
}
|
|
10798
10792
|
function DefaultErrorScreen({ message, digest, reset }) {
|
|
10799
|
-
return /* @__PURE__ */
|
|
10800
|
-
badge: /* @__PURE__ */
|
|
10793
|
+
return /* @__PURE__ */ jsxDEV3(ScreenFrame, {
|
|
10794
|
+
badge: /* @__PURE__ */ jsxDEV3("div", {
|
|
10801
10795
|
style: BADGE_STYLE,
|
|
10802
10796
|
children: "500 \u2014 ERROR"
|
|
10803
10797
|
}, undefined, false, undefined, this),
|
|
10804
10798
|
children: [
|
|
10805
|
-
/* @__PURE__ */
|
|
10799
|
+
/* @__PURE__ */ jsxDEV3("h1", {
|
|
10806
10800
|
style: HEADING_STYLE,
|
|
10807
10801
|
children: "Something went wrong"
|
|
10808
10802
|
}, undefined, false, undefined, this),
|
|
10809
|
-
/* @__PURE__ */
|
|
10803
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10810
10804
|
style: CODE_BOX_STYLE,
|
|
10811
10805
|
children: [
|
|
10812
|
-
/* @__PURE__ */
|
|
10806
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
10813
10807
|
style: CODE_LABEL_STYLE,
|
|
10814
10808
|
children: "CODE:"
|
|
10815
10809
|
}, undefined, false, undefined, this),
|
|
10816
|
-
/* @__PURE__ */
|
|
10810
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
10817
10811
|
children: digest
|
|
10818
10812
|
}, undefined, false, undefined, this)
|
|
10819
10813
|
]
|
|
10820
10814
|
}, undefined, true, undefined, this),
|
|
10821
|
-
/* @__PURE__ */
|
|
10815
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
10822
10816
|
style: DESCRIPTION_WRAPPER_STYLE,
|
|
10823
10817
|
children: message ? message : "We encountered an unexpected error. Please try again or return to the home page."
|
|
10824
10818
|
}, undefined, false, undefined, this),
|
|
10825
|
-
/* @__PURE__ */
|
|
10819
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10826
10820
|
style: ACTIONS_STYLE,
|
|
10827
10821
|
children: [
|
|
10828
|
-
/* @__PURE__ */
|
|
10822
|
+
/* @__PURE__ */ jsxDEV3(Link, {
|
|
10829
10823
|
style: BUTTON_PRIMARY,
|
|
10830
10824
|
to: "/",
|
|
10831
10825
|
children: "Go Home"
|
|
10832
10826
|
}, undefined, false, undefined, this),
|
|
10833
|
-
/* @__PURE__ */
|
|
10827
|
+
/* @__PURE__ */ jsxDEV3("button", {
|
|
10834
10828
|
onClick: reset,
|
|
10835
10829
|
style: BUTTON_SECONDARY,
|
|
10836
10830
|
type: "button",
|
|
@@ -10842,23 +10836,23 @@ function DefaultErrorScreen({ message, digest, reset }) {
|
|
|
10842
10836
|
}, undefined, true, undefined, this);
|
|
10843
10837
|
}
|
|
10844
10838
|
function DefaultNotFoundScreen({ message }) {
|
|
10845
|
-
return /* @__PURE__ */
|
|
10846
|
-
badge: /* @__PURE__ */
|
|
10839
|
+
return /* @__PURE__ */ jsxDEV3(ScreenFrame, {
|
|
10840
|
+
badge: /* @__PURE__ */ jsxDEV3("div", {
|
|
10847
10841
|
style: BADGE_STYLE,
|
|
10848
10842
|
children: "404 \u2014 NOT FOUND"
|
|
10849
10843
|
}, undefined, false, undefined, this),
|
|
10850
10844
|
children: [
|
|
10851
|
-
/* @__PURE__ */
|
|
10845
|
+
/* @__PURE__ */ jsxDEV3("h1", {
|
|
10852
10846
|
style: HEADING_STYLE,
|
|
10853
10847
|
children: "This page does not exist"
|
|
10854
10848
|
}, undefined, false, undefined, this),
|
|
10855
|
-
/* @__PURE__ */
|
|
10849
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
10856
10850
|
style: DESCRIPTION_WRAPPER_STYLE,
|
|
10857
10851
|
children: message ? message : "The page you are looking for could not be found. It may have been moved or removed."
|
|
10858
10852
|
}, undefined, false, undefined, this),
|
|
10859
|
-
/* @__PURE__ */
|
|
10853
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10860
10854
|
style: ACTIONS_STYLE,
|
|
10861
|
-
children: /* @__PURE__ */
|
|
10855
|
+
children: /* @__PURE__ */ jsxDEV3(Link, {
|
|
10862
10856
|
style: BUTTON_PRIMARY,
|
|
10863
10857
|
to: "/",
|
|
10864
10858
|
children: "Go Home"
|
|
@@ -10867,11 +10861,11 @@ function DefaultNotFoundScreen({ message }) {
|
|
|
10867
10861
|
]
|
|
10868
10862
|
}, undefined, true, undefined, this);
|
|
10869
10863
|
}
|
|
10870
|
-
var FONT_SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', FONT_MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', COLOR_BG = "#000000", COLOR_TEXT = "#ffffff", COLOR_TEXT_DIM = "rgba(255, 255, 255, 0.7)", COLOR_TEXT_MUTED = "rgba(255, 255, 255, 0.45)", COLOR_GRID = "rgba(255, 255, 255, 0.04)", COLOR_BRACKET = "rgba(255, 255, 255, 0.55)", COLOR_DANGER_DIM = "rgba(239, 68, 68, 0.6)", PAGE_STYLE, FRAME_STYLE, BRACKET_BASE, CARD_STYLE, BADGE_STYLE, HEADING_STYLE, CODE_BOX_STYLE, CODE_LABEL_STYLE, DESCRIPTION_WRAPPER_STYLE, ACTIONS_STYLE, BUTTON_BASE, BUTTON_PRIMARY, BUTTON_SECONDARY, DIVIDER_STYLE, RESET_CSS, DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */
|
|
10864
|
+
var FONT_SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', FONT_MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', COLOR_BG = "#000000", COLOR_TEXT = "#ffffff", COLOR_TEXT_DIM = "rgba(255, 255, 255, 0.7)", COLOR_TEXT_MUTED = "rgba(255, 255, 255, 0.45)", COLOR_GRID = "rgba(255, 255, 255, 0.04)", COLOR_BRACKET = "rgba(255, 255, 255, 0.55)", COLOR_DANGER_DIM = "rgba(239, 68, 68, 0.6)", PAGE_STYLE, FRAME_STYLE, BRACKET_BASE, CARD_STYLE, BADGE_STYLE, HEADING_STYLE, CODE_BOX_STYLE, CODE_LABEL_STYLE, DESCRIPTION_WRAPPER_STYLE, ACTIONS_STYLE, BUTTON_BASE, BUTTON_PRIMARY, BUTTON_SECONDARY, DIVIDER_STYLE, RESET_CSS, DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */ jsxDEV3(DefaultErrorScreen, {
|
|
10871
10865
|
digest: error.digest,
|
|
10872
10866
|
message: error.message,
|
|
10873
10867
|
reset
|
|
10874
|
-
}, undefined, false, undefined, this), DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */
|
|
10868
|
+
}, undefined, false, undefined, this), DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */ jsxDEV3(DefaultNotFoundScreen, {
|
|
10875
10869
|
message: error.message
|
|
10876
10870
|
}, undefined, false, undefined, this);
|
|
10877
10871
|
var init_default_screens = __esm(() => {
|
|
@@ -11011,7 +11005,7 @@ html, body {
|
|
|
11011
11005
|
|
|
11012
11006
|
// src/client/boundaries.tsx
|
|
11013
11007
|
import { Component, Fragment as Fragment2 } from "react";
|
|
11014
|
-
import { jsxDEV as
|
|
11008
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
11015
11009
|
function getServerDigest(error) {
|
|
11016
11010
|
if (typeof error !== "object" && typeof error !== "function" || error === null) {
|
|
11017
11011
|
return;
|
|
@@ -11035,14 +11029,14 @@ function wrapSegmentBoundaries(inner, segment, options) {
|
|
|
11035
11029
|
}
|
|
11036
11030
|
let wrapped = inner;
|
|
11037
11031
|
if (segment.notFound) {
|
|
11038
|
-
wrapped = /* @__PURE__ */
|
|
11032
|
+
wrapped = /* @__PURE__ */ jsxDEV4(FurinNotFoundBoundary, {
|
|
11039
11033
|
fallback: segment.notFound,
|
|
11040
11034
|
resetKey: options?.resetKey,
|
|
11041
11035
|
children: wrapped
|
|
11042
11036
|
}, undefined, false, undefined, this);
|
|
11043
11037
|
}
|
|
11044
11038
|
if (segment.error) {
|
|
11045
|
-
wrapped = /* @__PURE__ */
|
|
11039
|
+
wrapped = /* @__PURE__ */ jsxDEV4(FurinErrorBoundary, {
|
|
11046
11040
|
fallback: segment.error,
|
|
11047
11041
|
onReset: options?.onReset,
|
|
11048
11042
|
resetKey: options?.resetKey,
|
|
@@ -11095,15 +11089,15 @@ var init_boundaries = __esm(() => {
|
|
|
11095
11089
|
const serverDigest = getServerDigest(error);
|
|
11096
11090
|
const finalDigest = serverDigest ?? digest ?? this.props.digest ?? computeErrorDigest(error);
|
|
11097
11091
|
const message = this.props.fallback ? error.message : getPublicErrorMessage(error);
|
|
11098
|
-
const fallback = /* @__PURE__ */
|
|
11092
|
+
const fallback = /* @__PURE__ */ jsxDEV4(Fallback, {
|
|
11099
11093
|
error: { digest: finalDigest, message, status: DEFAULT_ERROR_STATUS },
|
|
11100
11094
|
reset: typeof window === "undefined" ? SERVER_RESET_NOOP : this.reset
|
|
11101
11095
|
}, undefined, false, undefined, this);
|
|
11102
|
-
return this.props.document ? /* @__PURE__ */
|
|
11096
|
+
return this.props.document ? /* @__PURE__ */ jsxDEV4(FurinDocumentFallback, {
|
|
11103
11097
|
children: fallback
|
|
11104
11098
|
}, undefined, false, undefined, this) : fallback;
|
|
11105
11099
|
}
|
|
11106
|
-
return /* @__PURE__ */
|
|
11100
|
+
return /* @__PURE__ */ jsxDEV4(Fragment2, {
|
|
11107
11101
|
children: this.props.children
|
|
11108
11102
|
}, epoch, false, undefined, this);
|
|
11109
11103
|
}
|
|
@@ -11125,11 +11119,11 @@ var init_boundaries = __esm(() => {
|
|
|
11125
11119
|
throw error;
|
|
11126
11120
|
}
|
|
11127
11121
|
const Fallback = this.props.fallback ?? DefaultNotFoundFallback;
|
|
11128
|
-
return /* @__PURE__ */
|
|
11122
|
+
return /* @__PURE__ */ jsxDEV4(Fallback, {
|
|
11129
11123
|
error: { data: error.data, message: error.message }
|
|
11130
11124
|
}, undefined, false, undefined, this);
|
|
11131
11125
|
}
|
|
11132
|
-
return /* @__PURE__ */
|
|
11126
|
+
return /* @__PURE__ */ jsxDEV4(Fragment2, {
|
|
11133
11127
|
children: this.props.children
|
|
11134
11128
|
}, epoch, false, undefined, this);
|
|
11135
11129
|
}
|
|
@@ -11242,10 +11236,10 @@ var init_route_element = __esm(() => {
|
|
|
11242
11236
|
});
|
|
11243
11237
|
|
|
11244
11238
|
// src/server/render/element.tsx
|
|
11245
|
-
import { jsxDEV as
|
|
11239
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
11246
11240
|
function buildNotFoundElement(component, error) {
|
|
11247
11241
|
const NotFound = component ?? DefaultNotFoundFallback;
|
|
11248
|
-
return /* @__PURE__ */
|
|
11242
|
+
return /* @__PURE__ */ jsxDEV5(NotFound, {
|
|
11249
11243
|
error: { data: error.data, message: error.message }
|
|
11250
11244
|
}, undefined, false, undefined, this);
|
|
11251
11245
|
}
|
|
@@ -11274,7 +11268,7 @@ function errorMessageForRender(component, error, messageOverride) {
|
|
|
11274
11268
|
function buildErrorElement(component, error, digest, messageOverride, status) {
|
|
11275
11269
|
const ErrorView = component ?? DefaultErrorFallback;
|
|
11276
11270
|
const message = errorMessageForRender(component, error, messageOverride);
|
|
11277
|
-
return /* @__PURE__ */
|
|
11271
|
+
return /* @__PURE__ */ jsxDEV5(ErrorView, {
|
|
11278
11272
|
error: { digest, message, status },
|
|
11279
11273
|
reset: SERVER_RESET_NOOP2
|
|
11280
11274
|
}, undefined, false, undefined, this);
|
|
@@ -12866,7 +12860,7 @@ function memoizedBinarySearch(haystack, needle, state, key) {
|
|
|
12866
12860
|
state.lastNeedle = needle;
|
|
12867
12861
|
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
12868
12862
|
}
|
|
12869
|
-
function
|
|
12863
|
+
function parse(map) {
|
|
12870
12864
|
return typeof map === "string" ? JSON.parse(map) : map;
|
|
12871
12865
|
}
|
|
12872
12866
|
function cast(map) {
|
|
@@ -12914,7 +12908,7 @@ var COLUMN = 0, SOURCES_INDEX = 1, SOURCE_LINE = 2, SOURCE_COLUMN = 3, NAMES_IND
|
|
|
12914
12908
|
const isString = typeof map === "string";
|
|
12915
12909
|
if (!isString && map._decodedMemo)
|
|
12916
12910
|
return map;
|
|
12917
|
-
const parsed =
|
|
12911
|
+
const parsed = parse(map);
|
|
12918
12912
|
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
12919
12913
|
this.version = version;
|
|
12920
12914
|
this.file = file;
|
|
@@ -14773,7 +14767,6 @@ var init_buffered_render = __esm(() => {
|
|
|
14773
14767
|
});
|
|
14774
14768
|
|
|
14775
14769
|
// src/server/render/static-params.ts
|
|
14776
|
-
import { dirname as dirname2, relative as relative4 } from "path";
|
|
14777
14770
|
function collectStaticParamsStages(route) {
|
|
14778
14771
|
const stages = [];
|
|
14779
14772
|
for (const [index, entry] of route.routeChain.entries()) {
|
|
@@ -14787,17 +14780,11 @@ function collectStaticParamsStages(route) {
|
|
|
14787
14780
|
return stages;
|
|
14788
14781
|
}
|
|
14789
14782
|
function ancestorPattern(route, ancestors) {
|
|
14790
|
-
const rootSourcePath = route.routeChain[0]?.sourcePath;
|
|
14791
14783
|
const ancestorSourcePath = ancestors.at(-1)?.sourcePath;
|
|
14792
|
-
if (
|
|
14793
|
-
return route.pattern;
|
|
14794
|
-
}
|
|
14795
|
-
const pagesDir = dirname2(rootSourcePath);
|
|
14796
|
-
const ancestorDir = dirname2(ancestorSourcePath);
|
|
14797
|
-
if (ancestorDir === pagesDir) {
|
|
14784
|
+
if (ancestors.length <= 1) {
|
|
14798
14785
|
return "/";
|
|
14799
14786
|
}
|
|
14800
|
-
return
|
|
14787
|
+
return route.layouts.find(({ path }) => path === ancestorSourcePath)?.pattern ?? route.pattern;
|
|
14801
14788
|
}
|
|
14802
14789
|
function createBuildContext(pattern, params, origin) {
|
|
14803
14790
|
const path = resolvePath(pattern, params);
|
|
@@ -14883,7 +14870,6 @@ async function resolveStaticParams(route, origin) {
|
|
|
14883
14870
|
}
|
|
14884
14871
|
var STATIC_PARAMS_CONCURRENCY = 4;
|
|
14885
14872
|
var init_static_params = __esm(() => {
|
|
14886
|
-
init_patterns();
|
|
14887
14873
|
init_assemble();
|
|
14888
14874
|
init_loaders();
|
|
14889
14875
|
});
|
|
@@ -15117,176 +15103,280 @@ var init_internal = __esm(() => {
|
|
|
15117
15103
|
_compileContexts = new Map;
|
|
15118
15104
|
});
|
|
15119
15105
|
|
|
15120
|
-
// src/plugin/route-
|
|
15106
|
+
// src/plugin/route-manifest.ts
|
|
15121
15107
|
import { existsSync as existsSync3, readdirSync } from "fs";
|
|
15122
|
-
import { extname as extname2
|
|
15123
|
-
function
|
|
15124
|
-
return `${
|
|
15108
|
+
import { extname as extname2 } from "path";
|
|
15109
|
+
function child(directory, name) {
|
|
15110
|
+
return `${directory}/${name}`;
|
|
15125
15111
|
}
|
|
15126
|
-
function
|
|
15127
|
-
return
|
|
15112
|
+
function sortedEntries(directory) {
|
|
15113
|
+
return readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
|
|
15128
15114
|
}
|
|
15129
|
-
function
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15115
|
+
function moduleBase(name) {
|
|
15116
|
+
if (name.endsWith(".d.ts") || !ROUTE_EXTENSION.test(name)) {
|
|
15117
|
+
return;
|
|
15118
|
+
}
|
|
15119
|
+
return name.slice(0, -extname2(name).length);
|
|
15120
|
+
}
|
|
15121
|
+
function findModule(directory, base) {
|
|
15122
|
+
return SOURCE_EXTENSIONS.map((extension) => child(directory, `${base}${extension}`)).find((path) => existsSync3(path));
|
|
15123
|
+
}
|
|
15124
|
+
function paramName(name, raw, sourcePath) {
|
|
15125
|
+
if (!PARAM_NAME.test(name)) {
|
|
15126
|
+
throw new Error(`[furin] Invalid dynamic parameter ${JSON.stringify(raw)} in ${JSON.stringify(sourcePath)}. Parameter names must match ${PARAM_NAME}.`);
|
|
15127
|
+
}
|
|
15128
|
+
return name;
|
|
15129
|
+
}
|
|
15130
|
+
function splitFlatName(base) {
|
|
15131
|
+
const tokens = [];
|
|
15132
|
+
let current = "";
|
|
15133
|
+
let escaped = false;
|
|
15134
|
+
for (const character of base) {
|
|
15135
|
+
if (character === "[") {
|
|
15136
|
+
escaped = true;
|
|
15137
|
+
} else if (character === "]") {
|
|
15138
|
+
escaped = false;
|
|
15147
15139
|
}
|
|
15148
|
-
if (
|
|
15140
|
+
if (character === "." && !escaped) {
|
|
15141
|
+
tokens.push(current);
|
|
15142
|
+
current = "";
|
|
15149
15143
|
continue;
|
|
15150
15144
|
}
|
|
15151
|
-
|
|
15152
|
-
|
|
15145
|
+
current += character;
|
|
15146
|
+
}
|
|
15147
|
+
tokens.push(current);
|
|
15148
|
+
return tokens;
|
|
15149
|
+
}
|
|
15150
|
+
function tanstackSegment(raw, sourcePath) {
|
|
15151
|
+
if (raw.startsWith("(") && raw.endsWith(")")) {
|
|
15152
|
+
return { raw, type: "group" };
|
|
15153
|
+
}
|
|
15154
|
+
if (raw === "$") {
|
|
15155
|
+
return { raw, type: "splat" };
|
|
15156
|
+
}
|
|
15157
|
+
if (raw.startsWith("{-$") && raw.endsWith("}")) {
|
|
15158
|
+
return {
|
|
15159
|
+
name: paramName(raw.slice(3, -1), raw, sourcePath),
|
|
15160
|
+
optional: true,
|
|
15161
|
+
raw,
|
|
15162
|
+
type: "param"
|
|
15163
|
+
};
|
|
15164
|
+
}
|
|
15165
|
+
if (raw.startsWith("$")) {
|
|
15166
|
+
return { name: paramName(raw.slice(1), raw, sourcePath), optional: false, raw, type: "param" };
|
|
15167
|
+
}
|
|
15168
|
+
if (raw.startsWith("_")) {
|
|
15169
|
+
return { raw, type: "pathless" };
|
|
15170
|
+
}
|
|
15171
|
+
const value = (raw.endsWith("_") ? raw.slice(0, -1) : raw).replace(BRACKET_ESCAPE, "$1");
|
|
15172
|
+
return { raw, type: "static", value };
|
|
15173
|
+
}
|
|
15174
|
+
function tanstackCandidate(base, segments, sourcePath) {
|
|
15175
|
+
const tokens = splitFlatName(base);
|
|
15176
|
+
const last = tokens.at(-1);
|
|
15177
|
+
const index = last === "index";
|
|
15178
|
+
const routeFile = last === "route";
|
|
15179
|
+
const own = (index || routeFile ? tokens.slice(0, -1) : tokens).map((token) => tanstackSegment(token, sourcePath));
|
|
15180
|
+
const routeSegments = [...segments, ...own];
|
|
15181
|
+
if (routeFile && routeSegments.length === 0) {
|
|
15182
|
+
throw new Error(`[furin] ${sourcePath}: a top-level route.tsx has no path to wrap. The root layout lives in __root.tsx.`);
|
|
15183
|
+
}
|
|
15184
|
+
return {
|
|
15185
|
+
forcedLayout: routeFile || routeSegments.at(-1)?.type === "pathless",
|
|
15186
|
+
index,
|
|
15187
|
+
segments: routeSegments,
|
|
15188
|
+
sourcePath
|
|
15189
|
+
};
|
|
15190
|
+
}
|
|
15191
|
+
function scanTanstack(pagesDir) {
|
|
15192
|
+
const candidates = [];
|
|
15193
|
+
const walk = (directory, segments) => {
|
|
15194
|
+
for (const entry of sortedEntries(directory)) {
|
|
15195
|
+
if (entry.name.startsWith("-")) {
|
|
15196
|
+
continue;
|
|
15197
|
+
}
|
|
15198
|
+
const sourcePath = child(directory, entry.name);
|
|
15199
|
+
if (entry.isDirectory()) {
|
|
15200
|
+
walk(sourcePath, [...segments, tanstackSegment(entry.name, sourcePath)]);
|
|
15201
|
+
continue;
|
|
15202
|
+
}
|
|
15203
|
+
const base = moduleBase(entry.name);
|
|
15204
|
+
if (base !== undefined && !(segments.length === 0 && base === "__root")) {
|
|
15205
|
+
candidates.push(tanstackCandidate(base, segments, sourcePath));
|
|
15206
|
+
}
|
|
15153
15207
|
}
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15208
|
+
};
|
|
15209
|
+
walk(pagesDir, []);
|
|
15210
|
+
return {
|
|
15211
|
+
boundaries: [],
|
|
15212
|
+
candidates,
|
|
15213
|
+
rootPath: findModule(pagesDir, "__root") ?? child(pagesDir, "__root.tsx")
|
|
15214
|
+
};
|
|
15215
|
+
}
|
|
15216
|
+
function nextSegment(name, sourcePath) {
|
|
15217
|
+
if (name.startsWith("(") && name.endsWith(")")) {
|
|
15218
|
+
return { raw: name, type: "group" };
|
|
15219
|
+
}
|
|
15220
|
+
const catchAll = name.match(NEXT_CATCH_ALL);
|
|
15221
|
+
if (catchAll?.[1] !== undefined) {
|
|
15222
|
+
paramName(catchAll[1], name, sourcePath);
|
|
15223
|
+
return { raw: "$", type: "splat" };
|
|
15224
|
+
}
|
|
15225
|
+
if (name.startsWith("[") && name.endsWith("]")) {
|
|
15226
|
+
const name_ = paramName(name.slice(1, -1), name, sourcePath);
|
|
15227
|
+
return { name: name_, optional: false, raw: `$${name_}`, type: "param" };
|
|
15228
|
+
}
|
|
15229
|
+
return { raw: name, type: "static", value: name };
|
|
15230
|
+
}
|
|
15231
|
+
function addNextFile(state, base, segments, sourcePath) {
|
|
15232
|
+
if (base === "route") {
|
|
15233
|
+
throw new Error(`[furin] ${sourcePath}: route handlers are not supported. Declare API routes on your Elysia app instead.`);
|
|
15234
|
+
}
|
|
15235
|
+
if (base === "layout" && segments.at(-1)?.type === "splat") {
|
|
15236
|
+
throw new Error(`[furin] ${sourcePath}: a layout cannot share a catch-all folder with its page: move it to the parent folder.`);
|
|
15237
|
+
}
|
|
15238
|
+
if (base === "page" || base === "layout" && segments.length > 0) {
|
|
15239
|
+
state.candidates.push({
|
|
15240
|
+
forcedLayout: base === "layout",
|
|
15241
|
+
index: base === "page" && segments.at(-1)?.type !== "splat",
|
|
15242
|
+
segments,
|
|
15157
15243
|
sourcePath
|
|
15158
15244
|
});
|
|
15245
|
+
} else if (base === "layout") {
|
|
15246
|
+
state.rootPath ??= sourcePath;
|
|
15247
|
+
} else if (base === "error") {
|
|
15248
|
+
state.boundary.errorPath ??= sourcePath;
|
|
15249
|
+
} else if (base === "not-found") {
|
|
15250
|
+
state.boundary.notFoundPath ??= sourcePath;
|
|
15159
15251
|
}
|
|
15160
15252
|
}
|
|
15161
|
-
function
|
|
15162
|
-
const
|
|
15163
|
-
|
|
15164
|
-
|
|
15165
|
-
|
|
15166
|
-
|
|
15253
|
+
function scanNext(pagesDir) {
|
|
15254
|
+
const candidates = [];
|
|
15255
|
+
const boundaries = [];
|
|
15256
|
+
let rootPath;
|
|
15257
|
+
const walk = (directory, segments) => {
|
|
15258
|
+
const boundary = { directory, errorPath: undefined, notFoundPath: undefined };
|
|
15259
|
+
const state = { boundary, candidates, rootPath };
|
|
15260
|
+
for (const entry of sortedEntries(directory)) {
|
|
15261
|
+
const sourcePath = child(directory, entry.name);
|
|
15262
|
+
if (!entry.isDirectory()) {
|
|
15263
|
+
addNextFile(state, moduleBase(entry.name), segments, sourcePath);
|
|
15264
|
+
} else if (!entry.name.startsWith("_")) {
|
|
15265
|
+
walk(sourcePath, [...segments, nextSegment(entry.name, sourcePath)]);
|
|
15266
|
+
}
|
|
15267
|
+
}
|
|
15268
|
+
rootPath ??= state.rootPath;
|
|
15269
|
+
if (boundary.errorPath || boundary.notFoundPath) {
|
|
15270
|
+
boundaries.push(boundary);
|
|
15271
|
+
}
|
|
15272
|
+
};
|
|
15273
|
+
walk(pagesDir, []);
|
|
15274
|
+
boundaries.sort((left, right) => left.directory.length - right.directory.length);
|
|
15275
|
+
return { boundaries, candidates, rootPath: rootPath ?? child(pagesDir, "layout.tsx") };
|
|
15276
|
+
}
|
|
15277
|
+
function segmentKey(segments) {
|
|
15278
|
+
return segments.map((segment) => segment.raw).join("/");
|
|
15279
|
+
}
|
|
15280
|
+
function segmentPattern(segment) {
|
|
15281
|
+
switch (segment.type) {
|
|
15282
|
+
case "group":
|
|
15283
|
+
case "pathless":
|
|
15284
|
+
return;
|
|
15285
|
+
case "param":
|
|
15286
|
+
return `:${segment.name}${segment.optional ? "?" : ""}`;
|
|
15287
|
+
case "splat":
|
|
15288
|
+
return "*";
|
|
15289
|
+
default:
|
|
15290
|
+
return segment.value;
|
|
15291
|
+
}
|
|
15167
15292
|
}
|
|
15168
|
-
function
|
|
15169
|
-
|
|
15170
|
-
return `_route_${instanceId}_${encodedPath}`;
|
|
15293
|
+
function urlPattern(segments) {
|
|
15294
|
+
return `/${segments.flatMap((segment) => segmentPattern(segment) ?? []).join("/")}`;
|
|
15171
15295
|
}
|
|
15172
|
-
function
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
return { ...file, pattern: undefined };
|
|
15179
|
-
}
|
|
15180
|
-
const relativePath = relative6(pagesDir, file.sourcePath).replaceAll("\\", "/");
|
|
15181
|
-
const pattern = filePathToPattern(relativePath);
|
|
15182
|
-
const patternKey = routePatternKey(pattern);
|
|
15183
|
-
const previousPath = seenPatterns.get(patternKey);
|
|
15184
|
-
if (previousPath !== undefined) {
|
|
15185
|
-
throw new Error(`[furin] Duplicate route pattern "${patternKey}" from "${previousPath}" and "${relativePath}".`);
|
|
15186
|
-
}
|
|
15187
|
-
seenPatterns.set(patternKey, relativePath);
|
|
15188
|
-
return { ...file, pattern };
|
|
15296
|
+
function routeParams(segments) {
|
|
15297
|
+
return segments.flatMap((segment) => {
|
|
15298
|
+
if (segment.type === "param") {
|
|
15299
|
+
return [{ name: segment.name, optional: segment.optional }];
|
|
15300
|
+
}
|
|
15301
|
+
return segment.type === "splat" ? [{ name: "_splat", optional: false }] : [];
|
|
15189
15302
|
});
|
|
15190
15303
|
}
|
|
15191
|
-
function
|
|
15192
|
-
const
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
const existing = nodes.get(key);
|
|
15196
|
-
if (existing) {
|
|
15197
|
-
return existing;
|
|
15198
|
-
}
|
|
15199
|
-
const node = {
|
|
15200
|
-
children: [],
|
|
15201
|
-
fileRoutes: [],
|
|
15202
|
-
indexRoute: undefined,
|
|
15203
|
-
layout: undefined,
|
|
15204
|
-
name: segments.at(-1) ?? ""
|
|
15205
|
-
};
|
|
15206
|
-
nodes.set(key, node);
|
|
15207
|
-
if (segments.length > 0) {
|
|
15208
|
-
ensureNode(segments.slice(0, -1)).children.push(node);
|
|
15209
|
-
}
|
|
15210
|
-
return node;
|
|
15211
|
-
};
|
|
15212
|
-
const root = ensureNode([]);
|
|
15213
|
-
for (const file of scanRouteManifest(pagesDir)) {
|
|
15214
|
-
const node = ensureNode(file.directorySegments);
|
|
15215
|
-
if (file.pattern === undefined) {
|
|
15216
|
-
const path = `/${file.directorySegments.map(segmentPath).join("/")}#layout`;
|
|
15217
|
-
node.layout = { id: routeId(instanceId, path), path: "", sourcePath: file.sourcePath };
|
|
15218
|
-
continue;
|
|
15219
|
-
}
|
|
15220
|
-
const route = {
|
|
15221
|
-
id: routeId(instanceId, file.pattern),
|
|
15222
|
-
path: file.pattern,
|
|
15223
|
-
sourcePath: file.sourcePath
|
|
15224
|
-
};
|
|
15225
|
-
if (file.base === "index") {
|
|
15226
|
-
node.indexRoute = route;
|
|
15227
|
-
} else {
|
|
15228
|
-
node.fileRoutes.push(route);
|
|
15229
|
-
}
|
|
15304
|
+
function assertSplatLast(candidate) {
|
|
15305
|
+
const splat = candidate.segments.findIndex((segment) => segment.type === "splat");
|
|
15306
|
+
if (splat !== -1 && splat < candidate.segments.length - 1) {
|
|
15307
|
+
throw new Error(`[furin] ${candidate.sourcePath}: a catch-all segment must be the last segment of its path.`);
|
|
15230
15308
|
}
|
|
15231
|
-
return root;
|
|
15232
15309
|
}
|
|
15233
|
-
function
|
|
15234
|
-
const
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
files.push(node.layout);
|
|
15243
|
-
}
|
|
15244
|
-
if (node.indexRoute) {
|
|
15245
|
-
files.push(node.indexRoute);
|
|
15310
|
+
function patternKeys(pattern) {
|
|
15311
|
+
const keys = expandOptionalSegments(pattern).map((variant) => variant.replace(PARAM_SEGMENT, "$1:param"));
|
|
15312
|
+
return [...new Set(keys)];
|
|
15313
|
+
}
|
|
15314
|
+
function claimPatterns(seenPatterns, pattern, sourcePath, relativePath) {
|
|
15315
|
+
for (const patternKey of patternKeys(pattern)) {
|
|
15316
|
+
const previous = seenPatterns.get(patternKey);
|
|
15317
|
+
if (previous !== undefined) {
|
|
15318
|
+
throw new Error(`[furin] Duplicate route pattern "${patternKey}" from "${relativePath(previous)}" and "${relativePath(sourcePath)}".`);
|
|
15246
15319
|
}
|
|
15247
|
-
|
|
15248
|
-
nodes.push(...node.children);
|
|
15320
|
+
seenPatterns.set(patternKey, sourcePath);
|
|
15249
15321
|
}
|
|
15250
|
-
return files;
|
|
15251
15322
|
}
|
|
15252
|
-
function
|
|
15253
|
-
const
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
const
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15323
|
+
function buildManifest(scan, pagesDir, prefix) {
|
|
15324
|
+
const relativePath = (path) => path.slice(pagesDir.length + 1);
|
|
15325
|
+
const { candidates } = scan;
|
|
15326
|
+
const keys = candidates.map((candidate) => segmentKey(candidate.segments));
|
|
15327
|
+
const hasDescendant = (key, self2) => candidates.some((other, index) => other !== self2 && (keys[index]?.startsWith(`${key}/`) === true || other.index && keys[index] === key));
|
|
15328
|
+
const layouts = new Map;
|
|
15329
|
+
const kinds = candidates.map((candidate, index) => {
|
|
15330
|
+
assertSplatLast(candidate);
|
|
15331
|
+
const key = keys[index] ?? "";
|
|
15332
|
+
const isLayout = !candidate.index && (candidate.forcedLayout || hasDescendant(key, candidate));
|
|
15333
|
+
if (!isLayout) {
|
|
15334
|
+
return "page";
|
|
15264
15335
|
}
|
|
15265
|
-
const
|
|
15266
|
-
if (
|
|
15267
|
-
|
|
15336
|
+
const existing = layouts.get(key);
|
|
15337
|
+
if (existing !== undefined) {
|
|
15338
|
+
throw new Error(`[furin] Two layouts wrap "/${key}": "${relativePath(existing)}" and "${relativePath(candidate.sourcePath)}".`);
|
|
15268
15339
|
}
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15340
|
+
layouts.set(key, candidate.sourcePath);
|
|
15341
|
+
return "layout";
|
|
15342
|
+
});
|
|
15343
|
+
const seenIds = new Map;
|
|
15344
|
+
const seenPatterns = new Map;
|
|
15345
|
+
const routes = candidates.map((candidate, index) => {
|
|
15346
|
+
const kind = kinds[index] ?? "page";
|
|
15347
|
+
const { segments, sourcePath } = candidate;
|
|
15348
|
+
const key = keys[index] ?? "";
|
|
15349
|
+
let parentPath = candidate.index ? layouts.get(key) : undefined;
|
|
15350
|
+
for (let depth = segments.length - 1;parentPath === undefined && depth > 0; depth -= 1) {
|
|
15351
|
+
parentPath = layouts.get(segmentKey(segments.slice(0, depth)));
|
|
15352
|
+
}
|
|
15353
|
+
const path = `/${key}${candidate.index && key !== "" ? "/" : ""}`;
|
|
15354
|
+
const id = prefix === "" ? path : `${prefix}${path}`;
|
|
15355
|
+
const previousId = seenIds.get(id);
|
|
15356
|
+
if (previousId !== undefined) {
|
|
15357
|
+
throw new Error(`[furin] Duplicate route id "${id}" from "${relativePath(previousId)}" and "${relativePath(sourcePath)}".`);
|
|
15358
|
+
}
|
|
15359
|
+
seenIds.set(id, sourcePath);
|
|
15360
|
+
const pattern = urlPattern(segments);
|
|
15361
|
+
if (kind === "page") {
|
|
15362
|
+
claimPatterns(seenPatterns, pattern, sourcePath, relativePath);
|
|
15363
|
+
}
|
|
15364
|
+
return { id, kind, params: routeParams(segments), parentPath, pattern, sourcePath };
|
|
15365
|
+
});
|
|
15366
|
+
return { boundaries: scan.boundaries, rootPath: scan.rootPath, routes };
|
|
15275
15367
|
}
|
|
15276
|
-
function
|
|
15277
|
-
const
|
|
15278
|
-
return
|
|
15279
|
-
...existsSync3(rootPath) ? [rootPath] : [],
|
|
15280
|
-
...routeSourcePaths(instance),
|
|
15281
|
-
...conventionSourcePaths(instance.pagesDir)
|
|
15282
|
-
].toSorted((left, right) => left.localeCompare(right));
|
|
15368
|
+
function scanRouteManifest({ pagesDir, prefix, style }) {
|
|
15369
|
+
const directory = pagesDir.replaceAll("\\", "/");
|
|
15370
|
+
return buildManifest(style === "nextjs" ? scanNext(directory) : scanTanstack(directory), directory, prefix);
|
|
15283
15371
|
}
|
|
15284
|
-
var ROUTE_EXTENSION,
|
|
15285
|
-
var
|
|
15286
|
-
init_patterns();
|
|
15372
|
+
var ROUTE_EXTENSION, PARAM_NAME, BRACKET_ESCAPE, SOURCE_EXTENSIONS, PARAM_SEGMENT, NEXT_CATCH_ALL;
|
|
15373
|
+
var init_route_manifest = __esm(() => {
|
|
15287
15374
|
ROUTE_EXTENSION = /\.(?:jsx?|tsx?)$/;
|
|
15288
|
-
|
|
15289
|
-
|
|
15375
|
+
PARAM_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
15376
|
+
BRACKET_ESCAPE = /\[([^\]]*)\]/g;
|
|
15377
|
+
SOURCE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
15378
|
+
PARAM_SEGMENT = /(^|\/):[^/]+/g;
|
|
15379
|
+
NEXT_CATCH_ALL = /^\[\[?\.\.\.([^\]]+)\]\]?$/;
|
|
15290
15380
|
});
|
|
15291
15381
|
|
|
15292
15382
|
// src/server/router/defined-route.ts
|
|
@@ -15304,9 +15394,11 @@ function adaptDefinedLayout(route, parent, sourcePath) {
|
|
|
15304
15394
|
const component = route.component;
|
|
15305
15395
|
return {
|
|
15306
15396
|
__type: "FURIN_ROUTE",
|
|
15397
|
+
errorComponent: route.errorComponent,
|
|
15307
15398
|
layout: component,
|
|
15308
15399
|
loader: route.loader,
|
|
15309
15400
|
mode: route.mode,
|
|
15401
|
+
notFoundComponent: route.notFoundComponent,
|
|
15310
15402
|
params: route.schemas?.params,
|
|
15311
15403
|
...parent ? { parent } : {},
|
|
15312
15404
|
query: route.schemas?.query,
|
|
@@ -15331,9 +15423,11 @@ function adaptDefinedPage(route, parent) {
|
|
|
15331
15423
|
requestLoader: route.requestLoader
|
|
15332
15424
|
},
|
|
15333
15425
|
component,
|
|
15426
|
+
errorComponent: route.errorComponent,
|
|
15334
15427
|
head,
|
|
15335
15428
|
loader: route.loader,
|
|
15336
15429
|
mode: route.mode,
|
|
15430
|
+
notFoundComponent: route.notFoundComponent,
|
|
15337
15431
|
revalidate: route.revalidate,
|
|
15338
15432
|
staticParams: route.staticParams,
|
|
15339
15433
|
tags: copyTags(route.tags)
|
|
@@ -15371,7 +15465,7 @@ function collectRouteTags(routeChain, page) {
|
|
|
15371
15465
|
function loadProdRoutes(ctx) {
|
|
15372
15466
|
const rootExport = ctx.modules[ctx.rootPath]?.route;
|
|
15373
15467
|
if (!isDefinedRouteTerminal(rootExport) || typeof rootExport.layout !== "function") {
|
|
15374
|
-
throw new Error(
|
|
15468
|
+
throw new Error(`[furin] ${ctx.rootPath}: defineRootRoute().layout() not found in CompileContext.`);
|
|
15375
15469
|
}
|
|
15376
15470
|
const rootRoute = adaptDefinedLayout(rootExport, undefined, ctx.rootPath);
|
|
15377
15471
|
function resolveModuleComponent(modPath) {
|
|
@@ -15381,26 +15475,28 @@ function loadProdRoutes(ctx) {
|
|
|
15381
15475
|
return ctx.modules[modPath]?.default;
|
|
15382
15476
|
}
|
|
15383
15477
|
const root = {
|
|
15384
|
-
error: resolveModuleComponent(ctx.rootConventions?.errorPath),
|
|
15385
|
-
notFound: resolveModuleComponent(ctx.rootConventions?.notFoundPath),
|
|
15478
|
+
error: rootRoute.errorComponent ?? resolveModuleComponent(ctx.rootConventions?.errorPath),
|
|
15479
|
+
notFound: rootRoute.notFoundComponent ?? resolveModuleComponent(ctx.rootConventions?.notFoundPath),
|
|
15386
15480
|
path: ctx.rootPath,
|
|
15387
15481
|
route: rootRoute
|
|
15388
15482
|
};
|
|
15389
15483
|
const routes = [];
|
|
15390
15484
|
for (const { pattern, path, mode } of ctx.routes) {
|
|
15391
|
-
const
|
|
15485
|
+
const meta = ctx.routeMetadata?.[path];
|
|
15486
|
+
const layouts = meta?.layouts ?? [];
|
|
15487
|
+
const page = resolveCompiledRuntimePage(ctx.modules[path] ?? {}, layouts, root, ctx);
|
|
15392
15488
|
if (!page) {
|
|
15393
15489
|
throw new Error(`[furin] ${path}: invalid page module in CompileContext.`);
|
|
15394
15490
|
}
|
|
15395
15491
|
const routeChain = collectRouteChainFromRoute(page._route);
|
|
15396
15492
|
validateRouteChain(routeChain, root.route, path);
|
|
15397
|
-
const
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
notFound: resolveModuleComponent(b.notFoundPath)
|
|
15493
|
+
const boundaries = (meta?.segmentBoundaries ?? []).map((boundary) => ({
|
|
15494
|
+
...boundary,
|
|
15495
|
+
error: boundary.fromRoute ? routeBoundaryComponent(ctx, boundary.errorPath, "errorComponent") : resolveModuleComponent(boundary.errorPath),
|
|
15496
|
+
notFound: boundary.fromRoute ? routeBoundaryComponent(ctx, boundary.notFoundPath, "notFoundComponent") : resolveModuleComponent(boundary.notFoundPath)
|
|
15402
15497
|
}));
|
|
15403
15498
|
routes.push({
|
|
15499
|
+
layouts,
|
|
15404
15500
|
mode,
|
|
15405
15501
|
page,
|
|
15406
15502
|
path,
|
|
@@ -15414,45 +15510,30 @@ function loadProdRoutes(ctx) {
|
|
|
15414
15510
|
}
|
|
15415
15511
|
return { root, routes };
|
|
15416
15512
|
}
|
|
15417
|
-
function
|
|
15513
|
+
function routeBoundaryComponent(ctx, modulePath, field) {
|
|
15514
|
+
const route = modulePath ? ctx.modules[modulePath]?.route : undefined;
|
|
15515
|
+
return isDefinedRouteTerminal(route) ? route[field] : undefined;
|
|
15516
|
+
}
|
|
15517
|
+
function resolveCompiledRuntimePage(module, layouts, root, context) {
|
|
15418
15518
|
if (!isDefinedRouteTerminal(module.route) || typeof module.route.page !== "function") {
|
|
15419
15519
|
return;
|
|
15420
15520
|
}
|
|
15421
|
-
|
|
15422
|
-
const
|
|
15521
|
+
let parent = root.route;
|
|
15522
|
+
for (const { path } of layouts) {
|
|
15523
|
+
const layout = context.modules[path]?.route;
|
|
15524
|
+
if (!isDefinedRouteTerminal(layout) || typeof layout.layout !== "function") {
|
|
15525
|
+
throw invalidNestedLayoutError(path);
|
|
15526
|
+
}
|
|
15527
|
+
parent = adaptDefinedLayout(layout, parent, path);
|
|
15528
|
+
}
|
|
15423
15529
|
return adaptDefinedPage(module.route, parent);
|
|
15424
15530
|
}
|
|
15425
15531
|
function invalidNestedLayoutError(layoutPath) {
|
|
15426
|
-
return new Error(`[furin] ${layoutPath}:
|
|
15427
|
-
export const route = defineRoute("/
|
|
15532
|
+
return new Error(`[furin] ${layoutPath}: a layout file must export \`route = defineRoute(id).config({ mode }).layout(({ children }) => ...)\`, with the file's id. For example, in board/route.tsx:
|
|
15533
|
+
export const route = defineRoute("/board")
|
|
15428
15534
|
.config({ mode: "ssr" })
|
|
15429
15535
|
.layout(({ children }) => <section>{children}</section>);`);
|
|
15430
15536
|
}
|
|
15431
|
-
function resolveCompiledLayoutParent(pagePath, pagesDir, rootRoute, context) {
|
|
15432
|
-
const pageDirectory = pagePath.slice(0, pagePath.lastIndexOf("/"));
|
|
15433
|
-
if (pageDirectory.length <= pagesDir.length) {
|
|
15434
|
-
return rootRoute;
|
|
15435
|
-
}
|
|
15436
|
-
const segments = pageDirectory.slice(pagesDir.length + 1).split("/");
|
|
15437
|
-
let directory = pagesDir;
|
|
15438
|
-
let parent = rootRoute;
|
|
15439
|
-
for (const segment of segments) {
|
|
15440
|
-
directory = `${directory}/${segment}`;
|
|
15441
|
-
for (const candidate of getSourceModuleCandidates(directory, "_route")) {
|
|
15442
|
-
const layoutModule = context.modules[candidate];
|
|
15443
|
-
if (!layoutModule) {
|
|
15444
|
-
continue;
|
|
15445
|
-
}
|
|
15446
|
-
const layout = layoutModule.route;
|
|
15447
|
-
if (!isDefinedRouteTerminal(layout) || typeof layout.layout !== "function") {
|
|
15448
|
-
throw invalidNestedLayoutError(candidate);
|
|
15449
|
-
}
|
|
15450
|
-
parent = adaptDefinedLayout(layout, parent, candidate);
|
|
15451
|
-
break;
|
|
15452
|
-
}
|
|
15453
|
-
}
|
|
15454
|
-
return parent;
|
|
15455
|
-
}
|
|
15456
15537
|
function toPosixPath(path) {
|
|
15457
15538
|
return path.replaceAll("\\", "/");
|
|
15458
15539
|
}
|
|
@@ -15461,36 +15542,60 @@ function routeRelativePath(pagesDir, absolutePath) {
|
|
|
15461
15542
|
const path = toPosixPath(absolutePath);
|
|
15462
15543
|
return path.startsWith(`${dir}/`) ? path.slice(dir.length + 1) : path;
|
|
15463
15544
|
}
|
|
15464
|
-
|
|
15465
|
-
const
|
|
15466
|
-
const
|
|
15467
|
-
|
|
15545
|
+
function manifestLayouts(manifest, route) {
|
|
15546
|
+
const byPath = new Map(manifest.routes.map((entry) => [entry.sourcePath, entry]));
|
|
15547
|
+
const layouts = [];
|
|
15548
|
+
for (let parent = route.parentPath;parent !== undefined; ) {
|
|
15549
|
+
const layout = byPath.get(parent);
|
|
15550
|
+
if (!layout) {
|
|
15551
|
+
break;
|
|
15552
|
+
}
|
|
15553
|
+
layouts.unshift({ path: layout.sourcePath, pattern: layout.pattern });
|
|
15554
|
+
parent = layout.parentPath;
|
|
15555
|
+
}
|
|
15556
|
+
return layouts;
|
|
15557
|
+
}
|
|
15558
|
+
async function scanPages(instance) {
|
|
15559
|
+
const pagesDir = toPosixPath(instance.pagesDir);
|
|
15560
|
+
const manifest = scanRouteManifest({ ...instance, pagesDir });
|
|
15561
|
+
const root = await scanRootLayout(manifest, pagesDir, instance.style);
|
|
15562
|
+
const routes = await scanPageFiles(manifest, pagesDir, instance.style, root);
|
|
15468
15563
|
if (routes.some((route) => route.routeChain.some((entry) => entry.requestLoader))) {
|
|
15469
15564
|
await annotateScannedRequestKeys(routes);
|
|
15470
15565
|
}
|
|
15471
15566
|
return { root, routes };
|
|
15472
15567
|
}
|
|
15473
|
-
async function scanRootLayout(pagesDir) {
|
|
15474
|
-
const rootPath =
|
|
15568
|
+
async function scanRootLayout(manifest, pagesDir, style) {
|
|
15569
|
+
const { rootPath } = manifest;
|
|
15570
|
+
const rootFile = ROOT_FILE_NAMES[style];
|
|
15475
15571
|
const ctx = getCompileContext();
|
|
15476
15572
|
if (!(existsSync4(rootPath) || ctx?.modules[rootPath])) {
|
|
15477
|
-
throw new Error(`[furin]
|
|
15573
|
+
throw new Error(`[furin] ${rootFile}: not found in ${pagesDir}. Every pages directory needs a root layout:
|
|
15478
15574
|
${ROOT_EXAMPLE}`);
|
|
15479
15575
|
}
|
|
15480
15576
|
const mod = ctx?.modules[rootPath] ?? await (isDevelopment() ? import(`${rootPath}?furin-server&t=${routeModuleSourceVersion(rootPath)}`) : import(rootPath));
|
|
15481
15577
|
const rootExport = mod.route;
|
|
15482
15578
|
if (!isDefinedRouteTerminal(rootExport)) {
|
|
15483
|
-
throw new Error(`[furin] ${rootPath}:
|
|
15579
|
+
throw new Error(`[furin] ${rootPath}: ${rootFile} must export \`route = defineRootRoute().config({ mode }).layout(...)\`:
|
|
15484
15580
|
${ROOT_EXAMPLE}`);
|
|
15485
15581
|
}
|
|
15486
15582
|
if (!rootExport.layout) {
|
|
15487
|
-
throw new Error(`[furin] ${rootPath}:
|
|
15583
|
+
throw new Error(`[furin] ${rootPath}: ${rootFile}: defineRootRoute() must end with .layout(({ children }) => ...):
|
|
15488
15584
|
${ROOT_EXAMPLE}`);
|
|
15489
15585
|
}
|
|
15490
15586
|
const rootRoute = adaptDefinedLayout(rootExport, undefined, rootPath);
|
|
15587
|
+
if (style === "tanstack") {
|
|
15588
|
+
return {
|
|
15589
|
+
error: rootRoute.errorComponent,
|
|
15590
|
+
notFound: rootRoute.notFoundComponent,
|
|
15591
|
+
path: rootPath,
|
|
15592
|
+
route: rootRoute
|
|
15593
|
+
};
|
|
15594
|
+
}
|
|
15595
|
+
const rootBoundary = manifest.boundaries.find((boundary) => boundary.directory === pagesDir);
|
|
15491
15596
|
const [notFoundEntry, errorEntry] = await Promise.all([
|
|
15492
|
-
loadConventionComponent(
|
|
15493
|
-
loadConventionComponent(
|
|
15597
|
+
loadConventionComponent(rootBoundary?.notFoundPath, "not-found"),
|
|
15598
|
+
loadConventionComponent(rootBoundary?.errorPath, "error")
|
|
15494
15599
|
]);
|
|
15495
15600
|
return {
|
|
15496
15601
|
error: errorEntry?.component,
|
|
@@ -15501,91 +15606,100 @@ ${ROOT_EXAMPLE}`);
|
|
|
15501
15606
|
route: rootRoute
|
|
15502
15607
|
};
|
|
15503
15608
|
}
|
|
15504
|
-
function
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15609
|
+
async function loadConventionComponent(filePath, name) {
|
|
15610
|
+
if (filePath === undefined) {
|
|
15611
|
+
return;
|
|
15612
|
+
}
|
|
15508
15613
|
const ctx = getCompileContext();
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
if (mod.default) {
|
|
15514
|
-
return { component: mod.default, path: filePath };
|
|
15515
|
-
}
|
|
15516
|
-
const exportNames = Object.keys(mod).join(", ") || "none";
|
|
15517
|
-
throw new Error(`[furin] ${filePath}: ${name}.tsx must default-export a React component (found exports: ${exportNames}). For example:
|
|
15518
|
-
${CONVENTION_EXAMPLES[name]}`);
|
|
15519
|
-
}
|
|
15614
|
+
const moduleSpecifier = isDevelopment() && existsSync4(filePath) ? `${filePath}?furin-server&t=${routeModuleSourceVersion(filePath)}` : filePath;
|
|
15615
|
+
const mod = ctx?.modules[filePath] ?? await import(moduleSpecifier);
|
|
15616
|
+
if (mod.default) {
|
|
15617
|
+
return { component: mod.default, path: filePath };
|
|
15520
15618
|
}
|
|
15619
|
+
const exportNames = Object.keys(mod).join(", ") || "none";
|
|
15620
|
+
throw new Error(`[furin] ${filePath}: ${name}.tsx must default-export a React component (found exports: ${exportNames}). For example:
|
|
15621
|
+
${CONVENTION_EXAMPLES[name]}`);
|
|
15521
15622
|
}
|
|
15522
|
-
async function scanPageFiles(pagesDir, root) {
|
|
15623
|
+
async function scanPageFiles(manifest, pagesDir, style, root) {
|
|
15523
15624
|
const routes = [];
|
|
15524
|
-
const
|
|
15525
|
-
const
|
|
15526
|
-
|
|
15527
|
-
if (pattern === undefined) {
|
|
15625
|
+
const boundaryCache = new Map;
|
|
15626
|
+
for (const manifestRoute of manifest.routes) {
|
|
15627
|
+
if (manifestRoute.kind !== "page") {
|
|
15528
15628
|
continue;
|
|
15529
15629
|
}
|
|
15530
|
-
const
|
|
15630
|
+
const { pattern } = manifestRoute;
|
|
15631
|
+
const absolutePath = manifestRoute.sourcePath;
|
|
15531
15632
|
const relativePath = routeRelativePath(pagesDir, absolutePath);
|
|
15532
|
-
const
|
|
15633
|
+
const layouts = manifestLayouts(manifest, manifestRoute);
|
|
15634
|
+
const directoryBoundaries = style === "nextjs" ? await collectSegmentBoundaries(absolutePath, manifest.boundaries, boundaryCache) : [];
|
|
15533
15635
|
if (isDevelopment()) {
|
|
15534
|
-
const devRoute = await buildDevRoute(absolutePath, relativePath, pattern, root,
|
|
15535
|
-
devRoute.segmentBoundaries = alignSegmentBoundaryDepths(
|
|
15636
|
+
const devRoute = await buildDevRoute(absolutePath, relativePath, pattern, root, layouts);
|
|
15637
|
+
devRoute.segmentBoundaries = style === "nextjs" ? alignSegmentBoundaryDepths(directoryBoundaries, devRoute.routeChain) : routeDefinedBoundaries(root, devRoute.routeChain, devRoute.page, absolutePath);
|
|
15536
15638
|
routes.push(devRoute);
|
|
15537
15639
|
continue;
|
|
15538
15640
|
}
|
|
15539
15641
|
const ctx = getCompileContext();
|
|
15540
15642
|
const pageMod = ctx?.modules[absolutePath] ?? await import(absolutePath);
|
|
15541
|
-
const page = await resolveRuntimePage(pageMod,
|
|
15643
|
+
const page = await resolveRuntimePage(pageMod, layouts, root.route);
|
|
15542
15644
|
if (!page) {
|
|
15543
15645
|
throw new Error(`[furin] ${relativePath}: no valid defineRoute(id).page() export found`);
|
|
15544
15646
|
}
|
|
15545
15647
|
const routeChain = collectRouteChainFromRoute(page._route);
|
|
15546
15648
|
validateRouteChain(routeChain, root.route, relativePath);
|
|
15547
15649
|
routes.push({
|
|
15650
|
+
layouts,
|
|
15548
15651
|
mode: resolveMode(page, routeChain),
|
|
15549
15652
|
page,
|
|
15550
15653
|
path: absolutePath,
|
|
15551
15654
|
pattern,
|
|
15552
15655
|
routeChain,
|
|
15553
|
-
segmentBoundaries: alignSegmentBoundaryDepths(
|
|
15656
|
+
segmentBoundaries: style === "nextjs" ? alignSegmentBoundaryDepths(directoryBoundaries, routeChain) : routeDefinedBoundaries(root, routeChain, page, absolutePath),
|
|
15554
15657
|
tags: collectRouteTags(routeChain, page)
|
|
15555
15658
|
});
|
|
15556
15659
|
}
|
|
15557
15660
|
return routes;
|
|
15558
15661
|
}
|
|
15559
|
-
|
|
15662
|
+
function routeDefinedBoundaries(root, routeChain, page, pagePath) {
|
|
15663
|
+
const entries = [
|
|
15664
|
+
{ depth: 0, path: root.path, route: routeChain[0] ?? root.route },
|
|
15665
|
+
...routeChain.slice(1, -1).map((route, index) => ({ depth: index, path: route.sourcePath, route })),
|
|
15666
|
+
{ depth: Math.max(routeChain.length - 2, 0), path: pagePath, route: page }
|
|
15667
|
+
];
|
|
15668
|
+
const pagesDir = root.path.slice(0, root.path.lastIndexOf("/"));
|
|
15669
|
+
return entries.flatMap(({ depth, path, route }) => {
|
|
15670
|
+
const { errorComponent, notFoundComponent } = route;
|
|
15671
|
+
if (path === undefined || !(errorComponent || notFoundComponent)) {
|
|
15672
|
+
return [];
|
|
15673
|
+
}
|
|
15674
|
+
return [
|
|
15675
|
+
{
|
|
15676
|
+
depth,
|
|
15677
|
+
error: errorComponent,
|
|
15678
|
+
errorPath: errorComponent ? path : undefined,
|
|
15679
|
+
fromRoute: true,
|
|
15680
|
+
notFound: notFoundComponent,
|
|
15681
|
+
notFoundPath: notFoundComponent ? path : undefined,
|
|
15682
|
+
path: path === root.path ? pagesDir : path
|
|
15683
|
+
}
|
|
15684
|
+
];
|
|
15685
|
+
});
|
|
15686
|
+
}
|
|
15687
|
+
async function resolveRuntimePage(module, layouts, rootRoute) {
|
|
15560
15688
|
if (!isDefinedRouteTerminal(module.route) || typeof module.route.page !== "function") {
|
|
15561
15689
|
return;
|
|
15562
15690
|
}
|
|
15563
|
-
const parent = await resolveDefinedLayoutParent(
|
|
15691
|
+
const parent = await resolveDefinedLayoutParent(layouts, rootRoute);
|
|
15564
15692
|
return adaptDefinedPage(module.route, parent);
|
|
15565
15693
|
}
|
|
15566
|
-
async function resolveDefinedLayoutParent(
|
|
15567
|
-
const pageDirectory = pagePath.slice(0, pagePath.lastIndexOf("/"));
|
|
15568
|
-
if (pageDirectory.length <= pagesDir.length) {
|
|
15569
|
-
return rootRoute;
|
|
15570
|
-
}
|
|
15571
|
-
const relativeDirectory = pageDirectory.slice(pagesDir.length + 1);
|
|
15572
|
-
const segments = relativeDirectory.split("/");
|
|
15573
|
-
let directory = pagesDir;
|
|
15694
|
+
async function resolveDefinedLayoutParent(layouts, rootRoute) {
|
|
15574
15695
|
let parent = rootRoute;
|
|
15575
|
-
for (const
|
|
15576
|
-
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
}
|
|
15581
|
-
const layoutModule = await (isDevelopment() ? import(`${candidate}?furin-server&t=${routeModuleSourceVersion(candidate)}`) : import(candidate));
|
|
15582
|
-
const layout = layoutModule.route;
|
|
15583
|
-
if (!isDefinedRouteTerminal(layout) || typeof layout.layout !== "function") {
|
|
15584
|
-
throw invalidNestedLayoutError(candidate);
|
|
15585
|
-
}
|
|
15586
|
-
parent = adaptDefinedLayout(layout, parent, candidate);
|
|
15587
|
-
break;
|
|
15696
|
+
for (const { path } of layouts) {
|
|
15697
|
+
const layoutModule = await (isDevelopment() ? import(`${path}?furin-server&t=${routeModuleSourceVersion(path)}`) : import(path));
|
|
15698
|
+
const layout = layoutModule.route;
|
|
15699
|
+
if (!isDefinedRouteTerminal(layout) || typeof layout.layout !== "function") {
|
|
15700
|
+
throw invalidNestedLayoutError(path);
|
|
15588
15701
|
}
|
|
15702
|
+
parent = adaptDefinedLayout(layout, parent, path);
|
|
15589
15703
|
}
|
|
15590
15704
|
return parent;
|
|
15591
15705
|
}
|
|
@@ -15604,50 +15718,35 @@ function alignSegmentBoundaryDepths(boundaries, routeChain) {
|
|
|
15604
15718
|
return { ...boundary, depth };
|
|
15605
15719
|
});
|
|
15606
15720
|
}
|
|
15607
|
-
async function collectSegmentBoundaries(pageAbsolutePath,
|
|
15721
|
+
async function collectSegmentBoundaries(pageAbsolutePath, boundaries, cache) {
|
|
15608
15722
|
const pageDir = pageAbsolutePath.slice(0, pageAbsolutePath.lastIndexOf("/"));
|
|
15609
|
-
const
|
|
15610
|
-
|
|
15611
|
-
const
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15615
|
-
|
|
15616
|
-
|
|
15617
|
-
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
return r;
|
|
15630
|
-
})
|
|
15631
|
-
]);
|
|
15632
|
-
if (errorEntry || notFoundEntry) {
|
|
15633
|
-
boundaries.push({
|
|
15634
|
-
depth,
|
|
15635
|
-
error: errorEntry?.component,
|
|
15636
|
-
errorPath: errorEntry?.path,
|
|
15637
|
-
notFound: notFoundEntry?.component,
|
|
15638
|
-
notFoundPath: notFoundEntry?.path,
|
|
15639
|
-
path: dir
|
|
15640
|
-
});
|
|
15641
|
-
}
|
|
15642
|
-
}
|
|
15643
|
-
return boundaries;
|
|
15723
|
+
const enclosing = boundaries.filter(({ directory }) => pageDir === directory || pageDir.startsWith(`${directory}/`));
|
|
15724
|
+
return await Promise.all(enclosing.map((boundary) => {
|
|
15725
|
+
const cached = cache.get(boundary.directory);
|
|
15726
|
+
if (cached) {
|
|
15727
|
+
return cached;
|
|
15728
|
+
}
|
|
15729
|
+
const loaded = Promise.all([
|
|
15730
|
+
loadConventionComponent(boundary.errorPath, "error"),
|
|
15731
|
+
loadConventionComponent(boundary.notFoundPath, "not-found")
|
|
15732
|
+
]).then(([errorEntry, notFoundEntry]) => ({
|
|
15733
|
+
depth: 0,
|
|
15734
|
+
error: errorEntry?.component,
|
|
15735
|
+
errorPath: errorEntry?.path,
|
|
15736
|
+
notFound: notFoundEntry?.component,
|
|
15737
|
+
notFoundPath: notFoundEntry?.path,
|
|
15738
|
+
path: boundary.directory
|
|
15739
|
+
}));
|
|
15740
|
+
cache.set(boundary.directory, loaded);
|
|
15741
|
+
return loaded;
|
|
15742
|
+
}));
|
|
15644
15743
|
}
|
|
15645
|
-
async function buildDevRoute(absolutePath, relativePath, pattern, root,
|
|
15744
|
+
async function buildDevRoute(absolutePath, relativePath, pattern, root, layouts) {
|
|
15646
15745
|
let page;
|
|
15647
15746
|
let routeChain = [];
|
|
15648
15747
|
try {
|
|
15649
15748
|
const pageMod = await import(`${absolutePath}?furin-server&t=${routeModuleSourceVersion(absolutePath)}`);
|
|
15650
|
-
const resolvedPage = await resolveRuntimePage(pageMod,
|
|
15749
|
+
const resolvedPage = await resolveRuntimePage(pageMod, layouts, root.route);
|
|
15651
15750
|
if (resolvedPage) {
|
|
15652
15751
|
page = resolvedPage;
|
|
15653
15752
|
routeChain = collectRouteChainFromRoute(page._route);
|
|
@@ -15660,6 +15759,7 @@ async function buildDevRoute(absolutePath, relativePath, pattern, root, pagesDir
|
|
|
15660
15759
|
component: () => null
|
|
15661
15760
|
};
|
|
15662
15761
|
return {
|
|
15762
|
+
layouts,
|
|
15663
15763
|
mode: page ? resolveMode(page, routeChain) : "ssr",
|
|
15664
15764
|
page: page ?? devStubPage,
|
|
15665
15765
|
path: absolutePath,
|
|
@@ -15676,9 +15776,9 @@ var ROOT_EXAMPLE = ` export const route = defineRootRoute()
|
|
|
15676
15776
|
<head><HeadContent /></head>
|
|
15677
15777
|
<body>{children}<Scripts /></body>
|
|
15678
15778
|
</html>
|
|
15679
|
-
));`, CONVENTION_EXAMPLES,
|
|
15779
|
+
));`, CONVENTION_EXAMPLES, ROOT_FILE_NAMES;
|
|
15680
15780
|
var init_discovery = __esm(() => {
|
|
15681
|
-
|
|
15781
|
+
init_route_manifest();
|
|
15682
15782
|
init_instance();
|
|
15683
15783
|
init_internal();
|
|
15684
15784
|
init_patterns();
|
|
@@ -15691,7 +15791,10 @@ var init_discovery = __esm(() => {
|
|
|
15691
15791
|
return <h1>Page not found</h1>;
|
|
15692
15792
|
}`
|
|
15693
15793
|
};
|
|
15694
|
-
|
|
15794
|
+
ROOT_FILE_NAMES = {
|
|
15795
|
+
nextjs: "layout.tsx",
|
|
15796
|
+
tanstack: "__root.tsx"
|
|
15797
|
+
};
|
|
15695
15798
|
});
|
|
15696
15799
|
|
|
15697
15800
|
// src/server/render/not-found.ts
|
|
@@ -16886,17 +16989,15 @@ async function importFreshRouteModuleCandidate(layoutPath, resolveImport, ctx) {
|
|
|
16886
16989
|
throw err;
|
|
16887
16990
|
}
|
|
16888
16991
|
}
|
|
16889
|
-
async function importFreshLayoutRouteModule(
|
|
16890
|
-
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
throw invalidExportFailure(invalidNestedLayoutError(layoutPath), layoutPath);
|
|
16897
|
-
}
|
|
16898
|
-
return freshMod;
|
|
16992
|
+
async function importFreshLayoutRouteModule(layoutPath, resolveImport, ctx) {
|
|
16993
|
+
const freshMod = await importFreshRouteModuleCandidate(layoutPath, resolveImport, ctx);
|
|
16994
|
+
if (!freshMod) {
|
|
16995
|
+
return;
|
|
16996
|
+
}
|
|
16997
|
+
if (!(isDefinedRouteTerminal(freshMod.route) && typeof freshMod.route.layout === "function")) {
|
|
16998
|
+
throw invalidExportFailure(invalidNestedLayoutError(layoutPath), layoutPath);
|
|
16899
16999
|
}
|
|
17000
|
+
return freshMod;
|
|
16900
17001
|
}
|
|
16901
17002
|
function invalidExportFailure(error, file) {
|
|
16902
17003
|
Reflect.set(error, "furinPosition", { column: 1, file, line: 1 });
|
|
@@ -16909,9 +17010,11 @@ function patchRouteEntryFromFreshModule(entry, freshMod) {
|
|
|
16909
17010
|
}
|
|
16910
17011
|
if (isDefinedRouteTerminal(freshRoute) && typeof freshRoute.layout === "function") {
|
|
16911
17012
|
const adapted = adaptDefinedLayout(freshRoute, entry.parent);
|
|
17013
|
+
entry.errorComponent = adapted.errorComponent;
|
|
16912
17014
|
entry.layout = adapted.layout;
|
|
16913
17015
|
entry.loader = adapted.loader;
|
|
16914
17016
|
entry.mode = adapted.mode;
|
|
17017
|
+
entry.notFoundComponent = adapted.notFoundComponent;
|
|
16915
17018
|
entry.params = adapted.params;
|
|
16916
17019
|
entry.query = adapted.query;
|
|
16917
17020
|
entry.requestLoader = adapted.requestLoader;
|
|
@@ -16920,21 +17023,14 @@ function patchRouteEntryFromFreshModule(entry, freshMod) {
|
|
|
16920
17023
|
entry.tags = adapted.tags;
|
|
16921
17024
|
}
|
|
16922
17025
|
}
|
|
16923
|
-
async function refreshLayoutChain(chain,
|
|
17026
|
+
async function refreshLayoutChain(chain, layoutPaths, importFn) {
|
|
16924
17027
|
const resolveImport = importFn ?? routeModuleImport;
|
|
16925
17028
|
const ctx = getCompileContext();
|
|
16926
|
-
const
|
|
16927
|
-
const
|
|
16928
|
-
|
|
16929
|
-
|
|
16930
|
-
if (chainIdx >= chain.length) {
|
|
16931
|
-
break;
|
|
16932
|
-
}
|
|
16933
|
-
if (!freshMod) {
|
|
16934
|
-
continue;
|
|
17029
|
+
const freshMods = await Promise.all(layoutPaths.map((layoutPath) => importFreshLayoutRouteModule(layoutPath, resolveImport, ctx)));
|
|
17030
|
+
for (const [index, freshMod] of freshMods.entries()) {
|
|
17031
|
+
if (freshMod) {
|
|
17032
|
+
patchRouteEntryFromFreshModule(chain[index + 1], freshMod);
|
|
16935
17033
|
}
|
|
16936
|
-
patchRouteEntryFromFreshModule(chain[chainIdx], freshMod);
|
|
16937
|
-
chainIdx += 1;
|
|
16938
17034
|
}
|
|
16939
17035
|
}
|
|
16940
17036
|
function rebuildDevRoute(base, page, chain) {
|
|
@@ -16961,7 +17057,7 @@ async function resolveCurrentDevRoute(route, root) {
|
|
|
16961
17057
|
let chain;
|
|
16962
17058
|
if (isDefinedRouteTerminal(pageMod.route) && typeof pageMod.route.page === "function") {
|
|
16963
17059
|
const currentChain = route.routeChain;
|
|
16964
|
-
await refreshLayoutChain(currentChain, route.path
|
|
17060
|
+
await refreshLayoutChain(currentChain, route.layouts.map(({ path }) => path), undefined);
|
|
16965
17061
|
const parent = currentChain.at(-2) ?? currentRoot.route;
|
|
16966
17062
|
const adaptedPage = adaptDefinedPage(pageMod.route, parent);
|
|
16967
17063
|
page = adaptedPage;
|
|
@@ -17014,7 +17110,7 @@ async function loadCachedDevLoaderData(route, ctx, root, mode, purpose) {
|
|
|
17014
17110
|
const result = purpose === "document" ? await runDevLoaders(route, loaderCtx) : await runPublicLoaders(route, loaderCtx);
|
|
17015
17111
|
if (result.type === "data") {
|
|
17016
17112
|
const entry = {
|
|
17017
|
-
dependencies: computeRouteDependencies(route.path, root.path),
|
|
17113
|
+
dependencies: computeRouteDependencies(route.path, root.path, route.layouts.map(({ path }) => path)),
|
|
17018
17114
|
generatedAt: Date.now(),
|
|
17019
17115
|
headers: result.headers,
|
|
17020
17116
|
loaderData: result.syncData,
|
|
@@ -17026,15 +17122,8 @@ async function loadCachedDevLoaderData(route, ctx, root, mode, purpose) {
|
|
|
17026
17122
|
}
|
|
17027
17123
|
return result;
|
|
17028
17124
|
}
|
|
17029
|
-
function computeRouteDependencies(pagePath, rootPath) {
|
|
17030
|
-
const deps = [pagePath, rootPath];
|
|
17031
|
-
for (const dir of collectIntermediateLayoutDirs(pagePath, rootPath)) {
|
|
17032
|
-
for (const candidate of getSourceModuleCandidates(dir, "_route")) {
|
|
17033
|
-
if (existsSync6(candidate)) {
|
|
17034
|
-
deps.push(candidate);
|
|
17035
|
-
}
|
|
17036
|
-
}
|
|
17037
|
-
}
|
|
17125
|
+
function computeRouteDependencies(pagePath, rootPath, layoutPaths) {
|
|
17126
|
+
const deps = [pagePath, rootPath, ...layoutPaths.filter((path) => existsSync6(path))];
|
|
17038
17127
|
const graph = devGraph(undefined);
|
|
17039
17128
|
return [...new Set(deps.flatMap((path) => graph.sourceDependencies(path)))].filter(existsSync6);
|
|
17040
17129
|
}
|
|
@@ -17126,7 +17215,7 @@ var init_hmr = __esm(() => {
|
|
|
17126
17215
|
|
|
17127
17216
|
// src/plugin/preflight.ts
|
|
17128
17217
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "fs";
|
|
17129
|
-
import { join as
|
|
17218
|
+
import { join as join4 } from "path";
|
|
17130
17219
|
function staticPlugins(bunfig) {
|
|
17131
17220
|
if (typeof bunfig !== "object" || bunfig === null || !("serve" in bunfig)) {
|
|
17132
17221
|
return [];
|
|
@@ -17142,7 +17231,7 @@ function staticPlugins(bunfig) {
|
|
|
17142
17231
|
return staticConfig.plugins.filter((plugin) => typeof plugin === "string");
|
|
17143
17232
|
}
|
|
17144
17233
|
function stripPluginPreflightWarning(projectRoot) {
|
|
17145
|
-
const bunfigPath =
|
|
17234
|
+
const bunfigPath = join4(projectRoot, "bunfig.toml");
|
|
17146
17235
|
const hasBunfig = existsSync7(bunfigPath);
|
|
17147
17236
|
const plugins = hasBunfig ? staticPlugins(Bun.TOML.parse(readFileSync4(bunfigPath, "utf8"))) : [];
|
|
17148
17237
|
if (plugins.includes(STRIP_PLUGIN)) {
|
|
@@ -18775,9 +18864,9 @@ var init_dist2 = __esm(() => {
|
|
|
18775
18864
|
});
|
|
18776
18865
|
|
|
18777
18866
|
// src/shared/parser.ts
|
|
18778
|
-
import { parse as
|
|
18867
|
+
import { parse as parse2 } from "yuku-parser";
|
|
18779
18868
|
function parseSource(code, lang) {
|
|
18780
|
-
return
|
|
18869
|
+
return parse2(code, { lang, sourceType: "module" });
|
|
18781
18870
|
}
|
|
18782
18871
|
var init_parser = () => {};
|
|
18783
18872
|
|
|
@@ -20535,7 +20624,7 @@ var init_transform_dev_page = __esm(() => {
|
|
|
20535
20624
|
|
|
20536
20625
|
// src/plugin/transform-client-module.ts
|
|
20537
20626
|
import { realpathSync as realpathSync2 } from "fs";
|
|
20538
|
-
import { dirname as
|
|
20627
|
+
import { dirname as dirname4 } from "path";
|
|
20539
20628
|
function clientModuleKey(modulePath) {
|
|
20540
20629
|
const realPath = realpathSync2(modulePath).replaceAll("\\", "/");
|
|
20541
20630
|
return `__FURIN_CLIENT_MODULE_${Bun.hash(realPath).toString(36)}__`;
|
|
@@ -20588,7 +20677,7 @@ function rewriteClientModules(module, environment) {
|
|
|
20588
20677
|
}
|
|
20589
20678
|
let key;
|
|
20590
20679
|
try {
|
|
20591
|
-
key = JSON.stringify(clientModuleKey(Bun.resolveSync(specifier,
|
|
20680
|
+
key = JSON.stringify(clientModuleKey(Bun.resolveSync(specifier, dirname4(filename))));
|
|
20592
20681
|
} catch (error) {
|
|
20593
20682
|
throw new Error(`[furin] Cannot resolve clientModule import ${JSON.stringify(specifier)} in ${filename}`, { cause: error });
|
|
20594
20683
|
}
|
|
@@ -21029,7 +21118,7 @@ var init_transform_isomorphic = __esm(() => {
|
|
|
21029
21118
|
});
|
|
21030
21119
|
|
|
21031
21120
|
// src/server/dev/error.ts
|
|
21032
|
-
import { relative as
|
|
21121
|
+
import { relative as relative5 } from "path";
|
|
21033
21122
|
function errorMessage2(error) {
|
|
21034
21123
|
if (error instanceof Error) {
|
|
21035
21124
|
return error.message;
|
|
@@ -21080,7 +21169,7 @@ function createDevErrorPayload(error, context) {
|
|
|
21080
21169
|
};
|
|
21081
21170
|
}
|
|
21082
21171
|
function displaySourcePath(path) {
|
|
21083
|
-
const projected =
|
|
21172
|
+
const projected = relative5(process.cwd(), path).replaceAll("\\", "/");
|
|
21084
21173
|
return projected.startsWith("../") ? path : projected;
|
|
21085
21174
|
}
|
|
21086
21175
|
function publishDevError(graph, error, context) {
|
|
@@ -21127,7 +21216,7 @@ var init_server_only_module = __esm(() => {
|
|
|
21127
21216
|
});
|
|
21128
21217
|
|
|
21129
21218
|
// src/server/dev/rewrite-module-specifiers.ts
|
|
21130
|
-
import { dirname as
|
|
21219
|
+
import { dirname as dirname5, resolve as resolve6 } from "path";
|
|
21131
21220
|
function sourcePosition2(source, byteOffset) {
|
|
21132
21221
|
const bytes = new TextEncoder().encode(source);
|
|
21133
21222
|
const prefix = new TextDecoder().decode(bytes.slice(0, byteOffset));
|
|
@@ -21148,7 +21237,7 @@ function relativeSpecifier(node) {
|
|
|
21148
21237
|
return isStringLiteral(node.source) ? node.source : undefined;
|
|
21149
21238
|
}
|
|
21150
21239
|
function resolvedSpecifier(specifier, directory, versioned) {
|
|
21151
|
-
const path = versioned ? Bun.resolveSync(specifier, directory) :
|
|
21240
|
+
const path = versioned ? Bun.resolveSync(specifier, directory) : resolve6(directory, specifier);
|
|
21152
21241
|
const normalized = path.replaceAll("\\", "/");
|
|
21153
21242
|
return versioned && SCRIPT_FILE_FILTER.test(normalized) && !isServerOnlyModule(path) ? `${normalized}?furin-server&t=${routeModuleSourceVersion(normalized)}` : normalized;
|
|
21154
21243
|
}
|
|
@@ -21160,7 +21249,7 @@ function rewriteModuleSpecifiers(input) {
|
|
|
21160
21249
|
Reflect.set(error, "position", sourcePosition2(input.code, parseError.start));
|
|
21161
21250
|
throw error;
|
|
21162
21251
|
}
|
|
21163
|
-
const directory =
|
|
21252
|
+
const directory = dirname5(input.filePath);
|
|
21164
21253
|
const output = new MagicString(input.code);
|
|
21165
21254
|
walkAST(program, (node) => {
|
|
21166
21255
|
const literal = relativeSpecifier(node);
|
|
@@ -21182,7 +21271,7 @@ var init_rewrite_module_specifiers = __esm(() => {
|
|
|
21182
21271
|
});
|
|
21183
21272
|
|
|
21184
21273
|
// src/server/dev-page-imports.ts
|
|
21185
|
-
import { dirname as
|
|
21274
|
+
import { dirname as dirname6, isAbsolute as isAbsolute4, resolve as resolve7 } from "path";
|
|
21186
21275
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
21187
21276
|
function toImportSpecifier(filePath) {
|
|
21188
21277
|
return filePath.replaceAll("\\", "/");
|
|
@@ -21209,7 +21298,7 @@ function pinJsxRuntime(source, loader) {
|
|
|
21209
21298
|
if (!runtime || loader === "ts") {
|
|
21210
21299
|
return source;
|
|
21211
21300
|
}
|
|
21212
|
-
const pragma = `/** @jsxImportSource ${pathToFileURL(
|
|
21301
|
+
const pragma = `/** @jsxImportSource ${pathToFileURL(dirname6(runtime)).href} */ `;
|
|
21213
21302
|
const shebangEnd = source.startsWith("#!") ? source.indexOf(`
|
|
21214
21303
|
`) + 1 : 0;
|
|
21215
21304
|
return shebangEnd > 0 ? `${source.slice(0, shebangEnd)}${pragma}${source.slice(shebangEnd)}` : `${pragma}${source}`;
|
|
@@ -21275,7 +21364,7 @@ var init_dev_page_imports = __esm(() => {
|
|
|
21275
21364
|
|
|
21276
21365
|
// src/server/dev-page-plugin.ts
|
|
21277
21366
|
import { statSync as statSync4 } from "fs";
|
|
21278
|
-
import { dirname as
|
|
21367
|
+
import { dirname as dirname7, isAbsolute as isAbsolute5 } from "path";
|
|
21279
21368
|
function getSourceLoader(filePath) {
|
|
21280
21369
|
return SCRIPT_FILE_FILTER.test(filePath) ? detectLoaderFromPath(filePath) : null;
|
|
21281
21370
|
}
|
|
@@ -21359,7 +21448,7 @@ function transformDevSource(raw, filePath, options) {
|
|
|
21359
21448
|
const serverSource = split?.contract ?? isomorphicSource;
|
|
21360
21449
|
let result = options.rewriteRelativeImports ? rewriteRelativeImportsWithVersion(serverSource, filePath, true) : serverSource;
|
|
21361
21450
|
if (options.rewriteBareImports) {
|
|
21362
|
-
result = rewriteBareImports(result,
|
|
21451
|
+
result = rewriteBareImports(result, dirname7(filePath), loader);
|
|
21363
21452
|
}
|
|
21364
21453
|
result = rewriteSingletonImports(result, loader);
|
|
21365
21454
|
return pinJsxRuntime(result, loader);
|
|
@@ -21496,9 +21585,9 @@ var init_dev_page_plugin = __esm(() => {
|
|
|
21496
21585
|
|
|
21497
21586
|
// src/plugin/route-modules.ts
|
|
21498
21587
|
import { existsSync as existsSync8, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
|
|
21499
|
-
import { dirname as
|
|
21588
|
+
import { dirname as dirname8, isAbsolute as isAbsolute6, join as join5, relative as relative6, sep as sep2 } from "path";
|
|
21500
21589
|
function validateRouteParams(path, schemas) {
|
|
21501
|
-
const pathParams = path.split("/").filter((segment) => segment === "*" || segment.startsWith(":")).map((segment) => segment === "*" ?
|
|
21590
|
+
const pathParams = path.split("/").filter((segment) => segment === "*" || segment.startsWith(":")).map((segment) => segment === "*" ? SPLAT_PARAM : segment.slice(1).replace(OPTIONAL_MARK, ""));
|
|
21502
21591
|
if (pathParams.length === 0) {
|
|
21503
21592
|
return;
|
|
21504
21593
|
}
|
|
@@ -21518,18 +21607,18 @@ function routeModuleCache() {
|
|
|
21518
21607
|
return cache;
|
|
21519
21608
|
}
|
|
21520
21609
|
function findPackageRoot(sourcePath) {
|
|
21521
|
-
const fallback =
|
|
21610
|
+
const fallback = dirname8(sourcePath);
|
|
21522
21611
|
let directory = fallback;
|
|
21523
|
-
while (
|
|
21524
|
-
if (existsSync8(
|
|
21612
|
+
while (dirname8(directory) !== directory) {
|
|
21613
|
+
if (existsSync8(join5(directory, "package.json"))) {
|
|
21525
21614
|
return directory;
|
|
21526
21615
|
}
|
|
21527
|
-
directory =
|
|
21616
|
+
directory = dirname8(directory);
|
|
21528
21617
|
}
|
|
21529
|
-
return existsSync8(
|
|
21618
|
+
return existsSync8(join5(directory, "package.json")) ? directory : fallback;
|
|
21530
21619
|
}
|
|
21531
21620
|
function isWithinDirectory(path, directory) {
|
|
21532
|
-
const relativePath =
|
|
21621
|
+
const relativePath = relative6(directory, path);
|
|
21533
21622
|
return relativePath === "" || !(relativePath.startsWith("..") || isAbsolute6(relativePath));
|
|
21534
21623
|
}
|
|
21535
21624
|
function isFurinPackageImport(specifier) {
|
|
@@ -21547,8 +21636,8 @@ function resolveRouteModuleImports(dependencyPath, packageRoot) {
|
|
|
21547
21636
|
continue;
|
|
21548
21637
|
}
|
|
21549
21638
|
try {
|
|
21550
|
-
const resolvedImport = realpathSync3.native(Bun.resolveSync(imported.path,
|
|
21551
|
-
if (isAbsolute6(resolvedImport) && isWithinDirectory(resolvedImport, packageRoot) && !
|
|
21639
|
+
const resolvedImport = realpathSync3.native(Bun.resolveSync(imported.path, dirname8(dependencyPath)));
|
|
21640
|
+
if (isAbsolute6(resolvedImport) && isWithinDirectory(resolvedImport, packageRoot) && !relative6(packageRoot, resolvedImport).split(sep2).includes("node_modules")) {
|
|
21552
21641
|
resolvedImports.push(resolvedImport);
|
|
21553
21642
|
}
|
|
21554
21643
|
} catch {}
|
|
@@ -21580,19 +21669,99 @@ function collectRouteModuleDependencies(sourcePath) {
|
|
|
21580
21669
|
function routeModuleDependencies(sourcePath) {
|
|
21581
21670
|
return routeModuleCache().get(sourcePath)?.dependencies ?? collectRouteModuleDependencies(sourcePath);
|
|
21582
21671
|
}
|
|
21583
|
-
var ROUTE_MODULE_CACHE_SYMBOL;
|
|
21672
|
+
var ROUTE_MODULE_CACHE_SYMBOL, OPTIONAL_MARK;
|
|
21584
21673
|
var init_route_modules = __esm(() => {
|
|
21585
21674
|
init_lang_detect();
|
|
21675
|
+
init_patterns();
|
|
21586
21676
|
ROUTE_MODULE_CACHE_SYMBOL = Symbol.for("@teyik0/furin/route-module-cache");
|
|
21677
|
+
OPTIONAL_MARK = /\?$/;
|
|
21678
|
+
});
|
|
21679
|
+
|
|
21680
|
+
// src/plugin/route-tree.ts
|
|
21681
|
+
import { existsSync as existsSync9 } from "fs";
|
|
21682
|
+
import { resolve as resolve8 } from "path";
|
|
21683
|
+
function instanceKey(instance) {
|
|
21684
|
+
return `${resolve8(instance.pagesDir)}\x00${instance.prefix}`;
|
|
21685
|
+
}
|
|
21686
|
+
function routeModuleSpecifier(instance) {
|
|
21687
|
+
return `@teyik0/furin/routes?instance=${Bun.hash(instanceKey(instance)).toString(16)}`;
|
|
21688
|
+
}
|
|
21689
|
+
function routeId(instanceId, id) {
|
|
21690
|
+
const encodedId = Array.from(new TextEncoder().encode(id), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
21691
|
+
return `_route_${instanceId}_${encodedId}`;
|
|
21692
|
+
}
|
|
21693
|
+
function relativePrefix(pattern, parentPattern) {
|
|
21694
|
+
const own = pattern === "/" ? "" : pattern;
|
|
21695
|
+
const parent = parentPattern === "/" ? "" : parentPattern;
|
|
21696
|
+
if (!own.startsWith(parent)) {
|
|
21697
|
+
throw new Error(`[furin] Route pattern "${pattern}" does not extend its layout's "${parentPattern}".`);
|
|
21698
|
+
}
|
|
21699
|
+
return own.slice(parent.length);
|
|
21700
|
+
}
|
|
21701
|
+
function buildRouteTree(instance, instanceId) {
|
|
21702
|
+
const { routes } = scanRouteManifest(instance);
|
|
21703
|
+
const byPath = new Map(routes.map((route) => [route.sourcePath, route]));
|
|
21704
|
+
const root = { children: [], layout: undefined, pages: [], prefix: "" };
|
|
21705
|
+
const nodes = new Map([[undefined, root]]);
|
|
21706
|
+
const parentPattern = (route) => route.parentPath === undefined ? "/" : byPath.get(route.parentPath)?.pattern ?? "/";
|
|
21707
|
+
const ensureNode = (sourcePath) => {
|
|
21708
|
+
const existing = nodes.get(sourcePath);
|
|
21709
|
+
if (existing) {
|
|
21710
|
+
return existing;
|
|
21711
|
+
}
|
|
21712
|
+
const layout = sourcePath === undefined ? undefined : byPath.get(sourcePath);
|
|
21713
|
+
if (!layout) {
|
|
21714
|
+
return root;
|
|
21715
|
+
}
|
|
21716
|
+
const prefix = relativePrefix(layout.pattern, parentPattern(layout));
|
|
21717
|
+
const node = {
|
|
21718
|
+
children: [],
|
|
21719
|
+
layout: {
|
|
21720
|
+
id: routeId(instanceId, layout.id),
|
|
21721
|
+
path: "",
|
|
21722
|
+
prefix,
|
|
21723
|
+
sourcePath: resolve8(layout.sourcePath)
|
|
21724
|
+
},
|
|
21725
|
+
pages: [],
|
|
21726
|
+
prefix
|
|
21727
|
+
};
|
|
21728
|
+
nodes.set(sourcePath, node);
|
|
21729
|
+
ensureNode(layout.parentPath).children.push(node);
|
|
21730
|
+
return node;
|
|
21731
|
+
};
|
|
21732
|
+
for (const route of routes) {
|
|
21733
|
+
if (route.kind === "layout") {
|
|
21734
|
+
ensureNode(route.sourcePath);
|
|
21735
|
+
continue;
|
|
21736
|
+
}
|
|
21737
|
+
ensureNode(route.parentPath).pages.push({
|
|
21738
|
+
id: routeId(instanceId, route.id),
|
|
21739
|
+
path: route.pattern,
|
|
21740
|
+
prefix: relativePrefix(route.pattern, parentPattern(route)),
|
|
21741
|
+
sourcePath: resolve8(route.sourcePath)
|
|
21742
|
+
});
|
|
21743
|
+
}
|
|
21744
|
+
return root;
|
|
21745
|
+
}
|
|
21746
|
+
function routeSnapshotSourcePaths(instance) {
|
|
21747
|
+
const { boundaries, rootPath, routes } = scanRouteManifest(instance);
|
|
21748
|
+
return [
|
|
21749
|
+
...existsSync9(rootPath) ? [rootPath] : [],
|
|
21750
|
+
...routes.map(({ sourcePath }) => sourcePath),
|
|
21751
|
+
...boundaries.flatMap(({ errorPath, notFoundPath }) => [errorPath, notFoundPath].filter((path) => path !== undefined))
|
|
21752
|
+
].map((path) => resolve8(path)).toSorted((left, right) => left.localeCompare(right));
|
|
21753
|
+
}
|
|
21754
|
+
var init_route_tree = __esm(() => {
|
|
21755
|
+
init_route_manifest();
|
|
21587
21756
|
});
|
|
21588
21757
|
|
|
21589
21758
|
// src/plugin/dev-routes.ts
|
|
21590
|
-
import { existsSync as
|
|
21591
|
-
import { dirname as
|
|
21759
|
+
import { existsSync as existsSync10, readFileSync as readFileSync7, statSync as statSync6, watch } from "fs";
|
|
21760
|
+
import { dirname as dirname9, relative as relative7, resolve as resolve9, sep as sep3 } from "path";
|
|
21592
21761
|
import { Elysia as Elysia16 } from "elysia";
|
|
21593
21762
|
function routeTopologySource(instance) {
|
|
21594
21763
|
const pagesDir = resolve9(instance.pagesDir);
|
|
21595
|
-
const paths = routeSnapshotSourcePaths(instance).map((path) =>
|
|
21764
|
+
const paths = routeSnapshotSourcePaths(instance).map((path) => relative7(pagesDir, path).replaceAll("\\", "/"));
|
|
21596
21765
|
return `${JSON.stringify(paths)}
|
|
21597
21766
|
`;
|
|
21598
21767
|
}
|
|
@@ -21701,7 +21870,7 @@ function reportChangedSourceError(state, directory, filename) {
|
|
|
21701
21870
|
return;
|
|
21702
21871
|
}
|
|
21703
21872
|
const sourcePath = resolve9(directory, String(filename));
|
|
21704
|
-
if (!(SCRIPT_FILE_FILTER.test(sourcePath) &&
|
|
21873
|
+
if (!(SCRIPT_FILE_FILTER.test(sourcePath) && existsSync10(sourcePath))) {
|
|
21705
21874
|
return;
|
|
21706
21875
|
}
|
|
21707
21876
|
try {
|
|
@@ -21719,7 +21888,7 @@ function replaceSourceWatchers(state) {
|
|
|
21719
21888
|
const directories = new Set;
|
|
21720
21889
|
for (const path of routeDependencyPaths(state.instance)) {
|
|
21721
21890
|
if (!(path === pagesDir || path.startsWith(`${pagesDir}${sep3}`))) {
|
|
21722
|
-
directories.add(
|
|
21891
|
+
directories.add(dirname9(path));
|
|
21723
21892
|
}
|
|
21724
21893
|
}
|
|
21725
21894
|
const watchDirectory = (directory, recursive) => {
|
|
@@ -21871,27 +22040,20 @@ async function composableRouteApps(route) {
|
|
|
21871
22040
|
};
|
|
21872
22041
|
}
|
|
21873
22042
|
async function composeRuntimeNode(node) {
|
|
21874
|
-
const
|
|
21875
|
-
const
|
|
21876
|
-
const [layoutApps, indexRouteApps, fileRouteApps, childApps] = await Promise.all([
|
|
22043
|
+
const { pages, prefix } = node;
|
|
22044
|
+
const [layoutApps, pageApps, childApps] = await Promise.all([
|
|
21877
22045
|
node.layout ? composableRouteApps(node.layout) : undefined,
|
|
21878
|
-
|
|
21879
|
-
Promise.all(fileRoutes.map((route) => composableRouteApps(route))),
|
|
22046
|
+
Promise.all(pages.map((route) => composableRouteApps(route))),
|
|
21880
22047
|
Promise.all(node.children.map((child) => composeRuntimeNode(child)))
|
|
21881
22048
|
]);
|
|
21882
22049
|
const appScope = layoutApps?.app ?? new Elysia16;
|
|
21883
22050
|
const shellScope = layoutApps?.shell ?? new Elysia16;
|
|
21884
|
-
|
|
21885
|
-
|
|
21886
|
-
shellScope.use(new Elysia16({ prefix: "" }).use(indexRouteApps.shell));
|
|
21887
|
-
}
|
|
21888
|
-
for (const [index, route] of fileRoutes.entries()) {
|
|
21889
|
-
const routeApps = fileRouteApps[index];
|
|
22051
|
+
for (const [index, route] of pages.entries()) {
|
|
22052
|
+
const routeApps = pageApps[index];
|
|
21890
22053
|
if (routeApps) {
|
|
21891
|
-
|
|
21892
|
-
appScope.use(new Elysia16({ prefix: `/${segment}` }).use(routeApps.app));
|
|
22054
|
+
appScope.use(new Elysia16({ prefix: route.prefix }).use(routeApps.app));
|
|
21893
22055
|
if (route.path !== "/*") {
|
|
21894
|
-
shellScope.use(new Elysia16({ prefix:
|
|
22056
|
+
shellScope.use(new Elysia16({ prefix: route.prefix }).use(routeApps.shell));
|
|
21895
22057
|
}
|
|
21896
22058
|
}
|
|
21897
22059
|
}
|
|
@@ -21908,7 +22070,7 @@ async function composeRuntimeInstance(instance) {
|
|
|
21908
22070
|
await Promise.resolve().then(() => init_dev_page_plugin());
|
|
21909
22071
|
registerDevPagePlugin();
|
|
21910
22072
|
const instanceId = Bun.hash(instanceKey(instance)).toString(16);
|
|
21911
|
-
return composeRuntimeNode(buildRouteTree(instance
|
|
22073
|
+
return composeRuntimeNode(buildRouteTree(instance, instanceId));
|
|
21912
22074
|
}
|
|
21913
22075
|
function registerDevRoutesPlugin(instances) {
|
|
21914
22076
|
for (const instance of instances) {
|
|
@@ -21937,7 +22099,6 @@ var DEV_ROUTE_WATCHERS_SYMBOL, DEV_ROUTE_WATCHER_OWNERS_SYMBOL, DEV_ROUTE_RECONC
|
|
|
21937
22099
|
var init_dev_routes = __esm(() => {
|
|
21938
22100
|
init_define_route();
|
|
21939
22101
|
init_lang_detect();
|
|
21940
|
-
init_patterns();
|
|
21941
22102
|
init_source_version();
|
|
21942
22103
|
init_route_modules();
|
|
21943
22104
|
init_route_tree();
|
|
@@ -21947,11 +22108,8 @@ var init_dev_routes = __esm(() => {
|
|
|
21947
22108
|
});
|
|
21948
22109
|
|
|
21949
22110
|
// src/plugin/route-config.ts
|
|
21950
|
-
import { existsSync as
|
|
21951
|
-
import {
|
|
21952
|
-
function withoutExtension(path) {
|
|
21953
|
-
return path.replace(EXTENSION_RE, "");
|
|
21954
|
-
}
|
|
22111
|
+
import { existsSync as existsSync11, readFileSync as readFileSync8, writeFileSync } from "fs";
|
|
22112
|
+
import { relative as relative8, resolve as resolve10 } from "path";
|
|
21955
22113
|
function propertyName(key) {
|
|
21956
22114
|
if (key?.type === "Identifier") {
|
|
21957
22115
|
return key.name;
|
|
@@ -22032,9 +22190,9 @@ function position2(source, offset) {
|
|
|
22032
22190
|
function issueAt(file, parsed, node, message) {
|
|
22033
22191
|
return { file, ...position2(parsed.source, node.start), message };
|
|
22034
22192
|
}
|
|
22035
|
-
function checkKey(file,
|
|
22193
|
+
function checkKey(file, route, parsed) {
|
|
22036
22194
|
const { config, head, id } = parsed.route;
|
|
22037
|
-
const expected =
|
|
22195
|
+
const expected = route.id;
|
|
22038
22196
|
if (!id) {
|
|
22039
22197
|
return issueAt(file, parsed, head, `defineRoute() must name this file. Its id is "${expected}":
|
|
22040
22198
|
defineRoute("${expected}")`);
|
|
@@ -22063,21 +22221,21 @@ function suggestedMode(route, isRoot) {
|
|
|
22063
22221
|
}
|
|
22064
22222
|
return route.methods.has("loader") || route.methods.has("requestLoader") ? "ssr" : "ssg";
|
|
22065
22223
|
}
|
|
22066
|
-
function checkFactory(file,
|
|
22224
|
+
function checkFactory(file, manifestRoute, parsed) {
|
|
22067
22225
|
const { route } = parsed;
|
|
22068
|
-
const isRoot =
|
|
22226
|
+
const isRoot = manifestRoute === undefined;
|
|
22069
22227
|
if (isRoot === route.isRootFactory) {
|
|
22070
22228
|
return;
|
|
22071
22229
|
}
|
|
22072
22230
|
const mode = suggestedMode(route, isRoot);
|
|
22073
22231
|
if (isRoot) {
|
|
22074
|
-
return issueAt(file, parsed, route.head, `root
|
|
22232
|
+
return issueAt(file, parsed, route.head, `The root layout must use defineRootRoute(), which has no parent layout:
|
|
22075
22233
|
import { defineRootRoute } from "@teyik0/furin";
|
|
22076
22234
|
export const route = defineRootRoute().config({ mode: "${mode}" })`);
|
|
22077
22235
|
}
|
|
22078
|
-
return issueAt(file, parsed, route.head, `defineRootRoute() is reserved for root.
|
|
22236
|
+
return issueAt(file, parsed, route.head, `defineRootRoute() is reserved for the root layout. Use defineRoute with this file's id:
|
|
22079
22237
|
import { defineRoute } from "@teyik0/furin";
|
|
22080
|
-
export const route = defineRoute("${
|
|
22238
|
+
export const route = defineRoute("${manifestRoute.id}").config({ mode: "${mode}" })`);
|
|
22081
22239
|
}
|
|
22082
22240
|
function checkConfig(file, parsed) {
|
|
22083
22241
|
const { route } = parsed;
|
|
@@ -22108,56 +22266,64 @@ function declaredParams(route) {
|
|
|
22108
22266
|
}
|
|
22109
22267
|
return new Set(keys.filter((key) => key !== undefined));
|
|
22110
22268
|
}
|
|
22111
|
-
function
|
|
22112
|
-
return
|
|
22113
|
-
const dynamic = parseDynamicRouteSegment(segment, file);
|
|
22114
|
-
return dynamic ? [{ key: dynamic.catchAll ? "*" : dynamic.name, segment }] : [];
|
|
22115
|
-
}).filter(({ key }) => declared !== true && !declared.has(key));
|
|
22269
|
+
function undeclaredParams(route, declared) {
|
|
22270
|
+
return route.params.filter(({ name }) => declared !== true && !declared.has(name));
|
|
22116
22271
|
}
|
|
22117
|
-
function paramsSchema(
|
|
22118
|
-
const fields =
|
|
22272
|
+
function paramsSchema(params) {
|
|
22273
|
+
const fields = params.map(({ name, optional }) => `${IDENTIFIER_RE.test(name) ? name : JSON.stringify(name)}: ${optional ? "t.Optional(t.String())" : "t.String()"}`);
|
|
22119
22274
|
return `params: t.Object({ ${fields.join(", ")} })`;
|
|
22120
22275
|
}
|
|
22121
|
-
function checkParams(file,
|
|
22122
|
-
const missing =
|
|
22276
|
+
function checkParams(file, route, parsed) {
|
|
22277
|
+
const missing = undeclaredParams(route, declaredParams(parsed.route));
|
|
22123
22278
|
if (missing.length === 0) {
|
|
22124
22279
|
return;
|
|
22125
22280
|
}
|
|
22126
22281
|
const plural = missing.length > 1;
|
|
22127
22282
|
const tImport = parsed.imports.get("t")?.specifier === "elysia" ? "" : `
|
|
22128
22283
|
import { t } from "elysia";`;
|
|
22129
|
-
return issueAt(file, parsed, parsed.route.config ?? parsed.route.head, `The
|
|
22284
|
+
return issueAt(file, parsed, parsed.route.config ?? parsed.route.head, `The path param${plural ? "s" : ""} ${missing.map(({ name }) => name).join(", ")} ${plural ? "are" : "is"} missing from this page's params schema. Each page declares every dynamic segment of its path, including those of its layouts. Add to config():${tImport}
|
|
22130
22285
|
${paramsSchema(missing)}`);
|
|
22131
22286
|
}
|
|
22132
|
-
function
|
|
22133
|
-
const
|
|
22287
|
+
function checkBoundaryMethods(file, instance, parsed) {
|
|
22288
|
+
const method = ["error", "notFound"].find((name) => parsed.route.methods.has(name));
|
|
22289
|
+
if (instance.style !== "nextjs" || method === undefined) {
|
|
22290
|
+
return;
|
|
22291
|
+
}
|
|
22292
|
+
const convention = method === "error" ? "an error.tsx" : "a not-found.tsx";
|
|
22293
|
+
return issueAt(file, parsed, parsed.route.head, `.${method}() is the TanStack style. In the nextjs style, default-export the component from ${convention} next to this route.`);
|
|
22294
|
+
}
|
|
22295
|
+
function checkRoute(file, instance, route, parsed) {
|
|
22296
|
+
const factory = checkFactory(file, route, parsed);
|
|
22134
22297
|
if (factory) {
|
|
22135
22298
|
return [factory];
|
|
22136
22299
|
}
|
|
22137
|
-
const isLayout = basename3(withoutExtension(file)) === "_route";
|
|
22138
22300
|
return [
|
|
22139
22301
|
checkConfig(file, parsed),
|
|
22140
|
-
|
|
22302
|
+
route === undefined ? undefined : checkKey(file, route, parsed),
|
|
22141
22303
|
checkMode(file, parsed),
|
|
22142
|
-
|
|
22304
|
+
route === undefined || route.kind === "layout" ? undefined : checkParams(file, route, parsed),
|
|
22305
|
+
checkBoundaryMethods(file, instance, parsed)
|
|
22143
22306
|
];
|
|
22144
22307
|
}
|
|
22145
|
-
function routeFiles(
|
|
22146
|
-
const
|
|
22147
|
-
|
|
22148
|
-
|
|
22149
|
-
|
|
22150
|
-
|
|
22308
|
+
function routeFiles(manifest) {
|
|
22309
|
+
const files = manifest.routes.map((route) => [
|
|
22310
|
+
resolve10(route.sourcePath),
|
|
22311
|
+
route
|
|
22312
|
+
]);
|
|
22313
|
+
if (existsSync11(manifest.rootPath)) {
|
|
22314
|
+
files.push([resolve10(manifest.rootPath), undefined]);
|
|
22315
|
+
}
|
|
22316
|
+
return files.toSorted(([left], [right]) => left.localeCompare(right));
|
|
22151
22317
|
}
|
|
22152
|
-
function validateRouteConfig(
|
|
22153
|
-
const instance = { pagesDir: resolve10(pagesDir)
|
|
22154
|
-
return routeFiles(instance
|
|
22318
|
+
function validateRouteConfig(spec) {
|
|
22319
|
+
const instance = { ...spec, pagesDir: resolve10(spec.pagesDir) };
|
|
22320
|
+
return routeFiles(scanRouteManifest(instance)).flatMap(([file, route]) => {
|
|
22155
22321
|
const parsed = parseRoute(file);
|
|
22156
|
-
return parsed ? checkRoute(file, instance, parsed).filter((issue) => issue !== undefined) : [];
|
|
22322
|
+
return parsed ? checkRoute(file, instance, route, parsed).filter((issue) => issue !== undefined) : [];
|
|
22157
22323
|
});
|
|
22158
22324
|
}
|
|
22159
22325
|
function displayPath2(file) {
|
|
22160
|
-
const projected =
|
|
22326
|
+
const projected = relative8(process.cwd(), file).replaceAll("\\", "/");
|
|
22161
22327
|
return projected.startsWith("../") ? file : projected;
|
|
22162
22328
|
}
|
|
22163
22329
|
function formatRouteConfigIssue(issue) {
|
|
@@ -22190,30 +22356,32 @@ function createRouteConfigReporter(instance, store) {
|
|
|
22190
22356
|
});
|
|
22191
22357
|
};
|
|
22192
22358
|
}
|
|
22193
|
-
function scaffoldTemplate(
|
|
22194
|
-
if (
|
|
22359
|
+
function scaffoldTemplate(route) {
|
|
22360
|
+
if (route === undefined) {
|
|
22195
22361
|
return ROOT_TEMPLATE;
|
|
22196
22362
|
}
|
|
22197
|
-
const isLayout =
|
|
22198
|
-
const params =
|
|
22363
|
+
const isLayout = route.kind === "layout";
|
|
22364
|
+
const { params } = route;
|
|
22199
22365
|
return `import { defineRoute } from "@teyik0/furin";${params.length > 0 ? `
|
|
22200
22366
|
import { t } from "elysia";` : ""}
|
|
22201
22367
|
|
|
22202
|
-
export const route = defineRoute("${
|
|
22368
|
+
export const route = defineRoute("${route.id}")
|
|
22203
22369
|
.config({ mode: "${isLayout ? "ssr" : "ssg"}"${params.length > 0 ? `, ${paramsSchema(params)}` : ""} })
|
|
22204
22370
|
.${isLayout ? "layout(({ children }) => children)" : "page(() => null)"};
|
|
22205
22371
|
`;
|
|
22206
22372
|
}
|
|
22207
|
-
function scaffoldEmptyRoutes(
|
|
22208
|
-
const instance = { pagesDir: resolve10(pagesDir)
|
|
22373
|
+
function scaffoldEmptyRoutes(spec) {
|
|
22374
|
+
const instance = { ...spec, pagesDir: resolve10(spec.pagesDir) };
|
|
22209
22375
|
const written = [];
|
|
22210
|
-
for (const file of routeFiles(instance
|
|
22211
|
-
|
|
22212
|
-
|
|
22376
|
+
for (const [file, route] of routeFiles(scanRouteManifest(instance))) {
|
|
22377
|
+
if (readSource(file)?.trim() === "") {
|
|
22378
|
+
writeFileSync(file, scaffoldTemplate(route));
|
|
22379
|
+
written.push(file);
|
|
22380
|
+
}
|
|
22213
22381
|
}
|
|
22214
22382
|
return written;
|
|
22215
22383
|
}
|
|
22216
|
-
var
|
|
22384
|
+
var IDENTIFIER_RE, ROUTE_CONFIG_DIAGNOSTIC = "route config", ROOT_TEMPLATE = `import { defineRootRoute, HeadContent, Scripts } from "@teyik0/furin";
|
|
22217
22385
|
|
|
22218
22386
|
export const route = defineRootRoute()
|
|
22219
22387
|
.config({ mode: "ssr" })
|
|
@@ -22231,13 +22399,10 @@ export const route = defineRootRoute()
|
|
|
22231
22399
|
`;
|
|
22232
22400
|
var init_route_config = __esm(() => {
|
|
22233
22401
|
init_lang_detect();
|
|
22234
|
-
init_patterns();
|
|
22235
22402
|
init_parser();
|
|
22236
22403
|
init_route_chains();
|
|
22237
|
-
|
|
22238
|
-
EXTENSION_RE = /\.(?:[cm]?[jt]sx?)$/;
|
|
22404
|
+
init_route_manifest();
|
|
22239
22405
|
IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/;
|
|
22240
|
-
PATH_SEPARATOR_RE = /[\\/]/;
|
|
22241
22406
|
});
|
|
22242
22407
|
|
|
22243
22408
|
// src/build/route-metadata.ts
|
|
@@ -22272,13 +22437,13 @@ var init_route_metadata = __esm(() => {
|
|
|
22272
22437
|
});
|
|
22273
22438
|
|
|
22274
22439
|
// src/rsc/build/paths.ts
|
|
22275
|
-
import { dirname as
|
|
22440
|
+
import { dirname as dirname10, join as join6 } from "path";
|
|
22276
22441
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
22277
22442
|
var SOURCE_DIR, CLIENT_REFERENCE_RUNTIME_PATH, BUNDLED_CLIENT_CODEC_PATH;
|
|
22278
22443
|
var init_paths = __esm(() => {
|
|
22279
|
-
SOURCE_DIR =
|
|
22280
|
-
CLIENT_REFERENCE_RUNTIME_PATH =
|
|
22281
|
-
BUNDLED_CLIENT_CODEC_PATH =
|
|
22444
|
+
SOURCE_DIR = dirname10(fileURLToPath4(import.meta.resolve("@teyik0/furin/rsc")));
|
|
22445
|
+
CLIENT_REFERENCE_RUNTIME_PATH = join6(SOURCE_DIR, "rsc/client-references.ts");
|
|
22446
|
+
BUNDLED_CLIENT_CODEC_PATH = join6(SOURCE_DIR, "rsc/bundled-client-codec.ts");
|
|
22282
22447
|
});
|
|
22283
22448
|
|
|
22284
22449
|
// src/shared/route-map.ts
|
|
@@ -22308,8 +22473,8 @@ ${body}
|
|
|
22308
22473
|
}
|
|
22309
22474
|
|
|
22310
22475
|
// src/build/route-types.ts
|
|
22311
|
-
import { existsSync as
|
|
22312
|
-
import { extname as extname3, join as
|
|
22476
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
22477
|
+
import { extname as extname3, join as join7, relative as relative9, resolve as resolve11 } from "path";
|
|
22313
22478
|
function tagKeyToPropertyName(tag) {
|
|
22314
22479
|
return /^[$A-Z_a-z][$\w]*$/.test(tag) ? tag : JSON.stringify(tag);
|
|
22315
22480
|
}
|
|
@@ -22320,38 +22485,19 @@ function tagToStringLiteral(tag) {
|
|
|
22320
22485
|
function importSpecifier(path, projectRoot) {
|
|
22321
22486
|
const extension = extname3(path);
|
|
22322
22487
|
const sourcePath = extension ? path.slice(0, -extension.length) : path;
|
|
22323
|
-
const relativePath =
|
|
22488
|
+
const relativePath = relative9(projectRoot, sourcePath).replaceAll("\\", "/");
|
|
22324
22489
|
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
22325
22490
|
}
|
|
22326
|
-
function fileRouteEntries(
|
|
22327
|
-
const
|
|
22328
|
-
const
|
|
22329
|
-
|
|
22330
|
-
const
|
|
22331
|
-
const
|
|
22332
|
-
return { base, path, relativePath, segments };
|
|
22333
|
-
});
|
|
22334
|
-
const layouts = new Map(files.filter(({ base }) => base === "_route").map((file) => [file.segments.join("/"), file.path]));
|
|
22335
|
-
return files.map(({ base, path, relativePath, segments }) => {
|
|
22336
|
-
const isLayout = base === "_route";
|
|
22337
|
-
let parent = join9(pages, "root.tsx");
|
|
22338
|
-
for (let depth = isLayout ? segments.length - 1 : segments.length;depth > 0; depth -= 1) {
|
|
22339
|
-
const layout = layouts.get(segments.slice(0, depth).join("/"));
|
|
22340
|
-
if (layout) {
|
|
22341
|
-
parent = layout;
|
|
22342
|
-
break;
|
|
22343
|
-
}
|
|
22344
|
-
}
|
|
22345
|
-
const pathParams = [...segments, base].flatMap((segment) => {
|
|
22346
|
-
const dynamic = parseDynamicRouteSegment(segment, path);
|
|
22347
|
-
return dynamic ? [dynamic.catchAll ? '"*": string' : `${dynamic.name}: string`] : [];
|
|
22348
|
-
});
|
|
22349
|
-
const id = fileRouteId({ pagesDir: pages, prefix }, path);
|
|
22350
|
-
const pattern = filePathToPattern(isLayout ? segments.concat("index").join("/") : relativePath);
|
|
22491
|
+
function fileRouteEntries(instance, projectRoot) {
|
|
22492
|
+
const { prefix } = instance;
|
|
22493
|
+
const manifest = scanRouteManifest({ ...instance, pagesDir: resolve11(instance.pagesDir) });
|
|
22494
|
+
return manifest.routes.map(({ id, kind, params, parentPath, pattern }) => {
|
|
22495
|
+
const parent = parentPath ?? manifest.rootPath;
|
|
22496
|
+
const pathParams = params.map(({ name, optional }) => `${name}${optional ? "?" : ""}: string`);
|
|
22351
22497
|
return {
|
|
22352
22498
|
id,
|
|
22353
22499
|
lines: ` ${JSON.stringify(id)}: {
|
|
22354
|
-
kind: "${
|
|
22500
|
+
kind: "${kind}";
|
|
22355
22501
|
pattern: ${JSON.stringify(`${prefix}${pattern === "/" ? "" : pattern}` || "/")};
|
|
22356
22502
|
parent: typeof import(${JSON.stringify(importSpecifier(parent, projectRoot))}).route;
|
|
22357
22503
|
pathParams: {${pathParams.length > 0 ? ` ${pathParams.join("; ")} ` : ""}};
|
|
@@ -22390,8 +22536,8 @@ import "@teyik0/furin/routes";
|
|
|
22390
22536
|
|
|
22391
22537
|
${apps === undefined ? "" : fileRoutesDeclaration(apps, projectRoot)}${routeMapDeclaration(entries)}${tagBlock}
|
|
22392
22538
|
`;
|
|
22393
|
-
const typesPath =
|
|
22394
|
-
const existing =
|
|
22539
|
+
const typesPath = join7(projectRoot, "furin-env.d.ts");
|
|
22540
|
+
const existing = existsSync12(typesPath) ? readFileSync9(typesPath, "utf8") : "";
|
|
22395
22541
|
if (content === existing) {
|
|
22396
22542
|
return false;
|
|
22397
22543
|
}
|
|
@@ -22401,8 +22547,7 @@ ${apps === undefined ? "" : fileRoutesDeclaration(apps, projectRoot)}${routeMapD
|
|
|
22401
22547
|
return true;
|
|
22402
22548
|
}
|
|
22403
22549
|
var init_route_types = __esm(() => {
|
|
22404
|
-
|
|
22405
|
-
init_patterns();
|
|
22550
|
+
init_route_manifest();
|
|
22406
22551
|
});
|
|
22407
22552
|
|
|
22408
22553
|
// src/build/shared.ts
|
|
@@ -22417,8 +22562,8 @@ var init_shared2 = __esm(() => {
|
|
|
22417
22562
|
});
|
|
22418
22563
|
|
|
22419
22564
|
// src/build/hydrate.ts
|
|
22420
|
-
import { existsSync as
|
|
22421
|
-
import {
|
|
22565
|
+
import { existsSync as existsSync13, mkdirSync, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
|
|
22566
|
+
import { join as join8 } from "path";
|
|
22422
22567
|
function generateClientReferenceEntry(boundaries) {
|
|
22423
22568
|
if (boundaries.length === 0) {
|
|
22424
22569
|
return "";
|
|
@@ -22470,11 +22615,13 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
|
|
|
22470
22615
|
continue;
|
|
22471
22616
|
}
|
|
22472
22617
|
const parts = [`depth: ${seg.depth}`];
|
|
22618
|
+
const errorExport = seg.fromRoute ? "route.errorComponent" : "default";
|
|
22619
|
+
const notFoundExport = seg.fromRoute ? "route.notFoundComponent" : "default";
|
|
22473
22620
|
if (errorIdent) {
|
|
22474
|
-
parts.push(`error: ${errorIdent}
|
|
22621
|
+
parts.push(`error: ${errorIdent}.${errorExport}`);
|
|
22475
22622
|
}
|
|
22476
22623
|
if (notFoundIdent) {
|
|
22477
|
-
parts.push(`notFound: ${notFoundIdent}
|
|
22624
|
+
parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
|
|
22478
22625
|
}
|
|
22479
22626
|
if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
|
|
22480
22627
|
parts.push("isRoot: false");
|
|
@@ -22817,8 +22964,8 @@ function releaseDevRouteTypes(projectRoot, prefix) {
|
|
|
22817
22964
|
function writeDevRouteTypes(projectRoot, prefix, app) {
|
|
22818
22965
|
const apps = devRouteTypesApps.get(projectRoot) ?? new Map;
|
|
22819
22966
|
devRouteTypesApps.set(projectRoot, apps.set(prefix, app));
|
|
22820
|
-
const live = [...apps].filter(([, { pagesDir }]) =>
|
|
22821
|
-
return writeRouteTypes(live.find(([appPrefix]) => appPrefix === "")?.[1].routes ?? [], projectRoot, live.map(([appPrefix, { pagesDir }]) => ({ pagesDir, prefix: appPrefix })));
|
|
22967
|
+
const live = [...apps].filter(([, { pagesDir }]) => existsSync13(pagesDir));
|
|
22968
|
+
return writeRouteTypes(live.find(([appPrefix]) => appPrefix === "")?.[1].routes ?? [], projectRoot, live.map(([appPrefix, { pagesDir, style }]) => ({ pagesDir, prefix: appPrefix, style })));
|
|
22822
22969
|
}
|
|
22823
22970
|
function writeDevFiles(routes, {
|
|
22824
22971
|
outDir,
|
|
@@ -22826,30 +22973,31 @@ function writeDevFiles(routes, {
|
|
|
22826
22973
|
basePath,
|
|
22827
22974
|
clientLogging,
|
|
22828
22975
|
clientBoundaries,
|
|
22976
|
+
pages,
|
|
22829
22977
|
prefix
|
|
22830
22978
|
}, projectRoot, serverSourceVersion) {
|
|
22831
|
-
if (!
|
|
22979
|
+
if (!existsSync13(outDir)) {
|
|
22832
22980
|
mkdirSync(outDir, { recursive: true });
|
|
22833
22981
|
}
|
|
22834
22982
|
const serverVersion = serverSourceVersion === undefined ? "" : `
|
|
22835
22983
|
if (import.meta.hot) import.meta.hot.data.furinServerSourceVersion = ${JSON.stringify(serverSourceVersion)};
|
|
22836
22984
|
`;
|
|
22837
22985
|
const hydrateCode = generateClientReferenceEntry(clientBoundaries ?? []) + generateHydrateEntry(routes, rootLayout, basePath, clientLogging) + serverVersion;
|
|
22838
|
-
const hydratePath =
|
|
22839
|
-
const existingHydrate =
|
|
22986
|
+
const hydratePath = join8(outDir, "_hydrate.tsx");
|
|
22987
|
+
const existingHydrate = existsSync13(hydratePath) ? readFileSync10(hydratePath, "utf8") : "";
|
|
22840
22988
|
let changed = false;
|
|
22841
22989
|
if (hydrateCode !== existingHydrate) {
|
|
22842
22990
|
writeFileSync3(hydratePath, hydrateCode);
|
|
22843
22991
|
changed = true;
|
|
22844
22992
|
}
|
|
22845
22993
|
const indexHtml = generateIndexHtml();
|
|
22846
|
-
const indexPath =
|
|
22847
|
-
const existingIndex =
|
|
22994
|
+
const indexPath = join8(outDir, "index.html");
|
|
22995
|
+
const existingIndex = existsSync13(indexPath) ? readFileSync10(indexPath, "utf8") : "";
|
|
22848
22996
|
if (indexHtml !== existingIndex) {
|
|
22849
22997
|
writeFileSync3(indexPath, indexHtml);
|
|
22850
22998
|
changed = true;
|
|
22851
22999
|
}
|
|
22852
|
-
changed = writeDevRouteTypes(projectRoot, prefix, {
|
|
23000
|
+
changed = writeDevRouteTypes(projectRoot, prefix, { ...pages, routes }) || changed;
|
|
22853
23001
|
if (changed) {
|
|
22854
23002
|
console.log("[furin] Dev files written (.furin/_hydrate.tsx + .furin/index.html + furin-env.d.ts)");
|
|
22855
23003
|
}
|
|
@@ -23142,7 +23290,7 @@ var init_discover = __esm(() => {
|
|
|
23142
23290
|
|
|
23143
23291
|
// src/plugin/hmr-dependencies.ts
|
|
23144
23292
|
import { readFileSync as readFileSync11 } from "fs";
|
|
23145
|
-
import { dirname as
|
|
23293
|
+
import { dirname as dirname11, isAbsolute as isAbsolute7, resolve as resolve12 } from "path";
|
|
23146
23294
|
function hmrDependencySignature(imports, filename) {
|
|
23147
23295
|
const routePath = resolve12(filename);
|
|
23148
23296
|
const visited = new Set;
|
|
@@ -23151,7 +23299,7 @@ function hmrDependencySignature(imports, filename) {
|
|
|
23151
23299
|
if (specifier === "furin" || specifier.startsWith("furin/") || specifier === "@teyik0/furin" || specifier.startsWith("@teyik0/furin/")) {
|
|
23152
23300
|
return true;
|
|
23153
23301
|
}
|
|
23154
|
-
const path = Bun.resolveSync(specifier,
|
|
23302
|
+
const path = Bun.resolveSync(specifier, dirname11(importer));
|
|
23155
23303
|
if (path === routePath) {
|
|
23156
23304
|
return false;
|
|
23157
23305
|
}
|
|
@@ -23318,21 +23466,18 @@ var exports_runtime = {};
|
|
|
23318
23466
|
__export(exports_runtime, {
|
|
23319
23467
|
createDevRuntime: () => createDevRuntime
|
|
23320
23468
|
});
|
|
23321
|
-
import { existsSync as
|
|
23322
|
-
import {
|
|
23469
|
+
import { existsSync as existsSync14, readFileSync as readFileSync12 } from "fs";
|
|
23470
|
+
import { join as join9, resolve as resolve13 } from "path";
|
|
23323
23471
|
import { staticPlugin as staticPlugin2 } from "@elysia/static";
|
|
23324
23472
|
import { Elysia as Elysia17, file as file2 } from "elysia";
|
|
23325
|
-
function wrapsRoute(sourcePath,
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
}
|
|
23329
|
-
const directory = dirname14(sourcePath).replaceAll("\\", "/");
|
|
23330
|
-
return routePath.replaceAll("\\", "/").startsWith(`${directory}/`);
|
|
23473
|
+
function wrapsRoute(sourcePath, route) {
|
|
23474
|
+
const normalized = sourcePath.replaceAll("\\", "/");
|
|
23475
|
+
return route.layouts.some(({ path }) => path.replaceAll("\\", "/") === normalized);
|
|
23331
23476
|
}
|
|
23332
23477
|
function repairedDevelopmentRoutes(snapshot, changedSources, graph) {
|
|
23333
23478
|
const patterns = new Set;
|
|
23334
23479
|
for (const route of snapshot.routes) {
|
|
23335
|
-
if (changedSources.some((sourcePath) => route.path === sourcePath || snapshot.root.path === sourcePath || graph.dependsOn(route.path, sourcePath) || wrapsRoute(sourcePath, route
|
|
23480
|
+
if (changedSources.some((sourcePath) => route.path === sourcePath || snapshot.root.path === sourcePath || graph.dependsOn(route.path, sourcePath) || wrapsRoute(sourcePath, route))) {
|
|
23336
23481
|
patterns.add(route.pattern);
|
|
23337
23482
|
}
|
|
23338
23483
|
}
|
|
@@ -23352,9 +23497,9 @@ function ownerAddsRouteHooks(app, owner) {
|
|
|
23352
23497
|
const mounted = anchor && owner.routes.find((route) => route.method === anchor.method && route.handler === anchor.handler && route.path.endsWith(anchor.path));
|
|
23353
23498
|
return mounted !== undefined && handlerPhaseHookCount(mounted.hooks) !== handlerPhaseHookCount(anchor?.hooks);
|
|
23354
23499
|
}
|
|
23355
|
-
async function loadDevelopmentRoutes(
|
|
23500
|
+
async function loadDevelopmentRoutes(routeInstance) {
|
|
23356
23501
|
await Promise.resolve().then(() => init_discovery());
|
|
23357
|
-
return scanPages(
|
|
23502
|
+
return scanPages(routeInstance);
|
|
23358
23503
|
}
|
|
23359
23504
|
function createDevelopmentRouteSnapshot(instance, root, routes) {
|
|
23360
23505
|
const searchRoutes = createSearchRouteMetadata(routes);
|
|
@@ -23365,7 +23510,7 @@ function createDevelopmentRouteSnapshot(instance, root, routes) {
|
|
|
23365
23510
|
routes
|
|
23366
23511
|
};
|
|
23367
23512
|
}
|
|
23368
|
-
async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
23513
|
+
async function createDevRuntime(instance, resolvedPagesDir, style, options) {
|
|
23369
23514
|
const { prefix, syncPath } = instance;
|
|
23370
23515
|
const { clientLogging, sync } = options;
|
|
23371
23516
|
const cwd = process.cwd();
|
|
@@ -23381,7 +23526,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23381
23526
|
registerDevPagePlugin();
|
|
23382
23527
|
await Promise.resolve().then(() => init_dev_routes());
|
|
23383
23528
|
await Promise.resolve().then(() => init_route_tree());
|
|
23384
|
-
const routeInstance = { pagesDir: resolvedPagesDir, prefix };
|
|
23529
|
+
const routeInstance = { pagesDir: resolvedPagesDir, prefix, style };
|
|
23385
23530
|
registerDevRoutesPlugin([routeInstance]);
|
|
23386
23531
|
await Promise.resolve().then(() => init_route_config());
|
|
23387
23532
|
const reportRouteConfig = createRouteConfigReporter(routeInstance, devDiagnosticStore(instance));
|
|
@@ -23389,7 +23534,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23389
23534
|
const graph = devGraph(instance);
|
|
23390
23535
|
const { nativeRoutesApp, root, routes } = await withInstance(instance, async () => {
|
|
23391
23536
|
const { furinShell } = await import(routeModuleSpecifier(routeInstance));
|
|
23392
|
-
const loaded = await loadDevelopmentRoutes(
|
|
23537
|
+
const loaded = await loadDevelopmentRoutes(routeInstance);
|
|
23393
23538
|
return { nativeRoutesApp: furinShell, ...loaded };
|
|
23394
23539
|
});
|
|
23395
23540
|
const initialSnapshot = createDevelopmentRouteSnapshot(instance, root, routes);
|
|
@@ -23470,6 +23615,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23470
23615
|
clientLogging: clientLogging ?? false,
|
|
23471
23616
|
clientBoundaries,
|
|
23472
23617
|
outDir: furinDir,
|
|
23618
|
+
pages: { pagesDir: resolvedPagesDir, style },
|
|
23473
23619
|
publicPath: `${prefix}/_client/`,
|
|
23474
23620
|
prefix,
|
|
23475
23621
|
rootLayout: snapshot.root.path
|
|
@@ -23478,13 +23624,13 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23478
23624
|
await writeCurrentDevFiles(initialSnapshot, []);
|
|
23479
23625
|
graph.commit(initialSnapshot);
|
|
23480
23626
|
reportRouteConfig();
|
|
23481
|
-
const hmrEntry = (await import(
|
|
23627
|
+
const hmrEntry = (await import(join9(furinDir, "index.html"))).default;
|
|
23482
23628
|
const refreshDevelopmentRoutes = (changedSources) => withInstance(instance, async () => {
|
|
23483
23629
|
invalidateStampedRouteModules();
|
|
23484
23630
|
try {
|
|
23485
23631
|
const previousSnapshot = currentSnapshot();
|
|
23486
23632
|
const repaired = repairedDevelopmentRoutes(previousSnapshot, changedSources, graph);
|
|
23487
|
-
const next = await loadDevelopmentRoutes(
|
|
23633
|
+
const next = await loadDevelopmentRoutes(routeInstance);
|
|
23488
23634
|
const nextRoutes = next.routes.map((route) => route.routeChain.length > 0 ? route : {
|
|
23489
23635
|
...route,
|
|
23490
23636
|
tags: previousSnapshot.routes.find((previous) => previous.path === route.path)?.tags
|
|
@@ -23508,7 +23654,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23508
23654
|
}
|
|
23509
23655
|
} catch (error) {
|
|
23510
23656
|
publishDevDiagnostic(error, {
|
|
23511
|
-
entryPath:
|
|
23657
|
+
entryPath: currentSnapshot().root.path,
|
|
23512
23658
|
phase: "import",
|
|
23513
23659
|
route: "*"
|
|
23514
23660
|
});
|
|
@@ -23516,7 +23662,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23516
23662
|
}
|
|
23517
23663
|
});
|
|
23518
23664
|
const publicDir = resolve13(cwd, "public");
|
|
23519
|
-
const publicExists =
|
|
23665
|
+
const publicExists = existsSync14(publicDir);
|
|
23520
23666
|
const publicAssets = publicExists ? await staticPlugin2({ assets: publicDir, prefix: "/public" }) : new Elysia17;
|
|
23521
23667
|
const browserEvents = (await Promise.resolve().then(() => (init_plugin2(), exports_plugin))).createBrowserEventsPlugin({
|
|
23522
23668
|
development: instance.development,
|
|
@@ -23537,7 +23683,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23537
23683
|
reportRouteConfig();
|
|
23538
23684
|
},
|
|
23539
23685
|
onSourceError: (error, sourcePath) => {
|
|
23540
|
-
const route = currentSnapshot().routes.find((candidate) => graph.dependsOn(candidate.path, sourcePath) || wrapsRoute(sourcePath, candidate
|
|
23686
|
+
const route = currentSnapshot().routes.find((candidate) => graph.dependsOn(candidate.path, sourcePath) || wrapsRoute(sourcePath, candidate));
|
|
23541
23687
|
withInstance(instance, () => publishDevDiagnostic(error, {
|
|
23542
23688
|
entryPath: route ? route.path : sourcePath,
|
|
23543
23689
|
phase: "transform",
|
|
@@ -23559,12 +23705,12 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23559
23705
|
routeTopologyWatcher?.close();
|
|
23560
23706
|
routeTopologyWatcher = undefined;
|
|
23561
23707
|
watcherOwner = undefined;
|
|
23562
|
-
}).get("/_bun_hmr_entry/index.html", hmrEntry).get("/_bun_hmr_entry", hmrEntry).use(options.requestHooks).use(publicAssets).get("/favicon.ico", publicExists ? file2(
|
|
23708
|
+
}).get("/_bun_hmr_entry/index.html", hmrEntry).get("/_bun_hmr_entry", hmrEntry).use(options.requestHooks).use(publicAssets).get("/favicon.ico", publicExists ? file2(join9(publicDir, "favicon.ico")) : () => new Response(null, { status: 404 })).use(browserEvents).use(createDevDiagnosticPlugin(devDiagnosticStore(instance), instance, async () => {
|
|
23563
23709
|
await routeTopologyWatcher?.refresh();
|
|
23564
23710
|
})).use(createInstrumentationPlugin(() => currentSnapshot().routes, syncPath))
|
|
23565
23711
|
};
|
|
23566
23712
|
}
|
|
23567
|
-
var
|
|
23713
|
+
var HANDLER_PHASE_HOOKS;
|
|
23568
23714
|
var init_runtime2 = __esm(() => {
|
|
23569
23715
|
init_prefix();
|
|
23570
23716
|
init_dev_loader();
|
|
@@ -23574,13 +23720,12 @@ var init_runtime2 = __esm(() => {
|
|
|
23574
23720
|
init_hmr();
|
|
23575
23721
|
init_patterns();
|
|
23576
23722
|
init_schemas();
|
|
23577
|
-
LAYOUT_FILE_RE = /^_route\.[cm]?[jt]sx?$/;
|
|
23578
23723
|
HANDLER_PHASE_HOOKS = ["transform", "beforeHandle", "afterHandle"];
|
|
23579
23724
|
});
|
|
23580
23725
|
|
|
23581
23726
|
// src/furin.ts
|
|
23582
23727
|
init_define_route();
|
|
23583
|
-
import { dirname as
|
|
23728
|
+
import { dirname as dirname12, resolve as resolve14 } from "path";
|
|
23584
23729
|
import { Elysia as Elysia18, NotFound as NotFound2 } from "elysia";
|
|
23585
23730
|
|
|
23586
23731
|
// src/server/cache/invalidation.ts
|
|
@@ -23796,13 +23941,13 @@ function createLoggerPlugin(instance, logger, clientLogging) {
|
|
|
23796
23941
|
|
|
23797
23942
|
// src/server/prod/runtime.ts
|
|
23798
23943
|
import { existsSync as existsSync5 } from "fs";
|
|
23799
|
-
import { join as
|
|
23944
|
+
import { join as join3 } from "path";
|
|
23800
23945
|
import { Elysia as Elysia12 } from "elysia";
|
|
23801
23946
|
|
|
23802
23947
|
// src/server/assets/client-dir.ts
|
|
23803
23948
|
init_prefix();
|
|
23804
23949
|
import { existsSync } from "fs";
|
|
23805
|
-
import { basename as basename2, delimiter, dirname as
|
|
23950
|
+
import { basename as basename2, delimiter, dirname as dirname2, join, resolve as resolve4 } from "path";
|
|
23806
23951
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
23807
23952
|
function resolveClientDirFromArgv(prefix) {
|
|
23808
23953
|
const dirName = clientDirNameForPrefix(prefix);
|
|
@@ -23814,7 +23959,7 @@ function resolveClientDirFromEnv(dirName) {
|
|
|
23814
23959
|
return null;
|
|
23815
23960
|
}
|
|
23816
23961
|
const base = envClientDir.startsWith("/") ? envClientDir : resolve4(process.cwd(), envClientDir);
|
|
23817
|
-
return dirName === "client" ? base : join(
|
|
23962
|
+
return dirName === "client" ? base : join(dirname2(base), dirName);
|
|
23818
23963
|
}
|
|
23819
23964
|
function resolveClientDirFromModuleUrl(dirName) {
|
|
23820
23965
|
try {
|
|
@@ -23826,7 +23971,7 @@ function resolveClientDirFromModuleUrl(dirName) {
|
|
|
23826
23971
|
if (modulePath.includes("/$bunfs/")) {
|
|
23827
23972
|
return null;
|
|
23828
23973
|
}
|
|
23829
|
-
const moduleClientDir = join(
|
|
23974
|
+
const moduleClientDir = join(dirname2(modulePath), dirName);
|
|
23830
23975
|
if (existsSync(join(moduleClientDir, "index.html"))) {
|
|
23831
23976
|
return moduleClientDir;
|
|
23832
23977
|
}
|
|
@@ -23858,7 +24003,7 @@ function resolveClientDirFromCandidate(candidate, dirName) {
|
|
|
23858
24003
|
}
|
|
23859
24004
|
const absolute = candidate.startsWith("/") ? candidate : resolve4(process.cwd(), candidate);
|
|
23860
24005
|
if (existsSync(absolute)) {
|
|
23861
|
-
const clientDir = join(
|
|
24006
|
+
const clientDir = join(dirname2(absolute), dirName);
|
|
23862
24007
|
if (existsSync(join(clientDir, "index.html"))) {
|
|
23863
24008
|
return clientDir;
|
|
23864
24009
|
}
|
|
@@ -23873,7 +24018,7 @@ function resolveClientDirFromPath(candidate, dirName) {
|
|
|
23873
24018
|
for (const dir of pathEntries) {
|
|
23874
24019
|
const fullPath = join(dir, candidate);
|
|
23875
24020
|
if (existsSync(fullPath)) {
|
|
23876
|
-
const clientDir = join(
|
|
24021
|
+
const clientDir = join(dirname2(fullPath), dirName);
|
|
23877
24022
|
if (existsSync(join(clientDir, "index.html"))) {
|
|
23878
24023
|
return clientDir;
|
|
23879
24024
|
}
|
|
@@ -23891,12 +24036,12 @@ function resolveFallbackClientDir(dirName) {
|
|
|
23891
24036
|
|
|
23892
24037
|
// src/server/assets/production.ts
|
|
23893
24038
|
import { existsSync as existsSync2 } from "fs";
|
|
23894
|
-
import { dirname as
|
|
24039
|
+
import { dirname as dirname3, isAbsolute as isAbsolute3, join as join2, relative as relative4, resolve as resolve5, sep } from "path";
|
|
23895
24040
|
import { staticPlugin } from "@elysia/static";
|
|
23896
24041
|
import { Elysia as Elysia11, file } from "elysia";
|
|
23897
24042
|
function resolveEmbeddedAssetPath(directory, requestPath) {
|
|
23898
24043
|
const assetPath = resolve5(directory, requestPath);
|
|
23899
|
-
const pathFromDirectory =
|
|
24044
|
+
const pathFromDirectory = relative4(directory, assetPath);
|
|
23900
24045
|
if (pathFromDirectory === "" || pathFromDirectory === ".." || pathFromDirectory.startsWith(`..${sep}`) || isAbsolute3(pathFromDirectory)) {
|
|
23901
24046
|
return null;
|
|
23902
24047
|
}
|
|
@@ -23948,7 +24093,7 @@ async function createProductionAssetsPlugin(ctx, embedded, clientDir) {
|
|
|
23948
24093
|
if (embedded) {
|
|
23949
24094
|
return createEmbeddedAssetsPlugin(embedded);
|
|
23950
24095
|
}
|
|
23951
|
-
const publicDir = join2(
|
|
24096
|
+
const publicDir = join2(dirname3(clientDir), "public");
|
|
23952
24097
|
const publicAssets = existsSync2(publicDir) ? new Elysia11().get("/favicon.ico", file(join2(publicDir, "favicon.ico"))).use(await staticPlugin({ assets: publicDir, prefix: "/public" })) : new Elysia11;
|
|
23953
24098
|
return publicAssets.use(await staticPlugin({
|
|
23954
24099
|
assets: clientDir,
|
|
@@ -23993,7 +24138,7 @@ async function createProductionBrowserEventsPlugin(sync, websocket, development)
|
|
|
23993
24138
|
}
|
|
23994
24139
|
async function setupProdTemplate(embedded, clientDir, instance) {
|
|
23995
24140
|
if (embedded) {
|
|
23996
|
-
const templatePath =
|
|
24141
|
+
const templatePath = join3(embedded.clientDir, "index.html");
|
|
23997
24142
|
if (!existsSync5(templatePath)) {
|
|
23998
24143
|
throw new Error("[furin] Embedded app is missing its HTML template (index.html).");
|
|
23999
24144
|
}
|
|
@@ -24001,7 +24146,7 @@ async function setupProdTemplate(embedded, clientDir, instance) {
|
|
|
24001
24146
|
setProductionTemplateContent(html, instance);
|
|
24002
24147
|
return;
|
|
24003
24148
|
}
|
|
24004
|
-
const templatePath =
|
|
24149
|
+
const templatePath = join3(clientDir, "index.html");
|
|
24005
24150
|
if (!existsSync5(templatePath)) {
|
|
24006
24151
|
throw new Error("[furin] No pre-built assets found. Run `bun run build` first.");
|
|
24007
24152
|
}
|
|
@@ -25447,6 +25592,10 @@ function AwaitInner({ resolve, children }) {
|
|
|
25447
25592
|
// src/furin.ts
|
|
25448
25593
|
init_defer();
|
|
25449
25594
|
init_not_found();
|
|
25595
|
+
var DEFAULT_PAGES_DIRS = {
|
|
25596
|
+
nextjs: "src/app",
|
|
25597
|
+
tanstack: "src/routes"
|
|
25598
|
+
};
|
|
25450
25599
|
function configurePageCache(instance, ctx, pageCache) {
|
|
25451
25600
|
if (pageCache !== undefined && ctx?.adapter?.capabilities.publicCache === "platform") {
|
|
25452
25601
|
throw new Error(`[furin] pageCache cannot be configured with the ${JSON.stringify(ctx.adapter.name)} adapter: its platform caches public SSG, ISR, and PPR pages.`);
|
|
@@ -25490,13 +25639,14 @@ async function createFurinApp(options) {
|
|
|
25490
25639
|
logger,
|
|
25491
25640
|
pageCache,
|
|
25492
25641
|
pagesDir,
|
|
25642
|
+
style,
|
|
25493
25643
|
sync
|
|
25494
25644
|
} = options;
|
|
25495
25645
|
const prefix = normalizePrefix(options.prefix);
|
|
25496
25646
|
const cwd = process.cwd();
|
|
25497
|
-
const paramPagesDir = resolve14(cwd, pagesDir ??
|
|
25647
|
+
const paramPagesDir = resolve14(cwd, pagesDir ?? DEFAULT_PAGES_DIRS[style]);
|
|
25498
25648
|
const ctx = getCompileContext(paramPagesDir, prefix);
|
|
25499
|
-
const resolvedPagesDir = ctx?.rootPath ?
|
|
25649
|
+
const resolvedPagesDir = ctx?.rootPath ? dirname12(ctx.rootPath) : paramPagesDir;
|
|
25500
25650
|
const normalizedPagesDir = resolvedPagesDir.replaceAll("\\", "/");
|
|
25501
25651
|
const instance = createInstance(prefix, normalizedPagesDir);
|
|
25502
25652
|
instance.syncPath = resolveSyncPath(sync);
|
|
@@ -25519,7 +25669,7 @@ async function createFurinApp(options) {
|
|
|
25519
25669
|
}),
|
|
25520
25670
|
sync: sync || undefined
|
|
25521
25671
|
};
|
|
25522
|
-
const mode = development ? await (await Promise.resolve().then(() => (init_runtime2(), exports_runtime))).createDevRuntime(instance, resolvedPagesDir, modeOptions) : await createProdRuntime(instance, ctx, clientDir, modeOptions);
|
|
25672
|
+
const mode = development ? await (await Promise.resolve().then(() => (init_runtime2(), exports_runtime))).createDevRuntime(instance, resolvedPagesDir, style, modeOptions) : await createProdRuntime(instance, ctx, clientDir, modeOptions);
|
|
25523
25673
|
const app = new Elysia18({
|
|
25524
25674
|
name: `furin-${prefix}-${normalizedPagesDir}`,
|
|
25525
25675
|
prefix: prefix || undefined,
|
|
@@ -25538,14 +25688,18 @@ async function createFurinApp(options) {
|
|
|
25538
25688
|
}
|
|
25539
25689
|
var mountedPrefixes = new WeakMap;
|
|
25540
25690
|
async function furin(options) {
|
|
25691
|
+
if (options.style !== "nextjs" && options.style !== "tanstack") {
|
|
25692
|
+
throw new Error(`[furin] furin() requires style: "nextjs" or "tanstack", received ${JSON.stringify(options.style)}.`);
|
|
25693
|
+
}
|
|
25541
25694
|
const registration = {
|
|
25542
|
-
pagesDir: options
|
|
25543
|
-
prefix: normalizePrefix(options
|
|
25695
|
+
pagesDir: options.pagesDir ?? DEFAULT_PAGES_DIRS[options.style],
|
|
25696
|
+
prefix: normalizePrefix(options.prefix),
|
|
25697
|
+
style: options.style
|
|
25544
25698
|
};
|
|
25545
25699
|
if (recordFurinRegistration(registration)) {
|
|
25546
25700
|
return (parentApp) => parentApp;
|
|
25547
25701
|
}
|
|
25548
|
-
const { app, hasSync, instance } = await createFurinApp(options
|
|
25702
|
+
const { app, hasSync, instance } = await createFurinApp(options);
|
|
25549
25703
|
let mounted = false;
|
|
25550
25704
|
return (parentApp) => {
|
|
25551
25705
|
if (mounted) {
|