update versions

This commit is contained in:
InsanusMokrassar 2020-08-18 10:53:53 +06:00
parent 3ab7451b2e
commit fc8c0cfc73
33 changed files with 70 additions and 96 deletions

View File

@ -31,12 +31,13 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api kotlin('reflect')
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.utils.common:$core_version" api "com.insanusmokrassar:postssystem.utils.common:$core_version"

View File

@ -26,11 +26,11 @@ class ContentSerialization {
} }
val stringified = registeredContentFakes.map { val stringified = registeredContentFakes.map {
Json.stringify(RegisteredContent.serializer(), it) Json.encodeToString(RegisteredContent.serializer(), it)
} }
val parsed = stringified.map { val parsed = stringified.map {
Json.parse(RegisteredContent.serializer(), it) Json.decodeFromString(RegisteredContent.serializer(), it)
} }
parsed.forEachIndexed { i, registeredContent -> assertEquals(registeredContentFakes[i], registeredContent) } parsed.forEachIndexed { i, registeredContent -> assertEquals(registeredContentFakes[i], registeredContent) }

View File

@ -31,7 +31,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -19,7 +19,7 @@ class ReadContentRepoKtorClient(
override suspend fun getContentsIds(): Set<ContentId> = client.get<ByteArray>( override suspend fun getContentsIds(): Set<ContentId> = client.get<ByteArray>(
"$baseUrl/$getContentsIdsRoute" "$baseUrl/$getContentsIdsRoute"
).let { ).let {
standardKtorSerialFormat.load(contentIdsSerializer, it) standardKtorSerialFormat.decodeFromByteArray(contentIdsSerializer, it)
} }
override suspend fun getContentById(id: ContentId): RegisteredContent? = client.uniget( override suspend fun getContentById(id: ContentId): RegisteredContent? = client.uniget(

View File

@ -17,13 +17,13 @@ class WriteContentRepoKtorClient(
override val contentCreatedFlow: Flow<RegisteredContent> = client.createStandardWebsocketFlow( override val contentCreatedFlow: Flow<RegisteredContent> = client.createStandardWebsocketFlow(
"$baseUrl/$contentCreatedFlowRoute" "$baseUrl/$contentCreatedFlowRoute"
) { ) {
standardKtorSerialFormat.load(RegisteredContent.serializer(), it) standardKtorSerialFormat.decodeFromByteArray(RegisteredContent.serializer(), it)
} }
override val contentDeletedFlow: Flow<RegisteredContent> = client.createStandardWebsocketFlow( override val contentDeletedFlow: Flow<RegisteredContent> = client.createStandardWebsocketFlow(
"$baseUrl/$contentDeletedFlowRoute" "$baseUrl/$contentDeletedFlowRoute"
) { ) {
standardKtorSerialFormat.load(RegisteredContent.serializer(), it) standardKtorSerialFormat.decodeFromByteArray(RegisteredContent.serializer(), it)
} }
override suspend fun registerContent(content: Content): RegisteredContent? = client.unipost( override suspend fun registerContent(content: Content): RegisteredContent? = client.unipost(

View File

@ -21,7 +21,7 @@ class ReadPostsRepoKtorClient(
override suspend fun getPostsIds(): Set<PostId> = client.get<ByteArray>( override suspend fun getPostsIds(): Set<PostId> = client.get<ByteArray>(
"$baseUrl/$getPostsIdsRoute" "$baseUrl/$getPostsIdsRoute"
).let { ).let {
standardKtorSerialFormat.load(postIdsSerializer, it) standardKtorSerialFormat.decodeFromByteArray(postIdsSerializer, it)
} }
override suspend fun getPostById(id: PostId): RegisteredPost? = client.uniget( override suspend fun getPostById(id: PostId): RegisteredPost? = client.uniget(

View File

@ -20,17 +20,17 @@ class WritePostsRepoKtorClient (
override val postCreatedFlow: Flow<RegisteredPost> = client.createStandardWebsocketFlow( override val postCreatedFlow: Flow<RegisteredPost> = client.createStandardWebsocketFlow(
"$baseUrl/$postCreatedFlowRoute" "$baseUrl/$postCreatedFlowRoute"
) { ) {
standardKtorSerialFormat.load(RegisteredPost.serializer(), it) standardKtorSerialFormat.decodeFromByteArray(RegisteredPost.serializer(), it)
} }
override val postDeletedFlow: Flow<RegisteredPost> = client.createStandardWebsocketFlow( override val postDeletedFlow: Flow<RegisteredPost> = client.createStandardWebsocketFlow(
"$baseUrl/$postDeletedFlowRoute" "$baseUrl/$postDeletedFlowRoute"
) { ) {
standardKtorSerialFormat.load(RegisteredPost.serializer(), it) standardKtorSerialFormat.decodeFromByteArray(RegisteredPost.serializer(), it)
} }
override val postUpdatedFlow: Flow<RegisteredPost> = client.createStandardWebsocketFlow( override val postUpdatedFlow: Flow<RegisteredPost> = client.createStandardWebsocketFlow(
"$baseUrl/$postUpdatedFlowRoute" "$baseUrl/$postUpdatedFlowRoute"
) { ) {
standardKtorSerialFormat.load(RegisteredPost.serializer(), it) standardKtorSerialFormat.decodeFromByteArray(RegisteredPost.serializer(), it)
} }
override suspend fun createPost(post: Post): RegisteredPost? = client.unipost( override suspend fun createPost(post: Post): RegisteredPost? = client.unipost(

View File

@ -31,7 +31,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -16,10 +16,10 @@ fun Route.configureWriteContentRepoRoutes(
proxyTo: WriteContentRepo proxyTo: WriteContentRepo
) { ) {
includeWebsocketHandling(contentCreatedFlowRoute, proxyTo.contentCreatedFlow) { includeWebsocketHandling(contentCreatedFlowRoute, proxyTo.contentCreatedFlow) {
standardKtorSerialFormat.dump(RegisteredContent.serializer(), it) standardKtorSerialFormat.encodeToByteArray(RegisteredContent.serializer(), it)
} }
includeWebsocketHandling(contentDeletedFlowRoute, proxyTo.contentDeletedFlow) { includeWebsocketHandling(contentDeletedFlowRoute, proxyTo.contentDeletedFlow) {
standardKtorSerialFormat.dump(RegisteredContent.serializer(), it) standardKtorSerialFormat.encodeToByteArray(RegisteredContent.serializer(), it)
} }
post(registerContentRoute) { post(registerContentRoute) {
val content = call.uniload(Content.serializer()) val content = call.uniload(Content.serializer())

View File

@ -16,13 +16,13 @@ fun Route.configureWritePostsRepoRoutes(
proxyTo: WritePostsRepo proxyTo: WritePostsRepo
) { ) {
includeWebsocketHandling(postCreatedFlowRoute, proxyTo.postCreatedFlow) { includeWebsocketHandling(postCreatedFlowRoute, proxyTo.postCreatedFlow) {
standardKtorSerialFormat.dump(RegisteredPost.serializer(), it) standardKtorSerialFormat.encodeToByteArray(RegisteredPost.serializer(), it)
} }
includeWebsocketHandling(postDeletedFlowRoute, proxyTo.postDeletedFlow) { includeWebsocketHandling(postDeletedFlowRoute, proxyTo.postDeletedFlow) {
standardKtorSerialFormat.dump(RegisteredPost.serializer(), it) standardKtorSerialFormat.encodeToByteArray(RegisteredPost.serializer(), it)
} }
includeWebsocketHandling(postUpdatedFlowRoute, proxyTo.postUpdatedFlow) { includeWebsocketHandling(postUpdatedFlowRoute, proxyTo.postUpdatedFlow) {
standardKtorSerialFormat.dump(RegisteredPost.serializer(), it) standardKtorSerialFormat.encodeToByteArray(RegisteredPost.serializer(), it)
} }
post(createPostRoute) { post(createPostRoute) {

View File

@ -1,19 +1,19 @@
kotlin.code.style=official kotlin.code.style=official
org.gradle.parallel=true org.gradle.parallel=true
kotlin_version=1.3.72 kotlin_version=1.4.0
kotlin_coroutines_version=1.3.8 kotlin_coroutines_version=1.3.9
kotlin_serialisation_runtime_version=0.20.0 kotlin_serialisation_core_version=1.0.0-RC
ktor_version=1.3.2 ktor_version=1.3.2-1.4.0-rc
klockVersion=1.11.14 klockVersion=1.12.0
uuidVersion=0.1.1 uuidVersion=0.2.0
exposed_version=0.26.2 exposed_version=0.26.2
test_sqlite_version=3.32.3.2 test_sqlite_version=3.32.3.2
javax_activation_version=1.1.1 javax_activation_version=1.1.1
gradle_bintray_plugin_version=1.8.4 gradle_bintray_plugin_version=1.8.5
core_version=0.4.2 core_version=0.5.0

View File

@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -31,7 +31,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -15,7 +15,7 @@ suspend fun <ResultType> HttpClient.uniget(
) = get<ByteArray>( ) = get<ByteArray>(
url url
).let { ).let {
standardKtorSerialFormat.load(resultDeserializer, it) standardKtorSerialFormat.decodeFromByteArray(resultDeserializer, it)
} }
suspend fun <BodyType, ResultType> HttpClient.unipost( suspend fun <BodyType, ResultType> HttpClient.unipost(
@ -23,7 +23,7 @@ suspend fun <BodyType, ResultType> HttpClient.unipost(
bodyInfo: BodyPair<BodyType>, bodyInfo: BodyPair<BodyType>,
resultDeserializer: DeserializationStrategy<ResultType> resultDeserializer: DeserializationStrategy<ResultType>
) = post<ByteArray>(url) { ) = post<ByteArray>(url) {
body = standardKtorSerialFormat.dump(bodyInfo.first, bodyInfo.second) body = standardKtorSerialFormat.encodeToByteArray(bodyInfo.first, bodyInfo.second)
}.let { }.let {
standardKtorSerialFormat.load(resultDeserializer, it) standardKtorSerialFormat.decodeFromByteArray(resultDeserializer, it)
} }

View File

@ -31,14 +31,14 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialisation_core_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-cbor-common:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_core_version"
api projectByName("postssystem.utils.common") api projectByName("postssystem.utils.common")
} }
@ -52,8 +52,7 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
implementation kotlin('stdlib-jdk8') implementation kotlin('stdlib-jdk8')
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version" // api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_core_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_runtime_version"
} }
} }
jvmTest { jvmTest {
@ -64,8 +63,7 @@ kotlin {
jsMain { jsMain {
dependencies { dependencies {
implementation kotlin('stdlib-js') implementation kotlin('stdlib-js')
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version" // api "org.jetbrains.kotlinx:kotlinx-serialization-cbor-js:$kotlin_serialisation_core_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-cbor-js:$kotlin_serialisation_runtime_version"
} }
} }
jsTest { jsTest {

View File

@ -36,7 +36,7 @@ kotlin {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version" api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api projectByName("postssystem.ktor.common") api projectByName("postssystem.ktor.common")
} }
@ -50,9 +50,6 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
api "io.ktor:ktor-server:$ktor_version" api "io.ktor:ktor-server:$ktor_version"
api "io.ktor:ktor-server-host-common:$ktor_version" api "io.ktor:ktor-server-host-common:$ktor_version"
api "io.ktor:ktor-server-netty:$ktor_version" api "io.ktor:ktor-server-netty:$ktor_version"

View File

@ -14,14 +14,14 @@ suspend fun <T> ApplicationCall.unianswer(
answer: T answer: T
) { ) {
respondBytes( respondBytes(
standardKtorSerialFormat.dump(answerSerializer, answer), standardKtorSerialFormat.encodeToByteArray(answerSerializer, answer),
standardKtorSerialFormatContentType standardKtorSerialFormatContentType
) )
} }
suspend fun <T> ApplicationCall.uniload( suspend fun <T> ApplicationCall.uniload(
deserializer: DeserializationStrategy<T> deserializer: DeserializationStrategy<T>
) = standardKtorSerialFormat.load( ) = standardKtorSerialFormat.decodeFromByteArray(
deserializer, deserializer,
request.receiveChannel().toByteArray() request.receiveChannel().toByteArray()
) )

View File

@ -3,10 +3,10 @@ package com.insanusmokrassar.postssystem.ktor.server.configurators
import io.ktor.application.Application import io.ktor.application.Application
import io.ktor.application.install import io.ktor.application.install
import io.ktor.features.CachingHeaders import io.ktor.features.CachingHeaders
import kotlinx.serialization.ContextualSerialization import kotlinx.serialization.Contextual
data class ApplicationCachingHeadersConfigurator( data class ApplicationCachingHeadersConfigurator(
private val elements: List<@ContextualSerialization Element> private val elements: List<@Contextual Element>
) : KtorApplicationConfigurator{ ) : KtorApplicationConfigurator{
interface Element { operator fun CachingHeaders.Configuration.invoke() } interface Element { operator fun CachingHeaders.Configuration.invoke() }

View File

@ -3,12 +3,12 @@ package com.insanusmokrassar.postssystem.ktor.server.configurators
import io.ktor.application.* import io.ktor.application.*
import io.ktor.routing.Route import io.ktor.routing.Route
import io.ktor.routing.Routing import io.ktor.routing.Routing
import kotlinx.serialization.ContextualSerialization import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@Serializable @Serializable
class ApplicationRoutingConfigurator( class ApplicationRoutingConfigurator(
private val elements: List<@ContextualSerialization Element> private val elements: List<@Contextual Element>
) : KtorApplicationConfigurator { ) : KtorApplicationConfigurator {
interface Element { operator fun Route.invoke() } interface Element { operator fun Route.invoke() }

View File

@ -3,10 +3,10 @@ package com.insanusmokrassar.postssystem.ktor.server.configurators
import io.ktor.application.Application import io.ktor.application.Application
import io.ktor.application.install import io.ktor.application.install
import io.ktor.sessions.Sessions import io.ktor.sessions.Sessions
import kotlinx.serialization.ContextualSerialization import kotlinx.serialization.Contextual
class ApplicationSessionsConfigurator( class ApplicationSessionsConfigurator(
private val elements: List<@ContextualSerialization Element> private val elements: List<@Contextual Element>
) : KtorApplicationConfigurator { ) : KtorApplicationConfigurator {
interface Element { operator fun Sessions.Configuration.invoke() } interface Element { operator fun Sessions.Configuration.invoke() }

View File

@ -3,10 +3,10 @@ package com.insanusmokrassar.postssystem.ktor.server.configurators
import io.ktor.application.Application import io.ktor.application.Application
import io.ktor.application.install import io.ktor.application.install
import io.ktor.features.StatusPages import io.ktor.features.StatusPages
import kotlinx.serialization.ContextualSerialization import kotlinx.serialization.*
class StatusPagesConfigurator( class StatusPagesConfigurator(
private val elements: List<@ContextualSerialization Element> private val elements: List<@Contextual Element>
) : KtorApplicationConfigurator { ) : KtorApplicationConfigurator {
interface Element { operator fun StatusPages.Configuration.invoke() } interface Element { operator fun StatusPages.Configuration.invoke() }

View File

@ -28,7 +28,7 @@ class WebsocketsTest {
install(WebSockets) install(WebSockets)
routing { routing {
includeWebsocketHandling(suburl, dataFlow) { includeWebsocketHandling(suburl, dataFlow) {
standardKtorSerialFormat.dump(Int.serializer(), it) standardKtorSerialFormat.encodeToByteArray(Int.serializer(), it)
} }
} }
}.also { }.also {
@ -44,7 +44,7 @@ class WebsocketsTest {
"$serverUrl/$suburl", "$serverUrl/$suburl",
{ false } // always skip reconnection { false } // always skip reconnection
) { ) {
standardKtorSerialFormat.load(Int.serializer(), it) standardKtorSerialFormat.decodeFromByteArray(Int.serializer(), it)
} }
var currentlyCheckingData: Int? = null var currentlyCheckingData: Int? = null

View File

@ -31,14 +31,14 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version" api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialisation_core_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core.api:$core_version" api "com.insanusmokrassar:postssystem.core.api:$core_version"
@ -59,8 +59,6 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
implementation kotlin('stdlib-jdk8') implementation kotlin('stdlib-jdk8')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
} }
} }
jvmTest { jvmTest {
@ -71,8 +69,6 @@ kotlin {
jsMain { jsMain {
dependencies { dependencies {
implementation kotlin('stdlib-js') implementation kotlin('stdlib-js')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
} }
} }
jsTest { jsTest {

View File

@ -31,14 +31,14 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version" api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialisation_core_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.markups.core:$core_version" api "com.insanusmokrassar:postssystem.markups.core:$core_version"
@ -56,9 +56,6 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
implementation kotlin('stdlib-jdk8') implementation kotlin('stdlib-jdk8')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
api "org.jetbrains.kotlinx:kotlinx-html-jvm:$kotlinx_html_version" api "org.jetbrains.kotlinx:kotlinx-html-jvm:$kotlinx_html_version"
} }
} }
@ -70,9 +67,6 @@ kotlin {
jsMain { jsMain {
dependencies { dependencies {
implementation kotlin('stdlib-js') implementation kotlin('stdlib-js')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
api "org.jetbrains.kotlinx:kotlinx-html-js:$kotlinx_html_version" api "org.jetbrains.kotlinx:kotlinx-html-js:$kotlinx_html_version"
} }
} }

View File

@ -31,7 +31,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -31,7 +31,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -29,7 +29,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -31,14 +31,14 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version" api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialisation_core_version"
api "com.soywiz.korlibs.klock:klock:$klockVersion" api "com.soywiz.korlibs.klock:klock:$klockVersion"
api "com.benasher44:uuid:$uuidVersion" api "com.benasher44:uuid:$uuidVersion"
@ -53,10 +53,6 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
implementation kotlin('stdlib-jdk8') implementation kotlin('stdlib-jdk8')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
api "javax.activation:activation:$javax_activation_version"
} }
} }
jvmTest { jvmTest {
@ -67,8 +63,6 @@ kotlin {
jsMain { jsMain {
dependencies { dependencies {
implementation kotlin('stdlib-js') implementation kotlin('stdlib-js')
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
} }
} }
jsTest { jsTest {

View File

@ -2,6 +2,9 @@ package com.insanusmokrassar.postssystem.utils.common
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.ByteArraySerializer import kotlinx.serialization.builtins.ByteArraySerializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
typealias ByteArrayAllocator = () -> ByteArray typealias ByteArrayAllocator = () -> ByteArray
@ -10,7 +13,7 @@ object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator> {
override val descriptor: SerialDescriptor = realSerializer.descriptor override val descriptor: SerialDescriptor = realSerializer.descriptor
override fun deserialize(decoder: Decoder): ByteArrayAllocator { override fun deserialize(decoder: Decoder): ByteArrayAllocator {
val bytes = decoder.decode(realSerializer) val bytes = realSerializer.deserialize(decoder)
return { bytes } return { bytes }
} }

View File

@ -1,6 +1,9 @@
package com.insanusmokrassar.postssystem.utils.common package com.insanusmokrassar.postssystem.utils.common
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
private val mimesCache = mutableMapOf<String, MimeType>().also { private val mimesCache = mutableMapOf<String, MimeType>().also {
knownMimeTypes.forEach { mimeType -> it[mimeType.raw] = mimeType } knownMimeTypes.forEach { mimeType -> it[mimeType.raw] = mimeType }
@ -14,7 +17,7 @@ internal fun parseMimeType(raw: String): MimeType = findBuiltinMimeType(raw) ?:
@Serializer(MimeType::class) @Serializer(MimeType::class)
internal object MimeTypeSerializer : KSerializer<MimeType> { internal object MimeTypeSerializer : KSerializer<MimeType> {
override val descriptor: SerialDescriptor = PrimitiveDescriptor("mimeType", PrimitiveKind.STRING) override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder): MimeType { override fun deserialize(decoder: Decoder): MimeType {
val mimeType = decoder.decodeString() val mimeType = decoder.decodeString()

View File

@ -1,7 +0,0 @@
package com.insanusmokrassar.postssystem.utils.common
import org.w3c.dom.get
import kotlin.browser.window
val MimeType.jsMimeType
get() = window.navigator.mimeTypes[raw]

View File

@ -1,5 +0,0 @@
package com.insanusmokrassar.postssystem.utils.common
val MimeType.asActivationMimeType: javax.activation.MimeType
get() = javax.activation.MimeType(raw)

View File

@ -31,7 +31,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js() js { browser() }
sourceSets { sourceSets {
commonMain { commonMain {