fix: resolve FluxaCore/FluxaShared type identity mismatch after moving Apple snapshot DTOs
Some checks failed
Apple / iOS simulator (push) Has been cancelled
Apple / tvOS simulator (push) Has been cancelled
Platform Verification / Android shared modules (push) Has been cancelled

Kotlin/Native generates distinct Swift types for a class depending on
whether it's imported directly from its owning module or transitively
re-exported through another framework, so files consuming these DTOs
via FluxaShared's re-export of core no longer matched the FluxaCore
type Loader/ResourceLoader now return directly. Route Bootstrap and
HomeEffectHandler through FluxaCore consistently, and add an explicit
FluxaCore->FluxaShared stream conversion where DetailStartup crosses
back into FluxaApple.shared's Shared-typed API.
This commit is contained in:
KhooLy 2026-07-28 19:42:59 +03:00
parent a0db322fed
commit afea67d02f
3 changed files with 23 additions and 12 deletions

View file

@ -1,4 +1,4 @@
import FluxaShared
import FluxaCore
import Foundation
@MainActor

View file

@ -1,3 +1,4 @@
import FluxaCore
import FluxaShared
import Foundation
@ -18,7 +19,7 @@ final class FluxaAppleDetailStartup {
self.addonResourceLoader = addonResourceLoader
}
func load(request: AppleDetailRequestSnapshot) async {
func load(request: FluxaShared.AppleDetailRequestSnapshot) async {
do {
let action = FluxaAppleDetailAction(
type: "detailLoadRequested",
@ -37,7 +38,7 @@ final class FluxaAppleDetailStartup {
}
}
func toggleWatchlist(request: AppleDetailRequestSnapshot) async {
func toggleWatchlist(request: FluxaShared.AppleDetailRequestSnapshot) async {
do {
let action = FluxaAppleToggleWatchlistAction(
type: "toggleWatchlistRequested",
@ -57,7 +58,7 @@ final class FluxaAppleDetailStartup {
private func updateSharedDetail(
result: FluxaAppleHeadlessResult,
request: AppleDetailRequestSnapshot
request: FluxaShared.AppleDetailRequestSnapshot
) async {
guard case .object(let detail)? = result.state["detail"],
case .object(let meta)? = detail["meta"] else {
@ -67,21 +68,21 @@ final class FluxaAppleDetailStartup {
let id = text(meta["id"]) ?? request.id
let type = text(meta["type"]) ?? request.type
let streams = await loadDirectStreams(request: request, contentType: type, id: id)
FluxaApple.shared.updateDetail(snapshot: AppleDetailSnapshot(id: id, type: type, title: text(meta["name"]) ?? request.id, description: text(meta["description"]) ?? "", posterUrl: text(meta["poster"]), backgroundUrl: text(meta["background"]), logoUrl: text(meta["logo"]), releaseLabel: text(meta["releaseInfo"]) ?? "", ratingLabel: text(meta["imdbRating"]) ?? "", isInWatchlist: bool(detail["isInWatchlist"]), isLoading: false, errorKey: nil, streams: streams, hasStreamProviders: !streams.isEmpty))
FluxaApple.shared.updateDetail(snapshot: FluxaShared.AppleDetailSnapshot(id: id, type: type, title: text(meta["name"]) ?? request.id, description: text(meta["description"]) ?? "", posterUrl: text(meta["poster"]), backgroundUrl: text(meta["background"]), logoUrl: text(meta["logo"]), releaseLabel: text(meta["releaseInfo"]) ?? "", ratingLabel: text(meta["imdbRating"]) ?? "", isInWatchlist: bool(detail["isInWatchlist"]), isLoading: false, errorKey: nil, streams: streams.map(toSharedStream), hasStreamProviders: !streams.isEmpty))
}
private func loadDirectStreams(
request: AppleDetailRequestSnapshot,
request: FluxaShared.AppleDetailRequestSnapshot,
contentType: String,
id: String
) async -> [AppleDetailStreamSnapshot] {
) async -> [FluxaCore.AppleDetailStreamSnapshot] {
let addons = ([request.addonTransportUrl].compactMap { $0 } + configurationStore.enabledAddonUrls())
.reduce(into: [String]()) { result, addon in
if !result.contains(addon) {
result.append(addon)
}
}
var results = [AppleDetailStreamSnapshot]()
var results = [FluxaCore.AppleDetailStreamSnapshot]()
for addon in addons {
if let streams = try? await addonResourceLoader.loadDirectStreams(
transportUrl: addon,
@ -94,8 +95,17 @@ final class FluxaAppleDetailStartup {
return results
}
private func updateEmptyDetail(request: AppleDetailRequestSnapshot) {
FluxaApple.shared.updateDetail(snapshot: AppleDetailSnapshot(id: request.id, type: request.type, title: request.title ?? request.id, description: "", posterUrl: nil, backgroundUrl: nil, logoUrl: nil, releaseLabel: "", ratingLabel: "", isInWatchlist: false, isLoading: false, errorKey: "auto.no_results_found", streams: [], hasStreamProviders: false))
private func toSharedStream(_ stream: FluxaCore.AppleDetailStreamSnapshot) -> FluxaShared.AppleDetailStreamSnapshot {
FluxaShared.AppleDetailStreamSnapshot(
addonName: stream.addonName,
title: stream.title,
playableUrl: stream.playableUrl,
requestHeadersJson: stream.requestHeadersJson
)
}
private func updateEmptyDetail(request: FluxaShared.AppleDetailRequestSnapshot) {
FluxaApple.shared.updateDetail(snapshot: FluxaShared.AppleDetailSnapshot(id: request.id, type: request.type, title: request.title ?? request.id, description: "", posterUrl: nil, backgroundUrl: nil, logoUrl: nil, releaseLabel: "", ratingLabel: "", isInWatchlist: false, isLoading: false, errorKey: "auto.no_results_found", streams: [], hasStreamProviders: false))
}
private func text(_ value: FluxaAppleJsonValue?) -> String? {

View file

@ -1,4 +1,5 @@
import Foundation
import FluxaCore
import FluxaShared
final class FluxaAppleHomeEffectHandler: FluxaApplePlatformEffectHandler {
@ -64,7 +65,7 @@ final class FluxaAppleHomeEffectHandler: FluxaApplePlatformEffectHandler {
}
}
private func homeCategory(_ row: AppleCatalogRowSnapshot) -> FluxaAppleJsonValue {
private func homeCategory(_ row: FluxaCore.AppleCatalogRowSnapshot) -> FluxaAppleJsonValue {
.object([
"id": .string(row.id),
"name": .string(row.title),
@ -75,7 +76,7 @@ final class FluxaAppleHomeEffectHandler: FluxaApplePlatformEffectHandler {
])
}
private func homeMeta(_ item: AppleCatalogItemSnapshot) -> FluxaAppleJsonValue {
private func homeMeta(_ item: FluxaCore.AppleCatalogItemSnapshot) -> FluxaAppleJsonValue {
.object([
"id": .string(item.id),
"type": .string(item.type),