-
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
103 changed files
with
1,345 additions
and
1,786 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
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,30 @@ | ||
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 toReadonlyArray(value: String, vararg moreValues: String): ReadonlyArray<JsString> = | ||
JsArray<JsString>() | ||
.apply { | ||
set(0, value.toJsString()) | ||
moreValues.forEachIndexed { index, s -> | ||
set(index + 1, 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)) | ||
} |
Oops, something went wrong.