@ryanatkn/gro 0.190.1 → 0.192.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 (323) hide show
  1. package/README.md +4 -278
  2. package/package.json +5 -142
  3. package/LICENSE +0 -21
  4. package/dist/args.d.ts +0 -37
  5. package/dist/args.d.ts.map +0 -1
  6. package/dist/args.js +0 -102
  7. package/dist/build.task.d.ts +0 -20
  8. package/dist/build.task.d.ts.map +0 -1
  9. package/dist/build.task.js +0 -119
  10. package/dist/build_cache.d.ts +0 -100
  11. package/dist/build_cache.d.ts.map +0 -1
  12. package/dist/build_cache.js +0 -299
  13. package/dist/changelog.d.ts +0 -11
  14. package/dist/changelog.d.ts.map +0 -1
  15. package/dist/changelog.js +0 -47
  16. package/dist/changeset.task.d.ts +0 -35
  17. package/dist/changeset.task.d.ts.map +0 -1
  18. package/dist/changeset.task.js +0 -151
  19. package/dist/changeset_helpers.d.ts +0 -17
  20. package/dist/changeset_helpers.d.ts.map +0 -1
  21. package/dist/changeset_helpers.js +0 -7
  22. package/dist/check.task.d.ts +0 -28
  23. package/dist/check.task.d.ts.map +0 -1
  24. package/dist/check.task.js +0 -95
  25. package/dist/child_process_logging.d.ts +0 -10
  26. package/dist/child_process_logging.d.ts.map +0 -1
  27. package/dist/child_process_logging.js +0 -26
  28. package/dist/clean.task.d.ts +0 -15
  29. package/dist/clean.task.d.ts.map +0 -1
  30. package/dist/clean.task.js +0 -40
  31. package/dist/clean_fs.d.ts +0 -9
  32. package/dist/clean_fs.d.ts.map +0 -1
  33. package/dist/clean_fs.js +0 -28
  34. package/dist/cli.d.ts +0 -34
  35. package/dist/cli.d.ts.map +0 -1
  36. package/dist/cli.js +0 -61
  37. package/dist/commit.task.d.ts +0 -11
  38. package/dist/commit.task.d.ts.map +0 -1
  39. package/dist/commit.task.js +0 -24
  40. package/dist/constants.d.ts +0 -46
  41. package/dist/constants.d.ts.map +0 -1
  42. package/dist/constants.js +0 -52
  43. package/dist/deploy.task.d.ts +0 -29
  44. package/dist/deploy.task.d.ts.map +0 -1
  45. package/dist/deploy.task.js +0 -217
  46. package/dist/dev.task.d.ts +0 -16
  47. package/dist/dev.task.d.ts.map +0 -1
  48. package/dist/dev.task.js +0 -44
  49. package/dist/disknode.d.ts +0 -23
  50. package/dist/disknode.d.ts.map +0 -1
  51. package/dist/disknode.js +0 -1
  52. package/dist/env.d.ts +0 -11
  53. package/dist/env.d.ts.map +0 -1
  54. package/dist/env.js +0 -49
  55. package/dist/esbuild_helpers.d.ts +0 -16
  56. package/dist/esbuild_helpers.d.ts.map +0 -1
  57. package/dist/esbuild_helpers.js +0 -36
  58. package/dist/esbuild_plugin_external_worker.d.ts +0 -23
  59. package/dist/esbuild_plugin_external_worker.d.ts.map +0 -1
  60. package/dist/esbuild_plugin_external_worker.js +0 -55
  61. package/dist/esbuild_plugin_svelte.d.ts +0 -15
  62. package/dist/esbuild_plugin_svelte.d.ts.map +0 -1
  63. package/dist/esbuild_plugin_svelte.js +0 -83
  64. package/dist/esbuild_plugin_sveltekit_local_imports.d.ts +0 -8
  65. package/dist/esbuild_plugin_sveltekit_local_imports.d.ts.map +0 -1
  66. package/dist/esbuild_plugin_sveltekit_local_imports.js +0 -30
  67. package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +0 -7
  68. package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts.map +0 -1
  69. package/dist/esbuild_plugin_sveltekit_shim_alias.js +0 -18
  70. package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +0 -9
  71. package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +0 -1
  72. package/dist/esbuild_plugin_sveltekit_shim_app.js +0 -22
  73. package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +0 -11
  74. package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +0 -1
  75. package/dist/esbuild_plugin_sveltekit_shim_env.js +0 -18
  76. package/dist/filer.d.ts +0 -33
  77. package/dist/filer.d.ts.map +0 -1
  78. package/dist/filer.js +0 -385
  79. package/dist/format.task.d.ts +0 -11
  80. package/dist/format.task.d.ts.map +0 -1
  81. package/dist/format.task.js +0 -27
  82. package/dist/format_directory.d.ts +0 -13
  83. package/dist/format_directory.d.ts.map +0 -1
  84. package/dist/format_directory.js +0 -40
  85. package/dist/format_file.d.ts +0 -9
  86. package/dist/format_file.d.ts.map +0 -1
  87. package/dist/format_file.js +0 -42
  88. package/dist/gen.d.ts +0 -142
  89. package/dist/gen.d.ts.map +0 -1
  90. package/dist/gen.js +0 -199
  91. package/dist/gen.task.d.ts +0 -12
  92. package/dist/gen.task.d.ts.map +0 -1
  93. package/dist/gen.task.js +0 -149
  94. package/dist/gen_helpers.d.ts +0 -11
  95. package/dist/gen_helpers.d.ts.map +0 -1
  96. package/dist/gen_helpers.js +0 -76
  97. package/dist/github.d.ts +0 -19
  98. package/dist/github.d.ts.map +0 -1
  99. package/dist/github.js +0 -33
  100. package/dist/gro.config.default.d.ts +0 -13
  101. package/dist/gro.config.default.d.ts.map +0 -1
  102. package/dist/gro.config.default.js +0 -33
  103. package/dist/gro.d.ts +0 -3
  104. package/dist/gro.d.ts.map +0 -1
  105. package/dist/gro.js +0 -21
  106. package/dist/gro_config.d.ts +0 -115
  107. package/dist/gro_config.d.ts.map +0 -1
  108. package/dist/gro_config.js +0 -114
  109. package/dist/gro_helpers.d.ts +0 -49
  110. package/dist/gro_helpers.d.ts.map +0 -1
  111. package/dist/gro_helpers.js +0 -97
  112. package/dist/gro_plugin_gen.d.ts +0 -12
  113. package/dist/gro_plugin_gen.d.ts.map +0 -1
  114. package/dist/gro_plugin_gen.js +0 -101
  115. package/dist/gro_plugin_server.d.ts +0 -80
  116. package/dist/gro_plugin_server.d.ts.map +0 -1
  117. package/dist/gro_plugin_server.js +0 -167
  118. package/dist/gro_plugin_sveltekit_app.d.ts +0 -9
  119. package/dist/gro_plugin_sveltekit_app.d.ts.map +0 -1
  120. package/dist/gro_plugin_sveltekit_app.js +0 -42
  121. package/dist/gro_plugin_sveltekit_library.d.ts +0 -16
  122. package/dist/gro_plugin_sveltekit_library.d.ts.map +0 -1
  123. package/dist/gro_plugin_sveltekit_library.js +0 -34
  124. package/dist/index.d.ts +0 -9
  125. package/dist/index.d.ts.map +0 -1
  126. package/dist/index.js +0 -4
  127. package/dist/input_path.d.ts +0 -64
  128. package/dist/input_path.d.ts.map +0 -1
  129. package/dist/input_path.js +0 -199
  130. package/dist/invoke.d.ts +0 -2
  131. package/dist/invoke.d.ts.map +0 -1
  132. package/dist/invoke.js +0 -28
  133. package/dist/invoke_task.d.ts +0 -30
  134. package/dist/invoke_task.d.ts.map +0 -1
  135. package/dist/invoke_task.js +0 -104
  136. package/dist/lint.task.d.ts +0 -11
  137. package/dist/lint.task.d.ts.map +0 -1
  138. package/dist/lint.task.js +0 -32
  139. package/dist/loader.d.ts +0 -6
  140. package/dist/loader.d.ts.map +0 -1
  141. package/dist/loader.js +0 -192
  142. package/dist/module.d.ts +0 -4
  143. package/dist/module.d.ts.map +0 -1
  144. package/dist/module.js +0 -6
  145. package/dist/modules.d.ts +0 -36
  146. package/dist/modules.d.ts.map +0 -1
  147. package/dist/modules.js +0 -71
  148. package/dist/package_json.d.ts +0 -32
  149. package/dist/package_json.d.ts.map +0 -1
  150. package/dist/package_json.js +0 -178
  151. package/dist/parse_exports.d.ts +0 -20
  152. package/dist/parse_exports.d.ts.map +0 -1
  153. package/dist/parse_exports.js +0 -65
  154. package/dist/parse_exports_context.d.ts +0 -21
  155. package/dist/parse_exports_context.d.ts.map +0 -1
  156. package/dist/parse_exports_context.js +0 -332
  157. package/dist/parse_imports.d.ts +0 -5
  158. package/dist/parse_imports.d.ts.map +0 -1
  159. package/dist/parse_imports.js +0 -140
  160. package/dist/paths.d.ts +0 -41
  161. package/dist/paths.d.ts.map +0 -1
  162. package/dist/paths.js +0 -69
  163. package/dist/plugin.d.ts +0 -36
  164. package/dist/plugin.d.ts.map +0 -1
  165. package/dist/plugin.js +0 -78
  166. package/dist/publish.task.d.ts +0 -26
  167. package/dist/publish.task.d.ts.map +0 -1
  168. package/dist/publish.task.js +0 -176
  169. package/dist/register.d.ts +0 -2
  170. package/dist/register.d.ts.map +0 -1
  171. package/dist/register.js +0 -2
  172. package/dist/reinstall.task.d.ts +0 -8
  173. package/dist/reinstall.task.d.ts.map +0 -1
  174. package/dist/reinstall.task.js +0 -35
  175. package/dist/release.task.d.ts +0 -8
  176. package/dist/release.task.d.ts.map +0 -1
  177. package/dist/release.task.js +0 -20
  178. package/dist/resolve.task.d.ts +0 -11
  179. package/dist/resolve.task.d.ts.map +0 -1
  180. package/dist/resolve.task.js +0 -38
  181. package/dist/resolve_specifier.d.ts +0 -22
  182. package/dist/resolve_specifier.d.ts.map +0 -1
  183. package/dist/resolve_specifier.js +0 -57
  184. package/dist/run.task.d.ts +0 -16
  185. package/dist/run.task.d.ts.map +0 -1
  186. package/dist/run.task.js +0 -52
  187. package/dist/run_gen.d.ts +0 -10
  188. package/dist/run_gen.d.ts.map +0 -1
  189. package/dist/run_gen.js +0 -73
  190. package/dist/run_task.d.ts +0 -17
  191. package/dist/run_task.d.ts.map +0 -1
  192. package/dist/run_task.js +0 -45
  193. package/dist/source_json.d.ts +0 -7
  194. package/dist/source_json.d.ts.map +0 -1
  195. package/dist/source_json.js +0 -145
  196. package/dist/svelte_config.d.ts +0 -57
  197. package/dist/svelte_config.d.ts.map +0 -1
  198. package/dist/svelte_config.js +0 -81
  199. package/dist/sveltekit_helpers.d.ts +0 -75
  200. package/dist/sveltekit_helpers.d.ts.map +0 -1
  201. package/dist/sveltekit_helpers.js +0 -94
  202. package/dist/sveltekit_shim_app.d.ts +0 -11
  203. package/dist/sveltekit_shim_app.d.ts.map +0 -1
  204. package/dist/sveltekit_shim_app.js +0 -31
  205. package/dist/sveltekit_shim_app_environment.d.ts +0 -13
  206. package/dist/sveltekit_shim_app_environment.d.ts.map +0 -1
  207. package/dist/sveltekit_shim_app_environment.js +0 -14
  208. package/dist/sveltekit_shim_app_forms.d.ts +0 -5
  209. package/dist/sveltekit_shim_app_forms.d.ts.map +0 -1
  210. package/dist/sveltekit_shim_app_forms.js +0 -6
  211. package/dist/sveltekit_shim_app_navigation.d.ts +0 -10
  212. package/dist/sveltekit_shim_app_navigation.d.ts.map +0 -1
  213. package/dist/sveltekit_shim_app_navigation.js +0 -11
  214. package/dist/sveltekit_shim_app_paths.d.ts +0 -17
  215. package/dist/sveltekit_shim_app_paths.d.ts.map +0 -1
  216. package/dist/sveltekit_shim_app_paths.js +0 -10
  217. package/dist/sveltekit_shim_app_state.d.ts +0 -5
  218. package/dist/sveltekit_shim_app_state.d.ts.map +0 -1
  219. package/dist/sveltekit_shim_app_state.js +0 -26
  220. package/dist/sveltekit_shim_env.d.ts +0 -5
  221. package/dist/sveltekit_shim_env.d.ts.map +0 -1
  222. package/dist/sveltekit_shim_env.js +0 -23
  223. package/dist/sync.task.d.ts +0 -16
  224. package/dist/sync.task.d.ts.map +0 -1
  225. package/dist/sync.task.js +0 -39
  226. package/dist/task.d.ts +0 -98
  227. package/dist/task.d.ts.map +0 -1
  228. package/dist/task.js +0 -109
  229. package/dist/task_logging.d.ts +0 -6
  230. package/dist/task_logging.d.ts.map +0 -1
  231. package/dist/task_logging.js +0 -201
  232. package/dist/test.task.d.ts +0 -13
  233. package/dist/test.task.d.ts.map +0 -1
  234. package/dist/test.task.js +0 -53
  235. package/dist/typecheck.task.d.ts +0 -13
  236. package/dist/typecheck.task.d.ts.map +0 -1
  237. package/dist/typecheck.task.js +0 -68
  238. package/dist/upgrade.task.d.ts +0 -20
  239. package/dist/upgrade.task.d.ts.map +0 -1
  240. package/dist/upgrade.task.js +0 -111
  241. package/dist/watch_dir.d.ts +0 -36
  242. package/dist/watch_dir.d.ts.map +0 -1
  243. package/dist/watch_dir.js +0 -69
  244. package/src/lib/args.ts +0 -115
  245. package/src/lib/build.task.ts +0 -151
  246. package/src/lib/build_cache.ts +0 -378
  247. package/src/lib/changelog.ts +0 -69
  248. package/src/lib/changeset.task.ts +0 -228
  249. package/src/lib/changeset_helpers.ts +0 -14
  250. package/src/lib/check.task.ts +0 -120
  251. package/src/lib/child_process_logging.ts +0 -38
  252. package/src/lib/clean.task.ts +0 -48
  253. package/src/lib/clean_fs.ts +0 -54
  254. package/src/lib/cli.ts +0 -98
  255. package/src/lib/commit.task.ts +0 -34
  256. package/src/lib/constants.ts +0 -56
  257. package/src/lib/deploy.task.ts +0 -287
  258. package/src/lib/dev.task.ts +0 -52
  259. package/src/lib/disknode.ts +0 -26
  260. package/src/lib/env.ts +0 -78
  261. package/src/lib/esbuild_helpers.ts +0 -49
  262. package/src/lib/esbuild_plugin_external_worker.ts +0 -94
  263. package/src/lib/esbuild_plugin_svelte.ts +0 -134
  264. package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +0 -38
  265. package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +0 -27
  266. package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +0 -42
  267. package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +0 -47
  268. package/src/lib/filer.ts +0 -458
  269. package/src/lib/format.task.ts +0 -44
  270. package/src/lib/format_directory.ts +0 -65
  271. package/src/lib/format_file.ts +0 -49
  272. package/src/lib/gen.task.ts +0 -206
  273. package/src/lib/gen.ts +0 -406
  274. package/src/lib/gen_helpers.ts +0 -131
  275. package/src/lib/github.ts +0 -46
  276. package/src/lib/gro.config.default.ts +0 -42
  277. package/src/lib/gro.ts +0 -29
  278. package/src/lib/gro_config.ts +0 -254
  279. package/src/lib/gro_helpers.ts +0 -108
  280. package/src/lib/gro_plugin_gen.ts +0 -149
  281. package/src/lib/gro_plugin_server.ts +0 -288
  282. package/src/lib/gro_plugin_sveltekit_app.ts +0 -58
  283. package/src/lib/gro_plugin_sveltekit_library.ts +0 -63
  284. package/src/lib/index.ts +0 -8
  285. package/src/lib/input_path.ts +0 -254
  286. package/src/lib/invoke.ts +0 -34
  287. package/src/lib/invoke_task.ts +0 -139
  288. package/src/lib/lint.task.ts +0 -39
  289. package/src/lib/loader.ts +0 -229
  290. package/src/lib/module.ts +0 -13
  291. package/src/lib/modules.ts +0 -117
  292. package/src/lib/package_json.ts +0 -255
  293. package/src/lib/parse_exports.ts +0 -100
  294. package/src/lib/parse_exports_context.ts +0 -395
  295. package/src/lib/parse_imports.ts +0 -180
  296. package/src/lib/paths.ts +0 -111
  297. package/src/lib/plugin.ts +0 -106
  298. package/src/lib/publish.task.ts +0 -228
  299. package/src/lib/register.ts +0 -3
  300. package/src/lib/reinstall.task.ts +0 -45
  301. package/src/lib/release.task.ts +0 -26
  302. package/src/lib/resolve.task.ts +0 -43
  303. package/src/lib/resolve_specifier.ts +0 -81
  304. package/src/lib/run.task.ts +0 -65
  305. package/src/lib/run_gen.ts +0 -110
  306. package/src/lib/run_task.ts +0 -82
  307. package/src/lib/source_json.ts +0 -183
  308. package/src/lib/svelte_config.ts +0 -140
  309. package/src/lib/sveltekit_helpers.ts +0 -193
  310. package/src/lib/sveltekit_shim_app.ts +0 -41
  311. package/src/lib/sveltekit_shim_app_environment.ts +0 -16
  312. package/src/lib/sveltekit_shim_app_forms.ts +0 -13
  313. package/src/lib/sveltekit_shim_app_navigation.ts +0 -23
  314. package/src/lib/sveltekit_shim_app_paths.ts +0 -26
  315. package/src/lib/sveltekit_shim_app_state.ts +0 -35
  316. package/src/lib/sveltekit_shim_env.ts +0 -45
  317. package/src/lib/sync.task.ts +0 -47
  318. package/src/lib/task.ts +0 -245
  319. package/src/lib/task_logging.ts +0 -255
  320. package/src/lib/test.task.ts +0 -63
  321. package/src/lib/typecheck.task.ts +0 -81
  322. package/src/lib/upgrade.task.ts +0 -148
  323. package/src/lib/watch_dir.ts +0 -115
