diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 33085d86c..446672788 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -2534,9 +2534,12 @@ raw/BiquadFilterNode[JT] val numberOfOutputs: Int raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit raw/BiquadFilterNode[JT] var `type`: String -raw/Blob[JC] def close(): Unit +raw/Blob[JC] def arrayBuffer(): js.Promise[ArrayBuffer] +raw/Blob[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit raw/Blob[JC] def size: Double raw/Blob[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob +raw/Blob[JC] def stream(): ReadableStream[Byte] +raw/Blob[JC] def text(): js.Promise[String] raw/Blob[JC] def `type`: String raw/Blob[JO] raw/BlobPropertyBag[JT] def endings: String @@ -3770,10 +3773,13 @@ raw/EventTarget[JC] def dispatchEvent(evt: Event): Boolean raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit raw/External[JT] -raw/File[JC] def close(): Unit +raw/File[JC] def arrayBuffer(): js.Promise[ArrayBuffer] +raw/File[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit raw/File[JC] def name: String raw/File[JC] def size: Double raw/File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob +raw/File[JC] def stream(): ReadableStream[Byte] +raw/File[JC] def text(): js.Promise[String] raw/File[JC] def `type`: String raw/FileList[JT] @scala.scalajs.js.annotation.JSBracketAccess def apply(index: Int): T raw/FileList[JT] def item(index: Int): T diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 23b3e8b97..a9f7be132 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -2534,9 +2534,12 @@ raw/BiquadFilterNode[JT] val numberOfOutputs: Int raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit raw/BiquadFilterNode[JT] var `type`: String -raw/Blob[JC] def close(): Unit +raw/Blob[JC] def arrayBuffer(): js.Promise[ArrayBuffer] +raw/Blob[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit raw/Blob[JC] def size: Double raw/Blob[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob +raw/Blob[JC] def stream(): ReadableStream[Byte] +raw/Blob[JC] def text(): js.Promise[String] raw/Blob[JC] def `type`: String raw/Blob[JO] raw/BlobPropertyBag[JT] def endings: String @@ -3770,10 +3773,13 @@ raw/EventTarget[JC] def dispatchEvent(evt: Event): Boolean raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit raw/External[JT] -raw/File[JC] def close(): Unit +raw/File[JC] def arrayBuffer(): js.Promise[ArrayBuffer] +raw/File[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit raw/File[JC] def name: String raw/File[JC] def size: Double raw/File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob +raw/File[JC] def stream(): ReadableStream[Byte] +raw/File[JC] def text(): js.Promise[String] raw/File[JC] def `type`: String raw/FileList[JT] @scala.scalajs.js.annotation.JSBracketAccess def apply(index: Int): T raw/FileList[JT] def item(index: Int): T diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index 6189da275..a1bf2132a 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -9,6 +9,7 @@ */ package org.scalajs.dom.raw +import org.scalajs.dom.experimental.ReadableStream import scala.scalajs.js import scala.scalajs.js.annotation._ import scala.scalajs.js.typedarray.ArrayBuffer @@ -7839,14 +7840,18 @@ object BlobPropertyBag { } /** - * A Blob object represents a file-like object of immutable, raw data. Blobs - * represent data that isn't necessarily in a JavaScript-native format. The File - * interface is based on Blob, inheriting blob functionality and expanding it to - * support files on the user's system. + * A Blob object represents a file-like object of immutable, raw data; they can be + * read as text or binary data, or converted into a ReadableStream so its methods + * can be used for processing the data. Blobs can represent data that isn't + * necessarily in a JavaScript-native format. The File interface is based on Blob, + * inheriting blob functionality and expanding it to support files on the user's system. * - * An easy way to construct a Blob is by invoking the Blob constuctor. Another - * way is to use the slice() method to create a blob that contains a subset of - * another blob's data. + * To construct a Blob from other non-blob objects and data, use the Blob() + * constructor. To create a blob that contains a subset of another blob's data, use the + * slice() method. To obtain a Blob object for a file on the user's file system, see + * the File documentation. + * + * The APIs accepting Blob objects are also listed in the File documentation. * * MDN */ @@ -7856,7 +7861,10 @@ class Blob(blobParts: js.Array[js.Any] = js.native, options: BlobPropertyBag = js.native) extends js.Object { - def `type`: String = js.native + @deprecated( + "This method seems to have been added in error and not actually exist.", + "1.2.0") + def close(): Unit = js.native /** * The size, in bytes, of the data contained in the Blob object. @@ -7866,15 +7874,44 @@ class Blob(blobParts: js.Array[js.Any] = js.native, def size: Double = js.native /** - * The slice is used to create a new Blob object containing the data in the specified - * range of bytes of the source Blob. + * A string indicating the MIME type of the data contained in the Blob. If the type + * is unknown, this string is empty. + * + * MDN + */ + def `type`: String = js.native + + /** + * A string indicating the MIME type of the data contained in the Blob. If the type + * is unknown, this string is empty. * * MDN */ def slice(start: Double = js.native, end: Double = js.native, contentType: String = js.native): Blob = js.native - def close(): Unit = js.native + /** + * Returns a ReadableStream that can be used to read the contents of the blob. + * + * MDN + */ + def stream(): ReadableStream[Byte] = js.native + + /** + * Returns a promise that resolves with a USVString containing the entire + * contents of the blob interpreted as UTF-8 text. + * + * MDN + * + * @see https://developer.mozilla.org/en-US/docs/Web/API/USVString + */ + def text(): js.Promise[String] = js.native + + /** + * Returns a promise that resolves with an ArrayBuffer containing the entire + * contents of the blob as binary data. + */ + def arrayBuffer(): js.Promise[ArrayBuffer] = js.native } @js.native