one 1.17.2 → 1.17.4

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 (95) hide show
  1. package/dist/cjs/cli/build.cjs +18 -12
  2. package/dist/cjs/cli/build.native.js +18 -12
  3. package/dist/cjs/cli/build.native.js.map +1 -1
  4. package/dist/cjs/typed-routes/generateRouteTypes.cjs +12 -2
  5. package/dist/cjs/typed-routes/generateRouteTypes.native.js +12 -2
  6. package/dist/cjs/typed-routes/generateRouteTypes.native.js.map +1 -1
  7. package/dist/cjs/typed-routes/generateRouteTypes.test.cjs +58 -0
  8. package/dist/cjs/typed-routes/generateRouteTypes.test.native.js +61 -0
  9. package/dist/cjs/typed-routes/generateRouteTypes.test.native.js.map +1 -0
  10. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.cjs +5 -5
  11. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js +5 -5
  12. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  13. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.cjs +18 -0
  14. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.native.js +25 -0
  15. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.native.js.map +1 -0
  16. package/dist/cjs/utils/routeFileWatch.cjs +58 -0
  17. package/dist/cjs/utils/routeFileWatch.native.js +62 -0
  18. package/dist/cjs/utils/routeFileWatch.native.js.map +1 -0
  19. package/dist/cjs/utils/routeFileWatch.test.cjs +92 -0
  20. package/dist/cjs/utils/routeFileWatch.test.native.js +95 -0
  21. package/dist/cjs/utils/routeFileWatch.test.native.js.map +1 -0
  22. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +16 -7
  23. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +16 -7
  24. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  25. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.cjs +111 -0
  26. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js +116 -0
  27. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -0
  28. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +9 -9
  29. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +10 -10
  30. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  31. package/dist/esm/cli/build.mjs +18 -12
  32. package/dist/esm/cli/build.mjs.map +1 -1
  33. package/dist/esm/cli/build.native.js +18 -12
  34. package/dist/esm/cli/build.native.js.map +1 -1
  35. package/dist/esm/typed-routes/generateRouteTypes.mjs +13 -3
  36. package/dist/esm/typed-routes/generateRouteTypes.mjs.map +1 -1
  37. package/dist/esm/typed-routes/generateRouteTypes.native.js +13 -3
  38. package/dist/esm/typed-routes/generateRouteTypes.native.js.map +1 -1
  39. package/dist/esm/typed-routes/generateRouteTypes.test.mjs +35 -0
  40. package/dist/esm/typed-routes/generateRouteTypes.test.mjs.map +1 -0
  41. package/dist/esm/typed-routes/generateRouteTypes.test.native.js +35 -0
  42. package/dist/esm/typed-routes/generateRouteTypes.test.native.js.map +1 -0
  43. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs +5 -5
  44. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs.map +1 -1
  45. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +5 -5
  46. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  47. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.mjs +19 -0
  48. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.mjs.map +1 -0
  49. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.native.js +23 -0
  50. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.native.js.map +1 -0
  51. package/dist/esm/utils/routeFileWatch.mjs +20 -0
  52. package/dist/esm/utils/routeFileWatch.mjs.map +1 -0
  53. package/dist/esm/utils/routeFileWatch.native.js +21 -0
  54. package/dist/esm/utils/routeFileWatch.native.js.map +1 -0
  55. package/dist/esm/utils/routeFileWatch.test.mjs +69 -0
  56. package/dist/esm/utils/routeFileWatch.test.mjs.map +1 -0
  57. package/dist/esm/utils/routeFileWatch.test.native.js +69 -0
  58. package/dist/esm/utils/routeFileWatch.test.native.js.map +1 -0
  59. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +16 -7
  60. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
  61. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +16 -7
  62. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  63. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs +88 -0
  64. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs.map +1 -0
  65. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js +90 -0
  66. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -0
  67. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +9 -9
  68. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
  69. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +10 -10
  70. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  71. package/package.json +11 -11
  72. package/src/cli/build.ts +25 -15
  73. package/src/typed-routes/generateRouteTypes.test.ts +53 -0
  74. package/src/typed-routes/generateRouteTypes.ts +14 -3
  75. package/src/typed-routes/getTypedRoutesDeclarationFile.test.ts +22 -0
  76. package/src/typed-routes/getTypedRoutesDeclarationFile.ts +5 -5
  77. package/src/utils/routeFileWatch.test.ts +94 -0
  78. package/src/utils/routeFileWatch.ts +40 -0
  79. package/src/vite/plugins/fileSystemRouterPlugin.test.ts +106 -0
  80. package/src/vite/plugins/fileSystemRouterPlugin.tsx +21 -13
  81. package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +16 -17
  82. package/types/cli/build.d.ts.map +1 -1
  83. package/types/typed-routes/generateRouteTypes.d.ts.map +1 -1
  84. package/types/typed-routes/generateRouteTypes.test.d.ts +2 -0
  85. package/types/typed-routes/generateRouteTypes.test.d.ts.map +1 -0
  86. package/types/typed-routes/getTypedRoutesDeclarationFile.test.d.ts +2 -0
  87. package/types/typed-routes/getTypedRoutesDeclarationFile.test.d.ts.map +1 -0
  88. package/types/utils/routeFileWatch.d.ts +9 -0
  89. package/types/utils/routeFileWatch.d.ts.map +1 -0
  90. package/types/utils/routeFileWatch.test.d.ts +2 -0
  91. package/types/utils/routeFileWatch.test.d.ts.map +1 -0
  92. package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
  93. package/types/vite/plugins/fileSystemRouterPlugin.test.d.ts +2 -0
  94. package/types/vite/plugins/fileSystemRouterPlugin.test.d.ts.map +1 -0
  95. package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
