Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

wasi: add documentation #24

Closed
wants to merge 1 commit into from
Closed

wasi: add documentation #24

wants to merge 1 commit into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Sep 29, 2019

No description provided.


> Stability: 1 - Experimental

The WASI API provides an implementation of the [WebAssembly System Interface][]
Copy link
Member

Choose a reason for hiding this comment

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

I think an explanation that WASI is basically a thing that lets us use file and socket I/O from WASM in Node.js might be useful here.

Most of our users probably aren't even sure what POSIX or system calls are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@benjamingr any chance you could provide the specific text you'd like to see? You can leave it as a comment or push directly to the branch as you see fit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

Seems very clear to me. A complete end-to-end example of loading a real WASI command might be a nice to have for those who don't want to strain to fill in the gaps themselves.

@cjihrig
Copy link
Contributor Author

cjihrig commented Sep 30, 2019

@guybedford do you mean the line const wasm = getWebAssemblyModuleSomehow();? That's the only part that isn't "real." I did that because there are a number of ways to "get" a wasm module, and that's how our streams docs do things. Do you have a preference on what you'd like to see there instead?

@guybedford
Copy link
Contributor

guybedford commented Sep 30, 2019

@cjihrig I was just thinking for users who aren't familiar with WASI if they were curious and this were their first introduction of playing around with it, a very simple:

const module = await WebAssembly.compile(fs.readFileSync('./binary.wasm'));

might just help.

Btw what is the status of stdout handling? Is it possible to setup piping or does it default to the same stdout as the Node.js process still?

Edit: removed the unnecessary base64 from my copy-paste example.

@cjihrig
Copy link
Contributor Author

cjihrig commented Sep 30, 2019

Is it possible to setup piping or does it default to the same stdout as the Node.js process still?

stdio currently uses the real file descriptors. However, I think it would be pretty straightforward to pass alternative file descriptors to uvwasi_init() and use those instead.

@cjihrig
Copy link
Contributor Author

cjihrig commented Sep 30, 2019

I've added @guybedford's suggested line of code to the example.

@guybedford
Copy link
Contributor

👍

stdio currently uses the real file descriptors. However, I think it would be pretty straightforward to pass alternative file descriptors to uvwasi_init() and use those instead.

It would be great to see an approach here further, as this is important to the command virtualization.

@cjihrig
Copy link
Contributor Author

cjihrig commented Oct 2, 2019

@guybedford I've added the file descriptor mapping piece to the checklist in #21 so it doesn't get forgotten about.

@cjihrig
Copy link
Contributor Author

cjihrig commented Oct 6, 2019

Landed in 41a2360. Thanks for the reviews!

@benjamingr please open a PR for any docs changes/additions you'd like to see.

@cjihrig cjihrig closed this Oct 6, 2019
@cjihrig cjihrig deleted the wasi-docs branch October 6, 2019 13:08
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.

5 participants