@wasm-oj/server 0.2.0 → 0.2.1
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.
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
use std::sync::{Arc, Mutex};
|
|
2
|
+
use wasmer::{AsStoreMut, Extern, Function, FunctionEnv, Imports, Memory, RuntimeError, Value};
|
|
3
|
+
use wasmer_wasix::wasmer_wasix_types::wasi::Filetype;
|
|
4
|
+
|
|
5
|
+
struct StdioEnv {
|
|
6
|
+
original: Function,
|
|
7
|
+
memory: Arc<Mutex<Option<Memory>>>,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
pub(crate) fn attach_redirected_stdio(
|
|
11
|
+
store: &mut impl AsStoreMut,
|
|
12
|
+
imports: &mut Imports,
|
|
13
|
+
memory: &Arc<Mutex<Option<Memory>>>,
|
|
14
|
+
) {
|
|
15
|
+
for namespace in ["wasi_snapshot_preview1", "wasix_32v1", "wasix_64v1"] {
|
|
16
|
+
let Some(Extern::Function(original)) = imports.get_export(namespace, "fd_fdstat_get")
|
|
17
|
+
else {
|
|
18
|
+
continue;
|
|
19
|
+
};
|
|
20
|
+
let signature = original.ty(store);
|
|
21
|
+
let env = FunctionEnv::new(
|
|
22
|
+
store,
|
|
23
|
+
StdioEnv {
|
|
24
|
+
original,
|
|
25
|
+
memory: memory.clone(),
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
imports.define(
|
|
29
|
+
namespace,
|
|
30
|
+
"fd_fdstat_get",
|
|
31
|
+
Function::new_with_env(store, &env, signature, |mut env, arguments| {
|
|
32
|
+
let result = env.data().original.clone().call(&mut env, arguments)?;
|
|
33
|
+
if matches!(arguments.first(), Some(Value::I32(0..=2)))
|
|
34
|
+
&& matches!(result.as_ref(), [Value::I32(0)])
|
|
35
|
+
{
|
|
36
|
+
let offset = match arguments[1] {
|
|
37
|
+
Value::I32(offset) => u64::from(offset as u32),
|
|
38
|
+
Value::I64(offset) => offset as u64,
|
|
39
|
+
_ => return Err(RuntimeError::new("Invalid fdstat pointer type")),
|
|
40
|
+
};
|
|
41
|
+
let memory = env.data().memory.lock().unwrap();
|
|
42
|
+
let memory = memory
|
|
43
|
+
.as_ref()
|
|
44
|
+
.ok_or_else(|| RuntimeError::new("Missing WASI memory"))?;
|
|
45
|
+
// Wasmer hardcodes stdio as CharacterDevice even when backed by pipes.
|
|
46
|
+
// WASI has no FIFO filetype; only replace the first fdstat field.
|
|
47
|
+
memory
|
|
48
|
+
.view(&env)
|
|
49
|
+
.write(offset, &[Filetype::Unknown as u8])
|
|
50
|
+
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
|
51
|
+
}
|
|
52
|
+
Ok(result.into_vec())
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -779,8 +779,8 @@ Object.freeze({
|
|
|
779
779
|
});
|
|
780
780
|
new TextEncoder();
|
|
781
781
|
Object.freeze({
|
|
782
|
-
runtimeCoreWasmSha256: "
|
|
783
|
-
runtimeSourceRootSha256: "
|
|
782
|
+
runtimeCoreWasmSha256: "e4c7fca566ff5ba66931e0cf11cacbf37610d35c36d5f3ee97d719468a2f6466",
|
|
783
|
+
runtimeSourceRootSha256: "0140ecc6ed5060eae465e73db6822bcde32295734517de84929a537e3c45e663",
|
|
784
784
|
wasmerNativeVersion: "7.2.1",
|
|
785
785
|
wasmerSdkVersion: "0.10.0",
|
|
786
786
|
wasmerSdkWasmSha256: "49a6646209f5ab5e7c737eac33407d87d9a9959ac83e5ecaaab9261b2323589e",
|
|
@@ -791,7 +791,7 @@ Object.freeze({
|
|
|
791
791
|
* Release verification independently checks the component bytes before this
|
|
792
792
|
* identity is admitted into a calibrated release.
|
|
793
793
|
*/
|
|
794
|
-
var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "
|
|
794
|
+
var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "59414bf4fa5191d0942c0e190c69d32f3a2251461b8eb41aaba32598baab1d5f";
|
|
795
795
|
//#endregion
|
|
796
796
|
//#region src/core/cost-profile.ts
|
|
797
797
|
function coordinates(language, target, optimization) {
|
|
@@ -562,8 +562,8 @@ Object.freeze({
|
|
|
562
562
|
});
|
|
563
563
|
new TextEncoder();
|
|
564
564
|
Object.freeze({
|
|
565
|
-
runtimeCoreWasmSha256: "
|
|
566
|
-
runtimeSourceRootSha256: "
|
|
565
|
+
runtimeCoreWasmSha256: "e4c7fca566ff5ba66931e0cf11cacbf37610d35c36d5f3ee97d719468a2f6466",
|
|
566
|
+
runtimeSourceRootSha256: "0140ecc6ed5060eae465e73db6822bcde32295734517de84929a537e3c45e663",
|
|
567
567
|
wasmerNativeVersion: "7.2.1",
|
|
568
568
|
wasmerSdkVersion: "0.10.0",
|
|
569
569
|
wasmerSdkWasmSha256: "49a6646209f5ab5e7c737eac33407d87d9a9959ac83e5ecaaab9261b2323589e",
|
|
@@ -574,7 +574,7 @@ Object.freeze({
|
|
|
574
574
|
* Release verification independently checks the component bytes before this
|
|
575
575
|
* identity is admitted into a calibrated release.
|
|
576
576
|
*/
|
|
577
|
-
var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "
|
|
577
|
+
var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "59414bf4fa5191d0942c0e190c69d32f3a2251461b8eb41aaba32598baab1d5f";
|
|
578
578
|
//#endregion
|
|
579
579
|
//#region src/core/cost-profile.ts
|
|
580
580
|
function coordinates(language, target, optimization) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wasm-oj/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Node.js compiler and runner host for the WASM-OJ SDK.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "JacobLinCool",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"node": ">=24.18.0 <25"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@wasm-oj/contracts": "0.2.
|
|
62
|
-
"@wasm-oj/core": "0.2.
|
|
61
|
+
"@wasm-oj/contracts": "0.2.1",
|
|
62
|
+
"@wasm-oj/core": "0.2.1",
|
|
63
63
|
"@wasmer/sdk": "0.10.0",
|
|
64
64
|
"fflate": "0.8.3"
|
|
65
65
|
},
|