Skip to content

Commit

Permalink
Merge pull request #796 from scala-js/compression
Browse files Browse the repository at this point in the history
Add Compression APIs
  • Loading branch information
armanbilge authored Aug 5, 2023
2 parents 8c52373 + 1d2abf1 commit c042b7e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions dom/src/main/scala-2/org/scalajs/dom/CompressionFormat.scala
Original file line number Diff line number Diff line change
@@ -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]
}
13 changes: 13 additions & 0 deletions dom/src/main/scala-3/org/scalajs/dom/CompressionFormat.scala
Original file line number Diff line number Diff line change
@@ -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"
}
19 changes: 19 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/CompressionStream.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** 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
}
19 changes: 19 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/DecompressionStream.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** 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
}

0 comments on commit c042b7e

Please sign in to comment.