@tybys/wasm-util 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -193
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/wasm-util.esm-bundler.js +2605 -2482
- package/dist/wasm-util.esm.js +2605 -2482
- package/dist/wasm-util.esm.min.js +1 -1
- package/dist/wasm-util.js +2605 -2482
- package/dist/wasm-util.min.js +1 -1
- package/lib/cjs/asyncify.js +157 -157
- package/lib/cjs/index.js +12 -12
- package/lib/cjs/jspi.js +45 -45
- package/lib/cjs/load.js +85 -85
- package/lib/cjs/memory.js +34 -34
- package/lib/cjs/wasi/error.js +102 -102
- package/lib/cjs/wasi/fd.js +267 -267
- package/lib/cjs/wasi/fs.js +2 -2
- package/lib/cjs/wasi/index.js +168 -168
- package/lib/cjs/wasi/path.js +173 -173
- package/lib/cjs/wasi/preview1.js +1478 -1369
- package/lib/cjs/wasi/rights.js +139 -139
- package/lib/cjs/wasi/types.js +219 -209
- package/lib/cjs/wasi/util.js +121 -67
- package/lib/cjs/webassembly.js +12 -12
- package/lib/mjs/asyncify.mjs +153 -153
- package/lib/mjs/index.mjs +9 -9
- package/lib/mjs/jspi.mjs +39 -39
- package/lib/mjs/load.mjs +78 -78
- package/lib/mjs/memory.mjs +28 -28
- package/lib/mjs/wasi/error.mjs +97 -97
- package/lib/mjs/wasi/fd.mjs +256 -256
- package/lib/mjs/wasi/fs.mjs +1 -1
- package/lib/mjs/wasi/index.mjs +164 -164
- package/lib/mjs/wasi/path.mjs +168 -168
- package/lib/mjs/wasi/preview1.mjs +1474 -1365
- package/lib/mjs/wasi/rights.mjs +134 -134
- package/lib/mjs/wasi/types.mjs +216 -206
- package/lib/mjs/wasi/util.mjs +108 -55
- package/lib/mjs/webassembly.mjs +9 -9
- package/package.json +58 -57
- package/lib/cjs/memfs.js +0 -2689
- package/lib/mjs/memfs.mjs +0 -2688
package/lib/cjs/jspi.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapExports = exports.wrapAsyncExport = exports.wrapAsyncImport = void 0;
|
|
4
|
-
const util_1 = require("./wasi/util");
|
|
5
|
-
const webassembly_1 = require("./webassembly");
|
|
6
|
-
function checkWebAssemblyFunction() {
|
|
7
|
-
const WebAssemblyFunction = webassembly_1._WebAssembly.Function;
|
|
8
|
-
if (typeof WebAssemblyFunction !== 'function') {
|
|
9
|
-
throw new Error('WebAssembly.Function is not supported in this environment.' +
|
|
10
|
-
' If you are using V8 based browser like Chrome, try to specify' +
|
|
11
|
-
' --js-flag="--wasm-staging --experimental-wasm-stack-switching"');
|
|
12
|
-
}
|
|
13
|
-
return WebAssemblyFunction;
|
|
14
|
-
}
|
|
15
|
-
/** @public */
|
|
16
|
-
function wrapAsyncImport(f, parameterType, returnType) {
|
|
17
|
-
const WebAssemblyFunction = checkWebAssemblyFunction();
|
|
18
|
-
if (typeof f !== 'function') {
|
|
19
|
-
throw new TypeError('Function required');
|
|
20
|
-
}
|
|
21
|
-
const parameters = parameterType.slice(0);
|
|
22
|
-
parameters.unshift('externref');
|
|
23
|
-
return new WebAssemblyFunction({ parameters, results: returnType }, f, { suspending: 'first' });
|
|
24
|
-
}
|
|
25
|
-
exports.wrapAsyncImport = wrapAsyncImport;
|
|
26
|
-
/** @public */
|
|
27
|
-
function wrapAsyncExport(f) {
|
|
28
|
-
const WebAssemblyFunction = checkWebAssemblyFunction();
|
|
29
|
-
if (typeof f !== 'function') {
|
|
30
|
-
throw new TypeError('Function required');
|
|
31
|
-
}
|
|
32
|
-
return new WebAssemblyFunction({ parameters: [...WebAssemblyFunction.type(f).parameters.slice(1)], results: ['externref'] }, f, { promising: 'first' });
|
|
33
|
-
}
|
|
34
|
-
exports.wrapAsyncExport = wrapAsyncExport;
|
|
35
|
-
/** @public */
|
|
36
|
-
function wrapExports(exports, needWrap) {
|
|
37
|
-
return (0, util_1.wrapInstanceExports)(exports, (exportValue, name) => {
|
|
38
|
-
let ignore = typeof exportValue !== 'function';
|
|
39
|
-
if (Array.isArray(needWrap)) {
|
|
40
|
-
ignore = ignore || (needWrap.indexOf(name) === -1);
|
|
41
|
-
}
|
|
42
|
-
return ignore ? exportValue : wrapAsyncExport(exportValue);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.wrapExports = wrapExports;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapExports = exports.wrapAsyncExport = exports.wrapAsyncImport = void 0;
|
|
4
|
+
const util_1 = require("./wasi/util");
|
|
5
|
+
const webassembly_1 = require("./webassembly");
|
|
6
|
+
function checkWebAssemblyFunction() {
|
|
7
|
+
const WebAssemblyFunction = webassembly_1._WebAssembly.Function;
|
|
8
|
+
if (typeof WebAssemblyFunction !== 'function') {
|
|
9
|
+
throw new Error('WebAssembly.Function is not supported in this environment.' +
|
|
10
|
+
' If you are using V8 based browser like Chrome, try to specify' +
|
|
11
|
+
' --js-flag="--wasm-staging --experimental-wasm-stack-switching"');
|
|
12
|
+
}
|
|
13
|
+
return WebAssemblyFunction;
|
|
14
|
+
}
|
|
15
|
+
/** @public */
|
|
16
|
+
function wrapAsyncImport(f, parameterType, returnType) {
|
|
17
|
+
const WebAssemblyFunction = checkWebAssemblyFunction();
|
|
18
|
+
if (typeof f !== 'function') {
|
|
19
|
+
throw new TypeError('Function required');
|
|
20
|
+
}
|
|
21
|
+
const parameters = parameterType.slice(0);
|
|
22
|
+
parameters.unshift('externref');
|
|
23
|
+
return new WebAssemblyFunction({ parameters, results: returnType }, f, { suspending: 'first' });
|
|
24
|
+
}
|
|
25
|
+
exports.wrapAsyncImport = wrapAsyncImport;
|
|
26
|
+
/** @public */
|
|
27
|
+
function wrapAsyncExport(f) {
|
|
28
|
+
const WebAssemblyFunction = checkWebAssemblyFunction();
|
|
29
|
+
if (typeof f !== 'function') {
|
|
30
|
+
throw new TypeError('Function required');
|
|
31
|
+
}
|
|
32
|
+
return new WebAssemblyFunction({ parameters: [...WebAssemblyFunction.type(f).parameters.slice(1)], results: ['externref'] }, f, { promising: 'first' });
|
|
33
|
+
}
|
|
34
|
+
exports.wrapAsyncExport = wrapAsyncExport;
|
|
35
|
+
/** @public */
|
|
36
|
+
function wrapExports(exports, needWrap) {
|
|
37
|
+
return (0, util_1.wrapInstanceExports)(exports, (exportValue, name) => {
|
|
38
|
+
let ignore = typeof exportValue !== 'function';
|
|
39
|
+
if (Array.isArray(needWrap)) {
|
|
40
|
+
ignore = ignore || (needWrap.indexOf(name) === -1);
|
|
41
|
+
}
|
|
42
|
+
return ignore ? exportValue : wrapAsyncExport(exportValue);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.wrapExports = wrapExports;
|
|
46
46
|
//# sourceMappingURL=jspi.js.map
|
package/lib/cjs/load.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asyncifyLoadSync = exports.loadSync = exports.asyncifyLoad = exports.load = void 0;
|
|
4
|
-
const webassembly_1 = require("./webassembly");
|
|
5
|
-
const asyncify_1 = require("./asyncify");
|
|
6
|
-
function validateImports(imports) {
|
|
7
|
-
if (imports && typeof imports !== 'object') {
|
|
8
|
-
throw new TypeError('imports must be an object or undefined');
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function fetchWasm(urlOrBuffer, imports) {
|
|
12
|
-
if (typeof wx !== 'undefined' && typeof __wxConfig !== 'undefined') {
|
|
13
|
-
return webassembly_1._WebAssembly.instantiate(urlOrBuffer, imports);
|
|
14
|
-
}
|
|
15
|
-
return fetch(urlOrBuffer)
|
|
16
|
-
.then(response => response.arrayBuffer())
|
|
17
|
-
.then(buffer => webassembly_1._WebAssembly.instantiate(buffer, imports));
|
|
18
|
-
}
|
|
19
|
-
/** @public */
|
|
20
|
-
function load(urlOrBuffer, imports) {
|
|
21
|
-
validateImports(imports);
|
|
22
|
-
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
23
|
-
let source;
|
|
24
|
-
if (urlOrBuffer instanceof ArrayBuffer || ArrayBuffer.isView(urlOrBuffer)) {
|
|
25
|
-
return webassembly_1._WebAssembly.instantiate(urlOrBuffer, imports);
|
|
26
|
-
}
|
|
27
|
-
if (typeof urlOrBuffer !== 'string' && !(urlOrBuffer instanceof URL)) {
|
|
28
|
-
throw new TypeError('Invalid source');
|
|
29
|
-
}
|
|
30
|
-
if (typeof webassembly_1._WebAssembly.instantiateStreaming === 'function') {
|
|
31
|
-
let responsePromise;
|
|
32
|
-
try {
|
|
33
|
-
responsePromise = fetch(urlOrBuffer);
|
|
34
|
-
source = webassembly_1._WebAssembly.instantiateStreaming(responsePromise, imports).catch(() => {
|
|
35
|
-
return fetchWasm(urlOrBuffer, imports);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
catch (_) {
|
|
39
|
-
source = fetchWasm(urlOrBuffer, imports);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
source = fetchWasm(urlOrBuffer, imports);
|
|
44
|
-
}
|
|
45
|
-
return source;
|
|
46
|
-
}
|
|
47
|
-
exports.load = load;
|
|
48
|
-
/** @public */
|
|
49
|
-
function asyncifyLoad(asyncify, urlOrBuffer, imports) {
|
|
50
|
-
validateImports(imports);
|
|
51
|
-
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
52
|
-
const asyncifyHelper = new asyncify_1.Asyncify();
|
|
53
|
-
imports = asyncifyHelper.wrapImports(imports);
|
|
54
|
-
return load(urlOrBuffer, imports).then(source => {
|
|
55
|
-
var _a;
|
|
56
|
-
const memory = source.instance.exports.memory || ((_a = imports.env) === null || _a === void 0 ? void 0 : _a.memory);
|
|
57
|
-
return { module: source.module, instance: asyncifyHelper.init(memory, source.instance, asyncify) };
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
exports.asyncifyLoad = asyncifyLoad;
|
|
61
|
-
/** @public */
|
|
62
|
-
function loadSync(buffer, imports) {
|
|
63
|
-
if ((buffer instanceof ArrayBuffer) && !ArrayBuffer.isView(buffer)) {
|
|
64
|
-
throw new TypeError('Invalid source');
|
|
65
|
-
}
|
|
66
|
-
validateImports(imports);
|
|
67
|
-
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
68
|
-
const module = new webassembly_1._WebAssembly.Module(buffer);
|
|
69
|
-
const instance = new webassembly_1._WebAssembly.Instance(module, imports);
|
|
70
|
-
const source = { instance, module };
|
|
71
|
-
return source;
|
|
72
|
-
}
|
|
73
|
-
exports.loadSync = loadSync;
|
|
74
|
-
/** @public */
|
|
75
|
-
function asyncifyLoadSync(asyncify, buffer, imports) {
|
|
76
|
-
var _a;
|
|
77
|
-
validateImports(imports);
|
|
78
|
-
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
79
|
-
const asyncifyHelper = new asyncify_1.Asyncify();
|
|
80
|
-
imports = asyncifyHelper.wrapImports(imports);
|
|
81
|
-
const source = loadSync(buffer, imports);
|
|
82
|
-
const memory = source.instance.exports.memory || ((_a = imports.env) === null || _a === void 0 ? void 0 : _a.memory);
|
|
83
|
-
return { module: source.module, instance: asyncifyHelper.init(memory, source.instance, asyncify) };
|
|
84
|
-
}
|
|
85
|
-
exports.asyncifyLoadSync = asyncifyLoadSync;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncifyLoadSync = exports.loadSync = exports.asyncifyLoad = exports.load = void 0;
|
|
4
|
+
const webassembly_1 = require("./webassembly");
|
|
5
|
+
const asyncify_1 = require("./asyncify");
|
|
6
|
+
function validateImports(imports) {
|
|
7
|
+
if (imports && typeof imports !== 'object') {
|
|
8
|
+
throw new TypeError('imports must be an object or undefined');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function fetchWasm(urlOrBuffer, imports) {
|
|
12
|
+
if (typeof wx !== 'undefined' && typeof __wxConfig !== 'undefined') {
|
|
13
|
+
return webassembly_1._WebAssembly.instantiate(urlOrBuffer, imports);
|
|
14
|
+
}
|
|
15
|
+
return fetch(urlOrBuffer)
|
|
16
|
+
.then(response => response.arrayBuffer())
|
|
17
|
+
.then(buffer => webassembly_1._WebAssembly.instantiate(buffer, imports));
|
|
18
|
+
}
|
|
19
|
+
/** @public */
|
|
20
|
+
function load(urlOrBuffer, imports) {
|
|
21
|
+
validateImports(imports);
|
|
22
|
+
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
23
|
+
let source;
|
|
24
|
+
if (urlOrBuffer instanceof ArrayBuffer || ArrayBuffer.isView(urlOrBuffer)) {
|
|
25
|
+
return webassembly_1._WebAssembly.instantiate(urlOrBuffer, imports);
|
|
26
|
+
}
|
|
27
|
+
if (typeof urlOrBuffer !== 'string' && !(urlOrBuffer instanceof URL)) {
|
|
28
|
+
throw new TypeError('Invalid source');
|
|
29
|
+
}
|
|
30
|
+
if (typeof webassembly_1._WebAssembly.instantiateStreaming === 'function') {
|
|
31
|
+
let responsePromise;
|
|
32
|
+
try {
|
|
33
|
+
responsePromise = fetch(urlOrBuffer);
|
|
34
|
+
source = webassembly_1._WebAssembly.instantiateStreaming(responsePromise, imports).catch(() => {
|
|
35
|
+
return fetchWasm(urlOrBuffer, imports);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (_) {
|
|
39
|
+
source = fetchWasm(urlOrBuffer, imports);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
source = fetchWasm(urlOrBuffer, imports);
|
|
44
|
+
}
|
|
45
|
+
return source;
|
|
46
|
+
}
|
|
47
|
+
exports.load = load;
|
|
48
|
+
/** @public */
|
|
49
|
+
function asyncifyLoad(asyncify, urlOrBuffer, imports) {
|
|
50
|
+
validateImports(imports);
|
|
51
|
+
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
52
|
+
const asyncifyHelper = new asyncify_1.Asyncify();
|
|
53
|
+
imports = asyncifyHelper.wrapImports(imports);
|
|
54
|
+
return load(urlOrBuffer, imports).then(source => {
|
|
55
|
+
var _a;
|
|
56
|
+
const memory = source.instance.exports.memory || ((_a = imports.env) === null || _a === void 0 ? void 0 : _a.memory);
|
|
57
|
+
return { module: source.module, instance: asyncifyHelper.init(memory, source.instance, asyncify) };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.asyncifyLoad = asyncifyLoad;
|
|
61
|
+
/** @public */
|
|
62
|
+
function loadSync(buffer, imports) {
|
|
63
|
+
if ((buffer instanceof ArrayBuffer) && !ArrayBuffer.isView(buffer)) {
|
|
64
|
+
throw new TypeError('Invalid source');
|
|
65
|
+
}
|
|
66
|
+
validateImports(imports);
|
|
67
|
+
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
68
|
+
const module = new webassembly_1._WebAssembly.Module(buffer);
|
|
69
|
+
const instance = new webassembly_1._WebAssembly.Instance(module, imports);
|
|
70
|
+
const source = { instance, module };
|
|
71
|
+
return source;
|
|
72
|
+
}
|
|
73
|
+
exports.loadSync = loadSync;
|
|
74
|
+
/** @public */
|
|
75
|
+
function asyncifyLoadSync(asyncify, buffer, imports) {
|
|
76
|
+
var _a;
|
|
77
|
+
validateImports(imports);
|
|
78
|
+
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
79
|
+
const asyncifyHelper = new asyncify_1.Asyncify();
|
|
80
|
+
imports = asyncifyHelper.wrapImports(imports);
|
|
81
|
+
const source = loadSync(buffer, imports);
|
|
82
|
+
const memory = source.instance.exports.memory || ((_a = imports.env) === null || _a === void 0 ? void 0 : _a.memory);
|
|
83
|
+
return { module: source.module, instance: asyncifyHelper.init(memory, source.instance, asyncify) };
|
|
84
|
+
}
|
|
85
|
+
exports.asyncifyLoadSync = asyncifyLoadSync;
|
|
86
86
|
//# sourceMappingURL=load.js.map
|
package/lib/cjs/memory.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extendMemory = exports.Memory = exports.WebAssemblyMemory = void 0;
|
|
4
|
-
/* eslint-disable spaced-comment */
|
|
5
|
-
const webassembly_1 = require("./webassembly");
|
|
6
|
-
/** @public */
|
|
7
|
-
exports.WebAssemblyMemory = (function () { return webassembly_1._WebAssembly.Memory; })();
|
|
8
|
-
/** @public */
|
|
9
|
-
class Memory extends exports.WebAssemblyMemory {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
11
|
-
constructor(descriptor) {
|
|
12
|
-
super(descriptor);
|
|
13
|
-
}
|
|
14
|
-
get HEAP8() { return new Int8Array(super.buffer); }
|
|
15
|
-
get HEAPU8() { return new Uint8Array(super.buffer); }
|
|
16
|
-
get HEAP16() { return new Int16Array(super.buffer); }
|
|
17
|
-
get HEAPU16() { return new Uint16Array(super.buffer); }
|
|
18
|
-
get HEAP32() { return new Int32Array(super.buffer); }
|
|
19
|
-
get HEAPU32() { return new Uint32Array(super.buffer); }
|
|
20
|
-
get HEAP64() { return new BigInt64Array(super.buffer); }
|
|
21
|
-
get HEAPU64() { return new BigUint64Array(super.buffer); }
|
|
22
|
-
get HEAPF32() { return new Float32Array(super.buffer); }
|
|
23
|
-
get HEAPF64() { return new Float64Array(super.buffer); }
|
|
24
|
-
get view() { return new DataView(super.buffer); }
|
|
25
|
-
}
|
|
26
|
-
exports.Memory = Memory;
|
|
27
|
-
/** @public */
|
|
28
|
-
function extendMemory(memory) {
|
|
29
|
-
if (Object.getPrototypeOf(memory) === webassembly_1._WebAssembly.Memory.prototype) {
|
|
30
|
-
Object.setPrototypeOf(memory, Memory.prototype);
|
|
31
|
-
}
|
|
32
|
-
return memory;
|
|
33
|
-
}
|
|
34
|
-
exports.extendMemory = extendMemory;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extendMemory = exports.Memory = exports.WebAssemblyMemory = void 0;
|
|
4
|
+
/* eslint-disable spaced-comment */
|
|
5
|
+
const webassembly_1 = require("./webassembly");
|
|
6
|
+
/** @public */
|
|
7
|
+
exports.WebAssemblyMemory = (function () { return webassembly_1._WebAssembly.Memory; })();
|
|
8
|
+
/** @public */
|
|
9
|
+
class Memory extends exports.WebAssemblyMemory {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
11
|
+
constructor(descriptor) {
|
|
12
|
+
super(descriptor);
|
|
13
|
+
}
|
|
14
|
+
get HEAP8() { return new Int8Array(super.buffer); }
|
|
15
|
+
get HEAPU8() { return new Uint8Array(super.buffer); }
|
|
16
|
+
get HEAP16() { return new Int16Array(super.buffer); }
|
|
17
|
+
get HEAPU16() { return new Uint16Array(super.buffer); }
|
|
18
|
+
get HEAP32() { return new Int32Array(super.buffer); }
|
|
19
|
+
get HEAPU32() { return new Uint32Array(super.buffer); }
|
|
20
|
+
get HEAP64() { return new BigInt64Array(super.buffer); }
|
|
21
|
+
get HEAPU64() { return new BigUint64Array(super.buffer); }
|
|
22
|
+
get HEAPF32() { return new Float32Array(super.buffer); }
|
|
23
|
+
get HEAPF64() { return new Float64Array(super.buffer); }
|
|
24
|
+
get view() { return new DataView(super.buffer); }
|
|
25
|
+
}
|
|
26
|
+
exports.Memory = Memory;
|
|
27
|
+
/** @public */
|
|
28
|
+
function extendMemory(memory) {
|
|
29
|
+
if (Object.getPrototypeOf(memory) === webassembly_1._WebAssembly.Memory.prototype) {
|
|
30
|
+
Object.setPrototypeOf(memory, Memory.prototype);
|
|
31
|
+
}
|
|
32
|
+
return memory;
|
|
33
|
+
}
|
|
34
|
+
exports.extendMemory = extendMemory;
|
|
35
35
|
//# sourceMappingURL=memory.js.map
|
package/lib/cjs/wasi/error.js
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WasiError = exports.strerror = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
function strerror(errno) {
|
|
6
|
-
switch (errno) {
|
|
7
|
-
case types_1.WasiErrno.ESUCCESS: return 'Success';
|
|
8
|
-
case types_1.WasiErrno.E2BIG: return 'Argument list too long';
|
|
9
|
-
case types_1.WasiErrno.EACCES: return 'Permission denied';
|
|
10
|
-
case types_1.WasiErrno.EADDRINUSE: return 'Address in use';
|
|
11
|
-
case types_1.WasiErrno.EADDRNOTAVAIL: return 'Address not available';
|
|
12
|
-
case types_1.WasiErrno.EAFNOSUPPORT: return 'Address family not supported by protocol';
|
|
13
|
-
case types_1.WasiErrno.EAGAIN: return 'Resource temporarily unavailable';
|
|
14
|
-
case types_1.WasiErrno.EALREADY: return 'Operation already in progress';
|
|
15
|
-
case types_1.WasiErrno.EBADF: return 'Bad file descriptor';
|
|
16
|
-
case types_1.WasiErrno.EBADMSG: return 'Bad message';
|
|
17
|
-
case types_1.WasiErrno.EBUSY: return 'Resource busy';
|
|
18
|
-
case types_1.WasiErrno.ECANCELED: return 'Operation canceled';
|
|
19
|
-
case types_1.WasiErrno.ECHILD: return 'No child process';
|
|
20
|
-
case types_1.WasiErrno.ECONNABORTED: return 'Connection aborted';
|
|
21
|
-
case types_1.WasiErrno.ECONNREFUSED: return 'Connection refused';
|
|
22
|
-
case types_1.WasiErrno.ECONNRESET: return 'Connection reset by peer';
|
|
23
|
-
case types_1.WasiErrno.EDEADLK: return 'Resource deadlock would occur';
|
|
24
|
-
case types_1.WasiErrno.EDESTADDRREQ: return 'Destination address required';
|
|
25
|
-
case types_1.WasiErrno.EDOM: return 'Domain error';
|
|
26
|
-
case types_1.WasiErrno.EDQUOT: return 'Quota exceeded';
|
|
27
|
-
case types_1.WasiErrno.EEXIST: return 'File exists';
|
|
28
|
-
case types_1.WasiErrno.EFAULT: return 'Bad address';
|
|
29
|
-
case types_1.WasiErrno.EFBIG: return 'File too large';
|
|
30
|
-
case types_1.WasiErrno.EHOSTUNREACH: return 'Host is unreachable';
|
|
31
|
-
case types_1.WasiErrno.EIDRM: return 'Identifier removed';
|
|
32
|
-
case types_1.WasiErrno.EILSEQ: return 'Illegal byte sequence';
|
|
33
|
-
case types_1.WasiErrno.EINPROGRESS: return 'Operation in progress';
|
|
34
|
-
case types_1.WasiErrno.EINTR: return 'Interrupted system call';
|
|
35
|
-
case types_1.WasiErrno.EINVAL: return 'Invalid argument';
|
|
36
|
-
case types_1.WasiErrno.EIO: return 'I/O error';
|
|
37
|
-
case types_1.WasiErrno.EISCONN: return 'Socket is connected';
|
|
38
|
-
case types_1.WasiErrno.EISDIR: return 'Is a directory';
|
|
39
|
-
case types_1.WasiErrno.ELOOP: return 'Symbolic link loop';
|
|
40
|
-
case types_1.WasiErrno.EMFILE: return 'No file descriptors available';
|
|
41
|
-
case types_1.WasiErrno.EMLINK: return 'Too many links';
|
|
42
|
-
case types_1.WasiErrno.EMSGSIZE: return 'Message too large';
|
|
43
|
-
case types_1.WasiErrno.EMULTIHOP: return 'Multihop attempted';
|
|
44
|
-
case types_1.WasiErrno.ENAMETOOLONG: return 'Filename too long';
|
|
45
|
-
case types_1.WasiErrno.ENETDOWN: return 'Network is down';
|
|
46
|
-
case types_1.WasiErrno.ENETRESET: return 'Connection reset by network';
|
|
47
|
-
case types_1.WasiErrno.ENETUNREACH: return 'Network unreachable';
|
|
48
|
-
case types_1.WasiErrno.ENFILE: return 'Too many files open in system';
|
|
49
|
-
case types_1.WasiErrno.ENOBUFS: return 'No buffer space available';
|
|
50
|
-
case types_1.WasiErrno.ENODEV: return 'No such device';
|
|
51
|
-
case types_1.WasiErrno.ENOENT: return 'No such file or directory';
|
|
52
|
-
case types_1.WasiErrno.ENOEXEC: return 'Exec format error';
|
|
53
|
-
case types_1.WasiErrno.ENOLCK: return 'No locks available';
|
|
54
|
-
case types_1.WasiErrno.ENOLINK: return 'Link has been severed';
|
|
55
|
-
case types_1.WasiErrno.ENOMEM: return 'Out of memory';
|
|
56
|
-
case types_1.WasiErrno.ENOMSG: return 'No message of the desired type';
|
|
57
|
-
case types_1.WasiErrno.ENOPROTOOPT: return 'Protocol not available';
|
|
58
|
-
case types_1.WasiErrno.ENOSPC: return 'No space left on device';
|
|
59
|
-
case types_1.WasiErrno.ENOSYS: return 'Function not implemented';
|
|
60
|
-
case types_1.WasiErrno.ENOTCONN: return 'Socket not connected';
|
|
61
|
-
case types_1.WasiErrno.ENOTDIR: return 'Not a directory';
|
|
62
|
-
case types_1.WasiErrno.ENOTEMPTY: return 'Directory not empty';
|
|
63
|
-
case types_1.WasiErrno.ENOTRECOVERABLE: return 'State not recoverable';
|
|
64
|
-
case types_1.WasiErrno.ENOTSOCK: return 'Not a socket';
|
|
65
|
-
case types_1.WasiErrno.ENOTSUP: return 'Not supported';
|
|
66
|
-
case types_1.WasiErrno.ENOTTY: return 'Not a tty';
|
|
67
|
-
case types_1.WasiErrno.ENXIO: return 'No such device or address';
|
|
68
|
-
case types_1.WasiErrno.EOVERFLOW: return 'Value too large for data type';
|
|
69
|
-
case types_1.WasiErrno.EOWNERDEAD: return 'Previous owner died';
|
|
70
|
-
case types_1.WasiErrno.EPERM: return 'Operation not permitted';
|
|
71
|
-
case types_1.WasiErrno.EPIPE: return 'Broken pipe';
|
|
72
|
-
case types_1.WasiErrno.EPROTO: return 'Protocol error';
|
|
73
|
-
case types_1.WasiErrno.EPROTONOSUPPORT: return 'Protocol not supported';
|
|
74
|
-
case types_1.WasiErrno.EPROTOTYPE: return 'Protocol wrong type for socket';
|
|
75
|
-
case types_1.WasiErrno.ERANGE: return 'Result not representable';
|
|
76
|
-
case types_1.WasiErrno.EROFS: return 'Read-only file system';
|
|
77
|
-
case types_1.WasiErrno.ESPIPE: return 'Invalid seek';
|
|
78
|
-
case types_1.WasiErrno.ESRCH: return 'No such process';
|
|
79
|
-
case types_1.WasiErrno.ESTALE: return 'Stale file handle';
|
|
80
|
-
case types_1.WasiErrno.ETIMEDOUT: return 'Operation timed out';
|
|
81
|
-
case types_1.WasiErrno.ETXTBSY: return 'Text file busy';
|
|
82
|
-
case types_1.WasiErrno.EXDEV: return 'Cross-device link';
|
|
83
|
-
case types_1.WasiErrno.ENOTCAPABLE: return 'Capabilities insufficient';
|
|
84
|
-
default: return 'Unknown error';
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.strerror = strerror;
|
|
88
|
-
class WasiError extends Error {
|
|
89
|
-
constructor(message, errno) {
|
|
90
|
-
super(message);
|
|
91
|
-
this.errno = errno;
|
|
92
|
-
}
|
|
93
|
-
getErrorMessage() {
|
|
94
|
-
return strerror(this.errno);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.WasiError = WasiError;
|
|
98
|
-
Object.defineProperty(WasiError.prototype, 'name', {
|
|
99
|
-
configurable: true,
|
|
100
|
-
writable: true,
|
|
101
|
-
value: 'WasiError'
|
|
102
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WasiError = exports.strerror = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
function strerror(errno) {
|
|
6
|
+
switch (errno) {
|
|
7
|
+
case types_1.WasiErrno.ESUCCESS: return 'Success';
|
|
8
|
+
case types_1.WasiErrno.E2BIG: return 'Argument list too long';
|
|
9
|
+
case types_1.WasiErrno.EACCES: return 'Permission denied';
|
|
10
|
+
case types_1.WasiErrno.EADDRINUSE: return 'Address in use';
|
|
11
|
+
case types_1.WasiErrno.EADDRNOTAVAIL: return 'Address not available';
|
|
12
|
+
case types_1.WasiErrno.EAFNOSUPPORT: return 'Address family not supported by protocol';
|
|
13
|
+
case types_1.WasiErrno.EAGAIN: return 'Resource temporarily unavailable';
|
|
14
|
+
case types_1.WasiErrno.EALREADY: return 'Operation already in progress';
|
|
15
|
+
case types_1.WasiErrno.EBADF: return 'Bad file descriptor';
|
|
16
|
+
case types_1.WasiErrno.EBADMSG: return 'Bad message';
|
|
17
|
+
case types_1.WasiErrno.EBUSY: return 'Resource busy';
|
|
18
|
+
case types_1.WasiErrno.ECANCELED: return 'Operation canceled';
|
|
19
|
+
case types_1.WasiErrno.ECHILD: return 'No child process';
|
|
20
|
+
case types_1.WasiErrno.ECONNABORTED: return 'Connection aborted';
|
|
21
|
+
case types_1.WasiErrno.ECONNREFUSED: return 'Connection refused';
|
|
22
|
+
case types_1.WasiErrno.ECONNRESET: return 'Connection reset by peer';
|
|
23
|
+
case types_1.WasiErrno.EDEADLK: return 'Resource deadlock would occur';
|
|
24
|
+
case types_1.WasiErrno.EDESTADDRREQ: return 'Destination address required';
|
|
25
|
+
case types_1.WasiErrno.EDOM: return 'Domain error';
|
|
26
|
+
case types_1.WasiErrno.EDQUOT: return 'Quota exceeded';
|
|
27
|
+
case types_1.WasiErrno.EEXIST: return 'File exists';
|
|
28
|
+
case types_1.WasiErrno.EFAULT: return 'Bad address';
|
|
29
|
+
case types_1.WasiErrno.EFBIG: return 'File too large';
|
|
30
|
+
case types_1.WasiErrno.EHOSTUNREACH: return 'Host is unreachable';
|
|
31
|
+
case types_1.WasiErrno.EIDRM: return 'Identifier removed';
|
|
32
|
+
case types_1.WasiErrno.EILSEQ: return 'Illegal byte sequence';
|
|
33
|
+
case types_1.WasiErrno.EINPROGRESS: return 'Operation in progress';
|
|
34
|
+
case types_1.WasiErrno.EINTR: return 'Interrupted system call';
|
|
35
|
+
case types_1.WasiErrno.EINVAL: return 'Invalid argument';
|
|
36
|
+
case types_1.WasiErrno.EIO: return 'I/O error';
|
|
37
|
+
case types_1.WasiErrno.EISCONN: return 'Socket is connected';
|
|
38
|
+
case types_1.WasiErrno.EISDIR: return 'Is a directory';
|
|
39
|
+
case types_1.WasiErrno.ELOOP: return 'Symbolic link loop';
|
|
40
|
+
case types_1.WasiErrno.EMFILE: return 'No file descriptors available';
|
|
41
|
+
case types_1.WasiErrno.EMLINK: return 'Too many links';
|
|
42
|
+
case types_1.WasiErrno.EMSGSIZE: return 'Message too large';
|
|
43
|
+
case types_1.WasiErrno.EMULTIHOP: return 'Multihop attempted';
|
|
44
|
+
case types_1.WasiErrno.ENAMETOOLONG: return 'Filename too long';
|
|
45
|
+
case types_1.WasiErrno.ENETDOWN: return 'Network is down';
|
|
46
|
+
case types_1.WasiErrno.ENETRESET: return 'Connection reset by network';
|
|
47
|
+
case types_1.WasiErrno.ENETUNREACH: return 'Network unreachable';
|
|
48
|
+
case types_1.WasiErrno.ENFILE: return 'Too many files open in system';
|
|
49
|
+
case types_1.WasiErrno.ENOBUFS: return 'No buffer space available';
|
|
50
|
+
case types_1.WasiErrno.ENODEV: return 'No such device';
|
|
51
|
+
case types_1.WasiErrno.ENOENT: return 'No such file or directory';
|
|
52
|
+
case types_1.WasiErrno.ENOEXEC: return 'Exec format error';
|
|
53
|
+
case types_1.WasiErrno.ENOLCK: return 'No locks available';
|
|
54
|
+
case types_1.WasiErrno.ENOLINK: return 'Link has been severed';
|
|
55
|
+
case types_1.WasiErrno.ENOMEM: return 'Out of memory';
|
|
56
|
+
case types_1.WasiErrno.ENOMSG: return 'No message of the desired type';
|
|
57
|
+
case types_1.WasiErrno.ENOPROTOOPT: return 'Protocol not available';
|
|
58
|
+
case types_1.WasiErrno.ENOSPC: return 'No space left on device';
|
|
59
|
+
case types_1.WasiErrno.ENOSYS: return 'Function not implemented';
|
|
60
|
+
case types_1.WasiErrno.ENOTCONN: return 'Socket not connected';
|
|
61
|
+
case types_1.WasiErrno.ENOTDIR: return 'Not a directory';
|
|
62
|
+
case types_1.WasiErrno.ENOTEMPTY: return 'Directory not empty';
|
|
63
|
+
case types_1.WasiErrno.ENOTRECOVERABLE: return 'State not recoverable';
|
|
64
|
+
case types_1.WasiErrno.ENOTSOCK: return 'Not a socket';
|
|
65
|
+
case types_1.WasiErrno.ENOTSUP: return 'Not supported';
|
|
66
|
+
case types_1.WasiErrno.ENOTTY: return 'Not a tty';
|
|
67
|
+
case types_1.WasiErrno.ENXIO: return 'No such device or address';
|
|
68
|
+
case types_1.WasiErrno.EOVERFLOW: return 'Value too large for data type';
|
|
69
|
+
case types_1.WasiErrno.EOWNERDEAD: return 'Previous owner died';
|
|
70
|
+
case types_1.WasiErrno.EPERM: return 'Operation not permitted';
|
|
71
|
+
case types_1.WasiErrno.EPIPE: return 'Broken pipe';
|
|
72
|
+
case types_1.WasiErrno.EPROTO: return 'Protocol error';
|
|
73
|
+
case types_1.WasiErrno.EPROTONOSUPPORT: return 'Protocol not supported';
|
|
74
|
+
case types_1.WasiErrno.EPROTOTYPE: return 'Protocol wrong type for socket';
|
|
75
|
+
case types_1.WasiErrno.ERANGE: return 'Result not representable';
|
|
76
|
+
case types_1.WasiErrno.EROFS: return 'Read-only file system';
|
|
77
|
+
case types_1.WasiErrno.ESPIPE: return 'Invalid seek';
|
|
78
|
+
case types_1.WasiErrno.ESRCH: return 'No such process';
|
|
79
|
+
case types_1.WasiErrno.ESTALE: return 'Stale file handle';
|
|
80
|
+
case types_1.WasiErrno.ETIMEDOUT: return 'Operation timed out';
|
|
81
|
+
case types_1.WasiErrno.ETXTBSY: return 'Text file busy';
|
|
82
|
+
case types_1.WasiErrno.EXDEV: return 'Cross-device link';
|
|
83
|
+
case types_1.WasiErrno.ENOTCAPABLE: return 'Capabilities insufficient';
|
|
84
|
+
default: return 'Unknown error';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.strerror = strerror;
|
|
88
|
+
class WasiError extends Error {
|
|
89
|
+
constructor(message, errno) {
|
|
90
|
+
super(message);
|
|
91
|
+
this.errno = errno;
|
|
92
|
+
}
|
|
93
|
+
getErrorMessage() {
|
|
94
|
+
return strerror(this.errno);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.WasiError = WasiError;
|
|
98
|
+
Object.defineProperty(WasiError.prototype, 'name', {
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: 'WasiError'
|
|
102
|
+
});
|
|
103
103
|
//# sourceMappingURL=error.js.map
|