@@ -106,6 +106,22 @@ public interface SymbolicationListener {
106
106
void onSymbolicationComplete (@ Nullable Iterable <StackFrame > stackFrames );
107
107
}
108
108
109
+ private enum BundleType {
110
+ BUNDLE ("bundle" ),
111
+ DELTA ("delta" ),
112
+ MAP ("map" );
113
+
114
+ private final String mTypeID ;
115
+
116
+ BundleType (String typeID ) {
117
+ mTypeID = typeID ;
118
+ }
119
+
120
+ public String typeID () {
121
+ return mTypeID ;
122
+ }
123
+ }
124
+
109
125
private final DevInternalSettings mSettings ;
110
126
private final OkHttpClient mClient ;
111
127
private final Handler mRestartOnChangePollingHandler ;
@@ -427,16 +443,20 @@ private boolean getJSMinifyMode() {
427
443
return mSettings .isJSMinifyEnabled ();
428
444
}
429
445
430
- private static String createBundleURL (
431
- String host , String jsModulePath , boolean devMode , boolean jsMinify , boolean useDeltas ) {
446
+ private String createBundleURL (String mainModuleID , BundleType type , String host ) {
432
447
return String .format (
433
448
Locale .US ,
434
449
BUNDLE_URL_FORMAT ,
435
450
host ,
436
- jsModulePath ,
437
- useDeltas ? "delta" : "bundle" ,
438
- devMode ,
439
- jsMinify );
451
+ mainModuleID ,
452
+ type .typeID (),
453
+ getDevMode (),
454
+ getJSMinifyMode ());
455
+ }
456
+
457
+ private String createBundleURL (String mainModuleID , BundleType type ) {
458
+ return createBundleURL (
459
+ mainModuleID , type , mSettings .getPackagerConnectionSettings ().getDebugServerHost ());
440
460
}
441
461
442
462
private static String createResourceURL (String host , String resourcePath ) {
@@ -453,11 +473,10 @@ private static String createOpenStackFrameURL(String host) {
453
473
454
474
public String getDevServerBundleURL (final String jsModulePath ) {
455
475
return createBundleURL (
456
- mSettings .getPackagerConnectionSettings ().getDebugServerHost (),
457
- jsModulePath ,
458
- getDevMode (),
459
- getJSMinifyMode (),
460
- mSettings .isBundleDeltasEnabled ());
476
+ jsModulePath ,
477
+ mSettings .isBundleDeltasEnabled () ? BundleType .DELTA : BundleType .BUNDLE ,
478
+ mSettings .getPackagerConnectionSettings ().getDebugServerHost ()
479
+ );
461
480
}
462
481
463
482
public void isPackagerRunning (final PackagerStatusCallback callback ) {
@@ -614,33 +633,20 @@ public void onResponse(Call call, Response response) throws IOException {
614
633
}
615
634
616
635
public String getSourceMapUrl (String mainModuleName ) {
617
- return String .format (
618
- Locale .US ,
619
- BUNDLE_URL_FORMAT ,
620
- mSettings .getPackagerConnectionSettings ().getDebugServerHost (),
621
- mainModuleName ,
622
- "map" ,
623
- getDevMode (),
624
- getJSMinifyMode ());
636
+ return createBundleURL (mainModuleName , BundleType .MAP );
625
637
}
626
638
627
639
public String getSourceUrl (String mainModuleName ) {
628
- return String .format (
629
- Locale .US ,
630
- BUNDLE_URL_FORMAT ,
631
- mSettings .getPackagerConnectionSettings ().getDebugServerHost (),
632
- mainModuleName ,
633
- mSettings .isBundleDeltasEnabled () ? "delta" : "bundle" ,
634
- getDevMode (),
635
- getJSMinifyMode ());
640
+ return createBundleURL (
641
+ mainModuleName , mSettings .isBundleDeltasEnabled () ? BundleType .DELTA : BundleType .BUNDLE );
636
642
}
637
643
638
644
public String getJSBundleURLForRemoteDebugging (String mainModuleName ) {
639
645
// The host we use when connecting to the JS bundle server from the emulator is not the
640
646
// same as the one needed to connect to the same server from the JavaScript proxy running on the
641
647
// host itself.
642
648
return createBundleURL (
643
- getHostForJSProxy (), mainModuleName , getDevMode (), getJSMinifyMode (), false );
649
+ mainModuleName , BundleType . BUNDLE , getHostForJSProxy () );
644
650
}
645
651
646
652
/**
0 commit comments