Skip to content

Commit c13db04

Browse files
committed
remove usage of getrandom in rand dependency and in our crate
- we use rand internally to create random names for div's and for file names, for that reason highly performant crypto and/or efficinet entropy generators are not a priority. Using rand with minimal features and no `getrandom` simplifies usage for downstream users as they don't need the custom WASM rustc flags for `getrandom` and `wasm_js` feature - bump versions Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent 773343a commit c13db04

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

.cargo/config.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6-
## [0.13.5] - 2025-07-30
6+
## [0.13.5] - 2025-07-31
77

88
### Fixed
99

10+
- [[#346](https://github.com/plotly/plotly.rs/pull/346)] Remove usage of `getrandom` for `rand` dependency and for this crate
1011
- [[#345](https://github.com/plotly/plotly.rs/pull/345)] Re-export `ImageFormat` from `plotly_static` into `plotly`
1112

1213
## [0.13.4] - 2025-07-17

plotly/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plotly"
3-
version = "0.13.4"
3+
version = "0.13.5"
44
description = "A plotting library powered by Plotly.js"
55
authors = [
66
"Ioannis Giagkiozis <[email protected]>",
@@ -60,10 +60,12 @@ serde = { version = "1.0", features = ["derive"] }
6060
serde_json = "1.0"
6161
serde_repr = "0.1"
6262
serde_with = ">=2, <4"
63-
rand = "0.9"
63+
rand = { version = "0.9", default-features = false, features = [
64+
"small_rng",
65+
"alloc",
66+
] }
6467

6568
[target.'cfg(target_arch = "wasm32")'.dependencies]
66-
getrandom = { version = "0.3", features = ["wasm_js"] }
6769
wasm-bindgen-futures = { version = "0.4" }
6870
wasm-bindgen = { version = "0.2" }
6971
serde-wasm-bindgen = { version = "0.6.3" }

plotly/src/plot.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use plotly_kaleido::ImageFormat;
99
use plotly_static::ImageFormat;
1010
use rand::{
1111
distr::{Alphanumeric, SampleString},
12-
rng,
12+
rngs::SmallRng,
13+
SeedableRng,
1314
};
1415
use serde::Serialize;
1516

@@ -265,12 +266,11 @@ impl Plot {
265266
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
266267
pub fn show(&self) {
267268
use std::env;
268-
269269
let rendered = self.render();
270270

271271
// Set up the temp file with a unique filename.
272272
let mut temp = env::temp_dir();
273-
let mut plot_name = Alphanumeric.sample_string(&mut rng(), 22);
273+
let mut plot_name = Alphanumeric.sample_string(&mut SmallRng::seed_from_u64(42), 22);
274274
plot_name.push_str(".html");
275275
plot_name = format!("plotly_{plot_name}");
276276
temp.push(plot_name);
@@ -313,7 +313,7 @@ impl Plot {
313313

314314
// Set up the temp file with a unique filename.
315315
let mut temp = env::temp_dir();
316-
let mut plot_name = Alphanumeric.sample_string(&mut rng(), 22);
316+
let mut plot_name = Alphanumeric.sample_string(&mut SmallRng::seed_from_u64(42), 22);
317317
plot_name.push_str(".html");
318318
plot_name = format!("plotly_{plot_name}");
319319
temp.push(plot_name);
@@ -371,13 +371,13 @@ impl Plot {
371371
pub fn to_inline_html(&self, plot_div_id: Option<&str>) -> String {
372372
let plot_div_id = match plot_div_id {
373373
Some(id) => id.to_string(),
374-
None => Alphanumeric.sample_string(&mut rng(), 20),
374+
None => Alphanumeric.sample_string(&mut SmallRng::seed_from_u64(42), 20),
375375
};
376376
self.render_inline(&plot_div_id)
377377
}
378378

379379
fn to_jupyter_notebook_html(&self) -> String {
380-
let plot_div_id = Alphanumeric.sample_string(&mut rng(), 20);
380+
let plot_div_id = Alphanumeric.sample_string(&mut SmallRng::seed_from_u64(42), 20);
381381

382382
let tmpl = JupyterNotebookPlotTemplate {
383383
plot: self,

plotly_derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plotly_derive"
3-
version = "0.13.4"
3+
version = "0.13.5"
44
description = "Internal proc macro crate for Plotly-rs."
55
authors = ["Ioannis Giagkiozis <[email protected]>"]
66
license = "MIT"

plotly_kaleido/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plotly_kaleido"
3-
version = "0.13.4"
3+
version = "0.13.5"
44
description = "Additional output format support for plotly using Kaleido"
55
authors = [
66
"Ioannis Giagkiozis <[email protected]>",

0 commit comments

Comments
 (0)