@wasm-oj/server 0.2.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/LICENSE +21 -0
- package/README.md +6 -0
- package/THIRD_PARTY_NOTICES.md +302 -0
- package/crates/runtime-core/Cargo.lock +5099 -0
- package/crates/runtime-core/Cargo.toml +66 -0
- package/crates/runtime-core/README.md +47 -0
- package/crates/runtime-core/src/bin/wasm-oj-compiler.rs +418 -0
- package/crates/runtime-core/src/bin/wasm-oj-runner.rs +294 -0
- package/crates/runtime-core/src/capabilities.rs +118 -0
- package/crates/runtime-core/src/compiler.rs +658 -0
- package/crates/runtime-core/src/contract.rs +5 -0
- package/crates/runtime-core/src/deterministic.rs +1051 -0
- package/crates/runtime-core/src/error.rs +58 -0
- package/crates/runtime-core/src/filesystem.rs +547 -0
- package/crates/runtime-core/src/filesystem_quota.rs +167 -0
- package/crates/runtime-core/src/go_compiler_session.rs +297 -0
- package/crates/runtime-core/src/interactive.rs +1019 -0
- package/crates/runtime-core/src/judge_package.rs +1539 -0
- package/crates/runtime-core/src/lib.rs +98 -0
- package/crates/runtime-core/src/memory.rs +84 -0
- package/crates/runtime-core/src/meter.rs +549 -0
- package/crates/runtime-core/src/module_imports.rs +149 -0
- package/crates/runtime-core/src/module_policy.rs +714 -0
- package/crates/runtime-core/src/output.rs +204 -0
- package/crates/runtime-core/src/run/mod.rs +208 -0
- package/crates/runtime-core/src/run/native.rs +260 -0
- package/crates/runtime-core/src/run/web.rs +229 -0
- package/crates/runtime-core/src/run/web_runtime.rs +109 -0
- package/crates/runtime-core/src/types.rs +268 -0
- package/crates/runtime-core/src/web.rs +83 -0
- package/dist/chunks/go-toolchain-Dbt-lp2L.js +426 -0
- package/dist/chunks/java-toolchain-DajoRCHu.js +44 -0
- package/dist/chunks/python-toolchain-Dx834o2A.js +4 -0
- package/dist/chunks/rust-toolchain-CJ3sMxPE.js +252 -0
- package/dist/chunks/toolchains-C6KuA1yM.js +224 -0
- package/dist/go-stage.mjs +193 -0
- package/dist/index.d.ts +221 -0
- package/dist/index.js +4393 -0
- package/dist/java-stage.mjs +111 -0
- package/dist/python-stage.mjs +90 -0
- package/dist/rustc-stage.mjs +301 -0
- package/dist/server-build-stage.mjs +2564 -0
- package/dist/server-runner-stage.mjs +155 -0
- package/licenses/fflate-MIT.txt +21 -0
- package/licenses/runtime-core-dependencies.html +6253 -0
- package/licenses/runtime-core-dependencies.json +3041 -0
- package/licenses/wasmer-sdk-MIT.txt +21 -0
- package/licenses/wasmer-sdk-dependencies.html +6901 -0
- package/licenses/wasmer-sdk-dependencies.json +3013 -0
- package/package.json +70 -0
- package/rust-toolchain.toml +5 -0
- package/testdata/wojjdg02-v2-text.hex +1 -0
- package/vendor/shared-buffer/Cargo.toml +22 -0
- package/vendor/shared-buffer/LICENSE_APACHE.md +176 -0
- package/vendor/shared-buffer/LICENSE_MIT.md +25 -0
- package/vendor/shared-buffer/README.md +34 -0
- package/vendor/shared-buffer/src/lib.rs +58 -0
- package/vendor/shared-buffer/src/mmap.rs +250 -0
- package/vendor/shared-buffer/src/owned.rs +389 -0
- package/vendor/virtual-fs/Cargo.toml +181 -0
- package/vendor/virtual-fs/LICENSE +25 -0
- package/vendor/virtual-fs/src/arc_box_file.rs +142 -0
- package/vendor/virtual-fs/src/arc_file.rs +182 -0
- package/vendor/virtual-fs/src/arc_fs.rs +68 -0
- package/vendor/virtual-fs/src/buffer_file.rs +103 -0
- package/vendor/virtual-fs/src/builder.rs +232 -0
- package/vendor/virtual-fs/src/combine_file.rs +101 -0
- package/vendor/virtual-fs/src/cow_file.rs +345 -0
- package/vendor/virtual-fs/src/dual_write_file.rs +113 -0
- package/vendor/virtual-fs/src/empty_fs.rs +81 -0
- package/vendor/virtual-fs/src/filesystems.rs +108 -0
- package/vendor/virtual-fs/src/host_fs.rs +1390 -0
- package/vendor/virtual-fs/src/lib.rs +782 -0
- package/vendor/virtual-fs/src/limiter.rs +252 -0
- package/vendor/virtual-fs/src/mem_fs/file.rs +1799 -0
- package/vendor/virtual-fs/src/mem_fs/file_opener.rs +941 -0
- package/vendor/virtual-fs/src/mem_fs/filesystem.rs +2134 -0
- package/vendor/virtual-fs/src/mem_fs/mod.rs +245 -0
- package/vendor/virtual-fs/src/mem_fs/offloaded_file.rs +474 -0
- package/vendor/virtual-fs/src/mem_fs/stdio.rs +318 -0
- package/vendor/virtual-fs/src/mount_fs.rs +2225 -0
- package/vendor/virtual-fs/src/null_file.rs +87 -0
- package/vendor/virtual-fs/src/ops.rs +364 -0
- package/vendor/virtual-fs/src/overlay_fs.rs +2216 -0
- package/vendor/virtual-fs/src/passthru_fs.rs +119 -0
- package/vendor/virtual-fs/src/pipe.rs +603 -0
- package/vendor/virtual-fs/src/random_file.rs +88 -0
- package/vendor/virtual-fs/src/special_file.rs +108 -0
- package/vendor/virtual-fs/src/static_file.rs +133 -0
- package/vendor/virtual-fs/src/static_fs.rs +460 -0
- package/vendor/virtual-fs/src/tmp_fs.rs +95 -0
- package/vendor/virtual-fs/src/trace_fs.rs +258 -0
- package/vendor/virtual-fs/src/webc_volume_fs.rs +829 -0
- package/vendor/virtual-fs/src/zero_file.rs +90 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
path::PathBuf,
|
|
3
|
+
pin::Pin,
|
|
4
|
+
task::{Context, Poll},
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
use futures::future::BoxFuture;
|
|
8
|
+
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf};
|
|
9
|
+
|
|
10
|
+
use crate::{FileOpener, FileSystem, OpenOptionsConfig, VirtualFile};
|
|
11
|
+
|
|
12
|
+
/// A [`FileSystem`] wrapper that will automatically log all operations at the
|
|
13
|
+
/// `trace` level.
|
|
14
|
+
///
|
|
15
|
+
/// To see these logs, you will typically need to set the `$RUST_LOG`
|
|
16
|
+
/// environment variable to `virtual_fs::trace_fs=trace`.
|
|
17
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
18
|
+
pub struct TraceFileSystem<F>(pub F);
|
|
19
|
+
|
|
20
|
+
impl<F> TraceFileSystem<F> {
|
|
21
|
+
pub fn new(filesystem: F) -> Self {
|
|
22
|
+
TraceFileSystem(filesystem)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
pub fn inner(&self) -> &F {
|
|
26
|
+
&self.0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pub fn inner_mut(&mut self) -> &mut F {
|
|
30
|
+
&mut self.0
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pub fn into_inner(self) -> F {
|
|
34
|
+
self.0
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
impl<F> FileSystem for TraceFileSystem<F>
|
|
39
|
+
where
|
|
40
|
+
F: FileSystem,
|
|
41
|
+
{
|
|
42
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
43
|
+
fn readlink(&self, path: &std::path::Path) -> crate::Result<PathBuf> {
|
|
44
|
+
self.0.readlink(path)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
48
|
+
fn read_dir(&self, path: &std::path::Path) -> crate::Result<crate::ReadDir> {
|
|
49
|
+
self.0.read_dir(path)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
53
|
+
fn create_dir(&self, path: &std::path::Path) -> crate::Result<()> {
|
|
54
|
+
self.0.create_dir(path)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
58
|
+
fn remove_dir(&self, path: &std::path::Path) -> crate::Result<()> {
|
|
59
|
+
self.0.remove_dir(path)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
63
|
+
fn rename<'a>(
|
|
64
|
+
&'a self,
|
|
65
|
+
from: &'a std::path::Path,
|
|
66
|
+
to: &'a std::path::Path,
|
|
67
|
+
) -> BoxFuture<'a, crate::Result<()>> {
|
|
68
|
+
Box::pin(async { self.0.rename(from, to).await })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
72
|
+
fn metadata(&self, path: &std::path::Path) -> crate::Result<crate::Metadata> {
|
|
73
|
+
self.0.metadata(path)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
77
|
+
fn symlink_metadata(&self, path: &std::path::Path) -> crate::Result<crate::Metadata> {
|
|
78
|
+
self.0.symlink_metadata(path)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#[tracing::instrument(level = "trace", skip(self), err)]
|
|
82
|
+
fn remove_file(&self, path: &std::path::Path) -> crate::Result<()> {
|
|
83
|
+
self.0.remove_file(path)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[tracing::instrument(level = "trace", skip(self))]
|
|
87
|
+
fn new_open_options(&self) -> crate::OpenOptions<'_> {
|
|
88
|
+
crate::OpenOptions::new(self)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
impl<F> FileOpener for TraceFileSystem<F>
|
|
93
|
+
where
|
|
94
|
+
F: FileSystem,
|
|
95
|
+
{
|
|
96
|
+
#[tracing::instrument(level = "trace", skip(self))]
|
|
97
|
+
fn open(
|
|
98
|
+
&self,
|
|
99
|
+
path: &std::path::Path,
|
|
100
|
+
conf: &OpenOptionsConfig,
|
|
101
|
+
) -> crate::Result<Box<dyn crate::VirtualFile + Send + Sync + 'static>> {
|
|
102
|
+
let file = self.0.new_open_options().options(conf.clone()).open(path)?;
|
|
103
|
+
Ok(Box::new(TraceFile {
|
|
104
|
+
file,
|
|
105
|
+
path: path.to_owned(),
|
|
106
|
+
}))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#[derive(Debug)]
|
|
111
|
+
struct TraceFile {
|
|
112
|
+
path: PathBuf,
|
|
113
|
+
file: Box<dyn crate::VirtualFile + Send + Sync + 'static>,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
impl VirtualFile for TraceFile {
|
|
117
|
+
#[tracing::instrument(level = "trace", skip(self), fields(path=%self.path.display()))]
|
|
118
|
+
fn last_accessed(&self) -> u64 {
|
|
119
|
+
self.file.last_accessed()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#[tracing::instrument(level = "trace", skip(self), fields(path=%self.path.display()))]
|
|
123
|
+
fn last_modified(&self) -> u64 {
|
|
124
|
+
self.file.last_modified()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#[tracing::instrument(level = "trace", skip(self), fields(path=%self.path.display()))]
|
|
128
|
+
fn created_time(&self) -> u64 {
|
|
129
|
+
self.file.created_time()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#[tracing::instrument(level = "trace", skip(self), fields(path=%self.path.display()))]
|
|
133
|
+
fn set_times(&mut self, atime: Option<u64>, mtime: Option<u64>) -> crate::Result<()> {
|
|
134
|
+
self.file.set_times(atime, mtime)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#[tracing::instrument(level = "trace", skip(self), fields(path=%self.path.display()))]
|
|
138
|
+
fn size(&self) -> u64 {
|
|
139
|
+
self.file.size()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#[tracing::instrument(level = "trace", skip(self), fields(path=%self.path.display()), err)]
|
|
143
|
+
fn set_len(&mut self, new_size: u64) -> crate::Result<()> {
|
|
144
|
+
self.file.set_len(new_size)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
fn unlink(&mut self) -> crate::Result<()> {
|
|
148
|
+
self.file.unlink()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
152
|
+
fn poll_read_ready(
|
|
153
|
+
mut self: Pin<&mut Self>,
|
|
154
|
+
cx: &mut Context<'_>,
|
|
155
|
+
) -> Poll<std::io::Result<usize>> {
|
|
156
|
+
let result = Pin::new(&mut *self.file).poll_read_ready(cx);
|
|
157
|
+
|
|
158
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
159
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
result
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
166
|
+
fn poll_write_ready(
|
|
167
|
+
mut self: Pin<&mut Self>,
|
|
168
|
+
cx: &mut Context<'_>,
|
|
169
|
+
) -> Poll<std::io::Result<usize>> {
|
|
170
|
+
let result = Pin::new(&mut *self.file).poll_write_ready(cx);
|
|
171
|
+
|
|
172
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
173
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
result
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
impl AsyncRead for TraceFile {
|
|
181
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
182
|
+
fn poll_read(
|
|
183
|
+
mut self: Pin<&mut Self>,
|
|
184
|
+
cx: &mut Context<'_>,
|
|
185
|
+
buf: &mut ReadBuf<'_>,
|
|
186
|
+
) -> Poll<std::io::Result<()>> {
|
|
187
|
+
let result = Pin::new(&mut *self.file).poll_read(cx, buf);
|
|
188
|
+
|
|
189
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
190
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
result
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
impl AsyncWrite for TraceFile {
|
|
198
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
199
|
+
fn poll_write(
|
|
200
|
+
mut self: Pin<&mut Self>,
|
|
201
|
+
cx: &mut Context<'_>,
|
|
202
|
+
buf: &[u8],
|
|
203
|
+
) -> Poll<Result<usize, std::io::Error>> {
|
|
204
|
+
let result = Pin::new(&mut *self.file).poll_write(cx, buf);
|
|
205
|
+
|
|
206
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
207
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
result
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
214
|
+
fn poll_flush(
|
|
215
|
+
mut self: Pin<&mut Self>,
|
|
216
|
+
cx: &mut Context<'_>,
|
|
217
|
+
) -> Poll<Result<(), std::io::Error>> {
|
|
218
|
+
let result = Pin::new(&mut *self.file).poll_flush(cx);
|
|
219
|
+
|
|
220
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
221
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
result
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
228
|
+
fn poll_shutdown(
|
|
229
|
+
mut self: Pin<&mut Self>,
|
|
230
|
+
cx: &mut Context<'_>,
|
|
231
|
+
) -> Poll<Result<(), std::io::Error>> {
|
|
232
|
+
let result = Pin::new(&mut *self.file).poll_shutdown(cx);
|
|
233
|
+
|
|
234
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
235
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
result
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
impl AsyncSeek for TraceFile {
|
|
243
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()), err)]
|
|
244
|
+
fn start_seek(mut self: Pin<&mut Self>, position: std::io::SeekFrom) -> std::io::Result<()> {
|
|
245
|
+
Pin::new(&mut *self.file).start_seek(position)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))]
|
|
249
|
+
fn poll_complete(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<u64>> {
|
|
250
|
+
let result = Pin::new(&mut *self.file).poll_complete(cx);
|
|
251
|
+
|
|
252
|
+
if let Poll::Ready(Err(e)) = &result {
|
|
253
|
+
tracing::trace!(error = e as &dyn std::error::Error);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
result
|
|
257
|
+
}
|
|
258
|
+
}
|