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

fix: 🐛 themes structure in manifest file #65

Merged
merged 14 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ cpp_link_args = [
'-sDYNAMIC_EXECUTION=0',
'--no-entry',
'--strip-all',
# '--embind-emit-tsd=${WASM_MODULE}.d.ts',
'--embind-emit-tsd=${WASM_MODULE}.d.ts',
'--minify=0']

[host_machine]
Expand Down Expand Up @@ -430,8 +430,8 @@ define WASM_RELEASE
mkdir -p $(RELEASE)/$(WASM)
cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).wasm \
$(RELEASE)/$(WASM)
# cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).d.ts \
# $(RELEASE)/$(WASM)
cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).d.ts \
$(RELEASE)/$(WASM)
cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).js \
$(RELEASE)/$(WASM)/$(WASM_MODULE).mjs
cd $(RELEASE)/$(WASM) && \
Expand Down
2 changes: 1 addition & 1 deletion deps/modules/libjpeg-turbo
Submodule libjpeg-turbo updated 179 files
2 changes: 1 addition & 1 deletion deps/modules/libpng
2 changes: 1 addition & 1 deletion deps/modules/zlib
Submodule zlib updated 73 files
+11 −1 .gitignore
+24 −19 CMakeLists.txt
+10 −0 ChangeLog
+1 −2 FAQ
+8 −8 Makefile.in
+3 −3 README
+5 −4 configure
+1 −1 contrib/delphi/ZLib.pas
+1 −1 contrib/dotzlib/DotZLib/ChecksumImpl.cs
+1 −1 contrib/dotzlib/DotZLib/UnitTests.cs
+3 −3 contrib/infback9/inftree9.c
+2 −2 contrib/infback9/inftree9.h
+2 −2 contrib/iostream3/zfstream.h
+1 −1 contrib/minizip/Makefile
+1 −1 contrib/minizip/configure.ac
+1 −1 contrib/minizip/ioapi.h
+16 −2 contrib/minizip/miniunz.c
+4 −4 contrib/minizip/unzip.c
+1 −1 contrib/minizip/unzip.h
+16 −5 contrib/minizip/zip.c
+2 −2 contrib/minizip/zip.h
+43 −0 contrib/nuget/nuget.csproj
+22 −0 contrib/nuget/nuget.sln
+1 −1 contrib/pascal/zlibpas.pas
+4 −4 contrib/puff/puff.c
+81 −75 contrib/vstudio/readme.txt
+4 −4 contrib/vstudio/vc10/zlib.rc
+1 −1 contrib/vstudio/vc10/zlibvc.def
+4 −4 contrib/vstudio/vc11/zlib.rc
+1 −1 contrib/vstudio/vc11/zlibvc.def
+4 −4 contrib/vstudio/vc12/zlib.rc
+1 −1 contrib/vstudio/vc12/zlibvc.def
+4 −4 contrib/vstudio/vc14/zlib.rc
+1 −1 contrib/vstudio/vc14/zlibvc.def
+409 −0 contrib/vstudio/vc17/miniunz.vcxproj
+405 −0 contrib/vstudio/vc17/minizip.vcxproj
+473 −0 contrib/vstudio/vc17/testzlib.vcxproj
+409 −0 contrib/vstudio/vc17/testzlibdll.vcxproj
+32 −0 contrib/vstudio/vc17/zlib.rc
+602 −0 contrib/vstudio/vc17/zlibstat.vcxproj
+158 −0 contrib/vstudio/vc17/zlibvc.def
+179 −0 contrib/vstudio/vc17/zlibvc.sln
+875 −0 contrib/vstudio/vc17/zlibvc.vcxproj
+4 −4 contrib/vstudio/vc9/zlib.rc
+1 −1 contrib/vstudio/vc9/zlibvc.def
+36 −11 deflate.c
+33 −2 deflate.h
+1 −1 doc/algorithm.txt
+2 −2 examples/gzlog.c
+1 −1 examples/zran.c
+2 −6 gzguts.h
+6 −6 gzlib.c
+1 −1 inflate.c
+3 −3 inftrees.c
+2 −2 inftrees.h
+1 −1 old/visual-basic.txt
+1 −1 os400/README400
+3 −3 os400/zlib.inc
+5 −5 qnx/package.qpg
+13 −12 test/example.c
+16 −16 test/minigzip.c
+2 −2 treebuild.xml
+17 −3 trees.c
+2 −18 win32/DLL_FAQ.txt
+4 −4 win32/README-WIN32.txt
+1 −9 zconf.h
+1 −9 zconf.h.cmakein
+1 −9 zconf.h.in
+3 −3 zlib.3
+ zlib.3.pdf
+11 −11 zlib.h
+100 −100 zlib.map
+3 −24 zutil.h
5 changes: 2 additions & 3 deletions dotlottie-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[dependencies]
uniffi = { version = "0.26.0", features = ["cli"] }
# Core runtime
uniffi = { version = "0.25.3", features = ["cli"] }
dotlottie_player = { path = "../dotlottie-rs" }
dotlottie_fms = { path = "../dotlottie-fms" }
cfg-if = "1.0"

