@useavalon/avalon 0.1.13 → 0.1.15

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 (230) hide show
  1. package/dist/mod.js +1 -0
  2. package/dist/src/build/integration-bundler-plugin.js +1 -0
  3. package/dist/src/build/integration-config.js +1 -0
  4. package/dist/src/build/integration-detection-plugin.js +1 -0
  5. package/dist/src/build/integration-resolver-plugin.js +1 -0
  6. package/dist/src/build/island-manifest.js +1 -0
  7. package/dist/src/build/island-types-generator.js +5 -0
  8. package/dist/src/build/mdx-island-transform.js +2 -0
  9. package/dist/src/build/mdx-plugin.js +1 -0
  10. package/dist/src/build/page-island-transform.js +3 -0
  11. package/dist/src/build/prop-extractors/index.js +1 -0
  12. package/dist/src/build/prop-extractors/lit.js +1 -0
  13. package/dist/src/build/prop-extractors/qwik.js +1 -0
  14. package/dist/src/build/prop-extractors/solid.js +1 -0
  15. package/dist/src/build/prop-extractors/svelte.js +1 -0
  16. package/dist/src/build/prop-extractors/vue.js +1 -0
  17. package/dist/src/build/sidecar-file-manager.js +1 -0
  18. package/dist/src/build/sidecar-renderer.js +6 -0
  19. package/dist/src/client/adapters/index.js +1 -0
  20. package/dist/src/client/components.js +1 -0
  21. package/dist/src/client/css-hmr-handler.js +1 -0
  22. package/dist/src/client/framework-adapter.js +13 -0
  23. package/dist/src/client/hmr-coordinator.js +1 -0
  24. package/dist/src/client/hmr-error-overlay.js +214 -0
  25. package/dist/src/client/main.js +39 -0
  26. package/dist/src/components/Image.js +1 -0
  27. package/dist/src/components/IslandErrorBoundary.js +1 -0
  28. package/dist/src/components/LayoutDataErrorBoundary.js +1 -0
  29. package/dist/src/components/LayoutErrorBoundary.js +1 -0
  30. package/dist/src/components/PersistentIsland.js +1 -0
  31. package/dist/src/components/StreamingErrorBoundary.js +1 -0
  32. package/dist/src/components/StreamingLayout.js +29 -0
  33. package/dist/src/core/components/component-analyzer.js +1 -0
  34. package/dist/src/core/components/component-detection.js +5 -0
  35. package/dist/src/core/components/enhanced-framework-detector.js +1 -0
  36. package/dist/src/core/components/framework-registry.js +1 -0
  37. package/dist/src/core/content/mdx-processor.js +1 -0
  38. package/dist/src/core/integrations/index.js +1 -0
  39. package/dist/src/core/integrations/loader.js +1 -0
  40. package/dist/src/core/integrations/registry.js +1 -0
  41. package/dist/src/core/islands/island-persistence.js +1 -0
  42. package/dist/src/core/islands/island-state-serializer.js +1 -0
  43. package/dist/src/core/islands/persistent-island-context.js +1 -0
  44. package/dist/src/core/islands/use-persistent-state.js +1 -0
  45. package/dist/src/core/layout/enhanced-layout-resolver.js +1 -0
  46. package/dist/src/core/layout/layout-cache-manager.js +1 -0
  47. package/dist/src/core/layout/layout-composer.js +1 -0
  48. package/dist/src/core/layout/layout-data-loader.js +1 -0
  49. package/dist/src/core/layout/layout-discovery.js +1 -0
  50. package/dist/src/core/layout/layout-matcher.js +1 -0
  51. package/dist/src/core/layout/layout-types.js +1 -0
  52. package/dist/src/core/modules/framework-module-resolver.js +1 -0
  53. package/dist/src/islands/component-analysis.js +1 -0
  54. package/dist/src/islands/css-utils.js +17 -0
  55. package/dist/src/islands/discovery/index.js +1 -0
  56. package/dist/src/islands/discovery/registry.js +1 -0
  57. package/dist/src/islands/discovery/resolver.js +2 -0
  58. package/dist/src/islands/discovery/scanner.js +1 -0
  59. package/dist/src/islands/discovery/types.js +1 -0
  60. package/dist/src/islands/discovery/validator.js +18 -0
  61. package/dist/src/islands/discovery/watcher.js +1 -0
  62. package/dist/src/islands/framework-detection.js +1 -0
  63. package/dist/src/islands/integration-loader.js +1 -0
  64. package/dist/src/islands/island.js +1 -0
  65. package/dist/src/islands/render-cache.js +1 -0
  66. package/dist/src/islands/types.js +1 -0
  67. package/dist/src/islands/universal-css-collector.js +5 -0
  68. package/dist/src/islands/universal-head-collector.js +2 -0
  69. package/dist/src/layout-system.js +1 -0
  70. package/dist/src/middleware/discovery.js +1 -0
  71. package/dist/src/middleware/executor.js +1 -0
  72. package/dist/src/middleware/index.js +1 -0
  73. package/dist/src/middleware/types.js +1 -0
  74. package/dist/src/nitro/build-config.js +1 -0
  75. package/dist/src/nitro/config.js +1 -0
  76. package/dist/src/nitro/error-handler.js +198 -0
  77. package/dist/src/nitro/index.js +1 -0
  78. package/dist/src/nitro/island-manifest.js +2 -0
  79. package/dist/src/nitro/middleware-adapter.js +1 -0
  80. package/dist/src/nitro/renderer.js +183 -0
  81. package/dist/src/nitro/route-discovery.js +1 -0
  82. package/dist/src/nitro/types.js +1 -0
  83. package/dist/src/render/collect-css.js +3 -0
  84. package/dist/src/render/error-pages.js +48 -0
  85. package/dist/src/render/isolated-ssr-renderer.js +1 -0
  86. package/dist/src/render/ssr.js +90 -0
  87. package/dist/src/schemas/api.js +1 -0
  88. package/dist/src/schemas/core.js +1 -0
  89. package/dist/src/schemas/index.js +1 -0
  90. package/dist/src/schemas/layout.js +1 -0
  91. package/dist/src/schemas/routing/index.js +1 -0
  92. package/dist/src/schemas/routing.js +1 -0
  93. package/dist/src/types/as-island.js +1 -0
  94. package/dist/src/types/layout.js +1 -0
  95. package/dist/src/types/routing.js +1 -0
  96. package/dist/src/types/types.js +1 -0
  97. package/dist/src/utils/dev-logger.js +12 -0
  98. package/dist/src/utils/fs.js +1 -0
  99. package/dist/src/vite-plugin/auto-discover.js +1 -0
  100. package/dist/src/vite-plugin/config.js +1 -0
  101. package/dist/src/vite-plugin/errors.js +1 -0
  102. package/dist/src/vite-plugin/image-optimization.js +45 -0
  103. package/dist/src/vite-plugin/integration-activator.js +1 -0
  104. package/dist/src/vite-plugin/island-sidecar-plugin.js +1 -0
  105. package/dist/src/vite-plugin/module-discovery.js +1 -0
  106. package/dist/src/vite-plugin/nitro-integration.js +42 -0
  107. package/dist/src/vite-plugin/plugin.js +1 -0
  108. package/dist/src/vite-plugin/types.js +1 -0
  109. package/dist/src/vite-plugin/validation.js +2 -0
  110. package/package.json +14 -20
  111. package/mod.ts +0 -302
  112. package/src/build/integration-bundler-plugin.ts +0 -116
  113. package/src/build/integration-config.ts +0 -168
  114. package/src/build/integration-detection-plugin.ts +0 -117
  115. package/src/build/integration-resolver-plugin.ts +0 -90
  116. package/src/build/island-manifest.ts +0 -269
  117. package/src/build/island-types-generator.ts +0 -476
  118. package/src/build/mdx-island-transform.ts +0 -464
  119. package/src/build/mdx-plugin.ts +0 -98
  120. package/src/build/page-island-transform.ts +0 -598
  121. package/src/build/prop-extractors/index.ts +0 -21
  122. package/src/build/prop-extractors/lit.ts +0 -140
  123. package/src/build/prop-extractors/qwik.ts +0 -16
  124. package/src/build/prop-extractors/solid.ts +0 -125
  125. package/src/build/prop-extractors/svelte.ts +0 -194
  126. package/src/build/prop-extractors/vue.ts +0 -111
  127. package/src/build/sidecar-file-manager.ts +0 -104
  128. package/src/build/sidecar-renderer.ts +0 -30
  129. package/src/client/adapters/index.ts +0 -21
  130. package/src/client/components.ts +0 -35
  131. package/src/client/css-hmr-handler.ts +0 -344
  132. package/src/client/framework-adapter.ts +0 -462
  133. package/src/client/hmr-coordinator.ts +0 -396
  134. package/src/client/hmr-error-overlay.js +0 -533
  135. package/src/client/main.js +0 -824
  136. package/src/components/Image.tsx +0 -123
  137. package/src/components/IslandErrorBoundary.tsx +0 -145
  138. package/src/components/LayoutDataErrorBoundary.tsx +0 -141
  139. package/src/components/LayoutErrorBoundary.tsx +0 -127
  140. package/src/components/PersistentIsland.tsx +0 -52
  141. package/src/components/StreamingErrorBoundary.tsx +0 -233
  142. package/src/components/StreamingLayout.tsx +0 -538
  143. package/src/core/components/component-analyzer.ts +0 -192
  144. package/src/core/components/component-detection.ts +0 -508
  145. package/src/core/components/enhanced-framework-detector.ts +0 -500
  146. package/src/core/components/framework-registry.ts +0 -563
  147. package/src/core/content/mdx-processor.ts +0 -46
  148. package/src/core/integrations/index.ts +0 -19
  149. package/src/core/integrations/loader.ts +0 -125
  150. package/src/core/integrations/registry.ts +0 -175
  151. package/src/core/islands/island-persistence.ts +0 -325
  152. package/src/core/islands/island-state-serializer.ts +0 -258
  153. package/src/core/islands/persistent-island-context.tsx +0 -80
  154. package/src/core/islands/use-persistent-state.ts +0 -68
  155. package/src/core/layout/enhanced-layout-resolver.ts +0 -322
  156. package/src/core/layout/layout-cache-manager.ts +0 -485
  157. package/src/core/layout/layout-composer.ts +0 -357
  158. package/src/core/layout/layout-data-loader.ts +0 -516
  159. package/src/core/layout/layout-discovery.ts +0 -243
  160. package/src/core/layout/layout-matcher.ts +0 -299
  161. package/src/core/layout/layout-types.ts +0 -110
  162. package/src/core/modules/framework-module-resolver.ts +0 -273
  163. package/src/islands/component-analysis.ts +0 -213
  164. package/src/islands/css-utils.ts +0 -565
  165. package/src/islands/discovery/index.ts +0 -80
  166. package/src/islands/discovery/registry.ts +0 -340
  167. package/src/islands/discovery/resolver.ts +0 -477
  168. package/src/islands/discovery/scanner.ts +0 -386
  169. package/src/islands/discovery/types.ts +0 -117
  170. package/src/islands/discovery/validator.ts +0 -544
  171. package/src/islands/discovery/watcher.ts +0 -368
  172. package/src/islands/framework-detection.ts +0 -428
  173. package/src/islands/integration-loader.ts +0 -490
  174. package/src/islands/island.tsx +0 -565
  175. package/src/islands/render-cache.ts +0 -550
  176. package/src/islands/types.ts +0 -80
  177. package/src/islands/universal-css-collector.ts +0 -157
  178. package/src/islands/universal-head-collector.ts +0 -137
  179. package/src/layout-system.ts +0 -218
  180. package/src/middleware/discovery.ts +0 -268
  181. package/src/middleware/executor.ts +0 -315
  182. package/src/middleware/index.ts +0 -76
  183. package/src/middleware/types.ts +0 -99
  184. package/src/nitro/build-config.ts +0 -576
  185. package/src/nitro/config.ts +0 -483
  186. package/src/nitro/error-handler.ts +0 -636
  187. package/src/nitro/index.ts +0 -173
  188. package/src/nitro/island-manifest.ts +0 -584
  189. package/src/nitro/middleware-adapter.ts +0 -260
  190. package/src/nitro/renderer.ts +0 -1471
  191. package/src/nitro/route-discovery.ts +0 -439
  192. package/src/nitro/types.ts +0 -321
  193. package/src/render/collect-css.ts +0 -198
  194. package/src/render/error-pages.ts +0 -79
  195. package/src/render/isolated-ssr-renderer.ts +0 -654
  196. package/src/render/ssr.ts +0 -1030
  197. package/src/schemas/api.ts +0 -30
  198. package/src/schemas/core.ts +0 -64
  199. package/src/schemas/index.ts +0 -212
  200. package/src/schemas/layout.ts +0 -279
  201. package/src/schemas/routing/index.ts +0 -38
  202. package/src/schemas/routing.ts +0 -376
  203. package/src/types/as-island.ts +0 -20
  204. package/src/types/layout.ts +0 -285
  205. package/src/types/routing.ts +0 -555
  206. package/src/types/types.ts +0 -5
  207. package/src/utils/dev-logger.ts +0 -299
  208. package/src/utils/fs.ts +0 -151
  209. package/src/vite-plugin/auto-discover.ts +0 -551
  210. package/src/vite-plugin/config.ts +0 -266
  211. package/src/vite-plugin/errors.ts +0 -127
  212. package/src/vite-plugin/image-optimization.ts +0 -156
  213. package/src/vite-plugin/integration-activator.ts +0 -126
  214. package/src/vite-plugin/island-sidecar-plugin.ts +0 -176
  215. package/src/vite-plugin/module-discovery.ts +0 -189
  216. package/src/vite-plugin/nitro-integration.ts +0 -1354
  217. package/src/vite-plugin/plugin.ts +0 -403
  218. package/src/vite-plugin/types.ts +0 -327
  219. package/src/vite-plugin/validation.ts +0 -228
  220. /package/{src → dist/src}/client/types/framework-runtime.d.ts +0 -0
  221. /package/{src → dist/src}/client/types/vite-hmr.d.ts +0 -0
  222. /package/{src → dist/src}/client/types/vite-virtual-modules.d.ts +0 -0
  223. /package/{src → dist/src}/layout-system.d.ts +0 -0
  224. /package/{src → dist/src}/types/image.d.ts +0 -0
  225. /package/{src → dist/src}/types/index.d.ts +0 -0
  226. /package/{src → dist/src}/types/island-jsx.d.ts +0 -0
  227. /package/{src → dist/src}/types/island-prop.d.ts +0 -0
  228. /package/{src → dist/src}/types/mdx.d.ts +0 -0
  229. /package/{src → dist/src}/types/urlpattern.d.ts +0 -0
  230. /package/{src → dist/src}/types/vite-env.d.ts +0 -0
