@warlock.js/core 4.0.20 → 4.0.21
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.
- package/esm/cli/cli-commands.manager.d.ts.map +1 -1
- package/esm/cli/cli-commands.manager.js +5 -6
- package/esm/cli/cli-commands.manager.js.map +1 -1
- package/esm/config/config-loader.d.ts.map +1 -1
- package/esm/config/config-loader.js +3 -2
- package/esm/config/config-loader.js.map +1 -1
- package/esm/dev2-server/development-server.d.ts.map +1 -1
- package/esm/dev2-server/development-server.js +1 -4
- package/esm/dev2-server/development-server.js.map +1 -1
- package/esm/dev2-server/file-event-handler.d.ts +115 -18
- package/esm/dev2-server/file-event-handler.d.ts.map +1 -1
- package/esm/dev2-server/file-event-handler.js +177 -63
- package/esm/dev2-server/file-event-handler.js.map +1 -1
- package/esm/dev2-server/file-manager.d.ts +301 -52
- package/esm/dev2-server/file-manager.d.ts.map +1 -1
- package/esm/dev2-server/file-manager.js +409 -203
- package/esm/dev2-server/file-manager.js.map +1 -1
- package/esm/dev2-server/file-operations.d.ts +161 -23
- package/esm/dev2-server/file-operations.d.ts.map +1 -1
- package/esm/dev2-server/file-operations.js +217 -80
- package/esm/dev2-server/file-operations.js.map +1 -1
- package/esm/dev2-server/files-orchestrator.d.ts +35 -11
- package/esm/dev2-server/files-orchestrator.d.ts.map +1 -1
- package/esm/dev2-server/files-orchestrator.js +51 -63
- package/esm/dev2-server/files-orchestrator.js.map +1 -1
- package/esm/dev2-server/import-transformer.d.ts +6 -5
- package/esm/dev2-server/import-transformer.d.ts.map +1 -1
- package/esm/dev2-server/import-transformer.js +27 -39
- package/esm/dev2-server/import-transformer.js.map +1 -1
- package/esm/dev2-server/layer-executor.js +1 -1
- package/esm/dev2-server/tsconfig-manager.d.ts +1 -1
- package/esm/dev2-server/tsconfig-manager.d.ts.map +1 -1
- package/esm/dev2-server/tsconfig-manager.js +3 -3
- package/esm/dev2-server/tsconfig-manager.js.map +1 -1
- package/esm/dev2-server/type-generator.d.ts +10 -6
- package/esm/dev2-server/type-generator.d.ts.map +1 -1
- package/esm/dev2-server/type-generator.js +84 -75
- package/esm/dev2-server/type-generator.js.map +1 -1
- package/esm/dev2-server/types.d.ts +15 -1
- package/esm/dev2-server/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,47 @@
|
|
|
1
1
|
import events from'@mongez/events';import {unlinkAsync}from'@mongez/fs';import {DEV_SERVER_EVENTS}from'./events.js';import {FileManager}from'./file-manager.js';import {parseImports}from'./parse-imports.js';import {Path}from'./path.js';import {areSetsEqual,warlockCachePath}from'./utils.js';/**
|
|
2
|
-
* FileOperations
|
|
3
|
-
* Handles file lifecycle operations: add, update, delete
|
|
2
|
+
* FileOperations - Handles file lifecycle operations
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* This class is responsible for managing the lifecycle of files:
|
|
5
|
+
* - **Add**: Register and process new files
|
|
6
|
+
* - **Update**: Reprocess changed files
|
|
7
|
+
* - **Delete**: Remove files and clean up resources
|
|
8
|
+
*
|
|
9
|
+
* It coordinates between:
|
|
10
|
+
* - FileManager instances (individual file processing)
|
|
11
|
+
* - DependencyGraph (tracking imports/dependents)
|
|
12
|
+
* - ManifestManager (caching file metadata)
|
|
13
|
+
* - SpecialFilesCollector (categorizing files by type)
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const fileOps = new FileOperations(files, graph, manifest, collector);
|
|
19
|
+
*
|
|
20
|
+
* // Add a new file
|
|
21
|
+
* const file = await fileOps.addFile("src/app/users/user.controller.ts");
|
|
22
|
+
*
|
|
23
|
+
* // Update an existing file
|
|
24
|
+
* const changed = await fileOps.updateFile("src/app/users/user.controller.ts");
|
|
25
|
+
*
|
|
26
|
+
* // Delete a file
|
|
27
|
+
* await fileOps.deleteFile("src/app/users/user.controller.ts");
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @class FileOperations
|
|
11
31
|
*/
|
|
12
32
|
class FileOperations {
|
|
13
33
|
files;
|
|
14
34
|
dependencyGraph;
|
|
15
35
|
manifest;
|
|
16
36
|
specialFilesCollector;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new FileOperations instance
|
|
39
|
+
*
|
|
40
|
+
* @param files - Map of all tracked FileManager instances (key: relative path)
|
|
41
|
+
* @param dependencyGraph - Graph tracking file dependencies
|
|
42
|
+
* @param manifest - Manager for persisting file metadata
|
|
43
|
+
* @param specialFilesCollector - Collector for categorizing special files
|
|
44
|
+
*/
|
|
17
45
|
constructor(files, dependencyGraph, manifest, specialFilesCollector) {
|
|
18
46
|
this.files = files;
|
|
19
47
|
this.dependencyGraph = dependencyGraph;
|
|
@@ -22,37 +50,88 @@ class FileOperations {
|
|
|
22
50
|
}
|
|
23
51
|
/**
|
|
24
52
|
* Add a new file to the system
|
|
25
|
-
*
|
|
26
|
-
*
|
|
53
|
+
*
|
|
54
|
+
* This method uses a two-phase approach to ensure dependencies are processed:
|
|
55
|
+
* 1. Parse the file to discover dependencies
|
|
56
|
+
* 2. Recursively add all dependencies (so their cache files exist)
|
|
57
|
+
* 3. Complete processing (transpile + transform + save)
|
|
58
|
+
*
|
|
59
|
+
* This ensures that when imports are transformed to cache paths,
|
|
60
|
+
* the dependency cache files actually exist.
|
|
61
|
+
*
|
|
62
|
+
* If the file is already tracked, returns the existing FileManager.
|
|
63
|
+
*
|
|
64
|
+
* @param relativePath - Relative path from project root
|
|
65
|
+
* @returns The FileManager instance for the file
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const file = await fileOps.addFile("src/config/auth.ts");
|
|
70
|
+
* // Dependencies like "app/users/models/user" are also processed
|
|
71
|
+
* console.log(file.state); // "ready"
|
|
72
|
+
* ```
|
|
27
73
|
*/
|
|
28
74
|
async addFile(relativePath) {
|
|
29
|
-
//
|
|
75
|
+
// Return existing if already tracked (idempotent)
|
|
30
76
|
if (this.files.has(relativePath)) {
|
|
31
|
-
|
|
77
|
+
return this.files.get(relativePath);
|
|
32
78
|
}
|
|
33
79
|
const absolutePath = Path.toAbsolute(relativePath);
|
|
34
80
|
const fileManager = new FileManager(absolutePath, this.files, this);
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
//
|
|
81
|
+
// Add to tracking FIRST so other files can find it during recursion
|
|
82
|
+
this.files.set(relativePath, fileManager);
|
|
83
|
+
// Phase 1: Parse to discover dependencies (no transpile yet)
|
|
84
|
+
await fileManager.parse();
|
|
85
|
+
// Phase 2: Recursively add all dependencies
|
|
86
|
+
// This ensures their cache files exist before we transform our imports
|
|
87
|
+
for (const depPath of fileManager.dependencies) {
|
|
88
|
+
if (!this.files.has(depPath)) {
|
|
89
|
+
try {
|
|
90
|
+
await this.addFile(depPath); // Recursive
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
// Dependency might be external or not exist, continue
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Phase 3: Complete processing (transpile + transform + save)
|
|
98
|
+
// Now all dependencies have cache files, so transforms will work
|
|
99
|
+
await fileManager.complete();
|
|
100
|
+
// Register dependencies in graph
|
|
38
101
|
for (const dependency of fileManager.dependencies) {
|
|
39
102
|
this.dependencyGraph.addDependency(relativePath, dependency);
|
|
40
103
|
}
|
|
41
104
|
// Add to special files collector
|
|
42
105
|
this.specialFilesCollector.addFile(fileManager);
|
|
43
|
-
//
|
|
44
|
-
// (i.e., they have broken imports that can now be resolved)
|
|
106
|
+
// Reload any files that were waiting for this dependency
|
|
45
107
|
await this.reloadFilesWaitingForDependency(relativePath);
|
|
46
|
-
// Add to tracking
|
|
47
|
-
this.files.set(relativePath, fileManager);
|
|
48
|
-
// Trigger event
|
|
49
|
-
events.trigger(DEV_SERVER_EVENTS.FILE_READY, fileManager);
|
|
50
108
|
return fileManager;
|
|
51
109
|
}
|
|
52
110
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
111
|
+
* Parse a new file without completing processing (Phase 1 of batch add)
|
|
112
|
+
*
|
|
113
|
+
* This is used during batch file operations where you need to:
|
|
114
|
+
* 1. Discover all dependencies first
|
|
115
|
+
* 2. Determine processing order (topological sort)
|
|
116
|
+
* 3. Complete processing in dependency order
|
|
117
|
+
*
|
|
118
|
+
* After calling this, call `finalizeNewFile()` to complete processing.
|
|
119
|
+
*
|
|
120
|
+
* @param relativePath - Relative path from project root
|
|
121
|
+
* @returns The FileManager instance (in "parsed" state)
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Phase 1: Parse all files to discover dependencies
|
|
126
|
+
* const files = await Promise.all(
|
|
127
|
+
* paths.map(path => fileOps.parseNewFile(path))
|
|
128
|
+
* );
|
|
129
|
+
*
|
|
130
|
+
* // Phase 2: Order by dependencies, then finalize
|
|
131
|
+
* for (const file of orderedFiles) {
|
|
132
|
+
* await fileOps.finalizeNewFile(file);
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
56
135
|
*/
|
|
57
136
|
async parseNewFile(relativePath) {
|
|
58
137
|
// Return existing if already tracked
|
|
@@ -61,49 +140,67 @@ class FileOperations {
|
|
|
61
140
|
}
|
|
62
141
|
const absolutePath = Path.toAbsolute(relativePath);
|
|
63
142
|
const fileManager = new FileManager(absolutePath, this.files, this);
|
|
64
|
-
// Parse only -
|
|
65
|
-
await fileManager.
|
|
66
|
-
// Add to files map
|
|
143
|
+
// Parse only - discover dependencies without full processing
|
|
144
|
+
await fileManager.parse();
|
|
145
|
+
// Add to files map so other files can find it during import resolution
|
|
67
146
|
this.files.set(relativePath, fileManager);
|
|
68
147
|
return fileManager;
|
|
69
148
|
}
|
|
70
149
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
150
|
+
* Complete processing for a parsed file (Phase 2 of batch add)
|
|
151
|
+
*
|
|
152
|
+
* This completes the processing pipeline for a file that was
|
|
153
|
+
* previously parsed with `parseNewFile()`.
|
|
154
|
+
*
|
|
155
|
+
* @param fileManager - The FileManager to finalize (must be in "parsed" state)
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const file = await fileOps.parseNewFile("src/app/users/user.controller.ts");
|
|
160
|
+
* // ... after dependencies are ready ...
|
|
161
|
+
* await fileOps.finalizeNewFile(file);
|
|
162
|
+
* ```
|
|
73
163
|
*/
|
|
74
164
|
async finalizeNewFile(fileManager) {
|
|
75
|
-
// Complete processing (transpile, transform imports,
|
|
76
|
-
await fileManager.
|
|
77
|
-
//
|
|
165
|
+
// Complete processing (transpile, transform imports, save cache)
|
|
166
|
+
await fileManager.complete();
|
|
167
|
+
// Register dependencies in graph
|
|
78
168
|
for (const dependency of fileManager.dependencies) {
|
|
79
169
|
this.dependencyGraph.addDependency(fileManager.relativePath, dependency);
|
|
80
170
|
}
|
|
81
171
|
// Add to special files collector
|
|
82
172
|
this.specialFilesCollector.addFile(fileManager);
|
|
83
|
-
//
|
|
173
|
+
// Reload any files that were waiting for this dependency
|
|
84
174
|
await this.reloadFilesWaitingForDependency(fileManager.relativePath);
|
|
85
175
|
}
|
|
86
176
|
/**
|
|
87
|
-
* Reload files that might have been waiting for
|
|
177
|
+
* Reload files that might have been waiting for a newly added dependency
|
|
178
|
+
*
|
|
88
179
|
* When a file is added, check if any existing files have imports
|
|
89
|
-
* that could now resolve to this new file
|
|
180
|
+
* that could now resolve to this new file. If so, reprocess them.
|
|
181
|
+
*
|
|
182
|
+
* This handles cases where:
|
|
183
|
+
* - A file was created that another file was trying to import
|
|
184
|
+
* - A batch of files is added where some depend on others
|
|
185
|
+
*
|
|
186
|
+
* @param newFilePath - Relative path of the newly added file
|
|
187
|
+
* @internal
|
|
90
188
|
*/
|
|
91
189
|
async reloadFilesWaitingForDependency(newFilePath) {
|
|
92
|
-
const newFileRelativePath = newFilePath;
|
|
93
190
|
const potentialDependents = [];
|
|
94
|
-
// Check all existing files to see if any
|
|
191
|
+
// Check all existing files to see if any could now resolve to the new file
|
|
95
192
|
for (const [existingPath, existingFile] of this.files) {
|
|
96
193
|
if (existingPath === newFilePath)
|
|
97
194
|
continue;
|
|
98
|
-
|
|
195
|
+
if (existingFile.state !== "ready")
|
|
196
|
+
continue;
|
|
99
197
|
try {
|
|
198
|
+
// Re-parse imports to check if any resolve to the new file
|
|
100
199
|
const importMap = await parseImports(existingFile.source, existingFile.absolutePath);
|
|
101
|
-
// Check if any import in the map resolves to the new file
|
|
102
200
|
for (const [_importPath, resolvedPath] of importMap) {
|
|
103
|
-
if (resolvedPath && Path.toRelative(resolvedPath) ===
|
|
104
|
-
// This import could now be resolved! Add to dependents
|
|
201
|
+
if (resolvedPath && Path.toRelative(resolvedPath) === newFilePath) {
|
|
105
202
|
potentialDependents.push(existingPath);
|
|
106
|
-
break;
|
|
203
|
+
break;
|
|
107
204
|
}
|
|
108
205
|
}
|
|
109
206
|
}
|
|
@@ -112,73 +209,95 @@ class FileOperations {
|
|
|
112
209
|
continue;
|
|
113
210
|
}
|
|
114
211
|
}
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Trigger reload event
|
|
126
|
-
events.trigger(DEV_SERVER_EVENTS.FILE_READY, dependentFile);
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
// Ignore errors - the file might still have broken imports
|
|
130
|
-
}
|
|
212
|
+
// Reprocess dependents
|
|
213
|
+
for (const dependentPath of potentialDependents) {
|
|
214
|
+
const dependentFile = this.files.get(dependentPath);
|
|
215
|
+
if (dependentFile) {
|
|
216
|
+
try {
|
|
217
|
+
await dependentFile.forceReprocess();
|
|
218
|
+
this.dependencyGraph.updateFile(dependentPath, dependentFile.dependencies);
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
// Ignore - file might still have issues
|
|
131
222
|
}
|
|
132
223
|
}
|
|
133
224
|
}
|
|
134
225
|
}
|
|
135
226
|
/**
|
|
136
|
-
* Update an existing file
|
|
137
|
-
*
|
|
138
|
-
*
|
|
227
|
+
* Update an existing file after it has changed
|
|
228
|
+
*
|
|
229
|
+
* This method:
|
|
230
|
+
* 1. Reprocesses the file if content has changed
|
|
231
|
+
* 2. Updates the dependency graph if dependencies changed
|
|
232
|
+
* 3. Updates the special files collector
|
|
233
|
+
* 4. Triggers the FILE_READY event
|
|
234
|
+
*
|
|
235
|
+
* If the file isn't tracked, it's treated as a new file.
|
|
236
|
+
*
|
|
237
|
+
* @param relativePath - Relative path from project root
|
|
238
|
+
* @returns True if file was changed and reprocessed, false if unchanged
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* const changed = await fileOps.updateFile("src/app/users/user.controller.ts");
|
|
243
|
+
* if (changed) {
|
|
244
|
+
* console.log("File was updated, triggering HMR...");
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
139
247
|
*/
|
|
140
248
|
async updateFile(relativePath) {
|
|
141
249
|
const fileManager = this.files.get(relativePath);
|
|
142
250
|
if (!fileManager) {
|
|
143
|
-
// File not tracked
|
|
251
|
+
// File not tracked - treat as new file
|
|
144
252
|
await this.addFile(relativePath);
|
|
145
253
|
return true;
|
|
146
254
|
}
|
|
147
|
-
// Store old dependencies
|
|
255
|
+
// Store old dependencies for comparison
|
|
148
256
|
const oldDependencies = new Set(fileManager.dependencies);
|
|
149
257
|
try {
|
|
150
|
-
// Update the file (
|
|
258
|
+
// Update the file (reprocess if changed)
|
|
151
259
|
const hasChanged = await fileManager.update();
|
|
152
260
|
if (!hasChanged) {
|
|
153
261
|
return false;
|
|
154
262
|
}
|
|
155
263
|
// Update dependency graph if dependencies changed
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.dependencyGraph.updateFile(relativePath, newDependencies);
|
|
264
|
+
if (!areSetsEqual(oldDependencies, fileManager.dependencies)) {
|
|
265
|
+
this.dependencyGraph.updateFile(relativePath, fileManager.dependencies);
|
|
159
266
|
}
|
|
160
267
|
// Update special files collector
|
|
161
268
|
this.specialFilesCollector.updateFile(fileManager);
|
|
162
|
-
// Trigger event
|
|
163
|
-
events.trigger(DEV_SERVER_EVENTS.FILE_READY, fileManager);
|
|
164
269
|
return true;
|
|
165
270
|
}
|
|
166
271
|
catch (error) {
|
|
167
272
|
// Failed to update (likely broken imports)
|
|
168
|
-
// Don't trigger FILE_READY event for broken files
|
|
169
273
|
return false;
|
|
170
274
|
}
|
|
171
275
|
}
|
|
172
276
|
/**
|
|
173
277
|
* Delete a file from the system
|
|
174
|
-
*
|
|
278
|
+
*
|
|
279
|
+
* This method:
|
|
280
|
+
* 1. Removes the cache file from disk
|
|
281
|
+
* 2. Removes the file from the dependency graph
|
|
282
|
+
* 3. Removes from special files collector
|
|
283
|
+
* 4. Removes from manifest
|
|
284
|
+
* 5. Triggers reload of dependents (so they see broken import errors)
|
|
285
|
+
* 6. Removes from the files map
|
|
286
|
+
*
|
|
287
|
+
* @param relativePath - Relative path from project root
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* await fileOps.deleteFile("src/app/users/user.controller.ts");
|
|
292
|
+
* // File is now fully removed from the system
|
|
293
|
+
* ```
|
|
175
294
|
*/
|
|
176
295
|
async deleteFile(relativePath) {
|
|
177
296
|
const fileManager = this.files.get(relativePath);
|
|
178
297
|
if (!fileManager) {
|
|
179
298
|
return;
|
|
180
299
|
}
|
|
181
|
-
// Get dependents before
|
|
300
|
+
// Get dependents before removal (so we can notify them)
|
|
182
301
|
const dependents = this.dependencyGraph.getDependents(relativePath);
|
|
183
302
|
// Delete cache file
|
|
184
303
|
try {
|
|
@@ -186,30 +305,38 @@ class FileOperations {
|
|
|
186
305
|
await unlinkAsync(cachePath);
|
|
187
306
|
}
|
|
188
307
|
catch (error) {
|
|
189
|
-
// Cache file might not exist
|
|
308
|
+
// Cache file might not exist - ignore
|
|
190
309
|
}
|
|
191
310
|
// Remove from dependency graph
|
|
192
311
|
this.dependencyGraph.removeFile(relativePath);
|
|
193
312
|
// Remove from special files collector
|
|
194
313
|
this.specialFilesCollector.removeFile(relativePath);
|
|
195
|
-
// Remove from
|
|
314
|
+
// Remove from manifest
|
|
196
315
|
this.manifest.removeFile(relativePath);
|
|
197
|
-
// Trigger reload of dependents
|
|
316
|
+
// Trigger reload of dependents (they'll see broken import errors)
|
|
198
317
|
for (const dependentPath of dependents) {
|
|
199
318
|
const dependentFile = this.files.get(dependentPath);
|
|
200
319
|
if (dependentFile) {
|
|
201
|
-
// Trigger event to reload the dependent (will fail with import error)
|
|
202
320
|
events.trigger(DEV_SERVER_EVENTS.FILE_READY, dependentFile);
|
|
203
321
|
}
|
|
204
322
|
}
|
|
323
|
+
// Remove from files map (delayed to allow other operations to complete)
|
|
205
324
|
setTimeout(() => {
|
|
206
|
-
// wait some time begore removing it from the files map
|
|
207
|
-
// so that other operations could use the existing file manager there
|
|
208
325
|
this.files.delete(relativePath);
|
|
209
326
|
}, 300);
|
|
210
327
|
}
|
|
211
328
|
/**
|
|
212
|
-
* Update dependents in all FileManager instances from dependency graph
|
|
329
|
+
* Update dependents in all FileManager instances from the dependency graph
|
|
330
|
+
*
|
|
331
|
+
* This synchronizes the `dependents` property of each FileManager
|
|
332
|
+
* with the current state of the dependency graph. Called after
|
|
333
|
+
* initial file processing or batch operations.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* // After processing all files
|
|
338
|
+
* fileOps.updateFileDependents();
|
|
339
|
+
* ```
|
|
213
340
|
*/
|
|
214
341
|
updateFileDependents() {
|
|
215
342
|
for (const [relativePath, fileManager] of this.files) {
|
|
@@ -218,7 +345,17 @@ class FileOperations {
|
|
|
218
345
|
}
|
|
219
346
|
}
|
|
220
347
|
/**
|
|
221
|
-
* Sync all FileManager instances to manifest
|
|
348
|
+
* Sync all FileManager instances to the manifest
|
|
349
|
+
*
|
|
350
|
+
* This persists the current state of all files to the manifest
|
|
351
|
+
* for caching across dev server restarts.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* // Before saving manifest
|
|
356
|
+
* fileOps.syncFilesToManifest();
|
|
357
|
+
* await manifest.save();
|
|
358
|
+
* ```
|
|
222
359
|
*/
|
|
223
360
|
syncFilesToManifest() {
|
|
224
361
|
for (const [relativePath, fileManager] of this.files) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-operations.js","sources":["../../src/dev2-server/file-operations.ts"],"sourcesContent":[null],"names":[],"mappings":"kSAWA
|
|
1
|
+
{"version":3,"file":"file-operations.js","sources":["../../src/dev2-server/file-operations.ts"],"sourcesContent":[null],"names":[],"mappings":"kSAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;MACU,cAAc,CAAA;AAUN,IAAA,KAAA,CAAA;AACA,IAAA,eAAA,CAAA;AACA,IAAA,QAAA,CAAA;AACA,IAAA,qBAAA,CAAA;AAZnB;;;;;;;AAOG;AACH,IAAA,WAAA,CACmB,KAA+B,EAC/B,eAAgC,EAChC,QAAyB,EACzB,qBAA4C,EAAA;QAH5C,IAAK,CAAA,KAAA,GAAL,KAAK,CAA0B;QAC/B,IAAe,CAAA,eAAA,GAAf,eAAe,CAAiB;QAChC,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAiB;QACzB,IAAqB,CAAA,qBAAA,GAArB,qBAAqB,CAAuB;KAC3D;AAEJ;;;;;;;;;;;;;;;;;;;;;;AAsBG;IACI,MAAM,OAAO,CAAC,YAAoB,EAAA;;QAEvC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CA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K,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SACjC,EAAE,GAAG,CAAC,CAAC;KACT;AAED;;;;;;;;;;;;AAYG;IACI,oBAAoB,GAAA;QACzB,KAAK,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;YACpD,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;AACpE,YAAA,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;AACrC,SAAA;KACF;AAED;;;;;;;;;;;;AAYG;IACI,mBAAmB,GAAA;QACxB,KAAK,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;AACpD,YAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;AAC/D,SAAA;KACF;AACF"}
|
|
@@ -16,8 +16,11 @@ export declare class FilesOrchestrator {
|
|
|
16
16
|
readonly specialFilesCollector: SpecialFilesCollector;
|
|
17
17
|
readonly moduleLoader: ModuleLoader;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Creates the FilesOrchestrator instance
|
|
20
|
+
*
|
|
21
|
+
* Initializes all subsystems:
|
|
22
|
+
* - FileOperations for file lifecycle management
|
|
23
|
+
* - FileEventHandler for processing file system events
|
|
21
24
|
*/
|
|
22
25
|
constructor();
|
|
23
26
|
/**
|
|
@@ -51,7 +54,24 @@ export declare class FilesOrchestrator {
|
|
|
51
54
|
*/
|
|
52
55
|
init(): Promise<void>;
|
|
53
56
|
/**
|
|
54
|
-
* Initialize
|
|
57
|
+
* Initialize all development server features
|
|
58
|
+
*
|
|
59
|
+
* This is the main initialization sequence that:
|
|
60
|
+
* 1. Discovers all TypeScript/JavaScript files in the project
|
|
61
|
+
* 2. Reconciles filesystem state with cached manifest
|
|
62
|
+
* 3. Builds the dependency graph for HMR
|
|
63
|
+
* 4. Persists file metadata to manifest
|
|
64
|
+
*
|
|
65
|
+
* Each file is fully processed (including import transforms) during
|
|
66
|
+
* reconciliation because transforms compute cache paths deterministically
|
|
67
|
+
* and don't depend on other files being processed first.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* await filesOrchestrator.init();
|
|
72
|
+
* await filesOrchestrator.initiaizeAll();
|
|
73
|
+
* await filesOrchestrator.watchFiles();
|
|
74
|
+
* ```
|
|
55
75
|
*/
|
|
56
76
|
initiaizeAll(): Promise<void>;
|
|
57
77
|
/**
|
|
@@ -74,7 +94,10 @@ export declare class FilesOrchestrator {
|
|
|
74
94
|
getAllFilesFromFilesystem(): Promise<string[]>;
|
|
75
95
|
/**
|
|
76
96
|
* Process all files fresh (no manifest exists)
|
|
77
|
-
*
|
|
97
|
+
*
|
|
98
|
+
* This happens on first run or when manifest is deleted.
|
|
99
|
+
* Each file is fully processed including import transforms.
|
|
100
|
+
*
|
|
78
101
|
* @param filePaths Array of relative file paths
|
|
79
102
|
*/
|
|
80
103
|
processAllFilesFresh(filePaths: string[]): Promise<void>;
|
|
@@ -84,7 +107,10 @@ export declare class FilesOrchestrator {
|
|
|
84
107
|
*/
|
|
85
108
|
private reconcileFiles;
|
|
86
109
|
/**
|
|
87
|
-
* Process newly discovered files
|
|
110
|
+
* Process newly discovered files (in filesystem but not in manifest)
|
|
111
|
+
*
|
|
112
|
+
* Each file is fully processed including import transforms.
|
|
113
|
+
*
|
|
88
114
|
* @param filePaths Array of relative file paths
|
|
89
115
|
*/
|
|
90
116
|
private processNewFiles;
|
|
@@ -95,6 +121,10 @@ export declare class FilesOrchestrator {
|
|
|
95
121
|
private processDeletedFiles;
|
|
96
122
|
/**
|
|
97
123
|
* Process existing files (check if they changed since last run)
|
|
124
|
+
*
|
|
125
|
+
* For unchanged files, loads from cache.
|
|
126
|
+
* For changed files, reprocesses fully.
|
|
127
|
+
*
|
|
98
128
|
* @param filePaths Array of relative file paths
|
|
99
129
|
*/
|
|
100
130
|
private processExistingFiles;
|
|
@@ -111,12 +141,6 @@ export declare class FilesOrchestrator {
|
|
|
111
141
|
* Start file watcher to detect changes during development
|
|
112
142
|
*/
|
|
113
143
|
watchFiles(): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Transform all imports to use cache paths
|
|
116
|
-
* This is called AFTER all files are processed and transpiled
|
|
117
|
-
* Only transforms files that haven't been transformed yet (freshly transpiled)
|
|
118
|
-
*/
|
|
119
|
-
private transformAllImports;
|
|
120
144
|
}
|
|
121
145
|
export declare const filesOrchestrator: FilesOrchestrator;
|
|
122
146
|
//# sourceMappingURL=files-orchestrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-orchestrator.d.ts","sourceRoot":"","sources":["../../src/dev2-server/files-orchestrator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"files-orchestrator.d.ts","sourceRoot":"","sources":["../../src/dev2-server/files-orchestrator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAEnF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EA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