Repository navigation
Conversation
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.
Refactor so that the
spark-rswasm project generates proper TypeScript types, which in turn are used by the worker. Motivation for this change comes from trying to add support for theextraandcommentfields of SOGv3. Since these will have to be parsed byspark-liband passed throughspark-rs->worker->Packed/ExtSplatsit's important each conversion happens safely. Without proper type information this becomes a lot more error-prone and maintenance heavy.The old flow had the following steps:
spark-rsgenerated a JS object dynamically for eitherPackedSplatsorExtSplatsspark_rs.d.tsdeclared these asanyworker.tscasts these to eitherDecodedPackedResult/DecodedExtResultworker.tsconverts fromDecodedPackedResult/DecodedExtResultto a sharedPackedResult/ExtResult(indefines.ts)PackedResult/ExtResultare compatible withPackedSplatsOptions/ExtSplatsOptionsThis PR introduces the
PackedSplatsResultandExtSplatsResultstructs in Rust, annotated usingtsify, so that it generates proper types. These have been structured in such a way that the conversion inworker.tsis no longer needed, resulting in the following steps:spark-rscreates an instance ofPackedSplatsResult/ExtSplatsResultspark_rs.d.tshas proper TypeScript types for theseworker.tscan simply return these to the callerPackedSplatsResult/ExtSplatsResultare compatible withPackedSplatsOptions/ExtSplatsOptionsFor further type safety, the
ChunkDecoderis made generic (on the TypeScript side). This allows adecoder.finish()inworker.tsto have a proper type, instead ofanyas well.