-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial port for wasmJs #170
Open
eygraber
wants to merge
3
commits into
JuulLabs:main
Choose a base branch
from
eygraber:wasm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package com.juul.indexeddb | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like quite a few files are missing their package directive now. Just gonna leave this one comment to cover all of them. |
||
import com.juul.indexeddb.external.IDBCursor | ||
import com.juul.indexeddb.external.IDBCursorWithValue | ||
import com.juul.indexeddb.external.IDBKey | ||
import com.juul.indexeddb.external.JsAny | ||
import kotlinx.coroutines.channels.SendChannel | ||
|
||
public open class Cursor internal constructor( | ||
internal open val cursor: IDBCursor, | ||
private val channel: SendChannel<*>, | ||
) { | ||
public val key: dynamic | ||
public val key: IDBKey | ||
get() = cursor.key | ||
|
||
public val primaryKey: dynamic | ||
public val primaryKey: IDBKey | ||
get() = cursor.primaryKey | ||
|
||
public fun close() { | ||
|
@@ -26,12 +26,12 @@ public open class Cursor internal constructor( | |
cursor.advance(count) | ||
} | ||
|
||
public fun `continue`(key: Key) { | ||
cursor.`continue`(key.toJs()) | ||
public fun `continue`(key: IDBKey) { | ||
cursor.`continue`(key) | ||
} | ||
|
||
public fun continuePrimaryKey(key: Key, primaryKey: Key) { | ||
cursor.continuePrimaryKey(key.toJs(), primaryKey.toJs()) | ||
public fun continuePrimaryKey(key: IDBKey, primaryKey: IDBKey) { | ||
cursor.continuePrimaryKey(key, primaryKey) | ||
} | ||
|
||
public enum class Direction( | ||
|
@@ -48,6 +48,6 @@ public class CursorWithValue internal constructor( | |
override val cursor: IDBCursorWithValue, | ||
channel: SendChannel<*>, | ||
) : Cursor(cursor, channel) { | ||
public val value: dynamic | ||
public val value: JsAny? | ||
get() = cursor.value | ||
} |
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/jsMain/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)) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: typically "Kotlin/Wasm" is used (without the "Js" attached).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the original wording because it is more precise. The use of IndexedDB is tied to the browser and thus to the wasmJS target and not WASM in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that to differentiate it from wasmWasi, although I guess the fact that it's a browser API should be enough to differentiate implicitly.