[build-dependencies]
uniffi = { version = "0.26.0", features = ["build"] }
uniffi = { version = "0.25.3", features = ["build"] }
lazy_static = "1.4"
28 changes: 20 additions & 8 deletions dotlottie-ffi/emscripten_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ EMSCRIPTEN_BINDINGS(DotLottiePlayer)

// Register std::vector<float> as VectorFloat for the Config::segments field
register_vector<float>("VectorFloat");
// register_vector<std::string>("VectorString");
// register_vector<ManifestTheme>("VectorManifestTheme");
// register_vector<ManifestAnimation>("VectorManifestAnimation");

enum_<Mode>("Mode")
.value("Forward", Mode::FORWARD)
Expand All @@ -41,10 +44,7 @@ EMSCRIPTEN_BINDINGS(DotLottiePlayer)

// value_object<ManifestTheme>("ManifestTheme")
// .field("id", &ManifestTheme::id)
// .field("values", &ManifestTheme::values);

// value_object<ManifestThemes>("ManifestThemes")
// .field("value", &ManifestThemes::value);
// .field("animations", &ManifestTheme::animations);

// value_object<ManifestAnimation>("ManifestAnimation")
// .field("autoplay", &ManifestAnimation::autoplay)
Expand All @@ -71,7 +71,19 @@ EMSCRIPTEN_BINDINGS(DotLottiePlayer)
// .field("states", &Manifest::states)
// .field("version", &Manifest::version);

// class_<Observer>("Observer")
// .smart_ptr<std::shared_ptr<Observer>>("Observer")
// .function("onFrame", &Observer::on_frame)
// .function("onLoad", &Observer::on_load)
// .function("onLoop", &Observer::on_loop)
// .function("onPause", &Observer::on_pause)
// .function("onPlay", &Observer::on_play)
// .function("onRender", &Observer::on_render)
// .function("onComplete", &Observer::on_complete)
// .function("onStop", &Observer::on_stop);

