Skip to content

Commit 0154752

Browse files
committed
Merge branch 'dev' into github-pages-deployment-with-dokka
2 parents ecd20e8 + e1c6b70 commit 0154752

File tree

48 files changed

+4563
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4563
-636
lines changed

.github/copilot-instructions.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# Copilot Instructions for Compose Multiplatform HTML Unified
2+
3+
## Repository Overview
4+
5+
**Compose Multiplatform HTML Unified** is a Kotlin Multiplatform library that provides unified Compose Multiplatform wrappers of common and Material Design APIs for both **rendering-based Compose UI** (Android, desktop JVM, iOS, web Kotlin/Wasm) and **DOM-based Compose HTML**. This library was previously named "Compose Multiplatform Material".
6+
7+
### Repository Statistics
8+
- **Size**: Medium-large multiplatform project with ~15 modules
9+
- **Language**: Kotlin (multiplatform)
10+
- **Build System**: Gradle with Kotlin DSL
11+
- **Target Platforms**: JVM, Android, iOS, JS (DOM), Wasm-JS (Canvas)
12+
- **Key Dependencies**: Compose Multiplatform, Kobweb Silk, Material Web Components
13+
14+
## Build Instructions and Environment Setup
15+
16+
### Prerequisites
17+
- **JDK 17**: Required (as specified in GitHub Actions workflows)
18+
- **Network Access**: Required for initial builds to download Android Gradle Plugin and other dependencies
19+
- **Gradle 9.1.0**: Automatically handled by wrapper
20+
21+
**IMPORTANT**: Initial builds require internet access for dependency resolution. Once dependencies are cached, subsequent builds can use `--offline` flag if needed.
22+
23+
**IMPORTANT**: If the project uses snapshot dependencies of other `com.huanshankeji` libraries, especially in a branch other than `main` such as `dev`, refer to the setup instructions at <https://github.com/huanshankeji/.github/blob/main/dev-instructions.md#about-snapshot-dependencies-of-our-library-projects>.
24+
25+
### Build Commands (In Order)
26+
27+
#### 1. Basic Project Setup
28+
```bash
29+
./gradlew --version # Verify Gradle 9.1.0 and JDK 17
30+
```
31+
32+
#### 2. Publishing to Local Maven (Primary Development Command)
33+
```bash
34+
./gradlew publishToMavenLocal
35+
```
36+
**Important**: Always run `publishToMavenLocal` first when making changes, as mentioned in CONTRIBUTING.md. This ensures libraries compile correctly and validates the build process.
37+
38+
#### 3. Running Tests and Checks (Essential Commands - validated and working)
39+
```bash
40+
./gradlew check
41+
```
42+
**Note**: The project has "limited number of tests" according to CONTRIBUTING.md, but this validates what exists.
43+
44+
#### 4. Building Demo Applications
45+
```bash
46+
# Build the side-by-side demo (used for GitHub Pages)
47+
./gradlew :compose-multiplatform-html-unified-demo:sideBySideBrowserDistribution
48+
49+
# Individual platform builds
50+
./gradlew jsBrowserDistribution # JS DOM version
51+
./gradlew wasmJsBrowserDistribution # Wasm-JS Canvas version
52+
```
53+
54+
### Build Configuration Details
55+
56+
#### Memory Requirements
57+
- **Gradle JVM**: 2GB memory allocated via `org.gradle.jvmargs=-Xmx2G` in gradle.properties (required for Wasm compilation)
58+
59+
#### Common Build Issues and Workarounds
60+
61+
1. **Network Connectivity**: Initial builds require internet access for Android Gradle Plugin (8.11.2) and other dependencies. If build fails with network errors, ensure internet connectivity.
62+
63+
2. **Memory Issues**: If Wasm compilation fails with OOM, the memory is already optimized in gradle.properties.
64+
65+
3. **Kotlin/JS Store**: The `kotlin-js-store` directory may be generated during JS builds - this should be committed when updated automatically by Gradle commands.
66+
67+
4. **Gradle Daemon**: May timeout on first runs. Use `--no-daemon` flag if needed: `./gradlew check --no-daemon`
68+
69+
### Build Timing and Known Issues
70+
71+
**Timing Expectations**:
72+
- First build: 5-10 minutes (includes dependency resolution and Wasm compilation)
73+
- Subsequent builds: 1-3 minutes
74+
- `publishToMavenLocal`: 3-5 minutes
75+
- `check` execution: 2-5 minutes (limited tests)
76+
- Demo builds: 2-4 minutes
77+
78+
**Common Issues**:
79+
- **Wasm Compilation**: Requires 2GB+ heap memory (pre-configured in gradle.properties)
80+
- **Network Dependencies**: Initial builds require internet access for dependency resolution
81+
- **Platform-specific builds**: Some targets may be disabled on certain OS (use `--continue` flag)
82+
83+
## Project Architecture and Layout
84+
85+
### Module Structure
86+
```
87+
├── common/ # Core APIs, layouts, modifiers (foundation equivalent)
88+
├── material-icons-core/ # Icon system core
89+
├── material2/ # Material Design 2 components
90+
├── material3/ # Material Design 3 components
91+
├── navigation/ # Navigation support (experimental)
92+
├── lifecycle-viewmodel/ # ViewModel support (experimental)
93+
├── demo/ # Demonstration application
94+
└── buildSrc/ # Build configuration and dependencies
95+
```
96+
97+
### Key Configuration Files
98+
- **buildSrc/src/main/kotlin/VersionsAndDependencies.kt**: All dependency versions
99+
- **buildSrc/src/main/kotlin/common-conventions.gradle.kts**: Shared build configuration
100+
- **buildSrc/src/main/kotlin/lib-conventions.gradle.kts**: Library-specific configuration
101+
- **gradle.properties**: JVM memory settings for Gradle (increase if OOM occurs) and Kotlin MPP configuration
102+
- **settings.gradle.kts**: Project structure and repository configuration
103+
104+
### Source Set Structure (Per Module)
105+
```
106+
src/
107+
├── commonMain/ # Shared APIs across all platforms
108+
├── composeUiMain/ # Compose UI targets (JVM, Android, iOS, Wasm)
109+
├── composeUiExceptAndroidMain/ # Compose UI excluding Android
110+
├── androidMain/ # Android-specific implementations
111+
├── jsMain/ # JS DOM implementations (Kobweb/HTML)
112+
├── jvmMain/ # Desktop JVM implementations
113+
└── iosMain/ # iOS-specific implementations
114+
```
115+
116+
### Dependencies and External Integration
117+
118+
#### Required External Repositories
119+
```kotlin
120+
repositories {
121+
mavenCentral()
122+
google() // For Android components
123+
}
124+
```
125+
126+
**Note**: All dependencies are available from standard repositories. If working with snapshot dependencies of other `com.huanshankeji` libraries, additional setup may be required as per organization instructions.
127+
128+
#### Key Dependencies
129+
- **Kotlin**: 2.2.20 with Compose Compiler
130+
- **Compose Multiplatform**: 1.9.0
131+
- **Android Gradle Plugin**: 8.11.2
132+
- **Kobweb**: 0.23.3 (now on Maven Central)
133+
- **Compose HTML Material**: 0.4.1-SNAPSHOT
134+
- **Binary Compatibility Validator**: 0.18.1 (enabled)
135+
136+
### Platform-Specific Implementation Patterns
137+
138+
#### Compose UI Platforms (Android, JVM, iOS, Wasm)
139+
- Delegate directly to official `androidx.compose` APIs
140+
- Located in `composeUiMain` source sets
141+
142+
#### JS DOM Platform
143+
- Built on **Kobweb Silk** (provides Modifier system and layouts)
144+
- Uses **Material Web Components** via Compose HTML Material
145+
- Located in `jsMain` source sets
146+
- Requires CSS imports for Material Icons
147+
148+
### Development Patterns and Conventions
149+
150+
#### API Structure
151+
- **Common APIs**: Defined in `commonMain`, expect/actual pattern for platform differences
152+
- **Ext Components**: Components in `ext` packages don't follow androidx.compose APIs exactly but provide more idiomatic platform-specific wrappers
153+
- **Parameter Naming**: Parameters with "JsDom" or "ComposeUi" suffixes are platform-specific
154+
155+
#### Code Quality and Validation
156+
- **Binary Compatibility**: Enforced via org.jetbrains.kotlinx.binary-compatibility-validator plugin
157+
- **Limited Testing**: Project acknowledges "limited number of tests"
158+
159+
**Code Style:**
160+
- Follow [our Kotlin code style guide](https://github.com/huanshankeji/.github/blob/main/kotlin-code-style.md) for all Kotlin code contributions
161+
162+
#### Architecture Notes
163+
- **Multi-module**: Each feature area is a separate Gradle subproject
164+
- **Expect/Actual Pattern**: Platform-specific implementations using Kotlin Multiplatform patterns
165+
- **Convention Plugins**: Custom build logic in `buildSrc` for consistency across modules
166+
- **Target Platforms**: Sophisticated setup targeting 6+ platforms with different implementation strategies
167+
168+
### Root Directory Files
169+
```
170+
.gitignore # Standard exclusions plus .kotlin, local.properties
171+
build.gradle.kts # Root build file with binary compatibility validator
172+
CHANGELOG.md # Detailed version history with breaking changes
173+
CODE_OF_CONDUCT.md # Standard code of conduct
174+
CONTRIBUTING.md # Development guidelines and contribution process
175+
gradle.properties # Memory settings and Kotlin configuration
176+
LEGACY_README.md # Previous project name reference
177+
LICENSE # Apache 2.0 license
178+
README.md # Comprehensive API documentation and usage guide
179+
settings.gradle.kts # Project structure and dependency management
180+
```
181+
182+
## Validation Steps for Changes
183+
184+
1. **Build Validation**: Run `./gradlew build` or `./gradlew publishToMavenLocal` to ensure libraries compile
185+
2. **Test Validation**: Run `./gradlew check` to validate existing tests pass
186+
3. **Demo Validation**: Build demo with `./gradlew :compose-multiplatform-html-unified-demo:sideBySideBrowserDistribution`
187+
4. **CI Simulation**: Test on multiple platforms if possible (the CI runs on Ubuntu, macOS, Windows)
188+
5. **Binary Compatibility**: The kotlinx binary compatibility validator will catch API breaks
189+
190+
## Important Notes for Agents
191+
192+
- **Trust These Instructions**: Only perform additional searches if information here is incomplete or incorrect
193+
- **Network Dependency**: Initial builds require internet access for dependency resolution
194+
- **Memory Requirements**: Ensure adequate memory for Wasm compilation (2GB JVM heap configured)
195+
- **Limited Test Coverage**: Don't expect comprehensive test suites - focus on build and demo validation
196+
- **Platform Complexity**: This is a sophisticated multiplatform project with 6+ target platforms and complex expect/actual patterns
197+
198+
**Trust these instructions**: This information has been validated through actual command execution and file inspection. Only search for additional information if these instructions are incomplete or found to be incorrect.

.github/workflows/ci.yml

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,35 @@
11
name: CI
22

33
on:
4+
workflow_dispatch:
45
push:
5-
branches: [ "*" ]
6+
branches: ["*"]
67
# pull_request:
78
# branches: [ "*" ]
89

910
jobs:
1011
check:
11-
1212
strategy:
1313
matrix:
14-
os: [ ubuntu-latest, macos-latest, windows-latest ]
14+
os: [ubuntu-latest, macos-latest, windows-latest]
1515
runs-on: ${{ matrix.os }}
1616
permissions:
1717
contents: read
1818

1919
steps:
20-
- uses: actions/checkout@v4
21-
- name: Set up JDK 8
22-
uses: actions/setup-java@v4
23-
with:
24-
java-version: '8'
25-
distribution: 'zulu'
26-
- name: Set up JDK 17
27-
uses: actions/setup-java@v4
20+
- uses: huanshankeji/.github/actions/[email protected]
2821
with:
29-
java-version: '17'
30-
distribution: 'temurin'
31-
32-
- name: Setup Gradle
33-
uses: gradle/actions/setup-gradle@v4
34-
35-
- name: Check with Gradle Wrapper
36-
run: ./gradlew check
22+
jdk-versions: 17-temurin
3723

3824
dependency-submission:
39-
4025
strategy:
4126
matrix:
42-
os: [ ubuntu-latest, macos-latest, windows-latest ]
27+
os: [ubuntu-latest, macos-latest, windows-latest]
4328
runs-on: ${{ matrix.os }}
4429
permissions:
4530
contents: write
4631

4732
steps:
48-
- uses: actions/checkout@v4
49-
- name: Set up JDK 17
50-
uses: actions/setup-java@v4
33+
- uses: huanshankeji/.github/actions/[email protected]
5134
with:
52-
java-version: '17'
53-
distribution: 'temurin'
54-
55-
- name: Generate and submit dependency graph
56-
uses: gradle/actions/dependency-submission@v4
35+
jdk-versions: 17-temurin

.github/workflows/demo-gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/configure-pages@v5
3333

3434
- name: Set up JDK 17
35-
uses: actions/setup-java@v4
35+
uses: actions/setup-java@v5
3636
with:
3737
java-version: "17"
3838
distribution: "temurin"

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ The `com.huanshankeji.compose.material.icons.Icon` class delegates to both kinds
132132

133133
- `outerBorder`
134134
- `roundedCornerBackgroundAndOuterBorder`
135+
- `outerPadding`, `innerPadding`
135136

136137
### Other APIs
137138

@@ -143,15 +144,11 @@ The `com.huanshankeji.compose.material.icons.Icon` class delegates to both kinds
143144

144145
### ViewModel
145146

146-
The ViewModel module currently supports a small subset of the Compose ViewModel APIs, and delegates to raw UI state on
147-
Compose HTML / JS DOM. These APIs are highly experimental now.
147+
The ViewModel module currently supports a subset of the Compose ViewModel APIs. For ViewModel to work properly on Compose HTML / JS DOM, call `com.huanshankeji.compose.ui.window.renderComposableInBodyWithViewModelStoreOwner` instead of `org.jetbrains.compose.web.renderComposableInBody` on JS. These APIs are experimental now.
148148

149149
### Navigation
150150

151-
The navigation module currently supports a small subset of the Compose Navigation APIs, which does not support
152-
transition or animation on Compose HTML / JS DOM. These APIs are also highly experimental now.
153-
See [CMP-4966](https://youtrack.jetbrains.com/issue/CMP-4966) for a bug to avoid. Also, ViewModel-related functions
154-
are not implemented yet on Compose HTML / JS DOM.
151+
The navigation module currently supports a small subset of the Compose Navigation APIs, which does not support transition or animation on Compose HTML / JS DOM. These APIs are also experimental now. See [CMP-4966](https://youtrack.jetbrains.com/issue/CMP-4966) for a bug to avoid.
155152

156153
## Add to your dependencies
157154

@@ -187,15 +184,6 @@ kotlin {
187184

188185
View [all the artifacts on Maven Central](https://search.maven.org/search?q=g:com.huanshankeji%20AND%20a:compose-multiplatform-*).
189186

190-
This project depends on [Kobweb](https://github.com/varabyte/kobweb) which is not published to Maven Central yet, so you have to add the following Maven repository:
191-
192-
```kotlin
193-
repositories {
194-
mavenCentral()
195-
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public")
196-
}
197-
```
198-
199187
### Material Symbols & Icons on JS
200188

201189
See [the corresponding section in Compose HTML Material](https://github.com/huanshankeji/compose-html-material?tab=readme-ov-file#material-symbols--icons) for configuring Material Icons on JS.

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tasks.wrapper {
33
}
44

55
plugins {
6-
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.16.3"
6+
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.18.1"
77
id("org.jetbrains.dokka")
88
}
99

@@ -14,7 +14,7 @@ apiValidation {
1414
}
1515

1616
ignoredProjects += "compose-multiplatform-html-unified".let {
17-
listOf("$it-demo", "$it-common-legacy")
17+
listOf("$it-demo")
1818
}
1919
}
2020

buildSrc/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ plugins {
33
}
44

55
repositories {
6-
//mavenLocal() // comment out when not needed
6+
mavenLocal() // TODO comment out when not needed so the build is always reproducible by others
77
gradlePluginPortal()
88
google()
99
mavenCentral()
1010
}
1111

1212
dependencies {
13-
val kotlinVersion = "2.1.0"
13+
val kotlinVersion = "2.2.10"
1414
implementation(kotlin("gradle-plugin", kotlinVersion))
1515
implementation("org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlinVersion")
16-
implementation("org.jetbrains.compose:compose-gradle-plugin:1.7.3")
17-
implementation("com.huanshankeji.team:gradle-plugins:0.9.0") // don't use a snapshot version in a main branch
18-
implementation("com.android.tools.build:gradle:8.7.3")
19-
implementation("com.huanshankeji:common-gradle-dependencies:0.9.0-20241203") // don't use a snapshot version in a main branch
16+
implementation("org.jetbrains.compose:compose-gradle-plugin:1.9.0")
17+
implementation("com.huanshankeji.team:gradle-plugins:0.10.0-SNAPSHOT") // TODO don't use a snapshot version in a main branch
18+
implementation("com.android.tools.build:gradle:8.12.3")
19+
implementation("com.huanshankeji:common-gradle-dependencies:0.10.0-20250918-SNAPSHOT") // TODO don't use a snapshot version in a main branch
2020
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
val androidSdkVersion = 34 // bump to 35 when AGP and Kotlin are bumped
1+
val androidSdkVersion = 36
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import com.huanshankeji.CommonDependencies
22
import org.jetbrains.compose.ComposeBuildConfig
33

4-
val projectVersion = "0.5.1-SNAPSHOT"
4+
val projectVersion = "0.6.0-SNAPSHOT"
55

66
val commonDependencies = CommonDependencies()
77

88
object DependencyVersions {
99
const val composeMultiplatform = ComposeBuildConfig.composeVersion // for "ui-unit"
10-
val kobweb = "0.19.2"
11-
val huanshankejiComposeHtml = "0.4.0" // don't use a snapshot version in a main branch
10+
11+
// https://slack-chats.kotlinlang.org/t/27579160/after-updating-to-1-8-0-rc01-package-androidx-compose-materi
12+
// https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.8.0-rc01
13+
const val composeMultiplatformMaterialIconsExtended = "1.7.3"
14+
val kobweb = "0.23.3"
15+
val huanshankejiComposeHtml = "0.4.1-SNAPSHOT" // TODO don't use a snapshot version in a main branch
1216
val kmdc = "0.1.2"
13-
val materialSymbols = "0.25.1"
17+
val materialSymbols = "0.35.2"
1418
}

0 commit comments

Comments
 (0)