@ai-ecoverse/slicc-kernel 1.94.1 → 1.94.3
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 +1 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +186 -16
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.js +229 -31
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +186 -16
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +253 -55
- package/dist/process-worker.js.map +4 -4
- package/package.json +6 -5
|
@@ -399,6 +399,13 @@ var init_pages = __esm({
|
|
|
399
399
|
this.length = size;
|
|
400
400
|
this.stored = size;
|
|
401
401
|
}
|
|
402
|
+
refresh(size) {
|
|
403
|
+
if (this.pinned) return;
|
|
404
|
+
for (const page of [...this.pages.keys()]) if (!this.dirty.has(page)) this.drop(page);
|
|
405
|
+
const resized = this.length !== this.stored || this.shrink !== void 0;
|
|
406
|
+
if (this.shrink === void 0) this.stored = size;
|
|
407
|
+
this.length = resized ? Math.max(this.length, this.stored) : size;
|
|
408
|
+
}
|
|
402
409
|
evict() {
|
|
403
410
|
if (this.pinned) return;
|
|
404
411
|
let clean = (this.pages.size - this.dirty.size) * PAGE;
|
|
@@ -436,12 +443,32 @@ var init_ranged = __esm({
|
|
|
436
443
|
io;
|
|
437
444
|
pinned = false;
|
|
438
445
|
version;
|
|
446
|
+
watch;
|
|
447
|
+
seen = 0;
|
|
439
448
|
path;
|
|
440
|
-
constructor(io, path, size, version) {
|
|
449
|
+
constructor(io, path, size, version, watch) {
|
|
441
450
|
this.io = io;
|
|
442
451
|
this.path = path;
|
|
443
452
|
this.version = version;
|
|
444
453
|
this.pages = new Pages(size);
|
|
454
|
+
this.watch = watch;
|
|
455
|
+
if (watch) this.seen = watch.seen ?? watch.view.now();
|
|
456
|
+
}
|
|
457
|
+
fresh() {
|
|
458
|
+
const watch = this.watch;
|
|
459
|
+
if (!watch || this.pinned) return;
|
|
460
|
+
const { now, changed: changed2 } = watch.view.changedSince(this.seen, this.path);
|
|
461
|
+
this.seen = now;
|
|
462
|
+
if (!changed2) return;
|
|
463
|
+
let st;
|
|
464
|
+
try {
|
|
465
|
+
st = watch.stat(this.path);
|
|
466
|
+
} catch {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (watch.ino !== void 0 && st.ino !== watch.ino) return;
|
|
470
|
+
this.version = st.version;
|
|
471
|
+
this.pages.refresh(st.size);
|
|
445
472
|
}
|
|
446
473
|
get changed() {
|
|
447
474
|
return this.pages.changed;
|
|
@@ -453,6 +480,7 @@ var init_ranged = __esm({
|
|
|
453
480
|
this.pages.reset(this.pages.length);
|
|
454
481
|
}
|
|
455
482
|
size() {
|
|
483
|
+
this.fresh();
|
|
456
484
|
return this.pages.length;
|
|
457
485
|
}
|
|
458
486
|
fetch(runs) {
|
|
@@ -461,14 +489,17 @@ var init_ranged = __esm({
|
|
|
461
489
|
}
|
|
462
490
|
}
|
|
463
491
|
read(at, length) {
|
|
492
|
+
this.fresh();
|
|
464
493
|
this.fetch(this.pages.missing(at, length));
|
|
465
494
|
return this.pages.read(at, length);
|
|
466
495
|
}
|
|
467
496
|
readInto(at, out) {
|
|
497
|
+
this.fresh();
|
|
468
498
|
this.fetch(this.pages.missing(at, out.length));
|
|
469
499
|
return this.pages.readInto(at, out);
|
|
470
500
|
}
|
|
471
501
|
write(at, bytes) {
|
|
502
|
+
this.fresh();
|
|
472
503
|
this.fetch(this.pages.partial(at, bytes.length));
|
|
473
504
|
this.pages.write(at, bytes);
|
|
474
505
|
if (!this.pinned && this.pages.dirtyBytes >= WRITEBACK) this.flush();
|
|
@@ -616,6 +647,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
616
647
|
};
|
|
617
648
|
const entry = (p) => [p, p.slice(0, p.lastIndexOf("/")) || "/"];
|
|
618
649
|
return {
|
|
650
|
+
...bridge.changes ? { changes: bridge.changes } : {},
|
|
619
651
|
readFile: (p) => bridge.readFile(p),
|
|
620
652
|
readdir: (p) => bridge.readdir(p),
|
|
621
653
|
readdirStat: (p) => {
|
|
@@ -666,6 +698,9 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
666
698
|
pwrite: (p, at, bytes, transfer) => rewriting(p, () => bridge.pwrite?.(p, at, bytes, transfer)),
|
|
667
699
|
truncate: (p, size) => rewriting(p, () => bridge.truncate?.(p, size))
|
|
668
700
|
} : {},
|
|
701
|
+
...bridge.append ? {
|
|
702
|
+
append: (p, bytes) => rewriting(p, () => bridge.append(p, bytes))
|
|
703
|
+
} : {},
|
|
669
704
|
...bridge.owners ? { owners: true } : {},
|
|
670
705
|
...bridge.links ? { links: true } : {},
|
|
671
706
|
invalidate,
|
|
@@ -681,7 +716,10 @@ function pinnedIo(bridge, handle, rewriting) {
|
|
|
681
716
|
writeFile: (p, bytes, open) => rewriting(p, () => io.writeFile(p, bytes, open)),
|
|
682
717
|
pread: (p, at, n, version) => pread(p, at, n, version),
|
|
683
718
|
pwrite: (p, at, bytes, transfer) => rewriting(p, () => pwrite(p, at, bytes, transfer)),
|
|
684
|
-
truncate: (p, size) => rewriting(p, () => truncate(p, size))
|
|
719
|
+
truncate: (p, size) => rewriting(p, () => truncate(p, size)),
|
|
720
|
+
...io.append ? {
|
|
721
|
+
append: (p, bytes) => rewriting(p, () => io.append(p, bytes))
|
|
722
|
+
} : {}
|
|
685
723
|
};
|
|
686
724
|
}
|
|
687
725
|
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, FS_GEN, RING, RING_SIZE, SLOT, SHARED_IDS_BYTES, StatCache;
|
|
@@ -708,16 +746,20 @@ var init_wasi_files = __esm({
|
|
|
708
746
|
fs;
|
|
709
747
|
where;
|
|
710
748
|
ranged;
|
|
749
|
+
watch;
|
|
750
|
+
seen = 0;
|
|
711
751
|
maxFile;
|
|
712
752
|
handle;
|
|
713
|
-
constructor(fs, path, empty, maxFile, size, version) {
|
|
753
|
+
constructor(fs, path, empty, maxFile, size, version, watch) {
|
|
714
754
|
this.fs = fs;
|
|
715
755
|
this.where = path;
|
|
716
756
|
this.maxFile = maxFile;
|
|
717
757
|
const { pread, pwrite, truncate } = fs;
|
|
758
|
+
this.watch = watch;
|
|
759
|
+
this.seen = watch?.seen ?? watch?.view.now() ?? 0;
|
|
718
760
|
if (size !== void 0 && pread && pwrite && truncate) {
|
|
719
761
|
const io = { pread: pread.bind(fs), pwrite: pwrite.bind(fs), truncate: truncate.bind(fs) };
|
|
720
|
-
this.ranged = new RangedFile(io, path, size, version);
|
|
762
|
+
this.ranged = new RangedFile(io, path, size, version, watch);
|
|
721
763
|
if (empty) this.truncate(0);
|
|
722
764
|
} else if (empty) {
|
|
723
765
|
this.data = new Uint8Array(0);
|
|
@@ -743,7 +785,14 @@ var init_wasi_files = __esm({
|
|
|
743
785
|
else this.load();
|
|
744
786
|
}
|
|
745
787
|
load() {
|
|
788
|
+
const view = this.watch?.view;
|
|
789
|
+
if (this.data && view && !this.dirty) {
|
|
790
|
+
const { now, changed: changed2 } = view.changedSince(this.seen, this.path);
|
|
791
|
+
this.seen = now;
|
|
792
|
+
if (changed2) this.data = void 0;
|
|
793
|
+
}
|
|
746
794
|
if (!this.data) {
|
|
795
|
+
this.seen = view?.now() ?? 0;
|
|
747
796
|
this.data = this.fs.readFile(this.path);
|
|
748
797
|
this.length = this.data.length;
|
|
749
798
|
}
|
|
@@ -782,6 +831,17 @@ var init_wasi_files = __esm({
|
|
|
782
831
|
this.length = Math.max(this.length, end);
|
|
783
832
|
return bytes.length;
|
|
784
833
|
}
|
|
834
|
+
append(bytes) {
|
|
835
|
+
const { append } = this.fs;
|
|
836
|
+
if (!append || this.orphaned) return void 0;
|
|
837
|
+
this.flush();
|
|
838
|
+
const end = append.call(this.fs, this.path, bytes);
|
|
839
|
+
if (!this.ranged) {
|
|
840
|
+
this.data = void 0;
|
|
841
|
+
this.length = 0;
|
|
842
|
+
}
|
|
843
|
+
return end;
|
|
844
|
+
}
|
|
785
845
|
truncate(size) {
|
|
786
846
|
this.fits(size);
|
|
787
847
|
this.dirty = true;
|
|
@@ -860,6 +920,14 @@ var init_wasi_files = __esm({
|
|
|
860
920
|
return this.buffer.pwrite(bytes, at);
|
|
861
921
|
}
|
|
862
922
|
write(bytes) {
|
|
923
|
+
if (this.append && bytes.length > 0) {
|
|
924
|
+
this.buffer.fits(this.buffer.size() + bytes.length);
|
|
925
|
+
const end = this.buffer.append(bytes);
|
|
926
|
+
if (end !== void 0) {
|
|
927
|
+
this.offset = end;
|
|
928
|
+
return bytes.length;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
863
931
|
if (this.append) this.offset = this.buffer.size();
|
|
864
932
|
const n = this.buffer.pwrite(bytes, this.offset);
|
|
865
933
|
this.offset += n;
|
|
@@ -1445,6 +1513,7 @@ var init_sync_fs_wire = __esm({
|
|
|
1445
1513
|
"kept",
|
|
1446
1514
|
"pread",
|
|
1447
1515
|
"pwrite",
|
|
1516
|
+
"append",
|
|
1448
1517
|
"truncate",
|
|
1449
1518
|
"chown",
|
|
1450
1519
|
"lchown",
|
|
@@ -2131,12 +2200,23 @@ var init_wasi_fds = __esm({
|
|
|
2131
2200
|
const made = !existing && this.createNew(path, oflags);
|
|
2132
2201
|
const empty = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
2133
2202
|
if (existing?.ranged) this.fs.invalidate?.();
|
|
2203
|
+
const seen = this.fs.changes?.now();
|
|
2134
2204
|
const st = existing?.ranged || !existing ? this.fs.stat(path) : existing;
|
|
2135
2205
|
const ranged = st.ranged ? st.size : void 0;
|
|
2136
2206
|
const asked = (want & 4 ? HOLD_READ : 0) | (want & 2 ? HOLD_WRITE : 0) | (made ? HOLD_CREATED : 0);
|
|
2137
2207
|
const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0);
|
|
2138
2208
|
const io = handle !== void 0 && this.fs.pinned ? this.fs.pinned(handle) : this.fs;
|
|
2139
|
-
const
|
|
2209
|
+
const view = this.fs.changes;
|
|
2210
|
+
const watch = view && {
|
|
2211
|
+
view,
|
|
2212
|
+
ino: st.ino,
|
|
2213
|
+
seen,
|
|
2214
|
+
stat: (at) => {
|
|
2215
|
+
this.fs.invalidate?.();
|
|
2216
|
+
return this.fs.stat(at);
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
const buffer = new FileBuffer(io, path, empty, st.maxFile, ranged, st.version, watch);
|
|
2140
2220
|
buffer.handle = handle;
|
|
2141
2221
|
this.buffers.set(path, buffer);
|
|
2142
2222
|
const id = this.identity(st);
|
|
@@ -4025,7 +4105,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4025
4105
|
var init_version = __esm({
|
|
4026
4106
|
"src/version.ts"() {
|
|
4027
4107
|
"use strict";
|
|
4028
|
-
KERNEL_VERSION = true ? "1.94.
|
|
4108
|
+
KERNEL_VERSION = true ? "1.94.3" : "0.0.0-dev";
|
|
4029
4109
|
OS_RELEASE = "6.0.0-slicc";
|
|
4030
4110
|
}
|
|
4031
4111
|
});
|
|
@@ -4084,7 +4164,8 @@ var init_js_kernel = __esm({
|
|
|
4084
4164
|
"fd-read",
|
|
4085
4165
|
"fd-write",
|
|
4086
4166
|
"fd-close",
|
|
4087
|
-
"fd-open-clipboard"
|
|
4167
|
+
"fd-open-clipboard",
|
|
4168
|
+
"net-ws-ready"
|
|
4088
4169
|
]);
|
|
4089
4170
|
JsKernel = class {
|
|
4090
4171
|
header;
|
|
@@ -5055,14 +5136,19 @@ function badPort(url) {
|
|
|
5055
5136
|
const port3 = url.port ? Number(url.port) : 0;
|
|
5056
5137
|
return port3 !== 0 && BAD_PORTS.has(port3);
|
|
5057
5138
|
}
|
|
5058
|
-
function
|
|
5059
|
-
const
|
|
5060
|
-
|
|
5061
|
-
|
|
5139
|
+
function checkUrl(url) {
|
|
5140
|
+
const parsed = new URL(url);
|
|
5141
|
+
const { protocol } = parsed;
|
|
5142
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
5143
|
+
throw failed(new JsCallError("EPROTONOSUPPORT", protocol));
|
|
5062
5144
|
}
|
|
5063
|
-
if (badPort(
|
|
5064
|
-
throw failed(new JsCallError("EACCES", `bad port: ${
|
|
5145
|
+
if (badPort(parsed) && !local2(url)) {
|
|
5146
|
+
throw failed(new JsCallError("EACCES", `bad port: ${url}`));
|
|
5065
5147
|
}
|
|
5148
|
+
}
|
|
5149
|
+
function rewrite(hop, status2, location) {
|
|
5150
|
+
const next2 = new URL(location, hop.url);
|
|
5151
|
+
checkUrl(next2.href);
|
|
5066
5152
|
if (local2(next2.href) && !local2(hop.url)) {
|
|
5067
5153
|
const from = new URL(hop.url).origin;
|
|
5068
5154
|
throw failed(
|
|
@@ -5288,7 +5374,7 @@ function fetchOp(kernel) {
|
|
|
5288
5374
|
} catch (err) {
|
|
5289
5375
|
settle();
|
|
5290
5376
|
await close(handle);
|
|
5291
|
-
throw signal.aborted ? signal.reason :
|
|
5377
|
+
throw signal.aborted ? signal.reason : new TypeError("terminated", { cause: err });
|
|
5292
5378
|
}
|
|
5293
5379
|
const bytes = r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
5294
5380
|
if (bytes.length > 0) {
|
|
@@ -5322,7 +5408,6 @@ function fetchOp(kernel) {
|
|
|
5322
5408
|
stream = stream.pipeThrough(
|
|
5323
5409
|
new DecompressionStream(format)
|
|
5324
5410
|
);
|
|
5325
|
-
headers.delete("content-encoding");
|
|
5326
5411
|
headers.delete("content-length");
|
|
5327
5412
|
}
|
|
5328
5413
|
const response = new Response(stream, {
|
|
@@ -5345,12 +5430,7 @@ function fetchOp(kernel) {
|
|
|
5345
5430
|
signal.throwIfAborted();
|
|
5346
5431
|
const { protocol } = new URL(request.url);
|
|
5347
5432
|
if (protocol === "data:") return dataResponse(request);
|
|
5348
|
-
|
|
5349
|
-
throw failed(new JsCallError("EPROTONOSUPPORT", protocol));
|
|
5350
|
-
}
|
|
5351
|
-
if (badPort(new URL(request.url))) {
|
|
5352
|
-
throw failed(new JsCallError("EACCES", `bad port: ${request.url}`));
|
|
5353
|
-
}
|
|
5433
|
+
checkUrl(request.url);
|
|
5354
5434
|
let known = await traitsAt(request.url);
|
|
5355
5435
|
if (!known.manualRedirects && request.redirect !== "follow") {
|
|
5356
5436
|
throw failed(new JsCallError("ENOTSUP", `redirect: ${request.redirect}`));
|
|
@@ -5375,7 +5455,8 @@ function fetchOp(kernel) {
|
|
|
5375
5455
|
return respond(head, hop.method, redirected, known.encodedBodies, signal);
|
|
5376
5456
|
}
|
|
5377
5457
|
await close(head.handle);
|
|
5378
|
-
if (request.redirect === "error")
|
|
5458
|
+
if (request.redirect === "error")
|
|
5459
|
+
throw failed(new JsCallError("EREDIRECT", "unexpected redirect"));
|
|
5379
5460
|
if (hops >= MAX_REDIRECTS) throw failed(new JsCallError("ELOOP", hop.url));
|
|
5380
5461
|
[hop, known] = await redirect(hop, head.status, location, known);
|
|
5381
5462
|
}
|
|
@@ -5691,6 +5772,61 @@ var init_wasi_errno = __esm({
|
|
|
5691
5772
|
}
|
|
5692
5773
|
});
|
|
5693
5774
|
|
|
5775
|
+
// src/fs/changes.ts
|
|
5776
|
+
function changeHash(path) {
|
|
5777
|
+
let h = 2166136261;
|
|
5778
|
+
for (let i = 0; i < path.length; i++) {
|
|
5779
|
+
h ^= path.charCodeAt(i);
|
|
5780
|
+
h = Math.imul(h, 16777619);
|
|
5781
|
+
}
|
|
5782
|
+
return h === 0 ? 1 : h;
|
|
5783
|
+
}
|
|
5784
|
+
function normal(path) {
|
|
5785
|
+
const parts = [];
|
|
5786
|
+
for (const part of path.split("/")) {
|
|
5787
|
+
if (part === "" || part === ".") continue;
|
|
5788
|
+
if (part === "..") parts.pop();
|
|
5789
|
+
else parts.push(part);
|
|
5790
|
+
}
|
|
5791
|
+
return `/${parts.join("/")}`;
|
|
5792
|
+
}
|
|
5793
|
+
var GEN2, RING2, RING_SIZE2, SLOT2, CHANGES_BYTES, ChangeView;
|
|
5794
|
+
var init_changes = __esm({
|
|
5795
|
+
"src/fs/changes.ts"() {
|
|
5796
|
+
"use strict";
|
|
5797
|
+
GEN2 = 0;
|
|
5798
|
+
RING2 = 1;
|
|
5799
|
+
RING_SIZE2 = 4096;
|
|
5800
|
+
SLOT2 = 2;
|
|
5801
|
+
CHANGES_BYTES = (RING2 + RING_SIZE2 * SLOT2) * 4;
|
|
5802
|
+
ChangeView = class {
|
|
5803
|
+
view;
|
|
5804
|
+
constructor(sab) {
|
|
5805
|
+
this.view = new Int32Array(sab);
|
|
5806
|
+
}
|
|
5807
|
+
now() {
|
|
5808
|
+
return Atomics.load(this.view, GEN2);
|
|
5809
|
+
}
|
|
5810
|
+
changedSince(seen, path) {
|
|
5811
|
+
const now = Atomics.load(this.view, GEN2);
|
|
5812
|
+
const distance = now - seen >>> 0;
|
|
5813
|
+
if (distance === 0) return { now, changed: false };
|
|
5814
|
+
if (distance > RING_SIZE2) return { now, changed: true };
|
|
5815
|
+
const hash = changeHash(normal(path));
|
|
5816
|
+
for (let i = 1; i <= distance; i++) {
|
|
5817
|
+
const g = seen + i | 0;
|
|
5818
|
+
const at = RING2 + (g & RING_SIZE2 - 1) * SLOT2;
|
|
5819
|
+
if (Atomics.load(this.view, at) !== g) return { now, changed: true };
|
|
5820
|
+
const hit = Atomics.load(this.view, at + 1) === hash;
|
|
5821
|
+
if (Atomics.load(this.view, at) !== g) return { now, changed: true };
|
|
5822
|
+
if (hit) return { now, changed: true };
|
|
5823
|
+
}
|
|
5824
|
+
return { now, changed: false };
|
|
5825
|
+
}
|
|
5826
|
+
};
|
|
5827
|
+
}
|
|
5828
|
+
});
|
|
5829
|
+
|
|
5694
5830
|
// src/realm/sync-sab-bridge.ts
|
|
5695
5831
|
function syncCallCount() {
|
|
5696
5832
|
return calls;
|
|
@@ -5797,7 +5933,8 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
5797
5933
|
},
|
|
5798
5934
|
truncate: (path, length) => {
|
|
5799
5935
|
changing({ op: "truncate", path, length, ...id }, path);
|
|
5800
|
-
}
|
|
5936
|
+
},
|
|
5937
|
+
append: (path, body) => json2({ op: "append", path, body, ...id }, path)
|
|
5801
5938
|
});
|
|
5802
5939
|
return {
|
|
5803
5940
|
...io({}),
|
|
@@ -5898,6 +6035,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
5898
6035
|
},
|
|
5899
6036
|
...opts.owners ? { owners: true } : {},
|
|
5900
6037
|
...opts.links ? { links: true } : {},
|
|
6038
|
+
...opts.changes ? { changes: new ChangeView(opts.changes) } : {},
|
|
5901
6039
|
access: (path, mode, kind = "access", nofollow) => {
|
|
5902
6040
|
run({ op: "access", path, mode, arg2: kind, ...nofollow ? { nofollow } : {} }, path);
|
|
5903
6041
|
},
|
|
@@ -5914,6 +6052,7 @@ var PATH_OPS, calls;
|
|
|
5914
6052
|
var init_sync_sab_bridge = __esm({
|
|
5915
6053
|
"src/realm/sync-sab-bridge.ts"() {
|
|
5916
6054
|
"use strict";
|
|
6055
|
+
init_changes();
|
|
5917
6056
|
init_cpu_clock();
|
|
5918
6057
|
init_sync_fs_wire();
|
|
5919
6058
|
init_sync_sab_wire();
|
|
@@ -5954,6 +6093,34 @@ function toMs(v) {
|
|
|
5954
6093
|
if (v === void 0 || v === null) return void 0;
|
|
5955
6094
|
return v instanceof Date ? v.getTime() : v;
|
|
5956
6095
|
}
|
|
6096
|
+
function needsLoad(s, view, path) {
|
|
6097
|
+
if (s.loaded && view && !s.dirty) {
|
|
6098
|
+
const { now, changed: changed2 } = view.changedSince(s.seen ?? 0, path());
|
|
6099
|
+
s.seen = now;
|
|
6100
|
+
if (changed2) {
|
|
6101
|
+
s.loaded = false;
|
|
6102
|
+
s.stat = void 0;
|
|
6103
|
+
}
|
|
6104
|
+
}
|
|
6105
|
+
if (s.loaded) return false;
|
|
6106
|
+
s.seen = view?.now();
|
|
6107
|
+
return true;
|
|
6108
|
+
}
|
|
6109
|
+
function rangedFileOf(bridge, call2, path, io) {
|
|
6110
|
+
const seen = bridge.changes?.now();
|
|
6111
|
+
const stat = () => call2(() => bridge.stat(path()));
|
|
6112
|
+
const st = stat();
|
|
6113
|
+
const watch = bridge.changes && { view: bridge.changes, ino: st.ino, seen, stat };
|
|
6114
|
+
return new RangedFile(io, path(), st.size, st.version, watch);
|
|
6115
|
+
}
|
|
6116
|
+
function unlessIo(op) {
|
|
6117
|
+
try {
|
|
6118
|
+
return op();
|
|
6119
|
+
} catch (err) {
|
|
6120
|
+
if (err.errno === wasiErrno("EIO")) return void 0;
|
|
6121
|
+
throw err;
|
|
6122
|
+
}
|
|
6123
|
+
}
|
|
5957
6124
|
function wantOf2(flags) {
|
|
5958
6125
|
if (flags & O_PATH) return 0;
|
|
5959
6126
|
const mode = flags & O_ACCMODE;
|
|
@@ -6102,7 +6269,7 @@ function createHelpers(Fs, ops) {
|
|
|
6102
6269
|
}
|
|
6103
6270
|
function ensureLoaded(node) {
|
|
6104
6271
|
const s = node.live;
|
|
6105
|
-
if (s.
|
|
6272
|
+
if (!needsLoad(s, bridgeOf(node).changes, () => liveNodePath(linked.holder(node)))) return;
|
|
6106
6273
|
const bytes = call2(() => fileIo(node).readFile(liveNodePath(linked.holder(node))));
|
|
6107
6274
|
s.data = bytes;
|
|
6108
6275
|
s.len = bytes.length;
|
|
@@ -6119,8 +6286,7 @@ function createHelpers(Fs, ops) {
|
|
|
6119
6286
|
pwrite: (_, at, bytes, transfer) => file().pwrite(path(), at, bytes, transfer),
|
|
6120
6287
|
truncate: (_, size) => file().truncate(path(), size)
|
|
6121
6288
|
};
|
|
6122
|
-
|
|
6123
|
-
s.ranged = new RangedFile(io, path(), st.size, st.version);
|
|
6289
|
+
s.ranged = rangedFileOf(bridge, call2, path, io);
|
|
6124
6290
|
return s.ranged;
|
|
6125
6291
|
}
|
|
6126
6292
|
function ensureCapacity(node, need) {
|
|
@@ -6401,6 +6567,27 @@ function createNodeOps(h) {
|
|
|
6401
6567
|
}
|
|
6402
6568
|
};
|
|
6403
6569
|
}
|
|
6570
|
+
function appendThrough(h, stream, bytes) {
|
|
6571
|
+
const node = stream.node;
|
|
6572
|
+
const s = node.live;
|
|
6573
|
+
const append = pinnedIo2(h.bridgeOf(node), s.handle).append;
|
|
6574
|
+
if (!append) return false;
|
|
6575
|
+
const body = bytes();
|
|
6576
|
+
const at = liveNodePath(h.linked.holder(node));
|
|
6577
|
+
const after = unlessIo(() => {
|
|
6578
|
+
h.flushNode(node);
|
|
6579
|
+
return h.call(() => append(at, body));
|
|
6580
|
+
});
|
|
6581
|
+
if (after === void 0) return false;
|
|
6582
|
+
if (!s.ranged) {
|
|
6583
|
+
s.data = void 0;
|
|
6584
|
+
s.loaded = false;
|
|
6585
|
+
s.len = 0;
|
|
6586
|
+
}
|
|
6587
|
+
s.stat = void 0;
|
|
6588
|
+
stream.position = after - body.length;
|
|
6589
|
+
return true;
|
|
6590
|
+
}
|
|
6404
6591
|
function createStreamOps(h) {
|
|
6405
6592
|
const { Fs, statOf, ensureLoaded, ensureCapacity, flushNode, bridgeOf, rangedOf } = h;
|
|
6406
6593
|
const held = (stream, change) => {
|
|
@@ -6535,10 +6722,12 @@ function createStreamOps(h) {
|
|
|
6535
6722
|
const s = node.live;
|
|
6536
6723
|
const end = position + length;
|
|
6537
6724
|
if (s.maxFile !== void 0 && end > s.maxFile) throw new Fs.ErrnoError(wasiErrno("EFBIG"));
|
|
6725
|
+
const bytes = () => new Uint8Array(buffer.buffer, buffer.byteOffset + offset, length).slice();
|
|
6726
|
+
if (stream.flags & O_APPEND4 && appendThrough(h, stream, bytes)) return length;
|
|
6538
6727
|
const ranged = rangedOf(node);
|
|
6539
6728
|
if (ranged) {
|
|
6540
|
-
const
|
|
6541
|
-
h.call(() => ranged.write(position,
|
|
6729
|
+
const bytes2 = new Uint8Array(buffer.buffer, buffer.byteOffset + offset, length);
|
|
6730
|
+
h.call(() => ranged.write(position, bytes2));
|
|
6542
6731
|
h.markDirty(node);
|
|
6543
6732
|
return length;
|
|
6544
6733
|
}
|
|
@@ -6885,7 +7074,7 @@ function readingLinks(Fs) {
|
|
|
6885
7074
|
}
|
|
6886
7075
|
};
|
|
6887
7076
|
}
|
|
6888
|
-
var S_IFDIR, S_IFREG, S_IFLNK, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR, SEEK_END, EARLY_WHOLE_FILE, O_ACCMODE, O_TRUNC, O_PATH, stale, opening;
|
|
7077
|
+
var S_IFDIR, S_IFREG, S_IFLNK, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR, SEEK_END, EARLY_WHOLE_FILE, O_APPEND4, O_ACCMODE, O_TRUNC, O_PATH, stale, opening;
|
|
6889
7078
|
var init_live_vfs_fs = __esm({
|
|
6890
7079
|
"src/realm/live-vfs-fs.ts"() {
|
|
6891
7080
|
"use strict";
|
|
@@ -6904,6 +7093,7 @@ var init_live_vfs_fs = __esm({
|
|
|
6904
7093
|
SEEK_CUR = 1;
|
|
6905
7094
|
SEEK_END = 2;
|
|
6906
7095
|
EARLY_WHOLE_FILE = 64 * 1024;
|
|
7096
|
+
O_APPEND4 = 1024;
|
|
6907
7097
|
O_ACCMODE = 3;
|
|
6908
7098
|
O_TRUNC = 512;
|
|
6909
7099
|
O_PATH = 2097152;
|
|
@@ -11751,7 +11941,11 @@ function kernelWrappers(imports, module, deps) {
|
|
|
11751
11941
|
holdWhileStopped(imports, new Int32Array(init.sab, 0, SAB_HEADER_I32), kernelGlue, deps.poll);
|
|
11752
11942
|
}
|
|
11753
11943
|
function bridgeFlags(init) {
|
|
11754
|
-
return {
|
|
11944
|
+
return {
|
|
11945
|
+
...init.owners ? { owners: true } : {},
|
|
11946
|
+
...init.links ? { links: true } : {},
|
|
11947
|
+
...init.changes ? { changes: init.changes } : {}
|
|
11948
|
+
};
|
|
11755
11949
|
}
|
|
11756
11950
|
function credSyncTransport(gated, early, cred) {
|
|
11757
11951
|
return {
|
|
@@ -14556,7 +14750,11 @@ function descriptors(init, fork, threads) {
|
|
|
14556
14750
|
return { inherited: init.fds ?? [], ...init.program.preopenRoot ? { preopenRoot: true } : {} };
|
|
14557
14751
|
}
|
|
14558
14752
|
function ownersOf(init) {
|
|
14559
|
-
return {
|
|
14753
|
+
return {
|
|
14754
|
+
...init.owners ? { owners: true } : {},
|
|
14755
|
+
...init.links ? { links: true } : {},
|
|
14756
|
+
...init.changes ? { changes: init.changes } : {}
|
|
14757
|
+
};
|
|
14560
14758
|
}
|
|
14561
14759
|
async function runWasiProcess(init, port3) {
|
|
14562
14760
|
captureBacktraces(init.env);
|