feat(tldraw): add headless RoomSnapshot to .tldr conversion#8590
Draft
steveruizok wants to merge 7 commits into
Draft
feat(tldraw): add headless RoomSnapshot to .tldr conversion#8590steveruizok wants to merge 7 commits into
steveruizok wants to merge 7 commits into
Conversation
Adds a pure `roomSnapshotToTldrawFile` helper that converts a `RoomSnapshot` (as produced by the sync server) into a `TldrawFile` without needing a live editor, DOM, or network access. Session-scoped records are dropped and orphan assets are pruned. Also adds a small tsx-based CLI at `apps/dotcom/sync-worker/scripts/snapshot-to-tldr.ts` that reads a `RoomSnapshot` JSON from stdin/`--in` and writes the resulting `.tldr` JSON to stdout/`--out`, for debugging bucket snapshots. Closes #8589
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
Collaborator
Author
|
@copilot review |
Contributor
|
Hey, thanks for your pull request! Before we can merge your PR, you will need to sign our Contributor License Agreement by posting a comment that reads:
|
Contributor
Self-review done. Found and fixed the main issue: duplicated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to turn a sync-worker
RoomSnapshotJSON blob (as written to the R2rooms-history-ephemeralbucket) into a standard.tldrfile without spinning up a liveEditoror touching the DOM, this PR adds a pureroomSnapshotToTldrawFilehelper in thetldrawpackage plus a small tsx-based CLI in the sync-worker. Closes #8589.The helper:
document,page,shape,asset,binding) and drops session-scoped records (instance,instance_page_state,instance_presence,camera,pointer,user).The CLI (
apps/dotcom/sync-worker/scripts/snapshot-to-tldr.ts) reads aRoomSnapshotJSON from stdin or--in <path>, runs it through the helper, and writes the result to stdout or--out <path>. It imports the helper directly from its source file so we don't load the fulltldrawpackage (React, editor, styles) just to transform JSON.Asset URL rewriting / data-URI inlining is explicitly out of scope, since that needs a DOM or network. Consumers that want inlined assets can re-import the file into an editor and use the existing
serializeTldrawJsonpath.API changes
roomSnapshotToTldrawFile(snapshot)— pure conversion from aRoomSnapshot-shaped input to aTldrawFile.RoomSnapshotLikeinterface — a structural mirror of@tldraw/sync-core'sRoomSnapshot, used as the helper's input type so thattldrawdoes not need to depend onsync-core. Any realRoomSnapshotis structurally assignable to it.Change type
featureTest plan
.tldrin the tldraw editor (yarn dev,File → Open). Confirm shapes, pages, and bindings load with no parse errors.Release notes
roomSnapshotToTldrawFile, a pure helper that converts a syncRoomSnapshotJSON blob into a.tldr-compatibleTldrawFilewithout needing a live editor or DOM.Code changes