@onekeyfe/react-native-native-overlay 6.7.0-61 → 6.7.0-62

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/docs/SPEC.md CHANGED
@@ -347,16 +347,50 @@ not change React ownership. Public APIs, Android/Web, and page scope are unchang
347
347
  first responder; passive toast/debug entries do not win solely by level.
348
348
  Keyboard restoration may finish after dismissal completion; callers/tests
349
349
  requiring keyboard geometry must observe the new keyboard readiness event.
350
- - Removing an entry while the app window has an interactive UIKit presentation
350
+ - Delivered-touch retirement extension (Implemented; thirty native checks and
351
+ four focused local iOS 27.0 App cases passed):
352
+ before showing a global entry, install a passive touch observer on its real
353
+ app window and on the entry window. Active and retired entries of that real
354
+ host share a touch lifetime, including touches delivered to a lower entry or
355
+ the exiting window itself. Other real app windows remain independent, even
356
+ within the same scene. Each observer tracks delivered touch identities, never
357
+ retains UIEvent objects, never cancels or delays touches, and neither prevents
358
+ nor can be prevented by another recognizer. It stays possible until the last
359
+ tracked touch ends or cancels, then fails and resets without recognizing.
360
+ It accepts concurrent touch types with `requiresExclusiveTouchType = false`
361
+ and preserves UIKit's default allowed touch types.
362
+ - Removing an entry while its real app window or any active/retired entry owned
363
+ by that real host has delivered active touches or
364
+ an interactive UIKit presentation
351
365
  removes that entry from active ordering and restores key ownership immediately,
352
- but retains its exiting window/root/scene until the interaction finishes or
353
- cancels. After UIKit reports the interaction change, cleanup runs on the next
354
- main turn and rechecks the current transition coordinator before releasing
366
+ but retains its exiting window/root/scene, without hiding it, until both the
367
+ delivered touch set is empty and the interaction finishes or cancels. Touch
368
+ completion/cancellation and UIKit interaction changes schedule cleanup on the
369
+ next main turn. Cleanup rechecks the complete current touch set and transition
370
+ coordinator before releasing
355
371
  that exact window lifetime. A newly interactive transition keeps it retired
356
372
  until its own completion; repeated or late callbacks cannot release a new
357
- entry for the same owner. Scene disconnect releases active and retired windows
373
+ entry for the same owner. A new touch beginning after a previous touch ends but
374
+ before queued cleanup keeps the window retired. Overlapping multi-touch can
375
+ extend retirement without a timeout. When neither condition exists, removal
376
+ still releases synchronously. Remove an entry observer only when its window
377
+ is released; remove a real app window's observer only when that host has no
378
+ active or retired entries. Touch callbacks query current host ownership across
379
+ scenes, rather than binding to the scene of first installation. Moving the
380
+ same real host to another scene keeps its remaining users protected.
381
+ Reassigning an observed window to a different host does not change its
382
+ delivered touch context: retain weak prior-host associations until a next-turn
383
+ check finds its complete touch set empty and those hosts' retirements released.
384
+ A new touch during an idle gap still protects a prior host whose context remains
385
+ retired. Touch completion, observer removal and host reassignment wake current
386
+ and prior hosts; queued cleanup does not require the source observer to survive.
387
+ Scene disconnect removes that scene's records and unregisters only observers with
388
+ no remaining users before releasing active and retired windows
358
389
  without notifying an already removed owner again. No fixed timeout controls
359
390
  this handoff.
391
+ Key restoration MUST NOT activate a host that has moved to another scene.
392
+ Public UIKit observation cannot account for a DOWN not yet delivered to the
393
+ app window; acceptance must separately exercise that delivery/teardown boundary.
360
394
  - Every presentation lifetime has a generation. Asynchronous present, dismiss,
361
395
  and animation completions must match the generation, controller/entry
362
396
  identity and applicable phase before changing state or emitting callbacks.
@@ -692,10 +726,57 @@ More reopened and a subsequent full drag dismissed normally. Home and Market
692
726
  remained interactive. This checks the main-UI window handoff only; physical
693
727
  devices and the broader runtime matrix remain unverified.
694
728
 
