one 1.2.15 → 1.2.17

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 (126) hide show
  1. package/dist/cjs/cli/generateRoutes.cjs +20 -5
  2. package/dist/cjs/cli/generateRoutes.js +18 -3
  3. package/dist/cjs/cli/generateRoutes.js.map +1 -1
  4. package/dist/cjs/cli/generateRoutes.native.js +30 -5
  5. package/dist/cjs/cli/generateRoutes.native.js.map +1 -1
  6. package/dist/cjs/cli.cjs +4 -0
  7. package/dist/cjs/cli.js +4 -0
  8. package/dist/cjs/cli.js.map +1 -1
  9. package/dist/cjs/cli.native.js +4 -0
  10. package/dist/cjs/cli.native.js.map +1 -1
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/router/createRoute.cjs +12 -1
  14. package/dist/cjs/router/createRoute.js +12 -1
  15. package/dist/cjs/router/createRoute.js.map +1 -1
  16. package/dist/cjs/router/createRoute.native.js +13 -2
  17. package/dist/cjs/router/createRoute.native.js.map +1 -1
  18. package/dist/cjs/typed-routes/generateRouteTypes.cjs +14 -3
  19. package/dist/cjs/typed-routes/generateRouteTypes.js +12 -3
  20. package/dist/cjs/typed-routes/generateRouteTypes.js.map +1 -1
  21. package/dist/cjs/typed-routes/generateRouteTypes.native.js +29 -3
  22. package/dist/cjs/typed-routes/generateRouteTypes.native.js.map +1 -1
  23. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.cjs +39 -2
  24. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.js +38 -2
  25. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.js.map +1 -1
  26. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js +40 -2
  27. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  28. package/dist/cjs/typed-routes/injectRouteHelpers.cjs +136 -0
  29. package/dist/cjs/typed-routes/injectRouteHelpers.js +104 -0
  30. package/dist/cjs/typed-routes/injectRouteHelpers.js.map +6 -0
  31. package/dist/cjs/typed-routes/injectRouteHelpers.native.js +146 -0
  32. package/dist/cjs/typed-routes/injectRouteHelpers.native.js.map +1 -0
  33. package/dist/cjs/vite/loadConfig.cjs +18 -12
  34. package/dist/cjs/vite/loadConfig.js +20 -13
  35. package/dist/cjs/vite/loadConfig.js.map +1 -1
  36. package/dist/cjs/vite/loadConfig.native.js +18 -11
  37. package/dist/cjs/vite/loadConfig.native.js.map +1 -1
  38. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +3 -2
  39. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js +13 -3
  40. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
  41. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +9 -6
  42. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  43. package/dist/esm/cli/generateRoutes.js +19 -2
  44. package/dist/esm/cli/generateRoutes.js.map +1 -1
  45. package/dist/esm/cli/generateRoutes.mjs +19 -4
  46. package/dist/esm/cli/generateRoutes.mjs.map +1 -1
  47. package/dist/esm/cli/generateRoutes.native.js +29 -4
  48. package/dist/esm/cli/generateRoutes.native.js.map +1 -1
  49. package/dist/esm/cli.js +4 -0
  50. package/dist/esm/cli.js.map +1 -1
  51. package/dist/esm/cli.mjs +4 -0
  52. package/dist/esm/cli.mjs.map +1 -1
  53. package/dist/esm/cli.native.js +4 -0
  54. package/dist/esm/cli.native.js.map +1 -1
  55. package/dist/esm/index.js.map +1 -1
  56. package/dist/esm/index.mjs.map +1 -1
  57. package/dist/esm/index.native.js.map +1 -1
  58. package/dist/esm/router/createRoute.js +12 -1
  59. package/dist/esm/router/createRoute.js.map +1 -1
  60. package/dist/esm/router/createRoute.mjs +12 -1
  61. package/dist/esm/router/createRoute.mjs.map +1 -1
  62. package/dist/esm/router/createRoute.native.js +13 -2
  63. package/dist/esm/router/createRoute.native.js.map +1 -1
  64. package/dist/esm/typed-routes/generateRouteTypes.js +14 -3
  65. package/dist/esm/typed-routes/generateRouteTypes.js.map +1 -1
  66. package/dist/esm/typed-routes/generateRouteTypes.mjs +14 -3
  67. package/dist/esm/typed-routes/generateRouteTypes.mjs.map +1 -1
  68. package/dist/esm/typed-routes/generateRouteTypes.native.js +29 -3
  69. package/dist/esm/typed-routes/generateRouteTypes.native.js.map +1 -1
  70. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.js +38 -2
  71. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.js.map +1 -1
  72. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs +39 -2
  73. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs.map +1 -1
  74. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +40 -2
  75. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  76. package/dist/esm/typed-routes/injectRouteHelpers.js +89 -0
  77. package/dist/esm/typed-routes/injectRouteHelpers.js.map +6 -0
  78. package/dist/esm/typed-routes/injectRouteHelpers.mjs +113 -0
  79. package/dist/esm/typed-routes/injectRouteHelpers.mjs.map +1 -0
  80. package/dist/esm/typed-routes/injectRouteHelpers.native.js +120 -0
  81. package/dist/esm/typed-routes/injectRouteHelpers.native.js.map +1 -0
  82. package/dist/esm/vite/loadConfig.js +20 -13
  83. package/dist/esm/vite/loadConfig.js.map +1 -1
  84. package/dist/esm/vite/loadConfig.mjs +18 -12
  85. package/dist/esm/vite/loadConfig.mjs.map +1 -1
  86. package/dist/esm/vite/loadConfig.native.js +18 -11
  87. package/dist/esm/vite/loadConfig.native.js.map +1 -1
  88. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js +13 -3
  89. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
  90. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +3 -2
  91. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
  92. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +9 -6
  93. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  94. package/package.json +10 -10
  95. package/src/cli/generateRoutes.ts +52 -4
  96. package/src/cli.ts +5 -0
  97. package/src/index.ts +14 -1
  98. package/src/interfaces/router.ts +19 -0
  99. package/src/router/createRoute.ts +16 -3
  100. package/src/typed-routes/generateRouteTypes.ts +46 -2
  101. package/src/typed-routes/getTypedRoutesDeclarationFile.ts +70 -0
  102. package/src/typed-routes/injectRouteHelpers.ts +186 -0
  103. package/src/utils/redirect.ts +1 -1
  104. package/src/vite/loadConfig.ts +29 -17
  105. package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +14 -3
  106. package/src/vite/types.ts +26 -0
  107. package/types/cli/generateRoutes.d.ts +1 -0
  108. package/types/cli/generateRoutes.d.ts.map +1 -1
  109. package/types/index.d.ts +13 -3
  110. package/types/index.d.ts.map +1 -1
  111. package/types/interfaces/router.d.ts +16 -0
  112. package/types/interfaces/router.d.ts.map +1 -1
  113. package/types/router/createRoute.d.ts +28 -13
  114. package/types/router/createRoute.d.ts.map +1 -1
  115. package/types/typed-routes/generateRouteTypes.d.ts +1 -1
  116. package/types/typed-routes/generateRouteTypes.d.ts.map +1 -1
  117. package/types/typed-routes/getTypedRoutesDeclarationFile.d.ts.map +1 -1
  118. package/types/typed-routes/injectRouteHelpers.d.ts +12 -0
  119. package/types/typed-routes/injectRouteHelpers.d.ts.map +1 -0
  120. package/types/utils/redirect.d.ts +1 -3
  121. package/types/utils/redirect.d.ts.map +1 -1
  122. package/types/vite/loadConfig.d.ts +1 -1
  123. package/types/vite/loadConfig.d.ts.map +1 -1
  124. package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
  125. package/types/vite/types.d.ts +25 -0
  126. package/types/vite/types.d.ts.map +1 -1
