expo-updates 0.25.9 → 0.25.11

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,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.25.11 — 2024-05-09
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 0.25.10 — 2024-05-09
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - Fixed loading error when both `expo-dev-client` and `expo-updates` installed but no `runtimeVersion` configured. ([#28662](https://github.com/expo/expo/pull/28662) by [@kudo](https://github.com/kudo))
22
+
13
23
  ## 0.25.9 — 2024-05-07
14
24
 
15
25
  _This version does not introduce any user-facing changes._
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-kapt'
3
3
 
4
4
  group = 'host.exp.exponent'
5
- version = '0.25.9'
5
+ version = '0.25.11'
6
6
 
7
7
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
8
8
  apply from: expoModulesCorePlugin
@@ -48,7 +48,7 @@ android {
48
48
  namespace "expo.modules.updates"
49
49
  defaultConfig {
50
50
  versionCode 31
51
- versionName '0.25.9'
51
+ versionName '0.25.11'
52
52
  consumerProguardFiles("proguard-rules.pro")
53
53
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
54
54
 
@@ -3,6 +3,7 @@ package expo.modules.updates
3
3
  import android.content.Context
4
4
  import android.os.AsyncTask
5
5
  import android.os.Bundle
6
+ import android.util.Log
6
7
  import com.facebook.react.bridge.ReactContext
7
8
  import com.facebook.react.devsupport.interfaces.DevSupportManager
8
9
  import expo.modules.kotlin.AppContext
@@ -114,26 +115,14 @@ class UpdatesDevLauncherController(
114
115
  context: Context,
115
116
  callback: UpdatesInterface.UpdateCallback
116
117
  ) {
117
- if (updatesDirectory == null) {
118
- callback.onFailure(updatesDirectoryException!!)
118
+ val newUpdatesConfiguration: UpdatesConfiguration
119
+ try {
120
+ newUpdatesConfiguration = createUpdatesConfiguration(configuration, context)
121
+ } catch (e: Exception) {
122
+ callback.onFailure(e)
119
123
  return
120
124
  }
121
-
122
- val newUpdatesConfiguration = when (UpdatesConfiguration.getUpdatesConfigurationValidationResult(context, configuration)) {
123
- UpdatesConfigurationValidationResult.VALID -> UpdatesConfiguration(context, configuration)
124
- UpdatesConfigurationValidationResult.INVALID_NOT_ENABLED -> {
125
- callback.onFailure(Exception("Failed to load update: UpdatesConfiguration object is not enabled"))
126
- return
127
- }
128
- UpdatesConfigurationValidationResult.INVALID_MISSING_URL -> {
129
- callback.onFailure(Exception("Failed to load update: UpdatesConfiguration object must include a valid update URL"))
130
- return
131
- }
132
- UpdatesConfigurationValidationResult.INVALID_MISSING_RUNTIME_VERSION -> {
133
- callback.onFailure(Exception("Failed to load update: UpdatesConfiguration object must include a valid runtime version"))
134
- return
135
- }
136
- }
125
+ check(updatesDirectory != null)
137
126
 
138
127
  // since controller is a singleton, save its config so we can reset to it if our request fails
139
128
  previousUpdatesConfiguration = updatesConfiguration
@@ -194,6 +183,36 @@ class UpdatesDevLauncherController(
194
183
  })
195
184
  }
196
185
 
186
+ override fun isValidUpdatesConfiguration(configuration: HashMap<String, Any>, context: Context): Boolean {
187
+ return try {
188
+ createUpdatesConfiguration(configuration, context)
189
+ true
190
+ } catch (e: Exception) {
191
+ Log.e(TAG, "Invalid updates configuration: ${e.localizedMessage}")
192
+ false
193
+ }
194
+ }
195
+
196
+ @Throws(Exception::class)
197
+ private fun createUpdatesConfiguration(configuration: HashMap<String, Any>, context: Context): UpdatesConfiguration {
198
+ if (updatesDirectory == null) {
199
+ throw updatesDirectoryException!!
200
+ }
201
+
202
+ return when (UpdatesConfiguration.getUpdatesConfigurationValidationResult(context, configuration)) {
203
+ UpdatesConfigurationValidationResult.VALID -> UpdatesConfiguration(context, configuration)
204
+ UpdatesConfigurationValidationResult.INVALID_NOT_ENABLED -> {
205
+ throw Exception("Failed to load update: UpdatesConfiguration object is not enabled")
206
+ }
207
+ UpdatesConfigurationValidationResult.INVALID_MISSING_URL -> {
208
+ throw Exception("Failed to load update: UpdatesConfiguration object must include a valid update URL")
209
+ }
210
+ UpdatesConfigurationValidationResult.INVALID_MISSING_RUNTIME_VERSION -> {
211
+ throw Exception("Failed to load update: UpdatesConfiguration object must include a valid runtime version")
212
+ }
213
+ }
214
+ }
215
+
197
216
  private fun setDevelopmentSelectionPolicy() {
198
217
  resetSelectionPolicyToDefault()
199
218
  val currentSelectionPolicy = selectionPolicy
@@ -332,4 +351,8 @@ class UpdatesDevLauncherController(
332
351
  ) {
333
352
  callback.onFailure(NotAvailableInDevClientException("Updates.setExtraParamAsync() is not supported in development builds."))
334
353
  }
354
+
355
+ companion object {
356
+ private val TAG = UpdatesDevLauncherController::class.java.simpleName
357
+ }
335
358
  }
@@ -102,65 +102,11 @@ public final class DevLauncherAppController: NSObject, InternalAppControllerInte
102
102
  success successBlock: @escaping UpdatesUpdateSuccessBlock,
103
103
  error errorBlock: @escaping UpdatesErrorBlock
104
104
  ) {
105
- if let directoryDatabaseException = directoryDatabaseException {
106
- errorBlock(directoryDatabaseException)
107
- return
108
- }
109
-
110
- // swiftlint:disable:next identifier_name
111
- let updatesConfigurationValidationResult = UpdatesConfig.getUpdatesConfigurationValidationResult(mergingOtherDictionary: configuration)
112
- switch updatesConfigurationValidationResult {
113
- case .Valid:
114
- break
115
- case .InvalidNotEnabled:
116
- errorBlock(NSError(
117
- domain: DevLauncherAppController.ErrorDomain,
118
- code: ErrorCode.invalidUpdateURL.rawValue,
119
- userInfo: [
120
- NSLocalizedDescriptionKey: "Failed to read stored updates: configuration object is not enabled"
121
- ]
122
- ))
123
- return
124
- case .InvalidPlistError:
125
- errorBlock(NSError(
126
- domain: DevLauncherAppController.ErrorDomain,
127
- code: ErrorCode.invalidUpdateURL.rawValue,
128
- userInfo: [
129
- NSLocalizedDescriptionKey: "Failed to read stored updates: invalid Expo.plist"
130
- ]
131
- ))
132
- return
133
- case .InvalidMissingURL:
134
- errorBlock(NSError(
135
- domain: DevLauncherAppController.ErrorDomain,
136
- code: ErrorCode.invalidUpdateURL.rawValue,
137
- userInfo: [
138
- NSLocalizedDescriptionKey: "Failed to read stored updates: configuration object must include a valid update URL"
139
- ]
140
- ))
141
- return
142
- case .InvalidMissingRuntimeVersion:
143
- errorBlock(NSError(
144
- domain: DevLauncherAppController.ErrorDomain,
145
- code: ErrorCode.invalidUpdateURL.rawValue,
146
- userInfo: [
147
- NSLocalizedDescriptionKey: "Failed to read stored updates: configuration object must include a valid runtime version"
148
- ]
149
- ))
150
- return
151
- }
152
-
153
- var updatesConfiguration: UpdatesConfig
105
+ let updatesConfiguration: UpdatesConfig
154
106
  do {
155
- updatesConfiguration = try UpdatesConfig.configWithExpoPlist(mergingOtherDictionary: configuration)
156
- } catch {
157
- errorBlock(NSError(
158
- domain: DevLauncherAppController.ErrorDomain,
159
- code: ErrorCode.configFailed.rawValue,
160
- userInfo: [
161
- NSLocalizedDescriptionKey: "Cannot load configuration from Expo.plist. Please ensure you've followed the setup and installation instructions for expo-updates to create Expo.plist and add it to your Xcode project."
162
- ]
163
- ))
107
+ updatesConfiguration = try createUpdatesConfiguration(configuration)
108
+ } catch let error {
109
+ errorBlock(error)
164
110
  return
165
111
  }
166
112
 
@@ -213,6 +159,16 @@ public final class DevLauncherAppController: NSObject, InternalAppControllerInte
213
159
  }
214
160
  }
215
161
 
162
+ public func isValidUpdatesConfiguration(_ configuration: [String: Any]) -> Bool {
163
+ do {
164
+ try createUpdatesConfiguration(configuration)
165
+ return true
166
+ } catch let error {
167
+ NSLog("Invalid updates configuration: %@", error.localizedDescription)
168
+ }
169
+ return false
170
+ }
171
+
216
172
  public func selectionPolicy() -> SelectionPolicy {
217
173
  if _selectionPolicy == nil {
218
174
  _selectionPolicy = defaultSelectionPolicy
@@ -226,6 +182,65 @@ public final class DevLauncherAppController: NSObject, InternalAppControllerInte
226
182
  _selectionPolicy = nil
227
183
  }
228
184
 
185
+ private func createUpdatesConfiguration(_ configuration: [String: Any]) throws -> UpdatesConfig {
186
+ if let directoryDatabaseException = directoryDatabaseException {
187
+ throw directoryDatabaseException
188
+ }
189
+
190
+ // swiftlint:disable:next identifier_name
191
+ let updatesConfigurationValidationResult = UpdatesConfig.getUpdatesConfigurationValidationResult(mergingOtherDictionary: configuration)
192
+ switch updatesConfigurationValidationResult {
193
+ case .Valid:
194
+ break
195
+ case .InvalidNotEnabled:
196
+ throw NSError(
197
+ domain: DevLauncherAppController.ErrorDomain,
198
+ code: ErrorCode.invalidUpdateURL.rawValue,
199
+ userInfo: [
200
+ NSLocalizedDescriptionKey: "Failed to read stored updates: configuration object is not enabled"
201
+ ]
202
+ )
203
+ case .InvalidPlistError:
204
+ throw NSError(
205
+ domain: DevLauncherAppController.ErrorDomain,
206
+ code: ErrorCode.invalidUpdateURL.rawValue,
207
+ userInfo: [
208
+ NSLocalizedDescriptionKey: "Failed to read stored updates: invalid Expo.plist"
209
+ ]
210
+ )
211
+ case .InvalidMissingURL:
212
+ throw NSError(
213
+ domain: DevLauncherAppController.ErrorDomain,
214
+ code: ErrorCode.invalidUpdateURL.rawValue,
215
+ userInfo: [
216
+ NSLocalizedDescriptionKey: "Failed to read stored updates: configuration object must include a valid update URL"
217
+ ]
218
+ )
219
+ case .InvalidMissingRuntimeVersion:
220
+ throw NSError(
221
+ domain: DevLauncherAppController.ErrorDomain,
222
+ code: ErrorCode.invalidUpdateURL.rawValue,
223
+ userInfo: [
224
+ NSLocalizedDescriptionKey: "Failed to read stored updates: configuration object must include a valid runtime version"
225
+ ]
226
+ )
227
+ }
228
+
229
+ let updatesConfiguration: UpdatesConfig
230
+ do {
231
+ updatesConfiguration = try UpdatesConfig.configWithExpoPlist(mergingOtherDictionary: configuration)
232
+ } catch {
233
+ throw NSError(
234
+ domain: DevLauncherAppController.ErrorDomain,
235
+ code: ErrorCode.configFailed.rawValue,
236
+ userInfo: [
237
+ NSLocalizedDescriptionKey: "Cannot load configuration from Expo.plist. Please ensure you've followed the setup and installation instructions for expo-updates to create Expo.plist and add it to your Xcode project."
238
+ ]
239
+ )
240
+ }
241
+ return updatesConfiguration
242
+ }
243
+
229
244
  private func setDevelopmentSelectionPolicy() {
230
245
  resetSelectionPolicyToDefault()
231
246
  let currentSelectionPolicy = selectionPolicy()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-updates",
3
- "version": "0.25.9",
3
+ "version": "0.25.11",
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",
@@ -47,7 +47,7 @@
47
47
  "expo-eas-client": "~0.12.0",
48
48
  "expo-manifests": "~0.14.0",
49
49
  "expo-structured-headers": "~3.8.0",
50
- "expo-updates-interface": "~0.16.0",
50
+ "expo-updates-interface": "~0.16.2",
51
51
  "fast-glob": "^3.3.2",
52
52
  "fbemitter": "^3.0.0",
53
53
  "ignore": "^5.3.1",
@@ -67,5 +67,5 @@
67
67
  "peerDependencies": {
68
68
  "expo": "*"
69
69
  },
70
- "gitHead": "1b95b402af6ec95f885aaf93eedfbfe521c548d9"
70
+ "gitHead": "4e22804b01274792b017515aebf37bb0cee46200"
71
71
  }