expo-dev-menu 58.0.10 → 58.0.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Disable the React Native shake gesture with its public API instead of replacing the shake listener through reflection. ([#51130](https://github.com/expo/expo/pull/51130) by [@alanjhughes](https://github.com/alanjhughes))
8
+
3
9
  ## 58.0.10
4
10
 
5
11
  ### Patch Changes
@@ -12,7 +12,7 @@ apply plugin: 'expo-module-gradle-plugin'
12
12
  apply plugin: 'org.jetbrains.kotlin.plugin.compose'
13
13
 
14
14
  group = 'host.exp.exponent'
15
- version = '58.0.10'
15
+ version = '58.0.11'
16
16
 
17
17
  def hasDevLauncher = findProject(":expo-dev-launcher") != null
18
18
  def configureInRelease = findProperty("expo.devmenu.configureInRelease") == "true"
@@ -29,7 +29,7 @@ android {
29
29
 
30
30
  defaultConfig {
31
31
  versionCode 10
32
- versionName '58.0.10'
32
+ versionName '58.0.11'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -17,7 +17,6 @@ import expo.modules.devmenu.GoHomeAction
17
17
  import expo.modules.devmenu.SwitchToComponentAction
18
18
  import expo.modules.devmenu.helpers.getPrivateDeclaredFieldValue
19
19
  import expo.modules.devmenu.helpers.setPrivateDeclaredFieldValue
20
- import expo.modules.devmenu.react.DevMenuShakeDetectorListenerSwapper
21
20
  import expo.modules.devmenu.websockets.DevMenuCommandHandlersProvider
22
21
  import expo.modules.kotlin.weak
23
22
  import java.lang.ref.WeakReference
@@ -89,15 +88,6 @@ object DevMenuApi {
89
88
  }
90
89
 
91
90
  fun uninstallDefaultShakeDetector(devSupportManager: DevSupportManager) {
92
- if (devSupportManager !is DevSupportManagerBase) {
93
- Log.w("DevMenu", "DevSupportManager is not an instance of DevSupportManagerBase. Skipping uninstallation of the default shake detector.")
94
- return
95
- }
96
-
97
- DevMenuShakeDetectorListenerSwapper()
98
- .swapShakeDetectorListener(
99
- devSupportManager,
100
- newListener = {}
101
- )
91
+ devSupportManager.shakeGestureEnabled = false
102
92
  }
103
93
  }
@@ -26,12 +26,3 @@ fun <T> Class<out T>.setPrivateDeclaredFieldValue(filedName: String, obj: T, new
26
26
 
27
27
  field.set(obj, newValue)
28
28
  }
29
-
30
- fun <T> Class<out T>.hasDeclaredField(fieldName: String): Boolean {
31
- return try {
32
- getDeclaredField(fieldName)
33
- true
34
- } catch (_: NoSuchFieldException) {
35
- false
36
- }
37
- }
@@ -0,0 +1,20 @@
1
+ package expo.modules.devmenu.api
2
+
3
+ import com.facebook.react.devsupport.interfaces.DevSupportManager
4
+ import io.mockk.mockk
5
+ import io.mockk.verify
6
+ import org.junit.Test
7
+ import org.junit.runner.RunWith
8
+ import org.robolectric.RobolectricTestRunner
9
+
10
+ @RunWith(RobolectricTestRunner::class)
11
+ internal class DevMenuApiTest {
12
+ @Test
13
+ fun `disables the React Native shake gesture`() {
14
+ val devSupportManager = mockk<DevSupportManager>(relaxed = true)
15
+
16
+ DevMenuApi.uninstallDefaultShakeDetector(devSupportManager)
17
+
18
+ verify { devSupportManager.shakeGestureEnabled = false }
19
+ }
20
+ }
@@ -123,24 +123,5 @@ Pod::Spec.new do |s|
123
123
  }
124
124
  end
125
125
 
126
- s.test_spec 'UITests' do |test_spec|
127
- test_spec.requires_app_host = true
128
- test_spec.source_files = 'ios/UITests/**/*'
129
- test_spec.dependency 'React-CoreModules'
130
- test_spec.dependency 'ReactAppDependencyProvider'
131
- test_spec.dependency 'React'
132
- # ExpoModulesCore requires React-hermes or React-jsc in tests, add ExpoModulesTestCore for the underlying dependencies
133
- test_spec.dependency 'ExpoModulesTestCore'
134
- test_spec.pod_target_xcconfig = {
135
- 'OTHER_LDFLAGS' => '$(inherited) -lc++'
136
- }
137
- test_spec.platforms = {
138
- :ios => '16.4'
139
- }
140
- test_spec.pod_target_xcconfig = {
141
- 'OTHER_LDFLAGS' => '$(inherited) -lc++'
142
- }
143
- end
144
-
145
126
  s.default_subspec = ['Main']
146
127
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-dev-menu",
3
- "version": "58.0.10",
3
+ "version": "58.0.11",
4
4
  "description": "Expo/React Native module with the developer menu.",
5
5
  "keywords": [
6
6
  "dev",
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/preset-typescript": "^7.7.4",
31
+ "@expo/internal-scripts": "58.0.1",
31
32
  "@testing-library/react-native": "^14.0.1",
32
- "@types/jest": "^29.2.1",
33
+ "@types/jest": "^30.0.0",
33
34
  "@types/node": "^22.14.0",
34
- "babel-preset-expo": "58.0.8",
35
- "expo-module-scripts": "56.0.5",
35
+ "babel-preset-expo": "58.0.12",
36
36
  "react": "19.3.0",
37
- "react-native": "0.88.0-rc.3"
37
+ "react-native": "0.88.0-rc.4"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "expo": "*",
@@ -1,39 +0,0 @@
1
- package expo.modules.devmenu.react
2
-
3
- import android.util.Log
4
- import com.facebook.react.common.ShakeDetector
5
- import com.facebook.react.devsupport.DevSupportManagerBase
6
- import expo.modules.devmenu.helpers.getPrivateDeclaredFieldValue
7
- import expo.modules.devmenu.helpers.hasDeclaredField
8
- import expo.modules.devmenu.helpers.setPrivateDeclaredFieldValue
9
-
10
- class DevMenuShakeDetectorListenerSwapper {
11
- fun swapShakeDetectorListener(
12
- devSupportManager: DevSupportManagerBase,
13
- newListener: ShakeDetector.ShakeListener
14
- ) {
15
- try {
16
- val shakeDetector: ShakeDetector =
17
- DevSupportManagerBase::class.java.getPrivateDeclaredFieldValue(
18
- "shakeDetector",
19
- devSupportManager
20
- )
21
-
22
- if (ShakeDetector::class.java.hasDeclaredField("shakeListener")) {
23
- ShakeDetector::class.java.setPrivateDeclaredFieldValue(
24
- "shakeListener",
25
- shakeDetector,
26
- newListener
27
- )
28
- } else {
29
- ShakeDetector::class.java.setPrivateDeclaredFieldValue(
30
- "mShakeListener",
31
- shakeDetector,
32
- newListener
33
- )
34
- }
35
- } catch (e: Exception) {
36
- Log.w("DevMenu", "Couldn't swap shake detector listener: ${e.message}", e)
37
- }
38
- }
39
- }
@@ -1,29 +0,0 @@
1
- import Foundation
2
- import XCTest
3
-
4
- class DevMenuLooper {
5
- static func runMainLoop(for sec: Double) {
6
- RunLoop.main.run(mode: .default, before: Date(timeIntervalSinceNow: sec))
7
- RunLoop.main.run(mode: .common, before: Date(timeIntervalSinceNow: sec))
8
- RunLoop.main.run(mode: .tracking, before: Date(timeIntervalSinceNow: sec))
9
- }
10
-
11
- static func runMainLoopUntilEmpty() {
12
- var isEmpty = false
13
-
14
- DispatchQueue.main.async {
15
- isEmpty = true
16
- }
17
-
18
- let timout = Date(timeIntervalSinceNow: DevMenuTestOptions.defaultTimeout)
19
- while timout.timeIntervalSinceNow > 0 {
20
- if isEmpty {
21
- return
22
- }
23
-
24
- DevMenuLooper.runMainLoop(for: DevMenuTestOptions.loopTime)
25
- }
26
-
27
- XCTFail("Wait for main thread timeout.")
28
- }
29
- }
@@ -1,4 +0,0 @@
1
- class DevMenuTestOptions {
2
- static let defaultTimeout = 30.0
3
- static let loopTime = 0.2
4
- }
@@ -1,106 +0,0 @@
1
- import XCTest
2
- import UIKit
3
-
4
- class DevMenuViews {
5
- static let mainScreen = "DevMenuMainScreen"
6
- static let footer = "DevMenuFooter"
7
- static let settingsScreen = "DevMenuSettingsScreen"
8
- static let profileScreen = "DevMenuProfileScreen"
9
- }
10
-
11
- class DevMenuUIMatchers {
12
- static func currentRootView() -> UIView? {
13
- return UIApplication.shared.keyWindow?.rootViewController?.view
14
- }
15
-
16
- static func findView(rootView: UIView, _ matcher: (UIView) -> Bool) -> UIView? {
17
- if matcher(rootView) {
18
- return rootView
19
- }
20
-
21
- for subView in rootView.subviews {
22
- let found = findView(rootView: subView, matcher)
23
- if found != nil {
24
- return found
25
- }
26
- }
27
-
28
- return nil
29
- }
30
-
31
- static func findView(_ matcher: (UIView) -> Bool) -> UIView? {
32
- guard let view = DevMenuUIMatchers.currentRootView() else {
33
- return nil
34
- }
35
-
36
- return findView(rootView: view, matcher)
37
- }
38
-
39
- static func findView(rootView: UIView, tag: String) -> UIView? {
40
- return DevMenuUIMatchers.findView(rootView: rootView) {
41
- return $0.accessibilityIdentifier == tag && $0.isVisible()
42
- }
43
- }
44
-
45
- static func findView(tag: String) -> UIView? {
46
- guard let view = DevMenuUIMatchers.currentRootView() else {
47
- return nil
48
- }
49
-
50
- return findView(rootView: view, tag: tag)
51
- }
52
-
53
- static func waitForView(_ matcher: (UIView) -> Bool) -> UIView {
54
- let timer = Date(timeIntervalSinceNow: DevMenuTestOptions.defaultTimeout)
55
-
56
- while timer.timeIntervalSinceNow > 0 {
57
- DevMenuLooper.runMainLoop(for: DevMenuTestOptions.loopTime)
58
-
59
- guard let view = DevMenuUIMatchers.currentRootView() else {
60
- continue
61
- }
62
-
63
- let found = findView(rootView: view, matcher)
64
- if found != nil {
65
- return found!
66
- }
67
- }
68
-
69
- XCTFail("Can not find view.")
70
- return UIView() // just for compiler
71
- }
72
-
73
- static func waitForView(tag: String) -> UIView {
74
- return waitForView {
75
- return $0.accessibilityIdentifier == tag && $0.isVisible()
76
- }
77
- }
78
-
79
- static func waitForView(text: String) -> UIView {
80
- return waitForView {
81
- if type(of: $0) == NSClassFromString("RCTTextView")! {
82
- return $0.isVisible() && ($0.value(forKey: "_textStorage") as! NSTextStorage).string == text
83
- }
84
-
85
- return false
86
- }
87
- }
88
-
89
- static func findView(rootView: UIView, text: String) -> UIView? {
90
- findView(rootView: rootView) {
91
- if type(of: $0) == NSClassFromString("RCTTextView")! {
92
- return $0.isVisible() && ($0.value(forKey: "_textStorage") as! NSTextStorage).string == text
93
- }
94
-
95
- return false
96
- }
97
- }
98
-
99
- static func findView(text: String) -> UIView? {
100
- guard let view = DevMenuUIMatchers.currentRootView() else {
101
- return nil
102
- }
103
-
104
- return findView(rootView: view, text: text)
105
- }
106
- }
@@ -1,19 +0,0 @@
1
- @testable import EXDevMenu
2
- @testable import EXDevMenuInterface
3
- import React
4
-
5
- class UIMockedNOOPBridge: RCTBridge {
6
- override func invalidate() {
7
- // NOOP
8
- }
9
-
10
- override func setUp() {
11
- bundleURL = URL(string: "http://localhost:1234")
12
- }
13
- }
14
-
15
- class BridgeWithDevMenuExtension: UIMockedNOOPBridge {
16
- override func module(forName moduleName: String!) -> Any! {
17
- return []
18
- }
19
- }
@@ -1,7 +0,0 @@
1
- import UIKit
2
-
3
- extension UIView {
4
- func isVisible() -> Bool {
5
- return isHidden == false && window != nil && bounds.isEmpty == false && bounds.width > 0 && bounds.height > 0
6
- }
7
- }
@@ -1,30 +0,0 @@
1
- import XCTest
2
-
3
- @testable import EXDevMenu
4
-
5
- extension XCTest {
6
- func assertViewExists(tag: String) {
7
- XCTAssertNotNil(DevMenuUIMatchers.findView(tag: tag), "View with tag \(tag) does not exist.")
8
- }
9
-
10
- func assertViewExists(text: String) {
11
- let view = DevMenuUIMatchers.findView(text: text)
12
- XCTAssertNotNil(view, "View with text \(text) does not exist.")
13
- }
14
-
15
- func waitForView(tag: String) {
16
- XCTAssertNotNil(DevMenuUIMatchers.waitForView(tag: tag))
17
- }
18
-
19
- func waitForDevMenu() {
20
- waitForView(tag: DevMenuViews.mainScreen)
21
- waitForView(tag: DevMenuViews.footer)
22
- XCTAssertTrue(DevMenuManager.shared.isVisible)
23
-
24
- DevMenuLooper.runMainLoopUntilEmpty()
25
- }
26
-
27
- func runMainLoop(for sec: Double) {
28
- DevMenuLooper.runMainLoop(for: sec)
29
- }
30
- }