Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/dragon_logs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.2.0

- **BREAKING**: Add WASM web support with OPFS-only storage
- **BREAKING**: Remove `file_system_access_api` and `js` dependencies
- **BREAKING**: Require Dart SDK `>=3.3.0` for extension types support
- Add `package:web` for modern web APIs compatibility
- Migrate from `dart:html` and `dart:js` to `dart:js_interop` and `package:web`
- Add WASM-specific platform detection using `dart.tool.dart2wasm`
- Implement Origin Private File System (OPFS) using modern JS interop
- Maintain full API compatibility while supporting both regular web and WASM compilation

## 1.1.0

- Bump packages to latest versions.
Expand All @@ -24,20 +35,15 @@ Refactor to share more code between web and native platforms (focused mainly on
- Stable release
- Tweak: Localisation initialisation no longer needs to be inialised before logs.


## 0.1.1-preview.1

- Memory improvement for log flushing.
- Bug fixes.


## 0.1.0-preview.1

- Bug fixes.


## 0.0.1-preview.1

- Initial preview version.


16 changes: 2 additions & 14 deletions packages/dragon_logs/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# 🚚 Repository Moved

> **⚠️ This repository has been migrated to the Komodo DeFi SDK Flutter monorepo.**
>
> πŸ“ **New location:** [packages/dragon_logs_flutter](https://github.com/KomodoPlatform/komodo-defi-sdk-flutter/tree/main/packages/dragon_logs_flutter)
>
> πŸ”„ **Active development** continues in the monorepo. Please update your forks, bookmarks, and links.
>
> πŸ’‘ **For issues, PRs, and contributions**, please use the [main monorepo](https://github.com/KomodoPlatform/komodo-defi-sdk-flutter).

---

# Dragon Logs (Archived)
# Dragon Logs

<p align="center">
<a href="https://pub.dev/packages/dragon_logs"><img src="https://img.shields.io/pub/v/dragon_logs.svg" alt="Pub"></a>
Expand All @@ -28,7 +16,7 @@ Dragon Logs aims to simplify the logging and log storage process in your Flutter

- βœ… Cross-platform log storage
- βœ… Cross-platform logs download
- ⬜ Flutter web wasm support
- βœ… Flutter web wasm support
- ⬜ Web multi-threading support
- ⬜ Log levels (e.g. debug, info, warning, error)
- ⬜ Performance metrics (in progress)
Expand Down
60 changes: 22 additions & 38 deletions packages/dragon_logs/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: async
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
url: "https://pub.dev"
source: hosted
version: "2.12.0"
version: "2.13.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -63,23 +63,23 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.4"
version: "1.2.0+1"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.2"
version: "1.3.3"
ffi:
dependency: transitive
description:
name: ffi
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
version: "2.1.4"
file:
dependency: transitive
description:
Expand All @@ -88,14 +88,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.1"
file_system_access_api:
dependency: transitive
description:
name: file_system_access_api
sha256: c961c5020ab4e5f05200dbdd9809c5256c3dc4a1fe5746ca7d8cf8e8cc11c47d
url: "https://pub.dev"
source: hosted
version: "2.0.0"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -136,26 +128,18 @@ packages:
dependency: transitive
description:
name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.19.0"
js:
dependency: transitive
description:
name: js
sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.20.2"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
url: "https://pub.dev"
source: hosted
version: "10.0.8"
version: "10.0.9"
leak_tracker_flutter_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -232,10 +216,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2"
sha256: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9
url: "https://pub.dev"
source: hosted
version: "2.2.15"
version: "2.2.17"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -389,10 +373,10 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: "3ba963161bd0fe395917ba881d320b9c4f6dd3c4a233da62ab18a5025c85f1e9"
sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
version: "2.4.1"
url_launcher_windows:
dependency: transitive
description:
Expand Down Expand Up @@ -421,26 +405,26 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
url: "https://pub.dev"
source: hosted
version: "14.3.1"
version: "15.0.0"
web:
dependency: transitive
description:
name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.1.1"
win32:
dependency: transitive
description:
name: win32
sha256: daf97c9d80197ed7b619040e86c8ab9a9dad285e7671ee7390f9180cc828a51e
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
url: "https://pub.dev"
source: hosted
version: "5.10.1"
version: "5.14.0"
xdg_directories:
dependency: transitive
description:
Expand All @@ -450,5 +434,5 @@ packages:
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.7.0-0 <4.0.0"
dart: ">=3.8.0 <4.0.0"
flutter: ">=3.27.0"
22 changes: 11 additions & 11 deletions packages/dragon_logs/lib/src/storage/file_log_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class FileLogStorage
Future<void> deleteOldLogs(int size) async {
while (await getLogFolderSize() > size) {
final files = await getLogFiles();
final sortedFiles = files.entries.toList()
..sort((a, b) => a.key.compareTo(b.key));
final sortedFiles =
files.entries.toList()..sort((a, b) => a.key.compareTo(b.key));
await sortedFiles.first.value.delete();
}
}
Expand All @@ -101,8 +101,8 @@ class FileLogStorage
Stream<String> exportLogsStream() async* {
final files = await getLogFiles();

final sortedFiles = files.values.toList()
..sort((a, b) => a.path.compareTo(b.path));
final sortedFiles =
files.values.toList()..sort((a, b) => a.path.compareTo(b.path));
for (final file in sortedFiles) {
final stats = file.statSync();
final sizeKb = stats.size / 1024;
Expand All @@ -127,9 +127,10 @@ class FileLogStorage

@override
Future<void> deleteExportedFiles() async {
final archives = _exportFilesDirectory
.listSync(followLinks: false, recursive: true)
.whereType<File>();
final archives =
_exportFilesDirectory
.listSync(followLinks: false, recursive: true)
.whereType<File>();

final deleteArchivesFutures = archives.map((archive) => archive.delete());

Expand Down Expand Up @@ -216,10 +217,9 @@ class FileLogStorage
await raf.close();

// Use share_plus to share the log file
await Share.shareXFiles(
[XFile(file.path, mimeType: 'text/plain')],
text: 'App log file export',
);
await Share.shareXFiles([
XFile(file.path, mimeType: 'text/plain'),
], text: 'App log file export');
}

static Future<String> getLogFolderPath() async {
Expand Down
3 changes: 2 additions & 1 deletion packages/dragon_logs/lib/src/storage/log_storage.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:dragon_logs/src/storage/platform_instance/log_storage_web_platform.dart'
if (dart.library.io) 'package:dragon_logs/src/storage/platform_instance/log_storage_native_platform.dart';
if (dart.library.io) 'package:dragon_logs/src/storage/platform_instance/log_storage_native_platform.dart'
if (dart.tool.dart2wasm) 'package:dragon_logs/src/storage/platform_instance/log_storage_wasm_platform.dart';

abstract class LogStorage {
Future<void> init();
Expand Down
74 changes: 74 additions & 0 deletions packages/dragon_logs/lib/src/storage/opfs_interop.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import 'package:web/web.dart';

/// JavaScript async iterator result type
@JS()
@anonymous
extension type JSIteratorResult._(JSObject _) implements JSObject {
external bool get done;
external JSAny? get value;
}

/// JavaScript async iterator type
@JS()
@anonymous
extension type JSAsyncIterator._(JSObject _) implements JSObject {
external JSPromise<JSIteratorResult> next();
}

/// Extensions for FileSystemDirectoryHandle to provide missing async iterator methods
/// that are available in the JavaScript File System API but not exposed in Flutter's web package.
@JS()
extension FileSystemDirectoryHandleExtension on FileSystemDirectoryHandle {
/// Returns an async iterator for the values (handles) in this directory.
/// Equivalent to calling `directoryHandle.values()` in JavaScript.
external JSAsyncIterator values();

/// Returns an async iterator for the keys (names) in this directory.
/// Equivalent to calling `directoryHandle.keys()` in JavaScript.
external JSAsyncIterator keys();

/// Returns an async iterator for the entries (name-handle pairs) in this directory.
/// Equivalent to calling `directoryHandle.entries()` in JavaScript.
external JSAsyncIterator entries();
}

/// Helper extensions to convert JavaScript async iterators to Dart async iterables
extension JSAsyncIteratorExtension on JSAsyncIterator {
/// Converts a JavaScript async iterator to a Dart Stream
Stream<JSAny?> asStream() async* {
while (true) {
final result = await next().toDart;
if (result.done) break;
yield result.value;
}
}
}

/// Extension to provide async iteration capabilities for FileSystemDirectoryHandle values
extension FileSystemDirectoryHandleValuesIterable on FileSystemDirectoryHandle {
/// Returns a Stream of FileSystemHandle objects for async iteration over directory contents
Stream<FileSystemHandle> valuesStream() {
return values().asStream().map((jsValue) => jsValue as FileSystemHandle);
}

/// Returns a Stream of file/directory names for async iteration over directory contents
Stream<String> keysStream() {
return keys().asStream().map((jsValue) => (jsValue as JSString).toDart);
}

/// Returns a Stream of [name, handle] pairs for async iteration over directory contents
static const int nameIndex = 0;
static const int handleIndex = 1;
Stream<(String, FileSystemHandle)> entriesStream() {
return entries().asStream().map((jsValue) {
// The entries() iterator returns [name, handle] arrays
// Use js_interop_unsafe to access array elements by numeric index
final jsObject = jsValue as JSObject;
final name = jsObject.getProperty<JSString>(nameIndex.toJS).toDart;
final handle = jsObject.getProperty<FileSystemHandle>(handleIndex.toJS);
return (name, handle);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import 'package:dragon_logs/src/storage/log_storage.dart';
import 'package:dragon_logs/src/storage/web_log_storage_wasm.dart';

LogStorage getLogStorageInstance() => WebLogStorageWasm();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:dragon_logs/src/storage/log_storage.dart';
import 'package:dragon_logs/src/storage/web_log_storage.dart';
import 'package:dragon_logs/src/storage/web_log_storage_wasm.dart';

LogStorage getLogStorageInstance() => WebLogStorage();
LogStorage getLogStorageInstance() => WebLogStorageWasm();
Loading
Loading