Skip to content

Commit 205a2c0

Browse files
authored
Merge pull request #117 from scpwiki/dependencies
[chore] Update dependencies
2 parents f28f54c + fc104ca commit 205a2c0

5 files changed

Lines changed: 40 additions & 43 deletions

File tree

.tarpaulin.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ all-features = true
44
workspace = true
55
exclude-files = [
66
"src/wasm/*",
7+
"src/render/html/random.rs",
78
]
89

910
[report]

Cargo.toml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["wikidot", "wikijump", "ftml", "parsing", "html"]
88
categories = ["parser-implementations"]
99
exclude = [".gitignore", ".editorconfig"]
1010

11-
version = "1.41.0"
11+
version = "1.42.0"
1212
authors = ["Emmie Smith <emmie.maeda@gmail.com>"]
1313
edition = "2024"
1414

@@ -27,19 +27,19 @@ mathml = ["html", "latex2mathml"]
2727
cfg-if = "1"
2828
enum-map = "2"
2929
entities = "1"
30-
icu_calendar = "2.1"
31-
icu_decimal = "2.1"
32-
icu_datetime = { version = "2.1", features = ["compiled_data"] }
33-
icu_experimental = { version = "0.4", features = ["compiled_data"] }
34-
icu_locale = "2.1"
30+
icu_calendar = "2.2"
31+
icu_decimal = "2.2"
32+
icu_datetime = { version = "2.2", features = ["compiled_data"] }
33+
icu_experimental = { version = "0.5", features = ["compiled_data"] }
34+
icu_locale = "2.2"
3535
latex2mathml = { version = "0.2", optional = true }
36-
lightningcss = { version = "1.0.0-alpha.67", optional = true }
36+
lightningcss = { version = "1.0.0-alpha.70", optional = true }
3737
log = "0.4"
3838
maplit = "1"
3939
pest = "2"
4040
pest_derive = "2"
41-
rand = { version = "0.9", features = ["small_rng"] }
42-
ref-map = "0.1"
41+
rand = "0.10"
42+
ref-map = "0.2"
4343
regex = "1"
4444
serde = { version = "1", features = ["derive"] }
4545
serde_json = "1"
@@ -62,7 +62,14 @@ proptest = "1"
6262
termcolor = "1"
6363

6464
[target.'cfg(target_arch = "wasm32")'.dependencies]
65-
getrandom = { version = "0.3", features = ["wasm_js"] }
65+
getrandom = { version = "0.4", features = ["wasm_js"] }
66+
# Ugly annoying bullshit because downstream packages depend on
67+
# getrandom v3, but for WASM we need this feature flag or only
68+
# these versions of getrandom won't be able to get OS entropy.
69+
#
70+
# I hate this and we should remove this once all child dependencies
71+
# stop depending on this version. Ugh.
72+
getrandom3 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }
6673
self_cell = "1.0"
6774
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
6875
web-sys = { version = "0.3", features = ["console"] }

src/includes/includer/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'t> Display for MapWrap<'_, 't> {
9090
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9191
// Get all entries and sort by key
9292
let mut entries: Vec<(&Cow<'t, str>, &Cow<'t, str>)> = self.0.iter().collect();
93-
entries.sort_by(|(key1, _), (key2, _)| key1.cmp(key2));
93+
entries.sort_by_key(|(key, _)| *key);
9494

9595
// Write all entries
9696
write!(f, "{{")?;

src/render/html/random.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,8 @@
1919
*/
2020

2121
use cfg_if::cfg_if;
22-
use rand::{Rng, SeedableRng, distr::Alphanumeric, rngs::SmallRng};
23-
use std::iter;
24-
25-
#[cfg(test)]
26-
const TEST_RANDOM_SEED: [u8; 32] = [
27-
0x53, 0x43, 0x50, 0x2d, 0x31, 0x37, 0x33, 0x3a, 0x20, 0x4d, 0x6f, 0x76, 0x65, 0x64,
28-
0x20, 0x74, 0x6f, 0x20, 0x53, 0x69, 0x74, 0x65, 0x2d, 0x31, 0x39, 0x20, 0x31, 0x39,
29-
0x39, 0x33, 0x2e, 0x0a,
30-
];
22+
use rand::distr::{Alphanumeric, SampleString};
23+
use rand::rngs::SmallRng;
3124