@@ -1,299 +0,0 @@
1
- /**
2
- * Dev-Only Logging Utilities
3
- *
4
- * These functions provide environment-aware logging that only outputs in development mode.
5
- * In production (NODE_ENV=production), all logging is suppressed for better performance.
6
- *
7
- * @module dev-logger
8
- */
9
-
10
- // ============================================================================
11
- // Environment Detection
12
- // ============================================================================
13
-
14
- /**
15
- * Check if we're in development mode
16
- * Returns true if NODE_ENV is not set to "production"
17
- */
18
- export function isDev(): boolean {
19
- try {
20
- return process.env.NODE_ENV !== "production";
21
- } catch {
22
- return true; // Default to dev mode if we can't check
23
- }
24
- }
25
-
26
- /**
27
- * Check if verbose logging is enabled
28
- * Returns true only if AVALON_VERBOSE=1 is set
29
- */
30
- export function isVerbose(): boolean {
31
- try {
32
- return process.env.AVALON_VERBOSE === "1";
33
- } catch {
34
- return false;
35
- }
36
- }
37
-
38
- // ============================================================================
39
- // Dev-Only Logging Functions
40
- // ============================================================================
41
-
42
- /**
43
- * Log a message only in development mode AND when AVALON_VERBOSE=1 is set.
44
- * By default this is a no-op — set AVALON_VERBOSE=1 to enable diagnostic output.
45
- *
46
- * @param args - Arguments to pass to console.log
47
- */
48
- export function devLog(...args: unknown[]): void {
49
- if (isDev() && isVerbose()) {
50
- console.log(...args);
51
- }
52
- }
53
-
54
- /**
55
- * Log a warning only in development mode
56
- * In production, this is a no-op for performance
57
- *
58
- * @param args - Arguments to pass to console.warn
59
- */
60
- export function devWarn(...args: unknown[]): void {
61
- if (isDev()) {
62
- console.warn(...args);
63
- }
64
- }
65
-
66
- /**
67
- * Log an error only in development mode
68
- * In production, this is a no-op for performance
69
- *
70
- * @param args - Arguments to pass to console.error
71
- */
72
- export function devError(...args: unknown[]): void {
73
- if (isDev()) {
74
- console.error(...args);
75
- }
76
- }
77
-
78
- // ============================================================================
79
- // Performance Tracking
80
- // ============================================================================
81
-
82
- /** Default threshold for slow render warnings (in milliseconds) */
83
- const DEFAULT_SLOW_RENDER_THRESHOLD = 100;
84
-
85
- /**
86
- * Log render timing information for an island component
87
- * Only logs in development mode AND when AVALON_VERBOSE=1 is set
88
- * Warns when render time exceeds the threshold
89
- *
90
- * @param src - The island source path
91
- * @param durationMs - The render duration in milliseconds
92
- * @param threshold - Optional threshold for slow render warning (default: 100ms)
93
- */
94
- export function logRenderTiming(
95
- src: string,
96
- durationMs: number,
97
- threshold: number = DEFAULT_SLOW_RENDER_THRESHOLD
98
- ): void {
99
- if (!isDev() || !isVerbose()) return;
100
-
101
- if (durationMs > threshold) {
102
- console.warn(`⚠️ Slow island render: ${src} took ${durationMs.toFixed(2)}ms`);
103
- } else {
104
- console.log(`🏝️ ${src} rendered in ${durationMs.toFixed(2)}ms`);
105
- }
106
- }
107
-
108
- /**
109
- * Log a cache hit event (dev mode only)
110
- *
111
- * @param cacheType - The type of cache (e.g., 'analysis', 'path', 'framework')
112
- * @param key - The cache key that was hit
113
- */
114
- export function logCacheHit(cacheType: string, key: string): void {
115
- if (!isDev() || !isVerbose()) return;
116
- console.log(`📦 Cache HIT [${cacheType}]: ${key}`);
117
- }
118
-
119
- /**
120
- * Log a cache miss event (dev mode only)
121
- *
122
- * @param cacheType - The type of cache (e.g., 'analysis', 'path', 'framework')
123
- * @param key - The cache key that was missed
124
- */
125
- export function logCacheMiss(cacheType: string, key: string): void {
126
- if (!isDev() || !isVerbose()) return;
127
- console.log(`📭 Cache MISS [${cacheType}]: ${key}`);
128
- }
129
-
130
- // ============================================================================
131
- // DevLogger Class (for Development Server UI)
132
- // ============================================================================
133
-
134
- const AVALON_ASCII = `
135
- █████╗ ██╗ ██╗ █████╗ ██╗ ██████╗ ███╗ ██╗
136
- ██╔══██╗██║ ██║██╔══██╗██║ ██╔═══██╗████╗ ██║
137
- ███████║██║ ██║███████║██║ ██║ ██║██╔██╗ ██║
138
- ██╔══██║╚██╗ ██╔╝██╔══██║██║ ██║ ██║██║╚██╗██║
139
- ██║ ██║ ╚████╔╝ ██║ ██║███████╗╚██████╔╝██║ ╚████║
140
- ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═══╝
141
- `;
142
-
143
- const COLORS = {
144
- reset: '\x1b[0m',
145
- cyan: '\x1b[36m',
146
- green: '\x1b[32m',
147
- yellow: '\x1b[33m',
148
- blue: '\x1b[34m',
149
- magenta: '\x1b[35m',
150
- gray: '\x1b[90m',
151
- bold: '\x1b[1m',
152
- };
153
-
154
- const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
155
-
156
- interface DevTask {
157
- name: string;
158
- status: 'pending' | 'running' | 'done';
159
- startTime?: number;
160
- }
161
-
162
- export class DevLogger {
163
- private readonly tasks: Map<string, DevTask> = new Map();
164
- private spinnerInterval?: ReturnType<typeof setInterval>;
165
- private currentFrame = 0;
166
- private readonly startTime = Date.now();
167
- private readonly originalConsoleLog: typeof console.log;
168
- private readonly originalConsoleWarn: typeof console.warn;
169
- private readonly originalConsoleError: typeof console.error;
170
- private readonly suppressedLogs: string[] = [];
171
- private readonly headerLines: number = 0;
172
-
173
- constructor() {
174
- this.originalConsoleLog = console.log;
175
- this.originalConsoleWarn = console.warn;
176
- this.originalConsoleError = console.error;
177
-
178
- this.suppressConsole();
179
-
180
- // Clear screen once at start
181
- process.stdout.write('\x1b[2J\x1b[H');
182
-
183
- const header = COLORS.cyan + AVALON_ASCII + COLORS.reset + '\n' +
184
- COLORS.gray + ' Development Server' + COLORS.reset + '\n\n';
185
- this.headerLines = AVALON_ASCII.split('\n').length + 2;
186
-
187
- process.stdout.write(header);
188
- }
189
-
190
- private suppressConsole() {
191
- console.log = (...args: unknown[]) => {
192
- this.suppressedLogs.push(args.map(String).join(' '));
193
- };
194
- console.warn = (...args: unknown[]) => {
195
- this.suppressedLogs.push('[WARN] ' + args.map(String).join(' '));
196
- };
197
- console.error = this.originalConsoleError;
198
- }
199
-
200
- restoreConsole() {
201
- console.log = this.originalConsoleLog;
202
- console.warn = this.originalConsoleWarn;
203
- console.error = this.originalConsoleError;
204
- }
205
-
206
-
207
-
208
- addTask(id: string, name: string) {
209
- this.tasks.set(id, { name, status: 'pending' });
210
- this.render();
211
- }
212
-
213
- startTask(id: string) {
214
- const task = this.tasks.get(id);
215
- if (task) {
216
- task.status = 'running';
217
- task.startTime = Date.now();
218
- this.render();
219
- }
220
- }
221
-
222
- completeTask(id: string) {
223
- const task = this.tasks.get(id);
224
- if (task) {
225
- task.status = 'done';
226
- this.render();
227
- }
228
- }
229
-
230
-
231
- private render() {
232
- let currentTask: DevTask | null = null;
233
- for (const task of this.tasks.values()) {
234
- if (task.status === 'running') {
235
- currentTask = task;
236
- break;
237
- }
238
- }
239
-
240
- // Use carriage return to overwrite the same line
241
- let output = '\r'; // Return to start of line
242
-
243
- if (currentTask) {
244
- const spinner = COLORS.cyan + SPINNER_FRAMES[this.currentFrame] + COLORS.reset;
245
- output += `${spinner} ${currentTask.name}`;
246
- } else {
247
- output += `${COLORS.gray}Initializing...${COLORS.reset}`;
248
- }
249
-
250
- // Clear to end of line
251
- output += '\x1b[K';
252
-
253
- process.stdout.write(output);
254
- }
255
-
256
- startSpinner() {
257
- this.spinnerInterval = setInterval(() => {
258
- this.currentFrame = (this.currentFrame + 1) % SPINNER_FRAMES.length;
259
- this.render();
260
- }, 100);
261
- }
262
-
263
- stopSpinner() {
264
- if (this.spinnerInterval) {
265
- clearInterval(this.spinnerInterval);
266
- }
267
- }
268
-
269
- finish(serverUrl: string, viteUrl?: string, hmrUrl?: string) {
270
- this.stopSpinner();
271
-
272
- // Clear the status line
273
- let output = `\x1b[${this.headerLines + 1};0H`;
274
- output += '\x1b[J'; // Clear from cursor down
275
- process.stdout.write(output);
276
-
277
- const elapsed = ((Date.now() - this.startTime) / 1000).toFixed(1);
278
-
279
- this.originalConsoleLog('');
280
- this.originalConsoleLog(COLORS.green + COLORS.bold + '✨ Server ready!' + COLORS.reset);
281
- this.originalConsoleLog('');
282
- this.originalConsoleLog(COLORS.cyan + ' ➜ ' + COLORS.reset + COLORS.bold + 'Local: ' + COLORS.reset + COLORS.cyan + serverUrl + COLORS.reset);
283
-
284
- if (viteUrl) {
285
- this.originalConsoleLog(COLORS.cyan + ' ➜ ' + COLORS.reset + COLORS.bold + 'Vite: ' + COLORS.reset + COLORS.gray + viteUrl + COLORS.reset);
286
- }
287
-
288
- if (hmrUrl) {
289
- this.originalConsoleLog(COLORS.cyan + ' ➜ ' + COLORS.reset + COLORS.bold + 'HMR: ' + COLORS.reset + COLORS.gray + hmrUrl + COLORS.reset);
290
- }
291
-
292
- this.originalConsoleLog('');
293
- this.originalConsoleLog(COLORS.gray + ` Ready in ${elapsed}s` + COLORS.reset);
294
- this.originalConsoleLog('');
295
- this.originalConsoleLog(COLORS.gray + ' Press Ctrl+C to stop' + COLORS.reset);
296
- this.originalConsoleLog('');
297
-
298
- }
299
- }
package/src/utils/fs.ts DELETED
@@ -1,151 +0,0 @@
1
- /**
2
- * Filesystem utilities for Avalon.
3
- * Provides Node.js-compatible implementations of common filesystem
4
- * functions used throughout the codebase.
5
- */
6
-
7
- import { readdirSync, statSync } from "node:fs";
8
- import { join } from "node:path";
9
-
10
- export interface WalkEntry {
11
- path: string;
12
- name: string;
13
- isFile: boolean;
14
- isDirectory: boolean;
15
- isSymlink: boolean;
16
- }
17
-
18
- export interface WalkOptions {
19
- maxDepth?: number;
20
- includeFiles?: boolean;
21
- includeDirs?: boolean;
22
- includeSymlinks?: boolean;
23
- match?: RegExp[];
24
- skip?: RegExp[];
25
- exts?: string[];
26
- }
27
-
28
- /**
29
- * Walks a directory tree yielding entries, compatible with @std/fs walk().
30
- */
31
- export async function* walk(
32
- root: string,
33
- options: WalkOptions = {},
34
- ): AsyncIterableIterator<WalkEntry> {
35
- const {
36
- maxDepth = Infinity,
37
- includeFiles = true,
38
- includeDirs = true,
39
- exts,
40
- match,
41
- skip,
42
- } = options;
43
-
44
- yield* walkSync(root, 0, { maxDepth, includeFiles, includeDirs, exts, match, skip });
45
- }
46
-
47
- interface WalkSyncState {
48
- maxDepth: number;
49
- includeFiles: boolean;
50
- includeDirs: boolean;
51
- exts?: string[];
52
- match?: RegExp[];
53
- skip?: RegExp[];
54
- }
55
-
56
- function matchesFile(name: string, fullPath: string, opts: WalkSyncState): boolean {
57
- if (opts.exts && !opts.exts.some((ext) => name.endsWith(ext))) return false;
58
- if (opts.match && !opts.match.some((r) => r.test(fullPath))) return false;
59
- return true;
60
- }
61
-
62
- function matchesDir(fullPath: string, match?: RegExp[]): boolean {
63
- return !match || match.some((r) => r.test(fullPath));
64
- }
65
-
66
- function* walkSync(
67
- dir: string,
68
- depth: number,
69
- opts: WalkSyncState,
70
- ): Generator<WalkEntry> {
71
- if (depth > opts.maxDepth) return;
72
-
73
- let entries;
74
- try {
75
- entries = readdirSync(dir, { withFileTypes: true });
76
- } catch {
77
- return;
78
- }
79
-
80
- for (const entry of entries) {
81
- const fullPath = join(dir, entry.name);
82
-
83
- if (opts.skip?.some((r) => r.test(fullPath))) continue;
84
-
85
- const walkEntry: WalkEntry = {
86
- path: fullPath,
87
- name: entry.name,
88
- isFile: entry.isFile(),
89
- isDirectory: entry.isDirectory(),
90
- isSymlink: entry.isSymbolicLink(),
91
- };
92
-
93
- if (entry.isDirectory()) {
94
- if (opts.includeDirs && matchesDir(fullPath, opts.match)) {
95
- yield walkEntry;
96
- }
97
- yield* walkSync(fullPath, depth + 1, opts);
98
- } else if (entry.isFile() && opts.includeFiles && matchesFile(entry.name, fullPath, opts)) {
99
- yield walkEntry;
100
- }
101
- }
102
- }
103
-
104
- /**
105
- * Ensures a directory exists, creating it recursively if needed.
106
- */
107
- export async function ensureDir(dir: string): Promise<void> {
108
- const { mkdirSync } = await import("node:fs");
109
- try {
110
- mkdirSync(dir, { recursive: true });
111
- } catch {
112
- // Directory already exists
113
- }
114
- }
115
-
116
- /**
117
- * Check if a file or directory exists.
118
- */
119
- export function exists(path: string): Promise<boolean> {
120
- try {
121
- statSync(path);
122
- return Promise.resolve(true);
123
- } catch {
124
- return Promise.resolve(false);
125
- }
126
- }
127
-
128
- /**
129
- * Synchronous check if a file or directory exists.
130
- */
131
- export function existsSync(path: string): boolean {
132
- try {
133
- statSync(path);
134
- return true;
135
- } catch {
136
- return false;
137
- }
138
- }
139
-
140
- /**
141
- * Empties a directory by removing all contents.
142
- */
143
- export async function emptyDir(dir: string): Promise<void> {
144
- const { rmSync, mkdirSync } = await import("node:fs");
145
- try {
146
- rmSync(dir, { recursive: true, force: true });
147
- } catch {
148
- // Directory doesn't exist
149
- }
150
- mkdirSync(dir, { recursive: true });
151
- }