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

Replace rand with fastrand #105

Merged
merged 1 commit into from
Dec 9, 2021
Merged

Replace rand with fastrand #105

merged 1 commit into from
Dec 9, 2021

Conversation

paolobarbolini
Copy link
Contributor

This has the advantage of removing a total of about 8 dependencies and adds support for wasm browser environments.

@kaj
Copy link
Owner

kaj commented May 9, 2021

Hm ... fastrand doesn't seem to do anything fishy other than maybe beeing a little too simplistic, both in the random number generation and in the seeding. But then, I don't think cryptographically strong random numbers is actually needed in sass.

I'll think about it for a bit longer.

@paolobarbolini
Copy link
Contributor Author

paolobarbolini commented Aug 19, 2021

I see two users have respectively left a 👍 and a ❤️ on the PR. Any updates @kaj?
I'm not sure where I would use a random number that changes everytime I recompile my .scss files, but scss has it so let's support it. Having a slow to compile cryptographically secure random number generator though starts to get noticeable.

@Maistho
Copy link

Maistho commented Oct 16, 2021

For what it's worth, the dart-sass implementation of random also doesn't use a cryptographically strong random number generator.

The default implementation supplies a stream of pseudo-random bits that are not suitable for cryptographic purposes.

https://api.dart.dev/stable/2.14.2/dart-math/Random-class.html

@kaj
Copy link
Owner

kaj commented Dec 9, 2021

I have considered this. Then I have done other things and pretty much ignored rsass for a while, sorry abut that ...

But now I have considered this again and decided to merge it. :-)

Thanks for the contribution!

@kaj kaj merged commit b3a7fe0 into kaj:master Dec 9, 2021
kaj added a commit that referenced this pull request Dec 9, 2021
kaj added a commit that referenced this pull request Dec 10, 2021
Released 2021-12-10.
Progress: 3849 of 6444 tests passed in dart-sass compatibility mode
(this may seem like a regression, but that is caused by changed in the
test suite).

### Breaking changes

* `Error` has a new alternative, `AtError`.
* In `sass::Item`, the `Error`, `MixinCall` and `MixinDeclaration`
  variants is changed to include a `SourcePos`.  Also, a `sass::Mixin`
  contains a `SourcePos` for where it is declared.
* The fields of `SourcePos` is now private.
* The `name` of a `sass::Item::AtRule` is now a SassString.
* A `css::Value::Literal` now contains a `CssString` rather than a
  `String` and a `Quotes`.  Evaluating a `SassString` also returns a
  `CssString` (PR #118).
* The selector types are split from one `selector` module to the `css`
  and `sass` modules.  Anything that used `selector` types should now
  use either `css` or `sass` types (PR #123).

### Improvements

* A css call is just a special kind of string.
* Include position of directive or function call when reporting
  `@error` errors.
* Improve error reporting from inside mixins and functions.
* Support interpolation in `@`-rule names.
* Fixed #116: The `sass:map.merge` function was buggy.
* Fixed #119: `saturate(200%)` is allowed (the argument is not limited
  to 0..100%).
* `sass:selector` functions `append`, `nest`, and `parse` are closer
  to correct (PR #123).
* `sass:meta` functions `calc-args` and `calc-name` implemented (PR #126).
* Css strings and selectors can now be parsed directly (PR #123).
* Fixed reformatting of to-much-indented comments.
* Fixed panics in some color arithmetic (Issue #120, #121, #122, PR #125).
* Replace rand with fastrand, hopefully compile faster (PR #105).
* Unicode Private-use characters are escaped when printed.
* Updated `nom` to 7.0 and `nom-locate` to 4.0.
* Update sass-spec test suite to 2021-11-30.

Thanks to @paolobarbolini, @connorskees and @charlesxsh for reporting
issues.
kaj added a commit that referenced this pull request Dec 10, 2021
Released 2021-12-10.
Progress: 3849 of 6444 tests passed in dart-sass compatibility mode
(this may seem like a regression, but that is caused by changed in the
test suite).

* `Error` has a new alternative, `AtError`.
* In `sass::Item`, the `Error`, `MixinCall` and `MixinDeclaration`
  variants is changed to include a `SourcePos`.  Also, a `sass::Mixin`
  contains a `SourcePos` for where it is declared.
* The fields of `SourcePos` is now private.
* The `name` of a `sass::Item::AtRule` is now a SassString.
* A `css::Value::Literal` now contains a `CssString` rather than a
  `String` and a `Quotes`.  Evaluating a `SassString` also returns a
  `CssString` (PR #118).
* The selector types are split from one `selector` module to the `css`
  and `sass` modules.  Anything that used `selector` types should now
  use either `css` or `sass` types (PR #123).

* A css call is just a special kind of string.
* Include position of directive or function call when reporting
  `@error` errors.
* Improve error reporting from inside mixins and functions.
* Support interpolation in `@`-rule names.
* Fixed #116: The `sass:map.merge` function was buggy.
* Fixed #119: `saturate(200%)` is allowed (the argument is not limited
  to 0..100%).
* `sass:selector` functions `append`, `nest`, and `parse` are closer
  to correct (PR #123).
* `sass:meta` functions `calc-args` and `calc-name` implemented (PR #126).
* Css strings and selectors can now be parsed directly (PR #123).
* Fixed reformatting of to-much-indented comments.
* Fixed panics in some color arithmetic (Issue #120, #121, #122, PR #125).
* Replace rand with fastrand, hopefully compile faster (PR #105).
* Unicode Private-use characters are escaped when printed.
* Updated `nom` to 7.0 and `nom-locate` to 4.0.
* Update sass-spec test suite to 2021-11-30.

Thanks to @paolobarbolini, @connorskees and @charlesxsh for reporting
issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants