@gallop.software/studio 2.3.17 → 2.3.19

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.
@@ -11,7 +11,7 @@
11
11
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
12
12
  }
13
13
  </style>
14
- <script type="module" crossorigin src="/assets/index-CpFx3R91.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-CgyTjFJ5.js"></script>
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -1866,13 +1866,17 @@ async function handleDownloadStream(request) {
1866
1866
  if (!imageKeys || !Array.isArray(imageKeys) || imageKeys.length === 0) {
1867
1867
  return jsonResponse({ error: "No image keys provided" }, { status: 400 });
1868
1868
  }
1869
+ const abortSignal = request.signal;
1869
1870
  const stream = new ReadableStream({
1870
1871
  async start(controller) {
1871
1872
  const encoder = new TextEncoder();
1872
1873
  const sendEvent = (data) => {
1873
- controller.enqueue(encoder.encode(`data: ${JSON.stringify(data)}
1874
+ try {
1875
+ controller.enqueue(encoder.encode(`data: ${JSON.stringify(data)}
1874
1876
 
1875
1877
  `));
1878
+ } catch {
1879
+ }
1876
1880
  };
1877
1881
  sendEvent({ type: "start", total: imageKeys.length });
1878
1882
  const downloaded = [];
@@ -1881,6 +1885,16 @@ async function handleDownloadStream(request) {
1881
1885
  try {
1882
1886
  const meta = await loadMeta();
1883
1887
  for (let i = 0; i < imageKeys.length; i++) {
1888
+ if (abortSignal?.aborted) {
1889
+ await saveMeta(meta);
1890
+ sendEvent({
1891
+ type: "stopped",
1892
+ downloaded: downloaded.length,
1893
+ message: `Stopped. ${downloaded.length} image${downloaded.length !== 1 ? "s" : ""} downloaded.`
1894
+ });
1895
+ controller.close();
1896
+ return;
1897
+ }
1884
1898
  const imageKey = imageKeys[i];
1885
1899
  const entry = getMetaEntry(meta, imageKey);
1886
1900
  if (!entry || entry.c === void 0) {
@@ -1895,6 +1909,16 @@ async function handleDownloadStream(request) {
1895
1909
  }
1896
1910
  try {
1897
1911
  const imageBuffer = await downloadFromCdn(imageKey);
1912
+ if (abortSignal?.aborted) {
1913
+ await saveMeta(meta);
1914
+ sendEvent({
1915
+ type: "stopped",
1916
+ downloaded: downloaded.length,
1917
+ message: `Stopped. ${downloaded.length} image${downloaded.length !== 1 ? "s" : ""} downloaded.`
1918
+ });
1919
+ controller.close();
1920
+ return;
1921
+ }
1898
1922
  const localPath = getPublicPath(imageKey.replace(/^\//, ""));
1899
1923
  await fs7.mkdir(path7.dirname(localPath), { recursive: true });
1900
1924
  await fs7.writeFile(localPath, imageBuffer);