Skip to content

Commit 87eb66e

Browse files
authored
Merge pull request #240 from YarnSpinnerTool/prepare-for-release
Prepare for release
2 parents 4954837 + 75a45a0 commit 87eb66e

File tree

14 files changed

+274
-157
lines changed

14 files changed

+274
-157
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,32 @@ jobs:
116116
run: cargo test --no-default-features -p yarnspinner -p yarnspinner_without_bevy_examples
117117
- name: Run doc tests for non-bevy
118118
run: LD_LIBRARY_PATH="$(rustc --print target-libdir)" cargo test --doc --no-default-features -p yarnspinner -p yarnspinner_without_bevy_examples
119+
120+
build-web:
121+
name: Build demo for web
122+
runs-on: ubuntu-latest
123+
timeout-minutes: 30
124+
steps:
125+
- name: Checkout repository
126+
uses: actions/checkout@v4
127+
128+
- name: Install Rust toolchain
129+
uses: dtolnay/rust-toolchain@stable
130+
with:
131+
targets: wasm32-unknown-unknown
132+
133+
- name: Install dependencies
134+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
135+
136+
- name: Populate target directory from cache
137+
uses: Leafwing-Studios/cargo-cache@v2
138+
with:
139+
sweep-cache: true
140+
141+
- name: Install Bevy CLI
142+
run: cargo install --git=https://github.com/TheBevyFlock/bevy_cli --locked bevy_cli
143+
144+
- name: Build for web
145+
run: |
146+
cd demo
147+
bevy build --locked --all-targets --yes -p bevy_yarnspinner_demo web

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bevy_plugin/src/commands/command_wrapping.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::prelude::*;
22
use bevy::ecs::system::SystemId;
33
use bevy::prelude::*;
4+
#[cfg(not(target_arch = "wasm32"))]
45
use bevy::tasks::Task;
56
use std::fmt::{Debug, Display, Formatter};
67
use std::marker::PhantomData;
@@ -126,9 +127,21 @@ impl<T: TaskFinishedIndicator> TaskFinishedIndicator for Vec<T> {
126127
}
127128
}
128129

129-
impl TaskFinishedIndicator for Task<()> {
130+
#[cfg(not(target_arch = "wasm32"))]
131+
impl<T: Debug + Send + Sync + 'static> TaskFinishedIndicator for Task<T> {
130132
fn is_finished(&self) -> bool {
131-
self.is_finished()
133+
// Little hack because calling Task::is_finished() would not resolve to the correct function,
134+
// resulting in a recursive call to TaskFinishedIndicator::is_finished().
135+
task_finished_name_change::is_finished_(self)
136+
}
137+
}
138+
139+
#[cfg(not(target_arch = "wasm32"))]
140+
mod task_finished_name_change {
141+
pub(super) fn is_finished_<T: std::fmt::Debug + Send + Sync + 'static>(
142+
task: &bevy::tasks::Task<T>,
143+
) -> bool {
144+
bevy::tasks::Task::is_finished(task)
132145
}
133146
}
134147

crates/bevy_plugin/src/dialogue_runner/runtime_interaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn continue_runtime(
118118
let new_events = if let Some(unsent_events) = unsent_events.take() {
119119
unsent_events
120120
} else {
121-
dialogue.continue_(world)?
121+
dialogue.continue_with_world(world)?
122122
};
123123
events.replace(new_events);
124124
}

crates/core/src/yarn_fn/function_registry.rs

Lines changed: 61 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ mod tests {
107107

108108
functions.register_function("test", || true);
109109
let function = functions.get("test").unwrap();
110-
let result: bool = function
111-
.call(
112-
vec![],
113-
#[cfg(feature = "bevy")]
114-
&mut World::default(),
115-
)
116-
.try_into()
117-
.unwrap();
110+
let params = vec![];
111+
#[cfg(feature = "bevy")]
112+
let result = function.call_with_world(params, &mut World::default());
113+
#[cfg(not(feature = "bevy"))]
114+
let result = function.call(params);
115+
let result: bool = result.try_into().unwrap();
118116

119117
assert!(result);
120118
}
@@ -125,14 +123,12 @@ mod tests {
125123

126124
functions.register_function("test", |a: f32| a);
127125
let function = functions.get("test").unwrap();
128-
let result: f32 = function
129-
.call(
130-
to_function_params([1.0]),
131-
#[cfg(feature = "bevy")]
132-
&mut World::default(),
133-
)
134-
.try_into()
135-
.unwrap();
126+
let params = to_function_params([1.0]);
127+
#[cfg(feature = "bevy")]
128+
let result = function.call_with_world(params, &mut World::default());
129+
#[cfg(not(feature = "bevy"))]
130+
let result = function.call(params);
131+
let result: f32 = result.try_into().unwrap();
136132

137133
assert_eq!(result, 1.0);
138134
}
@@ -159,8 +155,13 @@ mod tests {
159155
);
160156

