@tscircuit/runframe 0.0.843 → 0.0.844
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/{chunk-P34TNG7I.js → chunk-7PDSS5NT.js} +141 -4
- package/dist/preview.js +1 -1
- package/dist/runner.js +1 -1
- package/dist/standalone-preview.min.js +96 -20
- package/dist/standalone.min.js +97 -21
- package/package.json +1 -1
|
@@ -1333,7 +1333,7 @@ var useErrorTelemetry = ({
|
|
|
1333
1333
|
};
|
|
1334
1334
|
|
|
1335
1335
|
// package.json
|
|
1336
|
-
var version = "0.0.
|
|
1336
|
+
var version = "0.0.843";
|
|
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,9 +2462,146 @@ 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
|
+
|
|
2465
2568
|
// lib/optional-features/exporting/open-for-download.ts
|
|
2466
|
-
var
|
|
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) => {
|
|
2467
2577
|
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
|
+
}
|
|
2468
2605
|
const blob = content instanceof Blob ? content : new Blob([content], { type: mimeType });
|
|
2469
2606
|
const url = URL.createObjectURL(blob);
|
|
2470
2607
|
const a = document.createElement("a");
|
|
@@ -2507,7 +2644,7 @@ var exportFabricationFiles = async ({
|
|
|
2507
2644
|
const pnpCsv = await convertCircuitJsonToPickAndPlaceCsv(circuitJson);
|
|
2508
2645
|
zip.file("pick_and_place.csv", pnpCsv);
|
|
2509
2646
|
const zipBlob = await zip.generateAsync({ type: "blob" });
|
|
2510
|
-
openForDownload(zipBlob, {
|
|
2647
|
+
await openForDownload(zipBlob, {
|
|
2511
2648
|
fileName: `${projectName}_fabrication_files.zip`
|
|
2512
2649
|
});
|
|
2513
2650
|
};
|
|
@@ -2533,7 +2670,7 @@ var exportAndDownload = async ({
|
|
|
2533
2670
|
return;
|
|
2534
2671
|
}
|
|
2535
2672
|
if (exportName === "Circuit JSON") {
|
|
2536
|
-
openForDownload(JSON.stringify(circuitJson, null, 2), {
|
|
2673
|
+
await openForDownload(JSON.stringify(circuitJson, null, 2), {
|
|
2537
2674
|
fileName: `${projectName}.circuit.json`,
|
|
2538
2675
|
mimeType: "application/json"
|
|
2539
2676
|
});
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED