Skip to content

2.0.0 - wasm#514

Open
rteyssandier wants to merge 21 commits into2.0.0from
feat/2.0.0/wasm
Open

2.0.0 - wasm#514
rteyssandier wants to merge 21 commits into2.0.0from
feat/2.0.0/wasm

Conversation

@rteyssandier
Copy link
Copy Markdown
Contributor

No description provided.

@rteyssandier rteyssandier self-assigned this Mar 25, 2026
@rteyssandier rteyssandier added the enhancement New feature or request label Mar 25, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly advances the Flocon project's multiplatform strategy by integrating WebAssembly (WasmJs) support across its core modules. The changes enable the framework to compile and run on WasmJs, laying the groundwork for web-based applications while maintaining its modular and plugin-based architecture. This expansion broadens the reach of Flocon's standardized solutions for cross-cutting concerns like networking and data management to a new platform.

Highlights

  • WasmJs Target Integration: Introduced WebAssembly (WasmJs) as a new target platform across numerous Flocon modules, including database, datastores, deeplinks, flocon core, and network components. This significantly expands the multiplatform capabilities of the Flocon framework.
  • Kotlin Multiplatform Build Configuration Updates: Updated build.gradle.kts files for various modules to include wasmJs target configurations, define wasmJsMain source sets, and adjust dependencies for multiplatform compatibility. This involved converting datastores modules to KMP and refactoring source sets in database/room3.
  • WasmJs-Specific Implementations and Stubs: Added numerous wasmJsMain Kotlin files providing platform-specific implementations or no-op stubs for core Flocon functionalities. This includes database operations (SQLite not supported), logging, file handling, network data sources, crash reporting, device utilities, shared preferences, and WebSocket/HTTP clients, ensuring the project compiles for WasmJs while indicating areas for future native implementation.
  • DispatcherUtils for Multiplatform Coroutines: Introduced DispatcherUtils.kt with expect declarations for Dispatchers.IO in commonMain and provided actual implementations for Android, iOS, JVM, and WasmJs, standardizing coroutine dispatcher usage across platforms.
  • Project Documentation: Added a comprehensive AGENT.md file, providing a detailed overview of the Flocon project, its modular architecture, key features, technical stack, module structure, core concepts, and development guidelines.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly expands the Flocon Kotlin Multiplatform project by adding WebAssembly (WasmJs) support across various modules, including database, datastores, deeplinks, flocon core, and network components. This involved updating Gradle build configurations to include the wasmJs target and providing platform-specific implementations or stubs for WasmJs. A new FloconProject Overview markdown file was also added. The review identified several issues: a critical recursive definition of Dispatchers.IO in Android and JVM source sets leading to StackOverflowError, incorrect stubbing of time functions (currentTimeMillis, currentTimeNanos) in WasmJs, an unused constructor parameter in FloconRoom3DatabaseProviderImpl.wasmJs.kt, commented-out imports in FloconDatastorePreference.kt, and a potential bug in decodeNetworkBody in ktor-interceptor for WasmJs where charset information from headers is ignored.

Comment on lines +6 to +8
public actual val Dispatchers.IO: CoroutineDispatcher get() = Dispatchers.IO

public actual val IO: CoroutineDispatcher get() = Dispatchers.IO
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The actual implementations for Dispatchers.IO and IO are recursive. Because this file is in the kotlinx.coroutines package, Dispatchers.IO on the right-hand side of the getter refers to the property being defined, not the original dispatcher from the coroutines library. This will cause a StackOverflowError at runtime. This is a critical issue that needs to be addressed. A possible solution is to not define these actuals in the kotlinx.coroutines package to avoid shadowing.

Comment on lines +6 to +8
public actual val Dispatchers.IO: CoroutineDispatcher get() = Dispatchers.IO

public actual val IO: CoroutineDispatcher get() = Dispatchers.IO
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The actual implementations for Dispatchers.IO and IO are recursive. Because this file is in the kotlinx.coroutines package, Dispatchers.IO on the right-hand side of the getter refers to the property being defined, not the original dispatcher from the coroutines library. This will cause a StackOverflowError at runtime. This is a critical issue that needs to be addressed. A possible solution is to not define these actuals in the kotlinx.coroutines package to avoid shadowing.

Comment on lines +7 to +9
actual fun currentTimeMillis(): Long = 0L // Stub for now to ensure compilation

actual fun currentTimeNanos(): Long = 0L // Stub for now to ensure compilation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The functions currentTimeMillis and currentTimeNanos are stubbed to return 0L. This is incorrect and can lead to subtle bugs related to timing, caching, or logging. For WasmJS, you can get the current time from the JavaScript environment.

Suggested change
actual fun currentTimeMillis(): Long = 0L // Stub for now to ensure compilation
actual fun currentTimeNanos(): Long = 0L // Stub for now to ensure compilation
actual fun currentTimeMillis(): Long = kotlin.js.Date.now().toLong()
actual fun currentTimeNanos(): Long = (js("performance.now()") as Double * 1_000_000).toLong()

@OptIn(markerClass = [FloconMarker::class])
internal actual class FloconRoom3DatabaseProviderImpl actual constructor(
private val context: FloconContext,
paths: List<String>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The constructor parameter paths is not used within the class. To improve code clarity and signal that it's intentionally unused, you could rename it to _paths.

Suggested change
paths: List<String>
_paths: List<String>

Comment on lines +3 to +11
//import androidx.datastore.core.DataStore
//import androidx.datastore.preferences.core.Preferences
//import androidx.datastore.preferences.core.booleanPreferencesKey
//import androidx.datastore.preferences.core.doublePreferencesKey
//import androidx.datastore.preferences.core.edit
//import androidx.datastore.preferences.core.floatPreferencesKey
//import androidx.datastore.preferences.core.intPreferencesKey
//import androidx.datastore.preferences.core.longPreferencesKey
//import androidx.datastore.preferences.core.stringPreferencesKey
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These imports are commented out. Commented-out code should be removed to improve maintainability and reduce clutter. If these imports are needed for other platform-specific source sets, they should be moved there.

Comment on lines +3 to +6
internal actual fun decodeNetworkBody(
bytes: ByteArray,
headers: Map<String, String>
): String = bytes.decodeToString()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The decodeNetworkBody function currently ignores the headers parameter, which may contain important charset information in the Content-Type header. This can lead to incorrect decoding of the response body if it's not UTF-8. The headers should be parsed to extract the charset for a more robust implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant