Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
## [0.7.2]
* Fixed errors related to unexpected `runtimeType` names due to minifying in release builds

## [0.7.1]
* Fixing dead links

## [0.7.0]
* Initial release
* No struct support yet
* No pointer array extension support yet
## [0.7.3]
* The `wasmExports` is used instead of the obsolete `asm`.
* The sdk version is upgraded up to 3.0.0.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This is a fork of the package [web_ffi](https://pub.dev/packages/web_ffi) on pub.dev, and this package uses `wasmExports` instead of the obsolete `asm`.

# web_ffi
`web_ffi` is a drop-in solution for using `dart:ffi` on the web. This enables you to work with `WebAssembly` more easily and convenient.

Expand Down
1 change: 0 additions & 1 deletion example/example_flutter/lib/src/init_web.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:inject_js/inject_js.dart' as Js;
// Notice that in this file, we import web_ffi and not proxy_ffi.dart
Expand Down
49 changes: 28 additions & 21 deletions example/example_flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ packages:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.4.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.19.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -24,48 +26,53 @@ packages:
dependency: "direct main"
description:
name: inject_js
url: "https://pub.dartlang.org"
sha256: "3ab213e2c76375a611f57eb0044d32c6e18c5091d52510e7fe9f88f6bee83d19"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.3"
version: "0.6.7"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
url: "https://pub.dev"
source: hosted
version: "0.13.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.17.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.0.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.2.0"
web_ffi:
dependency: "direct main"
description:
path: "../.."
relative: true
source: path
version: "0.7.0"
version: "0.7.3"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=3.9.0-0 <4.0.0"
14 changes: 8 additions & 6 deletions example/example_no_flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ packages:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.3"
version: "0.6.7"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.16.0"
web_ffi:
dependency: "direct main"
description:
path: "../.."
relative: true
source: path
version: "0.7.0"
version: "0.7.3"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=3.0.0 <4.0.0"
7 changes: 4 additions & 3 deletions lib/src/modules/emscripten/emscripten_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _EmscriptenModuleJs {
external Uint8List? get wasmBinary;
external Uint8List? get HEAPU8;
external Object? get asm;
external Object? get wasmExports;

// Must have an unnamed factory constructor with named arguments.
external factory _EmscriptenModuleJs({Uint8List wasmBinary});
Expand Down Expand Up @@ -108,13 +109,13 @@ class EmscriptenModule extends Module {
this._emscriptenModuleJs, this._exports, this._malloc, this._free);

factory EmscriptenModule._fromJs(_EmscriptenModuleJs module) {
Object? asm = module.asm;
if (asm != null) {
final wasmExports = module.wasmExports ?? module.asm;
if (wasmExports != null) {
Map<int, WasmSymbol> knownAddresses = {};
_Malloc? malloc;
_Free? free;
List<WasmSymbol> exports = [];
List? entries = _entries(asm);
List? entries = _entries(wasmExports);
if (entries != null) {
for (dynamic entry in entries) {
if (entry is List) {
Expand Down
23 changes: 7 additions & 16 deletions lib/src/modules/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ class Global extends WasmSymbol {
: super(address: address, name: name);

@override
bool operator ==(dynamic other) {
if (other != null && other is Global) {
return name == other.name && address == other.address;
} else {
return false;
}
}
bool operator ==(Object other) => other is Global
&& name == other.name
&& address == other.address;
}

/// Describes a function exported from WebAssembly.
Expand All @@ -98,15 +94,10 @@ class FunctionDescription extends WasmSymbol {
int get hashCode => '$name$argumentCount$tableIndex'.hashCode;

@override
bool operator ==(dynamic other) {
if (other != null && other is FunctionDescription) {
return argumentCount == other.argumentCount &&
name == other.name &&
tableIndex == other.tableIndex;
} else {
return false;
}
}
bool operator ==(Object other) => other is FunctionDescription
&& argumentCount == other.argumentCount
&& name == other.name
&& tableIndex == other.tableIndex;

@override
String toString() =>
Expand Down
12 changes: 7 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ packages:
dependency: "direct main"
description:
name: js
url: "https://pub.dartlang.org"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.3"
version: "0.6.7"
meta:
dependency: "direct main"
description:
name: meta
url: "https://pub.dartlang.org"
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.16.0"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=3.0.0 <4.0.0"
11 changes: 7 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: web_ffi
version: 0.7.2
repository: https://github.com/EPNW/web_ffi/
version: 0.7.3
description: Translates dart:ffi calls on the web to WebAssembly using dart:js
repository: https://github.com/darkstarx/web_ffi

publish_to: https://pub.rightbrain.pro

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=3.0.0 <4.0.0"

dependencies:
js: ^0.6.3
meta: ^1.3.0
meta: ^1.3.0