@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.
Files changed (100) hide show
  1. package/README.md +1 -1
  2. package/dist/adapter/runtime-build.d.ts +7 -3
  3. package/dist/adapter/vercel.js +31 -6
  4. package/dist/build/client.d.ts +1 -1
  5. package/dist/build/entry-template.d.ts +3 -12
  6. package/dist/build/entry-template.ts +3 -15
  7. package/dist/build/hydrate.d.ts +6 -1
  8. package/dist/build/index.d.ts +1 -1
  9. package/dist/build/index.js +565 -401
  10. package/dist/build/route-metadata.d.ts +2 -2
  11. package/dist/build/route-types.d.ts +1 -1
  12. package/dist/build/types.d.ts +10 -4
  13. package/dist/cli/dev-worker.ts +10 -4
  14. package/dist/cli/index.js +624 -445
  15. package/dist/client/chunks/{client-xy6g38kx.js → client-a7spxfnn.js} +24 -5
  16. package/dist/client/chunks/{client-rjhxgt64.js → client-d9v49jwz.js} +1 -1
  17. package/dist/client/chunks/{client-k29262a4.js → client-rdxyrw11.js} +1 -1
  18. package/dist/client/define-route.d.ts +14 -0
  19. package/dist/client/internal/runtime-types.d.ts +8 -0
  20. package/dist/client/link.js +20 -17
  21. package/dist/client/router/link-utils.d.ts +3 -2
  22. package/dist/client/router/search/index.js +2 -2
  23. package/dist/client/router/types.d.ts +9 -3
  24. package/dist/client.js +22 -6
  25. package/dist/config.d.ts +4 -0
  26. package/dist/config.js +4 -1
  27. package/dist/define-route.d.ts +53 -12
  28. package/dist/furin.d.ts +13 -3
  29. package/dist/furin.js +815 -661
  30. package/dist/plugin/route-config.d.ts +3 -3
  31. package/dist/plugin/route-manifest.d.ts +46 -0
  32. package/dist/plugin/route-tree.d.ts +13 -29
  33. package/dist/routes.d.ts +2 -2
  34. package/dist/server/dev/runtime.d.ts +2 -1
  35. package/dist/server/internal.d.ts +6 -0
  36. package/dist/server/internal.js +97 -114
  37. package/dist/server/registrations.d.ts +4 -2
  38. package/dist/server/render/index.d.ts +0 -1
  39. package/dist/server/render/index.ts +0 -1
  40. package/dist/server/render/shell.d.ts +1 -13
  41. package/dist/server/render/shell.ts +1 -90
  42. package/dist/server/router/defined-route.d.ts +4 -0
  43. package/dist/server/router/discovery.d.ts +14 -4
  44. package/dist/server/router/hmr.d.ts +12 -12
  45. package/dist/server/router/patterns.d.ts +4 -12
  46. package/dist/server/router/types.d.ts +16 -1
  47. package/dist/server/static-export.js +128 -158
  48. package/dist/server/sync/drizzle/index.d.ts +8 -10
  49. package/dist/shared/not-found.d.ts +1 -1
  50. package/dist/shared/route-specificity.d.ts +10 -1
  51. package/package.json +8 -11
  52. package/src/adapter/package.ts +11 -37
  53. package/src/adapter/runtime-build.ts +5 -4
  54. package/src/adapter/static.ts +1 -1
  55. package/src/adapter/vercel.ts +2 -1
  56. package/src/build/client.ts +3 -3
  57. package/src/build/discover-pages-process.ts +1 -1
  58. package/src/build/elysia-aot.ts +2 -2
  59. package/src/build/entry-template.ts +3 -15
  60. package/src/build/hydrate.ts +12 -6
  61. package/src/build/index.ts +19 -9
  62. package/src/build/route-metadata.ts +15 -8
  63. package/src/build/route-types.ts +18 -43
  64. package/src/build/types.ts +12 -5
  65. package/src/cli/config.ts +6 -0
  66. package/src/cli/dev-worker.ts +10 -4
  67. package/src/cli/dev.ts +41 -26
  68. package/src/cli/index.ts +30 -14
  69. package/src/client/define-route.ts +29 -4
  70. package/src/client/internal/runtime-types.ts +8 -0
  71. package/src/client/link.tsx +21 -22
  72. package/src/client/router/context.ts +8 -7
  73. package/src/client/router/link-utils.ts +16 -8
  74. package/src/client/router/provider.tsx +5 -0
  75. package/src/client/router/types.ts +40 -14
  76. package/src/config.ts +5 -0
  77. package/src/define-route.ts +85 -16
  78. package/src/furin.ts +31 -7
  79. package/src/plugin/dev-routes.ts +8 -17
  80. package/src/plugin/route-config.ts +77 -62
  81. package/src/plugin/route-manifest.ts +437 -0
  82. package/src/plugin/route-modules.ts +6 -1
  83. package/src/plugin/route-registry.ts +7 -21
  84. package/src/plugin/route-tree.ts +71 -181
  85. package/src/routes.ts +2 -2
  86. package/src/server/dev/runtime.ts +16 -22
  87. package/src/server/internal.ts +4 -1
  88. package/src/server/registrations.ts +5 -2
  89. package/src/server/render/index.ts +0 -1
  90. package/src/server/render/shell.ts +1 -90
  91. package/src/server/render/static-params.ts +2 -10
  92. package/src/server/router/defined-route.ts +8 -0
  93. package/src/server/router/discovery.ts +237 -196
  94. package/src/server/router/hmr.ts +45 -63
  95. package/src/server/router/patterns.ts +41 -117
  96. package/src/server/router/types.ts +17 -1
  97. package/src/server/sync/drizzle/index.ts +18 -19
  98. package/src/shared/not-found.ts +1 -1
  99. package/src/shared/route-specificity.ts +34 -2
  100. package/src/shared/utils/index.ts +1 -1
@@ -1,11 +1,11 @@
1
1
  // @bun
2
2
  // src/build/index.ts
3
3
  import { existsSync as existsSync18, writeFileSync as writeFileSync13 } from "fs";
4
- import { join as join23, relative as relative16, resolve as resolve13 } from "path";
4
+ import { join as join21, relative as relative15, resolve as resolve13 } from "path";
5
5
 
6
6
  // src/adapter/build.ts
7
7
  import { existsSync as existsSync12, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
8
- import { basename as basename5, extname as extname3, join as join15, relative as relative10 } from "path";
8
+ import { basename as basename5, extname as extname3, join as join14, relative as relative9 } from "path";
9
9
 
10
10
  // src/build/bun-build.ts
11
11
  var PRODUCTION_DEFINE = { "process.env.NODE_ENV": JSON.stringify("production") };
@@ -184,7 +184,7 @@ function segmentSpecificity(segment) {
184
184
  }
185
185
  return segment.startsWith(":") ? 2 : 3;
186
186
  }
