react-native-debug-toolkit 3.3.4 → 3.3.8
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/README.md +48 -46
- package/README.zh-CN.md +48 -46
- package/android/src/main/java/com/reactnativedebugtoolkit/DebugToolkitDevConnectModule.java +0 -187
- package/bin/debug-toolkit.js +0 -16
- package/ios/DebugToolkitDevConnect.h +0 -12
- package/ios/DebugToolkitDevConnect.mm +0 -321
- package/lib/commonjs/core/initialize.js +8 -1
- package/lib/commonjs/core/initialize.js.map +1 -1
- package/lib/commonjs/features/devConnect/DevConnectTab.js +18 -470
- package/lib/commonjs/features/devConnect/DevConnectTab.js.map +1 -1
- package/lib/commonjs/features/devConnect/devConnectPreferences.js +0 -12
- package/lib/commonjs/features/devConnect/devConnectPreferences.js.map +1 -1
- package/lib/commonjs/features/devConnect/devConnectUtils.js +2 -57
- package/lib/commonjs/features/devConnect/devConnectUtils.js.map +1 -1
- package/lib/commonjs/features/devConnect/index.js +1 -23
- package/lib/commonjs/features/devConnect/index.js.map +1 -1
- package/lib/commonjs/features/devConnect/nativeDevConnect.js +1 -103
- package/lib/commonjs/features/devConnect/nativeDevConnect.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/DebugView.js +2 -0
- package/lib/commonjs/ui/DebugView.js.map +1 -1
- package/lib/commonjs/ui/panel/FloatPanelView.js +22 -10
- package/lib/commonjs/ui/panel/FloatPanelView.js.map +1 -1
- package/lib/commonjs/ui/panel/tabPersistence.js +17 -0
- package/lib/commonjs/ui/panel/tabPersistence.js.map +1 -0
- package/lib/commonjs/utils/createDebugTab.js +21 -0
- package/lib/commonjs/utils/createDebugTab.js.map +1 -0
- package/lib/commonjs/utils/debugPreferences.js +0 -1
- package/lib/commonjs/utils/debugPreferences.js.map +1 -1
- package/lib/module/core/initialize.js +8 -1
- package/lib/module/core/initialize.js.map +1 -1
- package/lib/module/features/devConnect/DevConnectTab.js +21 -473
- package/lib/module/features/devConnect/DevConnectTab.js.map +1 -1
- package/lib/module/features/devConnect/devConnectPreferences.js +1 -12
- package/lib/module/features/devConnect/devConnectPreferences.js.map +1 -1
- package/lib/module/features/devConnect/devConnectUtils.js +1 -53
- package/lib/module/features/devConnect/devConnectUtils.js.map +1 -1
- package/lib/module/features/devConnect/index.js +5 -9
- package/lib/module/features/devConnect/index.js.map +1 -1
- package/lib/module/features/devConnect/nativeDevConnect.js +1 -100
- package/lib/module/features/devConnect/nativeDevConnect.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/DebugView.js +2 -0
- package/lib/module/ui/DebugView.js.map +1 -1
- package/lib/module/ui/panel/FloatPanelView.js +22 -10
- package/lib/module/ui/panel/FloatPanelView.js.map +1 -1
- package/lib/module/ui/panel/tabPersistence.js +13 -0
- package/lib/module/ui/panel/tabPersistence.js.map +1 -0
- package/lib/module/utils/createDebugTab.js +17 -0
- package/lib/module/utils/createDebugTab.js.map +1 -0
- package/lib/module/utils/debugPreferences.js +0 -1
- package/lib/module/utils/debugPreferences.js.map +1 -1
- package/lib/typescript/src/core/initialize.d.ts +2 -0
- package/lib/typescript/src/core/initialize.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/DevConnectTab.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/devConnectPreferences.d.ts +0 -2
- package/lib/typescript/src/features/devConnect/devConnectPreferences.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts +0 -20
- package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/index.d.ts +2 -2
- package/lib/typescript/src/features/devConnect/index.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/nativeDevConnect.d.ts +0 -25
- package/lib/typescript/src/features/devConnect/nativeDevConnect.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/types.d.ts +1 -3
- package/lib/typescript/src/features/devConnect/types.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/ui/DebugView.d.ts +4 -2
- package/lib/typescript/src/ui/DebugView.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/FloatPanelView.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/tabPersistence.d.ts +3 -0
- package/lib/typescript/src/ui/panel/tabPersistence.d.ts.map +1 -0
- package/lib/typescript/src/utils/createDebugTab.d.ts +18 -0
- package/lib/typescript/src/utils/createDebugTab.d.ts.map +1 -0
- package/lib/typescript/src/utils/debugPreferences.d.ts +0 -1
- package/lib/typescript/src/utils/debugPreferences.d.ts.map +1 -1
- package/package.json +2 -6
- package/src/core/initialize.ts +17 -1
- package/src/features/devConnect/DevConnectTab.tsx +17 -381
- package/src/features/devConnect/devConnectPreferences.ts +0 -15
- package/src/features/devConnect/devConnectUtils.ts +1 -81
- package/src/features/devConnect/index.ts +2 -9
- package/src/features/devConnect/nativeDevConnect.ts +1 -136
- package/src/features/devConnect/types.ts +1 -3
- package/src/index.ts +2 -0
- package/src/ui/DebugView.tsx +5 -1
- package/src/ui/panel/FloatPanelView.tsx +22 -10
- package/src/ui/panel/tabPersistence.ts +22 -0
- package/src/utils/createDebugTab.ts +32 -0
- package/src/utils/debugPreferences.ts +0 -1
- package/app.plugin.js +0 -51
- package/dev-client.js +0 -3
- package/scripts/bundle/android.js +0 -101
- package/scripts/bundle/cli.js +0 -57
- package/scripts/bundle/doctor.js +0 -38
- package/scripts/bundle/ios.js +0 -179
- package/scripts/bundle/setup.js +0 -39
- package/scripts/debug-bundle.gradle +0 -147
|
@@ -1,189 +1,11 @@
|
|
|
1
1
|
#import "DebugToolkitDevConnect.h"
|
|
2
2
|
|
|
3
3
|
#import <Foundation/Foundation.h>
|
|
4
|
-
#import <UIKit/UIKit.h>
|
|
5
|
-
#import <React/RCTBridge.h>
|
|
6
|
-
#import <React/RCTBundleManager.h>
|
|
7
4
|
#import <React/RCTBridgeModule.h>
|
|
8
|
-
#import <React/RCTBundleURLProvider.h>
|
|
9
|
-
#import <React/RCTReloadCommand.h>
|
|
10
|
-
#import <objc/runtime.h>
|
|
11
5
|
#include <ifaddrs.h>
|
|
12
6
|
#include <arpa/inet.h>
|
|
13
7
|
#include <net/if.h>
|
|
14
8
|
|
|
15
|
-
// Debug-only Metro host switching — zero host-app native changes required.
|
|
16
|
-
//
|
|
17
|
-
// RN/Expo Debug templates call jsBundleURLForBundleRoot:fallbackURLProvider:, which consults
|
|
18
|
-
// -packagerServerHostPort (guessPackagerHost on simulator when Metro is running). We only hook
|
|
19
|
-
// jsBundleURLForBundleRoot:fallbackURLProvider: so no DevConnect host starts from main.jsbundle.
|
|
20
|
-
// Persisted DevConnect hosts still flow through RCTBundleURLProvider, preserving RN's reachability
|
|
21
|
-
// and fallback behavior when a saved Metro host is stale.
|
|
22
|
-
//
|
|
23
|
-
// Optional: host apps may call DebugToolkitMetroBundleURL() from bundleURL() for explicit control.
|
|
24
|
-
|
|
25
|
-
static NSString *const kBundleRoot = @"index";
|
|
26
|
-
// Expo prebuild templates pass this to jsBundleURLForBundleRoot: in Debug (see expo/expo#21643).
|
|
27
|
-
static NSString *const kExpoVirtualMetroEntry = @".expo/.virtual-metro-entry";
|
|
28
|
-
static NSString *const kMetroHostKey = @"_devconnect_metro_host";
|
|
29
|
-
|
|
30
|
-
static BOOL gBundleRootHookInstalled = NO;
|
|
31
|
-
|
|
32
|
-
static NSURL *(*gOrigJsBundleURLForBundleRootWithFallback)(id, SEL, NSString *, NSURL * _Nonnull (^)(void));
|
|
33
|
-
|
|
34
|
-
static BOOL DevConnectEmbeddedFirstHooksActive(void)
|
|
35
|
-
{
|
|
36
|
-
return gBundleRootHookInstalled;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static NSURL *DebugToolkitEmbeddedBundleURL(void)
|
|
40
|
-
{
|
|
41
|
-
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static NSString *DevConnectPersistedMetroHost(void)
|
|
45
|
-
{
|
|
46
|
-
return [[NSUserDefaults standardUserDefaults] stringForKey:kMetroHostKey];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static void DevConnectSetPersistedMetroHost(NSString *_Nullable hostPort)
|
|
50
|
-
{
|
|
51
|
-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
52
|
-
if (hostPort.length > 0) {
|
|
53
|
-
[defaults setObject:hostPort forKey:kMetroHostKey];
|
|
54
|
-
} else {
|
|
55
|
-
[defaults removeObjectForKey:kMetroHostKey];
|
|
56
|
-
}
|
|
57
|
-
[defaults synchronize];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static void DebugToolkitPrepareBundleSourceIfNeeded(void)
|
|
61
|
-
{
|
|
62
|
-
// Touch sharedSettings so RCTBundleURLProvider is linked before hook install retries.
|
|
63
|
-
RCTBundleURLProvider *settings = [RCTBundleURLProvider sharedSettings];
|
|
64
|
-
if (DevConnectPersistedMetroHost().length > 0) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
[settings resetToDefaults];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static BOOL DevConnectIsExpoProject(void)
|
|
71
|
-
{
|
|
72
|
-
static dispatch_once_t onceToken;
|
|
73
|
-
static BOOL isExpo = NO;
|
|
74
|
-
dispatch_once(&onceToken, ^{
|
|
75
|
-
// Heuristic: matches common Expo prebuild / dev-client binaries.
|
|
76
|
-
isExpo = NSClassFromString(@"EXAppDelegateWrapper") != nil
|
|
77
|
-
|| [[NSBundle mainBundle] objectForInfoDictionaryKey:@"EXUpdatesURL"] != nil
|
|
78
|
-
|| [[NSBundle mainBundle] objectForInfoDictionaryKey:@"EXPO_RUNTIME_VERSION"] != nil;
|
|
79
|
-
});
|
|
80
|
-
return isExpo;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/// Bundle root Metro expects when DevConnect steers the packager (index for plain RN, virtual entry for Expo).
|
|
84
|
-
static NSString *DevConnectMetroBundleRoot(void)
|
|
85
|
-
{
|
|
86
|
-
return DevConnectIsExpoProject() ? kExpoVirtualMetroEntry : kBundleRoot;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static NSURL *DevConnectMetroURLForPersistedHost(void)
|
|
90
|
-
{
|
|
91
|
-
NSString *host = DevConnectPersistedMetroHost();
|
|
92
|
-
if (host.length == 0) {
|
|
93
|
-
return nil;
|
|
94
|
-
}
|
|
95
|
-
RCTBundleURLProvider *settings = [RCTBundleURLProvider sharedSettings];
|
|
96
|
-
settings.jsLocation = host;
|
|
97
|
-
return [settings jsBundleURLForBundleRoot:DevConnectMetroBundleRoot()];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/// Primary hook: return embedded main.jsbundle before RN/Expo tries Metro / virtual-metro-entry.
|
|
101
|
-
static NSURL *replacement_jsBundleURLForBundleRoot_fallback(
|
|
102
|
-
id self, SEL _cmd, NSString *bundleRoot, NSURL * _Nonnull (^fallbackURLProvider)(void))
|
|
103
|
-
{
|
|
104
|
-
if (DevConnectPersistedMetroHost().length == 0) {
|
|
105
|
-
NSURL *embedded = DebugToolkitEmbeddedBundleURL();
|
|
106
|
-
if (embedded) {
|
|
107
|
-
NSLog(@"[DevConnect] cold start → embedded bundle (root=%@)", bundleRoot);
|
|
108
|
-
return embedded;
|
|
109
|
-
}
|
|
110
|
-
NSLog(@"[DevConnect] no embedded main.jsbundle — falling back to Metro (root=%@)", bundleRoot);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (gOrigJsBundleURLForBundleRootWithFallback) {
|
|
114
|
-
return gOrigJsBundleURLForBundleRootWithFallback(self, _cmd, bundleRoot, fallbackURLProvider);
|
|
115
|
-
}
|
|
116
|
-
return fallbackURLProvider ? fallbackURLProvider() : nil;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
static void DebugToolkitInstallBundleRootHook(Class cls)
|
|
120
|
-
{
|
|
121
|
-
if (gBundleRootHookInstalled) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
SEL selector = @selector(jsBundleURLForBundleRoot:fallbackURLProvider:);
|
|
125
|
-
Method method = class_getInstanceMethod(cls, selector);
|
|
126
|
-
if (!method) {
|
|
127
|
-
NSLog(@"[DevConnect] jsBundleURLForBundleRoot:fallbackURLProvider: not found");
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
IMP replacement = (IMP)replacement_jsBundleURLForBundleRoot_fallback;
|
|
131
|
-
gOrigJsBundleURLForBundleRootWithFallback =
|
|
132
|
-
(NSURL * (*)(id, SEL, NSString *, NSURL * _Nonnull (^)(void)))method_getImplementation(method);
|
|
133
|
-
if ((IMP)gOrigJsBundleURLForBundleRootWithFallback == replacement) {
|
|
134
|
-
gBundleRootHookInstalled = YES;
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
method_setImplementation(method, replacement);
|
|
138
|
-
gBundleRootHookInstalled = YES;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
static void DebugToolkitInstallAllHooks(void)
|
|
142
|
-
{
|
|
143
|
-
if (gBundleRootHookInstalled) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
Class cls = NSClassFromString(@"RCTBundleURLProvider");
|
|
148
|
-
if (!cls) {
|
|
149
|
-
NSLog(@"[DevConnect] RCTBundleURLProvider not loaded — hooks will retry");
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
DebugToolkitInstallBundleRootHook(cls);
|
|
154
|
-
|
|
155
|
-
static BOOL didLogOutcome = NO;
|
|
156
|
-
if (!didLogOutcome) {
|
|
157
|
-
didLogOutcome = YES;
|
|
158
|
-
if (DevConnectEmbeddedFirstHooksActive()) {
|
|
159
|
-
NSLog(@"[DevConnect] embedded-first hook active");
|
|
160
|
-
} else {
|
|
161
|
-
NSLog(@"[DevConnect] embedded-first hooks FAILED — rebuild / check React linkage");
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
NSURL *DebugToolkitMetroBundleURL(void)
|
|
167
|
-
{
|
|
168
|
-
return DevConnectMetroURLForPersistedHost();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// RCT_EXPORT_MODULE defines +load for module registration — use a separate class for hooks.
|
|
172
|
-
@interface DebugToolkitDevConnectBootstrap : NSObject
|
|
173
|
-
@end
|
|
174
|
-
|
|
175
|
-
@implementation DebugToolkitDevConnectBootstrap
|
|
176
|
-
|
|
177
|
-
+ (void)load
|
|
178
|
-
{
|
|
179
|
-
DebugToolkitPrepareBundleSourceIfNeeded();
|
|
180
|
-
DebugToolkitInstallAllHooks();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@end
|
|
184
|
-
|
|
185
|
-
#pragma mark - Module
|
|
186
|
-
|
|
187
9
|
@interface DebugToolkitDevConnect : NSObject <RCTBridgeModule>
|
|
188
10
|
@end
|
|
189
11
|
|
|
@@ -191,152 +13,9 @@ NSURL *DebugToolkitMetroBundleURL(void)
|
|
|
191
13
|
|
|
192
14
|
RCT_EXPORT_MODULE(DebugToolkitDevConnect)
|
|
193
15
|
|
|
194
|
-
@synthesize bridge = _bridge;
|
|
195
|
-
@synthesize bundleManager = _bundleManager;
|
|
196
|
-
|
|
197
|
-
- (instancetype)init
|
|
198
|
-
{
|
|
199
|
-
if ((self = [super init])) {
|
|
200
|
-
DebugToolkitInstallAllHooks();
|
|
201
|
-
}
|
|
202
|
-
return self;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
16
|
+ (BOOL)requiresMainQueueSetup { return NO; }
|
|
206
17
|
- (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); }
|
|
207
18
|
|
|
208
|
-
#pragma mark - Bundle Manager Resolution
|
|
209
|
-
|
|
210
|
-
- (RCTBundleManager *)resolveBundleManager
|
|
211
|
-
{
|
|
212
|
-
if (_bundleManager) return _bundleManager;
|
|
213
|
-
if (_bridge) return [_bridge moduleForClass:[RCTBundleManager class]];
|
|
214
|
-
return nil;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
#pragma mark - Host Parsing
|
|
218
|
-
|
|
219
|
-
- (NSString *)normalizeHostPort:(NSString *)hostPort
|
|
220
|
-
{
|
|
221
|
-
NSRange sep = [hostPort rangeOfString:@":" options:NSBackwardsSearch];
|
|
222
|
-
NSString *host = sep.location == NSNotFound ? hostPort : [hostPort substringToIndex:sep.location];
|
|
223
|
-
NSString *portStr = sep.location == NSNotFound ? @"" : [hostPort substringFromIndex:sep.location + 1];
|
|
224
|
-
|
|
225
|
-
NSNumberFormatter *formatter = [NSNumberFormatter new];
|
|
226
|
-
formatter.numberStyle = NSNumberFormatterDecimalStyle;
|
|
227
|
-
NSNumber *parsed = [formatter numberFromString:portStr];
|
|
228
|
-
int port;
|
|
229
|
-
if (parsed && parsed.intValue > 0 && parsed.intValue <= 65535) {
|
|
230
|
-
port = parsed.intValue;
|
|
231
|
-
} else {
|
|
232
|
-
#ifdef RCT_METRO_PORT
|
|
233
|
-
port = RCT_METRO_PORT;
|
|
234
|
-
#else
|
|
235
|
-
port = 8081;
|
|
236
|
-
#endif
|
|
237
|
-
}
|
|
238
|
-
return [NSString stringWithFormat:@"%@:%d", host, port];
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
#pragma mark - Reload helper
|
|
242
|
-
|
|
243
|
-
- (void)reloadWithBundleURL:(NSURL *)bundleURL reason:(NSString *)reason
|
|
244
|
-
{
|
|
245
|
-
if (bundleURL) {
|
|
246
|
-
RCTBundleManager *bm = [self resolveBundleManager];
|
|
247
|
-
if (bm) bm.bundleURL = bundleURL;
|
|
248
|
-
RCTReloadCommandSetBundleURL(bundleURL);
|
|
249
|
-
}
|
|
250
|
-
RCTTriggerReloadCommandListeners(reason);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
#pragma mark - Exported Methods
|
|
254
|
-
|
|
255
|
-
RCT_EXPORT_METHOD(applyMetroHost:(NSString *)hostPort
|
|
256
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
257
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
258
|
-
{
|
|
259
|
-
@try {
|
|
260
|
-
if (hostPort.length == 0) {
|
|
261
|
-
reject(@"invalid_host", @"Metro host cannot be empty.", nil);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
NSString *normalized = [self normalizeHostPort:hostPort];
|
|
265
|
-
|
|
266
|
-
DevConnectSetPersistedMetroHost(normalized);
|
|
267
|
-
|
|
268
|
-
RCTBundleURLProvider *settings = [RCTBundleURLProvider sharedSettings];
|
|
269
|
-
settings.jsLocation = normalized;
|
|
270
|
-
NSURL *bundleURL = [settings jsBundleURLForBundleRoot:DevConnectMetroBundleRoot()];
|
|
271
|
-
|
|
272
|
-
[self reloadWithBundleURL:bundleURL reason:@"Dev menu - apply changes"];
|
|
273
|
-
|
|
274
|
-
NSLog(@"[DevConnect] applyMetroHost host=%@ url=%@", normalized, bundleURL);
|
|
275
|
-
resolve(@{
|
|
276
|
-
@"hostPort": normalized,
|
|
277
|
-
@"bundleURL": bundleURL.absoluteString ?: [NSNull null],
|
|
278
|
-
});
|
|
279
|
-
} @catch (NSException *e) {
|
|
280
|
-
NSLog(@"[DevConnect] applyMetroHost EXCEPTION: %@", e.reason);
|
|
281
|
-
reject(@"native_error", e.reason ?: @"unknown", nil);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
RCT_EXPORT_METHOD(resetMetroHost:(RCTPromiseResolveBlock)resolve
|
|
286
|
-
rejecter:(__unused RCTPromiseRejectBlock)reject)
|
|
287
|
-
{
|
|
288
|
-
@try {
|
|
289
|
-
DevConnectSetPersistedMetroHost(nil);
|
|
290
|
-
|
|
291
|
-
RCTBundleURLProvider *settings = [RCTBundleURLProvider sharedSettings];
|
|
292
|
-
[settings resetToDefaults];
|
|
293
|
-
|
|
294
|
-
NSURL *embedded = DebugToolkitEmbeddedBundleURL();
|
|
295
|
-
if (!embedded) {
|
|
296
|
-
embedded = [settings jsBundleURLForFallbackExtension:nil];
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
[self reloadWithBundleURL:embedded reason:@"Dev menu - reset to default"];
|
|
300
|
-
|
|
301
|
-
NSLog(@"[DevConnect] resetMetroHost url=%@", embedded);
|
|
302
|
-
resolve([NSNull null]);
|
|
303
|
-
} @catch (NSException *e) {
|
|
304
|
-
NSLog(@"[DevConnect] resetMetroHost EXCEPTION: %@", e.reason);
|
|
305
|
-
reject(@"native_error", e.reason ?: @"unknown", nil);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
RCT_EXPORT_METHOD(getMetroHost:(RCTPromiseResolveBlock)resolve
|
|
310
|
-
rejecter:(__unused RCTPromiseRejectBlock)reject)
|
|
311
|
-
{
|
|
312
|
-
NSString *host = DevConnectPersistedMetroHost();
|
|
313
|
-
resolve(host.length > 0 ? host : [NSNull null]);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
RCT_EXPORT_METHOD(getDiagnostics:(RCTPromiseResolveBlock)resolve
|
|
317
|
-
rejecter:(__unused RCTPromiseRejectBlock)reject)
|
|
318
|
-
{
|
|
319
|
-
Class realDelegate = object_getClass([UIApplication sharedApplication].delegate);
|
|
320
|
-
NSString *delegateName = realDelegate ? NSStringFromClass(realDelegate) : @"unknown";
|
|
321
|
-
NSString *persisted = DevConnectPersistedMetroHost();
|
|
322
|
-
|
|
323
|
-
#if DEBUG
|
|
324
|
-
BOOL isDebug = YES;
|
|
325
|
-
#else
|
|
326
|
-
BOOL isDebug = NO;
|
|
327
|
-
#endif
|
|
328
|
-
|
|
329
|
-
resolve(@{
|
|
330
|
-
@"persistedMetroHost": persisted.length > 0 ? persisted : [NSNull null],
|
|
331
|
-
@"appDelegateClass": delegateName,
|
|
332
|
-
@"isDebugBuild": @(isDebug),
|
|
333
|
-
@"hasEmbeddedBundle": @(DebugToolkitEmbeddedBundleURL() != nil),
|
|
334
|
-
@"embeddedFirstHookInstalled": @(DevConnectEmbeddedFirstHooksActive()),
|
|
335
|
-
@"packagerHookInstalled": @NO,
|
|
336
|
-
@"bundleRootHookInstalled": @(gBundleRootHookInstalled),
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
19
|
RCT_EXPORT_METHOD(getPreference:(NSString *)key
|
|
341
20
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
342
21
|
rejecter:(__unused RCTPromiseRejectBlock)reject)
|
|
@@ -53,6 +53,12 @@ function resolveFeatureConfigs(configs) {
|
|
|
53
53
|
function resolveDefaultFeatures() {
|
|
54
54
|
return DEFAULT_FEATURES.map(name => featureRegistry[name]());
|
|
55
55
|
}
|
|
56
|
+
function appendCustomFeatures(builtInFeatures, customFeatures) {
|
|
57
|
+
if (!customFeatures || customFeatures.length === 0) {
|
|
58
|
+
return builtInFeatures;
|
|
59
|
+
}
|
|
60
|
+
return [...builtInFeatures, ...customFeatures];
|
|
61
|
+
}
|
|
56
62
|
|
|
57
63
|
/**
|
|
58
64
|
* Initialize the debug toolkit.
|
|
@@ -77,7 +83,8 @@ async function initializeDebugToolkit(options) {
|
|
|
77
83
|
enabled = isDebugMode;
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
|
-
const
|
|
86
|
+
const resolvedBuiltInFeatures = options?.features ? resolveFeatureConfigs(options.features) : resolveDefaultFeatures();
|
|
87
|
+
const resolvedFeatures = appendCustomFeatures(resolvedBuiltInFeatures, options?.customFeatures);
|
|
81
88
|
try {
|
|
82
89
|
_DebugToolkit.DebugToolkit.setEnabled(enabled);
|
|
83
90
|
if (!enabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_DebugToolkit","require","_network","_console","_zustand","_navigation","_track","_environment","_clipboard","_devConnect","_DaemonClient","isDebugMode","__DEV__","featureRegistry","network","createNetworkFeature","console","createConsoleLogFeature","zustand","createZustandLogFeature","navigation","createNavigationLogFeature","track","createTrackFeature","environment","createEnvironmentFeature","clipboard","createClipboardFeature","devConnect","createDevConnectFeature","DEFAULT_FEATURES","resolveFeatureConfigs","configs","features","entries","Object","name","config","creator","warn","undefined","push","resolveDefaultFeatures","map","initializeDebugToolkit","options","enabled","nativeResult","nativeIsDebugBuild","resolvedFeatures","DebugToolkit","setEnabled","reset","replaceFeatures","daemonClient","setEndpointDetector","url","addToBlacklist","hasFeatures","showLauncher","hideLauncher","restoreDevConnectSettingsToDaemon","then","restore","catch","error"],"sourceRoot":"../../../src","sources":["core/initialize.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAGA,MAAMU,WAAW,GAAGC,OAAO;;AAE3B;;
|
|
1
|
+
{"version":3,"names":["_DebugToolkit","require","_network","_console","_zustand","_navigation","_track","_environment","_clipboard","_devConnect","_DaemonClient","isDebugMode","__DEV__","featureRegistry","network","createNetworkFeature","console","createConsoleLogFeature","zustand","createZustandLogFeature","navigation","createNavigationLogFeature","track","createTrackFeature","environment","createEnvironmentFeature","clipboard","createClipboardFeature","devConnect","createDevConnectFeature","DEFAULT_FEATURES","resolveFeatureConfigs","configs","features","entries","Object","name","config","creator","warn","undefined","push","resolveDefaultFeatures","map","appendCustomFeatures","builtInFeatures","customFeatures","length","initializeDebugToolkit","options","enabled","nativeResult","nativeIsDebugBuild","resolvedBuiltInFeatures","resolvedFeatures","DebugToolkit","setEnabled","reset","replaceFeatures","daemonClient","setEndpointDetector","url","addToBlacklist","hasFeatures","showLauncher","hideLauncher","restoreDevConnectSettingsToDaemon","then","restore","catch","error"],"sourceRoot":"../../../src","sources":["core/initialize.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAGA,MAAMU,WAAW,GAAGC,OAAO;;AAE3B;;AAkBA;AACA;AACA;AACA,MAAMC,eAA8E,GAAG;EACrFC,OAAO,EAAEC,6BAAoB;EAC7BC,OAAO,EAAEC,gCAAuB;EAChCC,OAAO,EAAEC,gCAAuB;EAChCC,UAAU,EAAEC,sCAA0B;EACtCC,KAAK,EAAEC,yBAAkB;EACzBC,WAAW,EAAEC,qCAAwB;EACrCC,SAAS,EAAEC,iCAAsB;EACjCC,UAAU,EAAEC;AACd,CAAC;AAED,MAAMC,gBAAsC,GAAG,CAC7C,SAAS,EACT,SAAS,EACT,YAAY,EACZ,SAAS,EACT,OAAO,EACP,WAAW,EACX,YAAY,CACb;AAED,SAASC,qBAAqBA,CAACC,OAAuB,EAAqB;EACzE,MAAMC,QAA2B,GAAG,EAAE;EACtC,MAAMC,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACF,OAAO,CAAoC;EAE1E,KAAK,MAAM,CAACI,IAAI,EAAEC,MAAM,CAAC,IAAIH,OAAO,EAAE;IACpC,IAAIG,MAAM,KAAK,KAAK,EAAE;IAEtB,MAAMC,OAAO,GAAGzB,eAAe,CAACuB,IAAI,CAAC;IACrC,IAAI,CAACE,OAAO,EAAE;MACZtB,OAA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