one 1.15.10 → 1.16.0

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 (288) hide show
  1. package/dist/cjs/cli/build.cjs +98 -58
  2. package/dist/cjs/cli/build.native.js +106 -63
  3. package/dist/cjs/cli/build.native.js.map +1 -1
  4. package/dist/cjs/cli/buildPage.cjs +3 -3
  5. package/dist/cjs/cli/buildPage.native.js +3 -3
  6. package/dist/cjs/cli/buildPage.native.js.map +1 -1
  7. package/dist/cjs/constants.cjs +2 -0
  8. package/dist/cjs/constants.native.js +2 -0
  9. package/dist/cjs/constants.native.js.map +1 -1
  10. package/dist/cjs/createAPIRoute.native.js.map +1 -1
  11. package/dist/cjs/createApp.cjs +2 -6
  12. package/dist/cjs/createHandleRequest.cjs +2 -2
  13. package/dist/cjs/createHandleRequest.native.js +2 -2
  14. package/dist/cjs/createHandleRequest.native.js.map +1 -1
  15. package/dist/cjs/hooks.cjs +5 -1
  16. package/dist/cjs/hooks.native.js +7 -1
  17. package/dist/cjs/hooks.native.js.map +1 -1
  18. package/dist/cjs/index.native.js.map +1 -1
  19. package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +10 -7
  20. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +13 -10
  21. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  22. package/dist/cjs/metro-config/getViteMetroPluginOptions.test.cjs +23 -0
  23. package/dist/cjs/metro-config/getViteMetroPluginOptions.test.native.js +26 -0
  24. package/dist/cjs/metro-config/getViteMetroPluginOptions.test.native.js.map +1 -0
  25. package/dist/cjs/router/Route.cjs +21 -1
  26. package/dist/cjs/router/Route.native.js +22 -1
  27. package/dist/cjs/router/Route.native.js.map +1 -1
  28. package/dist/cjs/router/interceptRoutes.cjs +6 -6
  29. package/dist/cjs/router/interceptRoutes.native.js +6 -6
  30. package/dist/cjs/router/interceptRoutes.native.js.map +1 -1
  31. package/dist/cjs/router/params.cjs +46 -0
  32. package/dist/cjs/router/params.native.js +70 -0
  33. package/dist/cjs/router/params.native.js.map +1 -0
  34. package/dist/cjs/router/useScreens.cjs +3 -0
  35. package/dist/cjs/router/useScreens.native.js +2 -0
  36. package/dist/cjs/router/useScreens.native.js.map +1 -1
  37. package/dist/cjs/serve-worker.native.js.map +1 -1
  38. package/dist/cjs/server/getServerManifest.cjs +6 -6
  39. package/dist/cjs/server/getServerManifest.native.js +6 -6
  40. package/dist/cjs/server/getServerManifest.native.js.map +1 -1
  41. package/dist/cjs/server/oneServe.cjs +9 -5
  42. package/dist/cjs/server/oneServe.native.js +9 -5
  43. package/dist/cjs/server/oneServe.native.js.map +1 -1
  44. package/dist/cjs/server/workerHandler.cjs +2 -2
  45. package/dist/cjs/server/workerHandler.native.js +2 -2
  46. package/dist/cjs/server/workerHandler.native.js.map +1 -1
  47. package/dist/cjs/skewProtection.cjs +48 -7
  48. package/dist/cjs/skewProtection.native.js +48 -7
  49. package/dist/cjs/skewProtection.native.js.map +1 -1
  50. package/dist/cjs/useLoader.cjs +67 -69
  51. package/dist/cjs/useLoader.native.js +113 -117
  52. package/dist/cjs/useLoader.native.js.map +1 -1
  53. package/dist/cjs/utils/dynamicImport.cjs +3 -1
  54. package/dist/cjs/utils/dynamicImport.native.js +22 -1
  55. package/dist/cjs/utils/dynamicImport.native.js.map +1 -1
  56. package/dist/cjs/utils/toAbsolute.cjs +5 -2
  57. package/dist/cjs/utils/toAbsolute.native.js +6 -1
  58. package/dist/cjs/utils/toAbsolute.native.js.map +1 -1
  59. package/dist/cjs/utils/workerImport.cjs +1 -1
  60. package/dist/cjs/utils/workerImport.native.js +1 -1
  61. package/dist/cjs/utils/workerImport.native.js.map +1 -1
  62. package/dist/cjs/views/RootErrorBoundary.cjs +114 -117
  63. package/dist/cjs/views/RootErrorBoundary.native.js +126 -146
  64. package/dist/cjs/views/RootErrorBoundary.native.js.map +1 -1
  65. package/dist/cjs/views/Try.cjs +17 -18
  66. package/dist/cjs/views/Try.native.js +28 -42
  67. package/dist/cjs/views/Try.native.js.map +1 -1
  68. package/dist/cjs/vite/plugins/criticalCSSPlugin.cjs +2 -1
  69. package/dist/cjs/vite/plugins/criticalCSSPlugin.native.js +2 -1
  70. package/dist/cjs/vite/plugins/criticalCSSPlugin.native.js.map +1 -1
  71. package/dist/cjs/vite/plugins/criticalCSSPlugin.test.cjs +26 -20
  72. package/dist/cjs/vite/plugins/criticalCSSPlugin.test.native.js +28 -20
  73. package/dist/cjs/vite/plugins/criticalCSSPlugin.test.native.js.map +1 -1
  74. package/dist/cjs/vite/plugins/imageDataPlugin.cjs +3 -2
  75. package/dist/cjs/vite/plugins/imageDataPlugin.native.js +3 -2
  76. package/dist/cjs/vite/plugins/imageDataPlugin.native.js.map +1 -1
  77. package/dist/cjs/vite/plugins/imageDataPlugin.test.cjs +34 -69
  78. package/dist/cjs/vite/plugins/imageDataPlugin.test.native.js +34 -69
  79. package/dist/cjs/vite/plugins/imageDataPlugin.test.native.js.map +1 -1
  80. package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +20 -2
  81. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +23 -2
  82. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
  83. package/dist/cjs/vite/plugins/sourceInspectorPlugin.test.cjs +21 -0
  84. package/dist/cjs/vite/plugins/sourceInspectorPlugin.test.native.js +28 -0
  85. package/dist/cjs/vite/plugins/sourceInspectorPlugin.test.native.js.map +1 -0
  86. package/dist/cjs/vite/resolveResponse.cjs +7 -2
  87. package/dist/cjs/vite/resolveResponse.native.js +7 -2
  88. package/dist/cjs/vite/resolveResponse.native.js.map +1 -1
  89. package/dist/esm/cli/build.mjs +100 -60
  90. package/dist/esm/cli/build.mjs.map +1 -1
  91. package/dist/esm/cli/build.native.js +108 -65
  92. package/dist/esm/cli/build.native.js.map +1 -1
  93. package/dist/esm/cli/buildPage.mjs +4 -4
  94. package/dist/esm/cli/buildPage.mjs.map +1 -1
  95. package/dist/esm/cli/buildPage.native.js +4 -4
  96. package/dist/esm/cli/buildPage.native.js.map +1 -1
  97. package/dist/esm/constants.mjs +2 -1
  98. package/dist/esm/constants.mjs.map +1 -1
  99. package/dist/esm/constants.native.js +2 -1
  100. package/dist/esm/constants.native.js.map +1 -1
  101. package/dist/esm/createAPIRoute.mjs.map +1 -1
  102. package/dist/esm/createAPIRoute.native.js.map +1 -1
  103. package/dist/esm/createApp.mjs +2 -6
  104. package/dist/esm/createApp.mjs.map +1 -1
  105. package/dist/esm/createHandleRequest.mjs +2 -2
  106. package/dist/esm/createHandleRequest.mjs.map +1 -1
  107. package/dist/esm/createHandleRequest.native.js +2 -2
  108. package/dist/esm/createHandleRequest.native.js.map +1 -1
  109. package/dist/esm/hooks.mjs +5 -1
  110. package/dist/esm/hooks.mjs.map +1 -1
  111. package/dist/esm/hooks.native.js +7 -1
  112. package/dist/esm/hooks.native.js.map +1 -1
  113. package/dist/esm/index.js.map +1 -1
  114. package/dist/esm/index.mjs.map +1 -1
  115. package/dist/esm/index.native.js.map +1 -1
  116. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +9 -7
  117. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
  118. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +12 -10
  119. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  120. package/dist/esm/metro-config/getViteMetroPluginOptions.test.mjs +24 -0
  121. package/dist/esm/metro-config/getViteMetroPluginOptions.test.mjs.map +1 -0
  122. package/dist/esm/metro-config/getViteMetroPluginOptions.test.native.js +24 -0
  123. package/dist/esm/metro-config/getViteMetroPluginOptions.test.native.js.map +1 -0
  124. package/dist/esm/router/Route.mjs +21 -1
  125. package/dist/esm/router/Route.mjs.map +1 -1
  126. package/dist/esm/router/Route.native.js +22 -1
  127. package/dist/esm/router/Route.native.js.map +1 -1
  128. package/dist/esm/router/interceptRoutes.mjs +7 -7
  129. package/dist/esm/router/interceptRoutes.mjs.map +1 -1
  130. package/dist/esm/router/interceptRoutes.native.js +7 -7
  131. package/dist/esm/router/interceptRoutes.native.js.map +1 -1
  132. package/dist/esm/router/params.mjs +21 -0
  133. package/dist/esm/router/params.mjs.map +1 -0
  134. package/dist/esm/router/params.native.js +42 -0
  135. package/dist/esm/router/params.native.js.map +1 -0
  136. package/dist/esm/router/useScreens.mjs +3 -0
  137. package/dist/esm/router/useScreens.mjs.map +1 -1
  138. package/dist/esm/router/useScreens.native.js +2 -0
  139. package/dist/esm/router/useScreens.native.js.map +1 -1
  140. package/dist/esm/serve-worker.mjs.map +1 -1
  141. package/dist/esm/serve-worker.native.js.map +1 -1
  142. package/dist/esm/server/getServerManifest.mjs +6 -6
  143. package/dist/esm/server/getServerManifest.mjs.map +1 -1
  144. package/dist/esm/server/getServerManifest.native.js +6 -6
  145. package/dist/esm/server/getServerManifest.native.js.map +1 -1
  146. package/dist/esm/server/oneServe.mjs +11 -7
  147. package/dist/esm/server/oneServe.mjs.map +1 -1
  148. package/dist/esm/server/oneServe.native.js +11 -7
  149. package/dist/esm/server/oneServe.native.js.map +1 -1
  150. package/dist/esm/server/workerHandler.mjs +2 -2
  151. package/dist/esm/server/workerHandler.mjs.map +1 -1
  152. package/dist/esm/server/workerHandler.native.js +2 -2
  153. package/dist/esm/server/workerHandler.native.js.map +1 -1
  154. package/dist/esm/skewProtection.mjs +48 -8
  155. package/dist/esm/skewProtection.mjs.map +1 -1
  156. package/dist/esm/skewProtection.native.js +48 -8
  157. package/dist/esm/skewProtection.native.js.map +1 -1
  158. package/dist/esm/useLoader.mjs +64 -66
  159. package/dist/esm/useLoader.mjs.map +1 -1
  160. package/dist/esm/useLoader.native.js +112 -116
  161. package/dist/esm/useLoader.native.js.map +1 -1
  162. package/dist/esm/utils/dynamicImport.mjs +1 -1
  163. package/dist/esm/utils/dynamicImport.mjs.map +1 -1
  164. package/dist/esm/utils/dynamicImport.native.js +20 -1
  165. package/dist/esm/utils/dynamicImport.native.js.map +1 -1
  166. package/dist/esm/utils/toAbsolute.mjs +3 -1
  167. package/dist/esm/utils/toAbsolute.mjs.map +1 -1
  168. package/dist/esm/utils/toAbsolute.native.js +5 -1
  169. package/dist/esm/utils/toAbsolute.native.js.map +1 -1
  170. package/dist/esm/utils/workerImport.mjs +2 -2
  171. package/dist/esm/utils/workerImport.mjs.map +1 -1
  172. package/dist/esm/utils/workerImport.native.js +2 -2
  173. package/dist/esm/utils/workerImport.native.js.map +1 -1
  174. package/dist/esm/views/RootErrorBoundary.mjs +114 -117
  175. package/dist/esm/views/RootErrorBoundary.mjs.map +1 -1
  176. package/dist/esm/views/RootErrorBoundary.native.js +126 -146
  177. package/dist/esm/views/RootErrorBoundary.native.js.map +1 -1
  178. package/dist/esm/views/Try.mjs +17 -18
  179. package/dist/esm/views/Try.mjs.map +1 -1
  180. package/dist/esm/views/Try.native.js +28 -42
  181. package/dist/esm/views/Try.native.js.map +1 -1
  182. package/dist/esm/vite/plugins/criticalCSSPlugin.mjs +2 -1
  183. package/dist/esm/vite/plugins/criticalCSSPlugin.mjs.map +1 -1
  184. package/dist/esm/vite/plugins/criticalCSSPlugin.native.js +2 -1
  185. package/dist/esm/vite/plugins/criticalCSSPlugin.native.js.map +1 -1
  186. package/dist/esm/vite/plugins/criticalCSSPlugin.test.mjs +26 -20
  187. package/dist/esm/vite/plugins/criticalCSSPlugin.test.mjs.map +1 -1
  188. package/dist/esm/vite/plugins/criticalCSSPlugin.test.native.js +28 -20
  189. package/dist/esm/vite/plugins/criticalCSSPlugin.test.native.js.map +1 -1
  190. package/dist/esm/vite/plugins/imageDataPlugin.mjs +4 -3
  191. package/dist/esm/vite/plugins/imageDataPlugin.mjs.map +1 -1
  192. package/dist/esm/vite/plugins/imageDataPlugin.native.js +4 -3
  193. package/dist/esm/vite/plugins/imageDataPlugin.native.js.map +1 -1
  194. package/dist/esm/vite/plugins/imageDataPlugin.test.mjs +34 -69
  195. package/dist/esm/vite/plugins/imageDataPlugin.test.mjs.map +1 -1
  196. package/dist/esm/vite/plugins/imageDataPlugin.test.native.js +34 -69
  197. package/dist/esm/vite/plugins/imageDataPlugin.test.native.js.map +1 -1
  198. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +19 -3
  199. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -1
  200. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +22 -3
  201. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
  202. package/dist/esm/vite/plugins/sourceInspectorPlugin.test.mjs +22 -0
  203. package/dist/esm/vite/plugins/sourceInspectorPlugin.test.mjs.map +1 -0
  204. package/dist/esm/vite/plugins/sourceInspectorPlugin.test.native.js +26 -0
  205. package/dist/esm/vite/plugins/sourceInspectorPlugin.test.native.js.map +1 -0
  206. package/dist/esm/vite/resolveResponse.mjs +7 -2
  207. package/dist/esm/vite/resolveResponse.mjs.map +1 -1
  208. package/dist/esm/vite/resolveResponse.native.js +7 -2
  209. package/dist/esm/vite/resolveResponse.native.js.map +1 -1
  210. package/expo-plugin.cjs +1 -0
  211. package/package.json +15 -10
  212. package/react-native-commands.cjs +1 -0
  213. package/src/cli/build.ts +156 -99
  214. package/src/cli/buildPage.ts +4 -4
  215. package/src/constants.ts +15 -0
  216. package/src/createAPIRoute.ts +35 -2
  217. package/src/createApp.tsx +2 -6
  218. package/src/createHandleRequest.ts +6 -2
  219. package/src/hooks.tsx +9 -1
  220. package/src/index.ts +8 -1
  221. package/src/metro-config/getViteMetroPluginOptions.test.ts +34 -0
  222. package/src/metro-config/getViteMetroPluginOptions.ts +14 -11
  223. package/src/router/Route.tsx +52 -2
  224. package/src/router/interceptRoutes.ts +7 -7
  225. package/src/router/params.ts +32 -0
  226. package/src/router/useScreens.tsx +18 -0
  227. package/src/serve-worker.ts +4 -2
  228. package/src/server/getServerManifest.ts +11 -7
  229. package/src/server/oneServe.ts +12 -14
  230. package/src/server/workerHandler.ts +13 -2
  231. package/src/skewProtection.ts +45 -5
  232. package/src/useLoader.ts +6 -4
  233. package/src/utils/dynamicImport.ts +2 -2
  234. package/src/utils/toAbsolute.ts +5 -0
  235. package/src/utils/workerImport.ts +2 -2
  236. package/src/views/RootErrorBoundary.tsx +18 -0
  237. package/src/views/Try.tsx +18 -0
  238. package/src/vite/plugins/criticalCSSPlugin.test.ts +34 -24
  239. package/src/vite/plugins/criticalCSSPlugin.ts +3 -2
  240. package/src/vite/plugins/imageDataPlugin.test.ts +39 -83
  241. package/src/vite/plugins/imageDataPlugin.ts +5 -4
  242. package/src/vite/plugins/sourceInspectorPlugin.test.ts +40 -0
  243. package/src/vite/plugins/sourceInspectorPlugin.ts +30 -2
  244. package/src/vite/resolveResponse.ts +6 -2
  245. package/types/cli/build.d.ts.map +1 -1
  246. package/types/constants.d.ts +9 -0
  247. package/types/constants.d.ts.map +1 -1
  248. package/types/createAPIRoute.d.ts +28 -3
  249. package/types/createAPIRoute.d.ts.map +1 -1
  250. package/types/createApp.d.ts.map +1 -1
  251. package/types/createHandleRequest.d.ts +1 -1
  252. package/types/createHandleRequest.d.ts.map +1 -1
  253. package/types/headless-server.d.ts +1 -1
  254. package/types/hooks.d.ts.map +1 -1
  255. package/types/index.d.ts +1 -1
  256. package/types/index.d.ts.map +1 -1
  257. package/types/metro-config/getViteMetroPluginOptions.d.ts +5 -0
  258. package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
  259. package/types/metro-config/getViteMetroPluginOptions.test.d.ts +2 -0
  260. package/types/metro-config/getViteMetroPluginOptions.test.d.ts.map +1 -0
  261. package/types/router/Route.d.ts +1 -0
  262. package/types/router/Route.d.ts.map +1 -1
  263. package/types/router/params.d.ts +3 -0
  264. package/types/router/params.d.ts.map +1 -0
  265. package/types/router/useScreens.d.ts.map +1 -1
  266. package/types/serve-worker.d.ts +5 -3
  267. package/types/serve-worker.d.ts.map +1 -1
  268. package/types/server/getServerManifest.d.ts.map +1 -1
  269. package/types/server/oneServe.d.ts.map +1 -1
  270. package/types/server/workerHandler.d.ts +1 -1
  271. package/types/server/workerHandler.d.ts.map +1 -1
  272. package/types/skewProtection.d.ts +1 -0
  273. package/types/skewProtection.d.ts.map +1 -1
  274. package/types/useLoader.d.ts.map +1 -1
  275. package/types/utils/dynamicImport.d.ts +2 -0
  276. package/types/utils/dynamicImport.d.ts.map +1 -1
  277. package/types/utils/toAbsolute.d.ts +3 -0
  278. package/types/utils/toAbsolute.d.ts.map +1 -1
  279. package/types/views/RootErrorBoundary.d.ts.map +1 -1
  280. package/types/views/Try.d.ts.map +1 -1
  281. package/types/vite/plugins/criticalCSSPlugin.d.ts.map +1 -1
  282. package/types/vite/plugins/imageDataPlugin.d.ts.map +1 -1
  283. package/types/vite/plugins/sourceInspectorPlugin.d.ts +2 -0
  284. package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -1
  285. package/types/vite/plugins/sourceInspectorPlugin.test.d.ts +2 -0
  286. package/types/vite/plugins/sourceInspectorPlugin.test.d.ts.map +1 -0
  287. package/types/vite/resolveResponse.d.ts +1 -1
  288. package/types/vite/resolveResponse.d.ts.map +1 -1
