Skip to content

Commit 480942f

Browse files
committed
- update build setup to also include the wasm target
- FIX #177 - adjust module hierarchy to not split wasm from other source sets as some dependency currently does not offer wasm support
1 parent 0705491 commit 480942f

File tree

6 files changed

+46
-11
lines changed

6 files changed

+46
-11
lines changed

json-schema-validator/build.gradle.kts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ kotlin {
145145
generateTypeScriptDefinitions()
146146
nodejs()
147147
}
148+
wasmJs {
149+
nodejs()
150+
}
148151
applyDefaultHierarchyTemplate()
149152

150153
val macOsTargets =
@@ -168,7 +171,7 @@ kotlin {
168171
)
169172

170173
sourceSets {
171-
commonMain {
174+
val commonMain by getting {
172175
kotlin.srcDirs(generatedSourceDirectory)
173176

174177
dependencies {
@@ -182,11 +185,33 @@ kotlin {
182185
) {
183186
because("simplifies work with unicode codepoints")
184187
}
188+
}
189+
}
190+
191+
val wasmJsMain by getting {
192+
193+
}
194+
195+
val nonWasmJsMain by creating {
196+
dependsOn(commonMain)
197+
198+
dependencies {
185199
implementation(libs.normalize.get().toString()) {
186200
because("provides normalization required by IDN-hostname format")
187201
}
188202
}
189203
}
204+
205+
val jvmMain by getting {
206+
dependsOn(nonWasmJsMain)
207+
}
208+
val jsMain by getting {
209+
dependsOn(nonWasmJsMain)
210+
}
211+
val nativeMain by getting {
212+
dependsOn(nonWasmJsMain)
213+
}
214+
190215
commonTest {
191216
dependencies {
192217
implementation(libs.kotest.assertions.core)

json-schema-validator/src/commonMain/kotlin/io/github/optimumcode/json/schema/internal/formats/IdnHostnameFormatValidator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import io.github.optimumcode.json.schema.FormatValidator
77
import io.github.optimumcode.json.schema.internal.formats.IdnHostnameFormatValidator.BidiLabelType.LTR
88
import io.github.optimumcode.json.schema.internal.formats.IdnHostnameFormatValidator.BidiLabelType.NONE
99
import io.github.optimumcode.json.schema.internal.formats.IdnHostnameFormatValidator.BidiLabelType.RTL
10-
import io.github.optimumcode.json.schema.internal.hostname.Normalizer
1110
import io.github.optimumcode.json.schema.internal.hostname.Punycode
11+
import io.github.optimumcode.json.schema.internal.hostname.isNormalized
1212
import io.github.optimumcode.json.schema.internal.unicode.CharacterCategory
1313
import io.github.optimumcode.json.schema.internal.unicode.CharacterCategory.ENCLOSING_MARK
1414
import io.github.optimumcode.json.schema.internal.unicode.CharacterCategory.NONSPACING_MARK
@@ -108,7 +108,7 @@ internal object IdnHostnameFormatValidator : AbstractStringFormatValidator() {
108108
label
109109
}
110110

111-
if (!Normalizer.isNormalized(unicode)) {
111+
if (!isNormalized(unicode)) {
112112
return false
113113
}
114114

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
package io.github.optimumcode.json.schema.internal.hostname
22

3-
import doist.x.normalize.Form
4-
import doist.x.normalize.normalize
5-
6-
internal object Normalizer {
7-
fun isNormalized(label: String): Boolean {
8-
return label.normalize(Form.NFC) == label
9-
}
10-
}
3+
public expect fun isNormalized(label: String): Boolean
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.optimumcode.json.schema.internal.hostname
2+
3+
import doist.x.normalize.Form
4+
import doist.x.normalize.normalize
5+
6+
public actual fun isNormalized(label: String): Boolean {
7+
return label.normalize(Form.NFC) == label
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.github.optimumcode.json.schema.internal.hostname
2+
3+
public actual fun isNormalized(label: String): Boolean {
4+
// depending library does not yet support wasm: https://github.com/OptimumCode/json-schema-validator/issues/177#issuecomment-2268482409
5+
return true
6+
}

test-suites/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ kotlin {
2727
js(IR) {
2828
nodejs()
2929
}
30+
wasmJs {
31+
nodejs()
32+
}
3033
applyDefaultHierarchyTemplate()
3134

3235
val macOsTargets =

0 commit comments

Comments
 (0)