@@ -80,7 +80,8 @@ class WebDevFS {
80
80
}) async {
81
81
final mainPath = mainUri.toFilePath ();
82
82
final outputDirectory = fileSystem.directory (
83
- fileSystem.file (projectDirectory.resolve (mainPath)).parent.path);
83
+ fileSystem.file (projectDirectory.resolve (mainPath)).parent.path,
84
+ );
84
85
final entryPoint = mainUri.toString ();
85
86
86
87
var prefix = '' ;
@@ -99,10 +100,9 @@ class WebDevFS {
99
100
final bootstrap = '${prefix }main_module.bootstrap.js' ;
100
101
101
102
assetServer.writeFile (
102
- entryPoint,
103
- fileSystem
104
- .file (projectDirectory.resolve (mainPath))
105
- .readAsStringSync ());
103
+ entryPoint,
104
+ fileSystem.file (projectDirectory.resolve (mainPath)).readAsStringSync (),
105
+ );
106
106
assetServer.writeFile (stackMapper, stackTraceMapper.readAsStringSync ());
107
107
108
108
switch (ddcModuleFormat) {
@@ -118,27 +118,32 @@ class WebDevFS {
118
118
);
119
119
assetServer.writeFile (
120
120
bootstrap,
121
- generateMainModule (
122
- entrypoint: entryPoint,
123
- ),
121
+ generateMainModule (entrypoint: entryPoint),
124
122
);
125
123
break ;
126
124
case ModuleFormat .ddc:
127
125
assetServer.writeFile (
128
- ddcModuleLoader, ddcModuleLoaderJS.readAsStringSync ());
126
+ ddcModuleLoader,
127
+ ddcModuleLoaderJS.readAsStringSync (),
128
+ );
129
129
String bootstrapper;
130
130
String mainModule;
131
131
if (compilerOptions.canaryFeatures) {
132
132
bootstrapper = generateDDCLibraryBundleBootstrapScript (
133
- ddcModuleLoaderUrl: ddcModuleLoader,
134
- mapperUrl: stackMapper,
135
- entrypoint: entryPoint,
136
- bootstrapUrl: bootstrap);
133
+ ddcModuleLoaderUrl: ddcModuleLoader,
134
+ mapperUrl: stackMapper,
135
+ entrypoint: entryPoint,
136
+ bootstrapUrl: bootstrap,
137
+ );
137
138
const onLoadEndBootstrap = 'on_load_end_bootstrap.js' ;
138
- assetServer.writeFile (onLoadEndBootstrap,
139
- generateDDCLibraryBundleOnLoadEndBootstrap ());
139
+ assetServer.writeFile (
140
+ onLoadEndBootstrap,
141
+ generateDDCLibraryBundleOnLoadEndBootstrap (),
142
+ );
140
143
mainModule = generateDDCLibraryBundleMainModule (
141
- entrypoint: entryPoint, onLoadEndBootstrap: onLoadEndBootstrap);
144
+ entrypoint: entryPoint,
145
+ onLoadEndBootstrap: onLoadEndBootstrap,
146
+ );
142
147
} else {
143
148
bootstrapper = generateDDCBootstrapScript (
144
149
ddcModuleLoaderUrl: ddcModuleLoader,
@@ -152,19 +157,16 @@ class WebDevFS {
152
157
// removed, and special path elements like '/', '\', and '..' are
153
158
// replaced with
154
159
// '__'.
155
- final exportedMainName =
156
- pathToJSIdentifier (entryPoint.split ('.' )[0 ]);
160
+ final exportedMainName = pathToJSIdentifier (
161
+ entryPoint.split ('.' )[0 ],
162
+ );
157
163
mainModule = generateDDCMainModule (
158
- entrypoint: entryPoint, exportedMain: exportedMainName);
164
+ entrypoint: entryPoint,
165
+ exportedMain: exportedMainName,
166
+ );
159
167
}
160
- assetServer.writeFile (
161
- main,
162
- bootstrapper,
163
- );
164
- assetServer.writeFile (
165
- bootstrap,
166
- mainModule,
167
- );
168
+ assetServer.writeFile (main, bootstrapper);
169
+ assetServer.writeFile (bootstrap, mainModule);
168
170
break ;
169
171
default :
170
172
throw Exception ('Unsupported DDC module format $ddcModuleFormat .' );
@@ -198,16 +200,24 @@ class WebDevFS {
198
200
File metadataFile;
199
201
List <String > modules;
200
202
try {
201
- codeFile =
202
- outputDirectory.childFile ('${compilerOutput .outputFilename }.sources' );
203
- manifestFile =
204
- outputDirectory.childFile ('${compilerOutput .outputFilename }.json' );
205
- sourcemapFile =
206
- outputDirectory.childFile ('${compilerOutput .outputFilename }.map' );
207
- metadataFile = outputDirectory
208
- .childFile ('${compilerOutput .outputFilename }.metadata' );
203
+ codeFile = outputDirectory.childFile (
204
+ '${compilerOutput .outputFilename }.sources' ,
205
+ );
206
+ manifestFile = outputDirectory.childFile (
207
+ '${compilerOutput .outputFilename }.json' ,
208
+ );
209
+ sourcemapFile = outputDirectory.childFile (
210
+ '${compilerOutput .outputFilename }.map' ,
211
+ );
212
+ metadataFile = outputDirectory.childFile (
213
+ '${compilerOutput .outputFilename }.metadata' ,
214
+ );
209
215
modules = assetServer.write (
210
- codeFile, manifestFile, sourcemapFile, metadataFile);
216
+ codeFile,
217
+ manifestFile,
218
+ sourcemapFile,
219
+ metadataFile,
220
+ );
211
221
} on FileSystemException catch (err) {
212
222
throw Exception ('Failed to load recompiled sources:\n $err ' );
213
223
}
@@ -252,34 +262,37 @@ class WebDevFS {
252
262
final moduleToLibrary = < Map <String , Object >> [];
253
263
for (final module in modules) {
254
264
final metadata = ModuleMetadata .fromJson (
255
- json.decode (utf8
256
- .decode (assetServer.getMetadata ('$module .metadata' ).toList ()))
265
+ json.decode (
266
+ utf8.decode (assetServer.getMetadata ('$module .metadata' ).toList ()),
267
+ )
257
268
as Map <String , dynamic >,
258
269
);
259
270
final libraries = metadata.libraries.keys.toList ();
260
271
moduleToLibrary.add (< String , Object > {
261
272
'src' : '$fileServerUri /$module ' ,
262
273
'module' : metadata.name,
263
- 'libraries' : libraries
274
+ 'libraries' : libraries,
264
275
});
265
276
}
266
277
assetServer.writeFile (
267
- reloadedSourcesFileName, json.encode (moduleToLibrary));
278
+ reloadedSourcesFileName,
279
+ json.encode (moduleToLibrary),
280
+ );
268
281
}
269
282
270
283
File get ddcModuleLoaderJS =>
271
284
fileSystem.file (sdkLayout.ddcModuleLoaderJsPath);
272
285
File get requireJS => fileSystem.file (sdkLayout.requireJsPath);
273
286
File get dartSdk => fileSystem.file (switch (ddcModuleFormat) {
274
- ModuleFormat .amd => sdkLayout.amdJsPath,
275
- ModuleFormat .ddc => sdkLayout.ddcJsPath,
276
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
277
- });
287
+ ModuleFormat .amd => sdkLayout.amdJsPath,
288
+ ModuleFormat .ddc => sdkLayout.ddcJsPath,
289
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
290
+ });
278
291
File get dartSdkSourcemap => fileSystem.file (switch (ddcModuleFormat) {
279
- ModuleFormat .amd => sdkLayout.amdJsMapPath,
280
- ModuleFormat .ddc => sdkLayout.ddcJsMapPath,
281
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
282
- });
292
+ ModuleFormat .amd => sdkLayout.amdJsMapPath,
293
+ ModuleFormat .ddc => sdkLayout.ddcJsMapPath,
294
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
295
+ });
283
296
File get stackTraceMapper => fileSystem.file (sdkLayout.stackTraceMapperPath);
284
297
ModuleFormat get ddcModuleFormat => compilerOptions.moduleFormat;
285
298
}
@@ -293,9 +306,9 @@ class UpdateFSReport {
293
306
bool success = false ,
294
307
int invalidatedSourcesCount = 0 ,
295
308
int syncedBytes = 0 ,
296
- }) : _success = success,
297
- _invalidatedSourcesCount = invalidatedSourcesCount,
298
- _syncedBytes = syncedBytes;
309
+ }) : _success = success,
310
+ _invalidatedSourcesCount = invalidatedSourcesCount,
311
+ _syncedBytes = syncedBytes;
299
312
300
313
bool get success => _success;
301
314
int get invalidatedSourcesCount => _invalidatedSourcesCount;
@@ -319,7 +332,7 @@ class InvalidationResult {
319
332
/// application to determine when they are dirty.
320
333
class ProjectFileInvalidator {
321
334
ProjectFileInvalidator ({required FileSystem fileSystem})
322
- : _fileSystem = fileSystem;
335
+ : _fileSystem = fileSystem;
323
336
324
337
final FileSystem _fileSystem;
325
338
@@ -349,8 +362,8 @@ class ProjectFileInvalidator {
349
362
final updatedAt = uri.hasScheme && uri.scheme != 'file'
350
363
? _fileSystem.file (uri).statSync ().modified
351
364
: _fileSystem
352
- .statSync (uri.toFilePath (windows: Platform .isWindows))
353
- .modified;
365
+ .statSync (uri.toFilePath (windows: Platform .isWindows))
366
+ .modified;
354
367
if (updatedAt.isAfter (lastCompiled)) {
355
368
invalidatedFiles.add (uri);
356
369
}
0 commit comments