From afea67d02f3260f4d8ad41da5ca67018a715b8a4 Mon Sep 17 00:00:00 2001 From: KhooLy <73142442+KhooLy@users.noreply.github.com> Date: Tue, 28 Jul 2026 19:42:59 +0300 Subject: [PATCH] fix: resolve FluxaCore/FluxaShared type identity mismatch after moving Apple snapshot DTOs 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. --- .../FluxaAppleCatalogBootstrap.swift | 2 +- appleApp/iOS/FluxaAppleDetailStartup.swift | 28 +++++++++++++------ .../iOS/FluxaAppleHomeEffectHandler.swift | 5 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/appleApp/AppleCore/FluxaAppleCatalogBootstrap.swift b/appleApp/AppleCore/FluxaAppleCatalogBootstrap.swift index eace90e..ec387f1 100644 --- a/appleApp/AppleCore/FluxaAppleCatalogBootstrap.swift +++ b/appleApp/AppleCore/FluxaAppleCatalogBootstrap.swift @@ -1,4 +1,4 @@ -import FluxaShared +import FluxaCore import Foundation @MainActor diff --git a/appleApp/iOS/FluxaAppleDetailStartup.swift b/appleApp/iOS/FluxaAppleDetailStartup.swift index 6726bfe..c423114 100644 --- a/appleApp/iOS/FluxaAppleDetailStartup.swift +++ b/appleApp/iOS/FluxaAppleDetailStartup.swift @@ -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? { diff --git a/appleApp/iOS/FluxaAppleHomeEffectHandler.swift b/appleApp/iOS/FluxaAppleHomeEffectHandler.swift index 4ebdf42..b82c756 100644 --- a/appleApp/iOS/FluxaAppleHomeEffectHandler.swift +++ b/appleApp/iOS/FluxaAppleHomeEffectHandler.swift @@ -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),