Skip to content
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

feature/support_wasm #179

Merged
merged 28 commits into from
Dec 14, 2024
Merged

feature/support_wasm #179

merged 28 commits into from
Dec 14, 2024

Conversation

mshdabiola
Copy link
Owner

No description provided.

This commit updates dependencies and enables hierarchical project structure for database.
Specifically, the following changes were made:

- Enabled hierarchical project structure for Kotlin Multiplatform module in the `database` module.
- Moved dependencies to the common source set to enable shared code between platforms.
- Removed unused `kotlinx-coroutines-android` dependency from commonMainApi configuration.
Adds a nonJsMain source set to the database module for shared code between Android and JVM.
This allows to exclude the coroutines-android dependency from commonMainApi and add sqlite-bundled to commonMain.
This commit upgrades Ktor to version 3.0.2, updates dependencies,
and introduces a new hierarchy setup for multiplatform modules.
Additionally, it removes unnecessary dependencies and replaces
`coil-network-okhttp` with `coil-network-ktor3` for network
image loading.

Here's a breakdown of the changes:

- Upgraded ktor version to 3.0.2.
- Updated dependencies, including coil and others.
- Changed datastore's android implementation to nonJsMain.
- Reorganized dependencies in testing and data modules.
- Removed paging.common implementation from data.
- Introduced defaultHierarchyTemplate for JVM, Android, and WASM targets.
- Removed unused kermit.koin dependency from AndroidMain.
- Added kermit.koin to nonJsMain source set.
- Added browser support with debug capabilities to Android and library modules.
This commit introduces the implementation of the `Store` interface for the Wasm platform.

It adds a new `StoreImple` class that provides in-memory storage for user data.
It also adds a platform-specific module to provide the `Store` instance using Koin dependency injection.
This commit migrates the database models, DAOs, and related components from the `commonMain` source set to the `nonJsMain` source set. This change isolates the database logic to platforms that support it, while ensuring compatibility with other platforms.

The following files were moved or renamed:

- Model classes: `NoteEntity`, `ImageEntity`
- DAO interfaces: `NoteDao`, `ImageDao`
- Database class: `SkeletonDatabase`
- Database module: `DatabaseModule`
- Database migrations: `DatabaseMigrations`
- Platform-specific code: `Platform`
- Constants: `Constant`

Additionally, tests were updated to reflect the new location of the database components.
This commit updates the `RealModelRepository` and `DataModule` to support multiplatform.

Specifically, the following changes were made:

- Moved `RealModelRepository` from `commonMain` to `nonJsMain` and `wasmJsMain`.
- Created a common `DataModule` and platform-specific `DataModule` implementations for `nonJsMain` and `wasmJsMain`.
- Updated dependencies and imports to reflect the new structure.
Move the model module dependency to commonMain and remove the unnecessary kotlinx-coroutines dependency.
Add the sqlite-bundled dependency to the nonJsMain source set to support non-JavaScript platforms.
This commit introduces a platform-specific implementation of the `HttpClient` for Wasm using the Ktor Js engine.

The `httpClient` function is now implemented for the Wasm platform, utilizing the `HttpClient(Js)` constructor and calling the `init()` function for configuration.

Additionally, an empty `initPlatform` function is provided for platform-specific configuration of the `HttpClientEngineConfig`.
This commit removes the `NavigationPreview` expect/actual implementation.
Instead, the preview function is now directly defined in the platform-specific modules (jvmMain and main).
This simplifies the code and removes unnecessary indirection.
This commit adds `Web` as a supported platform in the `Platform` enum. It also provides implementations for `generalPath` and `currentPlatform` in the `wasmJsMain` source set, returning an empty string and `Platform.Web` respectively.
This commit replaces the `Math.toRadians` function with a new `radiansToDegrees` function in the `Background` component.

This change improves code readability and ensures consistency in calculating angles.

Additionally, the commit introduces a new `radiansToDegrees` function in the common code and provides a platform-specific implementation for non-JS platforms.
Moves the `NoteEx` class from the `commonMain` source set to the `nonJsMain` source set. This suggests that the functionality provided by this class is not intended or compatible with JavaScript targets.
This commit implements the analytics module for Wasm.

It creates an `AnalyticsHelper` object which is responsible for logging analytics events. Currently, it does not perform any action, acting as a placeholder for future implementation.
This commit implements the analytics module for Wasm.

It creates an `AnalyticsHelper` object which is responsible for logging analytics events. Currently, it does not perform any action, acting as a placeholder for future implementation.
This commit adds basic support for running the application on the web.

