Convert the encoded DCF and ServerFigmaDocs to Proto #1941
Merged
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.
Based on PR #1886
Chain of upstream PRs as of 2024-12-23
PR [PROTOCONV] Convert the Kotlin code to Proto #1886:
main
←feature/protoconv
feature/protoconv
←wb/froeht/protolize-dcf
This PR should convert all of our code that serializes and deserializes DCF files and the ServerFigmaDoc to encode them as Proto messages (mostly). This includes sending the doc from figma_import to the kotlin code via JNI.
The old DCF format consisted of the bincode-encoded header, bincode-encoded doc, and JSON-encoded image session all concatenated together. I've simply converted the bincode encoding to proto encoding, using the
encode/decodeDelimited()
functions that proto provides to write the length of the encoded message first, followed by the message. This results in pretty clean code on both sides, especially the Kotlin side which can just read through the input stream.I've added some tests in Common to decode and re-encode the DesignSwitcher and HelloWorld docs. These can be run right now, because we haven't broken the Common code. I've also enhanced the Figma_import fetch_tests to write the fetched doc to a file and read it back in.
You can test these by running
./gradlew common:test
andcargo test --all-features