@@ -33,10 +33,13 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
33
33
  }), mod);
34
34
  var sourceInspectorPlugin_exports = {};
35
35
  __export(sourceInspectorPlugin_exports, {
36
+ getSourceInspectorPath: () => getSourceInspectorPath,
37
+ resolveEditorFilePath: () => resolveEditorFilePath,
36
38
  sourceInspectorPlugin: () => sourceInspectorPlugin
37
39
  });
38
40
  module.exports = __toCommonJS(sourceInspectorPlugin_exports);
39
41
  var import_node_child_process = require("node:child_process");
42
+ var import_node_fs = require("node:fs");
40
43
  var import_node_path = __toESM(require("node:path"), 1);
41
44
  var import_oxc_parser = require("oxc-parser");
42
45
  var import_vite = require("vite");
@@ -95,10 +98,25 @@ async function findJsxElements(code, filename) {
95
98
  walk(result.program);
96
99
  return locations.sort((a, b) => b.insertOffset - a.insertOffset);
97
100
  }
101
+ function getSourceInspectorPath(filePath, cwd = process.cwd()) {
102
+ const normalizedFilePath = (0, import_vite.normalizePath)(filePath);
103
+ const normalizedCwd = (0, import_vite.normalizePath)(cwd);
104
+ if (normalizedFilePath === normalizedCwd) {
105
+ return "/";
106
+ }
107
+ if (normalizedFilePath.startsWith(`${normalizedCwd}/`)) {
108
+ return normalizedFilePath.slice(normalizedCwd.length);
109
+ }
110
+ return normalizedFilePath;
111
+ }
112
+ function resolveEditorFilePath(filePath, cwd = process.cwd(), fileExists = import_node_fs.existsSync) {
113
+ const projectPath = import_node_path.default.join(cwd, filePath);
114
+ return fileExists(projectPath) ? projectPath : filePath;
115
+ }
98
116
  async function injectSourceToJsx(code, id) {
99
117
  const [filePath] = id.split("?");
100
118
  if (!filePath) return;
101
- const location = filePath.replace((0, import_vite.normalizePath)(process.cwd()), "");
119
+ const location = getSourceInspectorPath(filePath);
102
120
  if (!code.includes("<") || !code.includes(">")) {
103
121
  return;
104
122
  }
@@ -139,7 +157,7 @@ function openInEditor(editor, filePath, line, column) {
139
157
  }
140
158
  return;
141
159
  }