It includes the following changes:

- Added an `index.html` file to serve as the entry point for the web application.
- Added a `styles.css` file for basic styling.
- Added a `Main.kt` file for the web entry point, which sets up a `ComposeViewport` and renders the `SkeletonApp`.
This commit removes the `expect` and `actual` keywords from the `ProfileCardPreview` composable function,
making it platform-agnostic.

Additionally, it initializes Koin in the `main` function for the Wasm target and includes Kermit logger initialization.
This allows dependency injection and logging in the Wasm environment.

The changes also include removing platform-specific `ProfileCardPreview` implementations.
Instead, the `ProfileCardPreview` function is now defined once and used for all platforms.
This commit introduces a splash screen for the Wasm target.

The splash screen displays the app icon and name centered on a primary-colored background. It provides a visual cue during app initialization.

Additionally, the commit includes adjustments to preview functions in `ProfileCard` and introduces `FlowExt` for semantic properties in Wasm.
This commit introduces WasmJs implementations for Background, Theme, and Type components, enabling them to function correctly in a Wasm environment.

Specifically, it includes:

- An implementation for `radiansToDegrees` in Background.wasmJs.kt.
- Support for dynamic theming and color retrieval in Theme.wasmJs.kt.
- Definitions for various text styles in Type.wasmJs.kt.
This commit adds a splash screen to the WebAssembly build of the application.

The splash screen is displayed for 2 seconds before the main application is loaded. This provides a more polished user experience and allows time for the application to initialize.

The splash screen is implemented using a simple `SplashScreen` composable function that displays a logo and some text. It is displayed in a `Box` composable function that also contains the main application. The `show` state variable is used to control the visibility of the splash screen. When the `show` state variable is `true`, the splash screen is displayed. When the `show` state variable is `false`, the main application is displayed.

The `LaunchedEffect` composable function is used to delay the loading of the main application by 2 seconds. This ensures that the splash screen is displayed for the desired amount of time.

The `mainApp` function has been created to encapsulate the splash screen and main application logic. This makes it easier to manage the splash screen and main application.
The `upsert` function in `RealModelRepository` has been updated to correctly generate unique IDs for new notes and handle updates to existing notes.

Previously, `upsert` would simply add a new note to the list without considering existing IDs, potentially leading to duplicate IDs or overwriting existing notes.

This change ensures that:

- New notes are assigned a unique ID based on the maximum existing ID.
- Updates to existing notes preserve the original ID and replace the old note in the list.
- It returns the ID of the upserted note.
This commit optimizes resource access in the `SettingScreen` composable by caching string array resources to avoid redundant lookups.

Specifically, the following changes were made:

- Stored string array resources for theme and day/night options in local variables: `themeArray` and `dayLightArray`, respectively.
- Used these cached variables to display text values in the setting items and the options dialog, using `getOrNull` for safer access and providing a fallback for empty strings.

This change improves performance by reducing the number of resource lookups and ensuring safer access to string array elements.
This commit implements the `Store` interface for the wasm target using the KStore library.

The `StoreImple` class now uses `storeOf` to create a `KStore` instance for storing `UserData`.
The `userData` flow is now derived from the `KStore` updates, ensuring updates are reflected in the flow.
The `updateUserData` function now updates the `KStore` with the transformed `UserData` and returns the updated data.

This implementation provides a persistent and efficient way to manage user data in the wasm environment.
This commit makes the `Note` data class serializable using the `@Serializable` annotation from kotlinx.serialization. This enables the `Note` object to be easily converted to and from various formats like JSON, facilitating data persistence and network communication.
This commit adds the kstore dependency to the project's version catalog.

Specifically, the following changes were made:

- Added `kstore` version to the `[versions]` section.
- Added `kstore-storage` and `kstore` libraries to the `[libraries]` section.
mshdabiola and others added 4 commits December 14, 2024 06:56
This commit renames `NoteEntityN` to `NoteEntity` and `NoteDaoN` to `NoteDao` in the database module.

This change improves the clarity and consistency of the database module's naming conventions.
This commit changes the title of the web application from "Testing" to "Hydraulic" in the index.html file. This provides a more appropriate title for the application when viewed in a web browser.
@mshdabiola mshdabiola merged commit 5f15eaf into develop Dec 14, 2024
3 checks passed
@mshdabiola mshdabiola deleted the feature/support_wasm branch December 14, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant