Skip to content

Commit 84084bc

Browse files
authored
Merge branch 'master' into MDN-Blob
2 parents 56470f9 + 6b2733a commit 84084bc

30 files changed

+333
-1567
lines changed

.github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
scalaversion: ["2.11.12", "2.12.12", "2.13.4", "3.0.1"]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: olafurpg/setup-scala@v10
19+
with:
20+
java-version: "[email protected]"
21+
- uses: coursier/cache-action@v5
22+
- name: Build
23+
run: sbt "++${{ matrix.scalaversion }}" package
24+
- name: Test generate documentation
25+
run: sbt "++${{ matrix.scalaversion }}" doc
26+
- name: Build examples
27+
run: sbt "++${{ matrix.scalaversion }}" example/compile
28+
- name: scalafmt
29+
run: sbt "++${{ matrix.scalaversion }}" scalafmtCheck
30+
readme:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v2
34+
- uses: olafurpg/setup-scala@v10
35+
with:
36+
java-version: "[email protected]"
37+
- uses: coursier/cache-action@v5
38+
- name: Readme generation
39+
run: sbt readme/run

.github/workflows/ghpages.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
name: Build and Deploy GhPages docs
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: olafurpg/setup-scala@v10
15+
with:
16+
java-version: "[email protected]"
17+
- uses: coursier/cache-action@v5
18+
19+
- name: Build
20+
run: sbt readme/run
21+
22+
- name: Deploy
23+
uses: JamesIves/[email protected]
24+
with:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
BRANCH: gh-pages
27+
FOLDER: readme/target/scalatex

.travis.yml

-33
This file was deleted.

build.sbt

+4-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ lazy val root = project.in(file(".")).
55

66
name := "Scala.js DOM"
77

8-
crossScalaVersions in ThisBuild := {
9-
if (scalaJSVersion.startsWith("1.")) Seq("2.12.10", "2.11.12", "2.13.1")
10-
else Seq("2.12.10", "2.11.12", "2.10.7", "2.13.1")
11-
}
12-
scalaVersion in ThisBuild := crossScalaVersions.value.head
8+
ThisBuild / crossScalaVersions := Seq("2.12.12", "2.11.12", "2.13.4", "3.0.1")
9+
ThisBuild / scalaVersion := crossScalaVersions.value.head
1310

1411
val commonSettings = Seq(
15-
version := "0.9.9-SNAPSHOT",
12+
version := "2.0.0-SNAPSHOT",
1613
organization := "org.scala-js",
1714
scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
1815
)
@@ -36,7 +33,6 @@ scalacOptions ++= {
3633
}
3734

3835
def hasNewCollections(version: String): Boolean = {
39-
!version.startsWith("2.10.") &&
4036
!version.startsWith("2.11.") &&
4137
!version.startsWith("2.12.")
4238
}
@@ -104,7 +100,7 @@ lazy val readme = ScalatexReadme(
104100
).settings(
105101
scalaVersion := "2.12.10",
106102
scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings"),
107-
(resources in Compile) += (fullOptJS in (example, Compile)).value.data
103+
(Compile / resources) += (example / Compile / fullOptJS).value.data
108104
)
109105

110106
lazy val example = project.

