Draft for wasm initializer API

This commit is contained in:
Simon Binder 2023-05-16 10:27:33 +02:00
parent f45ce5d909
commit 0bb7d6ade6
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
6 changed files with 96 additions and 28 deletions

View File

@ -25,6 +25,11 @@ targets:
modules:
- json1
- fts5
build_web_compilers:entrypoint:
generate_for:
- "web/drift_worker.dart"
options:
compiler: dart2js
custom:
auto_apply_builders: false

View File

@ -0,0 +1,9 @@
import 'package:drift/wasm.dart';
Future<WasmDatabaseResult> openWasmDatabase({
required Uri sqlite3WasmUri,
required Uri driftWorkerUri,
required String databaseName,
}) async {
throw 'todo';
}

View File

@ -131,3 +131,29 @@ class _WasmDelegate extends Sqlite3Delegate<CommonDatabase> {
}
}
}
enum WasmStorageImplementation {
opfsShared,
opfsLocks,
unsafeIndexedDb,
inMemory,
}
enum MissingBrowserFeature {
sharedWorkers,
dedicatedWorkersInSharedWorkers,
nestedDedicatedWorkers,
fileSystemAccess,
indexedDb,
atomics,
sharedArrayBuffers,
}
class WasmDatabaseResult {
final QueryExecutor resolvedExecutor;
final WasmStorageImplementation chosenImplementation;
final Set<MissingBrowserFeature> missingFeatures;
WasmDatabaseResult(
this.resolvedExecutor, this.chosenImplementation, this.missingFeatures);
}

View File

@ -22,6 +22,7 @@ dev_dependencies:
build_test: ^2.0.0
build_runner_core: ^7.0.0
build_verify: ^3.0.0
build_web_compilers: ^4.0.3
drift_dev: any
drift_testcases:
path: ../extras/integration_tests/drift_testcases

View File

@ -0,0 +1,3 @@
import 'package:drift/src/web/wasm_setup.dart';
Future<void> main() async {}

View File

@ -13,10 +13,10 @@ packages:
dependency: transitive
description:
name: args
sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440"
sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a
url: "https://pub.dev"
source: hosted
version: "2.4.0"
version: "2.4.1"
async:
dependency: transitive
description:
@ -25,6 +25,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
charcode:
dependency: transitive
description:
@ -53,18 +61,18 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.17.2"
conventional_commit:
dependency: transitive
description:
name: conventional_commit
sha256: "8eee25c315cf1946215d02d598402ca75cfee8a8ab482f3fac34cb0717323afa"
sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.0+1"
file:
dependency: transitive
description:
@ -85,18 +93,18 @@ packages:
dependency: transitive
description:
name: graphs
sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2
sha256: "772db3d53d23361d4ffcf5a9bb091cf3ee9b22f2be52cd107cd7a2683a89ba0e"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "2.3.0"
http:
dependency: transitive
description:
name: http
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
url: "https://pub.dev"
source: hosted
version: "0.13.5"
version: "0.13.6"
http_parser:
dependency: transitive
description:
@ -117,34 +125,34 @@ packages:
dependency: transitive
description:
name: json_annotation
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
url: "https://pub.dev"
source: hosted
version: "4.8.0"
version: "4.8.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.14"
version: "0.12.15"
melos:
dependency: "direct dev"
description:
name: melos
sha256: cd8e7db0250ee822c5354a8214afc751b6c1c41aadfbbef927456d509d953244
sha256: "993ac467e7a36bd832a6cdabbe18a0487c30bc52b5cca14e476a824679ebdce0"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.0.1"
meta:
dependency: transitive
description:
name: meta
sha256: "12307e7f0605ce3da64cf0db90e5fcab0869f3ca03f76be6bb2991ce0a55e82b"
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.9.1"
mustache_template:
dependency: transitive
description:
@ -197,10 +205,10 @@ packages:
dependency: transitive
description:
name: pub_semver
sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17"
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
version: "2.1.4"
pub_updater:
dependency: transitive
description:
@ -229,10 +237,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
@ -241,6 +249,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
string_scanner:
dependency: transitive
description:
@ -257,14 +273,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: daadc9baabec998b062c9091525aa95786508b1c48e9c30f1f891b8bf6ff2e64
url: "https://pub.dev"
source: hosted
version: "0.5.2"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.1"
version: "1.3.2"
uri:
dependency: transitive
description:
@ -277,17 +301,17 @@ packages:
dependency: transitive
description:
name: yaml
sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
version: "3.1.2"
yaml_edit:
dependency: transitive
description:
name: yaml_edit
sha256: "0b968021754d8fbd3e9c83563b538ee417d88b2cc587606da5615546b7ee033b"
sha256: "1579d4a0340a83cf9e4d580ea51a16329c916973bffd5bd4b45e911b25d46bfd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.1"
sdks:
dart: ">=2.19.0 <4.0.0"