729
+ Historical app-touch acceptance for revision `404e87c` (2026-11-13,
730
+ local Debug build on an isolated
731
+ iOS 27.0 simulator): all eight first-pan-only cases passed, starting from the
732
+ Home header or list body at 250, 300, 350 and 400 ms after More close UP. The
733
+ 250/300 ms cases kept all twenty old-context events routed to the app window;
734
+ 350/400 ms started after teardown (observed 5–49 ms later) and routed all twenty
735
+ new-context events normally. No backing-event-only dispatch occurred. Native
736
+ pager logs recorded ended state 3 in every case. List-body accessibility samples
737
+ continued moving after UP without another input, confirming inertia. After
738
+ waiting for release, the first React control tap opened Home More (header) or
739
+ AccountSelectorStack (body), without another pan or tab switch. Per-case main
740
+ and background runtime markers remained unchanged. These measured teardown
741
+ boundaries do not guarantee observation of a DOWN UIKit has not delivered yet.
742
+
743
+ For the same historical revision, two additional selector handoffs exercised
744
+ multiple front-card drags and a partial rebound, then front dismissal followed
745
+ 250 ms later by either a complete
746
+ back-selector dismissal or a partial drag canceled into rebound. Both preserved
747
+ complete old-context delivery (36 and 16 events respectively), zero backing-only
748
+ events, stable main/background markers, and working direct React controls.
749
+ The entry was the watch-only account-row More inside AccountSelectorStack,
750
+ which uses the same global NativeOverlay UIWindow over a UIKit modal host.
751
+ It is an equivalent-host regression, not a replay of the original three-account
752
+ HD wallet-level menu. Release/TestFlight binaries, physical devices and other
753
+ OS versions remain unverified.
754
+
755
+ Review extension acceptance for `c59572b`: thirty focused native checks passed.
756
+ A rebuilt local Debug App passed first-only header/250 ms and body/300 ms Home
757
+ handoffs with native ended state 3, direct React control actions and stable
758
+ main/background runtime markers. Two further cases used an independently mounted
759
+ passive global entry over Home More. A lower-entry drag received all sixteen
760
+ events in its own context while the upper entry closed; its next React close
761
+ action worked. This does not establish use of the upper entry's context by the
762
+ lower drag. In the exiting-entry case, UIKit delivered DOWN to the upper window,
763
+ restored key ownership to the lower window on close, and delivered UP to the
764
+ same upper window/context 657 ms after native close; the next lower React close
765
+ action worked. Runtime markers stayed stable throughout these four post-recovery
766
+ cases. The earlier nineteen native checks, eight Home cases and two equivalent
767
+ selector handoffs above belong to `404e87c`, not a rerun of the review version.
768
+ The eleven added native groups cover lower/exiting-entry and cross-window touch
769
+ ownership, mixed delivered types, repeated host reassignment, UP/rehost/DOWN and
770
+ coordinator-held idle gaps, projected scene ownership/disconnect, and key scope.
771
+ Mixed-type tests directly deliver synthetic touches and assert observer flags;
772
+ they do not prove physical Pencil input. Scene tests project one real scene into
773
+ controlled manager identity buckets using an internal resolver; they do not prove
774
+ system multi-scene migration. The default resolver remains `ObjectIdentifier(scene)`.
775
+
695
776
  Automated (P0):
696
777
 
697
778
  - `tests/ios/run.sh` compiles the production WindowManager, SheetController and
698
- Animation into an isolated UIKit test app. Its eleven checks cover bounded/live
779
+ Animation into an isolated UIKit test app. Its original nineteen checks cover bounded/live
699
780
  ordering, key restoration eligibility, owning-entry release, injected scene
700
781
  disconnect/reuse with original-window identity and reentrant-registration
