feat: folder web (#4580)

* chore: folder wasm

* chore: folder wasm

* chore: resolve deps

* chore: fix trait

* chore: try localset

* chore: fix

* chore: fix

* chore: fix

* chore: async init sdk

* chore: fix test

* chore: fix test
This commit is contained in:
Nathan.fooo
2024-02-04 05:50:23 +08:00
committed by GitHub
parent 08938b8c70
commit fda70ff560
65 changed files with 818 additions and 558 deletions

View File

@ -29,8 +29,16 @@ class FlowySDK {
Future<void> init(String configuration) async {
final port = RustStreamReceiver.shared.port;
ffi.set_stream_port(port);
ffi.store_dart_post_cobject(NativeApi.postCObject);
ffi.init_sdk(configuration.toNativeUtf8());
// final completer = Completer<Uint8List>();
// // Create a SendPort that accepts only one message.
// final sendPort = singleCompletePort(completer);
final code = ffi.init_sdk(0, configuration.toNativeUtf8());
if (code != 0) {
throw Exception('Failed to initialize the SDK');
}
// return completer.future;
}
}

View File

@ -77,17 +77,20 @@ typedef _invoke_sync_Dart = Pointer<Uint8> Function(
/// C function `init_sdk`.
int init_sdk(
int port,
Pointer<ffi.Utf8> data,
) {
return _init_sdk(data);
return _init_sdk(port, data);
}
final _init_sdk_Dart _init_sdk =
_dart_ffi_lib.lookupFunction<_init_sdk_C, _init_sdk_Dart>('init_sdk');
typedef _init_sdk_C = Int64 Function(
Int64 port,
Pointer<ffi.Utf8> path,
);
typedef _init_sdk_Dart = int Function(
int port,
Pointer<ffi.Utf8> path,
);

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdlib.h>
int64_t init_sdk(char *data);
int64_t init_sdk(int64_t port, char *data);
void async_event(int64_t port, const uint8_t *input, uintptr_t len);