@sebbro/paraglide-lite 0.1.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 (715) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/bin/run.js +4 -0
  4. package/dist/bundler-plugins/esbuild.d.ts +1 -0
  5. package/dist/bundler-plugins/esbuild.d.ts.map +1 -0
  6. package/dist/bundler-plugins/esbuild.js +4 -0
  7. package/dist/bundler-plugins/esbuild.js.map +1 -0
  8. package/dist/bundler-plugins/index.d.ts +6 -0
  9. package/dist/bundler-plugins/index.d.ts.map +1 -0
  10. package/dist/bundler-plugins/index.js +7 -0
  11. package/dist/bundler-plugins/index.js.map +1 -0
  12. package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts +19 -0
  13. package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts.map +1 -0
  14. package/dist/bundler-plugins/lazy-modules/scan-message-keys.js +85 -0
  15. package/dist/bundler-plugins/lazy-modules/scan-message-keys.js.map +1 -0
  16. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts +2 -0
  17. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts.map +1 -0
  18. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js +53 -0
  19. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js.map +1 -0
  20. package/dist/bundler-plugins/lazy-modules/ssr.d.ts +31 -0
  21. package/dist/bundler-plugins/lazy-modules/ssr.d.ts.map +1 -0
  22. package/dist/bundler-plugins/lazy-modules/ssr.js +42 -0
  23. package/dist/bundler-plugins/lazy-modules/ssr.js.map +1 -0
  24. package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts +2 -0
  25. package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts.map +1 -0
  26. package/dist/bundler-plugins/lazy-modules/ssr.test.js +48 -0
  27. package/dist/bundler-plugins/lazy-modules/ssr.test.js.map +1 -0
  28. package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts +7 -0
  29. package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts.map +1 -0
  30. package/dist/bundler-plugins/lazy-modules/virtual-ids.js +30 -0
  31. package/dist/bundler-plugins/lazy-modules/virtual-ids.js.map +1 -0
  32. package/dist/bundler-plugins/lazy-modules/virtual.d.ts +86 -0
  33. package/dist/bundler-plugins/lazy-modules/virtual.d.ts.map +1 -0
  34. package/dist/bundler-plugins/lazy-modules/virtual.js +2 -0
  35. package/dist/bundler-plugins/lazy-modules/virtual.js.map +1 -0
  36. package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts +18 -0
  37. package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts.map +1 -0
  38. package/dist/bundler-plugins/lazy-modules/vite-plugin.js +328 -0
  39. package/dist/bundler-plugins/lazy-modules/vite-plugin.js.map +1 -0
  40. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts +2 -0
  41. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts.map +1 -0
  42. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js +45 -0
  43. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js.map +1 -0
  44. package/dist/bundler-plugins/per-locale-build/constants.d.ts +2 -0
  45. package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -0
  46. package/dist/bundler-plugins/per-locale-build/constants.js +3 -0
  47. package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -0
  48. package/dist/bundler-plugins/per-locale-build/index.d.ts +6 -0
  49. package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -0
  50. package/dist/bundler-plugins/per-locale-build/index.js +43 -0
  51. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -0
  52. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts +8 -0
  53. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts.map +1 -0
  54. package/dist/bundler-plugins/per-locale-build/locale-id.js +13 -0
  55. package/dist/bundler-plugins/per-locale-build/locale-id.js.map +1 -0
  56. package/dist/bundler-plugins/per-locale-build/types.d.ts +4 -0
  57. package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -0
  58. package/dist/bundler-plugins/per-locale-build/types.js +2 -0
  59. package/dist/bundler-plugins/per-locale-build/types.js.map +1 -0
  60. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts +51 -0
  61. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts.map +1 -0
  62. package/dist/bundler-plugins/per-locale-build/vite-environments.js +250 -0
  63. package/dist/bundler-plugins/per-locale-build/vite-environments.js.map +1 -0
  64. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts +1 -0
  65. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts.map +1 -0
  66. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +250 -0
  67. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -0
  68. package/dist/bundler-plugins/plugin-core.d.ts +74 -0
  69. package/dist/bundler-plugins/plugin-core.d.ts.map +1 -0
  70. package/dist/bundler-plugins/plugin-core.js +292 -0
  71. package/dist/bundler-plugins/plugin-core.js.map +1 -0
  72. package/dist/bundler-plugins/rolldown.d.ts +10 -0
  73. package/dist/bundler-plugins/rolldown.d.ts.map +1 -0
  74. package/dist/bundler-plugins/rolldown.js +36 -0
  75. package/dist/bundler-plugins/rolldown.js.map +1 -0
  76. package/dist/bundler-plugins/rolldown.test.d.ts +1 -0
  77. package/dist/bundler-plugins/rolldown.test.d.ts.map +1 -0
  78. package/dist/bundler-plugins/rolldown.test.js +72 -0
  79. package/dist/bundler-plugins/rolldown.test.js.map +1 -0
  80. package/dist/bundler-plugins/rollup.d.ts +1 -0
  81. package/dist/bundler-plugins/rollup.d.ts.map +1 -0
  82. package/dist/bundler-plugins/rollup.js +4 -0
  83. package/dist/bundler-plugins/rollup.js.map +1 -0
  84. package/dist/bundler-plugins/rspack.d.ts +1 -0
  85. package/dist/bundler-plugins/rspack.d.ts.map +1 -0
  86. package/dist/bundler-plugins/rspack.js +4 -0
  87. package/dist/bundler-plugins/rspack.js.map +1 -0
  88. package/dist/bundler-plugins/unplugin.d.ts +3 -0
  89. package/dist/bundler-plugins/unplugin.d.ts.map +1 -0
  90. package/dist/bundler-plugins/unplugin.js +62 -0
  91. package/dist/bundler-plugins/unplugin.js.map +1 -0
  92. package/dist/bundler-plugins/unplugin.test.d.ts +1 -0
  93. package/dist/bundler-plugins/unplugin.test.d.ts.map +1 -0
  94. package/dist/bundler-plugins/unplugin.test.js +256 -0
  95. package/dist/bundler-plugins/unplugin.test.js.map +1 -0
  96. package/dist/bundler-plugins/virtual-modules.test.d.ts +1 -0
  97. package/dist/bundler-plugins/virtual-modules.test.d.ts.map +1 -0
  98. package/dist/bundler-plugins/virtual-modules.test.js +77 -0
  99. package/dist/bundler-plugins/virtual-modules.test.js.map +1 -0
  100. package/dist/bundler-plugins/vite.d.ts +17 -0
  101. package/dist/bundler-plugins/vite.d.ts.map +1 -0
  102. package/dist/bundler-plugins/vite.js +15 -0
  103. package/dist/bundler-plugins/vite.js.map +1 -0
  104. package/dist/bundler-plugins/vite.test.d.ts +1 -0
  105. package/dist/bundler-plugins/vite.test.d.ts.map +1 -0
  106. package/dist/bundler-plugins/vite.test.js +61 -0
  107. package/dist/bundler-plugins/vite.test.js.map +1 -0
  108. package/dist/bundler-plugins/webpack.d.ts +1 -0
  109. package/dist/bundler-plugins/webpack.d.ts.map +1 -0
  110. package/dist/bundler-plugins/webpack.js +4 -0
  111. package/dist/bundler-plugins/webpack.js.map +1 -0
  112. package/dist/cli/commands/compile/command.d.ts +2 -0
  113. package/dist/cli/commands/compile/command.d.ts.map +1 -0
  114. package/dist/cli/commands/compile/command.js +225 -0
  115. package/dist/cli/commands/compile/command.js.map +1 -0
  116. package/dist/cli/commands/compile/command.test.d.ts +1 -0
  117. package/dist/cli/commands/compile/command.test.d.ts.map +1 -0
  118. package/dist/cli/commands/compile/command.test.js +69 -0
  119. package/dist/cli/commands/compile/command.test.js.map +1 -0
  120. package/dist/cli/commands/init/command.d.ts +2 -0
  121. package/dist/cli/commands/init/command.d.ts.map +1 -0
  122. package/dist/cli/commands/init/command.js +90 -0
  123. package/dist/cli/commands/init/command.js.map +1 -0
  124. package/dist/cli/defaults.d.ts +11 -0
  125. package/dist/cli/defaults.d.ts.map +1 -0
  126. package/dist/cli/defaults.js +13 -0
  127. package/dist/cli/defaults.js.map +1 -0
  128. package/dist/cli/index.d.ts +2 -0
  129. package/dist/cli/index.d.ts.map +1 -0
  130. package/dist/cli/index.js +11 -0
  131. package/dist/cli/index.js.map +1 -0
  132. package/dist/cli/steps/add-vite-plugin.d.ts +31 -0
  133. package/dist/cli/steps/add-vite-plugin.d.ts.map +1 -0
  134. package/dist/cli/steps/add-vite-plugin.js +65 -0
  135. package/dist/cli/steps/add-vite-plugin.js.map +1 -0
  136. package/dist/cli/steps/add-vite-plugin.test.d.ts +1 -0
  137. package/dist/cli/steps/add-vite-plugin.test.d.ts.map +1 -0
  138. package/dist/cli/steps/add-vite-plugin.test.js +74 -0
  139. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -0
  140. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +5 -0
  141. package/dist/cli/steps/check-for-uncomitted-changes.d.ts.map +1 -0
  142. package/dist/cli/steps/check-for-uncomitted-changes.js +37 -0
  143. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -0
  144. package/dist/cli/steps/detect-bundler.d.ts +10 -0
  145. package/dist/cli/steps/detect-bundler.d.ts.map +1 -0
  146. package/dist/cli/steps/detect-bundler.js +22 -0
  147. package/dist/cli/steps/detect-bundler.js.map +1 -0
  148. package/dist/cli/steps/detect-bundler.test.d.ts +1 -0
  149. package/dist/cli/steps/detect-bundler.test.d.ts.map +1 -0
  150. package/dist/cli/steps/detect-bundler.test.js +29 -0
  151. package/dist/cli/steps/detect-bundler.test.js.map +1 -0
  152. package/dist/cli/steps/initialize-messages.d.ts +11 -0
  153. package/dist/cli/steps/initialize-messages.d.ts.map +1 -0
  154. package/dist/cli/steps/initialize-messages.js +31 -0
  155. package/dist/cli/steps/initialize-messages.js.map +1 -0
  156. package/dist/cli/steps/prompt-for-outdir.d.ts +8 -0
  157. package/dist/cli/steps/prompt-for-outdir.d.ts.map +1 -0
  158. package/dist/cli/steps/prompt-for-outdir.js +19 -0
  159. package/dist/cli/steps/prompt-for-outdir.js.map +1 -0
  160. package/dist/cli/steps/update-package-json.d.ts +11 -0
  161. package/dist/cli/steps/update-package-json.d.ts.map +1 -0
  162. package/dist/cli/steps/update-package-json.js +34 -0
  163. package/dist/cli/steps/update-package-json.js.map +1 -0
  164. package/dist/cli/steps/update-ts-config.d.ts +26 -0
  165. package/dist/cli/steps/update-ts-config.d.ts.map +1 -0
  166. package/dist/cli/steps/update-ts-config.js +270 -0
  167. package/dist/cli/steps/update-ts-config.js.map +1 -0
  168. package/dist/cli/steps/update-ts-config.test.d.ts +1 -0
  169. package/dist/cli/steps/update-ts-config.test.d.ts.map +1 -0
  170. package/dist/cli/steps/update-ts-config.test.js +60 -0
  171. package/dist/cli/steps/update-ts-config.test.js.map +1 -0
  172. package/dist/cli/utils.d.ts +36 -0
  173. package/dist/cli/utils.d.ts.map +1 -0
  174. package/dist/cli/utils.js +20 -0
  175. package/dist/cli/utils.js.map +1 -0
  176. package/dist/compiler/assert-url-pattern-available.d.ts +7 -0
  177. package/dist/compiler/assert-url-pattern-available.d.ts.map +1 -0
  178. package/dist/compiler/assert-url-pattern-available.js +17 -0
  179. package/dist/compiler/assert-url-pattern-available.js.map +1 -0
  180. package/dist/compiler/compile-annotation.d.ts +12 -0
  181. package/dist/compiler/compile-annotation.d.ts.map +1 -0
  182. package/dist/compiler/compile-annotation.js +136 -0
  183. package/dist/compiler/compile-annotation.js.map +1 -0
  184. package/dist/compiler/compile-bundle.d.ts +28 -0
  185. package/dist/compiler/compile-bundle.d.ts.map +1 -0
  186. package/dist/compiler/compile-bundle.js +431 -0
  187. package/dist/compiler/compile-bundle.js.map +1 -0
  188. package/dist/compiler/compile-bundle.test.d.ts +1 -0
  189. package/dist/compiler/compile-bundle.test.d.ts.map +1 -0
  190. package/dist/compiler/compile-bundle.test.js +399 -0
  191. package/dist/compiler/compile-bundle.test.js.map +1 -0
  192. package/dist/compiler/compile-local-variable.d.ts +16 -0
  193. package/dist/compiler/compile-local-variable.d.ts.map +1 -0
  194. package/dist/compiler/compile-local-variable.js +28 -0
  195. package/dist/compiler/compile-local-variable.js.map +1 -0
  196. package/dist/compiler/compile-local-variable.test.d.ts +1 -0
  197. package/dist/compiler/compile-local-variable.test.d.ts.map +1 -0
  198. package/dist/compiler/compile-local-variable.test.js +359 -0
  199. package/dist/compiler/compile-local-variable.test.js.map +1 -0
  200. package/dist/compiler/compile-message.d.ts +8 -0
  201. package/dist/compiler/compile-message.d.ts.map +1 -0
  202. package/dist/compiler/compile-message.js +174 -0
  203. package/dist/compiler/compile-message.js.map +1 -0
  204. package/dist/compiler/compile-message.test.d.ts +1 -0
  205. package/dist/compiler/compile-message.test.d.ts.map +1 -0
  206. package/dist/compiler/compile-message.test.js +1060 -0
  207. package/dist/compiler/compile-message.test.js.map +1 -0
  208. package/dist/compiler/compile-pattern.d.ts +29 -0
  209. package/dist/compiler/compile-pattern.d.ts.map +1 -0
  210. package/dist/compiler/compile-pattern.js +143 -0
  211. package/dist/compiler/compile-pattern.js.map +1 -0
  212. package/dist/compiler/compile-pattern.test.d.ts +1 -0
  213. package/dist/compiler/compile-pattern.test.d.ts.map +1 -0
  214. package/dist/compiler/compile-pattern.test.js +255 -0
  215. package/dist/compiler/compile-pattern.test.js.map +1 -0
  216. package/dist/compiler/compile-project.d.ts +21 -0
  217. package/dist/compiler/compile-project.d.ts.map +1 -0
  218. package/dist/compiler/compile-project.js +147 -0
  219. package/dist/compiler/compile-project.js.map +1 -0
  220. package/dist/compiler/compile-project.test.d.ts +1 -0
  221. package/dist/compiler/compile-project.test.d.ts.map +1 -0
  222. package/dist/compiler/compile-project.test.js +1709 -0
  223. package/dist/compiler/compile-project.test.js.map +1 -0
  224. package/dist/compiler/compile.bench.d.ts +1 -0
  225. package/dist/compiler/compile.bench.d.ts.map +1 -0
  226. package/dist/compiler/compile.bench.js +89 -0
  227. package/dist/compiler/compile.bench.js.map +1 -0
  228. package/dist/compiler/compile.d.ts +24 -0
  229. package/dist/compiler/compile.d.ts.map +1 -0
  230. package/dist/compiler/compile.js +106 -0
  231. package/dist/compiler/compile.js.map +1 -0
  232. package/dist/compiler/compile.test.d.ts +1 -0
  233. package/dist/compiler/compile.test.d.ts.map +1 -0
  234. package/dist/compiler/compile.test.js +66 -0
  235. package/dist/compiler/compile.test.js.map +1 -0
  236. package/dist/compiler/compiler-options.d.ts +466 -0
  237. package/dist/compiler/compiler-options.d.ts.map +1 -0
  238. package/dist/compiler/compiler-options.js +22 -0
  239. package/dist/compiler/compiler-options.js.map +1 -0
  240. package/dist/compiler/create-paraglide.d.ts +21 -0
  241. package/dist/compiler/create-paraglide.d.ts.map +1 -0
  242. package/dist/compiler/create-paraglide.js +69 -0
  243. package/dist/compiler/create-paraglide.js.map +1 -0
  244. package/dist/compiler/create-paraglide.test.d.ts +1 -0
  245. package/dist/compiler/create-paraglide.test.d.ts.map +1 -0
  246. package/dist/compiler/create-paraglide.test.js +55 -0
  247. package/dist/compiler/create-paraglide.test.js.map +1 -0
  248. package/dist/compiler/create-readme.d.ts +9 -0
  249. package/dist/compiler/create-readme.d.ts.map +1 -0
  250. package/dist/compiler/create-readme.js +127 -0
  251. package/dist/compiler/create-readme.js.map +1 -0
  252. package/dist/compiler/emit-files.d.ts +15 -0
  253. package/dist/compiler/emit-files.d.ts.map +1 -0
  254. package/dist/compiler/emit-files.js +58 -0
  255. package/dist/compiler/emit-files.js.map +1 -0
  256. package/dist/compiler/emit-files.test.d.ts +1 -0
  257. package/dist/compiler/emit-files.test.d.ts.map +1 -0
  258. package/dist/compiler/emit-files.test.js +43 -0
  259. package/dist/compiler/emit-files.test.js.map +1 -0
  260. package/dist/compiler/emit-ts-declarations.d.ts +11 -0
  261. package/dist/compiler/emit-ts-declarations.d.ts.map +1 -0
  262. package/dist/compiler/emit-ts-declarations.interop.test.d.ts +1 -0
  263. package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
  264. package/dist/compiler/emit-ts-declarations.interop.test.js +33 -0
  265. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
  266. package/dist/compiler/emit-ts-declarations.js +353 -0
  267. package/dist/compiler/emit-ts-declarations.js.map +1 -0
  268. package/dist/compiler/emit-ts-declarations.test.d.ts +1 -0
  269. package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
  270. package/dist/compiler/emit-ts-declarations.test.js +161 -0
  271. package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
  272. package/dist/compiler/index.d.ts +13 -0
  273. package/dist/compiler/index.d.ts.map +1 -0
  274. package/dist/compiler/index.js +11 -0
  275. package/dist/compiler/index.js.map +1 -0
  276. package/dist/compiler/jsdoc-types.d.ts +21 -0
  277. package/dist/compiler/jsdoc-types.d.ts.map +1 -0
  278. package/dist/compiler/jsdoc-types.js +59 -0
  279. package/dist/compiler/jsdoc-types.js.map +1 -0
  280. package/dist/compiler/jsdoc-types.test.d.ts +1 -0
  281. package/dist/compiler/jsdoc-types.test.d.ts.map +1 -0
  282. package/dist/compiler/jsdoc-types.test.js +100 -0
  283. package/dist/compiler/jsdoc-types.test.js.map +1 -0
  284. package/dist/compiler/lazy-modules/compile-cache.d.ts +37 -0
  285. package/dist/compiler/lazy-modules/compile-cache.d.ts.map +1 -0
  286. package/dist/compiler/lazy-modules/compile-cache.js +34 -0
  287. package/dist/compiler/lazy-modules/compile-cache.js.map +1 -0
  288. package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts +2 -0
  289. package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts.map +1 -0
  290. package/dist/compiler/lazy-modules/compile-project.lazy.test.js +65 -0
  291. package/dist/compiler/lazy-modules/compile-project.lazy.test.js.map +1 -0
  292. package/dist/compiler/lazy-modules/create-loader.d.ts +18 -0
  293. package/dist/compiler/lazy-modules/create-loader.d.ts.map +1 -0
  294. package/dist/compiler/lazy-modules/create-loader.js +182 -0
  295. package/dist/compiler/lazy-modules/create-loader.js.map +1 -0
  296. package/dist/compiler/lazy-modules/create-loader.test.d.ts +2 -0
  297. package/dist/compiler/lazy-modules/create-loader.test.d.ts.map +1 -0
  298. package/dist/compiler/lazy-modules/create-loader.test.js +82 -0
  299. package/dist/compiler/lazy-modules/create-loader.test.js.map +1 -0
  300. package/dist/compiler/lazy-modules/manifest.d.ts +32 -0
  301. package/dist/compiler/lazy-modules/manifest.d.ts.map +1 -0
  302. package/dist/compiler/lazy-modules/manifest.js +11 -0
  303. package/dist/compiler/lazy-modules/manifest.js.map +1 -0
  304. package/dist/compiler/match-literals.d.ts +2 -0
  305. package/dist/compiler/match-literals.d.ts.map +1 -0
  306. package/dist/compiler/match-literals.js +42 -0
  307. package/dist/compiler/match-literals.js.map +1 -0
  308. package/dist/compiler/output-structure/lazy-modules.d.ts +27 -0
  309. package/dist/compiler/output-structure/lazy-modules.d.ts.map +1 -0
  310. package/dist/compiler/output-structure/lazy-modules.js +157 -0
  311. package/dist/compiler/output-structure/lazy-modules.js.map +1 -0
  312. package/dist/compiler/output-structure/lazy-modules.test.d.ts +2 -0
  313. package/dist/compiler/output-structure/lazy-modules.test.d.ts.map +1 -0
  314. package/dist/compiler/output-structure/lazy-modules.test.js +128 -0
  315. package/dist/compiler/output-structure/lazy-modules.test.js.map +1 -0
  316. package/dist/compiler/output-structure/locale-modules.d.ts +4 -0
  317. package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -0
  318. package/dist/compiler/output-structure/locale-modules.js +81 -0
  319. package/dist/compiler/output-structure/locale-modules.js.map +1 -0
  320. package/dist/compiler/output-structure/locale-modules.test.d.ts +1 -0
  321. package/dist/compiler/output-structure/locale-modules.test.d.ts.map +1 -0
  322. package/dist/compiler/output-structure/locale-modules.test.js +163 -0
  323. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -0
  324. package/dist/compiler/output-structure/message-modules.d.ts +4 -0
  325. package/dist/compiler/output-structure/message-modules.d.ts.map +1 -0
  326. package/dist/compiler/output-structure/message-modules.js +100 -0
  327. package/dist/compiler/output-structure/message-modules.js.map +1 -0
  328. package/dist/compiler/output-structure/message-modules.test.d.ts +1 -0
  329. package/dist/compiler/output-structure/message-modules.test.d.ts.map +1 -0
  330. package/dist/compiler/output-structure/message-modules.test.js +148 -0
  331. package/dist/compiler/output-structure/message-modules.test.js.map +1 -0
  332. package/dist/compiler/per-locale-build.d.ts +2 -0
  333. package/dist/compiler/per-locale-build.d.ts.map +1 -0
  334. package/dist/compiler/per-locale-build.js +3 -0
  335. package/dist/compiler/per-locale-build.js.map +1 -0
  336. package/dist/compiler/registry.d.ts +13 -0
  337. package/dist/compiler/registry.d.ts.map +1 -0
  338. package/dist/compiler/registry.js +60 -0
  339. package/dist/compiler/registry.js.map +1 -0
  340. package/dist/compiler/resolve-tsc-js-path.d.ts +9 -0
  341. package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
  342. package/dist/compiler/resolve-tsc-js-path.js +23 -0
  343. package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
  344. package/dist/compiler/runtime/check-locale.d.ts +31 -0
  345. package/dist/compiler/runtime/check-locale.d.ts.map +1 -0
  346. package/dist/compiler/runtime/check-locale.js +51 -0
  347. package/dist/compiler/runtime/check-locale.js.map +1 -0
  348. package/dist/compiler/runtime/check-locale.test.d.ts +1 -0
  349. package/dist/compiler/runtime/check-locale.test.d.ts.map +1 -0
  350. package/dist/compiler/runtime/check-locale.test.js +84 -0
  351. package/dist/compiler/runtime/check-locale.test.js.map +1 -0
  352. package/dist/compiler/runtime/create-runtime.d.ts +35 -0
  353. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -0
  354. package/dist/compiler/runtime/create-runtime.js +196 -0
  355. package/dist/compiler/runtime/create-runtime.js.map +1 -0
  356. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +13 -0
  357. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
  358. package/dist/compiler/runtime/extract-locale-from-cookie.js +43 -0
  359. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -0
  360. package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +1 -0
  361. package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts.map +1 -0
  362. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +149 -0
  363. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -0
  364. package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -0
  365. package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -0
  366. package/dist/compiler/runtime/extract-locale-from-header.js +45 -0
  367. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -0
  368. package/dist/compiler/runtime/extract-locale-from-header.test.d.ts +1 -0
  369. package/dist/compiler/runtime/extract-locale-from-header.test.d.ts.map +1 -0
  370. package/dist/compiler/runtime/extract-locale-from-header.test.js +55 -0
  371. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -0
  372. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +12 -0
  373. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -0
  374. package/dist/compiler/runtime/extract-locale-from-navigator.js +33 -0
  375. package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -0
  376. package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts +1 -0
  377. package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts.map +1 -0
  378. package/dist/compiler/runtime/extract-locale-from-navigator.test.js +45 -0
  379. package/dist/compiler/runtime/extract-locale-from-navigator.test.js.map +1 -0
  380. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +34 -0
  381. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -0
  382. package/dist/compiler/runtime/extract-locale-from-request-async.js +70 -0
  383. package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -0
  384. package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts +1 -0
  385. package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts.map +1 -0
  386. package/dist/compiler/runtime/extract-locale-from-request-async.test.js +119 -0
  387. package/dist/compiler/runtime/extract-locale-from-request-async.test.js.map +1 -0
  388. package/dist/compiler/runtime/extract-locale-from-request.d.ts +41 -0
  389. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
  390. package/dist/compiler/runtime/extract-locale-from-request.js +96 -0
  391. package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -0
  392. package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +1 -0
  393. package/dist/compiler/runtime/extract-locale-from-request.test.d.ts.map +1 -0
  394. package/dist/compiler/runtime/extract-locale-from-request.test.js +351 -0
  395. package/dist/compiler/runtime/extract-locale-from-request.test.js.map +1 -0
  396. package/dist/compiler/runtime/extract-locale-from-url.d.ts +11 -0
  397. package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -0
  398. package/dist/compiler/runtime/extract-locale-from-url.js +68 -0
  399. package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -0
  400. package/dist/compiler/runtime/extract-locale-from-url.test.d.ts +1 -0
  401. package/dist/compiler/runtime/extract-locale-from-url.test.d.ts.map +1 -0
  402. package/dist/compiler/runtime/extract-locale-from-url.test.js +127 -0
  403. package/dist/compiler/runtime/extract-locale-from-url.test.js.map +1 -0
  404. package/dist/compiler/runtime/generate-static-localized-urls.d.ts +44 -0
  405. package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -0
  406. package/dist/compiler/runtime/generate-static-localized-urls.js +133 -0
  407. package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -0
  408. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts +1 -0
  409. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts.map +1 -0
  410. package/dist/compiler/runtime/generate-static-localized-urls.test.js +159 -0
  411. package/dist/compiler/runtime/generate-static-localized-urls.test.js.map +1 -0
  412. package/dist/compiler/runtime/get-locale.d.ts +42 -0
  413. package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
  414. package/dist/compiler/runtime/get-locale.js +158 -0
  415. package/dist/compiler/runtime/get-locale.js.map +1 -0
  416. package/dist/compiler/runtime/get-locale.test.d.ts +1 -0
  417. package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
  418. package/dist/compiler/runtime/get-locale.test.js +295 -0
  419. package/dist/compiler/runtime/get-locale.test.js.map +1 -0
  420. package/dist/compiler/runtime/get-text-direction.d.ts +15 -0
  421. package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -0
  422. package/dist/compiler/runtime/get-text-direction.js +46 -0
  423. package/dist/compiler/runtime/get-text-direction.js.map +1 -0
  424. package/dist/compiler/runtime/get-text-direction.test.d.ts +1 -0
  425. package/dist/compiler/runtime/get-text-direction.test.d.ts.map +1 -0
  426. package/dist/compiler/runtime/get-text-direction.test.js +40 -0
  427. package/dist/compiler/runtime/get-text-direction.test.js.map +1 -0
  428. package/dist/compiler/runtime/get-url-origin.d.ts +19 -0
  429. package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -0
  430. package/dist/compiler/runtime/get-url-origin.js +31 -0
  431. package/dist/compiler/runtime/get-url-origin.js.map +1 -0
  432. package/dist/compiler/runtime/get-url-origin.test.d.ts +1 -0
  433. package/dist/compiler/runtime/get-url-origin.test.d.ts.map +1 -0
  434. package/dist/compiler/runtime/get-url-origin.test.js +18 -0
  435. package/dist/compiler/runtime/get-url-origin.test.js.map +1 -0
  436. package/dist/compiler/runtime/host-routing.d.ts +28 -0
  437. package/dist/compiler/runtime/host-routing.d.ts.map +1 -0
  438. package/dist/compiler/runtime/host-routing.js +79 -0
  439. package/dist/compiler/runtime/host-routing.js.map +1 -0
  440. package/dist/compiler/runtime/host-routing.test.d.ts +1 -0
  441. package/dist/compiler/runtime/host-routing.test.d.ts.map +1 -0
  442. package/dist/compiler/runtime/host-routing.test.js +128 -0
  443. package/dist/compiler/runtime/host-routing.test.js.map +1 -0
  444. package/dist/compiler/runtime/localize-href.d.ts +84 -0
  445. package/dist/compiler/runtime/localize-href.d.ts.map +1 -0
  446. package/dist/compiler/runtime/localize-href.js +115 -0
  447. package/dist/compiler/runtime/localize-href.js.map +1 -0
  448. package/dist/compiler/runtime/localize-href.test.d.ts +1 -0
  449. package/dist/compiler/runtime/localize-href.test.d.ts.map +1 -0
  450. package/dist/compiler/runtime/localize-href.test.js +139 -0
  451. package/dist/compiler/runtime/localize-href.test.js.map +1 -0
  452. package/dist/compiler/runtime/localize-url.d.ts +95 -0
  453. package/dist/compiler/runtime/localize-url.d.ts.map +1 -0
  454. package/dist/compiler/runtime/localize-url.js +327 -0
  455. package/dist/compiler/runtime/localize-url.js.map +1 -0
  456. package/dist/compiler/runtime/localize-url.test.d.ts +1 -0
  457. package/dist/compiler/runtime/localize-url.test.d.ts.map +1 -0
  458. package/dist/compiler/runtime/localize-url.test.js +533 -0
  459. package/dist/compiler/runtime/localize-url.test.js.map +1 -0
  460. package/dist/compiler/runtime/route-strategy.d.ts +32 -0
  461. package/dist/compiler/runtime/route-strategy.d.ts.map +1 -0
  462. package/dist/compiler/runtime/route-strategy.js +72 -0
  463. package/dist/compiler/runtime/route-strategy.js.map +1 -0
  464. package/dist/compiler/runtime/set-locale.d.ts +46 -0
  465. package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
  466. package/dist/compiler/runtime/set-locale.js +172 -0
  467. package/dist/compiler/runtime/set-locale.js.map +1 -0
  468. package/dist/compiler/runtime/set-locale.test.d.ts +1 -0
  469. package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
  470. package/dist/compiler/runtime/set-locale.test.js +555 -0
  471. package/dist/compiler/runtime/set-locale.test.js.map +1 -0
  472. package/dist/compiler/runtime/should-redirect.d.ts +100 -0
  473. package/dist/compiler/runtime/should-redirect.d.ts.map +1 -0
  474. package/dist/compiler/runtime/should-redirect.js +155 -0
  475. package/dist/compiler/runtime/should-redirect.js.map +1 -0
  476. package/dist/compiler/runtime/should-redirect.test.d.ts +1 -0
  477. package/dist/compiler/runtime/should-redirect.test.d.ts.map +1 -0
  478. package/dist/compiler/runtime/should-redirect.test.js +270 -0
  479. package/dist/compiler/runtime/should-redirect.test.js.map +1 -0
  480. package/dist/compiler/runtime/strategy.d.ts +63 -0
  481. package/dist/compiler/runtime/strategy.d.ts.map +1 -0
  482. package/dist/compiler/runtime/strategy.js +65 -0
  483. package/dist/compiler/runtime/strategy.js.map +1 -0
  484. package/dist/compiler/runtime/strategy.test.d.ts +1 -0
  485. package/dist/compiler/runtime/strategy.test.d.ts.map +1 -0
  486. package/dist/compiler/runtime/strategy.test.js +90 -0
  487. package/dist/compiler/runtime/strategy.test.js.map +1 -0
  488. package/dist/compiler/runtime/track-message-call.d.ts +5 -0
  489. package/dist/compiler/runtime/track-message-call.d.ts.map +1 -0
  490. package/dist/compiler/runtime/track-message-call.js +14 -0
  491. package/dist/compiler/runtime/track-message-call.js.map +1 -0
  492. package/dist/compiler/runtime/track-message-call.test.d.ts +1 -0
  493. package/dist/compiler/runtime/track-message-call.test.d.ts.map +1 -0
  494. package/dist/compiler/runtime/track-message-call.test.js +22 -0
  495. package/dist/compiler/runtime/track-message-call.test.js.map +1 -0
  496. package/dist/compiler/runtime/type-definitions.d.ts +197 -0
  497. package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
  498. package/dist/compiler/runtime/type-definitions.js +150 -0
  499. package/dist/compiler/runtime/type-definitions.js.map +1 -0
  500. package/dist/compiler/runtime/type.d.ts +47 -0
  501. package/dist/compiler/runtime/type.d.ts.map +1 -0
  502. package/dist/compiler/runtime/type.js +2 -0
  503. package/dist/compiler/runtime/type.js.map +1 -0
  504. package/dist/compiler/runtime/type.test.d.ts +1 -0
  505. package/dist/compiler/runtime/type.test.d.ts.map +1 -0
  506. package/dist/compiler/runtime/type.test.js +153 -0
  507. package/dist/compiler/runtime/type.test.js.map +1 -0
  508. package/dist/compiler/runtime/url-pattern.d.ts +12 -0
  509. package/dist/compiler/runtime/url-pattern.d.ts.map +1 -0
  510. package/dist/compiler/runtime/url-pattern.js +35 -0
  511. package/dist/compiler/runtime/url-pattern.js.map +1 -0
  512. package/dist/compiler/runtime/variables.d.ts +128 -0
  513. package/dist/compiler/runtime/variables.d.ts.map +1 -0
  514. package/dist/compiler/runtime/variables.js +111 -0
  515. package/dist/compiler/runtime/variables.js.map +1 -0
  516. package/dist/compiler/safe-module-id.d.ts +7 -0
  517. package/dist/compiler/safe-module-id.d.ts.map +1 -0
  518. package/dist/compiler/safe-module-id.js +78 -0
  519. package/dist/compiler/safe-module-id.js.map +1 -0
  520. package/dist/compiler/safe-module-id.test.d.ts +1 -0
  521. package/dist/compiler/safe-module-id.test.d.ts.map +1 -0
  522. package/dist/compiler/safe-module-id.test.js +36 -0
  523. package/dist/compiler/safe-module-id.test.js.map +1 -0
  524. package/dist/compiler/seed-previous-compilation.d.ts +7 -0
  525. package/dist/compiler/seed-previous-compilation.d.ts.map +1 -0
  526. package/dist/compiler/seed-previous-compilation.js +9 -0
  527. package/dist/compiler/seed-previous-compilation.js.map +1 -0
  528. package/dist/compiler/server/create-server-file.d.ts +12 -0
  529. package/dist/compiler/server/create-server-file.d.ts.map +1 -0
  530. package/dist/compiler/server/create-server-file.js +91 -0
  531. package/dist/compiler/server/create-server-file.js.map +1 -0
  532. package/dist/compiler/server/create-server-file.test.d.ts +1 -0
  533. package/dist/compiler/server/create-server-file.test.d.ts.map +1 -0
  534. package/dist/compiler/server/create-server-file.test.js +48 -0
  535. package/dist/compiler/server/create-server-file.test.js.map +1 -0
  536. package/dist/compiler/server/middleware.d.ts +98 -0
  537. package/dist/compiler/server/middleware.d.ts.map +1 -0
  538. package/dist/compiler/server/middleware.js +278 -0
  539. package/dist/compiler/server/middleware.js.map +1 -0
  540. package/dist/compiler/server/middleware.test.d.ts +1 -0
  541. package/dist/compiler/server/middleware.test.d.ts.map +1 -0
  542. package/dist/compiler/server/middleware.test.js +1001 -0
  543. package/dist/compiler/server/middleware.test.js.map +1 -0
  544. package/dist/compiler/server/type.d.ts +6 -0
  545. package/dist/compiler/server/type.d.ts.map +1 -0
  546. package/dist/compiler/server/type.js +2 -0
  547. package/dist/compiler/server/type.js.map +1 -0
  548. package/dist/compiler/test-helpers.d.ts +30 -0
  549. package/dist/compiler/test-helpers.d.ts.map +1 -0
  550. package/dist/compiler/test-helpers.js +50 -0
  551. package/dist/compiler/test-helpers.js.map +1 -0
  552. package/dist/compiler/types.d.ts +7 -0
  553. package/dist/compiler/types.d.ts.map +1 -0
  554. package/dist/compiler/types.js +2 -0
  555. package/dist/compiler/types.js.map +1 -0
  556. package/dist/compiler/variable-access.d.ts +3 -0
  557. package/dist/compiler/variable-access.d.ts.map +1 -0
  558. package/dist/compiler/variable-access.js +15 -0
  559. package/dist/compiler/variable-access.js.map +1 -0
  560. package/dist/index.d.ts +2 -0
  561. package/dist/index.d.ts.map +1 -0
  562. package/dist/index.js +3 -0
  563. package/dist/index.js.map +1 -0
  564. package/dist/messages/ast.d.ts +102 -0
  565. package/dist/messages/ast.d.ts.map +1 -0
  566. package/dist/messages/ast.js +8 -0
  567. package/dist/messages/ast.js.map +1 -0
  568. package/dist/messages/create-bundle-nested.d.ts +16 -0
  569. package/dist/messages/create-bundle-nested.d.ts.map +1 -0
  570. package/dist/messages/create-bundle-nested.js +22 -0
  571. package/dist/messages/create-bundle-nested.js.map +1 -0
  572. package/dist/messages/index.d.ts +5 -0
  573. package/dist/messages/index.d.ts.map +1 -0
  574. package/dist/messages/index.js +5 -0
  575. package/dist/messages/index.js.map +1 -0
  576. package/dist/messages/load-messages.d.ts +19 -0
  577. package/dist/messages/load-messages.d.ts.map +1 -0
  578. package/dist/messages/load-messages.js +49 -0
  579. package/dist/messages/load-messages.js.map +1 -0
  580. package/dist/messages/message-format/flatten.d.ts +9 -0
  581. package/dist/messages/message-format/flatten.d.ts.map +1 -0
  582. package/dist/messages/message-format/flatten.js +32 -0
  583. package/dist/messages/message-format/flatten.js.map +1 -0
  584. package/dist/messages/message-format/import-files.d.ts +32 -0
  585. package/dist/messages/message-format/import-files.d.ts.map +1 -0
  586. package/dist/messages/message-format/import-files.js +53 -0
  587. package/dist/messages/message-format/import-files.js.map +1 -0
  588. package/dist/messages/message-format/import-files.test.d.ts +1 -0
  589. package/dist/messages/message-format/import-files.test.d.ts.map +1 -0
  590. package/dist/messages/message-format/import-files.test.js +145 -0
  591. package/dist/messages/message-format/import-files.test.js.map +1 -0
  592. package/dist/messages/message-format/index.d.ts +6 -0
  593. package/dist/messages/message-format/index.d.ts.map +1 -0
  594. package/dist/messages/message-format/index.js +7 -0
  595. package/dist/messages/message-format/index.js.map +1 -0
  596. package/dist/messages/message-format/parse-bundle.d.ts +31 -0
  597. package/dist/messages/message-format/parse-bundle.d.ts.map +1 -0
  598. package/dist/messages/message-format/parse-bundle.js +169 -0
  599. package/dist/messages/message-format/parse-bundle.js.map +1 -0
  600. package/dist/messages/message-format/parse-declaration.d.ts +2 -0
  601. package/dist/messages/message-format/parse-declaration.d.ts.map +1 -0
  602. package/dist/messages/message-format/parse-declaration.js +56 -0
  603. package/dist/messages/message-format/parse-declaration.js.map +1 -0
  604. package/dist/messages/message-format/parse-markup.d.ts +4 -0
  605. package/dist/messages/message-format/parse-markup.d.ts.map +1 -0
  606. package/dist/messages/message-format/parse-markup.js +167 -0
  607. package/dist/messages/message-format/parse-markup.js.map +1 -0
  608. package/dist/messages/message-format/parse-matches.d.ts +5 -0
  609. package/dist/messages/message-format/parse-matches.d.ts.map +1 -0
  610. package/dist/messages/message-format/parse-matches.js +31 -0
  611. package/dist/messages/message-format/parse-matches.js.map +1 -0
  612. package/dist/messages/message-format/parse-pattern.d.ts +5 -0
  613. package/dist/messages/message-format/parse-pattern.d.ts.map +1 -0
  614. package/dist/messages/message-format/parse-pattern.js +120 -0
  615. package/dist/messages/message-format/parse-pattern.js.map +1 -0
  616. package/dist/messages/message-format/unique.d.ts +2 -0
  617. package/dist/messages/message-format/unique.d.ts.map +1 -0
  618. package/dist/messages/message-format/unique.js +5 -0
  619. package/dist/messages/message-format/unique.js.map +1 -0
  620. package/dist/messages/nest-bundles.d.ts +19 -0
  621. package/dist/messages/nest-bundles.d.ts.map +1 -0
  622. package/dist/messages/nest-bundles.js +49 -0
  623. package/dist/messages/nest-bundles.js.map +1 -0
  624. package/dist/services/account/index.d.ts +14 -0
  625. package/dist/services/account/index.d.ts.map +1 -0
  626. package/dist/services/account/index.js +43 -0
  627. package/dist/services/account/index.js.map +1 -0
  628. package/dist/services/account/types.d.ts +4 -0
  629. package/dist/services/account/types.d.ts.map +1 -0
  630. package/dist/services/account/types.js +2 -0
  631. package/dist/services/account/types.js.map +1 -0
  632. package/dist/services/codegen/escape.d.ts +9 -0
  633. package/dist/services/codegen/escape.d.ts.map +1 -0
  634. package/dist/services/codegen/escape.js +19 -0
  635. package/dist/services/codegen/escape.js.map +1 -0
  636. package/dist/services/codegen/quotes.d.ts +4 -0
  637. package/dist/services/codegen/quotes.d.ts.map +1 -0
  638. package/dist/services/codegen/quotes.js +5 -0
  639. package/dist/services/codegen/quotes.js.map +1 -0
  640. package/dist/services/env-variables/create-index-file.d.ts +9 -0
  641. package/dist/services/env-variables/create-index-file.d.ts.map +1 -0
  642. package/dist/services/env-variables/create-index-file.js +28 -0
  643. package/dist/services/env-variables/create-index-file.js.map +1 -0
  644. package/dist/services/env-variables/index.d.ts +3 -0
  645. package/dist/services/env-variables/index.d.ts.map +1 -0
  646. package/dist/services/env-variables/index.js +4 -0
  647. package/dist/services/env-variables/index.js.map +1 -0
  648. package/dist/services/environment/package.d.ts +9 -0
  649. package/dist/services/environment/package.d.ts.map +1 -0
  650. package/dist/services/environment/package.js +31 -0
  651. package/dist/services/environment/package.js.map +1 -0
  652. package/dist/services/environment/package.test.d.ts +1 -0
  653. package/dist/services/environment/package.test.d.ts.map +1 -0
  654. package/dist/services/environment/package.test.js +21 -0
  655. package/dist/services/environment/package.test.js.map +1 -0
  656. package/dist/services/error-handling.d.ts +12 -0
  657. package/dist/services/error-handling.d.ts.map +1 -0
  658. package/dist/services/error-handling.js +27 -0
  659. package/dist/services/error-handling.js.map +1 -0
  660. package/dist/services/error-handling.test.d.ts +1 -0
  661. package/dist/services/error-handling.test.d.ts.map +1 -0
  662. package/dist/services/error-handling.test.js +10 -0
  663. package/dist/services/error-handling.test.js.map +1 -0
  664. package/dist/services/file-handling/content-hash.d.ts +9 -0
  665. package/dist/services/file-handling/content-hash.js +19 -0
  666. package/dist/services/file-handling/content-hash.js.map +1 -0
  667. package/dist/services/file-handling/exists.d.ts +7 -0
  668. package/dist/services/file-handling/exists.d.ts.map +1 -0
  669. package/dist/services/file-handling/exists.js +24 -0
  670. package/dist/services/file-handling/exists.js.map +1 -0
  671. package/dist/services/file-handling/exists.test.d.ts +1 -0
  672. package/dist/services/file-handling/exists.test.d.ts.map +1 -0
  673. package/dist/services/file-handling/exists.test.js +27 -0
  674. package/dist/services/file-handling/exists.test.js.map +1 -0
  675. package/dist/services/file-handling/types.d.ts +4 -0
  676. package/dist/services/file-handling/types.d.ts.map +1 -0
  677. package/dist/services/file-handling/types.js +2 -0
  678. package/dist/services/file-handling/types.js.map +1 -0
  679. package/dist/services/file-handling/write-output.d.ts +21 -0
  680. package/dist/services/file-handling/write-output.d.ts.map +1 -0
  681. package/dist/services/file-handling/write-output.js +157 -0
  682. package/dist/services/file-handling/write-output.js.map +1 -0
  683. package/dist/services/file-handling/write-output.test.d.ts +1 -0
  684. package/dist/services/file-handling/write-output.test.d.ts.map +1 -0
  685. package/dist/services/file-handling/write-output.test.js +217 -0
  686. package/dist/services/file-handling/write-output.test.js.map +1 -0
  687. package/dist/services/file-watching/tracked-fs.d.ts +25 -0
  688. package/dist/services/file-watching/tracked-fs.d.ts.map +1 -0
  689. package/dist/services/file-watching/tracked-fs.js +94 -0
  690. package/dist/services/file-watching/tracked-fs.js.map +1 -0
  691. package/dist/services/file-watching/tracked-fs.test.d.ts +1 -0
  692. package/dist/services/file-watching/tracked-fs.test.d.ts.map +1 -0
  693. package/dist/services/file-watching/tracked-fs.test.js +87 -0
  694. package/dist/services/file-watching/tracked-fs.test.js.map +1 -0
  695. package/dist/services/logger/index.d.ts +17 -0
  696. package/dist/services/logger/index.d.ts.map +1 -0
  697. package/dist/services/logger/index.js +58 -0
  698. package/dist/services/logger/index.js.map +1 -0
  699. package/dist/services/lookup.d.ts +14 -0
  700. package/dist/services/lookup.d.ts.map +1 -0
  701. package/dist/services/lookup.js +24 -0
  702. package/dist/services/lookup.js.map +1 -0
  703. package/dist/urlpattern-polyfill/index.d.ts +2 -0
  704. package/dist/urlpattern-polyfill/index.d.ts.map +1 -0
  705. package/dist/urlpattern-polyfill/index.js +2 -0
  706. package/dist/urlpattern-polyfill/index.js.map +1 -0
  707. package/dist/utilities/detect-json-formatting.d.ts +10 -0
  708. package/dist/utilities/detect-json-formatting.d.ts.map +1 -0
  709. package/dist/utilities/detect-json-formatting.js +80 -0
  710. package/dist/utilities/detect-json-formatting.js.map +1 -0
  711. package/dist/utilities/node-normalize-path.d.ts +1 -0
  712. package/dist/utilities/node-normalize-path.d.ts.map +1 -0
  713. package/dist/utilities/node-normalize-path.js +10 -0
  714. package/dist/utilities/node-normalize-path.js.map +1 -0
  715. package/package.json +87 -0