161157
let function1 = functions.get("test1").unwrap();
162-
let result1: bool = function1.call(vec![], &mut world).try_into().unwrap();
163-
assert!(result1);
158+
let params = vec![];
159+
#[cfg(feature = "bevy")]
160+
let result = function1.call_with_world(params, &mut world);
161+
#[cfg(not(feature = "bevy"))]
162+
let result = function1.call(params);
163+
let result: bool = result.try_into().unwrap();
164+
assert!(result);
164165
}
165166

166167
#[test]
@@ -183,22 +184,18 @@ mod tests {
183184
#[cfg(feature = "bevy")]
184185
let mut world = World::default();
185186

186-
let result1: bool = function1
187-
.call(
188-
vec![],
189-
#[cfg(feature = "bevy")]
190-
&mut world,
191-
)
192-
.try_into()
193-
.unwrap();
194-
let result2: f32 = function2
195-
.call(
196-
to_function_params([1.0]),
197-
#[cfg(feature = "bevy")]
198-
&mut world,
199-
)
200-
.try_into()
201-
.unwrap();
187+
let params1 = vec![];
188+
let params2 = to_function_params([1.0]);
189+
#[cfg(feature = "bevy")]
190+
let result1 = function1.call_with_world(params1, &mut world);
191+
#[cfg(not(feature = "bevy"))]
192+
let result1 = function1.call(params1);
193+
let result1: bool = result1.try_into().unwrap();
194+
#[cfg(feature = "bevy")]
195+
let result2 = function2.call_with_world(params2, &mut world);
196+
#[cfg(not(feature = "bevy"))]
197+
let result2 = function2.call(params2);
198+
let result2: f32 = result2.try_into().unwrap();
202199

203200
assert!(result1);
204201
assert_eq!(result2, 1.0);
@@ -224,43 +221,36 @@ mod tests {
224221
#[cfg(feature = "bevy")]
225222
let mut world = World::default();
226223

227-
let result1: bool = function1
228-
.call(
229-
vec![],
230-
#[cfg(feature = "bevy")]
231-
&mut world,
232-
)
233-
.try_into()
234-
.unwrap();
235-
let result2: f32 = function2
236-
.call(
237-
to_function_params([1.0, 2.0]),
238-
#[cfg(feature = "bevy")]
239-
&mut world,
240-
)
241-
.try_into()
242-
.unwrap();
243-
let result3: f32 = function3
244-
.call(
245-
to_function_params([1.0, 2.0, 3.0]),
246-
#[cfg(feature = "bevy")]
247-
&mut world,
248-
)
249-
.try_into()
250-
.unwrap();
251-
let result4: String = function4
252-
.call(
253-
to_function_params([
254-
YarnValue::from("a"),
255-
"b".into(),
256-
"c".into(),
257-
true.into(),
258-
1.0.into(),
259-
]),
260-
#[cfg(feature = "bevy")]
261-
&mut world,
262-
)
263-
.into();
224+
let params1 = vec![];
225+
let params2 = to_function_params([1.0, 2.0]);
226+
let params3 = to_function_params([1.0, 2.0, 3.0]);
227+
let params4 = to_function_params([
228+
YarnValue::from("a"),
229+
"b".into(),
230+
"c".into(),
231+
true.into(),
232+
1.0.into(),
233+
]);
234+
#[cfg(feature = "bevy")]
235+
let result1 = function1.call_with_world(params1, &mut world);
236+
#[cfg(not(feature = "bevy"))]
237+
let result1 = function1.call(params1);
238+
let result1: bool = result1.try_into().unwrap();
239+
#[cfg(feature = "bevy")]
240+
let result2 = function2.call_with_world(params2, &mut world);
241+
#[cfg(not(feature = "bevy"))]
242+
let result2 = function2.call(params2);
243+
let result2: f32 = result2.try_into().unwrap();
244+
#[cfg(feature = "bevy")]
245+
let result3 = function3.call_with_world(params3, &mut world);
246+
#[cfg(not(feature = "bevy"))]
247+
let result3 = function3.call(params3);
248+
let result3: f32 = result3.try_into().unwrap();
249+
#[cfg(feature = "bevy")]
250+
let result4 = function4.call_with_world(params4, &mut world);
251+
#[cfg(not(feature = "bevy"))]
252+
let result4 = function4.call(params4);
253+
let result4: String = result4.into();
264254

265255
assert!(result1);
266256
assert_eq!(result2, 3.0);

0 commit comments

Comments
 (0)