expo-updates 0.18.2 → 0.18.4

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.18.4 — 2023-06-27
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [iOS] Use weak delegate for state machine. ([#23060](https://github.com/expo/expo/pull/23060) by [@wschurman](https://github.com/wschurman))
18
+ - [Android] Convert LoaderTask.RemoteCheckResult to sealed class. ([#23061](https://github.com/expo/expo/pull/23061) by [@wschurman](https://github.com/wschurman))
19
+
20
+ ## 0.18.3 — 2023-06-24
21
+
22
+ ### 🐛 Bug fixes
23
+
24
+ - [Android] fix instrumentation tests. ([#23037](https://github.com/expo/expo/pull/23037) by [@douglowder](https://github.com/douglowder))
25
+ - [iOS] Fix crash when dev-client and updates used together. ([#23070](https://github.com/expo/expo/pull/23070) by [@douglowder](https://github.com/douglowder))
26
+ - [Android] Use sealed class for UpdatesStateEvent. ([#23038](https://github.com/expo/expo/pull/23038) by [@wschurman](https://github.com/wschurman))
27
+
13
28
  ## 0.18.2 — 2023-06-23
14
29
 
15
30
  ### 🐛 Bug fixes
@@ -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.18.2'
7
+ version = '0.18.4'
8
8
 
9
9
  def ex_updates_native_debug = System.getenv("EX_UPDATES_NATIVE_DEBUG") == "1" ? "true" : "false"
10
10
 
@@ -70,7 +70,7 @@ android {
70
70
  minSdkVersion safeExtGet("minSdkVersion", 21)
71
71
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
72
72
  versionCode 31
73
- versionName '0.18.2'
73
+ versionName '0.18.4'
74
74
  consumerProguardFiles("proguard-rules.pro")
75
75
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
76
76
 
@@ -286,13 +286,10 @@ class UpdatesController private constructor(
286
286
  }
287
287
 
288
288
  override fun onRemoteCheckForUpdateFinished(result: LoaderTask.RemoteCheckResult) {
289
- var event: UpdatesStateEvent = UpdatesStateEvent.CheckCompleteUnavailable()
290
- if (result.manifest != null) {
291
- event = UpdatesStateEvent.CheckCompleteWithUpdate(
292
- result.manifest
293
- )
294
- } else if (result.isRollBackToEmbedded == true) {
295
- event = UpdatesStateEvent.CheckCompleteWithRollback()
289
+ val event = when (result) {
290
+ is LoaderTask.RemoteCheckResult.NoUpdateAvailable -> UpdatesStateEvent.CheckCompleteUnavailable()
291
+ is LoaderTask.RemoteCheckResult.UpdateAvailable -> UpdatesStateEvent.CheckCompleteWithUpdate(result.manifest)
292
+ is LoaderTask.RemoteCheckResult.RollBackToEmbedded -> UpdatesStateEvent.CheckCompleteWithRollback()
296
293
  }
297
294
  stateMachine.processEvent(event)
298
295
  }
@@ -52,10 +52,18 @@ class LoaderTask(
52
52
  enum class RemoteUpdateStatus {
53
53
  ERROR, NO_UPDATE_AVAILABLE, UPDATE_AVAILABLE
54
54
  }
55
- data class RemoteCheckResult(
56
- val isRollBackToEmbedded: Boolean? = null,
57
- val manifest: JSONObject? = null
58
- )
55
+
56
+ sealed class RemoteCheckResult(private val status: Status) {
57
+ private enum class Status {
58
+ NO_UPDATE_AVAILABLE,
59
+ UPDATE_AVAILABLE,
60
+ ROLL_BACK_TO_EMBEDDED
61
+ }
62
+
63
+ class NoUpdateAvailable : RemoteCheckResult(Status.NO_UPDATE_AVAILABLE)
64
+ class UpdateAvailable(val manifest: JSONObject) : RemoteCheckResult(Status.UPDATE_AVAILABLE)
65
+ class RollBackToEmbedded : RemoteCheckResult(Status.ROLL_BACK_TO_EMBEDDED)
66
+ }
59
67
 
60
68
  interface LoaderTaskCallback {
61
69
  fun onFailure(e: Exception)
@@ -327,12 +335,12 @@ class LoaderTask(
327
335
  return when (updateDirective) {
328
336
  is UpdateDirective.RollBackToEmbeddedUpdateDirective -> {
329
337
  isUpToDate = true
330
- callback.onRemoteCheckForUpdateFinished(RemoteCheckResult(true, null))
338
+ callback.onRemoteCheckForUpdateFinished(RemoteCheckResult.RollBackToEmbedded())
331
339
  Loader.OnUpdateResponseLoadedResult(shouldDownloadManifestIfPresentInResponse = false)
332
340
  }
333
341
  is UpdateDirective.NoUpdateAvailableUpdateDirective -> {
334
342
  isUpToDate = true
335
- callback.onRemoteCheckForUpdateFinished(RemoteCheckResult())
343
+ callback.onRemoteCheckForUpdateFinished(RemoteCheckResult.NoUpdateAvailable())
336
344
  Loader.OnUpdateResponseLoadedResult(shouldDownloadManifestIfPresentInResponse = false)
337
345
  }
338
346
  }
@@ -341,7 +349,7 @@ class LoaderTask(
341
349
  val updateManifest = updateResponse.manifestUpdateResponsePart?.updateManifest
342
350
  if (updateManifest == null) {
343
351
  isUpToDate = true
344
- callback.onRemoteCheckForUpdateFinished(RemoteCheckResult())
352
+ callback.onRemoteCheckForUpdateFinished(RemoteCheckResult.NoUpdateAvailable())
345
353
  return Loader.OnUpdateResponseLoadedResult(shouldDownloadManifestIfPresentInResponse = false)
346
354
  }
347
355
 
@@ -353,12 +361,12 @@ class LoaderTask(
353
361
  ) {
354
362
  isUpToDate = false
355
363
  callback.onRemoteUpdateManifestResponseManifestLoaded(updateManifest)
356
- callback.onRemoteCheckForUpdateFinished(RemoteCheckResult(null, updateManifest.manifest.getRawJson()))
364
+ callback.onRemoteCheckForUpdateFinished(RemoteCheckResult.UpdateAvailable(updateManifest.manifest.getRawJson()))
357
365
  callback.onRemoteUpdateLoadStarted()
358
366
  Loader.OnUpdateResponseLoadedResult(shouldDownloadManifestIfPresentInResponse = true)
359
367
  } else {
360
368
  isUpToDate = true
361
- callback.onRemoteCheckForUpdateFinished(RemoteCheckResult())
369
+ callback.onRemoteCheckForUpdateFinished(RemoteCheckResult.NoUpdateAvailable())
362
370
  Loader.OnUpdateResponseLoadedResult(shouldDownloadManifestIfPresentInResponse = false)
363
371
  }
364
372
  }
@@ -147,7 +147,7 @@ public final class DevLauncherController: NSObject, UpdatesExternalInterface {
147
147
  let controller = AppController.sharedInstance
148
148
  var updatesConfiguration: UpdatesConfig
149
149
  do {
150
- updatesConfiguration = try UpdatesConfig.configWithExpoPlist(mergingOtherDictionary: nil)
150
+ updatesConfiguration = try UpdatesConfig.configWithExpoPlist(mergingOtherDictionary: configuration as? [String: Any] ?? [:])
151
151
  } catch {
152
152
  errorBlock(NSError(
153
153
  domain: DevLauncherController.ErrorDomain,
@@ -239,3 +239,5 @@ public final class DevLauncherController: NSObject, UpdatesExternalInterface {
239
239
  }
240
240
  }
241
241
  }
242
+
243
+ // swiftlint:enable force_unwrapping
@@ -46,10 +46,10 @@ internal final class LegacyUpdate: Update {
46
46
 
47
47
  var runtimeVersion: String
48
48
  let manifestRuntimeVersion = manifest.runtimeVersion()
49
- if let manifestRuntimeVersion = manifestRuntimeVersion {
50
- runtimeVersion = assertType(value: manifestRuntimeVersion, description: "Manifest JSON runtime version must be string")
49
+ if let manifestRuntimeVersion = manifestRuntimeVersion as? String {
50
+ runtimeVersion = manifestRuntimeVersion
51
51
  } else {
52
- runtimeVersion = manifest.expoGoSDKVersion().require("Manifest JSON must have a valid sdkVersion property defined")
52
+ runtimeVersion = manifest.expoGoSDKVersion().require("Manifest JSON must have either a valid runtimeVersion property or a valid sdkVersion property")
53
53
  }
54
54
 
55
55
  let bundleUrl = URL(string: bundleUrlString).require("Manifest JSON must have a valid URL as the bundleUrl property")
@@ -135,13 +135,13 @@ internal final class LegacyUpdate: Update {
135
135
  // The URL is valid and constant, so it'll never throw
136
136
  // swiftlint:disable:next force_unwrapping
137
137
  return URL(string: EXUpdatesExpoAssetBaseUrl)!
138
- } else {
139
- let assetsPathOrUrl = withManifest.assetUrlOverride() ?? "assets"
140
- // assetUrlOverride may be an absolute or relative URL
141
- // if relative, we should resolve with respect to the manifest URL
142
- return URL(string: assetsPathOrUrl, relativeTo: manifestUrl).require(
143
- "Invalid assetUrlOverride"
144
- ).absoluteURL.standardized
145
138
  }
139
+
140
+ let assetsPathOrUrl = withManifest.assetUrlOverride() ?? "assets"
141
+ // assetUrlOverride may be an absolute or relative URL
142
+ // if relative, we should resolve with respect to the manifest URL
143
+ return URL(string: assetsPathOrUrl, relativeTo: manifestUrl).require(
144
+ "Invalid assetUrlOverride"
145
+ ).absoluteURL.standardized
146
146
  }
147
147
  }
@@ -259,7 +259,7 @@ internal class UpdatesStateMachine {
259
259
  /**
260
260
  In production, this is the AppController instance.
261
261
  */
262
- internal let changeEventDelegate: (any UpdatesStateChangeDelegate)
262
+ private weak var changeEventDelegate: (any UpdatesStateChangeDelegate)?
263
263
 
264
264
  /**
265
265
  The current state
@@ -377,7 +377,7 @@ internal class UpdatesStateMachine {
377
377
  On each state change, all context properties are sent to JS
378
378
  */
379
379
  private func sendChangeEventToJS(_ event: UpdatesStateEvent? = nil) {
380
- changeEventDelegate.sendUpdateStateChangeEventToBridge(event?.type ?? .restart, body: [
380
+ changeEventDelegate?.sendUpdateStateChangeEventToBridge(event?.type ?? .restart, body: [
381
381
  "context": context.json
382
382
  ])
383
383
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-updates",
3
- "version": "0.18.2",
3
+ "version": "0.18.4",
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",
@@ -65,5 +65,5 @@
65
65
  "peerDependencies": {
66
66
  "expo": "*"
67
67
  },
68
- "gitHead": "a72ae33519fe54eaf195dc3e61a49db8345103db"
68
+ "gitHead": "aa6bda733cef821234c77a19bbe6008b72c1c594"
69
69
  }