142
- const fullPath = import_node_path.default.join(process.cwd(), filePath);
160
+ const fullPath = resolveEditorFilePath(filePath);
143
161
  const l = line || "1";
144
162
  const c = column || "1";
145
163
  const buildArgs = editorArgs[resolved];
@@ -35,10 +35,13 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
35
35
  }), mod);
36
36
  var sourceInspectorPlugin_exports = {};
37
37
  __export(sourceInspectorPlugin_exports, {
38
+ getSourceInspectorPath: () => getSourceInspectorPath,
39
+ resolveEditorFilePath: () => resolveEditorFilePath,
38
40
  sourceInspectorPlugin: () => sourceInspectorPlugin
39
41
  });
40
42
  module.exports = __toCommonJS(sourceInspectorPlugin_exports);
41
43
  var import_child_process = require("child_process");
44
+ var import_fs = require("fs");
42
45
  var import_path = __toESM(require("path"), 1);
43
46
  var import_oxc_parser = require("oxc-parser");
44
47
  var import_vite = require("vite");
@@ -147,10 +150,28 @@ async function findJsxElements(code, filename) {
147
150
  return b.insertOffset - a.insertOffset;
148
151
  });
149
152
  }
153
+ function getSourceInspectorPath(filePath) {
154
+ var cwd = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd();
155
+ var normalizedFilePath = (0, import_vite.normalizePath)(filePath);
156
+ var normalizedCwd = (0, import_vite.normalizePath)(cwd);
157
+ if (normalizedFilePath === normalizedCwd) {
158
+ return "/";
159
+ }
160
+ if (normalizedFilePath.startsWith(`${normalizedCwd}/`)) {
161
+ return normalizedFilePath.slice(normalizedCwd.length);
162
+ }
163
+ return normalizedFilePath;
164
+ }
165
+ function resolveEditorFilePath(filePath) {
166
+ var cwd = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd(),
167
+ fileExists = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : import_fs.existsSync;
168
+ var projectPath = import_path.default.join(cwd, filePath);
169
+ return fileExists(projectPath) ? projectPath : filePath;
170
+ }
150
171
  async function injectSourceToJsx(code, id) {
151
172
  var [filePath] = id.split("?");
152
173
  if (!filePath) return;
153
- var location = filePath.replace((0, import_vite.normalizePath)(process.cwd()), "");
174
+ var location = getSourceInspectorPath(filePath);
154
175
  if (!code.includes("<") || !code.includes(">")) {
155
176
  return;
156
177
  }
@@ -232,7 +253,7 @@ function openInEditor(editor, filePath, line, column) {
232
253
  }
233
254
  return;
234
255
  }