@@ -0,0 +1,113 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
3
+ async function injectRouteHelpers(filePath, routePath, mode) {
4
+ if (!existsSync(filePath)) return !1;
5
+ try {
6
+ let content = await readFile(filePath, "utf-8"),
7
+ modified = !1;
8
+ const hasTypeRoute = /^type\s+Route\s*=/m.test(content),
9
+ hasConstRoute = /^const\s+route\s*=/m.test(content);
10
+ if (mode === "runtime" && !hasConstRoute) {
11
+ const {
12
+ updatedContent
13
+ } = addCreateRouteImport(content);
14
+ content = updatedContent;
15
+ const routeDeclaration = `const route = createRoute<'${routePath}'>()`;
16
+ content = insertAfterImports(content, routeDeclaration), modified = !0;
17
+ }
18
+ if (mode === "type" && !hasTypeRoute) {
19
+ const {
20
+ updatedContent
21
+ } = addRouteTypeImport(content);
22
+ content = updatedContent;
23
+ const typeDeclaration = `type Route = RouteType<'${routePath}'>`;
24
+ content = insertAfterImports(content, typeDeclaration), modified = !0;
25
+ }
26
+ return modified ? (await writeFile(filePath, content, "utf-8"), !0) : !1;
27
+ } catch (error) {
28
+ return console.error(`Failed to inject route helpers into ${filePath}:`, error), !1;
29
+ }
30
+ }
31
+ function addCreateRouteImport(content) {
32
+ if (/import\s+[^'"]*createRoute[^'"]*from\s+['"]one['"]/m.test(content)) return {
33
+ updatedContent: content,
34
+ importAdded: !1
35
+ };
36
+ const oneImportRegex = /import\s+{([^}]*)}\s+from\s+['"]one['"]/m,
37
+ match = content.match(oneImportRegex);
38
+ if (match) {
39
+ const existingImports = match[1].trim(),
40
+ newImports = existingImports ? `${existingImports}, createRoute` : "createRoute";
41
+ return {
42
+ updatedContent: content.replace(oneImportRegex, `import { ${newImports} } from 'one'`),
43
+ importAdded: !0
44
+ };
45
+ }
46
+ const lastImportIndex = findLastImportIndex(content);
47
+ if (lastImportIndex >= 0) {
48
+ const lines = content.split(`
49
+ `);
50
+ return lines.splice(lastImportIndex + 1, 0, "import { createRoute } from 'one'"), {
51
+ updatedContent: lines.join(`
52
+ `),
53
+ importAdded: !0
54
+ };
55
+ }
56
+ return {
57
+ updatedContent: `import { createRoute } from 'one'
58
+ ` + content,
59
+ importAdded: !0
60
+ };
61
+ }
62
+ function addRouteTypeImport(content) {
63
+ if (/import\s+type\s+[^'"]*RouteType[^'"]*from\s+['"]one['"]/m.test(content)) return {
64
+ updatedContent: content,
65
+ importAdded: !1
66
+ };
67
+ const oneTypeImportRegex = /import\s+type\s+{([^}]*)}\s+from\s+['"]one['"]/m,
68
+ match = content.match(oneTypeImportRegex);
69
+ if (match) {
70
+ const existingImports = match[1].trim(),
71
+ newImports = existingImports ? `${existingImports}, RouteType` : "RouteType";
72
+ return {
73
+ updatedContent: content.replace(oneTypeImportRegex, `import type { ${newImports} } from 'one'`),
74
+ importAdded: !0
75
+ };
76
+ }
77
+ const lastImportIndex = findLastImportIndex(content);
78
+ if (lastImportIndex >= 0) {
79
+ const lines = content.split(`
80
+ `);
81
+ return lines.splice(lastImportIndex + 1, 0, "import type { RouteType } from 'one'"), {
82
+ updatedContent: lines.join(`
83
+ `),
84
+ importAdded: !0
85
+ };
86
+ }
87
+ return {
88
+ updatedContent: `import type { RouteType } from 'one'
89
+ ` + content,
90
+ importAdded: !0
91
+ };
92
+ }
93
+ function findLastImportIndex(content) {
94
+ const lines = content.split(`
95
+ `);
96
+ let lastImportIndex = -1;
97
+ for (let i = 0; i < lines.length; i++) {
98
+ const line = lines[i].trim();
99
+ if (line.startsWith("import ") || lastImportIndex >= 0 && (line.startsWith("from ") || line === "}")) lastImportIndex = i;else if (lastImportIndex >= 0 && line && !line.startsWith("//")) break;
100
+ }
101
+ return lastImportIndex;
102
+ }
103
+ function insertAfterImports(content, codeToInsert) {
104
+ const lines = content.split(`
105
+ `),
106
+ lastImportIndex = findLastImportIndex(content);
107
+ return lastImportIndex >= 0 ? (lines[lastImportIndex + 1] === "" ? lines.splice(lastImportIndex + 2, 0, codeToInsert, "") : lines.splice(lastImportIndex + 1, 0, "", codeToInsert, ""), lines.join(`
108
+ `)) : codeToInsert + `
109
+
110
+ ` + content;
111
+ }
112
+ export { injectRouteHelpers };
113
+ //# sourceMappingURL=injectRouteHelpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["readFile","writeFile","existsSync","injectRouteHelpers","filePath","routePath","mode","content","modified","hasTypeRoute","test","hasConstRoute","updatedContent","addCreateRouteImport","routeDeclaration","insertAfterImports","addRouteTypeImport","typeDeclaration","error","console","importAdded","oneImportRegex","match","existingImports","trim","newImports","replace","lastImportIndex","findLastImportIndex","lines","split","splice","join","oneTypeImportRegex","i","length","line","startsWith","codeToInsert"],"sources":["../../../src/typed-routes/injectRouteHelpers.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,SAAA,QAAiB;AACpC,SAASC,UAAA,QAAkB;AAa3B,eAAsBC,mBACpBC,QAAA,EACAC,SAAA,EACAC,IAAA,EACkB;EAClB,IAAI,CAACJ,UAAA,CAAWE,QAAQ,GACtB,OAAO;EAGT,IAAI;IACF,IAAIG,OAAA,GAAU,MAAMP,QAAA,CAASI,QAAA,EAAU,OAAO;MAC1CI,QAAA,GAAW;IAGf,MAAMC,YAAA,GAAe,qBAAqBC,IAAA,CAAKH,OAAO;MAChDI,aAAA,GAAgB,sBAAsBD,IAAA,CAAKH,OAAO;IAGxD,IAAID,IAAA,KAAS,aAAa,CAACK,aAAA,EAAe;MACxC,MAAM;QAAEC;MAAe,IAAIC,oBAAA,CAAqBN,OAAO;MACvDA,OAAA,GAAUK,cAAA;MAGV,MAAME,gBAAA,GAAmB,8BAA8BT,SAAS;MAChEE,OAAA,GAAUQ,kBAAA,CAAmBR,OAAA,EAASO,gBAAgB,GACtDN,QAAA,GAAW;IACb;IAGA,IAAIF,IAAA,KAAS,UAAU,CAACG,YAAA,EAAc;MACpC,MAAM;QAAEG;MAAe,IAAII,kBAAA,CAAmBT,OAAO;MACrDA,OAAA,GAAUK,cAAA;MAGV,MAAMK,eAAA,GAAkB,2BAA2BZ,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,IAAA,KAAS,MAE/DT,eAAA,GAAkBO,CAAA,UACTP,eAAA,IAAmB,KAAKS,IAAA,IAAQ,CAACA,IAAA,CAAKC,UAAA,CAAW,IAAI,GAE9D;EAEJ;EAEA,OAAOV,eAAA;AACT;AAMA,SAASZ,mBAAmBR,OAAA,EAAiB+B,YAAA,EAA8B;EACzE,MAAMT,KAAA,GAAQtB,OAAA,CAAQuB,KAAA,CAAM;AAAA,CAAI;IAC1BH,eAAA,GAAkBC,mBAAA,CAAoBrB,OAAO;EAEnD,OAAIoB,eAAA,IAAmB,KAEJE,KAAA,CAAMF,eAAA,GAAkB,CAAC,MACR,KAIhCE,KAAA,CAAME,MAAA,CAAOJ,eAAA,GAAkB,GAAG,GAAGW,YAAA,EAAc,EAAE,IAGrDT,KAAA,CAAME,MAAA,CAAOJ,eAAA,GAAkB,GAAG,GAAG,IAAIW,YAAA,EAAc,EAAE,GAGpDT,KAAA,CAAMG,IAAA,CAAK;AAAA,CAAI,KAIjBM,YAAA,GAAe;AAAA;AAAA,IAAS/B,OAAA;AACjC","ignoreList":[]}
@@ -0,0 +1,120 @@
1
+ import { readFile, writeFile } from "fs/promises";
2
+ import { existsSync } from "fs";
3
+ async function injectRouteHelpers(filePath, routePath, mode) {
4
+ if (!existsSync(filePath)) return !1;
5
+ try {
6
+ var content = await readFile(filePath, "utf-8"),
7
+ modified = !1,
8
+ hasTypeRoute = /^type\s+Route\s*=/m.test(content),
9
+ hasConstRoute = /^const\s+route\s*=/m.test(content);
10
+ if (mode === "runtime" && !hasConstRoute) {
11
+ var {
12
+ updatedContent
13
+ } = addCreateRouteImport(content);
14
+ content = updatedContent;
15
+ var routeDeclaration = `const route = createRoute<'${routePath}'>()`;
16
+ content = insertAfterImports(content, routeDeclaration), modified = !0;
17
+ }
18
+ if (mode === "type" && !hasTypeRoute) {
19
+ var {
20
+ updatedContent: updatedContent1
21
+ } = addRouteTypeImport(content);
22
+ content = updatedContent1;
23
+ var typeDeclaration = `type Route = RouteType<'${routePath}'>`;
24
+ content = insertAfterImports(content, typeDeclaration), modified = !0;
25
+ }
26
+ return modified ? (await writeFile(filePath, content, "utf-8"), !0) : !1;
27
+ } catch (error) {
28
+ return console.error(`Failed to inject route helpers into ${filePath}:`, error), !1;
29
+ }
30
+ }
31
+ function addCreateRouteImport(content) {
32
+ if (/import\s+[^'"]*createRoute[^'"]*from\s+['"]one['"]/m.test(content)) return {
33
+ updatedContent: content,
34
+ importAdded: !1
35
+ };
36
+ var oneImportRegex = /import\s+{([^}]*)}\s+from\s+['"]one['"]/m,
37
+ match = content.match(oneImportRegex);
38
+ if (match) {
39
+ var existingImports = match[1].trim(),
40
+ newImports = existingImports ? `${existingImports}, createRoute` : "createRoute",
41
+ updatedContent = content.replace(oneImportRegex, `import { ${newImports} } from 'one'`);
42
+ return {
43
+ updatedContent,
44
+ importAdded: !0
45
+ };
46
+ }
47
+ var lastImportIndex = findLastImportIndex(content);
48
+ if (lastImportIndex >= 0) {
49
+ var lines = content.split(`
50
+ `);
51
+ return lines.splice(lastImportIndex + 1, 0, "import { createRoute } from 'one'"), {
52
+ updatedContent: lines.join(`
53
+ `),
54
+ importAdded: !0
55
+ };
56
+ }
57
+ var newImport = `import { createRoute } from 'one'
58
+ `;
59
+ return {
60
+ updatedContent: newImport + content,
61
+ importAdded: !0
62
+ };
63
+ }
64
+ function addRouteTypeImport(content) {
65
+ if (/import\s+type\s+[^'"]*RouteType[^'"]*from\s+['"]one['"]/m.test(content)) return {
66
+ updatedContent: content,
67
+ importAdded: !1
68
+ };
69
+ var oneTypeImportRegex = /import\s+type\s+{([^}]*)}\s+from\s+['"]one['"]/m,
70
+ match = content.match(oneTypeImportRegex);
71
+ if (match) {
72
+ var existingImports = match[1].trim(),
73
+ newImports = existingImports ? `${existingImports}, RouteType` : "RouteType",
74
+ updatedContent = content.replace(oneTypeImportRegex, `import type { ${newImports} } from 'one'`);
75
+ return {
76
+ updatedContent,
77
+ importAdded: !0
78
+ };
79
+ }
80
+ var lastImportIndex = findLastImportIndex(content);
81
+ if (lastImportIndex >= 0) {
82
+ var lines = content.split(`
83
+ `);
84
+ return lines.splice(lastImportIndex + 1, 0, "import type { RouteType } from 'one'"), {
85
+ updatedContent: lines.join(`
86
+ `),
87
+ importAdded: !0
88
+ };
89
+ }
90
+ var newImport = `import type { RouteType } from 'one'
91
+ `;
92
+ return {
93
+ updatedContent: newImport + content,
94
+ importAdded: !0
95
+ };
96
+ }
97
+ function findLastImportIndex(content) {
98
+ for (var lines = content.split(`
99
+ `), lastImportIndex = -1, i = 0; i < lines.length; i++) {
100
+ var line = lines[i].trim();
101
+ if (line.startsWith("import ") || lastImportIndex >= 0 && (line.startsWith("from ") || line === "}")) lastImportIndex = i;else if (lastImportIndex >= 0 && line && !line.startsWith("//")) break;
102
+ }
103
+ return lastImportIndex;
104
+ }
105
+ function insertAfterImports(content, codeToInsert) {
106
+ var lines = content.split(`
107
+ `),
108
+ lastImportIndex = findLastImportIndex(content);
109
+ if (lastImportIndex >= 0) {
110
+ var nextLine = lines[lastImportIndex + 1],
111
+ hasBlankLine = nextLine === "";
112
+ return hasBlankLine ? lines.splice(lastImportIndex + 2, 0, codeToInsert, "") : lines.splice(lastImportIndex + 1, 0, "", codeToInsert, ""), lines.join(`
113
+ `);
114
+ }
115
+ return codeToInsert + `
116
+
117
+ ` + content;
118
+ }
119
+ export { injectRouteHelpers };
120
+ //# sourceMappingURL=injectRouteHelpers.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["readFile","writeFile","existsSync","injectRouteHelpers","filePath","routePath","mode","content","modified","hasTypeRoute","test","hasConstRoute","updatedContent","addCreateRouteImport","routeDeclaration","insertAfterImports","updatedContent1","addRouteTypeImport","typeDeclaration","error","console","importAdded","oneImportRegex","match","existingImports","trim","newImports","replace","lastImportIndex","findLastImportIndex","lines","split","splice","join","newImport","oneTypeImportRegex"],"sources":["../../../src/typed-routes/injectRouteHelpers.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAU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MA;EACE;EAAgC,IAC1Ba,SAAA;AAEN;EAawB,OAIjB;IAAetB,cAAA,EAAAsB,SAAA,GAAA3B,OAAA;IAASc,WAAA;EACjC","ignoreList":[]}
@@ -8,20 +8,27 @@ function getUserOneOptions() {
8
8
  throw new Error("One not loaded properly, is the one() plugin in your vite.config.ts?");
9
9
  return globalThis.__oneOptions;
10
10
  }
11
- async function loadUserOneOptions(command) {
12
- const config = await loadConfigFromFile({
13
- mode: command === "serve" ? "dev" : "prod",
14
- command
11
+ async function loadUserOneOptions(command, silent = !1) {
12
+ const originalConsoleError = console.error;
13
+ silent && (console.error = () => {
15
14
  });
16
- if (!config)
17
- throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
18
- const oneOptions = getUserOneOptions();
19
- if (!oneOptions)
20
- throw new Error("No One plugin config in this vite.config");
21
- return {
22
- config,
23
- oneOptions
24
- };
15
+ try {
16
+ const config = await loadConfigFromFile({
17
+ mode: command === "serve" ? "dev" : "prod",
18
+ command
19
+ });
20
+ if (!config)
21
+ throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
22
+ const oneOptions = getUserOneOptions();
23
+ if (!oneOptions)
24
+ throw new Error("No One plugin config in this vite.config");
25
+ return {
26
+ config,
27
+ oneOptions
28
+ };
29
+ } finally {
30
+ silent && (console.error = originalConsoleError);
31
+ }
25
32
  }
26
33
  export {
27
34
  loadUserOneOptions,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/vite/loadConfig.ts"],
4
- "mappings": "AAAA,SAAS,0BAA0B;AACnC,OAAO;AAKA,SAAS,cAAc,MAAyB;AACrD,aAAW,eAAe;AAC5B;AAEA,SAAS,oBAAoB;AAC3B,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,sEAAsE;AAExF,SAAO,WAAW;AACpB;AAEA,eAAsB,mBAAmB,SAA4B;AACnE,QAAM,SAAS,MAAM,mBAAmB;AAAA,IACtC,MAAM,YAAY,UAAU,QAAQ;AAAA,IACpC;AAAA,EACF,CAAC;AAED,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,uBAAuB,QAAQ,IAAI,CAAC,kCAAkC;AAGxF,QAAM,aAAa,kBAAkB;AAErC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,0CAA0C;AAG5D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "mappings": "AAAA,SAAS,0BAA0B;AACnC,OAAO;AAKA,SAAS,cAAc,MAAyB;AACrD,aAAW,eAAe;AAC5B;AAEA,SAAS,oBAAoB;AAC3B,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,sEAAsE;AAExF,SAAO,WAAW;AACpB;AAEA,eAAsB,mBAAmB,SAA4B,SAAS,IAAO;AAEnF,QAAM,uBAAuB,QAAQ;AACrC,EAAI,WACF,QAAQ,QAAQ,MAAM;AAAA,EAAC;AAGzB,MAAI;AACF,UAAM,SAAS,MAAM,mBAAmB;AAAA,MACtC,MAAM,YAAY,UAAU,QAAQ;AAAA,MACpC;AAAA,IACF,CAAC;AAED,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,uBAAuB,QAAQ,IAAI,CAAC,kCAAkC;AAGxF,UAAM,aAAa,kBAAkB;AAErC,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,0CAA0C;AAG5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,UAAE;AACA,IAAI,WACF,QAAQ,QAAQ;AAAA,EAEpB;AACF;",
5
5
  "names": []
6
6
  }
@@ -7,18 +7,24 @@ function getUserOneOptions() {
7
7
  if (!globalThis.__oneOptions) throw new Error("One not loaded properly, is the one() plugin in your vite.config.ts?");
8
8
  return globalThis.__oneOptions;
9
9
  }
10
- async function loadUserOneOptions(command) {
11
- const config = await loadConfigFromFile({
12
- mode: command === "serve" ? "dev" : "prod",
13
- command
14
- });
15
- if (!config) throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
16
- const oneOptions = getUserOneOptions();
17
- if (!oneOptions) throw new Error("No One plugin config in this vite.config");
18
- return {
19
- config,
20
- oneOptions
21
- };
10
+ async function loadUserOneOptions(command, silent = !1) {
11
+ const originalConsoleError = console.error;
12
+ silent && (console.error = () => {});
13
+ try {
14
+ const config = await loadConfigFromFile({
15
+ mode: command === "serve" ? "dev" : "prod",
16
+ command
17
+ });
18
+ if (!config) throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
19
+ const oneOptions = getUserOneOptions();
20
+ if (!oneOptions) throw new Error("No One plugin config in this vite.config");
21
+ return {
22
+ config,
23
+ oneOptions
24
+ };
25
+ } finally {
26
+ silent && (console.error = originalConsoleError);
27
+ }
22
28
  }
23
29
  export { loadUserOneOptions, setOneOptions };
24
30
  //# sourceMappingURL=loadConfig.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["loadConfigFromFile","setOneOptions","next","globalThis","__oneOptions","getUserOneOptions","Error","loadUserOneOptions","command","config","mode","process","cwd","oneOptions"],"sources":["../../../src/vite/loadConfig.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AACnC,OAAO;AAKA,SAASC,cAAcC,IAAA,EAAyB;EACrDC,UAAA,CAAWC,YAAA,GAAeF,IAAA;AAC5B;AAEA,SAASG,kBAAA,EAAoB;EAC3B,IAAI,CAACF,UAAA,CAAWC,YAAA,EACd,MAAM,IAAIE,KAAA,CAAM,sEAAsE;EAExF,OAAOH,UAAA,CAAWC,YAAA;AACpB;AAEA,eAAsBG,mBAAmBC,OAAA,EAA4B;EACnE,MAAMC,MAAA,GAAS,MAAMT,kBAAA,CAAmB;IACtCU,IAAA,EAAMF,OAAA,KAAY,UAAU,QAAQ;IACpCA;EACF,CAAC;EAED,IAAI,CAACC,MAAA,EACH,MAAM,IAAIH,KAAA,CAAM,uBAAuBK,OAAA,CAAQC,GAAA,CAAI,CAAC,kCAAkC;EAGxF,MAAMC,UAAA,GAAaR,iBAAA,CAAkB;EAErC,IAAI,CAACQ,UAAA,EACH,MAAM,IAAIP,KAAA,CAAM,0CAA0C;EAG5D,OAAO;IACLG,MAAA;IACAI;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["loadConfigFromFile","setOneOptions","next","globalThis","__oneOptions","getUserOneOptions","Error","loadUserOneOptions","command","silent","originalConsoleError","console","error","config","mode","process","cwd","oneOptions"],"sources":["../../../src/vite/loadConfig.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AACnC,OAAO;AAKA,SAASC,cAAcC,IAAA,EAAyB;EACrDC,UAAA,CAAWC,YAAA,GAAeF,IAAA;AAC5B;AAEA,SAASG,kBAAA,EAAoB;EAC3B,IAAI,CAACF,UAAA,CAAWC,YAAA,EACd,MAAM,IAAIE,KAAA,CAAM,sEAAsE;EAExF,OAAOH,UAAA,CAAWC,YAAA;AACpB;AAEA,eAAsBG,mBAAmBC,OAAA,EAA4BC,MAAA,GAAS,IAAO;EAEnF,MAAMC,oBAAA,GAAuBC,OAAA,CAAQC,KAAA;EACjCH,MAAA,KACFE,OAAA,CAAQC,KAAA,GAAQ,MAAM,CAAC;EAGzB,IAAI;IACF,MAAMC,MAAA,GAAS,MAAMb,kBAAA,CAAmB;MACtCc,IAAA,EAAMN,OAAA,KAAY,UAAU,QAAQ;MACpCA;IACF,CAAC;IAED,IAAI,CAACK,MAAA,EACH,MAAM,IAAIP,KAAA,CAAM,uBAAuBS,OAAA,CAAQC,GAAA,CAAI,CAAC,kCAAkC;IAGxF,MAAMC,UAAA,GAAaZ,iBAAA,CAAkB;IAErC,IAAI,CAACY,UAAA,EACH,MAAM,IAAIX,KAAA,CAAM,0CAA0C;IAG5D,OAAO;MACLO,MAAA;MACAI;IACF;EACF,UAAE;IACIR,MAAA,KACFE,OAAA,CAAQC,KAAA,GAAQF,oBAAA;EAEpB;AACF","ignoreList":[]}
@@ -8,17 +8,24 @@ function getUserOneOptions() {
8
8
  return globalThis.__oneOptions;
9
9
  }
10
10
  async function loadUserOneOptions(command) {
11
- var config = await loadConfigFromFile({
12
- mode: command === "serve" ? "dev" : "prod",
13
- command
14
- });
15
- if (!config) throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
16
- var oneOptions = getUserOneOptions();
17
- if (!oneOptions) throw new Error("No One plugin config in this vite.config");
18
- return {
19
- config,
20
- oneOptions
21
- };
11
+ var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1,
12
+ originalConsoleError = console.error;
13
+ silent && (console.error = function () {});
14
+ try {
15
+ var config = await loadConfigFromFile({
16
+ mode: command === "serve" ? "dev" : "prod",
17
+ command
18
+ });
19
+ if (!config) throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
20
+ var oneOptions = getUserOneOptions();
21
+ if (!oneOptions) throw new Error("No One plugin config in this vite.config");
22
+ return {
23
+ config,
24
+ oneOptions
25
+ };
26
+ } finally {
27
+ silent && (console.error = originalConsoleError);
28
+ }
22
29
  }
23
30
  export { loadUserOneOptions, setOneOptions };
24
31
  //# sourceMappingURL=loadConfig.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["loadConfigFromFile","setOneOptions","next","globalThis","__oneOptions","getUserOneOptions","Error","loadUserOneOptions","command","config","mode","process","cwd","oneOptions"],"sources":["../../../src/vite/loadConfig.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AACnC,OAAO;AAKA,SAASC,cAAcC,IAAA,EAAyB;EACrDC,UAAA,CAAWC,YAAA,GAAeF,IAAA;AAC5B;AAEA,SAASG,kBAAA,EAAoB;EAC3B,IAAI,CAACF,UAAA,CAAWC,YAAA,EACd,MAAM,IAAIE,KAAA,CAAM,sEAAsE;EAExF,OAAOH,UAAA,CAAWC,YAAA;AACpB;AAEA,eAAsBG,mBAAmBC,OAAA,EAA4B;EACnE,IAAAC,MAAM,SAAST,kBAAM;IACnBU,IAAA,EAAMF,OAAA,KAAY,UAAU,QAAQ;IACpCA;EACF,CAAC;EAED,IAAI,CAACC,MAAA,EACH,MAAM,IAAIH,KAAA,CAAM,uBAAuBK,OAAA,CAAQC,GAAA,CAAI,CAAC,kCAAkC;EAGxF,IAAAC,UAAM,GAAAR,iBAAa;EAEnB,IAAI,CAACQ,UAAA,EACH,MAAM,IAAIP,KAAA,CAAM,0CAA0C;EAG5D,OAAO;IACLG,MAAA;IACAI;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["loadConfigFromFile","setOneOptions","next","globalThis","__oneOptions","getUserOneOptions","Error","loadUserOneOptions","command","silent","arguments","length","originalConsoleError","console","error","config","mode","process","cwd","oneOptions"],"sources":["../../../src/vite/loadConfig.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AACnC,OAAO;AAKA,SAASC,cAAcC,IAAA,EAAyB;EACrDC,UAAA,CAAWC,YAAA,GAAeF,IAAA;AAC5B;AAEA,SAASG,kBAAA,EAAoB;EAC3B,IAAI,CAACF,UAAA,CAAWC,YAAA,EACd,MAAM,IAAIE,KAAA,CAAM,sEAAsE;EAExF,OAAOH,UAAA,CAAWC,YAAA;AACpB;AAEA,eAAsBG,mBAAmBC,OAAA,EAA4B;EAEnE,IAAAC,MAAM,GAAAC,SAAA,CAAAC,MAAuB,QAAQD,SAAA,iBAAAA,SAAA;IAAAE,oBAAA,GAAAC,OAAA,CAAAC,KAAA;EACjCL,MAAA,KACFI,OAAA,CAAQC,KAAA,GAAQ,YAAM,CAAC;EAGzB,IAAI;IACF,IAAAC,MAAM,SAASf,kBAAM;MACnBgB,IAAA,EAAMR,OAAA,KAAY,UAAU,QAAQ;MACpCA;IACF,CAAC;IAED,IAAI,CAACO,MAAA,EACH,MAAM,IAAIT,KAAA,CAAM,uBAAuBW,OAAA,CAAQC,GAAA,CAAI,CAAC,kCAAkC;IAGxF,IAAAC,UAAM,GAAAd,iBAAa;IAEnB,IAAI,CAACc,UAAA,EACH,MAAM,IAAIb,KAAA,CAAM,0CAA0C;IAG5D,OAAO;MACLS,MAAA;MACAI;IACF;EACF,UAAE;IACIV,MAAA,KACFI,OAAA,CAAQC,KAAA,GAAQF,oBAAA;EAEpB;AACF","ignoreList":[]}
@@ -8,11 +8,21 @@ function generateFileSystemRouteTypesPlugin(options) {
8
8
  enforce: "post",
9
9
  apply: "serve",
10
10
  configureServer(server) {
11
- const appDir = join(process.cwd(), getRouterRootFromOneOptions(options)), outFile = join(appDir, "routes.d.ts"), routerRoot = getRouterRootFromOneOptions(options), fileWatcherChangeListener = debounce(async (type, path) => {
12
- (type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles);
11
+ const appDir = join(process.cwd(), getRouterRootFromOneOptions(options)), outFile = join(appDir, "routes.d.ts"), routerRoot = getRouterRootFromOneOptions(options), typedRoutesGeneration = options.router?.experimental?.typedRoutesGeneration || void 0, fileWatcherChangeListener = debounce(async (type, path) => {
12
+ (type === "add" || type === "delete" || type === "change") && path.startsWith(appDir) && generateRouteTypes(
13
+ outFile,
14
+ routerRoot,
15
+ options.router?.ignoredRouteFiles,
16
+ typedRoutesGeneration
17
+ );
13
18
  }, 100);
14
19
  return server.watcher.addListener("all", fileWatcherChangeListener), () => {
15
- generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles);
20
+ generateRouteTypes(
21
+ outFile,
22
+ routerRoot,
23
+ options.router?.ignoredRouteFiles,
24
+ typedRoutesGeneration
25
+ );
16
26
  };
17
27
  }
18
28
  };
@@ -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;AAEzB,SAAS,0BAA0B;AACnC,SAAS,mCAAmC;AAGrC,SAAS,mCAAmC,SAAoC;AACrF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,IAEP,gBAAgB,QAAQ;AACtB,YAAM,SAAS,KAAK,QAAQ,IAA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
11
  const appDir = join(process.cwd(), getRouterRootFromOneOptions(options)),
12
12
  outFile = join(appDir, "routes.d.ts"),
13
13
  routerRoot = getRouterRootFromOneOptions(options),
14
+ typedRoutesGeneration = options.router?.experimental?.typedRoutesGeneration || void 0,
14
15
  fileWatcherChangeListener = debounce(async (type, path) => {
15
- (type === "add" || type === "delete") && path.startsWith(appDir) && generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles);
16
+ (type === "add" || type === "delete" || type === "change") && path.startsWith(appDir) && generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles, typedRoutesGeneration);
16
17
  }, 100);
17
18
  return server.watcher.addListener("all", fileWatcherChangeListener), () => {
18
- generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles);
19
+ generateRouteTypes(outFile, routerRoot, options.router?.ignoredRouteFiles, typedRoutesGeneration);
19
20
  };
20
21
  }
21
22
  };
@@ -1 +1 @@
1
- {"version":3,"names":["join","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","fileWatcherChangeListener","type","path","startsWith","router","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,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,GAASX,IAAA,CAAKY,OAAA,CAAQC,GAAA,CAAI,GAAGV,2BAAA,CAA4BE,OAAO,CAAC;QAEjES,OAAA,GAAUd,IAAA,CAAKW,MAAA,EAAQ,aAAa;QAEpCI,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,UAAA,EAAYV,OAAA,CAAQe,MAAA,EAAQC,iBAAiB;QAG/E,GAAG,GAAG;MAEN,OAAAX,MAAA,CAAOY,OAAA,CAAQC,WAAA,CAAY,OAAOP,yBAAyB,GAEpD,MAAM;QAGXd,kBAAA,CAAmBY,OAAA,EAASC,UAAA,EAAYV,OAAA,CAAQe,MAAA,EAAQC,iBAAiB;MAC3E;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["join","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","typedRoutesGeneration","router","experimental","fileWatcherChangeListener","type","path","startsWith","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,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,GAASX,IAAA,CAAKY,OAAA,CAAQC,GAAA,CAAI,GAAGV,2BAAA,CAA4BE,OAAO,CAAC;QAEjES,OAAA,GAAUd,IAAA,CAAKW,MAAA,EAAQ,aAAa;QAEpCI,UAAA,GAAaZ,2BAAA,CAA4BE,OAAO;QAChDW,qBAAA,GAAwBX,OAAA,CAAQY,MAAA,EAAQC,YAAA,EAAcF,qBAAA,IAAyB;QAG/EG,yBAAA,GAA4BlB,QAAA,CAAS,OAAOmB,IAAA,EAAcC,IAAA,KAAiB;UAC/E,CAAID,IAAA,KAAS,SAASA,IAAA,KAAS,YAAYA,IAAA,KAAS,aAC9CC,IAAA,CAAKC,UAAA,CAAWX,MAAM,KAExBT,kBAAA,CACEY,OAAA,EACAC,UAAA,EACAV,OAAA,CAAQY,MAAA,EAAQM,iBAAA,EAChBP,qBACF;QAGN,GAAG,GAAG;MAEN,OAAAN,MAAA,CAAOc,OAAA,CAAQC,WAAA,CAAY,OAAON,yBAAyB,GAEpD,MAAM;QAGXjB,kBAAA,CACEY,OAAA,EACAC,UAAA,EACAV,OAAA,CAAQY,MAAA,EAAQM,iBAAA,EAChBP,qBACF;MACF;IACF;EACF;AACF","ignoreList":[]}
@@ -8,18 +8,21 @@ function generateFileSystemRouteTypesPlugin(options) {
8
8
  enforce: "post",
9
9
  apply: "serve",
10
10
  configureServer(server) {
11
- var appDir = join(process.cwd(), getRouterRootFromOneOptions(options)),
11
+ var _options_router_experimental,
12
+ _options_router,
13
+ appDir = join(process.cwd(), getRouterRootFromOneOptions(options)),
12
14
  outFile = join(appDir, "routes.d.ts"),
13
15
  routerRoot = getRouterRootFromOneOptions(options),
16
+ typedRoutesGeneration = ((_options_router = options.router) === null || _options_router === void 0 || (_options_router_experimental = _options_router.experimental) === null || _options_router_experimental === void 0 ? void 0 : _options_router_experimental.typedRoutesGeneration) || void 0,
14
17
  fileWatcherChangeListener = debounce(async function (type, path) {
15
- if ((type === "add" || type === "delete") && path.startsWith(appDir)) {
16
- var _options_router;
17
- generateRouteTypes(outFile, routerRoot, (_options_router = options.router) === null || _options_router === void 0 ? void 0 : _options_router.ignoredRouteFiles);
18
+ if ((type === "add" || type === "delete" || type === "change") && path.startsWith(appDir)) {
19
+ var _options_router2;
20
+ generateRouteTypes(outFile, routerRoot, (_options_router2 = options.router) === null || _options_router2 === void 0 ? void 0 : _options_router2.ignoredRouteFiles, typedRoutesGeneration);
18
21
  }
19
22
  }, 100);
20
23
  return server.watcher.addListener("all", fileWatcherChangeListener), function () {
21
- var _options_router;
22
- generateRouteTypes(outFile, routerRoot, (_options_router = options.router) === null || _options_router === void 0 ? void 0 : _options_router.ignoredRouteFiles);
24
+ var _options_router2;
25
+ generateRouteTypes(outFile, routerRoot, (_options_router2 = options.router) === null || _options_router2 === void 0 ? void 0 : _options_router2.ignoredRouteFiles, typedRoutesGeneration);
23
26
  };
24
27
  }
25
28
  };
@@ -1 +1 @@
1
- {"version":3,"names":["join","debounce","generateRouteTypes","getRouterRootFromOneOptions","generateFileSystemRouteTypesPlugin","options","name","enforce","apply","configureServer","server","appDir","process","cwd","outFile","routerRoot","fileWatcherChangeListener","type","path","startsWith","_options_router","router","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,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,MAAM,GAAAX,IAAS,CAAAY,OAAK,CAAAC,GAAQ,IAAIV,2BAAG,CAAAE,OAA4B,EAAO;QAACS,OAEjE,GAAAd,IAAU,CAAAW,MAAK,eAAQ;QAAaI,UAEpC,GAAAZ,2BAAa,CAAAE,OAA4B;QAAOW,yBAGhD,GAAAf,QAA4B,iBAA8BgB,IAAA,EAAAC,IAAiB;UAC/E,IAAI,CAAAD,IAAA,KAAS,KAAS,IAAAA,IAAA,KAAS,aACzBC,IAAK,CAAAC,UAAW,CAAAR,MAAM,CAExB;YAGH,IAAGS,eAAA;YAENlB,kBAAe,CAAAY,OAAA,EAAAC,UAAmB,GAAAK,eAAA,GAAAf,OAE3B,CAAAgB,MAAM,cAAAD,eAAA,uBAAAA,eAAA,CAAAE,iBAAA;UAGX;QACF;MACF,OAAAZ,MAAA,CAAAa,OAAA,CAAAC,WAAA,QAAAR,yBAAA;QACF,IAAAI,eAAA;QACFlB,kBAAA,CAAAY,OAAA,EAAAC,UAAA,GAAAK,eAAA,GAAAf,OAAA,CAAAgB,MAAA,cAAAD,eAAA,uBAAAA,eAAA,CAAAE,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["join","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","startsWith","_options_router2","ignoredRouteFiles","watcher","addListener"],"sources":["../../../../src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAA,QAAY;AACrB,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;QAAAC,eAAG;QAAAC,MAAA,GAAAb,IAA4B,CAAAc,OAAQ,CAAAC,GAEjE,IAAAZ,2BAAuB,CAAAE,OAEvB;QAAAW,OAAa,GAAAhB,IAAA,CAAAa,MAAA,eAA4B;QAAAI,UACzC,GAAAd,2BAAgC,CAAAE,OAAQ;QAAAa,qBAAc,KAAAN,eAAyB,GAG/EP,OAAA,CAAAc,MAAA,cAA4BP,eAAgB,KAAc,UAAiB,CAAAD,4BAAA,GAAAC,eAAA,CAAAQ,YAAA,cAAAT,4BAAA,uBAAAA,4BAAA,CAAAO,qBAAA;QAAAG,yBAAA,GAAApB,QAAA,iBAAAqB,IAAA,EAAAC,IAAA;UAC/E,IAAI,CAAAD,IAAA,KAAS,KAAS,IAAAA,IAAA,KAAS,QAAY,IAAAA,IAAA,KAAS,aAC9CC,IAAK,CAAAC,UAAW,CAAAX,MAAM,CAExB;YACE,IAAAY,gBAAA;YACAvB,kBAAA,CAAAc,OAAA,EAAAC,UAAA,GAAAQ,gBAAA,GAAApB,OAAA,CAAAc,MAAA,cAAAM,gBAAA,uBAAAA,gBAAA,CAAAC,iBAAA,EAAAR,qBAAA;UAAA;QACgB,MAChB;MAAA,OACFR,MAAA,CAAAiB,OAAA,CAAAC,WAAA,QAAAP,yBAAA;QAGN,IAAMI,gBAAA;QAENvB,kBAAO,CAAAc,OAAQ,EAAAC,UAAY,EAAO,CAAAQ,gBAAA,GAAApB,OAE3B,CAAAc,MAAM,cAAAM,gBAAA,uBAAAA,gBAAA,CAAAC,iBAAA,EAAAR,qBAAA;MAGX;IAAA;EACE;AACA;AACgB,SAChBd,kCACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "license": "BSD-3-Clause",
5
5
  "sideEffects": [
6
6
  "setup.mjs",
@@ -121,17 +121,17 @@
121
121
  "@react-navigation/routers": "~7.5.1",
122
122
  "@swc/core": "^1.14.0",
123
123
  "@ungap/structured-clone": "^1.2.0",
124
- "@vxrn/compiler": "1.2.15",
125
- "@vxrn/resolve": "1.2.15",
126
- "@vxrn/tslib-lite": "1.2.15",
127
- "@vxrn/universal-color-scheme": "1.2.15",
128
- "@vxrn/use-isomorphic-layout-effect": "1.2.15",
129
- "@vxrn/vite-plugin-metro": "1.2.15",
124
+ "@vxrn/compiler": "1.2.17",
125
+ "@vxrn/resolve": "1.2.17",
126
+ "@vxrn/tslib-lite": "1.2.17",
127
+ "@vxrn/universal-color-scheme": "1.2.17",
128
+ "@vxrn/use-isomorphic-layout-effect": "1.2.17",
129
+ "@vxrn/vite-plugin-metro": "1.2.17",
130
130
  "babel-dead-code-elimination": "^1.0.10",
131
131
  "babel-plugin-module-resolver": "^5.0.2",
132
132
  "citty": "^0.1.6",
133
133
  "core-js": "^3.38.1",
134
- "create-vxrn": "1.2.15",
134
+ "create-vxrn": "1.2.17",
135
135
  "escape-string-regexp": "^5.0.0",
136
136
  "expo-linking": "~8.0.8",
137
137
  "expo-modules-core": "~3.0.24",
@@ -157,7 +157,7 @@
157
157
  "vite": "^7.1.12",
158
158
  "vite-plugin-barrel": "^0.4.1",
159
159
  "vite-tsconfig-paths": "^5.1.4",
160
- "vxrn": "1.2.15",
160
+ "vxrn": "1.2.17",
161
161
  "ws": "^8.18.0",
162
162
  "xxhashjs": "^0.2.2"
163
163
  },
@@ -175,7 +175,7 @@
175
175
  "devDependencies": {
176
176
  "@react-navigation/core": "^7.13.0",
177
177
  "@react-navigation/native": "~7.1.19",
178
- "@tamagui/build": "^1.136.1",
178
+ "@tamagui/build": "^1.137.1",
179
179
  "@types/node": "^24.10.0",
180
180
  "@types/react-dom": "^19.2.2",
181
181
  "@types/xxhashjs": "^0.2.4",
@@ -1,12 +1,39 @@
1
1
  import { existsSync } from 'node:fs'
2
2
  import { join } from 'node:path'
3
3
  import { generateRouteTypes } from '../typed-routes/generateRouteTypes'
4
+ import { getRouterRootFromOneOptions } from '../utils/getRouterRootFromOneOptions'
5
+ import { loadUserOneOptions } from '../vite/loadConfig'
4
6
 
5
- export async function run(args: { appDir?: string } = {}) {
7
+ export async function run(args: { appDir?: string; typed?: string } = {}) {
6
8
  const cwd = process.cwd()
7
9
 
8
- // Use provided appDir or default to 'app'
9
- const routerRoot = args.appDir || 'app'
10
+ // Try to load config to get One options
11
+ let oneOptions
12
+ let routerRoot: string
13
+ let ignoredRouteFiles: string[] | undefined
14
+
15
+ try {
16
+ // Suppress stderr during config load (Vite may output resolution errors)
17
+ const originalStderrWrite = process.stderr.write
18
+ let stderrBuffer = ''
19
+ process.stderr.write = ((chunk: any) => {
20
+ stderrBuffer += chunk
21
+ return true
22
+ }) as any
23
+
24
+ try {
25
+ const loaded = await loadUserOneOptions('build')
26
+ oneOptions = loaded.oneOptions
27
+ routerRoot = args.appDir || getRouterRootFromOneOptions(oneOptions)
28
+ ignoredRouteFiles = oneOptions.router?.ignoredRouteFiles
29
+ } finally {
30
+ process.stderr.write = originalStderrWrite
31
+ }
32
+ } catch (error) {
33
+ // Config loading failed - use defaults
34
+ routerRoot = args.appDir || 'app'
35
+ }
36
+
10
37
  const appDir = join(cwd, routerRoot)
11
38
 
12
39
  if (!existsSync(appDir)) {
@@ -19,5 +46,26 @@ export async function run(args: { appDir?: string } = {}) {
19
46
 
20
47
  const outFile = join(appDir, 'routes.d.ts')
21
48
 
22
- await generateRouteTypes(outFile, routerRoot, undefined)
49
+ // Get typed routes mode from CLI arg or config (CLI arg takes precedence)
50
+ let typedRoutesMode: 'type' | 'runtime' | undefined
51
+
52
+ if (args.typed) {
53
+ // CLI arg provided - validate and use it
54
+ if (args.typed === 'type' || args.typed === 'runtime') {
55
+ typedRoutesMode = args.typed
56
+ } else {
57
+ console.error(`Error: Invalid --typed value "${args.typed}". Must be "type" or "runtime"`)
58
+ process.exit(1)
59
+ }
60
+ } else if (oneOptions) {
61
+ // No CLI arg - use config value if available
62
+ typedRoutesMode = oneOptions.router?.experimental?.typedRoutesGeneration || undefined
63
+ }
64
+ if (typedRoutesMode) {
65
+ } else if (!args.typed) {
66
+ }
67
+
68
+ await generateRouteTypes(outFile, routerRoot, ignoredRouteFiles, typedRoutesMode)
69
+ if (typedRoutesMode) {
70
+ }
23
71
  }