Skip to content

Commit

Permalink
Scala3 support (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC authored Jan 17, 2022
1 parent 9dcddda commit 3191443
Show file tree
Hide file tree
Showing 57 changed files with 245 additions and 207 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.alarms.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

object AlarmInfo {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.app.window.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

object BoundsSpecification {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.app.window.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

object CreateWindowOptions {

Expand Down
24 changes: 12 additions & 12 deletions bindings/src/main/scala/chrome/app/window/bindings/Window.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ import chrome.events.bindings.Event

import scala.scalajs.js
import scala.scalajs.js.annotation.JSGlobal
import scala.scalajs.js.{UndefOr, native, undefined}
import scala.scalajs.js.{UndefOr, undefined}

@js.native
@JSGlobal("chrome.app.window")
object Window extends js.Object {

val onBoundsChanged: Event[js.Function0[_]] = native
val onClosed: Event[js.Function0[_]] = native
val onFullscreened: Event[js.Function0[_]] = native
val onMaximized: Event[js.Function0[_]] = native
val onMinimized: Event[js.Function0[_]] = native
val onRestored: Event[js.Function0[_]] = native
val onBoundsChanged: Event[js.Function0[_]] = js.native
val onClosed: Event[js.Function0[_]] = js.native
val onFullscreened: Event[js.Function0[_]] = js.native
val onMaximized: Event[js.Function0[_]] = js.native
val onMinimized: Event[js.Function0[_]] = js.native
val onRestored: Event[js.Function0[_]] = js.native

def current(): AppWindow = native
def current(): AppWindow = js.native

def create(
url: String,
options: UndefOr[CreateWindowOptions] = undefined,
callback: UndefOr[js.Function1[AppWindow, _]] = undefined
): Unit =
native
js.native

def getAll(): js.Array[AppWindow] = native
def getAll(): js.Array[AppWindow] = js.native

def get(id: AppWindow.Id): AppWindow = native
def get(id: AppWindow.Id): AppWindow = js.native

def canSetVisibleOnAllWorkspaces(): Boolean = native
def canSetVisibleOnAllWorkspaces(): Boolean = js.native

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.audio.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

object Properties {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package chrome.browserAction.bindings

import scala.scalajs.js
import scala.scalajs.js.|
import scala.scalajs.js.|.Evidence
import scala.scalajs.js.|.{Evidence, UnionOps, undefOr2jsAny}

@js.native
trait BadgeBackgroundColorDetails extends TabIdDetails {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.browserAction.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait BadgeTextDetails extends TabIdDetails {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.scalajs.dom.ImageData

import scala.scalajs.js
import scala.scalajs.js.|
import scala.scalajs.js.|.Evidence
import scala.scalajs.js.|.{Evidence, UnionOps, undefOr2jsAny}

@js.native
trait IconDetails extends TabIdDetails {
Expand All @@ -25,7 +25,7 @@ object IconDetails {
): IconDetails = {
// explicitly merge our union types so that dynamic is happy
val anyImageData: js.UndefOr[js.Any] = imageData.map(_.merge)
val anyPath: js.UndefOr[js.Any] = path.map(_.merge)
val anyPath: js.UndefOr[js.Any] = path.map(_.asInstanceOf[js.Any])

if (anyImageData.isDefined) {
js.Dynamic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.browserAction.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait PopupDetails extends TabIdDetails {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.browserAction.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait TabIdDetails extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.browserAction.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait TitleDetails extends TabIdDetails {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.downloads.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait DownloadOptions extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.downloads.bindings

import scalajs.js
import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait FileIconOptions extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.downloads.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait Query extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class EventSource3Impl[A, B, C](event: Event[js.Function3[A, B, C, _]]) extends

object EventSourceImplicits {

import scala.language.implicitConversions

implicit def eventAsEventSource0(event: Event[js.Function0[_]]): EventSource[Unit] =
new EventSource0Impl(event)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.notifications.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait NotificationOptions extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package chrome.permissions

import chrome.events.EventSource
import chrome.events.EventSourceImplicits._
import chrome.permissions.Permission.{API, Host}
import chrome.permissions.bindings._
import chrome.permissions.Permission.{Host, API}
import chrome.utils.ErrorHandling._

import scala.concurrent.{Future, Promise}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@ import chrome.events.bindings.Event

import scala.scalajs.js
import scala.scalajs.js.annotation.JSGlobal
import scala.scalajs.js.{UndefOr, native, undefined}
import scala.scalajs.js.{UndefOr, undefined}
import scala.scalajs.js.|.undefOr2jsAny

@js.native
@JSGlobal("chrome.permissions")
object Permissions extends js.Object {

val onAdded: Event[js.Function1[PermissionList, _]] = native
val onRemoved: Event[js.Function1[PermissionList, _]] = native
val onAdded: Event[js.Function1[PermissionList, _]] = js.native
val onRemoved: Event[js.Function1[PermissionList, _]] = js.native

def getAll(callback: js.Function1[PermissionList, _]): Unit = native
def getAll(callback: js.Function1[PermissionList, _]): Unit = js.native

def contains(permissions: PermissionList, callback: js.Function1[Boolean, _]): Unit = native
def contains(permissions: PermissionList, callback: js.Function1[Boolean, _]): Unit = js.native

def request(permissions: PermissionList, callback: UndefOr[js.Function1[Boolean, _]] = undefined): Unit =
native
js.native

def remove(permissions: PermissionList, callback: UndefOr[js.Function1[Boolean, _]] = undefined): Unit =
native
js.native

}

@js.native
trait PermissionList extends js.Object {

var permissions: UndefOr[js.Array[String]] = native
var origins: UndefOr[js.Array[String]] = native
var permissions: UndefOr[js.Array[String]] = js.native
var origins: UndefOr[js.Array[String]] = js.native

}

Expand Down
56 changes: 28 additions & 28 deletions bindings/src/main/scala/chrome/runtime/bindings/Runtime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,69 @@ import org.scalajs.dom.Window

import scala.scalajs.js
import scala.scalajs.js.annotation.JSGlobal
import scala.scalajs.js.{UndefOr, native, undefined}
import scala.scalajs.js.{UndefOr, undefined}

@JSGlobal("chrome.runtime")
@js.native
object Runtime extends js.Object {

type AppID = String

val id: AppID = native
val onStartup: Event[js.Function0[_]] = native
val onInstalled: Event[js.Function1[OnInstalledDetails, _]] = native
val onSuspend: Event[js.Function0[_]] = native
val onSuspendCanceled: Event[js.Function0[_]] = native
val id: AppID = js.native
val onStartup: Event[js.Function0[_]] = js.native
val onInstalled: Event[js.Function1[OnInstalledDetails, _]] = js.native
val onSuspend: Event[js.Function0[_]] = js.native
val onSuspendCanceled: Event[js.Function0[_]] = js.native

val onUpdateAvailable: Event[js.Function1[OnUpdateAvailableDetails, _]] =
native
val onBrowserUpdateAvailable: Event[js.Function0[_]] = native
val onConnect: Event[js.Function1[Port, _]] = native
val onConnectExternal: Event[js.Function1[Port, _]] = native
val onMessage: Event[js.Function3[UndefOr[Any], MessageSender, js.Function1[Any, _], Boolean]] = native
val onMessageExternal: Event[js.Function3[UndefOr[Any], MessageSender, js.Function1[Any, _], Boolean]] = native
js.native
val onBrowserUpdateAvailable: Event[js.Function0[_]] = js.native
val onConnect: Event[js.Function1[Port, _]] = js.native
val onConnectExternal: Event[js.Function1[Port, _]] = js.native
val onMessage: Event[js.Function3[UndefOr[Any], MessageSender, js.Function1[Any, _], Boolean]] = js.native
val onMessageExternal: Event[js.Function3[UndefOr[Any], MessageSender, js.Function1[Any, _], Boolean]] = js.native

val onRestartRequired: Event[js.Function1[RestartReasons.RestartReason, _]] =
native
js.native

def lastError: UndefOr[Error] = native
def lastError: UndefOr[Error] = js.native

def getBackgroundPage(callback: js.Function1[Window, _]): Unit = native
def getBackgroundPage(callback: js.Function1[Window, _]): Unit = js.native

def reload(): Unit = native
def reload(): Unit = js.native

def restart(): Unit = native
def restart(): Unit = js.native

def getManifest(): Manifest = native
def getManifest(): Manifest = js.native

def openOptionsPage(callback: js.UndefOr[js.Function0[_]]): Unit = js.native

def getURL(path: String): String = native
def getURL(path: String): String = js.native

def setUninstallURL(url: String): Unit = native
def setUninstallURL(url: String): Unit = js.native

def requestUpdateCheck(callback: js.Function2[UpdateCheck.Status, UndefOr[UpdateCheck.Details], _]): Unit = native
def requestUpdateCheck(callback: js.Function2[UpdateCheck.Status, UndefOr[UpdateCheck.Details], _]): Unit = js.native

def connect(extensionId: UndefOr[AppID] = undefined, connectInfo: UndefOr[ConnectInfo] = undefined): Port = native
def connect(extensionId: UndefOr[AppID] = undefined, connectInfo: UndefOr[ConnectInfo] = undefined): Port = js.native

def connectNative(application: String): Port = native
def connectNative(application: String): Port = js.native

def sendMessage(
extensionId: UndefOr[AppID] = undefined,
message: js.Any,
options: UndefOr[SendMessageOptions] = undefined,
responseCallback: UndefOr[js.Function1[js.Object, _]] = js.undefined
): Unit = native
): Unit = js.native

def sendNativeMessage(
application: String,
message: js.Object,
responseCallback: UndefOr[js.Function1[js.Object, _]]
): Unit = native
): Unit = js.native

def getPlatformInfo(callback: js.Function1[PlatformInfo, _]): Unit = native
def getPlatformInfo(callback: js.Function1[PlatformInfo, _]): Unit = js.native

def getPackageDirectoryEntry(callback: js.Function1[DirectoryEntry, _]): Unit = native
def getPackageDirectoryEntry(callback: js.Function1[DirectoryEntry, _]): Unit = js.native

}

Expand All @@ -82,7 +82,7 @@ object UpdateCheck {
@js.native
trait Details extends js.Object {

val version: String = native
val version: String = js.native

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.sockets.tcp.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait SecureOptions extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrome.sockets.tcp.bindings

import scala.scalajs.js
import scala.scalajs.js.|.undefOr2jsAny

@js.native
trait SocketProperties extends js.Object {
Expand Down
Loading

0 comments on commit 3191443

Please # to comment.