import 'dart:typed_data'; import 'artifact_viewer_fetch_stub.dart' if (dart.library.js_interop) 'artifact_viewer_fetch_web.dart' as impl; /// One artifact fetch result: the status the server answered and the bytes. class ArtifactFetchResult { const ArtifactFetchResult({required this.status, required this.bytes}); final int status; final Uint8List bytes; bool get ok => status >= 200 && status < 300; } /// A fetch that did not reach an HTTP response (network, TLS, blocked, ...). class ArtifactFetchException implements Exception { const ArtifactFetchException(this.message); final String message; @override String toString() => message; } /// Fetches an already resolved same-origin artifact. /// /// The viewer only calls this for [planArtifactPreview]'s safe local urls; the /// platform implementation sends no credentials to a different origin. typedef ArtifactFetch = Future Function(Uri uri); /// The host fetch used when a caller does not inject one. Web uses `fetch` with /// same-origin credentials; native uses an HttpClient with no stored cookies. Future fetchArtifact(Uri uri) => impl.fetchArtifact(uri);