{"id":15066302,"url":"https://github.com/second-state/wasmedge-extensions","last_synced_at":"2025-10-05T03:30:52.368Z","repository":{"id":45432830,"uuid":"405587756","full_name":"second-state/wasmedge-extensions","owner":"second-state","description":"WasmEdge for Node.js Addon with extensions","archived":true,"fork":false,"pushed_at":"2021-12-14T09:49:11.000Z","size":187,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-20T02:12:08.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/second-state.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-12T08:27:16.000Z","updated_at":"2023-09-12T06:24:18.000Z","dependencies_parsed_at":"2022-08-04T15:00:13.554Z","dependency_job_id":null,"html_url":"https://github.com/second-state/wasmedge-extensions","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/second-state","download_url":"https://codeload.github.com/second-state/wasmedge-extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235356202,"owners_count":18976819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-25T01:05:12.946Z","updated_at":"2025-10-05T03:30:47.076Z","avatar_url":"https://github.com/second-state.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WasmEdge for Node.js Addon with extensions\n\nThe [WasmEdge (previously known as Second State VM, SSVM)](https://github.com/WasmEdge/WasmEdge) is a high-performance WebAssembly runtime optimized for server-side applications. This project provides support for accessing WasmEdge as a Node.js addon. It allows Node.js applications to call WebAssembly functions written in Rust or other high-performance languages. [Why do you want to run WebAssembly on the server-side?](https://cloud.secondstate.io/server-side-webassembly/why) The WasmEdge addon could interact with the wasm files generated by the [rustwasmc](https://github.com/second-state/rustwasmc) compiler tool.\n\n## NOTICE\n\nIn the current stage, our prebuilt version **only supports** x86\\_64 and aarch64 Linux.\nOr you could use `--build-from-source` flag to build from the source during addon installation.\n\n## WasmEdge versions\n\nThere are mappings of wasmedge-extensions versoins and corresponding [WasmEdge](https://github.com/WasmEdge/WasmEdge) versions:\n\n| wasmedge-extensions  | WasmEdge    |\n| -------------------- | ----------- |\n| 0.8.1                | 0.8.1       |\n| 0.8.2                | 0.8.2       |\n| 0.8.3                | 0.8.2       |\n| 0.9.0-rc.1           | 0.9.0-rc.1  |\n| 0.9.0                | 0.9.0       |\n\n## Development Requirements\n\nUsers should install the dependencies by the following requirments:\n\n* boost \u003e= 1.65.0\n* llvm \u003e= 10\n* liblld-10-dev \u003e= 10\n* libstdc++6 \u003e= 6.0.28 (GLIBCXX \u003e= 3.4.28)\n* g++ version \u003e= 9.0 (Optional, if you have to build from source)\n\n### TensorFlow extensions\n\nPlease refer to [WasmEdge install section](https://github.com/WasmEdge/WasmEdge/blob/master/docs/install.md) to install the WasmEdge with other extensions.\n\n## Prepare the environment\n\n### Use our docker image or dockerfile\n\n```bash\n$ docker pull secondstate/ssvm-extensions\n# Or you can build it on your local environment.\n$ docker build . -f utils/docker/Dockerfile -t secondstate/ssvm-extensions\n```\n\n### Verify the version of llvm\n\n```bash\nsudo apt list | grep llvm\n\n# Expected output\n...omitted...\nllvm-dev/focal,now 1:10.0-50~exp1 amd64 [installed]\nllvm-runtime/focal,now 1:10.0-50~exp1 amd64 [installed,automatic]\nllvm/focal,now 1:10.0-50~exp1 amd64 [installed,automatic]\n...omitted...\n\n# If the version is 1:10.x, then your llvm version is correct.\n```\n\n### Verify the version of libstdc++6\n\n```bash\nstrings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX\n\n# Expected output\n...omitted...\nGLIBCXX_3.4.24\nGLIBCXX_3.4.25\nGLIBCXX_3.4.26\nGLIBCXX_3.4.27\nGLIBCXX_3.4.28\nGLIBCXX_DEBUG_MESSAGE_LENGTH\n\n# If you can find GLIBCXX_3.4.28 in the output, then your libstdc++6 version is correct.\n```\n\n### Works with Rust library using Wasm-Bindgen\n\nPlease refer to [Tutorial: A Wasm-Bindgen application](./Tutorial_Wasm_Bindgen.md).\n\n### Works with Rust application using standalone wasm32-wasi backend\n\nPlease refer to [Tutorial: A standalone wasm32-wasi application](./Tutorial_Wasm32_Wasi.md).\n\n## APIs\n\n### Constructor: `wasmedge.VM(wasm, wasmedge_options) -\u003e vm_instance`\n* Create a WasmEdge instance by given wasm file and options.\n* Arguments:\n\t* `wasm`: Input wasm file, can be the following two formats:\n\t\t1. Wasm file path (String, e.g. `/tmp/hello.wasm`)\n\t\t2. Wasm bytecode format which is the content of a wasm binary file (Uint8Array)\n\t* `options`: An options object for setup the WasmEdge execution environment.\n\t\t* `options` \u003cJS Object\u003e\n\t\t\t* `args` \u003cJS Array\u003e: An array of strings that the Wasm application will get as function arguments. Default: `[]`.\n\t\t\t* `env` \u003cJS Object\u003e: An object like `process.env` that Wasm application will get as its environment variables. Default: `{}`.\n\t\t\t* `preopens` \u003cJS Object\u003e: An object which maps '\u003cguest_path\u003e:\u003chost_path\u003e'. E.g. `{'/sandbox': '/some/real/path/that/wasm/can/access'}` Default: `{}`.\n\t\t\t* `EnableWasiStartFunction` \u003cBoolean\u003e: This option will disable wasm-bindgen mode and prepare the working environment for the standalone wasm program. If you want to run an application with `main()`, you should set this to `true`. Default: `false`.\n\t\t\t* `EnableAOT` \u003cBoolean\u003e: This option will enable WasmEdge AoT mode. Default: `false`.\n\t\t\t* `EnableMeasurement` \u003cBoolean\u003e: This option will enable measurement but decrease its performance. Default: `false`.\n\t\t\t* `AllowCommands` \u003cJS Array\u003e: An array of strings that indicate what commands are allowed to execute in the WasmEdge Process Module. Default `[]`.\n\t\t\t* `AllowAllCommands` \u003cBoolean\u003e: Allow users to call any command in the WasmEdge Process Module. This option will overwrite the `AllowCommands`. Default: `false`.\n* Return value:\n\t* `vm_instance`: A WasmEdge instance.\n\n### Methods\n\n#### `Start() -\u003e Integer`\n* Emit `_start()` and expect the return value type is `Integer` which represents the error code from `main()`.\n* Arguments:\n\t* If you want to append arguments for the standalone wasm program, please set the `args` in `wasi options`.\n* Example:\n```javascript\nlet error_code = Start();\n```\n\n#### `Run(function_name, args...) -\u003e void`\n* Emit `function_name` with `args` and expect the return value type is `void`.\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nRun(\"Print\", 1234);\n```\n\n#### `RunInt(function_name, args...) -\u003e Integer`\n* Emit `function_name` with `args` and expect the return value type is `Integer` (Int32).\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nlet result = RunInt(\"Add\", 1, 2);\n// result should be 3\n```\n\n#### `RunUInt(function_name, args...) -\u003e Integer`\n* Emit `function_name` with `args` and expect the return value type is `Integer` (UInt32).\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nlet result = RunInt(\"Add\", 1, 2);\n// result should be 3\n```\n\n#### `RunInt64(function_name, args...) -\u003e BigInt`\n* Emit `function_name` with `args` and expect the return value type is `BigInt` (Int64).\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nlet result = RunInt(\"Add\", 1, 2);\n// result should be 3\n```\n\n#### `RunUInt64(function_name, args...) -\u003e BigInt`\n* Emit `function_name` with `args` and expect the return value type is `BigInt` (UInt64).\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nlet result = RunInt(\"Add\", 1, 2);\n// result should be 3\n```\n\n#### `RunString(function_name, args...) -\u003e String`\n* Emit `function_name` with `args` and expect the return value type is `String`.\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nlet result = RunString(\"PrintMathScore\", \"Amy\", 98);\n// result: \"Amy’s math score is 98\".\n```\n\n#### `RunUint8Array(function_name, args...) -\u003e Uint8Array`\n* Emit `function_name` with `args` and expect the return value type is `Uint8Array`.\n* Arguments:\n\t* `function_name` \u003cString\u003e: The function name which users want to emit.\n\t* `args` \u003cInteger/String/Uint8Array\u003e\\*: The function arguments. The delimiter is `,`\n* Example:\n```javascript\nlet result = RunUint8Array(\"Hash\", \"Hello, world!\");\n// result: \"[12, 22, 33, 42, 51]\".\n```\n\n#### `Compile(output_filename) -\u003e boolean`\n* Compile a given wasm file (can be a file path or a byte array) into a native binary whose name is the given `output_filename`.\n* This function uses WasmEdge AoT compiler.\n* Return `false` when the compilation failed.\n```javascript\n// Compile only\nlet vm = wasmedge.VM(\"/path/to/wasm/file\", options);\nvm.Compile(\"/path/to/aot/file\");\n\n// When you want to run the compiled file\nlet vm = wasmedge.VM(\"/path/to/aot/file\", options);\nvm.RunXXX(\"Func\", args);\n```\n\n#### `GetStatistics() -\u003e Object`\n* If you want to enable measurement, set the option `EnableMeasurement` to `true`. But please notice that enabling measurement will significantly affect performance.\n* Get the statistics of execution runtime.\n* Return Value `Statistics` \u003cObject\u003e\n\t* `Measure` -\u003e \u003cBoolean\u003e: To show if the measurement is enabled or not.\n\t* `TotalExecutionTime` -\u003e \u003cInteger\u003e: Total execution time (Wasm exeuction time + Host function execution time) in `ns` unit.\n\t* `WasmExecutionTime` -\u003e \u003cInteger\u003e: Wasm instructions execution time in `ns` unit.\n\t* `HostFunctionExecutionTime` -\u003e \u003cInteger\u003e: Host functions (e.g. eei or wasi functions) execution time in `ns` unit.\n\t* `InstructionCount` -\u003e \u003cInteger\u003e: The number of executed instructions in this execution.\n\t* `TotalGasCost` -\u003e \u003cInteger\u003e: The cost of this execution.\n\t* `InstructionPerSecond` -\u003e \u003cFloat\u003e: The instructions per second of this execution.\n\n```javascript\nlet result = RunInt(\"Add\", 1, 2);\n// result should be 3\nlet stat = GetStatistics();\n/*\nIf the `EnableMeasurement: true`:\n\nstat = Statistics:  {\n  Measure: true,\n  TotalExecutionTime: 1512,\n  WasmExecutionTime: 1481,\n  HostFunctionExecutionTime: 31,\n  InstructionCount: 27972,\n  TotalGasCost: 27972,\n  InstructionPerSecond: 18887238.35246455\n}\n\nElse:\n\nstat = Statistics:  {\n  Measure: false\n}\n*/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fwasmedge-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecond-state%2Fwasmedge-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fwasmedge-extensions/lists"}