2021-01-31 12:50:12 -08:00
|
|
|
import 'dart:html';
|
|
|
|
|
2021-10-08 14:33:39 -07:00
|
|
|
import 'package:drift/drift.dart';
|
|
|
|
import 'package:drift/web.dart';
|
|
|
|
import 'package:drift/remote.dart';
|
2021-01-31 12:50:12 -08:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
final self = SharedWorkerGlobalScope.instance;
|
|
|
|
self.importScripts('sql-wasm.js');
|
|
|
|
|
2021-10-08 14:33:39 -07:00
|
|
|
final db = WebDatabase.withStorage(DriftWebStorage.indexedDb('worker',
|
2021-01-31 12:50:12 -08:00
|
|
|
migrateFromLocalStorage: false, inWebWorker: true));
|
2022-07-19 14:01:07 -07:00
|
|
|
final server = DriftServer(DatabaseConnection(db));
|
2021-01-31 12:50:12 -08:00
|
|
|
|
|
|
|
self.onConnect.listen((event) {
|
|
|
|
final msg = event as MessageEvent;
|
|
|
|
server.serve(msg.ports.first.channel());
|
|
|
|
});
|
|
|
|
}
|