Skip to content

Commit

Permalink
Rebase on main
Browse files Browse the repository at this point in the history
- Upgrade kotlin-js-store/yarn.lock
- Remove deprecated KLogger.error
- test-kit
- Update native inflater and HttpClient definitions
- Remove deprecated gatewayOnLogger
- Upgrade api dump
- Replace deprecated java.net.URL
  • Loading branch information
DRSchlaubi committed Jan 24, 2024
1 parent a46f98d commit 0724654
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 97 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Documentation.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.kotlin.dsl.assign
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import java.net.URL
import java.net.URI

fun AbstractDokkaLeafTask.applyKordDokkaOptions() {

Expand All @@ -16,7 +16,7 @@ fun AbstractDokkaLeafTask.applyKordDokkaOptions() {

sourceLink {
localDirectory = project.projectDir
remoteUrl = URL("https://github.com/kordlib/kord/blob/${project.commitHash}/${project.name}")
remoteUrl = URI("https://github.com/kordlib/kord/blob/${project.commitHash}/${project.name}").toURL()
remoteLineSuffix = "#L"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
applyDefaultHierarchyTemplate()
jvm()
js {
nodejs()
Expand Down
9 changes: 2 additions & 7 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ apiValidation {
applyKordBCVOptions()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default {
applyDefaultHierarchyTemplate {
common {
group("nonJvm") {
withNative()
Expand Down Expand Up @@ -66,12 +67,6 @@ kotlin {
implementation(project(":test-kit"))
}
}
val nonJvmMain by creating {
dependsOn(commonMain.get())
}
jsMain {
dependsOn(nonJvmMain)
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions common/api/common.api
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,6 @@ public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetada

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord {
public static final field Companion Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord$Companion;
public synthetic fun <init> (ILdev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;
Expand All @@ -2646,7 +2645,6 @@ public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetada
public final fun getType ()Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand Down Expand Up @@ -2682,6 +2680,7 @@ public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetada
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$Companion {
public final fun from (I)Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;
public final fun getEntries ()Ljava/util/List;
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
Expand Down Expand Up @@ -2711,7 +2710,6 @@ public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetada
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$Unknown : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public fun <init> (I)V
}

public final class dev/kord/common/entity/DiscordAttachment {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting",
"ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection"))
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))

package dev.kord.common.entity

Expand Down Expand Up @@ -32,15 +32,16 @@ public sealed class DiscordApplicationRoleConnectionMetadataRecordType(
final override fun hashCode(): Int = value.hashCode()

final override fun toString(): String =
"DiscordApplicationRoleConnectionMetadataRecordType.${this::class.simpleName}(value=$value)"
if (this is Unknown) "DiscordApplicationRoleConnectionMetadataRecordType.Unknown(value=$value)"
else "DiscordApplicationRoleConnectionMetadataRecordType.${this::class.simpleName}"

/**
* An unknown [DiscordApplicationRoleConnectionMetadataRecordType].
*
* This is used as a fallback for [DiscordApplicationRoleConnectionMetadataRecordType]s that
* haven't been added to Kord yet.
*/
public class Unknown(
public class Unknown internal constructor(
`value`: Int,
) : DiscordApplicationRoleConnectionMetadataRecordType(value)

Expand Down Expand Up @@ -98,18 +99,7 @@ public sealed class DiscordApplicationRoleConnectionMetadataRecordType(
}

override fun deserialize(decoder: Decoder):
DiscordApplicationRoleConnectionMetadataRecordType =
when (val value = decoder.decodeInt()) {
1 -> IntegerLessThanOrEqual
2 -> IntegerGreaterThanOrEqual
3 -> IntegerEqual
4 -> IntegerNotEqual
5 -> DateTimeLessThanOrEqual
6 -> DateTimeGreaterThanOrEqual
7 -> BooleanEqual
8 -> BooleanNotEqual
else -> Unknown(value)
}
DiscordApplicationRoleConnectionMetadataRecordType = from(decoder.decodeInt())
}

public companion object {
Expand All @@ -130,5 +120,22 @@ public sealed class DiscordApplicationRoleConnectionMetadataRecordType(
)
}


/**
* Returns an instance of [DiscordApplicationRoleConnectionMetadataRecordType] with
* [DiscordApplicationRoleConnectionMetadataRecordType.value] equal to the specified [value].
*/
public fun from(`value`: Int): DiscordApplicationRoleConnectionMetadataRecordType =
when (value) {
1 -> IntegerLessThanOrEqual
2 -> IntegerGreaterThanOrEqual
3 -> IntegerEqual
4 -> IntegerNotEqual
5 -> DateTimeLessThanOrEqual
6 -> DateTimeGreaterThanOrEqual
7 -> BooleanEqual
8 -> BooleanNotEqual
else -> Unknown(value)
}
}
}
2 changes: 1 addition & 1 deletion common/src/appleMain/kotlin/HttpEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import io.ktor.client.engine.darwin.*

/** @suppress */
@KordInternal
public actual object HttpEngine: HttpClientEngineFactory<HttpClientEngineConfig> by Darwin
public actual fun httpEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = Darwin
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
@file:GenerateKordEnum(
@file:Generate(
name = "DiscordApplicationRoleConnectionMetadataRecordType",
valueType = GenerateKordEnum.ValueType.INT,
docUrl = "https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object-application-role-connection-metadata-type",
kDoc = "Type of [DiscordRoleConnectionMetadata] values",
entityType = Generate.EntityType.INT_KORD_ENUM,
entries = [
GenerateKordEnum.Entry(
Generate.Entry(
name = "IntegerLessThanOrEqual",
intValue = 1,
kDoc = "The metadata value (integer) is less than or equal to the guild's configured value (integer)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "IntegerGreaterThanOrEqual",
intValue = 2,
kDoc = "The metadata value (integer) is greater than or equal to the guild's configured value (integer)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "IntegerEqual",
intValue = 3,
kDoc = "The metadata value (integer) is equal to the guild's configured value (integer)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "IntegerNotEqual",
intValue = 4,
kDoc = "The metadata value (integer) is not equal to the guild's configured value (integer)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "DateTimeLessThanOrEqual",
intValue = 5,
kDoc = "The metadata value (ISO8601 string) is less than or equal to the guild's configured value (integer; days before current date)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "DateTimeGreaterThanOrEqual",
intValue = 6,
kDoc = "The metadata value (ISO8601 string) is greater than or equal to the guild's configured value (integer; days before current date)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "BooleanEqual",
intValue = 7,
kDoc = "The metadata value (integer) is equal to the guild's configured value (integer; 1)"
),
GenerateKordEnum.Entry(
Generate.Entry(
name = "BooleanNotEqual",
intValue = 8,
kDoc = "The metadata value (integer) is not equal to the guild's configured value (integer; 1)"
Expand All @@ -51,7 +51,7 @@ package dev.kord.common.entity

import dev.kord.common.Locale
import dev.kord.common.entity.optional.Optional
import dev.kord.ksp.GenerateKordEnum
import dev.kord.ksp.Generate
import kotlinx.serialization.Serializable

/**
Expand Down
2 changes: 1 addition & 1 deletion common/src/mingwMain/kotlin/HttpEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import io.ktor.client.engine.winhttp.*

/** @suppress */
@KordInternal
public actual object HttpEngine : HttpClientEngineFactory<HttpClientEngineConfig> by WinHttp
public actual fun httpEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = WinHttp
5 changes: 5 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ kotlin {
implementation(libs.kotlin.logging.old)
}
}
nonJvmMain {
dependencies {
implementation(libs.stately.collections)
}
}
jvmMain {
dependencies {
implementation(libs.slf4j.api)
Expand Down
5 changes: 0 additions & 5 deletions gateway/api/gateway.api
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ public final class dev/kord/gateway/GatewayConfigurationBuilder {

public final class dev/kord/gateway/GatewayKt {
public static final fun editPresence (Ldev/kord/gateway/Gateway;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getGatewayOnLogger ()Lmu/KLogger;
public static final fun logCaughtThrowable (Ljava/lang/Throwable;)V
public static final fun requestGuildMembers (Ldev/kord/gateway/Gateway;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/flow/Flow;
public static final fun requestGuildMembers (Ldev/kord/gateway/Gateway;Ldev/kord/gateway/RequestGuildMembers;)Lkotlinx/coroutines/flow/Flow;
Expand Down Expand Up @@ -1875,10 +1874,6 @@ public final class dev/kord/gateway/UserUpdate : dev/kord/gateway/DispatchEvent
public fun toString ()Ljava/lang/String;
}

public final class dev/kord/gateway/UtilsKt {
public static final fun error (Lmu/KLogger;Ljava/lang/Throwable;)V
}

public final class dev/kord/gateway/VoiceServerUpdate : dev/kord/gateway/DispatchEvent {
public fun <init> (Ldev/kord/common/entity/DiscordVoiceServerUpdateData;Ljava/lang/Integer;)V
public final fun component1 ()Ldev/kord/common/entity/DiscordVoiceServerUpdateData;
Expand Down
3 changes: 0 additions & 3 deletions gateway/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ kotlin {

implementation(libs.kotlin.logging)

// TODO remove when gatewayOnLogger and mu.KLogger.error() are removed
implementation(libs.kotlin.logging.old)

compileOnly(projects.kspAnnotations)
}
}
Expand Down
5 changes: 0 additions & 5 deletions gateway/src/commonMain/kotlin/Gateway.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ public suspend inline fun Gateway.start(token: String, config: GatewayConfigurat
start(builder.build())
}

@Suppress("unused")
@Deprecated("Binary compatibility, remove after deprecation cycle.", level = DeprecationLevel.ERROR)
@PublishedApi
internal val gatewayOnLogger: mu.KLogger = mu.KotlinLogging.logger("Gateway.on")

/**
* Logger used to report [Throwable]s caught in [Gateway.on].
*/
Expand Down
8 changes: 0 additions & 8 deletions gateway/src/commonMain/kotlin/Utils.kt

This file was deleted.

7 changes: 4 additions & 3 deletions gateway/src/nativeMain/kotlin/Inflater.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package dev.kord.gateway

import io.ktor.utils.io.core.*
import io.ktor.websocket.*
import kotlinx.cinterop.*
import platform.zlib.*

private const val MAX_WBITS = 15 // Maximum window size in bits
private const val CHUNK_SIZE = 256 * 1000

internal actual fun Inflater(): Inflater = NativeInflater()

@OptIn(ExperimentalForeignApi::class)
internal actual class Inflater : Closeable {
private class NativeInflater : Inflater {
private val zStream = nativeHeap.alloc<z_stream>().apply {
val initResponse = inflateInit2(ptr, MAX_WBITS)
if (initResponse != Z_OK) {
Expand All @@ -18,7 +19,7 @@ internal actual class Inflater : Closeable {
}
}

actual fun Frame.inflateData(): String {
override fun Frame.inflateData(): String {
val compressedData = data
var out = ByteArray(0)
memScoped {
Expand Down
5 changes: 1 addition & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", versi
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
kotlinx-resources = { module = "com.goncalossilva:resources", version.ref = "kotlinx-resources" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }

# actually plugins, not libraries, but used is 'buildSrc/build.gradle.kts' as implementation dependencies:
Expand All @@ -94,13 +93,12 @@ dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref
atomicfu-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "kotlinx-atomicfu" }
binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
kordx-resources-plugin = { module = "com.goncalossilva:resources-plugin", version.ref = "kotlinx-resources" }

[bundles]

ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"]

test-common = ["kotlin-test-annotations-common", "kotlin-test", "kotlinx-coroutines-test", "kotlinx-resources"]
test-common = ["kotlin-test-annotations-common", "kotlin-test", "kotlinx-coroutines-test"]
test-js = ["kotlin-test-js", "kotlin-node"]
test-jvm = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"]

Expand All @@ -111,7 +109,6 @@ pluginsForBuildSrc = [
"atomicfu-plugin",
"binary-compatibility-validator-plugin",
"ksp-plugin",
"kordx-resources-plugin"
]


Expand Down
18 changes: 0 additions & 18 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ diff@5.0.0:
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==

dukat@0.5.8-rc.4:
version "0.5.8-rc.4"
resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.8-rc.4.tgz#90384dcb50b14c26f0e99dae92b2dea44f5fce21"
integrity sha512-ZnMt6DGBjlVgK2uQamXfd7uP/AxH7RqI0BL9GLrrJb2gKdDxvJChWy+M9AQEaL+7/6TmxzJxFOsRiInY9oGWTA==
dependencies:
google-protobuf "3.12.2"
typescript "3.9.5"

emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
Expand Down Expand Up @@ -249,11 +241,6 @@ glob@7.2.0:
once "^1.3.0"
path-is-absolute "^1.0.0"

google-protobuf@3.12.2:
version "3.12.2"
resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.12.2.tgz#50ce9f9b6281235724eb243d6a83e969a2176e53"
integrity sha512-4CZhpuRr1d6HjlyrxoXoocoGFnRYgKULgMtikMddA9ztRyYR59Aondv2FioyxWVamRo0rF2XpYawkTCBEQOSkA==

has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
Expand Down Expand Up @@ -533,11 +520,6 @@ tr46@~0.0.3:
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==

typescript@3.9.5:
version "3.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==

typescript@5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
Expand Down
4 changes: 0 additions & 4 deletions rest/src/nativeMain/kotlin/ratelimit/AbstractRateLimiter.kt

This file was deleted.

3 changes: 0 additions & 3 deletions rest/src/nonNativeMain/kotlin/AbstractRateLimiter.kt

This file was deleted.

Loading

0 comments on commit 0724654

Please sign in to comment.