@hanzo/studio 0.1.11 → 0.1.12
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/lib/app/director.d.ts +2 -5
- package/lib/app/director.js +268 -335
- package/lib/app/flow-run.d.ts +34 -0
- package/lib/app/flow-run.js +77 -0
- package/lib/app/flow.d.ts +2 -2
- package/lib/app/flow.js +546 -281
- package/lib/app/sections.d.ts +5 -0
- package/lib/app/sections.js +26 -0
- package/lib/attach.d.ts +2 -0
- package/lib/attach.js +7 -0
- package/lib/desk.d.ts +1 -1
- package/lib/desk.js +370 -14
- package/lib/download.d.ts +2 -0
- package/lib/download.js +11 -0
- package/lib/gpu.d.ts +13 -1
- package/lib/gpu.js +39 -16
- package/lib/handoff.d.ts +2 -0
- package/lib/handoff.js +2 -0
- package/lib/home.js +97 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/places.js +184 -30
- package/lib/route.d.ts +6 -0
- package/lib/route.js +6 -0
- package/lib/talk.js +98 -33
- package/lib/ui.d.ts +18 -4
- package/lib/ui.js +50 -22
- package/lib/wire.d.ts +17 -0
- package/lib/wire.js +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Which section of the Director and of Flow an address opens. */
|
|
2
|
+
export type StudioSection = 'create' | 'library' | 'documents' | 'video' | 'music' | 'model3d' | 'queue';
|
|
3
|
+
export declare function parseStudioSection(path?: string): StudioSection;
|
|
4
|
+
export type FlowSection = 'canvas' | 'hybrid' | 'comfy' | 'agents' | 'code' | 'publish';
|
|
5
|
+
export declare function parseFlowSection(path?: string): FlowSection;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Which section of the Director and of Flow an address opens. */
|
|
2
|
+
export function parseStudioSection(path) {
|
|
3
|
+
const clean = (path ?? '').replace(/^\/+|\/+$/g, '').split('/')[0] ?? '';
|
|
4
|
+
if (clean === 'create' || clean === 'refine' || clean === 'home')
|
|
5
|
+
return 'create';
|
|
6
|
+
if (clean === 'documents' || clean === 'docs' || clean === 'frames' || clean === 'office')
|
|
7
|
+
return 'documents';
|
|
8
|
+
if (clean === 'video' || clean === 'cinema')
|
|
9
|
+
return 'video';
|
|
10
|
+
if (clean === 'music' || clean === 'audio' || clean === 'voice')
|
|
11
|
+
return 'music';
|
|
12
|
+
if (clean === 'model3d' || clean === '3d' || clean === 'mesh')
|
|
13
|
+
return 'model3d';
|
|
14
|
+
if (clean === 'library' || clean === 'stacks' || clean === 'assets')
|
|
15
|
+
return 'library';
|
|
16
|
+
if (clean === 'queue' || clean === 'activity' || clean === 'gpus')
|
|
17
|
+
return 'queue';
|
|
18
|
+
return 'create';
|
|
19
|
+
}
|
|
20
|
+
export function parseFlowSection(path) {
|
|
21
|
+
const clean = (path ?? '').replace(/^\/+|\/+$/g, '').split('/')[0] ?? '';
|
|
22
|
+
if (clean === 'hybrid' || clean === 'comfy' || clean === 'agents' || clean === 'code' || clean === 'publish') {
|
|
23
|
+
return clean;
|
|
24
|
+
}
|
|
25
|
+
return 'canvas';
|
|
26
|
+
}
|
package/lib/attach.d.ts
ADDED
package/lib/attach.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The sentence for files that did not attach: which, and the last reason given. '' when all did. */
|
|
2
|
+
export function uploadFailure(names, reason) {
|
|
3
|
+
if (!names.length)
|
|
4
|
+
return '';
|
|
5
|
+
const label = names.length === 1 ? `“${names[0]}”` : `${names.length} files`;
|
|
6
|
+
return `Could not attach ${label}${reason ? `: ${reason}` : '.'}`;
|
|
7
|
+
}
|
package/lib/desk.d.ts
CHANGED
package/lib/desk.js
CHANGED
|
@@ -7,14 +7,84 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
* Compare draws two versions: a wipe for pictures (drag the line), side by
|
|
8
8
|
* side for everything else.
|
|
9
9
|
*/
|
|
10
|
+
import { RING } from './ui.js';
|
|
10
11
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
11
|
-
import { ChevronDown, Columns2, Download } from '@hanzogui/lucide-icons-2';
|
|
12
|
-
import { DropdownMenu } from '@hanzo/ui';
|
|
13
|
-
import { useState } from 'react';
|
|
12
|
+
import { Bookmark, Check, ChevronDown, Columns2, Download, Link2, MessageSquare, MoveHorizontal } from '@hanzogui/lucide-icons-2';
|
|
13
|
+
import { DropdownMenu, Popover, PopoverContent, PopoverTrigger } from '@hanzo/ui';
|
|
14
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
14
15
|
import { kind } from './kinds/index.js';
|
|
15
|
-
import { current } from './made.js';
|
|
16
|
-
import { download } from './
|
|
16
|
+
import { current, filename } from './made.js';
|
|
17
|
+
import { download } from './download.js';
|
|
18
|
+
import { pdf } from './pdf.js';
|
|
19
|
+
import { HANDOFF_CHAT } from './handoff.js';
|
|
20
|
+
import { useHost } from './host.js';
|
|
17
21
|
import { useUrl } from './use.js';
|
|
22
|
+
import { read, saveToLibrary, url } from './wire.js';
|
|
23
|
+
/** Render an image blob onto an offscreen canvas at `scale` (1x or 2x). */
|
|
24
|
+
async function rasterizeBlob(blob, scale) {
|
|
25
|
+
if (typeof document === 'undefined')
|
|
26
|
+
return null;
|
|
27
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
28
|
+
try {
|
|
29
|
+
const img = await new Promise((resolve, reject) => {
|
|
30
|
+
const el = new Image();
|
|
31
|
+
el.onload = () => resolve(el);
|
|
32
|
+
el.onerror = () => reject(new Error('Could not decode image'));
|
|
33
|
+
el.src = objectUrl;
|
|
34
|
+
});
|
|
35
|
+
const w = Math.max(1, Math.round((img.naturalWidth || img.width || 1024) * scale));
|
|
36
|
+
const h = Math.max(1, Math.round((img.naturalHeight || img.height || 1024) * scale));
|
|
37
|
+
const canvas = document.createElement('canvas');
|
|
38
|
+
canvas.width = w;
|
|
39
|
+
canvas.height = h;
|
|
40
|
+
const ctx = canvas.getContext('2d');
|
|
41
|
+
if (!ctx)
|
|
42
|
+
return null;
|
|
43
|
+
ctx.imageSmoothingEnabled = true;
|
|
44
|
+
ctx.imageSmoothingQuality = 'high';
|
|
45
|
+
ctx.drawImage(img, 0, 0, w, h);
|
|
46
|
+
return canvas;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
URL.revokeObjectURL(objectUrl);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function canvasToBlob(canvas, mime, quality = 0.92) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
canvas.toBlob((b) => (b ? resolve(b) : reject(new Error(`Could not encode ${mime}`))), mime, quality);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** A one-page PDF of a canvas, the page the picture's own size in points (src/pdf.ts). */
|
|
58
|
+
async function canvasToPdfBlob(canvas, title) {
|
|
59
|
+
const jpeg = new Uint8Array(await (await canvasToBlob(canvas, 'image/jpeg', 0.92)).arrayBuffer());
|
|
60
|
+
return pdf([{ jpeg, width: canvas.width, height: canvas.height, pageWidth: canvas.width * 0.75, pageHeight: canvas.height * 0.75 }], title);
|
|
61
|
+
}
|
|
62
|
+
async function copyText(text) {
|
|
63
|
+
try {
|
|
64
|
+
if (navigator.clipboard?.writeText) {
|
|
65
|
+
await navigator.clipboard.writeText(text);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Fall through to temporary textarea
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const ta = document.createElement('textarea');
|
|
74
|
+
ta.value = text;
|
|
75
|
+
ta.setAttribute('readonly', 'true');
|
|
76
|
+
ta.style.position = 'fixed';
|
|
77
|
+
ta.style.opacity = '0';
|
|
78
|
+
document.body.appendChild(ta);
|
|
79
|
+
ta.select();
|
|
80
|
+
const ok = document.execCommand('copy');
|
|
81
|
+
ta.remove();
|
|
82
|
+
return ok;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
18
88
|
const ago = (t) => {
|
|
19
89
|
const s = Math.max(0, Math.round((Date.now() - t) / 1000));
|
|
20
90
|
if (s < 60)
|
|
@@ -26,19 +96,204 @@ const ago = (t) => {
|
|
|
26
96
|
return new Date(t).toLocaleDateString();
|
|
27
97
|
};
|
|
28
98
|
export function Desk({ made, wire, others, onPick, onEdit, busy, failed }) {
|
|
99
|
+
const host = useHost();
|
|
29
100
|
const k = kind(made.kind);
|
|
30
101
|
const v = current(made);
|
|
31
102
|
const [against, setAgainst] = useState(null);
|
|
32
103
|
const [error, setError] = useState('');
|
|
33
|
-
const
|
|
104
|
+
const [exportOpen, setExportOpen] = useState(false);
|
|
105
|
+
const [exportFormat, setExportFormat] = useState(() => {
|
|
106
|
+
const hasImg = v.files.some((f) => f.mime.startsWith('image/'));
|
|
107
|
+
if (hasImg || made.kind === 'image' || made.kind === 'poster' || made.kind === 'ad')
|
|
108
|
+
return 'png';
|
|
109
|
+
if (made.kind === 'document' || made.kind === 'slides')
|
|
110
|
+
return 'pdf';
|
|
111
|
+
return 'original';
|
|
112
|
+
});
|
|
113
|
+
const [exportScale, setExportScale] = useState(2);
|
|
114
|
+
const [exportBusy, setExportBusy] = useState(false);
|
|
115
|
+
const [exportedOnce, setExportedOnce] = useState(false);
|
|
116
|
+
const [copiedLink, setCopiedLink] = useState(false);
|
|
117
|
+
const [savedLibrary, setSavedLibrary] = useState(false);
|
|
118
|
+
const [savingLibrary, setSavingLibrary] = useState(false);
|
|
119
|
+
const timersRef = useRef([]);
|
|
120
|
+
const handleOpenInChat = () => {
|
|
121
|
+
const noteText = v.note?.trim() ? `\n\nLatest design notes: ${v.note.trim()}` : '';
|
|
122
|
+
const prompt = `Continue refining my ${k.label.toLowerCase()} “${made.title}” (v${made.at + 1}).${noteText}`;
|
|
123
|
+
try {
|
|
124
|
+
window.sessionStorage.setItem(HANDOFF_CHAT, JSON.stringify({ prompt, title: made.title, kind: made.kind, ts: Date.now() }));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// Storage is blocked: Chat opens without the prompt.
|
|
128
|
+
}
|
|
129
|
+
host.open('/chat');
|
|
130
|
+
};
|
|
131
|
+
const handleSaveToLibrary = async () => {
|
|
132
|
+
if (savingLibrary)
|
|
133
|
+
return;
|
|
134
|
+
setError('');
|
|
135
|
+
setSavedLibrary(false);
|
|
136
|
+
setSavingLibrary(true);
|
|
137
|
+
try {
|
|
138
|
+
let blob;
|
|
139
|
+
let name;
|
|
140
|
+
let key;
|
|
141
|
+
const primaryFile = v.files[0];
|
|
142
|
+
if (primaryFile) {
|
|
143
|
+
blob = await read(wire, primaryFile.key);
|
|
144
|
+
name = primaryFile.name || filename(made.title, 'bin');
|
|
145
|
+
key = primaryFile.key;
|
|
146
|
+
}
|
|
147
|
+
else if (k.exports[0]) {
|
|
148
|
+
const out = await k.exports[0].run(wire, made, v);
|
|
149
|
+
blob = out.blob;
|
|
150
|
+
name = out.name;
|
|
151
|
+
key = `files/${made.kind}/${made.id}/${v.id}/${name}`;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
name = filename(made.title, 'json');
|
|
155
|
+
blob = new Blob([JSON.stringify({ id: made.id, title: made.title, kind: made.kind, version: v.id, spec: v.spec, note: v.note }, null, 2)], { type: 'application/json' });
|
|
156
|
+
key = `files/${made.kind}/${made.id}/${v.id}/${name}`;
|
|
157
|
+
}
|
|
158
|
+
await saveToLibrary(wire, key, blob);
|
|
159
|
+
setSavedLibrary(true);
|
|
160
|
+
timersRef.current.push(window.setTimeout(() => setSavedLibrary(false), 2500));
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
setSavedLibrary(false);
|
|
164
|
+
setError(e instanceof Error ? e.message : 'Could not save to Library.');
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
setSavingLibrary(false);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
return () => {
|
|
172
|
+
timersRef.current.forEach((id) => window.clearTimeout(id));
|
|
173
|
+
};
|
|
174
|
+
}, []);
|
|
175
|
+
const exportingNative = async (i) => {
|
|
34
176
|
setError('');
|
|
177
|
+
setExportBusy(true);
|
|
35
178
|
try {
|
|
36
179
|
const out = await k.exports[i].run(wire, made, v);
|
|
37
180
|
download(out.name, out.blob);
|
|
181
|
+
setExportedOnce(true);
|
|
182
|
+
timersRef.current.push(window.setTimeout(() => setExportedOnce(false), 1800));
|
|
38
183
|
}
|
|
39
184
|
catch (e) {
|
|
40
185
|
setError(e instanceof Error ? e.message : String(e));
|
|
41
186
|
}
|
|
187
|
+
finally {
|
|
188
|
+
setExportBusy(false);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const runUnifiedExport = async () => {
|
|
192
|
+
setError('');
|
|
193
|
+
setExportBusy(true);
|
|
194
|
+
try {
|
|
195
|
+
if (exportFormat === 'original') {
|
|
196
|
+
const primary = k.exports[0];
|
|
197
|
+
if (primary) {
|
|
198
|
+
const out = await primary.run(wire, made, v);
|
|
199
|
+
download(out.name, out.blob);
|
|
200
|
+
}
|
|
201
|
+
else if (v.files[0]) {
|
|
202
|
+
const blob = await read(wire, v.files[0].key);
|
|
203
|
+
download(v.files[0].name, blob);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (exportFormat === 'pdf') {
|
|
207
|
+
const nativePdf = k.exports.find((x) => /pdf/i.test(x.label));
|
|
208
|
+
if (nativePdf) {
|
|
209
|
+
const out = await nativePdf.run(wire, made, v);
|
|
210
|
+
download(out.name, out.blob);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const imgFile = v.files.find((f) => f.mime.startsWith('image/'));
|
|
214
|
+
const sourceBlob = imgFile
|
|
215
|
+
? await read(wire, imgFile.key)
|
|
216
|
+
: k.exports[0]
|
|
217
|
+
? (await k.exports[0].run(wire, made, v)).blob
|
|
218
|
+
: null;
|
|
219
|
+
if (sourceBlob && sourceBlob.type.startsWith('image/')) {
|
|
220
|
+
const canvas = await rasterizeBlob(sourceBlob, exportScale);
|
|
221
|
+
if (canvas) {
|
|
222
|
+
const pdfBlob = await canvasToPdfBlob(canvas, made.title);
|
|
223
|
+
download(filename(made.title, 'pdf'), pdfBlob);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
download(filename(made.title, 'png'), sourceBlob);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if (k.exports[0]) {
|
|
230
|
+
const out = await k.exports[0].run(wire, made, v);
|
|
231
|
+
download(out.name, out.blob);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
const targetMime = exportFormat === 'webp' ? 'image/webp' : 'image/png';
|
|
237
|
+
const imgFile = v.files.find((f) => f.mime.startsWith('image/'));
|
|
238
|
+
const nativeImg = k.exports.find((x) => new RegExp(exportFormat, 'i').test(x.label));
|
|
239
|
+
let sourceBlob = null;
|
|
240
|
+
if (imgFile) {
|
|
241
|
+
sourceBlob = await read(wire, imgFile.key);
|
|
242
|
+
}
|
|
243
|
+
else if (nativeImg) {
|
|
244
|
+
sourceBlob = (await nativeImg.run(wire, made, v)).blob;
|
|
245
|
+
}
|
|
246
|
+
else if (k.exports[0]) {
|
|
247
|
+
sourceBlob = (await k.exports[0].run(wire, made, v)).blob;
|
|
248
|
+
}
|
|
249
|
+
if (sourceBlob && sourceBlob.type.startsWith('image/')) {
|
|
250
|
+
const canvas = await rasterizeBlob(sourceBlob, exportScale);
|
|
251
|
+
if (canvas) {
|
|
252
|
+
const converted = await canvasToBlob(canvas, targetMime, 0.94);
|
|
253
|
+
const suffix = exportScale === 2 ? '-2x' : '';
|
|
254
|
+
download(filename(`${made.title}${suffix}`, exportFormat), converted);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
download(filename(made.title, exportFormat), sourceBlob);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else if (k.exports[0]) {
|
|
261
|
+
const out = await k.exports[0].run(wire, made, v);
|
|
262
|
+
download(out.name, out.blob);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
setExportedOnce(true);
|
|
266
|
+
timersRef.current.push(window.setTimeout(() => setExportedOnce(false), 1800));
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
270
|
+
}
|
|
271
|
+
finally {
|
|
272
|
+
setExportBusy(false);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const handleCopyLink = async () => {
|
|
276
|
+
setError('');
|
|
277
|
+
let link = typeof window !== 'undefined' ? window.location.href : '';
|
|
278
|
+
const primaryFile = v.files[0];
|
|
279
|
+
if (primaryFile) {
|
|
280
|
+
try {
|
|
281
|
+
const resolved = await url(wire, primaryFile.key);
|
|
282
|
+
if (resolved && /^https?:\/\//i.test(resolved))
|
|
283
|
+
link = resolved;
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
// Keep current page URL fallback
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const ok = await copyText(link);
|
|
290
|
+
if (ok) {
|
|
291
|
+
setCopiedLink(true);
|
|
292
|
+
timersRef.current.push(window.setTimeout(() => setCopiedLink(false), 2000));
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
setError('Could not copy link to clipboard.');
|
|
296
|
+
}
|
|
42
297
|
};
|
|
43
298
|
const Icon = k.icon;
|
|
44
299
|
const versions = made.versions.map((x, i) => ({
|
|
@@ -48,25 +303,126 @@ export function Desk({ made, wire, others, onPick, onEdit, busy, failed }) {
|
|
|
48
303
|
onSelect: () => onPick(i),
|
|
49
304
|
}));
|
|
50
305
|
const compare = against !== null && against !== made.at && made.versions[against] ? made.versions[against] : null;
|
|
51
|
-
|
|
306
|
+
const scaleApplies = exportFormat !== 'original';
|
|
307
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, "data-slot": "studio-tab", children: [_jsxs(XStack, { gap: "$1.5", px: "$2", py: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "var(--border)", shrink: 0, flexWrap: "wrap", children: [_jsxs(XStack, { items: "center", gap: "$2", flex: 1, minW: 0, px: "$1", children: [_jsx(XStack, { "$platform-web": { color: 'var(--foreground)' }, shrink: 0, children: _jsx(Icon, { size: 14 }) }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: made.title })] }), _jsx(DropdownMenu, { trigger: _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `v${made.at + 1} of ${made.versions.length}, versions`, items: "center", gap: "$1", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(SizableText, { size: "$2", color: "$ink", children: `v${made.at + 1} of ${made.versions.length}` }), _jsx(ChevronDown, { size: 13, color: "$soft" })] }), items: [{ type: 'label', key: 'h', label: 'Versions' }, ...versions] }), made.versions.length > 1 ? (_jsx(DropdownMenu, { trigger: _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Compare versions", "aria-pressed": compare ? true : undefined, items: "center", gap: "$1.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: compare ? '$ink' : 'var(--border-strong)', bg: compare ? '$hover' : 'transparent', cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(Columns2, { size: 14, color: "$ink" }), _jsx(SizableText, { size: "$2", color: "$ink", children: compare ? `v${(against ?? 0) + 1} | v${made.at + 1}` : 'Compare' })] }), items: [
|
|
52
308
|
{ type: 'label', key: 'h', label: 'Compare with' },
|
|
53
309
|
...made.versions.map((x, i) => ({ key: x.id, label: `Version ${i + 1}`, description: x.note.slice(0, 60), disabled: i === made.at, onSelect: () => setAgainst(i) })),
|
|
54
310
|
...(compare ? [{ type: 'separator', key: 's' }, { key: 'off', label: 'Stop comparing', onSelect: () => setAgainst(null) }] : []),
|
|
55
|
-
] })) : null,
|
|
311
|
+
] })) : null, _jsxs(XStack, { render: _jsx("button", { type: "button" }), "data-slot": "design-open-in-chat", "aria-label": "Open in Chat", onClick: handleOpenInChat, items: "center", gap: "$1.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(MessageSquare, { size: 14, color: "$ink", "aria-hidden": true }), _jsx(SizableText, { size: "$2", color: "$ink", children: "Open in Chat" })] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "data-slot": "design-save-library", "aria-label": savingLibrary ? 'Saving to Library' : savedLibrary ? 'Saved to Library' : 'Save to Library', disabled: savingLibrary, onClick: () => void handleSaveToLibrary(), items: "center", gap: "$1.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: savedLibrary ? '$hover' : 'transparent', opacity: savingLibrary ? 0.6 : 1, cursor: savingLibrary ? 'default' : 'pointer', hoverStyle: savingLibrary ? undefined : { bg: '$hover' }, focusVisibleStyle: RING, children: [savedLibrary ? _jsx(Check, { size: 14, color: "var(--state-success)", "aria-hidden": true }) : _jsx(Bookmark, { size: 14, color: "$ink", "aria-hidden": true }), _jsx(SizableText, { size: "$2", color: "$ink", children: savingLibrary ? 'Saving…' : savedLibrary ? 'Saved' : 'Save to Library' })] }), _jsxs(Popover, { open: exportOpen, onOpenChange: setExportOpen, placement: "bottom", children: [_jsx(PopoverTrigger, { asChild: true, disablePressTrigger: true, children: _jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => setExportOpen((prev) => !prev), "aria-label": "Export", "aria-expanded": exportOpen, items: "center", gap: "$1.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: exportOpen ? '$ink' : 'var(--border-strong)', bg: exportOpen ? '$hover' : 'transparent', cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(Download, { size: 14, color: "$ink" }), _jsx(SizableText, { size: "$2", color: "$ink", children: "Export" }), _jsx(ChevronDown, { size: 12, color: "$soft" })] }) }), _jsxs(PopoverContent, { solid: true, align: "end", sideOffset: 6, width: 284, p: "$3", gap: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--popover)", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", children: "Export creation" }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$soft", children: `v${made.at + 1} · ${k.label}` })] }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Format" }), _jsx(XStack, { role: "radiogroup", "aria-label": "Export format", gap: "$1.5", children: [
|
|
312
|
+
{ id: 'png', label: 'PNG' },
|
|
313
|
+
{ id: 'webp', label: 'WebP' },
|
|
314
|
+
{ id: 'pdf', label: 'PDF' },
|
|
315
|
+
{ id: 'original', label: 'Original' },
|
|
316
|
+
].map((fmt) => {
|
|
317
|
+
const on = exportFormat === fmt.id;
|
|
318
|
+
return (_jsx(XStack, { render: _jsx("button", { type: "button" }), role: "radio", "aria-checked": on, onClick: () => setExportFormat(fmt.id), flex: 1, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, items: "center", justify: "center", rounded: "$2", borderWidth: 1, borderColor: on ? '$ink' : 'var(--border-strong)', bg: on ? 'var(--surface-card-emphasis)' : 'transparent', cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: on ? '600' : '500', color: on ? '$ink' : '$soft', children: fmt.label }) }, fmt.id));
|
|
319
|
+
}) })] }), _jsxs(YStack, { gap: "$1.5", opacity: scaleApplies ? 1 : 0.45, children: [_jsxs(XStack, { items: "center", justify: "space-between", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Resolution" }), !scaleApplies ? (_jsx(SizableText, { size: "$1", color: "$hint", children: "Native size" })) : null] }), _jsx(XStack, { role: "radiogroup", "aria-label": "Export resolution", gap: "$1.5", children: [1, 2].map((sc) => {
|
|
320
|
+
const on = exportScale === sc;
|
|
321
|
+
return (_jsxs(XStack, { render: _jsx("button", { type: "button" }), role: "radio", "aria-checked": on, disabled: !scaleApplies, onClick: () => scaleApplies && setExportScale(sc), flex: 1, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, items: "center", justify: "center", gap: "$1", rounded: "$2", borderWidth: 1, borderColor: on && scaleApplies ? '$ink' : 'var(--border-strong)', bg: on && scaleApplies ? 'var(--surface-card-emphasis)' : 'transparent', cursor: scaleApplies ? 'pointer' : 'default', hoverStyle: scaleApplies ? { bg: '$hover' } : undefined, focusVisibleStyle: RING, children: [_jsx(SizableText, { size: "$1", fontFamily: "$mono", fontWeight: on ? '600' : '500', color: on && scaleApplies ? '$ink' : '$soft', children: `${sc}×` }), _jsx(SizableText, { size: "$1", color: "$soft", children: sc === 1 ? 'Standard' : 'Retina' })] }, sc));
|
|
322
|
+
}) })] }), _jsxs(XStack, { gap: "$2", children: [_jsxs(XStack, { render: _jsx("button", { type: "button" }), disabled: exportBusy, onClick: () => void runUnifiedExport(), flex: 1, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 34, height: 34 }, px: "$3", rounded: "$3", bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: exportBusy ? 'default' : 'pointer', opacity: exportBusy ? 0.6 : 1, hoverStyle: exportBusy ? undefined : { opacity: 0.9 }, focusVisibleStyle: RING, children: [exportedOnce ? _jsx(Check, { size: 13, color: "$background" }) : _jsx(Download, { size: 13, color: "$background" }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$background", children: exportBusy ? 'Exporting…' : exportedOnce ? 'Downloaded' : 'Download' })] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": copiedLink ? 'Link copied' : 'Copy link', onClick: () => void handleCopyLink(), minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 34, height: 34 }, px: "$3", rounded: "$3", borderWidth: 1, borderColor: copiedLink ? 'var(--state-success)' : 'var(--border-strong)', bg: copiedLink ? 'var(--state-success-bg)' : 'transparent', items: "center", justify: "center", gap: "$1.5", cursor: "pointer", hoverStyle: { bg: copiedLink ? 'var(--state-success-bg)' : '$hover' }, focusVisibleStyle: RING, children: [copiedLink ? _jsx(Check, { size: 13, color: "var(--state-success)" }) : _jsx(Link2, { size: 13, color: "$ink" }), _jsx(SizableText, { size: "$2", fontWeight: "500", color: copiedLink ? 'var(--state-success)' : '$ink', children: copiedLink ? 'Copied' : 'Copy link' })] })] }), k.exports.length > 1 ? (_jsxs(YStack, { gap: "$1", pt: "$2", borderTopWidth: 1, borderColor: "var(--border)", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Kind-specific exports" }), _jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: k.exports.map((ex, i) => (_jsx(XStack, { render: _jsx("button", { type: "button" }), disabled: exportBusy, onClick: () => void exportingNative(i), minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, px: "$2", rounded: "$2", borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", items: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", color: "$ink", children: ex.label }) }, ex.label))) })] })) : null] })] })] }), error || failed ? (_jsx(XStack, { px: "$3", py: "$2", bg: "var(--state-error-bg)", borderBottomWidth: 1, borderColor: "var(--border)", shrink: 0, children: _jsx(SizableText, { size: "$2", color: "var(--state-error)", children: error || failed }) })) : null, compare ? (_jsx(Compare, { made: made, a: compare, b: v, wire: wire, others: others })) : (_jsx(k.View, { made: made, version: v, wire: wire, edit: onEdit, busy: busy, others: others }))] }));
|
|
56
323
|
}
|
|
57
324
|
function Compare({ made, a, b, wire, others }) {
|
|
58
325
|
const pa = a.files.find((f) => f.mime.startsWith('image/'));
|
|
59
326
|
const pb = b.files.find((f) => f.mime.startsWith('image/'));
|
|
60
|
-
|
|
61
|
-
|
|
327
|
+
const va = made.versions.indexOf(a) + 1;
|
|
328
|
+
const vb = made.versions.indexOf(b) + 1;
|
|
329
|
+
if (pa && pb && (made.kind === 'image' || made.kind === 'poster' || made.kind === 'ad')) {
|
|
330
|
+
return _jsx(Wipe, { wire: wire, a: pa.key, b: pb.key, title: made.title, labelA: `v${va}`, labelB: `v${vb}` });
|
|
331
|
+
}
|
|
62
332
|
const k = kind(made.kind);
|
|
63
333
|
const none = () => undefined;
|
|
64
|
-
return (_jsx(XStack, { flex: 1, minH: 0, children: [a, b].map((v, i) => (_jsxs(YStack, { flex: 1, minW: 0, borderLeftWidth: i ? 1 : 0, borderColor: "
|
|
334
|
+
return (_jsx(XStack, { flex: 1, minH: 0, children: [a, b].map((v, i) => (_jsxs(YStack, { flex: 1, minW: 0, borderLeftWidth: i ? 1 : 0, borderColor: "var(--border)", children: [_jsx(SizableText, { size: "$1", color: "$soft", px: "$3", py: "$1", children: `Version ${made.versions.indexOf(v) + 1}` }), _jsx(k.View, { made: made, version: v, wire: wire, edit: none, busy: true, others: others })] }, v.id))) }));
|
|
65
335
|
}
|
|
66
|
-
/** Two pictures, one over the other,
|
|
67
|
-
function Wipe({ wire, a, b, title }) {
|
|
336
|
+
/** Two pictures, one over the other, dragged across by pointer, touch, or arrow keys. */
|
|
337
|
+
function Wipe({ wire, a, b, title, labelA, labelB }) {
|
|
68
338
|
const left = useUrl(wire, a);
|
|
69
339
|
const right = useUrl(wire, b);
|
|
70
340
|
const [at, setAt] = useState(50);
|
|
71
|
-
|
|
341
|
+
const [dragging, setDragging] = useState(false);
|
|
342
|
+
const [sliderFocused, setSliderFocused] = useState(false);
|
|
343
|
+
const stageRef = useRef(null);
|
|
344
|
+
const updateFromClientX = useCallback((clientX) => {
|
|
345
|
+
const rect = stageRef.current?.getBoundingClientRect();
|
|
346
|
+
if (!rect || rect.width <= 0)
|
|
347
|
+
return;
|
|
348
|
+
const pct = Math.min(100, Math.max(0, ((clientX - rect.left) / rect.width) * 100));
|
|
349
|
+
setAt(Math.round(pct * 10) / 10);
|
|
350
|
+
}, []);
|
|
351
|
+
const onPointerDown = (e) => {
|
|
352
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
353
|
+
setDragging(true);
|
|
354
|
+
updateFromClientX(e.clientX);
|
|
355
|
+
};
|
|
356
|
+
const onPointerMove = (e) => {
|
|
357
|
+
if (!dragging)
|
|
358
|
+
return;
|
|
359
|
+
updateFromClientX(e.clientX);
|
|
360
|
+
};
|
|
361
|
+
const onPointerUp = (e) => {
|
|
362
|
+
if (dragging) {
|
|
363
|
+
try {
|
|
364
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
// Ignore
|
|
368
|
+
}
|
|
369
|
+
setDragging(false);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
const onKeyDown = (e) => {
|
|
373
|
+
const step = e.shiftKey ? 10 : 2;
|
|
374
|
+
if (e.key === 'ArrowLeft') {
|
|
375
|
+
e.preventDefault();
|
|
376
|
+
setAt((p) => Math.max(0, Math.round(p - step)));
|
|
377
|
+
}
|
|
378
|
+
else if (e.key === 'ArrowRight') {
|
|
379
|
+
e.preventDefault();
|
|
380
|
+
setAt((p) => Math.min(100, Math.round(p + step)));
|
|
381
|
+
}
|
|
382
|
+
else if (e.key === 'Home') {
|
|
383
|
+
e.preventDefault();
|
|
384
|
+
setAt(0);
|
|
385
|
+
}
|
|
386
|
+
else if (e.key === 'End') {
|
|
387
|
+
e.preventDefault();
|
|
388
|
+
setAt(100);
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, items: "center", justify: "center", p: "$3", gap: "$2.5", children: [_jsxs("div", { ref: stageRef, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, style: {
|
|
392
|
+
position: 'relative',
|
|
393
|
+
maxWidth: '100%',
|
|
394
|
+
maxHeight: 'calc(100% - 44px)',
|
|
395
|
+
display: 'inline-block',
|
|
396
|
+
cursor: 'ew-resize',
|
|
397
|
+
userSelect: 'none',
|
|
398
|
+
touchAction: 'none',
|
|
399
|
+
borderRadius: 12,
|
|
400
|
+
overflow: 'hidden',
|
|
401
|
+
border: '1px solid var(--border-strong)',
|
|
402
|
+
}, children: [right.src ? _jsx("img", { src: right.src, alt: `${title}, ${labelB}`, draggable: false, style: { display: 'block', maxWidth: '100%', maxHeight: '68vh' } }) : null, left.src ? (_jsx("img", { src: left.src, alt: `${title}, ${labelA}`, draggable: false, style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'contain', clipPath: `inset(0 ${100 - at}% 0 0)` } })) : null, _jsx(XStack, { "aria-hidden": true, position: "absolute", t: 10, l: 10, px: "$2", height: 22, rounded: 999, bg: "var(--surface-header)", borderWidth: 1, borderColor: "var(--border)", items: "center", children: _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$ink", children: `Before · ${labelA}` }) }), _jsx(XStack, { "aria-hidden": true, position: "absolute", t: 10, r: 10, px: "$2", height: 22, rounded: 999, bg: "var(--surface-header)", borderWidth: 1, borderColor: "var(--border)", items: "center", children: _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$ink", children: `After · ${labelB}` }) }), _jsx("div", { role: "slider", tabIndex: 0, "aria-label": "Compare before and after versions", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(at), onKeyDown: onKeyDown, onFocus: () => setSliderFocused(true), onBlur: () => setSliderFocused(false), style: {
|
|
403
|
+
position: 'absolute',
|
|
404
|
+
top: 0,
|
|
405
|
+
bottom: 0,
|
|
406
|
+
left: `${at}%`,
|
|
407
|
+
width: 2,
|
|
408
|
+
transform: 'translateX(-1px)',
|
|
409
|
+
background: 'var(--foreground)',
|
|
410
|
+
boxShadow: '0 0 0 1px var(--background)',
|
|
411
|
+
outline: 'none',
|
|
412
|
+
}, children: _jsx("div", { "aria-hidden": true, style: {
|
|
413
|
+
position: 'absolute',
|
|
414
|
+
top: '50%',
|
|
415
|
+
left: '50%',
|
|
416
|
+
transform: 'translate(-50%, -50%)',
|
|
417
|
+
width: 34,
|
|
418
|
+
height: 34,
|
|
419
|
+
borderRadius: 999,
|
|
420
|
+
background: 'var(--background)',
|
|
421
|
+
border: '1px solid var(--border-strong)',
|
|
422
|
+
display: 'flex',
|
|
423
|
+
alignItems: 'center',
|
|
424
|
+
justifyContent: 'center',
|
|
425
|
+
boxShadow: sliderFocused ? '0 0 0 2px var(--ring), var(--shadow-sheet-2)' : 'var(--shadow-sheet-2)',
|
|
426
|
+
color: 'var(--foreground)',
|
|
427
|
+
}, children: _jsx(MoveHorizontal, { size: 14 }) }) })] }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `Drag divider or press ← / → · ${Math.round(at)}%` })] }));
|
|
72
428
|
}
|
package/lib/download.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Save bytes as a file the person keeps. */
|
|
2
|
+
export function download(name, blob) {
|
|
3
|
+
const url = URL.createObjectURL(blob);
|
|
4
|
+
const a = document.createElement('a');
|
|
5
|
+
a.href = url;
|
|
6
|
+
a.download = name;
|
|
7
|
+
document.body.appendChild(a);
|
|
8
|
+
a.click();
|
|
9
|
+
a.remove();
|
|
10
|
+
setTimeout(() => URL.revokeObjectURL(url), 10_000);
|
|
11
|
+
}
|
package/lib/gpu.d.ts
CHANGED
|
@@ -7,8 +7,20 @@
|
|
|
7
7
|
* `failed` row carries the engine's reason, and a row still `queued` when the
|
|
8
8
|
* wait runs out is said to be still rendering, never called finished.
|
|
9
9
|
*/
|
|
10
|
-
import { dispatch, type Wire } from './wire.ts';
|
|
10
|
+
import { dispatch, type Row, type Wire } from './wire.ts';
|
|
11
11
|
export type Lane = Parameters<typeof dispatch>[1];
|
|
12
|
+
/** A sleep that ends early, and frees its timer, when `signal` aborts. */
|
|
13
|
+
export declare const nap: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Follow a dispatched job's work-log row until the engine closes it, `wait` ms
|
|
16
|
+
* pass or `signal` aborts. `seen` hears each change of status (`queued` while
|
|
17
|
+
* the row is not listed). Answers the last row; throws if the log cannot be read.
|
|
18
|
+
*/
|
|
19
|
+
export declare function follow(w: Wire, id: string, o: {
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
every?: number;
|
|
22
|
+
wait?: number;
|
|
23
|
+
}, seen: (status: string, row?: Row) => void): Promise<Row | undefined>;
|
|
12
24
|
export declare function render(w: Wire, lane: Lane, body: object, doing: (line: string) => void, signal: AbortSignal): Promise<{
|
|
13
25
|
blob: Blob;
|
|
14
26
|
path: string;
|
package/lib/gpu.js
CHANGED
|
@@ -11,28 +11,51 @@ import { dispatch, landed, Refusal, worklog } from './wire.js';
|
|
|
11
11
|
/** How long a render is followed, ms: a cold model load plus a video. */
|
|
12
12
|
const WAIT = 20 * 60_000;
|
|
13
13
|
const EVERY = 3_000;
|
|
14
|
+
/** A sleep that ends early, and frees its timer, when `signal` aborts. */
|
|
15
|
+
export const nap = (ms, signal) => new Promise((resolve) => {
|
|
16
|
+
const done = () => {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
signal.removeEventListener('abort', done);
|
|
19
|
+
resolve();
|
|
20
|
+
};
|
|
21
|
+
const timer = setTimeout(done, ms);
|
|
22
|
+
signal.addEventListener('abort', done, { once: true });
|
|
23
|
+
});
|
|
24
|
+
const closed = (status) => status === 'done' || status === 'failed' || status === 'cancelled';
|
|
25
|
+
/**
|
|
26
|
+
* Follow a dispatched job's work-log row until the engine closes it, `wait` ms
|
|
27
|
+
* pass or `signal` aborts. `seen` hears each change of status (`queued` while
|
|
28
|
+
* the row is not listed). Answers the last row; throws if the log cannot be read.
|
|
29
|
+
*/
|
|
30
|
+
export async function follow(w, id, o, seen) {
|
|
31
|
+
const until = Date.now() + (o.wait ?? WAIT);
|
|
32
|
+
let row;
|
|
33
|
+
let last = '';
|
|
34
|
+
while (!o.signal.aborted) {
|
|
35
|
+
row = (await worklog(w, o.signal)).find((r) => r.prompt_id === id || r.id === id);
|
|
36
|
+
const status = row?.status ?? 'queued';
|
|
37
|
+
if (status !== last)
|
|
38
|
+
seen((last = status), row);
|
|
39
|
+
if (closed(status) || Date.now() > until)
|
|
40
|
+
break;
|
|
41
|
+
await nap(o.every ?? EVERY, o.signal);
|
|
42
|
+
}
|
|
43
|
+
return row;
|
|
44
|
+
}
|
|
14
45
|
export async function render(w, lane, body, doing, signal) {
|
|
15
46
|
doing('Sending to your GPU');
|
|
16
47
|
const sent = await dispatch(w, lane, body, signal);
|
|
17
48
|
const id = sent.prompt_id ?? sent.id;
|
|
18
49
|
if (!id)
|
|
19
50
|
throw new Refusal(502, 'The engine took the render but named no job.');
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
if (status === 'failed' || status === 'cancelled')
|
|
30
|
-
throw new Refusal(502, row?.error || `The render ${status}.`);
|
|
31
|
-
if (Date.now() > until)
|
|
32
|
-
throw new Refusal(504, 'Still rendering on your GPU; it will land in the library when it finishes.');
|
|
33
|
-
doing(status === 'running' ? 'Rendering on your GPU' : 'Waiting for a GPU');
|
|
34
|
-
await new Promise((r) => setTimeout(r, EVERY));
|
|
35
|
-
}
|
|
51
|
+
const row = await follow(w, id, { signal }, (status) => doing(status === 'running' ? 'Rendering on your GPU' : 'Waiting for a GPU'));
|
|
52
|
+
if (signal.aborted)
|
|
53
|
+
throw new DOMException('aborted', 'AbortError');
|
|
54
|
+
const status = row?.status ?? 'queued';
|
|
55
|
+
if (status === 'failed' || status === 'cancelled')
|
|
56
|
+
throw new Refusal(502, row?.error || `The render ${status}.`);
|
|
57
|
+
if (status !== 'done')
|
|
58
|
+
throw new Refusal(504, 'Still rendering on your GPU; it will land in the library when it finishes.');
|
|
36
59
|
const paths = row?.outputs?.length ? row.outputs : row?.output ? [row.output] : [];
|
|
37
60
|
if (!paths.length)
|
|
38
61
|
throw new Refusal(502, 'The render finished with no file.');
|
package/lib/handoff.d.ts
ADDED
package/lib/handoff.js
ADDED