expo-web-browser 12.2.0 → 12.3.1

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,23 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 12.3.1 — 2023-06-27
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - On `iOS`, fixed crash when opening an invalid URL in the web browser. ([#22986](https://github.com/expo/expo/pull/23084) by [@hirbod](https://github.com/hirbod))
18
+
19
+ ## 12.3.0 — 2023-06-21
20
+
21
+ ### 📚 3rd party library updates
22
+
23
+ - Updated `robolectric` to `4.10`. ([#22395](https://github.com/expo/expo/pull/22395) by [@josephyanks](https://github.com/josephyanks))
24
+
25
+ ### 🐛 Bug fixes
26
+
27
+ - On `iOS` fix browser session being kept alive after view controller is dismissed. ([#22415](https://github.com/expo/expo/pull/22415) by [@alanjhughes](https://github.com/alanjhughes))
28
+ - Fixed Android build warnings for Gradle version 8. ([#22537](https://github.com/expo/expo/pull/22537), [#22609](https://github.com/expo/expo/pull/22609) by [@kudo](https://github.com/kudo))
29
+
13
30
  ## 12.2.0 — 2023-05-08
14
31
 
15
32
  _This version does not introduce any user-facing changes._
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '12.2.0'
6
+ version = '12.3.1'
7
7
 
8
8
 
9
9
  buildscript {
@@ -36,19 +36,11 @@ buildscript {
36
36
  }
37
37
  }
38
38
 
39
- // Creating sources with comments
40
- task androidSourcesJar(type: Jar) {
41
- classifier = 'sources'
42
- from android.sourceSets.main.java.srcDirs
43
- }
44
-
45
39
  afterEvaluate {
46
40
  publishing {
47
41
  publications {
48
42
  release(MavenPublication) {
49
43
  from components.release
50
- // Add additional sourcesJar to artifacts
51
- artifact(androidSourcesJar)
52
44
  }
53
45
  }
54
46
  repositories {
@@ -71,15 +63,21 @@ android {
71
63
  jvmTarget = JavaVersion.VERSION_11.majorVersion
72
64
  }
73
65
 
66
+ namespace "expo.modules.webbrowser"
74
67
  defaultConfig {
75
68
  minSdkVersion safeExtGet("minSdkVersion", 21)
76
69
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
77
70
  versionCode 18
78
- versionName '12.2.0'
71
+ versionName '12.3.1'
79
72
  }
80
73
  lintOptions {
81
74
  abortOnError false
82
75
  }
76
+ publishing {
77
+ singleVariant("release") {
78
+ withSourcesJar()
79
+ }
80
+ }
83
81
  }
84
82
 
85
83
  dependencies {
@@ -93,5 +91,5 @@ dependencies {
93
91
  if (project.findProject(':expo-modules-test-core')) {
94
92
  testImplementation project(':expo-modules-test-core')
95
93
  }
96
- testImplementation "org.robolectric:robolectric:4.3.1"
94
+ testImplementation "org.robolectric:robolectric:4.10"
97
95
  }
@@ -1,6 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="expo.modules.webbrowser">
3
-
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
4
2
  <queries>
5
3
  <intent>
6
4
  <!-- Required for opening tabs if targeting API 30 -->
@@ -7,3 +7,9 @@ final class WebBrowserAlreadyOpenException: Exception {
7
7
  "Another web browser is already open"
8
8
  }
9
9
  }
10
+
11
+ final class WebBrowserInvalidURLException: Exception {
12
+ override var reason: String {
13
+ return "The provided URL is not valid."
14
+ }
15
+ }
@@ -8,21 +8,34 @@ final public class WebBrowserModule: Module {
8
8
  private var currentWebBrowserSession: WebBrowserSession?
9
9
  private var currentAuthSession: WebAuthSession?
10
10
 
11
+ private func isValid(url: URL) -> Bool {
12
+ return url.scheme == "http" || url.scheme == "https"
13
+ }
14
+
11
15
  public func definition() -> ModuleDefinition {
12
16
  Name("ExpoWebBrowser")
13
17
 
14
- AsyncFunction("openBrowserAsync") { (url: URL, options: WebBrowserOptions, promise: Promise) throws in
15
- guard self.currentWebBrowserSession?.isOpen != true else {
18
+ AsyncFunction("openBrowserAsync") { (url: URL, options: WebBrowserOptions, promise: Promise) in
19
+ guard self.currentWebBrowserSession == nil else {
16
20
  throw WebBrowserAlreadyOpenException()
17
21
  }
18
- self.currentWebBrowserSession = WebBrowserSession(url: url, options: options)
19
- self.currentWebBrowserSession?.open(promise)
22
+
23
+ guard self.isValid(url: url) else {
24
+ throw WebBrowserInvalidURLException()
25
+ }
26
+
27
+ self.currentWebBrowserSession = WebBrowserSession(url: url, options: options) { [promise] type in
28
+ promise.resolve(["type": type])
29
+ self.currentWebBrowserSession = nil
30
+ }
31
+
32
+ self.currentWebBrowserSession?.open()
20
33
  }
21
34
  .runOnQueue(.main)
22
35
 
23
36
  AsyncFunction("dismissBrowser") {
24
- self.currentWebBrowserSession?.dismiss()
25
- self.currentWebBrowserSession = nil
37
+ currentWebBrowserSession?.dismiss()
38
+ currentWebBrowserSession = nil
26
39
  }
27
40
  .runOnQueue(.main)
28
41
 
@@ -5,12 +5,11 @@ import ExpoModulesCore
5
5
 
6
6
  internal class WebBrowserSession: NSObject, SFSafariViewControllerDelegate, UIAdaptivePresentationControllerDelegate {
7
7
  let viewController: SFSafariViewController
8
- var promise: Promise?
9
- var isOpen: Bool {
10
- promise != nil
11
- }
8
+ let onDismiss: (String) -> Void
9
+
10
+ init(url: URL, options: WebBrowserOptions, onDismiss: @escaping (String) -> Void) {
11
+ self.onDismiss = onDismiss
12
12
 
13
- init(url: URL, options: WebBrowserOptions) {
14
13
  let configuration = SFSafariViewController.Configuration()
15
14
  configuration.barCollapsingEnabled = options.enableBarCollapsing
16
15
  configuration.entersReaderIfAvailable = options.readerMode
@@ -26,14 +25,12 @@ internal class WebBrowserSession: NSObject, SFSafariViewControllerDelegate, UIAd
26
25
  viewController.presentationController?.delegate = self
27
26
  }
28
27
 
29
- func open(_ promise: Promise) {
28
+ func open() {
30
29
  var currentViewController = UIApplication.shared.keyWindow?.rootViewController
31
30
  while currentViewController?.presentedViewController != nil {
32
31
  currentViewController = currentViewController?.presentedViewController
33
32
  }
34
33
  currentViewController?.present(viewController, animated: true, completion: nil)
35
-
36
- self.promise = promise
37
34
  }
38
35
 
39
36
  func dismiss() {
@@ -57,7 +54,6 @@ internal class WebBrowserSession: NSObject, SFSafariViewControllerDelegate, UIAd
57
54
  // MARK: - Private
58
55
 
59
56
  private func finish(type: String) {
60
- promise?.resolve(["type": type])
61
- promise = nil
57
+ onDismiss(type)
62
58
  }
63
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-web-browser",
3
- "version": "12.2.0",
3
+ "version": "12.3.1",
4
4
  "description": "Provides access to the system's web browser and supports handling redirects. On iOS, it uses SFSafariViewController or SFAuthenticationSession, depending on the method you call, and on Android it uses ChromeCustomTabs. As of iOS 11, SFSafariViewController no longer shares cookies with Safari, so if you are using WebBrowser for authentication you will want to use WebBrowser.openAuthSessionAsync, and if you just want to open a webpage (such as your app privacy policy), then use WebBrowser.openBrowserAsync.",
5
5
  "main": "build/WebBrowser.js",
6
6
  "types": "build/WebBrowser.d.ts",
@@ -45,5 +45,5 @@
45
45
  "peerDependencies": {
46
46
  "expo": "*"
47
47
  },
48
- "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
48
+ "gitHead": "aa6bda733cef821234c77a19bbe6008b72c1c594"
49
49
  }