@bytecodealliance/preview2-shim 0.16.4 → 0.16.6
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/lib/browser/filesystem.js +1 -1
- package/lib/io/worker-io.js +1 -0
- package/lib/io/worker-socket-tcp.js +11 -3
- package/lib/io/worker-thread.js +1 -1
- package/lib/nodejs/filesystem.js +4 -4
- package/lib/nodejs/http.js +1 -1
- package/package.json +1 -1
- package/types/interfaces/wasi-cli-environment.d.ts +2 -2
- package/types/interfaces/wasi-filesystem-preopens.d.ts +1 -1
- package/types/interfaces/wasi-http-types.d.ts +4 -4
- package/types/interfaces/wasi-io-poll.d.ts +1 -1
- package/types/interfaces/wasi-sockets-udp.d.ts +2 -2
|
@@ -198,7 +198,7 @@ class Descriptor {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
statAt(_pathFlags, path) {
|
|
201
|
-
const entry = getChildEntry(this.#entry, path);
|
|
201
|
+
const entry = getChildEntry(this.#entry, path, { create: false, directory: false });
|
|
202
202
|
let type = 'unknown', size = BigInt(0);
|
|
203
203
|
if (entry.source) {
|
|
204
204
|
type = 'regular-file';
|
package/lib/io/worker-io.js
CHANGED
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
} from "./worker-sockets.js";
|
|
32
32
|
import { Socket, Server } from "node:net";
|
|
33
33
|
|
|
34
|
+
const winOrMac = process.platform === 'win32' || process.platform === 'darwin';
|
|
35
|
+
|
|
34
36
|
/**
|
|
35
37
|
* @typedef {import("../../types/interfaces/wasi-sockets-network.js").IpSocketAddress} IpSocketAddress
|
|
36
38
|
* @typedef {import("../../../types/interfaces/wasi-sockets-tcp.js").IpAddressFamily} IpAddressFamily
|
|
@@ -45,7 +47,7 @@ import { Socket, Server } from "node:net";
|
|
|
45
47
|
* @typedef {{
|
|
46
48
|
* state: number,
|
|
47
49
|
* future: number | null,
|
|
48
|
-
*
|
|
50
|
+
* tcpSocket: TcpSocket | null,
|
|
49
51
|
* listenBacklogSize: number,
|
|
50
52
|
* handle: TCP,
|
|
51
53
|
* pendingAccepts: PendingAccept[],
|
|
@@ -68,6 +70,7 @@ export function createTcpSocket() {
|
|
|
68
70
|
tcpSockets.set(++tcpSocketCnt, {
|
|
69
71
|
state: SOCKET_STATE_INIT,
|
|
70
72
|
future: null,
|
|
73
|
+
tcpSocket: null,
|
|
71
74
|
listenBacklogSize: 128,
|
|
72
75
|
handle,
|
|
73
76
|
pendingAccepts: [],
|
|
@@ -217,6 +220,7 @@ export function socketTcpAccept(id) {
|
|
|
217
220
|
tcpSockets.set(++tcpSocketCnt, {
|
|
218
221
|
state: SOCKET_STATE_CONNECTION,
|
|
219
222
|
future: null,
|
|
223
|
+
tcpSocket: accept.tcpSocket,
|
|
220
224
|
listenBacklogSize: 128,
|
|
221
225
|
handle: accept.tcpSocket._handle,
|
|
222
226
|
pendingAccepts: [],
|
|
@@ -265,8 +269,12 @@ export function socketTcpShutdown(id, shutdownType) {
|
|
|
265
269
|
const socket = tcpSockets.get(id);
|
|
266
270
|
if (socket.state !== SOCKET_STATE_CONNECTION) throw "invalid-state";
|
|
267
271
|
// Node.js only supports a write shutdown, which is triggered on end
|
|
268
|
-
if (shutdownType === "send" || shutdownType === "both")
|
|
269
|
-
socket.tcpSocket.
|
|
272
|
+
if (shutdownType === "send" || shutdownType === "both") {
|
|
273
|
+
if (winOrMac && socket.tcpSocket.destroySoon)
|
|
274
|
+
socket.tcpSocket.destroySoon();
|
|
275
|
+
else
|
|
276
|
+
socket.tcpSocket.destroy();
|
|
277
|
+
}
|
|
270
278
|
}
|
|
271
279
|
|
|
272
280
|
export function socketTcpSetKeepAlive(id, { keepAlive, keepAliveIdleTime }) {
|
package/lib/io/worker-thread.js
CHANGED
|
@@ -583,7 +583,7 @@ function handle(call, id, payload) {
|
|
|
583
583
|
Math.min(stream.stream.readableLength, Number(payload))
|
|
584
584
|
);
|
|
585
585
|
if (res) return res;
|
|
586
|
-
if (stream.stream.readableEnded)
|
|
586
|
+
if (stream.stream.readableEnded) throw { tag: "closed" };
|
|
587
587
|
return new Uint8Array();
|
|
588
588
|
}
|
|
589
589
|
case INPUT_STREAM_BLOCKING_READ: {
|
package/lib/nodejs/filesystem.js
CHANGED
|
@@ -352,7 +352,7 @@ class Descriptor {
|
|
|
352
352
|
let isSymlink = false;
|
|
353
353
|
try {
|
|
354
354
|
isSymlink = lstatSync(fullPath).isSymbolicLink();
|
|
355
|
-
} catch
|
|
355
|
+
} catch {
|
|
356
356
|
//
|
|
357
357
|
}
|
|
358
358
|
if (isSymlink) throw openFlags.directory ? "not-directory" : "loop";
|
|
@@ -361,7 +361,7 @@ class Descriptor {
|
|
|
361
361
|
let isFile = false;
|
|
362
362
|
try {
|
|
363
363
|
isFile = !statSync(fullPath).isDirectory();
|
|
364
|
-
} catch
|
|
364
|
+
} catch {
|
|
365
365
|
//
|
|
366
366
|
}
|
|
367
367
|
if (isFile) throw "not-directory";
|
|
@@ -430,7 +430,7 @@ class Descriptor {
|
|
|
430
430
|
let isDir = false;
|
|
431
431
|
try {
|
|
432
432
|
isDir = statSync(fullPath).isDirectory();
|
|
433
|
-
} catch
|
|
433
|
+
} catch {
|
|
434
434
|
//
|
|
435
435
|
}
|
|
436
436
|
if (!isDir) throw isWindows ? "no-entry" : "not-directory";
|
|
@@ -449,7 +449,7 @@ class Descriptor {
|
|
|
449
449
|
let isDir = false;
|
|
450
450
|
try {
|
|
451
451
|
isDir = statSync(fullPath).isDirectory();
|
|
452
|
-
} catch
|
|
452
|
+
} catch {
|
|
453
453
|
//
|
|
454
454
|
}
|
|
455
455
|
throw isDir ? (isWindows ? "access" : (isMac ? "not-permitted" : "is-directory")) : "not-directory";
|
package/lib/nodejs/http.js
CHANGED
package/package.json
CHANGED
|
@@ -9,11 +9,11 @@ export namespace WasiCliEnvironment {
|
|
|
9
9
|
* in the component model, this import function should return the same
|
|
10
10
|
* values each time it is called.
|
|
11
11
|
*/
|
|
12
|
-
export function getEnvironment(): [string, string]
|
|
12
|
+
export function getEnvironment(): Array<[string, string]>;
|
|
13
13
|
/**
|
|
14
14
|
* Get the POSIX-style arguments to the program.
|
|
15
15
|
*/
|
|
16
|
-
export function getArguments(): string
|
|
16
|
+
export function getArguments(): Array<string>;
|
|
17
17
|
/**
|
|
18
18
|
* Return a path that programs should use as their initial current working
|
|
19
19
|
* directory, interpreting `.` as shorthand for this.
|
|
@@ -2,7 +2,7 @@ export namespace WasiFilesystemPreopens {
|
|
|
2
2
|
/**
|
|
3
3
|
* Return the set of preopened directories, and their path.
|
|
4
4
|
*/
|
|
5
|
-
export function getDirectories(): [Descriptor, string]
|
|
5
|
+
export function getDirectories(): Array<[Descriptor, string]>;
|
|
6
6
|
}
|
|
7
7
|
import type { Descriptor } from './wasi-filesystem-types.js';
|
|
8
8
|
export { Descriptor };
|
|
@@ -324,14 +324,14 @@ export class Fields {
|
|
|
324
324
|
* An error result will be returned if any header or value was
|
|
325
325
|
* syntactically invalid, or if a header was forbidden.
|
|
326
326
|
*/
|
|
327
|
-
static fromList(entries: [FieldKey, FieldValue]
|
|
327
|
+
static fromList(entries: Array<[FieldKey, FieldValue]>): Fields;
|
|
328
328
|
/**
|
|
329
329
|
* Get all of the values corresponding to a key. If the key is not present
|
|
330
330
|
* in this `fields`, an empty list is returned. However, if the key is
|
|
331
331
|
* present but empty, this is represented by a list with one or more
|
|
332
332
|
* empty field-values present.
|
|
333
333
|
*/
|
|
334
|
-
get(name: FieldKey): FieldValue
|
|
334
|
+
get(name: FieldKey): Array<FieldValue>;
|
|
335
335
|
/**
|
|
336
336
|
* Returns `true` when the key is present in this `fields`. If the key is
|
|
337
337
|
* syntactically invalid, `false` is returned.
|
|
@@ -343,7 +343,7 @@ export class Fields {
|
|
|
343
343
|
*
|
|
344
344
|
* Fails with `header-error.immutable` if the `fields` are immutable.
|
|
345
345
|
*/
|
|
346
|
-
set(name: FieldKey, value: FieldValue
|
|
346
|
+
set(name: FieldKey, value: Array<FieldValue>): void;
|
|
347
347
|
/**
|
|
348
348
|
* Delete all values for a key. Does nothing if no values for the key
|
|
349
349
|
* exist.
|
|
@@ -366,7 +366,7 @@ export class Fields {
|
|
|
366
366
|
* which have multiple values are represented by multiple entries in this
|
|
367
367
|
* list with the same key.
|
|
368
368
|
*/
|
|
369
|
-
entries(): [FieldKey, FieldValue]
|
|
369
|
+
entries(): Array<[FieldKey, FieldValue]>;
|
|
370
370
|
/**
|
|
371
371
|
* Make a deep copy of the Fields. Equivelant in behavior to calling the
|
|
372
372
|
* `fields` constructor on the return value of `entries`. The resulting
|
|
@@ -20,7 +20,7 @@ export namespace WasiIoPoll {
|
|
|
20
20
|
* the pollables has an error, it is indicated by marking the source as
|
|
21
21
|
* being reaedy for I/O.
|
|
22
22
|
*/
|
|
23
|
-
export function poll(in_: Pollable
|
|
23
|
+
export function poll(in_: Array<Pollable>): Uint32Array;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export class Pollable {
|
|
@@ -78,7 +78,7 @@ export class IncomingDatagramStream {
|
|
|
78
78
|
* - <https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)>
|
|
79
79
|
* - <https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2>
|
|
80
80
|
*/
|
|
81
|
-
receive(maxResults: bigint): IncomingDatagram
|
|
81
|
+
receive(maxResults: bigint): Array<IncomingDatagram>;
|
|
82
82
|
/**
|
|
83
83
|
* Create a `pollable` which will resolve once the stream is ready to receive again.
|
|
84
84
|
*
|
|
@@ -139,7 +139,7 @@ export class OutgoingDatagramStream {
|
|
|
139
139
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendmsg>
|
|
140
140
|
* - <https://man.freebsd.org/cgi/man.cgi?query=send&sektion=2>
|
|
141
141
|
*/
|
|
142
|
-
send(datagrams: OutgoingDatagram
|
|
142
|
+
send(datagrams: Array<OutgoingDatagram>): bigint;
|
|
143
143
|
/**
|
|
144
144
|
* Create a `pollable` which will resolve once the stream is ready to send again.
|
|
145
145
|
*
|