235
- var fullPath = import_path.default.join(process.cwd(), filePath);
256
+ var fullPath = resolveEditorFilePath(filePath);
236
257
  var l = line || "1";
237
258
  var c = column || "1";
238
259
  var buildArgs = editorArgs[resolved];
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","sourceInspectorPlugin_exports","__export","sourceInspectorPlugin","module","exports","import_child_process","require","import_path","__toESM","import_oxc_parser","import_vite","_type_of","obj","Symbol","constructor","findJsxElements","code","filename","result","parse","errors","length","locations","getJsxName","node","type","name","_node_property","object","property","getLocation","offset","before","slice","lines","split","line","column","walk","tagName","endsWith","_node_attributes","hasSourceAttr","attributes","some","attr","_attr_name","nameEnd","end","loc","start","push","insertOffset","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","keys","iterator","_step","next","done","key","Array","isArray","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","child","err","return","program","sort","a","b","injectSourceToJsx","id","filePath","location","replace","normalizePath","process","cwd","includes","jsxLocations","jsx","sourceAttr","map","editorWarned","editorArgs","f","l","c","cursor","codium","vscodium","zed","subl","webstorm","idea","vim","nvim","emacs"],"sources":["../../../../src/vite/plugins/sourceInspectorPlugin.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,6BAAsB;AACtB,IAAAK,oBAAiB,GAAAC,OAAA;AACjB,IAAAC,WAAA,GAAAC,OAAsB,CAAAF,OAAA;AAEtB,IAAAG,iBAA8B,GAAAH,OAAA;AAe9B,IAAAI,WAAe,GAAAJ,OAAA,OAAgB;AAC7B,SAAMK,QAASA,CAAAC,GAAA;EAEf,uBAAkB;;EAChB,OAAAA,GAAQ,WAAAC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAAA;AAGV,eAAMG,eAA4BA,CAAAC,IAAA,EAAAC,QAAA;EAElC,IAAAC,MAAS,UAAW,GAAAT,iBAA0B,CAAAU,KAAA,EAAAF,QAAA,EAAAD,IAAA;EAC5C,IAAAE,MAAK,CAAAE,MAAM,CAAAC,MAAO;IAClB,OAAI,EAAK;EACT;EACE,IAAAC,SAAM,GAAM;EACZ,SAAAC,UAAaA,CAAGC,IAAG;IACrB,KAAAA,IAAA;IACA,IAAA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AAuD;EACzDK,IAAA,WAAAA,CACFP,CAAA,EAAAC,CAAA,EAAAC,CAAQ;IAAA,QAER,GAAAF,CAAA,IACFC,CAAC,IAAAC,CAAA,GAED;EACE;EAEAM,QAAA,WAAAA,CAAAR,CAAA,EAAOC,CAAA,EAAIC,CAAA;IAA4C,QACxD,QACF,EAAAD,CAAA,EACF,UACF,EAEDC,CAAA,EACEF,CAAA,CACE;EAAY;EAGdS,IAAA,WAAAA,CAAIT,CAAA,EAAAC,CAAA,EAAAC,CAAA;IACF,QACA,UAEAD,CAAA,EACE,YACAC,CAAA,EACAF,CAAA;EAIF;EACAU,GAAA,WAAAA,CAAAV,CAAA,EAAMC,CAAA;IACN,QACA,IAAAA,CAAA,IAEAD,CAAA,CAEA;EACA;EAAYW,IAAA,WAAAA,CACdX,CAAA,EAASC,CAAA;IACP,QACA,IAAAA,CAAA,IACAD,CAAA,CAA+B;EACjC;EACDY,KACH,WAAAA,CAAAZ,CAAA,EAAAC,CAAA,EAAAC,CAAA;IACF,QACF,IAAAD,CAAA,IAAAC,CAAA,IACFF,CAAA,C","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","sourceInspectorPlugin_exports","__export","getSourceInspectorPath","resolveEditorFilePath","sourceInspectorPlugin","module","exports","import_child_process","require","import_fs","import_path","__toESM","import_oxc_parser","import_vite","_type_of","obj","Symbol","constructor","findJsxElements","code","filename","result","parse","errors","length","locations","getJsxName","node","type","name","_node_property","object","property","getLocation","offset","before","slice","lines","split","line","column","walk","tagName","endsWith","_node_attributes","hasSourceAttr","attributes","some","attr","_attr_name","nameEnd","end","loc","start","push","insertOffset","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","keys","iterator","_step","next","done","key","Array","isArray","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","child","err","return","program","sort","a","b","filePath","cwd","arguments","process","normalizedFilePath","normalizePath","normalizedCwd","startsWith","fileExists","existsSync","projectPath","default","join","injectSourceToJsx","id","location","includes","jsxLocations","jsx","sourceAttr","map","editorWarned","editorArgs","f","l","c","cursor","codium","vscodium","zed","subl","webstorm","idea","vim","nvim","emacs"],"sources":["../../../../src/vite/plugins/sourceInspectorPlugin.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAA,CAAAK,6BAAsB;AACtB,IAAAO,oBAA2B,GAAAC,OAAA;AAC3B,IAAAC,SAAA,GAAAD,OAAiB;AACjB,IAAAE,WAAA,GAAAC,OAAsB,CAAAH,OAAA;AAEtB,IAAAI,iBAA8B,GAAAJ,OAAA;AAe9B,IAAAK,WAAe,GAAAL,OAAA,OAAgB;AAC7B,SAAMM,QAASA,CAAAC,GAAA;EAEf,uBAAkB;;EAChB,OAAAA,GAAQ,WAAAC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAAA;AAGV,eAAMG,eAA4BA,CAAAC,IAAA,EAAAC,QAAA;EAElC,IAAAC,MAAS,UAAW,GAAAT,iBAA0B,CAAAU,KAAA,EAAAF,QAAA,EAAAD,IAAA;EAC5C,IAAAE,MAAK,CAAAE,MAAM,CAAAC,MAAO;IAClB,OAAI,EAAK;EACT;EACE,IAAAC,SAAM,GAAM;EACZ,SAAAC,UAAaA,CAAGC,IAAG;IACrB,KAAAA,IAAA;IACA,IAAAA,IAAO,CAAAC,IAAA,6BAAAD,IAAA,CAAAE,IAAA;IACT,IAAAF,IAAA,CAAAC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,IACjCA,CAAA,IAAAD,CAAA,CACD;EACH;EAEJY,KAAA,WAAAA,CAAAZ,CAAA,EAAAC,CAAA,EAAAC,CAAA;IACF,Q","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ var import_vitest = require("vitest");
2
+ var import_sourceInspectorPlugin = require("./sourceInspectorPlugin.cjs");
3
+ (0, import_vitest.describe)("sourceInspectorPlugin helpers", () => {
4
+ (0, import_vitest.describe)("getSourceInspectorPath", () => {
5
+ (0, import_vitest.it)("keeps project files relative to the current cwd", () => {
6
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo/packages/one/src/App.tsx", "/repo")).toBe("/packages/one/src/App.tsx");
7
+ });
8
+ (0, import_vitest.it)("does not strip matching path prefixes from files outside cwd", () => {
9
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo-other/packages/one/src/App.tsx", "/repo")).toBe("/repo-other/packages/one/src/App.tsx");
10
+ });
11
+ });
12
+ (0, import_vitest.describe)("resolveEditorFilePath", () => {
13
+ (0, import_vitest.it)("resolves project-relative source paths against cwd", () => {
14
+ const fileExists = filePath => filePath === "/repo/packages/one/src/App.tsx";
15
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/packages/one/src/App.tsx", "/repo", fileExists)).toBe("/repo/packages/one/src/App.tsx");
16
+ });
17
+ (0, import_vitest.it)("preserves absolute source paths for files outside cwd", () => {
18
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/Users/n8/shared/ui/Button.tsx", "/repo/apps/site", () => false)).toBe("/Users/n8/shared/ui/Button.tsx");
19
+ });
20
+ });
21
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var import_vitest = require("vitest");
4
+ var import_sourceInspectorPlugin = require("./sourceInspectorPlugin.native.js");
5
+ (0, import_vitest.describe)("sourceInspectorPlugin helpers", function () {
6
+ (0, import_vitest.describe)("getSourceInspectorPath", function () {
7
+ (0, import_vitest.it)("keeps project files relative to the current cwd", function () {
8
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo/packages/one/src/App.tsx", "/repo")).toBe("/packages/one/src/App.tsx");
9
+ });
10
+ (0, import_vitest.it)("does not strip matching path prefixes from files outside cwd", function () {
11
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo-other/packages/one/src/App.tsx", "/repo")).toBe("/repo-other/packages/one/src/App.tsx");
12
+ });
13
+ });
14
+ (0, import_vitest.describe)("resolveEditorFilePath", function () {
15
+ (0, import_vitest.it)("resolves project-relative source paths against cwd", function () {
16
+ var fileExists = function (filePath) {
17
+ return filePath === "/repo/packages/one/src/App.tsx";
18
+ };
19
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/packages/one/src/App.tsx", "/repo", fileExists)).toBe("/repo/packages/one/src/App.tsx");
20
+ });
21
+ (0, import_vitest.it)("preserves absolute source paths for files outside cwd", function () {
22
+ (0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/Users/n8/shared/ui/Button.tsx", "/repo/apps/site", function () {
23
+ return false;
24
+ })).toBe("/Users/n8/shared/ui/Button.tsx");
25
+ });
26
+ });
27
+ });
28
+ //# sourceMappingURL=sourceInspectorPlugin.test.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["import_vitest","require","import_sourceInspectorPlugin","describe","it","expect","getSourceInspectorPath","toBe","fileExists","filePath","resolveEditorFilePath"],"sources":["../../../../src/vite/plugins/sourceInspectorPlugin.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AAEA,IAAAA,aAAA,GAAAC,OAAA,SAA8D;AAAA,IAE9DC,4BAAS,GAAAD,OAAA,oCAAuC;AAC9C,IAAAD,aAAA,CAAAG,QAAA,iCAAmC,cAAM;EACvC,IAAAH,aAAA,CAAAG,QAAG;IACD,IAAAH,aAAA,CAAAI,EAAA,mDAAO;MAAmE,EACxE,EAAAJ,aAAA,CAAAK,MAAA,MAAAH,4BAAA,CAAAI,sBAAA,8CAAAC,IAAA;IAAA,EACF;IACF,CAAC,GAAAP,aAAA,CAAAI,EAAA;MAED,IAAAJ,aAAA,CAAAK,MAAG,MAAAH,4BAAA,CAAAI,sBAAA,wCAAsE,YAAAC,IAAA;IACvE;EAAA;EACwE,IACxEP,aAAO,CAAAG,QAAA,yBAAsC;IAC/C,CAAC,GAAAH,aAAA,CAAAI,EAAA;MACF,IAAAI,UAAA,YAAAA,CAAAC,QAAA;QAED,OAAAA,QAAA,qCAAkC;MAChC;MACE,IAAAT,aAAM,CAAAK,MAAc,MAAAH,4BACL,CAAAQ,qBAAA,wCAAAF,UAAA,GAAAD,IAAA;IAEf;IAAA,IAAAP,aACE,CAAAI,EAAA,yDAAsB,cAA6B;MACrD,EAAE,EAAAJ,aAAK,CAAAK,MAAA,MAAAH,4BAAgC,CAAAQ,qBAAA;QACxC;MAED,IAAAH,IAAA,iCAAG;IACD;EAAA;AACE","ignoreList":[]}
@@ -74,7 +74,7 @@ function withRequestContext(fn) {
74
74
  }