@@ -0,0 +1,90 @@
1
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "fs";
2
+ import { tmpdir } from "os";
3
+ import path from "path";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ vi.mock("vite", async function () {
6
+ var actual = await vi.importActual("vite");
7
+ return {
8
+ ...actual,
9
+ createServerModuleRunner: vi.fn(function () {
10
+ return {
11
+ clearCache: vi.fn(),
12
+ import: vi.fn()
13
+ };
14
+ })
15
+ };
16
+ });
17
+ describe("createFileSystemRouterPlugin", function () {
18
+ var previousIsVxrnCli = process.env.IS_VXRN_CLI;
19
+ var previousVxrnPluginConfig;
20
+ var tempRoot;
21
+ beforeEach(function () {
22
+ previousVxrnPluginConfig = globalThis.__vxrnPluginConfig__;
23
+ });
24
+ afterEach(function () {
25
+ if (tempRoot) {
26
+ rmSync(tempRoot, {
27
+ recursive: true,
28
+ force: true
29
+ });
30
+ tempRoot = void 0;
31
+ }
32
+ if (previousIsVxrnCli === void 0) {
33
+ delete process.env.IS_VXRN_CLI;
34
+ } else {
35
+ process.env.IS_VXRN_CLI = previousIsVxrnCli;
36
+ }
37
+ if (previousVxrnPluginConfig === void 0) {
38
+ delete globalThis.__vxrnPluginConfig__;
39
+ } else {
40
+ ;
41
+ globalThis.__vxrnPluginConfig__ = previousVxrnPluginConfig;
42
+ }
43
+ vi.restoreAllMocks();
44
+ });
45
+ it("keeps route watcher rebuild errors handled", async function () {
46
+ process.env.IS_VXRN_CLI = "1";
47
+ tempRoot = mkdtempSync(path.join(tmpdir(), "one-router-watch-"));
48
+ var appDir = path.join(tempRoot, "app");
49
+ writeFileSync(path.join(tempRoot, "package.json"), "{}\n");
50
+ mkdirSync(appDir);
51
+ writeFileSync(path.join(appDir, "index.tsx"), "export default function Index() { return null }\n");
52
+ globalThis.__vxrnPluginConfig__ = {
53
+ web: {
54
+ defaultRenderMode: "ssg"
55
+ }
56
+ };
57
+ var {
58
+ createFileSystemRouterPlugin
59
+ } = await import("./fileSystemRouterPlugin.native.js");
60
+ var plugin = createFileSystemRouterPlugin({
61
+ router: {
62
+ root: appDir
63
+ }
64
+ });
65
+ var watcherListener;
66
+ var server = {
67
+ environments: {
68
+ ssr: {}
69
+ },
70
+ watcher: {
71
+ addListener: vi.fn(function (event, listener) {
72
+ if (event === "all") {
73
+ watcherListener = listener;
74
+ }
75
+ }),
76
+ on: vi.fn()
77
+ }
78
+ };
79
+ plugin.configureServer(server);
80
+ expect(watcherListener).toBeDefined();
81
+ var warn = vi.spyOn(console, "warn").mockImplementation(function () {});
82
+ delete globalThis.__vxrnPluginConfig__;
83
+ if (!watcherListener) {
84
+ throw new Error("Expected route watcher listener to be registered");
85
+ }
86
+ await expect(Promise.resolve(watcherListener("add", path.join(appDir, "new-route.tsx")))).resolves.toBeUndefined();
87
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining("[one] Failed to rebuild routes"), expect.any(Error));
88
+ });
89
+ });
90
+ //# sourceMappingURL=fileSystemRouterPlugin.test.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["mkdirSync","mkdtempSync","rmSync","writeFileSync","tmpdir","path","afterEach","beforeEach","describe","expect","it","vi","mock","actual","importActual","createServerModuleRunner","fn","clearCache","import","previousIsVxrnCli","process","env","IS_VXRN_CLI","previousVxrnPluginConfig","tempRoot","globalThis","__vxrnPluginConfig__","recursive","force","restoreAllMocks","join","appDir","web","defaultRenderMode","createFileSystemRouterPlugin","plugin","router","root","watcherListener","server","environments","ssr","watcher","addListener","event","listener","on","configureServer","toBeDefined","warn","spyOn","console","mockImplementation","Error","Promise","resolve","resolves","toBeUndefined","toHaveBeenCalledWith","stringContaining","any"],"sources":["../../../../src/vite/plugins/fileSystemRouterPlugin.test.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
@@ -2,25 +2,25 @@ import { join, resolve } from "node:path";
2
2
  import { debounce } from "perfect-debounce";
