Skip to content

Commit f7a41c9

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/hyprland-wayland-color-manager
2 parents a3e9439 + f498b35 commit f7a41c9

5 files changed

Lines changed: 108 additions & 3 deletions

File tree

‎apps/mobile/modules/t3-native-controls/expo-module.config.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"platforms": ["apple", "android"],
33
"apple": {
44
"modules": ["T3NativeControlsModule", "T3KeyboardCommandsModule"],
5-
"appDelegateSubscribers": ["T3WorkspaceOrientationSubscriber"]
5+
"appDelegateSubscribers": [
6+
"T3WorkspaceOrientationSubscriber",
7+
"T3MenuDismissTouchGateSubscriber"
8+
]
69
},
710
"android": {
811
"modules": [
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import ExpoModulesCore
2+
// Brings in `state` and `ignore(_:for:)` for the gate and React Native's touch handler.
3+
import UIKit.UIGestureRecognizerSubclass
4+
5+
/// Keeps the tap that dismisses a native menu from also pressing the React Native view under it.
6+
///
7+
/// UIKit passes that tap through the menu's window-level container and only holds it back from
8+
/// UIResponder touches, so React Native's surface touch handler still delivers a full press
9+
/// (react-native#58983). Adapted from expo-modules-core's SystemMenuTouchGate (MIT), which Expo
10+
/// installs only on windows hosting SwiftUI views; this covers MenuView buttons and header menus.
11+
final class T3MenuDismissTouchGate: UIGestureRecognizer, UIGestureRecognizerDelegate {
12+
static func install(in window: UIWindow) {
13+
guard !(window.gestureRecognizers ?? []).contains(where: { $0 is T3MenuDismissTouchGate }) else {
14+
return
15+
}
16+
window.addGestureRecognizer(T3MenuDismissTouchGate())
17+
}
18+
19+
private init() {
20+
super.init(target: nil, action: nil)
21+
// Never hold a touch back, and never give React Native's handler a reason to cancel.
22+
delaysTouchesEnded = false
23+
cancelsTouchesInView = false
24+
delegate = self
25+
}
26+
27+
// UIKit asks this before delivering the event's touches to any recognizer, so an ignored touch
28+
// never reaches JS as touchStart, pressIn, or press.
29+
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive event: UIEvent) -> Bool {
30+
if let touches = event.allTouches {
31+
ignoreSurfaceTouches(touches.filter { $0.phase == .began }, for: event)
32+
}
33+
return true
34+
}
35+
36+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
37+
super.touchesBegan(touches, with: event)
38+
ignoreSurfaceTouches(touches, for: event)
39+
state = .failed
40+
}
41+
42+
private func ignoreSurfaceTouches(_ touches: Set<UITouch>, for event: UIEvent) {
43+
guard let window = view as? UIWindow, window.subviews.contains(where: Self.isOpenMenuContainer) else {
44+
return
45+
}
46+
for touch in touches {
47+
var current = touch.view
48+
while let view = current {
49+
for recognizer in view.gestureRecognizers ?? []
50+
where NSStringFromClass(type(of: recognizer)) == "RCTSurfaceTouchHandler" {
51+
recognizer.ignore(touch, for: event)
52+
}
53+
current = view.superview
54+
}
55+
}
56+
}
57+
58+
// UIKit adds this container to the window while a menu is presented, and turns its interaction
59+
// off once dismissal commits so taps during the dismiss animation reach the app again.
60+
private static func isOpenMenuContainer(_ view: UIView) -> Bool {
61+
view.isUserInteractionEnabled
62+
&& NSStringFromClass(type(of: view)) == "_UI".appending("ContextMenuContainerView")
63+
}
64+
}
65+
66+
/// Installs the menu dismiss gate on every window the app shows.
67+
public final class T3MenuDismissTouchGateSubscriber: ExpoAppDelegateSubscriber {
68+
public func subscriberDidRegister() {
69+
NotificationCenter.default.addObserver(
70+
self,
71+
selector: #selector(windowDidBecomeVisible(_:)),
72+
name: UIWindow.didBecomeVisibleNotification,
73+
object: nil
74+
)
75+
}
76+
77+
@objc private func windowDidBecomeVisible(_ notification: Notification) {
78+
guard let window = notification.object as? UIWindow else { return }
79+
T3MenuDismissTouchGate.install(in: window)
80+
}
81+
}

‎pnpm-workspace.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ allowBuilds:
2121
# Ships N-API prebuilds; its install script only rebuilds from source.
2222
objc-js: false
2323
"react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.10.tgz": true
24-
react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.9.tgz: set this to true or false
2524
sharp: true
2625
tsc-rs: true
2726
utf-8-validate: false

‎scripts/build-desktop-artifact.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
DesktopDmgBackgroundSourceMissingError,
2323
createStageWorkspaceConfig,
2424
createStagePatchedDependencies,
25+
readWorkspaceConfig,
2526
createBuildConfig,
2627
DESKTOP_ELECTRON_LANGUAGES,
2728
DESKTOP_FILE_EXCLUSIONS,
@@ -497,6 +498,25 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
497498
});
498499
});
499500

501+
// pnpm writes "set this to true or false" placeholders into allowBuilds when a
502+
// tarball changes. pnpm ignores them, but the release build decode rejects them.
503+
it.effect("decodes the repo allowBuilds and every file: tarball it names exists", () =>
504+
Effect.gen(function* () {
505+
const fs = yield* FileSystem.FileSystem;
506+
const path = yield* Path.Path;
507+
const { allowBuilds = {} } = yield* readWorkspaceConfig();
508+
const repoRoot = path.join(import.meta.dirname, "..");
509+
for (const key of Object.keys(allowBuilds)) {
510+
const tarball = key.split("@file:")[1];
511+
if (tarball === undefined) continue;
512+
assert.isTrue(
513+
yield* fs.exists(path.join(repoRoot, tarball)),
514+
`allowBuilds names a missing tarball: ${key}`,
515+
);
516+
}
517+
}),
518+
);
519+
500520
it("stages pnpm 11 allowBuilds and patchedDependencies in the workspace yaml", () => {
501521
assert.deepStrictEqual(
502522
createStageWorkspaceConfig({

‎scripts/build-desktop-artifact.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ const encodeJsonString = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknow
111111
const decodeWorkspaceConfig = Schema.decodeEffect(fromYaml(WorkspaceConfig));
112112
const encodeStageWorkspaceConfig = Schema.encodeEffect(fromYaml(StageWorkspaceConfig));
113113

114-
const readWorkspaceConfig = Effect.fn("readWorkspaceConfig")(function* () {
114+
// Decodes the repo's pnpm-workspace.yaml. A PR CI test calls this too, so a bad
115+
// entry fails the PR instead of the nightly desktop build.
116+
export const readWorkspaceConfig = Effect.fn("readWorkspaceConfig")(function* () {
115117
const fs = yield* FileSystem.FileSystem;
116118
const path = yield* Path.Path;
117119
const repoRoot = yield* RepoRoot;

0 commit comments

Comments
 (0)