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

Add networked-dom-v0.2 protocol (#54) #210

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

MarcusLongmuir
Copy link
Collaborator

@MarcusLongmuir MarcusLongmuir commented Jan 14, 2025

Resolves #54

This PR adds a new iteration of the Networked DOM Protocol, networked-dom-v0.2 as a progression from networked-dom-v0.1.

This new protocol is binary-based and is based on uvarints, varints, and UTF-8 strings.

This new version of the protocol addresses multiple issues:

  • The protocol now supports representing multiple users' views with a single connection - allowing multiplexing/fan-out proxies
  • The protocol is binary-based rather than JSON-based which speeds up encoding by ~3x, decoding by ~2x, and reduces encoded size by ~3x.
  • The protocol adds support for batching multiple diffs together which avoids a client seeing/rendering a partial set of changes to the DOM (e.g. only some attributes of an animation element updating).

This PR adds support for networked-dom-v0.2 to the @mml-io/networked-dom-document library which now supports both networked-dom-v0.2 and networked-dom-v0.1 protocols for incoming WebSocket connections.

The NetworkedDOM class has been overhauled to support both protocols, and has had significant optimisations done to it in the process, including doing a single stringifying/encoding of messages for multiple clients for most mutations that affect all clients.


What kind of changes does your PR introduce? (check at least one)

  • Feature
  • Refactor

Does your PR introduce a breaking change? (check one)

  • No

Does your PR fulfill the following requirements?

  • All tests are passing
  • The title references the corresponding issue # (if relevant)

@MarcusLongmuir MarcusLongmuir force-pushed the feature/networked-dom-v02-protocol branch from d65241a to 886d735 Compare January 14, 2025 17:56
Copy link

github-actions bot commented Jan 14, 2025

🪓 PR closed, deleted preview at https://github.com/mml-io/mml/tree/gh-pages/pull/210/

TheCodeTherapy
TheCodeTherapy previously approved these changes Jan 17, 2025
@MarcusLongmuir MarcusLongmuir merged commit b3f15f5 into main Jan 20, 2025
9 checks passed
@MarcusLongmuir MarcusLongmuir deleted the feature/networked-dom-v02-protocol branch January 20, 2025 10:52
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.

NetworkedDOM Protocol v0.2
2 participants