Skip to content

Commit 0c851ce

Browse files
authored
Merge pull request #276 from YarnSpinnerTool/0.8
Release 0.8
2 parents a7764e3 + 8165b76 commit 0c851ce

File tree

18 files changed

+1531
-796
lines changed

18 files changed

+1531
-796
lines changed

Cargo.lock

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

crates/bevy_plugin/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_yarnspinner"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition = "2024"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
@@ -21,7 +21,7 @@ anyhow = "1"
2121
csv = "1"
2222
serde = { version = "1", features = [ "derive" ] }
2323
yarnspinner_internal_shared = { path = "../internal_shared", version = "0.1.0" }
24-
yarnspinner = { path = "../yarnspinner", features = [ "bevy", "serde" ], version = "0.7.0" }
24+
yarnspinner = { path = "../yarnspinner", features = [ "bevy", "serde" ], version = "0.8.0" }
2525
sha2 = "0.10"
2626
variadics_please = "1"
2727

@@ -40,4 +40,4 @@ default-features = false
4040
features = [ "bevy_core_pipeline", "bevy_audio" ]
4141

4242
[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))'.dependencies]
43-
glob = "0.3.1"
43+
glob = "0.3.3"

crates/codegen/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ name = "generate_proto"
1818
required-features = ["proto"]
1919

2020
[dependencies]
21-
prost = { version = "0.12", optional = true }
22-
prost-build = { version = "0.12", optional = true }
21+
prost = { version = "0.14", optional = true }
22+
prost-build = { version = "0.14", optional = true }

crates/compiler/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "yarnspinner_compiler"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition = "2024"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
@@ -19,17 +19,17 @@ antlr-rust = "=0.3.0-beta"
1919
better_any = "=0.2.0"
2020
regex = "1"
2121
yarnspinner_internal_shared = { path = "../internal_shared", version = "0.1.0" }
22-
yarnspinner_core = { path = "../core", version = "0.7.0" }
23-
annotate-snippets = "0.10"
22+
yarnspinner_core = { path = "../core", version = "0.8.0" }
23+
annotate-snippets = "0.12"
2424
serde = { version = "1", features = [ "derive" ], optional = true }
2525
serde_json = { version = "1", optional = true }
2626
bevy = { version = "0.18", default-features = false, optional = true }
27-
rand = { version = "0.9", features = [ "small_rng" ] }
27+
rand = { version = "0.10", default-features = false }
2828
crc32fast = "1.5"
2929
globset = "0.4"
3030
walkdir = "2.5"
3131

