refactor: move feature-not-yet-iOS-ready files to jvmAndroid

Clears the remaining easy iOS blockers in commons/commonMain by
relocating files whose underlying feature isn't iOS-ready yet, rather
than fabricating expect/actuals we won't need until that feature ships.

- NestViewModel + ActiveSubscription: depend on :nestsClient (audio
  rooms — Phase 5 per the iOS plan). Moved as-is; both already lived
  in a jvmAndroid-shaped package.
- HtmlCharsetParser: depends on java.nio.charset.Charset, used only
  by the Android link-preview pipeline (no Desktop / iOS consumer
  today).
- RenderMarkdown: depends on com.halilibo.richtext.* — needs iOS
  artifact verification before it can return to commonMain (tracked
  for Phase 3).
- MediaContentModels.kt is split:
  * URL-based models (BaseMediaContent, MediaUrlImage/Video/Pdf,
    EncryptedMediaUrlImage/Video) stay in commonMain — pure KMP, no
    java.io.File reference.
  * Locally-cached variants (MediaPreloadedContent, MediaLocalImage,
    MediaLocalVideo) move to a new MediaLocalContent.kt under
    jvmAndroid — they hold a java.io.File and call .exists().

After this PR commons/commonMain has 5 remaining java.* importers
(Note's BigDecimal, the two SortedSet observables, URL parsing in
RichTextParser + UrlInfoItem). Down from 18 at the start of Phase 2.
This commit is contained in:
Claude
2026-05-24 23:36:10 +00:00
parent 6f1292bfcf
commit 39008f90d3
6 changed files with 77 additions and 42 deletions
@@ -22,7 +22,11 @@ package com.vitorpamplona.amethyst.commons.richtext
import androidx.compose.runtime.Immutable
import com.vitorpamplona.quartz.nip94FileMetadata.tags.DimensionTag
import java.io.File
// URL-based media content models (KMP). The locally-cached variants
// (MediaPreloadedContent, MediaLocalImage, MediaLocalVideo) live in
// MediaLocalContent.kt under the jvmAndroid source set because they depend
// on java.io.File.
@Immutable
abstract class BaseMediaContent(
@@ -123,44 +127,3 @@ class EncryptedMediaUrlVideo(
thumbhash: String? = null,
authorPubKey: String? = null,
) : MediaUrlVideo(url, description, hash, dim, uri, artworkUri, authorName, blurhash, contentWarning, mimeType, thumbhash, authorPubKey = authorPubKey)
@Immutable
abstract class MediaPreloadedContent(
val localFile: File?,
description: String? = null,
val mimeType: String? = null,
val isVerified: Boolean? = null,
dim: DimensionTag? = null,
blurhash: String? = null,
val uri: String,
val id: String? = null,
thumbhash: String? = null,
) : BaseMediaContent(description, dim, blurhash, thumbhash) {
fun localFileExists() = localFile != null && localFile.exists()
}
@Immutable
class MediaLocalImage(
localFile: File?,
mimeType: String? = null,
description: String? = null,
dim: DimensionTag? = null,
blurhash: String? = null,
isVerified: Boolean? = null,
uri: String,
thumbhash: String? = null,
) : MediaPreloadedContent(localFile, description, mimeType, isVerified, dim, blurhash, uri, thumbhash = thumbhash)
@Immutable
class MediaLocalVideo(
localFile: File?,
mimeType: String? = null,
description: String? = null,
dim: DimensionTag? = null,
blurhash: String? = null,
isVerified: Boolean? = null,
uri: String,
val artworkUri: String? = null,
val authorName: String? = null,
thumbhash: String? = null,
) : MediaPreloadedContent(localFile, description, mimeType, isVerified, dim, blurhash, uri, thumbhash = thumbhash)
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2025 Vitor Pamplona
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.vitorpamplona.amethyst.commons.richtext
import androidx.compose.runtime.Immutable
import com.vitorpamplona.quartz.nip94FileMetadata.tags.DimensionTag
import java.io.File
// Locally-cached media content. Lives in jvmAndroid because java.io.File is
// JVM-only; iOS support will arrive when we either swap to okio.Path or pull
// these classes back into commonMain behind an expect/actual File abstraction.
// URL-based media classes (MediaUrlImage, MediaUrlVideo, …) remain in
// commonMain in MediaContentModels.kt.
@Immutable
abstract class MediaPreloadedContent(
val localFile: File?,
description: String? = null,
val mimeType: String? = null,
val isVerified: Boolean? = null,
dim: DimensionTag? = null,
blurhash: String? = null,
val uri: String,
val id: String? = null,
thumbhash: String? = null,
) : BaseMediaContent(description, dim, blurhash, thumbhash) {
fun localFileExists() = localFile != null && localFile.exists()
}
@Immutable
class MediaLocalImage(
localFile: File?,
mimeType: String? = null,
description: String? = null,
dim: DimensionTag? = null,
blurhash: String? = null,
isVerified: Boolean? = null,
uri: String,
thumbhash: String? = null,
) : MediaPreloadedContent(localFile, description, mimeType, isVerified, dim, blurhash, uri, thumbhash = thumbhash)
@Immutable
class MediaLocalVideo(
localFile: File?,
mimeType: String? = null,
description: String? = null,
dim: DimensionTag? = null,
blurhash: String? = null,
isVerified: Boolean? = null,
uri: String,
val artworkUri: String? = null,
val authorName: String? = null,
thumbhash: String? = null,
) : MediaPreloadedContent(localFile, description, mimeType, isVerified, dim, blurhash, uri, thumbhash = thumbhash)