comfy-ts 2.25.0 → 2.25.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfy-ts",
3
- "version": "2.25.0",
3
+ "version": "2.25.1",
4
4
  "description": "An efficient way to create, run, maintain and operate your ComfyUI workflows, for humans and agents. A TypeScript SDK typed from your own install, with a CLI, a terminal UI, a web panel and a guide for coding agents.",
5
5
  "keywords": [
6
6
  "comfyui",
@@ -193,6 +193,8 @@ export const LorasControl = observer(function LorasControl(p: {
193
193
  openFor(ix: number) {
194
194
  this.target = ix
195
195
  this.open = true
196
+ // a thumb that failed while the host was down tries again on the next open, not only on a reload
197
+ this.previewFailed.clear()
196
198
  },
197
199
  setOpen(open: boolean) {
198
200
  this.open = open
@@ -318,11 +318,17 @@ export function looksLikeImage(bytes: Uint8Array): boolean {
318
318
  )
319
319
  }
320
320
 
321
+ /** a gate before the body is read, the magic bytes decide after it. octet-stream passes: a
322
+ * Windows python mimetypes table lacks webp, so lora-manager there serves every .webp so */
323
+ function previewContentTypeMayBeImage(ct: string): boolean {
324
+ return ct === '' || ct.startsWith('image/') || ct.startsWith('application/octet-stream')
325
+ }
326
+
321
327
  /**
322
328
  * fetch a preview image's bytes from its server-relative preview_url.
323
329
  * cached on success at `.comfy-ts/cache/lora-previews/<sha1(url)>`. Returns null
324
330
  * when the file is missing: lora-manager SPA-fallbacks to index.html (HTML), so
325
- * a non-image content-type OR non-image magic bytes => no preview, not a crash.
331
+ * an html or video content-type OR non-image magic bytes => no preview, not a crash.
326
332
  */
327
333
  export async function fetchLoraPreviewBytes(host: ComfyHost, previewUrl: string): Promise<Uint8Array | null> {
328
334
  const storage = getComfyStorage()
@@ -332,8 +338,7 @@ export async function fetchLoraPreviewBytes(host: ComfyHost, previewUrl: string)
332
338
  // preview_url is already a full server-relative path — no /api probing
333
339
  const res = await host.fetch(previewUrl, {}, { apiPrefix: false })
334
340
  if (!res.ok) return null
335
- const ct = res.headers.get('content-type') ?? ''
336
- if (ct !== '' && !ct.startsWith('image/')) return null // HTML fallback etc.
341
+ if (!previewContentTypeMayBeImage(res.headers.get('content-type') ?? '')) return null
337
342
  const bytes = new Uint8Array(await res.arrayBuffer())
338
343
  if (!looksLikeImage(bytes)) return null
339
344
  storage.writeBytes(cachePath, bytes)