From 89312b3037f046dce4db5fddc83d5e7f8782d8b2 Mon Sep 17 00:00:00 2001 From: David Barri Date: Sun, 15 Nov 2020 14:46:11 +1100 Subject: [PATCH 1/2] Avoid forcing evaluation of crypto Having `val crypto` in the package object means that when it's undefined an exception is thrown immediately, which makes it impossible to use the WebCrypto facade in such a case. An example situation where this is preventative is using the WebCrypto API from Node where its available as a library and not globally available. --- src/main/scala/org/scalajs/dom/crypto/package.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/org/scalajs/dom/crypto/package.scala b/src/main/scala/org/scalajs/dom/crypto/package.scala index 796fa3c9a..a77f845ee 100644 --- a/src/main/scala/org/scalajs/dom/crypto/package.scala +++ b/src/main/scala/org/scalajs/dom/crypto/package.scala @@ -7,7 +7,7 @@ import scala.scalajs.js.| import scala.language.implicitConversions package object crypto { - val crypto = GlobalCrypto.crypto + @inline def crypto = GlobalCrypto.crypto type BigInteger = Uint8Array From a9ac287dd98ed119e276d369b79db336fdde1071 Mon Sep 17 00:00:00 2001 From: David Barri Date: Fri, 20 Aug 2021 12:18:33 +1000 Subject: [PATCH 2/2] Run `sbt prePR` --- api-reports/2_12.txt | 2 +- api-reports/2_13.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 3f4f8df0b..694632428 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -204,7 +204,7 @@ crypto/package[SO] type HashAlgorithmIdentifier = HashAlgorithm | String crypto/package[SO] type KeyAlgorithmIdentifier = KeyAlgorithm | String crypto/package[SO] implicit def arrayBuffer2BufferSource(b: ArrayBuffer): BufferSource crypto/package[SO] implicit def arrayBufferView2BufferSource(b: ArrayBufferView): BufferSource -crypto/package[SO] val crypto = GlobalCrypto.crypto +crypto/package[SO] def crypto = GlobalCrypto.crypto crypto/package.BufferSource[JT] css[SO] type FontFaceRule = raw.CSSFontFaceRule css[SO] type ImportRule = raw.CSSImportRule diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index f726af3aa..80e2cbcb9 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -204,7 +204,7 @@ crypto/package[SO] type HashAlgorithmIdentifier = HashAlgorithm | String crypto/package[SO] type KeyAlgorithmIdentifier = KeyAlgorithm | String crypto/package[SO] implicit def arrayBuffer2BufferSource(b: ArrayBuffer): BufferSource crypto/package[SO] implicit def arrayBufferView2BufferSource(b: ArrayBufferView): BufferSource -crypto/package[SO] val crypto = GlobalCrypto.crypto +crypto/package[SO] def crypto = GlobalCrypto.crypto crypto/package.BufferSource[JT] css[SO] type FontFaceRule = raw.CSSFontFaceRule css[SO] type ImportRule = raw.CSSImportRule