701
782
  rejection, conditional original-input focus restoration (including
@@ -705,6 +786,14 @@ Automated (P0):
705
786
  retired, and disconnecting a scene with only a retired window. They use a
706
787
  controlled transition coordinator to test manager lifecycle; the real
707
788
  gesture check is the iOS 27.0 simulator run above.
789
+ Eight app-touch checks directly drive the production observer's
790
+ `touchesBegan`/`touchesEnded`/`touchesCancelled` and reset with synthetic
791
+ touch objects. They assert passive gesture flags, touch-only retirement,
792
+ multi-touch and per-real-window isolation, next-turn touch-set rechecks,
793
+ reset cleanup, conjunction with coordinator ownership, owner/orphan reuse,
794
+ and scene-disconnect callback invalidation. They prove manager lifecycle,
795
+ not UIKit delivery or scroll inertia; those are covered separately by the
796
+ local App runtime checks above, with the stated selector-entry limitation.
708
797
  Sheet checks use `animated: false`; they do not compile the React/Fabric
709
798
  Container or replace Gallery coverage of animated reversal/generation races,
710
799
  real multi-scene/disconnect, keyboard geometry or accessibility.
@@ -147,6 +147,57 @@ protocol NativeOverlayWindowOwner: AnyObject {
147
147
  func overlaySceneDidDisconnect(window: UIWindow)
148
148
  }
149
149
 
150
+ /// Observes delivered window touches without participating in gesture arbitration.
151
+ final class NativeOverlayAppTouchObserver: UIGestureRecognizer {
152
+ var onTouchesFinished: (() -> Void)?
153
+ private var activeTouches = Set<ObjectIdentifier>()
154
+ var hasActiveTouches: Bool { !activeTouches.isEmpty }
155
+
156
+ override init(target: Any?, action: Selector?) {
157
+ super.init(target: target, action: action)
158
+ configure()
159
+ }
160
+
161
+ private func configure() {
162
+ cancelsTouchesInView = false
163
+ delaysTouchesBegan = false
164
+ delaysTouchesEnded = false
165
+ requiresExclusiveTouchType = false
166
+ }
167
+
168
+ override func canPrevent(_ preventedGestureRecognizer: UIGestureRecognizer) -> Bool { false }
169
+ override func canBePrevented(by preventingGestureRecognizer: UIGestureRecognizer) -> Bool { false }
170
+
171
+ override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
172
+ activeTouches.formUnion(touches.map(ObjectIdentifier.init))
173
+ }
174
+
175
+ override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) {}
176
+
177
+ override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
178
+ finish(touches)
179
+ }
180
+
181
+ override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) {
182
+ finish(touches)
183
+ }
184
+
185
+ private func finish(_ touches: Set<UITouch>) {
186
+ let hadTouches = hasActiveTouches
187
+ activeTouches.subtract(touches.map(ObjectIdentifier.init))
188
+ guard hadTouches, !hasActiveTouches else { return }
189
+ state = .failed
190
+ onTouchesFinished?()
191
+ }
192
+
193
+ override func reset() {
194
+ super.reset()
195
+ let hadTouches = hasActiveTouches
196
+ activeTouches.removeAll()
197
+ if hadTouches { onTouchesFinished?() }
198
+ }
199
+ }
200
+
150
201
  final class NativeOverlayWindowManager: NSObject {
151
202
  static let shared = NativeOverlayWindowManager()
152
203
 
@@ -185,12 +236,42 @@ final class NativeOverlayWindowManager: NSObject {
185
236
  }
186
237
  }
187
238
 
239
+ private final class WeakAppWindow {
240
+ weak var window: UIWindow?
241
+ init(_ window: UIWindow) { self.window = window }
242
+ }
243
+
244
+ private final class AppTouchObservation {
245
+ weak var window: UIWindow?
246
+ weak var appWindow: UIWindow?
247
+ let observer: NativeOverlayAppTouchObserver
248
+ var previousAppWindows: [ObjectIdentifier: WeakAppWindow] = [:]
249
+
250
+ var appWindows: [UIWindow] {
251
+ (appWindow.map { [$0] } ?? []) + previousAppWindows.values.compactMap(\.window)
252
+ }
253
+
254
+ init(window: UIWindow, appWindow: UIWindow, observer: NativeOverlayAppTouchObserver) {
255
+ self.window = window
256
+ self.appWindow = appWindow
257
+ self.observer = observer
258
+ }
259
+ }
260
+
188
261
  private var scenes: [ObjectIdentifier: [ObjectIdentifier: Entry]] = [:]
189
262
  private var retiredWindows: [ObjectIdentifier: [ObjectIdentifier: RetiredWindow]] = [:]
