diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 98edbd087..9a4935c94 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -373,7 +373,7 @@ Blob[JC] def stream(): ReadableStream[Uint8Array] Blob[JC] def text(): js.Promise[String] Blob[JC] def `type`: String Blob[JO] -BlobPropertyBag[JT] var endings: js.UndefOr[String] +BlobPropertyBag[JT] var endings: js.UndefOr[EndingType] BlobPropertyBag[JT] var `type`: js.UndefOr[String] BlobPropertyBag[SO] def apply(`type`: js.UndefOr[String]?): BlobPropertyBag (@deprecated in 2.0.0) Body[JT] def arrayBuffer(): js.Promise[ArrayBuffer] @@ -1801,6 +1801,9 @@ ElementDefinitionOptions[JT] var `extends`: js.UndefOr[String] EndOfStreamError[JT] EndOfStreamError[SO] val decode: EndOfStreamError EndOfStreamError[SO] val network: EndOfStreamError +EndingType[JT] +EndingType[SO] val native: EndingType +EndingType[SO] val transparent: EndingType ErrorEvent[JT] def bubbles: Boolean ErrorEvent[JT] def cancelBubble: Boolean ErrorEvent[JT] def cancelable: Boolean @@ -1946,15 +1949,20 @@ FetchEventInit[JT] var request: js.UndefOr[Request] FetchEventInit[JT] var scoped: js.UndefOr[Boolean] File[JC] def arrayBuffer(): js.Promise[ArrayBuffer] File[JC] def close(): Unit (@deprecated in 1.2.0) +File[JC] def lastModified: Double File[JC] def name: String File[JC] def size: Double File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob File[JC] def stream(): ReadableStream[Uint8Array] File[JC] def text(): js.Promise[String] File[JC] def `type`: String +File[JC] def webkitRelativePath: String FileList[JC] @JSBracketAccess def apply(index: Int): T FileList[JC] def item(index: Int): File FileList[JC] def length: Int +FilePropertyBag[JT] var endings: js.UndefOr[EndingType] +FilePropertyBag[JT] var lastModified: js.UndefOr[Double] +FilePropertyBag[JT] var `type`: js.UndefOr[String] FileReader[JC] def abort(): Unit FileReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit FileReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -26925,6 +26933,7 @@ intl/NumberFormatOptions[JT] var useGrouping: js.UndefOr[Boolean] intl/NumberFormatOptions[SO] def apply(localeMatcher: js.UndefOr[String]?, style: js.UndefOr[String]?, currency: js.UndefOr[String]?, currencyDisplay: js.UndefOr[String]?, useGrouping: js.UndefOr[Boolean]?, minimumIntegerDigits: js.UndefOr[Double]?, minimumFractionDigits: js.UndefOr[Double]?, maximumFractionDigits: js.UndefOr[Double]?, minimumSignificantDigits: js.UndefOr[Double]?, maximumSignificantDigits: js.UndefOr[Double]?): NumberFormatOptions (@deprecated in 2.0.0) package[SO] type AlgorithmIdentifier = Algorithm | String package[SO] type BigInteger = js.typedarray.Uint8Array +package[SO] type BlobPart = BufferSource | Blob | String package[SO] type BodyInit = Blob | BufferSource | FormData | String | ReadableStream[Uint8Array] | URLSearchParams package[SO] type BufferSource = ArrayBufferView | ArrayBuffer package[SO] type ByteString = String diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 98edbd087..9a4935c94 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -373,7 +373,7 @@ Blob[JC] def stream(): ReadableStream[Uint8Array] Blob[JC] def text(): js.Promise[String] Blob[JC] def `type`: String Blob[JO] -BlobPropertyBag[JT] var endings: js.UndefOr[String] +BlobPropertyBag[JT] var endings: js.UndefOr[EndingType] BlobPropertyBag[JT] var `type`: js.UndefOr[String] BlobPropertyBag[SO] def apply(`type`: js.UndefOr[String]?): BlobPropertyBag (@deprecated in 2.0.0) Body[JT] def arrayBuffer(): js.Promise[ArrayBuffer] @@ -1801,6 +1801,9 @@ ElementDefinitionOptions[JT] var `extends`: js.UndefOr[String] EndOfStreamError[JT] EndOfStreamError[SO] val decode: EndOfStreamError EndOfStreamError[SO] val network: EndOfStreamError +EndingType[JT] +EndingType[SO] val native: EndingType +EndingType[SO] val transparent: EndingType ErrorEvent[JT] def bubbles: Boolean ErrorEvent[JT] def cancelBubble: Boolean ErrorEvent[JT] def cancelable: Boolean @@ -1946,15 +1949,20 @@ FetchEventInit[JT] var request: js.UndefOr[Request] FetchEventInit[JT] var scoped: js.UndefOr[Boolean] File[JC] def arrayBuffer(): js.Promise[ArrayBuffer] File[JC] def close(): Unit (@deprecated in 1.2.0) +File[JC] def lastModified: Double File[JC] def name: String File[JC] def size: Double File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob File[JC] def stream(): ReadableStream[Uint8Array] File[JC] def text(): js.Promise[String] File[JC] def `type`: String +File[JC] def webkitRelativePath: String FileList[JC] @JSBracketAccess def apply(index: Int): T FileList[JC] def item(index: Int): File FileList[JC] def length: Int +FilePropertyBag[JT] var endings: js.UndefOr[EndingType] +FilePropertyBag[JT] var lastModified: js.UndefOr[Double] +FilePropertyBag[JT] var `type`: js.UndefOr[String] FileReader[JC] def abort(): Unit FileReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit FileReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -26925,6 +26933,7 @@ intl/NumberFormatOptions[JT] var useGrouping: js.UndefOr[Boolean] intl/NumberFormatOptions[SO] def apply(localeMatcher: js.UndefOr[String]?, style: js.UndefOr[String]?, currency: js.UndefOr[String]?, currencyDisplay: js.UndefOr[String]?, useGrouping: js.UndefOr[Boolean]?, minimumIntegerDigits: js.UndefOr[Double]?, minimumFractionDigits: js.UndefOr[Double]?, maximumFractionDigits: js.UndefOr[Double]?, minimumSignificantDigits: js.UndefOr[Double]?, maximumSignificantDigits: js.UndefOr[Double]?): NumberFormatOptions (@deprecated in 2.0.0) package[SO] type AlgorithmIdentifier = Algorithm | String package[SO] type BigInteger = js.typedarray.Uint8Array +package[SO] type BlobPart = BufferSource | Blob | String package[SO] type BodyInit = Blob | BufferSource | FormData | String | ReadableStream[Uint8Array] | URLSearchParams package[SO] type BufferSource = ArrayBufferView | ArrayBuffer package[SO] type ByteString = String diff --git a/dom/src/main/scala-2/org/scalajs/dom/EndingType.scala b/dom/src/main/scala-2/org/scalajs/dom/EndingType.scala new file mode 100644 index 000000000..fbb249a3c --- /dev/null +++ b/dom/src/main/scala-2/org/scalajs/dom/EndingType.scala @@ -0,0 +1,16 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** + * Endings enum for [[https://w3c.github.io/FileAPI/#enumdef-endingtype]] + * If set to "native", line endings will be converted to native in any USVString elements in blobParts + */ +@js.native +sealed trait EndingType extends js.Any + +object EndingType { + val transparent: EndingType = "transparent".asInstanceOf[EndingType] + val native: EndingType = "native".asInstanceOf[EndingType] + +} diff --git a/dom/src/main/scala-3/org/scalajs/dom/EndingType.scala b/dom/src/main/scala-3/org/scalajs/dom/EndingType.scala new file mode 100644 index 000000000..01295a3cd --- /dev/null +++ b/dom/src/main/scala-3/org/scalajs/dom/EndingType.scala @@ -0,0 +1,14 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** + * Endings enum for [[https://w3c.github.io/FileAPI/#enumdef-endingtype]] + * If set to "native", line endings will be converted to native in any USVString elements in blobParts + */ +opaque type EndingType <: String = String + +object EndingType { + val transparent: EndingType = "transparent" + val native: EndingType = "native" +} diff --git a/dom/src/main/scala/org/scalajs/dom/Blob.scala b/dom/src/main/scala/org/scalajs/dom/Blob.scala index 5690e3836..cd2156692 100644 --- a/dom/src/main/scala/org/scalajs/dom/Blob.scala +++ b/dom/src/main/scala/org/scalajs/dom/Blob.scala @@ -23,7 +23,7 @@ import scala.scalajs.js.typedarray.{ArrayBuffer, Uint8Array} */ @js.native @JSGlobal -class Blob(blobParts: js.Array[js.Any] = js.native, options: BlobPropertyBag = js.native) extends js.Object { +class Blob(blobParts: js.Iterable[BlobPart], options: BlobPropertyBag = js.native) extends js.Object { @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit = js.native diff --git a/dom/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala b/dom/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala index f59526533..924bbffac 100644 --- a/dom/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala +++ b/dom/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala @@ -11,7 +11,7 @@ import scala.scalajs.js trait BlobPropertyBag extends js.Object { var `type`: js.UndefOr[String] = js.undefined - var endings: js.UndefOr[String] = js.undefined + var endings: js.UndefOr[EndingType] = js.undefined } @deprecated("all members of BlobPropertyBag are deprecated", "2.0.0") diff --git a/dom/src/main/scala/org/scalajs/dom/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index 4a7003f11..f405b5758 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -19,8 +19,23 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -abstract class File extends Blob { +class File(bits: js.Iterable[BlobPart], _name: String, options: FilePropertyBag = js.native) + extends Blob(bits, options) { /** Returns the name of the file. For security reasons, the path is excluded from this property. */ def name: String = js.native + + /** The File.lastModified read-only property provides the last modified date of the file as the number of milliseconds + * since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current + * date. + */ + def lastModified: Double = js.native + + /** The File.webkitRelativePath is a read-only property that contains a string which specifies the file's path + * relative to the directory selected by the user in an element with its webkitdirectory attribute set. + * + * @return + * A string containing the path of the file relative to the ancestor directory the user selected. + */ + def webkitRelativePath: String = js.native } diff --git a/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala b/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala new file mode 100644 index 000000000..b7ee4e25b --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala @@ -0,0 +1,8 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** An options object containing optional attributes for the file. */ +trait FilePropertyBag extends BlobPropertyBag { + var lastModified: js.UndefOr[Double] = js.undefined +} diff --git a/dom/src/main/scala/org/scalajs/dom/package.scala b/dom/src/main/scala/org/scalajs/dom/package.scala index 96b116cad..a17cd5c33 100644 --- a/dom/src/main/scala/org/scalajs/dom/package.scala +++ b/dom/src/main/scala/org/scalajs/dom/package.scala @@ -112,4 +112,6 @@ package object dom { @js.native @JSGlobal("crypto") val webcrypto: Crypto = js.native + + type BlobPart = BufferSource | Blob | String }