Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

feat: Introduce web bindings and orb NPM package #182

Merged
merged 7 commits into from
Dec 4, 2022
Merged

Conversation

cdata
Copy link
Collaborator

@cdata cdata commented Dec 3, 2022

This change proposes a milestone feature for Noosphere: a working NPM package that vends a TypeScript-based library that exposes Noosphere to JavaScript via a Wasm kernel.

In addition to the NPM package, this change includes wasm-bindgen-based FFI on the Rust side and a minimum viable Lit + Redux viewer application that is designed to render sphere content when loaded from a commodity IPFS Kubo gateway.

In support of the loading-out-of-a-gateway use case, the change includes a feature-gated KuboStorage implementation that can wrap any Storage implementation. KuboStorage will "fall back" to looking for blocks from an IPFS gateway if a requested block is not found in local storage. This makes KuboStorage suitable for read-only Noosphere use cases where an IPFS gateway API may be available.

I chose https://github.com/google/wireit to orchestrate builds across Rust and TypeScript packages. Largely thanks to Wireit, we don't need to be aware of yet-another-tool to run correct builds that span multiple source trees. Running npm run build from the typescript folder is sufficient to build everything (including Rust dependencies) in the intended order. The same goes for running tests: npm run test from the typescript folder will ensure all dependencies are built in time for the tests to run.

@aomarks has offered to lend us his scrutiny to make sure we get the most out of wireit.

Our test suite has also been expanded to include TypeScript tests (which are Mocha-formatted tests that run in headless Chrome). This should get us coverage from the JavaScript side of the web FFI.

Fixes #165

Copy link
Contributor

@aomarks aomarks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉🎉🎉

Awesome!

Many of these suggestions are optional, in particular the ones around including files and output, because it is valid to not include those, but without them you won't take full advantage of incremental build/caching.

typescript/package.json Show resolved Hide resolved
typescript/packages/orb/package.json Outdated Show resolved Hide resolved
typescript/packages/orb/package.json Show resolved Hide resolved
typescript/packages/orb/package.json Outdated Show resolved Hide resolved
typescript/packages/orb/package.json Show resolved Hide resolved
typescript/packages/sphere-viewer/package.json Outdated Show resolved Hide resolved
typescript/packages/sphere-viewer/package.json Outdated Show resolved Hide resolved
.github/workflows/run_test_suite.yaml Show resolved Hide resolved
cdata and others added 3 commits December 2, 2022 17:10
Co-authored-by: Alexander Marks <aomarks@google.com>
Co-authored-by: Alexander Marks <aomarks@google.com>
Co-authored-by: Alexander Marks <aomarks@google.com>
Copy link
Contributor

@jsantell jsantell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking through the Rust parts, it's looking excellent

rust/noosphere-cli/src/bin/orb.rs Show resolved Hide resolved
rust/noosphere/src/sphere/builder.rs Outdated Show resolved Hide resolved
rust/noosphere/src/wasm/fs.rs Outdated Show resolved Hide resolved
rust/noosphere/src/wasm/sphere.rs Show resolved Hide resolved
@cdata cdata force-pushed the feature/wasm-noosphere branch from 23586fc to eb7739e Compare December 3, 2022 01:37
jsantell
jsantell previously approved these changes Dec 3, 2022
Co-authored-by: Sebastian Zimmer <SebastianZimmer@users.noreply.github.com>
@cdata
Copy link
Collaborator Author

cdata commented Dec 4, 2022

I'm going to go ahead and merge since the last approval was dismissed by an unambiguously good (and small) patch. Thanks so much for the feedback @jsantell @aomarks and @SebastianZimmer !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce an NPM package built around Noosphere Wasm library
5 participants