@ruby/head-wasm-wasi 2.3.0 → 2.4.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 +3 -332
- package/dist/browser.script.iife.js +774 -2685
- package/dist/browser.script.umd.js +172 -2050
- package/dist/browser.umd.js +170 -2048
- package/dist/cjs/browser.js +4 -0
- package/dist/cjs/browser.script.js +4 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/node.js +4 -0
- package/dist/esm/browser.js +1 -0
- package/dist/esm/browser.script.js +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/node.js +4 -0
- package/dist/esm/package.json +1 -0
- package/dist/index.umd.js +160 -12
- package/dist/ruby+stdlib.wasm +0 -0
- package/dist/ruby.debug+stdlib.wasm +0 -0
- package/dist/ruby.wasm +0 -0
- package/package.json +14 -31
- package/dist/bindgen/rb-abi-guest.d.ts +0 -140
- package/dist/bindgen/rb-js-abi-host.d.ts +0 -53
- package/dist/browser.cjs.js +0 -3248
- package/dist/browser.d.ts +0 -10
- package/dist/browser.esm.js +0 -3243
- package/dist/browser.script.cjs.js +0 -3375
- package/dist/browser.script.d.ts +0 -5
- package/dist/browser.script.esm.js +0 -3373
- package/dist/index.cjs.js +0 -1195
- package/dist/index.d.ts +0 -192
- package/dist/index.esm.js +0 -1190
- package/dist/node.cjs.js +0 -1212
- package/dist/node.d.ts +0 -10
- package/dist/node.esm.js +0 -1210
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/browser" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`require('ruby-head-wasm-wasi/dist/browser');\` with \`require('@ruby/wasm-wasi/dist/browser');\`[0m`);
|
|
3
|
+
|
|
4
|
+
module.exports = require('@ruby/wasm-wasi/dist/browser');
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/browser.script" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`require('ruby-head-wasm-wasi/dist/browser.script');\` with \`require('@ruby/wasm-wasi/dist/browser.script');\`[0m`);
|
|
3
|
+
|
|
4
|
+
module.exports = require('@ruby/wasm-wasi/dist/browser.script');
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/index" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`require('ruby-head-wasm-wasi');\` with \`require('@ruby/wasm-wasi');\`[0m`);
|
|
3
|
+
|
|
4
|
+
module.exports = require('@ruby/wasm-wasi');
|
package/dist/cjs/node.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/node" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`require('ruby-head-wasm-wasi/dist/node');\` with \`require('@ruby/wasm-wasi/dist/node');\`[0m`);
|
|
3
|
+
|
|
4
|
+
module.exports = require('@ruby/wasm-wasi/dist/node');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ruby/wasm-wasi/dist/browser';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/browser.script" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`import * from 'ruby-head-wasm-wasi/dist/browser.script';\` with \`import * from '@ruby/wasm-wasi/dist/browser.script';\`[0m`);
|
|
3
|
+
|
|
4
|
+
export * from '@ruby/wasm-wasi/dist/browser.script';
|
package/dist/esm/node.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/node" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`import * from 'ruby-head-wasm-wasi/dist/node';\` with \`import * from '@ruby/wasm-wasi/dist/node';\`[0m`);
|
|
3
|
+
|
|
4
|
+
export * from '@ruby/wasm-wasi/dist/node';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
package/dist/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "index.umd
|
|
2
|
-
Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd
|
|
1
|
+
console.warn(`[33mDEPRECATED(ruby-head-wasm-wasi): "dist/index.umd" will be moved to "@ruby/wasm-wasi" in the next major release.
|
|
2
|
+
Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd');\` with \`require('@ruby/wasm-wasi/dist/index.umd');\`[0m`);
|
|
3
3
|
|
|
4
4
|
(function (global, factory) {
|
|
5
5
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -604,6 +604,107 @@ Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd.js');\` with \
|
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Create a console printer that can be used as an overlay of WASI imports.
|
|
609
|
+
* See the example below for how to use it.
|
|
610
|
+
*
|
|
611
|
+
* ```javascript
|
|
612
|
+
* const imports = {
|
|
613
|
+
* "wasi_snapshot_preview1": wasi.wasiImport,
|
|
614
|
+
* }
|
|
615
|
+
* const printer = consolePrinter();
|
|
616
|
+
* printer.addToImports(imports);
|
|
617
|
+
*
|
|
618
|
+
* const instance = await WebAssembly.instantiate(module, imports);
|
|
619
|
+
* printer.setMemory(instance.exports.memory);
|
|
620
|
+
* ```
|
|
621
|
+
*
|
|
622
|
+
* Note that the `stdout` and `stderr` functions are called with text, not
|
|
623
|
+
* bytes. This means that bytes written to stdout/stderr will be decoded as
|
|
624
|
+
* UTF-8 and then passed to the `stdout`/`stderr` functions every time a write
|
|
625
|
+
* occurs without buffering.
|
|
626
|
+
*
|
|
627
|
+
* @param stdout A function that will be called when stdout is written to.
|
|
628
|
+
* Defaults to `console.log`.
|
|
629
|
+
* @param stderr A function that will be called when stderr is written to.
|
|
630
|
+
* Defaults to `console.warn`.
|
|
631
|
+
* @returns An object that can be used as an overlay of WASI imports.
|
|
632
|
+
*/
|
|
633
|
+
function consolePrinter({ stdout, stderr, } = {
|
|
634
|
+
stdout: console.log,
|
|
635
|
+
stderr: console.warn,
|
|
636
|
+
}) {
|
|
637
|
+
let memory = undefined;
|
|
638
|
+
let _view = undefined;
|
|
639
|
+
function getMemoryView() {
|
|
640
|
+
if (typeof memory === "undefined") {
|
|
641
|
+
throw new Error("Memory is not set");
|
|
642
|
+
}
|
|
643
|
+
if (_view === undefined || _view.buffer.byteLength === 0) {
|
|
644
|
+
_view = new DataView(memory.buffer);
|
|
645
|
+
}
|
|
646
|
+
return _view;
|
|
647
|
+
}
|
|
648
|
+
const decoder = new TextDecoder();
|
|
649
|
+
return {
|
|
650
|
+
addToImports(imports) {
|
|
651
|
+
const wasiImport = imports.wasi_snapshot_preview1;
|
|
652
|
+
const original_fd_write = wasiImport.fd_write;
|
|
653
|
+
wasiImport.fd_write = (fd, iovs, iovsLen, nwritten) => {
|
|
654
|
+
if (fd !== 1 && fd !== 2) {
|
|
655
|
+
return original_fd_write(fd, iovs, iovsLen, nwritten);
|
|
656
|
+
}
|
|
657
|
+
const view = getMemoryView();
|
|
658
|
+
const buffers = Array.from({ length: iovsLen }, (_, i) => {
|
|
659
|
+
const ptr = iovs + i * 8;
|
|
660
|
+
const buf = view.getUint32(ptr, true);
|
|
661
|
+
const bufLen = view.getUint32(ptr + 4, true);
|
|
662
|
+
return new Uint8Array(memory.buffer, buf, bufLen);
|
|
663
|
+
});
|
|
664
|
+
let written = 0;
|
|
665
|
+
let str = "";
|
|
666
|
+
for (const buffer of buffers) {
|
|
667
|
+
str += decoder.decode(buffer);
|
|
668
|
+
written += buffer.byteLength;
|
|
669
|
+
}
|
|
670
|
+
view.setUint32(nwritten, written, true);
|
|
671
|
+
const log = fd === 1 ? stdout : stderr;
|
|
672
|
+
log(str);
|
|
673
|
+
return 0;
|
|
674
|
+
};
|
|
675
|
+
const original_fd_filestat_get = wasiImport.fd_filestat_get;
|
|
676
|
+
wasiImport.fd_filestat_get = (fd, filestat) => {
|
|
677
|
+
if (fd !== 1 && fd !== 2) {
|
|
678
|
+
return original_fd_filestat_get(fd, filestat);
|
|
679
|
+
}
|
|
680
|
+
const view = getMemoryView();
|
|
681
|
+
const result = original_fd_filestat_get(fd, filestat);
|
|
682
|
+
if (result !== 0) {
|
|
683
|
+
return result;
|
|
684
|
+
}
|
|
685
|
+
const filetypePtr = filestat + 0;
|
|
686
|
+
view.setUint8(filetypePtr, 2); // FILETYPE_CHARACTER_DEVICE
|
|
687
|
+
return 0;
|
|
688
|
+
};
|
|
689
|
+
const original_fd_fdstat_get = wasiImport.fd_fdstat_get;
|
|
690
|
+
wasiImport.fd_fdstat_get = (fd, fdstat) => {
|
|
691
|
+
if (fd !== 1 && fd !== 2) {
|
|
692
|
+
return original_fd_fdstat_get(fd, fdstat);
|
|
693
|
+
}
|
|
694
|
+
const view = getMemoryView();
|
|
695
|
+
const fs_filetypePtr = fdstat + 0;
|
|
696
|
+
view.setUint8(fs_filetypePtr, 2); // FILETYPE_CHARACTER_DEVICE
|
|
697
|
+
const fs_rights_basePtr = fdstat + 8;
|
|
698
|
+
view.setBigUint64(fs_rights_basePtr, BigInt(1)); // RIGHTS_FD_WRITE
|
|
699
|
+
return 0;
|
|
700
|
+
};
|
|
701
|
+
},
|
|
702
|
+
setMemory(m) {
|
|
703
|
+
memory = m;
|
|
704
|
+
},
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
|
|
607
708
|
/**
|
|
608
709
|
* A Ruby VM instance
|
|
609
710
|
*
|
|
@@ -936,12 +1037,14 @@ Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd.js');\` with \
|
|
|
936
1037
|
wrap(value) {
|
|
937
1038
|
return this.transport.importJsValue(value, this);
|
|
938
1039
|
}
|
|
1040
|
+
/** @private */
|
|
939
1041
|
privateObject() {
|
|
940
1042
|
return {
|
|
941
1043
|
transport: this.transport,
|
|
942
1044
|
exceptionFormatter: this.exceptionFormatter,
|
|
943
1045
|
};
|
|
944
1046
|
}
|
|
1047
|
+
/** @private */
|
|
945
1048
|
rbValueOfPointer(pointer) {
|
|
946
1049
|
const abiValue = new RbAbiValue(pointer, this.guest);
|
|
947
1050
|
return new RbValue(abiValue, this, this.privateObject());
|
|
@@ -1066,8 +1169,27 @@ Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd.js');\` with \
|
|
|
1066
1169
|
class RbExceptionFormatter {
|
|
1067
1170
|
constructor() {
|
|
1068
1171
|
this.literalsCache = null;
|
|
1172
|
+
this.isFormmatting = false;
|
|
1069
1173
|
}
|
|
1070
1174
|
format(error, vm, privateObject) {
|
|
1175
|
+
// All Ruby exceptions raised during formatting exception message should
|
|
1176
|
+
// be caught and return a fallback message.
|
|
1177
|
+
// Therefore, we don't need to worry about infinite recursion here ideally
|
|
1178
|
+
// but checking re-entrancy just in case.
|
|
1179
|
+
class RbExceptionFormatterError extends Error {
|
|
1180
|
+
}
|
|
1181
|
+
if (this.isFormmatting) {
|
|
1182
|
+
throw new RbExceptionFormatterError("Unexpected exception occurred during formatting exception message");
|
|
1183
|
+
}
|
|
1184
|
+
this.isFormmatting = true;
|
|
1185
|
+
try {
|
|
1186
|
+
return this._format(error, vm, privateObject);
|
|
1187
|
+
}
|
|
1188
|
+
finally {
|
|
1189
|
+
this.isFormmatting = false;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
_format(error, vm, privateObject) {
|
|
1071
1193
|
const [zeroLiteral, oneLiteral, newLineLiteral] = (() => {
|
|
1072
1194
|
if (this.literalsCache == null) {
|
|
1073
1195
|
const zeroOneNewLine = [
|
|
@@ -1082,18 +1204,43 @@ Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd.js');\` with \
|
|
|
1082
1204
|
return this.literalsCache;
|
|
1083
1205
|
}
|
|
1084
1206
|
})();
|
|
1085
|
-
|
|
1207
|
+
let className;
|
|
1208
|
+
let backtrace;
|
|
1209
|
+
let message;
|
|
1210
|
+
try {
|
|
1211
|
+
className = error.call("class").toString();
|
|
1212
|
+
}
|
|
1213
|
+
catch (e) {
|
|
1214
|
+
className = "unknown";
|
|
1215
|
+
}
|
|
1216
|
+
try {
|
|
1217
|
+
message = error.toString();
|
|
1218
|
+
}
|
|
1219
|
+
catch (e) {
|
|
1220
|
+
message = "unknown";
|
|
1221
|
+
}
|
|
1222
|
+
try {
|
|
1223
|
+
backtrace = error.call("backtrace");
|
|
1224
|
+
}
|
|
1225
|
+
catch (e) {
|
|
1226
|
+
return this.formatString(className, message);
|
|
1227
|
+
}
|
|
1086
1228
|
if (backtrace.call("nil?").toString() === "true") {
|
|
1087
|
-
return this.formatString(
|
|
1229
|
+
return this.formatString(className, message);
|
|
1230
|
+
}
|
|
1231
|
+
try {
|
|
1232
|
+
const firstLine = backtrace.call("at", zeroLiteral);
|
|
1233
|
+
const restLines = backtrace
|
|
1234
|
+
.call("drop", oneLiteral)
|
|
1235
|
+
.call("join", newLineLiteral);
|
|
1236
|
+
return this.formatString(className, message, [
|
|
1237
|
+
firstLine.toString(),
|
|
1238
|
+
restLines.toString(),
|
|
1239
|
+
]);
|
|
1240
|
+
}
|
|
1241
|
+
catch (e) {
|
|
1242
|
+
return this.formatString(className, message);
|
|
1088
1243
|
}
|
|
1089
|
-
const firstLine = backtrace.call("at", zeroLiteral);
|
|
1090
|
-
const restLines = backtrace
|
|
1091
|
-
.call("drop", oneLiteral)
|
|
1092
|
-
.call("join", newLineLiteral);
|
|
1093
|
-
return this.formatString(error.call("class").toString(), error.toString(), [
|
|
1094
|
-
firstLine.toString(),
|
|
1095
|
-
restLines.toString(),
|
|
1096
|
-
]);
|
|
1097
1244
|
}
|
|
1098
1245
|
formatString(klass, message, backtrace) {
|
|
1099
1246
|
if (backtrace) {
|
|
@@ -1197,5 +1344,6 @@ Please replace your \`require('ruby-head-wasm-wasi/dist/index.umd.js');\` with \
|
|
|
1197
1344
|
exports.RbFatalError = RbFatalError;
|
|
1198
1345
|
exports.RbValue = RbValue;
|
|
1199
1346
|
exports.RubyVM = RubyVM;
|
|
1347
|
+
exports.consolePrinter = consolePrinter;
|
|
1200
1348
|
|
|
1201
1349
|
}));
|
package/dist/ruby+stdlib.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/dist/ruby.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,36 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruby/head-wasm-wasi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Ruby head built on WASI",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"
|
|
7
|
-
"module": "./dist/index.esm.js",
|
|
8
|
-
"typings": "./dist/index.d.ts",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
9
7
|
"exports": {
|
|
10
8
|
".": {
|
|
11
|
-
"browser": "./dist/index.
|
|
12
|
-
"umd": "./dist/index.
|
|
13
|
-
"import": "./dist/index.
|
|
14
|
-
"require": "./dist/index.
|
|
15
|
-
"types": "./dist/browser.d.ts"
|
|
9
|
+
"browser": "./dist/esm/index.js",
|
|
10
|
+
"umd": "./dist/umd/index.js",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js"
|
|
16
13
|
},
|
|
17
|
-
"./dist
|
|
18
|
-
"browser": "./dist/
|
|
19
|
-
"umd": "./dist/
|
|
20
|
-
"import": "./dist/
|
|
21
|
-
"require": "./dist/
|
|
22
|
-
"types": "./dist/browser.d.ts"
|
|
23
|
-
},
|
|
24
|
-
"./dist/browser.script": {
|
|
25
|
-
"browser": "./dist/browser.script.esm.js",
|
|
26
|
-
"umd": "./dist/browser.script.umd.js",
|
|
27
|
-
"import": "./dist/browser.script.esm.js",
|
|
28
|
-
"types": "./dist/browser.script.d.ts"
|
|
29
|
-
},
|
|
30
|
-
"./dist/node": {
|
|
31
|
-
"import": "./dist/node.esm.js",
|
|
32
|
-
"require": "./dist/node.cjs.js",
|
|
33
|
-
"types": "./dist/node.d.ts"
|
|
14
|
+
"./dist/*": {
|
|
15
|
+
"browser": "./dist/esm/*.js",
|
|
16
|
+
"umd": "./dist/umd/*.js",
|
|
17
|
+
"import": "./dist/esm/*.js",
|
|
18
|
+
"require": "./dist/cjs/*.js"
|
|
34
19
|
}
|
|
35
20
|
},
|
|
36
21
|
"files": [
|
|
@@ -45,7 +30,7 @@
|
|
|
45
30
|
"build:static": "npm run build:static:files && npm run build:static:compat",
|
|
46
31
|
"build:wasm": "../ruby-wasm-wasi/tools/pack-ruby-wasm.sh ../../../rubies/head-wasm32-unknown-wasi-full-js-debug ./dist",
|
|
47
32
|
"build:rollup": "rollup -c rollup.config.mjs",
|
|
48
|
-
"build": "npm run build:deps && npm run build:static && npm run build:wasm && npm run build:rollup"
|
|
33
|
+
"build": "npm run build:deps && npm run build:static && npm run build:wasm && npm run build:rollup && ../ruby-wasm-wasi/tools/post-build.sh ./dist"
|
|
49
34
|
},
|
|
50
35
|
"repository": "https://github.com/ruby/ruby.wasm",
|
|
51
36
|
"homepage": "https://github.com/ruby/ruby.wasm/tree/main/packages/npm-packages/ruby-head-wasm-wasi",
|
|
@@ -60,10 +45,8 @@
|
|
|
60
45
|
],
|
|
61
46
|
"license": "MIT",
|
|
62
47
|
"devDependencies": {
|
|
63
|
-
"@rollup/plugin-inject": "^5.0.5",
|
|
64
48
|
"@rollup/plugin-json": "^6.0.1",
|
|
65
|
-
"rollup": "^
|
|
66
|
-
"rollup-plugin-polyfill-node": "^0.12.0"
|
|
49
|
+
"rollup": "^4.6.1"
|
|
67
50
|
},
|
|
68
51
|
"dependencies": {
|
|
69
52
|
"@ruby/wasm-wasi": "^2.0.0"
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
export type RbErrno = number;
|
|
2
|
-
export type RbId = number;
|
|
3
|
-
export class RbAbiGuest {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The WebAssembly instance that this class is operating with.
|
|
7
|
-
* This is only available after the `instantiate` method has
|
|
8
|
-
* been called.
|
|
9
|
-
*/
|
|
10
|
-
instance: WebAssembly.Instance;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Constructs a new instance with internal state necessary to
|
|
14
|
-
* manage a wasm instance.
|
|
15
|
-
*
|
|
16
|
-
* Note that this does not actually instantiate the WebAssembly
|
|
17
|
-
* instance or module, you'll need to call the `instantiate`
|
|
18
|
-
* method below to "activate" this class.
|
|
19
|
-
*/
|
|
20
|
-
constructor();
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* This is a low-level method which can be used to add any
|
|
24
|
-
* intrinsics necessary for this instance to operate to an
|
|
25
|
-
* import object.
|
|
26
|
-
*
|
|
27
|
-
* The `import` object given here is expected to be used later
|
|
28
|
-
* to actually instantiate the module this class corresponds to.
|
|
29
|
-
* If the `instantiate` method below actually does the
|
|
30
|
-
* instantiation then there's no need to call this method, but
|
|
31
|
-
* if you're instantiating manually elsewhere then this can be
|
|
32
|
-
* used to prepare the import object for external instantiation.
|
|
33
|
-
*/
|
|
34
|
-
addToImports(imports: any): void;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Initializes this object with the provided WebAssembly
|
|
38
|
-
* module/instance.
|
|
39
|
-
*
|
|
40
|
-
* This is intended to be a flexible method of instantiating
|
|
41
|
-
* and completion of the initialization of this class. This
|
|
42
|
-
* method must be called before interacting with the
|
|
43
|
-
* WebAssembly object.
|
|
44
|
-
*
|
|
45
|
-
* The first argument to this method is where to get the
|
|
46
|
-
* wasm from. This can be a whole bunch of different types,
|
|
47
|
-
* for example:
|
|
48
|
-
*
|
|
49
|
-
* * A precompiled `WebAssembly.Module`
|
|
50
|
-
* * A typed array buffer containing the wasm bytecode.
|
|
51
|
-
* * A `Promise` of a `Response` which is used with
|
|
52
|
-
* `instantiateStreaming`
|
|
53
|
-
* * A `Response` itself used with `instantiateStreaming`.
|
|
54
|
-
* * An already instantiated `WebAssembly.Instance`
|
|
55
|
-
*
|
|
56
|
-
* If necessary the module is compiled, and if necessary the
|
|
57
|
-
* module is instantiated. Whether or not it's necessary
|
|
58
|
-
* depends on the type of argument provided to
|
|
59
|
-
* instantiation.
|
|
60
|
-
*
|
|
61
|
-
* If instantiation is performed then the `imports` object
|
|
62
|
-
* passed here is the list of imports used to instantiate
|
|
63
|
-
* the instance. This method may add its own intrinsics to
|
|
64
|
-
* this `imports` object too.
|
|
65
|
-
*/
|
|
66
|
-
instantiate(
|
|
67
|
-
module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
|
|
68
|
-
imports?: any,
|
|
69
|
-
): Promise<void>;
|
|
70
|
-
rubyShowVersion(): void;
|
|
71
|
-
rubyInit(): void;
|
|
72
|
-
rubySysinit(args: string[]): void;
|
|
73
|
-
rubyOptions(args: string[]): RbIseq;
|
|
74
|
-
rubyScript(name: string): void;
|
|
75
|
-
rubyInitLoadpath(): void;
|
|
76
|
-
rbEvalStringProtect(str: string): [RbAbiValue, number];
|
|
77
|
-
rbFuncallvProtect(recv: RbAbiValue, mid: RbId, args: RbAbiValue[]): [RbAbiValue, number];
|
|
78
|
-
rbIntern(name: string): RbId;
|
|
79
|
-
rbErrinfo(): RbAbiValue;
|
|
80
|
-
rbClearErrinfo(): void;
|
|
81
|
-
rstringPtr(value: RbAbiValue): string;
|
|
82
|
-
rbVmBugreport(): void;
|
|
83
|
-
rbGcEnable(): boolean;
|
|
84
|
-
rbGcDisable(): boolean;
|
|
85
|
-
rbSetShouldProhibitRewind(newValue: boolean): boolean;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export class RbIseq {
|
|
89
|
-
// Creates a new strong reference count as a new
|
|
90
|
-
// object. This is only required if you're also
|
|
91
|
-
// calling `drop` below and want to manually manage
|
|
92
|
-
// the reference count from JS.
|
|
93
|
-
//
|
|
94
|
-
// If you don't call `drop`, you don't need to call
|
|
95
|
-
// this and can simply use the object from JS.
|
|
96
|
-
clone(): RbIseq;
|
|
97
|
-
|
|
98
|
-
// Explicitly indicate that this JS object will no
|
|
99
|
-
// longer be used. If the internal reference count
|
|
100
|
-
// reaches zero then this will deterministically
|
|
101
|
-
// destroy the underlying wasm object.
|
|
102
|
-
//
|
|
103
|
-
// This is not required to be called from JS. Wasm
|
|
104
|
-
// destructors will be automatically called for you
|
|
105
|
-
// if this is not called using the JS
|
|
106
|
-
// `FinalizationRegistry`.
|
|
107
|
-
//
|
|
108
|
-
// Calling this method does not guarantee that the
|
|
109
|
-
// underlying wasm object is deallocated. Something
|
|
110
|
-
// else (including wasm) may be holding onto a
|
|
111
|
-
// strong reference count.
|
|
112
|
-
drop(): void;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export class RbAbiValue {
|
|
116
|
-
// Creates a new strong reference count as a new
|
|
117
|
-
// object. This is only required if you're also
|
|
118
|
-
// calling `drop` below and want to manually manage
|
|
119
|
-
// the reference count from JS.
|
|
120
|
-
//
|
|
121
|
-
// If you don't call `drop`, you don't need to call
|
|
122
|
-
// this and can simply use the object from JS.
|
|
123
|
-
clone(): RbAbiValue;
|
|
124
|
-
|
|
125
|
-
// Explicitly indicate that this JS object will no
|
|
126
|
-
// longer be used. If the internal reference count
|
|
127
|
-
// reaches zero then this will deterministically
|
|
128
|
-
// destroy the underlying wasm object.
|
|
129
|
-
//
|
|
130
|
-
// This is not required to be called from JS. Wasm
|
|
131
|
-
// destructors will be automatically called for you
|
|
132
|
-
// if this is not called using the JS
|
|
133
|
-
// `FinalizationRegistry`.
|
|
134
|
-
//
|
|
135
|
-
// Calling this method does not guarantee that the
|
|
136
|
-
// underlying wasm object is deallocated. Something
|
|
137
|
-
// else (including wasm) may be holding onto a
|
|
138
|
-
// strong reference count.
|
|
139
|
-
drop(): void;
|
|
140
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export type JsAbiResult = JsAbiResultSuccess | JsAbiResultFailure;
|
|
2
|
-
export interface JsAbiResultSuccess {
|
|
3
|
-
tag: "success",
|
|
4
|
-
val: JsAbiValue,
|
|
5
|
-
}
|
|
6
|
-
export interface JsAbiResultFailure {
|
|
7
|
-
tag: "failure",
|
|
8
|
-
val: JsAbiValue,
|
|
9
|
-
}
|
|
10
|
-
export type RawInteger = RawIntegerF64 | RawIntegerBignum;
|
|
11
|
-
export interface RawIntegerF64 {
|
|
12
|
-
tag: "f64",
|
|
13
|
-
val: number,
|
|
14
|
-
}
|
|
15
|
-
export interface RawIntegerBignum {
|
|
16
|
-
tag: "bignum",
|
|
17
|
-
val: string,
|
|
18
|
-
}
|
|
19
|
-
export function addRbJsAbiHostToImports(imports: any, obj: RbJsAbiHost, get_export: (name: string) => WebAssembly.ExportValue): void;
|
|
20
|
-
export interface RbJsAbiHost {
|
|
21
|
-
evalJs(code: string): JsAbiResult;
|
|
22
|
-
isJs(value: JsAbiValue): boolean;
|
|
23
|
-
instanceOf(value: JsAbiValue, klass: JsAbiValue): boolean;
|
|
24
|
-
globalThis(): JsAbiValue;
|
|
25
|
-
intToJsNumber(value: number): JsAbiValue;
|
|
26
|
-
floatToJsNumber(value: number): JsAbiValue;
|
|
27
|
-
stringToJsString(value: string): JsAbiValue;
|
|
28
|
-
boolToJsBool(value: boolean): JsAbiValue;
|
|
29
|
-
procToJsFunction(value: number): JsAbiValue;
|
|
30
|
-
rbObjectToJsRbValue(rawRbAbiValue: number): JsAbiValue;
|
|
31
|
-
jsValueToString(value: JsAbiValue): string;
|
|
32
|
-
jsValueToInteger(value: JsAbiValue): RawInteger;
|
|
33
|
-
exportJsValueToHost(value: JsAbiValue): void;
|
|
34
|
-
importJsValueFromHost(): JsAbiValue;
|
|
35
|
-
jsValueTypeof(value: JsAbiValue): string;
|
|
36
|
-
jsValueEqual(lhs: JsAbiValue, rhs: JsAbiValue): boolean;
|
|
37
|
-
jsValueStrictlyEqual(lhs: JsAbiValue, rhs: JsAbiValue): boolean;
|
|
38
|
-
reflectApply(target: JsAbiValue, thisArgument: JsAbiValue, arguments: JsAbiValue[]): JsAbiResult;
|
|
39
|
-
reflectConstruct(target: JsAbiValue, arguments: JsAbiValue[]): JsAbiValue;
|
|
40
|
-
reflectDeleteProperty(target: JsAbiValue, propertyKey: string): boolean;
|
|
41
|
-
reflectGet(target: JsAbiValue, propertyKey: string): JsAbiResult;
|
|
42
|
-
reflectGetOwnPropertyDescriptor(target: JsAbiValue, propertyKey: string): JsAbiValue;
|
|
43
|
-
reflectGetPrototypeOf(target: JsAbiValue): JsAbiValue;
|
|
44
|
-
reflectHas(target: JsAbiValue, propertyKey: string): boolean;
|
|
45
|
-
reflectIsExtensible(target: JsAbiValue): boolean;
|
|
46
|
-
reflectOwnKeys(target: JsAbiValue): JsAbiValue[];
|
|
47
|
-
reflectPreventExtensions(target: JsAbiValue): boolean;
|
|
48
|
-
reflectSet(target: JsAbiValue, propertyKey: string, value: JsAbiValue): JsAbiResult;
|
|
49
|
-
reflectSetPrototypeOf(target: JsAbiValue, prototype: JsAbiValue): boolean;
|
|
50
|
-
dropJsAbiValue?: (val: JsAbiValue) => void;
|
|
51
|
-
}
|
|
52
|
-
export interface JsAbiValue {
|
|
53
|
-
}
|