Skip to content

Commit f35a957

Browse files
committed
Move :codeviewer into sdk, introduce :hightlights-core
1 parent 7684a44 commit f35a957

File tree

23 files changed

+117
-68
lines changed

23 files changed

+117
-68
lines changed

compose/codeviewer/api/codeviewer.klib.api

Lines changed: 0 additions & 13 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
public final class io/github/composegears/valkyrie/compose/codeviewer/KotlinCodeViewerKt {
2-
public static final fun KotlinCodeViewer (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V
3-
}
4-
5-
public final class io/github/composegears/valkyrie/compose/codeviewer/core/CodeEditorKt {
1+
public final class io/github/composegears/valkyrie/sdk/compose/codeviewer/CodeEditorKt {
62
public static final fun CodeEditor (Ldev/snipme/highlights/Highlights;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;ZZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/ui/text/input/VisualTransformation;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIILandroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material3/TextFieldColors;Landroidx/compose/runtime/Composer;IIII)V
73
}
84

9-
public final class io/github/composegears/valkyrie/compose/codeviewer/core/CodeViewerKt {
5+
public final class io/github/composegears/valkyrie/sdk/compose/codeviewer/CodeViewerKt {
106
public static final fun CodeViewer (Ldev/snipme/highlights/Highlights;Landroidx/compose/ui/Modifier;Landroidx/compose/runtime/Composer;II)V
117
}
128

13-
public final class io/github/composegears/valkyrie/compose/codeviewer/core/CommonKt {
14-
public static final fun getEmphasisLocations (Ljava/lang/String;Ljava/lang/String;)[Ldev/snipme/highlights/model/PhraseLocation;
15-
public static final fun rememberCodeHighlight (Ljava/lang/String;[Ldev/snipme/highlights/model/PhraseLocation;Landroidx/compose/runtime/Composer;I)Ldev/snipme/highlights/Highlights;
9+
public final class io/github/composegears/valkyrie/sdk/compose/codeviewer/CommonKt {
10+
public static final fun rememberCodeHighlight (Ljava/lang/String;Z[Ldev/snipme/highlights/model/PhraseLocation;Landroidx/compose/runtime/Composer;I)Ldev/snipme/highlights/Highlights;
11+
}
12+
13+
public final class io/github/composegears/valkyrie/sdk/compose/codeviewer/KotlinCodeViewerKt {
14+
public static final fun KotlinCodeViewer (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V
1615
}
1716

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Klib ABI Dump
2+
// Targets: [wasmJs]
3+
// Rendering settings:
4+
// - Signature version: 2
5+
// - Show manifest properties: true
6+
// - Show declarations: true
7+
8+
// Library unique name: <valkyrie.sdk.compose:codeviewer>
9+
final fun io.github.composegears.valkyrie.sdk.compose.codeviewer/CodeEditor(dev.snipme.highlights/Highlights, kotlin/Function1<kotlin/String, kotlin/Unit>, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, kotlin/Boolean, androidx.compose.ui.text.input/VisualTransformation?, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, androidx.compose.material3/TextFieldColors?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // io.github.composegears.valkyrie.sdk.compose.codeviewer/CodeEditor|CodeEditor(dev.snipme.highlights.Highlights;kotlin.Function1<kotlin.String,kotlin.Unit>;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;kotlin.Boolean;androidx.compose.ui.text.input.VisualTransformation?;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;androidx.compose.material3.TextFieldColors?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0]
10+
final fun io.github.composegears.valkyrie.sdk.compose.codeviewer/CodeViewer(dev.snipme.highlights/Highlights, androidx.compose.ui/Modifier?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // io.github.composegears.valkyrie.sdk.compose.codeviewer/CodeViewer|CodeViewer(dev.snipme.highlights.Highlights;androidx.compose.ui.Modifier?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
11+
final fun io.github.composegears.valkyrie.sdk.compose.codeviewer/KotlinCodeViewer(kotlin/String, androidx.compose.ui/Modifier?, kotlin/Function1<kotlin/String, kotlin/Unit>?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // io.github.composegears.valkyrie.sdk.compose.codeviewer/KotlinCodeViewer|KotlinCodeViewer(kotlin.String;androidx.compose.ui.Modifier?;kotlin.Function1<kotlin.String,kotlin.Unit>?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
12+
final fun io.github.composegears.valkyrie.sdk.compose.codeviewer/rememberCodeHighlight(kotlin/String, kotlin/Boolean, kotlin/Array<out dev.snipme.highlights.model/PhraseLocation>..., androidx.compose.runtime/Composer?, kotlin/Int): dev.snipme.highlights/Highlights // io.github.composegears.valkyrie.sdk.compose.codeviewer/rememberCodeHighlight|rememberCodeHighlight(kotlin.String;kotlin.Boolean;kotlin.Array<out|dev.snipme.highlights.model.PhraseLocation>...;androidx.compose.runtime.Composer?;kotlin.Int){}[0]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ kotlin {
88
sourceSets {
99
commonMain.dependencies {
1010
implementation(projects.sdk.compose.foundation)
11+
implementation(projects.sdk.compose.highlightsCore)
1112
implementation(projects.compose.ui)
1213
implementation(projects.compose.util)
1314

1415
implementation(compose.material3)
15-
api(libs.highlights)
1616
}
1717
}
1818
}

compose/codeviewer/src/commonMain/kotlin/io/github/composegears/valkyrie/compose/codeviewer/core/CodeEditor.kt renamed to sdk/compose/codeviewer/src/commonMain/kotlin/io/github/composegears/valkyrie/sdk/compose/codeviewer/CodeEditor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.composegears.valkyrie.compose.codeviewer.core
1+
package io.github.composegears.valkyrie.sdk.compose.codeviewer
22

33
import androidx.compose.foundation.horizontalScroll
44
import androidx.compose.foundation.interaction.MutableInteractionSource
@@ -41,6 +41,7 @@ import io.github.composegears.valkyrie.compose.ui.foundation.VerticalScrollbar
4141
import io.github.composegears.valkyrie.compose.util.disabled
4242
import io.github.composegears.valkyrie.sdk.compose.foundation.rememberMutableIntState
4343
import io.github.composegears.valkyrie.sdk.compose.foundation.rememberMutableState
44+
import io.github.composegears.valkyrie.sdk.compose.highlights.core.buildAnnotatedString
4445

4546
@Composable
4647
fun CodeEditor(

compose/codeviewer/src/commonMain/kotlin/io/github/composegears/valkyrie/compose/codeviewer/core/CodeViewer.kt renamed to sdk/compose/codeviewer/src/commonMain/kotlin/io/github/composegears/valkyrie/sdk/compose/codeviewer/CodeViewer.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.composegears.valkyrie.compose.codeviewer.core
1+
package io.github.composegears.valkyrie.sdk.compose.codeviewer
22

33
import androidx.compose.material3.MaterialTheme
44
import androidx.compose.material3.Text
@@ -7,6 +7,8 @@ import androidx.compose.ui.Modifier
77
import androidx.compose.ui.text.font.FontFamily
88
import dev.snipme.highlights.Highlights
99
import dev.snipme.highlights.model.PhraseLocation
10+
import io.github.composegears.valkyrie.compose.util.isLight
11+
import io.github.composegears.valkyrie.sdk.compose.highlights.core.buildAnnotatedString
1012

1113
@Composable
1214
fun CodeViewer(
@@ -36,6 +38,7 @@ private fun CodeTextViewPreview() {
3638
}
3739
""".trimIndent(),
3840
emphasisLocation = arrayOf(PhraseLocation(start = 8, end = 39)),
41+
isLight = MaterialTheme.colorScheme.isLight,
3942
)
4043

4144
CodeViewer(highlights)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.github.composegears.valkyrie.sdk.compose.codeviewer
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.runtime.remember
5+
import dev.snipme.highlights.Highlights
6+
import dev.snipme.highlights.model.PhraseLocation
7+
import dev.snipme.highlights.model.SyntaxLanguage
8+
import dev.snipme.highlights.model.SyntaxThemes
9+
10+
@Composable
11+
fun rememberCodeHighlight(
12+
codeBlock: String,
13+
isLight: Boolean,
14+
vararg emphasisLocation: PhraseLocation,
15+
): Highlights {
16+
return remember(isLight, codeBlock, emphasisLocation) {
17+
Highlights.Builder()
18+
.code(codeBlock)
19+
.language(SyntaxLanguage.KOTLIN)
20+
.theme(SyntaxThemes.darcula(darkMode = !isLight))
21+
.emphasis(*emphasisLocation)
22+
.build()
23+
}
24+
}

compose/codeviewer/src/commonMain/kotlin/io/github/composegears/valkyrie/compose/codeviewer/KotlinCodeViewer.kt renamed to sdk/compose/codeviewer/src/commonMain/kotlin/io/github/composegears/valkyrie/sdk/compose/codeviewer/KotlinCodeViewer.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.composegears.valkyrie.compose.codeviewer
1+
package io.github.composegears.valkyrie.sdk.compose.codeviewer
22

33
import androidx.compose.material3.MaterialTheme
44
import androidx.compose.material3.TextFieldDefaults
@@ -11,7 +11,6 @@ import androidx.compose.ui.unit.sp
1111
import dev.snipme.highlights.Highlights
1212
import dev.snipme.highlights.model.SyntaxLanguage
1313
import dev.snipme.highlights.model.SyntaxThemes
14-
import io.github.composegears.valkyrie.compose.codeviewer.core.CodeEditor
1514
import io.github.composegears.valkyrie.compose.util.isLight
1615
import io.github.composegears.valkyrie.sdk.compose.foundation.rememberMutableState
1716

sdk/compose/foundation/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ kotlin {
88
sourceSets {
99
commonMain.dependencies {
1010
implementation(compose.foundation)
11-
implementation(compose.runtime)
1211
}
1312
}
1413
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public final class io/github/composegears/valkyrie/sdk/compose/highlights/core/CommonKt {
2+
public static final fun buildAnnotatedString (Ldev/snipme/highlights/Highlights;)Landroidx/compose/ui/text/AnnotatedString;
3+
public static final fun getEmphasisLocations (Ljava/lang/String;Ljava/lang/String;)[Ldev/snipme/highlights/model/PhraseLocation;
4+
}
5+

0 commit comments

Comments
 (0)