Skip to content

Commit 6930cd5

Browse files
authored
Merge branch 'scala-js:main' into add/scala-js#621
2 parents e5596c1 + c70fba0 commit 6930cd5

23 files changed

+522
-41
lines changed

.github/workflows/ghpages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run: sbt readme/run
2020

2121
- name: Deploy
22-
uses: JamesIves/[email protected].0
22+
uses: JamesIves/[email protected].1
2323
with:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
branch: gh-pages

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.5.9
1+
version = 3.6.1
22
runner.dialect = scala213source3
33
project.git = true
44
style = Scala.js

api-reports/2_12.txt

Lines changed: 187 additions & 8 deletions
Large diffs are not rendered by default.

api-reports/2_13.txt

Lines changed: 187 additions & 8 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
/**
6+
* Helps distinguish whether apps "pasting" a clipboard item should insert the contents of an appropriate representation inline at the point of paste or if it should be treated as an attachment.
7+
* See [[https://w3c.github.io/clipboard-apis/#enumdef-presentationstyle PresentationStyle enum]]
8+
*/
9+
@js.native
10+
sealed trait PresentationStyle extends js.Any
11+
12+
object PresentationStyle{
13+
val unspecified: PresentationStyle = "unspecified".asInstanceOf[PresentationStyle]
14+
val inline: PresentationStyle = "inline".asInstanceOf[PresentationStyle]
15+
val attachment: PresentationStyle = "attachment".asInstanceOf[PresentationStyle]
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
/**
6+
* Helps distinguish whether apps "pasting" a clipboard item should insert the contents of an appropriate representation inline at the point of paste or if it should be treated as an attachment.
7+
* See [[https://w3c.github.io/clipboard-apis/#enumdef-presentationstyle PresentationStyle enum]]
8+
*/
9+
opaque type PresentationStyle <: String = String
10+
11+
object PresentationStyle {
12+
val unspecified: PresentationStyle = "unspecified"
13+
val inline: PresentationStyle = "inline"
14+
val attachment: PresentationStyle = "attachment"
15+
}

dom/src/main/scala/org/scalajs/dom/Body.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ trait Body extends js.Object {
2222
/** Takes a Response stream and reads it to completion. It returns a promise that resolves with a FormData object. */
2323
def formData(): js.Promise[FormData] = js.native
2424

25-
/** Takes a Response stream and reads it to completion. It returns a promise that resolves with a JSON object. //todo:
26-
* define the JSON type, and return a Promise[JSON] as per spec
27-
*/
25+
/** Takes a Response stream and reads it to completion. It returns a promise that resolves with a JSON object. */
2826
def json(): js.Promise[js.Any] = js.native
2927

3028
/** Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). */

dom/src/main/scala/org/scalajs/dom/Clipboard.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait Clipboard extends EventTarget {
2525
*
2626
* To read from the clipboard, you must first have the "clipboard-read" permission.
2727
*/
28-
def read(): js.Promise[DataTransfer] = js.native
28+
def read(): js.Promise[js.Array[ClipboardItem]] = js.native
2929

3030
/** The readText() method returns a Promise which resolves with a copy of the textual contents of the system
3131
* clipboard.
@@ -38,7 +38,7 @@ trait Clipboard extends EventTarget {
3838
* Before you can write to the clipboard, you need to use the Permissions API to get the "clipboard-write"
3939
* permission.
4040
*/
41-
def write(data: DataTransfer): js.Promise[Unit] = js.native
41+
def write(data: js.Array[ClipboardItem]): js.Promise[Unit] = js.native
4242

4343
/** The writeText() method writes the specified text string to the system clipboard. */
4444
def writeText(newClipText: String): js.Promise[Unit] = js.native
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API
2+
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later.
3+
* http://creativecommons.org/licenses/by-sa/2.5/
4+
*
5+
* Everything else is under the MIT License http://opensource.org/licenses/MIT
6+
*/
7+
package org.scalajs.dom
8+
9+
import scala.scalajs.js
10+
import scala.scalajs.js.annotation._
11+
12+
/** A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or
13+
* "copy" command
14+
*/
15+
@js.native
16+
@JSGlobal
17+
class ClipboardItem(items: js.Dictionary[ClipboardItemData], options: ClipboardItemOptions = js.native)
18+
extends js.Object {
19+
def presentationStyle: PresentationStyle = js.native
20+
21+
/** Returns an Array of MIME types available within the ClipboardItem. */
22+
def types: FrozenArray[String] = js.native
23+
24+
/** Returns a Promise that resolves with a Blob of the requested MIME type, or an error if the MIME type is not found.
25+
*/
26+
def getType(`type`: String): js.Promise[Blob] = js.native
27+
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API
2+
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later.
3+
* http://creativecommons.org/licenses/by-sa/2.5/
4+
*
5+
* Everything else is under the MIT License http://opensource.org/licenses/MIT
6+
*/
7+
package org.scalajs.dom
8+
9+
import scala.scalajs.js
10+
11+
trait ClipboardItemOptions extends js.Object {
12+
def presentationStyle: js.UndefOr[PresentationStyle] = js.undefined
13+
}

dom/src/main/scala/org/scalajs/dom/Element.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,9 @@ abstract class Element extends Node with NodeSelector with ParentNode with NonDo
270270
* inserted as equivalent Text nodes.
271271
*/
272272
def replaceWith(nodes: (Node | String)*): Unit = js.native
273+
274+
/** Traverses the element and its parents (heading toward the document root) until it finds a node that matches the
275+
* specified CSS selector.
276+
*/
277+
def closest(selector: String): Element = js.native
273278
}

dom/src/main/scala/org/scalajs/dom/Event.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class Event(typeArg: String, init: js.UndefOr[EventInit] = js.undefined) extends
6666

6767
/** Cancels the event if it is cancelable, without stopping further propagation of the event. */
6868
def preventDefault(): Unit = js.native
69+
70+
/** Indicates whether or not the event will propagate across the shadow DOM boundary into the standard DOM. */
71+
def composed: Boolean = js.native
6972
}
7073

7174
@js.native
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API
2+
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later.
3+
* http://creativecommons.org/licenses/by-sa/2.5/
4+
*
5+
* Everything else is under the MIT License http://opensource.org/licenses/MIT
6+
*/
7+
package org.scalajs.dom
8+
9+
import scala.scalajs.js
10+
11+
/** A frozen array type is a parameterized type whose values are references to objects that hold a fixed length array of
12+
* unmodifiable values. The values in the array are of type T.
13+
*
14+
* Since FrozenArray<T> values are references, they are unlike sequence types, which are lists of values that are
15+
* passed by value.
16+
*/
17+
@js.native
18+
trait FrozenArray[+T] extends js.Iterable[T] {
19+
val length: Int = js.native
20+
21+
@js.annotation.JSBracketAccess
22+
def apply(index: Int): T = js.native
23+
}

dom/src/main/scala/org/scalajs/dom/KeyboardEvent.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class KeyboardEvent(typeArg: String, init: js.UndefOr[KeyboardEventInit])
5454

5555
/** Returns the current state of the specified modifier key. */
5656
def getModifierState(keyArg: String): Boolean = js.native
57+
58+
/** Returns a string with the code value of the physical key represented by the event. */
59+
def code: String = js.native
5760
}
5861

5962
@js.native

dom/src/main/scala/org/scalajs/dom/KeyboardEventInit.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ trait KeyboardEventInit extends UIEventInit with ModifierKeyEventInit {
2727

2828
/** Sets value of KeyboardEvent.repeat. Defaults to false. */
2929
var repeat: js.UndefOr[Boolean] = js.undefined
30+
31+
/** Sets value of KeyboardEvent.code. Defaults to empty string. */
32+
var code: js.UndefOr[String] = js.undefined;
3033
}

dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,36 @@ package org.scalajs.dom
88

99
import scala.scalajs.js
1010

11-
/** A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to
12-
* listeners when the media queries on the document change.
11+
/** A MediaQueryList object stores information on a media query applied to a document, with support for both immediate
12+
* and event-driven matching against the state of the document.
1313
*/
1414
@js.native
15-
trait MediaQueryList extends js.Object {
15+
trait MediaQueryList extends EventTarget {
1616

17-
/** true if the document currently matches the media query list; otherwise false. Read only. */
17+
/** A boolean value that returns true if the document currently matches the media query list, or false if not. */
1818
def matches: Boolean = js.native
1919

20-
/** The serialized media query list */
21-
var media: String = js.native
20+
/** A string representing a serialized media query. */
21+
def media: String = js.native
2222

23-
/** Adds a new listener to the media query list. If the specified listener is already in the list, this method has no
24-
* effect.
23+
/** Adds to the MediaQueryList a callback which is invoked whenever the media query status—whether or not the document
24+
* matches the media queries in the list—changes.
25+
*
26+
* This method exists primarily for backward compatibility; if possible, you should instead use addEventListener() to
27+
* watch for the change event.
28+
* @deprecated
2529
*/
30+
@deprecated("Use addEventListener() instead", "2.4.0")
2631
def addListener(listener: MediaQueryListListener): Unit = js.native
2732

28-
/** Removes a listener from the media query list. Does nothing if the specified listener isn't already in the list. */
33+
/** Removes the specified listener callback from the callbacks to be invoked when the MediaQueryList changes media
34+
* query status, which happens any time the document switches between matching and not matching the media queries
35+
* listed in the MediaQueryList.
36+
*
37+
* This method has been kept for backward compatibility; if possible, you should generally use removeEventListener()
38+
* to remove change notification callbacks (which should have previously been added using addEventListener()).
39+
* @deprecated
40+
*/
41+
@deprecated("Use removeEventListener() instead", "2.4.0")
2942
def removeListener(listener: MediaQueryListListener): Unit = js.native
3043
}

dom/src/main/scala/org/scalajs/dom/MediaQueryListListener.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ package org.scalajs.dom
88

99
import scala.scalajs.js
1010

11-
/** A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to
12-
* listeners when the media queries on the document change.
13-
*/
1411
@js.native
12+
@deprecated("See MediaQueryList for more info", "2.4.0")
1513
trait MediaQueryListListener extends js.Object {
1614
def apply(mql: MediaQueryList): Unit = js.native
1715
}

dom/src/main/scala/org/scalajs/dom/Storage.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.scalajs.js.annotation._
1616
@js.native
1717
@JSGlobal
1818
class Storage extends js.Object {
19-
var length: Int = js.native
19+
def length: Int = js.native
2020

2121
def getItem(key: String): String = js.native
2222

dom/src/main/scala/org/scalajs/dom/SubtleCrypto.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scalajs.dom
22

33
import scala.scalajs.js
4+
import scala.scalajs.js.typedarray.ArrayBuffer
45

56
/** [[http://www.w3.org/TR/WebCryptoAPI/#subtlecrypto-interface w3c ¶14 Subtle Crytpo interface]]
67
*
@@ -72,7 +73,8 @@ trait SubtleCrypto extends js.Object {
7273
*
7374
* Defined at [[http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveBits ¶14.3.8 The deriveBits method]]
7475
*/
75-
def deriveBits(algorithm: AlgorithmIdentifier, baseKey: CryptoKey, length: Double): js.Promise[js.Any] = js.native
76+
def deriveBits(algorithm: AlgorithmIdentifier, baseKey: CryptoKey,
77+
length: Double): js.Promise[ArrayBuffer] = js.native
7678

7779
/** Returns a Promise of a CryptoKey corresponding to the format, the algorithm, the raw key data, the usages and the
7880
* extractability given as parameters.

dom/src/main/scala/org/scalajs/dom/html.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ object html {
1313
type Collection[+E] = HTMLCollection[E]
1414
type DataList = HTMLDataListElement
1515
type Div = HTMLDivElement
16+
type Dialog = HTMLDialogElement
1617
type DList = HTMLDListElement
1718
type Document = HTMLDocument
1819
type Element = HTMLElement

dom/src/main/scala/org/scalajs/dom/package.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,6 @@ package object dom {
114114
val webcrypto: Crypto = js.native
115115

116116
type BlobPart = BufferSource | Blob | String
117+
118+
type ClipboardItemData = js.Promise[String | Blob]
117119
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.7.1
1+
sbt.version=1.8.2

project/plugins.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"
22
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1"
33

4-
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.1")
4+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4")
55
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
6-
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
6+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
77
addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.11")
88
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
9-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
9+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")

0 commit comments

Comments
 (0)