-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #592 from scala-js/topic/opaque-type
Use opaque types for Scala 3
- Loading branch information
Showing
72 changed files
with
753 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type ClientType = String | ||
|
||
object ClientType { | ||
val window: ClientType = "window" | ||
|
||
val worker: ClientType = "worker" | ||
|
||
val sharedworker: ClientType = "sharedworker" | ||
|
||
val all: ClientType = "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type FrameType = String | ||
|
||
/** part of ServiceWorker | ||
* [[https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/#client-frametype ¶4.2.2 frameType]] of | ||
* serviceWorker spec | ||
*/ | ||
object FrameType { | ||
|
||
/** The window client's global object's browsing context is an auxiliary browsing context. */ | ||
val auxiliary: FrameType = "auxiliary" | ||
|
||
/** The window client's global object's browsing context is a top-level browsing context. */ | ||
val `top-level`: FrameType = "top-level" | ||
|
||
/** The window client's global object's browsing context is a nested browsing context. */ | ||
val nested: FrameType = "nested" | ||
|
||
val none: FrameType = "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API | ||
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later. | ||
* http://creativecommons.org/licenses/by-sa/2.5/ | ||
* | ||
* Everything else is under the MIT License http://opensource.org/licenses/MIT | ||
*/ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type IDBCursorDirection = js.Any | ||
|
||
object IDBCursorDirection { | ||
|
||
/** The cursor shows all records, including duplicates. It starts at the upper bound of the key range and moves | ||
* downwards (monotonically decreasing in the order of keys). | ||
*/ | ||
val prev: IDBCursorDirection = "prev" | ||
|
||
/** The cursor shows all records, excluding duplicates. If multiple records exist with the same key, only the first | ||
* one iterated is retrieved. It starts at the upper bound of the key range and moves downwards. | ||
*/ | ||
val prevunique: IDBCursorDirection = "prevunique" | ||
|
||
/** The cursor shows all records, including duplicates. It starts at the lower bound of the key range and moves | ||
* upwards (monotonically increasing in the order of keys). | ||
*/ | ||
val next: IDBCursorDirection = "next" | ||
|
||
/** The cursor shows all records, excluding duplicates. If multiple records exist with the same key, only the first | ||
* one iterated is retrieved. It starts at the lower bound of the key range and moves upwards. | ||
*/ | ||
val nextunique: IDBCursorDirection = "nextunique" | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/scala-3/org/scalajs/dom/IDBTransactionDurability.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API | ||
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later. | ||
* http://creativecommons.org/licenses/by-sa/2.5/ | ||
* | ||
* Everything else is under the MIT License http://opensource.org/licenses/MIT | ||
*/ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type IDBTransactionDurability = String | ||
|
||
object IDBTransactionDurability { | ||
val default: IDBTransactionDurability = "default" | ||
val strict: IDBTransactionDurability = "strict" | ||
val relaxed: IDBTransactionDurability = "relaxed" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API | ||
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later. | ||
* http://creativecommons.org/licenses/by-sa/2.5/ | ||
* | ||
* Everything else is under the MIT License http://opensource.org/licenses/MIT | ||
*/ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** IndexedDB transaction mode Provides constants for IDB Transaction modes These constants have been removed from | ||
* browser support and replaced by String values | ||
*/ | ||
opaque type IDBTransactionMode = String | ||
|
||
object IDBTransactionMode { | ||
|
||
/** Allows data to be read but not changed. It is the default transaction mode. */ | ||
val readonly: IDBTransactionMode = "readonly" | ||
|
||
/** Allows any operation to be performed, including ones that delete and create object stores and indexes. This mode | ||
* is for updating the version number of transactions that were started using the setVersion() method of IDBDatabase | ||
* objects. Transactions of this mode cannot run concurrently with other transactions. | ||
*/ | ||
val versionchange: IDBTransactionMode = "versionchange" | ||
|
||
/** Allows reading and writing of data in existing data stores to be changed. */ | ||
val readwrite: IDBTransactionMode = "readwrite" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** see [[http://www.w3.org/TR/WebCryptoAPI/#dfn-KeyFormat ¶14.2 Data Types]] in W3C spec */ | ||
opaque type KeyFormat = String | ||
|
||
object KeyFormat { | ||
|
||
/** An unformatted sequence of bytes. Intended for secret keys. */ | ||
val raw: KeyFormat = "raw" | ||
|
||
/** The DER encoding of the PrivateKeyInfo structure from RFC 5208. */ | ||
val pkcs8: KeyFormat = "pkcs8" | ||
|
||
/** The DER encoding of the SubjectPublicKeyInfo structure from RFC 5280. */ | ||
val spki: KeyFormat = "spki" | ||
|
||
/** The key is a JsonWebKey dictionary encoded as a JavaScript object */ | ||
val jwk: KeyFormat = "jwk" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** see [[http://www.w3.org/TR/WebCryptoAPI/#cryptokey-interface ¶13 CryptoKey interface]] in W3C doc */ | ||
opaque type KeyType = String | ||
|
||
object KeyType { | ||
val public: KeyType = "public" | ||
val `private`: KeyType = "private" | ||
val secret: KeyType = "secret" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** See [[http://www.w3.org/TR/WebCryptoAPI/#cryptokey-interface ¶ 13. CryptoKey Interface]] of w3c spec */ | ||
opaque type KeyUsage = String | ||
|
||
object KeyUsage { | ||
val encrypt: KeyUsage = "encrypt" | ||
val decrypt: KeyUsage = "decrypt" | ||
val sign: KeyUsage = "sign" | ||
val verify: KeyUsage = "verify" | ||
val deriveKey: KeyUsage = "deriveKey" | ||
val deriveBits: KeyUsage = "deriveBits" | ||
val wrapKey: KeyUsage = "wrapKey" | ||
val unwrapKey: KeyUsage = "unwrapKey" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type MIMEType = String | ||
|
||
object MIMEType { | ||
val `text/html`: MIMEType = "text/html" | ||
val `text/xml`: MIMEType = "text/xml" | ||
val `application/xml`: MIMEType = "application/xml" | ||
|
||
val `application/xhtml+xml`: MIMEType = | ||
"application/xhtml+xml" | ||
val `image/svg+xml`: MIMEType = "image/svg+xml" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** https://www.w3.org/TR/2016/CR-mediacapture-streams-20160519/ */ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** see [[https://www.w3.org/TR/2016/CR-mediacapture-streams-20160519/#idl-def-MediaDeviceKind]] in W3C spec */ | ||
opaque type MediaDeviceKind = String | ||
|
||
object MediaDeviceKind { | ||
|
||
/** Represents an audio input device; for example a microphone. */ | ||
val audioinput: MediaDeviceKind = "audioinput" | ||
|
||
/** Represents an audio output device; for example a pair of headphones. */ | ||
val audiooutput: MediaDeviceKind = "audiooutput" | ||
|
||
/** Represents a video input device; for example a webcam. */ | ||
val videoinput: MediaDeviceKind = "videoinput" | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/scala-3/org/scalajs/dom/MediaStreamTrackState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** https://www.w3.org/TR/2016/CR-mediacapture-streams-20160519/ */ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** see [[https://www.w3.org/TR/2013/WD-mediacapture-streams-20130903/#widl-MediaStream-onended]] in W3C spec */ | ||
opaque type MediaStreamTrackState = String | ||
|
||
object MediaStreamTrackState { | ||
|
||
/** The track is active (the track's underlying media source is making a best-effort attempt to provide data in real | ||
* time). The output of a track in the live state can be switched on and off with the enabled attribute. | ||
*/ | ||
val live: MediaStreamTrackState = "live" | ||
|
||
/** The track has ended (the track's underlying media source is no longer providing data, and will never provide more | ||
* data for this track). Once a track enters this state, it never exits it. | ||
* | ||
* For example, a video track in a MediaStream ends if the user unplugs the USB web camera that acts as the track's | ||
* media source. | ||
*/ | ||
val ended: MediaStreamTrackState = "ended" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type PermissionName = String | ||
|
||
object PermissionName { | ||
val geolocation: PermissionName = "geolocation" | ||
val midi: PermissionName = "midi" | ||
val notifications: PermissionName = "notifications" | ||
val push: PermissionName = "push" | ||
|
||
val `persistent-storage`: PermissionName = | ||
"persistent-storage" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
opaque type PermissionState = String | ||
|
||
object PermissionState { | ||
val granted: PermissionState = "granted" | ||
val denied: PermissionState = "denied" | ||
val prompt: PermissionState = "prompt" | ||
} |
Oops, something went wrong.