@ruby/wasm-wasi 0.0.0-next → 2.0.0-2023-05-21-a
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/browser.cjs.js +9 -1
- package/dist/browser.esm.js +9 -1
- package/dist/browser.script.cjs.js +31 -6
- package/dist/browser.script.esm.js +31 -6
- package/dist/browser.script.umd.js +31 -6
- package/dist/browser.umd.js +9 -1
- package/dist/node.cjs.js +9 -1
- package/dist/node.esm.js +9 -1
- package/package.json +8 -2
package/dist/browser.cjs.js
CHANGED
|
@@ -3220,7 +3220,15 @@ const consolePrinter = () => {
|
|
|
3220
3220
|
};
|
|
3221
3221
|
const DefaultRubyVM = async (rubyModule, options = { consolePrint: true }) => {
|
|
3222
3222
|
await n();
|
|
3223
|
-
const wasi = new s({
|
|
3223
|
+
const wasi = new s({
|
|
3224
|
+
env: {
|
|
3225
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
3226
|
+
// default Fiber stack size as well as main stack size allocated
|
|
3227
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
3228
|
+
// stack consumption in setjmp.
|
|
3229
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
3230
|
+
}
|
|
3231
|
+
});
|
|
3224
3232
|
const vm = new RubyVM();
|
|
3225
3233
|
const imports = wasi.getImports(rubyModule);
|
|
3226
3234
|
vm.addToImports(imports);
|
package/dist/browser.esm.js
CHANGED
|
@@ -3218,7 +3218,15 @@ const consolePrinter = () => {
|
|
|
3218
3218
|
};
|
|
3219
3219
|
const DefaultRubyVM = async (rubyModule, options = { consolePrint: true }) => {
|
|
3220
3220
|
await n();
|
|
3221
|
-
const wasi = new s({
|
|
3221
|
+
const wasi = new s({
|
|
3222
|
+
env: {
|
|
3223
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
3224
|
+
// default Fiber stack size as well as main stack size allocated
|
|
3225
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
3226
|
+
// stack consumption in setjmp.
|
|
3227
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3222
3230
|
const vm = new RubyVM();
|
|
3223
3231
|
const imports = wasi.getImports(rubyModule);
|
|
3224
3232
|
vm.addToImports(imports);
|
|
@@ -3257,7 +3257,15 @@ const consolePrinter = () => {
|
|
|
3257
3257
|
};
|
|
3258
3258
|
const DefaultRubyVM = async (rubyModule, options = { consolePrint: true }) => {
|
|
3259
3259
|
await n();
|
|
3260
|
-
const wasi = new s({
|
|
3260
|
+
const wasi = new s({
|
|
3261
|
+
env: {
|
|
3262
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
3263
|
+
// default Fiber stack size as well as main stack size allocated
|
|
3264
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
3265
|
+
// stack consumption in setjmp.
|
|
3266
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
3267
|
+
}
|
|
3268
|
+
});
|
|
3261
3269
|
const vm = new RubyVM();
|
|
3262
3270
|
const imports = wasi.getImports(rubyModule);
|
|
3263
3271
|
vm.addToImports(imports);
|
|
@@ -3306,9 +3314,17 @@ const runRubyScriptsInHtml = async (vm) => {
|
|
|
3306
3314
|
_c = promisingRubyScripts_1_1.value;
|
|
3307
3315
|
_d = false;
|
|
3308
3316
|
try {
|
|
3309
|
-
const
|
|
3310
|
-
if (
|
|
3311
|
-
|
|
3317
|
+
const script = _c;
|
|
3318
|
+
if (script) {
|
|
3319
|
+
const { scriptContent, evalStyle } = script;
|
|
3320
|
+
switch (evalStyle) {
|
|
3321
|
+
case "async":
|
|
3322
|
+
vm.evalAsync(scriptContent);
|
|
3323
|
+
break;
|
|
3324
|
+
case "sync":
|
|
3325
|
+
vm.eval(scriptContent);
|
|
3326
|
+
break;
|
|
3327
|
+
}
|
|
3312
3328
|
}
|
|
3313
3329
|
}
|
|
3314
3330
|
finally {
|
|
@@ -3324,7 +3340,16 @@ const runRubyScriptsInHtml = async (vm) => {
|
|
|
3324
3340
|
finally { if (e_1) throw e_1.error; }
|
|
3325
3341
|
}
|
|
3326
3342
|
};
|
|
3343
|
+
const deriveEvalStyle = (tag) => {
|
|
3344
|
+
const rawEvalStyle = tag.getAttribute("data-eval") || "sync";
|
|
3345
|
+
if (rawEvalStyle !== "async" && rawEvalStyle !== "sync") {
|
|
3346
|
+
console.warn(`data-eval attribute of script tag must be "async" or "sync". ${rawEvalStyle} is ignored and "sync" is used instead.`);
|
|
3347
|
+
return "sync";
|
|
3348
|
+
}
|
|
3349
|
+
return rawEvalStyle;
|
|
3350
|
+
};
|
|
3327
3351
|
const loadScriptAsync = async (tag) => {
|
|
3352
|
+
const evalStyle = deriveEvalStyle(tag);
|
|
3328
3353
|
// Inline comments can be written with the src attribute of the script tag.
|
|
3329
3354
|
// The presence of the src attribute is checked before the presence of the inline.
|
|
3330
3355
|
// see: https://html.spec.whatwg.org/multipage/scripting.html#inline-documentation-for-external-scripts
|
|
@@ -3332,11 +3357,11 @@ const loadScriptAsync = async (tag) => {
|
|
|
3332
3357
|
const url = tag.getAttribute("src");
|
|
3333
3358
|
const response = await fetch(url);
|
|
3334
3359
|
if (response.ok) {
|
|
3335
|
-
return await response.text();
|
|
3360
|
+
return { scriptContent: await response.text(), evalStyle };
|
|
3336
3361
|
}
|
|
3337
3362
|
return Promise.resolve(null);
|
|
3338
3363
|
}
|
|
3339
|
-
return Promise.resolve(tag.innerHTML);
|
|
3364
|
+
return Promise.resolve({ scriptContent: tag.innerHTML, evalStyle });
|
|
3340
3365
|
};
|
|
3341
3366
|
|
|
3342
3367
|
exports.main = main;
|
|
@@ -3255,7 +3255,15 @@ const consolePrinter = () => {
|
|
|
3255
3255
|
};
|
|
3256
3256
|
const DefaultRubyVM = async (rubyModule, options = { consolePrint: true }) => {
|
|
3257
3257
|
await n();
|
|
3258
|
-
const wasi = new s({
|
|
3258
|
+
const wasi = new s({
|
|
3259
|
+
env: {
|
|
3260
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
3261
|
+
// default Fiber stack size as well as main stack size allocated
|
|
3262
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
3263
|
+
// stack consumption in setjmp.
|
|
3264
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3259
3267
|
const vm = new RubyVM();
|
|
3260
3268
|
const imports = wasi.getImports(rubyModule);
|
|
3261
3269
|
vm.addToImports(imports);
|
|
@@ -3304,9 +3312,17 @@ const runRubyScriptsInHtml = async (vm) => {
|
|
|
3304
3312
|
_c = promisingRubyScripts_1_1.value;
|
|
3305
3313
|
_d = false;
|
|
3306
3314
|
try {
|
|
3307
|
-
const
|
|
3308
|
-
if (
|
|
3309
|
-
|
|
3315
|
+
const script = _c;
|
|
3316
|
+
if (script) {
|
|
3317
|
+
const { scriptContent, evalStyle } = script;
|
|
3318
|
+
switch (evalStyle) {
|
|
3319
|
+
case "async":
|
|
3320
|
+
vm.evalAsync(scriptContent);
|
|
3321
|
+
break;
|
|
3322
|
+
case "sync":
|
|
3323
|
+
vm.eval(scriptContent);
|
|
3324
|
+
break;
|
|
3325
|
+
}
|
|
3310
3326
|
}
|
|
3311
3327
|
}
|
|
3312
3328
|
finally {
|
|
@@ -3322,7 +3338,16 @@ const runRubyScriptsInHtml = async (vm) => {
|
|
|
3322
3338
|
finally { if (e_1) throw e_1.error; }
|
|
3323
3339
|
}
|
|
3324
3340
|
};
|
|
3341
|
+
const deriveEvalStyle = (tag) => {
|
|
3342
|
+
const rawEvalStyle = tag.getAttribute("data-eval") || "sync";
|
|
3343
|
+
if (rawEvalStyle !== "async" && rawEvalStyle !== "sync") {
|
|
3344
|
+
console.warn(`data-eval attribute of script tag must be "async" or "sync". ${rawEvalStyle} is ignored and "sync" is used instead.`);
|
|
3345
|
+
return "sync";
|
|
3346
|
+
}
|
|
3347
|
+
return rawEvalStyle;
|
|
3348
|
+
};
|
|
3325
3349
|
const loadScriptAsync = async (tag) => {
|
|
3350
|
+
const evalStyle = deriveEvalStyle(tag);
|
|
3326
3351
|
// Inline comments can be written with the src attribute of the script tag.
|
|
3327
3352
|
// The presence of the src attribute is checked before the presence of the inline.
|
|
3328
3353
|
// see: https://html.spec.whatwg.org/multipage/scripting.html#inline-documentation-for-external-scripts
|
|
@@ -3330,11 +3355,11 @@ const loadScriptAsync = async (tag) => {
|
|
|
3330
3355
|
const url = tag.getAttribute("src");
|
|
3331
3356
|
const response = await fetch(url);
|
|
3332
3357
|
if (response.ok) {
|
|
3333
|
-
return await response.text();
|
|
3358
|
+
return { scriptContent: await response.text(), evalStyle };
|
|
3334
3359
|
}
|
|
3335
3360
|
return Promise.resolve(null);
|
|
3336
3361
|
}
|
|
3337
|
-
return Promise.resolve(tag.innerHTML);
|
|
3362
|
+
return Promise.resolve({ scriptContent: tag.innerHTML, evalStyle });
|
|
3338
3363
|
};
|
|
3339
3364
|
|
|
3340
3365
|
export { main };
|
|
@@ -3261,7 +3261,15 @@
|
|
|
3261
3261
|
};
|
|
3262
3262
|
const DefaultRubyVM = async (rubyModule, options = { consolePrint: true }) => {
|
|
3263
3263
|
await n();
|
|
3264
|
-
const wasi = new s({
|
|
3264
|
+
const wasi = new s({
|
|
3265
|
+
env: {
|
|
3266
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
3267
|
+
// default Fiber stack size as well as main stack size allocated
|
|
3268
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
3269
|
+
// stack consumption in setjmp.
|
|
3270
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
3271
|
+
}
|
|
3272
|
+
});
|
|
3265
3273
|
const vm = new RubyVM();
|
|
3266
3274
|
const imports = wasi.getImports(rubyModule);
|
|
3267
3275
|
vm.addToImports(imports);
|
|
@@ -3310,9 +3318,17 @@
|
|
|
3310
3318
|
_c = promisingRubyScripts_1_1.value;
|
|
3311
3319
|
_d = false;
|
|
3312
3320
|
try {
|
|
3313
|
-
const
|
|
3314
|
-
if (
|
|
3315
|
-
|
|
3321
|
+
const script = _c;
|
|
3322
|
+
if (script) {
|
|
3323
|
+
const { scriptContent, evalStyle } = script;
|
|
3324
|
+
switch (evalStyle) {
|
|
3325
|
+
case "async":
|
|
3326
|
+
vm.evalAsync(scriptContent);
|
|
3327
|
+
break;
|
|
3328
|
+
case "sync":
|
|
3329
|
+
vm.eval(scriptContent);
|
|
3330
|
+
break;
|
|
3331
|
+
}
|
|
3316
3332
|
}
|
|
3317
3333
|
}
|
|
3318
3334
|
finally {
|
|
@@ -3328,7 +3344,16 @@
|
|
|
3328
3344
|
finally { if (e_1) throw e_1.error; }
|
|
3329
3345
|
}
|
|
3330
3346
|
};
|
|
3347
|
+
const deriveEvalStyle = (tag) => {
|
|
3348
|
+
const rawEvalStyle = tag.getAttribute("data-eval") || "sync";
|
|
3349
|
+
if (rawEvalStyle !== "async" && rawEvalStyle !== "sync") {
|
|
3350
|
+
console.warn(`data-eval attribute of script tag must be "async" or "sync". ${rawEvalStyle} is ignored and "sync" is used instead.`);
|
|
3351
|
+
return "sync";
|
|
3352
|
+
}
|
|
3353
|
+
return rawEvalStyle;
|
|
3354
|
+
};
|
|
3331
3355
|
const loadScriptAsync = async (tag) => {
|
|
3356
|
+
const evalStyle = deriveEvalStyle(tag);
|
|
3332
3357
|
// Inline comments can be written with the src attribute of the script tag.
|
|
3333
3358
|
// The presence of the src attribute is checked before the presence of the inline.
|
|
3334
3359
|
// see: https://html.spec.whatwg.org/multipage/scripting.html#inline-documentation-for-external-scripts
|
|
@@ -3336,11 +3361,11 @@
|
|
|
3336
3361
|
const url = tag.getAttribute("src");
|
|
3337
3362
|
const response = await fetch(url);
|
|
3338
3363
|
if (response.ok) {
|
|
3339
|
-
return await response.text();
|
|
3364
|
+
return { scriptContent: await response.text(), evalStyle };
|
|
3340
3365
|
}
|
|
3341
3366
|
return Promise.resolve(null);
|
|
3342
3367
|
}
|
|
3343
|
-
return Promise.resolve(tag.innerHTML);
|
|
3368
|
+
return Promise.resolve({ scriptContent: tag.innerHTML, evalStyle });
|
|
3344
3369
|
};
|
|
3345
3370
|
|
|
3346
3371
|
exports.main = main;
|
package/dist/browser.umd.js
CHANGED
|
@@ -3224,7 +3224,15 @@
|
|
|
3224
3224
|
};
|
|
3225
3225
|
const DefaultRubyVM = async (rubyModule, options = { consolePrint: true }) => {
|
|
3226
3226
|
await n();
|
|
3227
|
-
const wasi = new s({
|
|
3227
|
+
const wasi = new s({
|
|
3228
|
+
env: {
|
|
3229
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
3230
|
+
// default Fiber stack size as well as main stack size allocated
|
|
3231
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
3232
|
+
// stack consumption in setjmp.
|
|
3233
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
3234
|
+
}
|
|
3235
|
+
});
|
|
3228
3236
|
const vm = new RubyVM();
|
|
3229
3237
|
const imports = wasi.getImports(rubyModule);
|
|
3230
3238
|
vm.addToImports(imports);
|
package/dist/node.cjs.js
CHANGED
|
@@ -1189,7 +1189,15 @@ class RbFatalError extends RbError {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
|
|
1191
1191
|
const DefaultRubyVM = async (rubyModule) => {
|
|
1192
|
-
const wasi$1 = new wasi.WASI(
|
|
1192
|
+
const wasi$1 = new wasi.WASI({
|
|
1193
|
+
env: {
|
|
1194
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
1195
|
+
// default Fiber stack size as well as main stack size allocated
|
|
1196
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
1197
|
+
// stack consumption in setjmp.
|
|
1198
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1193
1201
|
const vm = new RubyVM();
|
|
1194
1202
|
const imports = {
|
|
1195
1203
|
wasi_snapshot_preview1: wasi$1.wasiImport,
|
package/dist/node.esm.js
CHANGED
|
@@ -1187,7 +1187,15 @@ class RbFatalError extends RbError {
|
|
|
1187
1187
|
}
|
|
1188
1188
|
|
|
1189
1189
|
const DefaultRubyVM = async (rubyModule) => {
|
|
1190
|
-
const wasi = new WASI(
|
|
1190
|
+
const wasi = new WASI({
|
|
1191
|
+
env: {
|
|
1192
|
+
// FIXME(katei): setjmp consumes a LOT of stack now, so we extend
|
|
1193
|
+
// default Fiber stack size as well as main stack size allocated
|
|
1194
|
+
// by wasm-ld's --stack-size. The ideal solution is to reduce
|
|
1195
|
+
// stack consumption in setjmp.
|
|
1196
|
+
"RUBY_FIBER_MACHINE_STACK_SIZE": "16777216"
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1191
1199
|
const vm = new RubyVM();
|
|
1192
1200
|
const imports = {
|
|
1193
1201
|
wasi_snapshot_preview1: wasi.wasiImport,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruby/wasm-wasi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-2023-05-21-a",
|
|
4
4
|
"description": "WebAssembly port of CRuby with WASI",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"umd:main": "./dist/index.umd.js",
|
|
@@ -23,9 +23,15 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"scripts": {
|
|
26
|
-
"test": "npm run test:unit && npm run test:jest",
|
|
26
|
+
"test:run": "npm run test:unit && npm run test:jest && npm run test:e2e",
|
|
27
|
+
"test:head": "RUBY_ROOT=../../../rubies/head-wasm32-unknown-wasi-full-js-debug npm run test:run",
|
|
28
|
+
"test": "npm run test:head",
|
|
27
29
|
"test:jest": "NODE_OPTIONS=\"--experimental-wasi-unstable-preview1\" jest --coverage",
|
|
28
30
|
"test:unit": "./tools/run-test-unit.mjs",
|
|
31
|
+
"test:e2e": "playwright install && npm run test:e2e:examples && npm run test:e2e:integrations",
|
|
32
|
+
"test:e2e:examples": "playwright test -c test-e2e/playwright.examples.config.ts",
|
|
33
|
+
"test:e2e:integrations": "playwright test -c test-e2e/playwright.integrations.config.ts",
|
|
34
|
+
"serve:example": "bundle exec ruby -run -e httpd ./example -p 8085",
|
|
29
35
|
"format": "prettier --write .",
|
|
30
36
|
"build:static": "./tools/pack-bindgen-src.sh ./dist",
|
|
31
37
|
"build:rollup": "rollup -c rollup.config.mjs && tsc --build",
|