@tscircuit/cli 0.1.218 → 0.1.219

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.
Files changed (2) hide show
  1. package/dist/main.js +49 -12
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -63215,7 +63215,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
63215
63215
  import { execSync as execSync2 } from "node:child_process";
63216
63216
  var import_semver2 = __toESM2(require_semver2(), 1);
63217
63217
  // package.json
63218
- var version = "0.1.217";
63218
+ var version = "0.1.218";
63219
63219
  var package_default = {
63220
63220
  name: "@tscircuit/cli",
63221
63221
  version,
@@ -63225,7 +63225,7 @@ var package_default = {
63225
63225
  "@biomejs/biome": "^1.9.4",
63226
63226
  "@tscircuit/circuit-json-util": "0.0.67",
63227
63227
  "@tscircuit/fake-snippets": "^0.0.87",
63228
- "@tscircuit/file-server": "^0.0.28",
63228
+ "@tscircuit/file-server": "^0.0.30",
63229
63229
  "@tscircuit/math-utils": "0.0.21",
63230
63230
  "@tscircuit/props": "^0.0.315",
63231
63231
  "@tscircuit/runframe": "^0.0.941",
@@ -64194,12 +64194,10 @@ import { z as z10 } from "zod";
64194
64194
  import { z as z11 } from "zod";
64195
64195
  import { Buffer as Buffer2 } from "node:buffer";
64196
64196
  import { z as z12 } from "zod";
64197
- import { Buffer as Buffer22 } from "node:buffer";
64198
64197
  import { z as z13 } from "zod";
64199
64198
  import { z as z14 } from "zod";
64200
64199
  import { z as z15 } from "zod";
64201
64200
  import { z as z16 } from "zod";
64202
- import { Buffer as Buffer3 } from "node:buffer";
64203
64201
  import { z as z17 } from "zod";
64204
64202
  import { z as z18 } from "zod";
64205
64203
  import { z as z19 } from "zod";
@@ -64695,6 +64693,15 @@ var delete_default = withRouteSpec({
64695
64693
  }
64696
64694
  return ctx.json(null, { status: 204 });
64697
64695
  });
64696
+ var decodeBase64ToUint8Array = (base64) => {
64697
+ const buffer = Buffer2.from(base64, "base64");
64698
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
64699
+ };
64700
+ var uint8ArrayToArrayBuffer = (view) => {
64701
+ const buffer = new ArrayBuffer(view.byteLength);
64702
+ new Uint8Array(buffer).set(view);
64703
+ return buffer;
64704
+ };
64698
64705
  var download_default = withRouteSpec({
64699
64706
  methods: ["GET"],
64700
64707
  queryParams: z11.object({
@@ -64708,10 +64715,20 @@ var download_default = withRouteSpec({
64708
64715
  return new Response("File not found", { status: 404 });
64709
64716
  }
64710
64717
  const isText = file.text_content !== undefined;
64711
- const body = isText ? file.text_content : Buffer2.from(file.binary_content_b64, "base64");
64712
- return new Response(body, {
64718
+ if (!isText && file.binary_content_b64) {
64719
+ const binaryBody = decodeBase64ToUint8Array(file.binary_content_b64);
64720
+ const responseBody = uint8ArrayToArrayBuffer(binaryBody);
64721
+ return new Response(responseBody, {
64722
+ headers: {
64723
+ "Content-Type": "application/octet-stream",
64724
+ "Content-Disposition": `attachment; filename="${file.file_path.split("/").pop()}"`,
64725
+ "Content-Length": binaryBody.byteLength.toString()
64726
+ }
64727
+ });
64728
+ }
64729
+ return new Response(file.text_content, {
64713
64730
  headers: {
64714
- "Content-Type": isText ? "text/plain" : "application/octet-stream",
64731
+ "Content-Type": "text/plain",
64715
64732
  "Content-Disposition": `attachment; filename="${file.file_path.split("/").pop()}"`
64716
64733
  }
64717
64734
  });
@@ -64728,10 +64745,20 @@ var file_path_default = withRouteSpec({
64728
64745
  return new Response("File not found", { status: 404 });
64729
64746
  }
64730
64747
  const isText = file.text_content !== undefined;
64731
- const body = isText ? file.text_content : Buffer22.from(file.binary_content_b64, "base64");
64732
- return new Response(body, {
64748
+ if (!isText && file.binary_content_b64) {
64749
+ const binaryBody = decodeBase64ToUint8Array(file.binary_content_b64);
64750
+ const responseBody = uint8ArrayToArrayBuffer(binaryBody);
64751
+ return new Response(responseBody, {
64752
+ headers: {
64753
+ "Content-Type": "application/octet-stream",
64754
+ "Content-Disposition": `attachment; filename="${file.file_path.split("/").pop()}"`,
64755
+ "Content-Length": binaryBody.byteLength.toString()
64756
+ }
64757
+ });
64758
+ }
64759
+ return new Response(file.text_content, {
64733
64760
  headers: {
64734
- "Content-Type": isText ? "text/plain" : "application/octet-stream",
64761
+ "Content-Type": "text/plain",
64735
64762
  "Content-Disposition": `attachment; filename="${file.file_path.split("/").pop()}"`
64736
64763
  }
64737
64764
  });
@@ -64823,6 +64850,7 @@ var getMimeType = (filePath) => {
64823
64850
  svg: "image/svg+xml",
64824
64851
  webp: "image/webp",
64825
64852
  ico: "image/x-icon",
64853
+ glb: "model/gltf-binary",
64826
64854
  mp3: "audio/mpeg",
64827
64855
  wav: "audio/wav",
64828
64856
  ogg: "audio/ogg",
@@ -64850,8 +64878,17 @@ var file_path_default2 = withRouteSpec({
64850
64878
  return new Response("File not found", { status: 404 });
64851
64879
  }
64852
64880
  const mimeType = getMimeType(file.file_path);
64853
- const body = file.text_content ?? Buffer3.from(file.binary_content_b64, "base64");
64854
- return new Response(body, {
64881
+ if (file.binary_content_b64) {
64882
+ const binaryBody = decodeBase64ToUint8Array(file.binary_content_b64);
64883
+ const responseBody = uint8ArrayToArrayBuffer(binaryBody);
64884
+ return new Response(responseBody, {
64885
+ headers: {
64886
+ "Content-Type": mimeType,
64887
+ "Content-Length": binaryBody.byteLength.toString()
64888
+ }
64889
+ });
64890
+ }
64891
+ return new Response(file.text_content, {
64855
64892
  headers: {
64856
64893
  "Content-Type": mimeType
64857
64894
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.218",
3
+ "version": "0.1.219",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
7
7
  "@biomejs/biome": "^1.9.4",
8
8
  "@tscircuit/circuit-json-util": "0.0.67",
9
9
  "@tscircuit/fake-snippets": "^0.0.87",
10
- "@tscircuit/file-server": "^0.0.28",
10
+ "@tscircuit/file-server": "^0.0.30",
11
11
  "@tscircuit/math-utils": "0.0.21",
12
12
  "@tscircuit/props": "^0.0.315",
13
13
  "@tscircuit/runframe": "^0.0.941",