Skip to content

Commit

Permalink
Revert "[web] Move JS content to its own .js files (#117691)" (#120…
Browse files Browse the repository at this point in the history
…275)

This reverts commit e03029e.
  • Loading branch information
itsjustkevin authored Feb 9, 2023
1 parent ef854a3 commit 0fb4406
Show file tree
Hide file tree
Showing 9 changed files with 568 additions and 667 deletions.
39 changes: 0 additions & 39 deletions packages/flutter_tools/lib/src/artifacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'base/common.dart';
import 'base/file_system.dart';
import 'base/os.dart';
import 'base/platform.dart';
import 'base/user_messages.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'cache.dart';
Expand Down Expand Up @@ -63,9 +62,6 @@ enum Artifact {
/// Tools related to subsetting or icon font files.
fontSubset,
constFinder,

/// The location of file generators.
flutterToolsFileGenerators,
}

/// A subset of [Artifact]s that are platform and build mode independent
Expand Down Expand Up @@ -206,8 +202,6 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
return 'font-subset$exe';
case Artifact.constFinder:
return 'const_finder.dart.snapshot';
case Artifact.flutterToolsFileGenerators:
return '';
}
}

Expand Down Expand Up @@ -531,8 +525,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
return _getHostArtifactPath(artifact, platform, mode);
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
}
}

Expand Down Expand Up @@ -570,8 +562,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
return _getHostArtifactPath(artifact, platform, mode);
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
}
}

Expand Down Expand Up @@ -621,8 +611,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
return _getHostArtifactPath(artifact, platform, mode);
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
}
}

Expand Down Expand Up @@ -697,8 +685,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.fuchsiaFlutterRunner:
case Artifact.fuchsiaKernelCompiler:
throw StateError('Artifact $artifact not available for platform $platform.');
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
}
}

Expand Down Expand Up @@ -966,8 +952,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
case Artifact.dart2wasmSnapshot:
case Artifact.frontendServerSnapshotForEngineDartSdk:
return _fileSystem.path.join(_getDartSdkPath(), 'bin', 'snapshots', artifactFileName);
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
}
}

Expand Down Expand Up @@ -1115,7 +1099,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
case Artifact.fuchsiaFlutterRunner:
case Artifact.fontSubset:
case Artifact.constFinder:
case Artifact.flutterToolsFileGenerators:
break;
}
}
Expand Down Expand Up @@ -1315,11 +1298,6 @@ class _TestArtifacts implements Artifacts {
BuildMode? mode,
EnvironmentType? environmentType,
}) {
// The path to file generators is the same even in the test environment.
if (artifact == Artifact.flutterToolsFileGenerators) {
return _getFileGeneratorsPath();
}

final StringBuffer buffer = StringBuffer();
buffer.write(artifact);
if (platform != null) {
Expand Down Expand Up @@ -1362,20 +1340,3 @@ class _TestLocalEngine extends _TestArtifacts {
@override
final LocalEngineInfo localEngineInfo;
}

String _getFileGeneratorsPath() {
final String flutterRoot = Cache.defaultFlutterRoot(
fileSystem: globals.localFileSystem,
platform: const LocalPlatform(),
userMessages: UserMessages(),
);
return globals.localFileSystem.path.join(
flutterRoot,
'packages',
'flutter_tools',
'lib',
'src',
'web',
'file_generators',
);
}
8 changes: 1 addition & 7 deletions packages/flutter_tools/lib/src/build_system/targets/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,7 @@ class WebBuiltInAssets extends Target {

// Write the flutter.js file
final File flutterJsFile = environment.outputDir.childFile('flutter.js');
final String fileGeneratorsPath =
globals.artifacts!.getArtifactPath(Artifact.flutterToolsFileGenerators);
flutterJsFile.writeAsStringSync(
flutter_js.generateFlutterJsFile(fileGeneratorsPath));
flutterJsFile.writeAsStringSync(flutter_js.generateFlutterJsFile());
}
}

Expand Down Expand Up @@ -601,10 +598,7 @@ class WebServiceWorker extends Target {
final ServiceWorkerStrategy serviceWorkerStrategy = _serviceWorkerStrategyFromString(
environment.defines[kServiceWorkerStrategy],
);
final String fileGeneratorsPath =
globals.artifacts!.getArtifactPath(Artifact.flutterToolsFileGenerators);
final String serviceWorker = generateServiceWorker(
fileGeneratorsPath,
urlToHash,
<String>[
'main.dart.js',
Expand Down
5 changes: 1 addition & 4 deletions packages/flutter_tools/lib/src/isolated/devfs_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,7 @@ class WebDevFS implements DevFS {
'stack_trace_mapper.js', stackTraceMapper.readAsBytesSync());
webAssetServer.writeFile(
'manifest.json', '{"info":"manifest not generated in run mode."}');
final String fileGeneratorsPath = globals.artifacts!
.getArtifactPath(Artifact.flutterToolsFileGenerators);
webAssetServer.writeFile(
'flutter.js', flutter_js.generateFlutterJsFile(fileGeneratorsPath));
webAssetServer.writeFile('flutter.js', flutter_js.generateFlutterJsFile());
webAssetServer.writeFile('flutter_service_worker.js',
'// Service worker not loaded in run mode.');
webAssetServer.writeFile(
Expand Down
Loading

0 comments on commit 0fb4406

Please sign in to comment.