@@ -1,83 +0,0 @@
1
- import * as esbuild from 'esbuild';
2
- import { compile, compileModule, preprocess, } from 'svelte/compiler';
3
- import { readFile } from 'node:fs/promises';
4
- import { relative } from 'node:path';
5
- import { to_define_import_meta_env, default_ts_transform_options } from "./esbuild_helpers.js";
6
- import { default_svelte_config, to_default_compile_module_options, } from "./svelte_config.js";
7
- import { TS_MATCHER, SVELTE_MATCHER, SVELTE_RUNES_MATCHER } from "./constants.js";
8
- export const esbuild_plugin_svelte = (options) => {
9
- const { dev, base_url, dir = process.cwd(), svelte_compile_options = default_svelte_config.svelte_compile_options, svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options), svelte_preprocessors, ts_transform_options = default_ts_transform_options, is_ts = (f) => TS_MATCHER.test(f), } = options;
10
- const final_ts_transform_options = {
11
- ...ts_transform_options,
12
- define: to_define_import_meta_env(dev, base_url),
13
- sourcemap: 'inline',
14
- };
15
- return {
16
- name: 'svelte',
17
- setup: (build) => {
18
- build.onLoad({ filter: SVELTE_RUNES_MATCHER }, async ({ path }) => {
19
- const source = await readFile(path, 'utf8');
20
- try {
21
- const filename = relative(dir, path);
22
- const js_source = is_ts(filename)
23
- ? (await esbuild.transform(source, {
24
- ...final_ts_transform_options,
25
- sourcefile: filename,
26
- })).code // TODO @many use warnings? handle not-inline sourcemaps?
27
- : source;
28
- const { js, warnings } = compileModule(js_source, {
29
- ...svelte_compile_module_options,
30
- filename,
31
- });
32
- const contents = js.code + '//# sourceMappingURL=' + js.map.toUrl();
33
- return {
34
- contents,
35
- warnings: warnings.map((w) => convert_svelte_message_to_esbuild(filename, source, w)),
36
- };
37
- }
38
- catch (error) {
39
- return { errors: [convert_svelte_message_to_esbuild(path, source, error)] };
40
- }
41
- });
42
- build.onLoad({ filter: SVELTE_MATCHER }, async ({ path }) => {
43
- let source = await readFile(path, 'utf8');
44
- try {
45
- const filename = relative(dir, path);
46
- const preprocessed = svelte_preprocessors
47
- ? await preprocess(source, svelte_preprocessors, { filename })
48
- : null;
49
- if (preprocessed?.code)
50
- source = preprocessed.code;
51
- const { js, warnings } = compile(source, { ...svelte_compile_options, filename });
52
- const contents = js.code + '//# sourceMappingURL=' + js.map.toUrl();
53
- return {
54
- contents,
55
- warnings: warnings.map((w) => convert_svelte_message_to_esbuild(filename, source, w)),
56
- };
57
- }
58
- catch (error) {
59
- return { errors: [convert_svelte_message_to_esbuild(path, source, error)] };
60
- }
61
- });
62
- },
63
- };
64
- };
65
- /**
66
- * Following the example in the esbuild docs:
67
- * https://esbuild.github.io/plugins/#svelte-plugin
68
- */
69
- const convert_svelte_message_to_esbuild = (path, source, { message, start, end }) => {
70
- let location = null;
71
- if (start && end) {
72
- const lineText = source.split(/\r\n|\r|\n/g)[start.line - 1] ?? '';
73
- const lineEnd = start.line === end.line ? end.column : lineText.length;
74
- location = {
75
- file: path,
76
- line: start.line,
77
- lineText,
78
- column: start.column,
79
- length: lineEnd - start.column,
80
- };
81
- }
82
- return { text: message, location };
83
- };
@@ -1,8 +0,0 @@
1
- import type * as esbuild from 'esbuild';
2
- /**
3
- * Adds support for imports to both `.ts` and `.js`,
4
- * as well as imports without extensions that resolve to `.js` or `.ts`.
5
- * Prefers `.ts` over any `.js`, and falls back to `.ts` if no file is found.
6
- */
7
- export declare const esbuild_plugin_sveltekit_local_imports: () => esbuild.Plugin;
8
- //# sourceMappingURL=esbuild_plugin_sveltekit_local_imports.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esbuild_plugin_sveltekit_local_imports.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/esbuild_plugin_sveltekit_local_imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAOxC;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,QAAO,OAAO,CAAC,MAyBhE,CAAC"}
@@ -1,30 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { dirname } from 'node:path';
3
- import { resolve_specifier } from "./resolve_specifier.js";
4
- import { EVERYTHING_MATCHER } from "./constants.js";
5
- /**
6
- * Adds support for imports to both `.ts` and `.js`,
7
- * as well as imports without extensions that resolve to `.js` or `.ts`.
8
- * Prefers `.ts` over any `.js`, and falls back to `.ts` if no file is found.
9
- */
10
- export const esbuild_plugin_sveltekit_local_imports = () => ({
11
- name: 'sveltekit_local_imports',
12
- setup: (build) => {
13
- build.onResolve({ filter: /^(\/|\.)/ }, async (args) => {
14
- const { path, importer } = args;
15
- if (!importer)
16
- return { path };
17
- const { path_id, namespace } = await resolve_specifier(path, dirname(importer));
18
- return { path: path_id, namespace }; // `namespace` may be `undefined`, but esbuild needs the absolute path for json etc
19
- });
20
- build.onLoad({ filter: EVERYTHING_MATCHER, namespace: 'sveltekit_local_imports_ts' }, async ({ path }) => ({
21
- contents: await readFile(path),
22
- loader: 'ts',
23
- resolveDir: dirname(path),
24
- }));
25
- build.onLoad({ filter: EVERYTHING_MATCHER, namespace: 'sveltekit_local_imports_js' }, async ({ path }) => ({
26
- contents: await readFile(path),
27
- resolveDir: dirname(path),
28
- }));
29
- },
30
- });
@@ -1,7 +0,0 @@
1
- import type * as esbuild from 'esbuild';
2
- export interface EsbuildPluginSveltekitShimAliasOptions {
3
- dir?: string;
4
- alias?: Record<string, string>;
5
- }
6
- export declare const esbuild_plugin_sveltekit_shim_alias: ({ dir, alias, }: EsbuildPluginSveltekitShimAliasOptions) => esbuild.Plugin;
7
- //# sourceMappingURL=esbuild_plugin_sveltekit_shim_alias.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esbuild_plugin_sveltekit_shim_alias.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/esbuild_plugin_sveltekit_shim_alias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAIxC,MAAM,WAAW,sCAAsC;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,eAAO,MAAM,mCAAmC,GAAI,iBAGjD,sCAAsC,KAAG,OAAO,CAAC,MAclD,CAAC"}
@@ -1,18 +0,0 @@
1
- import { escape_regexp } from '@fuzdev/fuz_util/regexp.js';
2
- import { join } from 'node:path';
3
- export const esbuild_plugin_sveltekit_shim_alias = ({ dir = process.cwd(), alias, }) => ({
4
- name: 'sveltekit_shim_alias',
5
- setup: (build) => {
6
- const aliases = { $lib: 'src/lib', ...alias };
7
- // Create a Go-compatible regexp
8
- const filter = new RegExp(`^(?:${Object.keys(aliases).map(escape_regexp).join('|')})`);
9
- build.onResolve({ filter }, async (args) => {
10
- const { path, ...rest } = args;
11
- // Find which alias prefix matches
12
- const prefix = Object.keys(aliases).find((key) => path.startsWith(key));
13
- if (!prefix)
14
- return null;
15
- return build.resolve(join(dir, aliases[prefix] + path.substring(prefix.length)), rest);
16
- });
17
- },
18
- });
@@ -1,9 +0,0 @@
1
- import type * as esbuild from 'esbuild';
2
- import type { ParsedSvelteConfig } from './svelte_config.ts';
3
- export interface EsbuildPluginSveltekitShimAppOptions {
4
- dev: boolean;
5
- base_url: ParsedSvelteConfig['base_url'];
6
- assets_url: ParsedSvelteConfig['assets_url'];
7
- }
8
- export declare const esbuild_plugin_sveltekit_shim_app: ({ dev, base_url, assets_url, }: EsbuildPluginSveltekitShimAppOptions) => esbuild.Plugin;
9
- //# sourceMappingURL=esbuild_plugin_sveltekit_shim_app.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esbuild_plugin_sveltekit_shim_app.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/esbuild_plugin_sveltekit_shim_app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAOxC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAG3D,MAAM,WAAW,oCAAoC;IACpD,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACzC,UAAU,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,iCAAiC,GAAI,gCAI/C,oCAAoC,KAAG,OAAO,CAAC,MAqBhD,CAAC"}
@@ -1,22 +0,0 @@
1
- import { render_sveltekit_shim_app_environment, render_sveltekit_shim_app_paths, sveltekit_shim_app_specifiers, } from "./sveltekit_shim_app.js";
2
- import { EVERYTHING_MATCHER } from "./constants.js";
3
- export const esbuild_plugin_sveltekit_shim_app = ({ dev, base_url, assets_url, }) => ({
4
- name: 'sveltekit_shim_app',
5
- setup: (build) => {
6
- build.onResolve({ filter: /^\$app\/(forms|navigation|stores)$/ }, ({ path, ...rest }) => build.resolve(sveltekit_shim_app_specifiers.get(path), rest));
7
- build.onResolve({ filter: /^\$app\/paths$/ }, ({ path }) => ({
8
- path: sveltekit_shim_app_specifiers.get(path),
9
- namespace: 'sveltekit_shim_app_paths',
10
- }));
11
- build.onLoad({ filter: EVERYTHING_MATCHER, namespace: 'sveltekit_shim_app_paths' }, () => ({
12
- contents: render_sveltekit_shim_app_paths(base_url, assets_url),
13
- }));
14
- build.onResolve({ filter: /^\$app\/environment$/ }, ({ path }) => ({
15
- path: sveltekit_shim_app_specifiers.get(path),
16
- namespace: 'sveltekit_shim_app_environment',
17
- }));
18
- build.onLoad({ filter: EVERYTHING_MATCHER, namespace: 'sveltekit_shim_app_environment' }, () => ({
19
- contents: render_sveltekit_shim_app_environment(dev),
20
- }));
21
- },
22
- });
@@ -1,11 +0,0 @@
1
- import type * as esbuild from 'esbuild';
2
- export interface EsbuildPluginSveltekitShimEnvOptions {
3
- dev: boolean;
4
- public_prefix?: string;
5
- private_prefix?: string;
6
- env_dir?: string;
7
- env_files?: Array<string>;
8
- ambient_env?: Record<string, string>;
9
- }
10
- export declare const esbuild_plugin_sveltekit_shim_env: ({ dev, public_prefix, private_prefix, env_dir, env_files, ambient_env, }: EsbuildPluginSveltekitShimEnvOptions) => esbuild.Plugin;
11
- //# sourceMappingURL=esbuild_plugin_sveltekit_shim_env.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esbuild_plugin_sveltekit_shim_env.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/esbuild_plugin_sveltekit_shim_env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAKxC,MAAM,WAAW,oCAAoC;IACpD,GAAG,EAAE,OAAO,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAID,eAAO,MAAM,iCAAiC,GAAI,0EAO/C,oCAAoC,KAAG,OAAO,CAAC,MAuBhD,CAAC"}
@@ -1,18 +0,0 @@
1
- import { render_env_shim_module } from "./sveltekit_shim_env.js";
2
- import { SVELTEKIT_ENV_MATCHER, EVERYTHING_MATCHER } from "./constants.js";
3
- const namespace = 'sveltekit_shim_env';
4
- export const esbuild_plugin_sveltekit_shim_env = ({ dev, public_prefix, private_prefix, env_dir, env_files, ambient_env, }) => ({
5
- name: 'sveltekit_shim_env',
6
- setup: (build) => {
7
- build.onResolve({ filter: SVELTEKIT_ENV_MATCHER }, ({ path }) => ({ path, namespace }));
8
- build.onLoad({ filter: EVERYTHING_MATCHER, namespace }, ({ path }) => {
9
- const matches = SVELTEKIT_ENV_MATCHER.exec(path);
10
- const mode = matches[1];
11
- const visibility = matches[2];
12
- return {
13
- loader: 'ts',
14
- contents: render_env_shim_module(dev, mode, visibility, public_prefix, private_prefix, env_dir, env_files, ambient_env),
15
- };
16
- });
17
- },
18
- });
package/dist/filer.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import type { OmitStrict } from '@fuzdev/fuz_util/types.js';
2
- import type { Logger } from '@fuzdev/fuz_util/log.js';
3
- import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
4
- import type { FileFilter, PathId } from '@fuzdev/fuz_util/path.js';
5
- import { watch_dir, type WatcherChange, type WatchDirOptions } from './watch_dir.ts';
6
- import type { Disknode } from './disknode.ts';
7
- export type OnFilerChange = (change: WatcherChange, disknode: Disknode) => void;
8
- export interface FilerOptions {
9
- watch_dir?: typeof watch_dir;
10
- watch_dir_options?: Partial<OmitStrict<WatchDirOptions, 'on_change'>>;
11
- package_json_cache?: Record<string, PackageJson>;
12
- log?: Logger;
13
- }
14
- export declare class Filer {
15
- #private;
16
- readonly root_dir: PathId;
17
- readonly files: Map<PathId, Disknode>;
18
- constructor(options?: FilerOptions);
19
- get inited(): boolean;
20
- get_by_id: (id: PathId) => Disknode | undefined;
21
- get_or_create: (id: PathId) => Disknode;
22
- filter(predicate: (disknode: Disknode) => boolean): Array<Disknode> | null;
23
- /**
24
- * Initialize the filer to populate files without watching.
25
- * Safe to call multiple times - subsequent calls are no-ops.
26
- * Used by gen files to access the file graph.
27
- */
28
- init(): Promise<void>;
29
- watch(listener: OnFilerChange): Promise<() => void>;
30
- close(): Promise<void>;
31
- }
32
- export declare const filter_dependents: (disknode: Disknode, get_by_id: (id: PathId) => Disknode | undefined, filter?: FileFilter, results?: Set<PathId>, searched?: Set<PathId>, log?: Logger) => Set<PathId>;
33
- //# sourceMappingURL=filer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filer.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/filer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AAI1D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAGjE,OAAO,EACN,SAAS,EAET,KAAK,aAAa,EAClB,KAAK,eAAe,EAEpB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAI5C,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEhF,MAAM,WAAW,YAAY;IAC5B,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;IACtE,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,KAAK;;IACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAG1B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAa;gBAetC,OAAO,GAAE,YAA2B;IAUhD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,SAAS,GAAI,IAAI,MAAM,KAAG,QAAQ,GAAG,SAAS,CAE5C;IAEF,aAAa,GAAI,IAAI,MAAM,KAAG,QAAQ,CAqBpC;IAEF,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI;IAU1E;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsDrB,KAAK,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAmBzD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CA8OtB;AAGD,eAAO,MAAM,iBAAiB,GAC7B,UAAU,QAAQ,EAClB,WAAW,CAAC,EAAE,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,EAC/C,SAAS,UAAU,EACnB,UAAS,GAAG,CAAC,MAAM,CAAa,EAChC,WAAU,GAAG,CAAC,MAAM,CAAa,EACjC,MAAM,MAAM,KACV,GAAG,CAAC,MAAM,CAuBZ,CAAC"}
package/dist/filer.js DELETED
@@ -1,385 +0,0 @@
1
- import { EMPTY_OBJECT } from '@fuzdev/fuz_util/object.js';
2
- import { readFile, stat } from 'node:fs/promises';
3
- import { dirname, resolve } from 'node:path';
4
- import { isBuiltin } from 'node:module';
5
- import { fileURLToPath, pathToFileURL } from 'node:url';
6
- import { UnreachableError } from '@fuzdev/fuz_util/error.js';
7
- import { hash_secure } from '@fuzdev/fuz_util/hash.js';
8
- import { watch_dir, } from "./watch_dir.js";
9
- import { paths } from "./paths.js";
10
- import { parse_imports } from "./parse_imports.js";
11
- import { resolve_specifier } from "./resolve_specifier.js";
12
- import { default_svelte_config } from "./svelte_config.js";
13
- import { map_sveltekit_aliases } from "./sveltekit_helpers.js";
14
- import { SVELTEKIT_GLOBAL_SPECIFIER } from "./constants.js";
15
- const aliases = Object.entries(default_svelte_config.alias);
16
- export class Filer {
17
- root_dir;
18
- // TODO rename everything to `disknode`
19
- files = new Map();
20
- #watch_dir;
21
- #watch_dir_options;
22
- #log;
23
- #listeners = new Set();
24
- #watching;
25
- #initing;
26
- #closing;
27
- #change_queue = [];
28
- #processing_promise = null;
29
- constructor(options = EMPTY_OBJECT) {
30
- this.#watch_dir = options.watch_dir ?? watch_dir;
31
- this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
32
- this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
33
- // TODO for package.json maybe another array of files/dirs to watch to invalidate everything?
34
- // or instead of that, think of taking an array of config objects that can specify invalidation rules,
35
- // so package.json would be configured differently than ./src, and we could add a default with
36
- // package.json/gro.config.ts/tsconfig.json/svelte.config.js/vite.config.ts to invalidate everything
37
- this.#log = options.log;
38
- }
39
- get inited() {
40
- return this.#watching !== undefined;
41
- }
42
- get_by_id = (id) => {
43
- return this.files.get(id);
44
- };
45
- get_or_create = (id) => {
46
- const existing = this.get_by_id(id);
47
- if (existing)
48
- return existing;
49
- const file = {
50
- id,
51
- contents: null,
52
- external: this.#is_external(id), // TODO maybe filter externals by default? the user needs to configure the filer then
53
- ctime: null,
54
- mtime: null,
55
- content_hash: null,
56
- dependents: new Map(),
57
- dependencies: new Map(),
58
- };
59
- this.files.set(id, file);
60
- // Defer external file change notification to avoid reentrancy during queue processing
61
- if (file.external) {
62
- queueMicrotask(() => {
63
- this.#on_change({ type: 'add', path: file.id, is_directory: false });
64
- });
65
- }
66
- return file;
67
- };
68
- filter(predicate) {
69
- let found = null;
70
- for (const disknode of this.files.values()) {
71
- if (predicate(disknode)) {
72
- (found ??= []).push(disknode);
73
- }
74
- }
75
- return found;
76
- }
77
- /**
78
- * Initialize the filer to populate files without watching.
79
- * Safe to call multiple times - subsequent calls are no-ops.
80
- * Used by gen files to access the file graph.
81
- */
82
- async init() {
83
- // if already initing, return the existing promise
84
- if (this.#initing)
85
- return this.#initing;
86
- // if already initialized, just ensure ready
87
- if (this.#watching) {
88
- return this.#watching.init();
89
- }
90
- // start new initialization
91
- this.#initing = this.#init();
92
- try {
93
- await this.#initing;
94
- }
95
- catch (error) {
96
- // use shared cleanup logic
97
- this.#cleanup();
98
- throw error;
99
- }
100
- finally {
101
- this.#initing = undefined;
102
- }
103
- }
104
- async #init() {
105
- const watcher = this.#watch_dir({
106
- ...this.#watch_dir_options,
107
- dir: this.root_dir,
108
- on_change: this.#on_change,
109
- });
110
- try {
111
- await watcher.init();
112
- // Wait for any queued changes from init to be processed
113
- await this.#drain_queue();
114
- // check if close() was called during init
115
- if (this.#closing) {
116
- await watcher.close();
117
- return;
118
- }
119
- // only set after successful init and not closing
120
- this.#watching = watcher;
121
- }
122
- catch (error) {
123
- // clean up watcher on error, but don't let close error mask init error
124
- try {
125
- await watcher.close();
126
- }
127
- catch {
128
- // ignore close errors - init error is more important
129
- }
130
- throw error;
131
- }
132
- }
133
- async watch(listener) {
134
- await this.#add_listener(listener);
135
- return () => {
136
- this.#remove_listener(listener);
137
- };
138
- }
139
- /**
140
- * Internal cleanup of all state - can be called safely from anywhere
141
- */
142
- #cleanup() {
143
- this.#listeners.clear();
144
- this.files.clear();
145
- this.#watching = undefined;
146
- this.#change_queue = [];
147
- this.#processing_promise = null;
148
- // #initing is handled in finally block of init()
149
- }
150
- close() {
151
- // if already closing, return existing promise
152
- if (this.#closing)
153
- return this.#closing;
154
- // if already closed and not initing, nothing to do
155
- if (!this.#watching && !this.#initing)
156
- return Promise.resolve();
157
- // start new close operation
158
- const closing = this.#close();
159
- this.#closing = closing;
160
- // Clean up after completion, but don't change the returned promise
161
- // Use void to ensure we don't accidentally return the .then() promise
162
- void closing.then(() => {
163
- this.#closing = undefined;
164
- }, () => {
165
- this.#closing = undefined;
166
- });
167
- return this.#closing;
168
- }
169
- async #close() {
170
- // wait for any pending initialization to complete
171
- if (this.#initing) {
172
- try {
173
- await this.#initing;
174
- }
175
- catch {
176
- // ignore errors during close
177
- }
178
- }
179
- // close watcher if it exists
180
- if (this.#watching) {
181
- await this.#watching.close();
182
- }
183
- // clean up all state
184
- this.#cleanup();
185
- }
186
- async #update(id) {
187
- const file = this.get_or_create(id);
188
- let stats = null;
189
- let new_contents = null; // TODO need to lazily load contents, probably turn `Disknode` into a class
190
- try {
191
- [stats, new_contents] = await Promise.all([stat(id), readFile(id, 'utf8')]);
192
- }
193
- catch (error) {
194
- const code = error.code;
195
- // Treat file as deleted/inaccessible for common error codes
196
- if (code === 'ENOENT' || code === 'EACCES' || code === 'EPERM') {
197
- // File doesn't exist or is inaccessible, treat as deleted
198
- }
199
- else {
200
- throw error;
201
- }
202
- }
203
- // Compute hash for new contents
204
- const new_hash = new_contents !== null ? await hash_secure(new_contents) : null;
205
- file.ctime = stats?.ctimeMs ?? null;
206
- file.mtime = stats?.mtimeMs ?? null;
207
- // Use hash comparison for change detection (content-based, not mtime-based)
208
- if (file.content_hash === new_hash) {
209
- return null;
210
- }
211
- file.contents = new_contents;
212
- file.content_hash = new_hash;
213
- const dir = dirname(file.id);
214
- const dependencies_before = new Set(file.dependencies.keys());
215
- const dependencies_removed = new Set(dependencies_before);
216
- let imported = [];
217
- if (file.contents) {
218
- try {
219
- imported = parse_imports(file.id, file.contents);
220
- }
221
- catch (error) {
222
- this.#log?.error('[filer] Failed to parse imports', file.id, error);
223
- }
224
- }
225
- for (const specifier of imported) {
226
- if (SVELTEKIT_GLOBAL_SPECIFIER.test(specifier))
227
- continue;
228
- const path = map_sveltekit_aliases(specifier, aliases);
229
- let path_id;
230
- // TODO can we replace `resolve_specifier` with `import.meta.resolve` completely now outside of esbuild plugins?
231
- if (path[0] === '.' || path[0] === '/') {
232
- const resolved = await resolve_specifier(path, dir); // eslint-disable-line no-await-in-loop
233
- path_id = resolved.path_id;
234
- }
235
- else {
236
- if (isBuiltin(path))
237
- continue;
238
- const file_url = pathToFileURL(file.id);
239
- try {
240
- path_id = fileURLToPath(import.meta.resolve(path, file_url.href));
241
- }
242
- catch (error) {
243
- // if resolving fails for any reason, just log and ignore it
244
- this.#log?.error('[filer] failed to resolve path', path, file_url.href, error);
245
- continue;
246
- }
247
- }
248
- dependencies_removed.delete(path_id);
249
- if (!dependencies_before.has(path_id)) {
250
- const d = this.get_or_create(path_id);
251
- file.dependencies.set(d.id, d);
252
- d.dependents.set(file.id, file);
253
- }
254
- }
255
- // update any removed dependencies
256
- for (const dependency_removed of dependencies_removed) {
257
- file.dependencies.delete(dependency_removed);
258
- const dependency_removed_file = this.get_or_create(dependency_removed);
259
- dependency_removed_file.dependents.delete(file.id);
260
- }
261
- return file;
262
- }
263
- #remove(id) {
264
- const file = this.get_by_id(id);
265
- if (!file)
266
- return null; // this is safe because the object would exist if any other file referenced it as a dependency or dependent
267
- file.contents = null; // clear contents in case it gets re-added later, we want the change to be detected
268
- file.content_hash = null; // clear hash so re-add detects the change
269
- file.dependencies.clear();
270
- // keep the file in memory if other files still depend on it
271
- if (file.dependents.size === 0) {
272
- this.files.delete(id);
273
- }
274
- return file;
275
- }
276
- #sync_listener_with_files(listener) {
277
- for (const disknode of this.files.values()) {
278
- try {
279
- listener({ type: 'add', path: disknode.id, is_directory: false }, disknode);
280
- }
281
- catch (error) {
282
- this.#log?.error('[filer] Listener error during sync:', error);
283
- }
284
- }
285
- }
286
- #notify_change(change, disknode) {
287
- for (const listener of this.#listeners) {
288
- try {
289
- listener(change, disknode);
290
- }
291
- catch (error) {
292
- this.#log?.error('[filer] Listener error during change notification:', error);
293
- }
294
- }
295
- }
296
- async #add_listener(listener) {
297
- this.#listeners.add(listener);
298
- // ensure initialized
299
- await this.init();
300
- // notify of existing files
301
- this.#sync_listener_with_files(listener);
302
- }
303
- #remove_listener(listener) {
304
- this.#listeners.delete(listener);
305
- // keep watching active even with no listeners, only close() tears down
306
- }
307
- async #drain_queue() {
308
- // Wait for queue to be empty and no active processing
309
- while (this.#change_queue.length > 0 || this.#processing_promise) {
310
- await this.#process_queue(); // eslint-disable-line no-await-in-loop
311
- }
312
- }
313
- async #process_queue() {
314
- // If already processing, return the existing promise
315
- if (this.#processing_promise)
316
- return this.#processing_promise;
317
- // Create and track the processing promise
318
- this.#processing_promise = this.#do_process_queue();
319
- try {
320
- await this.#processing_promise;
321
- }
322
- finally {
323
- this.#processing_promise = null;
324
- }
325
- }
326
- async #do_process_queue() {
327
- while (this.#change_queue.length > 0) {
328
- const change = this.#change_queue.shift();
329
- if (this.#closing)
330
- continue; // ignore changes during close
331
- if (change.is_directory)
332
- continue; // TODO manage directories?
333
- let disknode;
334
- switch (change.type) {
335
- case 'add':
336
- case 'update': {
337
- disknode = await this.#update(change.path); // eslint-disable-line no-await-in-loop
338
- break;
339
- }
340
- case 'delete': {
341
- disknode = this.#remove(change.path);
342
- break;
343
- }
344
- default:
345
- throw new UnreachableError(change.type);
346
- }
347
- if (disknode && this.#listeners.size > 0) {
348
- this.#notify_change(change, disknode);
349
- }
350
- }
351
- }
352
- #on_change = (change) => {
353
- // Enqueue the change (sync callback from chokidar)
354
- this.#change_queue.push(change);
355
- // Start processing if not already running
356
- void this.#process_queue();
357
- };
358
- #is_external(id) {
359
- const { filter } = this.#watch_dir_options;
360
- return !id.startsWith(this.root_dir + '/') || (!!filter && !filter(id, false));
361
- }
362
- }
363
- // TODO maybe `Disknode` class?
364
- export const filter_dependents = (disknode, get_by_id, filter, results = new Set(), searched = new Set(), log) => {
365
- // Use iterative approach to avoid stack overflow on deep dependency trees
366
- const stack = [disknode];
367
- while (stack.length > 0) {
368
- const current = stack.pop();
369
- for (const dependent_id of current.dependents.keys()) {
370
- if (searched.has(dependent_id))
371
- continue;
372
- searched.add(dependent_id);
373
- if (!filter || filter(dependent_id)) {
374
- results.add(dependent_id);
375
- }
376
- const dependent_disknode = get_by_id(dependent_id);
377
- if (!dependent_disknode) {
378
- log?.warn(`[filer.filter_dependents] dependent source file ${dependent_id} not found for ${current.id}`);
379
- continue;
380
- }
381
- stack.push(dependent_disknode);
382
- }
383
- }
384
- return results;
385
- };
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- import { type Task } from './task.ts';
3
- /** @nodocs */
4
- export declare const Args: z.ZodObject<{
5
- _: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
- check: z.ZodDefault<z.ZodBoolean>;
7
- }, z.core.$strict>;
8
- export type Args = z.infer<typeof Args>;
9
- /** @nodocs */
10
- export declare const task: Task<Args>;
11
- //# sourceMappingURL=format.task.d.ts.map