187
- function compareRouteSpecificity(a, b) {
187
+ function compareConcreteSpecificity(a, b) {
188
188
  const aSegments = a.split("/").filter(Boolean);
189
189
  const bSegments = b.split("/").filter(Boolean);
190
190
  const length = Math.max(aSegments.length, bSegments.length);
@@ -204,6 +204,24 @@ function compareRouteSpecificity(a, b) {
204
204
  }
205
205
  return 0;
206
206
  }
207
+ function expandOptionalSegments(pattern) {
208
+ let variants = [[]];
209
+ for (const segment of pattern.split("/").filter(Boolean)) {
210
+ if (segment.startsWith(":") && segment.endsWith("?")) {
211
+ const required = segment.slice(0, -1);
212
+ variants = variants.flatMap((variant) => [variant, [...variant, required]]);
213
+ } else {
214
+ variants = variants.map((variant) => [...variant, segment]);
215
+ }
216
+ }
217
+ return variants.map((variant) => `/${variant.join("/")}`);
218
+ }
219
+ function mostSpecificVariant(pattern) {
220
+ return expandOptionalSegments(pattern).reduce((best, variant) => compareConcreteSpecificity(variant, best) > 0 ? variant : best);
221
+ }
222
+ function compareRouteSpecificity(a, b) {
223
+ return compareConcreteSpecificity(mostSpecificVariant(a), mostSpecificVariant(b));
224
+ }
207
225
 
208
226
  // src/shared/search-params.ts
209
227
  function isObject(value) {
@@ -352,7 +370,6 @@ function normalizePrefix(prefix) {
352
370
  }
353
371
 
354
372
  // src/server/router/patterns.ts
355
- import { parse } from "path";
356
373
  function resolveRouteRevalidate(page) {
357
374
  return page.revalidate ?? page._route.revalidate;
358
375
  }
@@ -372,60 +389,7 @@ function resolveDocumentRevalidate(route) {
372
389
  }
373
390
  return Math.min(...intervals);
374
391
  }
375
- var DYNAMIC_PARAMETER_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
376
- function parseDynamicRouteSegment(segment, sourcePath) {
377
- if (!(segment.startsWith("[") && segment.endsWith("]"))) {
378
- return;
379
- }
380
- const inner = segment.slice(1, -1);
381
- const catchAll = inner.startsWith("...");
382
- const name = catchAll ? inner.slice(3) : inner;
383
- if (!DYNAMIC_PARAMETER_NAME_RE.test(name)) {
384
- throw new Error(`[furin] Invalid dynamic parameter ${JSON.stringify(name)} in ${JSON.stringify(sourcePath ?? segment)}. Parameter names must match ${DYNAMIC_PARAMETER_NAME_RE}.`);
385
- }
386
- return { catchAll, name };
387
- }
388
- function routeSegmentToPattern(segment) {
389
- const dynamic = parseDynamicRouteSegment(segment, undefined);
390
- if (!dynamic) {
391
- return segment;
392
- }
393
- return dynamic.catchAll ? "*" : `:${dynamic.name}`;
394
- }
395
- var ROUTE_GROUP_RE = /^\([^()]+\)$/;
396
- function isRouteGroup(segment) {
397
- return ROUTE_GROUP_RE.test(segment);
398
- }
399
- var DYNAMIC_ROUTE_SEGMENT_RE = /(^|\/):[^/]+/g;
400
- function routePatternKey(pattern) {
401
- return pattern.replace(DYNAMIC_ROUTE_SEGMENT_RE, "$1:param");
402
- }
403
- function filePathToPattern(path) {
404
- const parts = path.replaceAll("\\", "/").split("/");
405
- const segments = [];
406
- const lastIndex = parts.length - 1;
407
- for (let idx = 0;idx < parts.length; idx += 1) {
408
- const part = parts[idx];
409
- if (part === undefined || part.length === 0) {
410
- continue;
411
- }
412
- const isFile = idx === lastIndex;
413
- const name = isFile ? parse(part).name : part;
414
- if (!isFile && isRouteGroup(name)) {
415
- continue;
416
- }
417
- if (isFile && name === "index") {
418
- continue;
419
- }
420
- const dynamic = parseDynamicRouteSegment(name, path);
421
- if (dynamic) {
422
- segments.push(dynamic.catchAll ? "*" : `:${dynamic.name}`);
423
- } else {
424
- segments.push(name);
425
- }
426
- }
427
- return `/${segments.join("/")}`;
428
- }
392
+ var SPLAT_PARAM = "_splat";
429
393
  var REGEX_META_CHARS_RE = /[.*+?^${}()|[\]\\]/g;
430
394
  function escapeRegExp(value) {
431
395
  return value.replace(REGEX_META_CHARS_RE, "\\$&");
@@ -441,11 +405,17 @@ function routePatternRegexSource(pattern, sources) {
441
405
  while (i < pattern.length && pattern[i] !== "/") {
442
406
  i += 1;
443
407
  }
444
- paramNames.push(pattern.slice(start, i));
445
- source += sources.param;
408
+ const name = pattern.slice(start, i);
409
+ if (name.endsWith("?") && source.endsWith("/")) {
410
+ paramNames.push(name.slice(0, -1));
411
+ source = `${source.slice(0, -1)}(?:/${sources.param})?`;
412
+ } else {
413
+ paramNames.push(name);
414
+ source += sources.param;
415
+ }
446
416
  } else if (pattern[i] === "*") {
447
- paramNames.push("*");
448
- source += sources.catchAll;
417
+ paramNames.push(SPLAT_PARAM);
418
+ source = source.endsWith("/") ? `${source.slice(0, -1)}(?:/${sources.catchAll})?` : source + sources.catchAll;
449
419
  i += 1;
450
420
  } else {
451
421
  const ch = pattern[i];
@@ -1768,18 +1738,19 @@ function movePrivateServerSourceMaps(outputDir, privateDir, filenames) {
1768
1738
 
1769
1739
  // src/build/server-app-entry.ts
1770
1740
  import { writeFileSync as writeFileSync2 } from "fs";
1771
- import { join as join7 } from "path";
1741
+ import { join as join6 } from "path";
1772
1742
 
1773
1743
  // src/plugin/route-registry.ts
1774
- import { dirname as dirname5, join as join6, resolve as resolve2 } from "path";
1744
+ import { dirname as dirname5, join as join5, resolve as resolve2 } from "path";
1775
1745
 
1776
1746
  // src/plugin/route-modules.ts
1777
1747
  import { existsSync as existsSync5, readFileSync, realpathSync, statSync } from "fs";
1778
1748
  import { dirname as dirname4, isAbsolute as isAbsolute2, join as join4, relative as relative3, sep } from "path";
1779
1749
  import { pathToFileURL } from "url";
1780
1750
  var ROUTE_MODULE_CACHE_SYMBOL = Symbol.for("@teyik0/furin/route-module-cache");
1751
+ var OPTIONAL_MARK = /\?$/;
1781
1752
  function validateRouteParams(path, schemas) {
1782
- const pathParams = path.split("/").filter((segment) => segment === "*" || segment.startsWith(":")).map((segment) => segment === "*" ? segment : segment.slice(1));
1753
+ const pathParams = path.split("/").filter((segment) => segment === "*" || segment.startsWith(":")).map((segment) => segment === "*" ? SPLAT_PARAM : segment.slice(1).replace(OPTIONAL_MARK, ""));
1783
1754
  if (pathParams.length === 0) {
1784
1755
  return;
1785
1756
  }
@@ -1895,118 +1866,342 @@ async function validateRouteModules(routeFiles) {
1895
1866
  }
1896
1867
 
1897
1868
  // src/plugin/route-tree.ts
1869
+ import { resolve } from "path";
1870
+
1871
+ // src/plugin/route-manifest.ts
1898
1872
  import { existsSync as existsSync6, readdirSync } from "fs";
1899
- import { extname, join as join5, relative as relative4, resolve } from "path";
1873
+ import { extname } from "path";
1900
1874
  var ROUTE_EXTENSION = /\.(?:jsx?|tsx?)$/;
1901
- var ROUTE_CONVENTIONS = new Set(["error", "not-found", "root"]);
1902
- function instanceKey(instance) {
1903
- return `${resolve(instance.pagesDir)}\x00${instance.prefix}`;
1875
+ var PARAM_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
1876
+ var BRACKET_ESCAPE = /\[([^\]]*)\]/g;
1877
+ var SOURCE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
1878
+ var PARAM_SEGMENT = /(^|\/):[^/]+/g;
1879
+ var NEXT_CATCH_ALL = /^\[\[?\.\.\.([^\]]+)\]\]?$/;
1880
+ function child(directory, name) {
1881
+ return `${directory}/${name}`;
1882
+ }
1883
+ function sortedEntries(directory) {
1884
+ return readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
1885
+ }
1886
+ function moduleBase(name) {
1887
+ if (name.endsWith(".d.ts") || !ROUTE_EXTENSION.test(name)) {
1888
+ return;
1889
+ }
1890
+ return name.slice(0, -extname(name).length);
1904
1891
  }
1905
- function routeModuleSpecifier(instance) {
1906
- return `@teyik0/furin/routes?instance=${Bun.hash(instanceKey(instance)).toString(16)}`;
1892
+ function findModule(directory, base) {
1893
+ return SOURCE_EXTENSIONS.map((extension) => child(directory, `${base}${extension}`)).find((path) => existsSync6(path));
1907
1894
  }
1908
- function scanRouteFiles(directory, directorySegments, files) {
1909
- const entries = readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
1910
- for (const entry of entries) {
1911
- if (entry.isDirectory()) {
1912
- if (entry.name.startsWith("_")) {
1913
- continue;
1914
- }
1915
- scanRouteFiles(join5(directory, entry.name), [...directorySegments, entry.name], files);
1916
- continue;
1917
- }
1918
- const extension = extname(entry.name);
1919
- if (!ROUTE_EXTENSION.test(extension) || entry.name.endsWith(".d.ts")) {
1920
- continue;
1921
- }
1922
- const base = entry.name.slice(0, -extension.length);
1923
- const sourcePath = join5(directory, entry.name);
1924
- for (const segment of [...directorySegments, base]) {
1925
- parseDynamicRouteSegment(segment, sourcePath);
1926
- }
1927
- if (ROUTE_CONVENTIONS.has(base)) {
1895
+ function paramName(name, raw, sourcePath) {
1896
+ if (!PARAM_NAME.test(name)) {
1897
+ throw new Error(`[furin] Invalid dynamic parameter ${JSON.stringify(raw)} in ${JSON.stringify(sourcePath)}. Parameter names must match ${PARAM_NAME}.`);
1898
+ }
1899
+ return name;
1900
+ }
1901
+ function splitFlatName(base) {
1902
+ const tokens = [];
1903
+ let current = "";
1904
+ let escaped = false;
1905
+ for (const character of base) {
1906
+ if (character === "[") {
1907
+ escaped = true;
1908
+ } else if (character === "]") {
1909
+ escaped = false;
1910
+ }
1911
+ if (character === "." && !escaped) {
1912
+ tokens.push(current);
1913
+ current = "";
1928
1914
  continue;
1929
1915
  }
1930
- if (base.startsWith("_") && base !== "_route") {
1931
- continue;
1916
+ current += character;
1917
+ }
1918
+ tokens.push(current);
1919
+ return tokens;
1920
+ }
1921
+ function tanstackSegment(raw, sourcePath) {
1922
+ if (raw.startsWith("(") && raw.endsWith(")")) {
1923
+ return { raw, type: "group" };
1924
+ }
1925
+ if (raw === "$") {
1926
+ return { raw, type: "splat" };
1927
+ }
1928
+ if (raw.startsWith("{-$") && raw.endsWith("}")) {
1929
+ return {
1930
+ name: paramName(raw.slice(3, -1), raw, sourcePath),
1931
+ optional: true,
1932
+ raw,
1933
+ type: "param"
1934
+ };
1935
+ }
1936
+ if (raw.startsWith("$")) {
1937
+ return { name: paramName(raw.slice(1), raw, sourcePath), optional: false, raw, type: "param" };
1938
+ }
1939
+ if (raw.startsWith("_")) {
1940
+ return { raw, type: "pathless" };
1941
+ }
1942
+ const value = (raw.endsWith("_") ? raw.slice(0, -1) : raw).replace(BRACKET_ESCAPE, "$1");
1943
+ return { raw, type: "static", value };
1944
+ }
1945
+ function tanstackCandidate(base, segments, sourcePath) {
1946
+ const tokens = splitFlatName(base);
1947
+ const last = tokens.at(-1);
1948
+ const index = last === "index";
1949
+ const routeFile = last === "route";
1950
+ const own = (index || routeFile ? tokens.slice(0, -1) : tokens).map((token) => tanstackSegment(token, sourcePath));
1951
+ const routeSegments = [...segments, ...own];
1952
+ if (routeFile && routeSegments.length === 0) {
1953
+ throw new Error(`[furin] ${sourcePath}: a top-level route.tsx has no path to wrap. The root layout lives in __root.tsx.`);
1954
+ }
1955
+ return {
1956
+ forcedLayout: routeFile || routeSegments.at(-1)?.type === "pathless",
1957
+ index,
1958
+ segments: routeSegments,
1959
+ sourcePath
1960
+ };
1961
+ }
1962
+ function scanTanstack(pagesDir) {
1963
+ const candidates = [];
1964
+ const walk = (directory, segments) => {
1965
+ for (const entry of sortedEntries(directory)) {
1966
+ if (entry.name.startsWith("-")) {
1967
+ continue;
1968
+ }
1969
+ const sourcePath = child(directory, entry.name);
1970
+ if (entry.isDirectory()) {
1971
+ walk(sourcePath, [...segments, tanstackSegment(entry.name, sourcePath)]);
1972
+ continue;
1973
+ }
1974
+ const base = moduleBase(entry.name);
1975
+ if (base !== undefined && !(segments.length === 0 && base === "__root")) {
1976
+ candidates.push(tanstackCandidate(base, segments, sourcePath));
1977
+ }
1932
1978
  }
1933
- files.push({
1934
- base,
1935
- directorySegments,
1979
+ };
1980
+ walk(pagesDir, []);
1981
+ return {
1982
+ boundaries: [],
1983
+ candidates,
1984
+ rootPath: findModule(pagesDir, "__root") ?? child(pagesDir, "__root.tsx")
1985
+ };
1986
+ }
1987
+ function nextSegment(name, sourcePath) {
1988
+ if (name.startsWith("(") && name.endsWith(")")) {
1989
+ return { raw: name, type: "group" };
1990
+ }
1991
+ const catchAll = name.match(NEXT_CATCH_ALL);
1992
+ if (catchAll?.[1] !== undefined) {
1993
+ paramName(catchAll[1], name, sourcePath);
1994
+ return { raw: "$", type: "splat" };
1995
+ }
1996
+ if (name.startsWith("[") && name.endsWith("]")) {
1997
+ const name_ = paramName(name.slice(1, -1), name, sourcePath);
1998
+ return { name: name_, optional: false, raw: `$${name_}`, type: "param" };
1999
+ }
2000
+ return { raw: name, type: "static", value: name };
2001
+ }
2002
+ function addNextFile(state, base, segments, sourcePath) {
2003
+ if (base === "route") {
2004
+ throw new Error(`[furin] ${sourcePath}: route handlers are not supported. Declare API routes on your Elysia app instead.`);
2005
+ }
2006
+ if (base === "layout" && segments.at(-1)?.type === "splat") {
2007
+ throw new Error(`[furin] ${sourcePath}: a layout cannot share a catch-all folder with its page: move it to the parent folder.`);
2008
+ }
2009
+ if (base === "page" || base === "layout" && segments.length > 0) {
2010
+ state.candidates.push({
2011
+ forcedLayout: base === "layout",
2012
+ index: base === "page" && segments.at(-1)?.type !== "splat",
2013
+ segments,
1936
2014
  sourcePath
1937
2015
  });
2016
+ } else if (base === "layout") {
2017
+ state.rootPath ??= sourcePath;
2018
+ } else if (base === "error") {
2019
+ state.boundary.errorPath ??= sourcePath;
2020
+ } else if (base === "not-found") {
2021
+ state.boundary.notFoundPath ??= sourcePath;
2022
+ }
2023
+ }
2024
+ function scanNext(pagesDir) {
2025
+ const candidates = [];
2026
+ const boundaries = [];
2027
+ let rootPath;
2028
+ const walk = (directory, segments) => {
2029
+ const boundary = { directory, errorPath: undefined, notFoundPath: undefined };
2030
+ const state = { boundary, candidates, rootPath };
2031
+ for (const entry of sortedEntries(directory)) {
2032
+ const sourcePath = child(directory, entry.name);
2033
+ if (!entry.isDirectory()) {
2034
+ addNextFile(state, moduleBase(entry.name), segments, sourcePath);
2035
+ } else if (!entry.name.startsWith("_")) {
2036
+ walk(sourcePath, [...segments, nextSegment(entry.name, sourcePath)]);
2037
+ }
2038
+ }
2039
+ rootPath ??= state.rootPath;
2040
+ if (boundary.errorPath || boundary.notFoundPath) {
2041
+ boundaries.push(boundary);
2042
+ }
2043
+ };
2044
+ walk(pagesDir, []);
2045
+ boundaries.sort((left, right) => left.directory.length - right.directory.length);
2046
+ return { boundaries, candidates, rootPath: rootPath ?? child(pagesDir, "layout.tsx") };
2047
+ }
2048
+ function segmentKey(segments) {
2049
+ return segments.map((segment) => segment.raw).join("/");
2050
+ }
2051
+ function segmentPattern(segment) {
2052
+ switch (segment.type) {
2053
+ case "group":
2054
+ case "pathless":
2055
+ return;
2056
+ case "param":
2057
+ return `:${segment.name}${segment.optional ? "?" : ""}`;
2058
+ case "splat":
2059
+ return "*";
2060
+ default:
2061
+ return segment.value;
1938
2062
  }
1939
2063
  }
1940
- var INDEX_SUFFIX = /\/index$/;
1941
- function fileRouteId({ pagesDir, prefix }, sourcePath) {
1942
- const path = relative4(pagesDir, sourcePath).replaceAll("\\", "/").replace(ROUTE_EXTENSION, "");
1943
- return `${prefix}/${path}`.replace(INDEX_SUFFIX, "") || "/";
2064
+ function urlPattern(segments) {
2065
+ return `/${segments.flatMap((segment) => segmentPattern(segment) ?? []).join("/")}`;
2066
+ }
2067
+ function routeParams(segments) {
2068
+ return segments.flatMap((segment) => {
2069
+ if (segment.type === "param") {
2070
+ return [{ name: segment.name, optional: segment.optional }];
2071
+ }
2072
+ return segment.type === "splat" ? [{ name: "_splat", optional: false }] : [];
2073
+ });
2074
+ }
2075
+ function assertSplatLast(candidate) {
2076
+ const splat = candidate.segments.findIndex((segment) => segment.type === "splat");
2077
+ if (splat !== -1 && splat < candidate.segments.length - 1) {
2078
+ throw new Error(`[furin] ${candidate.sourcePath}: a catch-all segment must be the last segment of its path.`);
2079
+ }
1944
2080
  }
1945
- function segmentPath(segment) {
1946
- return routeSegmentToPattern(segment);
2081
+ function patternKeys(pattern) {
2082
+ const keys = expandOptionalSegments(pattern).map((variant) => variant.replace(PARAM_SEGMENT, "$1:param"));
2083
+ return [...new Set(keys)];
1947
2084
  }
1948
- function routeId(instanceId, path) {
1949
- const encodedPath = Array.from(new TextEncoder().encode(path), (byte) => byte.toString(16).padStart(2, "0")).join("");
1950
- return `_route_${instanceId}_${encodedPath}`;
2085
+ function claimPatterns(seenPatterns, pattern, sourcePath, relativePath) {
2086
+ for (const patternKey of patternKeys(pattern)) {
2087
+ const previous = seenPatterns.get(patternKey);
2088
+ if (previous !== undefined) {
2089
+ throw new Error(`[furin] Duplicate route pattern "${patternKey}" from "${relativePath(previous)}" and "${relativePath(sourcePath)}".`);
2090
+ }
2091
+ seenPatterns.set(patternKey, sourcePath);
2092
+ }
1951
2093
  }
1952
- function scanRouteManifest(pagesDir) {
1953
- const scannedFiles = [];
1954
- scanRouteFiles(pagesDir, [], scannedFiles);
2094
+ function buildManifest(scan, pagesDir, prefix) {
2095
+ const relativePath = (path) => path.slice(pagesDir.length + 1);
2096
+ const { candidates } = scan;
2097
+ const keys = candidates.map((candidate) => segmentKey(candidate.segments));
2098
+ const hasDescendant = (key, self2) => candidates.some((other, index) => other !== self2 && (keys[index]?.startsWith(`${key}/`) === true || other.index && keys[index] === key));
2099
+ const layouts = new Map;
2100
+ const kinds = candidates.map((candidate, index) => {
2101
+ assertSplatLast(candidate);
2102
+ const key = keys[index] ?? "";
2103
+ const isLayout = !candidate.index && (candidate.forcedLayout || hasDescendant(key, candidate));
2104
+ if (!isLayout) {
2105
+ return "page";
2106
+ }
2107
+ const existing = layouts.get(key);
2108
+ if (existing !== undefined) {
2109
+ throw new Error(`[furin] Two layouts wrap "/${key}": "${relativePath(existing)}" and "${relativePath(candidate.sourcePath)}".`);
2110
+ }
2111
+ layouts.set(key, candidate.sourcePath);
2112
+ return "layout";
2113
+ });
2114
+ const seenIds = new Map;
1955
2115
  const seenPatterns = new Map;
1956
- return scannedFiles.map((file) => {
1957
- if (file.base === "_route") {
1958
- return { ...file, pattern: undefined };
1959
- }
1960
- const relativePath = relative4(pagesDir, file.sourcePath).replaceAll("\\", "/");
1961
- const pattern = filePathToPattern(relativePath);
1962
- const patternKey = routePatternKey(pattern);
1963
- const previousPath = seenPatterns.get(patternKey);
1964
- if (previousPath !== undefined) {
1965
- throw new Error(`[furin] Duplicate route pattern "${patternKey}" from "${previousPath}" and "${relativePath}".`);
1966
- }
1967
- seenPatterns.set(patternKey, relativePath);
1968
- return { ...file, pattern };
2116
+ const routes = candidates.map((candidate, index) => {
2117
+ const kind = kinds[index] ?? "page";
2118
+ const { segments, sourcePath } = candidate;
2119
+ const key = keys[index] ?? "";
2120
+ let parentPath = candidate.index ? layouts.get(key) : undefined;
2121
+ for (let depth = segments.length - 1;parentPath === undefined && depth > 0; depth -= 1) {
2122
+ parentPath = layouts.get(segmentKey(segments.slice(0, depth)));
2123
+ }
2124
+ const path = `/${key}${candidate.index && key !== "" ? "/" : ""}`;
2125
+ const id = prefix === "" ? path : `${prefix}${path}`;
2126
+ const previousId = seenIds.get(id);
2127
+ if (previousId !== undefined) {
2128
+ throw new Error(`[furin] Duplicate route id "${id}" from "${relativePath(previousId)}" and "${relativePath(sourcePath)}".`);
2129
+ }
2130
+ seenIds.set(id, sourcePath);
2131
+ const pattern = urlPattern(segments);
2132
+ if (kind === "page") {
2133
+ claimPatterns(seenPatterns, pattern, sourcePath, relativePath);
2134
+ }
2135
+ return { id, kind, params: routeParams(segments), parentPath, pattern, sourcePath };
1969
2136
  });
2137
+ return { boundaries: scan.boundaries, rootPath: scan.rootPath, routes };
2138
+ }
2139
+ function scanRouteManifest({ pagesDir, prefix, style }) {
2140
+ const directory = pagesDir.replaceAll("\\", "/");
2141
+ return buildManifest(style === "nextjs" ? scanNext(directory) : scanTanstack(directory), directory, prefix);
2142
+ }
2143
+
2144
+ // src/plugin/route-tree.ts
2145
+ function instanceKey(instance) {
2146
+ return `${resolve(instance.pagesDir)}\x00${instance.prefix}`;
2147
+ }
2148
+ function routeModuleSpecifier(instance) {
2149
+ return `@teyik0/furin/routes?instance=${Bun.hash(instanceKey(instance)).toString(16)}`;
1970
2150
  }
1971
- function buildRouteTree(pagesDir, instanceId) {
1972
- const nodes = new Map;
1973
- const ensureNode = (segments) => {
1974
- const key = segments.join("/");
1975
- const existing = nodes.get(key);
2151
+ function routeId(instanceId, id) {
2152
+ const encodedId = Array.from(new TextEncoder().encode(id), (byte) => byte.toString(16).padStart(2, "0")).join("");
2153
+ return `_route_${instanceId}_${encodedId}`;
2154
+ }
2155
+ function relativePrefix(pattern, parentPattern) {
2156
+ const own = pattern === "/" ? "" : pattern;
2157
+ const parent = parentPattern === "/" ? "" : parentPattern;
2158
+ if (!own.startsWith(parent)) {
2159
+ throw new Error(`[furin] Route pattern "${pattern}" does not extend its layout's "${parentPattern}".`);
2160
+ }
2161
+ return own.slice(parent.length);
2162
+ }
2163
+ function buildRouteTree(instance, instanceId) {
2164
+ const { routes } = scanRouteManifest(instance);
2165
+ const byPath = new Map(routes.map((route) => [route.sourcePath, route]));
2166
+ const root = { children: [], layout: undefined, pages: [], prefix: "" };
2167
+ const nodes = new Map([[undefined, root]]);
2168
+ const parentPattern = (route) => route.parentPath === undefined ? "/" : byPath.get(route.parentPath)?.pattern ?? "/";
2169
+ const ensureNode = (sourcePath) => {
2170
+ const existing = nodes.get(sourcePath);
1976
2171
  if (existing) {
1977
2172
  return existing;
1978
2173
  }
2174
+ const layout = sourcePath === undefined ? undefined : byPath.get(sourcePath);
2175
+ if (!layout) {
2176
+ return root;
2177
+ }
2178
+ const prefix = relativePrefix(layout.pattern, parentPattern(layout));
1979
2179
  const node = {
1980
2180
  children: [],
1981
- fileRoutes: [],
1982
- indexRoute: undefined,
1983
- layout: undefined,
1984
- name: segments.at(-1) ?? ""
2181
+ layout: {
2182
+ id: routeId(instanceId, layout.id),
2183
+ path: "",
2184
+ prefix,
2185
+ sourcePath: resolve(layout.sourcePath)
2186
+ },
2187
+ pages: [],
2188
+ prefix
1985
2189
  };
1986
- nodes.set(key, node);
1987
- if (segments.length > 0) {
1988
- ensureNode(segments.slice(0, -1)).children.push(node);
1989
- }
2190
+ nodes.set(sourcePath, node);
2191
+ ensureNode(layout.parentPath).children.push(node);
1990
2192
  return node;
1991
2193
  };
1992
- const root = ensureNode([]);
1993
- for (const file of scanRouteManifest(pagesDir)) {
1994
- const node = ensureNode(file.directorySegments);
1995
- if (file.pattern === undefined) {
1996
- const path = `/${file.directorySegments.map(segmentPath).join("/")}#layout`;
1997
- node.layout = { id: routeId(instanceId, path), path: "", sourcePath: file.sourcePath };
2194
+ for (const route of routes) {
2195
+ if (route.kind === "layout") {
2196
+ ensureNode(route.sourcePath);
1998
2197
  continue;
1999
2198
  }
2000
- const route = {
2001
- id: routeId(instanceId, file.pattern),
2002
- path: file.pattern,
2003
- sourcePath: file.sourcePath
2004
- };
2005
- if (file.base === "index") {
2006
- node.indexRoute = route;
2007
- } else {
2008
- node.fileRoutes.push(route);
2009
- }
2199
+ ensureNode(route.parentPath).pages.push({
2200
+ id: routeId(instanceId, route.id),
2201
+ path: route.pattern,
2202
+ prefix: relativePrefix(route.pattern, parentPattern(route)),
2203
+ sourcePath: resolve(route.sourcePath)
2204
+ });
2010
2205
  }
2011
2206
  return root;
2012
2207
  }
@@ -2021,17 +2216,13 @@ function collectRouteFiles(root) {
2021
2216
  if (node.layout) {
2022
2217
  files.push(node.layout);
2023
2218
  }
2024
- if (node.indexRoute) {
2025
- files.push(node.indexRoute);
2026
- }
2027
- files.push(...node.fileRoutes);
2219
+ files.push(...node.pages);
2028
2220
  nodes.push(...node.children);
2029
2221
  }
2030
2222
  return files;
2031
2223
  }
2032
2224
  function routeSourcePaths(instance) {
2033
- const instanceId = Bun.hash(instanceKey(instance)).toString(16);
2034
- return collectRouteFiles(buildRouteTree(instance.pagesDir, instanceId)).map(({ sourcePath }) => resolve(sourcePath)).toSorted((left, right) => left.localeCompare(right));
2225
+ return scanRouteManifest(instance).routes.map(({ sourcePath }) => resolve(sourcePath)).toSorted((left, right) => left.localeCompare(right));
2035
2226
  }
2036
2227
 
2037
2228
  // src/plugin/route-registry.ts
@@ -2054,15 +2245,10 @@ function instanceNamespace(instance) {
2054
2245
  }
2055
2246
  function emitRouteNode(node, indentation, includeRootCatchAll) {
2056
2247
  const childIndentation = `${indentation} `;
2057
- const prefix = node.name && !isRouteGroup(node.name) ? `/${segmentPath(node.name)}` : "";
2058
- const head = `new Elysia({ prefix: ${JSON.stringify(prefix)} })`;
2248
+ const head = `new Elysia({ prefix: ${JSON.stringify(node.prefix)} })`;
2059
2249
  const content = [];
2060
- if (node.indexRoute) {
2061
- content.push(`${childIndentation}.use(new Elysia({ prefix: "" }).use(${node.indexRoute.id}.elysia))`);
2062
- }
2063
- for (const route of node.fileRoutes.filter((file) => includeRootCatchAll || file.path !== "/*")) {
2064
- const segment = route.path.slice(route.path.lastIndexOf("/") + 1);
2065
- content.push(`${childIndentation}.use(new Elysia({ prefix: ${JSON.stringify(`/${segment}`)} }).use(${route.id}.elysia))`);
2250
+ for (const route of node.pages.filter((file) => includeRootCatchAll || file.path !== "/*")) {
2251
+ content.push(`${childIndentation}.use(new Elysia({ prefix: ${JSON.stringify(route.prefix)} }).use(${route.id}.elysia))`);
2066
2252
  }
2067
2253
  for (const child of node.children) {
2068
2254
  content.push(`${childIndentation}.use(`);
@@ -2092,11 +2278,8 @@ async function retainComposableRoutes(node) {
2092
2278
  if (node.layout && !await isComposable(node.layout)) {
2093
2279
  node.layout = undefined;
2094
2280
  }
2095
- if (node.indexRoute && !await isComposable(node.indexRoute)) {
2096
- node.indexRoute = undefined;
2097
- }
2098
- const composableRoutes = (await Promise.all(node.fileRoutes.map(async (route) => ({ keep: await isComposable(route), route })))).flatMap(({ keep, route }) => keep ? [route] : []);
2099
- node.fileRoutes = composableRoutes;
2281
+ const composableRoutes = (await Promise.all(node.pages.map(async (route) => ({ keep: await isComposable(route), route })))).flatMap(({ keep, route }) => keep ? [route] : []);
2282
+ node.pages = composableRoutes;
2100
2283
  await Promise.all(node.children.map((child) => retainComposableRoutes(child)));
2101
2284
  }
2102
2285
  async function generateServerInstance(instance, routeFilesBySpecifier, materialized, includeRootCatchAll) {
@@ -2107,7 +2290,7 @@ async function generateServerInstance(instance, routeFilesBySpecifier, materiali
2107
2290
  return includeRootCatchAll ? instance.routeRegistry.complete : instance.routeRegistry.composable;
2108
2291
  }
2109
2292
  const instanceId = Bun.hash(instanceKey(instance)).toString(16);
2110
- const tree = buildRouteTree(instance.pagesDir, instanceId);
2293
+ const tree = buildRouteTree(instance, instanceId);
2111
2294
  await retainComposableRoutes(tree);
2112
2295
  const imports = collectRouteFiles(tree).sort((left, right) => left.sourcePath.localeCompare(right.sourcePath)).map((route) => {
2113
2296
  const specifier = materialized ? resolve2(route.sourcePath).replaceAll("\\", "/") : routeFileSpecifier(route);
@@ -2151,7 +2334,7 @@ async function clientRoutesSource(instance) {
2151
2334
  if (instance.routeRegistry) {
2152
2335
  return instance.routeRegistry.client;
2153
2336
  }
2154
- const tree = buildRouteTree(instance.pagesDir, Bun.hash(instanceKey(instance)).toString(16));
2337
+ const tree = buildRouteTree(instance, Bun.hash(instanceKey(instance)).toString(16));
2155
2338
  const routes = collectRouteFiles(tree).filter((route) => route.path !== "").sort((left, right) => left.path.localeCompare(right.path));
2156
2339
  const metadata = await Promise.all(routes.map(async (routeFile) => {
2157
2340
  const module = await loadRouteModule(routeFile.sourcePath);
@@ -2181,8 +2364,8 @@ function serverProxySource(instance, includeRootCatchAll) {
2181
2364
  function createRoutesPlugin(options) {
2182
2365
  const routeFilesBySpecifier = new Map;
2183
2366
  const routeFilesByResolvedPath = new Map;
2184
- const registryVirtualPath = join6(resolve2(primaryInstance(options.instances).pagesDir), ".furin-routes-registry.ts?furin-virtual");
2185
- const composableRegistryVirtualPath = join6(resolve2(primaryInstance(options.instances).pagesDir), ".furin-routes-registry-composable.ts?furin-virtual");
2367
+ const registryVirtualPath = join5(resolve2(primaryInstance(options.instances).pagesDir), ".furin-routes-registry.ts?furin-virtual");
2368
+ const composableRegistryVirtualPath = join5(resolve2(primaryInstance(options.instances).pagesDir), ".furin-routes-registry-composable.ts?furin-virtual");
2186
2369
  const instancesBySpecifier = new Map(options.instances.flatMap((instance) => [
2187
2370
  [
2188
2371
  routeModuleSpecifier(instance),
@@ -2265,11 +2448,11 @@ async function materializeServerAppEntry(options) {
2265
2448
  if (!instance) {
2266
2449
  throw new Error(`[furin] Missing route instance for server app ${index}.`);
2267
2450
  }
2268
- const routePath = join7(options.outDir, `_furin-routes-${index}.ts`);
2451
+ const routePath = join6(options.outDir, `_furin-routes-${index}.ts`);
2269
2452
  writeFileSync2(routePath, await materializedRouteModuleSource(instance));
2270
2453
  return { ...app, nativeRoutes: toPosixPath(routePath) };
2271
2454
  }));
2272
- const entryPath = join7(options.outDir, "_furin-app.ts");
2455
+ const entryPath = join6(options.outDir, "_furin-app.ts");
2273
2456
  writeFileSync2(entryPath, buildEntrySource({
2274
2457
  apps,
2275
2458
  headerComment: options.headerComment,
@@ -2282,7 +2465,7 @@ async function materializeServerAppEntry(options) {
2282
2465
 
2283
2466
  // src/rsc/build/index.ts
2284
2467
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
2285
- import { basename as basename2, join as join9 } from "path";
2468
+ import { basename as basename2, join as join8 } from "path";
2286
2469
  import { fileURLToPath as fileURLToPath5 } from "url";
2287
2470
  // ../../node_modules/.bun/yuku-ast@0.13.0/node_modules/yuku-ast/dist/aliases.js
2288
2471
  var ALIAS_GROUPS = {
@@ -4806,9 +4989,9 @@ var MagicString = class MagicString {
4806
4989
  };
4807
4990
 
4808
4991
  // src/shared/parser.ts
4809
- import { parse as parse2 } from "yuku-parser";
4992
+ import { parse } from "yuku-parser";
4810
4993
  function parseSource(code, lang) {
4811
- return parse2(code, { lang, sourceType: "module" });
4994
+ return parse(code, { lang, sourceType: "module" });
4812
4995
  }
4813
4996
 
4814
4997
  // src/plugin/module-transform.ts
@@ -5680,7 +5863,7 @@ import { dirname as dirname8 } from "path";
5680
5863
  var A;
5681
5864
  var B = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
5682
5865
  var Q = typeof Buffer != "undefined";
5683
- function parse3(g, C = "@") {
5866
+ function parse2(g, C = "@") {
5684
5867
  A || initSync();
5685
5868
  const G = g.length + 1, D = (A.__heap_base.value || A.__heap_base) + 4 * G - A.memory.buffer.byteLength;
5686
5869
  D > 0 && A.memory.grow(Math.ceil(D / 65536));
@@ -5859,11 +6042,11 @@ function initSync() {
5859
6042
  import { readFileSync as readFileSync2 } from "fs";
5860
6043
 
5861
6044
  // src/rsc/build/paths.ts
5862
- import { dirname as dirname7, join as join8 } from "path";
6045
+ import { dirname as dirname7, join as join7 } from "path";
5863
6046
  import { fileURLToPath as fileURLToPath3 } from "url";
5864
6047
  var SOURCE_DIR = dirname7(fileURLToPath3(import.meta.resolve("@teyik0/furin/rsc")));
5865
- var CLIENT_REFERENCE_RUNTIME_PATH = join8(SOURCE_DIR, "rsc/client-references.ts");
5866
- var BUNDLED_CLIENT_CODEC_PATH = join8(SOURCE_DIR, "rsc/bundled-client-codec.ts");
6048
+ var CLIENT_REFERENCE_RUNTIME_PATH = join7(SOURCE_DIR, "rsc/client-references.ts");
6049
+ var BUNDLED_CLIENT_CODEC_PATH = join7(SOURCE_DIR, "rsc/bundled-client-codec.ts");
5867
6050
 
5868
6051
  // src/rsc/build/flight-loader.ts
5869
6052
  var CLIENT_CODEC = /react-server-dom-webpack-client\.(?:edge|browser)\.(?:development|production)\.js$/;
@@ -6015,7 +6198,7 @@ function commonJsExports(source, path) {
6015
6198
  withoutImports.remove(statement.start, statement.end);
6016
6199
  }
6017
6200
  }
6018
- return parse3(withoutImports.toString());
6201
+ return parse2(withoutImports.toString());
6019
6202
  }
6020
6203
  async function exportedNames(source, path, visited) {
6021
6204
  if (visited.has(path)) {
@@ -6144,7 +6327,7 @@ ${codecResult.logs.map((log) => log.message).join(`
6144
6327
  }
6145
6328
  async function buildRscGraph(apps, outDir, buildId, userPlugins, external) {
6146
6329
  await assertInstalledRscVersions();
6147
- const graphDir = join9(outDir, "rsc");
6330
+ const graphDir = join8(outDir, "rsc");
6148
6331
  mkdirSync2(graphDir, { recursive: true });
6149
6332
  const rscEntry = fileURLToPath5(import.meta.resolve("../../rsc-server.tsx"));
6150
6333
  const entrypoints = [
@@ -6198,13 +6381,13 @@ ${result.logs.map((log) => log.message).join(`
6198
6381
  clientReferences: referencedClientExports(clientReferences, result.metafile),
6199
6382
  css
6200
6383
  };
6201
- writeFileSync3(join9(graphDir, "manifest.json"), JSON.stringify(manifest, null, 2));
6384
+ writeFileSync3(join8(graphDir, "manifest.json"), JSON.stringify(manifest, null, 2));
6202
6385
  return manifest;
6203
6386
  }
6204
6387
 
6205
6388
  // src/adapter/prerender.ts
6206
6389
  import { readFileSync as readFileSync3, rmSync as rmSync2 } from "fs";
6207
- import { join as join10 } from "path";
6390
+ import { join as join9 } from "path";
6208
6391
  import { pathToFileURL as pathToFileURL2 } from "url";
6209
6392
  function prerenderScript(module, render, resultPath) {
6210
6393
  const href = JSON.stringify(pathToFileURL2(module.path).href);
@@ -6223,7 +6406,7 @@ process.exit(0);
6223
6406
  `;
6224
6407
  }
6225
6408
  async function runBundleScript(script, cwd, failure) {
6226
- const resultPath = join10(cwd, ".furin", "build", `prerender-${crypto.randomUUID()}.json`);
6409
+ const resultPath = join9(cwd, ".furin", "build", `prerender-${crypto.randomUUID()}.json`);
6227
6410
  const child = Bun.spawn([process.execPath, "-e", script(resultPath)], {
6228
6411
  cwd,
6229
6412
  env: { ...process.env, NODE_ENV: "production" },
@@ -6256,12 +6439,12 @@ function exportStaticFromBundle(path, cwd, options) {
6256
6439
  // src/adapter/runtime-build.ts
6257
6440
  import { existsSync as existsSync10, realpathSync as realpathSync4, writeFileSync as writeFileSync6 } from "fs";
6258
6441
  import { createRequire } from "module";
6259
- import { dirname as dirname12, isAbsolute as isAbsolute5, join as join13, relative as relative6, resolve as resolve7 } from "path";
6442
+ import { dirname as dirname12, isAbsolute as isAbsolute5, join as join12, relative as relative5, resolve as resolve7 } from "path";
6260
6443
  import { fileURLToPath as fileURLToPath7 } from "url";
6261
6444
 
6262
6445
  // src/build/client.ts
6263
6446
  import { existsSync as existsSync9, mkdirSync as mkdirSync3 } from "fs";
6264
- import { basename as basename4, dirname as dirname11, join as join12, sep as sep2 } from "path";
6447
+ import { basename as basename4, dirname as dirname11, join as join11, sep as sep2 } from "path";
6265
6448
  import { fileURLToPath as fileURLToPath6 } from "url";
6266
6449
 
6267
6450
  // src/plugin/client-plugin.ts
@@ -7423,7 +7606,7 @@ ${buildIdMeta}${modeMeta}${faviconLink}${cssLinks ? `${cssLinks}
7423
7606
 
7424
7607
  // src/build/route-types.ts
7425
7608
  import { existsSync as existsSync7, readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync as writeFileSync4 } from "fs";
7426
- import { extname as extname2, join as join11, relative as relative5, resolve as resolve5 } from "path";
7609
+ import { extname as extname2, join as join10, relative as relative4, resolve as resolve5 } from "path";
7427
7610
 
7428
7611
  // src/shared/route-map.ts
7429
7612
  function compareCodeUnits(left, right) {
@@ -7462,38 +7645,19 @@ function tagToStringLiteral(tag) {
7462
7645
  function importSpecifier(path, projectRoot) {
7463
7646
  const extension = extname2(path);
7464
7647
  const sourcePath = extension ? path.slice(0, -extension.length) : path;
7465
- const relativePath = relative5(projectRoot, sourcePath).replaceAll("\\", "/");
7648
+ const relativePath = relative4(projectRoot, sourcePath).replaceAll("\\", "/");
7466
7649
  return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
7467
7650
  }
7468
- function fileRouteEntries({ pagesDir, prefix }, projectRoot) {
7469
- const pages = resolve5(pagesDir);
7470
- const files = routeSourcePaths({ pagesDir: pages, prefix }).map((path) => {
7471
- const relativePath = relative5(pages, path).replaceAll("\\", "/");
7472
- const segments = relativePath.split("/");
7473
- const base = (segments.pop() ?? "").slice(0, -extname2(path).length);
7474
- return { base, path, relativePath, segments };
7475
- });
7476
- const layouts = new Map(files.filter(({ base }) => base === "_route").map((file) => [file.segments.join("/"), file.path]));
7477
- return files.map(({ base, path, relativePath, segments }) => {
7478
- const isLayout = base === "_route";
7479
- let parent = join11(pages, "root.tsx");
7480
- for (let depth = isLayout ? segments.length - 1 : segments.length;depth > 0; depth -= 1) {
7481
- const layout = layouts.get(segments.slice(0, depth).join("/"));
7482
- if (layout) {
7483
- parent = layout;
7484
- break;
7485
- }
7486
- }
7487
- const pathParams = [...segments, base].flatMap((segment) => {
7488
- const dynamic = parseDynamicRouteSegment(segment, path);
7489
- return dynamic ? [dynamic.catchAll ? '"*": string' : `${dynamic.name}: string`] : [];
7490
- });
7491
- const id = fileRouteId({ pagesDir: pages, prefix }, path);
7492
- const pattern = filePathToPattern(isLayout ? segments.concat("index").join("/") : relativePath);
7651
+ function fileRouteEntries(instance, projectRoot) {
7652
+ const { prefix } = instance;
7653
+ const manifest = scanRouteManifest({ ...instance, pagesDir: resolve5(instance.pagesDir) });
7654
+ return manifest.routes.map(({ id, kind, params, parentPath, pattern }) => {
7655
+ const parent = parentPath ?? manifest.rootPath;
7656
+ const pathParams = params.map(({ name, optional }) => `${name}${optional ? "?" : ""}: string`);
7493
7657
  return {
7494
7658
  id,
7495
7659
  lines: ` ${JSON.stringify(id)}: {
7496
- kind: "${isLayout ? "layout" : "page"}";
7660
+ kind: "${kind}";
7497
7661
  pattern: ${JSON.stringify(`${prefix}${pattern === "/" ? "" : pattern}` || "/")};
7498
7662
  parent: typeof import(${JSON.stringify(importSpecifier(parent, projectRoot))}).route;
7499
7663
  pathParams: {${pathParams.length > 0 ? ` ${pathParams.join("; ")} ` : ""}};
@@ -7532,7 +7696,7 @@ import "@teyik0/furin/routes";
7532
7696
 
7533
7697
  ${apps === undefined ? "" : fileRoutesDeclaration(apps, projectRoot)}${routeMapDeclaration(entries)}${tagBlock}
7534
7698
  `;
7535
- const typesPath = join11(projectRoot, "furin-env.d.ts");
7699
+ const typesPath = join10(projectRoot, "furin-env.d.ts");
7536
7700
  const existing = existsSync7(typesPath) ? readFileSync5(typesPath, "utf8") : "";
7537
7701
  if (content === existing) {
7538
7702
  return false;
@@ -7595,11 +7759,13 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7595
7759
  continue;
7596
7760
  }
7597
7761
  const parts = [`depth: ${seg.depth}`];
7762
+ const errorExport = seg.fromRoute ? "route.errorComponent" : "default";
7763
+ const notFoundExport = seg.fromRoute ? "route.notFoundComponent" : "default";
7598
7764
  if (errorIdent) {
7599
- parts.push(`error: ${errorIdent}.default`);
7765
+ parts.push(`error: ${errorIdent}.${errorExport}`);
7600
7766
  }
7601
7767
  if (notFoundIdent) {
7602
- parts.push(`notFound: ${notFoundIdent}.default`);
7768
+ parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
7603
7769
  }
7604
7770
  if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
7605
7771
  parts.push("isRoot: false");
@@ -7994,7 +8160,7 @@ function writeClientPreloadManifest(metafile, outputPaths, entryChunkPath, route
7994
8160
  }
7995
8161
 
7996
8162
  // src/build/client.ts
7997
- var CLIENT_DIST_DIR = `${join12(dirname11(dirname11(fileURLToPath6(import.meta.resolve("@teyik0/furin")))), "dist")}${sep2}`;
8163
+ var CLIENT_DIST_DIR = `${join11(dirname11(dirname11(fileURLToPath6(import.meta.resolve("@teyik0/furin")))), "dist")}${sep2}`;
7998
8164
  async function buildClient(routes, {
7999
8165
  outDir,
8000
8166
  rootLayout,
@@ -8007,11 +8173,11 @@ async function buildClient(routes, {
8007
8173
  metafilePath,
8008
8174
  optimizeImports,
8009
8175
  reactCompiler,
8010
- pagesDir,
8176
+ pages,
8011
8177
  routeRegistry
8012
8178
  }) {
8013
8179
  const dirName = clientDirName ?? "client";
8014
- const clientDir = join12(outDir, dirName);
8180
+ const clientDir = join11(outDir, dirName);
8015
8181
  if (!existsSync9(outDir)) {
8016
8182
  mkdirSync3(outDir, { recursive: true });
8017
8183
  }
@@ -8020,7 +8186,7 @@ async function buildClient(routes, {
8020
8186
  }
8021
8187
  const boundaries = await discoverClientBoundaries([...new Set([rootLayout, ...routes.flatMap((route) => [route.path, ...route.routeChain.flatMap((entry) => entry.sourcePath ? [entry.sourcePath] : [])])])], plugins);
8022
8188
  const hydrateCode = generateClientReferenceEntry(boundaries) + generateProductionHydrateEntry(routes, rootLayout, basePath, clientLogging);
8023
- const hydratePath = join12(outDir, dirName === "client" ? "_hydrate.tsx" : `_hydrate-${dirName}.tsx`);
8189
+ const hydratePath = join11(outDir, dirName === "client" ? "_hydrate.tsx" : `_hydrate-${dirName}.tsx`);
8024
8190
  const hydrateEntry = createVirtualBuildEntry(hydratePath, hydrateCode, "tsx");
8025
8191
  console.log("[furin] Building production client bundle\u2026");
8026
8192
  const routerLoggerPlugin = {
@@ -8060,7 +8226,7 @@ async function buildClient(routes, {
8060
8226
  hydrateEntry.plugin,
8061
8227
  ...plugins ?? [],
8062
8228
  ...!clientLogging ? [routerLoggerPlugin] : [],
8063
- ...pagesDir ? [createRoutesPlugin({ instances: [{ pagesDir, prefix: basePath, routeRegistry }], target: "client" })] : [],
8229
+ ...pages ? [createRoutesPlugin({ instances: [{ ...pages, prefix: basePath, routeRegistry }], target: "client" })] : [],
8064
8230
  createClientStripPlugin({ mode: "build" })
8065
8231
  ],
8066
8232
  define: {
@@ -8098,10 +8264,10 @@ async function buildClient(routes, {
8098
8264
 
8099
8265
  // src/adapter/runtime-build.ts
8100
8266
  var _pkgRoot2 = dirname12(dirname12(fileURLToPath7(import.meta.resolve("@teyik0/furin"))));
8101
- var _pkgSrcDir2 = existsSync10(join13(_pkgRoot2, "src", "furin.ts")) ? join13(_pkgRoot2, "src") : join13(_pkgRoot2, "dist");
8267
+ var _pkgSrcDir2 = existsSync10(join12(_pkgRoot2, "src", "furin.ts")) ? join12(_pkgRoot2, "src") : join12(_pkgRoot2, "dist");
8102
8268
  var _ext2 = ".ts";
8103
8269
  function frameworkSourceModule(path) {
8104
- return join13(_pkgRoot2, "src", path);
8270
+ return join12(_pkgRoot2, "src", path);
8105
8271
  }
8106
8272
  var PPR_ROUTE_IMPORT_RE = /ppr-route(?:\.ts)?$/;
8107
8273
  var MIXED_CACHE_IMPORT_RE = /mixed-cache(?:\.ts)?$/;
@@ -8154,7 +8320,7 @@ function nearestFingerprintFile(directory, names, boundary) {
8154
8320
  let current = directory;
8155
8321
  while (current !== undefined) {
8156
8322
  for (const name of names) {
8157
- const path = join13(current, name);
8323
+ const path = join12(current, name);
8158
8324
  if (existsSync10(path)) {
8159
8325
  return path;
8160
8326
  }
@@ -8212,7 +8378,7 @@ async function createBuildFingerprint(entryChunk, cssChunks, routes, root, serve
8212
8378
  if (!isScript) {
8213
8379
  return;
8214
8380
  }
8215
- const relativePath = toPosixPath(relative6(rootBoundary, path));
8381
+ const relativePath = toPosixPath(relative5(rootBoundary, path));
8216
8382
  const manifestBoundary = relativePath === ".." || relativePath.startsWith("../") || isAbsolute5(relativePath) ? undefined : rootBoundary;
8217
8383
  const manifest = nearestFingerprintFile(dirname12(path), ["package.json"], manifestBoundary);
8218
8384
  if (manifest) {
@@ -8261,11 +8427,11 @@ function stableFingerprintPath(path, projectRoot) {
8261
8427
  if (dependencyStart !== -1) {
8262
8428
  return `dependency/${posixPath.slice(dependencyStart + "/node_modules/".length)}`;
8263
8429
  }
8264
- const projectPath = relative6(realpathSync4(projectRoot), absolutePath);
8430
+ const projectPath = relative5(realpathSync4(projectRoot), absolutePath);
8265
8431
  if (!isAbsolute5(projectPath) && projectPath !== ".." && !projectPath.startsWith("../") && !projectPath.startsWith("..\\")) {
8266
8432
  return `app/${toPosixPath(projectPath)}`;
8267
8433
  }
8268
- const frameworkPath = relative6(_pkgRoot2, absolutePath);
8434
+ const frameworkPath = relative5(_pkgRoot2, absolutePath);
8269
8435
  if (!isAbsolute5(frameworkPath) && frameworkPath !== ".." && !frameworkPath.startsWith("../") && !frameworkPath.startsWith("..\\")) {
8270
8436
  return `furin/${toPosixPath(frameworkPath)}`;
8271
8437
  }
@@ -8279,11 +8445,13 @@ function buildCompileMetadata(root, routes) {
8279
8445
  const routeMetadata = {};
8280
8446
  for (const route of routes) {
8281
8447
  routeMetadata[toPosixPath(route.path)] = {
8448
+ layouts: route.layouts.map((layout) => ({ ...layout, path: toPosixPath(layout.path) })),
8282
8449
  requestKeys: route.requestKeys,
8283
8450
  requestKeysByLoader: route.requestKeysByLoader,
8284
8451
  segmentBoundaries: route.segmentBoundaries.map((boundary) => ({
8285
8452
  depth: boundary.depth,
8286
8453
  errorPath: boundary.errorPath ? toPosixPath(boundary.errorPath) : undefined,
8454
+ ...boundary.fromRoute ? { fromRoute: boundary.fromRoute } : {},
8287
8455
  notFoundPath: boundary.notFoundPath ? toPosixPath(boundary.notFoundPath) : undefined,
8288
8456
  path: toPosixPath(boundary.path)
8289
8457
  }))
@@ -8349,7 +8517,7 @@ function isFrameworkRuntimeImporter(importer) {
8349
8517
  if (importer === "") {
8350
8518
  return false;
8351
8519
  }
8352
- const fromRuntimeRoot = relative6(_pkgSrcDir2, importer.split("?")[0]);
8520
+ const fromRuntimeRoot = relative5(_pkgSrcDir2, importer.split("?")[0]);
8353
8521
  return fromRuntimeRoot !== ".." && !fromRuntimeRoot.startsWith("../") && !fromRuntimeRoot.startsWith("..\\");
8354
8522
  }
8355
8523
  async function buildRuntimeApp(app, projectRoot, targetDir, serverEntry, options, targetName) {
@@ -8361,10 +8529,10 @@ async function buildRuntimeApp(app, projectRoot, targetDir, serverEntry, options
8361
8529
  basePath: prefix,
8362
8530
  clientDirName,
8363
8531
  clientLogging: options.clientLogging ?? false,
8364
- metafilePath: options.analyze ? join13(dirname12(targetDir), "analysis", `${targetName}-${clientDirName}.json`) : undefined,
8532
+ metafilePath: options.analyze ? join12(dirname12(targetDir), "analysis", `${targetName}-${clientDirName}.json`) : undefined,
8365
8533
  optimizeImports: options.optimizeImports,
8366
8534
  outDir: targetDir,
8367
- pagesDir: app.pagesDir,
8535
+ pages: { pagesDir: app.pagesDir, style: app.style },
8368
8536
  routeRegistry: app.routeRegistry,
8369
8537
  plugins: options.plugins,
8370
8538
  preloadRouteChunks: options.preload?.routeChunks,
@@ -8375,9 +8543,9 @@ async function buildRuntimeApp(app, projectRoot, targetDir, serverEntry, options
8375
8543
  const buildFingerprint = await createBuildFingerprint(`${prefix}
8376
8544
  ${entryChunk}`, cssChunks, routes, root, serverEntry, modulePaths, projectRoot);
8377
8545
  const buildId = Bun.hash(buildFingerprint).toString(16).slice(0, 12);
8378
- const clientDir = join13(targetDir, clientDirName);
8546
+ const clientDir = join12(targetDir, clientDirName);
8379
8547
  const indexHtml = generateProdIndexHtml(entryChunk, cssChunks, buildId, undefined, false);
8380
- writeFileSync6(join13(clientDir, "index.html"), indexHtml);
8548
+ writeFileSync6(join12(clientDir, "index.html"), indexHtml);
8381
8549
  const { rootConventions, routeMetadata } = buildCompileMetadata(root, routes);
8382
8550
  console.log(`[furin] Built ${label} (buildId ${buildId})`);
8383
8551
  return {
@@ -8404,16 +8572,16 @@ ${entryChunk}`, cssChunks, routes, root, serverEntry, modulePaths, projectRoot);
8404
8572
  }
8405
8573
 
8406
8574
  // src/adapter/server-bundle.ts
8407
- import { dirname as dirname15, relative as relative9 } from "path";
8575
+ import { dirname as dirname15, relative as relative8 } from "path";
8408
8576
 
8409
8577
  // src/build/elysia-aot.ts
8410
8578
  import { fork } from "child_process";
8411
8579
  import { existsSync as existsSync11, realpathSync as realpathSync5 } from "fs";
8412
- import { dirname as dirname13, join as join14, relative as relative7, resolve as resolve8 } from "path";
8580
+ import { dirname as dirname13, join as join13, relative as relative6, resolve as resolve8 } from "path";
8413
8581
  import { fileURLToPath as fileURLToPath8 } from "url";
8414
8582
  var AOT_NAMESPACE = "furin-elysia-aot";
8415
8583
  var ELYSIA_RESOLVE_DIR = dirname13(Bun.resolveSync("elysia", import.meta.dir));
8416
- var AOT_PROCESS_PATH = join14(dirname13(dirname13(fileURLToPath8(import.meta.resolve("@teyik0/furin")))), "src/build/elysia-aot-worker.ts");
8584
+ var AOT_PROCESS_PATH = join13(dirname13(dirname13(fileURLToPath8(import.meta.resolve("@teyik0/furin")))), "src/build/elysia-aot-worker.ts");
8417
8585
  var SOURCE_FILTER = /\.[cm]?[jt]sx?$/;
8418
8586
  var ELYSIA_IMPORT_FILTER = /^elysia(?:\/(?!compiled$|type$).*)?$/;
8419
8587
  var ELYSIA_VIRTUAL_IMPORT_FILTER = /^elysia\/(?:compiled|type)$/;
@@ -8443,10 +8611,10 @@ export function drainWaiters(){return e()}
8443
8611
  export function handleWSResponse(){return e()}
8444
8612
  `;
8445
8613
  }
8446
- function mountLabel(rootDir, { pagesDir, prefix }) {
8614
+ function mountLabel(rootDir, { pagesDir, prefix, style }) {
8447
8615
  const absolute = resolve8(rootDir, pagesDir);
8448
8616
  const path = existsSync11(absolute) ? realpathSync5(absolute) : absolute;
8449
- return `prefix ${JSON.stringify(prefix || "/")} (pagesDir ${relative7(rootDir, path) || "."})`;
8617
+ return `prefix ${JSON.stringify(prefix || "/")} (pagesDir ${relative6(rootDir, path) || "."}, style ${style})`;
8450
8618
  }
8451
8619
  function registrationMismatch(build, registrations, evaluated) {
8452
8620
  const root = realpathSync5(build.rootDir);
@@ -8607,7 +8775,7 @@ function elysiaAot(entry, expected) {
8607
8775
  }
8608
8776
 
8609
8777
  // src/build/production-instrumentation.ts
8610
- import { dirname as dirname14, relative as relative8, resolve as resolve9 } from "path";
8778
+ import { dirname as dirname14, relative as relative7, resolve as resolve9 } from "path";
8611
8779
  var INSTRUMENTATION_IMPORT = /(?:^|[/\\])devtools[/\\]instrumentation(?:\.ts|\.js)?$/;
8612
8780
  var DEV_PAGE_PLUGIN_IMPORT = /(?:^|[/\\])server[/\\]dev-page-plugin(?:\.ts|\.js)?$/;
8613
8781
  var DEV_RUNTIME_IMPORT = /(?:^|[/\\])server[/\\]dev[/\\](?:browser-events|diagnostics|graph|plugin|runtime)(?:\.ts|\.js)?$/;
@@ -8617,7 +8785,7 @@ var PRODUCTION_BOUNDARY_IMPORT = /(?:browser-events|instrumentation|dev-page-plu
8617
8785
  var PRODUCTION_STUB_NAMESPACE = "furin-production-runtime-stub";
8618
8786
  var FURIN_RUNTIME_ROOT = resolve9(import.meta.dir, "..");
8619
8787
  function isFurinRuntimePath(path) {
8620
- const fromRuntimeRoot = relative8(FURIN_RUNTIME_ROOT, path);
8788
+ const fromRuntimeRoot = relative7(FURIN_RUNTIME_ROOT, path);
8621
8789
  return fromRuntimeRoot !== ".." && !fromRuntimeRoot.startsWith("../") && !fromRuntimeRoot.startsWith("..\\");
8622
8790
  }
8623
8791
  function devBuildExports(path) {
@@ -8675,7 +8843,7 @@ function isFurinRuntimeImporter(importer) {
8675
8843
  if (importer === "") {
8676
8844
  return false;
8677
8845
  }
8678
- const fromRuntimeRoot = relative9(FURIN_RUNTIME_ROOT2, importer.split("?")[0]);
8846
+ const fromRuntimeRoot = relative8(FURIN_RUNTIME_ROOT2, importer.split("?")[0]);
8679
8847
  return fromRuntimeRoot !== ".." && !fromRuntimeRoot.startsWith("../") && !fromRuntimeRoot.startsWith("..\\");
8680
8848
  }
8681
8849
  function appSpecifierPlugin(appEntry) {
@@ -8769,10 +8937,10 @@ function withAssetContexts(adapter, builds, targetDir) {
8769
8937
  return prepareCompileEntryApps({
8770
8938
  apps: contexts.map((context) => ({
8771
8939
  ...context,
8772
- embed: { clientDir: join15(targetDir, clientDirNameForPrefix(context.prefix ?? "")) }
8940
+ embed: { clientDir: join14(targetDir, clientDirNameForPrefix(context.prefix ?? "")) }
8773
8941
  })),
8774
8942
  outDir: targetDir,
8775
- publicDir: join15(targetDir, "public")
8943
+ publicDir: join14(targetDir, "public")
8776
8944
  });
8777
8945
  }
8778
8946
  function adapterRoute(app, route) {
@@ -8816,22 +8984,22 @@ async function bundleServer(adapter, apps, appEntry, clientReferences, rootDir,
8816
8984
  if (build.metafile === undefined) {
8817
8985
  throw new Error(`[furin] The ${adapter.name} server build did not produce its metafile.`);
8818
8986
  }
8819
- writeBuildMetafile(join15(buildRoot, "analysis", `${adapter.name}-server.json`), build.metafile, "Server");
8987
+ writeBuildMetafile(join14(buildRoot, "analysis", `${adapter.name}-server.json`), build.metafile, "Server");
8820
8988
  }
8821
8989
  return {
8822
8990
  dir: targetDir,
8823
8991
  entry: `${basename5(adapter.runtimeModule, extname3(adapter.runtimeModule))}.js`,
8824
- files: build.outputs.filter((output) => output.path.endsWith(".js")).map((output) => toPosixPath(relative10(targetDir, output.path)))
8992
+ files: build.outputs.filter((output) => output.path.endsWith(".js")).map((output) => toPosixPath(relative9(targetDir, output.path)))
8825
8993
  };
8826
8994
  }
8827
8995
  function writePrerenderSnapshot(targetDir, prerenders) {
8828
8996
  const snapshot = Object.fromEntries(prerenders.map(({ prefix, ssg }) => [prefix, ssg]));
8829
- writeFileSync7(join15(targetDir, PRERENDER_SNAPSHOT_FILE), `${JSON.stringify(snapshot)}
8997
+ writeFileSync7(join14(targetDir, PRERENDER_SNAPSHOT_FILE), `${JSON.stringify(snapshot)}
8830
8998
  `);
8831
8999
  }
8832
9000
  async function buildAdapterTarget(adapter, apps, rootDir, buildRoot, serverEntry, options) {
8833
9001
  assertServerEntry(serverEntry, adapter);
8834
- const targetDir = join15(buildRoot, adapter.name);
9002
+ const targetDir = join14(buildRoot, adapter.name);
8835
9003
  rmSync3(targetDir, { force: true, recursive: true });
8836
9004
  rmSync3(privateServerSourceMapDir(buildRoot, adapter.name), {
8837
9005
  force: true,
@@ -8842,10 +9010,10 @@ async function buildAdapterTarget(adapter, apps, rootDir, buildRoot, serverEntry
8842
9010
  const rootIndex = apps.findIndex((app) => app.prefix === "");
8843
9011
  const { buildId } = builds[rootIndex === -1 ? 0 : rootIndex];
8844
9012
  const rscManifest = await buildRscGraph(apps, targetDir, buildId, options.plugins, options.serverExternalPackages);
8845
- const projectPublicDir = join15(rootDir, "public");
9013
+ const projectPublicDir = join14(rootDir, "public");
8846
9014
  const publicDir = existsSync12(projectPublicDir) ? projectPublicDir : undefined;
8847
9015
  if (publicDir !== undefined && adapter.capabilities.assets !== "platform") {
8848
- copyDirRecursive(publicDir, join15(targetDir, "public"));
9016
+ copyDirRecursive(publicDir, join14(targetDir, "public"));
8849
9017
  }
8850
9018
  const frameworkCache = adapter.capabilities.publicCache === "framework";
8851
9019
  const appEntry = await materializeServerAppEntry({
@@ -8864,7 +9032,7 @@ async function buildAdapterTarget(adapter, apps, rootDir, buildRoot, serverEntry
8864
9032
  const info = routeBuildInfo(route);
8865
9033
  return info.documentMode !== "ssr" && (info.queryKeys?.length ?? 0) === 0;
8866
9034
  }));
8867
- const prerenders = needsPrerender ? await prerenderFromBundle({ kind: "app", path: join15(targetDir, APP_MODULE) }, rootDir, frameworkCache) : [];
9035
+ const prerenders = needsPrerender ? await prerenderFromBundle({ kind: "app", path: join14(targetDir, APP_MODULE) }, rootDir, frameworkCache) : [];
8868
9036
  if (frameworkCache) {
8869
9037
  writePrerenderSnapshot(targetDir, prerenders);
8870
9038
  }
@@ -8888,7 +9056,7 @@ async function buildAdapterTarget(adapter, apps, rootDir, buildRoot, serverEntry
8888
9056
 
8889
9057
  // src/adapter/bun.ts
8890
9058
  import { existsSync as existsSync13, rmSync as rmSync4 } from "fs";
8891
- import { join as join16, relative as relative11 } from "path";
9059
+ import { join as join15, relative as relative10 } from "path";
8892
9060
  var RUNTIME_MODULE = frameworkSourceModule("adapter/bun/server.ts");
8893
9061
  var APP_RUNTIME_MODULE = frameworkSourceModule("adapter/bun/app.ts");
8894
9062
  function compiledServerFilename(platform) {
@@ -8897,12 +9065,12 @@ function compiledServerFilename(platform) {
8897
9065
  async function compileExecutable(output, compile, manifest) {
8898
9066
  const { apps, buildRoot, server } = output;
8899
9067
  const filename = compiledServerFilename(process.platform);
8900
- const publicDir = join16(server.dir, "public");
9068
+ const publicDir = join15(server.dir, "public");
8901
9069
  const embedded = compile === "embed" ? [...apps.map((app) => app.clientDir), ...existsSync13(publicDir) ? [publicDir] : []] : undefined;
8902
9070
  const build = await runBunBuild({
8903
9071
  bytecode: true,
8904
- compile: { assets: embedded, outfile: join16(server.dir, filename) },
8905
- entrypoints: [join16(server.dir, server.entry)],
9072
+ compile: { assets: embedded, outfile: join15(server.dir, filename) },
9073
+ entrypoints: [join15(server.dir, server.entry)],
8906
9074
  format: "esm",
8907
9075
  minify: true,
8908
9076
  sourcemap: output.serverSourceMaps ? "external" : "none",
@@ -8913,13 +9081,13 @@ async function compileExecutable(output, compile, manifest) {
8913
9081
  movePrivateServerSourceMaps(server.dir, privateServerSourceMapDir(buildRoot, "bun"), build.outputs.filter((entry) => entry.kind === "sourcemap").map((entry) => entry.path));
8914
9082
  }
8915
9083
  for (const file of [...server.files, PRERENDER_SNAPSHOT_FILE]) {
8916
- rmSync4(join16(server.dir, file), { force: true });
9084
+ rmSync4(join15(server.dir, file), { force: true });
8917
9085
  }
8918
- manifest.serverPath = toPosixPath(join16(manifest.targetDir, filename));
8919
- console.log(`[furin] Server binary: ${join16(server.dir, filename)}`);
9086
+ manifest.serverPath = toPosixPath(join15(manifest.targetDir, filename));
9087
+ console.log(`[furin] Server binary: ${join15(server.dir, filename)}`);
8920
9088
  if (compile === "embed") {
8921
9089
  for (const app of apps) {
8922
- rmSync4(join16(server.dir, clientDirNameForPrefix(app.prefix)), {
9090
+ rmSync4(join15(server.dir, clientDirNameForPrefix(app.prefix)), {
8923
9091
  force: true,
8924
9092
  recursive: true
8925
9093
  });
@@ -8942,15 +9110,15 @@ function bun(compile, bunOutput) {
8942
9110
  },
8943
9111
  name: "bun",
8944
9112
  async onBuildComplete(output) {
8945
- const targetDir = toPosixPath(relative11(output.rootDir, output.server.dir));
9113
+ const targetDir = toPosixPath(relative10(output.rootDir, output.server.dir));
8946
9114
  const manifest = {
8947
9115
  buildId: output.buildId,
8948
- clientDir: toPosixPath(join16(targetDir, "client")),
9116
+ clientDir: toPosixPath(join15(targetDir, "client")),
8949
9117
  generatedAt: new Date().toISOString(),
8950
- rscManifestPath: toPosixPath(join16(targetDir, "rsc", "manifest.json")),
8951
- serverPath: toPosixPath(join16(targetDir, output.server.entry)),
9118
+ rscManifestPath: toPosixPath(join15(targetDir, "rsc", "manifest.json")),
9119
+ serverPath: toPosixPath(join15(targetDir, output.server.entry)),
8952
9120
  targetDir,
8953
- templatePath: toPosixPath(join16(targetDir, "client", "index.html"))
9121
+ templatePath: toPosixPath(join15(targetDir, "client", "index.html"))
8954
9122
  };
8955
9123
  if (isApp) {
8956
9124
  manifest.appPath = manifest.serverPath;
@@ -8971,20 +9139,20 @@ function bun(compile, bunOutput) {
8971
9139
 
8972
9140
  // src/adapter/package.ts
8973
9141
  import { existsSync as existsSync14, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "fs";
8974
- import { join as join17, relative as relative12, resolve as resolve10 } from "path";
9142
+ import { join as join16, relative as relative11, resolve as resolve10 } from "path";
8975
9143
  async function buildPackageTarget(app, rootDir, buildRoot, options) {
8976
9144
  const { prefix, root, routes, pagesDir } = app;
8977
9145
  const modulePaths = routeSourcePaths(app);
8978
- const targetDir = join17(buildRoot, "package");
9146
+ const targetDir = join16(buildRoot, "package");
8979
9147
  rmSync5(targetDir, { force: true, recursive: true });
8980
9148
  ensureDir(targetDir);
8981
9149
  const { entryChunk, cssChunks, preloadManifest } = await buildClient(routes, {
8982
9150
  basePath: prefix,
8983
9151
  clientLogging: options.clientLogging ?? false,
8984
- metafilePath: options.analyze ? join17(buildRoot, "analysis", "package-client.json") : undefined,
9152
+ metafilePath: options.analyze ? join16(buildRoot, "analysis", "package-client.json") : undefined,
8985
9153
  optimizeImports: options.optimizeImports,
8986
9154
  outDir: targetDir,
8987
- pagesDir,
9155
+ pages: { pagesDir, style: app.style },
8988
9156
  routeRegistry: app.routeRegistry,
8989
9157
  plugins: options.plugins,
8990
9158
  preloadRouteChunks: options.preload?.routeChunks,
@@ -8995,30 +9163,14 @@ async function buildPackageTarget(app, rootDir, buildRoot, options) {
8995
9163
  const buildFingerprint = await createBuildFingerprint(`${prefix}
8996
9164
  ${entryChunk}`, cssChunks, routes, root, null, modulePaths, rootDir);
8997
9165
  const buildId = Bun.hash(buildFingerprint).toString(16).slice(0, 12);
8998
- const clientDir = join17(targetDir, "client");
8999
- const publicDir = join17(rootDir, "public");
9166
+ const clientDir = join16(targetDir, "client");
9167
+ const publicDir = join16(rootDir, "public");
9000
9168
  if (existsSync14(publicDir)) {
9001
- copyDirRecursive(publicDir, join17(targetDir, "public"));
9169
+ copyDirRecursive(publicDir, join16(targetDir, "public"));
9002
9170
  }
9003
9171
  const indexHtml = generateProdIndexHtml(entryChunk, cssChunks, buildId, undefined, false);
9004
- writeFileSync8(join17(clientDir, "index.html"), indexHtml);
9005
- const rootConventions = root.errorPath || root.notFoundPath ? {
9006
- errorPath: root.errorPath ? toPosixPath(root.errorPath) : undefined,
9007
- notFoundPath: root.notFoundPath ? toPosixPath(root.notFoundPath) : undefined
9008
- } : undefined;
9009
- const routeMetadata = {};
9010
- for (const route of routes) {
9011
- routeMetadata[toPosixPath(route.path)] = {
9012
- requestKeys: route.requestKeys,
9013
- requestKeysByLoader: route.requestKeysByLoader,
9014
- segmentBoundaries: route.segmentBoundaries.map((b) => ({
9015
- depth: b.depth,
9016
- errorPath: b.errorPath ? toPosixPath(b.errorPath) : undefined,
9017
- notFoundPath: b.notFoundPath ? toPosixPath(b.notFoundPath) : undefined,
9018
- path: toPosixPath(b.path)
9019
- }))
9020
- };
9021
- }
9172
+ writeFileSync8(join16(clientDir, "index.html"), indexHtml);
9173
+ const { rootConventions, routeMetadata } = buildCompileMetadata(root, routes);
9022
9174
  const registerSource = buildEntrySource({
9023
9175
  apps: [
9024
9176
  {
@@ -9038,7 +9190,7 @@ ${entryChunk}`, cssChunks, routes, root, null, modulePaths, rootDir);
9038
9190
  mode: "register",
9039
9191
  prerenderSnapshot: true
9040
9192
  });
9041
- const registerEntry = join17(targetDir, "register.ts");
9193
+ const registerEntry = join16(targetDir, "register.ts");
9042
9194
  const register = createVirtualBuildEntry(registerEntry, registerSource, "ts");
9043
9195
  const result = await runBunBuild({
9044
9196
  define: PRODUCTION_DEFINE,
@@ -9065,7 +9217,7 @@ ${entryChunk}`, cssChunks, routes, root, null, modulePaths, rootDir);
9065
9217
  if (!result.success) {
9066
9218
  throw new AggregateError(result.logs, "[furin] package register build failed");
9067
9219
  }
9068
- const relativePagesDir = toPosixPath(relative12(targetDir, resolve10(rootDir, pagesDir)));
9220
+ const relativePagesDir = toPosixPath(relative11(targetDir, resolve10(rootDir, pagesDir)));
9069
9221
  const factorySource = `// Auto-generated by \`furin build --target package\` \u2014 do not edit
9070
9222
  import { fileURLToPath } from "node:url";
9071
9223
  import { furin } from "@teyik0/furin";
@@ -9078,7 +9230,7 @@ const CLIENT_DIR = fileURLToPath(new URL("./client", import.meta.url));
9078
9230
  * Mounts this packaged furin app as an Elysia plugin.
9079
9231
  *
9080
9232
  * @param {object} [options] Extra furin() options (logger, sync, ...) \u2014
9081
- * pagesDir/prefix/clientDir are baked into the package and cannot be overridden.
9233
+ * pagesDir/prefix/style/clientDir are baked into the package and cannot be overridden.
9082
9234
  * @returns {ReturnType<typeof import("@teyik0/furin").furin>}
9083
9235
  */
9084
9236
  export function createFurinApp(options = {}) {
@@ -9086,45 +9238,46 @@ export function createFurinApp(options = {}) {
9086
9238
  ...options,
9087
9239
  pagesDir: PAGES_DIR,
9088
9240
  prefix: ${JSON.stringify(prefix)},
9241
+ style: ${JSON.stringify(app.style)},
9089
9242
  clientDir: CLIENT_DIR,
9090
9243
  });
9091
9244
  }
9092
9245
 
9093
9246
  export const prefix = ${JSON.stringify(prefix)};
9094
9247
  `;
9095
- writeFileSync8(join17(targetDir, "index.js"), factorySource);
9248
+ writeFileSync8(join16(targetDir, "index.js"), factorySource);
9096
9249
  const dtsSource = `import type { FurinOptions, furin } from "@teyik0/furin";
9097
9250
 
9098
- /** Extra furin() options \u2014 pagesDir/prefix/clientDir are baked into the package and cannot be overridden. */
9099
- export type CreateFurinAppOptions = Omit<FurinOptions, "pagesDir" | "prefix" | "clientDir">;
9251
+ /** Extra furin() options \u2014 pagesDir/prefix/style/clientDir are baked into the package and cannot be overridden. */
9252
+ export type CreateFurinAppOptions = Omit<FurinOptions, "pagesDir" | "prefix" | "style" | "clientDir">;
9100
9253
  export declare function createFurinApp(options?: CreateFurinAppOptions): ReturnType<typeof furin>;
9101
9254
  export declare const prefix: string;
9102
9255
  `;
9103
- writeFileSync8(join17(targetDir, "index.d.ts"), dtsSource);
9104
- const snapshotPath = join17(targetDir, PRERENDER_SNAPSHOT_FILE);
9256
+ writeFileSync8(join16(targetDir, "index.d.ts"), dtsSource);
9257
+ const snapshotPath = join16(targetDir, PRERENDER_SNAPSHOT_FILE);
9105
9258
  writeFileSync8(snapshotPath, `{}
9106
9259
  `);
9107
- const prerenders = await prerenderFromBundle({ kind: "package", path: join17(targetDir, "index.js") }, rootDir, true);
9260
+ const prerenders = await prerenderFromBundle({ kind: "package", path: join16(targetDir, "index.js") }, rootDir, true);
9108
9261
  writeFileSync8(snapshotPath, `${JSON.stringify(Object.fromEntries(prerenders.map(({ prefix: key, ssg }) => [key, ssg])))}
9109
9262
  `);
9110
- console.log(`[furin] Package artifact: ${toPosixPath(relative12(rootDir, targetDir))}`);
9263
+ console.log(`[furin] Package artifact: ${toPosixPath(relative11(rootDir, targetDir))}`);
9111
9264
  return {
9112
9265
  buildId,
9113
9266
  generatedAt: new Date().toISOString(),
9114
9267
  prefix,
9115
- targetDir: toPosixPath(relative12(rootDir, targetDir))
9268
+ targetDir: toPosixPath(relative11(rootDir, targetDir))
9116
9269
  };
9117
9270
  }
9118
9271
 
9119
9272
  // src/adapter/static.ts
9120
9273
  import { cpSync as cpSync2, existsSync as existsSync15, rmSync as rmSync6, writeFileSync as writeFileSync9 } from "fs";
9121
- import { dirname as dirname16, isAbsolute as isAbsolute6, join as join18, parse as parse4, relative as relative13, resolve as resolve11, sep as sep3, win32 } from "path";
9274
+ import { dirname as dirname16, isAbsolute as isAbsolute6, join as join17, parse as parse3, relative as relative12, resolve as resolve11, sep as sep3, win32 } from "path";
9122
9275
  var TRAILING_SLASHES_RE = /\/+$/;
9123
9276
  var STATIC_RENDER_ORIGIN = "http://localhost";
9124
9277
  function pathToOutputFile(urlPath, outDir, fileName) {
9125
9278
  const normalizedOutDir = resolve11(outDir);
9126
9279
  if (urlPath === "/" || urlPath === "") {
9127
- return join18(normalizedOutDir, fileName);
9280
+ return join17(normalizedOutDir, fileName);
9128
9281
  }
9129
9282
  const resolved = resolve11(normalizedOutDir, urlPath.slice(1), fileName);
9130
9283
  if (!resolved.startsWith(`${normalizedOutDir}${sep3}`)) {
@@ -9258,12 +9411,12 @@ function replaceOutDir(outDir, publicSrcDir, clientSrcDir, outputs, shellHtml) {
9258
9411
  cpSync2(publicSrcDir, outDir, { recursive: true, dereference: true });
9259
9412
  }
9260
9413
  if (existsSync15(clientSrcDir)) {
9261
- cpSync2(clientSrcDir, join18(outDir, "_client"), { recursive: true, dereference: true });
9414
+ cpSync2(clientSrcDir, join17(outDir, "_client"), { recursive: true, dereference: true });
9262
9415
  }
9263
9416
  for (const output of outputs) {
9264
9417
  writeStaticOutput(output);
9265
9418
  }
9266
- writeFileSync9(join18(outDir, "404.html"), shellHtml);
9419
+ writeFileSync9(join17(outDir, "404.html"), shellHtml);
9267
9420
  console.log("[furin] static: wrote 404.html (SPA shell fallback)");
9268
9421
  }
9269
9422
  function logRenderFailure(failure, error) {
@@ -9292,7 +9445,7 @@ var STATIC_ENTRY = "_furin-static";
9292
9445
  async function bundleStaticExport(app, shellHtml, preloadManifest, serverDir, rootDir, options) {
9293
9446
  const { root, routes } = app;
9294
9447
  const { rootConventions, routeMetadata } = buildCompileMetadata(root, routes);
9295
- const entry = createVirtualBuildEntry(join18(serverDir, `${STATIC_ENTRY}.ts`), buildEntrySource({
9448
+ const entry = createVirtualBuildEntry(join17(serverDir, `${STATIC_ENTRY}.ts`), buildEntrySource({
9296
9449
  apps: [
9297
9450
  {
9298
9451
  clientLogging: Boolean(options.clientLogging),
@@ -9339,7 +9492,7 @@ async function bundleStaticExport(app, shellHtml, preloadManifest, serverDir, ro
9339
9492
  throw new AggregateError(result.logs, "[furin] static export bundle failed");
9340
9493
  }
9341
9494
  await buildFlightCodec(serverDir, options.plugins);
9342
- return join18(serverDir, `${STATIC_ENTRY}.js`);
9495
+ return join17(serverDir, `${STATIC_ENTRY}.js`);
9343
9496
  }
9344
9497
  function assertNoRequestLoaders(routes, root) {
9345
9498
  const offenders = [];
@@ -9375,11 +9528,11 @@ async function buildStaticTarget(app, rootDir, buildRoot, options) {
9375
9528
  const outDir = resolve11(rootDir, rawOutDir);
9376
9529
  const normalizedRoot = resolve11(rootDir);
9377
9530
  const normalizedBuildRoot = resolve11(buildRoot);
9378
- if (outDir === normalizedRoot || outDir === normalizedBuildRoot || outDir === parse4(outDir).root || rawOutDir === win32.parse(rawOutDir).root) {
9531
+ if (outDir === normalizedRoot || outDir === normalizedBuildRoot || outDir === parse3(outDir).root || rawOutDir === win32.parse(rawOutDir).root) {
9379
9532
  throw new Error(`[furin] static: outDir resolves to "${outDir}" which is unsafe to delete. ` + `Use a dedicated output directory such as "dist".`);
9380
9533
  }
9381
9534
  function isOutsideOutDir(target) {
9382
- const rel = relative13(outDir, target);
9535
+ const rel = relative12(outDir, target);
9383
9536
  return rel.startsWith("..") || isAbsolute6(rel);
9384
9537
  }
9385
9538
  if (!(isOutsideOutDir(normalizedRoot) && isOutsideOutDir(normalizedBuildRoot))) {
@@ -9390,17 +9543,17 @@ async function buildStaticTarget(app, rootDir, buildRoot, options) {
9390
9543
  const renderedRoutes = [];
9391
9544
  const skippedRoutes = [];
9392
9545
  const ssgRoutes = collectSsgRoutes(routes, onSSR, skippedRoutes);
9393
- const targetDir = join18(buildRoot, "static");
9546
+ const targetDir = join17(buildRoot, "static");
9394
9547
  rmSync6(targetDir, { force: true, recursive: true });
9395
9548
  ensureDir(targetDir);
9396
9549
  try {
9397
9550
  const { entryChunk, cssChunks, preloadManifest } = await buildClient(ssgRoutes, {
9398
9551
  basePath,
9399
9552
  clientLogging: Boolean(options.clientLogging),
9400
- metafilePath: options.analyze ? join18(buildRoot, "analysis", "static-client.json") : undefined,
9553
+ metafilePath: options.analyze ? join17(buildRoot, "analysis", "static-client.json") : undefined,
9401
9554
  optimizeImports: options.optimizeImports,
9402
9555
  outDir: targetDir,
9403
- pagesDir: dirname16(root.path),
9556
+ pages: { pagesDir: app.pagesDir, style: app.style },
9404
9557
  routeRegistry: app.routeRegistry,
9405
9558
  plugins: options.plugins,
9406
9559
  preloadRouteChunks: options.preload?.routeChunks,
@@ -9408,16 +9561,16 @@ async function buildStaticTarget(app, rootDir, buildRoot, options) {
9408
9561
  reactCompiler: options.reactCompiler,
9409
9562
  rootLayout: root.path
9410
9563
  });
9411
- const publicFavicon = join18(rootDir, "public", "favicon.ico");
9564
+ const publicFavicon = join17(rootDir, "public", "favicon.ico");
9412
9565
  const faviconHref = existsSync15(publicFavicon) ? `${basePath}/favicon.ico` : undefined;
9413
9566
  const shellHtml = generateProdIndexHtml(entryChunk, cssChunks, undefined, faviconHref, true);
9414
- const bundle = await bundleStaticExport(app, shellHtml, preloadManifest, join18(targetDir, "server"), rootDir, options);
9567
+ const bundle = await bundleStaticExport(app, shellHtml, preloadManifest, join17(targetDir, "server"), rootDir, options);
9415
9568
  const exported = await exportStaticFromBundle(bundle, rootDir, {
9416
9569
  basePath,
9417
9570
  patterns: ssgRoutes.map((route) => route.pattern)
9418
9571
  });
9419
9572
  const outputs = await collectStaticOutputs(exported, outDir, basePath, onSSR, skippedRoutes);
9420
- replaceOutDir(outDir, join18(rootDir, "public"), join18(targetDir, "client"), outputs, shellHtml);
9573
+ replaceOutDir(outDir, join17(rootDir, "public"), join17(targetDir, "client"), outputs, shellHtml);
9421
9574
  renderedRoutes.push(...outputs.map((output) => output.path));
9422
9575
  } finally {
9423
9576
  rmSync6(targetDir, { force: true, recursive: true });
@@ -9442,7 +9595,7 @@ import {
9442
9595
  symlinkSync,
9443
9596
  writeFileSync as writeFileSync10
9444
9597
  } from "fs";
9445
- import { basename as basename6, dirname as dirname17, join as join19, relative as relative14 } from "path";
9598
+ import { basename as basename6, dirname as dirname17, join as join18, relative as relative13 } from "path";
9446
9599
  import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL3 } from "url";
9447
9600
 
9448
9601
  // src/adapter/vercel/data.ts
@@ -9488,7 +9641,7 @@ function assertRegions(regions) {
9488
9641
  }
9489
9642
  function frameworkVersion() {
9490
9643
  const packageRoot = dirname17(dirname17(fileURLToPath9(import.meta.resolve("@teyik0/furin"))));
9491
- const packageJson = JSON.parse(readFileSync8(join19(packageRoot, "package.json"), "utf8"));
9644
+ const packageJson = JSON.parse(readFileSync8(join18(packageRoot, "package.json"), "utf8"));
9492
9645
  return packageJson.version;
9493
9646
  }
9494
9647
  function encodeCacheTag(value) {
@@ -9513,7 +9666,7 @@ function functionNameForPath(path, mode, names) {
9513
9666
  return "[...splat]";
9514
9667
  }
9515
9668
  if (segment.startsWith(":")) {
9516
- return `[${segment.slice(1)}]`;
9669
+ return segment.endsWith("?") ? `[[${segment.slice(1, -1)}]]` : `[${segment.slice(1)}]`;
9517
9670
  }
9518
9671
  const sanitized = segment.replace(UNSAFE_FUNCTION_PATH_RE, "-");
9519
9672
  if (sanitized === segment && segment !== "." && segment !== "..") {
@@ -9628,7 +9781,7 @@ async function addPrerenderFallback(job, response, functionsDir) {
9628
9781
  const { spec } = job;
9629
9782
  const fallback = `${basename6(spec.functionName)}.prerender-fallback.html`;
9630
9783
  const location = response.headers.get("location") ?? undefined;
9631
- const fallbackPath = join19(dirname17(join19(functionsDir, spec.functionName)), fallback);
9784
+ const fallbackPath = join18(dirname17(join18(functionsDir, spec.functionName)), fallback);
9632
9785
  ensureDir(dirname17(fallbackPath));
9633
9786
  writeFileSync10(fallbackPath, await response.text());
9634
9787
  spec.config.fallback = fallback;
@@ -9644,10 +9797,10 @@ async function buildProductionFallbacks(jobs, functionsDir, rootDir, buildRoot)
9644
9797
  if (jobs.length === 0) {
9645
9798
  return;
9646
9799
  }
9647
- const resultPath = join19(buildRoot, `vercel-prerender-${crypto.randomUUID()}.json`);
9800
+ const resultPath = join18(buildRoot, `vercel-prerender-${crypto.randomUUID()}.json`);
9648
9801
  const requests = jobs.map(({ path, spec }) => `http://localhost/${spec.functionName}?${ISR_PATH_PARAM}=${encodeURIComponent(path)}`);
9649
9802
  const script = `
9650
- const handler = (await import(${JSON.stringify(pathToFileURL3(join19(functionsDir, "__server.func/index.js")).href)})).default;
9803
+ const handler = (await import(${JSON.stringify(pathToFileURL3(join18(functionsDir, "__server.func/index.js")).href)})).default;
9651
9804
  const results = [];
9652
9805
  for (const [index, url] of ${JSON.stringify(requests)}.entries()) {
9653
9806
  const response = await handler.fetch(new Request(url));
@@ -9702,9 +9855,9 @@ async function buildBootstrap(serverFunctionDir) {
9702
9855
  });
9703
9856
  }
9704
9857
  function createFunctionAlias(functionsDir, serverFunctionDir, functionName) {
9705
- const aliasPath = join19(functionsDir, `${functionName}.func`);
9858
+ const aliasPath = join18(functionsDir, `${functionName}.func`);
9706
9859
  ensureDir(dirname17(aliasPath));
9707
- const target = relative14(dirname17(aliasPath), serverFunctionDir);
9860
+ const target = relative13(dirname17(aliasPath), serverFunctionDir);
9708
9861
  symlinkSync(target, aliasPath, process.platform === "win32" ? "junction" : "dir");
9709
9862
  }
9710
9863
  function copyStaticAssets(output, staticDir) {
@@ -9712,16 +9865,16 @@ function copyStaticAssets(output, staticDir) {
9712
9865
  if (publicDir !== undefined) {
9713
9866
  cpSync3(publicDir, staticDir, { recursive: true });
9714
9867
  for (const app of apps) {
9715
- const appStaticDir = join19(staticDir, app.prefix.slice(1));
9716
- cpSync3(publicDir, join19(appStaticDir, "public"), { recursive: true });
9717
- const favicon = join19(publicDir, "favicon.ico");
9868
+ const appStaticDir = join18(staticDir, app.prefix.slice(1));
9869
+ cpSync3(publicDir, join18(appStaticDir, "public"), { recursive: true });
9870
+ const favicon = join18(publicDir, "favicon.ico");
9718
9871
  if (app.prefix !== "" && existsSync16(favicon)) {
9719
- cpSync3(favicon, join19(appStaticDir, "favicon.ico"));
9872
+ cpSync3(favicon, join18(appStaticDir, "favicon.ico"));
9720
9873
  }
9721
9874
  }
9722
9875
  }
9723
9876
  for (const app of apps) {
9724
- cpSync3(app.clientDir, join19(staticDir, app.prefix.slice(1), "_client"), { recursive: true });
9877
+ cpSync3(app.clientDir, join18(staticDir, app.prefix.slice(1), "_client"), { recursive: true });
9725
9878
  }
9726
9879
  }
9727
9880
  function buildOutputConfig(apps, specs) {
@@ -9755,7 +9908,7 @@ function buildOutputConfig(apps, specs) {
9755
9908
  };
9756
9909
  }
9757
9910
  function writeFunctionConfig(serverFunctionDir, regions) {
9758
- writeFileSync10(join19(serverFunctionDir, ".vc-config.json"), `${JSON.stringify({
9911
+ writeFileSync10(join18(serverFunctionDir, ".vc-config.json"), `${JSON.stringify({
9759
9912
  handler: "index.js",
9760
9913
  launcherType: "Nodejs",
9761
9914
  ...regions === undefined ? {} : { regions },
@@ -9772,39 +9925,39 @@ function vercel(options) {
9772
9925
  name: "vercel",
9773
9926
  async onBuildComplete(output) {
9774
9927
  const { apps, rootDir, server } = output;
9775
- const outputDir = join19(rootDir, ".vercel", "output");
9776
- const staticDir = join19(outputDir, "static");
9777
- const functionsDir = join19(outputDir, "functions");
9778
- const serverFunctionDir = join19(functionsDir, "__server.func");
9928
+ const outputDir = join18(rootDir, ".vercel", "output");
9929
+ const staticDir = join18(outputDir, "static");
9930
+ const functionsDir = join18(outputDir, "functions");
9931
+ const serverFunctionDir = join18(functionsDir, "__server.func");
9779
9932
  rmSync7(outputDir, { force: true, recursive: true });
9780
9933
  ensureDir(staticDir);
9781
9934
  ensureDir(serverFunctionDir);
9782
9935
  for (const file of [...server.files, "server-codec.js"]) {
9783
- cpSync3(join19(server.dir, file), join19(serverFunctionDir, file));
9936
+ cpSync3(join18(server.dir, file), join18(serverFunctionDir, file));
9784
9937
  }
9785
9938
  copyStaticAssets(output, staticDir);
9786
9939
  const pprResumeKey = crypto.randomUUID();
9787
9940
  const { jobs, specs } = createPrerenderSpecs(apps, pprResumeKey);
9788
- const serverBundleBytes = server.files.reduce((total, file) => total + statSync2(join19(server.dir, file)).size, 0);
9789
- writeFileSync10(join19(serverFunctionDir, VERCEL_DATA_FILE), `${JSON.stringify(runtimeData(apps, specs, pprResumeKey, serverBundleBytes))}
9941
+ const serverBundleBytes = server.files.reduce((total, file) => total + statSync2(join18(server.dir, file)).size, 0);
9942
+ writeFileSync10(join18(serverFunctionDir, VERCEL_DATA_FILE), `${JSON.stringify(runtimeData(apps, specs, pprResumeKey, serverBundleBytes))}
9790
9943
  `);
9791
9944
  await buildBootstrap(serverFunctionDir);
9792
9945
  await buildProductionFallbacks(jobs, functionsDir, rootDir, output.buildRoot);
9793
9946
  writeFunctionConfig(serverFunctionDir, options.regions);
9794
9947
  for (const spec of specs) {
9795
9948
  createFunctionAlias(functionsDir, serverFunctionDir, spec.functionName);
9796
- writeFileSync10(join19(functionsDir, `${spec.functionName}.prerender-config.json`), `${JSON.stringify(spec.config, null, 2)}
9949
+ writeFileSync10(join18(functionsDir, `${spec.functionName}.prerender-config.json`), `${JSON.stringify(spec.config, null, 2)}
9797
9950
  `);
9798
9951
  }
9799
- writeFileSync10(join19(outputDir, "config.json"), `${JSON.stringify(buildOutputConfig(apps, specs), null, 2)}
9952
+ writeFileSync10(join18(outputDir, "config.json"), `${JSON.stringify(buildOutputConfig(apps, specs), null, 2)}
9800
9953
  `);
9801
- console.log(`[furin] Vercel output: ${toPosixPath(relative14(rootDir, outputDir))}`);
9954
+ console.log(`[furin] Vercel output: ${toPosixPath(relative13(rootDir, outputDir))}`);
9802
9955
  return {
9803
9956
  buildId: output.buildId,
9804
9957
  generatedAt: new Date().toISOString(),
9805
9958
  isrRoutes: apps.flatMap((app) => app.routes.filter((route) => route.mode === "isr").map((route) => physicalPath(app.prefix, route.pattern))).toSorted(),
9806
- outputDir: toPosixPath(relative14(rootDir, outputDir)),
9807
- serverPath: toPosixPath(relative14(rootDir, serverFunctionDir)),
9959
+ outputDir: toPosixPath(relative13(rootDir, outputDir)),
9960
+ serverPath: toPosixPath(relative13(rootDir, serverFunctionDir)),
9808
9961
  ssgRoutes: jobs.filter((job) => job.route.mode === "ssg").map((job) => job.path).toSorted()
9809
9962
  };
9810
9963
  },
@@ -9816,10 +9969,12 @@ function vercel(options) {
9816
9969
  import { t } from "elysia";
9817
9970
  var BUILD_TARGETS = ["bun", "vercel", "static", "package"];
9818
9971
  var compileTargetSchema = t.Union([t.Literal("server"), t.Literal("embed")]);
9972
+ var routeStyleSchema = t.Union([t.Literal("nextjs"), t.Literal("tanstack")]);
9819
9973
  var configSchema = t.Object({
9820
9974
  apps: t.Optional(t.Array(t.Object({
9821
9975
  pagesDir: t.String(),
9822
- prefix: t.Optional(t.String())
9976
+ prefix: t.Optional(t.String()),
9977
+ style: routeStyleSchema
9823
9978
  }))),
9824
9979
  bun: t.Optional(t.Object({
9825
9980
  compile: t.Optional(compileTargetSchema),
@@ -9834,6 +9989,7 @@ var configSchema = t.Object({
9834
9989
  rootDir: t.Optional(t.String()),
9835
9990
  serverEntry: t.Optional(t.String()),
9836
9991
  serverSourceMaps: t.Optional(t.Boolean()),
9992
+ style: t.Optional(routeStyleSchema),
9837
9993
  static: t.Optional(t.Object({
9838
9994
  basePath: t.Optional(t.String()),
9839
9995
  onSSR: t.Optional(t.Union([t.Literal("error"), t.Literal("skip")])),
@@ -9843,13 +9999,8 @@ var configSchema = t.Object({
9843
9999
 
9844
10000
  // src/plugin/route-config.ts
9845
10001
  import { existsSync as existsSync17, readFileSync as readFileSync9, writeFileSync as writeFileSync11 } from "fs";
9846
- import { basename as basename7, join as join20, relative as relative15, resolve as resolve12 } from "path";
9847
- var EXTENSION_RE = /\.(?:[cm]?[jt]sx?)$/;
10002
+ import { relative as relative14, resolve as resolve12 } from "path";
9848
10003
  var IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/;
9849
- var PATH_SEPARATOR_RE = /[\\/]/;
9850
- function withoutExtension(path) {
9851
- return path.replace(EXTENSION_RE, "");
9852
- }
9853
10004
  function propertyName(key) {
9854
10005
  if (key?.type === "Identifier") {
9855
10006
  return key.name;
@@ -9930,9 +10081,9 @@ function position2(source, offset) {
9930
10081
  function issueAt(file, parsed, node, message) {
9931
10082
  return { file, ...position2(parsed.source, node.start), message };
9932
10083
  }
9933
- function checkKey(file, instance, parsed) {
10084
+ function checkKey(file, route, parsed) {
9934
10085
  const { config, head, id } = parsed.route;
9935
- const expected = fileRouteId(instance, file);
10086
+ const expected = route.id;
9936
10087
  if (!id) {
9937
10088
  return issueAt(file, parsed, head, `defineRoute() must name this file. Its id is "${expected}":
9938
10089
  defineRoute("${expected}")`);
@@ -9961,21 +10112,21 @@ function suggestedMode(route, isRoot) {
9961
10112
  }
9962
10113
  return route.methods.has("loader") || route.methods.has("requestLoader") ? "ssr" : "ssg";
9963
10114
  }
9964
- function checkFactory(file, instance, parsed) {
10115
+ function checkFactory(file, manifestRoute, parsed) {
9965
10116
  const { route } = parsed;
9966
- const isRoot = withoutExtension(file) === join20(instance.pagesDir, "root");
10117
+ const isRoot = manifestRoute === undefined;
9967
10118
  if (isRoot === route.isRootFactory) {
9968
10119
  return;
9969
10120
  }
9970
10121
  const mode = suggestedMode(route, isRoot);
9971
10122
  if (isRoot) {
9972
- return issueAt(file, parsed, route.head, `root.tsx must use defineRootRoute(), which has no parent layout:
10123
+ return issueAt(file, parsed, route.head, `The root layout must use defineRootRoute(), which has no parent layout:
9973
10124
  import { defineRootRoute } from "@teyik0/furin";
9974
10125
  export const route = defineRootRoute().config({ mode: "${mode}" })`);
9975
10126
  }
9976
- return issueAt(file, parsed, route.head, `defineRootRoute() is reserved for root.tsx. Use defineRoute with this file's id:
10127
+ return issueAt(file, parsed, route.head, `defineRootRoute() is reserved for the root layout. Use defineRoute with this file's id:
9977
10128
  import { defineRoute } from "@teyik0/furin";
9978
- export const route = defineRoute("${fileRouteId(instance, file)}").config({ mode: "${mode}" })`);
10129
+ export const route = defineRoute("${manifestRoute.id}").config({ mode: "${mode}" })`);
9979
10130
  }
9980
10131
  function checkConfig(file, parsed) {
9981
10132
  const { route } = parsed;
@@ -10006,56 +10157,64 @@ function declaredParams(route) {
10006
10157
  }
10007
10158
  return new Set(keys.filter((key) => key !== undefined));
10008
10159
  }
10009
- function undeclaredSegments(file, pagesDir, declared) {
10010
- return withoutExtension(relative15(pagesDir, file)).split(PATH_SEPARATOR_RE).flatMap((segment) => {
10011
- const dynamic = parseDynamicRouteSegment(segment, file);
10012
- return dynamic ? [{ key: dynamic.catchAll ? "*" : dynamic.name, segment }] : [];
10013
- }).filter(({ key }) => declared !== true && !declared.has(key));
10160
+ function undeclaredParams(route, declared) {
10161
+ return route.params.filter(({ name }) => declared !== true && !declared.has(name));
10014
10162
  }
10015
- function paramsSchema(segments) {
10016
- const fields = segments.map(({ key }) => `${IDENTIFIER_RE.test(key) ? key : JSON.stringify(key)}: t.String()`);
10163
+ function paramsSchema(params) {
10164
+ const fields = params.map(({ name, optional }) => `${IDENTIFIER_RE.test(name) ? name : JSON.stringify(name)}: ${optional ? "t.Optional(t.String())" : "t.String()"}`);
10017
10165
  return `params: t.Object({ ${fields.join(", ")} })`;
10018
10166
  }
10019
- function checkParams(file, pagesDir, parsed) {
10020
- const missing = undeclaredSegments(file, pagesDir, declaredParams(parsed.route));
10167
+ function checkParams(file, route, parsed) {
10168
+ const missing = undeclaredParams(route, declaredParams(parsed.route));
10021
10169
  if (missing.length === 0) {
10022
10170
  return;
10023
10171
  }
10024
10172
  const plural = missing.length > 1;
10025
10173
  const tImport = parsed.imports.get("t")?.specifier === "elysia" ? "" : `
10026
10174
  import { t } from "elysia";`;
10027
- return issueAt(file, parsed, parsed.route.config ?? parsed.route.head, `The URL segment${plural ? "s" : ""} ${missing.map(({ segment }) => segment).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}
10175
+ 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}
10028
10176
  ${paramsSchema(missing)}`);
10029
10177
  }
10030
- function checkRoute(file, instance, parsed) {
10031
- const factory = checkFactory(file, instance, parsed);
10178
+ function checkBoundaryMethods(file, instance, parsed) {
10179
+ const method = ["error", "notFound"].find((name) => parsed.route.methods.has(name));
10180
+ if (instance.style !== "nextjs" || method === undefined) {
10181
+ return;
10182
+ }
10183
+ const convention = method === "error" ? "an error.tsx" : "a not-found.tsx";
10184
+ 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.`);
10185
+ }
10186
+ function checkRoute(file, instance, route, parsed) {
10187
+ const factory = checkFactory(file, route, parsed);
10032
10188
  if (factory) {
10033
10189
  return [factory];
10034
10190
  }
10035
- const isLayout = basename7(withoutExtension(file)) === "_route";
10036
10191
  return [
10037
10192
  checkConfig(file, parsed),
10038
- parsed.route.isRootFactory ? undefined : checkKey(file, instance, parsed),
10193
+ route === undefined ? undefined : checkKey(file, route, parsed),
10039
10194
  checkMode(file, parsed),
10040
- parsed.route.isRootFactory || isLayout ? undefined : checkParams(file, instance.pagesDir, parsed)
10195
+ route === undefined || route.kind === "layout" ? undefined : checkParams(file, route, parsed),
10196
+ checkBoundaryMethods(file, instance, parsed)
10041
10197
  ];
10042
10198
  }
10043
- function routeFiles(pagesDir) {
10044
- const root = join20(pagesDir, "root.tsx");
10045
- return [
10046
- ...existsSync17(root) ? [root] : [],
10047
- ...routeSourcePaths({ pagesDir, prefix: "" })
10048
- ].toSorted((left, right) => left.localeCompare(right));
10199
+ function routeFiles(manifest) {
10200
+ const files = manifest.routes.map((route) => [
10201
+ resolve12(route.sourcePath),
10202
+ route
10203
+ ]);
10204
+ if (existsSync17(manifest.rootPath)) {
10205
+ files.push([resolve12(manifest.rootPath), undefined]);
10206
+ }
10207
+ return files.toSorted(([left], [right]) => left.localeCompare(right));
10049
10208
  }
10050
- function validateRouteConfig({ pagesDir, prefix }) {
10051
- const instance = { pagesDir: resolve12(pagesDir), prefix };
10052
- return routeFiles(instance.pagesDir).flatMap((file) => {
10209
+ function validateRouteConfig(spec) {
10210
+ const instance = { ...spec, pagesDir: resolve12(spec.pagesDir) };
10211
+ return routeFiles(scanRouteManifest(instance)).flatMap(([file, route]) => {
10053
10212
  const parsed = parseRoute(file);
10054
- return parsed ? checkRoute(file, instance, parsed).filter((issue) => issue !== undefined) : [];
10213
+ return parsed ? checkRoute(file, instance, route, parsed).filter((issue) => issue !== undefined) : [];
10055
10214
  });
10056
10215
  }
10057
10216
  function displayPath(file) {
10058
- const projected = relative15(process.cwd(), file).replaceAll("\\", "/");
10217
+ const projected = relative14(process.cwd(), file).replaceAll("\\", "/");
10059
10218
  return projected.startsWith("../") ? file : projected;
10060
10219
  }
10061
10220
  function formatRouteConfigIssue(issue) {
@@ -10072,10 +10231,10 @@ function assertValidRouteConfig(instance) {
10072
10231
 
10073
10232
  // src/build/discover-mounts.ts
10074
10233
  import { readFileSync as readFileSync10, rmSync as rmSync8 } from "fs";
10075
- import { join as join21 } from "path";
10234
+ import { join as join19 } from "path";
10076
10235
  var DISCOVERY_PROCESS = frameworkSourceModule("build/discover-mounts-process.ts");
10077
10236
  async function discoverFurinMounts(serverEntry, rootDir) {
10078
- const resultPath = join21(rootDir, ".furin", "build", `mounts-${crypto.randomUUID()}.json`);
10237
+ const resultPath = join19(rootDir, ".furin", "build", `mounts-${crypto.randomUUID()}.json`);
10079
10238
  const child = Bun.spawn([process.execPath, DISCOVERY_PROCESS, serverEntry, resultPath], {
10080
10239
  cwd: rootDir,
10081
10240
  env: { ...process.env, NODE_ENV: "production" },
@@ -10102,7 +10261,7 @@ ${stdout}
10102
10261
 
10103
10262
  // src/build/discover-pages.ts
10104
10263
  import { mkdtempSync, readFileSync as readFileSync11, renameSync as renameSync3, rmSync as rmSync9, writeFileSync as writeFileSync12 } from "fs";
10105
- import { join as join22 } from "path";
10264
+ import { join as join20 } from "path";
10106
10265
  import { serialize } from "v8";
10107
10266
 
10108
10267
  // src/build/discovery-plugins.ts
@@ -10173,10 +10332,10 @@ async function discoveryPlugins(plugins) {
10173
10332
  // src/build/discover-pages.ts
10174
10333
  async function discoverPages(apps, rootDir, plugins) {
10175
10334
  const runtime = await discoveryPlugins(plugins);
10176
- const buildDir = join22(rootDir, ".furin/build");
10335
+ const buildDir = join20(rootDir, ".furin/build");
10177
10336
  ensureDir(buildDir);
10178
- const directory = mkdtempSync(join22(buildDir, "discovery-"));
10179
- const resultPath = join22(directory, "pages.json");
10337
+ const directory = mkdtempSync(join20(buildDir, "discovery-"));
10338
+ const resultPath = join20(directory, "pages.json");
10180
10339
  const child = Bun.spawn([
10181
10340
  process.execPath,
10182
10341
  frameworkSourceModule("build/discover-pages-process.ts"),
@@ -10246,22 +10405,21 @@ async function resolveAppSpecs(options, serverEntry, rootDir) {
10246
10405
  if (options.apps && options.apps.length > 0) {
10247
10406
  return options.apps.map((app) => ({
10248
10407
  pagesDir: resolve13(rootDir, app.pagesDir),
10249
- prefix: normalizePrefix(app.prefix)
10408
+ prefix: normalizePrefix(app.prefix),
10409
+ style: app.style
10250
10410
  }));
10251
10411
  }
10252
- if (options.pagesDir) {
10253
- return [{ pagesDir: resolve13(rootDir, options.pagesDir), prefix: "" }];
10254
- }
10255
10412
  if (serverEntry) {
10256
10413
  const mounted = await discoverFurinMounts(serverEntry, rootDir);
10257
10414
  if (mounted.length > 0) {
10258
10415
  return mounted.map((app) => ({
10259
10416
  pagesDir: resolve13(rootDir, app.pagesDir),
10260
- prefix: app.prefix
10417
+ prefix: app.prefix,
10418
+ style: app.style
10261
10419
  }));
10262
10420
  }
10263
10421
  }
10264
- return [{ pagesDir: resolve13(rootDir, "src/pages"), prefix: "" }];
10422
+ throw new Error(`[furin] No app to build: ${serverEntry ? `${toPosixPath(relative15(rootDir, serverEntry))} mounts no furin() plugin` : "no server entry found"}. Mount furin({ style }) in the server entry, or list the apps in furin.config.ts: apps: [{ pagesDir: "src/routes", style: "tanstack" }].`);
10265
10423
  }
10266
10424
  async function scanApps(options, serverEntry, rootDir) {
10267
10425
  const appSpecs = await resolveAppSpecs(options, serverEntry, rootDir);
@@ -10290,9 +10448,13 @@ function generateRouteTypes(options) {
10290
10448
  async function buildApp(options) {
10291
10449
  return withProductionBuild(() => buildAppInternal(options));
10292
10450
  }
10451
+ function existingServerEntry(options, rootDir) {
10452
+ const entry = resolve13(rootDir, options.serverEntry ?? "src/server.ts");
10453
+ return existsSync18(entry) ? entry : null;
10454
+ }
10293
10455
  async function buildAppInternal(options) {
10294
10456
  const rootDir = resolve13(options.rootDir ?? process.cwd());
10295
- const buildRoot = join23(rootDir, BUILD_OUTPUT_DIR);
10457
+ const buildRoot = join21(rootDir, BUILD_OUTPUT_DIR);
10296
10458
  const targets = requestedTargets(options.target);
10297
10459
  const serverEntry = (() => {
10298
10460
  if (targets.every(isServerless)) {
@@ -10310,7 +10472,8 @@ async function buildAppInternal(options) {
10310
10472
  }
10311
10473
  return entry;
10312
10474
  })();
10313
- const apps = await scanApps(options, serverEntry, rootDir);
10475
+ const mountEntry = serverEntry ?? existingServerEntry(options, rootDir);
10476
+ const apps = await scanApps(options, mountEntry, rootDir);
10314
10477
  writeAppRouteTypes(apps, rootDir);
10315
10478
  const primaryApp = apps.find((app) => app.prefix === "") ?? apps[0];
10316
10479
  ensureDir(buildRoot);
@@ -10318,13 +10481,14 @@ async function buildAppInternal(options) {
10318
10481
  version: 1,
10319
10482
  generatedAt: new Date().toISOString(),
10320
10483
  rootDir: toPosixPath(rootDir),
10321
- pagesDir: toPosixPath(relative16(rootDir, primaryApp.pagesDir)),
10322
- rootPath: toPosixPath(relative16(rootDir, primaryApp.root.path)),
10323
- serverEntry: serverEntry ? toPosixPath(relative16(rootDir, serverEntry)) : null,
10484
+ pagesDir: toPosixPath(relative15(rootDir, primaryApp.pagesDir)),
10485
+ rootPath: toPosixPath(relative15(rootDir, primaryApp.root.path)),
10486
+ serverEntry: serverEntry ? toPosixPath(relative15(rootDir, serverEntry)) : null,
10324
10487
  routes: primaryApp.routes.map((route) => toBuildRouteManifestEntry(route, rootDir)),
10325
10488
  apps: apps.map((app) => ({
10326
- pagesDir: toPosixPath(relative16(rootDir, app.pagesDir)),
10489
+ pagesDir: toPosixPath(relative15(rootDir, app.pagesDir)),
10327
10490
  prefix: app.prefix,
10491
+ style: app.style,
10328
10492
  routes: app.routes.map((route) => toBuildRouteManifestEntry(route, rootDir))
10329
10493
  })),
10330
10494
  targets: {}
@@ -10350,7 +10514,7 @@ async function buildAppInternal(options) {
10350
10514
  const adapter = adapterFor(target, options);
10351
10515
  manifest.targets[adapter.name] = await buildAdapterTarget(adapter, apps, rootDir, buildRoot, serverEntry, options);
10352
10516
  }
10353
- writeFileSync13(join23(buildRoot, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
10517
+ writeFileSync13(join21(buildRoot, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
10354
10518
  `);
10355
10519
  return {
10356
10520
  manifest,