@bytecodealliance/preview3-shim 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nodejs/cli.d.ts +1 -1
- package/dist/nodejs/clocks.d.ts +2 -2
- package/dist/nodejs/filesystem/descriptor.d.ts +2 -2
- package/dist/nodejs/sockets/address.d.ts +2 -2
- package/dist/nodejs/sockets/tcp.d.ts +1 -1
- package/dist/nodejs/sockets/tcp.js +1 -1
- package/dist/nodejs/sockets/udp.js +1 -1
- package/dist/nodejs/workers/cli-worker.bundle.js +3 -1
- package/dist/nodejs/workers/filesystem-worker.bundle.js +1 -1
- package/dist/nodejs/workers/http-worker.bundle.js +2 -1
- package/package.json +4 -4
package/dist/nodejs/cli.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const stdin: {
|
|
|
17
17
|
*
|
|
18
18
|
* @returns {[StreamReader, FutureReader]} A tuple of [stream, future].
|
|
19
19
|
*/
|
|
20
|
-
readViaStream(): (
|
|
20
|
+
readViaStream(): (import("./future.js").FutureReader | StreamReader)[];
|
|
21
21
|
};
|
|
22
22
|
export declare const stdout: {
|
|
23
23
|
/**
|
package/dist/nodejs/clocks.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare const systemClock: {
|
|
|
13
13
|
getResolution(): bigint;
|
|
14
14
|
};
|
|
15
15
|
export declare const monotonicClock: {
|
|
16
|
+
now(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Instant;
|
|
17
|
+
resolution(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Duration;
|
|
16
18
|
/**
|
|
17
19
|
* Query the resolution of the clock.
|
|
18
20
|
*
|
|
@@ -50,6 +52,4 @@ export declare const monotonicClock: {
|
|
|
50
52
|
* @throws {TypeError} If durationNs is not a bigint
|
|
51
53
|
*/
|
|
52
54
|
waitFor(durationNs: any): Promise<void>;
|
|
53
|
-
now(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Instant;
|
|
54
|
-
resolution(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Duration;
|
|
55
55
|
};
|
|
@@ -18,7 +18,7 @@ declare class Descriptor {
|
|
|
18
18
|
* A tuple: a readable byte stream and a future that resolves to an error code.
|
|
19
19
|
* @throws {FSError} `payload.tag` contains mapped WASI error code.
|
|
20
20
|
*/
|
|
21
|
-
readViaStream(offset: any): (
|
|
21
|
+
readViaStream(offset: any): (FutureReader | StreamReader)[];
|
|
22
22
|
/**
|
|
23
23
|
* Write to a file via a byte stream.
|
|
24
24
|
* WIT:
|
|
@@ -141,7 +141,7 @@ declare class Descriptor {
|
|
|
141
141
|
* @returns {{stream: StreamReader, future: FutureReader}}
|
|
142
142
|
* @throws {FSError} `payload.tag` contains mapped WASI error code.
|
|
143
143
|
*/
|
|
144
|
-
readDirectory(): (
|
|
144
|
+
readDirectory(): (FutureReader | StreamReader)[];
|
|
145
145
|
/**
|
|
146
146
|
* Synchronize data & metadata to disk.
|
|
147
147
|
* WIT:
|
|
@@ -108,7 +108,7 @@ export declare class TcpSocket {
|
|
|
108
108
|
* @throws {SocketError} for other errors, payload.tag maps the system error
|
|
109
109
|
* @returns {{ stream: StreamReader, future: FutureReader }}
|
|
110
110
|
*/
|
|
111
|
-
receive(): (
|
|
111
|
+
receive(): (FutureReader | StreamReader)[];
|
|
112
112
|
/**
|
|
113
113
|
* Gets the bound local address
|
|
114
114
|
* WIT:
|
|
@@ -462,7 +462,7 @@ export class UdpSocket {
|
|
|
462
462
|
* Releases native resources and marks the socket as closed.
|
|
463
463
|
*/
|
|
464
464
|
[Symbol.dispose]() {
|
|
465
|
-
if (this.#socketId) {
|
|
465
|
+
if (this.#socketId !== null) {
|
|
466
466
|
worker().runSync({
|
|
467
467
|
op: "udp-dispose",
|
|
468
468
|
socketId: this.#socketId,
|
|
@@ -64,7 +64,9 @@ function notify(condvar) {
|
|
|
64
64
|
Router().op("stdout", handleOp).op("stderr", handleOp);
|
|
65
65
|
async function handleOp(msg) {
|
|
66
66
|
const { op, stream } = msg;
|
|
67
|
-
|
|
67
|
+
const readable = Readable.from(byteChunks(stream), { objectMode: false });
|
|
68
|
+
const writable = op === "stdout" ? process.stdout : process.stderr;
|
|
69
|
+
await pipeline(readable, writable, { end: false });
|
|
68
70
|
return { ok: true };
|
|
69
71
|
}
|
|
70
72
|
async function* byteChunks(stream) {
|
|
@@ -156,7 +156,7 @@ function wasiTypeFromDirent(obj) {
|
|
|
156
156
|
const readAsync = promisify(fs.read);
|
|
157
157
|
const writeAsync = promisify(fs.write);
|
|
158
158
|
const { opendir } = fs.promises;
|
|
159
|
-
const CHUNK_BYTES =
|
|
159
|
+
const CHUNK_BYTES = 65536;
|
|
160
160
|
const BUFFER = Buffer.alloc(CHUNK_BYTES);
|
|
161
161
|
const MAX_SAFE_FILE_POSITION = BigInt(Number.MAX_SAFE_INTEGER);
|
|
162
162
|
/** Auto‐dispatch all ops */
|
|
@@ -173,7 +173,8 @@ async function handleNext({ serverId }) {
|
|
|
173
173
|
const { req } = srv.inflight.get(requestId);
|
|
174
174
|
const { port1: tx, port2: trailers } = new MessageChannel();
|
|
175
175
|
const { readable: body, writable } = new TransformStream();
|
|
176
|
-
|
|
176
|
+
const stream = Writable.fromWeb(writable);
|
|
177
|
+
pipeline(req, stream).then(() => tx.postMessage({ val: toEntries(req.trailersDistinct || req.trailers || {}) })).catch((err) => tx.postMessage({ err })).finally(() => tx.close());
|
|
177
178
|
const headers = toEntries(req.headersDistinct);
|
|
178
179
|
const { method, url } = req;
|
|
179
180
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/preview3-shim",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "WASI Preview3 shim for JS environments",
|
|
5
5
|
"homepage": "https://github.com/bytecodealliance/jco/blob/main/packages/preview3-shim/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^24.12.4",
|
|
55
55
|
"globals": "^17.6.0",
|
|
56
|
-
"rolldown": "^1.2.
|
|
57
|
-
"typescript": "
|
|
56
|
+
"rolldown": "^1.2.4",
|
|
57
|
+
"typescript": "7.0.2",
|
|
58
58
|
"vite": "^8.0.16",
|
|
59
|
-
"vitest": "^4.
|
|
59
|
+
"vitest": "^4.1.10"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsc --project tsconfig.build.json && node scripts/build-workers.mjs",
|