class_<DotLottiePlayer>("DotLottiePlayer")
.smart_ptr<std::shared_ptr<DotLottiePlayer>>("DotLottiePlayer")
.constructor(&DotLottiePlayer::init, allow_raw_pointers())
.function("buffer", &buffer)
.function("clear", &DotLottiePlayer::clear)
Expand All @@ -86,7 +98,7 @@ EMSCRIPTEN_BINDINGS(DotLottiePlayer)
.function("loadAnimationPath", &DotLottiePlayer::load_animation_path, allow_raw_pointers())
.function("loadDotLottieData", &load_dotlottie_data, allow_raw_pointers())
.function("loadAnimation", &DotLottiePlayer::load_animation, allow_raw_pointers())
// FIXME: .function("manifest", &DotLottiePlayer::manifest)
// .function("manifest", &DotLottiePlayer::manifest)
.function("manifestString", &DotLottiePlayer::manifest_string)
.function("loopCount", &DotLottiePlayer::loop_count)
.function("pause", &DotLottiePlayer::pause)
Expand All @@ -98,7 +110,7 @@ EMSCRIPTEN_BINDINGS(DotLottiePlayer)
.function("setFrame", &DotLottiePlayer::set_frame)
.function("stop", &DotLottiePlayer::stop)
.function("totalFrames", &DotLottiePlayer::total_frames)
.function("subscribe", &DotLottiePlayer::subscribe)
.function("unsubscribe", &DotLottiePlayer::unsubscribe)
// .function("subscribe", &DotLottiePlayer::subscribe)
// .function("unsubscribe", &DotLottiePlayer::unsubscribe)
.function("isComplete", &DotLottiePlayer::is_complete);
}
}
8 changes: 2 additions & 6 deletions dotlottie-ffi/src/dotlottie_player.udl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ dictionary Config {

dictionary ManifestTheme {
string id;
sequence<string> values;
};

dictionary ManifestThemes {
sequence<ManifestTheme>? value;
sequence<string> animations;
};

dictionary ManifestAnimation {
Expand All @@ -61,7 +57,7 @@ dictionary Manifest {
string? generator;
string? keywords;
u32? revision;
ManifestThemes? themes;
sequence<ManifestTheme>? themes;
sequence<string>? states;
string? version;
};
Expand Down
36 changes: 16 additions & 20 deletions dotlottie-ffi/src/dotlottie_player_cpp.udl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
namespace dotlottie_player {
};

[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();
};
/// [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",
Expand All @@ -32,11 +32,7 @@ dictionary Config {

dictionary ManifestTheme {
string id;
sequence<string> values;
};

dictionary ManifestThemes {
sequence<ManifestTheme>? value;
sequence<string> animations;
};

dictionary ManifestAnimation {
Expand All @@ -61,7 +57,7 @@ dictionary Manifest {
string? generator;
string? keywords;
u32? revision;
ManifestThemes? themes;
sequence<ManifestTheme>? themes;
sequence<string>? states;
string? version;
};
Expand All @@ -72,7 +68,7 @@ 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();
/// Manifest? manifest();
string manifest_string();
u64 buffer_ptr();
u64 buffer_len();
Expand All @@ -94,7 +90,7 @@ interface DotLottiePlayer {
boolean render();
boolean resize(u32 width, u32 height);
void clear();
void subscribe(Observer observer);
void unsubscribe([ByRef] Observer observer);
/// void subscribe(Observer observer);
/// void unsubscribe([ByRef] Observer observer);
boolean is_complete();
};
13 changes: 7 additions & 6 deletions dotlottie-fms/src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use json::{self, array, object};

use crate::{ManifestAnimation, ManifestThemes};
use crate::{ManifestAnimation, ManifestTheme};
use serde::{Deserialize, Serialize};

use std::fmt::Display;
Expand All @@ -15,7 +15,7 @@ pub struct Manifest {
pub generator: Option<String>,
pub keywords: Option<String>,
pub revision: Option<u32>,
pub themes: Option<ManifestThemes>,
pub themes: Option<Vec<ManifestTheme>>,
pub states: Option<Vec<String>>,
pub version: Option<String>,
}
Expand All @@ -28,7 +28,7 @@ impl Manifest {
author: Some("LottieFiles".to_string()),
// custom,
description: None,
generator: Some("dotLottie-utils".to_string()),
generator: Some("dotLottie-fms".to_string()),
keywords: Some("dotLottie".to_string()),
revision: Some(1),
themes: None,
Expand All @@ -54,9 +54,10 @@ impl Manifest {
json["description"] = self.description.clone().into();
}
if let Some(themes) = &self.themes {
if !themes.clone().value.unwrap().is_empty() {
json["themes"] = themes.to_json();
}
json["themes"] = array!(themes
.iter()
.map(|t| t.to_json())
.collect::<Vec<json::JsonValue>>());
}
if let Some(states) = &self.states {
json["states"] = array!(states
Expand Down
59 changes: 2 additions & 57 deletions dotlottie-fms/src/manifest_themes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,17 @@ use json::{self, object};

use serde::{Deserialize, Serialize};

use std::fmt::Display;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ManifestTheme {
pub id: String,
pub values: Vec<String>,
pub animations: Vec<String>,
}

impl ManifestTheme {
pub fn to_json(&self) -> json::JsonValue {
object! {
"id" => self.id.clone(),
"values" => self.values.clone(),
}
}
}

impl Display for ManifestTheme {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let json_value = object! {
"id" => self.id.clone(),
"values" => self.values.clone(),
};
write!(f, "{}", json_value)
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ManifestThemes {
pub value: Option<Vec<ManifestTheme>>,
}

impl ManifestThemes {
pub fn to_json(&self) -> json::JsonValue {
if self.value.is_none() {
return json::JsonValue::Array(vec![]);
}

let animations_json: Vec<json::JsonValue> = self
.value
.as_ref()
.unwrap()
.iter()
.map(|themes| themes.to_json())
.collect();

json::JsonValue::Array(animations_json)
}
}

impl std::fmt::Display for ManifestThemes {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match &self.value {
Some(themes) => {
let themes_json = themes
.iter()
.map(|theme| theme.to_json()) // Assuming ManifestTheme implements Display
.collect::<Vec<json::JsonValue>>();

write!(
f,
"[{}]",
json::stringify(json::JsonValue::Array(themes_json))
)
}
None => write!(f, "[]"),
"animations" => self.animations.clone(),
}
}
}
Loading