import 'dart:io'; import 'package:flutter/foundation.dart'; import '../../../comms/Comms.dart' show LogLine; import '../application/ServiceConfig.dart'; import '../application/StepTracker.dart'; import 'BuildService.dart'; import 'ConnectFileStorage.dart'; import 'WebArchive.dart'; /// The one concrete [ConnectFileStorage]. Owns the [BuildService] and delegates /// archiving to [WebArchive]; holds no state of its own beyond the builder. class FileStorage implements ConnectFileStorage { final BuildService _builder = BuildService(); @override bool get buildSupported => BuildService.supported; @override Stream get buildLogs => _builder.logs; @override Stream> get buildStepStream => _builder.stepStream; @override Future build(ServiceConfig service) => _builder.build(service); @override Future buildWeb(ServiceConfig service) => _builder.buildWeb(service); @override void cancelBuild() => _builder.cancel(); @override Future readArtifact(String path) => File(path).readAsBytes(); @override Future artifactExists(String path) => File(path).exists(); @override Future<(Uint8List, int)> packageWeb(String directoryPath) => // Packaging a large static tree blocks long enough to drop frames, so it // runs on a background isolate. compute(packageWebDir, directoryPath); }