1import type { Manifest } from './Updates.types'; 2 3/** 4 * Structure encapsulating information on the currently running app 5 * (either the embedded bundle or a downloaded update). 6 */ 7export type CurrentlyRunningInfo = { 8 /** 9 * The UUID that uniquely identifies the currently running update if `expo-updates` is enabled. The 10 * UUID is represented in its canonical string form (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`) and 11 * will always use lowercase letters. In development mode, or any other environment in which 12 * `expo-updates` is disabled, this value is undefined. 13 */ 14 updateId?: string; 15 /** 16 * The channel name of the current build, if configured for use with EAS Update; undefined otherwise. 17 */ 18 channel?: string; 19 /** 20 * If `expo-updates` is enabled, this is a `Date` object representing the creation time of the update 21 * that's currently running (whether it was embedded or downloaded at runtime). 22 * 23 * In development mode, or any other environment in which `expo-updates` is disabled, this value is 24 * undefined. 25 */ 26 createdAt?: Date; 27 /** 28 * This will be true if the currently running update is the one embedded in the build, 29 * and not one downloaded from the updates server. 30 */ 31 isEmbeddedLaunch: boolean; 32 /** 33 * `expo-updates` does its very best to always launch monotonically newer versions of your app so 34 * you don't need to worry about backwards compatibility when you put out an update. In very rare 35 * cases, it's possible that `expo-updates` may need to fall back to the update that's embedded in 36 * the app binary, even after newer updates have been downloaded and run (an "emergency launch"). 37 * This boolean will be `true` if the app is launching under this fallback mechanism and `false` 38 * otherwise. If you are concerned about backwards compatibility of future updates to your app, you 39 * can use this constant to provide special behavior for this rare case. 40 */ 41 isEmergencyLaunch: boolean; 42 /** 43 * If `expo-updates` is enabled, this is the 44 * [manifest](https://docs.expo.dev/versions/latest/sdk/updates/#updatesmanifest) object for the update that's currently 45 * running. 46 * 47 * In development mode, or any other environment in which `expo-updates` is disabled, this object is 48 * empty. 49 */ 50 manifest?: Partial<Manifest>; 51 /** 52 * The runtime version of the current build. 53 */ 54 runtimeVersion?: string; 55}; 56 57/** 58 * The different possible types of updates. 59 * Currently, the only supported type is `UpdateInfoType.NEW`, indicating a new update that can be downloaded and launched 60 * on the device. 61 * In future, other types of updates may be added to this list. 62 */ 63export enum UpdateInfoType { 64 /** 65 * This is the type for new updates found on or downloaded from the update server, that are launchable on the device. 66 */ 67 NEW = 'new', 68} 69 70/** 71 * Structure representing an update. Currently, this is limited to updates of type `UpdateInfoType.NEW`. 72 */ 73export type UpdateInfo = { 74 /** 75 * The type of update. 76 */ 77 type: UpdateInfoType.NEW; 78 /** 79 * For updates of type `UpdateInfoType.NEW`, this is 80 * a string that uniquely identifies the update. For the manifests used in the current Expo Updates protocol (including 81 * EAS Update), this represents the update's UUID in its canonical string form (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`) 82 * and will always use lowercase letters. 83 */ 84 updateId: string; 85 /** 86 * For all types of updates, this is 87 * a `Date` object representing the creation time or commit time of the update. 88 */ 89 createdAt: Date; 90 /** 91 * For updates of type `UpdateInfoType.NEW`, this is 92 * the [manifest](https://docs.expo.dev/versions/latest/sdk/constants/#manifest) for the update. 93 */ 94 manifest: Manifest; 95}; 96 97/** 98 * The structures and methods returned by `useUpdates()`. 99 */ 100export type UseUpdatesReturnType = { 101 /** 102 * Information on the currently running app 103 */ 104 currentlyRunning: CurrentlyRunningInfo; 105 /** 106 * If a new available update has been found, either by using checkForUpdate(), 107 * or by the `UpdateEvent` listener in `useUpdates()`, 108 * this will contain the information for that update. 109 */ 110 availableUpdate?: UpdateInfo; 111 /** 112 * If an available update has been downloaded, this will contain the information 113 * for that update. 114 */ 115 downloadedUpdate?: UpdateInfo; 116 /** 117 * True if a new available update has been found, false otherwise. 118 */ 119 isUpdateAvailable: boolean; 120 /** 121 * True if a new available update is available and has been downloaded. 122 */ 123 isUpdatePending: boolean; 124 /** 125 * True if the app is currently checking for a new available update from the server. 126 */ 127 isChecking: boolean; 128 /** 129 * True if the app is currently downloading an update from the server. 130 */ 131 isDownloading: boolean; 132 /** 133 * If an error is returned from either the startup check for updates, or a call to `checkForUpdateAsync()`, 134 * the error description will appear here. 135 */ 136 checkError?: Error; 137 /** 138 * If an error is returned from either a startup update download, or a call to `fetchUpdateAsync()`, 139 * the error description will appear here. 140 */ 141 downloadError?: Error; 142 /** 143 * If an error occurs during initialization of `useUpdates()`, the error description will appear here. 144 */ 145 initializationError?: Error; 146 /** 147 * A `Date` object representing the last time this client checked for an available update, 148 * or `undefined` if no check has yet occurred since the app started. Does not persist across 149 * app reloads or restarts. 150 */ 151 lastCheckForUpdateTimeSinceRestart?: Date; 152}; 153