1 //  Copyright © 2021 650 Industries. All rights reserved.
2 
3 import Foundation
4 
5 public typealias UpdatesErrorBlock = (_ error: Error) -> Void
6 public typealias UpdatesUpdateSuccessBlock = (_ manifest: [String: Any]?) -> Void
7 public typealias UpdatesQuerySuccessBlock = (_ updateIds: [UUID]) -> Void
8 public typealias UpdatesProgressBlock = (_ successfulAssetCount: UInt, _ failedAssetCount: UInt, _ totalAssetCount: UInt) -> Void
9 
10 /**
11  * Called when a manifest has been downloaded. The return value indicates whether or not to
12  * continue downloading the update described by this manifest. Returning `NO` will abort the
13  * load, and the success block will be immediately called with a nil `manifest`.
14  */
15 public typealias UpdatesManifestBlock = (_ manifest: [String: Any]) -> Bool
16 
17 /**
18  * Protocol for modules that depend on expo-updates for loading production updates but do not want
19  * to depend on expo-updates or delegate control to the singleton EXUpdatesAppController.
20  */
21 @objc(EXUpdatesExternalInterface)
22 public protocol UpdatesExternalInterface {
23   @objc weak var bridge: AnyObject? { get set }
24   @objc var launchAssetURL: URL? { get }
25 
resetnull26   @objc func reset()
27 
28   @objc func fetchUpdate(
29     withConfiguration configuration: [String: Any],
30     onManifest manifestBlock: @escaping UpdatesManifestBlock,
31     progress progressBlock: @escaping UpdatesProgressBlock,
32     success successBlock: @escaping UpdatesUpdateSuccessBlock,
33     error errorBlock: @escaping UpdatesErrorBlock
34   )
35 
36   /**
37    * Obtains a list of UUIDs for updates already in the updates DB that are in the READY state.
38    * The success block will pass in the array of UUIDs
39    */
40   @objc func storedUpdateIds(
41     withConfiguration configuration: [String: Any],
42     success successBlock: @escaping UpdatesQuerySuccessBlock,
43     error errorBlock: @escaping UpdatesErrorBlock
44   )
45 }
46