From f347479ec19c7ce54df4542315222629feb96d10 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 20 Jul 2023 19:48:48 +0000 Subject: [PATCH 1/2] Add Compression APIs --- api-reports/2_12.txt | 8 ++++++++ api-reports/2_13.txt | 8 ++++++++ .../org/scalajs/dom/CompressionFormat.scala | 14 +++++++++++++ .../org/scalajs/dom/CompressionFormat.scala | 13 ++++++++++++ .../org/scalajs/dom/CompressionStream.scala | 20 +++++++++++++++++++ .../org/scalajs/dom/DecompressionStream.scala | 20 +++++++++++++++++++ 6 files changed, 83 insertions(+) create mode 100644 dom/src/main/scala-2/org/scalajs/dom/CompressionFormat.scala create mode 100644 dom/src/main/scala-3/org/scalajs/dom/CompressionFormat.scala create mode 100644 dom/src/main/scala/org/scalajs/dom/CompressionStream.scala create mode 100644 dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index e57d886a6..f11ffed63 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1348,6 +1348,12 @@ CompositionEventInit[JT] var detail: js.UndefOr[Int] CompositionEventInit[JT] var locale: js.UndefOr[String] CompositionEventInit[JT] var scoped: js.UndefOr[Boolean] CompositionEventInit[JT] var view: js.UndefOr[Window] +CompressionFormat[JT] +CompressionFormat[SO] val deflate: CompressionFormat +CompressionFormat[SO] val `deflate-raw`: CompressionFormat +CompressionFormat[SO] val gzip: CompressionFormat +CompressionStream[JC] def readable: ReadableStream[Uint8Array] +CompressionStream[JC] def writable: WriteableStream[Uint8Array] ConcatParams[JT] val algorithmId: BufferSource ConcatParams[JT] val hash: HashAlgorithmIdentifier ConcatParams[JT] val name: String @@ -1561,6 +1567,8 @@ DataTransferItemList[JC] @js.annotation.JSBracketAccess def apply(index: Int): D DataTransferItemList[JC] def clear(): Unit DataTransferItemList[JC] def length: Int DataTransferItemList[JC] def remove(index: Int): Unit +DecompressionStream[JC] def readable: ReadableStream[Uint8Array] +DecompressionStream[JC] def writable: WriteableStream[Uint8Array] DedicatedWorkerGlobalScope[JO] def self: DedicatedWorkerGlobalScope DedicatedWorkerGlobalScope[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit DedicatedWorkerGlobalScope[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index e57d886a6..f11ffed63 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1348,6 +1348,12 @@ CompositionEventInit[JT] var detail: js.UndefOr[Int] CompositionEventInit[JT] var locale: js.UndefOr[String] CompositionEventInit[JT] var scoped: js.UndefOr[Boolean] CompositionEventInit[JT] var view: js.UndefOr[Window] +CompressionFormat[JT] +CompressionFormat[SO] val deflate: CompressionFormat +CompressionFormat[SO] val `deflate-raw`: CompressionFormat +CompressionFormat[SO] val gzip: CompressionFormat +CompressionStream[JC] def readable: ReadableStream[Uint8Array] +CompressionStream[JC] def writable: WriteableStream[Uint8Array] ConcatParams[JT] val algorithmId: BufferSource ConcatParams[JT] val hash: HashAlgorithmIdentifier ConcatParams[JT] val name: String @@ -1561,6 +1567,8 @@ DataTransferItemList[JC] @js.annotation.JSBracketAccess def apply(index: Int): D DataTransferItemList[JC] def clear(): Unit DataTransferItemList[JC] def length: Int DataTransferItemList[JC] def remove(index: Int): Unit +DecompressionStream[JC] def readable: ReadableStream[Uint8Array] +DecompressionStream[JC] def writable: WriteableStream[Uint8Array] DedicatedWorkerGlobalScope[JO] def self: DedicatedWorkerGlobalScope DedicatedWorkerGlobalScope[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit DedicatedWorkerGlobalScope[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit diff --git a/dom/src/main/scala-2/org/scalajs/dom/CompressionFormat.scala b/dom/src/main/scala-2/org/scalajs/dom/CompressionFormat.scala new file mode 100644 index 000000000..220dcc8f4 --- /dev/null +++ b/dom/src/main/scala-2/org/scalajs/dom/CompressionFormat.scala @@ -0,0 +1,14 @@ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +sealed trait CompressionFormat extends js.Any + +object CompressionFormat { + val deflate: CompressionFormat = "deflate".asInstanceOf[CompressionFormat] + + val `deflate-raw`: CompressionFormat = "deflate-raw".asInstanceOf[CompressionFormat] + + val gzip: CompressionFormat = "gzip".asInstanceOf[CompressionFormat] +} diff --git a/dom/src/main/scala-3/org/scalajs/dom/CompressionFormat.scala b/dom/src/main/scala-3/org/scalajs/dom/CompressionFormat.scala new file mode 100644 index 000000000..cd5d630bc --- /dev/null +++ b/dom/src/main/scala-3/org/scalajs/dom/CompressionFormat.scala @@ -0,0 +1,13 @@ +package org.scalajs.dom + +import scala.scalajs.js + +opaque type CompressionFormat <: String = String + +object CompressionFormat { + val deflate: CompressionFormat = "deflate" + + val `deflate-raw`: CompressionFormat = "deflate-raw" + + val gzip: CompressionFormat = "gzip" +} diff --git a/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala b/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala new file mode 100644 index 000000000..213ff6ae0 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala @@ -0,0 +1,20 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ +import scala.scalajs.js.typedarray.Uint8Array + +/** An API for compressing a stream of data. + */ +@js.native +@JSGlobal +class CompressionStream(format: CompressionFormat) extends js.Object { + def readable: ReadableStream[Uint8Array] = js.native + def writable: WriteableStream[Uint8Array] = js.native +} diff --git a/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala b/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala new file mode 100644 index 000000000..857cb6623 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala @@ -0,0 +1,20 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ +import scala.scalajs.js.typedarray.Uint8Array + +/** An API for decompressing a stream of data. + */ +@js.native +@JSGlobal +class DecompressionStream(format: CompressionFormat) extends js.Object { + def readable: ReadableStream[Uint8Array] = js.native + def writable: WriteableStream[Uint8Array] = js.native +} From 1d2abf1a97a162e962f25d9616edbdfd0d1ed153 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 20 Jul 2023 23:18:26 +0000 Subject: [PATCH 2/2] Formatting --- dom/src/main/scala/org/scalajs/dom/CompressionStream.scala | 3 +-- dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala b/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala index 213ff6ae0..7842b46a4 100644 --- a/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala +++ b/dom/src/main/scala/org/scalajs/dom/CompressionStream.scala @@ -10,8 +10,7 @@ import scala.scalajs.js import scala.scalajs.js.annotation._ import scala.scalajs.js.typedarray.Uint8Array -/** An API for compressing a stream of data. - */ +/** An API for compressing a stream of data. */ @js.native @JSGlobal class CompressionStream(format: CompressionFormat) extends js.Object { diff --git a/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala b/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala index 857cb6623..8eb1f9ccb 100644 --- a/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala +++ b/dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala @@ -10,8 +10,7 @@ import scala.scalajs.js import scala.scalajs.js.annotation._ import scala.scalajs.js.typedarray.Uint8Array -/** An API for decompressing a stream of data. - */ +/** An API for decompressing a stream of data. */ @js.native @JSGlobal class DecompressionStream(format: CompressionFormat) extends js.Object {