expo-dev-menu-interface 0.5.0 → 0.5.1
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/android/build.gradle +4 -4
- package/ios/DevMenuBridgeProtocol.swift +1 -1
- package/ios/DevMenuDelegateProtocol.swift +2 -2
- package/ios/DevMenuExtensionProtocol.swift +3 -4
- package/ios/DevMenuManagerProtocol.swift +7 -7
- package/ios/DevMenuManagerProviderProtocol.swift +0 -2
- package/ios/DevMenuUIResponderExtensionProtocol.swift +0 -2
- package/ios/ExpoApiClient/DevMenuEASUpdates.swift +11 -11
- package/ios/ExpoApiClient/DevMenuExpoApiClientProtocol.swift +7 -7
- package/ios/MenuItems/DevMenuAction.swift +21 -21
- package/ios/MenuItems/DevMenuDataSource.swift +4 -4
- package/ios/MenuItems/DevMenuExportedCallable.swift +12 -12
- package/ios/MenuItems/DevMenuGroup.swift +6 -6
- package/ios/MenuItems/DevMenuItem.swift +2 -2
- package/ios/MenuItems/DevMenuItemsContainer.swift +5 -5
- package/ios/MenuItems/DevMenuItemsContainerProtocol.swift +1 -1
- package/ios/MenuItems/DevMenuLink.swift +3 -3
- package/ios/MenuItems/DevMenuScreen.swift +9 -9
- package/ios/MenuItems/DevMenuSelectionList.swift +19 -19
- package/ios/Tests/DevMenuActionTest.swift +7 -7
- package/ios/Tests/DevMenuEASUpdatesTest.swift +9 -9
- package/ios/Tests/DevMenuItemsContainerTest.swift +12 -12
- package/ios/Tests/DevMenuLinkTest.swift +2 -2
- package/ios/Tests/DevMenuScreenTest.swift +2 -2
- package/ios/Tests/DevMenuSelectionListTest.swift +2 -2
- package/package.json +2 -2
- package/Info-generated.plist +0 -22
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '0.5.
|
|
6
|
+
version = '0.5.1'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
@@ -16,7 +16,7 @@ buildscript {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
dependencies {
|
|
19
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.
|
|
19
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.6.10')}")
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -57,7 +57,7 @@ android {
|
|
|
57
57
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
58
58
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
59
59
|
versionCode 6
|
|
60
|
-
versionName '0.5.
|
|
60
|
+
versionName '0.5.1'
|
|
61
61
|
}
|
|
62
62
|
lintOptions {
|
|
63
63
|
abortOnError false
|
|
@@ -70,6 +70,6 @@ dependencies {
|
|
|
70
70
|
|
|
71
71
|
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
|
|
72
72
|
|
|
73
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.
|
|
73
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.6.10')}"
|
|
74
74
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
|
|
75
75
|
}
|
|
@@ -15,7 +15,7 @@ public protocol DevMenuDelegateProtocol {
|
|
|
15
15
|
Returns a dictionary with the most important informations about the current app.
|
|
16
16
|
*/
|
|
17
17
|
@objc
|
|
18
|
-
optional func appInfo(forDevMenuManager manager: DevMenuManagerProtocol) -> [String
|
|
18
|
+
optional func appInfo(forDevMenuManager manager: DevMenuManagerProtocol) -> [String: Any]?
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
Tells the manager whether it can change dev menu visibility. In some circumstances you may want not to show/close the dev menu. (Optional)
|
|
@@ -42,7 +42,7 @@ public protocol DevMenuDelegateProtocol {
|
|
|
42
42
|
@available(iOS 12.0, *)
|
|
43
43
|
@objc
|
|
44
44
|
optional func userInterfaceStyle(forDevMenuManager manager: DevMenuManagerProtocol) -> UIUserInterfaceStyle
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
@objc
|
|
47
47
|
optional func supportsDevelopment() -> Bool
|
|
48
48
|
}
|
|
@@ -17,7 +17,7 @@ public protocol DevMenuExtensionProtocol {
|
|
|
17
17
|
This function is optional because otherwise we end up with linker warning:
|
|
18
18
|
`method '+moduleName' in category from /.../expo-dev-menu/libexpo-dev-menu.a(DevMenuExtensions-....o)
|
|
19
19
|
overrides method from class in /.../expo-dev-menu/libexpo-dev-menu.a(DevMenuExtensions-....o`
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
So we assume that this method will be implemented by `RCTBridgeModule`.
|
|
22
22
|
In theory we can remove it. However, we leave it to get easy access to the module name.
|
|
23
23
|
*/
|
|
@@ -30,11 +30,10 @@ public protocol DevMenuExtensionProtocol {
|
|
|
30
30
|
*/
|
|
31
31
|
@objc
|
|
32
32
|
optional func devMenuItems(_ settings: DevMenuExtensionSettingsProtocol) -> DevMenuItemsContainerProtocol?
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
@objc
|
|
35
35
|
optional func devMenuScreens(_ settings: DevMenuExtensionSettingsProtocol) -> [DevMenuScreen]?
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
@objc
|
|
38
38
|
optional func devMenuDataSources(_ settings: DevMenuExtensionSettingsProtocol) -> [DevMenuDataSourceProtocol]?
|
|
39
39
|
}
|
|
40
|
-
|
|
@@ -9,42 +9,42 @@ public protocol DevMenuManagerProtocol {
|
|
|
9
9
|
*/
|
|
10
10
|
@objc
|
|
11
11
|
var isVisible: Bool { get }
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
@objc
|
|
14
14
|
var delegate: DevMenuDelegateProtocol? { get set }
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
/**
|
|
17
17
|
Opens up the dev menu.
|
|
18
18
|
*/
|
|
19
19
|
@objc
|
|
20
20
|
@discardableResult
|
|
21
21
|
func openMenu(_ screen: String?) -> Bool
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
@objc
|
|
24
24
|
@discardableResult
|
|
25
25
|
func openMenu() -> Bool
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
/**
|
|
28
28
|
Sends an event to JS to start collapsing the dev menu bottom sheet.
|
|
29
29
|
*/
|
|
30
30
|
@objc
|
|
31
31
|
@discardableResult
|
|
32
32
|
func closeMenu() -> Bool
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
/**
|
|
35
35
|
Forces the dev menu to hide. Called by JS once collapsing the bottom sheet finishes.
|
|
36
36
|
*/
|
|
37
37
|
@objc
|
|
38
38
|
@discardableResult
|
|
39
39
|
func hideMenu() -> Bool
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
/**
|
|
42
42
|
Toggles the visibility of the dev menu.
|
|
43
43
|
*/
|
|
44
44
|
@objc
|
|
45
45
|
@discardableResult
|
|
46
46
|
func toggleMenu() -> Bool
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
@objc
|
|
49
49
|
var expoApiClient: DevMenuExpoApiClientProtocol { get }
|
|
50
50
|
}
|
|
@@ -5,18 +5,18 @@ import Foundation
|
|
|
5
5
|
@objc
|
|
6
6
|
public protocol DevMenuConstructibleFromDictionary {
|
|
7
7
|
@objc
|
|
8
|
-
init(dictionary: [String
|
|
8
|
+
init(dictionary: [String: Any])
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public struct DevMenuEASUpdates {
|
|
12
12
|
@objc
|
|
13
|
-
public class Channel
|
|
13
|
+
public class Channel: NSObject, DevMenuConstructibleFromDictionary {
|
|
14
14
|
public let id: String
|
|
15
15
|
public let name: String
|
|
16
16
|
public let createdAt: String
|
|
17
17
|
public let updatedAt: String
|
|
18
|
-
|
|
19
|
-
required public init(dictionary: [String
|
|
18
|
+
|
|
19
|
+
required public init(dictionary: [String: Any]) {
|
|
20
20
|
id = dictionary["id"] as! String
|
|
21
21
|
name = dictionary["name"] as! String
|
|
22
22
|
createdAt = dictionary["createdAt"] as! String
|
|
@@ -25,27 +25,27 @@ public struct DevMenuEASUpdates {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
@objc
|
|
28
|
-
public class Branch
|
|
28
|
+
public class Branch: NSObject, DevMenuConstructibleFromDictionary {
|
|
29
29
|
public let id: String
|
|
30
30
|
public let updates: [Update]
|
|
31
|
-
|
|
32
|
-
required public init(dictionary: [String
|
|
31
|
+
|
|
32
|
+
required public init(dictionary: [String: Any]) {
|
|
33
33
|
id = dictionary["id"] as! String
|
|
34
|
-
let updatesData = dictionary["updates"] as? [[String
|
|
34
|
+
let updatesData = dictionary["updates"] as? [[String: Any]] ?? []
|
|
35
35
|
updates = updatesData.map { Update(dictionary: $0) }
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
@objc
|
|
40
|
-
public class Update
|
|
40
|
+
public class Update: NSObject, DevMenuConstructibleFromDictionary {
|
|
41
41
|
public let id: String
|
|
42
42
|
public let message: String
|
|
43
43
|
public let platform: String
|
|
44
44
|
public let runtimeVersion: String
|
|
45
45
|
public let createdAt: String
|
|
46
46
|
public let updatedAt: String
|
|
47
|
-
|
|
48
|
-
required public init(dictionary: [String
|
|
47
|
+
|
|
48
|
+
required public init(dictionary: [String: Any]) {
|
|
49
49
|
id = dictionary["id"] as! String
|
|
50
50
|
message = dictionary["message"] as! String
|
|
51
51
|
platform = dictionary["platform"] as! String
|
|
@@ -10,13 +10,13 @@ public class DevMenuGraphQLOptions: NSObject {
|
|
|
10
10
|
public let limit: Int
|
|
11
11
|
@objc
|
|
12
12
|
public let offset: Int
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
@objc
|
|
15
15
|
public init(withLimit limit: Int = 10, withOffset offset: Int = 0) {
|
|
16
16
|
self.limit = limit
|
|
17
17
|
self.offset = offset
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
@objc
|
|
21
21
|
public convenience init(withOffset offset: Int) {
|
|
22
22
|
self.init(withLimit: 10, withOffset: offset)
|
|
@@ -27,20 +27,20 @@ public class DevMenuGraphQLOptions: NSObject {
|
|
|
27
27
|
public protocol DevMenuExpoApiClientProtocol {
|
|
28
28
|
@objc
|
|
29
29
|
func isLoggedIn() -> Bool
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
@objc
|
|
32
32
|
func setSessionSecret(_ sessionSecret: String?)
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
@objc
|
|
35
35
|
func queryDevSessionsAsync(_ installationID: String?, completionHandler: @escaping HTTPCompletionHandler)
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
@objc
|
|
38
38
|
func queryUpdateChannels(
|
|
39
39
|
appId: String,
|
|
40
40
|
completionHandler: @escaping ([DevMenuEASUpdates.Channel]?, URLResponse?, Error?) -> Void,
|
|
41
41
|
options: DevMenuGraphQLOptions
|
|
42
42
|
)
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
@objc
|
|
45
45
|
func queryUpdateBranches(
|
|
46
46
|
appId: String,
|
|
@@ -57,7 +57,7 @@ public extension DevMenuExpoApiClientProtocol {
|
|
|
57
57
|
) {
|
|
58
58
|
queryUpdateChannels(appId: appId, completionHandler: completionHandler, options: DevMenuGraphQLOptions())
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
func queryUpdateBranches(
|
|
62
62
|
appId: String,
|
|
63
63
|
completionHandler: @escaping ([DevMenuEASUpdates.Branch]?, URLResponse?, Error?) -> Void
|
|
@@ -7,13 +7,13 @@ import UIKit
|
|
|
7
7
|
open class DevMenuAction: DevMenuScreenItem, DevMenuCallableProvider {
|
|
8
8
|
@objc
|
|
9
9
|
public var callable: DevMenuExportedAction
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
@objc
|
|
12
12
|
public var action: () -> Void {
|
|
13
13
|
get { return self.callable.action }
|
|
14
14
|
set { self.callable.action = newValue }
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
@objc
|
|
18
18
|
open var isAvailable: () -> Bool {
|
|
19
19
|
get {
|
|
@@ -23,7 +23,7 @@ open class DevMenuAction: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
23
23
|
self.callable.isAvailable = newValue
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
@objc
|
|
28
28
|
open var isEnabled: () -> Bool = { false }
|
|
29
29
|
|
|
@@ -43,16 +43,16 @@ open class DevMenuAction: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@objc
|
|
46
|
-
public convenience init(withId id: String, action: @escaping () ->
|
|
46
|
+
public convenience init(withId id: String, action: @escaping () -> Void) {
|
|
47
47
|
self.init(withId: id)
|
|
48
48
|
self.callable.action = action
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
@objc
|
|
52
|
-
public convenience init(withId id: String, _ action: @escaping () ->
|
|
52
|
+
public convenience init(withId id: String, _ action: @escaping () -> Void) {
|
|
53
53
|
self.init(withId: id, action: action)
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
public func registerCallable() -> DevMenuExportedCallable? {
|
|
57
57
|
return self.callable
|
|
58
58
|
}
|
|
@@ -61,16 +61,16 @@ open class DevMenuAction: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
61
61
|
open func registerKeyCommand(input: String, modifiers: UIKeyModifierFlags) {
|
|
62
62
|
self.callable.registerKeyCommand(input: input, modifiers: modifiers)
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
@objc
|
|
66
|
-
open override func serialize() -> [String
|
|
66
|
+
open override func serialize() -> [String: Any] {
|
|
67
67
|
var dict = super.serialize()
|
|
68
68
|
dict["actionId"] = self.callable.id
|
|
69
69
|
dict["keyCommand"] = self.callable.keyCommand == nil ? nil : [
|
|
70
70
|
"input": self.callable.keyCommand!.input!,
|
|
71
71
|
"modifiers": exportKeyCommandModifiers()
|
|
72
72
|
]
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
dict["isAvailable"] = isAvailable()
|
|
75
75
|
dict["isEnabled"] = isAvailable()
|
|
76
76
|
dict["label"] = label()
|
|
@@ -79,27 +79,27 @@ open class DevMenuAction: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
79
79
|
|
|
80
80
|
return dict
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
private func exportKeyCommandModifiers() -> Int {
|
|
84
|
-
var exportedValue = 0
|
|
84
|
+
var exportedValue = 0
|
|
85
85
|
let keyCommand = self.callable.keyCommand!
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
if keyCommand.modifierFlags.contains(.control) {
|
|
88
|
-
exportedValue += 1 << 0
|
|
88
|
+
exportedValue += 1 << 0
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
if keyCommand.modifierFlags.contains(.alternate) {
|
|
92
|
-
exportedValue += 1 << 1
|
|
92
|
+
exportedValue += 1 << 1
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
if keyCommand.modifierFlags.contains(.command) {
|
|
96
|
-
exportedValue += 1 << 2
|
|
96
|
+
exportedValue += 1 << 2
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
if keyCommand.modifierFlags.contains(.shift) {
|
|
100
|
-
exportedValue += 1 << 3
|
|
100
|
+
exportedValue += 1 << 3
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
return exportedValue
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -5,7 +5,7 @@ import Foundation
|
|
|
5
5
|
@objc
|
|
6
6
|
public protocol DevMenuDataSourceItem {
|
|
7
7
|
@objc
|
|
8
|
-
func serialize() -> [String
|
|
8
|
+
func serialize() -> [String: Any]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public typealias DevMenuDataSourceResolver = ([DevMenuDataSourceItem]) -> Void
|
|
@@ -13,7 +13,7 @@ public typealias DevMenuDataSourceResolver = ([DevMenuDataSourceItem]) -> Void
|
|
|
13
13
|
@objc
|
|
14
14
|
public protocol DevMenuDataSourceProtocol {
|
|
15
15
|
var id: String { get }
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
func fetchData(resolve: @escaping DevMenuDataSourceResolver)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,12 +21,12 @@ public protocol DevMenuDataSourceProtocol {
|
|
|
21
21
|
public class DevMenuListDataSource: NSObject, DevMenuDataSourceProtocol {
|
|
22
22
|
public var id: String
|
|
23
23
|
private var dataFetcher: (@escaping ([DevMenuSelectionList.Item]) -> Void) -> Void
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
public init(id: String, dataFetcher: @escaping (@escaping ([DevMenuSelectionList.Item]) -> Void) -> Void) {
|
|
26
26
|
self.id = id
|
|
27
27
|
self.dataFetcher = dataFetcher
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
public func fetchData(resolve: @escaping ([DevMenuDataSourceItem]) -> Void) {
|
|
31
31
|
dataFetcher(resolve)
|
|
32
32
|
}
|
|
@@ -13,7 +13,7 @@ public protocol DevMenuCallableProvider {
|
|
|
13
13
|
public class DevMenuExportedCallable: NSObject {
|
|
14
14
|
@objc
|
|
15
15
|
public let id: String
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
@objc
|
|
18
18
|
init(withId id: String) {
|
|
19
19
|
self.id = id
|
|
@@ -23,15 +23,15 @@ public class DevMenuExportedCallable: NSObject {
|
|
|
23
23
|
@objc
|
|
24
24
|
public class DevMenuExportedFunction: DevMenuExportedCallable {
|
|
25
25
|
@objc
|
|
26
|
-
public var function: ([String
|
|
27
|
-
|
|
26
|
+
public var function: ([String: Any]?) -> Void
|
|
27
|
+
|
|
28
28
|
@objc
|
|
29
|
-
public init(withId id: String, withFunction function: @escaping ([String
|
|
29
|
+
public init(withId id: String, withFunction function: @escaping ([String: Any]?) -> Void) {
|
|
30
30
|
self.function = function
|
|
31
31
|
super.init(withId: id)
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
public func call(args: [String
|
|
33
|
+
|
|
34
|
+
public func call(args: [String: Any]?) {
|
|
35
35
|
function(args)
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -40,23 +40,23 @@ public class DevMenuExportedFunction: DevMenuExportedCallable {
|
|
|
40
40
|
public class DevMenuExportedAction: DevMenuExportedCallable {
|
|
41
41
|
@objc
|
|
42
42
|
public var action: () -> Void
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
@objc
|
|
45
|
-
public private(set) var keyCommand: UIKeyCommand?
|
|
46
|
-
|
|
45
|
+
public private(set) var keyCommand: UIKeyCommand?
|
|
46
|
+
|
|
47
47
|
@objc
|
|
48
48
|
public var isAvailable: () -> Bool = { true }
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
@objc
|
|
51
51
|
public init(withId id: String, withAction action: @escaping () -> Void) {
|
|
52
52
|
self.action = action
|
|
53
53
|
super.init(withId: id)
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
public func call() {
|
|
57
57
|
action()
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
@objc
|
|
61
61
|
public func registerKeyCommand(input: String, modifiers: UIKeyModifierFlags) {
|
|
62
62
|
keyCommand = UIKeyCommand(input: input, modifierFlags: modifiers, action: #selector(DevMenuUIResponderExtensionProtocol.EXDevMenu_handleKeyCommand(_:)))
|
|
@@ -5,7 +5,7 @@ import Foundation
|
|
|
5
5
|
@objc
|
|
6
6
|
open class DevMenuGroup: DevMenuScreenItem, DevMenuItemsContainerProtocol {
|
|
7
7
|
let container = DevMenuItemsContainer()
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
@objc
|
|
10
10
|
public init() {
|
|
11
11
|
super.init(type: .Group)
|
|
@@ -15,21 +15,21 @@ open class DevMenuGroup: DevMenuScreenItem, DevMenuItemsContainerProtocol {
|
|
|
15
15
|
public func addItem(_ item: DevMenuScreenItem) {
|
|
16
16
|
container.addItem(item)
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
public func getRootItems() -> [DevMenuScreenItem] {
|
|
20
20
|
return container.getRootItems()
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
public func getAllItems() -> [DevMenuScreenItem] {
|
|
24
24
|
return container.getAllItems()
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
public func serializeItems() -> [[String
|
|
26
|
+
|
|
27
|
+
public func serializeItems() -> [[String: Any]] {
|
|
28
28
|
return container.serializeItems()
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
@objc
|
|
32
|
-
public override func serialize() -> [String
|
|
32
|
+
public override func serialize() -> [String: Any] {
|
|
33
33
|
var dict = super.serialize()
|
|
34
34
|
dict["items"] = serializeItems()
|
|
35
35
|
return dict
|
|
@@ -5,11 +5,11 @@ import Foundation
|
|
|
5
5
|
@objc
|
|
6
6
|
public class DevMenuItemsContainer: NSObject, DevMenuItemsContainerProtocol {
|
|
7
7
|
private var items: [DevMenuScreenItem] = []
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
public func getRootItems() -> [DevMenuScreenItem] {
|
|
10
10
|
return items.sorted { $0.importance > $1.importance }
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
public func getAllItems() -> [DevMenuScreenItem] {
|
|
14
14
|
var result: [DevMenuScreenItem] = []
|
|
15
15
|
for item in items {
|
|
@@ -20,13 +20,13 @@ public class DevMenuItemsContainer: NSObject, DevMenuItemsContainerProtocol {
|
|
|
20
20
|
}
|
|
21
21
|
return result.sorted { $0.importance > $1.importance }
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
@objc
|
|
25
25
|
public func addItem(_ item: DevMenuScreenItem) {
|
|
26
26
|
items.append(item)
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
func serializeItems() -> [[String
|
|
28
|
+
|
|
29
|
+
func serializeItems() -> [[String: Any]] {
|
|
30
30
|
return getRootItems().map({ $0.serialize() })
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -5,7 +5,7 @@ import Foundation
|
|
|
5
5
|
@objc
|
|
6
6
|
public class DevMenuLink: DevMenuScreenItem {
|
|
7
7
|
var target: String
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
@objc
|
|
10
10
|
open var label: () -> String = { "" }
|
|
11
11
|
|
|
@@ -16,9 +16,9 @@ public class DevMenuLink: DevMenuScreenItem {
|
|
|
16
16
|
self.target = target
|
|
17
17
|
super.init(type: .Link)
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
@objc
|
|
21
|
-
open override func serialize() -> [String
|
|
21
|
+
open override func serialize() -> [String: Any] {
|
|
22
22
|
var dict = super.serialize()
|
|
23
23
|
dict["target"] = target
|
|
24
24
|
dict["label"] = label()
|
|
@@ -3,32 +3,32 @@
|
|
|
3
3
|
import Foundation
|
|
4
4
|
|
|
5
5
|
@objc
|
|
6
|
-
public class DevMenuScreen
|
|
6
|
+
public class DevMenuScreen: DevMenuItem, DevMenuItemsContainerProtocol {
|
|
7
7
|
let container = DevMenuItemsContainer()
|
|
8
8
|
public private(set) var screenName: String
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
public func getRootItems() -> [DevMenuScreenItem] {
|
|
11
11
|
return container.getRootItems()
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
public func getAllItems() -> [DevMenuScreenItem] {
|
|
15
15
|
return container.getAllItems()
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
public func addItem(_ item: DevMenuScreenItem) {
|
|
19
19
|
container.addItem(item)
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
func serializeItems() -> [[String
|
|
21
|
+
|
|
22
|
+
func serializeItems() -> [[String: Any]] {
|
|
23
23
|
return container.serializeItems()
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
public init(_ screenName: String) {
|
|
27
27
|
self.screenName = screenName
|
|
28
28
|
super.init(type: .Screen)
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
public override func serialize() -> [String
|
|
30
|
+
|
|
31
|
+
public override func serialize() -> [String: Any] {
|
|
32
32
|
var dict = super.serialize()
|
|
33
33
|
dict["screenName"] = screenName
|
|
34
34
|
dict["items"] = serializeItems()
|
|
@@ -7,37 +7,37 @@ public class DevMenuSelectionList: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
7
7
|
@objc
|
|
8
8
|
public class Item: NSObject, DevMenuDataSourceItem {
|
|
9
9
|
@objc
|
|
10
|
-
public class Tag
|
|
10
|
+
public class Tag: NSObject {
|
|
11
11
|
@objc
|
|
12
12
|
public var text: () -> String = { "" }
|
|
13
13
|
|
|
14
14
|
@objc
|
|
15
15
|
public var glyphName: () -> String? = { nil }
|
|
16
|
-
|
|
17
|
-
fileprivate func serialize() -> [String
|
|
16
|
+
|
|
17
|
+
fileprivate func serialize() -> [String: Any] {
|
|
18
18
|
return [
|
|
19
19
|
"text": text(),
|
|
20
|
-
"glyphName": glyphName() ?? NSNull()
|
|
20
|
+
"glyphName": glyphName() ?? NSNull()
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
@objc
|
|
26
|
-
public var onClickData: () -> [String
|
|
27
|
-
|
|
26
|
+
public var onClickData: () -> [String: Any]? = { nil }
|
|
27
|
+
|
|
28
28
|
@objc
|
|
29
29
|
public var title: () -> String = { "" }
|
|
30
30
|
|
|
31
31
|
@objc
|
|
32
32
|
public var warning: () -> String? = { nil }
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
@objc
|
|
35
35
|
public var isChecked: () -> Bool = { false }
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
@objc
|
|
38
38
|
public var tags: () -> [Tag] = { [] }
|
|
39
|
-
|
|
40
|
-
public func serialize() -> [String
|
|
39
|
+
|
|
40
|
+
public func serialize() -> [String: Any] {
|
|
41
41
|
return [
|
|
42
42
|
"title": title(),
|
|
43
43
|
"warning": warning() ?? NSNull(),
|
|
@@ -47,22 +47,22 @@ public class DevMenuSelectionList: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
47
47
|
]
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
public static var ActionID = 1
|
|
52
52
|
private let callable: DevMenuExportedFunction
|
|
53
53
|
private var items: [Item] = []
|
|
54
54
|
private let dataSourceId: String?
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
@objc
|
|
57
57
|
public func addItem(_ item: Item) {
|
|
58
58
|
items.append(item)
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
@objc
|
|
62
62
|
public convenience init() {
|
|
63
63
|
self.init(dataSourceId: nil)
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
@objc
|
|
67
67
|
public init(dataSourceId: String?) {
|
|
68
68
|
self.dataSourceId = dataSourceId
|
|
@@ -70,21 +70,21 @@ public class DevMenuSelectionList: DevMenuScreenItem, DevMenuCallableProvider {
|
|
|
70
70
|
DevMenuSelectionList.ActionID += 1
|
|
71
71
|
super.init(type: .SelectionList)
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
@objc
|
|
75
|
-
public override func serialize() -> [String
|
|
75
|
+
public override func serialize() -> [String: Any] {
|
|
76
76
|
var dict = super.serialize()
|
|
77
77
|
dict["items"] = items.map { $0.serialize() }
|
|
78
78
|
dict["dataSourceId"] = dataSourceId ?? NSNull()
|
|
79
79
|
dict["actionId"] = self.callable.id
|
|
80
80
|
return dict
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
@objc
|
|
84
84
|
public func addOnClick(hander: @escaping ([String: Any]?) -> Void) {
|
|
85
85
|
self.callable.function = hander
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
public func registerCallable() -> DevMenuExportedCallable? {
|
|
89
89
|
return self.callable
|
|
90
90
|
}
|
|
@@ -13,9 +13,9 @@ class DevMenuActionTest: QuickSpec {
|
|
|
13
13
|
action.detail = { "action-1-details" }
|
|
14
14
|
action.glyphName = { "action-1-glyphname" }
|
|
15
15
|
action.registerKeyCommand(input: "r", modifiers: .command)
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
let serilizedData = action.serialize()
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
expect(serilizedData["type"] as? Int).to(equal(ItemType.action.rawValue))
|
|
20
20
|
expect(serilizedData["actionId"] as? String).to(equal("action-1"))
|
|
21
21
|
expect(serilizedData["isAvailable"] as? Bool).to(beTrue())
|
|
@@ -23,19 +23,19 @@ class DevMenuActionTest: QuickSpec {
|
|
|
23
23
|
expect(serilizedData["label"] as? String).to(equal("action-1-label"))
|
|
24
24
|
expect(serilizedData["detail"] as? String).to(equal("action-1-details"))
|
|
25
25
|
expect(serilizedData["glyphName"] as? String).to(equal("action-1-glyphname"))
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
let keyCommand = serilizedData["keyCommand"] as! [String: Any]
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
expect(keyCommand["input"] as? String).to(equal("r"))
|
|
30
30
|
expect(keyCommand["modifiers"] as? Int).to(equal(1 << 2))
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
it("Action callable should be contain passed action") {
|
|
34
34
|
var wasCalled = false
|
|
35
35
|
let action = DevMenuAction(withId: "action-1", { wasCalled = true })
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
action.callable.call()
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
expect(wasCalled).to(beTrue())
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -12,15 +12,15 @@ class DevMenuEASUpdatesTest: QuickSpec {
|
|
|
12
12
|
"createdAt": "1635508863",
|
|
13
13
|
"updatedAt": "1635508873"
|
|
14
14
|
]
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
let channel = DevMenuEASUpdates.Channel(dictionary: seeder)
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
expect(channel.id).to(equal("1234"))
|
|
19
19
|
expect(channel.name).to(equal("channel-1"))
|
|
20
20
|
expect(channel.createdAt).to(equal("1635508863"))
|
|
21
21
|
expect(channel.updatedAt).to(equal("1635508873"))
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
it("Update constructor should populate all fields") {
|
|
25
25
|
let seeder = [
|
|
26
26
|
"id": "1234",
|
|
@@ -30,9 +30,9 @@ class DevMenuEASUpdatesTest: QuickSpec {
|
|
|
30
30
|
"createdAt": "1635508863",
|
|
31
31
|
"updatedAt": "1635508873"
|
|
32
32
|
]
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
let update = DevMenuEASUpdates.Update(dictionary: seeder)
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
expect(update.id).to(equal("1234"))
|
|
37
37
|
expect(update.message).to(equal("update-1"))
|
|
38
38
|
expect(update.platform).to(equal("ios"))
|
|
@@ -40,7 +40,7 @@ class DevMenuEASUpdatesTest: QuickSpec {
|
|
|
40
40
|
expect(update.createdAt).to(equal("1635508863"))
|
|
41
41
|
expect(update.updatedAt).to(equal("1635508873"))
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
it("Branch constructor should populate all fields") {
|
|
45
45
|
let seeder = [
|
|
46
46
|
"id": "1",
|
|
@@ -62,12 +62,12 @@ class DevMenuEASUpdatesTest: QuickSpec {
|
|
|
62
62
|
"updatedAt": "1635508873"
|
|
63
63
|
]
|
|
64
64
|
]
|
|
65
|
-
] as [String
|
|
66
|
-
|
|
65
|
+
] as [String: Any]
|
|
66
|
+
|
|
67
67
|
let branch = DevMenuEASUpdates.Branch(dictionary: seeder)
|
|
68
68
|
let update1 = branch.updates[0]
|
|
69
69
|
let update2 = branch.updates[1]
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
expect(branch.id).to(equal("1"))
|
|
72
72
|
expect(update1.id).to(equal("1234"))
|
|
73
73
|
expect(update1.message).to(equal("update-1"))
|
|
@@ -7,54 +7,54 @@ class DevMenuItemsContainerTest: QuickSpec {
|
|
|
7
7
|
override func spec() {
|
|
8
8
|
it("should respect importance") {
|
|
9
9
|
let container = DevMenuItemsContainer()
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
let seeder = [("action-1", ItemImportance.lowest), ("action-2", ItemImportance.medium), ("action-3", ItemImportance.highest)]
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
seeder.forEach { actionDate in
|
|
14
14
|
let action = DevMenuAction(withId: actionDate.0)
|
|
15
15
|
action.label = { actionDate.0 }
|
|
16
16
|
action.importance = actionDate.1.rawValue
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
container.addItem(action)
|
|
19
19
|
}
|
|
20
20
|
let items = container.getRootItems()
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
expect(items.count).to(equal(3))
|
|
23
23
|
expect((items[0] as! DevMenuAction).label()).to(equal("action-3"))
|
|
24
24
|
expect((items[1] as! DevMenuAction).label()).to(equal("action-2"))
|
|
25
25
|
expect((items[2] as! DevMenuAction).label()).to(equal("action-1"))
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
it("should unwrap other containers") {
|
|
29
29
|
let container = DevMenuItemsContainer()
|
|
30
30
|
container.addItem(DevMenuAction(withId: "action-1"))
|
|
31
31
|
let innerContainer = DevMenuGroup()
|
|
32
32
|
innerContainer.addItem(DevMenuAction(withId: "action-2"))
|
|
33
33
|
container.addItem(innerContainer)
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
let items = container.getAllItems()
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
expect(items.count).to(equal(3))
|
|
38
38
|
expect(items[0] as? DevMenuAction).toNot(beNil())
|
|
39
39
|
expect(items[1] as? DevMenuGroup).toNot(beNil())
|
|
40
40
|
expect(items[2] as? DevMenuAction).toNot(beNil())
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
it("should serilize items") {
|
|
44
44
|
let container = DevMenuItemsContainer()
|
|
45
45
|
container.addItem(DevMenuAction(withId: "action-1"))
|
|
46
46
|
let innerContainer = DevMenuGroup()
|
|
47
47
|
innerContainer.addItem(DevMenuAction(withId: "action-2"))
|
|
48
48
|
container.addItem(innerContainer)
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
let items = container.serializeItems()
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
expect(items.count).to(equal(2))
|
|
53
53
|
expect(items[0]["type"] as? Int).to(equal(ItemType.action.rawValue))
|
|
54
54
|
expect(items[0]["actionId"] as? String).to(equal("action-1"))
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
expect(items[1]["type"] as? Int).to(equal(ItemType.group.rawValue))
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
let innerItem = (items[1]["items"] as! [[String: Any]])[0]
|
|
59
59
|
expect(innerItem["type"] as? Int).to(equal(ItemType.action.rawValue))
|
|
60
60
|
expect(innerItem["actionId"] as? String).to(equal("action-2"))
|
|
@@ -9,9 +9,9 @@ class DevMenuLinkTest: QuickSpec {
|
|
|
9
9
|
let link = DevMenuLink(withTarget: "target-1")
|
|
10
10
|
link.glyphName = { "link-1-glyph" }
|
|
11
11
|
link.label = { "link-1-label" }
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
let serilizedData = link.serialize()
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
expect(serilizedData["type"] as? Int).to(equal(ItemType.link.rawValue))
|
|
16
16
|
expect(serilizedData["label"] as? String).to(equal("link-1-label"))
|
|
17
17
|
expect(serilizedData["glyphName"] as? String).to(equal("link-1-glyph"))
|
|
@@ -7,9 +7,9 @@ class DevMenuScreenTest: QuickSpec {
|
|
|
7
7
|
override func spec() {
|
|
8
8
|
it("Screen should be serializable") {
|
|
9
9
|
let screen = DevMenuScreen("screen-1")
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
let serilizedData = screen.serialize()
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
expect(serilizedData["type"] as? Int).to(equal(ItemType.screen.rawValue))
|
|
14
14
|
expect(serilizedData["screenName"] as? String).to(equal("screen-1"))
|
|
15
15
|
}
|
|
@@ -7,9 +7,9 @@ class DevMenuSelectionListTest: QuickSpec {
|
|
|
7
7
|
override func spec() {
|
|
8
8
|
it("List should be serializable") {
|
|
9
9
|
let list = DevMenuSelectionList()
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
let serilizedData = list.serialize()
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
expect(serilizedData["type"] as? Int).to(equal(ItemType.selectionList.rawValue))
|
|
14
14
|
expect(serilizedData["actionId"] as? String).toNot(beNil())
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-dev-menu-interface",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Interface for expo-dev-menu",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"expo": "*"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "89187292ca30183c7f936fc890ba9ee9e221a128"
|
|
29
29
|
}
|
package/Info-generated.plist
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>expo.dev.menu.interface</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>EXDevMenuInterface</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>FMWK</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>0.3.2</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>0</string>
|
|
21
|
-
</dict>
|
|
22
|
-
</plist>
|