Skip to content
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

[expo] introduce api for devtools plugin #24667

Merged
merged 5 commits into from
Oct 21, 2023
Merged

[expo] introduce api for devtools plugin #24667

merged 5 commits into from
Oct 21, 2023

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Sep 28, 2023

Why

for devtools plugins integration
close ENG-9981
close ENG-10329

having series prs to add devtools plugins support:

How

introduce useDevToolsPluginClient(pluginName) hook from the expo package. this api has some designs in mind:

  • pluginName as message namespace. so that method hello from different plugins will not conflict.
  • the websocket client in the app supports multiplexing. multiple plugins would have just one websocket client and will terminate the connection once reference count reaches zero.
  • if multiple webpages with the same pluginName connect to the app, we will terminate previous connection and let the latest plugin webpage win.

Test Plan

add some unit test and ci passed

Checklist

@linear
Copy link

linear bot commented Oct 2, 2023

@Kudo Kudo marked this pull request as ready for review October 2, 2023 14:31
@Kudo Kudo requested review from byCedric and EvanBacon and removed request for ide and tsapeta October 2, 2023 14:32
@Kudo Kudo changed the title [expo] introduce @expo/devtools for devtools plugin [expo] introduce api for devtools plugin Oct 18, 2023
@linear
Copy link

linear bot commented Oct 18, 2023

ENG-10329 Handle multiple devices workflow

Currently the devtool plugin clients broadcast messages on the ws://{devServer}/message endpoint. If there are multiple devices connected, the messages will conflict. We should maybe passing some id to between the messages.

Copy link
Member

@brentvatne brentvatne left a comment

Choose a reason for hiding this comment

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

introduce useDevToolsPluginClient(pluginName) hook from the expo package

nice :) that simplifies the api.

as discussed last week, let's follow up at some point with some concept of a device id that is built into the client, so there is a first class concept built into this api for plugins to be able to handle multiple devices

*/
public abstract isConnected(): boolean;

protected handleMessage = (event: WebSocketMessageEvent): void => {
Copy link
Member

Choose a reason for hiding this comment

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

One nitpick: prefer using functions over arrow functions when the arrow function is not necessary 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is required because we want to bind "this" to the DevToolsPluginClient class. since the function would be called inside an event callback.

Kudo added a commit that referenced this pull request Oct 21, 2023
# Why

support devtools plugins for autolinking
close ENG-9981

having series prs to add devtools plugins support:
- #24649
- #24650 
- #24667

# How

- add `devtools` as a platform
- passing `projectRoot` rather than default implicit `process.cwd()`
- exposing autolinking interfaces for cli integration
- introduce `onlyProjectDeps` for not filtering out project dependencies from monorepo

# Test Plan

- ci passed
- manual test from devtools plugins

---------

Co-authored-by: Tomasz Sapeta <tomasz.sapeta@swmansion.com>
Kudo added a commit that referenced this pull request Oct 21, 2023
# Why

add devtools plugins support to cli
close ENG-9981

having series prs to add devtools plugins support:
- #24649
- #24650 
- #24667

# How

- [prebuild-config] update expo-modules-autolinking integrate because now it exports public apis from #24649
- [cli] add `DevToolsPluginManager` and `DevToolsPluginMiddleware` for devtools plugins support

# Test Plan

add unit tests and ci passed
@Kudo
Copy link
Contributor Author

Kudo commented Oct 21, 2023

as discussed last week, let's follow up at some point with some concept of a device id that is built into the client, so there is a first class concept built into this api for plugins to be able to handle multiple devices

will follow up this in a separate pr and going to merge this.

@Kudo Kudo merged commit e27f0db into main Oct 21, 2023
7 checks passed
@Kudo Kudo deleted the @kudo/devtools-plugin-3 branch October 21, 2023 15:52
marklawlor pushed a commit that referenced this pull request Oct 30, 2023
# Why

support devtools plugins for autolinking
close ENG-9981

having series prs to add devtools plugins support:
- #24649
- #24650 
- #24667

# How

- add `devtools` as a platform
- passing `projectRoot` rather than default implicit `process.cwd()`
- exposing autolinking interfaces for cli integration
- introduce `onlyProjectDeps` for not filtering out project dependencies from monorepo

# Test Plan

- ci passed
- manual test from devtools plugins

---------

Co-authored-by: Tomasz Sapeta <tomasz.sapeta@swmansion.com>
marklawlor pushed a commit that referenced this pull request Oct 30, 2023
# Why

add devtools plugins support to cli
close ENG-9981

having series prs to add devtools plugins support:
- #24649
- #24650 
- #24667

# How

- [prebuild-config] update expo-modules-autolinking integrate because now it exports public apis from #24649
- [cli] add `DevToolsPluginManager` and `DevToolsPluginMiddleware` for devtools plugins support

# Test Plan

add unit tests and ci passed
marklawlor pushed a commit that referenced this pull request Oct 30, 2023
# Why

for devtools plugins integration
close ENG-9981
close ENG-10329

having series prs to add devtools plugins support:
- #24649
- #24650 
- #24667

# How

introduce `useDevToolsPluginClient(pluginName)` hook from the expo package. this api has some designs in mind:
- pluginName as message namespace. so that method `hello` from different plugins will not conflict.
- the websocket client in the app supports multiplexing. multiple plugins would have just one websocket client and will terminate the connection once reference count reaches zero.
- if multiple webpages with the same pluginName connect to the app, we will terminate previous connection and let the latest plugin webpage win.

# Test Plan

add some unit test and ci passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants