1import { NewManifest, BareManifest } from 'expo-manifests'; 2 3export type Manifest = NewManifest | BareManifest; 4 5/** 6 * The types of update-related events. 7 */ 8export enum UpdateEventType { 9 /** 10 * A new update has finished downloading to local storage. If you would like to start using this 11 * update at any point before the user closes and restarts the app on their own, you can call 12 * [`Updates.reloadAsync()`](#reloadasync) to launch this new update. 13 */ 14 UPDATE_AVAILABLE = 'updateAvailable', 15 /** 16 * No updates are available, and the most up-to-date update is already running. 17 */ 18 NO_UPDATE_AVAILABLE = 'noUpdateAvailable', 19 /** 20 * An error occurred trying to fetch the latest update. 21 */ 22 ERROR = 'error', 23} 24 25export enum UpdateCheckResultNotAvailableReason { 26 /** 27 * No update manifest or rollback directive received from the update server. 28 */ 29 NO_UPDATE_AVAILABLE_ON_SERVER = 'noUpdateAvailableOnServer', 30 /** 31 * An update manifest was received from the update server, but the update is not launchable, 32 * or does not pass the configured selection policy. 33 */ 34 UPDATE_REJECTED_BY_SELECTION_POLICY = 'updateRejectedBySelectionPolicy', 35 /** 36 * An update manifest was received from the update server, but the update has been previously 37 * launched on this device and never successfully launched. 38 */ 39 UPDATE_PREVIOUSLY_FAILED = 'updatePreviouslyFailed', 40 /** 41 * A rollback directive was received from the update server, but the directive does not pass 42 * the configured selection policy. 43 */ 44 ROLLBACK_REJECTED_BY_SELECTION_POLICY = 'rollbackRejectedBySelectionPolicy', 45 /** 46 * A rollback directive was received from the update server, but this app has no embedded update. 47 */ 48 ROLLBACK_NO_EMBEDDED = 'rollbackNoEmbeddedConfiguration', 49} 50 51/** 52 * The update check result when a rollback directive is received. 53 */ 54export type UpdateCheckResultRollBack = { 55 /** 56 * Whether an update is available. This property is false for a roll back update. 57 */ 58 isAvailable: false; 59 /** 60 * The manifest of the update when available. 61 */ 62 manifest: undefined; 63 /** 64 * Whether a roll back to embedded update is available. 65 */ 66 isRollBackToEmbedded: true; 67 /** 68 * If no new update is found, this contains one of several enum values indicating the reason. 69 */ 70 reason: undefined; 71}; 72 73/** 74 * The update check result when a new update is found on the server. 75 */ 76export type UpdateCheckResultAvailable = { 77 /** 78 * Whether an update is available. This property is false for a roll back update. 79 */ 80 isAvailable: true; 81 /** 82 * The manifest of the update when available. 83 */ 84 manifest: Manifest; 85 /** 86 * Whether a roll back to embedded update is available. 87 */ 88 isRollBackToEmbedded: false; 89 /** 90 * If no new update is found, this contains one of several enum values indicating the reason. 91 */ 92 reason: undefined; 93}; 94 95/** 96 * The update check result if no new update was found. 97 */ 98export type UpdateCheckResultNotAvailable = { 99 /** 100 * Whether an update is available. This property is false for a roll back update. 101 */ 102 isAvailable: false; 103 /** 104 * The manifest of the update when available. 105 */ 106 manifest: undefined; 107 /** 108 * Whether a roll back to embedded update is available. 109 */ 110 isRollBackToEmbedded: false; 111 /** 112 * If no new update is found, this contains one of several enum values indicating the reason. 113 */ 114 reason: UpdateCheckResultNotAvailableReason; 115}; 116 117/** 118 * The result of checking for a new update. 119 */ 120export type UpdateCheckResult = 121 | UpdateCheckResultRollBack 122 | UpdateCheckResultAvailable 123 | UpdateCheckResultNotAvailable; 124 125/** 126 * @deprecated 127 */ 128export type UpdateCheckResultSuccess = UpdateCheckResultAvailable; 129 130/** 131 * @deprecated 132 */ 133export type UpdateCheckResultFailure = UpdateCheckResultNotAvailable; 134 135/** 136 * The successful result of fetching a new update. 137 */ 138export type UpdateFetchResultSuccess = { 139 /** 140 * Whether the fetched update is new (that is, a different version than what's currently running). 141 * False when roll back to embedded is true. 142 */ 143 isNew: true; 144 /** 145 * The manifest of the fetched update. 146 */ 147 manifest: Manifest; 148 /** 149 * Whether the fetched update is a roll back to the embedded update. 150 */ 151 isRollBackToEmbedded: false; 152}; 153 154/** 155 * The failed result of fetching a new update. 156 */ 157export type UpdateFetchResultFailure = { 158 /** 159 * Whether the fetched update is new (that is, a different version than what's currently running). 160 * False when roll back to embedded is true. 161 */ 162 isNew: false; 163 /** 164 * The manifest of the fetched update. 165 */ 166 manifest: undefined; 167 /** 168 * Whether the fetched update is a roll back to the embedded update. 169 */ 170 isRollBackToEmbedded: false; 171}; 172 173/** 174 * The roll back to embedded result of fetching a new update. 175 */ 176type UpdateFetchResultRollBackToEmbedded = { 177 /** 178 * Whether the fetched update is new (that is, a different version than what's currently running). 179 * False when roll back to embedded is true. 180 */ 181 isNew: false; 182 /** 183 * The manifest of the fetched update. 184 */ 185 manifest: undefined; 186 /** 187 * Whether the fetched update is a roll back to the embedded update. 188 */ 189 isRollBackToEmbedded: true; 190}; 191 192/** 193 * The result of fetching a new update. 194 */ 195export type UpdateFetchResult = 196 | UpdateFetchResultSuccess 197 | UpdateFetchResultFailure 198 | UpdateFetchResultRollBackToEmbedded; 199 200/** 201 * An object that is passed into each event listener when an auto-update check occurs. 202 */ 203export type UpdateEvent = { 204 /** 205 * Type of the event. 206 */ 207 type: UpdateEventType; 208 /** 209 * If `type` is `Updates.UpdateEventType.UPDATE_AVAILABLE`, the manifest of the newly downloaded 210 * update, and `undefined` otherwise. 211 */ 212 manifest?: Manifest; 213 /** 214 * If `type` is `Updates.UpdateEventType.ERROR`, the error message, and `undefined` otherwise. 215 */ 216 message?: string; 217}; 218 219/** 220 * An object representing a single log entry from expo-updates logging on the client. 221 */ 222export type UpdatesLogEntry = { 223 /** 224 * The time the log was written, in milliseconds since Jan 1 1970 UTC. 225 */ 226 timestamp: number; 227 /** 228 * The log entry message. 229 */ 230 message: string; 231 /** 232 * One of the defined code values for expo-updates log entries. 233 */ 234 code: UpdatesLogEntryCode; 235 /** 236 * One of the defined log level or severity values. 237 */ 238 level: UpdatesLogEntryLevel; 239 /** 240 * If present, the unique ID of an update associated with this log entry. 241 */ 242 updateId?: string; 243 /** 244 * If present, the unique ID or hash of an asset associated with this log entry. 245 */ 246 assetId?: string; 247 /** 248 * If present, an iOS or Android native stack trace associated with this log entry. 249 */ 250 stacktrace?: string[]; 251}; 252 253/** 254 * The possible code values for expo-updates log entries 255 */ 256export enum UpdatesLogEntryCode { 257 NONE = 'None', 258 NO_UPDATES_AVAILABLE = 'NoUpdatesAvailable', 259 UPDATE_ASSETS_NOT_AVAILABLE = 'UpdateAssetsNotAvailable', 260 UPDATE_SERVER_UNREACHABLE = 'UpdateServerUnreachable', 261 UPDATE_HAS_INVALID_SIGNATURE = 'UpdateHasInvalidSignature', 262 UPDATE_CODE_SIGNING_ERROR = 'UpdateCodeSigningError', 263 UPDATE_FAILED_TO_LOAD = 'UpdateFailedToLoad', 264 ASSETS_FAILED_TO_LOAD = 'AssetsFailedToLoad', 265 JS_RUNTIME_ERROR = 'JSRuntimeError', 266 UNKNOWN = 'Unknown', 267} 268 269/** 270 * The possible log levels for expo-updates log entries 271 */ 272export enum UpdatesLogEntryLevel { 273 TRACE = 'trace', 274 DEBUG = 'debug', 275 INFO = 'info', 276 WARN = 'warn', 277 ERROR = 'error', 278 FATAL = 'fatal', 279} 280 281/** 282 * The possible settings that determine if expo-updates will check for updates on app startup. 283 * By default, Expo will check for updates every time the app is loaded. Set this to `ON_ERROR_RECOVERY` to disable automatic checking unless recovering from an error. Set this to `NEVER` to completely disable automatic checking. Must be one of `ON_LOAD` (default value), `ON_ERROR_RECOVERY`, `WIFI_ONLY`, or `NEVER` 284 */ 285export enum UpdatesCheckAutomaticallyValue { 286 /** 287 * Checks for updates whenever the app is loaded. This is the default setting. 288 */ 289 ON_LOAD = 'ON_LOAD', 290 /** 291 * Only checks for updates when the app starts up after an error recovery. 292 */ 293 ON_ERROR_RECOVERY = 'ON_ERROR_RECOVERY', 294 /** 295 * Only checks for updates when the app starts and has a WiFi connection. 296 */ 297 WIFI_ONLY = 'WIFI_ONLY', 298 /** 299 * Automatic update checks are off, and update checks must be done through the JS API. 300 */ 301 NEVER = 'NEVER', 302} 303 304// @docsMissing 305/** 306 * @hidden 307 */ 308export type LocalAssets = Record<string, string>; 309 310/** 311 * @hidden 312 */ 313export type UpdatesNativeStateRollback = { 314 // ISO date string with the rollback commit time 315 commitTime: string; 316}; 317 318/** 319 * @hidden 320 */ 321export type UpdatesNativeStateMachineContext = { 322 // The native state machine context, either read directly from a native module method, 323 // or received in a state change event. Used internally by this module and not exported publicly. 324 isUpdateAvailable: boolean; 325 isUpdatePending: boolean; 326 isChecking: boolean; 327 isDownloading: boolean; 328 isRestarting: boolean; 329 latestManifest?: Manifest; 330 downloadedManifest?: Manifest; 331 rollback?: UpdatesNativeStateRollback; 332 checkError?: Error; 333 downloadError?: Error; 334 lastCheckForUpdateTime?: Date; 335}; 336 337/** 338 * @hidden 339 */ 340export type UpdatesNativeStateChangeEvent = { 341 // Change event emitted by native 342 context: UpdatesNativeStateMachineContext; 343}; 344