open-index/open-npm huggingface dataset:
npm package: @fermyon/spin-sdk
Description: This is an SDK for Javascript and Typescript based on [ComponentizeJS](https://github.com/bytecodealliance/ComponentizeJS).
Latest version: 3.2.0

# Spin JS SDK

This is an SDK for Javascript and Typescript based on [ComponentizeJS](https://github.com/bytecodealliance/ComponentizeJS).

Note that this SDK supersedes an earlier, experimental version, which may be found in the [sdk-v1](https://github.com/fermyon/spin-js-sdk/tree/old-sdk) branch.

## [API Documentation](https://fermyon.github.io/spin-js-sdk)

## Installing the templates

[Spin](https://github.com/fermyon/spin) is a prerequisite. 

The templates can be installed with the following command:

```bash
spin templates install --update --git https://github.com/fermyon/spin-js-sdk 
```

## Creating and building a new app

Create a new app from the template installed in the previous step:

```bash
spin new -t http-ts hello-world -a
```
Change directory into the app:
```bash
cd hello-world
```

Install the dependencies and build the app:
```bash
npm install
spin build
```

## Running the app

```bash
spin up
```

Finally, you can test your app using e.g. `curl` in another terminal:

```shell
curl -i http://127.0.0.1:3000
```

If all goes well, you should see something like:

```
HTTP/1.1 200 OK
content-type: text/plain
content-length: 14
date: Thu, 11 Apr 2024 17:42:31 GMT

hello universe
```

Please file an issue if you have any trouble.

See the [examples directory](https://github.com/fermyon/spin-js-sdk/tree/main/examples) in the repository for more examples.

To learn more about the JS SDK checkout the [documentation](https://developer.fermyon.com/spin/v2/javascript-components)
npm package: @fermyon/wasi-ext
Description: This is a library compatible with WASI 0.2 that makes select Node.js APIs available in [ComponentizeJS](https://github.com/bytecodealliance/componentizeJS/) and [StarlingMonkey](https://github.com/bytecodealliance/starlingmonkey).
Author: Fermyon Engineering
Latest version: 0.1.1

# `js-wasi-ext`

This is a library compatible with WASI 0.2 that makes select Node.js APIs available in
[ComponentizeJS](https://github.com/bytecodealliance/componentizeJS/) and
[StarlingMonkey](https://github.com/bytecodealliance/starlingmonkey).

## Usage

This library currently requires Webpack and uses a plugin to define the fall backs.:

```js
const WasiExtPlugin = require("wasi-ext/plugin")

module.exports = {
    ...
    plugins: [
        new WasiExtPlugin()
    ],
    ...
};

```

> Note: this currently does not support the `node:process` syntax yet.

Because accessing environment variables needs to happen at runtime (not during
pre-initialization), the actual environment variables can only be accessed from
the handler function. If accessed outside, that is not supported (and currently,
`process.env` returns an empty map; we can discuss what this behavior should be).

The library currently exports a `setupExt()` function that explicitly initializes
`process.env` from the handler. We could potentially remove that depending on the
desired experience of this library.

After setup:

```js
import process from "process";

...
console.log(process.env["PET"]);
```

## Supported APIs

* `process`: certain methods are no-ops and few throw exceptions. For detailed list refer to the [upstream library](https://github.com/defunctzombie/node-process/blob/master/browser.js). `process.env` is only populated when inside the handler function, when outside, it returns an empty object (i.e) `{}`
* `fs`: Limited to `readFileSync` and `readdirSync`