@ai-ecoverse/slicc-kernel 1.147.7 → 1.147.8
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 -1
- package/dist/kernel-worker.js +3 -2
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +51 -30
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +3 -2
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +51 -30
- package/dist/process-worker.js.map +2 -2
- package/dist/types/process/js/js-context.d.ts +1 -0
- package/dist/types/process/js/js-io.d.ts +5 -0
- package/dist/types/process/js/js-sync.d.ts +1 -0
- package/package.json +2 -2
|
@@ -2588,6 +2588,12 @@ var init_js_kernel = __esm({
|
|
|
2588
2588
|
});
|
|
2589
2589
|
|
|
2590
2590
|
// src/process/js/js-io.ts
|
|
2591
|
+
function intoTarget(into, offset, length) {
|
|
2592
|
+
if (!into) return void 0;
|
|
2593
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset + length > into.length)
|
|
2594
|
+
throw Object.assign(new RangeError("read: the buffer is too small"), { code: "EINVAL" });
|
|
2595
|
+
return { into, at: offset };
|
|
2596
|
+
}
|
|
2591
2597
|
function typeOf(info) {
|
|
2592
2598
|
if (info.meta && "dir" in info.meta) return "directory";
|
|
2593
2599
|
if (info.meta && "device" in info.meta) return "device";
|
|
@@ -2673,7 +2679,7 @@ function openRequest(abs, o) {
|
|
|
2673
2679
|
function index2(n, what) {
|
|
2674
2680
|
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
2675
2681
|
}
|
|
2676
|
-
var CHUNK, MAX_IO, O_WRONLY, O_RDWR, O_APPEND, BLOCK, O_NONBLOCK_OPEN;
|
|
2682
|
+
var CHUNK, MAX_IO, MAX_PREAD, O_WRONLY, O_RDWR, O_APPEND, BLOCK, O_NONBLOCK_OPEN;
|
|
2677
2683
|
var init_js_io = __esm({
|
|
2678
2684
|
"src/process/js/js-io.ts"() {
|
|
2679
2685
|
"use strict";
|
|
@@ -2681,6 +2687,7 @@ var init_js_io = __esm({
|
|
|
2681
2687
|
init_js_kernel();
|
|
2682
2688
|
CHUNK = 64 * 1024;
|
|
2683
2689
|
MAX_IO = 1024 * 1024;
|
|
2690
|
+
MAX_PREAD = 16 * 1024 * 1024;
|
|
2684
2691
|
O_WRONLY = 1;
|
|
2685
2692
|
O_RDWR = 2;
|
|
2686
2693
|
O_APPEND = 1024;
|
|
@@ -7157,7 +7164,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
7157
7164
|
var init_version = __esm({
|
|
7158
7165
|
"src/version.ts"() {
|
|
7159
7166
|
"use strict";
|
|
7160
|
-
KERNEL_VERSION = true ? "1.147.
|
|
7167
|
+
KERNEL_VERSION = true ? "1.147.8" : "0.0.0-dev";
|
|
7161
7168
|
OS_RELEASE = "6.0.0-slicc";
|
|
7162
7169
|
}
|
|
7163
7170
|
});
|
|
@@ -12085,6 +12092,23 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
12085
12092
|
const live = () => {
|
|
12086
12093
|
if (!open) throw new JsCallError("EBADF", path);
|
|
12087
12094
|
};
|
|
12095
|
+
const pread = (position, length, target) => {
|
|
12096
|
+
index2(position, "read");
|
|
12097
|
+
index2(length, "read");
|
|
12098
|
+
const parts = [];
|
|
12099
|
+
let got = 0;
|
|
12100
|
+
do {
|
|
12101
|
+
live();
|
|
12102
|
+
const max = Math.min(length - got, MAX_PREAD);
|
|
12103
|
+
if (max <= 0) break;
|
|
12104
|
+
const chunk = kernel.bytes({ op: "fd-pread", fd, offset: position + got, max });
|
|
12105
|
+
if (chunk.length === 0) break;
|
|
12106
|
+
if (target) target.into.set(chunk, target.at + got);
|
|
12107
|
+
else parts.push(chunk);
|
|
12108
|
+
got += chunk.length;
|
|
12109
|
+
} while (got < length);
|
|
12110
|
+
return target ? got : joined(parts, got);
|
|
12111
|
+
};
|
|
12088
12112
|
const file = {
|
|
12089
12113
|
fd,
|
|
12090
12114
|
path,
|
|
@@ -12092,21 +12116,11 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
12092
12116
|
live();
|
|
12093
12117
|
return kernel.json({ op: "fd-vfs-stat", fd }).size;
|
|
12094
12118
|
},
|
|
12119
|
+
readInto(position, into, offset = 0, length = into.length - offset) {
|
|
12120
|
+
return pread(position, length, intoTarget(into, offset, length));
|
|
12121
|
+
},
|
|
12095
12122
|
read(position, length) {
|
|
12096
|
-
|
|
12097
|
-
index2(length, "read");
|
|
12098
|
-
const parts = [];
|
|
12099
|
-
let got = 0;
|
|
12100
|
-
do {
|
|
12101
|
-
live();
|
|
12102
|
-
const max = Math.min(length - got, MAX_IO);
|
|
12103
|
-
if (max <= 0) break;
|
|
12104
|
-
const chunk = kernel.bytes({ op: "fd-pread", fd, offset: position + got, max });
|
|
12105
|
-
if (chunk.length === 0) break;
|
|
12106
|
-
parts.push(chunk);
|
|
12107
|
-
got += chunk.length;
|
|
12108
|
-
} while (got < length);
|
|
12109
|
-
return joined(parts, got);
|
|
12123
|
+
return pread(position, length);
|
|
12110
12124
|
},
|
|
12111
12125
|
write(position, data) {
|
|
12112
12126
|
index2(position, "write");
|
|
@@ -15772,6 +15786,23 @@ function fileHandle(kernel, fd, path, append, forget) {
|
|
|
15772
15786
|
const live = () => {
|
|
15773
15787
|
if (!open) throw new JsCallError("EBADF", path);
|
|
15774
15788
|
};
|
|
15789
|
+
const pread = async (position, length, target) => {
|
|
15790
|
+
index2(position, "read");
|
|
15791
|
+
index2(length, "read");
|
|
15792
|
+
const parts = [];
|
|
15793
|
+
let got = 0;
|
|
15794
|
+
do {
|
|
15795
|
+
live();
|
|
15796
|
+
const max = Math.min(length - got, MAX_PREAD);
|
|
15797
|
+
if (max <= 0) break;
|
|
15798
|
+
const chunk = await kernel.bytes({ op: "fd-pread", fd, offset: position + got, max });
|
|
15799
|
+
if (chunk.length === 0) break;
|
|
15800
|
+
if (target) target.into.set(chunk, target.at + got);
|
|
15801
|
+
else parts.push(chunk);
|
|
15802
|
+
got += chunk.length;
|
|
15803
|
+
} while (got < length);
|
|
15804
|
+
return target ? got : joined(parts, got);
|
|
15805
|
+
};
|
|
15775
15806
|
const file = {
|
|
15776
15807
|
fd,
|
|
15777
15808
|
path,
|
|
@@ -15780,21 +15811,11 @@ function fileHandle(kernel, fd, path, append, forget) {
|
|
|
15780
15811
|
const s = await kernel.json({ op: "fd-vfs-stat", fd });
|
|
15781
15812
|
return s.size;
|
|
15782
15813
|
},
|
|
15814
|
+
async readInto(position, into, offset = 0, length = into.length - offset) {
|
|
15815
|
+
return await pread(position, length, intoTarget(into, offset, length));
|
|
15816
|
+
},
|
|
15783
15817
|
async read(position, length) {
|
|
15784
|
-
|
|
15785
|
-
index2(length, "read");
|
|
15786
|
-
const parts = [];
|
|
15787
|
-
let got = 0;
|
|
15788
|
-
do {
|
|
15789
|
-
live();
|
|
15790
|
-
const max = Math.min(length - got, MAX_IO);
|
|
15791
|
-
if (max <= 0) break;
|
|
15792
|
-
const chunk = await kernel.bytes({ op: "fd-pread", fd, offset: position + got, max });
|
|
15793
|
-
if (chunk.length === 0) break;
|
|
15794
|
-
parts.push(chunk);
|
|
15795
|
-
got += chunk.length;
|
|
15796
|
-
} while (got < length);
|
|
15797
|
-
return joined(parts, got);
|
|
15818
|
+
return await pread(position, length);
|
|
15798
15819
|
},
|
|
15799
15820
|
async write(position, data) {
|
|
15800
15821
|
index2(position, "write");
|