-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
1,264 additions
and
1,743 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
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
4 changes: 1 addition & 3 deletions
4
core/src/wasmJsMain/kotlin/Exceptions.kt → core/src/commonMain/kotlin/Exceptions.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import com.juul.indexeddb.external.IDBCursor | ||
import com.juul.indexeddb.external.IDBCursorWithValue | ||
import com.juul.indexeddb.external.IDBIndex | ||
import com.juul.indexeddb.external.IDBKey | ||
import com.juul.indexeddb.external.JsNumber | ||
import com.juul.indexeddb.external.ReadonlyArray | ||
|
||
public class Index internal constructor( | ||
internal val index: IDBIndex, | ||
) : Queryable() { | ||
override fun requestGet(key: IDBKey): Request<*> = | ||
Request(index.get(key)) | ||
|
||
override fun requestGetAll(query: IDBKey?): Request<ReadonlyArray<*>> = | ||
Request(index.getAll(query)) | ||
|
||
override fun requestOpenCursor( | ||
query: IDBKey?, | ||
direction: Cursor.Direction, | ||
): Request<IDBCursorWithValue?> = | ||
Request(index.openCursor(query, direction.constant)) | ||
|
||
override fun requestOpenKeyCursor( | ||
query: IDBKey?, | ||
direction: Cursor.Direction, | ||
): Request<IDBCursor?> = | ||
Request(index.openKeyCursor(query, direction.constant)) | ||
|
||
override fun requestCount(query: IDBKey?): Request<JsNumber> = | ||
Request(index.count(query)) | ||
} |
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 @@ | ||
import com.juul.indexeddb.external.JsAny | ||
import com.juul.indexeddb.external.JsArray | ||
import com.juul.indexeddb.external.JsString | ||
import com.juul.indexeddb.external.ReadonlyArray | ||
import com.juul.indexeddb.external.set | ||
import com.juul.indexeddb.external.toJsString | ||
import com.juul.indexeddb.toReadonlyArray | ||
|
||
internal fun Array<out String>.toReadonlyArray(): ReadonlyArray<JsString> = | ||
JsArray<JsString>() | ||
.apply { | ||
forEachIndexed { index, s -> | ||
set(index, s.toJsString()) | ||
} | ||
}.toReadonlyArray() | ||
|
||
internal fun Iterable<String?>.toJsArray(): JsArray<JsString?> = | ||
JsArray<JsString?>().apply { | ||
forEachIndexed { index, s -> | ||
set(index, s?.toJsString()) | ||
} | ||
} | ||
|
||
internal fun <T : JsAny?> JsArray(vararg values: T): JsArray<T> = | ||
JsArray<T>().apply { | ||
for (i in values.indices) { | ||
set(i, values[i]) | ||
} | ||
} |
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,9 @@ | ||
package com.juul.indexeddb | ||
|
||
import com.juul.indexeddb.external.JsAny | ||
|
||
// Copied from: | ||
// https://github.com/JetBrains/kotlin-wrappers/blob/91b2c1568ec6f779af5ec10d89b5e2cbdfe785ff/kotlin-extensions/src/main/kotlin/kotlinx/js/jso.kt | ||
|
||
internal expect fun <T : JsAny> jso(): T | ||
internal fun <T : JsAny> jso(block: T.() -> Unit): T = jso<T>().apply(block) |
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,39 @@ | ||
import com.juul.indexeddb.external.IDBKey | ||
import com.juul.indexeddb.external.IDBKeyRange | ||
import com.juul.indexeddb.external.JsAny | ||
import com.juul.indexeddb.external.toJsString | ||
|
||
public object AutoIncrement | ||
|
||
public class KeyPath private constructor( | ||
private val paths: List<String?>, | ||
) { | ||
init { | ||
require(paths.isNotEmpty()) { "A key path must have at least one member." } | ||
} | ||
|
||
public constructor(path: String?, vararg morePaths: String?) : this(listOf(path, *morePaths)) | ||
|
||
internal fun toJs(): JsAny? = if (paths.size == 1) paths[0]?.toJsString() else paths.toJsArray() | ||
} | ||
|
||
public fun lowerBound( | ||
x: JsAny?, | ||
open: Boolean = false, | ||
): IDBKey = IDBKey(IDBKeyRange.lowerBound(x, open)) | ||
|
||
public fun upperBound( | ||
y: JsAny?, | ||
open: Boolean = false, | ||
): IDBKey = IDBKey(IDBKeyRange.upperBound(y, open)) | ||
|
||
public fun bound( | ||
x: JsAny?, | ||
y: JsAny?, | ||
lowerOpen: Boolean = false, | ||
upperOpen: Boolean = false, | ||
): IDBKey = IDBKey(IDBKeyRange.bound(x, y, lowerOpen, upperOpen)) | ||
|
||
public fun only( | ||
z: JsAny?, | ||
): IDBKey = IDBKey(IDBKeyRange.only(z)) |
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,25 @@ | ||
import com.juul.indexeddb.external.IDBCursor | ||
import com.juul.indexeddb.external.IDBCursorWithValue | ||
import com.juul.indexeddb.external.IDBKey | ||
import com.juul.indexeddb.external.IDBObjectStore | ||
import com.juul.indexeddb.external.JsNumber | ||
import com.juul.indexeddb.external.ReadonlyArray | ||
|
||
public class ObjectStore internal constructor( | ||
internal val objectStore: IDBObjectStore, | ||
) : Queryable() { | ||
override fun requestGet(key: IDBKey): Request<*> = | ||
Request(objectStore.get(key)) | ||
|
||
override fun requestGetAll(query: IDBKey?): Request<ReadonlyArray<*>> = | ||
Request(objectStore.getAll(query)) | ||
|
||
override fun requestOpenCursor(query: IDBKey?, direction: Cursor.Direction): Request<IDBCursorWithValue?> = | ||
Request(objectStore.openCursor(query, direction.constant)) | ||
|
||
override fun requestOpenKeyCursor(query: IDBKey?, direction: Cursor.Direction): Request<IDBCursor?> = | ||
Request(objectStore.openKeyCursor(query, direction.constant)) | ||
|
||
override fun requestCount(query: IDBKey?): Request<JsNumber> = | ||
Request(objectStore.count(query)) | ||
} |
6 changes: 2 additions & 4 deletions
6
core/src/wasmJsMain/kotlin/OnNextEvent.kt → core/src/commonMain/kotlin/OnNextEvent.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.juul.indexeddb | ||
|
||
import com.juul.indexeddb.external.IDBFactory | ||
import com.juul.indexeddb.external.JsAny | ||
import com.juul.indexeddb.external.JsArray | ||
import com.juul.indexeddb.external.JsByteArray | ||
import com.juul.indexeddb.external.ReadonlyArray | ||
import com.juul.indexeddb.external.toJsByteArray | ||
|
||
internal expect val selfIndexedDB: IDBFactory? | ||
|
||
internal expect fun <T : JsAny?> JsArray<T>.toReadonlyArray(): ReadonlyArray<T> | ||
|
||
internal expect fun <T : JsAny?> JsAny.unsafeCast(): T | ||
|
||
internal fun ByteArray.toJsByteArray(): JsByteArray = toTypedArray().toJsByteArray() |
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,13 @@ | ||
import com.juul.indexeddb.external.IDBCursor | ||
import com.juul.indexeddb.external.IDBCursorWithValue | ||
import com.juul.indexeddb.external.IDBKey | ||
import com.juul.indexeddb.external.JsNumber | ||
import com.juul.indexeddb.external.ReadonlyArray | ||
|
||
public sealed class Queryable { | ||
internal abstract fun requestGet(key: IDBKey): Request<*> | ||
internal abstract fun requestGetAll(query: IDBKey?): Request<ReadonlyArray<*>> | ||
internal abstract fun requestOpenCursor(query: IDBKey?, direction: Cursor.Direction): Request<IDBCursorWithValue?> | ||
internal abstract fun requestOpenKeyCursor(query: IDBKey?, direction: Cursor.Direction): Request<IDBCursor?> | ||
internal abstract fun requestCount(query: IDBKey?): Request<JsNumber> | ||
} |
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,6 @@ | ||
import com.juul.indexeddb.external.IDBRequest | ||
import com.juul.indexeddb.external.JsAny | ||
|
||
internal class Request<T : JsAny?> internal constructor( | ||
internal val request: IDBRequest<T>, | ||
) |
Oops, something went wrong.