Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export class NetworkPlugin implements ToolPlugin {
inspectorBridge: RadonInspectorBridge,
networkBridge: NetworkBridge,
metroPort: number,
useNativeNetworkInspectorFlag: boolean
useNativeNetworkInspector: boolean
) {
this.networkInspector = useNativeNetworkInspectorFlag
this.networkInspector = useNativeNetworkInspector
? new DebuggerNetworkInspector(inspectorBridge, networkBridge, metroPort)
: new InspectorBridgeNetworkInspector(inspectorBridge, metroPort);
initialize();
Expand Down
13 changes: 1 addition & 12 deletions packages/vscode-extension/src/project/ApplicationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ function checkFuseboxSupport(appRoot: string): boolean {
return supportsFusebox;
}

function checkNativeNetworkInspectorSupport(appRoot: string): boolean {
const reactNativeVersion = getReactNativeVersion(appRoot);
if (reactNativeVersion === null) {
return false;
}
const supportsNativeNetworkInspector = reactNativeVersion.compare("0.83.0") >= 0;
return supportsNativeNetworkInspector;
}

function resolveLaunchConfig(configuration: LaunchConfiguration): ResolvedLaunchConfig {
const appRoot = configuration.appRoot;
const absoluteAppRoot = path.resolve(workspace.workspaceFolders![0].uri.fsPath, appRoot);
Expand Down Expand Up @@ -115,9 +106,7 @@ function resolveLaunchConfig(configuration: LaunchConfiguration): ResolvedLaunch
},
usePrebuild: configuration.usePrebuild,
useOldDevtools: configuration.useOldDevtools ?? !checkFuseboxSupport(absoluteAppRoot),
useNativeNetworkInspector:
configuration.useNativeNetworkInspector ??
checkNativeNetworkInspectorSupport(absoluteAppRoot),
useNativeNetworkInspector: configuration.useNativeNetworkInspector,
};
}

Expand Down
30 changes: 29 additions & 1 deletion packages/vscode-extension/src/project/applicationSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ export class ApplicationSession implements Disposable {
this.applicationContext,
devtoolsInspectorBridge,
this.networkBridge,
this.metro.port
this.metro.port,
this.shouldEnableNativeNetworkInspector()
);

this.disposables.push(this.toolsManager);
Expand Down Expand Up @@ -316,6 +317,33 @@ export class ApplicationSession implements Disposable {

// #region Tools

private shouldEnableNativeNetworkInspector(): boolean {
const launchConfig = this.applicationContext.launchConfig;
const useNativeNetworkInspectorFlag = launchConfig.useNativeNetworkInspector;

const explicitlyEnabled = useNativeNetworkInspectorFlag === true;
const explicitlyDisabled = useNativeNetworkInspectorFlag === false;

if (explicitlyEnabled) {
return true;
}
if (explicitlyDisabled) {
return false;
}

const reactNativeVersion = this.applicationContext.reactNativeVersion;
const meetsMinimumVersion = (reactNativeVersion?.compare("0.83.0") ?? -1) >= 0;
const isAndroid = this.device.platform === DevicePlatform.Android;
const isAndroid0830 = reactNativeVersion?.compare("0.83.0") === 0 && isAndroid;

// RN 0.83.0 on Android has known issues with native network inspector
if (isAndroid0830) {
return false;
}

return meetsMinimumVersion;
}
Comment on lines +320 to +345
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this, but I don't have a better idea.


public async updateToolEnabledState(toolName: ToolKey, enabled: boolean) {
return this.toolsManager.updateToolEnabledState(toolName, enabled);
}
Expand Down
12 changes: 3 additions & 9 deletions packages/vscode-extension/src/project/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ export class ToolsManager implements Disposable {
private disposables: Disposable[] = [];
private readonly workspaceConfigState: StateManager<WorkspaceConfiguration>;
private readonly launchConfig: ResolvedLaunchConfig;
private readonly useNativeNetworkInspectorFlag: boolean;

public constructor(
private readonly stateManager: StateManager<ToolsState>,
private readonly applicationContext: ApplicationContext,
public readonly inspectorBridge: RadonInspectorBridge,
public readonly networkBridge: NetworkBridge,
public readonly metroPort: number
public readonly metroPort: number,
private readonly useNativeNetworkInspector: boolean
) {
this.workspaceConfigState = this.applicationContext.workspaceConfigState;
this.launchConfig = this.applicationContext.launchConfig;
this.useNativeNetworkInspectorFlag = this.launchConfig.useNativeNetworkInspector ?? false;

this.toolsSettings = Object.assign({}, extensionContext.workspaceState.get(TOOLS_SETTINGS_KEY));
for (const plugin of createExpoDevPluginTools()) {
Expand All @@ -106,12 +105,7 @@ export class ToolsManager implements Disposable {
this.plugins.set(APOLLO_PLUGIN_ID, new ApolloClientDevtoolsPlugin(inspectorBridge));
this.plugins.set(
NETWORK_PLUGIN_ID,
new NetworkPlugin(
inspectorBridge,
networkBridge,
metroPort,
this.useNativeNetworkInspectorFlag
)
new NetworkPlugin(inspectorBridge, networkBridge, metroPort, this.useNativeNetworkInspector)
);
this.plugins.set(
RENDER_OUTLINES_PLUGIN_ID,
Expand Down
Loading