@runmu.sh/ext-wasm-add 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ - Its own repository, [runmu-sh/ext-wasm-add](https://github.com/runmu-sh/ext-wasm-add), made with `npm create @runmu.sh/extension` and published to the marketplace from its version tags. The package is `@runmu.sh/ext-wasm-add`, built against `@runmu.sh/sdk` from npm. Nothing changes in the extension itself.
6
+
7
+ ## 0.1.0
8
+
9
+ - First version.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 runmu.sh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # WASM Add (`@runmu.sh/ext-wasm-add`)
2
+
3
+ The example for `mu.wasm.load` (SDK 1.3, <https://runmu.sh/docs/extensions/wasm>). Install it from
4
+ **☰ → Extensions → Discover** ([marketplace listing](https://runmu.sh/marketplace/x/wasm-add)).
5
+
6
+ - `wasm/add.wat` is the source of `wasm/add.wasm` (41 bytes, one exported `add(i32, i32) → i32`). The binary
7
+ is committed, so the build needs no `wat2wasm` or Rust toolchain.
8
+ - `package.json` lists it in `muclient.wasm` with its sha256, and `files` includes `wasm/`, so it ships in the
9
+ package. μClient refuses bytes that do not match that hash, pins it at install and re-checks it on every load.
10
+ - `activate` awaits `mu.wasm.load('wasm/add.wasm')`, then registers a panel that calls `add`.
11
+
12
+ ## Commands
13
+ ```sh
14
+ npm install
15
+ npm run build # dist/index.js + manifest check
16
+ npm run typecheck # tsc --noEmit against the SDK types
17
+ npm run dev # dev server on http://localhost:5199/ with hot reload
18
+ ```
19
+
20
+ After editing `add.wat`, rebuild the binary (`wat2wasm wasm/add.wat -o wasm/add.wasm`) and put its new sha256
21
+ in `muclient.wasm`.
22
+
23
+ ## Publish
24
+ This repository is linked to the marketplace listing [wasm-add](https://runmu.sh/marketplace/x/wasm-add): a
25
+ version tag is imported within seconds (webhook), or within 30 minutes (poll).
26
+
27
+ ```sh
28
+ npm run build && git commit -am "WASM Add x.y.z" && git tag vx.y.z && git push origin main vx.y.z
29
+ ```
30
+
31
+ Versions are immutable.
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ // src/index.ts
2
+ import { defineExtension } from "@muclient/sdk";
3
+ var index_default = defineExtension({
4
+ async activate(ctx) {
5
+ const mu = ctx.mu;
6
+ const { exports } = await mu.wasm.load("wasm/add.wasm");
7
+ const add = exports.add;
8
+ const c = mu.ui.css;
9
+ mu.panels.register({
10
+ id: "wasm-add",
11
+ title: "WASM add",
12
+ defaultPosition: "right-bottom",
13
+ mount(el) {
14
+ el.style.cssText = "display:flex;flex-direction:column;gap:6px;padding:8px 10px;font-size:var(--t-body, .8rem)";
15
+ el.innerHTML = `
16
+ <div class="${c.secHead}">add(a, b) in WebAssembly</div>
17
+ <form data-testid="wa-form" style="display:flex;gap:6px;align-items:center">
18
+ <input class="${c.inp}" name="a" value="2" inputmode="numeric" aria-label="a" style="width:5em" />
19
+ <span>+</span>
20
+ <input class="${c.inp}" name="b" value="40" inputmode="numeric" aria-label="b" style="width:5em" />
21
+ <button class="${c.tool}" type="submit">=</button>
22
+ <output data-testid="wa-result" class="${c.glow}"></output>
23
+ </form>`;
24
+ const form = el.querySelector("form");
25
+ const out = el.querySelector("[data-testid=wa-result]");
26
+ const run = () => {
27
+ const v = (n) => Number(form.elements.namedItem(n).value) | 0;
28
+ out.textContent = String(add(v("a"), v("b")));
29
+ };
30
+ form.onsubmit = (e) => {
31
+ e.preventDefault();
32
+ run();
33
+ };
34
+ run();
35
+ }
36
+ });
37
+ mu.log.info("add(2, 40) =", add(2, 40));
38
+ return { add };
39
+ }
40
+ });
41
+ export {
42
+ index_default as default
43
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@runmu.sh/ext-wasm-add",
3
+ "version": "1.0.0",
4
+ "description": "The mu.wasm.load example: a panel that calls add(a, b) in a 41-byte hand-written WebAssembly module (wasm/add.wat), pinned by sha256 in muclient.wasm.",
5
+ "keywords": [
6
+ "muclient-extension"
7
+ ],
8
+ "license": "MIT",
9
+ "homepage": "https://runmu.sh/marketplace/x/wasm-add",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/runmu-sh/ext-wasm-add.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/runmu-sh/ext-wasm-add/issues"
16
+ },
17
+ "type": "module",
18
+ "exports": "./dist/index.js",
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "CHANGELOG.md",
23
+ "wasm"
24
+ ],
25
+ "scripts": {
26
+ "build": "node scripts/build.mjs",
27
+ "dev": "node scripts/dev.mjs",
28
+ "typecheck": "tsc --noEmit",
29
+ "check": "node scripts/build.mjs --check"
30
+ },
31
+ "devDependencies": {
32
+ "@muclient/sdk": "npm:@runmu.sh/sdk@^1.6.0",
33
+ "@runmu.sh/dev": "^0.1.0",
34
+ "esbuild": "^0.28.2",
35
+ "typescript": "^5.9.0"
36
+ },
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "muclient": {
41
+ "id": "wasm-add",
42
+ "api": "^1.3",
43
+ "source": "src/index.ts",
44
+ "displayName": "WASM Add",
45
+ "description": "The mu.wasm.load example: a panel that calls add(a, b) in a 41-byte hand-written WebAssembly module (wasm/add.wat), pinned by sha256 in muclient.wasm.",
46
+ "contributes": {
47
+ "panels": [
48
+ {
49
+ "id": "wasm-add",
50
+ "title": "WASM add"
51
+ }
52
+ ]
53
+ },
54
+ "capabilities": [],
55
+ "wasm": {
56
+ "wasm/add.wasm": "f61fd62f57c41269c3c23f360eeaf1090b1db9c38651106674d48bc65dba88ba"
57
+ },
58
+ "publisher": "bitmuse"
59
+ }
60
+ }
package/wasm/add.wasm ADDED
Binary file
package/wasm/add.wat ADDED
@@ -0,0 +1,8 @@
1
+ ;; The source of add.wasm (41 bytes, committed as a binary: the host has no wat2wasm/Rust toolchain).
2
+ ;; Rebuild with `wat2wasm add.wat -o add.wasm`, then update the sha256 in ../package.json (the build
3
+ ;; refuses a mismatch).
4
+ (module
5
+ (func (export "add") (param i32 i32) (result i32)
6
+ local.get 0
7
+ local.get 1
8
+ i32.add))