@capgo/capacitor-stream-call 0.0.34 → 0.0.36

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/README.md CHANGED
@@ -6,8 +6,7 @@
6
6
  <h2><a href="https://capgo.app/consulting/?ref=plugin"> Fix your annoying bug now, Hire a Capacitor expert 💪</a></h2>
7
7
  </div>
8
8
 
9
- WIP: We are actively working on this plugin. not yet ready for production.
10
- Uses the https://getstream.io/ SDK to implement calling in Capacitor
9
+ Uses the https://getstream.io/ native SDK to implement calling in Capacitor
11
10
 
12
11
  ## Install
13
12
 
@@ -5,7 +5,10 @@ import WebKit
5
5
  class TouchInterceptView: UIView {
6
6
  private weak var webView: UIView?
7
7
  private weak var overlayView: UIView?
8
- private var touchStartPoint: CGPoint?
8
+ private var forwardTimer: Timer?
9
+ private var lastTouchPoint: CGPoint?
10
+ private let touchThreshold: CGFloat = 5.0 // pixels
11
+ private let timerDelay: TimeInterval = 0.1 // seconds
9
12
 
10
13
  func setupWithWebView(_ webView: UIView, overlayView: UIView) {
11
14
  self.webView = webView
@@ -44,7 +47,6 @@ class TouchInterceptView: UIView {
44
47
  let y = Int(locationInWeb.y)
45
48
  let js = """
46
49
  (() => {
47
- console.log('forwardClickToWeb', \(x), \(y));
48
50
  const x = \(x); const y = \(y);
49
51
  const el = document.elementFromPoint(x, y);
50
52
  if (!el) return 'NO_ELEM';
@@ -77,28 +79,74 @@ class TouchInterceptView: UIView {
77
79
  }
78
80
  }
79
81
 
80
- override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
81
- os_log(.debug, "TouchInterceptView: touchesBegan at %{public}s", String(describing: touches))
82
- if let touch = touches.first {
83
- touchStartPoint = touch.location(in: self)
84
- os_log(.debug, "TouchInterceptView: touchesBegan at %{public}s", String(describing: touchStartPoint))
82
+ override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
83
+ os_log(.debug, "TouchInterceptView: hitTest entry at %{public}s", String(describing: point))
84
+
85
+ // Check if this is same touch location continuing
86
+ if let lastPoint = lastTouchPoint {
87
+ let distance = sqrt(pow(point.x - lastPoint.x, 2) + pow(point.y - lastPoint.y, 2))
88
+ if distance <= touchThreshold {
89
+ // Same touch continuing, cancel existing timer
90
+ forwardTimer?.invalidate()
91
+ os_log(.debug, "TouchInterceptView: Touch continuing at %{public}s, cancelling timer", String(describing: point))
92
+ }
85
93
  }
86
- super.touchesBegan(touches, with: event)
87
- }
88
-
89
- override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
90
- os_log(.debug, "TouchInterceptView: touchesEnded at %{public}s", String(describing: touches))
91
- if let startPoint = touchStartPoint {
92
- os_log(.debug, "TouchInterceptView: touchesEnded - forwarding click to web at %{public}s", String(describing: startPoint))
93
- forwardClickToWeb(at: startPoint)
94
+
95
+ // Store current point and start new timer
96
+ lastTouchPoint = point
97
+ forwardTimer?.invalidate()
98
+ forwardTimer = Timer.scheduledTimer(withTimeInterval: timerDelay, repeats: false) { [weak self] _ in
99
+ os_log(.debug, "TouchInterceptView: Timer fired, forwarding click to web at %{public}s", String(describing: point))
100
+ self?.forwardClickToWeb(at: point)
101
+ }
102
+
103
+ // 1. interactive hit on overlay (including root)
104
+ if let overlayView = self.overlayView, !overlayView.isHidden {
105
+ let overlayPoint = self.convert(point, to: overlayView)
106
+ if let overlayHit = nonGreedyInteractiveHitTest(in: overlayView, point: overlayPoint, with: event) {
107
+ os_log(.debug, "TouchInterceptView: hitTest - Overlay view %{public}s at %{public}s", String(describing: overlayHit), String(describing: overlayPoint))
108
+ return overlayHit
109
+ }
94
110
  }
95
- touchStartPoint = nil
96
- super.touchesEnded(touches, with: event)
111
+ // 2. webView fallback
112
+ if let webView = self.webView {
113
+ let webPoint = self.convert(point, to: webView)
114
+ let result = webView.hitTest(webPoint, with: event)
115
+ os_log(.debug, "TouchInterceptView: hitTest - WebView result %{public}s at %{public}s", String(describing: result), String(describing: webPoint))
116
+ return result
117
+ }
118
+ os_log(.debug, "TouchInterceptView: hitTest - No view found for %{public}s", String(describing: point))
119
+ return nil
97
120
  }
98
121
 
99
- override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
100
- os_log(.debug, "TouchInterceptView: touchesCancelled at %{public}s", String(describing: touches))
101
- touchStartPoint = nil
102
- super.touchesCancelled(touches, with: event)
122
+ override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
123
+ guard let webView = self.webView else {
124
+ os_log(.debug, "TouchInterceptView: point(inside) - webView is nil for point %{public}s. Checking overlay or deferring to super.", String(describing: point))
125
+ if let overlayView = self.overlayView, !overlayView.isHidden {
126
+ let overlayPoint = self.convert(point, to: overlayView)
127
+ let overlayViewConsidersPointInside = overlayView.point(inside: overlayPoint, with: event)
128
+ os_log(.debug, "TouchInterceptView: point(inside) - webView nil. Overlay (%{public}s) for converted point %{public}s = %s", String(describing: overlayViewConsidersPointInside), String(describing: overlayPoint), String(describing: overlayViewConsidersPointInside))
129
+ return overlayViewConsidersPointInside
130
+ }
131
+ return super.point(inside: point, with: event)
132
+ }
133
+
134
+ let webViewPoint = self.convert(point, to: webView)
135
+ let webViewConsidersPointInside = webView.point(inside: webViewPoint, with: event)
136
+
137
+ if let overlayView = self.overlayView, !overlayView.isHidden {
138
+ let overlayPoint = self.convert(point, to: overlayView)
139
+ let overlayViewConsidersPointInside = overlayView.point(inside: overlayPoint, with: event)
140
+ let result = webViewConsidersPointInside || overlayViewConsidersPointInside
141
+ os_log(.debug, "TouchInterceptView: point(inside) - WebView (%{public}s at %{public}s) OR Visible Overlay (%{public}s at %{public}s) for original point %{public}s = %s", String(describing: webViewConsidersPointInside), String(describing: webViewPoint), String(describing: overlayViewConsidersPointInside), String(describing: overlayPoint), String(describing: point), String(describing: result))
142
+ return result
143
+ } else {
144
+ if self.overlayView == nil {
145
+ os_log(.debug, "TouchInterceptView: point(inside) - Overlay nil. WebView (%{public}s at %{public}s) for original point %{public}s = %s", String(describing: webViewConsidersPointInside), String(describing: webViewPoint), String(describing: point), String(describing: webViewConsidersPointInside))
146
+ } else {
147
+ os_log(.debug, "TouchInterceptView: point(inside) - Overlay hidden. WebView (%{public}s at %{public}s) for original point %{public}s = %s", String(describing: webViewConsidersPointInside), String(describing: webViewPoint), String(describing: point), String(describing: webViewConsidersPointInside))
148
+ }
149
+ return webViewConsidersPointInside
150
+ }
103
151
  }
104
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-stream-call",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "Uses the https://getstream.io/ SDK to implement calling in Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",