75
75
  return fn();
76
76
  }
77
- function resolveAPIEndpoint(runEndpoint, request, params) {
77
+ function resolveAPIEndpoint(runEndpoint, request, params, env, executionCtx) {
78
78
  return resolveResponse(async () => {
79
79
  const imported = await runEndpoint();
80
80
  const requestType = request.method || "GET";
@@ -83,8 +83,13 @@ function resolveAPIEndpoint(runEndpoint, request, params) {
83
83
  console.warn(`No handler found for request ${requestType}`);
84
84
  return;
85
85
  }
86
+ const worker = env !== void 0 || executionCtx !== void 0 ? {
87
+ env,
88
+ executionCtx
89
+ } : void 0;
86
90
  return await handler(request, {
87
- params
91
+ params,
92
+ worker
88
93
  });
89
94
  });
90
95
  }
@@ -88,7 +88,7 @@ function withRequestContext(fn) {
88
88
  }
89
89
  return fn();
90
90
  }
91
- function resolveAPIEndpoint(runEndpoint, request, params) {
91
+ function resolveAPIEndpoint(runEndpoint, request, params, env, executionCtx) {
92
92
  return resolveResponse(async function () {
93
93
  var imported = await runEndpoint();
94
94
  var requestType = request.method || "GET";
@@ -97,8 +97,13 @@ function resolveAPIEndpoint(runEndpoint, request, params) {
97
97
  console.warn(`No handler found for request ${requestType}`);
98
98
  return;
99
99
  }
100
+ var worker = env !== void 0 || executionCtx !== void 0 ? {
101
+ env,
102
+ executionCtx
103
+ } : void 0;
100
104
  return await handler(request, {
101
- params
105
+ params,
106
+ worker
102
107
  });
103
108
  });
104
109
  }
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","resolveResponse_exports","__export","resolveAPIEndpoint","resolveResponse","withRequestContext","module","exports","import_isResponse","require","import_one_server_only","_instanceof","left","right","Symbol","hasInstance","_type_of","obj","constructor","_nextId","createId","_id","getResponse","store","requestAsyncLocalStore","globalThis","id","response","run","getResponseWithAddedHeaders","err","isResponse","runWithAsyncLocalContext","id2","response2","fn","runEndpoint","request","params","imported","requestType","method","handler","default","console","warn","_globalThis___vxrnasyncHeadersCache","cache","asyncHeadersCache","asyncHeaders","get","Response","cloned","clone","headers","Headers","mergeHeaders","body","status","statusText"],"sources":["../../../src/vite/resolveResponse.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAA2B,CAAAK,uBAAA;AAC3B,IAAAO,iBAAA,GAAAC,OAMO;AAGP,IAAIC,sBAAU,GAAAD,OAAA;AACd,SAASE,WAAkBA,CAAAC,IAAA,EAAAC,KAAA;EACzB,IAAAA,KA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UAAA;UAEOL;QACT","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","resolveResponse_exports","__export","resolveAPIEndpoint","resolveResponse","withRequestContext","module","exports","import_isResponse","require","import_one_server_only","_instanceof","left","right","Symbol","hasInstance","_type_of","obj","constructor","_nextId","createId","_id","getResponse","store","requestAsyncLocalStore","globalThis","id","response","run","getResponseWithAddedHeaders","err","isResponse","runWithAsyncLocalContext","id2","response2","fn","runEndpoint","request","params","env","executionCtx","imported","requestType","method","handler","default","console","warn","worker","_globalThis___vxrnasyncHeadersCache","cache","asyncHeadersCache","asyncHeaders","get","Response","cloned","clone","headers","Headers","mergeHeaders","body"],"sources":["../../../src/vite/resolveResponse.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAA2B,CAAAK,uBAAA;AAC3B,IAAAO,iBAAA,GAAAC,OAMO;AAGP,IAAIC,sBAAU,GAAAD,OAAA;AACd,SAASE,WAAkBA,CAAAC,IAAA,EAAAC,KAAA;EACzB,IAAAA,KAAS,QAAK,WAAUC,MAAA,oBAAAD,KAAA,CAAAC,MAAA,CAAAC,WAAA;IAC1B,SAAAF,KAAA,CAAAC,MAAA,CAAAC,WAAA,EAAAH,IAAA;EAEA;IAEE,OAAMA,IAAA,YACJC,KAAA;EAEF;AACE;AACA,SAAIG,SAAAC,GAAA;EACJ,uBAAoB;;EAClB,OAAAA,GAAI,WAAAH,MAAA,oBAAAG,GAAA,CAAAC,WAAA,KAAAJ,MAAA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pC,eAAe,mBAAY;IAEjC,IAAIqC,QAAA,SAAcL,WAAA;IAChB,IAAIM,WAAA,GAAAL,OAAA,CAAAM,MAAA;IACF,IAAAC,OAAI,GAAAH,QAAA,CAAAC,WAAoB,KAAUD,QAAA,CAAAI,OAAA;IAMhC,KAAAD,OAAM;MACNE,OAAA,CAAMC,IAAA,iCAAsBL,WAAA;MAC5B;IACA;IACA,IAAAM,MAAA,GAAAT,GAAW,KAAI,UAASC,YAAa;MAAAD,GAAA;MACpBC;IACI,SACnB;IAAA,OACD,MAAAI,OAAA,CAAAP,OAAA;MACHC,MAAA;MACEU;IACE;EAA4D;AAI5D;AACA,eAAKnB,2BAA0BA,CAAAF,QAAG,EAAAD,EAAA;EAGhC,IAAAuB,mCAA4B;EAAW,IAAAC,KACzC,IAAAD,mCAAA,GAAAxB,UAAA,yCAAAwB,mCAAA,cAAAA,mCAAA,GAAAvC,sBAAA,CAAAyC,iBAAA;EACA,IAAAC,YAAA,GAAWF,KAAI,CAAAG,GAAA,CAAA3B,EAAA,CAAS;EAA4B,IAAA0B,YACtD;IAAA,IACF;MACF,IAAAzC,WAAc,CAAAgB,QAAA,EAAA2B,QAAA;QACZ,IAAAC,MAAQ,GAAM5B,QAAA,CAAA6B,KAAA;QAChB,IAAAC,OAAA,OAAAC,OAAA;QACF,IAAAhD,sBAAA,CAAAiD,YAAA,EAAAF,OAAA,EAAAF,MAAA,CAAAE,OAAA;QAEA,CAAO,GAAA/C,sBAAA,CAAAiD,YAAA,EAAAF,OAAA,EAAAL,YAAA;QACTzB,QAAA,OAAA2B,QAAA,CAAAC,MAAA,CAAAK,IAAA","ignoreList":[]}
@@ -4,14 +4,14 @@ import Path, { join, relative, resolve } from "node:path";
4
4
  import { resolvePath } from "@vxrn/resolve";
5
5
  import FSExtra from "fs-extra";
6
6
  import MicroMatch from "micromatch";
7
- import { mergeConfig, build as viteBuild } from "vite";
7
+ import { createBuilder, mergeConfig, normalizePath, build as viteBuild } from "vite";
8
8
  import { fillOptions, getOptimizeDeps, rollupRemoveUnusedImportsPlugin, build as vxrnBuild } from "vxrn";
9
9
  import * as constants from "../constants.mjs";
10
10
  import { setServerGlobals } from "../server/setServerGlobals.mjs";
11
11
  import { getPathnameFromFilePath } from "../utils/getPathnameFromFilePath.mjs";
12
12
  import { getRouterRootFromOneOptions } from "../utils/getRouterRootFromOneOptions.mjs";
13
13
  import { isRolldown } from "../utils/isRolldown.mjs";
14
- import { toAbsolute } from "../utils/toAbsolute.mjs";
14
+ import { toAbsolute, toAbsoluteUrl } from "../utils/toAbsolute.mjs";
15
15
  import { buildVercelOutputDirectory } from "../vercel/build/buildVercelOutputDirectory.mjs";
16
16
  import { getManifest } from "../vite/getManifest.mjs";
17
17
  import { loadUserOneOptions } from "../vite/loadConfig.mjs";
@@ -283,10 +283,30 @@ async function build(args) {
283
283
  rolldownOptions: _rolldownOptions,
284
284
  ...optimizeDepsNoRolldown
285
285
  } = optimizeDeps;
286
- const clonedWebBuildConfig = clonePluginHooks(vxrnOutput.webBuildConfig);
287
- const apiBuildConfig = mergeConfig(
288
- // feels like this should build off the *server* build config not web
289
- clonedWebBuildConfig, {
286
+ const serverOpts = oneOptions.build?.server;
287
+ const isUnified = typeof serverOpts === "object" && serverOpts !== null && serverOpts.unified === true;
288
+ let baseForApi = isUnified ? clonePluginHooks(vxrnOutput.serverBuildConfig ?? vxrnOutput.webBuildConfig) : clonePluginHooks(vxrnOutput.webBuildConfig);
289
+ if (isUnified) {
290
+ const clone = {
291
+ ...baseForApi,
292
+ build: baseForApi.build ? {
293
+ ...baseForApi.build
294
+ } : void 0,
295
+ plugins: baseForApi.plugins ? baseForApi.plugins.filter(p => p && typeof p === "object" && p.name !== "omit-api-routes") : void 0
296
+ };
297
+ if (clone.build && clone.build.rolldownOptions) {
298
+ const ro = {
299
+ ...clone.build.rolldownOptions
300
+ };
301
+ delete ro.input;
302
+ clone.build.rolldownOptions = ro;
303
+ }
304
+ if (clone.build) {
305
+ delete clone.build.outDir;
306
+ }
307
+ baseForApi = clone;
308
+ }
309
+ const apiBuildConfig = mergeConfig(baseForApi, {
290
310
  configFile: false,
291
311
  appType: "custom",
292
312
  optimizeDeps: optimizeDepsNoRolldown,
@@ -311,13 +331,13 @@ async function build(args) {
311
331
  const mergedConfig = mergeConfig(apiBuildConfig, {
312
332
  appType: "custom",
313
333
  configFile: false,
314
- // plugins: [
315
- // nodeExternals({
316
- // exclude: optimizeDeps.include,
317
- // }) as any,
318
- // ],
319
334
  define: vxrnOutput.processEnvDefines,
320
- ssr: {
335
+ ssr: isUnified ? {
336
+ // in unified mode let the base (serverBuildConfig) set ssr.noExternal
337
+ // — default is now ['react', 'react-dom'] instead of `true`, so
338
+ // rolldown can externalize the rest.
339
+ optimizeDeps: optimizeDepsNoRolldown
340
+ } : {
321
341
  noExternal: true,
322
342
  external: ["react", "react-dom"],
323
343
  optimizeDeps: optimizeDepsNoRolldown
@@ -349,7 +369,12 @@ async function build(args) {
349
369
  // prevents it from shaking out the exports
350
370
  preserveEntrySignatures: "strict",
351
371
  input,
352
- external: [],
372
+ // in unified mode, inherit externals from serverBuildConfig (user
373
+ // ssr.external / rolldownOptions.external). the legacy path resets
374
+ // them to [] so per-route files bundle everything.
375
+ ...(isUnified ? {} : {
376
+ external: []
377
+ }),
353
378
  output: {
354
379
  entryFileNames: "[name]",
355
380
  exports: "auto",
@@ -398,14 +423,14 @@ async function build(args) {
398
423
  if (middlewareBuildInfo) {
399
424
  for (const middleware of manifest.middlewareRoutes) {
400
425
  const absoluteRoot = resolve(process.cwd(), options.root);
401
- const fullPath = join(absoluteRoot, routerRoot, middleware.file);
426
+ const fullPath = normalizePath(join(absoluteRoot, routerRoot, middleware.file));
402
427
  const outChunks = middlewareBuildInfo.output.filter(x => x.type === "chunk");
403
428
  const chunk = outChunks.find(x => x.facadeModuleId === fullPath);
404
429
  if (!chunk) throw new Error(`internal err finding middleware`);
405
430
  builtMiddlewares[middleware.file] = join(outDir, "middlewares", chunk.fileName);
406
431
  }
407
432
  }
408
- globalThis["require"] = createRequire(join(import.meta.url, ".."));
433
+ globalThis["require"] = createRequire(import.meta.dirname + "/");
409
434
  const assets = [];
410
435
  const builtRoutes = [];
411
436
  const sitemapData = [];
@@ -448,7 +473,7 @@ async function build(args) {
448
473
  const id = output.facadeModuleId || "";
449
474
  const file = Path.basename(id);
450
475
  if (file.startsWith("_layout") && id.includes(`/${routerRoot}/`)) {
451
- const relativePath = relative(process.cwd(), id).replace(`${routerRoot}/`, "");
476
+ const relativePath = normalizePath(relative(process.cwd(), id)).replace(`${routerRoot}/`, "");
452
477
  const contextKey = `./${relativePath}`;
453
478
  layoutServerPaths.set(contextKey, output.fileName);
454
479
  }
@@ -499,7 +524,7 @@ async function build(args) {
499
524
  if (!foundRoute.file) {
500
525
  continue;
501
526
  }
502
- const routeModulePath = join(resolve(process.cwd(), options.root), routerRoot, foundRoute.file.slice(2));
527
+ const routeModulePath = normalizePath(join(resolve(process.cwd(), options.root), routerRoot, foundRoute.file.slice(2)));
503
528
  const serverFileName = moduleIdToServerChunk.get(routeModulePath);
504
529
  if (!serverFileName) {
505
530
  if (foundRoute.type === "spa") {
@@ -641,7 +666,7 @@ async function build(args) {
641
666
  const serverJsPath = join(`${outDir}/server`, serverFileName);
642
667
  let exported;
643
668
  try {
644
- exported = await import(toAbsolute(serverJsPath));
669
+ exported = await import(toAbsoluteUrl(serverJsPath));
645
670
  } catch (err) {
646
671
  console.error(`Error importing page (original error)`, err);
647
672
  throw new Error(`Error importing page: ${serverJsPath}`, {
@@ -783,9 +808,17 @@ async function build(args) {
783
808
  }));
784
809
  }
785
810
  const buildInfo = builtRoutes.find(x => x.routeFile === route.file);
786
- if (built.middlewares && buildInfo?.middlewares) {
811
+ if (built.middlewares) {
787
812
  for (const [index, mw] of built.middlewares.entries()) {
788
- mw.contextKey = buildInfo.middlewares[index];
813
+ const viaBuildInfo = buildInfo?.middlewares?.[index];
814
+ if (viaBuildInfo) {
815
+ mw.contextKey = viaBuildInfo;
816
+ continue;
817
+ }
818
+ const viaMiddlewareMap = builtMiddlewares[mw.contextKey];
819
+ if (viaMiddlewareMap) {
820
+ mw.contextKey = viaMiddlewareMap;
821
+ }
789
822
  }
790
823
  }
791
824
  if (buildInfo) {
@@ -861,6 +894,11 @@ async function build(args) {
861
894
  }
862
895
  case "cloudflare":
863
896
  {
897
+ const workerSrcDir = join(options.root, outDir);
898
+ const getWorkerSourceImportPath = routeFile => {
899
+ const importPath = normalizePath(relative(workerSrcDir, join(options.root, routerRoot, routeFile)));
900
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
901
+ };
864
902
  const pageRouteMap = [];
865
903
  const apiRouteMap = [];
866
904
  const middlewareRouteMap = [];
@@ -872,13 +910,12 @@ async function build(args) {
872
910
  }
873
911
  for (const route of buildInfoForWriting.manifest.apiRoutes) {
874
912
  if (route.file) {
875
- const apiFileName = route.page.slice(1).replace(/\[/g, "_").replace(/\]/g, "_");
876
- const importPath = `./api/${apiFileName}.js`;
913
+ const importPath = getWorkerSourceImportPath(route.file);
877
914
  apiRouteMap.push(` '${route.page}': () => import('${importPath}')`);
878
915
  }
879
916
  }
880
- for (const [, builtPath] of Object.entries(builtMiddlewares)) {
881
- const importPath = "./" + builtPath.replace(new RegExp(`^${outDir}/`), "");
917
+ for (const [sourceFile, builtPath] of Object.entries(builtMiddlewares)) {
918
+ const importPath = getWorkerSourceImportPath(sourceFile);
882
919
  middlewareRouteMap.push(` '${builtPath}': () => import('${importPath}')`);
883
920
  }
884
921
  const workerSrcPath = join(options.root, outDir, "_worker-src.js");
@@ -936,7 +973,7 @@ export default {
936
973
  }
937
974
 
938
975
  try {
939
- const response = await server.fetch(request)
976
+ const response = await server.fetch(request, env, ctx)
940
977
 
941
978
  // no route matched or 404 \u2192 try static assets
942
979
  if (!response || response.status === 404) {
@@ -960,38 +997,34 @@ export default {
960
997
  }
961
998
  `;
962
999
  await FSExtra.writeFile(workerSrcPath, workerCode);
1000
+ const projectName = await getCloudflareProjectName(options.root);
1001
+ const userWranglerConfig = await loadUserWranglerConfig(options.root);
1002
+ const wranglerInputConfig = createCloudflareWranglerConfig(projectName, userWranglerConfig?.config);
1003
+ wranglerInputConfig.main = relative(join(options.root, outDir), workerSrcPath);
1004
+ const wranglerInputPath = join(options.root, outDir, "_wrangler.input.jsonc");
1005
+ await FSExtra.writeFile(wranglerInputPath, `${JSON.stringify(wranglerInputConfig, null, 2)}
1006
+ `);
963
1007
  console.info("\n [cloudflare] Bundling worker...");
964
- await viteBuild({
1008
+ const {
1009
+ cloudflare
1010
+ } = await import("@cloudflare/vite-plugin");
1011
+ const builder = await createBuilder({
965
1012
  root: options.root,
966
1013
  mode: "production",
967
1014
  logLevel: "warn",
968
- build: {
969
- outDir,
970
- emptyOutDir: false,
971
- // Use SSR mode with node target for proper Node.js module resolution
972
- ssr: workerSrcPath,
973
- rolldownOptions: {
974
- external: [
975
- // React Native dev tools - not needed in production
976
- "@react-native/dev-middleware", "@react-native/debugger-shell", "metro", "metro-core", "metro-runtime",
977
- // Native modules that can't run in workers
978
- /\.node$/],
979
- output: {
980
- entryFileNames: "worker.js",
981
- format: "es",
982
- // Keep dynamic imports separate for lazy loading
983
- inlineDynamicImports: false
984
- }
985
- },
986
- minify: true,
987
- target: "esnext"
988
- },
1015
+ configFile: false,
989
1016
  define: {
990
1017
  "process.env.NODE_ENV": JSON.stringify("production"),
991
- "process.env.VITE_ENVIRONMENT": JSON.stringify("ssr")
1018
+ "process.env.VITE_ENVIRONMENT": JSON.stringify("ssr"),
1019
+ "process.env.ONE_CACHE_KEY": JSON.stringify(constants.CACHE_KEY)
992
1020
  },
1021
+ plugins: [cloudflare({
1022
+ configPath: wranglerInputPath,
1023
+ viteEnvironment: {
1024
+ name: "worker"
1025
+ }
1026
+ })],
993
1027
  resolve: {
994
- conditions: ["workerd", "worker", "node", "module", "default"],
995
1028
  alias: [
996
1029
  // rolldown can't parse react-native's Flow syntax; alias to react-native-web for ssr
997
1030
  {
@@ -1008,22 +1041,29 @@ export default {
1008
1041
  replacement: resolvePath("@vxrn/safe-area", options.root)
1009
1042
  }]
1010
1043
  },
1011
- ssr: {
1012
- target: "node",
1013
- noExternal: true
1044
+ build: {
1045
+ outDir,
1046
+ emptyOutDir: false,
1047
+ rolldownOptions: {
1048
+ // Match the main web build behavior so RN packages that import
1049
+ // native-only symbols from react-native can still bundle against
1050
+ // the react-native-web alias in the worker graph.
1051
+ shimMissingExports: true
1052
+ }
1014
1053
  }
1015
1054
  });
1055
+ const workerEnv = builder.environments.worker;
1056
+ if (!workerEnv) {
1057
+ throw new Error('[one] plugin did not register "worker" environment');
1058
+ }
1059
+ await builder.build(workerEnv);
1016
1060
  await FSExtra.remove(workerSrcPath);
1017
- const projectName = await getCloudflareProjectName(options.root);
1018
- const userWranglerConfig = await loadUserWranglerConfig(options.root);
1019
- const wranglerConfig = createCloudflareWranglerConfig(projectName, userWranglerConfig?.config);
1061
+ await FSExtra.remove(wranglerInputPath);
1020
1062
  if (userWranglerConfig) {
1021
- console.info(` [cloudflare] Merging ${relative(options.root, userWranglerConfig.path)} into ${outDir}/wrangler.jsonc`);
1063
+ console.info(` [cloudflare] Merging ${relative(options.root, userWranglerConfig.path)} into ${outDir}/worker/wrangler.json`);
1022
1064
  }
1023
- await FSExtra.writeFile(join(options.root, outDir, "wrangler.jsonc"), `${JSON.stringify(wranglerConfig, null, 2)}
1024
- `);
1025
- postBuildLogs.push(`Cloudflare worker bundled at ${outDir}/worker.js`);
1026
- postBuildLogs.push(`To deploy: cd ${outDir} && wrangler deploy`);
1065
+ postBuildLogs.push(`Cloudflare worker bundled at ${outDir}/worker/index.js`);
1066
+ postBuildLogs.push(`To deploy: cd ${outDir}/worker && wrangler deploy`);
1027
1067
  break;
1028
1068
  }
1029
1069
  }