Consolidates 137 wave commits + 31 supporting commits (CLAUDE.md bump, typealias additions, AnyObject→EngineMedia restoration) into one squashed commit. Migrates dozens of consumer-side public APIs, struct fields, protocol methods, and enum payloads from Postbox protocols/structs to TelegramEngine engine wrappers and typealiases. Drops `import Postbox` from many files. Adds new TelegramCore typealiases and one TelegramEngineUnauthorized facade. Notable changes by category: **TelegramCore typealias additions** (rule 2 — narrow utility typealiases): - EngineChatListIndex, EngineTempBoxFile, EngineItemCollectionItemIndex, EngineItemCollectionViewEntryIndex, EngineValueBoxEncryptionParameters, EngineMessageAndThreadId, EnginePeerStoryStats, EngineMessageHistoryAnchorIndex, EngineChatListTotalUnreadStateCategory, EngineChatListTotalUnreadStateStats, EnginePeerSummaryCounterTags, EngineChatListTotalUnreadState, EngineItemCacheEntryId, EngineHashFunctions, EngineCachedMediaResourceRepresentationResult, EngineMediaResourceDataFetchResult, EngineMediaResourceDataFetchError, EngineMediaResourceStatus, EngineCachedPeerData **TelegramCore engine extensions/forwarders**: - EngineMessage.engineMedia, EngineMessage.enginePeers, EngineMessage.adAttribute, EngineMessage.effectivelyIncoming - engineFileSize forwarder - TelegramEngine.Resources.clearCachedMediaResources(mediaResourceIds: Set<EngineMediaResource.Id>) - TelegramEngine.Resources.fetchStatus(id:resourceSize:) - TelegramEngineUnauthorized.UnauthorizedResources facade with storeResourceData **Public API/struct migrations to engine types**: - ChatAvailableMessageActions.banAuthor/banAuthors → EnginePeer?/[EnginePeer] - WebSessionsContextState.peers → [EnginePeer.Id: EnginePeer] - CacheUsageStats.peers → [EnginePeer.Id: EnginePeer] - PeerCommand.peer → EnginePeer - PeerInfoControllerMode.calls(messages:) → [EngineMessage] - CallControllerNodeProtocol.updatePeer → EnginePeer params - ChatHistoryListNode.messageInCurrentHistoryView (and 4 variants) → EngineMessage? - ChatHistorySearchContainerNode.messageForGallery → EngineMessage? - PeerInfoPaneNode.findLoadedMessage / ensureMessageIsVisible / transitionNodeForGallery → engine-typed - GalleryHiddenMediaTarget.getTransitionInfo / GalleryHiddenMediaManager.findTarget → engine-typed - ChatPanelInterfaceInteraction.presentReactionDeletionOptions / presentBan*MessageOptions → EnginePeer - DrawingMessageRenderer.messages → [EngineMessage] - ChatVideoGalleryItemScrubberView.setFetchStatusSignal → EngineMediaResource.FetchStatus - ChannelDiscussionGroupActionSheetItem.peer, VoiceChatPeerEntry.peer, VoiceChatFullscreenParticipantItem.peer, MediaStreamComponent.chatPeer, MediaStreamVideoComponent.callPeer, ChatMessageContactBubbleContentNode.contactPeer, ChatMessageForwardInfoNode.peer, ChatMessageCommentFooterContentNode.replyPeers, ChatReportPeerTitlePanelNode.peer, ChatMessageActionUrlAuthController.bot, PeerMediaCollectionInterfaceState.peer, ChatMessageCallBubbleContentNode.peopleAvatars, ChatLoadingNode.renderedPeer (→ EngineRenderedPeer) — all to engine types **Wave-71-shadow stored-field migrations** (Postbox Peer/Message → Engine wrapper): - LegacyCallControllerNode.peer - CallStatusBarNode.currentPeer **Dead-code / dead-field removals**: - CallController.peer, CallControllerNodeV2.account, ContactMultiselectionController PeerNameIndex fields, preparedChatListNodeViewTransition account: Account param, FetchResource.swift entirely (unused function) **Module-level Postbox import drops**: 30+ files including TelegramRootController, EditStories, GiftViewScreen, AnimatedStickerUtils, FetchPhotoLibraryImageResource, PeerInfoGiftsPaneNode, PeerInfoPaneContainerNode, PresentAddMembers, PeerInfoProfileItems, ChatControllerAdminBanUsers, PresentationData typealiases, DefaultDayPresentationTheme, ChatListViewTransition, GalleryHiddenMediaManager, RecentSessionsController, GifContext, AuthorizationSequenceController, PeerInfoHeaderEditingContentNode, PeerInfoHeaderNode, PeerAllowedReactionListController, CallControllerNodeV2, and 6 PeerInfo pane files. **AnyObject restoration**: rule 8 added (never substitute Postbox protocols with Any/AnyObject) — undid previous AnyObject substitutions in waves 141/143 back to EngineMedia. Doc maintenance: CLAUDE.md updated to reflect new typealiases and forwarders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
142 lines
3.6 KiB
Swift
142 lines
3.6 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import Postbox
|
|
|
|
public final class TelegramEngine {
|
|
public let account: Account
|
|
|
|
public init(account: Account) {
|
|
self.account = account
|
|
}
|
|
|
|
public lazy var secureId: SecureId = {
|
|
return SecureId(account: self.account)
|
|
}()
|
|
|
|
public lazy var peersNearby: PeersNearby = {
|
|
return PeersNearby(account: self.account)
|
|
}()
|
|
|
|
public lazy var payments: Payments = {
|
|
return Payments(account: self.account)
|
|
}()
|
|
|
|
public lazy var peers: Peers = {
|
|
return Peers(account: self.account)
|
|
}()
|
|
|
|
public lazy var auth: Auth = {
|
|
return Auth(account: self.account)
|
|
}()
|
|
|
|
public lazy var accountData: AccountData = {
|
|
return AccountData(account: self.account)
|
|
}()
|
|
|
|
public lazy var stickers: Stickers = {
|
|
return Stickers(account: self.account)
|
|
}()
|
|
|
|
public lazy var localization: Localization = {
|
|
return Localization(account: self.account)
|
|
}()
|
|
|
|
public lazy var themes: Themes = {
|
|
return Themes(account: self.account)
|
|
}()
|
|
|
|
public lazy var messages: Messages = {
|
|
return Messages(account: self.account)
|
|
}()
|
|
|
|
public lazy var privacy: Privacy = {
|
|
return Privacy(account: self.account)
|
|
}()
|
|
|
|
public lazy var calls: Calls = {
|
|
return Calls(account: self.account)
|
|
}()
|
|
|
|
public lazy var historyImport: HistoryImport = {
|
|
return HistoryImport(postbox: self.account.postbox, network: self.account.network)
|
|
}()
|
|
|
|
public lazy var contacts: Contacts = {
|
|
return Contacts(account: self.account)
|
|
}()
|
|
|
|
public lazy var resources: Resources = {
|
|
return Resources(account: self.account)
|
|
}()
|
|
|
|
public lazy var resolve: Resolve = {
|
|
return Resolve(account: self.account)
|
|
}()
|
|
|
|
public lazy var data: EngineData = {
|
|
return EngineData(accountPeerId: self.account.peerId, postbox: self.account.postbox)
|
|
}()
|
|
|
|
public lazy var orderedLists: OrderedLists = {
|
|
return OrderedLists(account: self.account)
|
|
}()
|
|
|
|
public lazy var itemCache: ItemCache = {
|
|
return ItemCache(account: self.account)
|
|
}()
|
|
|
|
public lazy var notices: Notices = {
|
|
return Notices(account: self.account)
|
|
}()
|
|
|
|
public lazy var preferences: Preferences = {
|
|
return Preferences(account: self.account)
|
|
}()
|
|
}
|
|
|
|
public final class TelegramEngineUnauthorized {
|
|
public let account: UnauthorizedAccount
|
|
|
|
public init(account: UnauthorizedAccount) {
|
|
self.account = account
|
|
}
|
|
|
|
public lazy var auth: Auth = {
|
|
return Auth(account: self.account)
|
|
}()
|
|
|
|
public lazy var localization: Localization = {
|
|
return Localization(account: self.account)
|
|
}()
|
|
|
|
public lazy var payments: Payments = {
|
|
return Payments(account: self.account)
|
|
}()
|
|
|
|
public lazy var resources: UnauthorizedResources = {
|
|
return UnauthorizedResources(account: self.account)
|
|
}()
|
|
|
|
public lazy var itemCache: ItemCache = {
|
|
return ItemCache(account: self.account)
|
|
}()
|
|
}
|
|
|
|
public extension TelegramEngineUnauthorized {
|
|
final class UnauthorizedResources {
|
|
private let account: UnauthorizedAccount
|
|
|
|
init(account: UnauthorizedAccount) {
|
|
self.account = account
|
|
}
|
|
|
|
public func storeResourceData(id: EngineMediaResource.Id, data: Data, synchronous: Bool = false) {
|
|
self.account.postbox.mediaBox.storeResourceData(MediaResourceId(id.stringRepresentation), data: data, synchronous: synchronous)
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum SomeTelegramEngine {
|
|
case unauthorized(TelegramEngineUnauthorized)
|
|
case authorized(TelegramEngine)
|
|
}
|