-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge
AssetWriterSpy
functionality into SingleStepReader
, make it…
… `SingleStepReaderWriter`.
- Loading branch information
1 parent
e9845a4
commit b87bb92
Showing
20 changed files
with
680 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:crypto/crypto.dart'; | ||
import 'package:glob/glob.dart'; | ||
|
||
import '../asset/id.dart'; | ||
import '../asset/reader.dart'; | ||
import '../asset/writer.dart'; | ||
import 'asset_finder.dart'; | ||
import 'asset_path_provider.dart'; | ||
import 'filesystem.dart'; | ||
import 'filesystem_cache.dart'; | ||
import 'reader_state.dart'; | ||
|
||
/// An [AssetReader] and [AssetWriter]. | ||
abstract interface class AssetReaderWriter | ||
implements AssetReader, AssetWriter {} | ||
|
||
/// An [AssetReaderWriter] that delegates to an [AssetReader] and an | ||
/// [AssetWriter]. | ||
/// | ||
/// The main `package:build` readers and writers already implement | ||
/// `AssetReaderWriter`, this is used to support nonstandard readers/writers for | ||
/// testing. | ||
class DelegatingAssetReaderWriter | ||
implements AssetReaderWriter, AssetReaderState { | ||
final AssetReader reader; | ||
final AssetWriter writer; | ||
|
||
DelegatingAssetReaderWriter({required this.reader, required this.writer}); | ||
|
||
@override | ||
AssetFinder get assetFinder => reader.assetFinder; | ||
|
||
@override | ||
AssetPathProvider get assetPathProvider => reader.assetPathProvider; | ||
|
||
@override | ||
FilesystemCache get cache => reader.cache; | ||
|
||
@override | ||
AssetReaderWriter copyWith({ | ||
AssetPathProvider? assetPathProvider, | ||
FilesystemCache? cache, | ||
}) => DelegatingAssetReaderWriter( | ||
reader: reader.copyWith(assetPathProvider: assetPathProvider, cache: cache), | ||
writer: writer, | ||
); | ||
|
||
@override | ||
Filesystem get filesystem => reader.filesystem; | ||
|
||
@override | ||
Future<bool> canRead(AssetId id) => reader.canRead(id); | ||
|
||
@override | ||
Future<Digest> digest(AssetId id) => reader.digest(id); | ||
|
||
@override | ||
Stream<AssetId> findAssets(Glob glob) => reader.findAssets(glob); | ||
|
||
@override | ||
Future<List<int>> readAsBytes(AssetId id) => reader.readAsBytes(id); | ||
|
||
@override | ||
Future<String> readAsString(AssetId id, {Encoding encoding = utf8}) => | ||
reader.readAsString(id, encoding: encoding); | ||
|
||
@override | ||
Future<void> writeAsBytes(AssetId id, List<int> bytes) => | ||
writer.writeAsBytes(id, bytes); | ||
|
||
@override | ||
Future<void> writeAsString( | ||
AssetId id, | ||
String contents, { | ||
Encoding encoding = utf8, | ||
}) => writer.writeAsString(id, contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.