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

Add JavaScript bindings via Wasm #360

Closed
wants to merge 28 commits into from

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Apr 10, 2024

What

Add JavaScript bindings via Wasm

Why

Based on #347 and continuation of #351 by @willemneal.

The Rust XDR lib is the only implementation of the XDR<>JSON format. This is a shortcut to allowing the use of the format in JavaScript contexts as a hold over until there is a native implementation in JavaScript.

Everything in this change is experimental, even more experimental than the JSON format that is itself still relatively experimental.

Merging

Intended to be merged to main after #347.

@leighmcculloch leighmcculloch deleted the rust-add-schemas-and-wasm branch April 10, 2024 07:19
@leighmcculloch leighmcculloch restored the rust-add-schemas-and-wasm branch April 10, 2024 07:21
@leighmcculloch leighmcculloch changed the base branch from main to rust-add-schemas April 10, 2024 07:24
- Remove npx use native tools without wrappers that doesn't introduce the npm
  and versioning consistency concerns in CI.
- Remove yalc as a developer who wishes to import the lib can choose to use
  yalc, the repo doesn't need to prescribe it.
- Remove visitor that modifies the schema because it results in two sets of
  schema being exported from the lib, the one defined on the types, and the one
  returned by the function. Also the visitor's modification of union types was
  buggy resulting in titles on union arms that were incorrect. Since this change
  is focused on a JS language binding we can revisit improving the schema in a
  separate PR and ideally do it on the types itself.
- Remove the Schema/TryFrom conversions as the pattern doesn't allow an
  importer to select the JSON Schema version, and encourage use of the schemars
  types for doing so.
- Changed the size optimization profile to be limited to the binding crate
  instead of all the crates in the repo.
- Remove the rlib crate-type because it is unnecessary and multiple
  crate-type's will cause rustc to abandon LTO, resulting in a larger .wasm
  file.
- Remove appveyor config that isn't used in the repos CI.
- Move the generation of the bindings into the Makefile where this repo defines
  all its targets.
- Remove all wasm-pack targets except the default bundler since longer term we
  will probably use the bundler target combined with webpack to generate a UMD
  package that can be used in nodejs and in the browser.
- Added types and exceptions to the wasmbind-gen functions so that the JS side
  can deal with arrays directly without having to decode JSON, and exceptions
  without having to decode errors from the JSON response that may conflict with
  valid JSON outputs.
- Separated the guess functionality into a separate function and made it behave
  more like the CLI guess function in that it returns all valid values, not
  just the first.
Base automatically changed from rust-add-schemas to main May 16, 2024 20:27
@leighmcculloch
Copy link
Member Author

Superseded by:

@leighmcculloch leighmcculloch deleted the rust-add-schemas-and-wasm branch May 28, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants