Skip to content

Add developer tools extension.#1094

Closed
teymour-aldridge wants to merge 35 commits intoyewstack:masterfrom
teymour-aldridge:devtools
Closed

Add developer tools extension.#1094
teymour-aldridge wants to merge 35 commits intoyewstack:masterfrom
teymour-aldridge:devtools

Conversation

@teymour-aldridge
Copy link
Copy Markdown
Contributor

This (draft) pull request implements feature #1090. It opens a WebSocket connection using a thread_local! and sends information about components to a (not yet developed) browser extension to make it easier to debug Yew applications.

@jstarry
Copy link
Copy Markdown
Member

jstarry commented Apr 20, 2020

@teymour-aldridge could you please rebase off latest master. CI times have been reduced and repo structure has been updated

@teymour-aldridge teymour-aldridge marked this pull request as ready for review May 1, 2020 07:46
Copy link
Copy Markdown
Member

@jstarry jstarry left a comment

Choose a reason for hiding this comment

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

@teymour-aldridge could you please rebase your changes off of master? There are a lot of changes in this PR that are unrelated to dev tools (I think from a bad merge?)

@teymour-aldridge
Copy link
Copy Markdown
Contributor Author

teymour-aldridge commented May 3, 2020 via email

@jstarry
Copy link
Copy Markdown
Member

jstarry commented May 3, 2020

@teymour-aldridge good luck! If you can't get it working lmk and I can fix it for you

@teymour-aldridge
Copy link
Copy Markdown
Contributor Author

@jstarry I think I've now done this successfully. If I haven't, would you mind letting me know?

Comment thread yew/src/lib.rs
pub mod dev;

#[cfg(feature = "dev")]
thread_local! {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: can you please move this inside the dev module? I don't think it needs to be here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, I'll move it into the dev module.

Chunk(Option<FileChunk>),
Files(Vec<File>, Chunks),
ToggleByChunks,
InvalidString,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The changes in this file can be removed. In a separate change, I changed the type of Chunk to use Option<FileChunk>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Comment thread Cargo.toml Outdated
"examples/two_apps",
"examples/webgl",
]
] No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: please add a newline to remove this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

serde = "1"
serde_derive = "1"
yew = { path = "../../yew" }
yew = { path = "../../yew", features = ["std_web"] }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: revert this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

</head>
<body>
<script src="/todomvc.js"></script>
<script src="/todomvc_std_web.js"></script>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: revert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Comment thread yew/src/app.rs Outdated
pub fn mount(self, element: Element) -> ComponentLink<COMP> {
#[cfg(feature = "dev")]
let _ = wasm_bindgen_futures::spawn_local(async move {
let new_debugger = crate::dev::DebuggerConnection::new().await;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this is necessary if you have a message queue. The debugger connection message queue should be immediately available

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No – it's here from before I added the message queue.

Comment thread yew/src/dev/mod.rs

/// Describes the state of a WebSocket connection.
#[derive(Debug)]
pub enum ConnectionState {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No (and the future isn't being used either). It's some code I had here when I was trying to work out how to handle the WebSocket connection.
I'm now using an event listener to send messages when the connection opens (I'll also add one to raise an error if it can't connect).

Comment thread yew/src/dev/messages.rs Outdated
/// The event which has happened
event: ComponentEvent,
/// Optional additional data about the event.
data: Option<DebugComponent>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why would this ever be None?

Comment thread yew/src/dev/messages.rs Outdated
/// A message sent to describe a change in a component's state.
#[derive(Serialize, Debug)]
pub struct ComponentMessage {
/// Time in seconds since the page was loaded.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be milliseconds, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Comment thread yew/src/dev/messages.rs Outdated
#[derive(Serialize, Debug)]
pub struct ComponentMessage {
/// Time in seconds since the page was loaded.
time: f64,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the purpose of sending this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought it could be used to build a timeline of events on the page.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The extension will receive messages in order so I think it can handle timestamping on its end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, I'll remove the field.

@jstarry
Copy link
Copy Markdown
Member

jstarry commented May 10, 2020

This is a good first step, let me know if you need any clarification on my comments!

@teymour-aldridge teymour-aldridge marked this pull request as draft May 11, 2020 07:43
@totorigolo
Copy link
Copy Markdown
Contributor

I love this PR. Did you start working on the browser extension?

@teymour-aldridge
Copy link
Copy Markdown
Contributor Author

teymour-aldridge commented May 12, 2020

This PR (I love it too!) is a mess right now. I'm trying to fix it, but once that's done I intend to start working on the browser extension.

My thoughts on the browser extension are that hopefully I'll be able to get the extension to open a WebSocket server, but I suspect that a server running locally coordinating the extension and the code may be necessary which would in turn require a command line script.

I'm not sure when this will be releasable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants