diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 4120f3b14..d61d01552 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -13530,32 +13530,43 @@ HttpMethod[SO] val PATCH: HttpMethod HttpMethod[SO] val POST: HttpMethod HttpMethod[SO] val PUT: HttpMethod HttpMethod[SO] val QUERY: HttpMethod -IDBCursor[JC] def advance(count: Int): Unit -IDBCursor[JC] def continue(key: js.Any?): Unit -IDBCursor[JC] def delete(): IDBRequest +IDBCreateIndexOptions[JT] val locale: js.UndefOr[String] +IDBCreateIndexOptions[JT] val multiEntry: js.UndefOr[Boolean] +IDBCreateIndexOptions[JT] val unique: js.UndefOr[Boolean] +IDBCreateObjectStoreOptions[JT] val autoIncrement: js.UndefOr[Boolean] +IDBCreateObjectStoreOptions[JT] val keyPath: IDBKeyPath +IDBCursor[JC] def advance(count: Double): Unit +IDBCursor[JC] def continue(key: IDBKey?): Unit +IDBCursor[JC] def delete(): IDBRequest[S, Unit] IDBCursor[JC] def direction: IDBCursorDirection -IDBCursor[JC] def key: js.Any -IDBCursor[JC] def primaryKey: js.Any -IDBCursor[JC] def source: js.Any -IDBCursor[JC] def update(value: js.Any): IDBRequest +IDBCursor[JC] def key: IDBKey +IDBCursor[JC] def primaryKey: IDBKey +IDBCursor[JC] def source: S +IDBCursor[JC] def update(value: IDBValue): IDBRequest[S, IDBKey] IDBCursorDirection[JT] -IDBCursorDirection[SO] val NEXT: IDBCursorDirection -IDBCursorDirection[SO] val NEXT_UNIQUE: IDBCursorDirection -IDBCursorDirection[SO] val PREV: IDBCursorDirection -IDBCursorDirection[SO] val PREV_UNIQUE: IDBCursorDirection -IDBCursorWithValue[JC] def advance(count: Int): Unit -IDBCursorWithValue[JC] def continue(key: js.Any?): Unit -IDBCursorWithValue[JC] def delete(): IDBRequest +IDBCursorDirection[SO] def next: IDBCursorDirection +IDBCursorDirection[SO] def nextunique: IDBCursorDirection +IDBCursorDirection[SO] def prev: IDBCursorDirection +IDBCursorDirection[SO] def prevunique: IDBCursorDirection +IDBCursorReadOnly[JC] def advance(count: Double): Unit +IDBCursorReadOnly[JC] def continue(key: IDBKey?): Unit +IDBCursorReadOnly[JC] def direction: IDBCursorDirection +IDBCursorReadOnly[JC] def key: IDBKey +IDBCursorReadOnly[JC] def primaryKey: IDBKey +IDBCursorReadOnly[JC] def source: S +IDBCursorWithValue[JC] def advance(count: Double): Unit +IDBCursorWithValue[JC] def continue(key: IDBKey?): Unit +IDBCursorWithValue[JC] def delete(): IDBRequest[S, Unit] IDBCursorWithValue[JC] def direction: IDBCursorDirection -IDBCursorWithValue[JC] def key: js.Any -IDBCursorWithValue[JC] def primaryKey: js.Any -IDBCursorWithValue[JC] def source: js.Any -IDBCursorWithValue[JC] def update(value: js.Any): IDBRequest -IDBCursorWithValue[JC] def value: js.Any +IDBCursorWithValue[JC] def key: IDBKey +IDBCursorWithValue[JC] def primaryKey: IDBKey +IDBCursorWithValue[JC] def source: S +IDBCursorWithValue[JC] def update(value: IDBValue): IDBRequest[S, IDBKey] +IDBCursorWithValue[JC] def value: IDBValue IDBDatabase[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBDatabase[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit IDBDatabase[JC] def close(): Unit -IDBDatabase[JC] def createObjectStore(name: String, optionalParameters: js.Any?): IDBObjectStore +IDBDatabase[JC] def createObjectStore(name: String, optionalParameters: js.UndefOr[IDBCreateObjectStoreOptions]?): IDBObjectStore IDBDatabase[JC] def deleteObjectStore(name: String): Unit IDBDatabase[JC] def dispatchEvent(evt: Event): Boolean IDBDatabase[JC] def name: String @@ -13565,48 +13576,72 @@ IDBDatabase[JC] var onerror: js.Function1[Event, _] IDBDatabase[JC] var onversionchange: js.Function1[IDBVersionChangeEvent, _] IDBDatabase[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBDatabase[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -IDBDatabase[JC] def transaction(storeNames: js.Any, mode: IDBTransactionMode?): IDBTransaction +IDBDatabase[JC] def transaction(storeNames: String | js.Array[String], mode: js.UndefOr[IDBTransactionMode]?, options: js.UndefOr[IDBTransactionOptions]?): IDBTransaction IDBDatabase[JC] def version: Int +IDBDatabaseInfo[JT] val name: String +IDBDatabaseInfo[JT] val version: Int IDBEnvironment[JT] def indexedDB: IDBFactory (@deprecated in 1.2.0) -IDBFactory[JC] def cmp(first: js.Any, second: js.Any): Int -IDBFactory[JC] def deleteDatabase(name: String): IDBOpenDBRequest -IDBFactory[JC] def open(name: String): IDBOpenDBRequest -IDBFactory[JC] def open(name: String, version: Int): IDBOpenDBRequest -IDBIndex[JC] def count(): IDBRequest -IDBIndex[JC] def count(key: js.Any): IDBRequest -IDBIndex[JC] def get(key: js.Any): IDBRequest -IDBIndex[JC] def getKey(key: js.Any): IDBRequest -IDBIndex[JC] def keyPath: String +IDBEvent[JC] def bubbles: Boolean +IDBEvent[JC] def cancelBubble: Boolean +IDBEvent[JC] def cancelable: Boolean +IDBEvent[JC] def currentTarget: EventTarget +IDBEvent[JC] def defaultPrevented: Boolean +IDBEvent[JC] def eventPhase: Int +IDBEvent[JC] def isTrusted: Boolean +IDBEvent[JC] def preventDefault(): Unit +IDBEvent[JC] def stopImmediatePropagation(): Unit +IDBEvent[JC] def stopPropagation(): Unit +IDBEvent[JC] def target: EventTarget +IDBEvent[JC] override def target: IDBEventTarget[A] +IDBEvent[JC] def timeStamp: Double +IDBEvent[JC] def `type`: String +IDBEventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +IDBEventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +IDBEventTarget[JC] def dispatchEvent(evt: Event): Boolean +IDBEventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +IDBEventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +IDBEventTarget[JC] def result: A +IDBFactory[JC] def cmp(first: IDBValue, second: IDBValue): Int +IDBFactory[JC] def databases(): js.Promise[js.Array[IDBDatabaseInfo]] +IDBFactory[JC] def deleteDatabase(name: String): IDBOpenDBRequest[Unit] +IDBFactory[JC] def open(name: String, version: Int?): IDBOpenDBRequest[IDBDatabase] +IDBIndex[JC] def count(query: IDBKey | IDBKeyRange?): IDBRequest[S, Double] +IDBIndex[JC] def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] +IDBIndex[JC] def getAll(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBValue]] +IDBIndex[JC] def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBKey]] +IDBIndex[JC] def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] +IDBIndex[JC] def keyPath: IDBKeyPath +IDBIndex[JC] val multiEntry: Boolean IDBIndex[JC] def name: String IDBIndex[JC] def objectStore: IDBObjectStore -IDBIndex[JC] def openCursor(range: IDBKeyRange?, direction: IDBCursorDirection?): IDBRequest -IDBIndex[JC] def openKeyCursor(range: IDBKeyRange?, direction: IDBCursorDirection?): IDBRequest +IDBIndex[JC] def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursor[S]] +IDBIndex[JC] def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursorReadOnly[S]] IDBIndex[JC] def unique: Boolean -IDBKeyRange[JC] def lower: js.Any +IDBKeyRange[JC] def lower: IDBKey IDBKeyRange[JC] def lowerOpen: Boolean -IDBKeyRange[JC] def upper: js.Any +IDBKeyRange[JC] def upper: IDBKey IDBKeyRange[JC] def upperOpen: Boolean -IDBKeyRange[JO] def bound(lower: js.Any, upper: js.Any, lowerOpen: Boolean?, upperOpen: Boolean?): IDBKeyRange -IDBKeyRange[JO] def lowerBound(bound: js.Any, open: Boolean?): IDBKeyRange -IDBKeyRange[JO] def only(value: js.Any): IDBKeyRange -IDBKeyRange[JO] def upperBound(bound: js.Any, open: Boolean?): IDBKeyRange -IDBObjectStore[JC] def add(value: js.Any, key: js.Any?): IDBRequest -IDBObjectStore[JC] def clear(): IDBRequest -IDBObjectStore[JC] def count(key: js.Any?): IDBRequest -IDBObjectStore[JC] def createIndex(name: String, keyPath: String, optionalParameters: js.Any?): IDBIndex -IDBObjectStore[JC] def delete(key: js.Any): IDBRequest +IDBKeyRange[JO] def bound(lower: IDBKey, upper: IDBKey, lowerOpen: Boolean?, upperOpen: Boolean?): IDBKeyRange +IDBKeyRange[JO] def lowerBound(bound: IDBKey, open: Boolean?): IDBKeyRange +IDBKeyRange[JO] def only(value: IDBValue): IDBKeyRange +IDBKeyRange[JO] def upperBound(bound: IDBKey, open: Boolean?): IDBKeyRange +IDBObjectStore[JC] def add(value: IDBValue, key: IDBKey?): IDBRequest[IDBObjectStore, IDBKey] +IDBObjectStore[JC] def clear(): IDBRequest[IDBObjectStore, Unit] +IDBObjectStore[JC] def count(query: IDBKey | IDBKeyRange?): IDBRequest[S, Double] +IDBObjectStore[JC] def createIndex(name: String, keyPath: IDBKeyPath, optionalParameters: IDBCreateIndexOptions?): IDBIndex +IDBObjectStore[JC] def delete(key: IDBKey | IDBKeyRange): IDBRequest[IDBObjectStore, Unit] IDBObjectStore[JC] def deleteIndex(indexName: String): Unit -IDBObjectStore[JC] def get(key: js.Any): IDBRequest -IDBObjectStore[JC] def getAll(query: js.UndefOr[IDBKeyRange | js.Any]?, count: js.UndefOr[Int]?): IDBRequest -IDBObjectStore[JC] def getAllKeys(query: js.UndefOr[IDBKeyRange | js.Any]?, count: js.UndefOr[Int]?): IDBRequest -IDBObjectStore[JC] def getKey(key: js.Any): IDBRequest +IDBObjectStore[JC] def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] +IDBObjectStore[JC] def getAll(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBValue]] +IDBObjectStore[JC] def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBKey]] +IDBObjectStore[JC] def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] IDBObjectStore[JC] def index(name: String): IDBIndex IDBObjectStore[JC] def indexNames: DOMStringList -IDBObjectStore[JC] def keyPath: String +IDBObjectStore[JC] def keyPath: IDBKeyPath IDBObjectStore[JC] def name: String -IDBObjectStore[JC] def openCursor(range: js.UndefOr[IDBKeyRange | js.Any]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest -IDBObjectStore[JC] def openKeyCursor(range: js.UndefOr[IDBKeyRange | js.Any]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest -IDBObjectStore[JC] def put(value: js.Any, key: js.Any?): IDBRequest +IDBObjectStore[JC] def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursor[S]] +IDBObjectStore[JC] def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursorReadOnly[S]] +IDBObjectStore[JC] def put(value: IDBValue, key: IDBKey?): IDBRequest[IDBObjectStore, IDBKey] IDBObjectStore[JC] def transaction: IDBTransaction IDBOpenDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBOpenDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -13614,26 +13649,35 @@ IDBOpenDBRequest[JC] def dispatchEvent(evt: Event): Boolean IDBOpenDBRequest[JC] def error: DOMException IDBOpenDBRequest[JC] var onblocked: js.Function1[IDBVersionChangeEvent, _] IDBOpenDBRequest[JC] var onerror: js.Function1[Event, _] -IDBOpenDBRequest[JC] var onsuccess: js.Function1[Event, _] +IDBOpenDBRequest[JC] var onsuccess: js.Function1[IDBEvent[A], _] IDBOpenDBRequest[JC] var onupgradeneeded: js.Function1[IDBVersionChangeEvent, _] IDBOpenDBRequest[JC] def readyState: String IDBOpenDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBOpenDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -IDBOpenDBRequest[JC] def result: js.Any -IDBOpenDBRequest[JC] def source: js.Any +IDBOpenDBRequest[JC] def result: A +IDBOpenDBRequest[JC] def source: S IDBOpenDBRequest[JC] def transaction: IDBTransaction IDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit IDBRequest[JC] def dispatchEvent(evt: Event): Boolean IDBRequest[JC] def error: DOMException IDBRequest[JC] var onerror: js.Function1[Event, _] -IDBRequest[JC] var onsuccess: js.Function1[Event, _] +IDBRequest[JC] var onsuccess: js.Function1[IDBEvent[A], _] IDBRequest[JC] def readyState: String IDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -IDBRequest[JC] def result: js.Any -IDBRequest[JC] def source: js.Any +IDBRequest[JC] def result: A +IDBRequest[JC] def source: S IDBRequest[JC] def transaction: IDBTransaction +IDBStoreLike[JT] def count(query: IDBKey | IDBKeyRange?): IDBRequest[S, Double] +IDBStoreLike[JT] def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] +IDBStoreLike[JT] def getAll(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBValue]] +IDBStoreLike[JT] def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBKey]] +IDBStoreLike[JT] def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] +IDBStoreLike[JT] def keyPath: IDBKeyPath +IDBStoreLike[JT] def name: String +IDBStoreLike[JT] def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursor[S]] +IDBStoreLike[JT] def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursorReadOnly[S]] IDBTransaction[JC] def abort(): Unit IDBTransaction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBTransaction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -13647,10 +13691,15 @@ IDBTransaction[JC] var oncomplete: js.Function1[Event, _] IDBTransaction[JC] var onerror: js.Function1[Event, _] IDBTransaction[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBTransaction[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +IDBTransactionDurability[JT] +IDBTransactionDurability[SO] def default: IDBTransactionDurability +IDBTransactionDurability[SO] def relaxed: IDBTransactionDurability +IDBTransactionDurability[SO] def strict: IDBTransactionDurability IDBTransactionMode[JT] -IDBTransactionMode[SO] val READ_ONLY: IDBTransactionMode -IDBTransactionMode[SO] val READ_WRITE: IDBTransactionMode -IDBTransactionMode[SO] val VERSION_CHANGE: IDBTransactionMode +IDBTransactionMode[SO] def readonly: IDBTransactionMode +IDBTransactionMode[SO] def readwrite: IDBTransactionMode +IDBTransactionMode[SO] def versionchange: IDBTransactionMode +IDBTransactionOptions[JT] val durability: js.UndefOr[IDBTransactionDurability] IDBVersionChangeEvent[JC] def bubbles: Boolean IDBVersionChangeEvent[JC] def cancelBubble: Boolean IDBVersionChangeEvent[JC] def cancelable: Boolean @@ -13664,6 +13713,7 @@ IDBVersionChangeEvent[JC] def preventDefault(): Unit IDBVersionChangeEvent[JC] def stopImmediatePropagation(): Unit IDBVersionChangeEvent[JC] def stopPropagation(): Unit IDBVersionChangeEvent[JC] def target: EventTarget +IDBVersionChangeEvent[JC] override def target: IDBEventTarget[A] IDBVersionChangeEvent[JC] def timeStamp: Double IDBVersionChangeEvent[JC] def `type`: String IDBVersionChangeEventInit[JT] var bubbles: js.UndefOr[Boolean] @@ -25561,17 +25611,26 @@ html[SO] type UList = HTMLUListElement html[SO] type Unknown = HTMLUnknownElement html[SO] type Video = HTMLVideoElement html[SO] def Media = HTMLMediaElement -idb[SO] type Cursor = IDBCursor -idb[SO] type CursorWithValue = IDBCursorWithValue +idb[SO] type CreateIndexOptions = IDBCreateIndexOptions +idb[SO] type CreateObjectStoreOptions = IDBCreateObjectStoreOptions +idb[SO] type CursorReadOnly[+Source] = IDBCursorReadOnly[Source] +idb[SO] type CursorWithValue[+Source] = IDBCursorWithValue[Source] +idb[SO] type Cursor[+Source] = IDBCursor[Source] idb[SO] type Database = IDBDatabase +idb[SO] type DatabaseInfo = IDBDatabaseInfo idb[SO] type Environment = IDBEnvironment (@deprecated in 1.2.0) +idb[SO] type EventTarget[+Result] = IDBEventTarget[Result] +idb[SO] type Event[+TargetResult] = IDBEvent[TargetResult] idb[SO] type Factory = IDBFactory idb[SO] type Index = IDBIndex +idb[SO] type Key = IDBKey +idb[SO] type KeyPath = IDBKeyPath idb[SO] type KeyRange = IDBKeyRange idb[SO] type ObjectStore = IDBObjectStore -idb[SO] type OpenDBRequest = IDBOpenDBRequest -idb[SO] type Request = IDBRequest +idb[SO] type OpenDBRequest[TargetResult] = IDBOpenDBRequest[TargetResult] +idb[SO] type Request[+Source, TargetResult] = IDBRequest[Source, TargetResult] idb[SO] type Transaction = IDBTransaction +idb[SO] type Value = IDBValue idb[SO] type VersionChangeEvent = IDBVersionChangeEvent idb[SO] def CursorDirection = IDBCursorDirection idb[SO] def KeyRange = IDBKeyRange @@ -25582,6 +25641,9 @@ package[SO] type ByteString = String package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) package[SO] type ClientRectList = DOMRectList (@deprecated in 2.0.0) package[SO] type HeadersInit = Headers | Sequence[Sequence[ByteString]] | OpenEndedDictionary[ByteString] +package[SO] type IDBKey = Any +package[SO] type IDBKeyPath = Any +package[SO] type IDBValue = Any package[SO] type NodeListOf[+T <: Node] = NodeList[T] (@deprecated in 2.0.0) package[SO] type OpenEndedDictionary[T] = js.Dictionary[T] package[SO] type RequestInfo = String | Request @@ -25736,16 +25798,16 @@ raw[SO] type HTMLUnknownElement = dom.HTMLUnknownElement (@deprecated in 2.0.0) raw[SO] type HTMLVideoElement = dom.HTMLVideoElement (@deprecated in 2.0.0) raw[SO] type HashChangeEvent = dom.HashChangeEvent (@deprecated in 2.0.0) raw[SO] type History = dom.History (@deprecated in 2.0.0) -raw[SO] type IDBCursor = dom.IDBCursor (@deprecated in 2.0.0) -raw[SO] type IDBCursorWithValue = dom.IDBCursorWithValue (@deprecated in 2.0.0) +raw[SO] type IDBCursor = dom.IDBCursor[IDBObjectStore | IDBIndex] (@deprecated in 2.0.0) +raw[SO] type IDBCursorWithValue = dom.IDBCursorWithValue[Any] (@deprecated in 2.0.0) raw[SO] type IDBDatabase = dom.IDBDatabase (@deprecated in 2.0.0) raw[SO] type IDBEnvironment = dom.IDBEnvironment (@deprecated in 2.0.0) raw[SO] type IDBFactory = dom.IDBFactory (@deprecated in 2.0.0) raw[SO] type IDBIndex = dom.IDBIndex (@deprecated in 2.0.0) raw[SO] type IDBKeyRange = dom.IDBKeyRange (@deprecated in 2.0.0) raw[SO] type IDBObjectStore = dom.IDBObjectStore (@deprecated in 2.0.0) -raw[SO] type IDBOpenDBRequest = dom.IDBOpenDBRequest (@deprecated in 2.0.0) -raw[SO] type IDBRequest = dom.IDBRequest (@deprecated in 2.0.0) +raw[SO] type IDBOpenDBRequest = dom.IDBOpenDBRequest[Any] (@deprecated in 2.0.0) +raw[SO] type IDBRequest = dom.IDBRequest[Any, Any] (@deprecated in 2.0.0) raw[SO] type IDBTransaction = dom.IDBTransaction (@deprecated in 2.0.0) raw[SO] type IDBVersionChangeEvent = dom.IDBVersionChangeEvent (@deprecated in 2.0.0) raw[SO] type ImageBitmap = dom.ImageBitmap (@deprecated in 2.0.0) diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 4120f3b14..d61d01552 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -13530,32 +13530,43 @@ HttpMethod[SO] val PATCH: HttpMethod HttpMethod[SO] val POST: HttpMethod HttpMethod[SO] val PUT: HttpMethod HttpMethod[SO] val QUERY: HttpMethod -IDBCursor[JC] def advance(count: Int): Unit -IDBCursor[JC] def continue(key: js.Any?): Unit -IDBCursor[JC] def delete(): IDBRequest +IDBCreateIndexOptions[JT] val locale: js.UndefOr[String] +IDBCreateIndexOptions[JT] val multiEntry: js.UndefOr[Boolean] +IDBCreateIndexOptions[JT] val unique: js.UndefOr[Boolean] +IDBCreateObjectStoreOptions[JT] val autoIncrement: js.UndefOr[Boolean] +IDBCreateObjectStoreOptions[JT] val keyPath: IDBKeyPath +IDBCursor[JC] def advance(count: Double): Unit +IDBCursor[JC] def continue(key: IDBKey?): Unit +IDBCursor[JC] def delete(): IDBRequest[S, Unit] IDBCursor[JC] def direction: IDBCursorDirection -IDBCursor[JC] def key: js.Any -IDBCursor[JC] def primaryKey: js.Any -IDBCursor[JC] def source: js.Any -IDBCursor[JC] def update(value: js.Any): IDBRequest +IDBCursor[JC] def key: IDBKey +IDBCursor[JC] def primaryKey: IDBKey +IDBCursor[JC] def source: S +IDBCursor[JC] def update(value: IDBValue): IDBRequest[S, IDBKey] IDBCursorDirection[JT] -IDBCursorDirection[SO] val NEXT: IDBCursorDirection -IDBCursorDirection[SO] val NEXT_UNIQUE: IDBCursorDirection -IDBCursorDirection[SO] val PREV: IDBCursorDirection -IDBCursorDirection[SO] val PREV_UNIQUE: IDBCursorDirection -IDBCursorWithValue[JC] def advance(count: Int): Unit -IDBCursorWithValue[JC] def continue(key: js.Any?): Unit -IDBCursorWithValue[JC] def delete(): IDBRequest +IDBCursorDirection[SO] def next: IDBCursorDirection +IDBCursorDirection[SO] def nextunique: IDBCursorDirection +IDBCursorDirection[SO] def prev: IDBCursorDirection +IDBCursorDirection[SO] def prevunique: IDBCursorDirection +IDBCursorReadOnly[JC] def advance(count: Double): Unit +IDBCursorReadOnly[JC] def continue(key: IDBKey?): Unit +IDBCursorReadOnly[JC] def direction: IDBCursorDirection +IDBCursorReadOnly[JC] def key: IDBKey +IDBCursorReadOnly[JC] def primaryKey: IDBKey +IDBCursorReadOnly[JC] def source: S +IDBCursorWithValue[JC] def advance(count: Double): Unit +IDBCursorWithValue[JC] def continue(key: IDBKey?): Unit +IDBCursorWithValue[JC] def delete(): IDBRequest[S, Unit] IDBCursorWithValue[JC] def direction: IDBCursorDirection -IDBCursorWithValue[JC] def key: js.Any -IDBCursorWithValue[JC] def primaryKey: js.Any -IDBCursorWithValue[JC] def source: js.Any -IDBCursorWithValue[JC] def update(value: js.Any): IDBRequest -IDBCursorWithValue[JC] def value: js.Any +IDBCursorWithValue[JC] def key: IDBKey +IDBCursorWithValue[JC] def primaryKey: IDBKey +IDBCursorWithValue[JC] def source: S +IDBCursorWithValue[JC] def update(value: IDBValue): IDBRequest[S, IDBKey] +IDBCursorWithValue[JC] def value: IDBValue IDBDatabase[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBDatabase[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit IDBDatabase[JC] def close(): Unit -IDBDatabase[JC] def createObjectStore(name: String, optionalParameters: js.Any?): IDBObjectStore +IDBDatabase[JC] def createObjectStore(name: String, optionalParameters: js.UndefOr[IDBCreateObjectStoreOptions]?): IDBObjectStore IDBDatabase[JC] def deleteObjectStore(name: String): Unit IDBDatabase[JC] def dispatchEvent(evt: Event): Boolean IDBDatabase[JC] def name: String @@ -13565,48 +13576,72 @@ IDBDatabase[JC] var onerror: js.Function1[Event, _] IDBDatabase[JC] var onversionchange: js.Function1[IDBVersionChangeEvent, _] IDBDatabase[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBDatabase[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -IDBDatabase[JC] def transaction(storeNames: js.Any, mode: IDBTransactionMode?): IDBTransaction +IDBDatabase[JC] def transaction(storeNames: String | js.Array[String], mode: js.UndefOr[IDBTransactionMode]?, options: js.UndefOr[IDBTransactionOptions]?): IDBTransaction IDBDatabase[JC] def version: Int +IDBDatabaseInfo[JT] val name: String +IDBDatabaseInfo[JT] val version: Int IDBEnvironment[JT] def indexedDB: IDBFactory (@deprecated in 1.2.0) -IDBFactory[JC] def cmp(first: js.Any, second: js.Any): Int -IDBFactory[JC] def deleteDatabase(name: String): IDBOpenDBRequest -IDBFactory[JC] def open(name: String): IDBOpenDBRequest -IDBFactory[JC] def open(name: String, version: Int): IDBOpenDBRequest -IDBIndex[JC] def count(): IDBRequest -IDBIndex[JC] def count(key: js.Any): IDBRequest -IDBIndex[JC] def get(key: js.Any): IDBRequest -IDBIndex[JC] def getKey(key: js.Any): IDBRequest -IDBIndex[JC] def keyPath: String +IDBEvent[JC] def bubbles: Boolean +IDBEvent[JC] def cancelBubble: Boolean +IDBEvent[JC] def cancelable: Boolean +IDBEvent[JC] def currentTarget: EventTarget +IDBEvent[JC] def defaultPrevented: Boolean +IDBEvent[JC] def eventPhase: Int +IDBEvent[JC] def isTrusted: Boolean +IDBEvent[JC] def preventDefault(): Unit +IDBEvent[JC] def stopImmediatePropagation(): Unit +IDBEvent[JC] def stopPropagation(): Unit +IDBEvent[JC] def target: EventTarget +IDBEvent[JC] override def target: IDBEventTarget[A] +IDBEvent[JC] def timeStamp: Double +IDBEvent[JC] def `type`: String +IDBEventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +IDBEventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +IDBEventTarget[JC] def dispatchEvent(evt: Event): Boolean +IDBEventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +IDBEventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +IDBEventTarget[JC] def result: A +IDBFactory[JC] def cmp(first: IDBValue, second: IDBValue): Int +IDBFactory[JC] def databases(): js.Promise[js.Array[IDBDatabaseInfo]] +IDBFactory[JC] def deleteDatabase(name: String): IDBOpenDBRequest[Unit] +IDBFactory[JC] def open(name: String, version: Int?): IDBOpenDBRequest[IDBDatabase] +IDBIndex[JC] def count(query: IDBKey | IDBKeyRange?): IDBRequest[S, Double] +IDBIndex[JC] def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] +IDBIndex[JC] def getAll(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBValue]] +IDBIndex[JC] def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBKey]] +IDBIndex[JC] def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] +IDBIndex[JC] def keyPath: IDBKeyPath +IDBIndex[JC] val multiEntry: Boolean IDBIndex[JC] def name: String IDBIndex[JC] def objectStore: IDBObjectStore -IDBIndex[JC] def openCursor(range: IDBKeyRange?, direction: IDBCursorDirection?): IDBRequest -IDBIndex[JC] def openKeyCursor(range: IDBKeyRange?, direction: IDBCursorDirection?): IDBRequest +IDBIndex[JC] def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursor[S]] +IDBIndex[JC] def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursorReadOnly[S]] IDBIndex[JC] def unique: Boolean -IDBKeyRange[JC] def lower: js.Any +IDBKeyRange[JC] def lower: IDBKey IDBKeyRange[JC] def lowerOpen: Boolean -IDBKeyRange[JC] def upper: js.Any +IDBKeyRange[JC] def upper: IDBKey IDBKeyRange[JC] def upperOpen: Boolean -IDBKeyRange[JO] def bound(lower: js.Any, upper: js.Any, lowerOpen: Boolean?, upperOpen: Boolean?): IDBKeyRange -IDBKeyRange[JO] def lowerBound(bound: js.Any, open: Boolean?): IDBKeyRange -IDBKeyRange[JO] def only(value: js.Any): IDBKeyRange -IDBKeyRange[JO] def upperBound(bound: js.Any, open: Boolean?): IDBKeyRange -IDBObjectStore[JC] def add(value: js.Any, key: js.Any?): IDBRequest -IDBObjectStore[JC] def clear(): IDBRequest -IDBObjectStore[JC] def count(key: js.Any?): IDBRequest -IDBObjectStore[JC] def createIndex(name: String, keyPath: String, optionalParameters: js.Any?): IDBIndex -IDBObjectStore[JC] def delete(key: js.Any): IDBRequest +IDBKeyRange[JO] def bound(lower: IDBKey, upper: IDBKey, lowerOpen: Boolean?, upperOpen: Boolean?): IDBKeyRange +IDBKeyRange[JO] def lowerBound(bound: IDBKey, open: Boolean?): IDBKeyRange +IDBKeyRange[JO] def only(value: IDBValue): IDBKeyRange +IDBKeyRange[JO] def upperBound(bound: IDBKey, open: Boolean?): IDBKeyRange +IDBObjectStore[JC] def add(value: IDBValue, key: IDBKey?): IDBRequest[IDBObjectStore, IDBKey] +IDBObjectStore[JC] def clear(): IDBRequest[IDBObjectStore, Unit] +IDBObjectStore[JC] def count(query: IDBKey | IDBKeyRange?): IDBRequest[S, Double] +IDBObjectStore[JC] def createIndex(name: String, keyPath: IDBKeyPath, optionalParameters: IDBCreateIndexOptions?): IDBIndex +IDBObjectStore[JC] def delete(key: IDBKey | IDBKeyRange): IDBRequest[IDBObjectStore, Unit] IDBObjectStore[JC] def deleteIndex(indexName: String): Unit -IDBObjectStore[JC] def get(key: js.Any): IDBRequest -IDBObjectStore[JC] def getAll(query: js.UndefOr[IDBKeyRange | js.Any]?, count: js.UndefOr[Int]?): IDBRequest -IDBObjectStore[JC] def getAllKeys(query: js.UndefOr[IDBKeyRange | js.Any]?, count: js.UndefOr[Int]?): IDBRequest -IDBObjectStore[JC] def getKey(key: js.Any): IDBRequest +IDBObjectStore[JC] def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] +IDBObjectStore[JC] def getAll(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBValue]] +IDBObjectStore[JC] def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBKey]] +IDBObjectStore[JC] def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] IDBObjectStore[JC] def index(name: String): IDBIndex IDBObjectStore[JC] def indexNames: DOMStringList -IDBObjectStore[JC] def keyPath: String +IDBObjectStore[JC] def keyPath: IDBKeyPath IDBObjectStore[JC] def name: String -IDBObjectStore[JC] def openCursor(range: js.UndefOr[IDBKeyRange | js.Any]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest -IDBObjectStore[JC] def openKeyCursor(range: js.UndefOr[IDBKeyRange | js.Any]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest -IDBObjectStore[JC] def put(value: js.Any, key: js.Any?): IDBRequest +IDBObjectStore[JC] def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursor[S]] +IDBObjectStore[JC] def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursorReadOnly[S]] +IDBObjectStore[JC] def put(value: IDBValue, key: IDBKey?): IDBRequest[IDBObjectStore, IDBKey] IDBObjectStore[JC] def transaction: IDBTransaction IDBOpenDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBOpenDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -13614,26 +13649,35 @@ IDBOpenDBRequest[JC] def dispatchEvent(evt: Event): Boolean IDBOpenDBRequest[JC] def error: DOMException IDBOpenDBRequest[JC] var onblocked: js.Function1[IDBVersionChangeEvent, _] IDBOpenDBRequest[JC] var onerror: js.Function1[Event, _] -IDBOpenDBRequest[JC] var onsuccess: js.Function1[Event, _] +IDBOpenDBRequest[JC] var onsuccess: js.Function1[IDBEvent[A], _] IDBOpenDBRequest[JC] var onupgradeneeded: js.Function1[IDBVersionChangeEvent, _] IDBOpenDBRequest[JC] def readyState: String IDBOpenDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBOpenDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -IDBOpenDBRequest[JC] def result: js.Any -IDBOpenDBRequest[JC] def source: js.Any +IDBOpenDBRequest[JC] def result: A +IDBOpenDBRequest[JC] def source: S IDBOpenDBRequest[JC] def transaction: IDBTransaction IDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBRequest[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit IDBRequest[JC] def dispatchEvent(evt: Event): Boolean IDBRequest[JC] def error: DOMException IDBRequest[JC] var onerror: js.Function1[Event, _] -IDBRequest[JC] var onsuccess: js.Function1[Event, _] +IDBRequest[JC] var onsuccess: js.Function1[IDBEvent[A], _] IDBRequest[JC] def readyState: String IDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBRequest[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -IDBRequest[JC] def result: js.Any -IDBRequest[JC] def source: js.Any +IDBRequest[JC] def result: A +IDBRequest[JC] def source: S IDBRequest[JC] def transaction: IDBTransaction +IDBStoreLike[JT] def count(query: IDBKey | IDBKeyRange?): IDBRequest[S, Double] +IDBStoreLike[JT] def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] +IDBStoreLike[JT] def getAll(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBValue]] +IDBStoreLike[JT] def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey]?, count: js.UndefOr[Double]?): IDBRequest[S, js.Array[IDBKey]] +IDBStoreLike[JT] def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] +IDBStoreLike[JT] def keyPath: IDBKeyPath +IDBStoreLike[JT] def name: String +IDBStoreLike[JT] def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursor[S]] +IDBStoreLike[JT] def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey]?, direction: js.UndefOr[IDBCursorDirection]?): IDBRequest[S, IDBCursorReadOnly[S]] IDBTransaction[JC] def abort(): Unit IDBTransaction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBTransaction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -13647,10 +13691,15 @@ IDBTransaction[JC] var oncomplete: js.Function1[Event, _] IDBTransaction[JC] var onerror: js.Function1[Event, _] IDBTransaction[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit IDBTransaction[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +IDBTransactionDurability[JT] +IDBTransactionDurability[SO] def default: IDBTransactionDurability +IDBTransactionDurability[SO] def relaxed: IDBTransactionDurability +IDBTransactionDurability[SO] def strict: IDBTransactionDurability IDBTransactionMode[JT] -IDBTransactionMode[SO] val READ_ONLY: IDBTransactionMode -IDBTransactionMode[SO] val READ_WRITE: IDBTransactionMode -IDBTransactionMode[SO] val VERSION_CHANGE: IDBTransactionMode +IDBTransactionMode[SO] def readonly: IDBTransactionMode +IDBTransactionMode[SO] def readwrite: IDBTransactionMode +IDBTransactionMode[SO] def versionchange: IDBTransactionMode +IDBTransactionOptions[JT] val durability: js.UndefOr[IDBTransactionDurability] IDBVersionChangeEvent[JC] def bubbles: Boolean IDBVersionChangeEvent[JC] def cancelBubble: Boolean IDBVersionChangeEvent[JC] def cancelable: Boolean @@ -13664,6 +13713,7 @@ IDBVersionChangeEvent[JC] def preventDefault(): Unit IDBVersionChangeEvent[JC] def stopImmediatePropagation(): Unit IDBVersionChangeEvent[JC] def stopPropagation(): Unit IDBVersionChangeEvent[JC] def target: EventTarget +IDBVersionChangeEvent[JC] override def target: IDBEventTarget[A] IDBVersionChangeEvent[JC] def timeStamp: Double IDBVersionChangeEvent[JC] def `type`: String IDBVersionChangeEventInit[JT] var bubbles: js.UndefOr[Boolean] @@ -25561,17 +25611,26 @@ html[SO] type UList = HTMLUListElement html[SO] type Unknown = HTMLUnknownElement html[SO] type Video = HTMLVideoElement html[SO] def Media = HTMLMediaElement -idb[SO] type Cursor = IDBCursor -idb[SO] type CursorWithValue = IDBCursorWithValue +idb[SO] type CreateIndexOptions = IDBCreateIndexOptions +idb[SO] type CreateObjectStoreOptions = IDBCreateObjectStoreOptions +idb[SO] type CursorReadOnly[+Source] = IDBCursorReadOnly[Source] +idb[SO] type CursorWithValue[+Source] = IDBCursorWithValue[Source] +idb[SO] type Cursor[+Source] = IDBCursor[Source] idb[SO] type Database = IDBDatabase +idb[SO] type DatabaseInfo = IDBDatabaseInfo idb[SO] type Environment = IDBEnvironment (@deprecated in 1.2.0) +idb[SO] type EventTarget[+Result] = IDBEventTarget[Result] +idb[SO] type Event[+TargetResult] = IDBEvent[TargetResult] idb[SO] type Factory = IDBFactory idb[SO] type Index = IDBIndex +idb[SO] type Key = IDBKey +idb[SO] type KeyPath = IDBKeyPath idb[SO] type KeyRange = IDBKeyRange idb[SO] type ObjectStore = IDBObjectStore -idb[SO] type OpenDBRequest = IDBOpenDBRequest -idb[SO] type Request = IDBRequest +idb[SO] type OpenDBRequest[TargetResult] = IDBOpenDBRequest[TargetResult] +idb[SO] type Request[+Source, TargetResult] = IDBRequest[Source, TargetResult] idb[SO] type Transaction = IDBTransaction +idb[SO] type Value = IDBValue idb[SO] type VersionChangeEvent = IDBVersionChangeEvent idb[SO] def CursorDirection = IDBCursorDirection idb[SO] def KeyRange = IDBKeyRange @@ -25582,6 +25641,9 @@ package[SO] type ByteString = String package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) package[SO] type ClientRectList = DOMRectList (@deprecated in 2.0.0) package[SO] type HeadersInit = Headers | Sequence[Sequence[ByteString]] | OpenEndedDictionary[ByteString] +package[SO] type IDBKey = Any +package[SO] type IDBKeyPath = Any +package[SO] type IDBValue = Any package[SO] type NodeListOf[+T <: Node] = NodeList[T] (@deprecated in 2.0.0) package[SO] type OpenEndedDictionary[T] = js.Dictionary[T] package[SO] type RequestInfo = String | Request @@ -25736,16 +25798,16 @@ raw[SO] type HTMLUnknownElement = dom.HTMLUnknownElement (@deprecated in 2.0.0) raw[SO] type HTMLVideoElement = dom.HTMLVideoElement (@deprecated in 2.0.0) raw[SO] type HashChangeEvent = dom.HashChangeEvent (@deprecated in 2.0.0) raw[SO] type History = dom.History (@deprecated in 2.0.0) -raw[SO] type IDBCursor = dom.IDBCursor (@deprecated in 2.0.0) -raw[SO] type IDBCursorWithValue = dom.IDBCursorWithValue (@deprecated in 2.0.0) +raw[SO] type IDBCursor = dom.IDBCursor[IDBObjectStore | IDBIndex] (@deprecated in 2.0.0) +raw[SO] type IDBCursorWithValue = dom.IDBCursorWithValue[Any] (@deprecated in 2.0.0) raw[SO] type IDBDatabase = dom.IDBDatabase (@deprecated in 2.0.0) raw[SO] type IDBEnvironment = dom.IDBEnvironment (@deprecated in 2.0.0) raw[SO] type IDBFactory = dom.IDBFactory (@deprecated in 2.0.0) raw[SO] type IDBIndex = dom.IDBIndex (@deprecated in 2.0.0) raw[SO] type IDBKeyRange = dom.IDBKeyRange (@deprecated in 2.0.0) raw[SO] type IDBObjectStore = dom.IDBObjectStore (@deprecated in 2.0.0) -raw[SO] type IDBOpenDBRequest = dom.IDBOpenDBRequest (@deprecated in 2.0.0) -raw[SO] type IDBRequest = dom.IDBRequest (@deprecated in 2.0.0) +raw[SO] type IDBOpenDBRequest = dom.IDBOpenDBRequest[Any] (@deprecated in 2.0.0) +raw[SO] type IDBRequest = dom.IDBRequest[Any, Any] (@deprecated in 2.0.0) raw[SO] type IDBTransaction = dom.IDBTransaction (@deprecated in 2.0.0) raw[SO] type IDBVersionChangeEvent = dom.IDBVersionChangeEvent (@deprecated in 2.0.0) raw[SO] type ImageBitmap = dom.ImageBitmap (@deprecated in 2.0.0) diff --git a/src/main/scala/org/scalajs/dom/IDBTypes.scala b/src/main/scala/org/scalajs/dom/IDBTypes.scala index 40c8a5b58..2a196e41e 100644 --- a/src/main/scala/org/scalajs/dom/IDBTypes.scala +++ b/src/main/scala/org/scalajs/dom/IDBTypes.scala @@ -10,6 +10,19 @@ import scala.scalajs.js import scala.scalajs.js.annotation._ import scala.scalajs.js.| +/** @tparam A Type of `.target.result` */ +@js.native +@JSGlobal("Event") +class IDBEvent[+A](typeArg: String, init: js.UndefOr[EventInit] = js.undefined) extends Event(typeArg, init) { + override def target: IDBEventTarget[A] = js.native +} + +@js.native +@JSGlobal("EventTarget") +class IDBEventTarget[+A] extends EventTarget { + def result: A = js.native +} + /** IndexedDB transaction mode Provides constants for IDB Transaction modes These constants have been removed from * browser support and replaced by String values */ @@ -19,69 +32,147 @@ sealed trait IDBTransactionMode extends js.Any object IDBTransactionMode { /** Allows data to be read but not changed. It is the default transaction mode. */ - val READ_ONLY: IDBTransactionMode = "readonly".asInstanceOf[IDBTransactionMode] + @inline def readonly: IDBTransactionMode = "readonly".asInstanceOf[IDBTransactionMode] /** 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 VERSION_CHANGE: IDBTransactionMode = "versionchange".asInstanceOf[IDBTransactionMode] + @inline def versionchange: IDBTransactionMode = "versionchange".asInstanceOf[IDBTransactionMode] /** Allows reading and writing of data in existing data stores to be changed. */ - val READ_WRITE: IDBTransactionMode = "readwrite".asInstanceOf[IDBTransactionMode] + @inline def readwrite: IDBTransactionMode = "readwrite".asInstanceOf[IDBTransactionMode] +} + +@js.native +sealed trait IDBTransactionDurability extends js.Any +object IDBTransactionDurability { + @inline def default: IDBTransactionDurability = "default".asInstanceOf[IDBTransactionDurability] + @inline def strict: IDBTransactionDurability = "strict".asInstanceOf[IDBTransactionDurability] + @inline def relaxed: IDBTransactionDurability = "relaxed".asInstanceOf[IDBTransactionDurability] } -/** The IDBObjectStore interface of the IndexedDB API represents an object store in a database. Records within an object - * store are sorted according to their keys. This sorting enables fast insertion, look-up, and ordered retrieval. +/** Common members shared between [[IDBObjectStore]] and [[IDBIndex]]. + * + * @tparam S + * The type of `.source` */ @js.native -@JSGlobal -class IDBObjectStore extends js.Object { +trait IDBStoreLike[S] extends js.Object { - /** A list of the names of indexes on objects in this object store. */ - def indexNames: DOMStringList = js.native + def count(query: IDBKey | IDBKeyRange = js.native): IDBRequest[S, Double] = js.native - def name: String = js.native + /** Returns an [[IDBRequest]] object, and, in a separate thread, returns the object store selected by the specified + * key. This is for retrieving specific records from an object store. + * + * Note: This method produces the same result for: a) a record that doesn't exist in the database and b) a record + * that has an undefined value. To tell these situations apart, call the [[openCursor]] method with the same key. + * That method provides a cursor if the record exists, and no cursor if it does not. + */ + def get(key: IDBKey | IDBKeyRange): IDBRequest[S, IDBValue] = js.native - /** The name of the transaction to which this object store belongs. */ - def transaction: IDBTransaction = js.native + /** Returns an [[IDBRequest]] object containing all objects in the object store matching the specified parameter or + * all objects in the store if no parameters are given. + * + * If a value is successfully found, then a structured clone of it is created and set as the result of the request + * object. + * + * This method produces the same result for: + * + * - a record that doesn't exist in the database + * - a record that has an undefined value + * + * To tell these situations apart, you either call + * + * - the [[openCursor]] method with the same key. That method provides a cursor if the record exists, and no cursor + * if it does not. + * - the [[count]] method with the same key, which will return 1 if the row exists and 0 if it doesn't. + */ + def getAll(query: js.UndefOr[IDBKeyRange | IDBKey] = js.native, + count: js.UndefOr[Double] = js.native): IDBRequest[S, js.Array[IDBValue]] = js.native + + /** Returns an [[IDBRequest]] object retrieves record keys for all objects in the object store matching the specified + * parameter or all objects in the store if no parameters are given. + * + * If a value is successfully found, then a structured clone of it is created and set as the result of the request + * object. + * + * This method produces the same result for: + * + * - a record that doesn't exist in the database + * - a record that has an undefined value + * + * To tell these situations apart, you need to call the [[openCursor]] method with the same key. That method provides + * a cursor if the record exists, and no cursor if it does not. + */ + def getAllKeys(query: js.UndefOr[IDBKeyRange | IDBKey] = js.native, + count: js.UndefOr[Double] = js.native): IDBRequest[S, js.Array[IDBKey]] = js.native + + /** Returns an [[IDBRequest]] object, and, in a separate thread, returns the key selected by the specified query. This + * is for retrieving specific records from an object store. + */ + def getKey(key: IDBKey): IDBRequest[S, js.UndefOr[IDBKey]] = js.native /** The key path of this object store. If this attribute is null, the application must provide a key for each * modification operation. */ - def keyPath: String = js.native + def keyPath: IDBKeyPath = js.native + + def name: String = js.native - def count(key: js.Any = js.native): IDBRequest = js.native + /** The method sets the position of the cursor to the appropriate record, based on the specified direction. + * + * @return + * [[IDBRequest]] with the `target` value being a new cursor or `null`. + */ + def openCursor(range: js.UndefOr[IDBKeyRange | IDBKey] = js.native, + direction: js.UndefOr[IDBCursorDirection] = js.native): IDBRequest[S, IDBCursor[S]] = js.native + + /** The method sets the position of the cursor to the appropriate key, based on the specified direction. + * + * @return + * [[IDBRequest]] with the `target` value being a new cursor or `null`. + */ + def openKeyCursor(range: js.UndefOr[IDBKeyRange | IDBKey] = js.native, + direction: js.UndefOr[IDBCursorDirection] = js.native): IDBRequest[S, IDBCursorReadOnly[S]] = js.native +} + +/** The IDBObjectStore interface of the IndexedDB API represents an object store in a database. Records within an object + * store are sorted according to their keys. This sorting enables fast insertion, look-up, and ordered retrieval. + */ +@js.native +@JSGlobal +class IDBObjectStore extends IDBStoreLike[IDBObjectStore] { /** To determine if the add operation has completed successfully, listen for the transaction’s complete event in * addition to the IDBObjectStore.add request’s success event, because the transaction may still fail after the * success event fires. In other words, the success event is only triggered when the transaction has been * successfully queued. + * + * @return + * [[IDBRequest]] with the key as the `target` value */ - def add(value: js.Any, key: js.Any = js.native): IDBRequest = js.native + def add(value: IDBValue, key: IDBKey = js.native): IDBRequest[IDBObjectStore, IDBKey] = js.native /** Clearing an object store consists of removing all records from the object store and removing all records in * indexes that reference the object store. */ - def clear(): IDBRequest = js.native + def clear(): IDBRequest[IDBObjectStore, Unit] = js.native /** Note that this method must be called only from a VersionChange transaction mode callback. */ - def createIndex(name: String, keyPath: String, optionalParameters: js.Any = js.native): IDBIndex = js.native + def createIndex(name: String, keyPath: IDBKeyPath, + optionalParameters: IDBCreateIndexOptions = js.native): IDBIndex = js.native - /** If the record is successfully stored, then a success event is fired on the returned request object with the result - * set to the key for the stored record, and the transaction set to the transaction in which this object store is - * opened. + /** Returns an [[IDBRequest]] object, and, in a separate thread, deletes the specified record or records. + * + * Either a key or an [[IDBKeyRange]] can be passed, allowing one or multiple records to be deleted from a store. To + * delete all records in a store, use [[clear]]. + * + * Bear in mind that if you are using an [[IDBCursor]], you can use the [[IDBCursor.delete]] method to more + * efficiently delete the current record — without having to explicitly look up the record's key. */ - def put(value: js.Any, key: js.Any = js.native): IDBRequest = js.native - - /** The method sets the position of the cursor to the appropriate record, based on the specified direction. */ - def openCursor(range: js.UndefOr[IDBKeyRange | js.Any] = js.native, - direction: js.UndefOr[IDBCursorDirection] = js.native): IDBRequest = js.native - - /** The method sets the position of the cursor to the appropriate key, based on the specified direction. */ - def openKeyCursor(range: js.UndefOr[IDBKeyRange | js.Any] = js.native, - direction: js.UndefOr[IDBCursorDirection] = js.native): IDBRequest = js.native + def delete(key: IDBKey | IDBKeyRange): IDBRequest[IDBObjectStore, Unit] = js.native /** Note that this method must be called only from a VersionChange transaction mode callback. Note that this method * synchronously modifies the IDBObjectStore.indexNames property. @@ -91,30 +182,20 @@ class IDBObjectStore extends js.Object { /** This method may raise a DOMException of one of the following types: */ def index(name: String): IDBIndex = js.native - /** If a value is successfully found, then a structured clone of it is created and set as the result of the request - * object. - */ - def get(key: js.Any): IDBRequest = js.native - - /** If a value is successfully found, then a structured clone of it is created and set as the result of the request - * object. - */ - def getAll(query: js.UndefOr[IDBKeyRange | js.Any] = js.native, - count: js.UndefOr[Int] = js.native): IDBRequest = js.native - - /** If a value is successfully found, then a structured clone of it is created and set as the result of the request - * object. - */ - def getAllKeys(query: js.UndefOr[IDBKeyRange | js.Any] = js.native, - count: js.UndefOr[Int] = js.native): IDBRequest = js.native + /** A list of the names of indexes on objects in this object store. */ + def indexNames: DOMStringList = js.native - /** If a value is successfully found, then a structured clone of it is created and set as the result of the request - * object. + /** If the record is successfully stored, then a success event is fired on the returned request object with the result + * set to the key for the stored record, and the transaction set to the transaction in which this object store is + * opened. + * + * @return + * [[IDBRequest]] with the key as the `target` value */ - def getKey(key: js.Any): IDBRequest = js.native + def put(value: IDBValue, key: IDBKey = js.native): IDBRequest[IDBObjectStore, IDBKey] = js.native - /** returns an IDBRequest object, and, in a separate thread, deletes the current object store. */ - def delete(key: js.Any): IDBRequest = js.native + /** The name of the transaction to which this object store belongs. */ + def transaction: IDBTransaction = js.native } trait IDBVersionChangeEventInit extends EventInit { @@ -127,7 +208,8 @@ trait IDBVersionChangeEventInit extends EventInit { */ @js.native @JSGlobal -class IDBVersionChangeEvent(typeArg: String, init: js.UndefOr[IDBVersionChangeEventInit]) extends Event(typeArg, init) { +class IDBVersionChangeEvent(typeArg: String, init: js.UndefOr[IDBVersionChangeEventInit]) + extends IDBEvent[IDBDatabase](typeArg, init) { /** Returns the new version of the database. * @@ -155,43 +237,21 @@ class IDBVersionChangeEvent(typeArg: String, init: js.UndefOr[IDBVersionChangeEv */ @js.native @JSGlobal -class IDBIndex extends js.Object { - - /** If true, this index does not allow duplicate values for a key. */ - def unique: Boolean = js.native - - def name: String = js.native - - /** The key path of this index. If null, this index is not auto-populated. */ - def keyPath: String = js.native +class IDBIndex extends IDBStoreLike[IDBIndex] { /** The name of the object store referenced by this index. */ def objectStore: IDBObjectStore = js.native - def count(key: js.Any): IDBRequest = js.native - - /** If you want to see how many records are between keys 1000 and 2000 in an object store, you can write the - * following: - */ - def count(): IDBRequest = js.native - - /** Returns an IDBRequest object, and, in a separate thread, finds either the given key or the primary key, if key is - * a key range. - */ - def getKey(key: js.Any): IDBRequest = js.native - - /** Returns an IDBRequest object, and, in a separate thread, creates a cursor over the specified key range, as - * arranged by this index. - */ - def openKeyCursor(range: IDBKeyRange = js.native, direction: IDBCursorDirection = js.native): IDBRequest = js.native - - /** Returns an IDBRequest object, and, in a separate thread, finds either the value in the referenced object store - * that corresponds to the given key or the first corresponding value, if key is a key range. + /** Returns a boolean value that affects how the index behaves when the result of evaluating the index's key path + * yields an array. + * + * This is decided when the index is created, using the `IDBObjectStore.createIndex` method. This method takes an + * optional options parameter whose `multiEntry` property is set to `true`/`false`. */ - def get(key: js.Any): IDBRequest = js.native + val multiEntry: Boolean = js.native - /** The method sets the position of the cursor to the appropriate record, based on the specified direction. */ - def openCursor(range: IDBKeyRange = js.native, direction: IDBCursorDirection = js.native): IDBRequest = js.native + /** If true, this index does not allow duplicate values for a key. */ + def unique: Boolean = js.native } /** The IDBCursor interface of the IndexedDB API represents a cursor for traversing or iterating over multiple records @@ -200,16 +260,19 @@ class IDBIndex extends js.Object { * The cursor has a source that indicates which index or object store it is iterating. It has a position within the * range, and moves in a direction that is increasing or decreasing in the order of record keys. The cursor enables an * application to asynchronously process all the records in the cursor's range. + * + * @tparam S + * The type of `.source` */ @js.native @JSGlobal -class IDBCursor extends js.Object { +class IDBCursorReadOnly[+S] extends js.Object { /** On getting, this object returns the IDBObjectStore or IDBIndex that the cursor is iterating. This function never * returns null or throws an exception, even if the cursor is currently being iterated, has iterated past its end, or * its transaction is not active. */ - def source: js.Any = js.native + def source: S = js.native /** Is a DOMString that, on getting, returns the direction of traversal of the cursor. See Constants for possible * values. @@ -219,15 +282,15 @@ class IDBCursor extends js.Object { /** Returns the key for the record at the cursor's position. If the cursor is outside its range, this is set to * undefined. The cursor's key can be any data type. */ - def key: js.Any = js.native + def key: IDBKey = js.native /** Returns the cursor's current effective key. If the cursor is currently being iterated or has iterated outside its * range, this is set to undefined. The cursor's primary key can be any data type. */ - def primaryKey: js.Any = js.native + def primaryKey: IDBKey = js.native /** This method may raise a DOMException of one of the following types: */ - def advance(count: Int): Unit = js.native + def advance(count: Double): Unit = js.native /** Sets cursor to key if specified, otherwise advances cursor by one. * @@ -237,17 +300,32 @@ class IDBCursor extends js.Object { * * W3C */ - def continue(key: js.Any = js.native): Unit = js.native + def continue(key: IDBKey = js.native): Unit = js.native +} + +/** The IDBCursor interface of the IndexedDB API represents a cursor for traversing or iterating over multiple records + * in a database. + * + * The cursor has a source that indicates which index or object store it is iterating. It has a position within the + * range, and moves in a direction that is increasing or decreasing in the order of record keys. The cursor enables an + * application to asynchronously process all the records in the cursor's range. + * + * @tparam S + * The type of `.source` + */ +@js.native +@JSGlobal +class IDBCursor[+S] extends IDBCursorReadOnly[S] { /** Returns an IDBRequest object, and, in a separate thread, deletes the record at the cursor's position, without * changing the cursor's position. */ - def delete(): IDBRequest = js.native + def delete(): IDBRequest[S, Unit] = js.native /** Returns an IDBRequest object, and, in a separate thread, updates the value at the current position of the cursor * in the object store. */ - def update(value: js.Any): IDBRequest = js.native + def update(value: IDBValue): IDBRequest[S, IDBKey] = js.native } @js.native @@ -258,29 +336,33 @@ 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".asInstanceOf[IDBCursorDirection] + @inline def prev: IDBCursorDirection = "prev".asInstanceOf[IDBCursorDirection] /** 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 PREV_UNIQUE: IDBCursorDirection = "prevunique".asInstanceOf[IDBCursorDirection] + @inline def prevunique: IDBCursorDirection = "prevunique".asInstanceOf[IDBCursorDirection] /** 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".asInstanceOf[IDBCursorDirection] + @inline def next: IDBCursorDirection = "next".asInstanceOf[IDBCursorDirection] /** 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 NEXT_UNIQUE: IDBCursorDirection = "nextunique".asInstanceOf[IDBCursorDirection] + @inline def nextunique: IDBCursorDirection = "nextunique".asInstanceOf[IDBCursorDirection] } -/** Same as IDBCursor with the value property. */ +/** Same as [[IDBCursor]] with the `value` property. + * + * @tparam S + * The type of `.source` + */ @js.native @JSGlobal -class IDBCursorWithValue extends IDBCursor { - def value: js.Any = js.native +class IDBCursorWithValue[+S] extends IDBCursor[S] { + def value: IDBValue = js.native } /** The IDBKeyRange interface of the IndexedDB API represents a continuous interval over some data type that is used for @@ -297,13 +379,13 @@ class IDBCursorWithValue extends IDBCursor { class IDBKeyRange extends js.Object { /** The upper bound of the key range (can be any type.) */ - def upper: js.Any = js.native + def upper: IDBKey = js.native /** Returns false if the upper-bound value is included in the key range. */ def upperOpen: Boolean = js.native /** The lower bound of the key range (can be any type.) */ - def lower: js.Any = js.native + def lower: IDBKey = js.native /** Returns false if the lower-bound value is included in the key range. */ def lowerOpen: Boolean = js.native @@ -316,17 +398,17 @@ object IDBKeyRange extends js.Object { /** The bounds can be open (that is, the bounds exclude the endpoint values) or closed (that is, the bounds include * the endpoint values). By default, the bounds are closed. */ - def bound(lower: js.Any, upper: js.Any, lowerOpen: Boolean = js.native, + def bound(lower: IDBKey, upper: IDBKey, lowerOpen: Boolean = js.native, upperOpen: Boolean = js.native): IDBKeyRange = js.native /** This method may raise a DOMException of the following types: */ - def only(value: js.Any): IDBKeyRange = js.native + def only(value: IDBValue): IDBKeyRange = js.native /** By default, it includes the lower endpoint value and is closed. */ - def lowerBound(bound: js.Any, open: Boolean = js.native): IDBKeyRange = js.native + def lowerBound(bound: IDBKey, open: Boolean = js.native): IDBKeyRange = js.native /** By default, it includes the upper endpoint value and is closed. */ - def upperBound(bound: js.Any, open: Boolean = js.native): IDBKeyRange = js.native + def upperBound(bound: IDBKey, open: Boolean = js.native): IDBKeyRange = js.native } /** The IDBTransaction interface of the IndexedDB API provides a static, asynchronous transaction on a database using @@ -413,7 +495,8 @@ class IDBDatabase extends EventTarget { * important optional properties. You can use the property to uniquely identify individual objects in the store. As * the property is an identifier, it should be unique to every object, and every object should have that property. */ - def createObjectStore(name: String, optionalParameters: js.Any = js.native): IDBObjectStore = js.native + def createObjectStore(name: String, + optionalParameters: js.UndefOr[IDBCreateObjectStoreOptions] = js.native): IDBObjectStore = js.native /** The connection is not actually closed until all transactions created using this connection are complete. No new * transactions can be created for this connection once this method is called. Methods that create transactions throw @@ -424,7 +507,8 @@ class IDBDatabase extends EventTarget { /** Immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which * you can use to access your object store. Runs in a separate thread. */ - def transaction(storeNames: js.Any, mode: IDBTransactionMode = js.native): IDBTransaction = js.native + def transaction(storeNames: String | js.Array[String], mode: js.UndefOr[IDBTransactionMode] = js.native, + options: js.UndefOr[IDBTransactionOptions] = js.native): IDBTransaction = js.native /** As with createObjectStore, this method can be called only within a versionchange transaction. So for WebKit * browsers you must call the IDBVersionChangeRequest.setVersion method first before you can remove any object store @@ -435,10 +519,13 @@ class IDBDatabase extends EventTarget { /** The IDBOpenDBRequest interface of the IndexedDB API provides access to results of requests to open databases using * specific event handler attributes. + * + * @tparam A + * Type of `.target.result` on events */ @js.native @JSGlobal -class IDBOpenDBRequest extends IDBRequest { +class IDBOpenDBRequest[A] extends IDBRequest[Null, A] { /** The event handler for the upgradeneeded event, fired when a database of a bigger version number than the existing * stored database is loaded. @@ -462,20 +549,37 @@ class IDBOpenDBRequest extends IDBRequest { @js.native @JSGlobal class IDBFactory extends js.Object { - def open(name: String, version: Int): IDBOpenDBRequest = js.native /** The open() method of the IDBFactory interface requests opening a connection to a database. see * [[https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/open IDBFactory.open() on MDN]] * * w3c spec [[http://www.w3.org/TR/IndexedDB/#requests ¶3.2.3 Opening a database]] */ - def open(name: String): IDBOpenDBRequest = js.native + def open(name: String, version: Int = js.native): IDBOpenDBRequest[IDBDatabase] = js.native - /** A method that compares two keys and returns a result indicating which one is greater in value. */ - def cmp(first: js.Any, second: js.Any): Int = js.native + /** Compares two values as keys to determine equality and ordering for IndexedDB operations, such as storing and + * iterating. + * + * @return + * One of the following: + * - `-1` means 1st key is less than the 2nd key + * - `0` means 1st key is equal to the 2nd key + * - `1` means 1st key is greater than the 2nd key + */ + def cmp(first: IDBValue, second: IDBValue): Int = js.native + + /** Returns a promise which resolves to a list of objects giving a snapshot of the names and versions of databases + * within the origin. + * + * This API is intended for web applications to introspect the use of databases, for example to clean up from earlier + * versions of a site’s code. Note that the result is a snapshot; there are no guarantees about the sequencing of the + * collection of the data or the delivery of the response with respect to requests to create, upgrade, or delete + * databases by this context or others. + */ + def databases(): js.Promise[js.Array[IDBDatabaseInfo]] = js.native /** The deletion operation (performed in a different thread) consists of the following steps: */ - def deleteDatabase(name: String): IDBOpenDBRequest = js.native + def deleteDatabase(name: String): IDBOpenDBRequest[Unit] = js.native } /** The IDBRequest interface of the IndexedDB API provides access to results of asynchronous requests to databases and @@ -485,18 +589,21 @@ class IDBFactory extends js.Object { * The request object does not initially contain any information about the result of the operation, but once * information becomes available, an event is fired on the request, and the information becomes available through the * properties of the IDBRequest instance. + * + * @tparam A + * Type of `.target.result` on events */ @js.native @JSGlobal -class IDBRequest extends EventTarget { +class IDBRequest[+S, A] extends EventTarget { /** The source of the request, such as an Index or a ObjectStore. If no source exists (such as when calling * IDBFactory.open), it returns null. */ - def source: js.Any = js.native + def source: S = js.native /** The event handler for the success event. */ - var onsuccess: js.Function1[Event, _] = js.native + var onsuccess: js.Function1[IDBEvent[A], _] = js.native /** Returns a DOMException in the event of an unsuccessful request, indicating what went wrong. */ def error: DOMException = js.native @@ -517,7 +624,28 @@ class IDBRequest extends EventTarget { /** Returns the result of the request. If the the request failed and the result is not available, * the InvalidStateError exception is thrown. */ - def result: js.Any = js.native + def result: A = js.native +} + +@js.native +trait IDBDatabaseInfo extends js.Object { + val name: String = js.native + val version: Int = js.native +} + +trait IDBCreateObjectStoreOptions extends js.Object { + val keyPath: IDBKeyPath = js.undefined + val autoIncrement: js.UndefOr[Boolean] = js.undefined +} + +trait IDBCreateIndexOptions extends js.Object { + val unique: js.UndefOr[Boolean] = js.undefined + val multiEntry: js.UndefOr[Boolean] = js.undefined + val locale: js.UndefOr[String] = js.undefined +} + +trait IDBTransactionOptions extends js.Object { + val durability: js.UndefOr[IDBTransactionDurability] = js.undefined } /** The IDBEvironment interface of the IndexedDB API provides asynchronous access to a client-side database. It is diff --git a/src/main/scala/org/scalajs/dom/idb.scala b/src/main/scala/org/scalajs/dom/idb.scala index d613ca717..12ed55a2f 100644 --- a/src/main/scala/org/scalajs/dom/idb.scala +++ b/src/main/scala/org/scalajs/dom/idb.scala @@ -2,21 +2,32 @@ package org.scalajs.dom /** Short aliases of all the dom.IDBThing classes */ object idb { - type Cursor = IDBCursor - @inline def CursorDirection = IDBCursorDirection - type CursorWithValue = IDBCursorWithValue + + type CreateIndexOptions = IDBCreateIndexOptions + type CreateObjectStoreOptions = IDBCreateObjectStoreOptions + type Cursor[+Source] = IDBCursor[Source] + type CursorReadOnly[+Source] = IDBCursorReadOnly[Source] + type CursorWithValue[+Source] = IDBCursorWithValue[Source] type Database = IDBDatabase + type DatabaseInfo = IDBDatabaseInfo + type Event[+TargetResult] = IDBEvent[TargetResult] + type EventTarget[+Result] = IDBEventTarget[Result] type Factory = IDBFactory type Index = IDBIndex + type Key = IDBKey + type KeyPath = IDBKeyPath type KeyRange = IDBKeyRange - @inline def KeyRange = IDBKeyRange type ObjectStore = IDBObjectStore - type OpenDBRequest = IDBOpenDBRequest - type Request = IDBRequest + type OpenDBRequest[TargetResult] = IDBOpenDBRequest[TargetResult] + type Request[+Source, TargetResult] = IDBRequest[Source, TargetResult] type Transaction = IDBTransaction - @inline def TransactionMode = IDBTransactionMode + type Value = IDBValue type VersionChangeEvent = IDBVersionChangeEvent + @inline def CursorDirection = IDBCursorDirection + @inline def KeyRange = IDBKeyRange + @inline def TransactionMode = IDBTransactionMode + @deprecated( "Removed. This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible. See https://developer.mozilla.org/en-US/docs/Web/API/IDBEnvironment", "1.2.0") diff --git a/src/main/scala/org/scalajs/dom/package.scala b/src/main/scala/org/scalajs/dom/package.scala index d6603ba70..e432e4d1f 100644 --- a/src/main/scala/org/scalajs/dom/package.scala +++ b/src/main/scala/org/scalajs/dom/package.scala @@ -71,4 +71,16 @@ package object dom { @deprecated("use NodeList[T] instead", "2.0.0") type NodeListOf[+T <: Node] = NodeList[T] + + type IDBKey = Any + + /** A valid key path can include one of the following: an empty string, a JavaScript identifier, or multiple + * JavaScript identifiers separated by periods or an array containing any of those. It cannot include spaces. + * + * @see + * https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Basic_Terminology#key_path + */ + type IDBKeyPath = Any + + type IDBValue = Any } diff --git a/src/main/scala/org/scalajs/dom/raw.scala b/src/main/scala/org/scalajs/dom/raw.scala index 5b76cfd29..8adcc480e 100644 --- a/src/main/scala/org/scalajs/dom/raw.scala +++ b/src/main/scala/org/scalajs/dom/raw.scala @@ -9,6 +9,7 @@ package org.scalajs.dom import org.scalajs.dom import scala.scalajs.js import scala.scalajs.js.annotation._ +import scala.scalajs.js.| @deprecated("All the members of raw.* have been moved to dom.*", "2.0.0") object raw { @@ -479,10 +480,10 @@ object raw { type HTMLVideoElement = dom.HTMLVideoElement @deprecated("use dom.IDBCursor instead", "2.0.0") - type IDBCursor = dom.IDBCursor + type IDBCursor = dom.IDBCursor[IDBObjectStore | IDBIndex] @deprecated("use dom.IDBCursorWithValue instead", "2.0.0") - type IDBCursorWithValue = dom.IDBCursorWithValue + type IDBCursorWithValue = dom.IDBCursorWithValue[Any] @deprecated("use dom.IDBDatabase instead", "2.0.0") type IDBDatabase = dom.IDBDatabase @@ -506,10 +507,10 @@ object raw { type IDBObjectStore = dom.IDBObjectStore @deprecated("use dom.IDBOpenDBRequest instead", "2.0.0") - type IDBOpenDBRequest = dom.IDBOpenDBRequest + type IDBOpenDBRequest = dom.IDBOpenDBRequest[Any] @deprecated("use dom.IDBRequest instead", "2.0.0") - type IDBRequest = dom.IDBRequest + type IDBRequest = dom.IDBRequest[Any, Any] @deprecated("use dom.IDBTransaction instead", "2.0.0") type IDBTransaction = dom.IDBTransaction diff --git a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/AsyncTesting.scala b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/AsyncTesting.scala index 2a1646097..7d723804d 100644 --- a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/AsyncTesting.scala +++ b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/AsyncTesting.scala @@ -3,6 +3,7 @@ package org.scalajs.dom.tests.shared import org.junit.Assert import scala.concurrent._ import scala.util._ +import scala.scalajs.js import scala.scalajs.js.timers._ object AsyncTesting { @@ -12,6 +13,12 @@ object AsyncTesting { implicit def global: ExecutionContext = ExecutionContext.global + def asyncPass: AsyncResult = + Future.successful(Success(())) + + def asyncWhenDefined[A](o: js.UndefOr[A])(f: A => AsyncResult): AsyncResult = + o.fold(asyncPass)(f) + def async(run: => Future[Any]): AsyncResult = { val p = Promise[Try[Unit]]() val timeout = setTimeout(1200) { diff --git a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/IdbTest.scala b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/IdbTest.scala new file mode 100644 index 000000000..c3952e4f3 --- /dev/null +++ b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/IdbTest.scala @@ -0,0 +1,82 @@ +package org.scalajs.dom.tests.shared + +import java.util.UUID +import org.junit.Assert._ +import org.scalajs.dom._ +import org.scalajs.dom.tests.shared.AsyncTesting._ +import scala.concurrent._ +import scala.scalajs.js +import scala.util.Try + +/** Scala.js version of https://gist.github.com/JamesMessinger/a0d6389a5d0e3a24814b */ +object IdbTest { + + def apply(idb: js.UndefOr[IDBFactory]): AsyncResult = + asyncWhenDefined(idb)(apply(_)) + + def apply(idb: IDBFactory): AsyncResult = async { + open(idb).flatMap(use) + } + + private def open(idb: IDBFactory): Future[IDBDatabase] = { + val p = Promise[IDBDatabase]() + val r = idb.open(UUID.randomUUID().toString) + + r.onerror = (e: Event) => fail(p, "idb.open failed: " + r.error) + + r.onupgradeneeded = (e: IDBEvent[IDBDatabase]) => { + val db = e.target.result + val opts = new IDBCreateObjectStoreOptions { override val keyPath = "id" } + val store = db.createObjectStore("MyObjectStore", opts) + store.createIndex("NameIndex", js.Array("name.last", "name.first")) + } + + r.onsuccess = (e: IDBEvent[IDBDatabase]) => { + assertSame(r.result, e.target.result) + p.success(r.result) + } + + p.future + } + + private def fail(p: Promise[_], why: Any): Unit = + p.failure(new RuntimeException("" + why)) + + private def use(db: IDBDatabase): Future[Unit] = { + import js.Dynamic.{literal => obj} + + val tx = db.transaction("MyObjectStore", IDBTransactionMode.readwrite) + val store = tx.objectStore("MyObjectStore") + val index = store.index("NameIndex") + + // Add some data + store.put(obj(id = 12345, name = obj(first = "John", last = "Doe"), age = 42)) + store.put(obj(id = 67890, name = obj(first = "Bob", last = "Smith"), age = 35)) + + // Query the data + val getJohn = store.get(12345) + val getBob = index.get(js.Array("Smith", "Bob")) + + // Close the db when the transaction is done + tx.oncomplete = (e: Event) => { + db.close() + } + + def getFirstName(r: IDBRequest[_, IDBValue]): Future[String] = { + val p = Promise[String]() + r.onerror = (e: Event) => fail(p, e) + r.onsuccess = (e: IDBEvent[IDBValue]) => { + p.complete(Try(e.target.result.asInstanceOf[js.Dynamic].name.first.asInstanceOf[String])) + } + p.future + } + + for { + john <- getFirstName(getJohn) + bob <- getFirstName(getBob) + } yield { + assertEquals("John", john) + assertEquals("Bob", bob) + } + } +} diff --git a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/SharedTests.scala b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/SharedTests.scala index 15c84e377..456b34102 100644 --- a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/SharedTests.scala +++ b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/SharedTests.scala @@ -1,10 +1,12 @@ package org.scalajs.dom.tests.shared -import java.util.UUID +import org.scalajs.dom.tests.shared.AsyncTesting._ import org.junit.Test trait SharedTests { - import SharedTests._ + + // =================================================================================================================== + // Tests WITHOUT org.scalajs.dom._ in scope // This tests that ops are always implicitly available, no imports required @Test final def NodeListOpsTest(): Unit = @@ -18,7 +20,8 @@ trait SharedTests { .map(_.classList.mkString) } - // Don't move up + // =================================================================================================================== + // Tests WITH org.scalajs.dom._ in scope import org.scalajs.dom._ // https://github.com/scala-js/scala-js-dom/issues/411 - console doesn't work in web workers @@ -30,17 +33,6 @@ trait SharedTests { val _ = crypto.HashAlgorithm } - @Test final def WindowIdbTest(): Unit = - window.indexedDB.foreach(testIdb) - -} - -object SharedTests { - import org.scalajs.dom._ - - def testIdb(idb: IDBFactory): Unit = { - val open = idb.open(UUID.randomUUID().toString()) - open.onerror = (e: Event) => sys.error("idb open failed: " + e) - // TODO: Test properly in a different PR - } + @Test final def WindowIdbTest(): AsyncResult = + IdbTest(window.indexedDB) } diff --git a/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Server.scala b/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Server.scala index d017c7bf3..f3bad138e 100644 --- a/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Server.scala +++ b/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Server.scala @@ -1,6 +1,7 @@ package org.scalajs.dom.tests.webworker import org.scalajs.dom._ +import scala.concurrent.ExecutionContext.Implicits.global object Server extends ServerResponses { import Protocol._ @@ -13,9 +14,11 @@ object Server extends ServerResponses { val id = msgIn._1 val cmdId = msgIn._2 val cmd = WebWorkerCmd.byId(cmdId) - val output = respond(cmd) - val msgOut = Message(id, output) - ww.postMessage(msgOut) + respond(cmd).onComplete { t => + val output = t.getOrElse(t.failed.get.toString) + val msgOut = Message(id, output) + ww.postMessage(msgOut) + } } ww.postMessage(Message(ServerStarted, "")) diff --git a/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/WebWorkerTests.scala b/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/WebWorkerTests.scala index 340519cdc..02aa7a1c8 100644 --- a/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/WebWorkerTests.scala +++ b/tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/WebWorkerTests.scala @@ -1,5 +1,7 @@ package org.scalajs.dom.tests.webworker +import scala.language.implicitConversions +import scala.concurrent.Future import org.junit.Assert._ import org.junit.Test import org.scalajs.dom.tests.shared.AsyncTesting._ @@ -46,10 +48,21 @@ trait WebWorkerTests { // ===================================================================================================================== trait ServerResponses { import org.scalajs.dom._ - import org.scalajs.dom.tests.shared.SharedTests._ + import org.scalajs.dom.tests.shared._ import org.scalajs.dom.DedicatedWorkerGlobalScope.self - final val respond: WebWorkerCmd => String = { + private implicit def autoLift(s: => String): Future[String] = + Future(s) + + private implicit class AsyncOps(r: AsyncResult) { + def andReturn(s: String): Future[String] = + r.map { t => + t.get + s + } + } + + final val respond: WebWorkerCmd => Future[String] = { case SayHello => "hello" @@ -60,7 +73,6 @@ trait ServerResponses { case TestIdb => assertTrue(self.indexedDB.isDefined) - testIdb(self.indexedDB.get) - "ok" + IdbTest(self.indexedDB.get).andReturn("ok") } }