@bytecodealliance/preview2-shim 0.17.4 → 0.17.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/config.js +4 -1
- package/lib/browser/filesystem.js +99 -2
- package/lib/browser/http.js +10 -0
- package/lib/browser/io.js +5 -2
- package/package.json +33 -14
package/lib/browser/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { streams } from './io.js';
|
|
2
2
|
import { environment } from './environment.js';
|
|
3
3
|
|
|
4
|
-
import { _setCwd } from './config.js';
|
|
4
|
+
import { _setCwd, _getCwd } from './config.js';
|
|
5
5
|
export { _setCwd } from './config.js';
|
|
6
6
|
|
|
7
7
|
const { InputStream, OutputStream } = streams;
|
|
@@ -30,7 +30,7 @@ function getChildEntry(parentEntry, subpath, openFlags) {
|
|
|
30
30
|
_rootPreopen &&
|
|
31
31
|
descriptorGetEntry(_rootPreopen[0]) === parentEntry
|
|
32
32
|
) {
|
|
33
|
-
subpath =
|
|
33
|
+
subpath = _getCwd();
|
|
34
34
|
if (subpath.startsWith('/') && subpath !== '/') {
|
|
35
35
|
subpath = subpath.slice(1);
|
|
36
36
|
}
|
|
@@ -325,6 +325,103 @@ export const preopens = {
|
|
|
325
325
|
export const types = {
|
|
326
326
|
Descriptor,
|
|
327
327
|
DirectoryEntryStream,
|
|
328
|
+
filesystemErrorCode(err) {
|
|
329
|
+
return convertFsError(err.payload);
|
|
330
|
+
},
|
|
328
331
|
};
|
|
329
332
|
|
|
333
|
+
function convertFsError(e) {
|
|
334
|
+
switch (e.code) {
|
|
335
|
+
case 'EACCES':
|
|
336
|
+
return 'access';
|
|
337
|
+
case 'EAGAIN':
|
|
338
|
+
case 'EWOULDBLOCK':
|
|
339
|
+
return 'would-block';
|
|
340
|
+
case 'EALREADY':
|
|
341
|
+
return 'already';
|
|
342
|
+
case 'EBADF':
|
|
343
|
+
return 'bad-descriptor';
|
|
344
|
+
case 'EBUSY':
|
|
345
|
+
return 'busy';
|
|
346
|
+
case 'EDEADLK':
|
|
347
|
+
return 'deadlock';
|
|
348
|
+
case 'EDQUOT':
|
|
349
|
+
return 'quota';
|
|
350
|
+
case 'EEXIST':
|
|
351
|
+
return 'exist';
|
|
352
|
+
case 'EFBIG':
|
|
353
|
+
return 'file-too-large';
|
|
354
|
+
case 'EILSEQ':
|
|
355
|
+
return 'illegal-byte-sequence';
|
|
356
|
+
case 'EINPROGRESS':
|
|
357
|
+
return 'in-progress';
|
|
358
|
+
case 'EINTR':
|
|
359
|
+
return 'interrupted';
|
|
360
|
+
case 'EINVAL':
|
|
361
|
+
return 'invalid';
|
|
362
|
+
case 'EIO':
|
|
363
|
+
return 'io';
|
|
364
|
+
case 'EISDIR':
|
|
365
|
+
return 'is-directory';
|
|
366
|
+
case 'ELOOP':
|
|
367
|
+
return 'loop';
|
|
368
|
+
case 'EMLINK':
|
|
369
|
+
return 'too-many-links';
|
|
370
|
+
case 'EMSGSIZE':
|
|
371
|
+
return 'message-size';
|
|
372
|
+
case 'ENAMETOOLONG':
|
|
373
|
+
return 'name-too-long';
|
|
374
|
+
case 'ENODEV':
|
|
375
|
+
return 'no-device';
|
|
376
|
+
case 'ENOENT':
|
|
377
|
+
return 'no-entry';
|
|
378
|
+
case 'ENOLCK':
|
|
379
|
+
return 'no-lock';
|
|
380
|
+
case 'ENOMEM':
|
|
381
|
+
return 'insufficient-memory';
|
|
382
|
+
case 'ENOSPC':
|
|
383
|
+
return 'insufficient-space';
|
|
384
|
+
case 'ENOTDIR':
|
|
385
|
+
case 'ERR_FS_EISDIR':
|
|
386
|
+
return 'not-directory';
|
|
387
|
+
case 'ENOTEMPTY':
|
|
388
|
+
return 'not-empty';
|
|
389
|
+
case 'ENOTRECOVERABLE':
|
|
390
|
+
return 'not-recoverable';
|
|
391
|
+
case 'ENOTSUP':
|
|
392
|
+
return 'unsupported';
|
|
393
|
+
case 'ENOTTY':
|
|
394
|
+
return 'no-tty';
|
|
395
|
+
// windows gives this error for badly structured `//` reads
|
|
396
|
+
// this seems like a slightly better error than unknown given
|
|
397
|
+
// that it's a common footgun
|
|
398
|
+
case -4094:
|
|
399
|
+
case 'ENXIO':
|
|
400
|
+
return 'no-such-device';
|
|
401
|
+
case 'EOVERFLOW':
|
|
402
|
+
return 'overflow';
|
|
403
|
+
case 'EPERM':
|
|
404
|
+
return 'not-permitted';
|
|
405
|
+
case 'EPIPE':
|
|
406
|
+
return 'pipe';
|
|
407
|
+
case 'EROFS':
|
|
408
|
+
return 'read-only';
|
|
409
|
+
case 'ESPIPE':
|
|
410
|
+
return 'invalid-seek';
|
|
411
|
+
case 'ETXTBSY':
|
|
412
|
+
return 'text-file-busy';
|
|
413
|
+
case 'EXDEV':
|
|
414
|
+
return 'cross-device';
|
|
415
|
+
case 'UNKNOWN':
|
|
416
|
+
switch (e.errno) {
|
|
417
|
+
case -4094:
|
|
418
|
+
return 'no-such-device';
|
|
419
|
+
default:
|
|
420
|
+
throw e;
|
|
421
|
+
}
|
|
422
|
+
default:
|
|
423
|
+
throw e;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
330
427
|
export { types as filesystemTypes };
|
package/lib/browser/http.js
CHANGED
|
@@ -142,4 +142,14 @@ export const types = {
|
|
|
142
142
|
listenToFutureIncomingResponse(_f) {
|
|
143
143
|
console.log('[types] Listen to future incoming response');
|
|
144
144
|
},
|
|
145
|
+
Fields: class Fields {},
|
|
146
|
+
FutureIncomingResponse: new class FutureIncomingResponse {},
|
|
147
|
+
IncomingBody: new class IncomingBody {},
|
|
148
|
+
IncomingRequest: new class IncomingRequest {},
|
|
149
|
+
IncomingResponse: new class IncomingResponse {},
|
|
150
|
+
OutgoingBody: new class OutgoingBody {},
|
|
151
|
+
OutgoingRequest: new class OutgoingRequest {},
|
|
152
|
+
OutgoingResponse: new class OutgoingResponse {},
|
|
153
|
+
RequestOptions: new class RequestOptions {},
|
|
154
|
+
ResponseOutparam: new class ResponseOutparam {},
|
|
145
155
|
};
|
package/lib/browser/io.js
CHANGED
|
@@ -17,7 +17,7 @@ const IoError = class Error {
|
|
|
17
17
|
* blockingRead: (len: BigInt) => Uint8Array,
|
|
18
18
|
* skip?: (len: BigInt) => BigInt,
|
|
19
19
|
* blockingSkip?: (len: BigInt) => BigInt,
|
|
20
|
-
* subscribe: () =>
|
|
20
|
+
* subscribe: () => Pollable,
|
|
21
21
|
* drop?: () => void,
|
|
22
22
|
* }} InputStreamHandler
|
|
23
23
|
*
|
|
@@ -33,7 +33,7 @@ const IoError = class Error {
|
|
|
33
33
|
* splice?: (src: InputStream, len: BigInt) => BigInt,
|
|
34
34
|
* blockingSplice?: (src: InputStream, len: BigInt) => BigInt,
|
|
35
35
|
* forward?: (src: InputStream) => void,
|
|
36
|
-
* subscribe?: () =>
|
|
36
|
+
* subscribe?: () => Pollable,
|
|
37
37
|
* drop?: () => void,
|
|
38
38
|
* }} OutputStreamHandler
|
|
39
39
|
*
|
|
@@ -78,6 +78,7 @@ class InputStream {
|
|
|
78
78
|
}
|
|
79
79
|
subscribe() {
|
|
80
80
|
console.log(`[streams] Subscribe to input stream ${this.id}`);
|
|
81
|
+
return new Pollable();
|
|
81
82
|
}
|
|
82
83
|
[symbolDispose]() {
|
|
83
84
|
if (this.handler.drop) {
|
|
@@ -168,6 +169,7 @@ class OutputStream {
|
|
|
168
169
|
}
|
|
169
170
|
subscribe() {
|
|
170
171
|
console.log(`[streams] Subscribe to output stream ${this.id}`);
|
|
172
|
+
return new Pollable();
|
|
171
173
|
}
|
|
172
174
|
[symbolDispose]() {}
|
|
173
175
|
}
|
|
@@ -190,4 +192,5 @@ export const poll = {
|
|
|
190
192
|
Pollable,
|
|
191
193
|
pollList,
|
|
192
194
|
pollOne,
|
|
195
|
+
poll: pollOne,
|
|
193
196
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/preview2-shim",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.6",
|
|
4
4
|
"description": "WASI Preview2 shim for JS environments",
|
|
5
5
|
"author": "Guy Bedford, Eduardo Rodrigues<16357187+eduardomourar@users.noreply.github.com>",
|
|
6
|
+
"contributors": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Guy Bedford"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Eduardo Rodrigues",
|
|
12
|
+
"email": "16357187+eduardomourar@users.noreply.github.com"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "Victor Adossi",
|
|
16
|
+
"email": "vadossi@cosmonic.com"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/bytecodealliance/jco.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "(Apache-2.0 WITH LLVM-exception)",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/bytecodealliance/jco/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/bytecodealliance/jco#readme",
|
|
6
28
|
"type": "module",
|
|
7
29
|
"types": "./types/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"types",
|
|
32
|
+
"lib"
|
|
33
|
+
],
|
|
8
34
|
"exports": {
|
|
9
35
|
".": {
|
|
10
36
|
"types": "./types/index.d.ts",
|
|
@@ -29,17 +55,10 @@
|
|
|
29
55
|
"lint:fix": "npm run lint -- --fix",
|
|
30
56
|
"test": "vitest run -c test/vitest.ts"
|
|
31
57
|
},
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"url": "git+https://github.com/bytecodealliance/jco.git"
|
|
39
|
-
},
|
|
40
|
-
"license": "(Apache-2.0 WITH LLVM-exception)",
|
|
41
|
-
"bugs": {
|
|
42
|
-
"url": "https://github.com/bytecodealliance/jco/issues"
|
|
43
|
-
},
|
|
44
|
-
"homepage": "https://github.com/bytecodealliance/jco#readme"
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@bytecodealliance/componentize-js": "0.19.3",
|
|
60
|
+
"@bytecodealliance/jco": "1.15.2",
|
|
61
|
+
"mime": "^4.0.7",
|
|
62
|
+
"puppeteer": "^24.16.2"
|
|
63
|
+
}
|
|
45
64
|
}
|