@superfan-app/spotify-auth 0.1.43 → 0.1.44

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.
@@ -57,50 +57,68 @@ class SpotifyOAuthView: ExpoView {
57
57
  }
58
58
 
59
59
  private func setupWebView() {
60
+ // Ensure we're on the main thread for UI setup
61
+ guard Thread.isMainThread else {
62
+ DispatchQueue.main.async { [weak self] in
63
+ self?.setupWebView()
64
+ }
65
+ return
66
+ }
67
+
60
68
  // Create a configuration that prevents data persistence
61
- let config = WKWebViewConfiguration()
62
- let prefs = WKWebpagePreferences()
63
- prefs.allowsContentJavaScript = true
64
- config.defaultWebpagePreferences = prefs
65
-
66
- // Ensure cookies and data are not persisted
67
- let dataStore = WKWebsiteDataStore.nonPersistent()
68
- config.websiteDataStore = dataStore
69
-
70
- webView = WKWebView(frame: .zero, configuration: config)
71
- webView.navigationDelegate = self
72
- webView.allowsBackForwardNavigationGestures = true
73
- webView.customUserAgent = "SpotifyAuth-iOS/1.0" // Custom UA to identify our app
74
-
75
- // Add loading indicator
76
- let activityIndicator = UIActivityIndicatorView(style: .medium)
77
- activityIndicator.translatesAutoresizingMaskIntoConstraints = false
78
- activityIndicator.hidesWhenStopped = true
79
-
80
- addSubview(webView)
81
- addSubview(activityIndicator)
82
-
83
- // Setup constraints
84
- webView.translatesAutoresizingMaskIntoConstraints = false
85
- NSLayoutConstraint.activate([
86
- webView.topAnchor.constraint(equalTo: topAnchor),
87
- webView.leadingAnchor.constraint(equalTo: leadingAnchor),
88
- webView.trailingAnchor.constraint(equalTo: trailingAnchor),
89
- webView.bottomAnchor.constraint(equalTo: bottomAnchor),
69
+ let config: WKWebViewConfiguration = {
70
+ let configuration = WKWebViewConfiguration()
71
+ configuration.processPool = WKProcessPool() // Create a new process pool
72
+ let prefs = WKWebpagePreferences()
73
+ prefs.allowsContentJavaScript = true
74
+ configuration.defaultWebpagePreferences = prefs
90
75
 
91
- activityIndicator.centerXAnchor.constraint(equalTo: centerXAnchor),
92
- activityIndicator.centerYAnchor.constraint(equalTo: centerYAnchor)
93
- ])
94
-
95
- // Setup modern KVO observation
96
- observerToken = webView.observe(\.isLoading, options: [.new]) { [weak self] _, _ in
97
- if let activityIndicator = self?.subviews.first(where: { $0 is UIActivityIndicatorView }) as? UIActivityIndicatorView {
98
- if self?.webView.isLoading == true {
99
- activityIndicator.startAnimating()
100
- } else {
101
- activityIndicator.stopAnimating()
76
+ // Ensure cookies and data are not persisted
77
+ let dataStore = WKWebsiteDataStore.nonPersistent()
78
+ configuration.websiteDataStore = dataStore
79
+ return configuration
80
+ }()
81
+
82
+ // Initialize webview on main thread with error handling
83
+ do {
84
+ webView = WKWebView(frame: .zero, configuration: config)
85
+ webView.navigationDelegate = self
86
+ webView.allowsBackForwardNavigationGestures = true
87
+ webView.customUserAgent = "SpotifyAuth-iOS/1.0" // Custom UA to identify our app
88
+
89
+ // Add loading indicator
90
+ let activityIndicator = UIActivityIndicatorView(style: .medium)
91
+ activityIndicator.translatesAutoresizingMaskIntoConstraints = false
92
+ activityIndicator.hidesWhenStopped = true
93
+
94
+ addSubview(webView)
95
+ addSubview(activityIndicator)
96
+
97
+ // Setup constraints
98
+ webView.translatesAutoresizingMaskIntoConstraints = false
99
+ NSLayoutConstraint.activate([
100
+ webView.topAnchor.constraint(equalTo: topAnchor),
101
+ webView.leadingAnchor.constraint(equalTo: leadingAnchor),
102
+ webView.trailingAnchor.constraint(equalTo: trailingAnchor),
103
+ webView.bottomAnchor.constraint(equalTo: bottomAnchor),
104
+
105
+ activityIndicator.centerXAnchor.constraint(equalTo: centerXAnchor),
106
+ activityIndicator.centerYAnchor.constraint(equalTo: centerYAnchor)
107
+ ])
108
+
109
+ // Setup modern KVO observation
110
+ observerToken = webView.observe(\.isLoading, options: [.new]) { [weak self] _, _ in
111
+ if let activityIndicator = self?.subviews.first(where: { $0 is UIActivityIndicatorView }) as? UIActivityIndicatorView {
112
+ if self?.webView.isLoading == true {
113
+ activityIndicator.startAnimating()
114
+ } else {
115
+ activityIndicator.stopAnimating()
116
+ }
102
117
  }
103
118
  }
119
+ } catch {
120
+ secureLog("Failed to setup WebView: \(error.localizedDescription)")
121
+ delegate?.oauthView(self, didFailWithError: SpotifyOAuthError.authorizationError("Failed to initialize web view"))
104
122
  }
105
123
  }
106
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfan-app/spotify-auth",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "description": "Spotify OAuth module for Expo",
5
5
  "main": "src/index.tsx",
6
6
  "types": "build/index.d.ts",