-
-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sqflite_common_ffi_web] fix issue #1095 android web support
- Loading branch information
1 parent
b414d0e
commit d1790b9
Showing
14 changed files
with
168 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages_web/sqflite_common_ffi_web_test/test/sqflite_ffi_web_basic_web_worker_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@TestOn('browser') | ||
import 'package:sqflite_common_ffi/sqflite_ffi.dart'; | ||
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart'; | ||
import 'package:sqflite_common_test/all_test.dart' as all; | ||
import 'package:sqflite_common_test/sqflite_test.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
var _factory = createDatabaseFactoryFfiWeb( | ||
options: SqfliteFfiWebOptions( | ||
forceAsBasicWorker: true, | ||
sharedWorkerUri: Uri.parse('sqflite_sw_v1.js'))); | ||
|
||
class SqfliteFfiWebTestContext extends SqfliteLocalTestContext { | ||
SqfliteFfiWebTestContext() : super(databaseFactory: _factory); | ||
} | ||
|
||
var ffiTestContext = SqfliteFfiWebTestContext(); | ||
|
||
Future<void> main() async { | ||
/// Initialize ffi loader | ||
// sqliteFfiWebDebugWebWorker = true; | ||
sqfliteFfiInit(); | ||
try { | ||
var dbsPath = await _factory.getDatabasesPath(); | ||
await _factory.setDatabasesPath('${dbsPath}_web_basic_worker'); | ||
|
||
all.run(ffiTestContext); | ||
} catch (e) { | ||
print('Please run setup_web_tests first'); | ||
test('Please run setup_web_tests first', () {}, skip: true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// ignore_for_file: unused_import | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart'; | ||
|
||
import 'main_ffi.dart'; | ||
|
||
void main() { | ||
if (kIsWeb) { | ||
// sqliteFfiWebDebugWebWorker = true; | ||
// ignore: avoid_print | ||
print('running on the web basic worker'); | ||
} | ||
mainFfi(webBasicWorker: true); | ||
//mainFfi(); | ||
} |
16 changes: 16 additions & 0 deletions
16
sqflite_test_app/tool/flutter_build_and_serve_basic_worker.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:dev_build/build_support.dart'; | ||
import 'package:path/path.dart'; | ||
import 'package:process_run/shell.dart'; | ||
|
||
Future<void> main() async { | ||
await checkAndActivatePackage('dhttpd'); | ||
var shell = Shell(); | ||
await shell.run(''' | ||
flutter build web -t lib/main_web_simple_worker.dart'''); | ||
shell = shell.cd(join('build', 'web')); | ||
// ignore: avoid_print | ||
print('http://localhost:8080'); | ||
|
||
await shell.run( | ||
'dart pub global run dhttpd:dhttpd . --headers=Cross-Origin-Embedder-Policy=credentialless;Cross-Origin-Opener-Policy=same-origin'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:sqflite_common_ffi_web/src/setup/setup.dart'; | ||
|
||
Future<void> main() async { | ||
await setupBinaries(options: SetupOptions(force: true, verbose: true)); | ||
} |