Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 💡 wasm size optimization #103

Closed
wants to merge 3 commits into from
Closed
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
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,14 @@ endef

define CARGO_BUILD
source $(EMSDK_DIR)/$(EMSDK)_env.sh && \
RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build \
-Z build-std=std,panic_abort \
-Z build-std-features=panic_immediate_abort \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--target $(CARGO_TARGET) \
--release
export CC="emcc" && \
export CXX="em++" && \
RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build \
-Z build-std=std,panic_abort \
-Z build-std-features=panic_immediate_abort \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--target $(CARGO_TARGET) \
--release
endef

define UNIFFI_BINDINGS_BUILD
Expand Down
2 changes: 1 addition & 1 deletion dotlottie-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ path = "uniffi-bindgen.rs"
# uniffi = { version = "0.25.3", features = ["cli"] }
uniffi = { version = "0.26.1", features = ["cli"] }
dotlottie_player = { path = "../dotlottie-rs" }
dotlottie_fms = { path = "../dotlottie-fms" }
# dotlottie_fms = { path = "../dotlottie-fms" }
cfg-if = "1.0"

[build-dependencies]
Expand Down
8 changes: 2 additions & 6 deletions dotlottie-ffi/src/dotlottie_player.udl
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,12 @@ dictionary ManifestTheme {

dictionary ManifestAnimation {
boolean? autoplay;
string? defaultTheme;
string? default_theme;
i8? direction;
boolean? hover;
string id;
u32? intermission;
boolean? loop;
u32? loop_count;
string? playMode;
string? play_mode;
u32? speed;
string? themeColor;
};

dictionary Manifest {
Expand Down
51 changes: 0 additions & 51 deletions dotlottie-ffi/src/dotlottie_player_cpp.udl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ namespace dotlottie_player {
Layout create_default_layout();
};

/// [Trait]
/// interface Observer {
/// void on_load();
/// void on_play();
/// void on_pause();
/// void on_stop();
/// void on_frame(f32 frame_no);
/// void on_render(f32 frame_no);
/// void on_loop(u32 loop_count);
/// void on_complete();
/// };

enum Mode {
"Forward",
"Reverse",
Expand Down Expand Up @@ -47,42 +35,6 @@ dictionary Config {
string marker;
};

///dictionary ManifestTheme {
/// string id;
/// sequence<string> animations;
///};

///dictionary ManifestThemes {
/// sequence<ManifestTheme>? value;
///};

///dictionary ManifestAnimation {
/// boolean? autoplay;
/// string? defaultTheme;
/// i8? direction;
/// boolean? hover;
/// string id;
/// u32? intermission;
/// boolean? loop;
/// u32? loop_count;
/// string? playMode;
/// u32? speed;
/// string? themeColor;
///};

///dictionary Manifest {
/// string? active_animation_id;
/// sequence<ManifestAnimation> animations;
/// string? author;
/// string? description;
/// string? generator;
/// string? keywords;
/// u32? revision;
/// sequence<ManifestTheme>? themes;
/// sequence<string>? states;
/// string? version;
///};

dictionary Marker {
string name;
f32 time;
Expand All @@ -95,7 +47,6 @@ interface DotLottiePlayer {
boolean load_animation_path([ByRef] string animation_path, u32 width, u32 height);
boolean load_dotlottie_data([ByRef] bytes file_data, u32 width, u32 height);
boolean load_animation([ByRef] string animation_id, u32 width, u32 height);
/// Manifest? manifest();
string manifest_string();
u64 buffer_ptr();
u64 buffer_len();
Expand All @@ -118,8 +69,6 @@ interface DotLottiePlayer {
boolean render();
boolean resize(u32 width, u32 height);
void clear();
/// void subscribe(Observer observer);
/// void unsubscribe([ByRef] Observer observer);
boolean is_complete();
boolean load_theme([ByRef] string theme_id);
boolean load_theme_data([ByRef] string theme_data);
Expand Down
2 changes: 1 addition & 1 deletion dotlottie-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use dotlottie_fms::*;
// pub use dotlottie_fms::*;
pub use dotlottie_player_core::*;

pub fn create_default_layout() -> Layout {
Expand Down
8 changes: 4 additions & 4 deletions dotlottie-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ name = "dotlottie_player_core"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dotlottie_fms = { path = "../dotlottie-fms" }
thiserror = "1.0.48"
# "emscripten-no-leading-underscore" branch fix this issue -> https://github.com/sebcrozet/instant/issues/35
instant = {git = "https://github.com/hoodmane/instant", branch = "emscripten-no-leading-underscore", features = ["inaccurate"]}
serde_json = "1.0.107"
serde = { version = "1.0.188", features = ["derive"] }
serde-json-core = {version = "0.5", default-features = false, features = ["std"]}
serde = {version = "1.0", default-features = false, features = ["derive"] }
libdeflater = { version = "1.19", default-features = false, features = ["freestanding"]}
js-sys = "0.3.69"

[build-dependencies]
bindgen = "0.69.1"
Expand Down
Loading
Loading