feat: initial Cutdex application

Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
lingjhf committed 2026-10-05 23:36:23 +08:00
commit 27e77fff39
718 files changed
+183958

No files matched your search

@@ -0,0 +1,139 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'package:flutter/scheduler.dart';
import 'package:uuid/uuid.dart';
import 'package:path/path.dart' as p;
import 'request_report.dart';
import 'app_diagnostics.dart';
import 'diagnostic_redactor.dart';
/// Per-send measurements; never retains prompts, results, or credentials.
class AgentRequestDiagnostics {
AgentRequestDiagnostics({String? requestId})
: requestId = requestId ?? const Uuid().v4() {
SchedulerBinding.instance.addTimingsCallback(_frames);
_timer = Timer.periodic(const Duration(milliseconds: 200), (_) {
final now = _clock.elapsedMicroseconds;
maxTimerDelayUs = max(maxTimerDelayUs, now - _lastTickUs - 200000);
_lastTickUs = now;
});
}
final _clock = Stopwatch()..start();
final String requestId;
late final Timer _timer;
int _lastTickUs = 0;
int frameCount = 0;
int slowFrames = 0;
int maxBuildUs = 0;
int maxRasterUs = 0;
int maxTimerDelayUs = 0;
int? preparationUs;
String outcome = 'error';
final List<Map<String, Object?>> runs = [];
void prepared() => preparationUs = _clock.elapsedMicroseconds;
void _frames(List<FrameTiming> frames) {
for (final frame in frames) {
frameCount++;
final build = frame.buildDuration.inMicroseconds;
final raster = frame.rasterDuration.inMicroseconds;
maxBuildUs = max(maxBuildUs, build);
maxRasterUs = max(maxRasterUs, raster);
if (build > 16667 || raster > 16667) slowFrames++;
}
}
RequestReport stop() {
maxTimerDelayUs = max(
maxTimerDelayUs,
_clock.elapsedMicroseconds - _lastTickUs - 200000,
);
_timer.cancel();
SchedulerBinding.instance.removeTimingsCallback(_frames);
_clock.stop();
return RequestReport(
requestId: requestId,
sessionId: AppDiagnostics.instance?.sessionId,
outcome: outcome,
elapsedUs: _clock.elapsedMicroseconds,
preparationUs: preparationUs,
frames: RequestFrameReport(
count: frameCount,
slowFrames: slowFrames,
maxBuildUs: maxBuildUs,
maxRasterUs: maxRasterUs,
maxTimerDelayUs: maxTimerDelayUs,
),
runs: List.of(runs),
);
}
/// Keeps the latest 20 reports, serializing publication and pruning.
/// Best effort: storage failures never prevent the next edit.
static Future<void> _writes = Future.value();
static Future<void> persist(Directory root, RequestReport report) {
final write = _writes.then((_) async {
try {
final directory = Directory(p.join(root.path, 'diagnostics'));
await directory.create(recursive: true);
final now = DateTime.now().toUtc();
final suppliedId = report.requestId;
final requestId =
suppliedId != null &&
RegExp(r'^[a-fA-F0-9-]{36}$').hasMatch(suppliedId)
? suppliedId
: const Uuid().v4();
final file = File(
p.join(
directory.path,
'request-${now.microsecondsSinceEpoch}-$requestId.json',
),
);
final temporary = File('${file.path}.tmp');
final encoded = jsonEncode(
DiagnosticRedactor().value(report.copyWith(at: now).toJson()),
);
if (utf8.encode(encoded).length > 256 * 1024) return;
await temporary.writeAsString(encoded, flush: true);
await temporary.rename(file.path);
final files = await directory
.list()
.where(
(e) =>
e is File &&
p.basename(e.path).startsWith('request-') &&
e.path.endsWith('.json'),
)
.cast<File>()
.toList();
final dated = <(File, DateTime)>[];
for (final file in files) {
dated.add((file, (await file.stat()).modified));
}
dated.sort((a, b) => a.$2.compareTo(b.$2));
if (dated.length > 20) {
for (final entry in dated.take(dated.length - 20)) {
await entry.$1.delete();
}
}
} catch (error, stack) {
AppDiagnostics.failure(
'agent',
'persistRequestReport',
error,
stack,
context: {'requestId': report.requestId},
);
// Disk and encoding failures must not affect the conversation.
}
});
_writes = write;
return write;
}
}
+215
View File
@@ -0,0 +1,215 @@
import 'dart:async';
import 'dart:io';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_native/cutdex_native.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
import 'package:uuid/uuid.dart';
import 'diagnostic_store.dart';
import 'request_report.dart';
/// Application-owned storage and SDK adapter. Inactive unless explicitly installed.
final class AppDiagnostics {
AppDiagnostics(
this.store, {
String? sessionId,
Map<String, Object?> metadata = const {},
}) : sessionId = sessionId ?? const Uuid().v4(),
metadata = Map.of(metadata);
static AppDiagnostics? instance;
final DiagnosticStore store;
final String sessionId;
final Map<String, Object?> metadata;
static Future<AppDiagnostics> initialize() async {
Directory directory;
Object? initializationFailure;
StackTrace? initializationStack;
try {
directory = Directory(
p.join(
(await getApplicationSupportDirectory()).path,
'Cutdex',
'Diagnostics',
),
);
} catch (error, stack) {
initializationFailure = error;
initializationStack = stack;
// Use temporary storage when support-directory discovery is unavailable.
directory = Directory(
p.join(Directory.systemTemp.path, 'Cutdex', 'Diagnostics'),
);
}
final diagnostics = AppDiagnostics(
DiagnosticStore(directory),
metadata: {
'platform': Platform.operatingSystem,
'osVersion': Platform.operatingSystemVersion,
'dartVersion': Platform.version,
'buildMode': kReleaseMode
? 'release'
: kProfileMode
? 'profile'
: 'debug',
'appVersion': const String.fromEnvironment(
'CUTDEX_APP_VERSION',
defaultValue: 'unknown',
),
'appBuild': const String.fromEnvironment(
'CUTDEX_APP_BUILD',
defaultValue: 'unknown',
),
},
);
instance = diagnostics;
diagnostics.event(
const DiagnosticEvent(
component: 'app',
operation: 'start',
level: DiagnosticSeverity.info,
),
);
if (initializationFailure != null) {
diagnostics.event(
DiagnosticEvent(
component: 'diagnostics',
operation: 'initialize',
error: initializationFailure,
stackTrace: initializationStack,
),
);
}
return diagnostics;
}
static void report(DiagnosticEvent event) => instance?.event(event);
static void failure(
String component,
String operation,
Object error,
StackTrace stack, {
Map<String, Object?> context = const {},
}) => reportDiagnostic(
report,
DiagnosticEvent(
component: component,
operation: operation,
error: error,
stackTrace: stack,
context: context,
),
);
void event(DiagnosticEvent event, {bool immediate = false}) {
try {
final error = event.error;
store.record({
'version': 1,
'at': DateTime.now().toUtc().toIso8601String(),
'sessionId': sessionId,
'environment': metadata,
'level': event.level.name,
'component': event.component,
'operation': event.operation,
if (error != null)
'error': {
'type': error.runtimeType.toString(),
'message': switch (error) {
FormatException() => 'FormatException: ${error.message}',
ArgumentError() =>
'ArgumentError(${error.name}): ${error.message}',
ProcessException() =>
'ProcessException: ${error.message} (${error.errorCode})',
_ => error.toString(),
},
if (error is RuntimeException) ...{
'code': error.code,
'domain': error.domain,
'retryable': error.retryable,
'nativeDetails': error.details,
},
if (error is ProcessingException) ...{
'code': error.code,
'backend': error.backend,
},
},
if (event.stackTrace != null) 'stackTrace': event.stackTrace.toString(),
'context': event.context,
}, immediate: immediate);
} catch (_) {
// Diagnostics cannot change the application failure path.
}
}
Future<void> request(RequestReport report, String requestId) =>
store.saveRequest({
...report.copyWith(at: report.at ?? DateTime.now().toUtc()).toJson(),
'requestId': requestId,
'sessionId': sessionId,
}, requestId);
Future<File> export(Directory destination) =>
store.export(destination, {...metadata, 'sessionId': sessionId});
Future<void> readApplicationInfo() async {
try {
metadata.addAll(
await NativeDeviceInfo.readApplicationInfo().timeout(
const Duration(seconds: 2),
),
);
event(
const DiagnosticEvent(
component: 'app',
operation: 'applicationInfo',
level: DiagnosticSeverity.info,
),
);
} catch (error, stack) {
event(
DiagnosticEvent(
component: 'diagnostics',
operation: 'applicationInfo',
error: error,
stackTrace: stack,
level: DiagnosticSeverity.warning,
),
);
}
}
/// Preserves framework/engine behavior while observing both error routes.
void installErrorHandlers() {
final previousFlutter = FlutterError.onError;
FlutterError.onError = (details) {
event(
DiagnosticEvent(
component: 'flutter',
operation: 'frameworkError',
error: details.exception,
stackTrace: details.stack,
context: {'library': details.library},
),
);
if (previousFlutter != null) previousFlutter(details);
};
final previousPlatform = PlatformDispatcher.instance.onError;
PlatformDispatcher.instance.onError = (error, stack) {
event(
DiagnosticEvent(
component: 'dart',
operation: 'uncaughtAsyncError',
error: error,
stackTrace: stack,
),
immediate: true,
);
return previousPlatform?.call(error, stack) ?? false;
};
}
}
+76
View File
@@ -0,0 +1,76 @@
/// Sanitizes diagnostic values before they reach memory, disk or an export.
final class DiagnosticRedactor {
static final _privateKey = RegExp(
r'^(authorization|cookies?|password|secret|(?:access|refresh|auth)?[_-]?token|credential(?:Id)?|api.?key|prompt|messages|responseBody|requestBody)$',
caseSensitive: false,
);
static final _bearer = RegExp(
r'\bBearer\s+[^\s,;"\x27]+',
caseSensitive: false,
);
static final _apiKey = RegExp(r'\bsk-[a-zA-Z0-9_-]+');
static final _assignment = RegExp(
r'\b(api[_-]?key|access[_-]?token|password|secret|authorization)\s*[:=]\s*[^\r\n,;]+',
caseSensitive: false,
);
static final _url = RegExp(r'https?://[^\s<>"\x27]+');
static final _path = RegExp(
r'(?:file://)?/(?:Users|home|private|tmp|var|Volumes|storage|data|mnt|media|sdcard|Documents)/[^\r\n"\x27,;]*|[A-Za-z]:[\\/][^\r\n"\x27,;]*|\\\\[^\r\n"\x27,;]+',
);
static final _email = RegExp(r'\b[^\s@]+@[^\s@]+\.[a-zA-Z]{2,}\b');
String text(String value, {int limit = 8192}) {
var result = value;
// Most metadata consists of identifiers. Avoid expensive pattern scans when
// their required marker is absent; matching and redaction stay unchanged.
if (result.toLowerCase().contains('bearer')) {
result = result.replaceAll(_bearer, 'Bearer [redacted]');
}
if (result.contains('sk-')) {
result = result.replaceAll(_apiKey, '[redacted]');
}
if (result.contains(':') || result.contains('=')) {
result = result.replaceAllMapped(
_assignment,
(m) => '${m[1]}=[redacted]',
);
}
if (result.contains('http://') || result.contains('https://')) {
result = result.replaceAllMapped(_url, (m) {
final uri = Uri.tryParse(m[0]!);
return uri == null ? '[url]' : '${uri.scheme}://${uri.host}/[redacted]';
});
}
if (result.contains('/') || result.contains(r'\')) {
result = result.replaceAll(_path, '[local-path]');
}
if (result.contains('@')) {
result = result.replaceAll(_email, '[email]');
}
if (result.length > limit) {
result = '${result.substring(0, limit)}…[truncated]';
}
return result;
}
Object? value(Object? input, {int depth = 0}) {
if (depth > 8) return '[truncated]';
if (input == null || input is bool || input is num) return input;
if (input is String) return text(input);
if (input is Map) {
return <String, Object?>{
for (final entry in input.entries.take(64))
text(
entry.key.toString(),
limit: 128,
): _privateKey.hasMatch(entry.key.toString())
? '[redacted]'
: value(entry.value, depth: depth + 1),
};
}
if (input is Iterable) {
return input.take(2048).map((v) => value(v, depth: depth + 1)).toList();
}
return text(input.toString());
}
}
+353
View File
@@ -0,0 +1,353 @@
import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:path/path.dart' as p;
import 'diagnostic_redactor.dart';
/// Serializes bounded log writes, rotation and exports; failures remain observable
/// in memory without interrupting editing or recursively logging themselves.
final class DiagnosticStore {
DiagnosticStore(
this.directory, {
this.maxFileBytes = 512 * 1024,
this.fileCount = 5,
this.maxPending = 256,
this.flushInterval = const Duration(milliseconds: 250),
this.batchSize = 32,
this.maxBatchBytes = 64 * 1024,
this.maxPendingBytes = 1024 * 1024,
int? errorReserveRecords,
int? errorReserveBytes,
}) : errorReserveRecords = errorReserveRecords ?? maxPending ~/ 8,
errorReserveBytes = errorReserveBytes ?? maxPendingBytes ~/ 4,
assert(
errorReserveRecords == null ||
(errorReserveRecords >= 0 && errorReserveRecords < maxPending),
),
assert(
errorReserveBytes == null ||
(errorReserveBytes >= 0 && errorReserveBytes < maxPendingBytes),
),
assert(maxFileBytes >= 1024),
assert(fileCount > 0),
assert(maxPending > 0),
assert(flushInterval > Duration.zero),
assert(batchSize > 0),
assert(maxBatchBytes > 0),
assert(maxPendingBytes > 0);
final Directory directory;
final int maxFileBytes, fileCount, maxPending;
final Duration flushInterval;
final int batchSize, maxBatchBytes, maxPendingBytes;
final int errorReserveRecords, errorReserveBytes;
final _buffer = Queue<_DiagnosticRecord>();
Timer? _timer;
int _bufferBytes = 0;
int _pendingBytes = 0;
int eventWriteBatches = 0;
int eventFlushes = 0;
int eventBytesWritten = 0;
int get pendingRecords => _pending;
int get pendingEventBytes => _pendingBytes;
final _redactor = DiagnosticRedactor();
Future<void> _tail = Future.value();
int _pending = 0;
int dropped = 0;
int droppedErrors = 0;
int writeFailures = 0;
String? lastWriteFailure;
final List<Map<String, Object?>> _fallback = [];
File _log(int index) => File(p.join(directory.path, 'events-$index.jsonl'));
void record(Map<String, Object?> record, {bool immediate = false}) {
final isError = record['level'] == 'error';
final recordLimit = isError ? maxPending : maxPending - errorReserveRecords;
final byteLimit = isError
? maxPendingBytes
: maxPendingBytes - errorReserveBytes;
// Non-error events and reports cannot consume reserved error capacity.
// Saturated queues skip formatting; fatal errors bypass both limits.
if (!immediate && (_pending >= recordLimit || _pendingBytes >= byteLimit)) {
_drop(isError);
return;
}
try {
final safe = (_redactor.value(record)! as Map).cast<String, Object?>();
final encoded = utf8.encode('${jsonEncode(safe)}\n');
if (encoded.length > maxFileBytes) {
_drop(isError);
return;
}
if (immediate) {
try {
directory.createSync(recursive: true);
final fatal = File(p.join(directory.path, 'fatal.jsonl'));
if (fatal.existsSync() &&
fatal.lengthSync() + encoded.length > maxFileBytes) {
fatal.deleteSync();
}
fatal.writeAsBytesSync(encoded, mode: FileMode.append, flush: true);
} catch (error) {
_failed([_DiagnosticRecord(safe, encoded)], error);
}
return;
}
if (_pendingBytes + encoded.length > byteLimit) {
_drop(isError);
return;
}
_pending++;
_pendingBytes += encoded.length;
_bufferBytes += encoded.length;
_buffer.add(_DiagnosticRecord(safe, encoded));
if (_buffer.length >= batchSize || _bufferBytes >= maxBatchBytes) {
_enqueueBuffered();
} else {
_timer ??= Timer(flushInterval, _enqueueBuffered);
}
} catch (_) {
_drop(isError);
}
}
void _drop(bool isError) {
dropped++;
if (isError) droppedErrors++;
}
void _enqueueBuffered() {
_timer?.cancel();
_timer = null;
if (_buffer.isEmpty) return;
final records = _buffer.toList(growable: false);
_buffer.clear();
_bufferBytes = 0;
_tail = _tail.then((_) => _writeBatch(records));
}
Future<void> _writeBatch(List<_DiagnosticRecord> records) async {
eventWriteBatches++;
var written = 0;
try {
await directory.create(recursive: true);
while (written < records.length) {
final current = _log(0);
var length = 0;
var interrupted = false;
if (await current.exists()) {
final reader = await current.open();
try {
length = await reader.length();
if (length > 0) {
await reader.setPosition(length - 1);
interrupted = await reader.readByte() != 10;
}
} finally {
await reader.close();
}
}
if (length + (interrupted ? 1 : 0) + records[written].encoded.length >
maxFileBytes) {
await _rotate();
length = 0;
interrupted = false;
}
final bytes = BytesBuilder(copy: false);
// Isolate an interrupted append from the next complete JSONL record.
if (interrupted) bytes.addByte(10);
var end = written;
while (end < records.length) {
final encoded = records[end].encoded;
if (length + bytes.length + encoded.length > maxFileBytes ||
(end > written &&
bytes.length + encoded.length > maxBatchBytes)) {
break;
}
bytes.add(encoded);
end++;
}
final chunk = bytes.takeBytes();
await current.writeAsBytes(chunk, mode: FileMode.append, flush: true);
eventFlushes++;
eventBytesWritten += chunk.length;
written = end;
}
} catch (error) {
// A failed batch retains every unconfirmed record, with bounded fallback.
_failed(records.skip(written), error);
} finally {
_pending -= records.length;
_pendingBytes -= records.fold(
0,
(size, record) => size + record.encoded.length,
);
}
}
Future<void> _rotate() async {
final oldest = _log(fileCount - 1);
if (await oldest.exists()) await oldest.delete();
for (var i = fileCount - 2; i >= 0; i--) {
final file = _log(i);
if (await file.exists()) await file.rename(_log(i + 1).path);
}
}
void _failed(Iterable<_DiagnosticRecord> records, Object error) {
lastWriteFailure = _redactor.text(error.toString());
for (final record in records) {
writeFailures++;
_fallback.add(record.safe);
if (_fallback.length > 100) _fallback.removeAt(0);
}
}
/// Drains buffered records and waits for writes already accepted by the store.
Future<void> flush() {
_enqueueBuffered();
return _tail;
}
Future<void> saveRequest(Map<String, Object?> report, String requestId) {
// UUID-only names prevent user text or paths from choosing a destination.
if (!RegExp(r'^[a-fA-F0-9-]{36}$').hasMatch(requestId)) {
return Future.value();
}
if (_pending >= maxPending - errorReserveRecords) {
dropped++;
return Future.value();
}
_enqueueBuffered();
_pending++;
final operation = _tail.then((_) async {
final requests = Directory(p.join(directory.path, 'requests'));
try {
await requests.create(recursive: true);
final safe = _redactor.value(report);
final encoded = jsonEncode(safe);
if (utf8.encode(encoded).length > 256 * 1024) {
dropped++;
return;
}
final file = File(
p.join(
requests.path,
'${DateTime.now().toUtc().microsecondsSinceEpoch}-$requestId.json',
),
);
final temporary = File('${file.path}.tmp');
await temporary.writeAsString(encoded, flush: true);
await temporary.rename(file.path);
final files = await requests
.list()
.where((e) => e is File && e.path.endsWith('.json'))
.cast<File>()
.toList();
files.sort((a, b) => a.path.compareTo(b.path));
if (files.length > 20) {
for (final old in files.take(files.length - 20)) {
await old.delete();
}
}
} catch (error) {
writeFailures++;
lastWriteFailure = _redactor.text(error.toString());
} finally {
_pending--;
}
});
_tail = operation;
return operation;
}
/// Exports only managed diagnostics, never project files or conversations.
Future<File> export(Directory destination, Map<String, Object?> metadata) {
_enqueueBuffered();
final completion = Completer<File>();
_tail = _tail.then((_) async {
try {
final records = <Object?>[];
final logs = [
for (var i = fileCount - 1; i >= 0; i--) _log(i),
File(p.join(directory.path, 'fatal.jsonl')),
];
for (final file in logs) {
if (!await file.exists() || await file.length() > maxFileBytes) {
continue;
}
for (final line in await file.readAsLines()) {
try {
records.add(_redactor.value(jsonDecode(line)));
} catch (_) {
// An interrupted append must not prevent exporting other records.
}
}
}
final reports = <Object?>[];
final requests = Directory(p.join(directory.path, 'requests'));
if (await requests.exists()) {
final files = await requests
.list()
.where((e) => e is File && e.path.endsWith('.json'))
.cast<File>()
.toList();
files.sort((a, b) => b.path.compareTo(a.path));
for (final file in files.take(20)) {
if (await file.length() > 256 * 1024) continue;
try {
reports.add(
_redactor.value(jsonDecode(await file.readAsString())),
);
} catch (_) {}
}
}
await destination.create(recursive: true);
final file = File(
p.join(
destination.path,
'cutdex-diagnostics-${DateTime.now().toUtc().microsecondsSinceEpoch}.json',
),
);
final temporary = File('${file.path}.tmp');
await temporary.writeAsString(
jsonEncode({
'version': 1,
'exportedAt': DateTime.now().toUtc().toIso8601String(),
'metadata': _redactor.value(metadata),
'storage': {
'dropped': dropped,
'droppedErrors': droppedErrors,
'errorReserveRecords': errorReserveRecords,
'errorReserveBytes': errorReserveBytes,
'writeFailures': writeFailures,
'eventWriteBatches': eventWriteBatches,
'eventFlushes': eventFlushes,
'eventBytesWritten': eventBytesWritten,
'lastWriteFailure': lastWriteFailure,
},
'events': records,
'requests': reports,
'fallbackEvents': _fallback,
}),
flush: true,
);
await temporary.rename(file.path);
completion.complete(file);
} catch (error, stack) {
completion.completeError(error, stack);
}
});
return completion.future;
}
}
final class _DiagnosticRecord {
const _DiagnosticRecord(this.safe, this.encoded);
final Map<String, Object?> safe;
final List<int> encoded;
}
+53
View File
@@ -0,0 +1,53 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
import 'package:flutter/scheduler.dart';
/// Opt-in real-engine timings. No callbacks or I/O in ordinary app launches.
/// Set CUTDEX_FRAME_TIMINGS to a JSONL output path before launching the app.
void recordFrameTimingsFromEnvironment() {
final path = Platform.environment['CUTDEX_FRAME_TIMINGS'];
if (path == null || path.isEmpty) return;
final pending = <List<int>>[];
var writing = false;
var dropped = 0;
SchedulerBinding.instance.addTimingsCallback((frames) {
for (final frame in frames) {
if (pending.length >= 2048) {
dropped++;
continue;
}
pending.add([
frame.timestampInMicroseconds(FramePhase.vsyncStart),
frame.buildDuration.inMicroseconds,
frame.rasterDuration.inMicroseconds,
frame.totalSpan.inMicroseconds,
]);
}
});
Timer.periodic(const Duration(seconds: 2), (_) async {
if (writing || pending.isEmpty) return;
writing = true;
final batch = List<List<int>>.of(pending);
pending.clear();
final lost = dropped;
dropped = 0;
try {
await File(path).writeAsString(
'${jsonEncode({
'at': DateTime.now().toUtc().toIso8601String(),
'columns': ['vsyncUs', 'buildUs', 'rasterUs', 'totalUs'],
'dropped': lost,
'frames': batch,
})}\n',
mode: FileMode.append,
);
} on FileSystemException {
// Diagnostics must never interrupt editing (e.g. an unavailable drive).
} finally {
writing = false;
}
});
}
+34
View File
@@ -0,0 +1,34 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'request_report.freezed.dart';
part 'request_report.g.dart';
@freezed
abstract class RequestFrameReport with _$RequestFrameReport {
const factory RequestFrameReport({
required int count,
@JsonKey(name: 'over16ms') required int slowFrames,
required int maxBuildUs,
required int maxRasterUs,
required int maxTimerDelayUs,
}) = _RequestFrameReport;
factory RequestFrameReport.fromJson(Map<String, Object?> json) =>
_$RequestFrameReportFromJson(json);
}
@freezed
abstract class RequestReport with _$RequestReport {
const factory RequestReport({
@Default(1) int version,
required String outcome,
required int elapsedUs,
int? preparationUs,
required RequestFrameReport frames,
required List<Map<String, Object?>> runs,
@JsonKey(includeIfNull: false) DateTime? at,
@JsonKey(includeIfNull: false) String? requestId,
@JsonKey(includeIfNull: false) String? sessionId,
}) = _RequestReport;
factory RequestReport.fromJson(Map<String, Object?> json) =>
_$RequestReportFromJson(json);
}
File diff suppressed because it is too large. Load diff
+55
View File
@@ -0,0 +1,55 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'request_report.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_RequestFrameReport _$RequestFrameReportFromJson(Map<String, dynamic> json) =>
_RequestFrameReport(
count: (json['count'] as num).toInt(),
slowFrames: (json['over16ms'] as num).toInt(),
maxBuildUs: (json['maxBuildUs'] as num).toInt(),
maxRasterUs: (json['maxRasterUs'] as num).toInt(),
maxTimerDelayUs: (json['maxTimerDelayUs'] as num).toInt(),
);
Map<String, dynamic> _$RequestFrameReportToJson(_RequestFrameReport instance) =>
<String, dynamic>{
'count': instance.count,
'over16ms': instance.slowFrames,
'maxBuildUs': instance.maxBuildUs,
'maxRasterUs': instance.maxRasterUs,
'maxTimerDelayUs': instance.maxTimerDelayUs,
};
_RequestReport _$RequestReportFromJson(Map<String, dynamic> json) =>
_RequestReport(
version: (json['version'] as num?)?.toInt() ?? 1,
outcome: json['outcome'] as String,
elapsedUs: (json['elapsedUs'] as num).toInt(),
preparationUs: (json['preparationUs'] as num?)?.toInt(),
frames: RequestFrameReport.fromJson(
json['frames'] as Map<String, dynamic>,
),
runs: (json['runs'] as List<dynamic>)
.map((e) => e as Map<String, dynamic>)
.toList(),
at: json['at'] == null ? null : DateTime.parse(json['at'] as String),
requestId: json['requestId'] as String?,
sessionId: json['sessionId'] as String?,
);
Map<String, dynamic> _$RequestReportToJson(_RequestReport instance) =>
<String, dynamic>{
'version': instance.version,
'outcome': instance.outcome,
'elapsedUs': instance.elapsedUs,
'preparationUs': instance.preparationUs,
'frames': instance.frames.toJson(),
'runs': instance.runs,
'at': ?instance.at?.toIso8601String(),
'requestId': ?instance.requestId,
'sessionId': ?instance.sessionId,
};