-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat (cli) Added Brave Browser debugger support #25109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for bringing this great pr. i'm leaving some comments and will need to test brave on windows and linux before merging it.
packages/@expo/cli/src/start/server/type-generation/__typetests__/fixtures/basic.ts
Outdated
Show resolved
Hide resolved
@@ -15,6 +19,21 @@ export interface MetroInspectorProxyApp { | |||
|
|||
let openingBrowserInstance: LaunchBrowserInstance | null = null; | |||
|
|||
const IS_WSL = require('is-wsl') && !require('is-docker')(); | |||
|
|||
function createBrowser() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you share the insight why you would like to move the internal createBrowser
from LaunchBrowser.ts to JsInspector.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved createBrowser
to JSInspector.ts because createBrowser
was only being used in LaunchBrowser.ts. So I could have exported createBrowser
from LaunchBrowser.ts or just move it to JSInspector.ts. The former made more sense to me. Nevertheless, if the latter makes more sense I can adjust the changes accordingly.
And I did all of that just to to inject a LaunchBrowserImpl
instance into the launchBrowserAsync
function and make it testable. Yeah, sure, I could've used jest.mock
instead, but I am not fond of jest.mock
and I find this to be the safer way. But if using jest.mock
suits this project more, I could also do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i think exporting createBrowser
makes more sense and also helps LaunchBrowser.ts isolated.
Our test target would then change to createBrowser
and we coud also move the logic here into the createBrowser
.
expo/packages/@expo/cli/src/start/server/middleware/inspector/LaunchBrowser.ts
Lines 33 to 35 in 95eaac9
for (const browserType of [LaunchBrowserTypes.CHROME, LaunchBrowserTypes.EDGE]) { | |
const isSupported = await browser.isSupportedBrowser(browserType); | |
if (isSupported) { |
does that sound good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've understood the first part and I'll export the createBrowser
function from LaunchBrowser.ts.
But I am not entirely sure what you mean by the second part: to move the browser is supported check to the createBrowser
function. You mean you want to check if the browser is supported, before returning the LaunchBrowserImpl
instance from createBrowser
? Something like:
export async function createBrowserAsync(
platform: NodeJS.Platform,
supportedBrowsers: LaunchBrowserTypes[]
) {
let browserImpl: LaunchBrowserImpl | undefined = undefined;
if (platform === 'darwin') {
browserImpl = new LaunchBrowserImplMacOS();
}
if (platform === 'win32' || IS_WSL) {
browserImpl = new LaunchBrowserImplWindows();
}
if (platform === 'linux') {
browserImpl = new LaunchBrowserImplLinux();
}
if (browserImpl === undefined) {
throw new Error('[LaunchBrowser] Unsupported host platform');
}
let supportedBrowsersCount = 0;
for (const browserType of supportedBrowsers) {
const isSupported = await browserImpl.isSupportedBrowser(browserType);
if (isSupported) {
supportedBrowsersCount++;
}
}
if (supportedBrowsersCount === 0) {
throw new Error(
`[LaunchBrowser] Unable to find a browser on the host to open the inspector. Supported browsers: ${supportedBrowsers.join(
', '
)}`
);
}
return browserImpl;
}
If this is what you meant, then I will still have to loop over the supportedBrowsers
array inside of LaunchBrowser
:
expo/packages/@expo/cli/src/start/server/middleware/inspector/LaunchBrowser.ts
Lines 33 to 38 in 95eaac9
for (const browserType of [LaunchBrowserTypes.CHROME, LaunchBrowserTypes.EDGE]) { | |
const isSupported = await browser.isSupportedBrowser(browserType); | |
if (isSupported) { | |
return browser.launchAsync(browserType, launchArgs); | |
} | |
} |
In order to call browser.launchAsync
with the browserType
argument.
I have a feeling that I misunderstood you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i didn't describe it clearly. let's show the code directly: https://github.com/expo/expo/compare/%40kudo/pr-25109
if there's still any unclear part, please feel free to let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is clear now. Thank you for the clarification and your code.
I rebased to your branch.
2810d0e
to
1c7855e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for helping that. i've got a chance to test brave on linux and windows. please help to revise the launch id accordingly.
packages/@expo/cli/src/start/server/middleware/inspector/LaunchBrowserImplLinux.ts
Outdated
Show resolved
Hide resolved
packages/@expo/cli/src/start/server/middleware/inspector/LaunchBrowser.types.ts
Outdated
Show resolved
Hide resolved
packages/@expo/cli/src/start/server/middleware/inspector/LaunchBrowserImplWindows.ts
Outdated
Show resolved
Hide resolved
packages/@expo/cli/src/start/server/type-generation/__typetests__/fixtures/basic.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's ready to go. thanks again for the awesome work.
Why
I wanted to debug my app using Brave Browser, but I couldn't. So I decided to add support for it.
How
By extending the
LaunchBrowser
andLaunchBrowserImpl
functionalities.Test Plan
Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).