Skip to content

Commit 1f7e61b

Browse files
committed
Prepare to publish sqlite3 web
1 parent 73d73d8 commit 1f7e61b

File tree

6 files changed

+25
-1
lines changed

6 files changed

+25
-1
lines changed

sqlite3_web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.0
2+
3+
- Make `FileSystem` implementation functional, add `FileSystem.flush()`.
4+
15
## 0.1.3
26

37
- Support latest version of `package:web`.

sqlite3_web/lib/src/types.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,16 @@ final class RemoteException implements Exception {
7575
}
7676
}
7777

78+
/// A virtual file system used by a worker to persist database files.
7879
abstract class FileSystem {
80+
/// Returns whether a database file identified by its [type] exists.
7981
Future<bool> exists(FileType type);
82+
83+
/// Reads the database file (or its journal).
8084
Future<Uint8List> readFile(FileType type);
85+
86+
/// Replaces the database file (or its journal), creating the virtual file if
87+
/// it doesn't exist.
8188
Future<void> writeFile(FileType type, Uint8List content);
8289

8390
/// If the file system hosting the database in the worker is not synchronous,

sqlite3_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sqlite3_web
22
description: Utilities to simplify accessing sqlite3 on the web, with automated feature detection.
3-
version: 0.1.3
3+
version: 0.2.0
44
homepage: https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3_web
55
repository: https://github.com/simolus3/sqlite3.dart
66

sqlite3_web/test/integration_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void main() {
169169
expect(await driver.countUpdateEvents(), 1);
170170

171171
expect(await driver.assertFile(true), isPositive);
172+
await driver.flush();
172173
});
173174
}
174175
});

sqlite3_web/tool/server.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,11 @@ class TestWebDriver {
194194
return null;
195195
}
196196
}
197+
198+
Future<void> flush() async {
199+
final result = await driver.executeAsync('flush("", arguments[0])', []);
200+
if (result != true) {
201+
throw 'flush() failed: $result';
202+
}
203+
}
197204
}

sqlite3_web/web/main.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ void main() {
5353

5454
return true.toJS;
5555
});
56+
_addCallbackForWebDriver('flush', (arg) async {
57+
final vfs = database!.fileSystem;
58+
await vfs.flush();
59+
return true.toJS;
60+
});
5661

5762
document.getElementById('selfcheck')?.onClick.listen((event) async {
5863
print('starting');

0 commit comments

Comments
 (0)