Line data Source code
1 : import 'dart:async'; 2 : 3 : import 'package:matrix/matrix.dart'; 4 : 5 : class NativeImplementationsWebWorker extends NativeImplementations { 6 : /// the default handler for stackTraces in web workers 7 0 : static StackTrace defaultStackTraceHandler(String obfuscatedStackTrace) { 8 0 : return StackTrace.fromString(obfuscatedStackTrace); 9 : } 10 : 11 0 : NativeImplementationsWebWorker( 12 : Uri href, { 13 : Duration timeout = const Duration(seconds: 30), 14 : WebWorkerStackTraceCallback onStackTrace = defaultStackTraceHandler, 15 : }); 16 : } 17 : 18 : class WebWorkerError extends Error { 19 : /// the error thrown in the web worker. Usually a [String] 20 : final Object? error; 21 : 22 : /// de-serialized [StackTrace] 23 : @override 24 : final StackTrace stackTrace; 25 : 26 0 : WebWorkerError({required this.error, required this.stackTrace}); 27 : 28 0 : @override 29 : String toString() { 30 0 : return '$error, $stackTrace'; 31 : } 32 : } 33 : 34 : /// converts a stringifyed, obfuscated [StackTrace] into a [StackTrace] 35 : typedef WebWorkerStackTraceCallback = FutureOr<StackTrace> Function( 36 : String obfuscatedStackTrace);