-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f78f848
commit 314628f
Showing
5 changed files
with
53 additions
and
12 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
packages/wasm_packages/image_rs/example/image_rs_example.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import 'package:image_rs/image_rs.dart'; | ||
// import 'package:image_rs/image_rs.dart'; | ||
|
||
void main() { | ||
var awesome = Awesome(); | ||
print('awesome: ${awesome.isAwesome}'); | ||
// var awesome = Awesome(); | ||
// print('awesome: ${awesome.isAwesome}'); | ||
} |
45 changes: 41 additions & 4 deletions
45
packages/wasm_packages/image_rs/lib/src/image_rs_base.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 |
---|---|---|
@@ -1,6 +1,43 @@ | ||
// TODO: Put public facing types in this file. | ||
import 'package:wasm_run/load_module.dart'; | ||
import 'package:wasm_run/wasm_run.dart'; | ||
import 'package:image_rs/src/image_rs_wit.gen.dart'; | ||
|
||
/// Checks if you are awesome. Spoiler: you are. | ||
class Awesome { | ||
bool get isAwesome => true; | ||
export 'package:image_rs/src/image_rs_wit.gen.dart'; | ||
|
||
/// Creates a [ImageRsWorld] with the given [wasiConfig]. | ||
/// It setsUp the dynamic library for wasm_run in native platforms and | ||
/// loads the image_rs WASM module from the file system or | ||
/// from the url pointing to 'lib/image_rs_wasm.wasm'. | ||
/// | ||
/// If [loadModule] is provided, it will be used to load the WASM module. | ||
/// This can be useful if you want to provide a different configuration | ||
/// or implementation, or you are loading it from Flutter assets or | ||
/// from a different HTTP endpoint. By default, it will load the WASM module | ||
/// from the file system in `lib/image_rs_wasm.wasm` either reading it directly | ||
/// in native platforms or with a GET request for Dart web. | ||
Future<ImageRsWorld> createImageRs({ | ||
required WasiConfig wasiConfig, | ||
Future<WasmModule> Function()? loadModule, | ||
WorkersConfig? workersConfig, | ||
}) async { | ||
await WasmRunLibrary.setUp(override: false); | ||
|
||
final WasmModule module; | ||
if (loadModule != null) { | ||
module = await loadModule(); | ||
} else { | ||
final uri = await WasmFileUris.uriForPackage( | ||
package: 'image_rs', | ||
libPath: 'image_rs_wasm.wasm', | ||
envVariable: 'IMAGE_RS_WASM_PATH', | ||
); | ||
final uris = WasmFileUris(uri: uri); | ||
module = await uris.loadModule(); | ||
} | ||
final builder = module.builder( | ||
wasiConfig: wasiConfig, | ||
workersConfig: workersConfig, | ||
); | ||
|
||
return ImageRsWorld.init(builder, imports: const ImageRsWorldImports()); | ||
} |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import 'package:image_rs/image_rs.dart'; | ||
// import 'package:image_rs/image_rs.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('A group of tests', () { | ||
final awesome = Awesome(); | ||
// final awesome = Awesome(); | ||
|
||
setUp(() { | ||
// Additional setup goes here. | ||
}); | ||
|
||
test('First Test', () { | ||
expect(awesome.isAwesome, isTrue); | ||
// expect(awesome.isAwesome, isTrue); | ||
}); | ||
}); | ||
} |
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