Gitea CI / Check code and tests (pull_request) Failing after 8s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 1s
72 lines
2.0 KiB
Dart
72 lines
2.0 KiB
Dart
import 'dart:io';
|
|
import 'dart:convert';
|
|
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
import 'export_publication.dart';
|
|
|
|
import 'package:cutdex_core/editor.dart';
|
|
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
|
|
|
/// Native session and output-file adapter. Compilation belongs to editor.
|
|
final class RuntimeEditorExport implements RecoverableEditorExportService {
|
|
const RuntimeEditorExport(this.runtime);
|
|
final CutdexRuntime runtime;
|
|
|
|
@override
|
|
Future<MediaInfo?> probe(MediaReference media) => runtime.probe(media);
|
|
|
|
@override
|
|
Future<EditorExportCapabilities> capabilities() async {
|
|
final features = await runtime.capabilities();
|
|
return EditorExportCapabilities(
|
|
imageProbe:
|
|
features.query('media.imageProbe') ==
|
|
CapabilityAvailability.available,
|
|
toneMapping:
|
|
features.query('render.toneMapping') ==
|
|
CapabilityAvailability.available,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<Uri?> recoverExport(Uri destination, String operationId) =>
|
|
ExportPublication(destination, operationId).recover();
|
|
|
|
@override
|
|
Future<Uri> exportRecoverable(
|
|
ExecutionPlan plan,
|
|
Uri destination,
|
|
String operationId,
|
|
) => ExportPublication(destination, operationId).run(
|
|
sha256.convert(utf8.encode(jsonEncode(plan.toMap()))).toString(),
|
|
(staging) => export(plan, staging),
|
|
);
|
|
|
|
@override
|
|
Future<Uri> export(ExecutionPlan plan, Uri destination) async {
|
|
if (await FileSystemEntity.type(
|
|
destination.toFilePath(),
|
|
followLinks: false,
|
|
) !=
|
|
FileSystemEntityType.notFound) {
|
|
throw const CommandRejected(
|
|
'destinationExists',
|
|
'Destination already exists',
|
|
);
|
|
}
|
|
if (!await File.fromUri(destination).parent.exists()) {
|
|
throw const CommandRejected(
|
|
'invalidDestination',
|
|
'Destination directory does not exist',
|
|
);
|
|
}
|
|
final session = await runtime.createSession();
|
|
try {
|
|
return await session.export(plan, destination);
|
|
} finally {
|
|
await session.close();
|
|
}
|
|
}
|
|
}
|