example/src/main/scala/example/Example.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ object XMLHttpRequest{
123123
@JSExport
124124
def main(pre: html.Pre) = {
125125
val xhr = new dom.XMLHttpRequest()
126-
xhr.open("GET",
127-
"http://api.openweathermap.org/" +
128-
"data/2.5/weather?q=Singapore"
126+
xhr.open("GET",
127+
"https://www.boredapi.com/api/activity"
129128
)
130129
xhr.onload = { (e: dom.Event) =>
131130
if (xhr.status == 200) {
@@ -142,7 +141,7 @@ object Websocket {
142141
@JSExport
143142
def main(in: html.Input,
144143
pre: html.Pre) = {
145-
val echo = "ws://echo.websocket.org"
144+
val echo = "wss://echo.websocket.org"
146145
val socket = new dom.WebSocket(echo)
147146
socket.onmessage = {
148147
(e: dom.MessageEvent) =>
@@ -167,8 +166,7 @@ object AjaxExtension {
167166
.Implicits
168167
.global
169168
val url =
170-
"http://api.openweathermap.org/" +
171-
"data/2.5/weather?q=Singapore"
169+
"https://www.boredapi.com/api/activity"
172170
Ajax.get(url).foreach { case xhr =>
173171
pre.textContent = xhr.responseText
174172
}

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.8
1+
sbt.version=1.5.5

project/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
val scalaJSVersion =
2-
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.28")
2+
Option(System.getenv("SCALAJS_VERSION")).filter(_ != "").getOrElse("1.5.0")
33

44
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
55

readme/Index.scalatex

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@
4848
@pair("Alert", Nil)
4949

5050
@p
51-
Will cause a javascript alert box saying `HAI` to appear. Other javascript classes and objects can be similarly accessed e.g. @hl.scala{new dom.XMLHttpRequest()} to perform a new Ajax request, @hl.scala{dom.document} to access the global @hl.scala{document} object, or @hl.scala{html.Div} to to refer to the type of a @hl.scala{<div>} element.
51+
Will cause a javascript alert box saying `Hi from Scala-js-dom` to appear. Other javascript classes and objects can be similarly accessed e.g. @hl.scala{new dom.XMLHttpRequest()} to perform a new Ajax request, @hl.scala{dom.document} to access the global @hl.scala{document} object, or @hl.scala{html.Div} to to refer to the type of a @hl.scala{<div>} element.
5252

5353
@sect{Usage}
5454
@p
5555
Add the following to your sbt build definition:
5656

5757
@hl.scala
58-
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.8"
58+
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0"
5959

6060
@p
61-
then enjoy the types available in @hl.scala{org.scalajs.dom}. scalajs-dom 0.9.8 is built and published for Scala.js 0.6.17 and later, Scala.js 1.0.0-M8 and 1.0.0-RC1, with Scala 2.10, 2.11, 2.12 and 2.13. It will also most likely be published as is for further versions of Scala.js 1.x in the future.
61+
then enjoy the types available in @hl.scala{org.scalajs.dom}. scalajs-dom 1.1.0 is built and published for Scala.js 0.6.17+ and Scala.js 1.0.0+, with Scala 2.10, 2.11, 2.12 and 2.13.
6262

6363
@p
6464
To begin with, @code{scala-js-dom} organizes the full-list of DOM APIs into a number of buckets:
@@ -90,7 +90,7 @@
9090
@sect{Node.onmousemove}
9191
@pair(
9292
"EventHandler",
93-
Seq(pre("pre")),
93+
Seq(pre("Hover this box!")),
9494
autorun=true
9595
)
9696

src/main/scala/org/scalajs/dom/crypto/Crypto.scala

-2
Original file line numberDiff line numberDiff line change
@@ -930,10 +930,8 @@ object KeyFormat {
930930
trait RSAPublicKey extends js.Object {
931931

932932
/* modulus, as a base64 URL encoded String */
933-
@js.native
934933
def n: String = js.native
935934

936935
/* exponent, as a base64 URL encoded String */
937-
@js.native
938936
def e: String = js.native
939937
}

src/main/scala/org/scalajs/dom/experimental/Fetch.scala

+13-67
Original file line numberDiff line numberDiff line change
@@ -74,89 +74,35 @@ class Request(input: RequestInfo, init: RequestInit = null) extends js.Object {
7474
def signal: AbortSignal = js.native
7575
}
7676

77-
object RequestInit {
78-
79-
/**
80-
* Create a RequestInit with some minimal typesafety on attributes.
81-
*
82-
* This method creates as light weight a RequestInit literal as possible
83-
* from the provided parameters, so as to allow the browser to work through
84-
* its default setting strategy.
85-
*
86-
* It is actually quite difficult to work out the defaults, which parameters
87-
* work together and which don't. Check the rules here in case of doubt:
88-
* - [[https://fetch.spec.whatwg.org/#requests ¶3.1.5 Requests]]
89-
* - [[https://fetch.spec.whatwg.org/#request-class ¶6.3 Request class]], especially the constructor function
90-
* of the whatwg Fetch spec.
91-
*
92-
* //todo: it would help a lot if there were a way to make this fully type safe
93-
*/
94-
@inline
95-
@deprecated("use `new RequestInit {}` instead", "0.9.7")
96-
def apply(method: js.UndefOr[HttpMethod] = js.undefined,
97-
headers: js.UndefOr[HeadersInit] = js.undefined,
98-
body: js.UndefOr[BodyInit] = js.undefined,
99-
referrer: js.UndefOr[String] = js.undefined, //should be USVString
100-
referrerPolicy: js.UndefOr[ReferrerPolicy] = js.undefined,
101-
mode: js.UndefOr[RequestMode] = js.undefined,
102-
credentials: js.UndefOr[RequestCredentials] = js.undefined,
103-
requestCache: js.UndefOr[RequestCache] = js.undefined,
104-
requestRedirect: js.UndefOr[RequestRedirect] = js.undefined,
105-
integrity: js.UndefOr[String] = js.undefined, //see [[https://w3c
106-
// .github.io/webappsec-subresource-integrity/ integrity spec]]
107-
window: js.UndefOr[Null] = js.undefined): RequestInit = {
108-
val result = js.Dynamic.literal()
109-
110-
@inline
111-
def set[T](attribute: String, value: js.UndefOr[T]) = value.foreach { x =>
112-
result.updateDynamic(attribute)(x.asInstanceOf[js.Any])
113-
}
114-
115-
set("method", method)
116-
set("headers", headers)
117-
set("body", body)
118-
set("referrer", referrer)
119-
set("referrerPolicy", referrerPolicy)
120-
set("mode", mode)
121-
set("credentials", credentials)
122-
set("cache", requestCache)
123-
set("redirect", requestRedirect)
124-
set("integrity", integrity)
125-
set("window", window)
126-
127-
result.asInstanceOf[RequestInit]
128-
}
129-
}
130-
13177
/**
13278
* See [[https://fetch.spec.whatwg.org/#requestinit RequestInit]] in Fetch API
13379
* The underlying object is a dictionary. This trait is here to help encode
13480
* the types.
13581
*/
13682
trait RequestInit extends js.Object {
137-
var method: js.UndefOr[HttpMethod]
83+
var method: js.UndefOr[HttpMethod] = js.undefined
13884

139-
var headers: js.UndefOr[HeadersInit]
85+
var headers: js.UndefOr[HeadersInit] = js.undefined
14086

141-
var body: js.UndefOr[BodyInit]
87+
var body: js.UndefOr[BodyInit] = js.undefined
14288

143-
var referrer: js.UndefOr[String]
89+
var referrer: js.UndefOr[String] = js.undefined
14490

145-
var referrerPolicy: js.UndefOr[ReferrerPolicy]
91+
var referrerPolicy: js.UndefOr[ReferrerPolicy] = js.undefined
14692

147-
var mode: js.UndefOr[RequestMode]
93+
var mode: js.UndefOr[RequestMode] = js.undefined
14894

149-
var credentials: js.UndefOr[RequestCredentials]
95+
var credentials: js.UndefOr[RequestCredentials] = js.undefined
15096

151-
var cache: js.UndefOr[RequestCache]
97+
var cache: js.UndefOr[RequestCache] = js.undefined
15298

153-
var redirect: js.UndefOr[RequestRedirect]
99+
var redirect: js.UndefOr[RequestRedirect] = js.undefined
154100

155-
var integrity: js.UndefOr[String]
101+
var integrity: js.UndefOr[String] = js.undefined
156102

157-
var keepalive: js.UndefOr[Boolean]
103+
var keepalive: js.UndefOr[Boolean] = js.undefined
158104

159-
var signal: js.UndefOr[AbortSignal]
105+
var signal: js.UndefOr[AbortSignal] = js.undefined
160106

161107
/**
162108
* The whatwg spec section on [[https://fetch.spec.whatwg.org/#requestinit RequestInit dictionary]]
@@ -165,7 +111,7 @@ trait RequestInit extends js.Object {
165111
* it says even more clearly:
166112
* "If init's window member is present and it is not null, throw a TypeError."
167113
*/
168-
var window: js.UndefOr[Null]
114+
var window: js.UndefOr[Null] = js.undefined
169115
}
170116

171117
/**

src/main/scala/org/scalajs/dom/experimental/deviceorientation/DeviceOrientation.scala

-10
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ trait DeviceOrientationEventInit extends EventInit {
4848
var absolute: js.UndefOr[Boolean] = js.undefined
4949
}
5050

51-
object DeviceOrientationEventInit {
52-
@deprecated("Create new DeviceOrientationEventInit instead", "0.9.8")
53-
def apply(alpha: Double, beta: Double, gamma: Double,
54-
absolute: Boolean): DeviceOrientationEventInit = {
55-
js.Dynamic
56-
.literal(alpha = alpha, beta = beta, gamma = gamma, absolute = absolute)
57-
.asInstanceOf[DeviceOrientationEventInit]
58-
}
59-
}
60-
6151
trait DeviceAcceleration extends js.Any {
6252

6353
/** The acceleration in x. In m/s<sup>2</sup>. */

src/main/scala/org/scalajs/dom/experimental/gamepad/Gamepad.scala

-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ trait GamepadEventInit extends EventInit {
7070
var gamepad: js.UndefOr[Gamepad]
7171
}
7272

73-
object GamepadEventInit {
74-
@deprecated("Create new ClipboardEventInit instead", "0.9.8")
75-
def apply(gamepad: Gamepad): GamepadEventInit =
76-
js.Dynamic.literal("gamepad" -> gamepad).asInstanceOf[GamepadEventInit]
77-
}
78-
7973
@JSGlobal("GamepadEvent")
8074
@js.native
8175
class GamepadEvent(typeArg: String,

0 commit comments

Comments
 (0)