open-index/open-npm huggingface dataset:
npm package: @higress/proxy-wasm-assemblyscript-sdk
Description: Use this SDK to write extensions for the proxy WASM ABI
Author: jingze.dai
Latest version: 0.0.2

# WebAssembly for Proxies (AssemblyScript SDK)

This is a friendly fork of https://github.com/solo-io/proxy-runtime/,
temporarily mantained to address an incompatibility between the AssemblyScript
SDK and ngx_wasm_module.

## How to use this SDK

Create a new project:

```shell
npm init
npm install --save-dev assemblyscript
npx asinit .
```

Include `"use": "abort=abort_proc_exit"` to the `asconfig.json` file as part of
the options passed to `asc` compiler:
```
{
  "options": {
    "use": "abort=abort_proc_exit"
  }
}
```

Add `"@kong/proxy-wasm-sdk": "0.0.6"` to your dependencies then run `npm install`.


## Hello, World

Copy this into assembly/index.ts:

```ts
export * from "@kong/proxy-wasm-sdk/proxy";
import {
  RootContext,
  Context,
  registerRootContext,
  FilterHeadersStatusValues,
  stream_context
} from "@kong/proxy-wasm-sdk";

class AddHeaderRoot extends RootContext {
  createContext(context_id: u32): Context {
    return new AddHeader(context_id, this);
  }
}

class AddHeader extends Context {
  constructor(context_id: u32, root_context: AddHeaderRoot) {
    super(context_id, root_context);
  }
  onResponseHeaders(a: u32, end_of_stream: bool): FilterHeadersStatusValues {
    const root_context = this.root_context;
    if (root_context.getConfiguration() == "") {
      stream_context.headers.response.add("hello", "world!");
    } else {
      stream_context.headers.response.add("hello", root_context.getConfiguration());
    }
    return FilterHeadersStatusValues.Continue;
  }
}

registerRootContext((context_id: u32) => { return new AddHeaderRoot(context_id); }, "add_header");
```
## build

To build, simply run:
```
npm run asbuild
```

build results will be in the build folder. `untouched.wasm` and `optimized.wasm` are the compiled 
file that we will use (you only need one of them, if unsure use `optimized.wasm`).

## Run
Configure envoy with your filter:
```yaml
          - name: envoy.filters.http.wasm
            config:
              config:
                name: "add_header"
                root_id: "add_header"
                configuration: "what ever you want"
                vm_config:
                  vm_id: "my_vm_id"
                  runtime: "envoy.wasm.runtime.v8"
                  code:
                    local:
                      filename: /PATH/TO/CODE/build/optimized.wasm
                  allow_precompiled: false
```
npm package: @higress/wasm-assemblyscript
Description: 此 SDK 用于使用 AssemblyScript 语言开发 Higress 的 Wasm 插件。
Author: jingze.dai
Latest version: 0.0.4

## 介绍

此 SDK 用于使用 AssemblyScript 语言开发 Higress 的 Wasm 插件。

### 如何使用SDK

创建一个新的 AssemblyScript 项目。

```
npm init
npm install --save-dev assemblyscript
npx asinit .
```

在asconfig.json文件中，作为传递给asc编译器的选项之一，包含"use": "abort=abort_proc_exit"。

```
{
  "options": {
    "use": "abort=abort_proc_exit"
  }
}
```

将`"@higress/proxy-wasm-assemblyscript-sdk": "^0.0.1"`和`"@higress/wasm-assemblyscript": "^0.0.3"`添加到你的依赖项中，然后运行`npm install`。

### 本地构建

```
npm run asbuild
```

构建结果将在`build`文件夹中。其中，`debug.wasm`和`release.wasm`是已编译的文件，在生产环境中建议使用`release.wasm`。

注：如果需要插件带有 name section 信息需要带上`"debug": true`，编译参数解释详见[using-the-compiler](https://www.assemblyscript.org/compiler.html#using-the-compiler)。

```json
"release": {
  "outFile": "build/release.wasm",
  "textFile": "build/release.wat",
  "sourceMap": true,
  "optimizeLevel": 3,
  "shrinkLevel": 0,
  "converge": false,
  "noAssert": false,
  "debug": true
}
```

### AssemblyScript 限制

此 SDK 使用的 AssemblyScript 版本为`0.27.29`，参考[AssemblyScript Status](https://www.assemblyscript.org/status.html)该版本尚未支持闭包、异常、迭代器等特性，并且JSON，正则表达式等功能还尚未在标准库中实现，暂时需要使用社区提供的实现。