@@ -0,0 +1,157 @@
1
+ import path from "node:path";
2
+ import { hashOutputContents, hashContent } from "./content-hash.js";
3
+ export async function writeOutput(args) {
4
+ const currentOutputHashes = hashOutput(args.output, args.directory);
5
+ // if the output hasn't changed, don't write it
6
+ const changedFiles = new Set();
7
+ for (const [filePath, hash] of Object.entries(currentOutputHashes)) {
8
+ if (args.previousOutputHashes?.[filePath] !== hash) {
9
+ changedFiles.add(filePath);
10
+ }
11
+ }
12
+ // Find files that have been removed in the current output
13
+ const filesToDelete = new Set();
14
+ if (args.previousOutputHashes) {
15
+ for (const filePath of Object.keys(args.previousOutputHashes)) {
16
+ if (!currentOutputHashes[filePath]) {
17
+ filesToDelete.add(filePath);
18
+ }
19
+ }
20
+ }
21
+ if (changedFiles.size === 0 && filesToDelete.size === 0) {
22
+ return currentOutputHashes;
23
+ }
24
+ // clear the output directory
25
+ //
26
+ // disabled because of https://github.com/opral/inlang-paraglide-js/issues/350
27
+ // and re-enabled because of https://github.com/opral/inlang-paraglide-js/issues/420
28
+ if (args.cleanDirectory) {
29
+ await args.fs.rm(args.directory, { recursive: true, force: true });
30
+ }
31
+ else {
32
+ await args.fs.mkdir(args.directory, { recursive: true });
33
+ }
34
+ // Delete files that have been removed
35
+ // ignore if cleanDirectory is true because the directory will be cleaned anyway
36
+ if (filesToDelete.size > 0 && !args.cleanDirectory) {
37
+ await deleteRemovedFiles(args.fs, args.directory, filesToDelete);
38
+ }
39
+ //Create missing directories inside the output directory
40
+ await Promise.allSettled(Object.keys(args.output).map(async (filePath) => {
41
+ const fullPath = path.resolve(args.directory, filePath);
42
+ const directory = path.dirname(fullPath);
43
+ await args.fs.mkdir(directory, { recursive: true });
44
+ }));
45
+ //Write files
46
+ await Promise.allSettled(Object.entries(args.output).map(async ([filePath, fileContent]) => {
47
+ if (!changedFiles.has(filePath)) {
48
+ return;
49
+ }
50
+ const fullPath = path.resolve(args.directory, filePath);
51
+ await args.fs.writeFile(fullPath, fileContent);
52
+ }));
53
+ //Only update the previousOutputHashes if the write was successful
54
+ return currentOutputHashes;
55
+ }
56
+ /**
57
+ * Delete files that have been removed and clean up empty directories
58
+ */
59
+ async function deleteRemovedFiles(fs, baseDirectory, filesToDelete) {
60
+ // Collect directories that might need cleanup
61
+ const potentialEmptyDirs = new Set();
62
+ // First pass: delete all files and collect parent directories
63
+ await Promise.allSettled(Array.from(filesToDelete).map(async (filePath) => {
64
+ const fullPath = path.resolve(baseDirectory, filePath);
65
+ try {
66
+ await fs.unlink(fullPath);
67
+ // Add parent directory for potential cleanup
68
+ const dirPath = path.dirname(fullPath);
69
+ if (dirPath !== baseDirectory) {
70
+ potentialEmptyDirs.add(dirPath);
71
+ }
72
+ }
73
+ catch {
74
+ // Ignore errors if the file doesn't exist
75
+ }
76
+ }));
77
+ // Second pass: clean up empty directories, starting from deepest paths
78
+ const sortedDirs = Array.from(potentialEmptyDirs).sort((a, b) => b.length - a.length);
79
+ for (const dirPath of sortedDirs) {
80
+ // Only process directories within the base directory
81
+ if (!dirPath.startsWith(baseDirectory) || dirPath === baseDirectory) {
82
+ continue;
83
+ }
84
+ try {
85
+ const dirContents = await fs.readdir(dirPath);
86
+ if (dirContents.length === 0) {
87
+ await fs.rmdir(dirPath);
88
+ // Add parent directory for potential cleanup
89
+ const parentDir = path.dirname(dirPath);
90
+ if (parentDir !== baseDirectory) {
91
+ sortedDirs.push(parentDir);
92
+ }
93
+ }
94
+ }
95
+ catch {
96
+ // Ignore errors during directory cleanup
97
+ }
98
+ }
99
+ }
100
+ function hashOutput(output, outputDirectory) {
101
+ return hashOutputContents(output, (filePath, fileContent) => fileContent + path.resolve(outputDirectory, filePath));
102
+ }
103
+ /**
104
+ * Walk an existing output directory and produce the same hash map that
105
+ * {@link writeOutput} would have returned on a previous compile.
106
+ *
107
+ * Used by the bundler plugins to seed `previousCompilation` on a fresh
108
+ * process so the first compile's diff against unchanged inputs is empty
109
+ * and `writeOutput` short-circuits — letting us avoid wiping the directory
110
+ * out from under concurrent SSR/prerender readers (#659).
111
+ *
112
+ * Returns `undefined` if the directory does not exist. Keys are
113
+ * forward-slash relative paths to match {@link hashOutput}.
114
+ */
115
+ export async function hashDirectory(directory, fs) {
116
+ try {
117
+ const stat = await fs.stat(directory);
118
+ if (!stat.isDirectory())
119
+ return undefined;
120
+ }
121
+ catch {
122
+ return undefined;
123
+ }
124
+ const hashes = {};
125
+ async function walk(currentDir, relativePrefix) {
126
+ let entries;
127
+ try {
128
+ entries = await fs.readdir(currentDir, { withFileTypes: true });
129
+ }
130
+ catch {
131
+ return;
132
+ }
133
+ for (const entry of entries) {
134
+ const entryAbsolutePath = path.resolve(currentDir, entry.name);
135
+ const relativePath = relativePrefix
136
+ ? `${relativePrefix}/${entry.name}`
137
+ : entry.name;
138
+ if (entry.isDirectory()) {
139
+ await walk(entryAbsolutePath, relativePath);
140
+ }
141
+ else if (entry.isFile()) {
142
+ try {
143
+ const fileContent = await fs.readFile(entryAbsolutePath, "utf-8");
144
+ const combinedContent = fileContent + path.resolve(directory, relativePath);
145
+ hashes[relativePath] = hashContent(combinedContent);
146
+ }
147
+ catch {
148
+ // Another compiler process may be rewriting this file. A partial
149
+ // seed is safe; the following compile will repair missing outputs.
150
+ }
151
+ }
152
+ }
153
+ }
154
+ await walk(directory, "");
155
+ return hashes;
156
+ }
157
+ //# sourceMappingURL=write-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-output.js","sourceRoot":"","sources":["../../../src/services/file-handling/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAMjC;IACA,MAAM,mBAAmB,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAEpE,+CAA+C;IAC/C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;IAE/B,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACpE,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;YACpD,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IAED,0DAA0D;IAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAA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AC,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;gBACrD,CAAC;gBAAC,MAAM,CAAC;oBACR,iEAAiE;oBACjE,mEAAmE;gBACpE,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC1B,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import path from \"node:path\";\nimport type nodeFs from \"node:fs/promises\";\nimport { hashOutputContents, hashContent } from \"./content-hash.js\";\n\nexport async function writeOutput(args: {\n\tdirectory: string;\n\toutput: Record<string, string>;\n\tcleanDirectory?: boolean;\n\tfs: typeof nodeFs;\n\tpreviousOutputHashes?: Record<string, string>;\n}) {\n\tconst currentOutputHashes = hashOutput(args.output, args.directory);\n\n\t// if the output hasn't changed, don't write it\n\tconst changedFiles = new Set();\n\n\tfor (const [filePath, hash] of Object.entries(currentOutputHashes)) {\n\t\tif (args.previousOutputHashes?.[filePath] !== hash) {\n\t\t\tchangedFiles.add(filePath);\n\t\t}\n\t}\n\n\t// Find files that have been removed in the current output\n\tconst filesToDelete = new Set<string>();\n\tif (args.previousOutputHashes) {\n\t\tfor (const filePath of Object.keys(args.previousOutputHashes)) {\n\t\t\tif (!currentOutputHashes[filePath]) {\n\t\t\t\tfilesToDelete.add(filePath);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (changedFiles.size === 0 && filesToDelete.size === 0) {\n\t\treturn currentOutputHashes;\n\t}\n\n\t// clear the output directory\n\t//\n\t// disabled because of https://github.com/opral/inlang-paraglide-js/issues/350\n\t// and re-enabled because of https://github.com/opral/inlang-paraglide-js/issues/420\n\tif (args.cleanDirectory) {\n\t\tawait args.fs.rm(args.directory, { recursive: true, force: true });\n\t} else {\n\t\tawait args.fs.mkdir(args.directory, { recursive: true });\n\t}\n\t// Delete files that have been removed\n\t// ignore if cleanDirectory is true because the directory will be cleaned anyway\n\tif (filesToDelete.size > 0 && !args.cleanDirectory) {\n\t\tawait deleteRemovedFiles(args.fs, args.directory, filesToDelete);\n\t}\n\n\t//Create missing directories inside the output directory\n\tawait Promise.allSettled(\n\t\tObject.keys(args.output).map(async (filePath) => {\n\t\t\tconst fullPath = path.resolve(args.directory, filePath);\n\t\t\tconst directory = path.dirname(fullPath);\n\t\t\tawait args.fs.mkdir(directory, { recursive: true });\n\t\t})\n\t);\n\n\t//Write files\n\tawait Promise.allSettled(\n\t\tObject.entries(args.output).map(async ([filePath, fileContent]) => {\n\t\t\tif (!changedFiles.has(filePath)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst fullPath = path.resolve(args.directory, filePath);\n\t\t\tawait args.fs.writeFile(fullPath, fileContent);\n\t\t})\n\t);\n\n\t//Only update the previousOutputHashes if the write was successful\n\treturn currentOutputHashes;\n}\n\n/**\n * Delete files that have been removed and clean up empty directories\n */\nasync function deleteRemovedFiles(\n\tfs: typeof nodeFs,\n\tbaseDirectory: string,\n\tfilesToDelete: Set<string>\n) {\n\t// Collect directories that might need cleanup\n\tconst potentialEmptyDirs = new Set<string>();\n\n\t// First pass: delete all files and collect parent directories\n\tawait Promise.allSettled(\n\t\tArray.from(filesToDelete).map(async (filePath) => {\n\t\t\tconst fullPath = path.resolve(baseDirectory, filePath);\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(fullPath);\n\n\t\t\t\t// Add parent directory for potential cleanup\n\t\t\t\tconst dirPath = path.dirname(fullPath);\n\t\t\t\tif (dirPath !== baseDirectory) {\n\t\t\t\t\tpotentialEmptyDirs.add(dirPath);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore errors if the file doesn't exist\n\t\t\t}\n\t\t})\n\t);\n\n\t// Second pass: clean up empty directories, starting from deepest paths\n\tconst sortedDirs = Array.from(potentialEmptyDirs).sort(\n\t\t(a, b) => b.length - a.length\n\t);\n\n\tfor (const dirPath of sortedDirs) {\n\t\t// Only process directories within the base directory\n\t\tif (!dirPath.startsWith(baseDirectory) || dirPath === baseDirectory) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\tconst dirContents = await fs.readdir(dirPath);\n\t\t\tif (dirContents.length === 0) {\n\t\t\t\tawait fs.rmdir(dirPath);\n\n\t\t\t\t// Add parent directory for potential cleanup\n\t\t\t\tconst parentDir = path.dirname(dirPath);\n\t\t\t\tif (parentDir !== baseDirectory) {\n\t\t\t\t\tsortedDirs.push(parentDir);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore errors during directory cleanup\n\t\t}\n\t}\n}\n\nfunction hashOutput(\n\toutput: Record<string, string>,\n\toutputDirectory: string\n): Record<string, string> {\n\treturn hashOutputContents(\n\t\toutput,\n\t\t(filePath, fileContent) =>\n\t\t\tfileContent + path.resolve(outputDirectory, filePath)\n\t);\n}\n\n/**\n * Walk an existing output directory and produce the same hash map that\n * {@link writeOutput} would have returned on a previous compile.\n *\n * Used by the bundler plugins to seed `previousCompilation` on a fresh\n * process so the first compile's diff against unchanged inputs is empty\n * and `writeOutput` short-circuits — letting us avoid wiping the directory\n * out from under concurrent SSR/prerender readers (#659).\n *\n * Returns `undefined` if the directory does not exist. Keys are\n * forward-slash relative paths to match {@link hashOutput}.\n */\nexport async function hashDirectory(\n\tdirectory: string,\n\tfs: typeof nodeFs\n): Promise<Record<string, string> | undefined> {\n\ttry {\n\t\tconst stat = await fs.stat(directory);\n\t\tif (!stat.isDirectory()) return undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\tconst hashes: Record<string, string> = {};\n\n\tasync function walk(currentDir: string, relativePrefix: string) {\n\t\tlet entries;\n\t\ttry {\n\t\t\tentries = await fs.readdir(currentDir, { withFileTypes: true });\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst entryAbsolutePath = path.resolve(currentDir, entry.name);\n\t\t\tconst relativePath = relativePrefix\n\t\t\t\t? `${relativePrefix}/${entry.name}`\n\t\t\t\t: entry.name;\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(entryAbsolutePath, relativePath);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst fileContent = await fs.readFile(entryAbsolutePath, \"utf-8\");\n\t\t\t\t\tconst combinedContent =\n\t\t\t\t\t\tfileContent + path.resolve(directory, relativePath);\n\t\t\t\t\thashes[relativePath] = hashContent(combinedContent);\n\t\t\t\t} catch {\n\t\t\t\t\t// Another compiler process may be rewriting this file. A partial\n\t\t\t\t\t// seed is safe; the following compile will repair missing outputs.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(directory, \"\");\n\treturn hashes;\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-output.test.d.ts","sourceRoot":"","sources":["../../../src/services/file-handling/write-output.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,217 @@
1
+ import memfs from "memfs";
2
+ import { test, expect, vi, beforeEach } from "vitest";
3
+ beforeEach(() => {
4
+ vi.resetModules();
5
+ });
6
+ test("should write the output to a non-existing directory", async () => {
7
+ const { writeOutput } = await import("./write-output.js");
8
+ const fs = mockFs({});
9
+ await writeOutput({
10
+ directory: "/output",
11
+ output: { "test.txt": "test" },
12
+ fs,
13
+ });
14
+ expect(await fs.readFile("/output/test.txt", { encoding: "utf-8" })).toBe("test");
15
+ });
16
+ test("should clear & overwrite output that's already there", async () => {
17
+ const { writeOutput } = await import("./write-output.js");
18
+ const fs = mockFs({
19
+ "/output/test.txt": "old",
20
+ "/output/other.txt": "other",
21
+ });
22
+ await writeOutput({
23
+ directory: "/output",
24
+ output: { "test.txt": "new" },
25
+ cleanDirectory: true,
26
+ fs,
27
+ });
28
+ expect(await fs.readFile("/output/test.txt", { encoding: "utf-8" })).toBe("new");
29
+ await expect(async () => await fs.readFile("/output/other.txt", { encoding: "utf-8" })).rejects.toBeDefined();
30
+ });
31
+ test("should create any missing directories", async () => {
32
+ const { writeOutput } = await import("./write-output.js");
33
+ const fs = mockFs({});
34
+ await writeOutput({
35
+ directory: "/output/messages",
36
+ output: {
37
+ "de/test.txt": "de",
38
+ "en/test.txt": "en",
39
+ },
40
+ fs,
41
+ });
42
+ expect(await fs.readFile("/output/messages/de/test.txt", { encoding: "utf-8" })).toBe("de");
43
+ expect(await fs.readFile("/output/messages/en/test.txt", { encoding: "utf-8" })).toBe("en");
44
+ });
45
+ test("should only write once if the output hasn't changed", async () => {
46
+ const { writeOutput } = await import("./write-output.js");
47
+ const fs = mockFs({});
48
+ const writeFileSpy = vi.spyOn(fs, "writeFile");
49
+ const hashes = await writeOutput({
50
+ directory: "/output",
51
+ output: { "test.txt": "test" },
52
+ fs,
53
+ });
54
+ const hashes2 = await writeOutput({
55
+ directory: "/output",
56
+ output: { "test.txt": "test" },
57
+ fs,
58
+ previousOutputHashes: hashes,
59
+ });
60
+ expect(hashes).toEqual(hashes2);
61
+ expect(await fs.readFile("/output/test.txt", { encoding: "utf-8" })).toBe("test");
62
+ expect(writeFileSpy).toHaveBeenCalledTimes(1);
63
+ });
64
+ test("should write again if the output has changed", async () => {
65
+ const { writeOutput } = await import("./write-output.js");
66
+ const fs = mockFs({});
67
+ const writeFileSpy = vi.spyOn(fs, "writeFile");
68
+ const hashes = await writeOutput({
69
+ directory: "/output",
70
+ output: { "test.txt": "test" },
71
+ fs,
72
+ });
73
+ await writeOutput({
74
+ directory: "/output",
75
+ output: { "test.txt": "test2" },
76
+ fs,
77
+ previousOutputHashes: hashes,
78
+ });
79
+ expect(await fs.readFile("/output/test.txt", { encoding: "utf-8" })).toBe("test2");
80
+ expect(writeFileSpy).toHaveBeenCalledTimes(2);
81
+ });
82
+ test("should write files if output has partially changed", async () => {
83
+ const { writeOutput } = await import("./write-output.js");
84
+ const fs = mockFs({});
85
+ const writeFileSpy = vi.spyOn(fs, "writeFile");
86
+ const hashes = await writeOutput({
87
+ directory: "/output",
88
+ output: { "file1.txt": "test", "file2.txt": "test" },
89
+ fs,
90
+ });
91
+ await writeOutput({
92
+ directory: "/output",
93
+ output: { "file1.txt": "test", "file2.txt": "test2" },
94
+ fs,
95
+ previousOutputHashes: hashes,
96
+ });
97
+ expect(writeFileSpy).toHaveBeenCalledWith("/output/file2.txt", "test2");
98
+ expect(writeFileSpy).toHaveBeenCalledTimes(3);
99
+ });
100
+ test("should delete files that have been removed from the output", async () => {
101
+ const { writeOutput } = await import("./write-output.js");
102
+ const fs = mockFs({});
103
+ // First write with three files
104
+ const hashes = await writeOutput({
105
+ directory: "/output",
106
+ output: {
107
+ "file1.txt": "content1",
108
+ "file2.txt": "content2",
109
+ "subdir/file3.txt": "content3",
110
+ },
111
+ fs,
112
+ });
113
+ // Verify all files were written
114
+ expect(await fs.readFile("/output/file1.txt", { encoding: "utf-8" })).toBe("content1");
115
+ expect(await fs.readFile("/output/file2.txt", { encoding: "utf-8" })).toBe("content2");
116
+ expect(await fs.readFile("/output/subdir/file3.txt", { encoding: "utf-8" })).toBe("content3");
117
+ // Second write with file2.txt removed
118
+ await writeOutput({
119
+ directory: "/output",
120
+ output: {
121
+ "file1.txt": "content1",
122
+ "subdir/file3.txt": "content3updated",
123
+ },
124
+ fs,
125
+ previousOutputHashes: hashes,
126
+ });
127
+ // Verify file1.txt still exists
128
+ expect(await fs.readFile("/output/file1.txt", { encoding: "utf-8" })).toBe("content1");
129
+ // Verify file2.txt has been deleted
130
+ await expect(async () => await fs.readFile("/output/file2.txt", { encoding: "utf-8" })).rejects.toBeDefined();
131
+ // Verify file3.txt was updated
132
+ expect(await fs.readFile("/output/subdir/file3.txt", { encoding: "utf-8" })).toBe("content3updated");
133
+ // Get the new hashes
134
+ const newHashes = await writeOutput({
135
+ directory: "/output",
136
+ output: {
137
+ "file1.txt": "content1",
138
+ "subdir/file3.txt": "content3updated",
139
+ },
140
+ fs,
141
+ previousOutputHashes: hashes,
142
+ });
143
+ // Third write with subdir/file3.txt removed
144
+ await writeOutput({
145
+ directory: "/output",
146
+ output: {
147
+ "file1.txt": "content1",
148
+ },
149
+ fs,
150
+ previousOutputHashes: newHashes,
151
+ });
152
+ // Verify file1.txt still exists
153
+ expect(await fs.readFile("/output/file1.txt", { encoding: "utf-8" })).toBe("content1");
154
+ // Verify subdir/file3.txt has been deleted
155
+ await expect(async () => await fs.readFile("/output/subdir/file3.txt", { encoding: "utf-8" })).rejects.toBeDefined();
156
+ // Verify the subdir directory has also been removed
157
+ await expect(async () => await fs.readdir("/output/subdir")).rejects.toBeDefined();
158
+ });
159
+ test("hashDirectory matches the hashes writeOutput returns", async () => {
160
+ const { writeOutput, hashDirectory } = await import("./write-output.js");
161
+ const fs = mockFs({});
162
+ const output = {
163
+ "a.txt": "alpha",
164
+ "nested/b.txt": "beta",
165
+ "nested/deep/c.txt": "gamma",
166
+ };
167
+ const writtenHashes = await writeOutput({
168
+ directory: "/output",
169
+ output,
170
+ fs,
171
+ });
172
+ const seededHashes = await hashDirectory("/output", fs);
173
+ expect(seededHashes).toEqual(writtenHashes);
174
+ });
175
+ test("hashDirectory returns undefined when directory does not exist", async () => {
176
+ const { hashDirectory } = await import("./write-output.js");
177
+ const fs = mockFs({});
178
+ expect(await hashDirectory("/nope", fs)).toBeUndefined();
179
+ });
180
+ test("hashDirectory skips files that disappear while walking", async () => {
181
+ const { hashDirectory } = await import("./write-output.js");
182
+ const fs = mockFs({
183
+ "/output/a.txt": "alpha",
184
+ "/output/b.txt": "beta",
185
+ });
186
+ const readFile = fs.readFile.bind(fs);
187
+ vi.spyOn(fs, "readFile").mockImplementation((async (...args) => {
188
+ if (args[0] === "/output/b.txt") {
189
+ throw new Error("file disappeared");
190
+ }
191
+ return readFile(args[0], args[1]);
192
+ }));
193
+ const seededHashes = await hashDirectory("/output", fs);
194
+ expect(seededHashes).toEqual({
195
+ "a.txt": expect.any(String),
196
+ });
197
+ });
198
+ test("hashDirectory skips directories that disappear while walking", async () => {
199
+ const { hashDirectory } = await import("./write-output.js");
200
+ const fs = mockFs({
201
+ "/output/nested/b.txt": "beta",
202
+ });
203
+ const readdir = fs.readdir.bind(fs);
204
+ vi.spyOn(fs, "readdir").mockImplementation((async (...args) => {
205
+ if (args[0] === "/output/nested") {
206
+ throw new Error("directory disappeared");
207
+ }
208
+ return readdir(args[0], args[1]);
209
+ }));
210
+ const seededHashes = await hashDirectory("/output", fs);
211
+ expect(seededHashes).toEqual({});
212
+ });
213
+ const mockFs = (files) => {
214
+ const _memfs = memfs.createFsFromVolume(memfs.Volume.fromJSON(files));
215
+ return _memfs.promises;
216
+ };
217
+ //# sourceMappingURL=write-output.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-output.test.js","sourceRoot":"","sources":["../../../src/services/file-handling/write-output.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtD,UAAU,CAAC,GAAG,EAAE;IACf,EAAE,CAAC,YAAY,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;IACtE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAEtB,MAAM,WAAW,CAAC;QACjB,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;QAC9B,EAAE;KACF,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CACxE,MAAM,CACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;IACvE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAA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C,OAAO,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,KAA0B,EAAE,EAAE;IAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,QAAgC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import memfs from \"memfs\";\nimport type fs from \"node:fs/promises\";\nimport { test, expect, vi, beforeEach } from \"vitest\";\n\nbeforeEach(() => {\n\tvi.resetModules();\n});\n\ntest(\"should write the output to a non-existing directory\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\tawait writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"test.txt\": \"test\" },\n\t\tfs,\n\t});\n\texpect(await fs.readFile(\"/output/test.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"test\"\n\t);\n});\n\ntest(\"should clear & overwrite output that's already there\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({\n\t\t\"/output/test.txt\": \"old\",\n\t\t\"/output/other.txt\": \"other\",\n\t});\n\n\tawait writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"test.txt\": \"new\" },\n\t\tcleanDirectory: true,\n\t\tfs,\n\t});\n\n\texpect(await fs.readFile(\"/output/test.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"new\"\n\t);\n\tawait expect(\n\t\tasync () => await fs.readFile(\"/output/other.txt\", { encoding: \"utf-8\" })\n\t).rejects.toBeDefined();\n});\n\ntest(\"should create any missing directories\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\tawait writeOutput({\n\t\tdirectory: \"/output/messages\",\n\t\toutput: {\n\t\t\t\"de/test.txt\": \"de\",\n\t\t\t\"en/test.txt\": \"en\",\n\t\t},\n\t\tfs,\n\t});\n\texpect(\n\t\tawait fs.readFile(\"/output/messages/de/test.txt\", { encoding: \"utf-8\" })\n\t).toBe(\"de\");\n\texpect(\n\t\tawait fs.readFile(\"/output/messages/en/test.txt\", { encoding: \"utf-8\" })\n\t).toBe(\"en\");\n});\n\ntest(\"should only write once if the output hasn't changed\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\tconst writeFileSpy = vi.spyOn(fs as any, \"writeFile\");\n\n\tconst hashes = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"test.txt\": \"test\" },\n\t\tfs,\n\t});\n\tconst hashes2 = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"test.txt\": \"test\" },\n\t\tfs,\n\t\tpreviousOutputHashes: hashes,\n\t});\n\texpect(hashes).toEqual(hashes2);\n\texpect(await fs.readFile(\"/output/test.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"test\"\n\t);\n\texpect(writeFileSpy).toHaveBeenCalledTimes(1);\n});\n\ntest(\"should write again if the output has changed\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\tconst writeFileSpy = vi.spyOn(fs as any, \"writeFile\");\n\n\tconst hashes = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"test.txt\": \"test\" },\n\t\tfs,\n\t});\n\tawait writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"test.txt\": \"test2\" },\n\t\tfs,\n\t\tpreviousOutputHashes: hashes,\n\t});\n\texpect(await fs.readFile(\"/output/test.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"test2\"\n\t);\n\texpect(writeFileSpy).toHaveBeenCalledTimes(2);\n});\n\ntest(\"should write files if output has partially changed\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\tconst writeFileSpy = vi.spyOn(fs as any, \"writeFile\");\n\n\tconst hashes = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"file1.txt\": \"test\", \"file2.txt\": \"test\" },\n\t\tfs,\n\t});\n\n\tawait writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: { \"file1.txt\": \"test\", \"file2.txt\": \"test2\" },\n\t\tfs,\n\t\tpreviousOutputHashes: hashes,\n\t});\n\texpect(writeFileSpy).toHaveBeenCalledWith(\"/output/file2.txt\", \"test2\");\n\texpect(writeFileSpy).toHaveBeenCalledTimes(3);\n});\n\ntest(\"should delete files that have been removed from the output\", async () => {\n\tconst { writeOutput } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\t// First write with three files\n\tconst hashes = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: {\n\t\t\t\"file1.txt\": \"content1\",\n\t\t\t\"file2.txt\": \"content2\",\n\t\t\t\"subdir/file3.txt\": \"content3\",\n\t\t},\n\t\tfs,\n\t});\n\n\t// Verify all files were written\n\texpect(await fs.readFile(\"/output/file1.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"content1\"\n\t);\n\texpect(await fs.readFile(\"/output/file2.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"content2\"\n\t);\n\texpect(\n\t\tawait fs.readFile(\"/output/subdir/file3.txt\", { encoding: \"utf-8\" })\n\t).toBe(\"content3\");\n\n\t// Second write with file2.txt removed\n\tawait writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: {\n\t\t\t\"file1.txt\": \"content1\",\n\t\t\t\"subdir/file3.txt\": \"content3updated\",\n\t\t},\n\t\tfs,\n\t\tpreviousOutputHashes: hashes,\n\t});\n\n\t// Verify file1.txt still exists\n\texpect(await fs.readFile(\"/output/file1.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"content1\"\n\t);\n\t// Verify file2.txt has been deleted\n\tawait expect(\n\t\tasync () => await fs.readFile(\"/output/file2.txt\", { encoding: \"utf-8\" })\n\t).rejects.toBeDefined();\n\t// Verify file3.txt was updated\n\texpect(\n\t\tawait fs.readFile(\"/output/subdir/file3.txt\", { encoding: \"utf-8\" })\n\t).toBe(\"content3updated\");\n\n\t// Get the new hashes\n\tconst newHashes = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: {\n\t\t\t\"file1.txt\": \"content1\",\n\t\t\t\"subdir/file3.txt\": \"content3updated\",\n\t\t},\n\t\tfs,\n\t\tpreviousOutputHashes: hashes,\n\t});\n\n\t// Third write with subdir/file3.txt removed\n\tawait writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput: {\n\t\t\t\"file1.txt\": \"content1\",\n\t\t},\n\t\tfs,\n\t\tpreviousOutputHashes: newHashes,\n\t});\n\n\t// Verify file1.txt still exists\n\texpect(await fs.readFile(\"/output/file1.txt\", { encoding: \"utf-8\" })).toBe(\n\t\t\"content1\"\n\t);\n\t// Verify subdir/file3.txt has been deleted\n\tawait expect(\n\t\tasync () =>\n\t\t\tawait fs.readFile(\"/output/subdir/file3.txt\", { encoding: \"utf-8\" })\n\t).rejects.toBeDefined();\n\t// Verify the subdir directory has also been removed\n\tawait expect(\n\t\tasync () => await fs.readdir(\"/output/subdir\")\n\t).rejects.toBeDefined();\n});\n\ntest(\"hashDirectory matches the hashes writeOutput returns\", async () => {\n\tconst { writeOutput, hashDirectory } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\tconst output = {\n\t\t\"a.txt\": \"alpha\",\n\t\t\"nested/b.txt\": \"beta\",\n\t\t\"nested/deep/c.txt\": \"gamma\",\n\t};\n\n\tconst writtenHashes = await writeOutput({\n\t\tdirectory: \"/output\",\n\t\toutput,\n\t\tfs,\n\t});\n\n\tconst seededHashes = await hashDirectory(\"/output\", fs);\n\n\texpect(seededHashes).toEqual(writtenHashes);\n});\n\ntest(\"hashDirectory returns undefined when directory does not exist\", async () => {\n\tconst { hashDirectory } = await import(\"./write-output.js\");\n\tconst fs = mockFs({});\n\n\texpect(await hashDirectory(\"/nope\", fs)).toBeUndefined();\n});\n\ntest(\"hashDirectory skips files that disappear while walking\", async () => {\n\tconst { hashDirectory } = await import(\"./write-output.js\");\n\tconst fs = mockFs({\n\t\t\"/output/a.txt\": \"alpha\",\n\t\t\"/output/b.txt\": \"beta\",\n\t});\n\tconst readFile = fs.readFile.bind(fs);\n\tvi.spyOn(fs, \"readFile\").mockImplementation((async (...args) => {\n\t\tif (args[0] === \"/output/b.txt\") {\n\t\t\tthrow new Error(\"file disappeared\");\n\t\t}\n\t\treturn readFile(args[0], args[1]);\n\t}) as typeof fs.readFile);\n\n\tconst seededHashes = await hashDirectory(\"/output\", fs);\n\n\texpect(seededHashes).toEqual({\n\t\t\"a.txt\": expect.any(String),\n\t});\n});\n\ntest(\"hashDirectory skips directories that disappear while walking\", async () => {\n\tconst { hashDirectory } = await import(\"./write-output.js\");\n\tconst fs = mockFs({\n\t\t\"/output/nested/b.txt\": \"beta\",\n\t});\n\tconst readdir = fs.readdir.bind(fs);\n\tvi.spyOn(fs, \"readdir\").mockImplementation((async (...args) => {\n\t\tif (args[0] === \"/output/nested\") {\n\t\t\tthrow new Error(\"directory disappeared\");\n\t\t}\n\t\treturn readdir(args[0], args[1] as never);\n\t}) as typeof fs.readdir);\n\n\tconst seededHashes = await hashDirectory(\"/output\", fs);\n\n\texpect(seededHashes).toEqual({});\n});\n\nconst mockFs = (files: memfs.DirectoryJSON) => {\n\tconst _memfs = memfs.createFsFromVolume(memfs.Volume.fromJSON(files));\n\treturn _memfs.promises as unknown as typeof fs;\n};\n"]}
@@ -0,0 +1,25 @@
1
+ type TrackedFs = {
2
+ fs: typeof import("node:fs");
3
+ readFiles: Set<string>;
4
+ clearReadFiles: () => void;
5
+ };
6
+ type TrackedFsOptions = {
7
+ baseDir?: string;
8
+ fs?: typeof import("node:fs");
9
+ };
10
+ type WatchTargetOptions = {
11
+ baseDir?: string;
12
+ outdir?: string;
13
+ ignoreCache?: boolean;
14
+ includeDirectories?: boolean;
15
+ ignorePath?: (path: string) => boolean;
16
+ };
17
+ type WatchTargets = {
18
+ files: Set<string>;
19
+ directories: Set<string>;
20
+ isIgnoredPath: (path: string) => boolean;
21
+ };
22
+ export declare function isPathWithinDirectories(path: string, directories: Iterable<string>): boolean;
23
+ export declare function getWatchTargets(files: Iterable<string>, options?: WatchTargetOptions): WatchTargets;
24
+ export declare function createTrackedFs(options?: TrackedFsOptions): TrackedFs;
25
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracked-fs.d.ts","sourceRoot":"","sources":["../../../src/services/file-watching/tracked-fs.ts"],"names":[],"mappings":"AAIA,KAAK,SAAS,GAAG;IAChB,EAAE,EAAE,cAAc,SAAS,CAAC,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,cAAc,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,cAAc,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC,CAAC;AAEF,KAAK,YAAY,GAAG;IACnB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACzC,CAAC;AAEF,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC3B,OAAO,CAYT;AAED,wBAAgB,eAAe,CAC9B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,OAAO,GAAE,kBAAuB,GAC9B,YAAY,CAgDd;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAgDzE"}
@@ -0,0 +1,94 @@
1
+ import fs from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { nodeNormalizePath } from "../../utilities/node-normalize-path.js";
4
+ export function isPathWithinDirectories(path, directories) {
5
+ const normalizedPath = nodeNormalizePath(path);
6
+ for (const directory of directories) {
7
+ const normalizedDirectory = nodeNormalizePath(directory);
8
+ if (normalizedPath === normalizedDirectory ||
9
+ normalizedPath.startsWith(`${normalizedDirectory}/`)) {
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ }
15
+ export function getWatchTargets(files, options = {}) {
16
+ const baseDir = options.baseDir ?? process.cwd();
17
+ const outdirPath = options.outdir
18
+ ? nodeNormalizePath(resolve(baseDir, options.outdir))
19
+ : undefined;
20
+ const ignoreCache = options.ignoreCache ?? true;
21
+ const includeDirectories = options.includeDirectories ?? true;
22
+ const ignorePath = options.ignorePath;
23
+ const isIgnoredPath = (path) => {
24
+ const normalizedPath = nodeNormalizePath(path);
25
+ // match whole path segments only — a project under e.g. /cachet-app/
26
+ // must not have its inputs ignored
27
+ if (ignoreCache && /(^|\/)cache(\/|$)/.test(normalizedPath)) {
28
+ return true;
29
+ }
30
+ if (outdirPath &&
31
+ (normalizedPath === outdirPath ||
32
+ normalizedPath.startsWith(`${outdirPath}/`))) {
33
+ return true;
34
+ }
35
+ return ignorePath ? ignorePath(normalizedPath) : false;
36
+ };
37
+ const nextFiles = new Set();
38
+ const nextDirectories = new Set();
39
+ for (const filePath of files) {
40
+ const normalizedPath = nodeNormalizePath(filePath);
41
+ if (isIgnoredPath(normalizedPath)) {
42
+ continue;
43
+ }
44
+ nextFiles.add(normalizedPath);
45
+ if (includeDirectories) {
46
+ const directoryPath = dirname(normalizedPath);
47
+ if (!isIgnoredPath(directoryPath)) {
48
+ nextDirectories.add(directoryPath);
49
+ }
50
+ }
51
+ }
52
+ return {
53
+ files: nextFiles,
54
+ directories: nextDirectories,
55
+ isIgnoredPath,
56
+ };
57
+ }
58
+ export function createTrackedFs(options = {}) {
59
+ const baseDir = options.baseDir ?? process.cwd();
60
+ const baseFs = options.fs ?? fs;
61
+ const readFiles = new Set();
62
+ const trackRead = (path) => {
63
+ readFiles.add(nodeNormalizePath(resolve(baseDir, path.toString())));
64
+ };
65
+ const wrappedFs = {
66
+ ...baseFs,
67
+ // @ts-expect-error - Node's fs has too many overloads
68
+ readFile: (path, options, callback) => {
69
+ trackRead(path);
70
+ return baseFs.readFile(path, options, callback);
71
+ },
72
+ // @ts-expect-error - Node's fs has too many overloads
73
+ readFileSync: (path, options) => {
74
+ trackRead(path);
75
+ return baseFs.readFileSync(path, options);
76
+ },
77
+ promises: {
78
+ ...baseFs.promises,
79
+ // @ts-expect-error - Node's fs.promises has too many overloads
80
+ readFile: async (path, options) => {
81
+ trackRead(path);
82
+ return baseFs.promises.readFile(path, options);
83
+ },
84
+ },
85
+ };
86
+ return {
87
+ fs: wrappedFs,
88
+ readFiles,
89
+ clearReadFiles: () => {
90
+ readFiles.clear();
91
+ },
92
+ };
93
+ }
94
+ //# sourceMappingURL=tracked-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracked-fs.js","sourceRoot":"","sources":["../../../src/services/file-watching/tracked-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AA2B3E,MAAM,UAAU,uBAAuB,CACtC,IAAY,EACZ,WAA6B;IAE7B,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC/C,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,SAAS,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AAQ,CAAC,CAAC;QACjD,CAAC;QACD,sDAAsD;QACtD,YAAY,EAAE,CACb,IAA0B,EAC1B,OAA+D,EAC9D,EAAE;YACH,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QACD,QAAQ,EAAE;YACT,GAAG,MAAM,CAAC,QAAQ;YAClB,+DAA+D;YAC/D,QAAQ,EAAE,KAAK,EACd,IAAiB,EACjB,OAAmD,EACjC,EAAE;gBACpB,SAAS,CAAC,IAAI,CAAC,CAAC;gBAChB,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAChD,CAAC;SACD;KACD,CAAC;IAEF,OAAO;QACN,EAAE,EAAE,SAAS;QACb,SAAS;QACT,cAAc,EAAE,GAAG,EAAE;YACpB,SAAS,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { nodeNormalizePath } from \"../../utilities/node-normalize-path.js\";\n\ntype TrackedFs = {\n\tfs: typeof import(\"node:fs\");\n\treadFiles: Set<string>;\n\tclearReadFiles: () => void;\n};\n\ntype TrackedFsOptions = {\n\tbaseDir?: string;\n\tfs?: typeof import(\"node:fs\");\n};\n\ntype WatchTargetOptions = {\n\tbaseDir?: string;\n\toutdir?: string;\n\tignoreCache?: boolean;\n\tincludeDirectories?: boolean;\n\tignorePath?: (path: string) => boolean;\n};\n\ntype WatchTargets = {\n\tfiles: Set<string>;\n\tdirectories: Set<string>;\n\tisIgnoredPath: (path: string) => boolean;\n};\n\nexport function isPathWithinDirectories(\n\tpath: string,\n\tdirectories: Iterable<string>\n): boolean {\n\tconst normalizedPath = nodeNormalizePath(path);\n\tfor (const directory of directories) {\n\t\tconst normalizedDirectory = nodeNormalizePath(directory);\n\t\tif (\n\t\t\tnormalizedPath === normalizedDirectory ||\n\t\t\tnormalizedPath.startsWith(`${normalizedDirectory}/`)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nexport function getWatchTargets(\n\tfiles: Iterable<string>,\n\toptions: WatchTargetOptions = {}\n): WatchTargets {\n\tconst baseDir = options.baseDir ?? process.cwd();\n\tconst outdirPath = options.outdir\n\t\t? nodeNormalizePath(resolve(baseDir, options.outdir))\n\t\t: undefined;\n\tconst ignoreCache = options.ignoreCache ?? true;\n\tconst includeDirectories = options.includeDirectories ?? true;\n\tconst ignorePath = options.ignorePath;\n\n\tconst isIgnoredPath = (path: string) => {\n\t\tconst normalizedPath = nodeNormalizePath(path);\n\t\t// match whole path segments only — a project under e.g. /cachet-app/\n\t\t// must not have its inputs ignored\n\t\tif (ignoreCache && /(^|\\/)cache(\\/|$)/.test(normalizedPath)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (\n\t\t\toutdirPath &&\n\t\t\t(normalizedPath === outdirPath ||\n\t\t\t\tnormalizedPath.startsWith(`${outdirPath}/`))\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn ignorePath ? ignorePath(normalizedPath) : false;\n\t};\n\n\tconst nextFiles = new Set<string>();\n\tconst nextDirectories = new Set<string>();\n\n\tfor (const filePath of files) {\n\t\tconst normalizedPath = nodeNormalizePath(filePath);\n\t\tif (isIgnoredPath(normalizedPath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tnextFiles.add(normalizedPath);\n\t\tif (includeDirectories) {\n\t\t\tconst directoryPath = dirname(normalizedPath);\n\t\t\tif (!isIgnoredPath(directoryPath)) {\n\t\t\t\tnextDirectories.add(directoryPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tfiles: nextFiles,\n\t\tdirectories: nextDirectories,\n\t\tisIgnoredPath,\n\t};\n}\n\nexport function createTrackedFs(options: TrackedFsOptions = {}): TrackedFs {\n\tconst baseDir = options.baseDir ?? process.cwd();\n\tconst baseFs = options.fs ?? fs;\n\tconst readFiles = new Set<string>();\n\n\tconst trackRead = (path: fs.PathLike | number) => {\n\t\treadFiles.add(nodeNormalizePath(resolve(baseDir, path.toString())));\n\t};\n\n\tconst wrappedFs: typeof import(\"node:fs\") = {\n\t\t...baseFs,\n\t\t// @ts-expect-error - Node's fs has too many overloads\n\t\treadFile: (\n\t\t\tpath: fs.PathLike | number,\n\t\t\toptions: { encoding?: null; flag?: string } | null | undefined,\n\t\t\tcallback: (err: NodeJS.ErrnoException | null, data: Buffer) => void\n\t\t) => {\n\t\t\ttrackRead(path);\n\t\t\treturn baseFs.readFile(path, options, callback);\n\t\t},\n\t\t// @ts-expect-error - Node's fs has too many overloads\n\t\treadFileSync: (\n\t\t\tpath: fs.PathLike | number,\n\t\t\toptions?: { encoding?: null; flag?: string } | null | undefined\n\t\t) => {\n\t\t\ttrackRead(path);\n\t\t\treturn baseFs.readFileSync(path, options);\n\t\t},\n\t\tpromises: {\n\t\t\t...baseFs.promises,\n\t\t\t// @ts-expect-error - Node's fs.promises has too many overloads\n\t\t\treadFile: async (\n\t\t\t\tpath: fs.PathLike,\n\t\t\t\toptions?: { encoding?: null; flag?: string } | null\n\t\t\t): Promise<Buffer> => {\n\t\t\t\ttrackRead(path);\n\t\t\t\treturn baseFs.promises.readFile(path, options);\n\t\t\t},\n\t\t},\n\t};\n\n\treturn {\n\t\tfs: wrappedFs,\n\t\treadFiles,\n\t\tclearReadFiles: () => {\n\t\t\treadFiles.clear();\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracked-fs.test.d.ts","sourceRoot":"","sources":["../../../src/services/file-watching/tracked-fs.test.ts"],"names":[],"mappings":""}