263
+ private var appTouchObservations: [ObjectIdentifier: AppTouchObservation] = [:]
190
264
  private var disconnectingScenes = Set<ObjectIdentifier>()
191
265
  private var sequence = 0
266
+ private let sceneIdentity: (UIWindowScene) -> ObjectIdentifier
192
267
 
193
- override init() {
268
+ override convenience init() {
269
+ self.init(sceneIdentity: { ObjectIdentifier($0) })
270
+ }
271
+
272
+ // Internal identity projection lets native tests exercise scene ownership with real windows.
273
+ init(sceneIdentity: @escaping (UIWindowScene) -> ObjectIdentifier) {
274
+ self.sceneIdentity = sceneIdentity
194
275
  super.init()
195
276
  NotificationCenter.default.addObserver(
196
277
  self, selector: #selector(sceneDidDisconnect(_:)),
@@ -198,7 +279,13 @@ final class NativeOverlayWindowManager: NSObject {
198
279
  )
199
280
  }
200
281
 
201
- deinit { NotificationCenter.default.removeObserver(self) }
282
+ deinit {
283
+ NotificationCenter.default.removeObserver(self)
284
+ for observation in appTouchObservations.values {
285
+ observation.observer.onTouchesFinished = nil
286
+ observation.window?.removeGestureRecognizer(observation.observer)
287
+ }
288
+ }
202
289
 
203
290
  /// Every owner has an independent root presenter, shared by no other entry.
204
291
  func window(for owner: NativeOverlayWindowOwner, level: NativeOverlayLevel,
@@ -208,10 +295,11 @@ final class NativeOverlayWindowManager: NSObject {
208
295
  ((hostWindow as? NativeOverlayPassthroughWindow)?.rootViewController
209
296
  as? NativeOverlayRootViewController)?.appWindow ?? hostWindow
210
297
  guard let scene = appWindow.windowScene, scene.activationState != .unattached else { return nil }
211
- let sceneKey = ObjectIdentifier(scene)
298
+ let sceneKey = sceneIdentity(scene)
212
299
  guard !disconnectingScenes.contains(sceneKey) else { return nil }
213
300
  let orphanWindows = (scenes[sceneKey] ?? [:]).values.filter { $0.owner == nil }.map(\.window)
214
301
  orphanWindows.forEach { entryRemoved(from: $0) }
302
+ observeTouches(in: appWindow, appWindow: appWindow)
215
303
  let ownerKey = ObjectIdentifier(owner)
216
304
  var entries = scenes[sceneKey] ?? [:]
217
305
  let entry: Entry
@@ -234,9 +322,11 @@ final class NativeOverlayWindowManager: NSObject {
234
322
  }
235
323
  entry.appWindow = appWindow
236
324
  (entry.window.rootViewController as? NativeOverlayRootViewController)?.appWindow = appWindow
325
+ observeTouches(in: entry.window, appWindow: appWindow)
237
326
  reorder(entries)
238
327
  entry.window.isHidden = false
239
328
  entry.window.rootViewController?.setNeedsStatusBarAppearanceUpdate()
329
+ removeUnusedTouchObservers()
240
330
  return entry.window
241
331
  }
242
332
 
@@ -268,8 +358,8 @@ final class NativeOverlayWindowManager: NSObject {
268
358
  scenes[sceneKey]?[ownerKey] = nil
269
359
  let remaining = scenes[sceneKey] ?? [:]
270
360
  if remaining.isEmpty { scenes[sceneKey] = nil }
271
- if Self.interactiveCoordinator(in: entry.appWindow) != nil {
272
- // Destroying this window context can strand a touch already routed to the app's interactive sheet.
361
+ if hasActiveTouches(in: entry.appWindow) || Self.interactiveCoordinator(in: entry.appWindow) != nil {
362
+ // Keep the routing context until this host's delivered touches and UIKit interactions finish.
273
363
  let retirement = RetiredWindow(window: entry.window, appWindow: entry.appWindow)
274
364
  let windowKey = ObjectIdentifier(entry.window)
275
365
  retiredWindows[sceneKey, default: [:]][windowKey] = retirement
@@ -277,12 +367,14 @@ final class NativeOverlayWindowManager: NSObject {
277
367
  } else {
278
368
  release(entry.window)
279
369
  }
370
+ removeUnusedTouchObservers()
280
371
  reorder(remaining)
281
372
  guard wasKey, let scene,
282
373
  scene.activationState == .foregroundActive || scene.activationState == .foregroundInactive else { return }
283
374
  let next = remaining.values.filter { Self.eligible($0, in: scene) }
284
375
  .max { Self.ordered($0, before: $1) }
285
- (next?.window ?? entry.appWindow)?.makeKey()
376
+ let appWindow = entry.appWindow?.windowScene === scene ? entry.appWindow : nil
377
+ (next?.window ?? appWindow)?.makeKey()
286
378
  }
287
379
 
288
380
  func restoreFocus(_ responder: UIView, in window: UIWindow) -> Bool {
@@ -351,6 +443,92 @@ final class NativeOverlayWindowManager: NSObject {
351
443
  window.windowScene = nil
352
444
  }
353
445
 
446
+ private func observeTouches(in window: UIWindow, appWindow: UIWindow) {
447
+ let windowKey = ObjectIdentifier(window)
448
+ if let observation = appTouchObservations[windowKey] {
449
+ if observation.appWindow !== appWindow, let previous = observation.appWindow {
450
+ // Reparenting does not change the context of an already delivered or queued touch stream.
451
+ if observation.observer.hasActiveTouches || hasRetirements(for: previous) {
452
+ observation.previousAppWindows[ObjectIdentifier(previous)] = WeakAppWindow(previous)
453
+ }
454
+ observation.appWindow = appWindow
455
+ scheduleObservationCleanup(observation, windowKey: windowKey)
456
+ scheduleRetirementCheck(for: previous)
457
+ } else {
458
+ observation.appWindow = appWindow
459
+ }
460
+ return
461
+ }
462
+ let observer = NativeOverlayAppTouchObserver(target: nil, action: nil)
463
+ appTouchObservations[windowKey] = AppTouchObservation(
464
+ window: window, appWindow: appWindow, observer: observer)
465
+ observer.onTouchesFinished = { [weak self, weak window, weak observer] in
466
+ guard let self, let window, let observer,
467
+ let observation = self.appTouchObservations[ObjectIdentifier(window)],
468
+ observation.observer === observer else { return }
469
+ self.scheduleObservationCleanup(observation, windowKey: ObjectIdentifier(window))
470
+ for appWindow in observation.appWindows { self.scheduleRetirementCheck(for: appWindow) }
471
+ }
472
+ window.addGestureRecognizer(observer)
473
+ }
474
+
475
+ private func scheduleObservationCleanup(_ observation: AppTouchObservation, windowKey: ObjectIdentifier) {
476
+ guard !observation.previousAppWindows.isEmpty else { return }
477
+ DispatchQueue.main.async { [weak self, weak observation] in
478
+ guard let self, let observation, self.appTouchObservations[windowKey] === observation,
479
+ !observation.observer.hasActiveTouches else { return }
480
+ self.prunePreviousAppWindows(in: observation)
481
+ }
482
+ }
483
+
484
+ private func prunePreviousAppWindows(in observation: AppTouchObservation) {
485
+ guard !observation.observer.hasActiveTouches else { return }
486
+ // An idle gap does not retire the old context if another touch or transition still owns it.
487
+ observation.previousAppWindows = observation.previousAppWindows.filter {
488
+ $0.value.window.map { hasRetirements(for: $0) } ?? false
489
+ }
490
+ }
491
+
492
+ private func hasRetirements(for appWindow: UIWindow) -> Bool {
493
+ retiredWindows.values.contains { $0.values.contains { $0.appWindow === appWindow } }
494
+ }
495
+
496
+ private func scheduleRetirementCheck(for appWindow: UIWindow?) {
497
+ guard let appWindow, hasRetirements(for: appWindow) else { return }
498
+ DispatchQueue.main.async { [weak self, weak appWindow] in
499
+ guard let self, let appWindow else { return }
500
+ // The source observer may be gone; query current host ownership and all delivered touches.
501
+ for (sceneKey, windows) in self.retiredWindows {
502
+ for (windowKey, retirement) in windows where retirement.appWindow === appWindow {
503
+ self.finishRetirement(retirement, sceneKey: sceneKey, windowKey: windowKey)
504
+ }
505
+ }
506
+ }
507
+ }
508
+
509
+ private func hasActiveTouches(in appWindow: UIWindow?) -> Bool {
510
+ guard let appWindow else { return false }
511
+ return appTouchObservations.values.contains {
512
+ $0.observer.hasActiveTouches && ($0.appWindow === appWindow ||
513
+ $0.previousAppWindows[ObjectIdentifier(appWindow)]?.window === appWindow)
514
+ }
515
+ }
516
+
517
+ private func removeUnusedTouchObservers() {
518
+ for (key, observation) in appTouchObservations {
519
+ prunePreviousAppWindows(in: observation)
520
+ let active = observation.window.map { window in
521
+ scenes.values.contains { $0.values.contains { $0.window === window || $0.appWindow === window } } ||
522
+ retiredWindows.values.contains { $0.values.contains { $0.window === window || $0.appWindow === window } }
523
+ } ?? false
524
+ guard !active else { continue }
525
+ observation.observer.onTouchesFinished = nil
526
+ observation.window?.removeGestureRecognizer(observation.observer)
527
+ appTouchObservations[key] = nil
528
+ for appWindow in observation.appWindows { scheduleRetirementCheck(for: appWindow) }
529
+ }
530
+ }
531
+
354
532
  private static func interactiveCoordinator(in appWindow: UIWindow?) -> UIViewControllerTransitionCoordinator? {
355
533
  var controller = appWindow?.rootViewController
356
534
  while let current = controller {
@@ -365,12 +543,15 @@ final class NativeOverlayWindowManager: NSObject {
365
543
  private func finishRetirement(_ retirement: RetiredWindow, sceneKey: ObjectIdentifier,
366
544
  windowKey: ObjectIdentifier) {
367
545
  guard retiredWindows[sceneKey]?[windowKey] === retirement else { return }
368
- guard let coordinator = Self.interactiveCoordinator(in: retirement.appWindow) else {
546
+ let coordinator = Self.interactiveCoordinator(in: retirement.appWindow)
547
+ if coordinator == nil && !hasActiveTouches(in: retirement.appWindow) {
369
548
  retiredWindows[sceneKey]?[windowKey] = nil
370
549
  if retiredWindows[sceneKey]?.isEmpty == true { retiredWindows[sceneKey] = nil }
371
550
  release(retirement.window)
551
+ removeUnusedTouchObservers()
372
552
  return
373
553
  }
554
+ guard let coordinator else { return }
374
555
  guard retirement.observedCoordinator !== coordinator else { return }
375
556
  retirement.observedCoordinator = coordinator
376
557
  coordinator.notifyWhenInteractionChanges { [weak self, weak retirement] context in
@@ -386,12 +567,13 @@ final class NativeOverlayWindowManager: NSObject {
386
567
  @objc private func sceneDidDisconnect(_ notification: Notification) {
387
568
  precondition(Thread.isMainThread)
388
569
  guard let scene = notification.object as? UIWindowScene else { return }
389
- let sceneKey = ObjectIdentifier(scene)
570
+ let sceneKey = sceneIdentity(scene)
390
571
  let entries = scenes.removeValue(forKey: sceneKey) ?? [:]
391
572
  let retired = retiredWindows.removeValue(forKey: sceneKey) ?? [:]
392
573
  guard !entries.isEmpty || !retired.isEmpty else { return }
393
574
  disconnectingScenes.insert(sceneKey)
394
575
  defer { disconnectingScenes.remove(sceneKey) }
576
+ removeUnusedTouchObservers()
395
577
  // Unregister first: owner callbacks must not restore a disconnected scene's key.
396
578
  for entry in entries.values {
397
579
  entry.owner?.overlaySceneDidDisconnect(window: entry.window)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-overlay",
3
- "version": "6.7.0-61",
3
+ "version": "6.7.0-62",
4
4
  "description": "Native and Web overlay hosts with ordered levels, page scope and Fabric measurement",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",