3225
#[derive(Debug)]
3326
pub struct Random {
@@ -39,9 +32,10 @@ impl Default for Random {
3932
fn default() -> Self {
4033
cfg_if! {
4134
if #[cfg(test)] {
42-
let rng = SmallRng::from_seed(TEST_RANDOM_SEED);
35+
use rand::SeedableRng;
36+
let rng = SmallRng::seed_from_u64(1);
4337
} else {
44-
let rng = SmallRng::from_rng(&mut rand::rng());
38+
let rng = rand::make_rng();
4539
}
4640
}
4741

@@ -52,13 +46,7 @@ impl Default for Random {
5246
impl Random {
5347
pub fn generate_html_id_into(&mut self, buffer: &mut String) {
5448
buffer.push_str("wj-id-");
55-
56-
let char_stream = iter::repeat(())
57-
.map(|_| self.rng.sample(Alphanumeric))
58-
.map(char::from)
59-
.take(16);
60-
61-
buffer.extend(char_stream);
49+
Alphanumeric.append_string(&mut self.rng, buffer, 16);
6250
}
6351

6452
pub fn generate_html_id(&mut self) -> String {
@@ -80,13 +68,13 @@ fn html_id() {
8068

8169
rand.generate_html_id_into(&mut buffer);
8270
assert_eq!(
83-
buffer, "wj-id-bW5Ql2DLZtnd9s18",
71+
buffer, "wj-id-zvGvLlhGI6VEZFKj",
8472
"Generated HTML ID doesn't match expected",
8573
);
8674

8775
let html_id = rand.generate_html_id();
8876
assert_eq!(
89-
html_id, "wj-id-ePZbhugrfP89c4Fk",
77+
html_id, "wj-id-e9pQyKaPmLnulpgn",
9078
"Generated HTML ID doesn't match expected",
9179
);
9280
}

src/tree/date.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,34 +338,35 @@ fn append_relative_time(
338338
let formatter = match unit {
339339
RelativeTimeUnit::Second => RelativeTimeFormatter::try_new_long_second(
340340
prefs,
341-
RelativeTimeFormatterOptions {
342-
numeric: Numeric::Always,
343-
},
341+
relative_time_fmt_options(Numeric::Always),
344342
),
345343
RelativeTimeUnit::Minute => RelativeTimeFormatter::try_new_long_minute(
346344
prefs,
347-
RelativeTimeFormatterOptions {
348-
numeric: Numeric::Always,
349-
},
345+
relative_time_fmt_options(Numeric::Always),
350346
),
351347
RelativeTimeUnit::Hour => RelativeTimeFormatter::try_new_long_hour(
352348
prefs,
353-
RelativeTimeFormatterOptions {
354-
numeric: Numeric::Always,
355-
},
349+
relative_time_fmt_options(Numeric::Always),
356350
),
357351
RelativeTimeUnit::Day => RelativeTimeFormatter::try_new_long_day(
358352
prefs,
359-
RelativeTimeFormatterOptions {
360-
numeric: Numeric::Auto,
361-
},
353+
relative_time_fmt_options(Numeric::Auto),
362354
),
363355
}
364356
.map_err(localization_error)?;
365357

366358
append_normalized_display(rendered, formatter.format(Decimal::from(value)))
367359
}
368360

361+
/// Helper to create a `RelativeTimeFormatterOptions`.
362+
/// Because the struct is non-exhaustive, we cannot use the struct syntax to
363+
/// create new instances here.
364+
fn relative_time_fmt_options(numeric: Numeric) -> RelativeTimeFormatterOptions {
365+
let mut options = RelativeTimeFormatterOptions::default();
366+
options.numeric = numeric;
367+
options
368+
}
369+
369370
fn relative_time_value(datetime: OffsetDateTime) -> (i64, RelativeTimeUnit) {
370371
let delta_seconds = datetime.unix_timestamp() - now().timestamp();
371372
let abs_delta = delta_seconds.unsigned_abs();

0 commit comments

Comments
 (0)