From 1604459234253b784f8dc976e4b8a7bcbbac4584 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 21 Aug 2022 17:12:43 +0200 Subject: [PATCH 1/8] Fixup File API --- dom/src/main/scala/org/scalajs/dom/File.scala | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/dom/src/main/scala/org/scalajs/dom/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index 4a7003f11..79c534653 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -19,8 +19,28 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -abstract class File extends Blob { +abstract class File[A](bits: js.Iterable[A], name: String, options: FileOptions) extends Blob { /** 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: Int = 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 +} + +/** An options object containing optional attributes for the file. */ +trait FileOptions extends js.Object { + var `type`: js.UndefOr[String] = js.undefined + var lastModified: js.UndefOr[Int] = js.undefined } From 6a010e322c0dd0a5007036260ba8dae0599d18c7 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 21 Aug 2022 17:20:44 +0200 Subject: [PATCH 2/8] Fixup File API with preSBT changes --- api-reports/2_12.txt | 5 ++++- api-reports/2_13.txt | 5 ++++- dom/src/main/scala/org/scalajs/dom/File.scala | 5 +---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 98edbd087..3056b93c3 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1946,15 +1946,18 @@ 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 name: String +File[JC] def lastModified: Int 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 +FileOptions[JT] var lastModified: js.UndefOr[Int] +FileOptions[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 diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 98edbd087..3056b93c3 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1946,15 +1946,18 @@ 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 name: String +File[JC] def lastModified: Int 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 +FileOptions[JT] var lastModified: js.UndefOr[Int] +FileOptions[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 diff --git a/dom/src/main/scala/org/scalajs/dom/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index 79c534653..d1a7f7d4e 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -19,10 +19,7 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -abstract class File[A](bits: js.Iterable[A], name: String, options: FileOptions) extends Blob { - - /** Returns the name of the file. For security reasons, the path is excluded from this property. */ - def name: String = js.native +abstract class File(bits: js.Iterable[Any], name: String, options: FileOptions) extends Blob { /** 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 From 9dabc3a93d5dd0a95821f08760292090e30080a6 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 21 Aug 2022 18:14:47 +0200 Subject: [PATCH 3/8] FileOptions changed to adhere to the spec and put in its own file --- dom/src/main/scala/org/scalajs/dom/File.scala | 10 ++-------- .../main/scala/org/scalajs/dom/FilePropertyBag.scala | 8 ++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala diff --git a/dom/src/main/scala/org/scalajs/dom/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index d1a7f7d4e..29faadb1e 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -19,7 +19,7 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -abstract class File(bits: js.Iterable[Any], name: String, options: FileOptions) extends Blob { +class File(bits: js.Iterable[Any], name: String, options: FilePropertyBag) extends Blob { /** 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 @@ -34,10 +34,4 @@ abstract class File(bits: js.Iterable[Any], name: String, options: FileOptions) * A string containing the path of the file relative to the ancestor directory the user selected. */ def webkitRelativePath: String = js.native -} - -/** An options object containing optional attributes for the file. */ -trait FileOptions extends js.Object { - var `type`: js.UndefOr[String] = js.undefined - var lastModified: js.UndefOr[Int] = js.undefined -} +} \ No newline at end of file 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..344c28b87 --- /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[Int] = js.undefined +} From 6b375a9cf5f2d42388bdb44f45eb91be92d98c42 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 21 Aug 2022 18:20:45 +0200 Subject: [PATCH 4/8] preSBT fixes --- api-reports/2_12.txt | 5 +++-- api-reports/2_13.txt | 5 +++-- dom/src/main/scala/org/scalajs/dom/File.scala | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 3056b93c3..a50d34418 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1956,8 +1956,9 @@ 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 -FileOptions[JT] var lastModified: js.UndefOr[Int] -FileOptions[JT] var `type`: js.UndefOr[String] +FilePropertyBag[JT] var endings: js.UndefOr[String] +FilePropertyBag[JT] var lastModified: js.UndefOr[Int] +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 diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 3056b93c3..a50d34418 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1956,8 +1956,9 @@ 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 -FileOptions[JT] var lastModified: js.UndefOr[Int] -FileOptions[JT] var `type`: js.UndefOr[String] +FilePropertyBag[JT] var endings: js.UndefOr[String] +FilePropertyBag[JT] var lastModified: js.UndefOr[Int] +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 diff --git a/dom/src/main/scala/org/scalajs/dom/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index 29faadb1e..6d6e1468c 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -34,4 +34,4 @@ class File(bits: js.Iterable[Any], name: String, options: FilePropertyBag) exten * A string containing the path of the file relative to the ancestor directory the user selected. */ def webkitRelativePath: String = js.native -} \ No newline at end of file +} From d0ef86075938a087501279279c453ca34ceb8493 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 21 Aug 2022 20:51:40 +0200 Subject: [PATCH 5/8] prePR commit --- api-reports/2_12.txt | 1 + api-reports/2_13.txt | 1 + dom/src/main/scala/org/scalajs/dom/Blob.scala | 2 +- dom/src/main/scala/org/scalajs/dom/File.scala | 3 ++- dom/src/main/scala/org/scalajs/dom/package.scala | 2 ++ 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index a50d34418..778d68534 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -26930,6 +26930,7 @@ intl/NumberFormatOptions[SO] def apply(localeMatcher: js.UndefOr[String]?, style package[SO] type AlgorithmIdentifier = Algorithm | String package[SO] type BigInteger = js.typedarray.Uint8Array package[SO] type BodyInit = Blob | BufferSource | FormData | String | ReadableStream[Uint8Array] | URLSearchParams +package[SO] type BlobPart = BufferSource | Blob | String package[SO] type BufferSource = ArrayBufferView | ArrayBuffer package[SO] type ByteString = String package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index a50d34418..778d68534 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -26930,6 +26930,7 @@ intl/NumberFormatOptions[SO] def apply(localeMatcher: js.UndefOr[String]?, style package[SO] type AlgorithmIdentifier = Algorithm | String package[SO] type BigInteger = js.typedarray.Uint8Array package[SO] type BodyInit = Blob | BufferSource | FormData | String | ReadableStream[Uint8Array] | URLSearchParams +package[SO] type BlobPart = BufferSource | Blob | String package[SO] type BufferSource = ArrayBufferView | ArrayBuffer package[SO] type ByteString = String package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) 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/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index 6d6e1468c..0e05ea166 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -19,7 +19,8 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -class File(bits: js.Iterable[Any], name: String, options: FilePropertyBag) extends Blob { +class File(bits: js.Iterable[BlobPart], name: String, options: FilePropertyBag = js.native) + extends Blob(bits, options) { /** 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 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 } From 335d828d8145251b06d5e8bfa7799eb737c368de Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 22 Aug 2022 17:22:29 +0200 Subject: [PATCH 6/8] Rebased and renamed name member in the constructor --- api-reports/2_12.txt | 3 ++- api-reports/2_13.txt | 3 ++- dom/src/main/scala/org/scalajs/dom/File.scala | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 778d68534..569be3567 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1947,6 +1947,7 @@ 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: Int +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] @@ -26929,8 +26930,8 @@ 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 BodyInit = Blob | BufferSource | FormData | String | ReadableStream[Uint8Array] | URLSearchParams 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 package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 778d68534..569be3567 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1947,6 +1947,7 @@ 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: Int +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] @@ -26929,8 +26930,8 @@ 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 BodyInit = Blob | BufferSource | FormData | String | ReadableStream[Uint8Array] | URLSearchParams 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 package[SO] type ClientRect = DOMRect (@deprecated in 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 0e05ea166..00deea1c6 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -19,9 +19,12 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -class File(bits: js.Iterable[BlobPart], name: String, options: FilePropertyBag = js.native) +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. From a9451fd909a943c5c2b130531f3b41bc6e2b4f2b Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 22 Aug 2022 17:53:57 +0200 Subject: [PATCH 7/8] Double type for lastModified --- api-reports/2_12.txt | 4 ++-- api-reports/2_13.txt | 4 ++-- dom/src/main/scala/org/scalajs/dom/File.scala | 2 +- dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 569be3567..425ce42e7 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1946,7 +1946,7 @@ 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: Int +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 @@ -1958,7 +1958,7 @@ 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[String] -FilePropertyBag[JT] var lastModified: js.UndefOr[Int] +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 diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 569be3567..425ce42e7 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1946,7 +1946,7 @@ 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: Int +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 @@ -1958,7 +1958,7 @@ 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[String] -FilePropertyBag[JT] var lastModified: js.UndefOr[Int] +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 diff --git a/dom/src/main/scala/org/scalajs/dom/File.scala b/dom/src/main/scala/org/scalajs/dom/File.scala index 00deea1c6..f405b5758 100644 --- a/dom/src/main/scala/org/scalajs/dom/File.scala +++ b/dom/src/main/scala/org/scalajs/dom/File.scala @@ -29,7 +29,7 @@ class File(bits: js.Iterable[BlobPart], _name: String, options: FilePropertyBag * since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current * date. */ - def lastModified: Int = js.native + 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. diff --git a/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala b/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala index 344c28b87..b7ee4e25b 100644 --- a/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala +++ b/dom/src/main/scala/org/scalajs/dom/FilePropertyBag.scala @@ -4,5 +4,5 @@ import scala.scalajs.js /** An options object containing optional attributes for the file. */ trait FilePropertyBag extends BlobPropertyBag { - var lastModified: js.UndefOr[Int] = js.undefined + var lastModified: js.UndefOr[Double] = js.undefined } From 997e36f1f3ba0bbdbdf60eccd5a9cdd4761f4057 Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 22 Aug 2022 18:13:28 +0200 Subject: [PATCH 8/8] EndingType enum for endings --- api-reports/2_12.txt | 7 +++++-- api-reports/2_13.txt | 7 +++++-- .../scala-2/org/scalajs/dom/EndingType.scala | 16 ++++++++++++++++ .../scala-3/org/scalajs/dom/EndingType.scala | 14 ++++++++++++++ .../scala/org/scalajs/dom/BlobPropertyBag.scala | 2 +- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 dom/src/main/scala-2/org/scalajs/dom/EndingType.scala create mode 100644 dom/src/main/scala-3/org/scalajs/dom/EndingType.scala diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 425ce42e7..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 @@ -1957,7 +1960,7 @@ 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[String] +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 diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 425ce42e7..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 @@ -1957,7 +1960,7 @@ 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[String] +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 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/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")