@tscircuit/runframe 0.0.844 → 0.0.845

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.
@@ -1333,7 +1333,7 @@ var useErrorTelemetry = ({
1333
1333
  };
1334
1334
 
1335
1335
  // package.json
1336
- var version = "0.0.843";
1336
+ var version = "0.0.844";
1337
1337
 
1338
1338
  // lib/hooks/use-eval-versions.ts
1339
1339
  import { useEffect as useEffect5, useMemo as useMemo2, useState as useState6 } from "react";
@@ -2462,146 +2462,9 @@ import {
2462
2462
  } from "circuit-json-to-bom-csv";
2463
2463
  import { convertCircuitJsonToPickAndPlaceCsv } from "circuit-json-to-pnp-csv";
2464
2464
 
2465
- // lib/utils/openJsonInNewTabForDownload.ts
2466
- var openJsonInNewTabForDownload = (content, fileName) => {
2467
- const newWindow = window.open("", "_blank");
2468
- if (!newWindow) {
2469
- console.warn("Popup blocked, cannot open JSON in new tab");
2470
- return;
2471
- }
2472
- const html = `
2473
- <!DOCTYPE html>
2474
- <html>
2475
- <head>
2476
- <title>Downloading: ${fileName}</title>
2477
- </head>
2478
- <body>
2479
- <p>Downloading ${fileName}...</p>
2480
-
2481
- <script>
2482
- function downloadAndClose() {
2483
- const blob = new Blob([${JSON.stringify(content)}], { type: 'application/json' });
2484
- const url = URL.createObjectURL(blob);
2485
- const a = document.createElement('a');
2486
- a.href = url;
2487
- a.download = ${JSON.stringify(fileName)};
2488
- document.body.appendChild(a);
2489
- a.click();
2490
- document.body.removeChild(a);
2491
- URL.revokeObjectURL(url);
2492
-
2493
- // Close the tab after a short delay to ensure download started
2494
- setTimeout(() => {
2495
- window.close();
2496
- }, 100);
2497
- }
2498
-
2499
- // Auto-download and close when the page loads
2500
- window.addEventListener('load', () => {
2501
- downloadAndClose();
2502
- });
2503
- <\/script>
2504
- </body>
2505
- </html>
2506
- `;
2507
- newWindow.document.write(html);
2508
- newWindow.document.close();
2509
- };
2510
-
2511
- // lib/utils/openZipInNewTabForDownload.ts
2512
- var openZipInNewTabForDownload = async (zipBlob, fileName) => {
2513
- const newWindow = window.open("", "_blank");
2514
- if (!newWindow) {
2515
- console.warn("Popup blocked, cannot open ZIP in new tab");
2516
- return;
2517
- }
2518
- const arrayBuffer = await zipBlob.arrayBuffer();
2519
- const uint8Array = new Uint8Array(arrayBuffer);
2520
- const base64String = btoa(String.fromCharCode(...uint8Array));
2521
- const html = `
2522
- <!DOCTYPE html>
2523
- <html>
2524
- <head>
2525
- <title>Downloading: ${fileName}</title>
2526
- </head>
2527
- <body>
2528
- <p>Downloading ${fileName}...</p>
2529
-
2530
- <script>
2531
- function downloadAndClose() {
2532
- // Convert base64 back to binary data
2533
- const base64 = ${JSON.stringify(base64String)};
2534
- const binaryString = atob(base64);
2535
- const bytes = new Uint8Array(binaryString.length);
2536
- for (let i = 0; i < binaryString.length; i++) {
2537
- bytes[i] = binaryString.charCodeAt(i);
2538
- }
2539
-
2540
- const blob = new Blob([bytes], { type: 'application/zip' });
2541
- const url = URL.createObjectURL(blob);
2542
- const a = document.createElement('a');
2543
- a.href = url;
2544
- a.download = ${JSON.stringify(fileName)};
2545
- document.body.appendChild(a);
2546
- a.click();
2547
- document.body.removeChild(a);
2548
- URL.revokeObjectURL(url);
2549
-
2550
- // Close the tab after a short delay to ensure download started
2551
- setTimeout(() => {
2552
- window.close();
2553
- }, 100);
2554
- }
2555
-
2556
- // Auto-download and close when the page loads
2557
- window.addEventListener('load', () => {
2558
- downloadAndClose();
2559
- });
2560
- <\/script>
2561
- </body>
2562
- </html>
2563
- `;
2564
- newWindow.document.write(html);
2565
- newWindow.document.close();
2566
- };
2567
-
2568
2465
  // lib/optional-features/exporting/open-for-download.ts
2569
- var isInIframe = () => {
2570
- try {
2571
- return window.self !== window.top;
2572
- } catch (e) {
2573
- return true;
2574
- }
2575
- };
2576
- var openForDownload = async (content, opts) => {
2466
+ var openForDownload = (content, opts) => {
2577
2467
  const { fileName, mimeType = "text/plain" } = opts;
2578
- const inIframe = isInIframe();
2579
- if (inIframe) {
2580
- if (mimeType === "application/json" && typeof content === "string") {
2581
- openJsonInNewTabForDownload(content, fileName);
2582
- return;
2583
- }
2584
- if (content instanceof Blob && (fileName.endsWith(".zip") || mimeType === "application/zip")) {
2585
- await openZipInNewTabForDownload(content, fileName);
2586
- return;
2587
- }
2588
- const blob2 = content instanceof Blob ? content : new Blob([content], { type: mimeType });
2589
- const url2 = URL.createObjectURL(blob2);
2590
- const newWindow = window.open(url2, "_blank");
2591
- if (!newWindow) {
2592
- console.warn("Popup blocked, cannot open file in new tab");
2593
- return;
2594
- }
2595
- setTimeout(() => {
2596
- if (newWindow.document) {
2597
- newWindow.document.title = `Download: ${fileName}`;
2598
- }
2599
- }, 100);
2600
- setTimeout(() => {
2601
- URL.revokeObjectURL(url2);
2602
- }, 5e3);
2603
- return;
2604
- }
2605
2468
  const blob = content instanceof Blob ? content : new Blob([content], { type: mimeType });
2606
2469
  const url = URL.createObjectURL(blob);
2607
2470
  const a = document.createElement("a");
@@ -2644,7 +2507,7 @@ var exportFabricationFiles = async ({
2644
2507
  const pnpCsv = await convertCircuitJsonToPickAndPlaceCsv(circuitJson);
2645
2508
  zip.file("pick_and_place.csv", pnpCsv);
2646
2509
  const zipBlob = await zip.generateAsync({ type: "blob" });
2647
- await openForDownload(zipBlob, {
2510
+ openForDownload(zipBlob, {
2648
2511
  fileName: `${projectName}_fabrication_files.zip`
2649
2512
  });
2650
2513
  };
@@ -2670,7 +2533,7 @@ var exportAndDownload = async ({
2670
2533
  return;
2671
2534
  }
2672
2535
  if (exportName === "Circuit JSON") {
2673
- await openForDownload(JSON.stringify(circuitJson, null, 2), {
2536
+ openForDownload(JSON.stringify(circuitJson, null, 2), {
2674
2537
  fileName: `${projectName}.circuit.json`,
2675
2538
  mimeType: "application/json"
2676
2539
  });
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-7PDSS5NT.js";
11
+ } from "./chunk-XLUQQUAM.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  useRunFrameStore,
24
24
  useRunnerStore,
25
25
  useStyles
26
- } from "./chunk-7PDSS5NT.js";
26
+ } from "./chunk-XLUQQUAM.js";
27
27
 
28
28
  // lib/components/RunFrame/RunFrame.tsx
29
29
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";