3
3
  import { generateRouteTypes } from "../../typed-routes/generateRouteTypes.mjs";
4
4
  import { getRouterRootFromOneOptions } from "../../utils/getRouterRootFromOneOptions.mjs";
5
+ import { isRouteFileWatchEvent } from "../../utils/routeFileWatch.mjs";
5
6
  function generateFileSystemRouteTypesPlugin(options) {
6
7
  return {
7
8
  name: `one-generate-fs-route-types`,
8
9
  enforce: "post",
9
10
  apply: "serve",
10
11
  configureServer(server) {
11
- const appDir = join(process.cwd(), getRouterRootFromOneOptions(options));
12
+ const appDir = resolve(process.cwd(), getRouterRootFromOneOptions(options));
12
13
  const outFile = join(appDir, "routes.d.ts");
13
14
  const routerRoot = getRouterRootFromOneOptions(options);
14
15
  const typedRoutesGeneration = options.router?.experimental?.typedRoutesGeneration || void 0;
15
16
  const fileWatcherChangeListener = debounce(async (type, path) => {
16
- if (type === "add" || type === "delete" || type === "change") {
17
- const absolutePath = resolve(path);
18
- if (absolutePath === outFile) {
19
- return;
20
- }
21
- if (absolutePath.startsWith(appDir)) {
22
- generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles, typedRoutesGeneration);
23
- }
17
+ if (isRouteFileWatchEvent({
18
+ event: type,
19
+ filePath: path,
20
+ routerRoot: appDir,
21
+ includeChangeEvents: true
22
+ })) {
23
+ generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles, typedRoutesGeneration);
24
24
  }
25
25
  }, 100);
26
26
  server.watcher.addListener("all", fileWatcherChangeListener);
@@ -1 +1 @@
1
- {"version":3,"names":["join","resolve","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","typedRoutesGeneration","router","experimental","fileWatcherChangeListener","type","path","absolutePath","startsWith","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,EAAMC,OAAA,QAAe;AAC9B,SAASC,QAAA,QAAgB;AAEzB,SAASC,kBAAA,QAA0B;AACnC,SAASC,2BAAA,QAAmC;AAGrC,SAASC,mCAAmCC,OAAA,EAAoC;EACrF,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,KAAA,EAAO;IAEPC,gBAAgBC,MAAA,EAAQ;MACtB,MAAMC,MAAA,GAASZ,IAAA,CAAKa,OAAA,CAAQC,GAAA,CAAI,GAAGV,2BAAA,CAA4BE,OAAO,CAAC;MAEvE,MAAMS,OAAA,GAAUf,IAAA,CAAKY,MAAA,EAAQ,aAAa;MAE1C,MAAMI,UAAA,GAAaZ,2BAAA,CAA4BE,OAAO;MACtD,MAAMW,qBAAA,GACJX,OAAA,CAAQY,MAAA,EAAQC,YAAA,EAAcF,qBAAA,IAAyB;MAGzD,MAAMG,yBAAA,GAA4BlB,QAAA,CAAS,OAAOmB,IAAA,EAAcC,IAAA,KAAiB;QAC/E,IAAID,IAAA,KAAS,SAASA,IAAA,KAAS,YAAYA,IAAA,KAAS,UAAU;UAE5D,MAAME,YAAA,GAAetB,OAAA,CAAQqB,IAAI;UAEjC,IAAIC,YAAA,KAAiBR,OAAA,EAAS;YAC5B;UACF;UACA,IAAIQ,YAAA,CAAaC,UAAA,CAAWZ,MAAM,GAAG;YAEnCT,kBAAA,CACEY,OAAA,EACAC,UAAA,EACAV,OAAA,CAAQY,MAAA,EAAQO,iBAAA,EAChBR,qBACF;UACF;QACF;MACF,GAAG,GAAG;MAENN,MAAA,CAAOe,OAAA,CAAQC,WAAA,CAAY,OAAOP,yBAAyB;MAE3D,OAAO,MAAM;QAGXjB,kBAAA,CACEY,OAAA,EACAC,UAAA,EACAV,OAAA,CAAQY,MAAA,EAAQO,iBAAA,EAChBR,qBACF;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["join","resolve","debounce","generateRouteTypes","getRouterRootFromOneOptions","isRouteFileWatchEvent","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","typedRoutesGeneration","router","experimental","fileWatcherChangeListener","type","path","event","filePath","includeChangeEvents","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,EAAMC,OAAA,QAAe;AAC9B,SAASC,QAAA,QAAgB;AAEzB,SAASC,kBAAA,QAA0B;AACnC,SAASC,2BAAA,QAAmC;AAC5C,SAASC,qBAAA,QAA6B;AAG/B,SAASC,mCAAmCC,OAAA,EAAoC;EACrF,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,KAAA,EAAO;IAEPC,gBAAgBC,MAAA,EAAQ;MACtB,MAAMC,MAAA,GAASZ,OAAA,CAAQa,OAAA,CAAQC,GAAA,CAAI,GAAGX,2BAAA,CAA4BG,OAAO,CAAC;MAE1E,MAAMS,OAAA,GAAUhB,IAAA,CAAKa,MAAA,EAAQ,aAAa;MAE1C,MAAMI,UAAA,GAAab,2BAAA,CAA4BG,OAAO;MACtD,MAAMW,qBAAA,GACJX,OAAA,CAAQY,MAAA,EAAQC,YAAA,EAAcF,qBAAA,IAAyB;MAGzD,MAAMG,yBAAA,GAA4BnB,QAAA,CAAS,OAAOoB,IAAA,EAAcC,IAAA,KAAiB;QAC/E,IACElB,qBAAA,CAAsB;UACpBmB,KAAA,EAAOF,IAAA;UACPG,QAAA,EAAUF,IAAA;UACVN,UAAA,EAAYJ,MAAA;UACZa,mBAAA,EAAqB;QACvB,CAAC,GACD;UACAvB,kBAAA,CACEa,OAAA,EACAC,UAAA,EACAV,OAAA,CAAQY,MAAA,EAAQQ,iBAAA,EAChBT,qBACF;QACF;MACF,GAAG,GAAG;MAENN,MAAA,CAAOgB,OAAA,CAAQC,WAAA,CAAY,OAAOR,yBAAyB;MAE3D,OAAO,MAAM;QAGXlB,kBAAA,CACEa,OAAA,EACAC,UAAA,EACAV,OAAA,CAAQY,MAAA,EAAQQ,iBAAA,EAChBT,qBACF;MACF;IACF;EACF;AACF","ignoreList":[]}
@@ -2,6 +2,7 @@ import { join, resolve } from "path";
2
2
  import { debounce } from "perfect-debounce";
3
3
  import { generateRouteTypes } from "../../typed-routes/generateRouteTypes.native.js";
4
4
  import { getRouterRootFromOneOptions } from "../../utils/getRouterRootFromOneOptions.native.js";
5
+ import { isRouteFileWatchEvent } from "../../utils/routeFileWatch.native.js";
5
6
  function generateFileSystemRouteTypesPlugin(options) {
6
7
  return {
7
8
  name: `one-generate-fs-route-types`,
@@ -9,20 +10,19 @@ function generateFileSystemRouteTypesPlugin(options) {
9
10
  apply: "serve",
10
11
  configureServer(server) {
11
12
  var _options_router_experimental, _options_router;
12
- var appDir = join(process.cwd(), getRouterRootFromOneOptions(options));
13
+ var appDir = resolve(process.cwd(), getRouterRootFromOneOptions(options));
13
14
  var outFile = join(appDir, "routes.d.ts");
14
15
  var routerRoot = getRouterRootFromOneOptions(options);
15
16
  var typedRoutesGeneration = ((_options_router = options.router) === null || _options_router === void 0 ? void 0 : (_options_router_experimental = _options_router.experimental) === null || _options_router_experimental === void 0 ? void 0 : _options_router_experimental.typedRoutesGeneration) || void 0;
16
17
  var fileWatcherChangeListener = debounce(async function (type, path) {
17
- if (type === "add" || type === "delete" || type === "change") {
18
- var absolutePath = resolve(path);
19
- if (absolutePath === outFile) {
20
- return;
21
- }
22
- if (absolutePath.startsWith(appDir)) {
23
- var _options_router2;
24
- generateRouteTypes(outFile, routerRoot, (_options_router2 = options.router) === null || _options_router2 === void 0 ? void 0 : _options_router2.ignoredRouteFiles, typedRoutesGeneration);
25
- }
18
+ if (isRouteFileWatchEvent({
19
+ event: type,
20
+ filePath: path,
21
+ routerRoot: appDir,
22
+ includeChangeEvents: true
23
+ })) {
24
+ var _options_router2;
25
+ generateRouteTypes(outFile, routerRoot, (_options_router2 = options.router) === null || _options_router2 === void 0 ? void 0 : _options_router2.ignoredRouteFiles, typedRoutesGeneration);
26
26
  }
27
27
  }, 100);
28
28
  server.watcher.addListener("all", fileWatcherChangeListener);
@@ -1 +1 @@
1
- {"version":3,"names":["join","resolve","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","_options_router_experimental","_options_router","appDir","process","cwd","outFile","routerRoot","typedRoutesGeneration","router","experimental","fileWatcherChangeListener","type","path","absolutePath","startsWith","_options_router2","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,EAAMC,OAAA,QAAe;AAC9B,SAASC,QAAA,QAAgB;AAEzB,SAASC,kBAAA,QAA0B;AACnC,SAASC,2BAAA,QAAmC;AAGrC,SAASC,mCAAmCC,OAAA,EAAoC;EACrF,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,KAAA,EAAO;IAEPC,gBAAgBC,MAAA,EAAQ;MACtB,IAAAC,4BAAgC,EAAAC,eAAG;MAEnC,IAAAC,MAAM,GAAAd,IAAU,CAAAe,OAAK,CAAAC,GAAQ,IAAAZ,2BAAa,CAAAE,OAAA;MAE1C,IAAAW,OAAM,GAAAjB,IAAA,CAAac,MAAA;MACnB,IAAAI,UAAM,GAAAd,2BACI,CAAAE,OAAQ;MAGlB,IAAAa,qBAAM,KAAAN,eAAqC,GAAAP,OAAO,CAAcc,MAAA,MAAiB,QAAAP,eAAA,wBAAAD,4BAAA,GAAAC,eAAA,CAAAQ,YAAA,cAAAT,4BAAA,uBAAAA,4BAAA,CAAAO,qBAAA;MAC/E,IAAAG,yBAAsB,GAAApB,QAAS,iBAAqBqB,IAAA,EAAAC,IAAU;QAE5D,IAAAD,IAAM,cAAAA,IAAe,KAAQ,QAAI,IAAAA,IAAA;UAEjC,IAAIE,YAAA,GAAAxB,OAAiB,CAAAuB,IAAS;UAC5B,IAAAC,YAAA,KAAAR,OAAA;YACF;UACA;UAEE,IAAAQ,YAAA,CAAAC,UAAA,CAAAZ,MAAA;YAAA,IACEa,gBAAA;YAAAxB,kBACA,CAAAc,OAAA,EAAAC,UAAA,GAAAS,gBAAA,GAAArB,OAAA,CAAAc,MAAA,cAAAO,gBAAA,uBAAAA,gBAAA,CAAAC,iBAAA,EAAAT,qBAAA;UAAA;QACgB;MAChB,MACF;MAAAR,MACF,CAAAkB,OAAA,CAAAC,WAAA,QAAAR,yBAAA;MAAA,OACF;QACF,IAAMK,gBAAA;QAENxB,kBAAe,CAAAc,OAAY,EAAAC,UAAO,GAAAS,gBAAyB,GAAArB,OAAA,CAAAc,MAAA,cAAAO,gBAAA,uBAAAA,gBAAA,CAAAC,iBAAA,EAAAT,qBAAA;MAE3D;IAGE;EAAA;AACE;AACA,SACgBd,kCAChB","ignoreList":[]}
1
+ {"version":3,"names":["join","resolve","debounce","generateRouteTypes","getRouterRootFromOneOptions","isRouteFileWatchEvent","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","_options_router_experimental","_options_router","appDir","process","cwd","outFile","routerRoot","typedRoutesGeneration","router","experimental","fileWatcherChangeListener","type","path","event","filePath","includeChangeEvents","_options_router2","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,EAAMC,OAAA,QAAe;AAC9B,SAASC,QAAA,QAAgB;AAEzB,SAASC,kBAAA,QAA0B;AACnC,SAASC,2BAAA,QAAmC;AAC5C,SAASC,qBAAA,QAA6B;AAG/B,SAASC,mCAAmCC,OAAA,EAAoC;EACrF,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,KAAA,EAAO;IAEPC,gBAAgBC,MAAA,EAAQ;MACtB,IAAAC,4BAA+B,EAAAC,eAAO;MAEtC,IAAAC,MAAM,GAAAd,OAAU,CAAKe,OAAA,CAAQC,GAAA,IAAAb,2BAAa,CAAAG,OAAA;MAE1C,IAAAW,OAAM,GAAAlB,IAAA,CAAae,MAAA;MACnB,IAAAI,UAAM,GAAAf,2BACI,CAAAG,OAAQ;MAGlB,IAAAa,qBAAM,KAAAN,eAAqC,GAAAP,OAAO,CAAcc,MAAA,MAAiB,QAAAP,eAAA,wBAAAD,4BAAA,GAAAC,eAAA,CAAAQ,YAAA,cAAAT,4BAAA,uBAAAA,4BAAA,CAAAO,qBAAA;MAC/E,IAAAG,yBACwB,GAAArB,QAAA,iBAAAsB,IAAA,EAAAC,IAAA;QAAA,IACpBpB,qBAAO;UACPqB,KAAA,EAAAF,IAAU;UACVG,QAAA,EAAAF,IAAY;UACZN,UAAA,EAAAJ,MAAA;UACDa,mBACD;QACA;UAAA,IACEC,gBAAA;UAAA1B,kBACA,CAAAe,OAAA,EAAAC,UAAA,GAAAU,gBAAA,GAAAtB,OAAA,CAAAc,MAAA,cAAAQ,gBAAA,uBAAAA,gBAAA,CAAAC,iBAAA,EAAAV,qBAAA;QAAA;MACgB,MAChB;MAAAR,MACF,CAAAmB,OAAA,CAAAC,WAAA,QAAAT,yBAAA;MAAA,OACF;QACF,IAAMM,gBAAA;QAEN1B,kBAAe,CAAAe,OAAY,EAAAC,UAAO,GAAAU,gBAAyB,GAAAtB,OAAA,CAAAc,MAAA,cAAAQ,gBAAA,uBAAAA,gBAAA,CAAAC,iBAAA,EAAAV,qBAAA;MAE3D;IAGE;EAAA;AACE;AACA,SACgBd,kCAChB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "1.17.2",
3
+ "version": "1.17.4",
4
4
  "license": "BSD-3-Clause",
5
5
  "sideEffects": [
6
6
  "setup.mjs",
@@ -180,18 +180,18 @@
180
180
  "@cloudflare/vite-plugin": "^1.33.1",
181
181
  "@swc/core": "^1.14.0",
182
182
  "@ungap/structured-clone": "^1.2.0",
183
- "@vxrn/color-scheme": "1.17.2",
184
- "@vxrn/compiler": "1.17.2",
185
- "@vxrn/resolve": "1.17.2",
186
- "@vxrn/tslib-lite": "1.17.2",
187
- "@vxrn/use-isomorphic-layout-effect": "1.17.2",
188
- "@vxrn/vite-plugin-metro": "1.17.2",
183
+ "@vxrn/color-scheme": "1.17.4",
184
+ "@vxrn/compiler": "1.17.4",
185
+ "@vxrn/resolve": "1.17.4",
186
+ "@vxrn/tslib-lite": "1.17.4",
187
+ "@vxrn/use-isomorphic-layout-effect": "1.17.4",
188
+ "@vxrn/vite-plugin-metro": "1.17.4",
189
189
  "babel-dead-code-elimination": "1.0.10",
190
190
  "babel-plugin-module-resolver": "^5.0.2",
191
191
  "babel-preset-expo": "*",
192
192
  "citty": "^0.1.6",
193
193
  "core-js": "^3.38.1",
194
- "create-vxrn": "1.17.2",
194
+ "create-vxrn": "1.17.4",
195
195
  "escape-string-regexp": "^5.0.0",
196
196
  "expo-linking": "~55.0.7",
197
197
  "expo-modules-core": "~55.0.16",
@@ -210,8 +210,8 @@
210
210
  "ts-pattern": "^5.6.2",
211
211
  "tsconfig-paths": "^4",
212
212
  "use-latest-callback": "^0.2.3",
213
- "vite": "^8.0.0",
214
- "vxrn": "1.17.2",
213
+ "vite": "^8.0.13",
214
+ "vxrn": "1.17.4",
215
215
  "ws": "^8.18.0",
216
216
  "xxhashjs": "^0.2.2"
217
217
  },
@@ -266,7 +266,7 @@
266
266
  "react": "19.2.0",
267
267
  "react-dom": "19.2.0",
268
268
  "react-native": "0.83.2",
269
- "rolldown": "^1.0.0-rc.17",
269
+ "rolldown": "^1.0.1",
270
270
  "sharp": "^0.34.5",
271
271
  "typescript": "^5.7.3",
272
272
  "vitest": "^4.1.0"
package/src/cli/build.ts CHANGED
@@ -272,21 +272,30 @@ import {
272
272
 
273
273
  installPrepareStackTraceGuard()
274
274
 
275
- process.on('uncaughtException', (err) => {
276
- try {
277
- process.stderr.write(`[one build] uncaught exception\n${formatErrorSafely(err)}\n`)
278
- } catch {}
279
- process.exit(1)
280
- })
281
-
282
- process.on('unhandledRejection', (reason) => {
283
- try {
284
- process.stderr.write(
285
- `[one build] unhandled rejection\n${formatErrorSafely(reason)}\n`
286
- )
287
- } catch {}
288
- process.exit(1)
289
- })
275
+ // these handlers must only attach when `build` is actually invoked. attaching
276
+ // them at module load leaks into `one dev`, because `one/vite` re-exports from
277
+ // this file — and dev intentionally does NOT exit on unhandled rejection (see
278
+ // dev.ts). a stray rejection from expo's manifest middleware (client closing
279
+ // the connection mid-stream) was killing the dev server.
280
+ let buildErrorHandlersInstalled = false
281
+ function installBuildErrorHandlers() {
282
+ if (buildErrorHandlersInstalled) return
283
+ buildErrorHandlersInstalled = true
284
+ process.on('uncaughtException', (err) => {
285
+ try {
286
+ process.stderr.write(`[one build] uncaught exception\n${formatErrorSafely(err)}\n`)
287
+ } catch {}
288
+ process.exit(1)
289
+ })
290
+ process.on('unhandledRejection', (reason) => {
291
+ try {
292
+ process.stderr.write(
293
+ `[one build] unhandled rejection\n${formatErrorSafely(reason)}\n`
294
+ )
295
+ } catch {}
296
+ process.exit(1)
297
+ })
298
+ }
290
299
 
291
300
  const HOOK_KEYS = [
292
301
  'resolveId',
@@ -327,6 +336,7 @@ export async function build(args: {
327
336
  platform?: 'ios' | 'web' | 'android'
328
337
  skipEnv?: boolean
329
338
  }) {
339
+ installBuildErrorHandlers()
330
340
  process.env.IS_VXRN_CLI = 'true'
331
341
 
332
342
  // set NODE_ENV, do before loading vite.config (see loadConfigFromFile)
@@ -0,0 +1,53 @@
1
+ import {
2
+ mkdirSync,
3
+ mkdtempSync,
4
+ rmSync,
5
+ statSync,
6
+ utimesSync,
7
+ writeFileSync,
8
+ } from 'node:fs'
9
+ import { tmpdir } from 'node:os'
10
+ import path from 'node:path'
11
+ import { afterEach, describe, expect, it } from 'vitest'
12
+ import { generateRouteTypes } from './generateRouteTypes'
13
+
14
+ describe(generateRouteTypes, () => {
15
+ const originalCwd = process.cwd()
16
+ let tempRoot: string | undefined
17
+
18
+ afterEach(() => {
19
+ process.chdir(originalCwd)
20
+
21
+ if (tempRoot) {
22
+ rmSync(tempRoot, { recursive: true, force: true })
23
+ tempRoot = undefined
24
+ }
25
+ })
26
+
27
+ it('does not rewrite routes declarations when contents are unchanged', async () => {
28
+ tempRoot = mkdtempSync(path.join(tmpdir(), 'one-routes-types-'))
29
+ const appDir = path.join(tempRoot, 'app')
30
+ mkdirSync(appDir)
31
+ writeFileSync(
32
+ path.join(appDir, 'index+ssg.tsx'),
33
+ 'export default function Index() { return null }\n'
34
+ )
35
+ writeFileSync(
36
+ path.join(appDir, '[slug]+ssg.tsx'),
37
+ 'export default function Slug() { return null }\n'
38
+ )
39
+
40
+ process.chdir(tempRoot)
41
+
42
+ const outFile = path.join('app', 'routes.d.ts')
43
+ await generateRouteTypes(outFile, 'app')
44
+
45
+ const oldDate = new Date('2001-01-01T00:00:00.000Z')
46
+ utimesSync(outFile, oldDate, oldDate)
47
+ const previousMtimeMs = statSync(outFile).mtimeMs
48
+
49
+ await generateRouteTypes(outFile, 'app')
50
+
51
+ expect(statSync(outFile).mtimeMs).toBe(previousMtimeMs)
52
+ })
53
+ })
@@ -1,4 +1,4 @@
1
- import { writeFile } from 'node:fs/promises'
1
+ import { readFile, writeFile } from 'node:fs/promises'
2
2
  import { dirname, join } from 'node:path'
3
3
  import FSExtra from 'fs-extra'
4
4
  import micromatch from 'micromatch'
@@ -33,8 +33,19 @@ export async function generateRouteTypes(
33
33
  const context = globbedRoutesToRouteContext(routes, routerRoot)
34
34
  const declarations = getTypedRoutesDeclarationFile(context)
35
35
  const outDir = dirname(outFile)
36
- await FSExtra.ensureDir(outDir)
37
- await writeFile(outFile, declarations)
36
+ let currentDeclarations: string | undefined
37
+ try {
38
+ currentDeclarations = await readFile(outFile, 'utf8')
39
+ } catch (error) {
40
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
41
+ throw error
42
+ }
43
+ }
44
+
45
+ if (currentDeclarations !== declarations) {
46
+ await FSExtra.ensureDir(outDir)
47
+ await writeFile(outFile, declarations)
48
+ }
38
49
 
39
50
  // If experimental.typedRoutesGeneration is enabled, inject helpers into route files
40
51
  if (typedRoutesMode) {
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import type { One } from '../vite/types'
3
+ import { getTypedRoutesDeclarationFile } from './getTypedRoutesDeclarationFile'
4
+
5
+ function createRouteContext(paths: string[]) {
6
+ const context = (() => ({ default() {} })) as unknown as One.RouteContext
7
+ Object.defineProperty(context, 'keys', {
8
+ value: () => paths,
9
+ })
10
+ return context
11
+ }
12
+
13
+ describe(getTypedRoutesDeclarationFile, () => {
14
+ it('does not emit trailing whitespace for multi-line route unions', () => {
15
+ const declaration = getTypedRoutesDeclarationFile(
16
+ createRouteContext(['./index+ssg.tsx', './about+ssg.tsx', './[slug]+ssg.tsx'])
17
+ )
18
+
19
+ expect(declaration).toContain(' StaticRoutes:\n | `/`')
20
+ expect(declaration).not.toMatch(/[ \t]+$/m)
21
+ })
22
+ })
@@ -36,9 +36,9 @@ import type { OneRouter } from 'one'
36
36
  declare module 'one' {
37
37
  export namespace OneRouter {
38
38
  export interface __routes<T extends string = string> extends Record<string, unknown> {
39
- StaticRoutes: ${setToUnionType(staticRoutes)}
40
- DynamicRoutes: ${setToUnionType(dynamicRoutes)}
41
- DynamicRouteTemplate: ${setToUnionType(dynamicRouteContextKeys)}
39
+ StaticRoutes:${setToUnionType(staticRoutes)}
40
+ DynamicRoutes:${setToUnionType(dynamicRoutes)}
41
+ DynamicRouteTemplate:${setToUnionType(dynamicRouteContextKeys)}
42
42
  IsTyped: true
43
43
  ${hasRoutes ? `RouteTypes: ${generateRouteTypesMap(dynamicRouteContextKeys)}` : ''}
44
44
  }
@@ -189,9 +189,9 @@ function addRouteNode(
189
189
  * Formats with one route per line for cleaner git diffs
190
190
  */
191
191
  const setToUnionType = <T>(set: Set<T>) => {
192
- if (set.size === 0) return 'never'
192
+ if (set.size === 0) return ' never'
193
193
  const sorted = [...set].sort()
194
- if (sorted.length === 1) return `\`${sorted[0]}\``
194
+ if (sorted.length === 1) return ` \`${sorted[0]}\``
195
195
  // format as multi-line union for cleaner diffs
196
196
  return '\n | ' + sorted.map((s) => `\`${s}\``).join('\n | ')
197
197
  }
@@ -0,0 +1,94 @@
1
+ import path from 'node:path'
2
+ import { describe, expect, it } from 'vitest'
3
+ import {
4
+ isPathInsideDirectory,
5
+ isRouteFilePath,
6
+ isRouteFileWatchEvent,
7
+ } from './routeFileWatch'
8
+
9
+ describe(isRouteFilePath, () => {
10
+ it('matches route source files', () => {
11
+ expect(isRouteFilePath('/project/app/index.ts')).toBe(true)
12
+ expect(isRouteFilePath('/project/app/index.tsx')).toBe(true)
13
+ expect(isRouteFilePath('/project/app/index.js')).toBe(true)
14
+ expect(isRouteFilePath('/project/app/index.jsx')).toBe(true)
15
+ })
16
+
17
+ it('ignores non-route files', () => {
18
+ expect(isRouteFilePath('/project/app/tamagui.generated.css')).toBe(false)
19
+ expect(isRouteFilePath('/project/app/routes.d.ts')).toBe(false)
20
+ })
21
+ })
22
+
23
+ describe(isPathInsideDirectory, () => {
24
+ it('only matches real descendants of the router root', () => {
25
+ const routerRoot = path.resolve('/project/app')
26
+
27
+ expect(isPathInsideDirectory('/project/app/index.tsx', routerRoot)).toBe(true)
28
+ expect(isPathInsideDirectory('/project/app-copy/index.tsx', routerRoot)).toBe(false)
29
+ expect(isPathInsideDirectory('/project/app', routerRoot)).toBe(false)
30
+ })
31
+ })
32
+
33
+ describe(isRouteFileWatchEvent, () => {
34
+ const routerRoot = path.resolve('/project/app')
35
+
36
+ it('matches route file add and delete events', () => {
37
+ expect(
38
+ isRouteFileWatchEvent({
39
+ event: 'add',
40
+ filePath: '/project/app/index.tsx',
41
+ routerRoot,
42
+ })
43
+ ).toBe(true)
44
+ expect(
45
+ isRouteFileWatchEvent({
46
+ event: 'delete',
47
+ filePath: '/project/app/nested/page.jsx',
48
+ routerRoot,
49
+ })
50
+ ).toBe(true)
51
+ expect(
52
+ isRouteFileWatchEvent({
53
+ event: 'unlink',
54
+ filePath: '/project/app/nested/page.jsx',
55
+ routerRoot,
56
+ })
57
+ ).toBe(true)
58
+ })
59
+
60
+ it('ignores non-route file add and delete events', () => {
61
+ expect(
62
+ isRouteFileWatchEvent({
63
+ event: 'add',
64
+ filePath: '/project/app/tamagui.generated.css',
65
+ routerRoot,
66
+ })
67
+ ).toBe(false)
68
+ expect(
69
+ isRouteFileWatchEvent({
70
+ event: 'delete',
71
+ filePath: '/project/app/routes.d.ts',
72
+ routerRoot,
73
+ })
74
+ ).toBe(false)
75
+ })
76
+
77
+ it('only matches change events when requested', () => {
78
+ expect(
79
+ isRouteFileWatchEvent({
80
+ event: 'change',
81
+ filePath: '/project/app/index.tsx',
82
+ routerRoot,
83
+ })
84
+ ).toBe(false)
85
+ expect(
86
+ isRouteFileWatchEvent({
87
+ event: 'change',
88
+ filePath: '/project/app/index.tsx',
89
+ routerRoot,
90
+ includeChangeEvents: true,
91
+ })
92
+ ).toBe(true)
93
+ })
94
+ })
@@ -0,0 +1,40 @@
1
+ import path from 'node:path'
2
+
3
+ const routeFileExtensionRe = /\.[jt]sx?$/
4
+
5
+ export function isRouteFilePath(filePath: string) {
6
+ return routeFileExtensionRe.test(filePath) && !filePath.endsWith('.d.ts')
7
+ }
8
+
9
+ export function isPathInsideDirectory(filePath: string, directory: string) {
10
+ const relativePath = path.relative(path.resolve(directory), path.resolve(filePath))
11
+ return (
12
+ relativePath !== '' &&
13
+ !relativePath.startsWith('..') &&
14
+ !path.isAbsolute(relativePath)
15
+ )
16
+ }
17
+
18
+ export function isRouteFileWatchEvent({
19
+ event,
20
+ filePath,
21
+ routerRoot,
22
+ includeChangeEvents = false,
23
+ }: {
24
+ event: string
25
+ filePath: string
26
+ routerRoot: string
27
+ includeChangeEvents?: boolean
28
+ }) {
29
+ const isRouteFileEvent =
30
+ event === 'add' ||
31
+ event === 'delete' ||
32
+ event === 'unlink' ||
33
+ (includeChangeEvents && event === 'change')
34
+
35
+ return (
36
+ isRouteFileEvent &&
37
+ isPathInsideDirectory(filePath, routerRoot) &&
38
+ isRouteFilePath(filePath)
39
+ )
40
+ }