1import Constants from 'expo-constants'; 2 3/** 4 * The types of update-related events. 5 */ 6export enum UpdateEventType { 7 /** 8 * A new update has finished downloading to local storage. If you would like to start using this 9 * update at any point before the user closes and restarts the app on their own, you can call 10 * [`Updates.reloadAsync()`](#reloadasync) to launch this new update. 11 */ 12 UPDATE_AVAILABLE = 'updateAvailable', 13 /** 14 * No updates are available, and the most up-to-date update is already running. 15 */ 16 NO_UPDATE_AVAILABLE = 'noUpdateAvailable', 17 /** 18 * An error occurred trying to fetch the latest update. 19 */ 20 ERROR = 'error', 21} 22 23// @docsMissing 24// TODO(eric): move source of truth for manifest type to this module 25/** 26 * @hidden 27 */ 28export type ClassicManifest = typeof Constants.manifest; 29 30// @docsMissing 31/** 32 * @hidden 33 */ 34export type Manifest = ClassicManifest | typeof Constants.manifest2; 35// modern manifest type is intentionally not exported, since the plan is to call it just "Manifest" 36// in the future 37 38type UpdateCheckResultRollBackToEmbedded = { 39 /** 40 * Whether an update is available. This property is false for a roll back update. 41 */ 42 isAvailable: false; 43 /** 44 * The manifest of the update when available. 45 */ 46 manifest: undefined; 47 /** 48 * Whether a roll back to embedded update is available. 49 */ 50 isRollBackToEmbedded: true; 51}; 52 53/** 54 * The successful result of checking for a new update. 55 */ 56export type UpdateCheckResultSuccess = { 57 /** 58 * Whether an update is available. This property is false for a roll back update. 59 */ 60 isAvailable: true; 61 /** 62 * The manifest of the update when available. 63 */ 64 manifest: Manifest; 65 /** 66 * Whether a roll back to embedded update is available. 67 */ 68 isRollBackToEmbedded: false; 69}; 70 71/** 72 * The failed result of checking for a new update. 73 */ 74export type UpdateCheckResultFailure = { 75 /** 76 * Whether an update is available. This property is false for a roll back update. 77 */ 78 isAvailable: false; 79 /** 80 * The manifest of the update when available. 81 */ 82 manifest: undefined; 83 /** 84 * Whether a roll back to embedded update is available. 85 */ 86 isRollBackToEmbedded: false; 87}; 88 89/** 90 * The result of checking for a new update. 91 */ 92export type UpdateCheckResult = 93 | UpdateCheckResultRollBackToEmbedded 94 | UpdateCheckResultSuccess 95 | UpdateCheckResultFailure; 96 97/** 98 * The successful result of fetching a new update. 99 */ 100export type UpdateFetchResultSuccess = { 101 /** 102 * Whether the fetched update is new (that is, a different version than what's currently running). 103 * False when roll back to embedded is true. 104 */ 105 isNew: true; 106 /** 107 * The manifest of the fetched update. 108 */ 109 manifest: Manifest; 110 /** 111 * Whether the fetched update is a roll back to the embedded update. 112 */ 113 isRollBackToEmbedded: false; 114}; 115 116/** 117 * The failed result of fetching a new update. 118 */ 119export type UpdateFetchResultFailure = { 120 /** 121 * Whether the fetched update is new (that is, a different version than what's currently running). 122 * False when roll back to embedded is true. 123 */ 124 isNew: false; 125 /** 126 * The manifest of the fetched update. 127 */ 128 manifest: undefined; 129 /** 130 * Whether the fetched update is a roll back to the embedded update. 131 */ 132 isRollBackToEmbedded: false; 133}; 134 135/** 136 * The roll back to embedded result of fetching a new update. 137 */ 138type UpdateFetchResultRollBackToEmbedded = { 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: false; 144 /** 145 * The manifest of the fetched update. 146 */ 147 manifest: undefined; 148 /** 149 * Whether the fetched update is a roll back to the embedded update. 150 */ 151 isRollBackToEmbedded: true; 152}; 153 154/** 155 * The result of fetching a new update. 156 */ 157export type UpdateFetchResult = 158 | UpdateFetchResultSuccess 159 | UpdateFetchResultFailure 160 | UpdateFetchResultRollBackToEmbedded; 161 162/** 163 * An object that is passed into each event listener when an auto-update check occurs. 164 */ 165export type UpdateEvent = { 166 /** 167 * Type of the event. 168 */ 169 type: UpdateEventType; 170 /** 171 * If `type` is `Updates.UpdateEventType.UPDATE_AVAILABLE`, the manifest of the newly downloaded 172 * update, and `undefined` otherwise. 173 */ 174 manifest?: Manifest; 175 /** 176 * If `type` is `Updates.UpdateEventType.ERROR`, the error message, and `undefined` otherwise. 177 */ 178 message?: string; 179}; 180 181/** 182 * An object representing a single log entry from expo-updates logging on the client. 183 */ 184export type UpdatesLogEntry = { 185 /** 186 * The time the log was written, in milliseconds since Jan 1 1970 UTC. 187 */ 188 timestamp: number; 189 /** 190 * The log entry message. 191 */ 192 message: string; 193 /** 194 * One of the defined code values for expo-updates log entries. 195 */ 196 code: UpdatesLogEntryCode; 197 /** 198 * One of the defined log level or severity values. 199 */ 200 level: UpdatesLogEntryLevel; 201 /** 202 * If present, the unique ID of an update associated with this log entry. 203 */ 204 updateId?: string; 205 /** 206 * If present, the unique ID or hash of an asset associated with this log entry. 207 */ 208 assetId?: string; 209 /** 210 * If present, an iOS or Android native stack trace associated with this log entry. 211 */ 212 stacktrace?: string[]; 213}; 214 215/** 216 * The possible code values for expo-updates log entries 217 */ 218export enum UpdatesLogEntryCode { 219 NONE = 'None', 220 NO_UPDATES_AVAILABLE = 'NoUpdatesAvailable', 221 UPDATE_ASSETS_NOT_AVAILABLE = 'UpdateAssetsNotAvailable', 222 UPDATE_SERVER_UNREACHABLE = 'UpdateServerUnreachable', 223 UPDATE_HAS_INVALID_SIGNATURE = 'UpdateHasInvalidSignature', 224 UPDATE_CODE_SIGNING_ERROR = 'UpdateCodeSigningError', 225 UPDATE_FAILED_TO_LOAD = 'UpdateFailedToLoad', 226 ASSETS_FAILED_TO_LOAD = 'AssetsFailedToLoad', 227 JS_RUNTIME_ERROR = 'JSRuntimeError', 228 UNKNOWN = 'Unknown', 229} 230 231/** 232 * The possible log levels for expo-updates log entries 233 */ 234export enum UpdatesLogEntryLevel { 235 TRACE = 'trace', 236 DEBUG = 'debug', 237 INFO = 'info', 238 WARN = 'warn', 239 ERROR = 'error', 240 FATAL = 'fatal', 241} 242 243/** 244 * The possible settings that determine if expo-updates will check for updates on app startup. 245 * 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` 246 */ 247export enum UpdatesCheckAutomaticallyValue { 248 /** 249 * Checks for updates whenever the app is loaded. This is the default setting. 250 */ 251 ON_LOAD = 'ON_LOAD', 252 /** 253 * Only checks for updates when the app starts up after an error recovery. 254 */ 255 ON_ERROR_RECOVERY = 'ON_ERROR_RECOVERY', 256 /** 257 * Only checks for updates when the app starts and has a WiFi connection. 258 */ 259 WIFI_ONLY = 'WIFI_ONLY', 260 /** 261 * Automatic update checks are off, and update checks must be done through the JS API. 262 */ 263 NEVER = 'NEVER', 264} 265 266// @docsMissing 267/** 268 * @hidden 269 */ 270export type LocalAssets = Record<string, string>; 271