expo-updates 0.16.2 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,21 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.16.3 — 2023-02-22
14
+
15
+ ### 🎉 New features
16
+
17
+ - New `useUpdateEvents` hook. ([#21258](https://github.com/expo/expo/pull/21258) by [@douglowder](https://github.com/douglowder))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - Make Updates API work with native debug. ([#21253](https://github.com/expo/expo/pull/21253) by [@douglowder](https://github.com/douglowder))
22
+
23
+ ### 💡 Others
24
+
25
+ - Break up E2E tests for reliability. ([#21223](https://github.com/expo/expo/pull/21223) by [@douglowder](https://github.com/douglowder))
26
+ - Convert E2E tests to TypeScript. ([#21278](https://github.com/expo/expo/pull/21278) by [@douglowder](https://github.com/douglowder))
27
+
13
28
  ## 0.16.2 — 2023-02-21
14
29
 
15
30
  _This version does not introduce any user-facing changes._
@@ -4,7 +4,7 @@ apply plugin: 'kotlin-kapt'
4
4
  apply plugin: 'maven-publish'
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '0.16.2'
7
+ version = '0.16.3'
8
8
 
9
9
  def ex_updates_native_debug = System.getenv("EX_UPDATES_NATIVE_DEBUG") == "1" ? "true" : "false"
10
10
 
@@ -79,7 +79,7 @@ android {
79
79
  minSdkVersion safeExtGet("minSdkVersion", 21)
80
80
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
81
81
  versionCode 31
82
- versionName '0.16.2'
82
+ versionName '0.16.3'
83
83
  consumerProguardFiles("proguard-rules.pro")
84
84
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
85
85
  buildConfigField("boolean", "EX_UPDATES_NATIVE_DEBUG", ex_updates_native_debug)
@@ -68,6 +68,7 @@ class UpdatesModule(
68
68
  constants["isUsingEmbeddedAssets"] = updatesServiceLocal.isUsingEmbeddedAssets
69
69
  constants["runtimeVersion"] = updatesServiceLocal.configuration.runtimeVersion ?: ""
70
70
  constants["channel"] = updatesServiceLocal.configuration.requestHeaders["expo-channel-name"] ?: ""
71
+ constants["nativeDebug"] = BuildConfig.EX_UPDATES_NATIVE_DEBUG
71
72
 
72
73
  val launchedUpdate = updatesServiceLocal.launchedUpdate
73
74
  if (launchedUpdate != null) {
@@ -140,7 +140,8 @@ export declare function fetchUpdateAsync(): Promise<UpdateFetchResult>;
140
140
  export declare function clearUpdateCacheExperimentalAsync(_sdkVersion?: string): void;
141
141
  /**
142
142
  * Adds a callback to be invoked when updates-related events occur (such as upon the initial app
143
- * load) due to auto-update settings chosen at build-time.
143
+ * load) due to auto-update settings chosen at build-time. See also the
144
+ * [`useUpdateEvents`](#useupdateeventslistener) React hook.
144
145
  *
145
146
  * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance
146
147
  * and should not return any value.
@@ -1 +1 @@
1
- {"version":3,"file":"Updates.d.ts","sourceRoot":"","sources":["../src/Updates.ts"],"names":[],"mappings":"AAMA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG5D,OAAO,EACL,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,cAAc,iBAAiB,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,GAAG,IAGtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAgD,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,GAAG,IAAkC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG,IAAyC,CAAC;AAGhF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAA2C,CAAC;AAEtE;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAg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W,KAAK,IAAI,GAAG,iBAAiB,CAGrF"}
package/build/Updates.js CHANGED
@@ -103,7 +103,7 @@ export async function reloadAsync() {
103
103
  if (!ExpoUpdates.reload) {
104
104
  throw new UnavailabilityError('Updates', 'reloadAsync');
105
105
  }
106
- if (__DEV__ && !isUsingExpoDevelopmentClient) {
106
+ if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingExpoDevelopmentClient)) {
107
107
  throw new CodedError('ERR_UPDATES_DISABLED', `You cannot use the Updates module in development mode in a production app. ${manualUpdatesInstructions}`);
108
108
  }
109
109
  await ExpoUpdates.reload();
@@ -127,7 +127,7 @@ export async function checkForUpdateAsync() {
127
127
  if (!ExpoUpdates.checkForUpdateAsync) {
128
128
  throw new UnavailabilityError('Updates', 'checkForUpdateAsync');
129
129
  }
130
- if (__DEV__ || isUsingDeveloperTool) {
130
+ if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingDeveloperTool)) {
131
131
  throw new CodedError('ERR_UPDATES_DISABLED', `You cannot check for updates in development mode. ${manualUpdatesInstructions}`);
132
132
  }
133
133
  const result = await ExpoUpdates.checkForUpdateAsync();
@@ -183,7 +183,7 @@ export async function fetchUpdateAsync() {
183
183
  if (!ExpoUpdates.fetchUpdateAsync) {
184
184
  throw new UnavailabilityError('Updates', 'fetchUpdateAsync');
185
185
  }
186
- if (__DEV__ || isUsingDeveloperTool) {
186
+ if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingDeveloperTool)) {
187
187
  throw new CodedError('ERR_UPDATES_DISABLED', `You cannot fetch updates in development mode. ${manualUpdatesInstructions}`);
188
188
  }
189
189
  const result = await ExpoUpdates.fetchUpdateAsync();
@@ -223,7 +223,8 @@ function _emitEvent(params) {
223
223
  }
224
224
  /**
225
225
  * Adds a callback to be invoked when updates-related events occur (such as upon the initial app
226
- * load) due to auto-update settings chosen at build-time.
226
+ * load) due to auto-update settings chosen at build-time. See also the
227
+ * [`useUpdateEvents`](#useupdateeventslistener) React hook.
227
228
  *
228
229
  * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance
229
230
  * and should not return any value.
@@ -1 +1 @@
1
- {"version":3,"file":"Updates.js","sourceRoot":"","sources":["../src/Updates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAqB,MAAM,WAAW,CAAC;AAE5D,OAAO,WAAW,MAAM,eAAe,CAAC;AAUxC,cAAc,iBAAiB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GACnB,WAAW,CAAC,QAAQ,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,QAAQ;IAC9D,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,EAAE;IACpC,CAAC,CAAC,IAAI,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAW,WAAW,CAAC,cAAc,IAAI,SAAS,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB,WAAW,CAAC,OAAO,IAAI,IAAI,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,WAAW,CAAC,cAAc,IAAI,IAAI,CAAC;AAEhF,eAAe;AACf;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAgB,WAAW,CAAC,WAAW,IAAI,EAAE,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAY,WAAW,CAAC,iBAAiB,IAAI,KAAK,CAAC;AAEjF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAY,WAAW,CAAC,gBAAgB,IAAI,KAAK,CAAC;AAE/E,eAAe;AACf;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAY,WAAW,CAAC,qBAAqB,IAAI,KAAK,CAAC;AAEzF;;;;;;;GAOG;AACH,MAA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Error,\n} from 'expo-modules-core';\nimport { EventEmitter, EventSubscription } from 'fbemitter';\n\nimport ExpoUpdates from './ExpoUpdates';\nimport {\n LocalAssets,\n Manifest,\n UpdateCheckResult,\n UpdateEvent,\n UpdateFetchResult,\n UpdatesLogEntry,\n} from './Updates.types';\n\nexport * from './Updates.types';\n\n/**\n * The UUID that uniquely identifies the currently running update if `expo-updates` is enabled. The\n * UUID is represented in its canonical string form (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`) and\n * will always use lowercase letters. In development mode, or any other environment in which\n * `expo-updates` is disabled, this value is `null`.\n */\nexport const updateId: string | null =\n ExpoUpdates.updateId && typeof ExpoUpdates.updateId === 'string'\n ? ExpoUpdates.updateId.toLowerCase()\n : null;\n\n/**\n * The name of the release channel currently configured in this standalone or bare app when using\n * classic updates. When using Expo Updates, the value of this field is always `\"default\"`.\n */\nexport const releaseChannel: string = ExpoUpdates.releaseChannel ?? 'default';\n\n/**\n * The channel name of the current build, if configured for use with EAS Update. Null otherwise.\n */\nexport const channel: string | null = ExpoUpdates.channel ?? null;\n\n/**\n * The runtime version of the current build.\n */\nexport const runtimeVersion: string | null = ExpoUpdates.runtimeVersion ?? null;\n\n// @docsMissing\n/**\n * @hidden\n */\nexport const localAssets: LocalAssets = ExpoUpdates.localAssets ?? {};\n\n/**\n * `expo-updates` does its very best to always launch monotonically newer versions of your app so\n * you don't need to worry about backwards compatibility when you put out an update. In very rare\n * cases, it's possible that `expo-updates` may need to fall back to the update that's embedded in\n * the app binary, even after newer updates have been downloaded and run (an \"emergency launch\").\n * This boolean will be `true` if the app is launching under this fallback mechanism and `false`\n * otherwise. If you are concerned about backwards compatibility of future updates to your app, you\n * can use this constant to provide special behavior for this rare case.\n */\nexport const isEmergencyLaunch: boolean = ExpoUpdates.isEmergencyLaunch || false;\n\n/**\n * This will be true if the currently running update is the one embedded in the build,\n * and not one downloaded from the updates server.\n */\nexport const isEmbeddedLaunch: boolean = ExpoUpdates.isEmbeddedLaunch || false;\n\n// @docsMissing\n/**\n * @hidden\n */\nexport const isUsingEmbeddedAssets: boolean = ExpoUpdates.isUsingEmbeddedAssets || false;\n\n/**\n * If `expo-updates` is enabled, this is the\n * [manifest](/workflow/expo-go#manifest) object for the update that's currently\n * running.\n *\n * In development mode, or any other environment in which `expo-updates` is disabled, this object is\n * empty.\n */\nexport const manifest: Partial<Manifest> =\n (ExpoUpdates.manifestString ? JSON.parse(ExpoUpdates.manifestString) : ExpoUpdates.manifest) ??\n {};\n\n/**\n * If `expo-updates` is enabled, this is a `Date` object representing the creation time of the update that's currently running (whether it was embedded or downloaded at runtime).\n *\n * In development mode, or any other environment in which `expo-updates` is disabled, this value is\n * null.\n */\nexport const createdAt: Date | null = ExpoUpdates.commitTime\n ? new Date(ExpoUpdates.commitTime)\n : null;\n\nconst isUsingDeveloperTool = !!(manifest as any).developer?.tool;\nconst isUsingExpoDevelopmentClient = NativeModulesProxy.ExponentConstants?.appOwnership === 'expo';\nconst manualUpdatesInstructions = isUsingExpoDevelopmentClient\n ? 'To test manual updates, publish your project using `expo publish` and open the published ' +\n 'version in this development client.'\n : 'To test manual updates, make a release build with `npm run ios --configuration Release` or ' +\n '`npm run android --variant Release`.';\n\n/**\n * Instructs the app to reload using the most recently downloaded version. This is useful for\n * triggering a newly downloaded update to launch without the user needing to manually restart the\n * app.\n *\n * It is not recommended to place any meaningful logic after a call to `await\n * Updates.reloadAsync()`. This is because the promise is resolved after verifying that the app can\n * be reloaded, and immediately before posting an asynchronous task to the main thread to actually\n * reload the app. It is unsafe to make any assumptions about whether any more JS code will be\n * executed after the `Updates.reloadAsync` method call resolves, since that depends on the OS and\n * the state of the native module and main threads.\n *\n * This method cannot be used in development mode, and the returned promise will be rejected if you\n * try to do so.\n *\n * @return A promise that fulfills right before the reload instruction is sent to the JS runtime, or\n * rejects if it cannot find a reference to the JS runtime. If the promise is rejected in production\n * mode, it most likely means you have installed the module incorrectly. Double check you've\n * followed the installation instructions. In particular, on iOS ensure that you set the `bridge`\n * property on `EXUpdatesAppController` with a pointer to the `RCTBridge` you want to reload, and on\n * Android ensure you either call `UpdatesController.initialize` with the instance of\n * `ReactApplication` you want to reload, or call `UpdatesController.setReactNativeHost` with the\n * proper instance of `ReactNativeHost`.\n */\nexport async function reloadAsync(): Promise<void> {\n if (!ExpoUpdates.reload) {\n throw new UnavailabilityError('Updates', 'reloadAsync');\n }\n if (__DEV__ && !isUsingExpoDevelopmentClient) {\n throw new CodedError(\n 'ERR_UPDATES_DISABLED',\n `You cannot use the Updates module in development mode in a production app. ${manualUpdatesInstructions}`\n );\n }\n await ExpoUpdates.reload();\n}\n\n/**\n * Checks the server to see if a newly deployed update to your project is available. Does not\n * actually download the update. This method cannot be used in development mode, and the returned\n * promise will be rejected if you try to do so.\n *\n * Checking for an update uses a device's bandwidth and battery life like any network call.\n * Additionally, updates served by Expo may be rate limited. A good rule of thumb to check for\n * updates judiciously is to check when the user launches or foregrounds the app. Avoid polling for\n * updates in a frequent loop.\n *\n * @return A promise that fulfills with an [`UpdateCheckResult`](#updatecheckresult) object.\n *\n * The promise rejects if the app is in development mode, or if there is an unexpected error or\n * timeout communicating with the server.\n */\nexport async function checkForUpdateAsync(): Promise<UpdateCheckResult> {\n if (!ExpoUpdates.checkForUpdateAsync) {\n throw new UnavailabilityError('Updates', 'checkForUpdateAsync');\n }\n if (__DEV__ || isUsingDeveloperTool) {\n throw new CodedError(\n 'ERR_UPDATES_DISABLED',\n `You cannot check for updates in development mode. ${manualUpdatesInstructions}`\n );\n }\n\n const result = await ExpoUpdates.checkForUpdateAsync();\n if (result.manifestString) {\n result.manifest = JSON.parse(result.manifestString);\n delete result.manifestString;\n }\n\n return result;\n}\n\n/**\n * Retrieves the most recent expo-updates log entries.\n *\n * @param maxAge Sets the max age of retrieved log entries in milliseconds. Default to 3600000 ms (1 hour).\n *\n * @return A promise that fulfills with an array of [`UpdatesLogEntry`](#updateslogentry) objects;\n *\n * The promise rejects if there is an unexpected error in retrieving the logs.\n */\nexport async function readLogEntriesAsync(maxAge: number = 3600000): Promise<UpdatesLogEntry[]> {\n if (!ExpoUpdates.readLogEntriesAsync) {\n throw new UnavailabilityError('Updates', 'readLogEntriesAsync');\n }\n return await ExpoUpdates.readLogEntriesAsync(maxAge);\n}\n\n/**\n * Clears existing expo-updates log entries.\n *\n * > For now, this operation does nothing on the client. Once log persistence has been\n * > implemented, this operation will actually remove existing logs.\n *\n * @return A promise that fulfills if the clear operation was successful.\n *\n * The promise rejects if there is an unexpected error in clearing the logs.\n *\n */\nexport async function clearLogEntriesAsync(): Promise<void> {\n if (!ExpoUpdates.clearLogEntriesAsync) {\n throw new UnavailabilityError('Updates', 'clearLogEntriesAsync');\n }\n await ExpoUpdates.clearLogEntriesAsync();\n}\n\n/**\n * Downloads the most recently deployed update to your project from server to the device's local\n * storage. This method cannot be used in development mode, and the returned promise will be\n * rejected if you try to do so.\n *\n * @return A promise that fulfills with an [`UpdateFetchResult`](#updatefetchresult) object.\n *\n * The promise rejects if the app is in development mode, or if there is an unexpected error or\n * timeout communicating with the server.\n */\nexport async function fetchUpdateAsync(): Promise<UpdateFetchResult> {\n if (!ExpoUpdates.fetchUpdateAsync) {\n throw new UnavailabilityError('Updates', 'fetchUpdateAsync');\n }\n if (__DEV__ || isUsingDeveloperTool) {\n throw new CodedError(\n 'ERR_UPDATES_DISABLED',\n `You cannot fetch updates in development mode. ${manualUpdatesInstructions}`\n );\n }\n\n const result = await ExpoUpdates.fetchUpdateAsync();\n if (result.manifestString) {\n result.manifest = JSON.parse(result.manifestString);\n delete result.manifestString;\n }\n\n return result;\n}\n\n/**\n * @hidden\n */\nexport function clearUpdateCacheExperimentalAsync(_sdkVersion?: string) {\n console.warn(\n \"This method is no longer necessary. `expo-updates` now automatically deletes your app's old bundle files!\"\n );\n}\n\nlet _emitter: EventEmitter | null;\n\nfunction _getEmitter(): EventEmitter {\n if (!_emitter) {\n _emitter = new EventEmitter();\n RCTDeviceEventEmitter.addListener('Expo.nativeUpdatesEvent', _emitEvent);\n }\n return _emitter;\n}\n\nfunction _emitEvent(params): void {\n let newParams = params;\n if (typeof params === 'string') {\n newParams = JSON.parse(params);\n }\n if (newParams.manifestString) {\n newParams.manifest = JSON.parse(newParams.manifestString);\n delete newParams.manifestString;\n }\n\n if (!_emitter) {\n throw new Error(`EventEmitter must be initialized to use from its listener`);\n }\n _emitter.emit('Expo.updatesEvent', newParams);\n}\n\n/**\n * Adds a callback to be invoked when updates-related events occur (such as upon the initial app\n * load) due to auto-update settings chosen at build-time.\n *\n * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance\n * and should not return any value.\n * @return An `EventSubscription` object on which you can call `remove()` to unsubscribe the\n * listener.\n */\nexport function addListener(listener: (event: UpdateEvent) => void): EventSubscription {\n const emitter = _getEmitter();\n return emitter.addListener('Expo.updatesEvent', listener);\n}\n"]}
1
+ {"version":3,"file":"Updates.js","sourceRoot":"","sources":["../src/Updates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAqB,MAAM,WAAW,CAAC;AAE5D,OAAO,WAAW,MAAM,eAAe,CAAC;AAUxC,cAAc,iBAAiB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GACnB,WAAW,CAAC,QAAQ,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,QAAQ;IAC9D,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,EAAE;IACpC,CAAC,CAAC,IAAI,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAW,WAAW,CAAC,cAAc,IAAI,SAAS,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB,WAAW,CAAC,OAAO,IAAI,IAAI,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,WAAW,CA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I,SAAS,CAAC,cAAc,EAAE;QAC5B,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC1D,OAAO,SAAS,CAAC,cAAc,CAAC;KACjC;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;KAC9E;IACD,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,QAAsC;IAChE,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import {\n RCTDeviceEventEmitter,\n CodedError,\n NativeModulesProxy,\n UnavailabilityError,\n} from 'expo-modules-core';\nimport { EventEmitter, EventSubscription } from 'fbemitter';\n\nimport ExpoUpdates from './ExpoUpdates';\nimport {\n LocalAssets,\n Manifest,\n UpdateCheckResult,\n UpdateEvent,\n UpdateFetchResult,\n UpdatesLogEntry,\n} from './Updates.types';\n\nexport * from './Updates.types';\n\n/**\n * The UUID that uniquely identifies the currently running update if `expo-updates` is enabled. The\n * UUID is represented in its canonical string form (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`) and\n * will always use lowercase letters. In development mode, or any other environment in which\n * `expo-updates` is disabled, this value is `null`.\n */\nexport const updateId: string | null =\n ExpoUpdates.updateId && typeof ExpoUpdates.updateId === 'string'\n ? ExpoUpdates.updateId.toLowerCase()\n : null;\n\n/**\n * The name of the release channel currently configured in this standalone or bare app when using\n * classic updates. When using Expo Updates, the value of this field is always `\"default\"`.\n */\nexport const releaseChannel: string = ExpoUpdates.releaseChannel ?? 'default';\n\n/**\n * The channel name of the current build, if configured for use with EAS Update. Null otherwise.\n */\nexport const channel: string | null = ExpoUpdates.channel ?? null;\n\n/**\n * The runtime version of the current build.\n */\nexport const runtimeVersion: string | null = ExpoUpdates.runtimeVersion ?? null;\n\n// @docsMissing\n/**\n * @hidden\n */\nexport const localAssets: LocalAssets = ExpoUpdates.localAssets ?? {};\n\n/**\n * `expo-updates` does its very best to always launch monotonically newer versions of your app so\n * you don't need to worry about backwards compatibility when you put out an update. In very rare\n * cases, it's possible that `expo-updates` may need to fall back to the update that's embedded in\n * the app binary, even after newer updates have been downloaded and run (an \"emergency launch\").\n * This boolean will be `true` if the app is launching under this fallback mechanism and `false`\n * otherwise. If you are concerned about backwards compatibility of future updates to your app, you\n * can use this constant to provide special behavior for this rare case.\n */\nexport const isEmergencyLaunch: boolean = ExpoUpdates.isEmergencyLaunch || false;\n\n/**\n * This will be true if the currently running update is the one embedded in the build,\n * and not one downloaded from the updates server.\n */\nexport const isEmbeddedLaunch: boolean = ExpoUpdates.isEmbeddedLaunch || false;\n\n// @docsMissing\n/**\n * @hidden\n */\nexport const isUsingEmbeddedAssets: boolean = ExpoUpdates.isUsingEmbeddedAssets || false;\n\n/**\n * If `expo-updates` is enabled, this is the\n * [manifest](/workflow/expo-go#manifest) object for the update that's currently\n * running.\n *\n * In development mode, or any other environment in which `expo-updates` is disabled, this object is\n * empty.\n */\nexport const manifest: Partial<Manifest> =\n (ExpoUpdates.manifestString ? JSON.parse(ExpoUpdates.manifestString) : ExpoUpdates.manifest) ??\n {};\n\n/**\n * If `expo-updates` is enabled, this is a `Date` object representing the creation time of the update that's currently running (whether it was embedded or downloaded at runtime).\n *\n * In development mode, or any other environment in which `expo-updates` is disabled, this value is\n * null.\n */\nexport const createdAt: Date | null = ExpoUpdates.commitTime\n ? new Date(ExpoUpdates.commitTime)\n : null;\n\nconst isUsingDeveloperTool = !!(manifest as any).developer?.tool;\nconst isUsingExpoDevelopmentClient = NativeModulesProxy.ExponentConstants?.appOwnership === 'expo';\nconst manualUpdatesInstructions = isUsingExpoDevelopmentClient\n ? 'To test manual updates, publish your project using `expo publish` and open the published ' +\n 'version in this development client.'\n : 'To test manual updates, make a release build with `npm run ios --configuration Release` or ' +\n '`npm run android --variant Release`.';\n\n/**\n * Instructs the app to reload using the most recently downloaded version. This is useful for\n * triggering a newly downloaded update to launch without the user needing to manually restart the\n * app.\n *\n * It is not recommended to place any meaningful logic after a call to `await\n * Updates.reloadAsync()`. This is because the promise is resolved after verifying that the app can\n * be reloaded, and immediately before posting an asynchronous task to the main thread to actually\n * reload the app. It is unsafe to make any assumptions about whether any more JS code will be\n * executed after the `Updates.reloadAsync` method call resolves, since that depends on the OS and\n * the state of the native module and main threads.\n *\n * This method cannot be used in development mode, and the returned promise will be rejected if you\n * try to do so.\n *\n * @return A promise that fulfills right before the reload instruction is sent to the JS runtime, or\n * rejects if it cannot find a reference to the JS runtime. If the promise is rejected in production\n * mode, it most likely means you have installed the module incorrectly. Double check you've\n * followed the installation instructions. In particular, on iOS ensure that you set the `bridge`\n * property on `EXUpdatesAppController` with a pointer to the `RCTBridge` you want to reload, and on\n * Android ensure you either call `UpdatesController.initialize` with the instance of\n * `ReactApplication` you want to reload, or call `UpdatesController.setReactNativeHost` with the\n * proper instance of `ReactNativeHost`.\n */\nexport async function reloadAsync(): Promise<void> {\n if (!ExpoUpdates.reload) {\n throw new UnavailabilityError('Updates', 'reloadAsync');\n }\n if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingExpoDevelopmentClient)) {\n throw new CodedError(\n 'ERR_UPDATES_DISABLED',\n `You cannot use the Updates module in development mode in a production app. ${manualUpdatesInstructions}`\n );\n }\n await ExpoUpdates.reload();\n}\n\n/**\n * Checks the server to see if a newly deployed update to your project is available. Does not\n * actually download the update. This method cannot be used in development mode, and the returned\n * promise will be rejected if you try to do so.\n *\n * Checking for an update uses a device's bandwidth and battery life like any network call.\n * Additionally, updates served by Expo may be rate limited. A good rule of thumb to check for\n * updates judiciously is to check when the user launches or foregrounds the app. Avoid polling for\n * updates in a frequent loop.\n *\n * @return A promise that fulfills with an [`UpdateCheckResult`](#updatecheckresult) object.\n *\n * The promise rejects if the app is in development mode, or if there is an unexpected error or\n * timeout communicating with the server.\n */\nexport async function checkForUpdateAsync(): Promise<UpdateCheckResult> {\n if (!ExpoUpdates.checkForUpdateAsync) {\n throw new UnavailabilityError('Updates', 'checkForUpdateAsync');\n }\n if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingDeveloperTool)) {\n throw new CodedError(\n 'ERR_UPDATES_DISABLED',\n `You cannot check for updates in development mode. ${manualUpdatesInstructions}`\n );\n }\n\n const result = await ExpoUpdates.checkForUpdateAsync();\n if (result.manifestString) {\n result.manifest = JSON.parse(result.manifestString);\n delete result.manifestString;\n }\n\n return result;\n}\n\n/**\n * Retrieves the most recent expo-updates log entries.\n *\n * @param maxAge Sets the max age of retrieved log entries in milliseconds. Default to 3600000 ms (1 hour).\n *\n * @return A promise that fulfills with an array of [`UpdatesLogEntry`](#updateslogentry) objects;\n *\n * The promise rejects if there is an unexpected error in retrieving the logs.\n */\nexport async function readLogEntriesAsync(maxAge: number = 3600000): Promise<UpdatesLogEntry[]> {\n if (!ExpoUpdates.readLogEntriesAsync) {\n throw new UnavailabilityError('Updates', 'readLogEntriesAsync');\n }\n return await ExpoUpdates.readLogEntriesAsync(maxAge);\n}\n\n/**\n * Clears existing expo-updates log entries.\n *\n * > For now, this operation does nothing on the client. Once log persistence has been\n * > implemented, this operation will actually remove existing logs.\n *\n * @return A promise that fulfills if the clear operation was successful.\n *\n * The promise rejects if there is an unexpected error in clearing the logs.\n *\n */\nexport async function clearLogEntriesAsync(): Promise<void> {\n if (!ExpoUpdates.clearLogEntriesAsync) {\n throw new UnavailabilityError('Updates', 'clearLogEntriesAsync');\n }\n await ExpoUpdates.clearLogEntriesAsync();\n}\n\n/**\n * Downloads the most recently deployed update to your project from server to the device's local\n * storage. This method cannot be used in development mode, and the returned promise will be\n * rejected if you try to do so.\n *\n * @return A promise that fulfills with an [`UpdateFetchResult`](#updatefetchresult) object.\n *\n * The promise rejects if the app is in development mode, or if there is an unexpected error or\n * timeout communicating with the server.\n */\nexport async function fetchUpdateAsync(): Promise<UpdateFetchResult> {\n if (!ExpoUpdates.fetchUpdateAsync) {\n throw new UnavailabilityError('Updates', 'fetchUpdateAsync');\n }\n if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingDeveloperTool)) {\n throw new CodedError(\n 'ERR_UPDATES_DISABLED',\n `You cannot fetch updates in development mode. ${manualUpdatesInstructions}`\n );\n }\n\n const result = await ExpoUpdates.fetchUpdateAsync();\n if (result.manifestString) {\n result.manifest = JSON.parse(result.manifestString);\n delete result.manifestString;\n }\n\n return result;\n}\n\n/**\n * @hidden\n */\nexport function clearUpdateCacheExperimentalAsync(_sdkVersion?: string) {\n console.warn(\n \"This method is no longer necessary. `expo-updates` now automatically deletes your app's old bundle files!\"\n );\n}\n\nlet _emitter: EventEmitter | null;\n\nfunction _getEmitter(): EventEmitter {\n if (!_emitter) {\n _emitter = new EventEmitter();\n RCTDeviceEventEmitter.addListener('Expo.nativeUpdatesEvent', _emitEvent);\n }\n return _emitter;\n}\n\nfunction _emitEvent(params): void {\n let newParams = params;\n if (typeof params === 'string') {\n newParams = JSON.parse(params);\n }\n if (newParams.manifestString) {\n newParams.manifest = JSON.parse(newParams.manifestString);\n delete newParams.manifestString;\n }\n\n if (!_emitter) {\n throw new Error(`EventEmitter must be initialized to use from its listener`);\n }\n _emitter.emit('Expo.updatesEvent', newParams);\n}\n\n/**\n * Adds a callback to be invoked when updates-related events occur (such as upon the initial app\n * load) due to auto-update settings chosen at build-time. See also the\n * [`useUpdateEvents`](#useupdateeventslistener) React hook.\n *\n * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance\n * and should not return any value.\n * @return An `EventSubscription` object on which you can call `remove()` to unsubscribe the\n * listener.\n */\nexport function addListener(listener: (event: UpdateEvent) => void): EventSubscription {\n const emitter = _getEmitter();\n return emitter.addListener('Expo.updatesEvent', listener);\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { UpdateEvent } from './Updates.types';
2
+ /**
3
+ * React hook to create an [`UpdateEvent`](#updateevent) listener subscription on mount, using
4
+ * [`addListener`](#updatesaddlistenerlistener). It calls `remove()` on the subscription during unmount.
5
+ *
6
+ * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance
7
+ * and should not return any value.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * function App() {
12
+ * const eventListener = (event) => {
13
+ * if (event.type === Updates.UpdateEventType.ERROR) {
14
+ * // Handle error
15
+ * } else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) {
16
+ * // Handle no update available
17
+ * } else if (event.type === Updates.UpdateEventType.UPDATE_AVAILABLE) {
18
+ * // Handle update available
19
+ * }
20
+ * };
21
+ * Updates.useUpdateEvents(eventListener);
22
+ * // React Component...
23
+ * }
24
+ * ```
25
+ */
26
+ export declare const useUpdateEvents: (listener: (event: UpdateEvent) => void) => void;
27
+ //# sourceMappingURL=UpdatesHooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpdatesHooks.d.ts","sourceRoot":"","sources":["../src/UpdatesHooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,qBAAsB,WAAW,KAAK,IAAI,SAOrE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { useEffect } from 'react';
2
+ import * as Updates from './Updates';
3
+ /**
4
+ * React hook to create an [`UpdateEvent`](#updateevent) listener subscription on mount, using
5
+ * [`addListener`](#updatesaddlistenerlistener). It calls `remove()` on the subscription during unmount.
6
+ *
7
+ * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance
8
+ * and should not return any value.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * function App() {
13
+ * const eventListener = (event) => {
14
+ * if (event.type === Updates.UpdateEventType.ERROR) {
15
+ * // Handle error
16
+ * } else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) {
17
+ * // Handle no update available
18
+ * } else if (event.type === Updates.UpdateEventType.UPDATE_AVAILABLE) {
19
+ * // Handle update available
20
+ * }
21
+ * };
22
+ * Updates.useUpdateEvents(eventListener);
23
+ * // React Component...
24
+ * }
25
+ * ```
26
+ */
27
+ export const useUpdateEvents = (listener) => {
28
+ useEffect(() => {
29
+ const subscription = Updates.addListener(listener);
30
+ return () => {
31
+ subscription.remove();
32
+ };
33
+ }, []);
34
+ };
35
+ //# sourceMappingURL=UpdatesHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpdatesHooks.js","sourceRoot":"","sources":["../src/UpdatesHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAsC,EAAE,EAAE;IACxE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACnD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nimport * as Updates from './Updates';\nimport { UpdateEvent } from './Updates.types';\n\n/**\n * React hook to create an [`UpdateEvent`](#updateevent) listener subscription on mount, using\n * [`addListener`](#updatesaddlistenerlistener). It calls `remove()` on the subscription during unmount.\n *\n * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance\n * and should not return any value.\n *\n * @example\n * ```ts\n * function App() {\n * const eventListener = (event) => {\n * if (event.type === Updates.UpdateEventType.ERROR) {\n * // Handle error\n * } else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) {\n * // Handle no update available\n * } else if (event.type === Updates.UpdateEventType.UPDATE_AVAILABLE) {\n * // Handle update available\n * }\n * };\n * Updates.useUpdateEvents(eventListener);\n * // React Component...\n * }\n * ```\n */\nexport const useUpdateEvents = (listener: (event: UpdateEvent) => void) => {\n useEffect(() => {\n const subscription = Updates.addListener(listener);\n return () => {\n subscription.remove();\n };\n }, []);\n};\n"]}
package/build/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './Updates';
2
+ export * from './UpdatesHooks';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
package/build/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './Updates';
2
+ export * from './UpdatesHooks';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from './Updates';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './Updates';\nexport * from './UpdatesHooks';\n"]}
@@ -7,6 +7,7 @@
7
7
  #import <EXUpdates/EXUpdatesRemoteAppLoader.h>
8
8
  #import <EXUpdates/EXUpdatesService.h>
9
9
  #import <EXUpdates/EXUpdatesUpdate.h>
10
+ #import <EXUpdates/EXUpdatesUtils.h>
10
11
 
11
12
  #if __has_include(<EXUpdates/EXUpdates-Swift.h>)
12
13
  #import <EXUpdates/EXUpdates-Swift.h>
@@ -81,7 +82,8 @@ EX_EXPORT_MODULE(ExpoUpdates);
81
82
  @"releaseChannel": releaseChannel,
82
83
  @"runtimeVersion": runtimeVersion,
83
84
  @"channel": channel,
84
- @"commitTime": @(commitTime)
85
+ @"commitTime": @(commitTime),
86
+ @"nativeDebug": @([EXUpdatesUtils isNativeDebuggingEnabled])
85
87
  };
86
88
  }
87
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-updates",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Fetches and manages remotely-hosted assets and updates to your app's JS bundle.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -63,5 +63,5 @@
63
63
  "peerDependencies": {
64
64
  "expo": "*"
65
65
  },
66
- "gitHead": "d7ecf4eaf234d2f1100249a2c893a948d47376aa"
66
+ "gitHead": "c0901a95276ad546e13878659eb7e0c0729ba817"
67
67
  }
package/src/Updates.ts CHANGED
@@ -132,7 +132,7 @@ export async function reloadAsync(): Promise<void> {
132
132
  if (!ExpoUpdates.reload) {
133
133
  throw new UnavailabilityError('Updates', 'reloadAsync');
134
134
  }
135
- if (__DEV__ && !isUsingExpoDevelopmentClient) {
135
+ if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingExpoDevelopmentClient)) {
136
136
  throw new CodedError(
137
137
  'ERR_UPDATES_DISABLED',
138
138
  `You cannot use the Updates module in development mode in a production app. ${manualUpdatesInstructions}`
@@ -160,7 +160,7 @@ export async function checkForUpdateAsync(): Promise<UpdateCheckResult> {
160
160
  if (!ExpoUpdates.checkForUpdateAsync) {
161
161
  throw new UnavailabilityError('Updates', 'checkForUpdateAsync');
162
162
  }
163
- if (__DEV__ || isUsingDeveloperTool) {
163
+ if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingDeveloperTool)) {
164
164
  throw new CodedError(
165
165
  'ERR_UPDATES_DISABLED',
166
166
  `You cannot check for updates in development mode. ${manualUpdatesInstructions}`
@@ -224,7 +224,7 @@ export async function fetchUpdateAsync(): Promise<UpdateFetchResult> {
224
224
  if (!ExpoUpdates.fetchUpdateAsync) {
225
225
  throw new UnavailabilityError('Updates', 'fetchUpdateAsync');
226
226
  }
227
- if (__DEV__ || isUsingDeveloperTool) {
227
+ if (!ExpoUpdates?.nativeDebug && (__DEV__ || isUsingDeveloperTool)) {
228
228
  throw new CodedError(
229
229
  'ERR_UPDATES_DISABLED',
230
230
  `You cannot fetch updates in development mode. ${manualUpdatesInstructions}`
@@ -277,7 +277,8 @@ function _emitEvent(params): void {
277
277
 
278
278
  /**
279
279
  * Adds a callback to be invoked when updates-related events occur (such as upon the initial app
280
- * load) due to auto-update settings chosen at build-time.
280
+ * load) due to auto-update settings chosen at build-time. See also the
281
+ * [`useUpdateEvents`](#useupdateeventslistener) React hook.
281
282
  *
282
283
  * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance
283
284
  * and should not return any value.
@@ -0,0 +1,37 @@
1
+ import { useEffect } from 'react';
2
+
3
+ import * as Updates from './Updates';
4
+ import { UpdateEvent } from './Updates.types';
5
+
6
+ /**
7
+ * React hook to create an [`UpdateEvent`](#updateevent) listener subscription on mount, using
8
+ * [`addListener`](#updatesaddlistenerlistener). It calls `remove()` on the subscription during unmount.
9
+ *
10
+ * @param listener A function that will be invoked with an [`UpdateEvent`](#updateevent) instance
11
+ * and should not return any value.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * function App() {
16
+ * const eventListener = (event) => {
17
+ * if (event.type === Updates.UpdateEventType.ERROR) {
18
+ * // Handle error
19
+ * } else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) {
20
+ * // Handle no update available
21
+ * } else if (event.type === Updates.UpdateEventType.UPDATE_AVAILABLE) {
22
+ * // Handle update available
23
+ * }
24
+ * };
25
+ * Updates.useUpdateEvents(eventListener);
26
+ * // React Component...
27
+ * }
28
+ * ```
29
+ */
30
+ export const useUpdateEvents = (listener: (event: UpdateEvent) => void) => {
31
+ useEffect(() => {
32
+ const subscription = Updates.addListener(listener);
33
+ return () => {
34
+ subscription.remove();
35
+ };
36
+ }, []);
37
+ };
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './Updates';
2
+ export * from './UpdatesHooks';