one 1.1.479 → 1.1.481
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/cjs/Root.cjs +1 -1
- package/dist/cjs/Root.js +1 -1
- package/dist/cjs/Root.js.map +1 -1
- package/dist/cjs/Root.native.js +1 -1
- package/dist/cjs/Root.native.js.map +2 -2
- package/dist/cjs/cli/build.cjs +28 -8
- package/dist/cjs/cli/build.js +29 -10
- package/dist/cjs/cli/build.js.map +1 -1
- package/dist/cjs/cli/build.native.js +60 -24
- package/dist/cjs/cli/build.native.js.map +2 -2
- package/dist/cjs/createApp.cjs +3 -1
- package/dist/cjs/createApp.js +3 -1
- package/dist/cjs/createApp.js.map +1 -1
- package/dist/cjs/createApp.native.js +1 -0
- package/dist/cjs/createApp.native.js.map +2 -2
- package/dist/cjs/createHandleRequest.cjs +6 -2
- package/dist/cjs/createHandleRequest.js +2 -2
- package/dist/cjs/createHandleRequest.js.map +1 -1
- package/dist/cjs/createHandleRequest.native.js +4 -2
- package/dist/cjs/createHandleRequest.native.js.map +2 -2
- package/dist/cjs/router/useViteRoutes.cjs +6 -6
- package/dist/cjs/router/useViteRoutes.js +6 -6
- package/dist/cjs/router/useViteRoutes.js.map +1 -1
- package/dist/cjs/router/useViteRoutes.native.js +6 -6
- package/dist/cjs/router/useViteRoutes.native.js.map +2 -2
- package/dist/cjs/server/getServerManifest.cjs +20 -8
- package/dist/cjs/server/getServerManifest.js +15 -14
- package/dist/cjs/server/getServerManifest.js.map +1 -1
- package/dist/cjs/server/getServerManifest.native.js +19 -4
- package/dist/cjs/server/getServerManifest.native.js.map +2 -2
- package/dist/cjs/server/oneServe.cjs +14 -2
- package/dist/cjs/server/oneServe.js +15 -2
- package/dist/cjs/server/oneServe.js.map +1 -1
- package/dist/cjs/server/oneServe.native.js +24 -12
- package/dist/cjs/server/oneServe.native.js.map +2 -2
- package/dist/cjs/typed-routes/generateRouteTypes.cjs +3 -3
- package/dist/cjs/typed-routes/generateRouteTypes.js +2 -2
- package/dist/cjs/typed-routes/generateRouteTypes.js.map +1 -1
- package/dist/cjs/typed-routes/generateRouteTypes.native.js +3 -3
- package/dist/cjs/typed-routes/generateRouteTypes.native.js.map +2 -2
- package/dist/cjs/utils/getRouterRootFromOneOptions.cjs +28 -0
- package/dist/cjs/utils/getRouterRootFromOneOptions.js +23 -0
- package/dist/cjs/utils/getRouterRootFromOneOptions.js.map +6 -0
- package/dist/cjs/utils/getRouterRootFromOneOptions.native.js +29 -0
- package/dist/cjs/utils/getRouterRootFromOneOptions.native.js.map +6 -0
- package/dist/cjs/vercel/build/buildVercelOutputDirectory.cjs +1 -1
- package/dist/cjs/vercel/build/buildVercelOutputDirectory.js +5 -0
- package/dist/cjs/vercel/build/buildVercelOutputDirectory.js.map +1 -1
- package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js +1 -1
- package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js.map +2 -2
- package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.cjs +11 -3
- package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.js +11 -3
- package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.js.map +1 -1
- package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.native.js +11 -3
- package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.native.js.map +1 -1
- package/dist/cjs/vite/getManifest.cjs +4 -2
- package/dist/cjs/vite/getManifest.js +2 -2
- package/dist/cjs/vite/getManifest.js.map +1 -1
- package/dist/cjs/vite/getManifest.native.js +2 -2
- package/dist/cjs/vite/getManifest.native.js.map +2 -2
- package/dist/cjs/vite/one.cjs +5 -3
- package/dist/cjs/vite/one.js +3 -3
- package/dist/cjs/vite/one.js.map +1 -1
- package/dist/cjs/vite/one.native.js +3 -3
- package/dist/cjs/vite/one.native.js.map +2 -2
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +10 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js +8 -7
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +9 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +2 -2
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +6 -4
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js +4 -4
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +4 -4
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +2 -2
- package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +4 -2
- package/dist/cjs/vite/plugins/virtualEntryPlugin.js +4 -2
- package/dist/cjs/vite/plugins/virtualEntryPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +4 -2
- package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
- package/dist/cjs/vite/types.native.js.map +1 -1
- package/dist/esm/Root.js +1 -1
- package/dist/esm/Root.js.map +1 -1
- package/dist/esm/Root.mjs +1 -1
- package/dist/esm/Root.mjs.map +1 -1
- package/dist/esm/Root.native.js +1 -1
- package/dist/esm/Root.native.js.map +1 -1
- package/dist/esm/cli/build.js +29 -9
- package/dist/esm/cli/build.js.map +1 -1
- package/dist/esm/cli/build.mjs +28 -8
- package/dist/esm/cli/build.mjs.map +1 -1
- package/dist/esm/cli/build.native.js +60 -24
- package/dist/esm/cli/build.native.js.map +1 -1
- package/dist/esm/createApp.js +3 -1
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/createApp.mjs +3 -1
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/createApp.native.js +1 -0
- package/dist/esm/createApp.native.js.map +1 -1
- package/dist/esm/createHandleRequest.js +2 -2
- package/dist/esm/createHandleRequest.js.map +1 -1
- package/dist/esm/createHandleRequest.mjs +6 -2
- package/dist/esm/createHandleRequest.mjs.map +1 -1
- package/dist/esm/createHandleRequest.native.js +7 -2
- package/dist/esm/createHandleRequest.native.js.map +1 -1
- package/dist/esm/router/useViteRoutes.js +6 -6
- package/dist/esm/router/useViteRoutes.js.map +1 -1
- package/dist/esm/router/useViteRoutes.mjs +6 -6
- package/dist/esm/router/useViteRoutes.mjs.map +1 -1
- package/dist/esm/router/useViteRoutes.native.js +6 -6
- package/dist/esm/router/useViteRoutes.native.js.map +1 -1
- package/dist/esm/server/getServerManifest.js +15 -14
- package/dist/esm/server/getServerManifest.js.map +1 -1
- package/dist/esm/server/getServerManifest.mjs +20 -8
- package/dist/esm/server/getServerManifest.mjs.map +1 -1
- package/dist/esm/server/getServerManifest.native.js +21 -4
- package/dist/esm/server/getServerManifest.native.js.map +1 -1
- package/dist/esm/server/oneServe.js +16 -3
- package/dist/esm/server/oneServe.js.map +1 -1
- package/dist/esm/server/oneServe.mjs +15 -3
- package/dist/esm/server/oneServe.mjs.map +1 -1
- package/dist/esm/server/oneServe.native.js +25 -13
- package/dist/esm/server/oneServe.native.js.map +1 -1
- package/dist/esm/typed-routes/generateRouteTypes.js +2 -2
- package/dist/esm/typed-routes/generateRouteTypes.js.map +1 -1
- package/dist/esm/typed-routes/generateRouteTypes.mjs +3 -3
- package/dist/esm/typed-routes/generateRouteTypes.mjs.map +1 -1
- package/dist/esm/typed-routes/generateRouteTypes.native.js +3 -3
- package/dist/esm/typed-routes/generateRouteTypes.native.js.map +1 -1
- package/dist/esm/utils/getRouterRootFromOneOptions.js +7 -0
- package/dist/esm/utils/getRouterRootFromOneOptions.js.map +6 -0
- package/dist/esm/utils/getRouterRootFromOneOptions.mjs +5 -0
- package/dist/esm/utils/getRouterRootFromOneOptions.mjs.map +1 -0
- package/dist/esm/utils/getRouterRootFromOneOptions.native.js +6 -0
- package/dist/esm/utils/getRouterRootFromOneOptions.native.js.map +1 -0
- package/dist/esm/vercel/build/buildVercelOutputDirectory.js +5 -0
- package/dist/esm/vercel/build/buildVercelOutputDirectory.js.map +1 -1
- package/dist/esm/vercel/build/buildVercelOutputDirectory.mjs +1 -1
- package/dist/esm/vercel/build/buildVercelOutputDirectory.mjs.map +1 -1
- package/dist/esm/vercel/build/buildVercelOutputDirectory.native.js +1 -1
- package/dist/esm/vercel/build/buildVercelOutputDirectory.native.js.map +1 -1
- package/dist/esm/vercel/build/generate/createSsrServerlessFunction.js +11 -3
- package/dist/esm/vercel/build/generate/createSsrServerlessFunction.js.map +1 -1
- package/dist/esm/vercel/build/generate/createSsrServerlessFunction.mjs +11 -3
- package/dist/esm/vercel/build/generate/createSsrServerlessFunction.mjs.map +1 -1
- package/dist/esm/vercel/build/generate/createSsrServerlessFunction.native.js +11 -3
- package/dist/esm/vercel/build/generate/createSsrServerlessFunction.native.js.map +1 -1
- package/dist/esm/vite/getManifest.js +2 -2
- package/dist/esm/vite/getManifest.js.map +1 -1
- package/dist/esm/vite/getManifest.mjs +4 -2
- package/dist/esm/vite/getManifest.mjs.map +1 -1
- package/dist/esm/vite/getManifest.native.js +5 -2
- package/dist/esm/vite/getManifest.native.js.map +1 -1
- package/dist/esm/vite/one.js +3 -2
- package/dist/esm/vite/one.js.map +1 -1
- package/dist/esm/vite/one.mjs +5 -3
- package/dist/esm/vite/one.mjs.map +1 -1
- package/dist/esm/vite/one.native.js +5 -3
- package/dist/esm/vite/one.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js +8 -6
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +9 -5
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +9 -5
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js +4 -3
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +5 -3
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +5 -3
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/virtualEntryPlugin.js +4 -2
- package/dist/esm/vite/plugins/virtualEntryPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +4 -2
- package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +4 -2
- package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
- package/package.json +10 -10
- package/src/Root.tsx +2 -1
- package/src/cli/build.ts +35 -10
- package/src/createApp.native.tsx +8 -6
- package/src/createApp.tsx +5 -1
- package/src/createHandleRequest.ts +2 -2
- package/src/router/useViteRoutes.tsx +6 -4
- package/src/server/getServerManifest.ts +12 -4
- package/src/server/oneServe.ts +30 -1
- package/src/typed-routes/generateRouteTypes.ts +3 -3
- package/src/utils/getRouterRootFromOneOptions.ts +5 -0
- package/src/vercel/build/buildVercelOutputDirectory.ts +9 -0
- package/src/vercel/build/generate/createSsrServerlessFunction.ts +11 -3
- package/src/vite/getManifest.ts +2 -2
- package/src/vite/one.ts +4 -1
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +8 -6
- package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +6 -3
- package/src/vite/plugins/virtualEntryPlugin.ts +4 -2
- package/src/vite/types.ts +7 -0
- package/types/Root.d.ts +1 -0
- package/types/Root.d.ts.map +1 -1
- package/types/cli/build.d.ts.map +1 -1
- package/types/createApp.d.ts +1 -0
- package/types/createApp.d.ts.map +1 -1
- package/types/createApp.native.d.ts +1 -5
- package/types/createApp.native.d.ts.map +1 -1
- package/types/createHandleRequest.d.ts +3 -1
- package/types/createHandleRequest.d.ts.map +1 -1
- package/types/router/useViteRoutes.d.ts +3 -3
- package/types/router/useViteRoutes.d.ts.map +1 -1
- package/types/server/getServerManifest.d.ts.map +1 -1
- package/types/server/oneServe.d.ts.map +1 -1
- package/types/typed-routes/generateRouteTypes.d.ts +1 -1
- package/types/typed-routes/generateRouteTypes.d.ts.map +1 -1
- package/types/utils/getRouterRootFromOneOptions.d.ts +3 -0
- package/types/utils/getRouterRootFromOneOptions.d.ts.map +1 -0
- package/types/vercel/build/buildVercelOutputDirectory.d.ts.map +1 -1
- package/types/vercel/build/generate/createSsrServerlessFunction.d.ts.map +1 -1
- package/types/vite/getManifest.d.ts +3 -1
- package/types/vite/getManifest.d.ts.map +1 -1
- package/types/vite/one.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
- package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
- package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
- package/types/vite/types.d.ts +7 -0
- package/types/vite/types.d.ts.map +1 -1
- package/vendor/react-dom/package.json +1 -1
@@ -1,17 +1,18 @@
|
|
1
1
|
import { join } from "node:path";
|
2
2
|
import { debounce } from "perfect-debounce";
|
3
3
|
import { generateRouteTypes } from "../../typed-routes/generateRouteTypes";
|
4
|
+
import { getRouterRootFromOneOptions } from "../../utils/getRouterRootFromOneOptions";
|
4
5
|
function generateFileSystemRouteTypesPlugin(options) {
|
5
6
|
return {
|
6
7
|
name: "one-generate-fs-route-types",
|
7
8
|
enforce: "post",
|
8
9
|
apply: "serve",
|
9
10
|
configureServer(server) {
|
10
|
-
const appDir = join(process.cwd(),
|
11
|
-
(type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile);
|
11
|
+
const appDir = join(process.cwd(), getRouterRootFromOneOptions(options)), outFile = join(process.cwd(), "routes.d.ts"), routerRoot = getRouterRootFromOneOptions(options), fileWatcherChangeListener = debounce(async (type, path) => {
|
12
|
+
(type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile, routerRoot);
|
12
13
|
}, 100);
|
13
14
|
return server.watcher.addListener("all", fileWatcherChangeListener), () => {
|
14
|
-
generateRouteTypes(outFile);
|
15
|
+
generateRouteTypes(outFile, routerRoot);
|
15
16
|
};
|
16
17
|
}
|
17
18
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],
|
4
|
-
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAGzB,SAAS,0BAA0B;
|
4
|
+
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAGzB,SAAS,0BAA0B;AACnC,SAAS,mCAAmC;AAErC,SAAS,mCAAmC,SAAoC;AACrF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,IAEP,gBAAgB,QAAQ;AACtB,YAAM,SAAS,KAAK,QAAQ,IAAI,GAAG,4BAA4B,OAAO,CAAC,GACjE,UAAU,KAAK,QAAQ,IAAI,GAAG,aAAa,GAE3C,aAAa,4BAA4B,OAAO,GAGhD,4BAA4B,SAAS,OAAO,MAAc,SAAiB;AAC/E,SAAI,SAAS,SAAS,SAAS,aACzB,KAAK,WAAW,MAAM,KAExB,mBAAmB,SAAS,UAAU;AAAA,MAG5C,GAAG,GAAG;AAEN,oBAAO,QAAQ,YAAY,OAAO,yBAAyB,GAEpD,MAAM;AAGX,2BAAmB,SAAS,UAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;",
|
5
5
|
"names": []
|
6
6
|
}
|
@@ -1,19 +1,21 @@
|
|
1
1
|
import { join } from "node:path";
|
2
2
|
import { debounce } from "perfect-debounce";
|
3
3
|
import { generateRouteTypes } from "../../typed-routes/generateRouteTypes.mjs";
|
4
|
+
import { getRouterRootFromOneOptions } from "../../utils/getRouterRootFromOneOptions.mjs";
|
4
5
|
function generateFileSystemRouteTypesPlugin(options) {
|
5
6
|
return {
|
6
7
|
name: "one-generate-fs-route-types",
|
7
8
|
enforce: "post",
|
8
9
|
apply: "serve",
|
9
10
|
configureServer(server) {
|
10
|
-
const appDir = join(process.cwd(),
|
11
|
+
const appDir = join(process.cwd(), getRouterRootFromOneOptions(options)),
|
11
12
|
outFile = join(process.cwd(), "routes.d.ts"),
|
13
|
+
routerRoot = getRouterRootFromOneOptions(options),
|
12
14
|
fileWatcherChangeListener = debounce(async (type, path) => {
|
13
|
-
(type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile);
|
15
|
+
(type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile, routerRoot);
|
14
16
|
}, 100);
|
15
17
|
return server.watcher.addListener("all", fileWatcherChangeListener), () => {
|
16
|
-
generateRouteTypes(outFile);
|
18
|
+
generateRouteTypes(outFile, routerRoot);
|
17
19
|
};
|
18
20
|
}
|
19
21
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["join","debounce","generateRouteTypes","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","fileWatcherChangeListener","type","path","startsWith","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,SAASC,QAAA,QAAgB;AAGzB,SAASC,kBAAA,QAA0B;
|
1
|
+
{"version":3,"names":["join","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","fileWatcherChangeListener","type","path","startsWith","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,SAASC,QAAA,QAAgB;AAGzB,SAASC,kBAAA,QAA0B;AACnC,SAASC,2BAAA,QAAmC;AAErC,SAASC,mCAAmCC,OAAA,EAAoC;EACrF,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,KAAA,EAAO;IAEPC,gBAAgBC,MAAA,EAAQ;MACtB,MAAMC,MAAA,GAASX,IAAA,CAAKY,OAAA,CAAQC,GAAA,CAAI,GAAGV,2BAAA,CAA4BE,OAAO,CAAC;QACjES,OAAA,GAAUd,IAAA,CAAKY,OAAA,CAAQC,GAAA,CAAI,GAAG,aAAa;QAE3CE,UAAA,GAAaZ,2BAAA,CAA4BE,OAAO;QAGhDW,yBAAA,GAA4Bf,QAAA,CAAS,OAAOgB,IAAA,EAAcC,IAAA,KAAiB;UAC/E,CAAID,IAAA,KAAS,SAASA,IAAA,KAAS,aACzBC,IAAA,CAAKC,UAAA,CAAWR,MAAM,KAExBT,kBAAA,CAAmBY,OAAA,EAASC,UAAU;QAG5C,GAAG,GAAG;MAEN,OAAAL,MAAA,CAAOU,OAAA,CAAQC,WAAA,CAAY,OAAOL,yBAAyB,GAEpD,MAAM;QAGXd,kBAAA,CAAmBY,OAAA,EAASC,UAAU;MACxC;IACF;EACF;AACF","ignoreList":[]}
|
@@ -1,19 +1,21 @@
|
|
1
1
|
import { join } from "node:path";
|
2
2
|
import { debounce } from "perfect-debounce";
|
3
3
|
import { generateRouteTypes } from "../../typed-routes/generateRouteTypes.native.js";
|
4
|
+
import { getRouterRootFromOneOptions } from "../../utils/getRouterRootFromOneOptions.native.js";
|
4
5
|
function generateFileSystemRouteTypesPlugin(options) {
|
5
6
|
return {
|
6
7
|
name: "one-generate-fs-route-types",
|
7
8
|
enforce: "post",
|
8
9
|
apply: "serve",
|
9
10
|
configureServer(server) {
|
10
|
-
var appDir = join(process.cwd(),
|
11
|
+
var appDir = join(process.cwd(), getRouterRootFromOneOptions(options)),
|
11
12
|
outFile = join(process.cwd(), "routes.d.ts"),
|
13
|
+
routerRoot = getRouterRootFromOneOptions(options),
|
12
14
|
fileWatcherChangeListener = debounce(async function (type, path) {
|
13
|
-
(type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile);
|
15
|
+
(type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile, routerRoot);
|
14
16
|
}, 100);
|
15
17
|
return server.watcher.addListener("all", fileWatcherChangeListener), function () {
|
16
|
-
generateRouteTypes(outFile);
|
18
|
+
generateRouteTypes(outFile, routerRoot);
|
17
19
|
};
|
18
20
|
}
|
19
21
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["join","debounce","generateRouteTypes","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","fileWatcherChangeListener","type","path","startsWith","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,SAASC,QAAA,QAAgB;AAGzB,SAASC,kBAAA,QAA0B;
|
1
|
+
{"version":3,"names":["join","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","fileWatcherChangeListener","type","path","startsWith","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,SAASC,QAAA,QAAgB;AAGzB,SAASC,kBAAA,QAA0B;AACnC,SAASC,2BAAA,QAAmC;AAErC,SAASC,mCAAmCC,OAAA,EAAoC;EACrF,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,KAAA,EAAO;IAEPC,gBAAgBC,MAAA,EAAQ;MACtB,IAAAC,MAAM,GAAAX,IAAS,CAAAY,OAAK,CAAAC,GAAQ,IAAIV,2BAAG,CAAAE,OAA4B,EAAO;QAACS,OACjE,GAAAd,IAAU,CAAAY,OAAK,CAAAC,GAAQ,IAAI,aAAG;QAAaE,UAE3C,GAAAZ,2BAAa,CAAAE,OAA4B;QAAOW,yBAGhD,GAAAf,QAA4B,iBAA8BgB,IAAA,EAAAC,IAAiB;UAC/E,CAAID,IAAA,KAAS,SAASA,IAAA,KAAS,aACzBC,IAAA,CAAKC,UAAA,CAAWR,MAAM,KAExBT,kBAAA,CAAmBY,OAAA,EAASC,UAAU;QAG5C,GAAG,GAAG;MAEN,OAAAL,MAAA,CAAOU,OAAA,CAAQC,WAAA,CAAY,OAAOL,yBAAyB,GAEpD,YAAM;QAGXd,kBAAA,CAAmBY,OAAA,EAASC,UAAU;MACxC;IACF;EACF;AACF","ignoreList":[]}
|
@@ -31,7 +31,8 @@ import { createApp } from 'one'
|
|
31
31
|
// globbing ${appDirGlob}
|
32
32
|
export default createApp({
|
33
33
|
routes: import.meta.glob('${appDirGlob}', { exhaustive: true }),
|
34
|
-
|
34
|
+
routerRoot: ${JSON.stringify(options.root)},
|
35
|
+
flags: ${JSON.stringify(options.flags)},
|
35
36
|
})
|
36
37
|
`;
|
37
38
|
if (id === resolvedVirtualEntryIdNative)
|
@@ -43,7 +44,8 @@ import { createApp } from 'one'
|
|
43
44
|
// globbing ${appDirGlob}
|
44
45
|
export default createApp({
|
45
46
|
routes: import.meta.glob(['${appDirGlob}', '!${appDirApiGlob}'], { exhaustive: true }),
|
46
|
-
|
47
|
+
routerRoot: ${JSON.stringify(options.root)},
|
48
|
+
flags: ${JSON.stringify(options.flags)},
|
47
49
|
})
|
48
50
|
`;
|
49
51
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/vite/plugins/virtualEntryPlugin.ts"],
|
4
|
-
"mappings": "AACA,SAAS,2BAA2B;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAMpB,SAAS,mBAAmB,SAAqD;AACtF,QAAM,aAAa,IAAI,QAAQ,IAAI,aAC7B,gBAAgB,IAAI,QAAQ,IAAI;AAEtC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,UAAU,IAAI;AACZ,UAAI,OAAO;AACT,eAAO;AAET,UAAI,OAAO;AACT,eAAO;AAAA,IAEX;AAAA,IAEA,KAAK,IAAI;AACP,UAAI,OAAO;AAIT,eAAO;AAAA,EAHa,oBAAoB,KAAK,WAAW,IACpD,KACA,kBAEC;AAAA;AAAA;AAAA;AAAA,cAIC,UAAU;AAAA;AAAA,8BAEM,UAAU;AAAA,
|
4
|
+
"mappings": "AACA,SAAS,2BAA2B;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAMpB,SAAS,mBAAmB,SAAqD;AACtF,QAAM,aAAa,IAAI,QAAQ,IAAI,aAC7B,gBAAgB,IAAI,QAAQ,IAAI;AAEtC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,UAAU,IAAI;AACZ,UAAI,OAAO;AACT,eAAO;AAET,UAAI,OAAO;AACT,eAAO;AAAA,IAEX;AAAA,IAEA,KAAK,IAAI;AACP,UAAI,OAAO;AAIT,eAAO;AAAA,EAHa,oBAAoB,KAAK,WAAW,IACpD,KACA,kBAEC;AAAA;AAAA;AAAA;AAAA,cAIC,UAAU;AAAA;AAAA,8BAEM,UAAU;AAAA,gBACxB,KAAK,UAAU,QAAQ,IAAI,CAAC;AAAA,WACjC,KAAK,UAAU,QAAQ,KAAK,CAAC;AAAA;AAAA;AAKlC,UAAI,OAAO;AAIT,eAAO;AAAA,EAHa,oBAAoB,KAAK,WAAW,IACpD,KACA,kBAEC;AAAA;AAAA;AAAA;AAAA,cAIC,UAAU;AAAA;AAAA,+BAEO,UAAU,QAAQ,aAAa;AAAA,gBAC9C,KAAK,UAAU,QAAQ,IAAI,CAAC;AAAA,WACjC,KAAK,UAAU,QAAQ,KAAK,CAAC;AAAA;AAAA;AAAA,IAIpC;AAAA,EACF;AACF;",
|
5
5
|
"names": []
|
6
6
|
}
|
@@ -24,7 +24,8 @@ import { createApp } from 'one'
|
|
24
24
|
// globbing ${appDirGlob}
|
25
25
|
export default createApp({
|
26
26
|
routes: import.meta.glob('${appDirGlob}', { exhaustive: true }),
|
27
|
-
|
27
|
+
routerRoot: ${JSON.stringify(options.root)},
|
28
|
+
flags: ${JSON.stringify(options.flags)},
|
28
29
|
})
|
29
30
|
`;
|
30
31
|
if (id === resolvedVirtualEntryIdNative) return `
|
@@ -35,7 +36,8 @@ import { createApp } from 'one'
|
|
35
36
|
// globbing ${appDirGlob}
|
36
37
|
export default createApp({
|
37
38
|
routes: import.meta.glob(['${appDirGlob}', '!${appDirApiGlob}'], { exhaustive: true }),
|
38
|
-
|
39
|
+
routerRoot: ${JSON.stringify(options.root)},
|
40
|
+
flags: ${JSON.stringify(options.flags)},
|
39
41
|
})
|
40
42
|
`;
|
41
43
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isNativeEnvironment","resolvedVirtualEntryId","resolvedVirtualEntryIdNative","virtualEntryId","virtualEntryIdNative","USE_ONE_SETUP_FILE","createVirtualEntry","options","appDirGlob","root","appDirApiGlob","name","enforce","resolveId","id","load","environment","JSON","stringify","flags"],"sources":["../../../../src/vite/plugins/virtualEntryPlugin.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,mBAAA,QAA2B;AAEpC,SACEC,sBAAA,EACAC,4BAAA,EACAC,cAAA,EACAC,oBAAA,QACK;AAEP,MAAMC,kBAAA,GAAqB;AAAA;AAAA;AAAA;AAAA;AAMpB,SAASC,mBAAmBC,OAAA,EAAqD;EACtF,MAAMC,UAAA,GAAa,IAAID,OAAA,CAAQE,IAAI;IAC7BC,aAAA,GAAgB,IAAIH,OAAA,CAAQE,IAAI;EAEtC,OAAO;IACLE,IAAA,EAAM;IACNC,OAAA,EAAS;IAETC,UAAUC,EAAA,EAAI;MACZ,IAAIA,EAAA,KAAOX,cAAA,EACT,OAAOF,sBAAA;MAET,IAAIa,EAAA,KAAOV,oBAAA,EACT,OAAOF,4BAAA;IAEX;IAEAa,KAAKD,EAAA,EAAI;MACP,IAAIA,EAAA,KAAOb,sBAAA,EAIT,OAAO;AAAA,EAHaD,mBAAA,CAAoB,KAAKgB,WAAW,IACpD,KACAX,kBAEC;AAAA;AAAA;AAAA;AAAA,cAICG,UAAU;AAAA;AAAA,8BAEMA,UAAU;AAAA,
|
1
|
+
{"version":3,"names":["isNativeEnvironment","resolvedVirtualEntryId","resolvedVirtualEntryIdNative","virtualEntryId","virtualEntryIdNative","USE_ONE_SETUP_FILE","createVirtualEntry","options","appDirGlob","root","appDirApiGlob","name","enforce","resolveId","id","load","environment","JSON","stringify","flags"],"sources":["../../../../src/vite/plugins/virtualEntryPlugin.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,mBAAA,QAA2B;AAEpC,SACEC,sBAAA,EACAC,4BAAA,EACAC,cAAA,EACAC,oBAAA,QACK;AAEP,MAAMC,kBAAA,GAAqB;AAAA;AAAA;AAAA;AAAA;AAMpB,SAASC,mBAAmBC,OAAA,EAAqD;EACtF,MAAMC,UAAA,GAAa,IAAID,OAAA,CAAQE,IAAI;IAC7BC,aAAA,GAAgB,IAAIH,OAAA,CAAQE,IAAI;EAEtC,OAAO;IACLE,IAAA,EAAM;IACNC,OAAA,EAAS;IAETC,UAAUC,EAAA,EAAI;MACZ,IAAIA,EAAA,KAAOX,cAAA,EACT,OAAOF,sBAAA;MAET,IAAIa,EAAA,KAAOV,oBAAA,EACT,OAAOF,4BAAA;IAEX;IAEAa,KAAKD,EAAA,EAAI;MACP,IAAIA,EAAA,KAAOb,sBAAA,EAIT,OAAO;AAAA,EAHaD,mBAAA,CAAoB,KAAKgB,WAAW,IACpD,KACAX,kBAEC;AAAA;AAAA;AAAA;AAAA,cAICG,UAAU;AAAA;AAAA,8BAEMA,UAAU;AAAA,gBACxBS,IAAA,CAAKC,SAAA,CAAUX,OAAA,CAAQE,IAAI,CAAC;AAAA,WACjCQ,IAAA,CAAKC,SAAA,CAAUX,OAAA,CAAQY,KAAK,CAAC;AAAA;AAAA;MAKlC,IAAIL,EAAA,KAAOZ,4BAAA,EAIT,OAAO;AAAA,EAHaF,mBAAA,CAAoB,KAAKgB,WAAW,IACpD,KACAX,kBAEC;AAAA;AAAA;AAAA;AAAA,cAICG,UAAU;AAAA;AAAA,+BAEOA,UAAU,QAAQE,aAAa;AAAA,gBAC9CO,IAAA,CAAKC,SAAA,CAAUX,OAAA,CAAQE,IAAI,CAAC;AAAA,WACjCQ,IAAA,CAAKC,SAAA,CAAUX,OAAA,CAAQY,KAAK,CAAC;AAAA;AAAA;IAIpC;EACF;AACF","ignoreList":[]}
|
@@ -27,7 +27,8 @@ import { createApp } from 'one'
|
|
27
27
|
// globbing ${appDirGlob}
|
28
28
|
export default createApp({
|
29
29
|
routes: import.meta.glob('${appDirGlob}', { exhaustive: true }),
|
30
|
-
|
30
|
+
routerRoot: ${JSON.stringify(options.root)},
|
31
|
+
flags: ${JSON.stringify(options.flags)},
|
31
32
|
})
|
32
33
|
`;
|
33
34
|
}
|
@@ -42,7 +43,8 @@ import { createApp } from 'one'
|
|
42
43
|
// globbing ${appDirGlob}
|
43
44
|
export default createApp({
|
44
45
|
routes: import.meta.glob(['${appDirGlob}', '!${appDirApiGlob}'], { exhaustive: true }),
|
45
|
-
|
46
|
+
routerRoot: ${JSON.stringify(options.root)},
|
47
|
+
flags: ${JSON.stringify(options.flags)},
|
46
48
|
})
|
47
49
|
`;
|
48
50
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isNativeEnvironment","resolvedVirtualEntryId","resolvedVirtualEntryIdNative","virtualEntryId","virtualEntryIdNative","USE_ONE_SETUP_FILE","createVirtualEntry","options","appDirGlob","root","appDirApiGlob","name","enforce","resolveId","id","load","prependCode","environment","JSON","stringify","flags","prependCode1"],"sources":["../../../../src/vite/plugins/virtualEntryPlugin.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,mBAAA,QAA2B;AAEpC,SAAAC,sBAAA,EAAAC,4BAAA,EAAAC,cAAA,EAAAC,oBAAA;AAAA,IACEC,kBAAA;AAAA;AACA;AACA;AACA;AAGF,SAAMC,kBAAqBA,CAAAC,OAAA;EAAA,IAAAC,UAAA,OAAAD,OAAA,CAAAE,IAAA;IAAAC,aAAA,OAAAH,OAAA,CAAAE,IAAA;EAAA;IAAAE,IAAA;IAAAC,OAAA;IAMpBC,SAASA,CAAAC,EAAA;MACd,IAAMA,EAAA,KAAAX,cAAiB,EAGvB,OAAOF,sBAAA;MACL,IAAMa,EAAA,KAAAV,oBAAA,EACN,OAASF,4BAAA;IAET;IACEa,KAAAD,EAAI;MACF,IAAAA,EAAA,KAAOb,sBAAA;QAET,IAAIe,WAAO,GAAAhB,mBAAA,MAAAiB,WAAA,UACT;QAEJZ,kBAAA,CAEK;QACH,OAAI;AAIF,EAAAW,WAAA;AAAO;AACF;AAAA;AAAA,cAAAR,UAAA;AAAA;AAIW,8BAAAA,UAAA;AAAA,
|
1
|
+
{"version":3,"names":["isNativeEnvironment","resolvedVirtualEntryId","resolvedVirtualEntryIdNative","virtualEntryId","virtualEntryIdNative","USE_ONE_SETUP_FILE","createVirtualEntry","options","appDirGlob","root","appDirApiGlob","name","enforce","resolveId","id","load","prependCode","environment","JSON","stringify","flags","prependCode1"],"sources":["../../../../src/vite/plugins/virtualEntryPlugin.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,mBAAA,QAA2B;AAEpC,SAAAC,sBAAA,EAAAC,4BAAA,EAAAC,cAAA,EAAAC,oBAAA;AAAA,IACEC,kBAAA;AAAA;AACA;AACA;AACA;AAGF,SAAMC,kBAAqBA,CAAAC,OAAA;EAAA,IAAAC,UAAA,OAAAD,OAAA,CAAAE,IAAA;IAAAC,aAAA,OAAAH,OAAA,CAAAE,IAAA;EAAA;IAAAE,IAAA;IAAAC,OAAA;IAMpBC,SAASA,CAAAC,EAAA;MACd,IAAMA,EAAA,KAAAX,cAAiB,EAGvB,OAAOF,sBAAA;MACL,IAAMa,EAAA,KAAAV,oBAAA,EACN,OAASF,4BAAA;IAET;IACEa,KAAAD,EAAI;MACF,IAAAA,EAAA,KAAOb,sBAAA;QAET,IAAIe,WAAO,GAAAhB,mBAAA,MAAAiB,WAAA,UACT;QAEJZ,kBAAA,CAEK;QACH,OAAI;AAIF,EAAAW,WAAA;AAAO;AACF;AAAA;AAAA,cAAAR,UAAA;AAAA;AAIW,8BAAAA,UAAA;AAAA,gBAAAU,IAAA,CAAAC,SAEM,CAAAZ,OAAA,CAAAE,IAAU;AAAA,WAAAS,IAAA,CACxBC,SAAK,CAAAZ,OAAU,CAAAa,KAAQ;AAAK;AACJ;MAAA;MAKlC,IAAIN,EAAA,KAAOZ,4BAAA;QAIT,IAAAmB,YAAO,GAAArB,mBAAA,MAAAiB,WAAA,UAHa;QAIfZ,kBAAA;QAAA;AAAA,EAAAgB,YAIC;AAAU;AAAA;AAEsC;AAClB,cACjCb,UAAK;AAAwB;AAAA,+BAAAA,UAAA,QAAAE,aAAA;AAAA,gBAIpCQ,IAAA,CAAAC,SAAA,CAAAZ,OAAA,CAAAE,IAAA;AAAA,WACFS,IAAA,CAAAC,SAAA,CAAAZ,OAAA,CAAAa,KAAA;AACF","ignoreList":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "one",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.481",
|
4
4
|
"license": "BSD-3-Clause",
|
5
5
|
"sideEffects": [
|
6
6
|
"setup.mjs",
|
@@ -95,15 +95,15 @@
|
|
95
95
|
"@react-navigation/routers": "~7",
|
96
96
|
"@swc/core": "^1.10.4",
|
97
97
|
"@ungap/structured-clone": "^1.2.0",
|
98
|
-
"@vxrn/compiler": "1.1.
|
99
|
-
"@vxrn/resolve": "1.1.
|
100
|
-
"@vxrn/tslib-lite": "1.1.
|
101
|
-
"@vxrn/universal-color-scheme": "1.1.
|
102
|
-
"@vxrn/use-isomorphic-layout-effect": "1.1.
|
98
|
+
"@vxrn/compiler": "1.1.481",
|
99
|
+
"@vxrn/resolve": "1.1.481",
|
100
|
+
"@vxrn/tslib-lite": "1.1.481",
|
101
|
+
"@vxrn/universal-color-scheme": "1.1.481",
|
102
|
+
"@vxrn/use-isomorphic-layout-effect": "1.1.481",
|
103
103
|
"babel-dead-code-elimination": "^1.0.9",
|
104
104
|
"citty": "^0.1.6",
|
105
105
|
"core-js": "^3.38.1",
|
106
|
-
"create-vxrn": "1.1.
|
106
|
+
"create-vxrn": "1.1.481",
|
107
107
|
"escape-string-regexp": "^5.0.0",
|
108
108
|
"expo-linking": "~6.3.1",
|
109
109
|
"expo-modules-core": "2.1.2",
|
@@ -116,9 +116,9 @@
|
|
116
116
|
"nanoid": "^3.3.7",
|
117
117
|
"perfect-debounce": "^1.0.0",
|
118
118
|
"picocolors": "^1.0.0",
|
119
|
-
"react": "^18.3.1 ||
|
119
|
+
"react": "^18.3.1 || ~19.0.0",
|
120
120
|
"react-compiler-runtime": "^19.0.0-beta-201e55d-20241215",
|
121
|
-
"react-dom": "^18.3.1 ||
|
121
|
+
"react-dom": "^18.3.1 || ~19.0.0",
|
122
122
|
"react-native-css-interop": "^0.1.22",
|
123
123
|
"react-native-gesture-handler": "^2.18.1",
|
124
124
|
"react-native-reanimated": "~3.16.5",
|
@@ -129,7 +129,7 @@
|
|
129
129
|
"vite": "^6.1.0",
|
130
130
|
"vite-plugin-barrel": "^0.4.1",
|
131
131
|
"vite-tsconfig-paths": "^5.0.1",
|
132
|
-
"vxrn": "1.1.
|
132
|
+
"vxrn": "1.1.481",
|
133
133
|
"ws": "^8.18.0",
|
134
134
|
"xxhashjs": "^0.2.2"
|
135
135
|
},
|
package/src/Root.tsx
CHANGED
@@ -35,6 +35,7 @@ type RootProps = Omit<InnerProps, 'context'> & {
|
|
35
35
|
path: string
|
36
36
|
isClient?: boolean
|
37
37
|
routes: GlobbedRouteImports
|
38
|
+
routerRoot: string
|
38
39
|
routeOptions?: One.RouteOptions
|
39
40
|
flags?: One.Flags
|
40
41
|
}
|
@@ -68,7 +69,7 @@ export function Root(props: RootProps) {
|
|
68
69
|
const { path, routes, routeOptions, isClient, navigationContainerProps, onRenderId } =
|
69
70
|
props
|
70
71
|
|
71
|
-
const context = useViteRoutes(routes, routeOptions, globalThis['__vxrnVersion'])
|
72
|
+
const context = useViteRoutes(routes, props.routerRoot, routeOptions, globalThis['__vxrnVersion'])
|
72
73
|
const location =
|
73
74
|
typeof window !== 'undefined' && window.location
|
74
75
|
? new URL(path || window.location.href || '/', window.location.href)
|
package/src/cli/build.ts
CHANGED
@@ -21,6 +21,7 @@ import { loadUserOneOptions } from '../vite/loadConfig'
|
|
21
21
|
import { runWithAsyncLocalContext } from '../vite/one-server-only'
|
22
22
|
import type { One, RouteInfo } from '../vite/types'
|
23
23
|
import { buildVercelOutputDirectory } from '../vercel/build/buildVercelOutputDirectory'
|
24
|
+
import { getRouterRootFromOneOptions } from '../utils/getRouterRootFromOneOptions'
|
24
25
|
|
25
26
|
import { buildPage } from './buildPage'
|
26
27
|
import { checkNodeVersion } from './checkNodeVersion'
|
@@ -49,7 +50,10 @@ export async function build(args: {
|
|
49
50
|
}
|
50
51
|
|
51
52
|
const { oneOptions } = await loadUserOneOptions('build')
|
52
|
-
const
|
53
|
+
const routerRoot = getRouterRootFromOneOptions(oneOptions)
|
54
|
+
const routerRootRegexp = new RegExp(`^${routerRoot}`)
|
55
|
+
|
56
|
+
const manifest = getManifest({ routerRoot })!
|
53
57
|
|
54
58
|
const serverOutputFormat =
|
55
59
|
oneOptions.build?.server === false ? 'esm' : (oneOptions.build?.server?.outputFormat ?? 'esm')
|
@@ -97,7 +101,7 @@ export async function build(args: {
|
|
97
101
|
|
98
102
|
async function buildCustomRoutes(subFolder: string, routes: RouteInfo<string>[]) {
|
99
103
|
const input = routes.reduce((entries, { page, file }) => {
|
100
|
-
entries[page.slice(1) + '.js'] = join(
|
104
|
+
entries[page.slice(1) + '.js'] = join(routerRoot, file)
|
101
105
|
return entries
|
102
106
|
}, {}) as Record<string, string>
|
103
107
|
|
@@ -208,7 +212,7 @@ export async function build(args: {
|
|
208
212
|
|
209
213
|
for (const middleware of manifest.middlewareRoutes) {
|
210
214
|
const absoluteRoot = resolve(process.cwd(), options.root)
|
211
|
-
const fullPath = join(absoluteRoot,
|
215
|
+
const fullPath = join(absoluteRoot, routerRoot, middleware.file)
|
212
216
|
const outChunks = middlewareBuildInfo.output.filter((x) => x.type === 'chunk')
|
213
217
|
const chunk = outChunks.find((x) => x.facadeModuleId === fullPath)
|
214
218
|
if (!chunk) throw new Error(`internal err finding middleware`)
|
@@ -252,13 +256,11 @@ export async function build(args: {
|
|
252
256
|
}
|
253
257
|
|
254
258
|
// temp we should use manifest but lets just filter out non-app dir stuff
|
255
|
-
if (!id.includes(
|
259
|
+
if (!id.includes(`/${routerRoot}/`)) {
|
256
260
|
continue
|
257
261
|
}
|
258
262
|
|
259
|
-
const relativeId = relative(process.cwd(), id)
|
260
|
-
// TODO hardcoded app
|
261
|
-
.replace('app/', '/')
|
263
|
+
const relativeId = relative(process.cwd(), id).replace(`${routerRoot}/`, '/')
|
262
264
|
|
263
265
|
const onlyBuild = vxrnOutput.buildArgs?.only
|
264
266
|
if (onlyBuild) {
|
@@ -281,7 +283,7 @@ export async function build(args: {
|
|
281
283
|
const clientManifestEntry = vxrnOutput.clientManifest[clientManifestKey]
|
282
284
|
|
283
285
|
const foundRoute = manifest.pageRoutes.find((route: RouteInfo<string>) => {
|
284
|
-
return route.file && clientManifestKey.replace(
|
286
|
+
return route.file && clientManifestKey.replace(routerRootRegexp, '') === route.file.slice(1)
|
285
287
|
})
|
286
288
|
|
287
289
|
if (!foundRoute) {
|
@@ -329,8 +331,7 @@ export async function build(args: {
|
|
329
331
|
// TODO isn't this getting all layouts not just the ones for this route?
|
330
332
|
const layoutEntries =
|
331
333
|
foundRoute.layouts?.flatMap((layout) => {
|
332
|
-
|
333
|
-
const clientKey = `app${layout.contextKey.slice(1)}`
|
334
|
+
const clientKey = `${routerRoot}${layout.contextKey.slice(1)}`
|
334
335
|
return vxrnOutput.clientManifest[clientKey]
|
335
336
|
}) ?? []
|
336
337
|
|
@@ -456,6 +457,7 @@ export async function build(args: {
|
|
456
457
|
// write out the static paths (pathname => html) for the server
|
457
458
|
const routeMap: Record<string, string> = {}
|
458
459
|
const routeToBuildInfo: Record<string, Omit<One.RouteBuildInfo, 'loaderData'>> = {}
|
460
|
+
const pathToRoute: Record<string, string> = {}
|
459
461
|
const preloads: Record<string, boolean> = {}
|
460
462
|
const loaders: Record<string, boolean> = {}
|
461
463
|
|
@@ -470,6 +472,9 @@ export async function build(args: {
|
|
470
472
|
} = route
|
471
473
|
|
472
474
|
routeToBuildInfo[route.routeFile] = rest
|
475
|
+
for (let p of getCleanPaths([route.path, route.cleanPath])) {
|
476
|
+
pathToRoute[p] = route.routeFile
|
477
|
+
}
|
473
478
|
preloads[route.preloadPath] = true
|
474
479
|
loaders[route.loaderPath] = true
|
475
480
|
}
|
@@ -497,6 +502,7 @@ export async function build(args: {
|
|
497
502
|
const buildInfoForWriting: One.BuildInfo = {
|
498
503
|
oneOptions,
|
499
504
|
routeToBuildInfo,
|
505
|
+
pathToRoute,
|
500
506
|
manifest: {
|
501
507
|
pageRoutes: manifest.pageRoutes.map(createBuildManifestRoute),
|
502
508
|
apiRoutes: manifest.apiRoutes.map(createBuildManifestRoute),
|
@@ -569,6 +575,25 @@ export async function build(args: {
|
|
569
575
|
console.info(`\n\n 💛 build complete\n\n`)
|
570
576
|
}
|
571
577
|
|
578
|
+
const TRAILING_INDEX_REGEX = /\/index(\.(web))?/
|
579
|
+
function getCleanPaths(possiblePaths: Array<string>) {
|
580
|
+
return Array.from(
|
581
|
+
new Set(
|
582
|
+
Array.from(new Set(possiblePaths)).flatMap((p) => {
|
583
|
+
const paths = [p]
|
584
|
+
|
585
|
+
if (p.match(TRAILING_INDEX_REGEX)) {
|
586
|
+
const pathWithTrailingIndexRemoved = p.replace(TRAILING_INDEX_REGEX, '')
|
587
|
+
paths.push(pathWithTrailingIndexRemoved)
|
588
|
+
paths.push(pathWithTrailingIndexRemoved + '/')
|
589
|
+
}
|
590
|
+
|
591
|
+
return paths
|
592
|
+
})
|
593
|
+
)
|
594
|
+
)
|
595
|
+
}
|
596
|
+
|
572
597
|
async function moveAllFiles(src: string, dest: string) {
|
573
598
|
try {
|
574
599
|
await FSExtra.copy(src, dest, { overwrite: true, errorOnExist: false })
|
package/src/createApp.native.tsx
CHANGED
@@ -3,11 +3,7 @@ import type { One } from './vite/types'
|
|
3
3
|
import './polyfills-mobile'
|
4
4
|
import { Root } from './Root'
|
5
5
|
import './setup'
|
6
|
-
|
7
|
-
export type CreateAppProps = {
|
8
|
-
routes: Record<string, () => Promise<unknown>>
|
9
|
-
flags?: One.Flags
|
10
|
-
}
|
6
|
+
import type { CreateAppProps } from './createApp'
|
11
7
|
|
12
8
|
// TODO temporary
|
13
9
|
LogBox.ignoreLogs([/Sending .* with no listeners registered/])
|
@@ -15,7 +11,13 @@ LogBox.ignoreLogs([/Sending .* with no listeners registered/])
|
|
15
11
|
export function createApp(options: CreateAppProps): void {
|
16
12
|
const App = () => {
|
17
13
|
let contents = (
|
18
|
-
<Root
|
14
|
+
<Root
|
15
|
+
isClient
|
16
|
+
flags={options.flags}
|
17
|
+
routes={options.routes}
|
18
|
+
routerRoot={options.routerRoot}
|
19
|
+
path="/"
|
20
|
+
/>
|
19
21
|
)
|
20
22
|
|
21
23
|
return contents
|
package/src/createApp.tsx
CHANGED
@@ -17,6 +17,7 @@ import { cloneElement } from 'react'
|
|
17
17
|
|
18
18
|
export type CreateAppProps = {
|
19
19
|
routes: Record<string, () => Promise<unknown>>
|
20
|
+
routerRoot: string
|
20
21
|
flags?: One.Flags
|
21
22
|
}
|
22
23
|
|
@@ -45,6 +46,7 @@ export function createApp(options: CreateAppProps) {
|
|
45
46
|
renderId = id
|
46
47
|
}}
|
47
48
|
routes={options.routes}
|
49
|
+
routerRoot={options.routerRoot}
|
48
50
|
{...props}
|
49
51
|
/>
|
50
52
|
)
|
@@ -116,7 +118,8 @@ export function createApp(options: CreateAppProps) {
|
|
116
118
|
}
|
117
119
|
|
118
120
|
// run their root layout before calling resolveClientLoader so they can register hook
|
119
|
-
const rootLayoutImport =
|
121
|
+
const rootLayoutImport =
|
122
|
+
options.routes[`/${options.routerRoot}/_layout.tsx`]?.()
|
120
123
|
|
121
124
|
return rootLayoutImport
|
122
125
|
.then(() => {
|
@@ -128,6 +131,7 @@ export function createApp(options: CreateAppProps) {
|
|
128
131
|
isClient
|
129
132
|
flags={options.flags}
|
130
133
|
routes={options.routes}
|
134
|
+
routerRoot={options.routerRoot}
|
131
135
|
path={window.location.href}
|
132
136
|
/>
|
133
137
|
)
|
@@ -211,8 +211,8 @@ export function compileManifest(manifest: { pageRoutes: RouteInfo[]; apiRoutes:
|
|
211
211
|
}
|
212
212
|
|
213
213
|
// in dev mode we do it more simply:
|
214
|
-
export function createHandleRequest(handlers: RequestHandlers) {
|
215
|
-
const manifest = getManifest()
|
214
|
+
export function createHandleRequest(handlers: RequestHandlers, { routerRoot }: { routerRoot: string }) {
|
215
|
+
const manifest = getManifest({ routerRoot })
|
216
216
|
if (!manifest) {
|
217
217
|
throw new Error(`No routes manifest`)
|
218
218
|
}
|
@@ -9,6 +9,7 @@ let context
|
|
9
9
|
// for some reason putting it in state doesnt even re-render
|
10
10
|
export function useViteRoutes(
|
11
11
|
routes: GlobbedRouteImports,
|
12
|
+
routerRoot: string,
|
12
13
|
options?: One.RouteOptions,
|
13
14
|
version?: number
|
14
15
|
) {
|
@@ -19,21 +20,22 @@ export function useViteRoutes(
|
|
19
20
|
}
|
20
21
|
|
21
22
|
if (!context) {
|
22
|
-
loadRoutes(routes, options)
|
23
|
+
loadRoutes(routes, routerRoot, options)
|
23
24
|
}
|
24
25
|
|
25
26
|
return context
|
26
27
|
}
|
27
28
|
|
28
|
-
export function loadRoutes(paths: GlobbedRouteImports, options?: One.RouteOptions) {
|
29
|
+
export function loadRoutes(paths: GlobbedRouteImports, routerRoot: string, options?: One.RouteOptions) {
|
29
30
|
if (context) return context
|
30
31
|
globalThis['__importMetaGlobbed'] = paths
|
31
|
-
context = globbedRoutesToRouteContext(paths, options)
|
32
|
+
context = globbedRoutesToRouteContext(paths, routerRoot, options)
|
32
33
|
return context
|
33
34
|
}
|
34
35
|
|
35
36
|
export function globbedRoutesToRouteContext(
|
36
37
|
paths: GlobbedRouteImports,
|
38
|
+
routerRoot: string,
|
37
39
|
options?: One.RouteOptions
|
38
40
|
): One.RouteContext {
|
39
41
|
// make it look like webpack context
|
@@ -48,7 +50,7 @@ export function globbedRoutesToRouteContext(
|
|
48
50
|
return
|
49
51
|
}
|
50
52
|
const loadRouteFunction = paths[path]
|
51
|
-
const pathWithoutRelative = path.replace(
|
53
|
+
const pathWithoutRelative = path.replace(`/${routerRoot}/`, './')
|
52
54
|
|
53
55
|
const originalPath = pathWithoutRelative.slice(1).replace(/\.[jt]sx?$/, '')
|
54
56
|
if (options?.routeModes?.[originalPath] === 'spa') {
|
@@ -139,6 +139,7 @@ function getRouteEntry(normalizedRoute: string, node: RouteNode): OneRouterServe
|
|
139
139
|
type: node.type,
|
140
140
|
namedRegex: result.namedRegex,
|
141
141
|
urlPath: result.urlPath,
|
142
|
+
urlCleanPath: result.urlCleanPath,
|
142
143
|
routeKeys: result.routeKeys,
|
143
144
|
layouts: node.layouts,
|
144
145
|
middlewares: node.middlewares,
|
@@ -190,7 +191,7 @@ function getPathMeta(route: string) {
|
|
190
191
|
const getSafeRouteKey = buildGetSafeRouteKey()
|
191
192
|
const routeKeys: Record<string, string> = {}
|
192
193
|
|
193
|
-
|
194
|
+
const urlPathParts: Array<{ content: string; type?: 'group' }> = []
|
194
195
|
|
195
196
|
const routeSegments = segments
|
196
197
|
.map((segment, index) => {
|
@@ -221,7 +222,7 @@ function getPathMeta(route: string) {
|
|
221
222
|
cleanedKey = getSafeRouteKey()
|
222
223
|
}
|
223
224
|
|
224
|
-
|
225
|
+
urlPathParts.push({ content: repeat ? '/*' : `/:${name}${optional ? '?' : ''}` })
|
225
226
|
routeKeys[cleanedKey] = name
|
226
227
|
|
227
228
|
return repeat
|
@@ -237,7 +238,7 @@ function getPathMeta(route: string) {
|
|
237
238
|
.map((group) => group.trim())
|
238
239
|
.filter(Boolean)
|
239
240
|
|
240
|
-
|
241
|
+
urlPathParts.push({ content: `/:${groupName}?`, type: 'group' })
|
241
242
|
|
242
243
|
if (groupName.length > 1) {
|
243
244
|
const optionalSegment = `\\((?:${groupName.map(escapeStringRegexp).join('|')})\\)`
|
@@ -250,15 +251,22 @@ function getPathMeta(route: string) {
|
|
250
251
|
return `(?:/${escapeStringRegexp(segment)})?`
|
251
252
|
}
|
252
253
|
|
253
|
-
|
254
|
+
urlPathParts.push({ content: `/${segment}` })
|
254
255
|
|
255
256
|
return `/${escapeStringRegexp(segment)}`
|
256
257
|
})
|
257
258
|
.join('')
|
258
259
|
|
260
|
+
const urlPath = urlPathParts.map((p) => p.content).join('')
|
261
|
+
const urlCleanPath = urlPathParts
|
262
|
+
.filter((p) => p.type !== 'group')
|
263
|
+
.map((p) => p.content)
|
264
|
+
.join('')
|
265
|
+
|
259
266
|
return {
|
260
267
|
namedRegex: `^${routeSegments}(?:/)?$`,
|
261
268
|
urlPath: urlPath === '' ? '/' : urlPath,
|
269
|
+
urlCleanPath: urlCleanPath === '' ? '/' : urlCleanPath,
|
262
270
|
routeKeys,
|
263
271
|
}
|
264
272
|
}
|
package/src/server/oneServe.ts
CHANGED
@@ -2,7 +2,7 @@ import { default as FSExtra } from 'fs-extra'
|
|
2
2
|
import type { Hono, MiddlewareHandler } from 'hono'
|
3
3
|
import type { BlankEnv } from 'hono/types'
|
4
4
|
import { extname, join } from 'node:path'
|
5
|
-
import { getServerEntry } from 'vxrn/serve'
|
5
|
+
import { getServerEntry, serveStatic } from 'vxrn/serve'
|
6
6
|
import { LOADER_JS_POSTFIX_UNCACHED, PRELOAD_JS_POSTFIX } from '../constants'
|
7
7
|
import { compileManifest, getURLfromRequestURL, type RequestHandlers } from '../createHandleRequest'
|
8
8
|
import type { RenderAppProps } from '../types'
|
@@ -135,6 +135,23 @@ url: ${url}`)
|
|
135
135
|
|
136
136
|
function createHonoHandler(route: RouteInfoCompiled): MiddlewareHandler<BlankEnv, never, {}> {
|
137
137
|
return async (context, next) => {
|
138
|
+
if (route.page.endsWith('/+not-found')) {
|
139
|
+
let didCallNext = false
|
140
|
+
|
141
|
+
const response = await serveStatic({
|
142
|
+
root: './dist/client',
|
143
|
+
onFound: (_path, c) => {
|
144
|
+
c.header('Cache-Control', `public, immutable, max-age=31536000`)
|
145
|
+
},
|
146
|
+
})(context, async () => {
|
147
|
+
didCallNext = true
|
148
|
+
})
|
149
|
+
|
150
|
+
if (response && !didCallNext) {
|
151
|
+
return response
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
138
155
|
try {
|
139
156
|
const request = context.req.raw
|
140
157
|
|
@@ -220,10 +237,22 @@ url: ${url}`)
|
|
220
237
|
app.post(route.urlPath, createHonoHandler(route))
|
221
238
|
app.delete(route.urlPath, createHonoHandler(route))
|
222
239
|
app.patch(route.urlPath, createHonoHandler(route))
|
240
|
+
|
241
|
+
if (route.urlPath !== route.urlCleanPath) {
|
242
|
+
app.get(route.urlCleanPath, createHonoHandler(route))
|
243
|
+
app.put(route.urlCleanPath, createHonoHandler(route))
|
244
|
+
app.post(route.urlCleanPath, createHonoHandler(route))
|
245
|
+
app.delete(route.urlCleanPath, createHonoHandler(route))
|
246
|
+
app.patch(route.urlCleanPath, createHonoHandler(route))
|
247
|
+
}
|
223
248
|
}
|
224
249
|
|
225
250
|
for (const route of compiledManifest.pageRoutes) {
|
226
251
|
app.get(route.urlPath, createHonoHandler(route))
|
252
|
+
|
253
|
+
if (route.urlPath !== route.urlCleanPath) {
|
254
|
+
app.get(route.urlCleanPath, createHonoHandler(route))
|
255
|
+
}
|
227
256
|
}
|
228
257
|
|
229
258
|
const { preloads } = buildInfo
|
@@ -5,13 +5,13 @@ import { globbedRoutesToRouteContext } from '../router/useViteRoutes'
|
|
5
5
|
import { globDir } from '../utils/globDir'
|
6
6
|
import { getTypedRoutesDeclarationFile } from './getTypedRoutesDeclarationFile'
|
7
7
|
|
8
|
-
export async function generateRouteTypes(outFile: string) {
|
9
|
-
const routePaths = globDir(
|
8
|
+
export async function generateRouteTypes(outFile: string, routerRoot: string) {
|
9
|
+
const routePaths = globDir(routerRoot)
|
10
10
|
const routes = routePaths.reduce((acc, cur) => {
|
11
11
|
acc[cur] = {}
|
12
12
|
return acc
|
13
13
|
}, {})
|
14
|
-
const context = globbedRoutesToRouteContext(routes)
|
14
|
+
const context = globbedRoutesToRouteContext(routes, routerRoot)
|
15
15
|
const declarations = getTypedRoutesDeclarationFile(context)
|
16
16
|
await FSExtra.ensureDir(dirname(outFile))
|
17
17
|
await writeFile(outFile, declarations)
|