@ai-ecoverse/slicc-kernel 1.31.0 → 1.31.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.
package/dist/process-worker.js
CHANGED
|
@@ -4001,6 +4001,9 @@ var init_wasi_files = __esm({
|
|
|
4001
4001
|
data;
|
|
4002
4002
|
length = 0;
|
|
4003
4003
|
dirty = false;
|
|
4004
|
+
whole = false;
|
|
4005
|
+
from = Infinity;
|
|
4006
|
+
to = 0;
|
|
4004
4007
|
orphaned = false;
|
|
4005
4008
|
opens = 0;
|
|
4006
4009
|
fs;
|
|
@@ -4019,6 +4022,7 @@ var init_wasi_files = __esm({
|
|
|
4019
4022
|
} else if (empty) {
|
|
4020
4023
|
this.data = new Uint8Array(0);
|
|
4021
4024
|
this.dirty = true;
|
|
4025
|
+
this.whole = true;
|
|
4022
4026
|
}
|
|
4023
4027
|
}
|
|
4024
4028
|
get path() {
|
|
@@ -4071,6 +4075,8 @@ var init_wasi_files = __esm({
|
|
|
4071
4075
|
this.load();
|
|
4072
4076
|
this.ensure(end);
|
|
4073
4077
|
const buf = this.data;
|
|
4078
|
+
this.from = Math.min(this.from, at, this.length);
|
|
4079
|
+
this.to = Math.max(this.to, end);
|
|
4074
4080
|
if (at > this.length) buf.fill(0, this.length, at);
|
|
4075
4081
|
buf.set(bytes, at);
|
|
4076
4082
|
this.length = Math.max(this.length, end);
|
|
@@ -4085,6 +4091,7 @@ var init_wasi_files = __esm({
|
|
|
4085
4091
|
}
|
|
4086
4092
|
this.load();
|
|
4087
4093
|
this.ensure(size);
|
|
4094
|
+
this.whole = true;
|
|
4088
4095
|
if (size > this.length) this.data.fill(0, this.length, size);
|
|
4089
4096
|
this.length = size;
|
|
4090
4097
|
}
|
|
@@ -4112,9 +4119,14 @@ var init_wasi_files = __esm({
|
|
|
4112
4119
|
flush() {
|
|
4113
4120
|
if (this.orphaned || !this.dirty) return;
|
|
4114
4121
|
if (this.ranged) this.ranged.flush();
|
|
4115
|
-
else if (this.data)
|
|
4116
|
-
else
|
|
4122
|
+
else if (!this.data) return;
|
|
4123
|
+
else if (this.whole || !this.fs.pwrite)
|
|
4124
|
+
this.fs.writeFile(this.path, this.data.slice(0, this.length));
|
|
4125
|
+
else this.fs.pwrite(this.path, this.from, this.data.slice(this.from, this.to), true);
|
|
4117
4126
|
this.dirty = false;
|
|
4127
|
+
this.whole = false;
|
|
4128
|
+
this.from = Infinity;
|
|
4129
|
+
this.to = 0;
|
|
4118
4130
|
}
|
|
4119
4131
|
};
|
|
4120
4132
|
LocalFile = class {
|
|
@@ -4563,6 +4575,14 @@ var init_wasi_fds = __esm({
|
|
|
4563
4575
|
flushAll() {
|
|
4564
4576
|
for (const buffer of this.buffers.values()) buffer.flush();
|
|
4565
4577
|
}
|
|
4578
|
+
flushEarly() {
|
|
4579
|
+
for (const buffer of this.buffers.values()) {
|
|
4580
|
+
try {
|
|
4581
|
+
buffer.flush();
|
|
4582
|
+
} catch {
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4566
4586
|
flushPath(path) {
|
|
4567
4587
|
for (const [p, buffer] of this.buffers) if (within(p, path)) buffer.flush();
|
|
4568
4588
|
if (this.shared) this.kernel.call({ op: "fd-path-flush", path });
|
|
@@ -4958,9 +4978,24 @@ var init_wasi_host = __esm({
|
|
|
4958
4978
|
listening;
|
|
4959
4979
|
o;
|
|
4960
4980
|
constructor(o) {
|
|
4961
|
-
|
|
4981
|
+
const { kernel } = o;
|
|
4982
|
+
const call2 = (req) => {
|
|
4983
|
+
if (req.op !== "fd-promote") this.fds.flushEarly();
|
|
4984
|
+
return kernel.call(req);
|
|
4985
|
+
};
|
|
4986
|
+
const sys = new Proxy(kernel.sys, {
|
|
4987
|
+
get: (target, name) => {
|
|
4988
|
+
const member = Reflect.get(target, name);
|
|
4989
|
+
if (typeof member !== "function") return member;
|
|
4990
|
+
return (...args) => {
|
|
4991
|
+
this.fds.flushEarly();
|
|
4992
|
+
return member.apply(target, args);
|
|
4993
|
+
};
|
|
4994
|
+
}
|
|
4995
|
+
});
|
|
4996
|
+
this.o = { ...o, kernel: { sys, call: call2 } };
|
|
4962
4997
|
this.startCwd = o.cwd;
|
|
4963
|
-
this.fds = new WasiFds(o.kernel, o.fs);
|
|
4998
|
+
this.fds = new WasiFds(this.o.kernel, o.fs);
|
|
4964
4999
|
if (o.shared) this.fds.share(o.shared, true);
|
|
4965
5000
|
else if (o.forked) this.fds.restore(o.forked.fds, o.forked.cloexec);
|
|
4966
5001
|
else this.fds.setup(o.cwd, o.inherited ?? [], o.preopenRoot === true);
|