@capgo/capacitor-stream-call 0.0.34 → 0.0.35
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.
|
@@ -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
|
|
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
|
|
81
|
-
os_log(.debug, "TouchInterceptView:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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