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

Convert the encoded DCF and ServerFigmaDocs to Proto #1941

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

timothyfroehlich
Copy link
Member

@timothyfroehlich timothyfroehlich commented Dec 23, 2024

Based on PR #1886

Chain of upstream PRs as of 2024-12-23

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 and cargo test --all-features

crates/dc_bundle/src/legacy_definition.rs Show resolved Hide resolved
crates/figma_import/src/fetch.rs Show resolved Hide resolved
crates/figma_import/src/tools/fetch.rs Outdated Show resolved Hide resolved
@timothyfroehlich timothyfroehlich merged commit 353b560 into feature/protoconv Dec 26, 2024
14 of 22 checks passed
@timothyfroehlich timothyfroehlich deleted the wb/froeht/protolize-dcf branch December 26, 2024 21:41
timothyfroehlich added a commit that referenced this pull request Dec 26, 2024
<!-- start git-machete generated -->

# Based on PR #1947

## Chain of upstream PRs as of 2024-12-26

* PR #1886:
  `main` ← `feature/protoconv`

  * PR #1941:
    `feature/protoconv` ← `wb/froeht/protolize-dcf`

    * PR #1943:
      `wb/froeht/protolize-dcf` ← `wb/froeht/delete-proto-utils`

      * PR #1946:
`wb/froeht/delete-proto-utils` ←
`wb/froeht/temp-disable-variant-animation-test`

        * PR #1947:
`wb/froeht/temp-disable-variant-animation-test` ←
`wb/froeht/remove-serde-from-kotlin`

          * **PR #1948 (THIS ONE)**:
`wb/froeht/remove-serde-from-kotlin` ←
`wb/froeht/resolve-runtime-exceptions`

<!-- end git-machete generated -->

Protobuf maps are immutable and need to be modified by copying them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants