@computesdk/sandbox0 1.0.21 → 1.0.22
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/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -22856,17 +22856,44 @@ var _provider = defineProvider({
|
|
|
22856
22856
|
const second = await readViaCommand(`cat ${path}`);
|
|
22857
22857
|
return Buffer.byteLength(second) >= Buffer.byteLength(first) ? second : first;
|
|
22858
22858
|
};
|
|
22859
|
+
const readDirect = async () => {
|
|
22860
|
+
const decoder = new TextDecoder();
|
|
22861
|
+
const read = (suffix) => sandbox.readFile(`${base}.${suffix}`);
|
|
22862
|
+
try {
|
|
22863
|
+
const [out, err, outLen, errLen, code] = await withinCommandDeadline(
|
|
22864
|
+
Promise.all([read("out"), read("err"), read("outlen"), read("errlen"), read("code")]),
|
|
22865
|
+
deadline,
|
|
22866
|
+
timeout
|
|
22867
|
+
);
|
|
22868
|
+
const expected = (bytes) => Number.parseInt(decoder.decode(bytes).trim(), 10);
|
|
22869
|
+
if (out.byteLength !== expected(outLen) || err.byteLength !== expected(errLen)) {
|
|
22870
|
+
return void 0;
|
|
22871
|
+
}
|
|
22872
|
+
return [decoder.decode(out), decoder.decode(err), decoder.decode(code)];
|
|
22873
|
+
} catch (error) {
|
|
22874
|
+
if (error instanceof Sandbox0CommandTimeoutError) throw error;
|
|
22875
|
+
return void 0;
|
|
22876
|
+
}
|
|
22877
|
+
};
|
|
22859
22878
|
let stdout;
|
|
22860
22879
|
let stderr;
|
|
22861
22880
|
let codeText;
|
|
22862
|
-
|
|
22863
|
-
|
|
22864
|
-
stderr =
|
|
22865
|
-
|
|
22866
|
-
} finally {
|
|
22867
|
-
await readViaCommand(
|
|
22881
|
+
const direct = await readDirect();
|
|
22882
|
+
if (direct) {
|
|
22883
|
+
[stdout, stderr, codeText] = direct;
|
|
22884
|
+
void readViaCommand(
|
|
22868
22885
|
`rm -f ${base}.out ${base}.err ${base}.outlen ${base}.errlen ${base}.code`
|
|
22869
22886
|
).catch(() => void 0);
|
|
22887
|
+
} else {
|
|
22888
|
+
try {
|
|
22889
|
+
stdout = await readVerified(`${base}.out`, `${base}.outlen`);
|
|
22890
|
+
stderr = await readVerified(`${base}.err`, `${base}.errlen`);
|
|
22891
|
+
codeText = await readViaCommand(`cat ${base}.code 2>/dev/null`).catch(() => "");
|
|
22892
|
+
} finally {
|
|
22893
|
+
await readViaCommand(
|
|
22894
|
+
`rm -f ${base}.out ${base}.err ${base}.outlen ${base}.errlen ${base}.code`
|
|
22895
|
+
).catch(() => void 0);
|
|
22896
|
+
}
|
|
22870
22897
|
}
|
|
22871
22898
|
const fileExit = Number.parseInt(codeText.trim(), 10);
|
|
22872
22899
|
return {
|