npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vscode/wasm-wasi

v1.0.1

Published

An API facade for the WASM WASI CORE VS Code extension

Downloads

675

Readme

WASM WASI Core API

Build Status

This npm module implements an API facade for the WASM WASI Core VS Code extension.

History

1.0.1

  • Readme updates.

1.0.0

The npm module now provides version specific import routes to support API migration in the future. The standard import import { Wasm } from '@vscode/wasm-wasi' still exists but points to deprecated code. Please switch to the new import route import { Wasm } from '@vscode/wasm-wasi/v1.

0.11.0

With release version 0.11.0 the implementation details of the WASM support for VS Code has changed. This npm module is now a facade around the wasm-wasi-core VS Code extension.

Example

The source code of the example can be found here

First we need to define a package.json for the extension that wants to execute a WASM process:

{
	"name": "...",
	...
	// depend on the wasm-wasi-core extension
	"extensionDependencies": [
		"ms-vscode.wasm-wasi-core"
	],
	// Depend on the wasm-wasi facade npm module to get easier API access to the
	// core extension.
	"dependencies": {
		"@vscode/wasm-wasi": "..."
	},
}

The actual source code to execute a WASM process looks like this

// Load the WASM API
const wasm: Wasm = await Wasm.load();

// Create a pseudoterminal to provide stdio to the WASM process.
const pty = wasm.createPseudoterminal();
const terminal = window.createTerminal({ name: 'Run C Example', pty, isTransient: true });
terminal.show(true);

// Load the WASM module. It is stored alongside the extension JS code.
// So we can use VS Code's file system API to load it. Makes it
// independent of whether the code runs in the desktop or the web.
try {
	const bits = await workspace.fs.readFile(Uri.joinPath(context.extensionUri, 'hello.wasm'));
	const module = await WebAssembly.compile(bits);
	// Create a WASM process.
	const process = await wasm.createProcess('hello', module, { stdio: pty.stdio });
	// Run the process and wait for its result.
	const result = await process.run();
} catch (error) {
	// Show an error message if something goes wrong.
	void window.showErrorMessage(error.message);
}