Skip to content

Commit ac43616

Browse files
authored
chore: fix for bundle size (#477)
* chore(plugin): update plugin name, vendor email, and description Renamed plugin to "AutoDev Next", updated vendor email, and revised description for clarity. * feat(ui): add platform-specific UTF-8 font support Introduce getUtf8FontFamily() for proper CJK/UTF-8 rendering on WASM using Noto Sans SC, while other platforms use system defaults. Also exclude heavy dependencies and large font assets from the IntelliJ plugin build to reduce size.
1 parent 82b8d18 commit ac43616

File tree

11 files changed

+105
-14
lines changed

11 files changed

+105
-14
lines changed

mpp-idea/build.gradle.kts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ repositories {
3737
}
3838
}
3939

40+
// Global exclusions for heavy dependencies not needed in IntelliJ plugin
41+
// These exclusions apply to ALL configurations including transitive dependencies from includeBuild projects
42+
configurations.all {
43+
exclude(group = "aws.sdk.kotlin") // AWS SDK (~30MB) - from ai.koog:prompt-executor-bedrock-client
44+
exclude(group = "aws.smithy.kotlin") // AWS Smithy runtime
45+
exclude(group = "org.apache.tika") // Apache Tika (~100MB) - document parsing
46+
exclude(group = "org.apache.poi") // Apache POI - Office document parsing (from Tika)
47+
exclude(group = "org.apache.pdfbox") // PDFBox (~10MB) - PDF parsing
48+
exclude(group = "net.sourceforge.plantuml") // PlantUML (~20MB) - from dev.snipme:highlights
49+
exclude(group = "org.jsoup") // Jsoup HTML parser
50+
exclude(group = "ai.koog", module = "prompt-executor-bedrock-client") // Bedrock executor
51+
// Redis/Lettuce - not needed in IDEA plugin (~5MB)
52+
exclude(group = "io.lettuce")
53+
exclude(group = "io.projectreactor")
54+
// RxJava - not needed (~2.6MB)
55+
exclude(group = "io.reactivex.rxjava3")
56+
// RSyntaxTextArea - IDEA has its own editor (~1.3MB)
57+
exclude(group = "com.fifesoft")
58+
// Netty - not needed for IDEA plugin (~3MB)
59+
exclude(group = "io.netty")
60+
// pty4j/jediterm - IDEA has its own terminal (~3MB)
61+
exclude(group = "org.jetbrains.pty4j")
62+
exclude(group = "org.jetbrains.jediterm")
63+
}
64+
4065
dependencies {
4166
// Depend on mpp-ui and mpp-core JVM targets for shared UI components and ConfigManager
4267
// For KMP projects, we need to depend on the JVM target specifically
@@ -98,6 +123,7 @@ dependencies {
98123
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-serialization-core-jvm")
99124
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-io-core")
100125
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-io-core-jvm")
126+
// Note: Heavy dependencies (AWS, Tika, POI, PDFBox, PlantUML, Jsoup) are excluded globally above
101127
}
102128

103129
// Use platform-provided kotlinx libraries to avoid classloader conflicts
@@ -192,6 +218,21 @@ tasks {
192218
useJUnitPlatform()
193219
}
194220

221+
// Exclude large font files from mpp-ui that are not needed in IDEA plugin
222+
// These fonts are for Desktop/WASM apps, IDEA has its own fonts
223+
named<org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask>("prepareSandbox") {
224+
// Exclude font files from the plugin distribution
225+
// NotoSansSC-Regular.ttf (~18MB), NotoColorEmoji.ttf (~11MB x2), FiraCode fonts (~1MB)
226+
exclude("**/fonts/**")
227+
exclude("**/composeResources/**/font/**")
228+
exclude("**/*.ttf")
229+
exclude("**/*.otf")
230+
// Also exclude icon files meant for desktop app
231+
exclude("**/icon.icns")
232+
exclude("**/icon.ico")
233+
exclude("**/icon-512.png")
234+
}
235+
195236
// Task to verify no conflicting dependencies are included
196237
register("verifyNoDuplicateDependencies") {
197238
group = "verification"

mpp-idea/src/main/resources/META-INF/plugin.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!-- Plugin Configuration File for mpp-idea Compose UI module -->
22
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
33
<id>cc.unitmesh.devins.idea</id>
4-
<name>AutoDev Compose UI</name>
5-
<vendor email="phodal@gmail.com" url="https://github.com/unit-mesh">UnitMesh</vendor>
4+
<name>AutoDev Next</name>
5+
<vendor email="h@phodal.com" url="https://github.com/unit-mesh">UnitMesh</vendor>
66

77
<description><![CDATA[
8-
AutoDev Compose UI module - Provides Compose-based UI components for IntelliJ IDEA 2025.2+.
8+
AutoDev Idea - Provides Compose-based UI components for IntelliJ IDEA 2025.2+.
99
This module leverages Jewel theme for native IDE integration with DevIn language support.
1010
]]></description>
1111

mpp-ui/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ tasks.register<DownloadWasmFontsTask>("downloadWasmFonts") {
696696
group = "build"
697697
description = "Download fonts for WASM UTF-8 support (not committed to Git)"
698698

699-
fontDir.set(file("src/commonMain/composeResources/font"))
699+
// Fonts are only needed for WASM platform, so download to wasmJsMain
700+
fontDir.set(file("src/wasmJsMain/composeResources/font"))
700701
useCJKFont.set(project.findProperty("useCJKFont")?.toString()?.toBoolean() ?: true)
701702
}
702703

mpp-ui/src/androidMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/CodeFont.android.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devins.ui.compose.sketch
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.text.font.Font
45
import androidx.compose.ui.text.font.FontFamily
56
import androidx.compose.ui.text.font.FontWeight
@@ -30,3 +31,10 @@ actual fun getFiraCodeFontFamily(): FontFamily {
3031
FontFamily.Monospace
3132
}
3233
}
34+
35+
/**
36+
* Android implementation - use default font family
37+
* Android has good system font support for UTF-8
38+
*/
39+
@Composable
40+
actual fun getUtf8FontFamily(): FontFamily = FontFamily.Default

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/agent/AgentMessageList.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@ import androidx.compose.ui.text.font.FontFamily
1717
import androidx.compose.ui.text.font.FontWeight
1818
import androidx.compose.ui.unit.dp
1919
import androidx.compose.ui.unit.sp
20-
import autodev_intellij.mpp_ui.generated.resources.NotoSansSC_Regular
21-
import autodev_intellij.mpp_ui.generated.resources.Res
22-
import cc.unitmesh.agent.Platform
2320
import cc.unitmesh.agent.render.TimelineItem
2421
import cc.unitmesh.devins.llm.Message
2522
import cc.unitmesh.devins.llm.MessageRole
2623
import cc.unitmesh.devins.ui.compose.icons.AutoDevComposeIcons
2724
import cc.unitmesh.devins.ui.compose.sketch.SketchRenderer
25+
import cc.unitmesh.devins.ui.compose.sketch.getUtf8FontFamily
2826
import kotlinx.coroutines.delay
2927
import kotlinx.coroutines.launch
30-
import org.jetbrains.compose.resources.Font
3128

3229
@Composable
3330
fun AgentMessageList(
@@ -278,7 +275,7 @@ fun MessageItem(
278275
} else {
279276
Text(
280277
text = message.content,
281-
fontFamily = if (Platform.isWasm) FontFamily(Font(Res.font.NotoSansSC_Regular)) else FontFamily.Monospace,
278+
fontFamily = getUtf8FontFamily(),
282279
style = MaterialTheme.typography.bodyMedium
283280
)
284281
}

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/DevInEditorInput.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import androidx.compose.ui.text.input.TextFieldValue
2525
import androidx.compose.ui.unit.IntOffset
2626
import androidx.compose.ui.unit.dp
2727
import androidx.compose.ui.unit.sp
28-
import autodev_intellij.mpp_ui.generated.resources.NotoSansSC_Regular
29-
import autodev_intellij.mpp_ui.generated.resources.Res
3028
import cc.unitmesh.agent.Platform
3129
import cc.unitmesh.agent.mcp.McpClientManager
3230
import cc.unitmesh.agent.mcp.McpConfig
@@ -41,13 +39,13 @@ import cc.unitmesh.devins.ui.compose.editor.completion.CompletionPopup
4139
import cc.unitmesh.devins.ui.compose.editor.completion.CompletionTrigger
4240
import cc.unitmesh.devins.ui.compose.editor.highlighting.DevInSyntaxHighlighter
4341
import cc.unitmesh.devins.ui.config.ConfigManager
42+
import cc.unitmesh.devins.ui.compose.sketch.getUtf8FontFamily
4443
import cc.unitmesh.devins.workspace.WorkspaceManager
4544
import cc.unitmesh.llm.KoogLLMService
4645
import cc.unitmesh.llm.ModelConfig
4746
import cc.unitmesh.llm.PromptEnhancer
4847
import kotlinx.coroutines.delay
4948
import kotlinx.coroutines.launch
50-
import org.jetbrains.compose.resources.Font
5149

5250
/**
5351
* DevIn 编辑器输入组件
@@ -485,7 +483,7 @@ fun DevInEditorInput(
485483
.onPreviewKeyEvent { handleKeyEvent(it) },
486484
textStyle =
487485
TextStyle(
488-
fontFamily = if (Platform.isWasm) FontFamily(Font(Res.font.NotoSansSC_Regular)) else FontFamily.Monospace,
486+
fontFamily = getUtf8FontFamily(),
489487
fontSize = inputFontSize,
490488
color = MaterialTheme.colorScheme.onSurface,
491489
lineHeight = inputLineHeight

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/CodeFont.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devins.ui.compose.sketch
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.text.font.FontFamily
45

56
/**
@@ -12,3 +13,11 @@ expect fun getFiraCodeFontFamily(): FontFamily
1213
* Get default monospace font family as fallback
1314
*/
1415
fun getDefaultMonospaceFontFamily(): FontFamily = FontFamily.Monospace
16+
17+
/**
18+
* Get UTF-8 font family for text display
19+
* On WASM, returns Noto Sans SC for CJK support
20+
* On other platforms, returns default font family
21+
*/
22+
@Composable
23+
expect fun getUtf8FontFamily(): FontFamily

mpp-ui/src/iosMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/CodeFont.ios.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devins.ui.compose.sketch
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.text.font.FontFamily
45

56
/**
@@ -12,3 +13,10 @@ actual fun getFiraCodeFontFamily(): FontFamily {
1213
return FontFamily.Monospace
1314
}
1415

16+
/**
17+
* iOS implementation - use default font family
18+
* iOS has good system font support for UTF-8
19+
*/
20+
@Composable
21+
actual fun getUtf8FontFamily(): FontFamily = FontFamily.Default
22+

mpp-ui/src/jsMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/CodeFont.js.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devins.ui.compose.sketch
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.text.font.FontFamily
45

56
/**
@@ -14,3 +15,10 @@ actual fun getFiraCodeFontFamily(): FontFamily {
1415
// The browser will use the system's monospace font
1516
return FontFamily.Monospace
1617
}
18+
19+
/**
20+
* JS implementation - use default font family
21+
* Browser has good system font support for UTF-8
22+
*/
23+
@Composable
24+
actual fun getUtf8FontFamily(): FontFamily = FontFamily.Default

mpp-ui/src/jvmMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/CodeFont.jvm.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devins.ui.compose.sketch
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.text.font.FontFamily
45
import androidx.compose.ui.text.font.FontWeight
56
import androidx.compose.ui.text.platform.Font
@@ -29,3 +30,10 @@ actual fun getFiraCodeFontFamily(): FontFamily {
2930
FontFamily.Monospace
3031
}
3132
}
33+
34+
/**
35+
* JVM implementation - use default font family
36+
* JVM has good system font support for UTF-8
37+
*/
38+
@Composable
39+
actual fun getUtf8FontFamily(): FontFamily = FontFamily.Default

0 commit comments

Comments
 (0)