3232
[target.'cfg(target_arch = "wasm32")'.dependencies]
33-
instant = { version = "0.1.12", features = [
33+
instant = { version = "0.1.13", features = [
3434
"wasm-bindgen",
3535
] } # see https://github.com/Amanieu/parking_lot/issues/269, pulled in by (unmaintained) anltr-rust

crates/compiler/src/listeners/error_listener/diagnostic.rs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::parser_rule_context_ext::ParserRuleContextExt;
22
use crate::prelude::*;
3-
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
3+
use annotate_snippets::renderer::DecorStyle;
4+
use annotate_snippets::{AnnotationKind, Level, Renderer, Snippet};
45
use antlr_rust::rule_context::CustomRuleContext;
56
use antlr_rust::token::Token;
67
use antlr_rust::token_factory::TokenFactory;
@@ -108,43 +109,32 @@ impl Diagnostic {
108109
impl Display for Diagnostic {
109110
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
110111
let label = &self.message;
111-
let annotation_type = match self.severity {
112-
DiagnosticSeverity::Error => AnnotationType::Error,
113-
DiagnosticSeverity::Warning => AnnotationType::Warning,
112+
let level = match self.severity {
113+
DiagnosticSeverity::Error => Level::ERROR,
114+
DiagnosticSeverity::Warning => Level::WARNING,
114115
};
115-
let snippet = Snippet {
116-
title: Some(Annotation {
117-
label: Some(label),
118-
id: None,
119-
annotation_type,
120-
}),
121-
footer: vec![],
122-
slices: vec![Slice {
123-
source: self.context.as_deref().unwrap_or("<unknown line>"),
124-
line_start: self.start_line + 1,
125-
origin: self.file_name.as_deref(),
126-
fold: false,
127-
annotations: vec![SourceAnnotation {
128-
label: "",
129-
annotation_type,
130-
range: convert_absolute_range_to_relative(self),
131-
}],
132-
}],
133-
};
134-
let renderer = Renderer::styled();
135-
let annotations = renderer.render(snippet);
116+
let report = level.primary_title(label).id("Y001").element(
117+
Snippet::source(self.context.as_deref().unwrap_or("<unknown line>"))
118+
.line_start(self.start_line + 1)
119+
.path(self.file_name.as_deref())
120+
.fold(false)
121+
.annotation(AnnotationKind::Primary.span(convert_absolute_range_to_relative(self))),
122+
);
123+
// Using `plain` until https://github.com/tokio-rs/tracing/issues/3378 is resolved... bleh
124+
let renderer = Renderer::plain().decor_style(DecorStyle::Unicode);
125+
let annotations = renderer.render(&[report]);
136126
writeln!(f, "{annotations}")?;
137127

138128
Ok(())
139129
}
140130
}
141131

142-
fn convert_absolute_range_to_relative(diagnostic: &Diagnostic) -> (usize, usize) {
132+
fn convert_absolute_range_to_relative(diagnostic: &Diagnostic) -> Range<usize> {
143133
let Some(range) = diagnostic.range.as_ref() else {
144-
return (0, 0);
134+
return 0..1;
145135
};
146136
let Some(context) = diagnostic.context.as_ref() else {
147-
return (0, 0);
137+
return 0..1;
148138
};
149139

150140
let relative_start_line = range.start.line - diagnostic.start_line;
@@ -165,7 +155,7 @@ fn convert_absolute_range_to_relative(diagnostic: &Diagnostic) -> (usize, usize)
165155
let mut char_indices = context.char_indices().map(|(i, _)| i);
166156
let byte_start = char_indices.clone().nth(relative_start).unwrap();
167157
let byte_end = char_indices.nth(relative_end).unwrap_or(byte_start);
168-
(byte_start, byte_end)
158+
byte_start..(byte_end + 1)
169159
}
170160

171161
/// Trait implemented for `Vec<Diagnostic>` to provide utility methods.

crates/compiler/src/listeners/untagged_line_listener.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use antlr_rust::parser_rule_context::ParserRuleContext;
1212
use antlr_rust::token::Token;
1313
use antlr_rust::token_stream::TokenStream;
1414
use antlr_rust::tree::ParseTreeListener;
15-
use rand::{Rng, SeedableRng, rngs::SmallRng};
15+
use rand::RngExt as _;
16+
use rand::rngs::SysRng;
17+
use rand::{SeedableRng, rngs::SmallRng};
1618
use std::cell::RefCell;
1719
use std::rc::Rc;
1820
use std::sync::atomic::AtomicBool;
@@ -42,7 +44,7 @@ impl<'input> UntaggedLineListener<'input> {
4244

4345
/// Generates a new unique line tag that is not present in `existing_line_tags`.
4446
fn generate_string(&self) -> LineId {
45-
let mut rng = SmallRng::from_os_rng();
47+
let mut rng = SmallRng::try_from_rng(&mut SysRng).unwrap();
4648
loop {
4749
let line: usize = rng.random_range(0..0x1000000);
4850
let tag = LineId(format!("{LINE_ID_PREFIX}{line}"));

crates/core/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "yarnspinner_core"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition = "2024"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
1010
description = "Core concepts for Yarn Spinner for Rust, the friendly tool for writing game dialogue"
1111

1212
[target.wasm32-unknown-unknown.dependencies]
13-
getrandom = { version = "0.3", features = [ "wasm_js" ] }
13+
getrandom = { version = "0.4", features = [ "wasm_js" ] }
1414

1515
[features]
1616
default = [ "std" ]
@@ -19,12 +19,12 @@ serde = [ "dep:serde", "bevy?/serialize", "hashbrown/serde" ]
1919
bevy = [ "dep:bevy" ]
2020

2121
[dependencies]
22-
rand = { version = "0.9", default-features = false, features = [ "small_rng" ] }
23-
prost = { version = "0.12", default-features = false, features = [ "prost-derive" ] }
22+
rand = { version = "0.10", default-features = false, features = [ "sys_rng" ] }
23+
prost = { version = "0.14", default-features = false, features = [ "derive" ] }
2424
serde = { version = "1", features = [ "derive" ], optional = true }
2525
bevy = { version = "0.18", default-features = false, optional = true, features = [ "std" ] }
2626
variadics_please = "1.1.0"
27-
hashbrown = "0.15.2"
27+
hashbrown = "0.16.1"
2828
yarnspinner_internal_shared = { path = "../internal_shared", version = "0.1.0" }
2929

3030
[dev-dependencies]

crates/core/src/library.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use alloc::borrow::Cow;
55
use core::fmt::Display;
66

77
use hashbrown::hash_map;
8-
use rand::{Rng, SeedableRng, rngs::SmallRng};
8+
use rand::{
9+
RngExt as _, SeedableRng,
10+
rngs::{SmallRng, SysRng},
11+
};
912

1013
/// A collection of functions that can be called from Yarn scripts.
1114
///
@@ -78,21 +81,21 @@ impl Library {
7881
"number" => |value: YarnValue| f32::try_from(value).expect("Failed to convert a Yarn value to a number"),
7982
"bool" => |value: YarnValue| bool::try_from(value).expect("Failed to convert a Yarn value to a bool"),
8083
"format_invariant" => |value: f32| value.to_string(),
81-
"random" => || SmallRng::from_os_rng().random_range(0.0..1.0),
84+
"random" => ||SmallRng::try_from_rng(&mut SysRng).unwrap().random_range(0.0..1.0),
8285
"random_range" => |min: f32, max: f32| {
8386
if let Some(min) = min.as_int()
8487
&& let Some(max_inclusive) = max.as_int()
8588
{
86-
return SmallRng::from_os_rng().random_range(min..=max_inclusive) as f32;
89+
return SmallRng::try_from_rng(&mut SysRng).unwrap().random_range(min..=max_inclusive) as f32;
8790
}
88-
SmallRng::from_os_rng().random_range(min..max)
91+
SmallRng::try_from_rng(&mut SysRng).unwrap().random_range(min..max)
8992
},
90-
"random_range_float" => |min: f32, max: f32| rand::random_range::<f32, _>(min..=max),
93+
"random_range_float" => |min: f32, max: f32| SmallRng::try_from_rng(&mut SysRng).unwrap().random_range::<f32, _>(min..=max),
9194
"dice" => |sides: u32| {
9295
if sides == 0 {
9396
return 1;
9497
}
95-
SmallRng::from_os_rng().random_range(1..=sides)
98+
SmallRng::try_from_rng(&mut SysRng).unwrap().random_range(1..=sides)
9699
},
97100
"round" => |value: f32| value.round() as i32,
98101
"round_places" => |value: f32, places: u32| value.round_places(places),

crates/example_dialogue_view/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_yarnspinner_example_dialogue_view"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition = "2024"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
@@ -14,7 +14,7 @@ readme = "../../readme.md"
1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515

1616
[dependencies]
17-
bevy_yarnspinner = { path = "../bevy_plugin", version = "0.7.0" }
17+
bevy_yarnspinner = { path = "../bevy_plugin", version = "0.8.0" }
1818
unicode-segmentation = "1"
1919

2020
[dependencies.bevy]

crates/runtime/Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "yarnspinner_runtime"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition = "2024"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
@@ -12,8 +12,6 @@ description = "Runtime / VM for Yarn Spinner for Rust, the friendly tool for wri
1212
[features]
1313
default = ["std"]
1414
std = [
15-
"icu_locid/std",
16-
"icu_plurals/std",
1715
"fixed_decimal/ryu",
1816
"unicode-normalization/std",
1917
"bevy_platform/std",
@@ -22,20 +20,20 @@ serde = [
2220
"dep:serde",
2321
"bevy?/serialize",
2422
"yarnspinner_core/serde",
25-
"icu_locid/serde",
23+
"icu_locale_core/serde",
2624
"bevy_platform/serialize",
2725
]
2826
bevy = ["dep:bevy", "yarnspinner_core/bevy"]
2927

3028
[dependencies]
3129
yarnspinner_internal_shared = { path = "../internal_shared", version = "0.1.0" }
32-
yarnspinner_core = { path = "../core", version = "0.7.0" }
30+
yarnspinner_core = { path = "../core", version = "0.8.0" }
3331
unicode-normalization = { version = "0.1", default-features = false }
3432
unicode-segmentation = "1"
3533
log = "0.4"
36-
icu_plurals = { version = "1.5", features = ["default"] }
37-
icu_locid = { version = "1.5", default-features = false }
38-
fixed_decimal = { version = "0.5", default-features = false, features = [
34+
icu_plurals = { version = "2", features = ["default"] }
35+
icu_locale_core = { version = "2", default-features = false }
36+
fixed_decimal = { version = "0.7", default-features = false, features = [
3937
"ryu",
4038
] }
4139
once_cell = "1"

0 commit comments

Comments
 (0)