@farm.js/core 0.1.0-beta.13 → 0.1.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3WIRO3N7.mjs → chunk-ARCGE2VT.mjs} +2 -2
- package/dist/{chunk-3WIRO3N7.mjs.map → chunk-ARCGE2VT.mjs.map} +1 -1
- package/dist/{chunk-Z3YG4OZT.mjs → chunk-PNFQQSRA.mjs} +31 -11
- package/dist/chunk-PNFQQSRA.mjs.map +1 -0
- package/dist/{chunk-VSDZEB5M.mjs → chunk-VUL55IAX.mjs} +2 -2
- package/dist/index.cjs +30 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/internal/build-runtime.cjs +30 -10
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/plugin.cjs +29 -9
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/server.cjs +30 -10
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +30 -10
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +1 -1
- package/types/client.d.ts +115 -4
- package/dist/chunk-Z3YG4OZT.mjs.map +0 -1
- /package/dist/{chunk-VSDZEB5M.mjs.map → chunk-VUL55IAX.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-VUL55IAX.mjs";
|
|
4
4
|
import "../chunk-4S3ORGFA.mjs";
|
|
5
5
|
import "../chunk-SL6HTIOK.mjs";
|
|
6
6
|
import "../chunk-OPHK6OJN.mjs";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import "../chunk-UVCIEUJC.mjs";
|
|
14
14
|
import "../chunk-DJSGLHCN.mjs";
|
|
15
15
|
import "../chunk-RQ633A5I.mjs";
|
|
16
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-PNFQQSRA.mjs";
|
|
17
17
|
import "../chunk-LGHEOHBU.mjs";
|
|
18
18
|
import "../chunk-FRPWCMMG.mjs";
|
|
19
19
|
import "../chunk-53MVSX3R.mjs";
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
import "../chunk-PFE6GMNE.mjs";
|
|
56
56
|
import "../chunk-RHIFZZUI.mjs";
|
|
57
57
|
import "../chunk-LM2YNO4U.mjs";
|
|
58
|
-
import "../chunk-
|
|
58
|
+
import "../chunk-ARCGE2VT.mjs";
|
|
59
59
|
import "../chunk-KLA67WKG.mjs";
|
|
60
60
|
import "../chunk-ITN462YM.mjs";
|
|
61
61
|
import "../chunk-B232I2GP.mjs";
|
package/dist/plugin.cjs
CHANGED
|
@@ -20938,39 +20938,48 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
20938
20938
|
const { root, srcDir = "src", extraRoutes = [], suppressLintOnLink = false } = options;
|
|
20939
20939
|
const sourceRoots = options.sourceRoots ?? [{ name: "project", root, srcDir, layer: false }];
|
|
20940
20940
|
const patterns = /* @__PURE__ */ new Set();
|
|
20941
|
+
const routeModulePatterns = /* @__PURE__ */ new Set();
|
|
20941
20942
|
const glob = await import("fast-glob");
|
|
20942
20943
|
for (const source of sourceRoots) {
|
|
20943
20944
|
const appDir = path14.join(source.root, source.srcDir, "app");
|
|
20944
20945
|
if (fs5.existsSync(appDir)) {
|
|
20945
|
-
const
|
|
20946
|
-
|
|
20947
|
-
|
|
20948
|
-
|
|
20949
|
-
|
|
20946
|
+
const routeModuleFiles = await glob.default(
|
|
20947
|
+
"**/{page,layout,loading,error}.{ts,tsx,js,jsx,md,mdx}",
|
|
20948
|
+
{
|
|
20949
|
+
cwd: appDir,
|
|
20950
|
+
absolute: false
|
|
20951
|
+
}
|
|
20952
|
+
);
|
|
20953
|
+
for (const file of routeModuleFiles) {
|
|
20950
20954
|
if (parseRouteSlotFile(file)) continue;
|
|
20951
20955
|
const route = parseRoutePath(file);
|
|
20956
|
+
const pattern = createRoutePattern(route);
|
|
20957
|
+
routeModulePatterns.add(pattern);
|
|
20952
20958
|
if (route.type === "page") {
|
|
20953
|
-
const pattern = createRoutePattern(route);
|
|
20954
20959
|
patterns.add(pattern);
|
|
20955
20960
|
}
|
|
20956
20961
|
}
|
|
20957
20962
|
}
|
|
20958
20963
|
for (const route of await discoverProgrammaticRoutePaths(source.root, source.srcDir)) {
|
|
20959
20964
|
patterns.add(route);
|
|
20965
|
+
routeModulePatterns.add(route);
|
|
20960
20966
|
}
|
|
20961
20967
|
}
|
|
20962
20968
|
for (const route of extraRoutes) {
|
|
20963
20969
|
if (route.startsWith("/")) {
|
|
20964
20970
|
patterns.add(route);
|
|
20971
|
+
routeModulePatterns.add(route);
|
|
20965
20972
|
}
|
|
20966
20973
|
}
|
|
20967
20974
|
const sortedPatterns = Array.from(patterns).sort();
|
|
20968
20975
|
const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
|
|
20969
20976
|
const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
|
|
20977
|
+
const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
|
|
20970
20978
|
const routePathType = suppressLintOnLink ? "string" : typeLiterals.length ? typeLiterals.join(" | ") : "never";
|
|
20971
20979
|
const routePatternType = suppressLintOnLink ? "string" : patternLiterals.length ? patternLiterals.join(" | ") : "never";
|
|
20980
|
+
const routeModulePatternType = routeModulePatternLiterals.length ? routeModulePatternLiterals.join(" | ") : "never";
|
|
20972
20981
|
const routeTypesImportPath = `./${path14.basename(outPath).replace(/\.d\.ts$/, "")}`;
|
|
20973
|
-
const
|
|
20982
|
+
const linkAugmentationBlock = suppressLintOnLink ? "" : `
|
|
20974
20983
|
declare module "@farm.js/core/client" {
|
|
20975
20984
|
interface LinkDefaultRoute {
|
|
20976
20985
|
_: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
|
|
@@ -20994,14 +21003,25 @@ declare module "@farm.js/core/dist/client.js" {
|
|
|
20994
21003
|
pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
|
|
20995
21004
|
}
|
|
20996
21005
|
}
|
|
21006
|
+
`;
|
|
21007
|
+
const routeModuleAugmentationBlock = `
|
|
21008
|
+
declare global {
|
|
21009
|
+
namespace FarmJS {
|
|
21010
|
+
interface RouteRegistry {
|
|
21011
|
+
pattern: import(${JSON.stringify(routeTypesImportPath)}).RouteModulePattern;
|
|
21012
|
+
}
|
|
21013
|
+
}
|
|
21014
|
+
}
|
|
20997
21015
|
`;
|
|
20998
21016
|
const content = `/**
|
|
20999
21017
|
* Auto-generated route types from src/app.
|
|
21000
|
-
* Link href
|
|
21018
|
+
* Link href and route component props are typed automatically from generated declarations.
|
|
21019
|
+
* Regenerated on dev start and when routes change.
|
|
21001
21020
|
* Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
|
|
21002
21021
|
*/
|
|
21003
21022
|
export type RoutePath = ${routePathType};
|
|
21004
|
-
export type RoutePattern = ${routePatternType}
|
|
21023
|
+
export type RoutePattern = ${routePatternType};
|
|
21024
|
+
export type RouteModulePattern = ${routeModulePatternType};${linkAugmentationBlock}${routeModuleAugmentationBlock}
|
|
21005
21025
|
`;
|
|
21006
21026
|
return content;
|
|
21007
21027
|
}
|