Skip to content

Commit

Permalink
feat!: implement Rust/WebAssembly-based decoder
Browse files Browse the repository at this point in the history
Reimplement the image decoder, previously implemented in handwritten
Asm.js, into Rust/WebAssembly. Since Asm.js is effectively a "done"
technology and is unsupported by esbuild, moving to WebAssembly is a
sensible choice.

The new implementation is almost as fast as the previous one in Chrome.

At build time, the WebAssembly binary is inlined into the bundle as a
base64-encoded string. This allows downstream users to use regular
bundlers.

Due to how WebAssembly works, however, the library's signature has
changed.
Now, the library exports a `Promise` object named `init`. This promise
is created when the library is imported, and is resolved asynchronously.
Before using symbols exported by the library (including the default
export), users must wait for the promise to resolve.

example:

    import PSD, {init} from '@webtoon/psd'

    async fun() => {
      await init;
      PSD.parse(/* ... */)
    }
  • Loading branch information
Yehyoung Kang authored and pastelmind committed Jun 13, 2022
1 parent af23d15 commit 020f7a0
Show file tree
Hide file tree
Showing 17 changed files with 1,508 additions and 503 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
@@ -1,3 +1,5 @@
/coverage/
dist/
/dist-web/
**/rust-wasm/pkg/
**/rust-wasm/target/

0 comments on commit 020f7a0

Please sign in to comment.