sim 2.1.5-dev.70.1 → 2.1.5-dev.73.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/index.js +32 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14967,6 +14967,18 @@ async function saveStagedFile(body, target, force) {
|
|
|
14967
14967
|
}
|
|
14968
14968
|
}
|
|
14969
14969
|
async function saveToFile(body, target, force) {
|
|
14970
|
+
const embedded = embedStore.getStore();
|
|
14971
|
+
if (embedded) {
|
|
14972
|
+
if (!embedded.writeFile) {
|
|
14973
|
+
throw new SimApiError(`--output-file cannot save ${target} here: this surface has no machine to write to. Read the file instead, or pipe a text command with | to-sandbox <name>.`, 0);
|
|
14974
|
+
}
|
|
14975
|
+
const bytes2 = new Uint8Array(await new Response(body).arrayBuffer());
|
|
14976
|
+
const written = await embedded.writeFile(target, bytes2);
|
|
14977
|
+
if (!written) {
|
|
14978
|
+
throw new SimApiError(`Could not write ${target} on your machine — the workbench is not running yet; run any run_code call first, then retry.`, 0);
|
|
14979
|
+
}
|
|
14980
|
+
return;
|
|
14981
|
+
}
|
|
14970
14982
|
return saveStagedFile(body, target, force);
|
|
14971
14983
|
}
|
|
14972
14984
|
async function streamToStdout(body, output = process.stdout) {
|
|
@@ -15038,6 +15050,16 @@ function attachFileGet(files) {
|
|
|
15038
15050
|
import { constants } from "node:fs";
|
|
15039
15051
|
import { access, stat } from "node:fs/promises";
|
|
15040
15052
|
import { basename } from "node:path";
|
|
15053
|
+
function embeddedFileKey(path) {
|
|
15054
|
+
return path.startsWith("@") ? path.slice(1) : path;
|
|
15055
|
+
}
|
|
15056
|
+
function embeddedFileContent(embedded, path) {
|
|
15057
|
+
const key = embeddedFileKey(path);
|
|
15058
|
+
const content = embedded.fileArguments?.[key];
|
|
15059
|
+
if (content !== undefined)
|
|
15060
|
+
return content;
|
|
15061
|
+
throw new SimApiError(`Files on your machine are passed as @path: use @${key}. (If it does not exist yet, write it with run_code or | to-sandbox first.)`, 0);
|
|
15062
|
+
}
|
|
15041
15063
|
var CONTENT_TYPES = {
|
|
15042
15064
|
css: "text/css",
|
|
15043
15065
|
csv: "text/csv",
|
|
@@ -15071,6 +15093,14 @@ function contentTypeFor(name) {
|
|
|
15071
15093
|
return CONTENT_TYPES[extension] ?? "application/octet-stream";
|
|
15072
15094
|
}
|
|
15073
15095
|
async function localFile(path, override) {
|
|
15096
|
+
const embedded = embedStore.getStore();
|
|
15097
|
+
if (embedded) {
|
|
15098
|
+
const content = embeddedFileContent(embedded, path);
|
|
15099
|
+
const size2 = Buffer.byteLength(content);
|
|
15100
|
+
if (size2 === 0)
|
|
15101
|
+
throw new SimApiError(`${path} is empty`, 0);
|
|
15102
|
+
return { name: override ?? basename(embeddedFileKey(path)), size: size2 };
|
|
15103
|
+
}
|
|
15074
15104
|
let size;
|
|
15075
15105
|
try {
|
|
15076
15106
|
const stats = await stat(path);
|
|
@@ -15133,7 +15163,8 @@ async function uploadParts(client, workspaceId, session, transfer, blob) {
|
|
|
15133
15163
|
}
|
|
15134
15164
|
async function finishUploadSession(client, workspaceId, session, path) {
|
|
15135
15165
|
try {
|
|
15136
|
-
const
|
|
15166
|
+
const embedded = embedStore.getStore();
|
|
15167
|
+
const blob = embedded ? new Blob([embeddedFileContent(embedded, path)]) : await openAsBlob(path);
|
|
15137
15168
|
if (session.transfer.method === "put") {
|
|
15138
15169
|
await uploadPut(session.transfer, blob);
|
|
15139
15170
|
} else {
|