File tree Expand file tree Collapse file tree 10 files changed +14
-32
lines changed
Expand file tree Collapse file tree 10 files changed +14
-32
lines changed Original file line number Diff line number Diff line change 55- __ Breaking__ : Rewrite the native connection pool implementation.
66 - Remove isolate connection factories. Simply open the same database on another isolate, it's safe to do so now.
77 - It is no longer possible to register user-defined functions in Dart. Extensions providing functions in native code can still be used.
8+ - __ Breaking__ : Remove ` AbstractDefaultSqliteOpenFactory ` and ` DefaultSqliteOpenFactory ` . Use ` SqliteOpenFactory ` instead.
9+ To provide a custom open factory, import ` NativeSqliteOpenFactory ` or ` WebSqliteOpenFactory ` with a platform-specific
10+ import and extend those classes.
811- __ Breaking__ : Remove the ` maxReaders ` parameter on ` SqliteDatabase ` . Set that parameter on ` SqliteOptions ` instead.
912- __ Breaking__ : Remove libraries exporting the ` sqlite3 ` package:
1013 - Instead of ` package:sqlite_async/sqlite3.dart ` , import ` package:sqlite3/sqlite3.dart ` .
Original file line number Diff line number Diff line change @@ -62,8 +62,7 @@ abstract base class SqliteDatabase
6262 /// do not block read transactions, and read transactions will see the state
6363 /// from the last committed write transaction.
6464 factory SqliteDatabase (
65- {required String path,
66- SqliteOptions options = const SqliteOptions .defaults ()}) {
65+ {required String path, SqliteOptions options = const SqliteOptions ()}) {
6766 return SqliteDatabase .withFactory (
6867 SqliteOpenFactory (path: path, options: options),
6968 );
Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ import 'worker.dart';
3030final class NativeSqliteDatabaseImpl extends SqliteDatabaseImpl {
3131 @override
3232 final NativeSqliteOpenFactory openFactory;
33- late final Future <SqliteConnectionPool > _pool =
34- _openNativePool (openFactory, maxReaders);
33+ late final Future <SqliteConnectionPool > _pool = _openNativePool (openFactory);
3534 bool _isClosed = false ;
3635 final _lockGuard = Object ();
3736
@@ -290,11 +289,11 @@ final class NativeSqliteDatabaseImpl extends SqliteDatabaseImpl {
290289
291290 static Future <SqliteConnectionPool > _openNativePool (
292291 NativeSqliteOpenFactory openFactory,
293- int maxReaders,
294292 ) {
295293 // We want to open pools asynchronously since running pragma statements as
296294 // part of openFactory.open might do IO. openAsync spawn a temporary isolate
297295 // for that.
296+ final maxReaders = openFactory.sqliteOptions.maxReaders;
298297 return SqliteConnectionPool .openAsync (
299298 name: openFactory.path,
300299 openConnections: () {
Original file line number Diff line number Diff line change @@ -2,9 +2,8 @@ final class WebSqliteOptions {
22 final String workerUri;
33 final String wasmUri;
44
5- const WebSqliteOptions .defaults ()
6- : workerUri = 'db_worker.js' ,
7- wasmUri = 'sqlite3.wasm' ;
5+ @Deprecated ('Use default WebSqliteOptions constructor instead' )
6+ const factory WebSqliteOptions .defaults () = WebSqliteOptions ;
87
98 const WebSqliteOptions (
109 {this .wasmUri = 'sqlite3.wasm' , this .workerUri = 'db_worker.js' });
@@ -51,7 +50,7 @@ final class SqliteOptions {
5150 this .journalMode = SqliteJournalMode .wal,
5251 this .journalSizeLimit = 6 * 1024 * 1024 ,
5352 this .synchronous = SqliteSynchronous .normal,
54- this .webSqliteOptions = const WebSqliteOptions . defaults (),
53+ this .webSqliteOptions = const WebSqliteOptions (),
5554 this .lockTimeout = const Duration (seconds: 30 ),
5655 this .profileQueries = _profileQueriesByDefault,
5756 this .maxReaders = defaultMaxReaders,
Original file line number Diff line number Diff line change @@ -8,29 +8,13 @@ import 'package:sqlite3_web/sqlite3_web.dart';
88import 'package:sqlite_async/sqlite_async.dart' ;
99import 'package:sqlite_async/src/utils/profiler.dart' ;
1010import 'package:sqlite_async/src/web/database/broadcast_updates.dart' ;
11- import 'package:web/web.dart' ;
1211import '../common/sqlite_database.dart' ;
1312import '../common/timeouts.dart' ;
1413import '../impl/context.dart' ;
1514import 'connection.dart' ;
1615import 'protocol.dart' ;
1716import 'web_mutex.dart' ;
1817
19- /// An endpoint that can be used, by any running JavaScript context in the same
20- /// website, to connect to an existing [WebDatabase] .
21- ///
22- /// These endpoints are created by calling [WebDatabase.exposeEndpoint]
23- /// and consist of a [MessagePort] and two [String] s internally identifying the
24- /// connection. Both objects can be transferred over send ports towards another
25- /// worker or context. That context can then use
26- /// [WebDatabase.connectToEndpoint] to connect to the port already
27- /// opened.
28- typedef WebDatabaseEndpoint = ({
29- MessagePort connectPort,
30- String connectName,
31- String ? lockName,
32- });
33-
3418final class WebDatabase extends SqliteDatabaseImpl
3519 implements WebSqliteConnection {
3620 final Database _database;
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ base class WebSqliteOpenFactory extends InternalOpenFactory {
3232 });
3333
3434 WebSqliteOpenFactory (
35- {required super .path,
36- super .sqliteOptions = const SqliteOptions .defaults ()}) {
35+ {required super .path, super .sqliteOptions = const SqliteOptions ()}) {
3736 // Make sure initializer starts running immediately
3837 _initialized;
3938 }
Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ abstract class AbstractTestUtils {
77 Future <CommonDatabase > openDatabaseForSingleConnection ();
88
99 Future <SqliteOpenFactory > testFactory (
10- {String ? path,
11- SqliteOptions options = const SqliteOptions .defaults ()}) async {
10+ {String ? path, SqliteOptions options = const SqliteOptions ()}) async {
1211 return SqliteOpenFactory (path: path ?? dbPath (), options: options);
1312 }
1413
Original file line number Diff line number Diff line change 11import 'dart:async' ;
22import 'dart:io' ;
33
4+ import 'package:sqlite3/common.dart' ;
45import 'package:sqlite3/sqlite3.dart' ;
5- import 'package:sqlite3/src/database.dart' ;
66import 'package:test_descriptor/test_descriptor.dart' as d;
77
88import 'abstract_test_utils.dart' ;
Original file line number Diff line number Diff line change 1- import 'package:sqlite3/src/database .dart' ;
1+ import 'package:sqlite3/common .dart' ;
22
33import 'abstract_test_utils.dart' ;
44
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ class TestUtils extends AbstractTestUtils {
5757 @override
5858 Future <SqliteOpenFactory > testFactory ({
5959 String ? path,
60- SqliteOptions options = const SqliteOptions . defaults (),
60+ SqliteOptions options = const SqliteOptions (),
6161 }) async {
6262 await _isInitialized;
6363 return super .testFactory (
You can’t perform that action at this time.
0 commit comments