diff --git a/.gitignore b/.gitignore
index 3e86e2ea5..75046d795 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,8 @@
/target
/dist
/jco.sh
+*.tsbuildinfo
+dist/
# Typescript
/src/**/*.d.ts
diff --git a/crates/xtask/src/build/workspace.rs b/crates/xtask/src/build/workspace.rs
index c3c8fd878..58771e094 100644
--- a/crates/xtask/src/build/workspace.rs
+++ b/crates/xtask/src/build/workspace.rs
@@ -14,7 +14,7 @@ pub(crate) fn run(release: bool) -> anyhow::Result<()> {
cmd!(sh, "cargo build --workspace --target wasm32-wasip1").read()?;
}
- // Build Jco TS code
- cmd!(sh, "npx -w @bytecodealliance/jco tsc -p tsconfig.json").read()?;
+ // compile all ts code
+ cmd!(sh, "npm run --workspaces --if-present compile").read()?;
Ok(())
}
diff --git a/package-lock.json b/package-lock.json
index e925792db..1b0bfb96c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,7 +20,10 @@
"examples/components/string-reverse",
"examples/components/string-reverse-upper",
"examples/components/webidl-book-library"
- ]
+ ],
+ "devDependencies": {
+ "prettier": "^3.6.2"
+ }
},
"examples/components/add": {
"name": "add-wasm",
@@ -29,39 +32,6 @@
"@bytecodealliance/jco": "^1.11.1"
}
},
- "examples/components/add/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/add/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/adder": {
"name": "adder-wasm",
"dependencies": {
@@ -69,78 +39,12 @@
"@bytecodealliance/jco": "^1.11.1"
}
},
- "examples/components/adder/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/adder/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/host-logging": {
"dependencies": {
"@bytecodealliance/componentize-js": "^0.18.3",
"@bytecodealliance/jco": "^1.11.1"
}
},
- "examples/components/host-logging/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/host-logging/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/http-hello-world": {
"name": "http-hello-world-wasm",
"dependencies": {
@@ -151,78 +55,12 @@
"terminate": "^2.8.0"
}
},
- "examples/components/http-hello-world/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/http-hello-world/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/http-server-fetch-handler": {
"dependencies": {
"@bytecodealliance/componentize-js": "^0.18.3",
"@bytecodealliance/jco": "^1.11.1"
}
},
- "examples/components/http-server-fetch-handler/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/http-server-fetch-handler/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/http-server-hono": {
"license": "MIT",
"dependencies": {
@@ -238,80 +76,12 @@
"typescript": "^5.8.3"
}
},
- "examples/components/http-server-hono/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "dev": true,
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/http-server-hono/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "dev": true,
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/node-fetch": {
"dependencies": {
"@bytecodealliance/componentize-js": "^0.18.3",
"@bytecodealliance/jco": "^1.11.1"
}
},
- "examples/components/node-fetch/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/node-fetch/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/string-reverse": {
"name": "string-reverse-wasm",
"dependencies": {
@@ -326,72 +96,6 @@
"@bytecodealliance/jco": "^1.11.1"
}
},
- "examples/components/string-reverse-upper/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/string-reverse-upper/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
- "examples/components/string-reverse/node_modules/@bytecodealliance/jco": {
- "version": "1.11.3",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.11.3.tgz",
- "integrity": "sha512-Ynv0GDj9iAp+cS03UGg+ss4uo/Hx5e4FyjcFDBfkRt9qJsqbL2AnPqgO/ORNlSXg9zu9PTNC0uGgE7/Vklcn/w==",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.17.0",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "bin": {
- "jco": "src/jco.js"
- }
- },
- "examples/components/string-reverse/node_modules/@bytecodealliance/jco/node_modules/@bytecodealliance/componentize-js": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.17.0.tgz",
- "integrity": "sha512-FDgO5UPipfjyq5OghSB4JW313LkQJK3Sl647WH1jvIuYAyCq1j+bMt+Q66c3UF6IVs6PneNTGfGSjYgzID/k0w==",
- "workspaces": [
- "."
- ],
- "dependencies": {
- "@bytecodealliance/jco": "^1.9.1",
- "@bytecodealliance/weval": "^0.3.3",
- "@bytecodealliance/wizer": "^7.0.5",
- "es-module-lexer": "^1.6.0"
- }
- },
"examples/components/webidl-book-library": {
"name": "webidl-book-library-wasm",
"devDependencies": {
@@ -1696,6 +1400,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@tsconfig/node20": {
+ "version": "20.1.6",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.6.tgz",
+ "integrity": "sha512-sz+Hqx9zwZDpZIV871WSbUzSqNIsXzghZydypnfgzPKLltVJfkINfUeTct31n/tTSa9ZE1ZOfKdRre1uHHquYQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@tybys/wasm-util": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.0.tgz",
@@ -4454,7 +4165,9 @@
}
},
"node_modules/prettier": {
- "version": "3.5.3",
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
+ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"dev": true,
"license": "MIT",
"bin": {
@@ -5761,7 +5474,7 @@
},
"packages/jco": {
"name": "@bytecodealliance/jco",
- "version": "1.12.0-rc.1",
+ "version": "1.12.0",
"license": "(Apache-2.0 WITH LLVM-exception)",
"dependencies": {
"@bytecodealliance/componentize-js": "^0.18.3",
@@ -5803,12 +5516,20 @@
"@bytecodealliance/preview2-shim": "^0.17.2",
"chalk-template": "^1",
"terser": "^5"
+ },
+ "devDependencies": {
+ "@tsconfig/node20": "^20.1.6",
+ "typescript": "^5.8.3"
}
},
"packages/preview2-shim": {
"name": "@bytecodealliance/preview2-shim",
"version": "0.17.2",
- "license": "(Apache-2.0 WITH LLVM-exception)"
+ "license": "(Apache-2.0 WITH LLVM-exception)",
+ "devDependencies": {
+ "@tsconfig/node20": "^20.1.6",
+ "typescript": "^5.8.3"
+ }
},
"packages/preview3-shim": {
"name": "@bytecodealliance/preview3-shim",
@@ -5819,9 +5540,11 @@
},
"devDependencies": {
"@eslint/js": "^9.21.0",
+ "@tsconfig/node20": "^20.1.6",
"eslint": "^9.21.0",
"globals": "^16.0.0",
"prettier": "^3.5.3",
+ "typescript": "^5.8.3",
"typescript-eslint": "^8.26.0",
"vitest": "^3.1.1"
}
diff --git a/package.json b/package.json
index f6b573229..055b1d519 100644
--- a/package.json
+++ b/package.json
@@ -24,5 +24,8 @@
"fmt": "npm run fmt --ws --if-present",
"lint": "npm run lint --ws --if-present",
"lint:fix": "npm run lint:fix --ws --if-present"
+ },
+ "devDependencies": {
+ "prettier": "^3.6.2"
}
}
diff --git a/packages/jco-transpile/package.json b/packages/jco-transpile/package.json
index d288ea741..36f9f6533 100644
--- a/packages/jco-transpile/package.json
+++ b/packages/jco-transpile/package.json
@@ -1,57 +1,63 @@
{
- "name": "@bytecodealliance/jco-transpile",
- "version": "0.0.3",
- "description": "WebAssembly Component transpilation functionality for Jco",
- "contributors": [
- {
- "name": "Guy Bedford"
+ "name": "@bytecodealliance/jco-transpile",
+ "version": "0.0.3",
+ "description": "WebAssembly Component transpilation functionality for Jco",
+ "contributors": [
+ {
+ "name": "Guy Bedford"
+ },
+ {
+ "name": "Eduardo Rodrigues",
+ "email": "16357187+eduardomourar@users.noreply.github.com"
+ },
+ {
+ "name": "Victor Adossi",
+ "email": "vadossi@cosmonic.com"
+ }
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/bytecodealliance/jco.git"
},
- {
- "name": "Eduardo Rodrigues",
- "email": "16357187+eduardomourar@users.noreply.github.com"
+ "license": "(Apache-2.0 WITH LLVM-exception)",
+ "bugs": {
+ "url": "https://github.com/bytecodealliance/jco/issues"
},
- {
- "name": "Victor Adossi",
- "email": "vadossi@cosmonic.com"
- }
- ],
- "repository": {
- "type": "git",
- "url": "git+https://github.com/bytecodealliance/jco.git"
- },
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "bugs": {
- "url": "https://github.com/bytecodealliance/jco/issues"
- },
- "homepage": "https://github.com/bytecodealliance/jco#readme",
- "keywords": [
- "Wasm",
- "WebAssembly",
- "Component"
- ],
- "type": "module",
- "files": [
- "types",
- "vendor",
- "src"
- ],
- "types": "./types/index.d.ts",
- "exports": {
- ".": {
- "types": "./src/index.d.ts",
- "default": "./src/index.js"
+ "homepage": "https://github.com/bytecodealliance/jco#readme",
+ "keywords": [
+ "Wasm",
+ "WebAssembly",
+ "Component"
+ ],
+ "type": "module",
+ "files": [
+ "types",
+ "vendor",
+ "src",
+ "dist"
+ ],
+ "types": "./dist/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./dist/index.d.ts",
+ "default": "./src/index.js"
+ }
+ },
+ "scripts": {
+ "lint": "eslint -c ../../eslint.config.mjs ./src/**/*.js ./test/**/*.js",
+ "lint:fix": "npm run lint -- --fix",
+ "test": "vitest run -c test/vitest.ts",
+ "setup:vendor": "npm run -w @bytecodealliance/jco build:release && cp ../jco/obj/*.core*.wasm vendor && cp ../jco/obj/*.js vendor && cp ../jco/obj/*.ts vendor && cp -r ../jco/obj/interfaces vendor",
+ "prepack": "npm run setup:vendor",
+ "compile": "tsc --build"
+ },
+ "dependencies": {
+ "@bytecodealliance/preview2-shim": "^0.17.2",
+ "chalk-template": "^1",
+ "terser": "^5"
+ },
+ "devDependencies": {
+ "@tsconfig/node20": "^20.1.6",
+ "typescript": "^5.8.3"
}
- },
- "scripts": {
- "lint": "eslint -c ../../eslint.config.mjs ./src/**/*.js ./test/**/*.js",
- "lint:fix": "npm run lint -- --fix",
- "test": "vitest run -c test/vitest.ts",
- "setup:vendor": "npm run -w @bytecodealliance/jco build:release && cp ../jco/obj/*.core*.wasm vendor && cp ../jco/obj/*.js vendor && cp ../jco/obj/*.ts vendor && cp -r ../jco/obj/interfaces vendor",
- "prepack": "npm run setup:vendor"
- },
- "dependencies": {
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "chalk-template": "^1",
- "terser": "^5"
- }
}
diff --git a/packages/jco-transpile/src/common.d.ts b/packages/jco-transpile/src/common.d.ts
deleted file mode 100644
index 7309b119f..000000000
--- a/packages/jco-transpile/src/common.d.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-export function setShowSpinner(val: boolean): void;
-export function getShowSpinner(): boolean;
-
-interface SizeStrOpts {
- significantDigits?: number;
-}
-export function sizeStr(num: any, opts?: SizeStrOpts): string;
-
-export function fixedDigitDisplay(num: number, maxChars: number): string;
-
-type CellAlignment = 'left' | 'right';
-export function table(data: any[][], cellAlignment?: CellAlignment[]): string;
-
-export function getTmpDir(): Promise;
-
-export function spawnIOTmp(
- cmd: any,
- input: any,
- args: any
-): Promise>;
-
-export const isWindows: boolean;
-
-export function readFile(
- file: string,
- encoding: string
-): Promise>;
-
-export function spawnIOTmp(
- cmd: string,
- input: Buffer | string | any,
- args: string[]
-): Promise;
-
-export function byteLengthLEB128(val: number): number;
-
-/** Bytes that belong in one or more files */
-type FileBytes = {
- [filename: string]: Uint8Array;
-};
-
-//# sourceMappingURL=common.d.ts.map
diff --git a/packages/jco-transpile/src/common.d.ts.map b/packages/jco-transpile/src/common.d.ts.map
deleted file mode 100644
index 6a692ec0e..000000000
--- a/packages/jco-transpile/src/common.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.js"],"names":[],"mappings":"AAWA,+CAEC;AACD,0CAIC;AAED,0CASC;AAED,mEAcC;AAED,wDAoBC;AAED;;;;GAIG;AACH,6CAEC;AAWD,8FAiCC;AAhHD,gCAA8C;;AAsE9C,yFAMC"}
\ No newline at end of file
diff --git a/packages/jco-transpile/src/index.d.ts b/packages/jco-transpile/src/index.d.ts
deleted file mode 100644
index c41d746ea..000000000
--- a/packages/jco-transpile/src/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export type { generateGuestTypes, generateHostTypes } from './typegen.js';
-export type { transpile } from './transpile.js';
diff --git a/packages/jco-transpile/src/opt.d.ts b/packages/jco-transpile/src/opt.d.ts
deleted file mode 100644
index 11743da5a..000000000
--- a/packages/jco-transpile/src/opt.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-type OptimizeOptions = {
- quiet: boolean;
- asyncify?: boolean;
- optArgs?: string[];
- noVerify?: boolean;
-};
-
-type OptimizeResult = {
- component: Uint8Array;
- compressionInfo: { beforeBytes: number; afterBytes: number }[];
-};
diff --git a/packages/jco-transpile/src/transpile.d.ts b/packages/jco-transpile/src/transpile.d.ts
deleted file mode 100644
index a5cfabb8f..000000000
--- a/packages/jco-transpile/src/transpile.d.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { Command } from 'commander';
-
-type TypeGenerationOptions = {
- name?: string;
- worldName?: string;
- instantiation?: 'async' | 'sync';
- tlaCompat?: boolean;
- asyncMode?: string;
- asyncImports?: string[];
- asyncExports?: string[];
- outDir?: string;
- features?: string[] | 'all';
- allFeatures?: boolean;
- asyncWasiImports?: boolean;
- asyncWasiExports?: boolean;
- guest?: boolean;
-};
-
-export function types(
- witPath: string,
- opts?: TypeGenerationOptions
-): Promise;
-
-export function guestTypes(
- witPath: string,
- opts: TypeGenerationOptions
-): Promise;
-
-/** Bytes that belong in one or more files */
-type FileBytes = {
- [filename: string]: Uint8Array;
-};
-
-/**
- * @param {string} witPath
- * @param {{
- * name?: string,
- * worldName?: string,
- * instantiation?: 'async' | 'sync',
- * tlaCompat?: bool,
- * asyncMode?: string,
- * asyncImports?: string[],
- * asyncExports?: string[],
- * outDir?: string,
- * features?: string[] | 'all',
- * guest?: bool,
- * }} opts
- * @returns {Promise<{ [filename: string]: Uint8Array }>}
- */
-export function typesComponent(
- witPath: string,
- opts: TypeGenerationOptions
-): Promise;
-
-type TranspilationOptions = {
- name: string;
- instantiation?: 'async' | 'sync';
- importBindings?: 'js' | 'optimized' | 'hybrid' | 'direct-optimized';
- map?: Record;
- asyncMode?: string;
- asyncImports?: string[];
- asyncExports?: string[];
- asyncWasiImports?: string[];
- asyncWasiExports?: string[];
- validLiftingOptimization?: boolean;
- tracing?: boolean;
- nodejsCompat?: boolean;
- tlaCompat?: boolean;
- base64Cutoff?: boolean;
- js?: boolean;
- minify?: boolean;
- optimize?: boolean;
- namespacedExports?: boolean;
- outDir?: string;
- multiMemory?: boolean;
- experimentalIdlImports?: boolean;
- optArgs?: string[];
-};
-
-export function transpile(
- componentPath: string,
- opts?: TranspilationOptions,
- program?: Command
-): Promise;
-
-type TranspilationResult = {
- files: FileBytes;
- imports: string[];
- exports: [string, 'function' | 'instance'][];
-};
-
-export function runTranspileComponent(
- component: Uint8Array,
- opts?: TranspilationOptions,
-): Promise;
-
-//# sourceMappingURL=transpile.d.ts.map
diff --git a/packages/jco-transpile/src/transpile.d.ts.map b/packages/jco-transpile/src/transpile.d.ts.map
deleted file mode 100644
index f9dceb062..000000000
--- a/packages/jco-transpile/src/transpile.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"AA+CA,8DAGC;AAED,mEAMC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wCAfW,MAAM,QACN;IACN,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC5B,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,GACS,OAAO,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC,CA+DvD;AAyCD,sFAoCC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,8CAzBW,UAAU,SACV;IACN,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,QAAQ,GAAG,kBAAkB,CAAC;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,wBAAwB,CAAC,EAAE,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,sBAAsB,CAAC,EAAE,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACS,OAAO,CAAC;IAAE,KAAK,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,CAAA;CAAE,CAAC,CAyTnI"}
\ No newline at end of file
diff --git a/packages/jco-transpile/src/typegen.d.ts b/packages/jco-transpile/src/typegen.d.ts
deleted file mode 100644
index a3e9cc7b0..000000000
--- a/packages/jco-transpile/src/typegen.d.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { FileBytes } from './common';
-
-type TypeGenerationOptions = {
- name?: string;
- worldName?: string;
- instantiation?: 'async' | 'sync';
- tlaCompat?: boolean;
- asyncMode?: string;
- asyncImports?: string[];
- asyncExports?: string[];
- outDir?: string;
- features?: string[] | 'all';
- allFeatures?: boolean;
- asyncWasiImports?: boolean;
- asyncWasiExports?: boolean;
- guest?: boolean;
-};
-
-export function generateHostTypes(
- witPath: string,
- opts?: TypeGenerationOptions
-): Promise;
-
-export function generateGuestTypes(
- witPath: string,
- opts: TypeGenerationOptions
-): Promise;
-
-export function runTypesComponent(
- witPath: string,
- opts: TypeGenerationOptions
-): Promise;
diff --git a/packages/jco-transpile/tsconfig.json b/packages/jco-transpile/tsconfig.json
new file mode 100644
index 000000000..55b8d4682
--- /dev/null
+++ b/packages/jco-transpile/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "extends": "@tsconfig/node20",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "dist",
+ "sourceMap": true,
+ "declaration": true,
+ "declarationMap": true,
+ "emitDeclarationOnly": true,
+ "composite": true,
+ "allowJs": true
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/jco/CHANGELOG.md b/packages/jco/CHANGELOG.md
index b712c4d70..686f91159 100644
--- a/packages/jco/CHANGELOG.md
+++ b/packages/jco/CHANGELOG.md
@@ -4,148 +4,119 @@
### 🚜 Refactor
-* *(jco)* move type generation functions to separate file (#839) by @vados-cosmonic in #839
-
-
-
+- _(jco)_ move type generation functions to separate file (#839) by @vados-cosmonic in #839
## [1.12.0-rc.1] - 2025-07-17
### 🚜 Refactor
-* *(jco)* move type generation functions to separate file (#839) by @vados-cosmonic in #839
-
-
-
+- _(jco)_ move type generation functions to separate file (#839) by @vados-cosmonic in #839
## [1.12.0-rc.0] - 2025-07-17
### 🐛 Bug Fixes
-* *(jco)* run linter on jco package source code (#758) by @andreiltd in #758
+- _(jco)_ run linter on jco package source code (#758) by @andreiltd in #758
### 🚜 Refactor
-* refactor: pass more debug options to componentize by @vados-cosmonic in #607
+- refactor: pass more debug options to componentize by @vados-cosmonic in #607
### ⚙️ Miscellaneous Tasks
-* chore(deps): update componentize-js to v0.18.3 by @vados-cosmonic in #620
-
+- chore(deps): update componentize-js to v0.18.3 by @vados-cosmonic in #620
## [1.11.3] - 2025-06-30
### 🐛 Bug Fixes
-* *(jco)* run linter on jco package source code (#758)
-
-
-
+- _(jco)_ run linter on jco package source code (#758)
## [1.11.3-rc.1] - 2025-06-30
-
-
## [1.11.3-rc.0] - 2025-06-28
### 🐛 Bug Fixes
-* *(jco)* run linter on jco package source code (#758) by @andreiltd in #758
-
-
-
+- _(jco)_ run linter on jco package source code (#758) by @andreiltd in #758
## [1.11.2] - 2025-05-12
### 🐛 Bug Fixes
-* *(jco)* missing stat dependency (#650) by @vados-cosmonic in #650
-
-* *(jco)* appending to const value raises error (#648) by @thomas9911 in #648
+- _(jco)_ missing stat dependency (#650) by @vados-cosmonic in #650
+- _(jco)_ appending to const value raises error (#648) by @thomas9911 in #648
### 🚜 Refactor
-* *(jco)* re-arrange package.json, add contributors (#679) by @vados-cosmonic in #679
-
+- _(jco)_ re-arrange package.json, add contributors (#679) by @vados-cosmonic in #679
### ⚙️ Miscellaneous Tasks
-* *(jco)* update printed versions (#677) by @vados-cosmonic in #677
-
-* *(jco)* update printed CLI version by @vados-cosmonic
-
+- _(jco)_ update printed versions (#677) by @vados-cosmonic in #677
+- _(jco)_ update printed CLI version by @vados-cosmonic
## New Contributors
-* @jco-release-bot made their first contribution in [#684](https://github.com/bytecodealliance/jco/pull/684)
-* @dependabot[bot] made their first contribution in [#662](https://github.com/bytecodealliance/jco/pull/662)
-* @thomas9911 made their first contribution in [#648](https://github.com/bytecodealliance/jco/pull/648)
+- @jco-release-bot made their first contribution in [#684](https://github.com/bytecodealliance/jco/pull/684)
+- @dependabot[bot] made their first contribution in [#662](https://github.com/bytecodealliance/jco/pull/662)
+- @thomas9911 made their first contribution in [#648](https://github.com/bytecodealliance/jco/pull/648)
## [1.11.2-rc.2] - 2025-05-12
### 🐛 Bug Fixes
-* *(jco)* missing stat dependency (#650) by @vados-cosmonic in #650
-
-* *(jco)* appending to const value raises error (#648) by @thomas9911 in #648
+- _(jco)_ missing stat dependency (#650) by @vados-cosmonic in #650
+- _(jco)_ appending to const value raises error (#648) by @thomas9911 in #648
### 🚜 Refactor
-* *(jco)* re-arrange package.json, add contributors (#679) by @vados-cosmonic in #679
-
+- _(jco)_ re-arrange package.json, add contributors (#679) by @vados-cosmonic in #679
### ⚙️ Miscellaneous Tasks
-* *(jco)* update printed versions (#677) by @vados-cosmonic in #677
-
-* *(jco)* update printed CLI version by @vados-cosmonic
-
+- _(jco)_ update printed versions (#677) by @vados-cosmonic in #677
+- _(jco)_ update printed CLI version by @vados-cosmonic
## New Contributors
-* @jco-release-bot made their first contribution in [#678](https://github.com/bytecodealliance/jco/pull/678)
-* @dependabot[bot] made their first contribution in [#662](https://github.com/bytecodealliance/jco/pull/662)
-* @thomas9911 made their first contribution in [#648](https://github.com/bytecodealliance/jco/pull/648)
+- @jco-release-bot made their first contribution in [#678](https://github.com/bytecodealliance/jco/pull/678)
+- @dependabot[bot] made their first contribution in [#662](https://github.com/bytecodealliance/jco/pull/662)
+- @thomas9911 made their first contribution in [#648](https://github.com/bytecodealliance/jco/pull/648)
## [1.11.2-rc.1] - 2025-05-12
### ⚙️ Miscellaneous Tasks
-* *(jco)* update printed versions (#677) by @vados-cosmonic in #677
-
-* *(jco)* update printed CLI version by @vados-cosmonic
-
-
+- _(jco)_ update printed versions (#677) by @vados-cosmonic in #677
+- _(jco)_ update printed CLI version by @vados-cosmonic
## [1.11.2-rc.0] - 2025-05-11
### 🐛 Bug Fixes
-* *(jco)* missing stat dependency (#650) by @vados-cosmonic in #650
-
-* *(jco)* appending to const value raises error (#648) by @thomas9911 in #648
-
+- _(jco)_ missing stat dependency (#650) by @vados-cosmonic in #650
+- _(jco)_ appending to const value raises error (#648) by @thomas9911 in #648
## New Contributors
-* @dependabot[bot] made their first contribution in [#662](https://github.com/bytecodealliance/jco/pull/662)
-* @thomas9911 made their first contribution in [#648](https://github.com/bytecodealliance/jco/pull/648)
+- @dependabot[bot] made their first contribution in [#662](https://github.com/bytecodealliance/jco/pull/662)
+- @thomas9911 made their first contribution in [#648](https://github.com/bytecodealliance/jco/pull/648)
## [jco-v1.11.0] - 2025-04-28
### 🚀 Features
-* *(jco)* expose comoponentizejs's debugBuild option on command line (#633) by @pchickey in #633
-
-
+- _(jco)_ expose comoponentizejs's debugBuild option on command line (#633) by @pchickey in #633
## New Contributors
-* @tanishiking made their first contribution in [#631](https://github.com/bytecodealliance/jco/pull/631)
-* @marosset made their first contribution in [#609](https://github.com/bytecodealliance/jco/pull/609)
-* @MendyBerger made their first contribution in [#591](https://github.com/bytecodealliance/jco/pull/591)
+
+- @tanishiking made their first contribution in [#631](https://github.com/bytecodealliance/jco/pull/631)
+- @marosset made their first contribution in [#609](https://github.com/bytecodealliance/jco/pull/609)
+- @MendyBerger made their first contribution in [#591](https://github.com/bytecodealliance/jco/pull/591)
diff --git a/packages/jco/README.md b/packages/jco/README.md
index 1d08097c5..2326a7e68 100644
--- a/packages/jco/README.md
+++ b/packages/jco/README.md
@@ -5,7 +5,7 @@
JavaScript toolchain for working with WebAssembly Components
- A Bytecode Alliance project
+A Bytecode Alliance project
@@ -24,11 +24,11 @@ Jco provides a fully native JS toolchain for working with [WebAssembly Component
Features include:
-* "Transpiling" Wasm Component binaries into ES modules that can run in any JS environment.
-* WASI Preview2 support in Node.js & browsers (experimental).
-* Component builds of [Wasm Tools](https://github.com/bytecodealliance/wasm-tools) helpers, available for use as a library or CLI commands for use in native JS environments, as well as optimization helper for Components via Binaryen.
-* Run and serve commands like Wasmtime, as JS implementations of the Command and HTTP Proxy worlds.
-* "Componentize" command to easily create components written in JavaScript (wrapper of [ComponentizeJS](https://github.com/bytecodealliance/ComponentizeJS)).
+- "Transpiling" Wasm Component binaries into ES modules that can run in any JS environment.
+- WASI Preview2 support in Node.js & browsers (experimental).
+- Component builds of [Wasm Tools](https://github.com/bytecodealliance/wasm-tools) helpers, available for use as a library or CLI commands for use in native JS environments, as well as optimization helper for Components via Binaryen.
+- Run and serve commands like Wasmtime, as JS implementations of the Command and HTTP Proxy worlds.
+- "Componentize" command to easily create components written in JavaScript (wrapper of [ComponentizeJS](https://github.com/bytecodealliance/ComponentizeJS)).
For creating components in other languages, see the [Cargo Component](https://github.com/bytecodealliance/cargo-Component) project for Rust and [Wit Bindgen](https://github.com/bytecodealliance/wit-bindgen) for various guest bindgen helpers.
diff --git a/packages/jco/package.json b/packages/jco/package.json
index ca8d19bcb..45a85cd74 100644
--- a/packages/jco/package.json
+++ b/packages/jco/package.json
@@ -1,96 +1,96 @@
{
- "name": "@bytecodealliance/jco",
- "version": "1.12.0",
- "description": "JavaScript tooling for working with WebAssembly Components",
- "homepage": "https://github.com/bytecodealliance/jco#readme",
- "author": "Guy Bedford",
- "contributors": [
- {
- "name": "Guy Bedford"
+ "name": "@bytecodealliance/jco",
+ "version": "1.12.0",
+ "description": "JavaScript tooling for working with WebAssembly Components",
+ "homepage": "https://github.com/bytecodealliance/jco#readme",
+ "author": "Guy Bedford",
+ "contributors": [
+ {
+ "name": "Guy Bedford"
+ },
+ {
+ "name": "Victor Adossi",
+ "email": "vadossi@cosmonic.com"
+ }
+ ],
+ "type": "module",
+ "license": "(Apache-2.0 WITH LLVM-exception)",
+ "bugs": {
+ "url": "https://github.com/bytecodealliance/jco/issues"
},
- {
- "name": "Victor Adossi",
- "email": "vadossi@cosmonic.com"
- }
- ],
- "type": "module",
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "bugs": {
- "url": "https://github.com/bytecodealliance/jco/issues"
- },
- "keywords": [
- "Wasm",
- "WebAssembly",
- "Component"
- ],
- "repository": {
- "type": "git",
- "url": "git+https://github.com/bytecodealliance/jco.git"
- },
- "imports": {
- "#ora": {
- "browser": "./src/ora-shim.js",
- "default": "ora"
- }
- },
- "exports": {
- ".": {
- "browser": "./src/browser.js",
- "default": "./src/api.js"
+ "keywords": [
+ "Wasm",
+ "WebAssembly",
+ "Component"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/bytecodealliance/jco.git"
+ },
+ "imports": {
+ "#ora": {
+ "browser": "./src/ora-shim.js",
+ "default": "ora"
+ }
+ },
+ "exports": {
+ ".": {
+ "browser": "./src/browser.js",
+ "default": "./src/api.js"
+ },
+ "./component": {
+ "types": "./obj/js-component-bindgen-component.d.ts",
+ "default": "./src/browser.js"
+ }
+ },
+ "bin": {
+ "jco": "src/jco.js"
+ },
+ "files": [
+ "lib",
+ "src",
+ "obj/*.core*.wasm",
+ "obj/*.js",
+ "obj/*.ts",
+ "obj/interfaces"
+ ],
+ "scripts": {
+ "build": "cargo xtask build debug",
+ "build:release": "cargo xtask build release",
+ "build:types:preview2-shim": "npm run build:types:preview2-shim --include-workspace-root",
+ "fmt": "prettier . --write",
+ "lint": "eslint -c ../../eslint.config.mjs --ext .js src test",
+ "lint:fix": "npm run lint -- --fix",
+ "test": "vitest run -c test/vitest.ts",
+ "test:lts": "vitest run -c test/vitest.lts.ts",
+ "prepack": "cargo xtask build release"
+ },
+ "dependencies": {
+ "@bytecodealliance/componentize-js": "^0.18.3",
+ "@bytecodealliance/preview2-shim": "^0.17.2",
+ "binaryen": "^123.0.0",
+ "chalk-template": "^1",
+ "commander": "^12",
+ "mkdirp": "^3",
+ "ora": "^8",
+ "terser": "^5"
},
- "./component": {
- "types": "./obj/js-component-bindgen-component.d.ts",
- "default": "./src/browser.js"
+ "devDependencies": {
+ "@commitlint/config-conventional": "^19.8.1",
+ "@types/node": "^22.15.17",
+ "@typescript-eslint/eslint-plugin": "^8.2.0",
+ "@typescript-eslint/parser": "^8.2.0",
+ "commitlint": "^19.8.1",
+ "conventional-changelog-conventionalcommits": "^8.0.0",
+ "eslint": "^9.9.0",
+ "eslint-config-prettier": "^10.1.1",
+ "eslint-plugin-prettier": "^5.2.3",
+ "mime": "^4.0.4",
+ "prettier": "^3.5.3",
+ "puppeteer": "^24.0.1",
+ "semver": "^7.7.1",
+ "smol-toml": "^1.3.1",
+ "typescript": "^5.8.3",
+ "vitest": "^3.0.7"
}
- },
- "bin": {
- "jco": "src/jco.js"
- },
- "files": [
- "lib",
- "src",
- "obj/*.core*.wasm",
- "obj/*.js",
- "obj/*.ts",
- "obj/interfaces"
- ],
- "scripts": {
- "build": "cargo xtask build debug",
- "build:release": "cargo xtask build release",
- "build:types:preview2-shim": "npm run build:types:preview2-shim --include-workspace-root",
- "fmt": "prettier . --write",
- "lint": "eslint -c ../../eslint.config.mjs --ext .js src test",
- "lint:fix": "npm run lint -- --fix",
- "test": "vitest run -c test/vitest.ts",
- "test:lts": "vitest run -c test/vitest.lts.ts",
- "prepack": "cargo xtask build release"
- },
- "dependencies": {
- "@bytecodealliance/componentize-js": "^0.18.3",
- "@bytecodealliance/preview2-shim": "^0.17.2",
- "binaryen": "^123.0.0",
- "chalk-template": "^1",
- "commander": "^12",
- "mkdirp": "^3",
- "ora": "^8",
- "terser": "^5"
- },
- "devDependencies": {
- "@commitlint/config-conventional": "^19.8.1",
- "@types/node": "^22.15.17",
- "@typescript-eslint/eslint-plugin": "^8.2.0",
- "@typescript-eslint/parser": "^8.2.0",
- "commitlint": "^19.8.1",
- "conventional-changelog-conventionalcommits": "^8.0.0",
- "eslint": "^9.9.0",
- "eslint-config-prettier": "^10.1.1",
- "eslint-plugin-prettier": "^5.2.3",
- "mime": "^4.0.4",
- "prettier": "^3.5.3",
- "puppeteer": "^24.0.1",
- "semver": "^7.7.1",
- "smol-toml": "^1.3.1",
- "typescript": "^5.8.3",
- "vitest": "^3.0.7"
- }
}
diff --git a/packages/jco/src/api.d.ts b/packages/jco/src/api.d.ts
deleted file mode 100644
index 6bef5ad12..000000000
--- a/packages/jco/src/api.d.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * @param {Parameters[0]} binary
- * @return {Promise>}
- */
-export function print(binary: Parameters[0]): Promise>;
-/**
- * @param {Parameters[0]} wat
- * @return {Promise>}
- */
-export function parse(wat: Parameters[0]): Promise>;
-/**
- * @param {Parameters[0]} binary
- * @return {Promise>}
- */
-export function componentWit(binary: Parameters[0]): Promise>;
-/**
- * @param {Parameters[0]} binary
- * @param {Parameters[1]} adapters
- * @return {Promise>}
- */
-export function componentNew(binary: Parameters[0], adapters: Parameters[1]): Promise>;
-/**
- * @param {Parameters[0]} embedOpts
- * @return {Promise>}
- */
-export function componentEmbed(embedOpts: Parameters[0]): Promise>;
-/**
- * @param {Parameters[0]} binary
- * @param {Parameters[1]} metadata
- * @return {Promise>}
- */
-export function metadataAdd(binary: Parameters[0], metadata: Parameters[1]): Promise>;
-/**
- * @param {Parameters[0]} binary
- * @return {Promise>}
- */
-export function metadataShow(binary: Parameters[0]): Promise>;
-export function preview1AdapterCommandPath(): URL;
-export function preview1AdapterReactorPath(): URL;
-export { optimizeComponent as opt } from "./cmd/opt.js";
-export { transpileComponent as transpile, typesComponent as types } from "./cmd/transpile.js";
-//# sourceMappingURL=api.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/api.d.ts.map b/packages/jco/src/api.d.ts.map
deleted file mode 100644
index da3dcb6e1..000000000
--- a/packages/jco/src/api.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["api.js"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,8BAHW,UAAU,CAAC,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAKpE;AACD;;;GAGG;AACH,2BAHW,UAAU,CAAC,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAKpE;AACD;;;GAGG;AACH,qCAHW,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,GACzD,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAK3E;AACD;;;;GAIG;AACH,qCAJW,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAC1D,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,GACzD,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAK3E;AACD;;;GAGG;AACH,0CAHW,UAAU,CAAC,OAAO,sBAAsB,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,GAC3D,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,cAAc,CAAC,CAAC,CAK7E;AACD;;;;GAIG;AACH,oCAJW,UAAU,CAAC,OAAO,sBAAsB,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,YACzD,UAAU,CAAC,OAAO,sBAAsB,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GACxD,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,WAAW,CAAC,CAAC,CAK1E;AACD;;;GAGG;AACH,qCAHW,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,GACzD,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAK3E;AACD,kDAKC;AACD,kDAKC"}
\ No newline at end of file
diff --git a/packages/jco/src/browser.d.ts b/packages/jco/src/browser.d.ts
deleted file mode 100644
index b4050040b..000000000
--- a/packages/jco/src/browser.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export function generate(...args: any[]): Promise;
-export function generateTypes(...args: any[]): Promise;
-export { generate as transpile };
-//# sourceMappingURL=browser.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/browser.d.ts.map b/packages/jco/src/browser.d.ts.map
deleted file mode 100644
index 70e8f2e14..000000000
--- a/packages/jco/src/browser.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["browser.js"],"names":[],"mappings":"AAMA,uDAGC;AAED,4DAGC"}
\ No newline at end of file
diff --git a/packages/jco/src/cmd/componentize.d.ts b/packages/jco/src/cmd/componentize.d.ts
deleted file mode 100644
index c06790b79..000000000
--- a/packages/jco/src/cmd/componentize.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export function componentize(jsSource: any, opts: any): Promise;
-//# sourceMappingURL=componentize.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/cmd/componentize.d.ts.map b/packages/jco/src/cmd/componentize.d.ts.map
deleted file mode 100644
index c65f88f10..000000000
--- a/packages/jco/src/cmd/componentize.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"componentize.d.ts","sourceRoot":"","sources":["componentize.js"],"names":[],"mappings":"AAIA,sEAkBC"}
\ No newline at end of file
diff --git a/packages/jco/src/cmd/opt.d.ts b/packages/jco/src/cmd/opt.d.ts
deleted file mode 100644
index 9171a6c3d..000000000
--- a/packages/jco/src/cmd/opt.d.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export function opt(componentPath: any, opts: any, program: any): Promise;
-/**
- *
- * @param {Uint8Array} componentBytes
- * @param {{ quiet: boolean, asyncify?: boolean, optArgs?: string[], noVerify?: boolean }} opts?
- * @returns {Promise<{ component: Uint8Array, compressionInfo: { beforeBytes: number, afterBytes: number }[] >}
- */
-export function optimizeComponent(componentBytes: Uint8Array, opts: {
- quiet: boolean;
- asyncify?: boolean;
- optArgs?: string[];
- noVerify?: boolean;
-}): Promise<{
- component: Uint8Array;
- compressionInfo: {
- beforeBytes: number;
- afterBytes: number;
- }[];
-}>;
-//# sourceMappingURL=opt.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/cmd/opt.d.ts.map b/packages/jco/src/cmd/opt.d.ts.map
deleted file mode 100644
index 0c2161c42..000000000
--- a/packages/jco/src/cmd/opt.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"opt.d.ts","sourceRoot":"","sources":["opt.js"],"names":[],"mappings":"AAgBA,gFA2CC;AAgBD;;;;;GAKG;AACH,kDAJW,UAAU,QACV;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5E,OAAO,CAAC;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,eAAe,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAA,CAAE,CAkK7G"}
\ No newline at end of file
diff --git a/packages/jco/src/cmd/run.d.ts b/packages/jco/src/cmd/run.d.ts
deleted file mode 100644
index c4a4b5647..000000000
--- a/packages/jco/src/cmd/run.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export function run(componentPath: any, args: any, opts: any): Promise;
-export function serve(componentPath: any, args: any, opts: any): Promise;
-//# sourceMappingURL=run.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/cmd/run.d.ts.map b/packages/jco/src/cmd/run.d.ts.map
deleted file mode 100644
index bb73c2fb9..000000000
--- a/packages/jco/src/cmd/run.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["run.js"],"names":[],"mappings":"AASA,6EAmBC;AAED,+EA2BC"}
\ No newline at end of file
diff --git a/packages/jco/src/cmd/transpile.d.ts b/packages/jco/src/cmd/transpile.d.ts
deleted file mode 100644
index 468abee13..000000000
--- a/packages/jco/src/cmd/transpile.d.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-export function types(witPath: any, opts: any): Promise;
-export function guestTypes(witPath: any, opts: any): Promise;
-/**
- * @param {string} witPath
- * @param {{
- * name?: string,
- * worldName?: string,
- * instantiation?: 'async' | 'sync',
- * tlaCompat?: bool,
- * asyncMode?: string,
- * asyncImports?: string[],
- * asyncExports?: string[],
- * outDir?: string,
- * features?: string[] | 'all',
- * guest?: bool,
- * }} opts
- * @returns {Promise<{ [filename: string]: Uint8Array }>}
- */
-export function typesComponent(witPath: string, opts: {
- name?: string;
- worldName?: string;
- instantiation?: "async" | "sync";
- tlaCompat?: boolean;
- asyncMode?: string;
- asyncImports?: string[];
- asyncExports?: string[];
- outDir?: string;
- features?: string[] | "all";
- guest?: boolean;
-}): Promise<{
- [filename: string]: Uint8Array;
-}>;
-export function transpile(componentPath: any, opts: any, program: any): Promise;
-/**
- *
- * @param {Uint8Array} component
- * @param {{
- * name: string,
- * instantiation?: 'async' | 'sync',
- * importBindings?: 'js' | 'optimized' | 'hybrid' | 'direct-optimized',
- * map?: Record,
- * asyncMode?: string,
- * asyncImports?: string[],
- * asyncExports?: string[],
- * validLiftingOptimization?: bool,
- * tracing?: bool,
- * nodejsCompat?: bool,
- * tlaCompat?: bool,
- * base64Cutoff?: bool,
- * js?: bool,
- * minify?: bool,
- * optimize?: bool,
- * namespacedExports?: bool,
- * outDir?: string,
- * multiMemory?: bool,
- * experimentalIdlImports?: bool,
- * optArgs?: string[],
- * }} opts
- * @returns {Promise<{ files: { [filename: string]: Uint8Array }, imports: string[], exports: [string, 'function' | 'instance'][] }>}
- */
-export function transpileComponent(component: Uint8Array, opts?: {
- name: string;
- instantiation?: "async" | "sync";
- importBindings?: "js" | "optimized" | "hybrid" | "direct-optimized";
- map?: Record;
- asyncMode?: string;
- asyncImports?: string[];
- asyncExports?: string[];
- validLiftingOptimization?: boolean;
- tracing?: boolean;
- nodejsCompat?: boolean;
- tlaCompat?: boolean;
- base64Cutoff?: boolean;
- js?: boolean;
- minify?: boolean;
- optimize?: boolean;
- namespacedExports?: boolean;
- outDir?: string;
- multiMemory?: boolean;
- experimentalIdlImports?: boolean;
- optArgs?: string[];
-}): Promise<{
- files: {
- [filename: string]: Uint8Array;
- };
- imports: string[];
- exports: [string, "function" | "instance"][];
-}>;
-//# sourceMappingURL=transpile.d.ts.map
diff --git a/packages/jco/src/cmd/transpile.d.ts.map b/packages/jco/src/cmd/transpile.d.ts.map
deleted file mode 100644
index f9dceb062..000000000
--- a/packages/jco/src/cmd/transpile.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"AA+CA,8DAGC;AAED,mEAMC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wCAfW,MAAM,QACN;IACN,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC5B,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,GACS,OAAO,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC,CA+DvD;AAyCD,sFAoCC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,8CAzBW,UAAU,SACV;IACN,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,QAAQ,GAAG,kBAAkB,CAAC;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,wBAAwB,CAAC,EAAE,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,sBAAsB,CAAC,EAAE,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACS,OAAO,CAAC;IAAE,KAAK,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,CAAA;CAAE,CAAC,CAyTnI"}
\ No newline at end of file
diff --git a/packages/jco/src/cmd/types.d.ts b/packages/jco/src/cmd/types.d.ts
deleted file mode 100644
index 117bb09e8..000000000
--- a/packages/jco/src/cmd/types.d.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-export function types(witPath: any, opts: any): Promise;
-export function guestTypes(witPath: any, opts: any): Promise;
-/**
- * @param {string} witPath
- * @param {{
- * name?: string,
- * worldName?: string,
- * instantiation?: 'async' | 'sync',
- * tlaCompat?: bool,
- * asyncMode?: string,
- * asyncImports?: string[],
- * asyncExports?: string[],
- * outDir?: string,
- * features?: string[] | 'all',
- * guest?: bool,
- * }} opts
- * @returns {Promise<{ [filename: string]: Uint8Array }>}
- */
-export function typesComponent(witPath: string, opts: {
- name?: string;
- worldName?: string;
- instantiation?: "async" | "sync";
- tlaCompat?: boolean;
- asyncMode?: string;
- asyncImports?: string[];
- asyncExports?: string[];
- outDir?: string;
- features?: string[] | "all";
- guest?: boolean;
-}): Promise<{
- [filename: string]: Uint8Array;
-}>;
-//# sourceMappingURL=types.d.ts.map
diff --git a/packages/jco/src/cmd/wasm-tools.d.ts b/packages/jco/src/cmd/wasm-tools.d.ts
deleted file mode 100644
index a130192b7..000000000
--- a/packages/jco/src/cmd/wasm-tools.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export function parse(file: any, opts: any): Promise;
-export function print(file: any, opts: any): Promise;
-export function componentWit(file: any, opts: any): Promise;
-export function componentNew(file: any, opts: any): Promise;
-export function componentEmbed(file: any, opts: any): Promise;
-export function metadataAdd(file: any, opts: any): Promise;
-export function metadataShow(file: any, opts: any): Promise;
-//# sourceMappingURL=wasm-tools.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/cmd/wasm-tools.d.ts.map b/packages/jco/src/cmd/wasm-tools.d.ts.map
deleted file mode 100644
index e6b76434a..000000000
--- a/packages/jco/src/cmd/wasm-tools.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"wasm-tools.d.ts","sourceRoot":"","sources":["wasm-tools.js"],"names":[],"mappings":"AAOA,2DAKC;AAED,2DASC;AAED,kEASC;AAED,kEAsBC;AAED,oEAaC;AAED,iEAUC;AAED,kEAiCC"}
\ No newline at end of file
diff --git a/packages/jco/src/common.d.ts b/packages/jco/src/common.d.ts
deleted file mode 100644
index 8c0f1be49..000000000
--- a/packages/jco/src/common.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export function setShowSpinner(val: any): void;
-export function getShowSpinner(): boolean;
-export function sizeStr(num: any): string;
-export function fixedDigitDisplay(num: any, maxChars: any): string;
-export function table(data: any, align?: any[]): string;
-/**
- * Securely creates a temporary directory and returns its path.
- *
- * The new directory is created using `fsPromises.mkdtemp()`.
- */
-export function getTmpDir(): Promise;
-export function spawnIOTmp(cmd: any, input: any, args: any): Promise>;
-export function writeFiles(files: any, summaryTitle: any): Promise;
-export const isWindows: boolean;
-export { readFileCli as readFile };
-declare function readFileCli(file: any, encoding: any): Promise>;
-//# sourceMappingURL=common.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/common.d.ts.map b/packages/jco/src/common.d.ts.map
deleted file mode 100644
index aff35feef..000000000
--- a/packages/jco/src/common.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.js"],"names":[],"mappings":"AA2BA,+CAEC;AACD,0CAIC;AAED,0CASC;AAED,mEAcC;AAED,wDAoBC;AAED;;;;GAIG;AACH,6CAEC;AAWD,8FAiCC;AAED,yEAmBC;AArJD,gCAA8C;;AAsF9C,yFAMC"}
\ No newline at end of file
diff --git a/packages/jco/src/jco.d.ts b/packages/jco/src/jco.d.ts
deleted file mode 100644
index 21be8ccad..000000000
--- a/packages/jco/src/jco.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env node
-export {};
-//# sourceMappingURL=jco.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/jco.d.ts.map b/packages/jco/src/jco.d.ts.map
deleted file mode 100644
index f5baa1351..000000000
--- a/packages/jco/src/jco.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"jco.d.ts","sourceRoot":"","sources":["jco.js"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/packages/jco/src/jco.js b/packages/jco/src/jco.js
index 55042b3d2..5cfbced37 100755
--- a/packages/jco/src/jco.js
+++ b/packages/jco/src/jco.js
@@ -443,7 +443,7 @@ program.showHelpAfterError();
program.parse();
function asyncAction(cmd) {
- return function() {
+ return function () {
const args = [...arguments];
(async () => {
try {
diff --git a/packages/jco/src/ora-shim.d.ts b/packages/jco/src/ora-shim.d.ts
deleted file mode 100644
index bbf72b797..000000000
--- a/packages/jco/src/ora-shim.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/** Browser shim for Ora */
-export default function ora(): Ora;
-declare class Ora {
- start(): void;
- stop(): void;
-}
-export {};
-//# sourceMappingURL=ora-shim.d.ts.map
\ No newline at end of file
diff --git a/packages/jco/src/ora-shim.d.ts.map b/packages/jco/src/ora-shim.d.ts.map
deleted file mode 100644
index 407eb7910..000000000
--- a/packages/jco/src/ora-shim.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ora-shim.d.ts","sourceRoot":"","sources":["ora-shim.js"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,mCAEC;AAED;IACI,cAAU;IACV,aAAS;CACZ"}
\ No newline at end of file
diff --git a/packages/jco/test/async.browser.js b/packages/jco/test/async.browser.js
index e2d4acda0..b813f9803 100644
--- a/packages/jco/test/async.browser.js
+++ b/packages/jco/test/async.browser.js
@@ -19,7 +19,7 @@ suite(`Async`, async () => {
var outDir;
var outFile;
- beforeAll(async function() {
+ beforeAll(async function () {
tmpDir = await getTmpDir();
outDir = resolve(tmpDir, 'out-component-dir');
outFile = resolve(tmpDir, 'out-component-file');
@@ -35,13 +35,13 @@ suite(`Async`, async () => {
);
});
- afterAll(async function() {
+ afterAll(async function () {
try {
await rm(tmpDir, { recursive: true });
} catch {}
});
- afterEach(async function() {
+ afterEach(async function () {
try {
await rm(outDir, { recursive: true });
await rm(outFile);
diff --git a/packages/jco/test/browser.html b/packages/jco/test/browser.html
index a6a5438eb..46554bf53 100644
--- a/packages/jco/test/browser.html
+++ b/packages/jco/test/browser.html
@@ -1,81 +1,100 @@
diff --git a/packages/jco/test/browser.js b/packages/jco/test/browser.js
index 465113776..f1da27cfa 100644
--- a/packages/jco/test/browser.js
+++ b/packages/jco/test/browser.js
@@ -23,7 +23,7 @@ suite('Browser', () => {
let tmpDir, outDir, outFile, outDirUrl;
let server, port, browser;
- beforeAll(async function() {
+ beforeAll(async function () {
tmpDir = await getTmpDir();
outDir = resolve(tmpDir, 'out-component-dir');
outDirUrl = pathToFileURL(outDir + '/');
@@ -85,7 +85,7 @@ suite('Browser', () => {
browser = await puppeteer.launch();
});
- afterAll(async function() {
+ afterAll(async function () {
try {
await rm(tmpDir, { recursive: true });
} catch {}
@@ -93,7 +93,7 @@ suite('Browser', () => {
await new Promise((resolve) => server.close(resolve));
});
- afterEach(async function() {
+ afterEach(async function () {
try {
await rm(outDir, { recursive: true });
await rm(outFile);
diff --git a/packages/jco/test/cli.js b/packages/jco/test/cli.js
index c51b0c19c..7f175af79 100644
--- a/packages/jco/test/cli.js
+++ b/packages/jco/test/cli.js
@@ -24,7 +24,7 @@ suite('CLI', () => {
var outDir;
var outFile;
- beforeAll(async function() {
+ beforeAll(async function () {
tmpDir = await getTmpDir();
outDir = resolve(tmpDir, 'out-component-dir');
outFile = resolve(tmpDir, 'out-component-file');
@@ -40,13 +40,13 @@ suite('CLI', () => {
);
});
- afterAll(async function() {
+ afterAll(async function () {
try {
await rm(tmpDir, { recursive: true });
} catch {}
});
- afterEach(async function() {
+ afterEach(async function () {
try {
await rm(outDir, { recursive: true });
await rm(outFile);
diff --git a/packages/jco/test/fixtures/browser/test-pages/something__test.async.html b/packages/jco/test/fixtures/browser/test-pages/something__test.async.html
index 6da546a3d..f1a4f2b5f 100644
--- a/packages/jco/test/fixtures/browser/test-pages/something__test.async.html
+++ b/packages/jco/test/fixtures/browser/test-pages/something__test.async.html
@@ -1,4 +1,4 @@
-
+
diff --git a/packages/jco/test/fixtures/commands/tests.json b/packages/jco/test/fixtures/commands/tests.json
index 07668b497..811704c23 100644
--- a/packages/jco/test/fixtures/commands/tests.json
+++ b/packages/jco/test/fixtures/commands/tests.json
@@ -1,7 +1,7 @@
{
- "dir.virt": {
- "args": ["/foo"],
- "stderr": "",
- "stdout": "Listing directory: /foo\n - .\n - ..\n - foo\n"
- }
+ "dir.virt": {
+ "args": ["/foo"],
+ "stderr": "",
+ "stdout": "Listing directory: /foo\n - .\n - ..\n - foo\n"
+ }
}
diff --git a/packages/jco/test/helpers.js b/packages/jco/test/helpers.js
index b5eb5d96b..bacb909f5 100644
--- a/packages/jco/test/helpers.js
+++ b/packages/jco/test/helpers.js
@@ -478,7 +478,7 @@ export async function loadTestPage(args) {
export async function getRandomPort() {
return await new Promise((resolve) => {
const server = createNetServer();
- server.listen(0, function() {
+ server.listen(0, function () {
const port = this.address().port;
server.on('close', () => resolve(port));
server.close();
diff --git a/packages/jco/test/tsconfig.json b/packages/jco/test/tsconfig.json
index afc00e083..f26bc80c6 100644
--- a/packages/jco/test/tsconfig.json
+++ b/packages/jco/test/tsconfig.json
@@ -1,22 +1,22 @@
{
- "include": ["runtime/*.ts"],
- "TODO": "why are these runtime tests excluded?",
- "exclude": [
- "runtime/strings.async+js.ts",
- "runtime/strings.sync+js.ts",
- "runtime/strings.sync.ts"
- ],
- "compilerOptions": {
- "outDir": "output",
- "module": "nodenext",
- "moduleResolution": "nodenext",
- "target": "es2020",
- "strict": true,
- "noImplicitAny": false,
- "strictNullChecks": true,
- "baseUrl": "../",
- "paths": {
- "@bytecodealliance/preview2-shim": ["package/preview2-shim"]
+ "include": ["runtime/*.ts"],
+ "TODO": "why are these runtime tests excluded?",
+ "exclude": [
+ "runtime/strings.async+js.ts",
+ "runtime/strings.sync+js.ts",
+ "runtime/strings.sync.ts"
+ ],
+ "compilerOptions": {
+ "outDir": "output",
+ "module": "nodenext",
+ "moduleResolution": "nodenext",
+ "target": "es2020",
+ "strict": true,
+ "noImplicitAny": false,
+ "strictNullChecks": true,
+ "baseUrl": "../",
+ "paths": {
+ "@bytecodealliance/preview2-shim": ["package/preview2-shim"]
+ }
}
- }
}
diff --git a/packages/jco/test/vitest.lts.ts b/packages/jco/test/vitest.lts.ts
index b92d4fc0e..e391c33ad 100644
--- a/packages/jco/test/vitest.lts.ts
+++ b/packages/jco/test/vitest.lts.ts
@@ -1,31 +1,31 @@
-import { availableParallelism, platform } from "node:os";
+import { availableParallelism, platform } from 'node:os';
-import { defineConfig } from "vitest/config";
+import { defineConfig } from 'vitest/config';
const DEFAULT_TIMEOUT_MS = 1000 * 60 * 10; // 10m
const REPORTERS = process.env.GITHUB_ACTIONS
- ? ["verbose", "github-actions"]
- : ["verbose"];
+ ? ['verbose', 'github-actions']
+ : ['verbose'];
export default defineConfig({
- test: {
- retry: 3,
- reporters: REPORTERS,
- maxConcurrency: Math.max(availableParallelism() / 2, 5),
- disableConsoleIntercept: true,
- printConsoleTrace: true,
- passWithNoTests: false,
- include: ["test/*.js"],
- setupFiles: ["test/meta-resolve-stub.ts"],
- exclude: [
- "test/output/*",
- "test/fixtures/*",
- "test/common.js",
- "test/helpers.js",
- ],
- testTimeout: DEFAULT_TIMEOUT_MS,
- hookTimeout: DEFAULT_TIMEOUT_MS,
- teardownTimeout: DEFAULT_TIMEOUT_MS,
- },
+ test: {
+ retry: 3,
+ reporters: REPORTERS,
+ maxConcurrency: Math.max(availableParallelism() / 2, 5),
+ disableConsoleIntercept: true,
+ printConsoleTrace: true,
+ passWithNoTests: false,
+ include: ['test/*.js'],
+ setupFiles: ['test/meta-resolve-stub.ts'],
+ exclude: [
+ 'test/output/*',
+ 'test/fixtures/*',
+ 'test/common.js',
+ 'test/helpers.js',
+ ],
+ testTimeout: DEFAULT_TIMEOUT_MS,
+ hookTimeout: DEFAULT_TIMEOUT_MS,
+ teardownTimeout: DEFAULT_TIMEOUT_MS,
+ },
});
diff --git a/packages/jco/test/vitest.ts b/packages/jco/test/vitest.ts
index 5b9dea150..ccdd9cb9e 100644
--- a/packages/jco/test/vitest.ts
+++ b/packages/jco/test/vitest.ts
@@ -1,37 +1,40 @@
-import { availableParallelism, platform } from "node:os";
+import { availableParallelism, platform } from 'node:os';
-import { defineConfig } from "vitest/config";
+import { defineConfig } from 'vitest/config';
const DEFAULT_TIMEOUT_MS = 1000 * 60 * 10; // 10m
const REPORTERS = process.env.GITHUB_ACTIONS
- ? ["verbose", "github-actions"]
- : ["verbose"];
+ ? ['verbose', 'github-actions']
+ : ['verbose'];
export default defineConfig({
- test: {
- retry: 3,
- reporters: REPORTERS,
- maxConcurrency: Math.max(availableParallelism() / 2, 5),
- disableConsoleIntercept: true,
- printConsoleTrace: true,
- passWithNoTests: false,
- include: ["test/*.js"],
- setupFiles: ["test/meta-resolve-stub.ts"],
- exclude: [
- "test/output/*",
- "test/fixtures/*",
- "test/common.js",
- "test/helpers.js",
- ],
- testTimeout: DEFAULT_TIMEOUT_MS,
- hookTimeout: DEFAULT_TIMEOUT_MS,
- teardownTimeout: DEFAULT_TIMEOUT_MS,
- pool: "forks",
- poolOptions: {
- forks: {
- execArgv: ["--experimental-wasm-jspi", "--stack-trace-limit=100"],
- },
+ test: {
+ retry: 3,
+ reporters: REPORTERS,
+ maxConcurrency: Math.max(availableParallelism() / 2, 5),
+ disableConsoleIntercept: true,
+ printConsoleTrace: true,
+ passWithNoTests: false,
+ include: ['test/*.js'],
+ setupFiles: ['test/meta-resolve-stub.ts'],
+ exclude: [
+ 'test/output/*',
+ 'test/fixtures/*',
+ 'test/common.js',
+ 'test/helpers.js',
+ ],
+ testTimeout: DEFAULT_TIMEOUT_MS,
+ hookTimeout: DEFAULT_TIMEOUT_MS,
+ teardownTimeout: DEFAULT_TIMEOUT_MS,
+ pool: 'forks',
+ poolOptions: {
+ forks: {
+ execArgv: [
+ '--experimental-wasm-jspi',
+ '--stack-trace-limit=100',
+ ],
+ },
+ },
},
- },
});
diff --git a/packages/jco/test/wit.js b/packages/jco/test/wit.js
index cada505c3..cf7284c20 100644
--- a/packages/jco/test/wit.js
+++ b/packages/jco/test/wit.js
@@ -16,7 +16,7 @@ suite('WIT', () => {
var witFixturesPath;
- beforeAll(async function() {
+ beforeAll(async function () {
tmpDir = await getTmpDir();
outFile = resolve(tmpDir, 'out-component-file');
featureGatesWitPath = resolve('test/fixtures/wits/feature-gates.wit');
@@ -25,13 +25,13 @@ suite('WIT', () => {
witFixturesPath = resolve('test/fixtures/wits');
});
- afterAll(async function() {
+ afterAll(async function () {
try {
await rm(tmpDir, { recursive: true });
} catch {}
});
- afterEach(async function() {
+ afterEach(async function () {
try {
await rm(outFile);
} catch {}
diff --git a/packages/jco/tsconfig.json b/packages/jco/tsconfig.json
index 28aba98d9..55b8d4682 100644
--- a/packages/jco/tsconfig.json
+++ b/packages/jco/tsconfig.json
@@ -1,13 +1,14 @@
{
- "include": ["src/**/*"],
- "exclude": ["node_modules", "src/cmd/**", "src/*.d.ts"],
- "compilerOptions": {
- "module": "nodenext",
- "moduleResolution": "nodenext",
- "allowJs": true,
- "declaration": true,
- "emitDeclarationOnly": true,
- "declarationMap": true,
- "skipLibCheck": true,
- }
+ "extends": "@tsconfig/node20",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "dist",
+ "sourceMap": true,
+ "declaration": true,
+ "declarationMap": true,
+ "emitDeclarationOnly": true,
+ "composite": true,
+ "allowJs": true
+ },
+ "include": ["src/**/*"]
}
diff --git a/packages/preview2-shim/package.json b/packages/preview2-shim/package.json
index 64fb8858d..74a3549bc 100644
--- a/packages/preview2-shim/package.json
+++ b/packages/preview2-shim/package.json
@@ -1,43 +1,47 @@
{
- "name": "@bytecodealliance/preview2-shim",
- "version": "0.17.2",
- "description": "WASI Preview2 shim for JS environments",
- "author": "Guy Bedford, Eduardo Rodrigues<16357187+eduardomourar@users.noreply.github.com>",
- "type": "module",
- "types": "./types/index.d.ts",
- "exports": {
- ".": {
- "types": "./types/index.d.ts",
- "node": "./lib/nodejs/index.js",
- "default": "./lib/browser/index.js"
+ "name": "@bytecodealliance/preview2-shim",
+ "version": "0.17.2",
+ "description": "WASI Preview2 shim for JS environments",
+ "author": "Guy Bedford, Eduardo Rodrigues<16357187+eduardomourar@users.noreply.github.com>",
+ "type": "module",
+ "types": "./types/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./types/index.d.ts",
+ "node": "./lib/nodejs/index.js",
+ "default": "./lib/browser/index.js"
+ },
+ "./*": {
+ "types": "./types/*.d.ts",
+ "node": "./lib/nodejs/*.js",
+ "default": "./lib/browser/*.js"
+ },
+ "./instantiation": {
+ "types": "./types/instantiation.d.ts",
+ "node": "./lib/common/instantiation.js",
+ "default": "./lib/common/instantiation.js"
+ }
},
- "./*": {
- "types": "./types/*.d.ts",
- "node": "./lib/nodejs/*.js",
- "default": "./lib/browser/*.js"
+ "scripts": {
+ "lint": "eslint -c ../../eslint.config.mjs ./lib/**/*.js",
+ "lint:fix": "npm run lint -- --fix",
+ "test": "vitest run -c test/vitest.ts"
},
- "./instantiation": {
- "types": "./types/instantiation.d.ts",
- "node": "./lib/common/instantiation.js",
- "default": "./lib/common/instantiation.js"
+ "files": [
+ "types",
+ "lib"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/bytecodealliance/jco.git"
+ },
+ "license": "(Apache-2.0 WITH LLVM-exception)",
+ "bugs": {
+ "url": "https://github.com/bytecodealliance/jco/issues"
+ },
+ "homepage": "https://github.com/bytecodealliance/jco#readme",
+ "devDependencies": {
+ "@tsconfig/node20": "^20.1.6",
+ "typescript": "^5.8.3"
}
- },
- "scripts": {
- "lint": "eslint -c ../../eslint.config.mjs ./lib/**/*.js",
- "lint:fix": "npm run lint -- --fix",
- "test": "vitest run -c test/vitest.ts"
- },
- "files": [
- "types",
- "lib"
- ],
- "repository": {
- "type": "git",
- "url": "git+https://github.com/bytecodealliance/jco.git"
- },
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "bugs": {
- "url": "https://github.com/bytecodealliance/jco/issues"
- },
- "homepage": "https://github.com/bytecodealliance/jco#readme"
}
diff --git a/packages/preview3-shim/package.json b/packages/preview3-shim/package.json
index 123d284ad..fcfa0e683 100644
--- a/packages/preview3-shim/package.json
+++ b/packages/preview3-shim/package.json
@@ -1,50 +1,52 @@
{
- "name": "@bytecodealliance/preview3-shim",
- "version": "0.1.0",
- "description": "WASI Preview3 shim for JS environments",
- "author": "Tomasz Andrzejak",
- "type": "module",
- "types": "./types/index.d.ts",
- "exports": {
- ".": {
- "node": "./lib/nodejs/index.js",
- "types": "./types/index.d.ts"
+ "name": "@bytecodealliance/preview3-shim",
+ "version": "0.1.0",
+ "description": "WASI Preview3 shim for JS environments",
+ "author": "Tomasz Andrzejak",
+ "type": "module",
+ "types": "./types/index.d.ts",
+ "exports": {
+ ".": {
+ "node": "./lib/nodejs/index.js",
+ "types": "./types/index.d.ts"
+ },
+ "./*": {
+ "node": "./lib/nodejs/*.js",
+ "types": "./types/*.d.ts"
+ }
},
- "./*": {
- "node": "./lib/nodejs/*.js",
- "types": "./types/*.d.ts"
- }
- },
- "scripts": {
- "compile:check": "tsc --noEmit types/index.d.ts",
- "fmt": "prettier . --write",
- "lint": "eslint -c ../../eslint.config.mjs --ext .js lib test",
- "lint:fix": "eslint -c ../../eslint.config.mjs --ext .js lib test --fix",
- "test": "vitest --run",
- "bench": "vitest bench --run"
- },
- "files": [
- "types",
- "lib"
- ],
- "dependencies": {
- "@bytecodealliance/preview2-shim": "^0.17.2"
- },
- "devDependencies": {
- "@eslint/js": "^9.21.0",
- "eslint": "^9.21.0",
- "globals": "^16.0.0",
- "vitest": "^3.1.1",
- "prettier": "^3.5.3",
- "typescript-eslint": "^8.26.0"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/bytecodealliance/jco.git"
- },
- "license": "(Apache-2.0 WITH LLVM-exception)",
- "bugs": {
- "url": "https://github.com/bytecodealliance/jco/issues"
- },
- "homepage": "https://github.com/bytecodealliance/jco/blob/main/packages/preview3-shim/#readme"
+ "scripts": {
+ "compile:check": "tsc --noEmit types/index.d.ts",
+ "fmt": "prettier . --write",
+ "lint": "eslint -c ../../eslint.config.mjs --ext .js lib test",
+ "lint:fix": "eslint -c ../../eslint.config.mjs --ext .js lib test --fix",
+ "test": "vitest --run",
+ "bench": "vitest bench --run"
+ },
+ "files": [
+ "types",
+ "lib"
+ ],
+ "dependencies": {
+ "@bytecodealliance/preview2-shim": "^0.17.2"
+ },
+ "devDependencies": {
+ "@eslint/js": "^9.21.0",
+ "@tsconfig/node20": "^20.1.6",
+ "eslint": "^9.21.0",
+ "globals": "^16.0.0",
+ "prettier": "^3.5.3",
+ "typescript": "^5.8.3",
+ "typescript-eslint": "^8.26.0",
+ "vitest": "^3.1.1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/bytecodealliance/jco.git"
+ },
+ "license": "(Apache-2.0 WITH LLVM-exception)",
+ "bugs": {
+ "url": "https://github.com/bytecodealliance/jco/issues"
+ },
+ "homepage": "https://github.com/bytecodealliance/jco/blob/main/packages/preview3-shim/#readme"
}
diff --git a/packages/preview3-shim/test/helpers.js b/packages/preview3-shim/test/helpers.js
index 6402f55d9..b4e691d35 100644
--- a/packages/preview3-shim/test/helpers.js
+++ b/packages/preview3-shim/test/helpers.js
@@ -4,7 +4,7 @@ import { createServer as createNetServer } from 'node:net';
export async function getRandomPort() {
return await new Promise((resolve) => {
const server = createNetServer();
- server.listen(0, function() {
+ server.listen(0, function () {
const port = this.address().port;
server.on('close', () => resolve(port));
server.close();
diff --git a/packages/preview3-shim/types/cli.d.ts b/packages/preview3-shim/types/cli.d.ts
index a9f842f92..25c66d737 100644
--- a/packages/preview3-shim/types/cli.d.ts
+++ b/packages/preview3-shim/types/cli.d.ts
@@ -1,11 +1,11 @@
-export type * as environment from "./interfaces/wasi-cli-environment.d.ts";
-export type * as exit from "./interfaces/wasi-cli-exit.d.ts";
-export type * as run from "./interfaces/wasi-cli-run.d.ts";
-export type * as stderr from "./interfaces/wasi-cli-stderr.d.ts";
-export type * as stdin from "./interfaces/wasi-cli-stdin.d.ts";
-export type * as stdout from "./interfaces/wasi-cli-stdout.d.ts";
-export type * as terminalInput from "./interfaces/wasi-cli-terminal-input.d.ts";
-export type * as terminalOutput from "./interfaces/wasi-cli-terminal-output.d.ts";
-export type * as terminalStderr from "./interfaces/wasi-cli-terminal-stderr.d.ts";
-export type * as terminalStdin from "./interfaces/wasi-cli-terminal-stdin.d.ts";
-export type * as terminalStdout from "./interfaces/wasi-cli-terminal-stdout.d.ts";
+export type * as environment from './interfaces/wasi-cli-environment.d.ts';
+export type * as exit from './interfaces/wasi-cli-exit.d.ts';
+export type * as run from './interfaces/wasi-cli-run.d.ts';
+export type * as stderr from './interfaces/wasi-cli-stderr.d.ts';
+export type * as stdin from './interfaces/wasi-cli-stdin.d.ts';
+export type * as stdout from './interfaces/wasi-cli-stdout.d.ts';
+export type * as terminalInput from './interfaces/wasi-cli-terminal-input.d.ts';
+export type * as terminalOutput from './interfaces/wasi-cli-terminal-output.d.ts';
+export type * as terminalStderr from './interfaces/wasi-cli-terminal-stderr.d.ts';
+export type * as terminalStdin from './interfaces/wasi-cli-terminal-stdin.d.ts';
+export type * as terminalStdout from './interfaces/wasi-cli-terminal-stdout.d.ts';
diff --git a/packages/preview3-shim/types/clocks.d.ts b/packages/preview3-shim/types/clocks.d.ts
index 19cc6c306..5924b0730 100644
--- a/packages/preview3-shim/types/clocks.d.ts
+++ b/packages/preview3-shim/types/clocks.d.ts
@@ -1,2 +1,2 @@
-export type * as monotonicClock from "./interfaces/wasi-clocks-monotonic-clock.d.ts";
-export type * as wallClock from "./interfaces/wasi-clocks-wall-clock.d.ts";
+export type * as monotonicClock from './interfaces/wasi-clocks-monotonic-clock.d.ts';
+export type * as wallClock from './interfaces/wasi-clocks-wall-clock.d.ts';
diff --git a/packages/preview3-shim/types/filesystem.d.ts b/packages/preview3-shim/types/filesystem.d.ts
index 56da9436e..0780816dc 100644
--- a/packages/preview3-shim/types/filesystem.d.ts
+++ b/packages/preview3-shim/types/filesystem.d.ts
@@ -1,2 +1,2 @@
-export type * as preopens from "./interfaces/wasi-filesystem-preopens.d.ts";
-export type * as types from "./interfaces/wasi-filesystem-types.d.ts";
+export type * as preopens from './interfaces/wasi-filesystem-preopens.d.ts';
+export type * as types from './interfaces/wasi-filesystem-types.d.ts';
diff --git a/packages/preview3-shim/types/http.d.ts b/packages/preview3-shim/types/http.d.ts
index 55189cac0..6edad6396 100644
--- a/packages/preview3-shim/types/http.d.ts
+++ b/packages/preview3-shim/types/http.d.ts
@@ -1,2 +1,2 @@
-export type * as handler from "./interfaces/wasi-http-handler.d.ts";
-export type * as types from "./interfaces/wasi-http-types.d.ts";
+export type * as handler from './interfaces/wasi-http-handler.d.ts';
+export type * as types from './interfaces/wasi-http-types.d.ts';
diff --git a/packages/preview3-shim/types/index.d.ts b/packages/preview3-shim/types/index.d.ts
index 48c7c3121..b10650765 100644
--- a/packages/preview3-shim/types/index.d.ts
+++ b/packages/preview3-shim/types/index.d.ts
@@ -1,6 +1,6 @@
-export type * as cli from "./cli.d.ts";
-export type * as clocks from "./clocks.d.ts";
-export type * as filesystem from "./filesystem.d.ts";
-export type * as http from "./http.d.ts";
-export type * as random from "./random.d.ts";
-export type * as sockets from "./sockets.d.ts";
+export type * as cli from './cli.d.ts';
+export type * as clocks from './clocks.d.ts';
+export type * as filesystem from './filesystem.d.ts';
+export type * as http from './http.d.ts';
+export type * as random from './random.d.ts';
+export type * as sockets from './sockets.d.ts';
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-environment.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-environment.d.ts
index a481affa8..6231cfc29 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-environment.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-environment.d.ts
@@ -1,10 +1,10 @@
/** @module Interface wasi:cli/environment@0.3.0 **/
/**
* Get the POSIX-style environment variables.
- *
+ *
* Each environment variable is provided as a pair of string variable names
* and string value.
- *
+ *
* Morally, these are a value import, but until value imports are available
* in the component model, this import function should return the same
* values each time it is called.
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-exit.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-exit.d.ts
index 3a516cb99..f47558c8d 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-exit.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-exit.d.ts
@@ -3,4 +3,4 @@
* Exit the current instance and any linked instances.
*/
export function exit(status: Result): void;
-export type Result = { tag: 'ok', val: T } | { tag: 'err', val: E };
+export type Result = { tag: 'ok'; val: T } | { tag: 'err'; val: E };
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-input.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-input.d.ts
index 44957389b..0ff53ce84 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-input.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-input.d.ts
@@ -1,8 +1,8 @@
/** @module Interface wasi:cli/terminal-input@0.3.0 **/
export class TerminalInput {
- /**
- * This type does not have a public constructor.
- */
- private constructor();
+ /**
+ * This type does not have a public constructor.
+ */
+ private constructor();
}
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-output.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-output.d.ts
index 7334d0567..4e43596a6 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-output.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-output.d.ts
@@ -1,8 +1,8 @@
/** @module Interface wasi:cli/terminal-output@0.3.0 **/
export class TerminalOutput {
- /**
- * This type does not have a public constructor.
- */
- private constructor();
+ /**
+ * This type does not have a public constructor.
+ */
+ private constructor();
}
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stderr.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stderr.d.ts
index 6a3243bf6..d82d47c91 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stderr.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stderr.d.ts
@@ -4,4 +4,5 @@
* allowing further interaction with it.
*/
export function getTerminalStderr(): TerminalOutput | undefined;
-export type TerminalOutput = import('./wasi-cli-terminal-output.js').TerminalOutput;
+export type TerminalOutput =
+ import('./wasi-cli-terminal-output.js').TerminalOutput;
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdin.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdin.d.ts
index 87fceb034..bfefeaa39 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdin.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdin.d.ts
@@ -4,4 +4,5 @@
* allowing further interaction with it.
*/
export function getTerminalStdin(): TerminalInput | undefined;
-export type TerminalInput = import('./wasi-cli-terminal-input.js').TerminalInput;
+export type TerminalInput =
+ import('./wasi-cli-terminal-input.js').TerminalInput;
diff --git a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdout.d.ts b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdout.d.ts
index 895c9193a..c5eab4238 100644
--- a/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdout.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-cli-terminal-stdout.d.ts
@@ -4,4 +4,5 @@
* allowing further interaction with it.
*/
export function getTerminalStdout(): TerminalOutput | undefined;
-export type TerminalOutput = import('./wasi-cli-terminal-output.js').TerminalOutput;
+export type TerminalOutput =
+ import('./wasi-cli-terminal-output.js').TerminalOutput;
diff --git a/packages/preview3-shim/types/interfaces/wasi-clocks-monotonic-clock.d.ts b/packages/preview3-shim/types/interfaces/wasi-clocks-monotonic-clock.d.ts
index 1c1d479d6..0c6dd6a0e 100644
--- a/packages/preview3-shim/types/interfaces/wasi-clocks-monotonic-clock.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-clocks-monotonic-clock.d.ts
@@ -1,7 +1,7 @@
/** @module Interface wasi:clocks/monotonic-clock@0.3.0 **/
/**
* Read the current value of the clock.
- *
+ *
* The clock is monotonic, therefore calling this function repeatedly will
* produce a sequence of non-decreasing values.
*/
diff --git a/packages/preview3-shim/types/interfaces/wasi-clocks-wall-clock.d.ts b/packages/preview3-shim/types/interfaces/wasi-clocks-wall-clock.d.ts
index efd21513b..5b49cb982 100644
--- a/packages/preview3-shim/types/interfaces/wasi-clocks-wall-clock.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-clocks-wall-clock.d.ts
@@ -1,23 +1,23 @@
/** @module Interface wasi:clocks/wall-clock@0.3.0 **/
/**
* Read the current value of the clock.
- *
+ *
* This clock is not monotonic, therefore calling this function repeatedly
* will not necessarily produce a sequence of non-decreasing values.
- *
+ *
* The returned timestamps represent the number of seconds since
* 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
* also known as [Unix Time].
- *
+ *
* The nanoseconds field of the output is always less than 1000000000.
- *
+ *
* [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
* [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
*/
export function now(): Datetime;
/**
* Query the resolution of the clock.
- *
+ *
* The nanoseconds field of the output is always less than 1000000000.
*/
export function resolution(): Datetime;
@@ -25,6 +25,6 @@ export function resolution(): Datetime;
* A time and date in seconds plus nanoseconds.
*/
export interface Datetime {
- seconds: bigint,
- nanoseconds: number,
+ seconds: bigint;
+ nanoseconds: number;
}
diff --git a/packages/preview3-shim/types/interfaces/wasi-filesystem-types.d.ts b/packages/preview3-shim/types/interfaces/wasi-filesystem-types.d.ts
index 0ac1f5d81..9dac4f552 100644
--- a/packages/preview3-shim/types/interfaces/wasi-filesystem-types.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-filesystem-types.d.ts
@@ -6,123 +6,131 @@ export type Datetime = import('./wasi-clocks-wall-clock.js').Datetime;
export type Filesize = bigint;
/**
* The type of a filesystem object referenced by a descriptor.
- *
+ *
* Note: This was called `filetype` in earlier versions of WASI.
* # Variants
- *
+ *
* ## `"unknown"`
- *
+ *
* The type of the descriptor or file is unknown or is different from
* any of the other types specified.
* ## `"block-device"`
- *
+ *
* The descriptor refers to a block device inode.
* ## `"character-device"`
- *
+ *
* The descriptor refers to a character device inode.
* ## `"directory"`
- *
+ *
* The descriptor refers to a directory inode.
* ## `"fifo"`
- *
+ *
* The descriptor refers to a named pipe.
* ## `"symbolic-link"`
- *
+ *
* The file refers to a symbolic link inode.
* ## `"regular-file"`
- *
+ *
* The descriptor refers to a regular file inode.
* ## `"socket"`
- *
+ *
* The descriptor refers to a socket.
*/
-export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
+export type DescriptorType =
+ | 'unknown'
+ | 'block-device'
+ | 'character-device'
+ | 'directory'
+ | 'fifo'
+ | 'symbolic-link'
+ | 'regular-file'
+ | 'socket';
/**
* Descriptor flags.
- *
+ *
* Note: This was called `fdflags` in earlier versions of WASI.
*/
export interface DescriptorFlags {
- /**
- * Read mode: Data can be read.
- */
- read?: boolean,
- /**
- * Write mode: Data can be written to.
- */
- write?: boolean,
- /**
- * Request that writes be performed according to synchronized I/O file
- * integrity completion. The data stored in the file and the file's
- * metadata are synchronized. This is similar to `O_SYNC` in POSIX.
- *
- * The precise semantics of this operation have not yet been defined for
- * WASI. At this time, it should be interpreted as a request, and not a
- * requirement.
- */
- fileIntegritySync?: boolean,
- /**
- * Request that writes be performed according to synchronized I/O data
- * integrity completion. Only the data stored in the file is
- * synchronized. This is similar to `O_DSYNC` in POSIX.
- *
- * The precise semantics of this operation have not yet been defined for
- * WASI. At this time, it should be interpreted as a request, and not a
- * requirement.
- */
- dataIntegritySync?: boolean,
- /**
- * Requests that reads be performed at the same level of integrity
- * requested for writes. This is similar to `O_RSYNC` in POSIX.
- *
- * The precise semantics of this operation have not yet been defined for
- * WASI. At this time, it should be interpreted as a request, and not a
- * requirement.
- */
- requestedWriteSync?: boolean,
- /**
- * Mutating directories mode: Directory contents may be mutated.
- *
- * When this flag is unset on a descriptor, operations using the
- * descriptor which would create, rename, delete, modify the data or
- * metadata of filesystem objects, or obtain another handle which
- * would permit any of those, shall fail with `error-code::read-only` if
- * they would otherwise succeed.
- *
- * This may only be set on directories.
- */
- mutateDirectory?: boolean,
+ /**
+ * Read mode: Data can be read.
+ */
+ read?: boolean;
+ /**
+ * Write mode: Data can be written to.
+ */
+ write?: boolean;
+ /**
+ * Request that writes be performed according to synchronized I/O file
+ * integrity completion. The data stored in the file and the file's
+ * metadata are synchronized. This is similar to `O_SYNC` in POSIX.
+ *
+ * The precise semantics of this operation have not yet been defined for
+ * WASI. At this time, it should be interpreted as a request, and not a
+ * requirement.
+ */
+ fileIntegritySync?: boolean;
+ /**
+ * Request that writes be performed according to synchronized I/O data
+ * integrity completion. Only the data stored in the file is
+ * synchronized. This is similar to `O_DSYNC` in POSIX.
+ *
+ * The precise semantics of this operation have not yet been defined for
+ * WASI. At this time, it should be interpreted as a request, and not a
+ * requirement.
+ */
+ dataIntegritySync?: boolean;
+ /**
+ * Requests that reads be performed at the same level of integrity
+ * requested for writes. This is similar to `O_RSYNC` in POSIX.
+ *
+ * The precise semantics of this operation have not yet been defined for
+ * WASI. At this time, it should be interpreted as a request, and not a
+ * requirement.
+ */
+ requestedWriteSync?: boolean;
+ /**
+ * Mutating directories mode: Directory contents may be mutated.
+ *
+ * When this flag is unset on a descriptor, operations using the
+ * descriptor which would create, rename, delete, modify the data or
+ * metadata of filesystem objects, or obtain another handle which
+ * would permit any of those, shall fail with `error-code::read-only` if
+ * they would otherwise succeed.
+ *
+ * This may only be set on directories.
+ */
+ mutateDirectory?: boolean;
}
/**
* Flags determining the method of how paths are resolved.
*/
export interface PathFlags {
- /**
- * As long as the resolved path corresponds to a symbolic link, it is
- * expanded.
- */
- symlinkFollow?: boolean,
+ /**
+ * As long as the resolved path corresponds to a symbolic link, it is
+ * expanded.
+ */
+ symlinkFollow?: boolean;
}
/**
* Open flags used by `open-at`.
*/
export interface OpenFlags {
- /**
- * Create file if it does not exist, similar to `O_CREAT` in POSIX.
- */
- create?: boolean,
- /**
- * Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
- */
- directory?: boolean,
- /**
- * Fail if file already exists, similar to `O_EXCL` in POSIX.
- */
- exclusive?: boolean,
- /**
- * Truncate file to size 0, similar to `O_TRUNC` in POSIX.
- */
- truncate?: boolean,
+ /**
+ * Create file if it does not exist, similar to `O_CREAT` in POSIX.
+ */
+ create?: boolean;
+ /**
+ * Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
+ */
+ directory?: boolean;
+ /**
+ * Fail if file already exists, similar to `O_EXCL` in POSIX.
+ */
+ exclusive?: boolean;
+ /**
+ * Truncate file to size 0, similar to `O_TRUNC` in POSIX.
+ */
+ truncate?: boolean;
}
/**
* Number of hard links to an inode.
@@ -130,81 +138,84 @@ export interface OpenFlags {
export type LinkCount = bigint;
/**
* File attributes.
- *
+ *
* Note: This was called `filestat` in earlier versions of WASI.
*/
export interface DescriptorStat {
- /**
- * File type.
- */
- type: DescriptorType,
- /**
- * Number of hard links to the file.
- */
- linkCount: LinkCount,
- /**
- * For regular files, the file size in bytes. For symbolic links, the
- * length in bytes of the pathname contained in the symbolic link.
- */
- size: Filesize,
- /**
- * Last data access timestamp.
- *
- * If the `option` is none, the platform doesn't maintain an access
- * timestamp for this file.
- */
- dataAccessTimestamp?: Datetime,
- /**
- * Last data modification timestamp.
- *
- * If the `option` is none, the platform doesn't maintain a
- * modification timestamp for this file.
- */
- dataModificationTimestamp?: Datetime,
- /**
- * Last file status-change timestamp.
- *
- * If the `option` is none, the platform doesn't maintain a
- * status-change timestamp for this file.
- */
- statusChangeTimestamp?: Datetime,
+ /**
+ * File type.
+ */
+ type: DescriptorType;
+ /**
+ * Number of hard links to the file.
+ */
+ linkCount: LinkCount;
+ /**
+ * For regular files, the file size in bytes. For symbolic links, the
+ * length in bytes of the pathname contained in the symbolic link.
+ */
+ size: Filesize;
+ /**
+ * Last data access timestamp.
+ *
+ * If the `option` is none, the platform doesn't maintain an access
+ * timestamp for this file.
+ */
+ dataAccessTimestamp?: Datetime;
+ /**
+ * Last data modification timestamp.
+ *
+ * If the `option` is none, the platform doesn't maintain a
+ * modification timestamp for this file.
+ */
+ dataModificationTimestamp?: Datetime;
+ /**
+ * Last file status-change timestamp.
+ *
+ * If the `option` is none, the platform doesn't maintain a
+ * status-change timestamp for this file.
+ */
+ statusChangeTimestamp?: Datetime;
}
/**
* When setting a timestamp, this gives the value to set it to.
*/
-export type NewTimestamp = NewTimestampNoChange | NewTimestampNow | NewTimestampTimestamp;
+export type NewTimestamp =
+ | NewTimestampNoChange
+ | NewTimestampNow
+ | NewTimestampTimestamp;
/**
* Leave the timestamp set to its previous value.
*/
export interface NewTimestampNoChange {
- tag: 'no-change',
+ tag: 'no-change';
}
/**
* Set the timestamp to the current time of the system clock associated
* with the filesystem.
*/
export interface NewTimestampNow {
- tag: 'now',
+ tag: 'now';
}
/**
* Set the timestamp to the given value.
*/
export interface NewTimestampTimestamp {
- tag: 'timestamp',
- val: Datetime,
+ tag: 'timestamp';
+ val: Datetime;
}
/**
* A directory entry.
*/
export interface DirectoryEntry {
- /**
- * The type of the file referred to by this directory entry.
- */
- type: DescriptorType,
- /**
- * The name of the object.
- */
- name: string,
+ /**
+ * The type of the file referred to by this directory entry.
+ */
+ type: DescriptorType;
+ /**
+ * The name of the object.
+ */
+ name: string;
}
/**
* Error codes returned by functions, similar to `errno` in POSIX.
@@ -212,419 +223,493 @@ export interface DirectoryEntry {
* API; some are used in higher-level library layers, and others are provided
* merely for alignment with POSIX.
* # Variants
- *
+ *
* ## `"access"`
- *
+ *
* Permission denied, similar to `EACCES` in POSIX.
* ## `"already"`
- *
+ *
* Connection already in progress, similar to `EALREADY` in POSIX.
* ## `"bad-descriptor"`
- *
+ *
* Bad descriptor, similar to `EBADF` in POSIX.
* ## `"busy"`
- *
+ *
* Device or resource busy, similar to `EBUSY` in POSIX.
* ## `"deadlock"`
- *
+ *
* Resource deadlock would occur, similar to `EDEADLK` in POSIX.
* ## `"quota"`
- *
+ *
* Storage quota exceeded, similar to `EDQUOT` in POSIX.
* ## `"exist"`
- *
+ *
* File exists, similar to `EEXIST` in POSIX.
* ## `"file-too-large"`
- *
+ *
* File too large, similar to `EFBIG` in POSIX.
* ## `"illegal-byte-sequence"`
- *
+ *
* Illegal byte sequence, similar to `EILSEQ` in POSIX.
* ## `"in-progress"`
- *
+ *
* Operation in progress, similar to `EINPROGRESS` in POSIX.
* ## `"interrupted"`
- *
+ *
* Interrupted function, similar to `EINTR` in POSIX.
* ## `"invalid"`
- *
+ *
* Invalid argument, similar to `EINVAL` in POSIX.
* ## `"io"`
- *
+ *
* I/O error, similar to `EIO` in POSIX.
* ## `"is-directory"`
- *
+ *
* Is a directory, similar to `EISDIR` in POSIX.
* ## `"loop"`
- *
+ *
* Too many levels of symbolic links, similar to `ELOOP` in POSIX.
* ## `"too-many-links"`
- *
+ *
* Too many links, similar to `EMLINK` in POSIX.
* ## `"message-size"`
- *
+ *
* Message too large, similar to `EMSGSIZE` in POSIX.
* ## `"name-too-long"`
- *
+ *
* Filename too long, similar to `ENAMETOOLONG` in POSIX.
* ## `"no-device"`
- *
+ *
* No such device, similar to `ENODEV` in POSIX.
* ## `"no-entry"`
- *
+ *
* No such file or directory, similar to `ENOENT` in POSIX.
* ## `"no-lock"`
- *
+ *
* No locks available, similar to `ENOLCK` in POSIX.
* ## `"insufficient-memory"`
- *
+ *
* Not enough space, similar to `ENOMEM` in POSIX.
* ## `"insufficient-space"`
- *
+ *
* No space left on device, similar to `ENOSPC` in POSIX.
* ## `"not-directory"`
- *
+ *
* Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
* ## `"not-empty"`
- *
+ *
* Directory not empty, similar to `ENOTEMPTY` in POSIX.
* ## `"not-recoverable"`
- *
+ *
* State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
* ## `"unsupported"`
- *
+ *
* Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
* ## `"no-tty"`
- *
+ *
* Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
* ## `"no-such-device"`
- *
+ *
* No such device or address, similar to `ENXIO` in POSIX.
* ## `"overflow"`
- *
+ *
* Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
* ## `"not-permitted"`
- *
+ *
* Operation not permitted, similar to `EPERM` in POSIX.
* ## `"pipe"`
- *
+ *
* Broken pipe, similar to `EPIPE` in POSIX.
* ## `"read-only"`
- *
+ *
* Read-only file system, similar to `EROFS` in POSIX.
* ## `"invalid-seek"`
- *
+ *
* Invalid seek, similar to `ESPIPE` in POSIX.
* ## `"text-file-busy"`
- *
+ *
* Text file busy, similar to `ETXTBSY` in POSIX.
* ## `"cross-device"`
- *
+ *
* Cross-device link, similar to `EXDEV` in POSIX.
*/
-export type ErrorCode = 'access' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
+export type ErrorCode =
+ | 'access'
+ | 'already'
+ | 'bad-descriptor'
+ | 'busy'
+ | 'deadlock'
+ | 'quota'
+ | 'exist'
+ | 'file-too-large'
+ | 'illegal-byte-sequence'
+ | 'in-progress'
+ | 'interrupted'
+ | 'invalid'
+ | 'io'
+ | 'is-directory'
+ | 'loop'
+ | 'too-many-links'
+ | 'message-size'
+ | 'name-too-long'
+ | 'no-device'
+ | 'no-entry'
+ | 'no-lock'
+ | 'insufficient-memory'
+ | 'insufficient-space'
+ | 'not-directory'
+ | 'not-empty'
+ | 'not-recoverable'
+ | 'unsupported'
+ | 'no-tty'
+ | 'no-such-device'
+ | 'overflow'
+ | 'not-permitted'
+ | 'pipe'
+ | 'read-only'
+ | 'invalid-seek'
+ | 'text-file-busy'
+ | 'cross-device';
/**
* File or memory access pattern advisory information.
* # Variants
- *
+ *
* ## `"normal"`
- *
+ *
* The application has no advice to give on its behavior with respect
* to the specified data.
* ## `"sequential"`
- *
+ *
* The application expects to access the specified data sequentially
* from lower offsets to higher offsets.
* ## `"random"`
- *
+ *
* The application expects to access the specified data in a random
* order.
* ## `"will-need"`
- *
+ *
* The application expects to access the specified data in the near
* future.
* ## `"dont-need"`
- *
+ *
* The application expects that it will not access the specified data
* in the near future.
* ## `"no-reuse"`
- *
+ *
* The application expects to access the specified data once and then
* not reuse it thereafter.
*/
-export type Advice = 'normal' | 'sequential' | 'random' | 'will-need' | 'dont-need' | 'no-reuse';
+export type Advice =
+ | 'normal'
+ | 'sequential'
+ | 'random'
+ | 'will-need'
+ | 'dont-need'
+ | 'no-reuse';
/**
* A 128-bit hash value, split into parts because wasm doesn't have a
* 128-bit integer type.
*/
export interface MetadataHashValue {
- /**
- * 64 bits of a 128-bit hash value.
- */
- lower: bigint,
- /**
- * Another 64 bits of a 128-bit hash value.
- */
- upper: bigint,
+ /**
+ * 64 bits of a 128-bit hash value.
+ */
+ lower: bigint;
+ /**
+ * Another 64 bits of a 128-bit hash value.
+ */
+ upper: bigint;
}
-export type Result = { tag: 'ok', val: T } | { tag: 'err', val: E };
+export type Result = { tag: 'ok'; val: T } | { tag: 'err'; val: E };
export class Descriptor {
- /**
- * This type does not have a public constructor.
- */
- private constructor();
- /**
- * Return a stream for reading from a file.
- *
- * Multiple read, write, and append streams may be active on the same open
- * file and they do not interfere with each other.
- *
- * This function returns a future, which will resolve to an error code if
- * reading full contents of the file fails.
- *
- * Note: This is similar to `pread` in POSIX.
- */
- readViaStream(offset: Filesize): [ReadableStream, Promise>];
- /**
- * Return a stream for writing to a file, if available.
- *
- * May fail with an error-code describing why the file cannot be written.
- *
- * It is valid to write past the end of a file; the file is extended to the
- * extent of the write, with bytes between the previous end and the start of
- * the write set to zero.
- *
- * This function returns once either full contents of the stream are
- * written or an error is encountered.
- *
- * Note: This is similar to `pwrite` in POSIX.
- */
- writeViaStream(data: ReadableStream, offset: Filesize): Promise;
- /**
- * Return a stream for appending to a file, if available.
- *
- * May fail with an error-code describing why the file cannot be appended.
- *
- * This function returns once either full contents of the stream are
- * written or an error is encountered.
- *
- * Note: This is similar to `write` with `O_APPEND` in POSIX.
- */
- appendViaStream(data: ReadableStream): Promise;
- /**
- * Provide file advisory information on a descriptor.
- *
- * This is similar to `posix_fadvise` in POSIX.
- */
- advise(offset: Filesize, length: Filesize, advice: Advice): Promise;
- /**
- * Synchronize the data of a file to disk.
- *
- * This function succeeds with no effect if the file descriptor is not
- * opened for writing.
- *
- * Note: This is similar to `fdatasync` in POSIX.
- */
- syncData(): Promise;
- /**
- * Get flags associated with a descriptor.
- *
- * Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
- *
- * Note: This returns the value that was the `fs_flags` value returned
- * from `fdstat_get` in earlier versions of WASI.
- */
- getFlags(): Promise;
- /**
- * Get the dynamic type of a descriptor.
- *
- * Note: This returns the same value as the `type` field of the `fd-stat`
- * returned by `stat`, `stat-at` and similar.
- *
- * Note: This returns similar flags to the `st_mode & S_IFMT` value provided
- * by `fstat` in POSIX.
- *
- * Note: This returns the value that was the `fs_filetype` value returned
- * from `fdstat_get` in earlier versions of WASI.
- */
- getType(): Promise;
- /**
- * Adjust the size of an open file. If this increases the file's size, the
- * extra bytes are filled with zeros.
- *
- * Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
- */
- setSize(size: Filesize): Promise;
- /**
- * Adjust the timestamps of an open file or directory.
- *
- * Note: This is similar to `futimens` in POSIX.
- *
- * Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
- */
- setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): Promise;
- /**
- * Read directory entries from a directory.
- *
- * On filesystems where directories contain entries referring to themselves
- * and their parents, often named `.` and `..` respectively, these entries
- * are omitted.
- *
- * This always returns a new stream which starts at the beginning of the
- * directory. Multiple streams may be active on the same directory, and they
- * do not interfere with each other.
- *
- * This function returns a future, which will resolve to an error code if
- * reading full contents of the directory fails.
- */
- readDirectory(): Promise<[ReadableStream, Promise>]>;
- /**
- * Synchronize the data and metadata of a file to disk.
- *
- * This function succeeds with no effect if the file descriptor is not
- * opened for writing.
- *
- * Note: This is similar to `fsync` in POSIX.
- */
- sync(): Promise;
- /**
- * Create a directory.
- *
- * Note: This is similar to `mkdirat` in POSIX.
- */
- createDirectoryAt(path: string): Promise;
- /**
- * Return the attributes of an open file or directory.
- *
- * Note: This is similar to `fstat` in POSIX, except that it does not return
- * device and inode information. For testing whether two descriptors refer to
- * the same underlying filesystem object, use `is-same-object`. To obtain
- * additional data that can be used do determine whether a file has been
- * modified, use `metadata-hash`.
- *
- * Note: This was called `fd_filestat_get` in earlier versions of WASI.
- */
- stat(): Promise;
- /**
- * Return the attributes of a file or directory.
- *
- * Note: This is similar to `fstatat` in POSIX, except that it does not
- * return device and inode information. See the `stat` description for a
- * discussion of alternatives.
- *
- * Note: This was called `path_filestat_get` in earlier versions of WASI.
- */
- statAt(pathFlags: PathFlags, path: string): Promise;
- /**
- * Adjust the timestamps of a file or directory.
- *
- * Note: This is similar to `utimensat` in POSIX.
- *
- * Note: This was called `path_filestat_set_times` in earlier versions of
- * WASI.
- */
- setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): Promise;
- /**
- * Create a hard link.
- *
- * Fails with `error-code::no-entry` if the old path does not exist,
- * with `error-code::exist` if the new path already exists, and
- * `error-code::not-permitted` if the old path is not a file.
- *
- * Note: This is similar to `linkat` in POSIX.
- */
- linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): Promise;
- /**
- * Open a file or directory.
- *
- * If `flags` contains `descriptor-flags::mutate-directory`, and the base
- * descriptor doesn't have `descriptor-flags::mutate-directory` set,
- * `open-at` fails with `error-code::read-only`.
- *
- * If `flags` contains `write` or `mutate-directory`, or `open-flags`
- * contains `truncate` or `create`, and the base descriptor doesn't have
- * `descriptor-flags::mutate-directory` set, `open-at` fails with
- * `error-code::read-only`.
- *
- * Note: This is similar to `openat` in POSIX.
- */
- openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Promise;
- /**
- * Read the contents of a symbolic link.
- *
- * If the contents contain an absolute or rooted path in the underlying
- * filesystem, this function fails with `error-code::not-permitted`.
- *
- * Note: This is similar to `readlinkat` in POSIX.
- */
- readlinkAt(path: string): Promise;
- /**
- * Remove a directory.
- *
- * Return `error-code::not-empty` if the directory is not empty.
- *
- * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
- */
- removeDirectoryAt(path: string): Promise;
- /**
- * Rename a filesystem object.
- *
- * Note: This is similar to `renameat` in POSIX.
- */
- renameAt(oldPath: string, newDescriptor: Descriptor, newPath: string): Promise;
- /**
- * Create a symbolic link (also known as a "symlink").
- *
- * If `old-path` starts with `/`, the function fails with
- * `error-code::not-permitted`.
- *
- * Note: This is similar to `symlinkat` in POSIX.
- */
- symlinkAt(oldPath: string, newPath: string): Promise;
- /**
- * Unlink a filesystem object that is not a directory.
- *
- * Return `error-code::is-directory` if the path refers to a directory.
- * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
- */
- unlinkFileAt(path: string): Promise;
- /**
- * Test whether two descriptors refer to the same filesystem object.
- *
- * In POSIX, this corresponds to testing whether the two descriptors have the
- * same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
- * wasi-filesystem does not expose device and inode numbers, so this function
- * may be used instead.
- */
- isSameObject(other: Descriptor): Promise;
- /**
- * Return a hash of the metadata associated with a filesystem object referred
- * to by a descriptor.
- *
- * This returns a hash of the last-modification timestamp and file size, and
- * may also include the inode number, device number, birth timestamp, and
- * other metadata fields that may change when the file is modified or
- * replaced. It may also include a secret value chosen by the
- * implementation and not otherwise exposed.
- *
- * Implementations are encouraged to provide the following properties:
- *
- * - If the file is not modified or replaced, the computed hash value should
- * usually not change.
- * - If the object is modified or replaced, the computed hash value should
- * usually change.
- * - The inputs to the hash should not be easily computable from the
- * computed hash.
- *
- * However, none of these is required.
- */
- metadataHash(): Promise;
- /**
- * Return a hash of the metadata associated with a filesystem object referred
- * to by a directory descriptor and a relative path.
- *
- * This performs the same hash computation as `metadata-hash`.
- */
- metadataHashAt(pathFlags: PathFlags, path: string): Promise;
+ /**
+ * This type does not have a public constructor.
+ */
+ private constructor();
+ /**
+ * Return a stream for reading from a file.
+ *
+ * Multiple read, write, and append streams may be active on the same open
+ * file and they do not interfere with each other.
+ *
+ * This function returns a future, which will resolve to an error code if
+ * reading full contents of the file fails.
+ *
+ * Note: This is similar to `pread` in POSIX.
+ */
+ readViaStream(
+ offset: Filesize
+ ): [ReadableStream, Promise>];
+ /**
+ * Return a stream for writing to a file, if available.
+ *
+ * May fail with an error-code describing why the file cannot be written.
+ *
+ * It is valid to write past the end of a file; the file is extended to the
+ * extent of the write, with bytes between the previous end and the start of
+ * the write set to zero.
+ *
+ * This function returns once either full contents of the stream are
+ * written or an error is encountered.
+ *
+ * Note: This is similar to `pwrite` in POSIX.
+ */
+ writeViaStream(
+ data: ReadableStream,
+ offset: Filesize
+ ): Promise;
+ /**
+ * Return a stream for appending to a file, if available.
+ *
+ * May fail with an error-code describing why the file cannot be appended.
+ *
+ * This function returns once either full contents of the stream are
+ * written or an error is encountered.
+ *
+ * Note: This is similar to `write` with `O_APPEND` in POSIX.
+ */
+ appendViaStream(data: ReadableStream): Promise;
+ /**
+ * Provide file advisory information on a descriptor.
+ *
+ * This is similar to `posix_fadvise` in POSIX.
+ */
+ advise(offset: Filesize, length: Filesize, advice: Advice): Promise;
+ /**
+ * Synchronize the data of a file to disk.
+ *
+ * This function succeeds with no effect if the file descriptor is not
+ * opened for writing.
+ *
+ * Note: This is similar to `fdatasync` in POSIX.
+ */
+ syncData(): Promise;
+ /**
+ * Get flags associated with a descriptor.
+ *
+ * Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
+ *
+ * Note: This returns the value that was the `fs_flags` value returned
+ * from `fdstat_get` in earlier versions of WASI.
+ */
+ getFlags(): Promise;
+ /**
+ * Get the dynamic type of a descriptor.
+ *
+ * Note: This returns the same value as the `type` field of the `fd-stat`
+ * returned by `stat`, `stat-at` and similar.
+ *
+ * Note: This returns similar flags to the `st_mode & S_IFMT` value provided
+ * by `fstat` in POSIX.
+ *
+ * Note: This returns the value that was the `fs_filetype` value returned
+ * from `fdstat_get` in earlier versions of WASI.
+ */
+ getType(): Promise;
+ /**
+ * Adjust the size of an open file. If this increases the file's size, the
+ * extra bytes are filled with zeros.
+ *
+ * Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
+ */
+ setSize(size: Filesize): Promise;
+ /**
+ * Adjust the timestamps of an open file or directory.
+ *
+ * Note: This is similar to `futimens` in POSIX.
+ *
+ * Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
+ */
+ setTimes(
+ dataAccessTimestamp: NewTimestamp,
+ dataModificationTimestamp: NewTimestamp
+ ): Promise;
+ /**
+ * Read directory entries from a directory.
+ *
+ * On filesystems where directories contain entries referring to themselves
+ * and their parents, often named `.` and `..` respectively, these entries
+ * are omitted.
+ *
+ * This always returns a new stream which starts at the beginning of the
+ * directory. Multiple streams may be active on the same directory, and they
+ * do not interfere with each other.
+ *
+ * This function returns a future, which will resolve to an error code if
+ * reading full contents of the directory fails.
+ */
+ readDirectory(): Promise<
+ [ReadableStream, Promise>]
+ >;
+ /**
+ * Synchronize the data and metadata of a file to disk.
+ *
+ * This function succeeds with no effect if the file descriptor is not
+ * opened for writing.
+ *
+ * Note: This is similar to `fsync` in POSIX.
+ */
+ sync(): Promise;
+ /**
+ * Create a directory.
+ *
+ * Note: This is similar to `mkdirat` in POSIX.
+ */
+ createDirectoryAt(path: string): Promise;
+ /**
+ * Return the attributes of an open file or directory.
+ *
+ * Note: This is similar to `fstat` in POSIX, except that it does not return
+ * device and inode information. For testing whether two descriptors refer to
+ * the same underlying filesystem object, use `is-same-object`. To obtain
+ * additional data that can be used do determine whether a file has been
+ * modified, use `metadata-hash`.
+ *
+ * Note: This was called `fd_filestat_get` in earlier versions of WASI.
+ */
+ stat(): Promise;
+ /**
+ * Return the attributes of a file or directory.
+ *
+ * Note: This is similar to `fstatat` in POSIX, except that it does not
+ * return device and inode information. See the `stat` description for a
+ * discussion of alternatives.
+ *
+ * Note: This was called `path_filestat_get` in earlier versions of WASI.
+ */
+ statAt(pathFlags: PathFlags, path: string): Promise;
+ /**
+ * Adjust the timestamps of a file or directory.
+ *
+ * Note: This is similar to `utimensat` in POSIX.
+ *
+ * Note: This was called `path_filestat_set_times` in earlier versions of
+ * WASI.
+ */
+ setTimesAt(
+ pathFlags: PathFlags,
+ path: string,
+ dataAccessTimestamp: NewTimestamp,
+ dataModificationTimestamp: NewTimestamp
+ ): Promise;
+ /**
+ * Create a hard link.
+ *
+ * Fails with `error-code::no-entry` if the old path does not exist,
+ * with `error-code::exist` if the new path already exists, and
+ * `error-code::not-permitted` if the old path is not a file.
+ *
+ * Note: This is similar to `linkat` in POSIX.
+ */
+ linkAt(
+ oldPathFlags: PathFlags,
+ oldPath: string,
+ newDescriptor: Descriptor,
+ newPath: string
+ ): Promise;
+ /**
+ * Open a file or directory.
+ *
+ * If `flags` contains `descriptor-flags::mutate-directory`, and the base
+ * descriptor doesn't have `descriptor-flags::mutate-directory` set,
+ * `open-at` fails with `error-code::read-only`.
+ *
+ * If `flags` contains `write` or `mutate-directory`, or `open-flags`
+ * contains `truncate` or `create`, and the base descriptor doesn't have
+ * `descriptor-flags::mutate-directory` set, `open-at` fails with
+ * `error-code::read-only`.
+ *
+ * Note: This is similar to `openat` in POSIX.
+ */
+ openAt(
+ pathFlags: PathFlags,
+ path: string,
+ openFlags: OpenFlags,
+ flags: DescriptorFlags
+ ): Promise;
+ /**
+ * Read the contents of a symbolic link.
+ *
+ * If the contents contain an absolute or rooted path in the underlying
+ * filesystem, this function fails with `error-code::not-permitted`.
+ *
+ * Note: This is similar to `readlinkat` in POSIX.
+ */
+ readlinkAt(path: string): Promise;
+ /**
+ * Remove a directory.
+ *
+ * Return `error-code::not-empty` if the directory is not empty.
+ *
+ * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
+ */
+ removeDirectoryAt(path: string): Promise;
+ /**
+ * Rename a filesystem object.
+ *
+ * Note: This is similar to `renameat` in POSIX.
+ */
+ renameAt(
+ oldPath: string,
+ newDescriptor: Descriptor,
+ newPath: string
+ ): Promise;
+ /**
+ * Create a symbolic link (also known as a "symlink").
+ *
+ * If `old-path` starts with `/`, the function fails with
+ * `error-code::not-permitted`.
+ *
+ * Note: This is similar to `symlinkat` in POSIX.
+ */
+ symlinkAt(oldPath: string, newPath: string): Promise;
+ /**
+ * Unlink a filesystem object that is not a directory.
+ *
+ * Return `error-code::is-directory` if the path refers to a directory.
+ * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
+ */
+ unlinkFileAt(path: string): Promise;
+ /**
+ * Test whether two descriptors refer to the same filesystem object.
+ *
+ * In POSIX, this corresponds to testing whether the two descriptors have the
+ * same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
+ * wasi-filesystem does not expose device and inode numbers, so this function
+ * may be used instead.
+ */
+ isSameObject(other: Descriptor): Promise;
+ /**
+ * Return a hash of the metadata associated with a filesystem object referred
+ * to by a descriptor.
+ *
+ * This returns a hash of the last-modification timestamp and file size, and
+ * may also include the inode number, device number, birth timestamp, and
+ * other metadata fields that may change when the file is modified or
+ * replaced. It may also include a secret value chosen by the
+ * implementation and not otherwise exposed.
+ *
+ * Implementations are encouraged to provide the following properties:
+ *
+ * - If the file is not modified or replaced, the computed hash value should
+ * usually not change.
+ * - If the object is modified or replaced, the computed hash value should
+ * usually change.
+ * - The inputs to the hash should not be easily computable from the
+ * computed hash.
+ *
+ * However, none of these is required.
+ */
+ metadataHash(): Promise;
+ /**
+ * Return a hash of the metadata associated with a filesystem object referred
+ * to by a directory descriptor and a relative path.
+ *
+ * This performs the same hash computation as `metadata-hash`.
+ */
+ metadataHashAt(
+ pathFlags: PathFlags,
+ path: string
+ ): Promise;
}
diff --git a/packages/preview3-shim/types/interfaces/wasi-http-handler.d.ts b/packages/preview3-shim/types/interfaces/wasi-http-handler.d.ts
index c2b87ad72..d8654794e 100644
--- a/packages/preview3-shim/types/interfaces/wasi-http-handler.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-http-handler.d.ts
@@ -3,7 +3,7 @@
* When exported, this function may be called with either an incoming
* request read from the network or a request synthesized or forwarded by
* another component.
- *
+ *
* When imported, this function may be used to either send an outgoing
* request over the network or pass it to another component.
*/
diff --git a/packages/preview3-shim/types/interfaces/wasi-http-types.d.ts b/packages/preview3-shim/types/interfaces/wasi-http-types.d.ts
index 22782d5e7..3139544a6 100644
--- a/packages/preview3-shim/types/interfaces/wasi-http-types.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-http-types.d.ts
@@ -3,205 +3,254 @@ export type Duration = import('./wasi-clocks-monotonic-clock.js').Duration;
/**
* This type corresponds to HTTP standard Methods.
*/
-export type Method = MethodGet | MethodHead | MethodPost | MethodPut | MethodDelete | MethodConnect | MethodOptions | MethodTrace | MethodPatch | MethodOther;
+export type Method =
+ | MethodGet
+ | MethodHead
+ | MethodPost
+ | MethodPut
+ | MethodDelete
+ | MethodConnect
+ | MethodOptions
+ | MethodTrace
+ | MethodPatch
+ | MethodOther;
export interface MethodGet {
- tag: 'get',
+ tag: 'get';
}
export interface MethodHead {
- tag: 'head',
+ tag: 'head';
}
export interface MethodPost {
- tag: 'post',
+ tag: 'post';
}
export interface MethodPut {
- tag: 'put',
+ tag: 'put';
}
export interface MethodDelete {
- tag: 'delete',
+ tag: 'delete';
}
export interface MethodConnect {
- tag: 'connect',
+ tag: 'connect';
}
export interface MethodOptions {
- tag: 'options',
+ tag: 'options';
}
export interface MethodTrace {
- tag: 'trace',
+ tag: 'trace';
}
export interface MethodPatch {
- tag: 'patch',
+ tag: 'patch';
}
export interface MethodOther {
- tag: 'other',
- val: string,
+ tag: 'other';
+ val: string;
}
/**
* This type corresponds to HTTP standard Related Schemes.
*/
export type Scheme = SchemeHttp | SchemeHttps | SchemeOther;
export interface SchemeHttp {
- tag: 'HTTP',
+ tag: 'HTTP';
}
export interface SchemeHttps {
- tag: 'HTTPS',
+ tag: 'HTTPS';
}
export interface SchemeOther {
- tag: 'other',
- val: string,
+ tag: 'other';
+ val: string;
}
/**
* Defines the case payload type for `DNS-error` above:
*/
export interface DnsErrorPayload {
- rcode?: string,
- infoCode?: number,
+ rcode?: string;
+ infoCode?: number;
}
/**
* Defines the case payload type for `TLS-alert-received` above:
*/
export interface TlsAlertReceivedPayload {
- alertId?: number,
- alertMessage?: string,
+ alertId?: number;
+ alertMessage?: string;
}
/**
* Defines the case payload type for `HTTP-response-{header,trailer}-size` above:
*/
export interface FieldSizePayload {
- fieldName?: string,
- fieldSize?: number,
+ fieldName?: string;
+ fieldSize?: number;
}
/**
* These cases are inspired by the IANA HTTP Proxy Error Types:
*
*/
-export type ErrorCode = ErrorCodeDnsTimeout | ErrorCodeDnsError | ErrorCodeDestinationNotFound | ErrorCodeDestinationUnavailable | ErrorCodeDestinationIpProhibited | ErrorCodeDestinationIpUnroutable | ErrorCodeConnectionRefused | ErrorCodeConnectionTerminated | ErrorCodeConnectionTimeout | ErrorCodeConnectionReadTimeout | ErrorCodeConnectionWriteTimeout | ErrorCodeConnectionLimitReached | ErrorCodeTlsProtocolError | ErrorCodeTlsCertificateError | ErrorCodeTlsAlertReceived | ErrorCodeHttpRequestDenied | ErrorCodeHttpRequestLengthRequired | ErrorCodeHttpRequestBodySize | ErrorCodeHttpRequestMethodInvalid | ErrorCodeHttpRequestUriInvalid | ErrorCodeHttpRequestUriTooLong | ErrorCodeHttpRequestHeaderSectionSize | ErrorCodeHttpRequestHeaderSize | ErrorCodeHttpRequestTrailerSectionSize | ErrorCodeHttpRequestTrailerSize | ErrorCodeHttpResponseIncomplete | ErrorCodeHttpResponseHeaderSectionSize | ErrorCodeHttpResponseHeaderSize | ErrorCodeHttpResponseBodySize | ErrorCodeHttpResponseTrailerSectionSize | ErrorCodeHttpResponseTrailerSize | ErrorCodeHttpResponseTransferCoding | ErrorCodeHttpResponseContentCoding | ErrorCodeHttpResponseTimeout | ErrorCodeHttpUpgradeFailed | ErrorCodeHttpProtocolError | ErrorCodeLoopDetected | ErrorCodeConfigurationError | ErrorCodeInternalError;
+export type ErrorCode =
+ | ErrorCodeDnsTimeout
+ | ErrorCodeDnsError
+ | ErrorCodeDestinationNotFound
+ | ErrorCodeDestinationUnavailable
+ | ErrorCodeDestinationIpProhibited
+ | ErrorCodeDestinationIpUnroutable
+ | ErrorCodeConnectionRefused
+ | ErrorCodeConnectionTerminated
+ | ErrorCodeConnectionTimeout
+ | ErrorCodeConnectionReadTimeout
+ | ErrorCodeConnectionWriteTimeout
+ | ErrorCodeConnectionLimitReached
+ | ErrorCodeTlsProtocolError
+ | ErrorCodeTlsCertificateError
+ | ErrorCodeTlsAlertReceived
+ | ErrorCodeHttpRequestDenied
+ | ErrorCodeHttpRequestLengthRequired
+ | ErrorCodeHttpRequestBodySize
+ | ErrorCodeHttpRequestMethodInvalid
+ | ErrorCodeHttpRequestUriInvalid
+ | ErrorCodeHttpRequestUriTooLong
+ | ErrorCodeHttpRequestHeaderSectionSize
+ | ErrorCodeHttpRequestHeaderSize
+ | ErrorCodeHttpRequestTrailerSectionSize
+ | ErrorCodeHttpRequestTrailerSize
+ | ErrorCodeHttpResponseIncomplete
+ | ErrorCodeHttpResponseHeaderSectionSize
+ | ErrorCodeHttpResponseHeaderSize
+ | ErrorCodeHttpResponseBodySize
+ | ErrorCodeHttpResponseTrailerSectionSize
+ | ErrorCodeHttpResponseTrailerSize
+ | ErrorCodeHttpResponseTransferCoding
+ | ErrorCodeHttpResponseContentCoding
+ | ErrorCodeHttpResponseTimeout
+ | ErrorCodeHttpUpgradeFailed
+ | ErrorCodeHttpProtocolError
+ | ErrorCodeLoopDetected
+ | ErrorCodeConfigurationError
+ | ErrorCodeInternalError;
export interface ErrorCodeDnsTimeout {
- tag: 'DNS-timeout',
+ tag: 'DNS-timeout';
}
export interface ErrorCodeDnsError {
- tag: 'DNS-error',
- val: DnsErrorPayload,
+ tag: 'DNS-error';
+ val: DnsErrorPayload;
}
export interface ErrorCodeDestinationNotFound {
- tag: 'destination-not-found',
+ tag: 'destination-not-found';
}
export interface ErrorCodeDestinationUnavailable {
- tag: 'destination-unavailable',
+ tag: 'destination-unavailable';
}
export interface ErrorCodeDestinationIpProhibited {
- tag: 'destination-IP-prohibited',
+ tag: 'destination-IP-prohibited';
}
export interface ErrorCodeDestinationIpUnroutable {
- tag: 'destination-IP-unroutable',
+ tag: 'destination-IP-unroutable';
}
export interface ErrorCodeConnectionRefused {
- tag: 'connection-refused',
+ tag: 'connection-refused';
}
export interface ErrorCodeConnectionTerminated {
- tag: 'connection-terminated',
+ tag: 'connection-terminated';
}
export interface ErrorCodeConnectionTimeout {
- tag: 'connection-timeout',
+ tag: 'connection-timeout';
}
export interface ErrorCodeConnectionReadTimeout {
- tag: 'connection-read-timeout',
+ tag: 'connection-read-timeout';
}
export interface ErrorCodeConnectionWriteTimeout {
- tag: 'connection-write-timeout',
+ tag: 'connection-write-timeout';
}
export interface ErrorCodeConnectionLimitReached {
- tag: 'connection-limit-reached',
+ tag: 'connection-limit-reached';
}
export interface ErrorCodeTlsProtocolError {
- tag: 'TLS-protocol-error',
+ tag: 'TLS-protocol-error';
}
export interface ErrorCodeTlsCertificateError {
- tag: 'TLS-certificate-error',
+ tag: 'TLS-certificate-error';
}
export interface ErrorCodeTlsAlertReceived {
- tag: 'TLS-alert-received',
- val: TlsAlertReceivedPayload,
+ tag: 'TLS-alert-received';
+ val: TlsAlertReceivedPayload;
}
export interface ErrorCodeHttpRequestDenied {
- tag: 'HTTP-request-denied',
+ tag: 'HTTP-request-denied';
}
export interface ErrorCodeHttpRequestLengthRequired {
- tag: 'HTTP-request-length-required',
+ tag: 'HTTP-request-length-required';
}
export interface ErrorCodeHttpRequestBodySize {
- tag: 'HTTP-request-body-size',
- val: bigint | undefined,
+ tag: 'HTTP-request-body-size';
+ val: bigint | undefined;
}
export interface ErrorCodeHttpRequestMethodInvalid {
- tag: 'HTTP-request-method-invalid',
+ tag: 'HTTP-request-method-invalid';
}
export interface ErrorCodeHttpRequestUriInvalid {
- tag: 'HTTP-request-URI-invalid',
+ tag: 'HTTP-request-URI-invalid';
}
export interface ErrorCodeHttpRequestUriTooLong {
- tag: 'HTTP-request-URI-too-long',
+ tag: 'HTTP-request-URI-too-long';
}
export interface ErrorCodeHttpRequestHeaderSectionSize {
- tag: 'HTTP-request-header-section-size',
- val: number | undefined,
+ tag: 'HTTP-request-header-section-size';
+ val: number | undefined;
}
export interface ErrorCodeHttpRequestHeaderSize {
- tag: 'HTTP-request-header-size',
- val: FieldSizePayload | undefined,
+ tag: 'HTTP-request-header-size';
+ val: FieldSizePayload | undefined;
}
export interface ErrorCodeHttpRequestTrailerSectionSize {
- tag: 'HTTP-request-trailer-section-size',
- val: number | undefined,
+ tag: 'HTTP-request-trailer-section-size';
+ val: number | undefined;
}
export interface ErrorCodeHttpRequestTrailerSize {
- tag: 'HTTP-request-trailer-size',
- val: FieldSizePayload,
+ tag: 'HTTP-request-trailer-size';
+ val: FieldSizePayload;
}
export interface ErrorCodeHttpResponseIncomplete {
- tag: 'HTTP-response-incomplete',
+ tag: 'HTTP-response-incomplete';
}
export interface ErrorCodeHttpResponseHeaderSectionSize {
- tag: 'HTTP-response-header-section-size',
- val: number | undefined,
+ tag: 'HTTP-response-header-section-size';
+ val: number | undefined;
}
export interface ErrorCodeHttpResponseHeaderSize {
- tag: 'HTTP-response-header-size',
- val: FieldSizePayload,
+ tag: 'HTTP-response-header-size';
+ val: FieldSizePayload;
}
export interface ErrorCodeHttpResponseBodySize {
- tag: 'HTTP-response-body-size',
- val: bigint | undefined,
+ tag: 'HTTP-response-body-size';
+ val: bigint | undefined;
}
export interface ErrorCodeHttpResponseTrailerSectionSize {
- tag: 'HTTP-response-trailer-section-size',
- val: number | undefined,
+ tag: 'HTTP-response-trailer-section-size';
+ val: number | undefined;
}
export interface ErrorCodeHttpResponseTrailerSize {
- tag: 'HTTP-response-trailer-size',
- val: FieldSizePayload,
+ tag: 'HTTP-response-trailer-size';
+ val: FieldSizePayload;
}
export interface ErrorCodeHttpResponseTransferCoding {
- tag: 'HTTP-response-transfer-coding',
- val: string | undefined,
+ tag: 'HTTP-response-transfer-coding';
+ val: string | undefined;
}
export interface ErrorCodeHttpResponseContentCoding {
- tag: 'HTTP-response-content-coding',
- val: string | undefined,
+ tag: 'HTTP-response-content-coding';
+ val: string | undefined;
}
export interface ErrorCodeHttpResponseTimeout {
- tag: 'HTTP-response-timeout',
+ tag: 'HTTP-response-timeout';
}
export interface ErrorCodeHttpUpgradeFailed {
- tag: 'HTTP-upgrade-failed',
+ tag: 'HTTP-upgrade-failed';
}
export interface ErrorCodeHttpProtocolError {
- tag: 'HTTP-protocol-error',
+ tag: 'HTTP-protocol-error';
}
export interface ErrorCodeLoopDetected {
- tag: 'loop-detected',
+ tag: 'loop-detected';
}
export interface ErrorCodeConfigurationError {
- tag: 'configuration-error',
+ tag: 'configuration-error';
}
/**
* This is a catch-all error for anything that doesn't fit cleanly into a
@@ -211,57 +260,62 @@ export interface ErrorCodeConfigurationError {
* between implementations.
*/
export interface ErrorCodeInternalError {
- tag: 'internal-error',
- val: string | undefined,
+ tag: 'internal-error';
+ val: string | undefined;
}
/**
* This type enumerates the different kinds of errors that may occur when
* setting or appending to a `fields` resource.
*/
-export type HeaderError = HeaderErrorInvalidSyntax | HeaderErrorForbidden | HeaderErrorImmutable;
+export type HeaderError =
+ | HeaderErrorInvalidSyntax
+ | HeaderErrorForbidden
+ | HeaderErrorImmutable;
/**
* This error indicates that a `field-name` or `field-value` was
* syntactically invalid when used with an operation that sets headers in a
* `fields`.
*/
export interface HeaderErrorInvalidSyntax {
- tag: 'invalid-syntax',
+ tag: 'invalid-syntax';
}
/**
* This error indicates that a forbidden `field-name` was used when trying
* to set a header in a `fields`.
*/
export interface HeaderErrorForbidden {
- tag: 'forbidden',
+ tag: 'forbidden';
}
/**
* This error indicates that the operation on the `fields` was not
* permitted because the fields are immutable.
*/
export interface HeaderErrorImmutable {
- tag: 'immutable',
+ tag: 'immutable';
}
/**
* This type enumerates the different kinds of errors that may occur when
* setting fields of a `request-options` resource.
*/
-export type RequestOptionsError = RequestOptionsErrorNotSupported | RequestOptionsErrorImmutable;
+export type RequestOptionsError =
+ | RequestOptionsErrorNotSupported
+ | RequestOptionsErrorImmutable;
/**
* Indicates the specified field is not supported by this implementation.
*/
export interface RequestOptionsErrorNotSupported {
- tag: 'not-supported',
+ tag: 'not-supported';
}
/**
* Indicates that the operation on the `request-options` was not permitted
* because it is immutable.
*/
export interface RequestOptionsErrorImmutable {
- tag: 'immutable',
+ tag: 'immutable';
}
/**
* Field names are always strings.
- *
+ *
* Field names should always be treated as case insensitive by the `fields`
* resource for the purposes of equality checking.
*/
@@ -284,308 +338,323 @@ export type Trailers = Fields;
* This type corresponds to the HTTP standard Status Code.
*/
export type StatusCode = number;
-export type Result = { tag: 'ok', val: T } | { tag: 'err', val: E };
+export type Result = { tag: 'ok'; val: T } | { tag: 'err'; val: E };
export class Fields {
- /**
- * Construct an empty HTTP Fields.
- *
- * The resulting `fields` is mutable.
- */
- constructor()
- /**
- * Construct an HTTP Fields.
- *
- * The resulting `fields` is mutable.
- *
- * The list represents each name-value pair in the Fields. Names
- * which have multiple values are represented by multiple entries in this
- * list with the same name.
- *
- * The tuple is a pair of the field name, represented as a string, and
- * Value, represented as a list of bytes. In a valid Fields, all names
- * and values are valid UTF-8 strings. However, values are not always
- * well-formed, so they are represented as a raw list of bytes.
- *
- * An error result will be returned if any header or value was
- * syntactically invalid, or if a header was forbidden.
- */
- static fromList(entries: Array<[FieldName, FieldValue]>): Fields;
- /**
- * Get all of the values corresponding to a name. If the name is not present
- * in this `fields`, an empty list is returned. However, if the name is
- * present but empty, this is represented by a list with one or more
- * empty field-values present.
- */
- get(name: FieldName): Array;
- /**
- * Returns `true` when the name is present in this `fields`. If the name is
- * syntactically invalid, `false` is returned.
- */
- has(name: FieldName): boolean;
- /**
- * Set all of the values for a name. Clears any existing values for that
- * name, if they have been set.
- *
- * Fails with `header-error.immutable` if the `fields` are immutable.
- */
- set(name: FieldName, value: Array): void;
- /**
- * Delete all values for a name. Does nothing if no values for the name
- * exist.
- *
- * Fails with `header-error.immutable` if the `fields` are immutable.
- */
- 'delete'(name: FieldName): void;
- /**
- * Delete all values for a name. Does nothing if no values for the name
- * exist.
- *
- * Returns all values previously corresponding to the name, if any.
- *
- * Fails with `header-error.immutable` if the `fields` are immutable.
- */
- getAndDelete(name: FieldName): Array;
- /**
- * Append a value for a name. Does not change or delete any existing
- * values for that name.
- *
- * Fails with `header-error.immutable` if the `fields` are immutable.
- */
- append(name: FieldName, value: FieldValue): void;
- /**
- * Retrieve the full set of names and values in the Fields. Like the
- * constructor, the list represents each name-value pair.
- *
- * The outer list represents each name-value pair in the Fields. Names
- * which have multiple values are represented by multiple entries in this
- * list with the same name.
- *
- * The names and values are always returned in the original casing and in
- * the order in which they will be serialized for transport.
- */
- entries(): Array<[FieldName, FieldValue]>;
- /**
- * Make a deep copy of the Fields. Equivalent in behavior to calling the
- * `fields` constructor on the return value of `entries`. The resulting
- * `fields` is mutable.
- */
- clone(): Fields;
+ /**
+ * Construct an empty HTTP Fields.
+ *
+ * The resulting `fields` is mutable.
+ */
+ constructor();
+ /**
+ * Construct an HTTP Fields.
+ *
+ * The resulting `fields` is mutable.
+ *
+ * The list represents each name-value pair in the Fields. Names
+ * which have multiple values are represented by multiple entries in this
+ * list with the same name.
+ *
+ * The tuple is a pair of the field name, represented as a string, and
+ * Value, represented as a list of bytes. In a valid Fields, all names
+ * and values are valid UTF-8 strings. However, values are not always
+ * well-formed, so they are represented as a raw list of bytes.
+ *
+ * An error result will be returned if any header or value was
+ * syntactically invalid, or if a header was forbidden.
+ */
+ static fromList(entries: Array<[FieldName, FieldValue]>): Fields;
+ /**
+ * Get all of the values corresponding to a name. If the name is not present
+ * in this `fields`, an empty list is returned. However, if the name is
+ * present but empty, this is represented by a list with one or more
+ * empty field-values present.
+ */
+ get(name: FieldName): Array;
+ /**
+ * Returns `true` when the name is present in this `fields`. If the name is
+ * syntactically invalid, `false` is returned.
+ */
+ has(name: FieldName): boolean;
+ /**
+ * Set all of the values for a name. Clears any existing values for that
+ * name, if they have been set.
+ *
+ * Fails with `header-error.immutable` if the `fields` are immutable.
+ */
+ set(name: FieldName, value: Array): void;
+ /**
+ * Delete all values for a name. Does nothing if no values for the name
+ * exist.
+ *
+ * Fails with `header-error.immutable` if the `fields` are immutable.
+ */
+ delete(name: FieldName): void;
+ /**
+ * Delete all values for a name. Does nothing if no values for the name
+ * exist.
+ *
+ * Returns all values previously corresponding to the name, if any.
+ *
+ * Fails with `header-error.immutable` if the `fields` are immutable.
+ */
+ getAndDelete(name: FieldName): Array;
+ /**
+ * Append a value for a name. Does not change or delete any existing
+ * values for that name.
+ *
+ * Fails with `header-error.immutable` if the `fields` are immutable.
+ */
+ append(name: FieldName, value: FieldValue): void;
+ /**
+ * Retrieve the full set of names and values in the Fields. Like the
+ * constructor, the list represents each name-value pair.
+ *
+ * The outer list represents each name-value pair in the Fields. Names
+ * which have multiple values are represented by multiple entries in this
+ * list with the same name.
+ *
+ * The names and values are always returned in the original casing and in
+ * the order in which they will be serialized for transport.
+ */
+ entries(): Array<[FieldName, FieldValue]>;
+ /**
+ * Make a deep copy of the Fields. Equivalent in behavior to calling the
+ * `fields` constructor on the return value of `entries`. The resulting
+ * `fields` is mutable.
+ */
+ clone(): Fields;
}
export class Request {
- /**
- * This type does not have a public constructor.
- */
- private constructor();
- /**
- * Construct a new `request` with a default `method` of `GET`, and
- * `none` values for `path-with-query`, `scheme`, and `authority`.
- *
- * `headers` is the HTTP Headers for the Request.
- *
- * `contents` is the optional body content stream.
- * Once it is closed, `trailers` future must resolve to a result.
- * If `trailers` resolves to an error, underlying connection
- * will be closed immediately.
- *
- * `options` is optional `request-options` resource to be used
- * if the request is sent over a network connection.
- *
- * It is possible to construct, or manipulate with the accessor functions
- * below, a `request` with an invalid combination of `scheme`
- * and `authority`, or `headers` which are not permitted to be sent.
- * It is the obligation of the `handler.handle` implementation
- * to reject invalid constructions of `request`.
- *
- * The returned future resolves to result of transmission of this request.
- */
- static 'new'(headers: Headers, contents: ReadableStream | undefined, trailers: Promise>, options: RequestOptions | undefined): [Request, Promise>];
- /**
- * Get the Method for the Request.
- */
- method(): Method;
- /**
- * Set the Method for the Request. Fails if the string present in a
- * `method.other` argument is not a syntactically valid method.
- */
- setMethod(method: Method): void;
- /**
- * Get the combination of the HTTP Path and Query for the Request. When
- * `none`, this represents an empty Path and empty Query.
- */
- pathWithQuery(): string | undefined;
- /**
- * Set the combination of the HTTP Path and Query for the Request. When
- * `none`, this represents an empty Path and empty Query. Fails is the
- * string given is not a syntactically valid path and query uri component.
- */
- setPathWithQuery(pathWithQuery: string | undefined): void;
- /**
- * Get the HTTP Related Scheme for the Request. When `none`, the
- * implementation may choose an appropriate default scheme.
- */
- scheme(): Scheme | undefined;
- /**
- * Set the HTTP Related Scheme for the Request. When `none`, the
- * implementation may choose an appropriate default scheme. Fails if the
- * string given is not a syntactically valid uri scheme.
- */
- setScheme(scheme: Scheme | undefined): void;
- /**
- * Get the authority of the Request's target URI. A value of `none` may be used
- * with Related Schemes which do not require an authority. The HTTP and
- * HTTPS schemes always require an authority.
- */
- authority(): string | undefined;
- /**
- * Set the authority of the Request's target URI. A value of `none` may be used
- * with Related Schemes which do not require an authority. The HTTP and
- * HTTPS schemes always require an authority. Fails if the string given is
- * not a syntactically valid URI authority.
- */
- setAuthority(authority: string | undefined): void;
- /**
- * Get the `request-options` to be associated with this request
- *
- * The returned `request-options` resource is immutable: `set-*` operations
- * will fail if invoked.
- *
- * This `request-options` resource is a child: it must be dropped before
- * the parent `request` is dropped, or its ownership is transferred to
- * another component by e.g. `handler.handle`.
- */
- options(): RequestOptions | undefined;
- /**
- * Get the headers associated with the Request.
- *
- * The returned `headers` resource is immutable: `set`, `append`, and
- * `delete` operations will fail with `header-error.immutable`.
- */
- headers(): Headers;
- /**
- * Get body of the Request.
- *
- * Stream returned by this method represents the contents of the body.
- * Once the stream is reported as closed, callers should await the returned future
- * to determine whether the body was received successfully.
- * The future will only resolve after the stream is reported as closed.
- *
- * The stream and future returned by this method are children:
- * they should be closed or consumed before the parent `response`
- * is dropped, or its ownership is transferred to another component
- * by e.g. `handler.handle`.
- *
- * This method may be called multiple times.
- *
- * This method will return an error if it is called while either:
- * - a stream or future returned by a previous call to this method is still open
- * - a stream returned by a previous call to this method has reported itself as closed
- * Thus there will always be at most one readable stream open for a given body.
- * Each subsequent stream picks up where the last stream left off, up until it is finished.
- */
- body(): [ReadableStream, Promise>];
+ /**
+ * This type does not have a public constructor.
+ */
+ private constructor();
+ /**
+ * Construct a new `request` with a default `method` of `GET`, and
+ * `none` values for `path-with-query`, `scheme`, and `authority`.
+ *
+ * `headers` is the HTTP Headers for the Request.
+ *
+ * `contents` is the optional body content stream.
+ * Once it is closed, `trailers` future must resolve to a result.
+ * If `trailers` resolves to an error, underlying connection
+ * will be closed immediately.
+ *
+ * `options` is optional `request-options` resource to be used
+ * if the request is sent over a network connection.
+ *
+ * It is possible to construct, or manipulate with the accessor functions
+ * below, a `request` with an invalid combination of `scheme`
+ * and `authority`, or `headers` which are not permitted to be sent.
+ * It is the obligation of the `handler.handle` implementation
+ * to reject invalid constructions of `request`.
+ *
+ * The returned future resolves to result of transmission of this request.
+ */
+ static new(
+ headers: Headers,
+ contents: ReadableStream | undefined,
+ trailers: Promise>,
+ options: RequestOptions | undefined
+ ): [Request, Promise>];
+ /**
+ * Get the Method for the Request.
+ */
+ method(): Method;
+ /**
+ * Set the Method for the Request. Fails if the string present in a
+ * `method.other` argument is not a syntactically valid method.
+ */
+ setMethod(method: Method): void;
+ /**
+ * Get the combination of the HTTP Path and Query for the Request. When
+ * `none`, this represents an empty Path and empty Query.
+ */
+ pathWithQuery(): string | undefined;
+ /**
+ * Set the combination of the HTTP Path and Query for the Request. When
+ * `none`, this represents an empty Path and empty Query. Fails is the
+ * string given is not a syntactically valid path and query uri component.
+ */
+ setPathWithQuery(pathWithQuery: string | undefined): void;
+ /**
+ * Get the HTTP Related Scheme for the Request. When `none`, the
+ * implementation may choose an appropriate default scheme.
+ */
+ scheme(): Scheme | undefined;
+ /**
+ * Set the HTTP Related Scheme for the Request. When `none`, the
+ * implementation may choose an appropriate default scheme. Fails if the
+ * string given is not a syntactically valid uri scheme.
+ */
+ setScheme(scheme: Scheme | undefined): void;
+ /**
+ * Get the authority of the Request's target URI. A value of `none` may be used
+ * with Related Schemes which do not require an authority. The HTTP and
+ * HTTPS schemes always require an authority.
+ */
+ authority(): string | undefined;
+ /**
+ * Set the authority of the Request's target URI. A value of `none` may be used
+ * with Related Schemes which do not require an authority. The HTTP and
+ * HTTPS schemes always require an authority. Fails if the string given is
+ * not a syntactically valid URI authority.
+ */
+ setAuthority(authority: string | undefined): void;
+ /**
+ * Get the `request-options` to be associated with this request
+ *
+ * The returned `request-options` resource is immutable: `set-*` operations
+ * will fail if invoked.
+ *
+ * This `request-options` resource is a child: it must be dropped before
+ * the parent `request` is dropped, or its ownership is transferred to
+ * another component by e.g. `handler.handle`.
+ */
+ options(): RequestOptions | undefined;
+ /**
+ * Get the headers associated with the Request.
+ *
+ * The returned `headers` resource is immutable: `set`, `append`, and
+ * `delete` operations will fail with `header-error.immutable`.
+ */
+ headers(): Headers;
+ /**
+ * Get body of the Request.
+ *
+ * Stream returned by this method represents the contents of the body.
+ * Once the stream is reported as closed, callers should await the returned future
+ * to determine whether the body was received successfully.
+ * The future will only resolve after the stream is reported as closed.
+ *
+ * The stream and future returned by this method are children:
+ * they should be closed or consumed before the parent `response`
+ * is dropped, or its ownership is transferred to another component
+ * by e.g. `handler.handle`.
+ *
+ * This method may be called multiple times.
+ *
+ * This method will return an error if it is called while either:
+ * - a stream or future returned by a previous call to this method is still open
+ * - a stream returned by a previous call to this method has reported itself as closed
+ * Thus there will always be at most one readable stream open for a given body.
+ * Each subsequent stream picks up where the last stream left off, up until it is finished.
+ */
+ body(): [
+ ReadableStream,
+ Promise>,
+ ];
}
export class RequestOptions {
- /**
- * Construct a default `request-options` value.
- */
- constructor()
- /**
- * The timeout for the initial connect to the HTTP Server.
- */
- connectTimeout(): Duration | undefined;
- /**
- * Set the timeout for the initial connect to the HTTP Server. An error
- * return value indicates that this timeout is not supported or that this
- * handle is immutable.
- */
- setConnectTimeout(duration: Duration | undefined): void;
- /**
- * The timeout for receiving the first byte of the Response body.
- */
- firstByteTimeout(): Duration | undefined;
- /**
- * Set the timeout for receiving the first byte of the Response body. An
- * error return value indicates that this timeout is not supported or that
- * this handle is immutable.
- */
- setFirstByteTimeout(duration: Duration | undefined): void;
- /**
- * The timeout for receiving subsequent chunks of bytes in the Response
- * body stream.
- */
- betweenBytesTimeout(): Duration | undefined;
- /**
- * Set the timeout for receiving subsequent chunks of bytes in the Response
- * body stream. An error return value indicates that this timeout is not
- * supported or that this handle is immutable.
- */
- setBetweenBytesTimeout(duration: Duration | undefined): void;
- /**
- * Make a deep copy of the `request-options`.
- * The resulting `request-options` is mutable.
- */
- clone(): RequestOptions;
+ /**
+ * Construct a default `request-options` value.
+ */
+ constructor();
+ /**
+ * The timeout for the initial connect to the HTTP Server.
+ */
+ connectTimeout(): Duration | undefined;
+ /**
+ * Set the timeout for the initial connect to the HTTP Server. An error
+ * return value indicates that this timeout is not supported or that this
+ * handle is immutable.
+ */
+ setConnectTimeout(duration: Duration | undefined): void;
+ /**
+ * The timeout for receiving the first byte of the Response body.
+ */
+ firstByteTimeout(): Duration | undefined;
+ /**
+ * Set the timeout for receiving the first byte of the Response body. An
+ * error return value indicates that this timeout is not supported or that
+ * this handle is immutable.
+ */
+ setFirstByteTimeout(duration: Duration | undefined): void;
+ /**
+ * The timeout for receiving subsequent chunks of bytes in the Response
+ * body stream.
+ */
+ betweenBytesTimeout(): Duration | undefined;
+ /**
+ * Set the timeout for receiving subsequent chunks of bytes in the Response
+ * body stream. An error return value indicates that this timeout is not
+ * supported or that this handle is immutable.
+ */
+ setBetweenBytesTimeout(duration: Duration | undefined): void;
+ /**
+ * Make a deep copy of the `request-options`.
+ * The resulting `request-options` is mutable.
+ */
+ clone(): RequestOptions;
}
export class Response {
- /**
- * This type does not have a public constructor.
- */
- private constructor();
- /**
- * Construct a new `response`, with a default `status-code` of `200`.
- * If a different `status-code` is needed, it must be set via the
- * `set-status-code` method.
- *
- * `headers` is the HTTP Headers for the Response.
- *
- * `contents` is the optional body content stream.
- * Once it is closed, `trailers` future must resolve to a result.
- * If `trailers` resolves to an error, underlying connection
- * will be closed immediately.
- *
- * The returned future resolves to result of transmission of this response.
- */
- static 'new'(headers: Headers, contents: ReadableStream | undefined, trailers: Promise>): [Response, Promise>];
- /**
- * Get the HTTP Status Code for the Response.
- */
- statusCode(): StatusCode;
- /**
- * Set the HTTP Status Code for the Response. Fails if the status-code
- * given is not a valid http status code.
- */
- setStatusCode(statusCode: StatusCode): void;
- /**
- * Get the headers associated with the Response.
- *
- * The returned `headers` resource is immutable: `set`, `append`, and
- * `delete` operations will fail with `header-error.immutable`.
- */
- headers(): Headers;
- /**
- * Get body of the Response.
- *
- * Stream returned by this method represents the contents of the body.
- * Once the stream is reported as closed, callers should await the returned future
- * to determine whether the body was received successfully.
- * The future will only resolve after the stream is reported as closed.
- *
- * The stream and future returned by this method are children:
- * they should be closed or consumed before the parent `response`
- * is dropped, or its ownership is transferred to another component
- * by e.g. `handler.handle`.
- *
- * This method may be called multiple times.
- *
- * This method will return an error if it is called while either:
- * - a stream or future returned by a previous call to this method is still open
- * - a stream returned by a previous call to this method has reported itself as closed
- * Thus there will always be at most one readable stream open for a given body.
- * Each subsequent stream picks up where the last stream left off, up until it is finished.
- */
- body(): [ReadableStream, Promise>];
+ /**
+ * This type does not have a public constructor.
+ */
+ private constructor();
+ /**
+ * Construct a new `response`, with a default `status-code` of `200`.
+ * If a different `status-code` is needed, it must be set via the
+ * `set-status-code` method.
+ *
+ * `headers` is the HTTP Headers for the Response.
+ *
+ * `contents` is the optional body content stream.
+ * Once it is closed, `trailers` future must resolve to a result.
+ * If `trailers` resolves to an error, underlying connection
+ * will be closed immediately.
+ *
+ * The returned future resolves to result of transmission of this response.
+ */
+ static new(
+ headers: Headers,
+ contents: ReadableStream | undefined,
+ trailers: Promise>
+ ): [Response, Promise>];
+ /**
+ * Get the HTTP Status Code for the Response.
+ */
+ statusCode(): StatusCode;
+ /**
+ * Set the HTTP Status Code for the Response. Fails if the status-code
+ * given is not a valid http status code.
+ */
+ setStatusCode(statusCode: StatusCode): void;
+ /**
+ * Get the headers associated with the Response.
+ *
+ * The returned `headers` resource is immutable: `set`, `append`, and
+ * `delete` operations will fail with `header-error.immutable`.
+ */
+ headers(): Headers;
+ /**
+ * Get body of the Response.
+ *
+ * Stream returned by this method represents the contents of the body.
+ * Once the stream is reported as closed, callers should await the returned future
+ * to determine whether the body was received successfully.
+ * The future will only resolve after the stream is reported as closed.
+ *
+ * The stream and future returned by this method are children:
+ * they should be closed or consumed before the parent `response`
+ * is dropped, or its ownership is transferred to another component
+ * by e.g. `handler.handle`.
+ *
+ * This method may be called multiple times.
+ *
+ * This method will return an error if it is called while either:
+ * - a stream or future returned by a previous call to this method is still open
+ * - a stream returned by a previous call to this method has reported itself as closed
+ * Thus there will always be at most one readable stream open for a given body.
+ * Each subsequent stream picks up where the last stream left off, up until it is finished.
+ */
+ body(): [
+ ReadableStream,
+ Promise>,
+ ];
}
diff --git a/packages/preview3-shim/types/interfaces/wasi-random-insecure-seed.d.ts b/packages/preview3-shim/types/interfaces/wasi-random-insecure-seed.d.ts
index 3e2e28fb6..f063e1830 100644
--- a/packages/preview3-shim/types/interfaces/wasi-random-insecure-seed.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-random-insecure-seed.d.ts
@@ -1,19 +1,19 @@
/** @module Interface wasi:random/insecure-seed@0.3.0 **/
/**
* Return a 128-bit value that may contain a pseudo-random value.
- *
+ *
* The returned value is not required to be computed from a CSPRNG, and may
* even be entirely deterministic. Host implementations are encouraged to
* provide pseudo-random values to any program exposed to
* attacker-controlled content, to enable DoS protection built into many
* languages' hash-map implementations.
- *
+ *
* This function is intended to only be called once, by a source language
* to initialize Denial Of Service (DoS) protection in its hash-map
* implementation.
- *
+ *
* # Expected future evolution
- *
+ *
* This will likely be changed to a value import, to prevent it from being
* called multiple times and potentially used for purposes other than DoS
* protection.
diff --git a/packages/preview3-shim/types/interfaces/wasi-random-insecure.d.ts b/packages/preview3-shim/types/interfaces/wasi-random-insecure.d.ts
index ddc524e00..91fc035c8 100644
--- a/packages/preview3-shim/types/interfaces/wasi-random-insecure.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-random-insecure.d.ts
@@ -1,10 +1,10 @@
/** @module Interface wasi:random/insecure@0.3.0 **/
/**
* Return `len` insecure pseudo-random bytes.
- *
+ *
* This function is not cryptographically secure. Do not use it for
* anything related to security.
- *
+ *
* There are no requirements on the values of the returned bytes, however
* implementations are encouraged to return evenly distributed values with
* a long period.
@@ -12,7 +12,7 @@
export function getInsecureRandomBytes(len: bigint): Uint8Array;
/**
* Return an insecure pseudo-random `u64` value.
- *
+ *
* This function returns the same type of pseudo-random data as
* `get-insecure-random-bytes`, represented as a `u64`.
*/
diff --git a/packages/preview3-shim/types/interfaces/wasi-random-random.d.ts b/packages/preview3-shim/types/interfaces/wasi-random-random.d.ts
index b33e1f55c..99a19131e 100644
--- a/packages/preview3-shim/types/interfaces/wasi-random-random.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-random-random.d.ts
@@ -1,14 +1,14 @@
/** @module Interface wasi:random/random@0.3.0 **/
/**
* Return `len` cryptographically-secure random or pseudo-random bytes.
- *
+ *
* This function must produce data at least as cryptographically secure and
* fast as an adequately seeded cryptographically-secure pseudo-random
* number generator (CSPRNG). It must not block, from the perspective of
* the calling program, under any circumstances, including on the first
* request and on requests for numbers of bytes. The returned data must
* always be unpredictable.
- *
+ *
* This function must always return fresh data. Deterministic environments
* must omit this function, rather than implementing it with deterministic
* data.
@@ -16,7 +16,7 @@
export function getRandomBytes(len: bigint): Uint8Array;
/**
* Return a cryptographically-secure random or pseudo-random `u64` value.
- *
+ *
* This function returns the same type of data as `get-random-bytes`,
* represented as a `u64`.
*/
diff --git a/packages/preview3-shim/types/interfaces/wasi-sockets-ip-name-lookup.d.ts b/packages/preview3-shim/types/interfaces/wasi-sockets-ip-name-lookup.d.ts
index c50618fa0..edbfd0e37 100644
--- a/packages/preview3-shim/types/interfaces/wasi-sockets-ip-name-lookup.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-sockets-ip-name-lookup.d.ts
@@ -1,22 +1,22 @@
/** @module Interface wasi:sockets/ip-name-lookup@0.3.0 **/
/**
* Resolve an internet host name to a list of IP addresses.
- *
+ *
* Unicode domain names are automatically converted to ASCII using IDNA encoding.
* If the input is an IP address string, the address is parsed and returned
* as-is without making any external requests.
- *
+ *
* See the wasi-socket proposal README.md for a comparison with getaddrinfo.
- *
+ *
* The results are returned in connection order preference.
- *
+ *
* This function never succeeds with 0 results. It either fails or succeeds
* with at least one address. Additionally, this function never returns
* IPv4-mapped IPv6 addresses.
- *
+ *
* The returned future will resolve to an error code in case of failure.
* It will resolve to success once the returned stream is exhausted.
- *
+ *
* # References:
* -
* -
@@ -28,34 +28,40 @@ export type IpAddress = import('./wasi-sockets-types.js').IpAddress;
/**
* Lookup error codes.
* # Variants
- *
+ *
* ## `"unknown"`
- *
+ *
* Unknown error
* ## `"access-denied"`
- *
+ *
* Access denied.
- *
+ *
* POSIX equivalent: EACCES, EPERM
* ## `"invalid-argument"`
- *
+ *
* `name` is a syntactically invalid domain name or IP address.
- *
+ *
* POSIX equivalent: EINVAL
* ## `"name-unresolvable"`
- *
+ *
* Name does not exist or has no suitable associated IP addresses.
- *
+ *
* POSIX equivalent: EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY
* ## `"temporary-resolver-failure"`
- *
+ *
* A temporary failure in name resolution occurred.
- *
+ *
* POSIX equivalent: EAI_AGAIN
* ## `"permanent-resolver-failure"`
- *
+ *
* A permanent failure in name resolution occurred.
- *
+ *
* POSIX equivalent: EAI_FAIL
*/
-export type ErrorCode = 'unknown' | 'access-denied' | 'invalid-argument' | 'name-unresolvable' | 'temporary-resolver-failure' | 'permanent-resolver-failure';
+export type ErrorCode =
+ | 'unknown'
+ | 'access-denied'
+ | 'invalid-argument'
+ | 'name-unresolvable'
+ | 'temporary-resolver-failure'
+ | 'permanent-resolver-failure';
diff --git a/packages/preview3-shim/types/interfaces/wasi-sockets-types.d.ts b/packages/preview3-shim/types/interfaces/wasi-sockets-types.d.ts
index fd91223df..6704d5deb 100644
--- a/packages/preview3-shim/types/interfaces/wasi-sockets-types.d.ts
+++ b/packages/preview3-shim/types/interfaces/wasi-sockets-types.d.ts
@@ -2,7 +2,7 @@
export type Duration = import('./wasi-clocks-monotonic-clock.js').Duration;
/**
* Error codes.
- *
+ *
* In theory, every API can return any error code.
* In practice, API's typically only return the errors documented per API
* combined with a couple of errors that are always possible:
@@ -10,693 +10,719 @@ export type Duration = import('./wasi-clocks-monotonic-clock.js').Duration;
* - `access-denied`
* - `not-supported`
* - `out-of-memory`
- *
+ *
* See each individual API for what the POSIX equivalents are. They sometimes differ per API.
* # Variants
- *
+ *
* ## `"unknown"`
- *
+ *
* Unknown error
* ## `"access-denied"`
- *
+ *
* Access denied.
- *
+ *
* POSIX equivalent: EACCES, EPERM
* ## `"not-supported"`
- *
+ *
* The operation is not supported.
- *
+ *
* POSIX equivalent: EOPNOTSUPP
* ## `"invalid-argument"`
- *
+ *
* One of the arguments is invalid.
- *
+ *
* POSIX equivalent: EINVAL
* ## `"out-of-memory"`
- *
+ *
* Not enough memory to complete the operation.
- *
+ *
* POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
* ## `"timeout"`
- *
+ *
* The operation timed out before it could finish completely.
* ## `"invalid-state"`
- *
+ *
* The operation is not valid in the socket's current state.
* ## `"address-not-bindable"`
- *
+ *
* A bind operation failed because the provided address is not an address that the `network` can bind to.
* ## `"address-in-use"`
- *
+ *
* A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
* ## `"remote-unreachable"`
- *
+ *
* The remote address is not reachable
* ## `"connection-refused"`
- *
+ *
* The TCP connection was forcefully rejected
* ## `"connection-reset"`
- *
+ *
* The TCP connection was reset.
* ## `"connection-aborted"`
- *
+ *
* A TCP connection was aborted.
* ## `"datagram-too-large"`
- *
+ *
* The size of a datagram sent to a UDP socket exceeded the maximum
* supported size.
*/
-export type ErrorCode = 'unknown' | 'access-denied' | 'not-supported' | 'invalid-argument' | 'out-of-memory' | 'timeout' | 'invalid-state' | 'address-not-bindable' | 'address-in-use' | 'remote-unreachable' | 'connection-refused' | 'connection-reset' | 'connection-aborted' | 'datagram-too-large';
+export type ErrorCode =
+ | 'unknown'
+ | 'access-denied'
+ | 'not-supported'
+ | 'invalid-argument'
+ | 'out-of-memory'
+ | 'timeout'
+ | 'invalid-state'
+ | 'address-not-bindable'
+ | 'address-in-use'
+ | 'remote-unreachable'
+ | 'connection-refused'
+ | 'connection-reset'
+ | 'connection-aborted'
+ | 'datagram-too-large';
/**
* # Variants
- *
+ *
* ## `"ipv4"`
- *
+ *
* Similar to `AF_INET` in POSIX.
* ## `"ipv6"`
- *
+ *
* Similar to `AF_INET6` in POSIX.
*/
export type IpAddressFamily = 'ipv4' | 'ipv6';
export type Ipv4Address = [number, number, number, number];
-export type Ipv6Address = [number, number, number, number, number, number, number, number];
+export type Ipv6Address = [
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+];
export type IpAddress = IpAddressIpv4 | IpAddressIpv6;
export interface IpAddressIpv4 {
- tag: 'ipv4',
- val: Ipv4Address,
+ tag: 'ipv4';
+ val: Ipv4Address;
}
export interface IpAddressIpv6 {
- tag: 'ipv6',
- val: Ipv6Address,
+ tag: 'ipv6';
+ val: Ipv6Address;
}
export interface Ipv4SocketAddress {
- /**
- * sin_port
- */
- port: number,
- /**
- * sin_addr
- */
- address: Ipv4Address,
+ /**
+ * sin_port
+ */
+ port: number;
+ /**
+ * sin_addr
+ */
+ address: Ipv4Address;
}
export interface Ipv6SocketAddress {
- /**
- * sin6_port
- */
- port: number,
- /**
- * sin6_flowinfo
- */
- flowInfo: number,
- /**
- * sin6_addr
- */
- address: Ipv6Address,
- /**
- * sin6_scope_id
- */
- scopeId: number,
+ /**
+ * sin6_port
+ */
+ port: number;
+ /**
+ * sin6_flowinfo
+ */
+ flowInfo: number;
+ /**
+ * sin6_addr
+ */
+ address: Ipv6Address;
+ /**
+ * sin6_scope_id
+ */
+ scopeId: number;
}
export type IpSocketAddress = IpSocketAddressIpv4 | IpSocketAddressIpv6;
export interface IpSocketAddressIpv4 {
- tag: 'ipv4',
- val: Ipv4SocketAddress,
+ tag: 'ipv4';
+ val: Ipv4SocketAddress;
}
export interface IpSocketAddressIpv6 {
- tag: 'ipv6',
- val: Ipv6SocketAddress,
+ tag: 'ipv6';
+ val: Ipv6SocketAddress;
}
-export type Result = { tag: 'ok', val: T } | { tag: 'err', val: E };
+export type Result = { tag: 'ok'; val: T } | { tag: 'err'; val: E };
export class TcpSocket {
- /**
- * Create a new TCP socket.
- *
- * Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
- * On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
- *
- * Unlike POSIX, WASI sockets have no notion of a socket-level
- * `O_NONBLOCK` flag. Instead they fully rely on the Component Model's
- * async support.
- *
- * # References
- * -
- * -
- * -
- * -
- */
- constructor(addressFamily: IpAddressFamily)
- /**
- * Bind the socket to the provided IP address and port.
- *
- * If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which
- * network interface(s) to bind to.
- * If the TCP/UDP port is zero, the socket will be bound to a random free port.
- *
- * Bind can be attempted multiple times on the same socket, even with
- * different arguments on each iteration. But never concurrently and
- * only as long as the previous bind failed. Once a bind succeeds, the
- * binding can't be changed anymore.
- *
- * # Typical errors
- * - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows)
- * - `invalid-argument`: `local-address` is not a unicast address. (EINVAL)
- * - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL)
- * - `invalid-state`: The socket is already bound. (EINVAL)
- * - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows)
- * - `address-in-use`: Address is already in use. (EADDRINUSE)
- * - `address-not-bindable`: `local-address` is not an address that can be bound to. (EADDRNOTAVAIL)
- *
- * # Implementors note
- * When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
- * state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR
- * socket option should be set implicitly on all platforms, except on Windows where this is the default behavior
- * and SO_REUSEADDR performs something different entirely.
- *
- * # References
- * -
- * -
- * -
- * -
- */
- bind(localAddress: IpSocketAddress): void;
- /**
- * Connect to a remote endpoint.
- *
- * On success, the socket is transitioned into the `connected` state and this function returns a connection resource.
- *
- * After a failed connection attempt, the socket will be in the `closed`
- * state and the only valid action left is to `drop` the socket. A single
- * socket can not be used to connect more than once.
- *
- * # Typical errors
- * - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT)
- * - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS)
- * - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos)
- * - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows)
- * - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows)
- * - `invalid-state`: The socket is already in the `connecting` state. (EALREADY)
- * - `invalid-state`: The socket is already in the `connected` state. (EISCONN)
- * - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows)
- * - `timeout`: Connection timed out. (ETIMEDOUT)
- * - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED)
- * - `connection-reset`: The connection was reset. (ECONNRESET)
- * - `connection-aborted`: The connection was aborted. (ECONNABORTED)
- * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
- * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD)
- *
- * # References
- * -
- * -
- * -
- * -
- */
- connect(remoteAddress: IpSocketAddress): Promise;
- /**
- * Start listening return a stream of new inbound connections.
- *
- * Transitions the socket into the `listening` state. This can be called
- * at most once per socket.
- *
- * If the socket is not already explicitly bound, this function will
- * implicitly bind the socket to a random free port.
- *
- * Normally, the returned sockets are bound, in the `connected` state
- * and immediately ready for I/O. Though, depending on exact timing and
- * circumstances, a newly accepted connection may already be `closed`
- * by the time the server attempts to perform its first I/O on it. This
- * is true regardless of whether the WASI implementation uses
- * "synthesized" sockets or not (see Implementors Notes below).
- *
- * The following properties are inherited from the listener socket:
- * - `address-family`
- * - `keep-alive-enabled`
- * - `keep-alive-idle-time`
- * - `keep-alive-interval`
- * - `keep-alive-count`
- * - `hop-limit`
- * - `receive-buffer-size`
- * - `send-buffer-size`
- *
- * # Typical errors
- * - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD)
- * - `invalid-state`: The socket is already in the `listening` state.
- * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE)
- *
- * # Implementors note
- * This method returns a single perpetual stream that should only close
- * on fatal errors (if any). Yet, the POSIX' `accept` function may also
- * return transient errors (e.g. ECONNABORTED). The exact details differ
- * per operation system. For example, the Linux manual mentions:
- *
- * > Linux accept() passes already-pending network errors on the new
- * > socket as an error code from accept(). This behavior differs from
- * > other BSD socket implementations. For reliable operation the
- * > application should detect the network errors defined for the
- * > protocol after accept() and treat them like EAGAIN by retrying.
- * > In the case of TCP/IP, these are ENETDOWN, EPROTO, ENOPROTOOPT,
- * > EHOSTDOWN, ENONET, EHOSTUNREACH, EOPNOTSUPP, and ENETUNREACH.
- * Source: https://man7.org/linux/man-pages/man2/accept.2.html
- *
- * WASI implementations have two options to handle this:
- * - Optionally log it and then skip over non-fatal errors returned by
- * `accept`. Guest code never gets to see these failures. Or:
- * - Synthesize a `tcp-socket` resource that exposes the error when
- * attempting to send or receive on it. Guest code then sees these
- * failures as regular I/O errors.
- *
- * In either case, the stream returned by this `listen` method remains
- * operational.
- *
- * # References
- * -
- * -
- * -
- * -
- * -
- * -
- * -
- * -
- */
- listen(): ReadableStream;
- /**
- * Transmit data to peer.
- *
- * The caller should close the stream when it has no more data to send
- * to the peer. Under normal circumstances this will cause a FIN packet
- * to be sent out. Closing the stream is equivalent to calling
- * `shutdown(SHUT_WR)` in POSIX.
- *
- * This function may be called at most once and returns once the full
- * contents of the stream are transmitted or an error is encountered.
- *
- * # Typical errors
- * - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN)
- * - `connection-reset`: The connection was reset. (ECONNRESET)
- * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
- *
- * # References
- * -
- * -
- * -
- * -
- */
- send(data: ReadableStream): Promise;
- /**
- * Read data from peer.
- *
- * This function returns a `stream` which provides the data received from the
- * socket, and a `future` providing additional error information in case the
- * socket is closed abnormally.
- *
- * If the socket is closed normally, `stream.read` on the `stream` will return
- * `read-status::closed` with no `error-context` and the future resolves to
- * the value `ok`. If the socket is closed abnormally, `stream.read` on the
- * `stream` returns `read-status::closed` with an `error-context` and the future
- * resolves to `err` with an `error-code`.
- *
- * `receive` is meant to be called only once per socket. If it is called more
- * than once, the subsequent calls return a new `stream` that fails as if it
- * were closed abnormally.
- *
- * If the caller is not expecting to receive any data from the peer,
- * they may drop the stream. Any data still in the receive queue
- * will be discarded. This is equivalent to calling `shutdown(SHUT_RD)`
- * in POSIX.
- *
- * # Typical errors
- * - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN)
- * - `connection-reset`: The connection was reset. (ECONNRESET)
- * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
- *
- * # References
- * -
- * -
- * -
- * -
- */
- receive(): [ReadableStream, Promise>];
- /**
- * Get the bound local address.
- *
- * POSIX mentions:
- * > If the socket has not been bound to a local name, the value
- * > stored in the object pointed to by `address` is unspecified.
- *
- * WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet.
- *
- * # Typical errors
- * - `invalid-state`: The socket is not bound to any local address.
- *
- * # References
- * -
- * -
- * -
- * -
- */
- localAddress(): IpSocketAddress;
- /**
- * Get the remote address.
- *
- * # Typical errors
- * - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN)
- *
- * # References
- * -
- * -
- * -
- * -
- */
- remoteAddress(): IpSocketAddress;
- /**
- * Whether the socket is in the `listening` state.
- *
- * Equivalent to the SO_ACCEPTCONN socket option.
- */
- isListening(): boolean;
- /**
- * Whether this is a IPv4 or IPv6 socket.
- *
- * This is the value passed to the constructor.
- *
- * Equivalent to the SO_DOMAIN socket option.
- */
- addressFamily(): IpAddressFamily;
- /**
- * Hints the desired listen queue size. Implementations are free to ignore this.
- *
- * If the provided value is 0, an `invalid-argument` error is returned.
- * Any other value will never cause an error, but it might be silently clamped and/or rounded.
- *
- * # Typical errors
- * - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen.
- * - `invalid-argument`: (set) The provided value was 0.
- * - `invalid-state`: (set) The socket is in the `connecting` or `connected` state.
- */
- setListenBacklogSize(value: bigint): void;
- /**
- * Enables or disables keepalive.
- *
- * The keepalive behavior can be adjusted using:
- * - `keep-alive-idle-time`
- * - `keep-alive-interval`
- * - `keep-alive-count`
- * These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true.
- *
- * Equivalent to the SO_KEEPALIVE socket option.
- */
- keepAliveEnabled(): boolean;
- setKeepAliveEnabled(value: boolean): void;
- /**
- * Amount of time the connection has to be idle before TCP starts sending keepalive packets.
- *
- * If the provided value is 0, an `invalid-argument` error is returned.
- * Any other value will never cause an error, but it might be silently clamped and/or rounded.
- * I.e. after setting a value, reading the same setting back may return a different value.
- *
- * Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS)
- *
- * # Typical errors
- * - `invalid-argument`: (set) The provided value was 0.
- */
- keepAliveIdleTime(): Duration;
- setKeepAliveIdleTime(value: Duration): void;
- /**
- * The time between keepalive packets.
- *
- * If the provided value is 0, an `invalid-argument` error is returned.
- * Any other value will never cause an error, but it might be silently clamped and/or rounded.
- * I.e. after setting a value, reading the same setting back may return a different value.
- *
- * Equivalent to the TCP_KEEPINTVL socket option.
- *
- * # Typical errors
- * - `invalid-argument`: (set) The provided value was 0.
- */
- keepAliveInterval(): Duration;
- setKeepAliveInterval(value: Duration): void;
- /**
- * The maximum amount of keepalive packets TCP should send before aborting the connection.
- *
- * If the provided value is 0, an `invalid-argument` error is returned.
- * Any other value will never cause an error, but it might be silently clamped and/or rounded.
- * I.e. after setting a value, reading the same setting back may return a different value.
- *
- * Equivalent to the TCP_KEEPCNT socket option.
- *
- * # Typical errors
- * - `invalid-argument`: (set) The provided value was 0.
- */
- keepAliveCount(): number;
- setKeepAliveCount(value: number): void;
- /**
- * Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
- *
- * If the provided value is 0, an `invalid-argument` error is returned.
- *
- * # Typical errors
- * - `invalid-argument`: (set) The TTL value must be 1 or higher.
- */
- hopLimit(): number;
- setHopLimit(value: number): void;
- /**
- * The kernel buffer space reserved for sends/receives on this socket.
- *
- * If the provided value is 0, an `invalid-argument` error is returned.
- * Any other value will never cause an error, but it might be silently clamped and/or rounded.
- * I.e. after setting a value, reading the same setting back may return a different value.
- *
- * Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
- *
- * # Typical errors
- * - `invalid-argument`: (set) The provided value was 0.
- */
- receiveBufferSize(): bigint;
- setReceiveBufferSize(value: bigint): void;
- sendBufferSize(): bigint;
- setSendBufferSize(value: bigint): void;
+ /**
+ * Create a new TCP socket.
+ *
+ * Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
+ * On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
+ *
+ * Unlike POSIX, WASI sockets have no notion of a socket-level
+ * `O_NONBLOCK` flag. Instead they fully rely on the Component Model's
+ * async support.
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ constructor(addressFamily: IpAddressFamily);
+ /**
+ * Bind the socket to the provided IP address and port.
+ *
+ * If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which
+ * network interface(s) to bind to.
+ * If the TCP/UDP port is zero, the socket will be bound to a random free port.
+ *
+ * Bind can be attempted multiple times on the same socket, even with
+ * different arguments on each iteration. But never concurrently and
+ * only as long as the previous bind failed. Once a bind succeeds, the
+ * binding can't be changed anymore.
+ *
+ * # Typical errors
+ * - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows)
+ * - `invalid-argument`: `local-address` is not a unicast address. (EINVAL)
+ * - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL)
+ * - `invalid-state`: The socket is already bound. (EINVAL)
+ * - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows)
+ * - `address-in-use`: Address is already in use. (EADDRINUSE)
+ * - `address-not-bindable`: `local-address` is not an address that can be bound to. (EADDRNOTAVAIL)
+ *
+ * # Implementors note
+ * When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
+ * state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR
+ * socket option should be set implicitly on all platforms, except on Windows where this is the default behavior
+ * and SO_REUSEADDR performs something different entirely.
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ bind(localAddress: IpSocketAddress): void;
+ /**
+ * Connect to a remote endpoint.
+ *
+ * On success, the socket is transitioned into the `connected` state and this function returns a connection resource.
+ *
+ * After a failed connection attempt, the socket will be in the `closed`
+ * state and the only valid action left is to `drop` the socket. A single
+ * socket can not be used to connect more than once.
+ *
+ * # Typical errors
+ * - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT)
+ * - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS)
+ * - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos)
+ * - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows)
+ * - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows)
+ * - `invalid-state`: The socket is already in the `connecting` state. (EALREADY)
+ * - `invalid-state`: The socket is already in the `connected` state. (EISCONN)
+ * - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows)
+ * - `timeout`: Connection timed out. (ETIMEDOUT)
+ * - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED)
+ * - `connection-reset`: The connection was reset. (ECONNRESET)
+ * - `connection-aborted`: The connection was aborted. (ECONNABORTED)
+ * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
+ * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD)
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ connect(remoteAddress: IpSocketAddress): Promise;
+ /**
+ * Start listening return a stream of new inbound connections.
+ *
+ * Transitions the socket into the `listening` state. This can be called
+ * at most once per socket.
+ *
+ * If the socket is not already explicitly bound, this function will
+ * implicitly bind the socket to a random free port.
+ *
+ * Normally, the returned sockets are bound, in the `connected` state
+ * and immediately ready for I/O. Though, depending on exact timing and
+ * circumstances, a newly accepted connection may already be `closed`
+ * by the time the server attempts to perform its first I/O on it. This
+ * is true regardless of whether the WASI implementation uses
+ * "synthesized" sockets or not (see Implementors Notes below).
+ *
+ * The following properties are inherited from the listener socket:
+ * - `address-family`
+ * - `keep-alive-enabled`
+ * - `keep-alive-idle-time`
+ * - `keep-alive-interval`
+ * - `keep-alive-count`
+ * - `hop-limit`
+ * - `receive-buffer-size`
+ * - `send-buffer-size`
+ *
+ * # Typical errors
+ * - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD)
+ * - `invalid-state`: The socket is already in the `listening` state.
+ * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE)
+ *
+ * # Implementors note
+ * This method returns a single perpetual stream that should only close
+ * on fatal errors (if any). Yet, the POSIX' `accept` function may also
+ * return transient errors (e.g. ECONNABORTED). The exact details differ
+ * per operation system. For example, the Linux manual mentions:
+ *
+ * > Linux accept() passes already-pending network errors on the new
+ * > socket as an error code from accept(). This behavior differs from
+ * > other BSD socket implementations. For reliable operation the
+ * > application should detect the network errors defined for the
+ * > protocol after accept() and treat them like EAGAIN by retrying.
+ * > In the case of TCP/IP, these are ENETDOWN, EPROTO, ENOPROTOOPT,
+ * > EHOSTDOWN, ENONET, EHOSTUNREACH, EOPNOTSUPP, and ENETUNREACH.
+ * Source: https://man7.org/linux/man-pages/man2/accept.2.html
+ *
+ * WASI implementations have two options to handle this:
+ * - Optionally log it and then skip over non-fatal errors returned by
+ * `accept`. Guest code never gets to see these failures. Or:
+ * - Synthesize a `tcp-socket` resource that exposes the error when
+ * attempting to send or receive on it. Guest code then sees these
+ * failures as regular I/O errors.
+ *
+ * In either case, the stream returned by this `listen` method remains
+ * operational.
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ * -
+ * -
+ * -
+ * -
+ */
+ listen(): ReadableStream;
+ /**
+ * Transmit data to peer.
+ *
+ * The caller should close the stream when it has no more data to send
+ * to the peer. Under normal circumstances this will cause a FIN packet
+ * to be sent out. Closing the stream is equivalent to calling
+ * `shutdown(SHUT_WR)` in POSIX.
+ *
+ * This function may be called at most once and returns once the full
+ * contents of the stream are transmitted or an error is encountered.
+ *
+ * # Typical errors
+ * - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN)
+ * - `connection-reset`: The connection was reset. (ECONNRESET)
+ * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ send(data: ReadableStream): Promise;
+ /**
+ * Read data from peer.
+ *
+ * This function returns a `stream` which provides the data received from the
+ * socket, and a `future` providing additional error information in case the
+ * socket is closed abnormally.
+ *
+ * If the socket is closed normally, `stream.read` on the `stream` will return
+ * `read-status::closed` with no `error-context` and the future resolves to
+ * the value `ok`. If the socket is closed abnormally, `stream.read` on the
+ * `stream` returns `read-status::closed` with an `error-context` and the future
+ * resolves to `err` with an `error-code`.
+ *
+ * `receive` is meant to be called only once per socket. If it is called more
+ * than once, the subsequent calls return a new `stream` that fails as if it
+ * were closed abnormally.
+ *
+ * If the caller is not expecting to receive any data from the peer,
+ * they may drop the stream. Any data still in the receive queue
+ * will be discarded. This is equivalent to calling `shutdown(SHUT_RD)`
+ * in POSIX.
+ *
+ * # Typical errors
+ * - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN)
+ * - `connection-reset`: The connection was reset. (ECONNRESET)
+ * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ receive(): [ReadableStream, Promise>];
+ /**
+ * Get the bound local address.
+ *
+ * POSIX mentions:
+ * > If the socket has not been bound to a local name, the value
+ * > stored in the object pointed to by `address` is unspecified.
+ *
+ * WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet.
+ *
+ * # Typical errors
+ * - `invalid-state`: The socket is not bound to any local address.
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ localAddress(): IpSocketAddress;
+ /**
+ * Get the remote address.
+ *
+ * # Typical errors
+ * - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN)
+ *
+ * # References
+ * -
+ * -
+ * -
+ * -
+ */
+ remoteAddress(): IpSocketAddress;
+ /**
+ * Whether the socket is in the `listening` state.
+ *
+ * Equivalent to the SO_ACCEPTCONN socket option.
+ */
+ isListening(): boolean;
+ /**
+ * Whether this is a IPv4 or IPv6 socket.
+ *
+ * This is the value passed to the constructor.
+ *
+ * Equivalent to the SO_DOMAIN socket option.
+ */
+ addressFamily(): IpAddressFamily;
+ /**
+ * Hints the desired listen queue size. Implementations are free to ignore this.
+ *
+ * If the provided value is 0, an `invalid-argument` error is returned.
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
+ *
+ * # Typical errors
+ * - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen.
+ * - `invalid-argument`: (set) The provided value was 0.
+ * - `invalid-state`: (set) The socket is in the `connecting` or `connected` state.
+ */
+ setListenBacklogSize(value: bigint): void;
+ /**
+ * Enables or disables keepalive.
+ *
+ * The keepalive behavior can be adjusted using:
+ * - `keep-alive-idle-time`
+ * - `keep-alive-interval`
+ * - `keep-alive-count`
+ * These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true.
+ *
+ * Equivalent to the SO_KEEPALIVE socket option.
+ */
+ keepAliveEnabled(): boolean;
+ setKeepAliveEnabled(value: boolean): void;
+ /**
+ * Amount of time the connection has to be idle before TCP starts sending keepalive packets.
+ *
+ * If the provided value is 0, an `invalid-argument` error is returned.
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
+ * I.e. after setting a value, reading the same setting back may return a different value.
+ *
+ * Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS)
+ *
+ * # Typical errors
+ * - `invalid-argument`: (set) The provided value was 0.
+ */
+ keepAliveIdleTime(): Duration;
+ setKeepAliveIdleTime(value: Duration): void;
+ /**
+ * The time between keepalive packets.
+ *
+ * If the provided value is 0, an `invalid-argument` error is returned.
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
+ * I.e. after setting a value, reading the same setting back may return a different value.
+ *
+ * Equivalent to the TCP_KEEPINTVL socket option.
+ *
+ * # Typical errors
+ * - `invalid-argument`: (set) The provided value was 0.
+ */
+ keepAliveInterval(): Duration;
+ setKeepAliveInterval(value: Duration): void;
+ /**
+ * The maximum amount of keepalive packets TCP should send before aborting the connection.
+ *
+ * If the provided value is 0, an `invalid-argument` error is returned.
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
+ * I.e. after setting a value, reading the same setting back may return a different value.
+ *
+ * Equivalent to the TCP_KEEPCNT socket option.
+ *
+ * # Typical errors
+ * - `invalid-argument`: (set) The provided value was 0.
+ */
+ keepAliveCount(): number;
+ setKeepAliveCount(value: number): void;
+ /**
+ * Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
+ *
+ * If the provided value is 0, an `invalid-argument` error is returned.
+ *
+ * # Typical errors
+ * - `invalid-argument`: (set) The TTL value must be 1 or higher.
+ */
+ hopLimit(): number;
+ setHopLimit(value: number): void;
+ /**
+ * The kernel buffer space reserved for sends/receives on this socket.
+ *
+ * If the provided value is 0, an `invalid-argument` error is returned.
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
+ * I.e. after setting a value, reading the same setting back may return a different value.
+ *
+ * Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
+ *
+ * # Typical errors
+ * - `invalid-argument`: (set) The provided value was 0.
+ */
+ receiveBufferSize(): bigint;
+ setReceiveBufferSize(value: bigint): void;
+ sendBufferSize(): bigint;
+ setSendBufferSize(value: bigint): void;
}
export class UdpSocket {
- /**
- * Create a new UDP socket.
- *
- * Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX.
- * On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
- *
- * Unlike POSIX, WASI sockets have no notion of a socket-level
- * `O_NONBLOCK` flag. Instead they fully rely on the Component Model's
- * async support.
- *
- * # References:
- * -
- * -
- * -
- * -
- */
- constructor(addressFamily: IpAddressFamily)
- /**
- * Bind the socket to the provided IP address and port.
- *
- * If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which
- * network interface(s) to bind to.
- * If the port is zero, the socket will be bound to a random free port.
- *
- * # Typical errors
- * - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows)
- * - `invalid-state`: The socket is already bound. (EINVAL)
- * - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows)
- * - `address-in-use`: Address is already in use. (EADDRINUSE)
- * - `address-not-bindable`: `local-address` is not an address that can be bound to. (EADDRNOTAVAIL)
- *
- * # References
- * -
- * -
- * -
- * -
- */
- bind(localAddress: IpSocketAddress): void;
- /**
- * Associate this socket with a specific peer address.
- *
- * On success, the `remote-address` of the socket is updated.
- * The `local-address` may be updated as well, based on the best network
- * path to `remote-address`. If the socket was not already explicitly
- * bound, this function will implicitly bind the socket to a random
- * free port.
- *
- * When a UDP socket is "connected", the `send` and `receive` methods
- * are limited to communicating with that peer only:
- * - `send` can only be used to send to this destination.
- * - `receive` will only return datagrams sent from the provided `remote-address`.
- *
- * The name "connect" was kept to align with the existing POSIX
- * terminology. Other than that, this function only changes the local
- * socket configuration and does not generate any network traffic.
- * The peer is not aware of this "connection".
- *
- * This method may be called multiple times on the same socket to change
- * its association, but only the most recent one will be effective.
- *
- * # Typical errors
- * - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT)
- * - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL)
- * - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL)
- * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD)
- *
- * # Implementors note
- * If the socket is already connected, some platforms (e.g. Linux)
- * require a disconnect before connecting to a different peer address.
- *
- * # References
- * -
- * -
- * -
- * -
- */
- connect(remoteAddress: IpSocketAddress): void;
- /**
- * Dissociate this socket from its peer address.
- *
- * After calling this method, `send` & `receive` are free to communicate
- * with any address again.
- *
- * The POSIX equivalent of this is calling `connect` with an `AF_UNSPEC` address.
- *
- * # Typical errors
- * - `invalid-state`: The socket is not connected.
- *
- * # References
- * -
- * -
- * -
- * -
- */
- disconnect(): void;
- /**
- * Send a message on the socket to a particular peer.
- *
- * If the socket is connected, the peer address may be left empty. In
- * that case this is equivalent to `send` in POSIX. Otherwise it is
- * equivalent to `sendto`.
- *
- * Additionally, if the socket is connected, a `remote-address` argument
- * _may_ be provided but then it must be identical to the address
- * passed to `connect`.
- *
- * Implementations may trap if the `data` length exceeds 64 KiB.
- *
- * # Typical errors
- * - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT)
- * - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL)
- * - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL)
- * - `invalid-argument`: The socket is in "connected" mode and `remote-address` is `some` value that does not match the address passed to `connect`. (EISCONN)
- * - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ)
- * - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
- * - `connection-refused`: The connection was refused. (ECONNREFUSED)
- * - `datagram-too-large`: The datagram is too large. (EMSGSIZE)
- *
- * # References
- * -