Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0015638874 | ||
|
|
a48d9c1437 | ||
|
|
48303e1452 | ||
|
|
b0171add24 |
@@ -1,5 +1,111 @@
|
||||
# DEVLOG - ComfyUI-Workflow-Studio
|
||||
|
||||
## 2026-05-16: v0.3.9 サイドパネル I タブ追加 / トップバーアイコン修正
|
||||
|
||||
### 概要
|
||||
|
||||
- ComfyUI サイドパネルのタブを W / N / P / M / **I** の 5 タブ構成に変更し、I タブ(Information / Metadata)を追加
|
||||
- トップバーアイコン(Workflow Studio / カメラ / Node Sets)が表示されない不具合を修正
|
||||
|
||||
### 変更内容
|
||||
|
||||
#### `web/comfyui/node_sets_menu.js`
|
||||
|
||||
**タブラベル短縮(□スタイル)**
|
||||
|
||||
- Workflows → **W**、Nodes → **N**、Prompts → **P**、Models → **M**
|
||||
- ホバー時に `title` 属性でフルネームを表示
|
||||
- CSS: 細ボーダー + アクティブ時に青ボーダーの□スタイル
|
||||
|
||||
**I タブ(Information / Metadata)追加**
|
||||
|
||||
- サブタブ: **model** / **lora** / **Prompts**
|
||||
- ファイルドロップエリア(常時表示、クリックでファイル選択も可)
|
||||
- ファイル情報行(ファイル名・サイズ・形式、常時表示)
|
||||
- model: Checkpoint / VAE / Diffusion Model / Text Encoder(LoRA 除く)
|
||||
- lora: LoRA 名 + strength_model / strength_clip 値
|
||||
- Prompts: POS / NEG バッジ付きリスト → クリックで全文プレビュー(height: 160px)+ Copy ボタン(1.2 秒「Copied!」表示)
|
||||
- メタデータ解析ロジックは `metadata-tab.js` から移植(関数名に `_` プレフィックス付き)
|
||||
- ドロップエリア min-height: 54px、プレビューエリア height: 160px
|
||||
|
||||
#### `web/comfyui/top_menu_extension.js`
|
||||
|
||||
**バグ修正: トップバーアイコン非表示**
|
||||
|
||||
- **原因**: `applyButtonIcon()` 内の `if (button.querySelector("svg")) return` チェックにより、
|
||||
新しい ComfyUI が Iconify で MDI クラス(`icon-[mdi--...]`)をインライン SVG に変換した際、
|
||||
すでに SVG が存在すると判定されてカスタム SVG への置換がスキップされていた
|
||||
- **修正**: 早期リターンチェックを削除し、常に `innerHTML` を上書きするよう変更
|
||||
- MutationObserver ベースの監視を廃止し、lora-manager と同パターンの `requestAnimationFrame` リトライ方式に統一
|
||||
- ボタン未発見時のみリトライ(発見後はリトライを停止)
|
||||
|
||||
---
|
||||
|
||||
## 2026-05-16: v0.3.8 Metadata タブ: data9 対応 / プロンプト判別不能テキスト
|
||||
|
||||
### 概要
|
||||
|
||||
data9 の新規ワークフロー(Flux.2 Dev fp8、Flux.2 Klein 4B Distilled、Ernie Image、
|
||||
Qwen-Image-Edit 2511、WAN2.2 14B Animate)の Metadata タブ表示に対応。
|
||||
あわせて、ポジティブ / ネガティブの判別ができないプロンプトを **Text(バッジなし)** として
|
||||
区別して表示する仕様に変更した。
|
||||
|
||||
### 問題と原因
|
||||
|
||||
| ファイル | 問題 |
|
||||
|---|---|
|
||||
| image_flux2_fp8.json | `SamplerCustomAdvanced` に positive/negative 入力ポートがなく、リンク解決でプロンプトが空になる |
|
||||
| image_ernie_image.json | `PrimitiveStringMultiline` がサブグラフ内にあり、ステップ4(トップのみ対象)で見つからない |
|
||||
| image_qwen_image_edit_2511.json | `TextEncodeQwenImageEditPlus` → `FluxKontextMultiReferenceLatentMethod` → KSampler という中間ノード経由で textMap にプロンプトが登録されない |
|
||||
| video_wan2_2_14B_animate.json | トップレベルの CLIPTextEncode とサブグラフ内の KSampler がクロスレベル接続され、単一レベル解析では取得できない |
|
||||
|
||||
### 変更内容
|
||||
|
||||
#### `static/js/metadata-tab.js`
|
||||
|
||||
**`extractPromptsFromNodeSet`**
|
||||
|
||||
- CLIPTextEncode のテキスト入力リンクのソースノードのタイプ制限を撤廃
|
||||
- 旧: `isPromptStylerNode` または `WFS_PromptText` のみ
|
||||
- 新: PromptStyler 以外は任意ノードの `widgets_values[originSlot]`(`ComfySwitchNode`、`PrimitiveStringMultiline` 等を包含)
|
||||
- テキスト入力名に `"prompt"` を追加(`TextEncodeQwenImageEditPlus` 対応)
|
||||
- `foundSampler = true` かつ pos / neg が両方空の場合(`SamplerCustomAdvanced` 等)、
|
||||
textMap のテキストを `{ positives: [], negatives: [], texts: [...] }` として返すよう変更
|
||||
(旧: `return null`)
|
||||
|
||||
**`extractPromptsLiteGraph`**
|
||||
|
||||
- ステップ4 `PrimitiveStringMultiline` — `nodes`(トップのみ)→ `collectAllNodes(wf)`(サブグラフ含む)に変更
|
||||
- 戻り値: `{ positives: primTexts, negatives: [] }` → `{ positives: [], negatives: [], texts: primTexts }`
|
||||
- ステップ7 最終フォールバック — `nodes`(トップのみ)→ `collectAllNodes(wf)`(サブグラフ含む)に変更
|
||||
- 戻り値: `{ positives: all, negatives: all }` → `{ positives: [], negatives: [], texts: all }`
|
||||
|
||||
**`extractPromptsAPI`**
|
||||
|
||||
- フォールバック時の戻り値: `{ positives: all, negatives: all }` → `{ positives: [], negatives: [], texts: all }`
|
||||
|
||||
**UI**
|
||||
|
||||
- `buildPromptItem`: `type === "text"` のときバッジ(POS/NEG)を表示しない
|
||||
- `buildPromptItem`: fullLabel に `t("metaPromptText")` を使用
|
||||
- `handleFile`: `(meta.texts ?? []).map(p => ({ type: "text", text: p }))` を allPrompts に追加
|
||||
|
||||
#### `static/js/i18n.js`
|
||||
|
||||
- `metaPromptText` を EN / JA / ZH に追加("Text" / "テキスト" / "文本")
|
||||
|
||||
### 対応済みワークフロー(data/data9)
|
||||
|
||||
| ファイル | 適用ステップ | プロンプト結果 |
|
||||
|---|---|---|
|
||||
| image_flux2_fp8.json | step5(サブグラフ + SamplerCustomAdvanced fallback) | texts(バッジなし) |
|
||||
| image_flux2_klein_image_edit_4b_distilled.json | step5(サブグラフ CLIPTextEncode + KSampler) | texts(バッジなし) |
|
||||
| image_ernie_image.json | step4(PrimitiveStringMultiline in subgraph) | texts(バッジなし) |
|
||||
| image_qwen_image_edit_2511.json | step5(TextEncodeQwenImageEditPlus fallback) | texts(バッジなし) |
|
||||
| video_wan2_2_14B_animate.json | step7(全ノード fallback) | texts(バッジなし) |
|
||||
|
||||
---
|
||||
|
||||
## 2026-05-15: v0.3.7 Metadata タブ: Flux2 / Qwen / Z-Image 対応
|
||||
|
||||
### 概要
|
||||
@@ -40,6 +146,12 @@ ComfyUI 公式テンプレート(Flux.2 Dev/Klein、Qwen-Image-Edit、Z-Image
|
||||
| image_z_image.json | UNETLoader + CLIPLoader + VAELoader (subgraph) | CLIPTextEncode (subgraph) |
|
||||
| image_z_image_turbo.json | 同上 | CLIPTextEncode (subgraph) |
|
||||
|
||||
#### `static/js/i18n.js` + `templates/index.html`
|
||||
|
||||
- `metaFormatTodo` を「Flux.2 / Qwen-Image / Z-Image サブグラフ形式に対応済み」に更新(EN/JA/ZH)
|
||||
- `helpMetadata5` の対応フォーマット一覧を更新し Flux.2 / Qwen-Image / Z-Image を明記(EN/JA/ZH)
|
||||
- index.html フォールバックテキストも同内容に更新
|
||||
|
||||
---
|
||||
|
||||
## 2026-05-15: v0.3.6 Metadata タブ追加
|
||||
|
||||
@@ -5,7 +5,7 @@ A comprehensive workflow management and generation UI plugin for [ComfyUI](https
|
||||
Browse, organize, and execute workflows directly from a dedicated studio interface — without switching between windows or manually editing JSON.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## Screenshots
|
||||
|
||||
@@ -92,15 +92,15 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
|
||||
- **Wildcard input toolbar** — one-click buttons to insert `{|}`, `{n$|}`, `__|__`, `<lora::1:LBW=;>` and other wildcard syntax; wraps selected text when applicable
|
||||
- **Wildcard file manager** — create, view, and edit `.txt` / `.yaml` wildcard files stored in `user/default/Workflow-Studio/wildcard/`; click a filename in the file picker to insert `__filename__` at cursor
|
||||
|
||||
### Metadata Tab (v0.3.6)
|
||||
### Metadata Tab (v0.3.8)
|
||||
- **3-column layout** — Drop zone (left) | Model info (center) | LoRA + Prompt (right)
|
||||
- **File drop** — drop a ComfyUI-generated PNG / WebP or workflow JSON onto the drop zone (or click to open a file picker); PNG/WebP images are shown as a preview
|
||||
- **Model extraction** — automatically extracts Checkpoint, VAE, Diffusion Model, and Text Encoder names from the embedded workflow metadata
|
||||
- **Model extraction** — automatically extracts Checkpoint, VAE, Diffusion Model, and Text Encoder names from the workflow; supports both standard and subgraph-based workflows (Flux.2 Dev/Klein, Qwen-Image-Edit/2511/Layered, Z-Image Base/Turbo, Ernie Image, WAN2.2)
|
||||
- **LoRA extraction** — lists all LoRA models with `strength_model / strength_clip` values
|
||||
- **Prompt extraction** — lists positive and negative prompts with POS/NEG badges; click any entry to view the full text below
|
||||
- **Prompt extraction** — lists prompts with POS / NEG badges when positive/negative can be determined; when distinction is not possible (e.g. `SamplerCustomAdvanced`, intermediate nodes, cross-level connections), prompts are shown without a badge as plain **Text**; click any entry to view the full text below
|
||||
- **Prompt actions** — Copy to clipboard, **GenUI:P/N** (set GenerateUI positive/negative prompt), **Prompt:P/N** (set Prompt tab preset positive/negative)
|
||||
- **Format support** — ComfyUI (PNG/WebP/JSON), SD WebUI, SD Forge, Fooocus; support for additional model types beyond SD1.5/SDXL/Illustrious is planned
|
||||
- **Format note** — supported formats are always shown in the left column; planned formats are noted in amber
|
||||
- **Format support** — ComfyUI PNG/WebP/JSON (standard + Flux.2 / Qwen-Image / Z-Image / Ernie Image / WAN2.2 subgraph workflows), SD WebUI, SD Forge, Fooocus
|
||||
- **Format note** — supported formats and covered model types are always shown in the left column
|
||||
|
||||
### Settings Tab
|
||||
- **2-column layout** — left column for all settings; right column shows the Theme panel fixed in place (sticky)
|
||||
@@ -155,13 +155,18 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
|
||||
- **Enable / Disable models** — hide models from ComfyUI by renaming the file extension (`.disabled` suffix); toggle per card (⏸ button), per group (Enable All / Disable All), or filter by status (All / Enabled / Disabled)
|
||||
- **Multi-select & bulk operations** — enter selection mode to check multiple models; bulk action bar supports add/remove from groups and permanent file deletion (model file + preview images + sidecar files such as `.json` / `.info`)
|
||||
|
||||
### Workflow Studio Library (ComfyUI Side Panel) (v0.2.5)
|
||||
- **Workflows tab** — browse favorite workflows (All / ★ Favorites / Groups / By Badge sub-tabs), ★ star shown for favorites in All view
|
||||
- **Nodes tab** — browse favorite nodes (All / ★ Favorites / Groups / Sets / 📂 Category / 🧩 Package sub-tabs), ★ star shown for favorites in All view
|
||||
### Workflow Studio Library (ComfyUI Side Panel) (v0.3.9)
|
||||
- **Tab layout (W / N / P / M / I)** — compact single-letter tabs with full name shown on hover
|
||||
- **W — Workflows tab** — browse favorite workflows (All / ★ Favorites / Groups / By Badge sub-tabs), ★ star shown for favorites in All view
|
||||
- **N — Nodes tab** — browse favorite nodes (All / ★ Favorites / Groups / Sets / 📂 Category / 🧩 Package sub-tabs), ★ star shown for favorites in All view
|
||||
- **Category sub-tab** — dropdown to filter nodes by top-level category
|
||||
- **Package sub-tab** — dropdown to filter nodes by custom node package name
|
||||
- **Models tab** — browse installed models (All / ★ Favorites / Groups / By Type sub-tabs)
|
||||
- **Prompts tab** — browse prompt presets with All / Favorites / Categories sub-tabs
|
||||
- **M — Models tab** — browse installed models (All / ★ Favorites / Groups / By Type sub-tabs)
|
||||
- **P — Prompts tab** — browse prompt presets with All / Favorites / Categories sub-tabs
|
||||
- **I — Information tab** — drop a ComfyUI-generated PNG/WebP or workflow JSON directly in the side panel to view its metadata without leaving the ComfyUI canvas
|
||||
- **model sub-tab** — Checkpoint, VAE, Diffusion Model, and Text Encoder extracted from the workflow
|
||||
- **lora sub-tab** — LoRA names with `strength_model / strength_clip` values
|
||||
- **Prompts sub-tab** — POS / NEG badge list; click any entry to view full text + Copy button
|
||||
- **Drag & drop workflows** — drag a workflow onto the canvas to load it
|
||||
- **Drag & drop nodes** — drag nodes/node sets onto the canvas to place them
|
||||
- **Drag & drop prompts** — drag a preset onto the canvas to create a WFS_PromptText node with positive/negative prompts
|
||||
@@ -245,11 +250,28 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
|
||||
|
||||
## Changelog
|
||||
|
||||
### v0.3.9
|
||||
- **Side panel I tab** — new Information tab in the Workflow Studio Library side panel; drop a ComfyUI PNG/WebP/JSON directly in the panel to inspect models, LoRAs, and prompts without opening the Metadata tab; sub-tabs: model / lora / Prompts with full-text preview and Copy button
|
||||
- **Side panel tab redesign** — tabs shortened to single letters (W / N / P / M / I) with full name shown on hover
|
||||
- **Bug fix: top bar icons** — icons (Workflow Studio / camera / Node Sets) were invisible in newer ComfyUI versions because Iconify converted the MDI CSS class to an inline SVG before the custom SVG could be injected; fixed by removing the early-return guard and adopting the same simple `requestAnimationFrame` retry pattern used by lora-manager
|
||||
|
||||
### v0.3.8
|
||||
- **Metadata Tab: extended subgraph support** — added extraction for Flux.2 Dev fp8 (`SamplerCustomAdvanced`), Flux.2 Klein 4B Distilled (image edit), Ernie Image, Qwen-Image-Edit 2511 (`TextEncodeQwenImageEditPlus`), and WAN2.2 14B Animate (top-level CLIPTextEncode + subgraph KSampler)
|
||||
- **Prompt type: Text (no badge)** — when positive/negative polarity cannot be determined (indirect sampler connections, cross-level links, `PrimitiveStringMultiline` etc.), prompts are listed without a POS/NEG badge; action buttons still work normally
|
||||
- **Prompt extraction improvements** — `extractPromptsFromNodeSet` now resolves link sources from any STRING-output node (e.g. `ComfySwitchNode`, `PrimitiveStringMultiline`) without type restriction; `PrimitiveStringMultiline` search and final text-encoder fallback both extended to include subgraph nodes via `collectAllNodes`
|
||||
- **i18n** — added `metaPromptText` key (EN: "Text" / JA: "テキスト" / ZH: "文本")
|
||||
|
||||
### v0.3.7
|
||||
- **Metadata Tab: subgraph workflow support** — Flux.2 (Dev fp8 / Klein), Qwen-Image-Edit (/ 2511 / Layered), and Z-Image (Base / Turbo) official templates now correctly extract models and prompts; these use ComfyUI's `definitions.subgraphs` format with `UNETLoader`, `CLIPLoader`, and `VAELoader` inside the subgraph
|
||||
- **Prompt extraction improvements** — 7-stage fallback chain: ImageMetadataPromptLoader → WFS_PromptText → top-level CLIPTextEncode+KSampler → `PrimitiveStringMultiline` (flux2-klein) → subgraph CLIPTextEncode+KSampler → PromptStyler → all CLIPTextEncode text
|
||||
- **MarkdownNote model fallback** — `extractMarkdownNoteModels()` parses `**section** → - [model](url)` patterns from MarkdownNote nodes as a supplemental model source
|
||||
- **Format note updated** — "Flux.2 / Qwen-Image / Z-Image subgraph workflows supported" (EN/JA/ZH)
|
||||
|
||||
### v0.3.6
|
||||
- **Metadata Tab** — new tab (between Prompt and Gallery) that extracts model and prompt information from ComfyUI-generated PNG/WebP images and workflow JSON files; 3-column layout: drop zone with image preview (left), Checkpoint/VAE/Diffusion Model/Text Encoder lists (center), LoRA list with strength values + Prompt list with full-text viewer (right)
|
||||
- **Prompt action buttons** — Copy, GenUI:P/N (set GenerateUI prompts), Prompt:P/N (set Prompt tab preset prompts) directly from the extracted prompt text
|
||||
- **SDXL Prompt Styler support** — improved prompt extraction resolves `PromptStyler → CLIPTextEncode` link chains in both LiteGraph and API workflow formats
|
||||
- **Format support** — ComfyUI (PNG/WebP/JSON), SD WebUI, SD Forge, Fooocus; format note in the left column indicates planned support for additional model types
|
||||
- **Format support** — ComfyUI (PNG/WebP/JSON), SD WebUI, SD Forge, Fooocus
|
||||
|
||||
### v0.3.5
|
||||
- **Feeder subtab** — new subtab in GenerateUI for controlling [comfyui-image-feeder](https://github.com/ketle-man/comfyui-image-feeder) nodes; left pane: node selector + all ImageFeeder parameters + presets + Run/Stop controls; center pane: folder tree, image grid with checkbox selection, and preview panel
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
@@ -306,6 +306,7 @@ function applyI18nToHtml() {
|
||||
"wfm-help-sidepanel-7": "helpSidepanel7", "wfm-help-sidepanel-8": "helpSidepanel8",
|
||||
"wfm-help-sidepanel-9": "helpSidepanel9", "wfm-help-sidepanel-10": "helpSidepanel10",
|
||||
"wfm-help-sidepanel-11": "helpSidepanel11", "wfm-help-sidepanel-12": "helpSidepanel12",
|
||||
"wfm-help-sidepanel-13": "helpSidepanel13",
|
||||
"wfm-help-shortcuts-title": "helpShortcutsTitle",
|
||||
"wfm-help-shortcuts-1": "helpShortcuts1", "wfm-help-shortcuts-2": "helpShortcuts2",
|
||||
"wfm-help-shortcuts-3": "helpShortcuts3", "wfm-help-shortcuts-4": "helpShortcuts4",
|
||||
|
||||
+12
-6
@@ -421,6 +421,7 @@ const LANGUAGES = {
|
||||
helpSidepanel10: "Search within each sub-tab to quickly find items",
|
||||
helpSidepanel11: "Models tab: All / ★ Favorites / Groups / By Type sub-tabs",
|
||||
helpSidepanel12: "⚙ Theme button (header): customize panel background, sub-header background, text, border, and secondary text colors — changes are saved to localStorage and applied on next open",
|
||||
helpSidepanel13: "I tab (Information): drop a ComfyUI PNG/WebP/JSON to inspect model, LoRA, and prompt metadata directly in the side panel — sub-tabs: model / lora / Prompts; click any prompt to view full text and copy",
|
||||
helpShortcutsTitle: "Keyboard Shortcuts",
|
||||
helpShortcuts1: "Escape: Close modal/panel",
|
||||
helpShortcuts2: "Enter: Confirm rename, send chat",
|
||||
@@ -558,19 +559,20 @@ const LANGUAGES = {
|
||||
metaParseError: "Failed to parse metadata",
|
||||
metaPromptPositive: "Positive",
|
||||
metaPromptNegative: "Negative",
|
||||
metaPromptText: "Text",
|
||||
metaSelectPrompt: "Select a prompt above to view full text...",
|
||||
metaFormatNoteTitle: "Supported formats",
|
||||
metaFmtComfyui: "ComfyUI — PNG / WebP / JSON",
|
||||
metaFmtSdwebui: "SD WebUI / SD Forge — PNG (parameters)",
|
||||
metaFmtFooocus: "Fooocus — PNG (fooocus_scheme)",
|
||||
metaFormatTodo: "More formats planned (non-SD1.5/SDXL/Illustrious models)",
|
||||
metaFormatTodo: "Flux.2 / Qwen-Image / Z-Image subgraph workflows supported",
|
||||
helpMetadataTitle: "Metadata Tab",
|
||||
helpMetadataDesc: "Drop a ComfyUI-generated PNG/WebP or workflow JSON to instantly extract and view the embedded model and prompt information.",
|
||||
helpMetadata1: "Left column: drop zone (image preview for PNG/WebP) and file info; click or drop to load",
|
||||
helpMetadata2: "Center column: Checkpoint, VAE, Diffusion Model, and Text Encoder lists extracted from the workflow",
|
||||
helpMetadata3: "Right column: LoRA list (with strength values) and Prompt list (click to view full text below)",
|
||||
helpMetadata4: "Prompt actions — Copy: copy to clipboard; GenUI:P/N: set GenerateUI positive/negative prompt; Prompt:P/N: set Prompt tab preset positive/negative",
|
||||
helpMetadata5: "Supported formats: ComfyUI (PNG/WebP/JSON), SD WebUI, SD Forge, Fooocus. Support for additional model types (beyond SD1.5/SDXL/Illustrious) is planned.",
|
||||
helpMetadata5: "Supported: ComfyUI PNG/WebP/JSON (standard + Flux.2 / Qwen-Image / Z-Image subgraph workflows), SD WebUI, SD Forge, Fooocus.",
|
||||
},
|
||||
|
||||
ja: {
|
||||
@@ -990,6 +992,7 @@ const LANGUAGES = {
|
||||
helpSidepanel10: "各サブタブ内で検索してアイテムをすばやく検索",
|
||||
helpSidepanel11: "Modelsタブ:All / ★ Favorites / Groups / By Typeサブタブ",
|
||||
helpSidepanel12: "⚙ テーマボタン(ヘッダー):パネル背景・サブヘッダー背景・文字色・ボーダー・補助テキスト色をカスタマイズ可能、設定はlocalStorageに保存され次回起動時も反映",
|
||||
helpSidepanel13: "I タブ(Information):ComfyUI の PNG / WebP / JSON をドロップするとサイドパネル内でモデル・LoRA・プロンプトのメタデータを確認可能 — サブタブ: model / lora / Prompts;プロンプトをクリックで全文表示・Copyボタンでコピー",
|
||||
helpShortcutsTitle: "キーボード操作",
|
||||
helpShortcuts1: "Escape:モーダル・パネルを閉じる",
|
||||
helpShortcuts2: "Enter:名前変更の確定、チャット送信",
|
||||
@@ -1127,19 +1130,20 @@ const LANGUAGES = {
|
||||
metaParseError: "メタデータの解析に失敗しました",
|
||||
metaPromptPositive: "ポジティブ",
|
||||
metaPromptNegative: "ネガティブ",
|
||||
metaPromptText: "テキスト",
|
||||
metaSelectPrompt: "上のプロンプトを選択すると全文を表示します...",
|
||||
metaFormatNoteTitle: "対応フォーマット",
|
||||
metaFmtComfyui: "ComfyUI — PNG / WebP / JSON",
|
||||
metaFmtSdwebui: "SD WebUI / SD Forge — PNG(parameters チャンク)",
|
||||
metaFmtFooocus: "Fooocus — PNG(fooocus_scheme チャンク)",
|
||||
metaFormatTodo: "対応予定: SD1.5 / SDXL / Illustrious 以外のモデル形式も順次対応",
|
||||
metaFormatTodo: "Flux.2 / Qwen-Image / Z-Image サブグラフ形式に対応済み",
|
||||
helpMetadataTitle: "Metadata タブ",
|
||||
helpMetadataDesc: "ComfyUI で生成した PNG / WebP または ワークフロー JSON をドロップすると、埋め込まれたモデル・プロンプト情報を即座に抽出・表示します。",
|
||||
helpMetadata1: "左列: ドロップゾーン(PNG/WebP は画像プレビュー表示)+ファイル情報・対応フォーマット説明",
|
||||
helpMetadata2: "中列: ワークフローから抽出した Checkpoint・VAE・Diffusion Model・Text Encoder の一覧",
|
||||
helpMetadata3: "右列: LoRA 一覧(強度値付き)+プロンプト一覧(クリックで下部に全文表示)",
|
||||
helpMetadata4: "プロンプトアクション — Copy: クリップボードにコピー; GenUI:P/N: GenerateUI のポジティブ/ネガティブプロンプトにセット; Prompt:P/N: Prompt タブ Presets のポジティブ/ネガティブにセット",
|
||||
helpMetadata5: "対応フォーマット: ComfyUI(PNG/WebP/JSON)・SD WebUI・SD Forge・Fooocus。SD1.5/SDXL/Illustrious 以外のモデル形式への対応は今後予定。",
|
||||
helpMetadata5: "対応フォーマット: ComfyUI PNG/WebP/JSON(標準形式 + Flux.2 / Qwen-Image / Z-Image サブグラフ形式)・SD WebUI・SD Forge・Fooocus。",
|
||||
},
|
||||
|
||||
zh: {
|
||||
@@ -1555,6 +1559,7 @@ const LANGUAGES = {
|
||||
helpSidepanel10: "在各子标签内搜索快速查找项目",
|
||||
helpSidepanel11: "Models标签:All / ★ Favorites / Groups / By Type子标签",
|
||||
helpSidepanel12: "⚙ 主题按钮(标题栏):可自定义面板背景、子标题背景、文字颜色、边框及辅助文字颜色,设置保存至localStorage并在下次打开时生效",
|
||||
helpSidepanel13: "I 标签(Information):拖放 ComfyUI PNG/WebP/JSON 即可在侧面板内查看模型、LoRA 和提示词元数据 — 子标签:model / lora / Prompts;点击提示词可查看全文并复制",
|
||||
helpShortcutsTitle: "键盘操作",
|
||||
helpShortcuts1: "Escape:关闭弹窗/面板",
|
||||
helpShortcuts2: "Enter:确认重命名、发送聊天",
|
||||
@@ -1692,19 +1697,20 @@ const LANGUAGES = {
|
||||
metaParseError: "元数据解析失败",
|
||||
metaPromptPositive: "正向提示",
|
||||
metaPromptNegative: "负向提示",
|
||||
metaPromptText: "文本",
|
||||
metaSelectPrompt: "选择上方提示词以查看全文...",
|
||||
metaFormatNoteTitle: "支持格式",
|
||||
metaFmtComfyui: "ComfyUI — PNG / WebP / JSON",
|
||||
metaFmtSdwebui: "SD WebUI / SD Forge — PNG(parameters)",
|
||||
metaFmtFooocus: "Fooocus — PNG(fooocus_scheme)",
|
||||
metaFormatTodo: "更多格式规划中(SD1.5/SDXL/Illustrious 以外模型)",
|
||||
metaFormatTodo: "已支持 Flux.2 / Qwen-Image / Z-Image 子图工作流",
|
||||
helpMetadataTitle: "Metadata 标签页",
|
||||
helpMetadataDesc: "拖放 ComfyUI 生成的 PNG/WebP 或工作流 JSON,即可提取并显示其中的模型和提示词信息。",
|
||||
helpMetadata1: "左列:拖放区(PNG/WebP 显示图片预览)及文件信息与支持格式说明",
|
||||
helpMetadata2: "中列:从工作流中提取的 Checkpoint、VAE、扩散模型、文本编码器列表",
|
||||
helpMetadata3: "右列:LoRA 列表(含强度值)和提示词列表(点击在下方显示全文)",
|
||||
helpMetadata4: "提示词操作 — Copy:复制到剪贴板;GenUI:P/N:设置 GenerateUI 正/负向提示;Prompt:P/N:设置 Prompt 标签页预设正/负向提示",
|
||||
helpMetadata5: "支持格式:ComfyUI(PNG/WebP/JSON)、SD WebUI、SD Forge、Fooocus。SD1.5/SDXL/Illustrious 以外模型格式的支持正在规划中。",
|
||||
helpMetadata5: "支持格式:ComfyUI PNG/WebP/JSON(标准格式 + Flux.2 / Qwen-Image / Z-Image 子图工作流)、SD WebUI、SD Forge、Fooocus。",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
+28
-13
@@ -205,16 +205,20 @@ function extractPromptsFromNodeSet(nodes, links) {
|
||||
if (text && typeof text === "string") {
|
||||
textMap.set(n.id, text);
|
||||
} else if (Array.isArray(n.inputs)) {
|
||||
const textInput = n.inputs.find(inp => inp.name === "text" || inp.name === "text_g");
|
||||
const textInput = n.inputs.find(inp => inp.name === "text" || inp.name === "text_g" || inp.name === "prompt");
|
||||
if (textInput?.link != null) {
|
||||
const originId = linkOrigin.get(textInput.link);
|
||||
const originSlot = linkSlot.get(textInput.link) ?? 0;
|
||||
const srcNode = originId != null ? nodeMap.get(originId) : null;
|
||||
if (srcNode) {
|
||||
const srcType = srcNode.type ?? "";
|
||||
if (isPromptStylerNode(srcType) || srcType === "WFS_PromptText") {
|
||||
if (isPromptStylerNode(srcType)) {
|
||||
const v = srcNode.widgets_values?.[originSlot];
|
||||
if (v && typeof v === "string") textMap.set(n.id, v);
|
||||
} else {
|
||||
// WFS_PromptText, PrimitiveStringMultiline, ComfySwitchNode 等、任意の STRING 出力ノード
|
||||
const v = srcNode.widgets_values?.[originSlot] ?? srcNode.widgets_values?.[0];
|
||||
if (v && typeof v === "string") textMap.set(n.id, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,7 +240,13 @@ function extractPromptsFromNodeSet(nodes, links) {
|
||||
else if (name === "negative" || name.startsWith("negative")) neg.add(text);
|
||||
}
|
||||
}
|
||||
if (!foundSampler || (pos.size === 0 && neg.size === 0)) return null;
|
||||
if (!foundSampler) return null;
|
||||
// SamplerCustomAdvanced などで positive/negative 直結がない場合、判別不能テキストとして返す
|
||||
if (pos.size === 0 && neg.size === 0) {
|
||||
const allTexts = [...textMap.values()].filter(t => t.trim());
|
||||
if (allTexts.length > 0) return { positives: [], negatives: [], texts: allTexts };
|
||||
return null;
|
||||
}
|
||||
return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
|
||||
@@ -331,7 +341,7 @@ function extractPromptsAPI(wf) {
|
||||
else if (key === "negative" || key.startsWith("negative")) neg.add(text);
|
||||
}
|
||||
}
|
||||
if (!foundSampler || (pos.size === 0 && neg.size === 0)) { const all = [...textMap.values()]; return { positives: all, negatives: all }; }
|
||||
if (!foundSampler || (pos.size === 0 && neg.size === 0)) { const all = [...textMap.values()].filter(t => t && t.trim()); return { positives: [], negatives: [], texts: all }; }
|
||||
return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
|
||||
@@ -359,14 +369,14 @@ function extractPromptsLiteGraph(wf) {
|
||||
const topResult = extractPromptsFromNodeSet(nodes, links ?? []);
|
||||
if (topResult) return topResult;
|
||||
|
||||
// 4. PrimitiveStringMultiline(flux2-klein など)
|
||||
// 4. PrimitiveStringMultiline(flux2-klein / ernie など)- サブグラフ内も探す
|
||||
const primTexts = [];
|
||||
for (const n of nodes) {
|
||||
for (const n of collectAllNodes(wf)) {
|
||||
if (n.type !== "PrimitiveStringMultiline") continue;
|
||||
const t = Array.isArray(n.widgets_values) ? n.widgets_values[0] : n.widgets_values;
|
||||
if (t && typeof t === "string" && t.trim()) primTexts.push(t.trim());
|
||||
}
|
||||
if (primTexts.length > 0) return { positives: primTexts, negatives: [] };
|
||||
if (primTexts.length > 0) return { positives: [], negatives: [], texts: primTexts };
|
||||
|
||||
// 5. サブグラフ内の CLIPTextEncode + KSampler(z-image / qwen / flux など)
|
||||
for (const sg of wf.definitions?.subgraphs ?? []) {
|
||||
@@ -388,14 +398,14 @@ function extractPromptsLiteGraph(wf) {
|
||||
}
|
||||
if (stylerPos.size > 0 || stylerNeg.size > 0) return { positives: [...stylerPos], negatives: [...stylerNeg] };
|
||||
|
||||
// 7. CLIPTextEncode 全テキスト(最終フォールバック)
|
||||
// 7. テキストエンコーダー全テキスト(最終フォールバック)- サブグラフも含む・判別不能
|
||||
const all = [];
|
||||
for (const n of nodes) {
|
||||
for (const n of collectAllNodes(wf)) {
|
||||
if (!isTextEncoderNode(n.type ?? "")) continue;
|
||||
const t = n.widgets_values?.[0];
|
||||
if (t && typeof t === "string") all.push(t);
|
||||
if (t && typeof t === "string" && t.trim()) all.push(t);
|
||||
}
|
||||
return { positives: all, negatives: all };
|
||||
return { positives: [], negatives: [], texts: all };
|
||||
}
|
||||
|
||||
// ── SD/Fooocus prompt extraction ──────────────────────────────
|
||||
@@ -508,13 +518,17 @@ function buildPromptItem(label, type, full, fullArea, fullLabel, listEl) {
|
||||
const el = document.createElement("div");
|
||||
el.className = "wfm-meta-item wfm-meta-item-clickable";
|
||||
const snippet = label.length > 60 ? label.slice(0, 60) + "…" : label;
|
||||
const typeBadge = type === "positive" ? `<span class="wfm-meta-badge-pos">POS</span>` : `<span class="wfm-meta-badge-neg">NEG</span>`;
|
||||
const typeBadge = type === "positive" ? `<span class="wfm-meta-badge-pos">POS</span>`
|
||||
: type === "negative" ? `<span class="wfm-meta-badge-neg">NEG</span>`
|
||||
: ``;
|
||||
el.innerHTML = `${typeBadge}<span class="wfm-meta-item-name">${escapeHtml(snippet)}</span>`;
|
||||
el.addEventListener("click", () => {
|
||||
listEl.querySelectorAll(".wfm-meta-item-clickable").forEach(e => e.classList.remove("selected"));
|
||||
el.classList.add("selected");
|
||||
fullArea.value = full;
|
||||
fullLabel.textContent = type === "positive" ? t("metaPromptPositive") : t("metaPromptNegative");
|
||||
fullLabel.textContent = type === "positive" ? t("metaPromptPositive")
|
||||
: type === "negative" ? t("metaPromptNegative")
|
||||
: t("metaPromptText") || "Text";
|
||||
});
|
||||
return el;
|
||||
}
|
||||
@@ -658,6 +672,7 @@ export function initMetadataTab() {
|
||||
const allPrompts = [
|
||||
...meta.positives.map(p => ({ type: "positive", text: p })),
|
||||
...meta.negatives.map(p => ({ type: "negative", text: p })),
|
||||
...(meta.texts ?? []).map(p => ({ type: "text", text: p })),
|
||||
];
|
||||
if (allPrompts.length > 0) {
|
||||
promptSection.classList.remove("wfm-meta-section-empty");
|
||||
|
||||
@@ -723,7 +723,7 @@
|
||||
<li id="wfm-meta-fmt-sdwebui">SD WebUI / SD Forge — PNG (parameters)</li>
|
||||
<li id="wfm-meta-fmt-fooocus">Fooocus — PNG (fooocus_scheme)</li>
|
||||
</ul>
|
||||
<div class="wfm-meta-format-todo" id="wfm-meta-format-todo">More formats planned (non-SD1.5/SDXL/Illustrious models)</div>
|
||||
<div class="wfm-meta-format-todo" id="wfm-meta-format-todo">Flux.2 / Qwen-Image / Z-Image subgraph workflows supported</div>
|
||||
</div>
|
||||
<input type="file" id="wfm-meta-file-input" accept="image/png,image/webp,.json,application/json" style="display:none;">
|
||||
</div>
|
||||
@@ -864,7 +864,7 @@
|
||||
<li id="wfm-help-metadata-2">Center column: Checkpoint, VAE, Diffusion Model, and Text Encoder lists extracted from the workflow</li>
|
||||
<li id="wfm-help-metadata-3">Right column: LoRA list (with strength values) and Prompt list (click to view full text below)</li>
|
||||
<li id="wfm-help-metadata-4">Prompt actions — Copy: copy to clipboard; GenUI:P/N: set GenerateUI positive/negative prompt; Prompt:P/N: set Prompt tab preset positive/negative</li>
|
||||
<li id="wfm-help-metadata-5">Supported formats: ComfyUI (PNG/WebP/JSON), SD WebUI, SD Forge, Fooocus. Support for additional model types (beyond SD1.5/SDXL/Illustrious) is planned.</li>
|
||||
<li id="wfm-help-metadata-5">Supported: ComfyUI PNG/WebP/JSON (standard + Flux.2 / Qwen-Image / Z-Image subgraph workflows), SD WebUI, SD Forge, Fooocus.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -945,6 +945,7 @@
|
||||
<li id="wfm-help-sidepanel-9">Double-click items to load/place without dragging</li>
|
||||
<li id="wfm-help-sidepanel-10">Search within each sub-tab to quickly find items</li>
|
||||
<li id="wfm-help-sidepanel-12">⚙ Theme button (header): customize panel background, text, border colors — saved to localStorage</li>
|
||||
<li id="wfm-help-sidepanel-13">I tab (Information): drop a ComfyUI PNG/WebP/JSON to inspect model, LoRA, and prompt metadata directly in the side panel — sub-tabs: model / lora / Prompts; click any prompt to view full text and copy</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
+855
-10
@@ -55,6 +55,9 @@ const state = {
|
||||
modelsLoaded: false,
|
||||
// Shared
|
||||
searchText: "",
|
||||
// Info (Metadata) tab
|
||||
infoSubTab: "info-model", // "info-model" | "info-lora" | "info-prompt"
|
||||
infoMeta: null, // parsed metadata from dropped file
|
||||
};
|
||||
|
||||
// ============================================
|
||||
@@ -608,10 +611,11 @@ const createPanel = () => {
|
||||
</div>
|
||||
<div class="wfm-nlp-theme-panel" style="display:none;"></div>
|
||||
<div class="wfm-nlp-tabs">
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab active" data-toptab="workflows">Workflows</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="nodes">Nodes</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="prompts">Prompts</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="models">Models</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab active" data-toptab="workflows" title="Workflows">W</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="nodes" title="Nodes">N</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="prompts" title="Prompts">P</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="models" title="Models">M</button>
|
||||
<button class="wfm-nlp-tab wfm-nlp-top-tab" data-toptab="info" title="Information (Metadata)">I</button>
|
||||
</div>
|
||||
<div class="wfm-nlp-subtabs"></div>
|
||||
<div class="wfm-nlp-subtabs wfm-nlp-subtabs-row2"></div>
|
||||
@@ -634,8 +638,8 @@ const createPanel = () => {
|
||||
const searchInput = panel.querySelector(".wfm-nlp-search-input");
|
||||
if (searchInput) {
|
||||
searchInput.value = "";
|
||||
const placeholders = { workflows: "Search workflows...", nodes: "Search nodes...", prompts: "Search prompts...", models: "Search models..." };
|
||||
searchInput.placeholder = placeholders[tab] || "Search...";
|
||||
const placeholders = { workflows: "Search workflows...", nodes: "Search nodes...", prompts: "Search prompts...", models: "Search models...", info: "" };
|
||||
searchInput.placeholder = placeholders[tab] ?? "Search...";
|
||||
}
|
||||
panel.querySelectorAll(".wfm-nlp-top-tab").forEach(b => b.classList.remove("active"));
|
||||
btn.classList.add("active");
|
||||
@@ -723,7 +727,27 @@ const rebuildSubTabs = () => {
|
||||
row2.querySelectorAll(".wfm-nlp-sub-tab").forEach(b => b.classList.remove("active"));
|
||||
};
|
||||
|
||||
if (state.topTab === "models") {
|
||||
if (state.topTab === "info") {
|
||||
const row1Tabs = [
|
||||
{ key: "info-model", label: "model" },
|
||||
{ key: "info-lora", label: "lora" },
|
||||
{ key: "info-prompt", label: "Prompts" },
|
||||
];
|
||||
const activeKey = state.infoSubTab;
|
||||
for (const t of row1Tabs) {
|
||||
const btn = document.createElement("button");
|
||||
btn.className = "wfm-nlp-tab wfm-nlp-sub-tab" + (activeKey === t.key ? " active" : "");
|
||||
btn.dataset.subtab = t.key;
|
||||
btn.textContent = t.label;
|
||||
btn.addEventListener("click", () => {
|
||||
state.infoSubTab = t.key;
|
||||
updateAllActive();
|
||||
btn.classList.add("active");
|
||||
renderInfoSubContent();
|
||||
});
|
||||
row1.appendChild(btn);
|
||||
}
|
||||
} else if (state.topTab === "models") {
|
||||
const row1Tabs = [
|
||||
{ key: "model-all", label: "All" },
|
||||
{ key: "model-favorites", label: "\u2605 Favorites" },
|
||||
@@ -879,6 +903,20 @@ const renderContent = () => {
|
||||
// Remove filter dropdowns from previous category/package views
|
||||
panelEl.querySelectorAll(".wfm-nlp-filter-row").forEach(e => e.remove());
|
||||
|
||||
// Show/hide search bar and adjust overflow for info tab
|
||||
const searchEl = panelEl?.querySelector(".wfm-nlp-search");
|
||||
if (state.topTab === "info") {
|
||||
if (searchEl) searchEl.style.display = "none";
|
||||
content.style.overflowY = "hidden";
|
||||
content.style.padding = "0";
|
||||
renderInfoTab(content);
|
||||
return;
|
||||
} else {
|
||||
if (searchEl) searchEl.style.display = "";
|
||||
content.style.overflowY = "auto";
|
||||
content.style.padding = "4px 0";
|
||||
}
|
||||
|
||||
if (state.topTab === "models") {
|
||||
if (!state.modelsLoaded) {
|
||||
content.innerHTML = `<div class="wfm-nlp-empty">Loading...</div>`;
|
||||
@@ -1926,6 +1964,641 @@ const showToast = (message, type = "info") => {
|
||||
|
||||
const esc = (s) => s ? String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) : "";
|
||||
|
||||
// ============================================
|
||||
// Info Tab – Metadata Parsing (ported from metadata-tab.js)
|
||||
// ============================================
|
||||
|
||||
const INFO_MAX_FILE_SIZE = 50 * 1024 * 1024;
|
||||
|
||||
function _sanitizeJSON(text) {
|
||||
return text
|
||||
.replace(/-Infinity\b/g, "null")
|
||||
.replace(/\bInfinity\b/g, "null")
|
||||
.replace(/\bNaN\b/g, "null");
|
||||
}
|
||||
|
||||
async function _readWebPEXIFChunk(file) {
|
||||
const buffer = await file.arrayBuffer();
|
||||
const bytes = new Uint8Array(buffer);
|
||||
const view = new DataView(buffer);
|
||||
const ascii = new TextDecoder("latin1");
|
||||
if (bytes.byteLength < 12) return null;
|
||||
if (ascii.decode(bytes.slice(0, 4)) !== "RIFF") return null;
|
||||
if (ascii.decode(bytes.slice(8, 12)) !== "WEBP") return null;
|
||||
let offset = 12;
|
||||
while (offset + 8 <= buffer.byteLength) {
|
||||
const fourcc = ascii.decode(bytes.slice(offset, offset + 4));
|
||||
const chunkSize = view.getUint32(offset + 4, true);
|
||||
if (fourcc === "EXIF") return bytes.slice(offset + 8, offset + 8 + chunkSize);
|
||||
offset += 8 + chunkSize;
|
||||
if (chunkSize % 2 === 1) offset++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function _extractWorkflowFromEXIF(exifBytes) {
|
||||
const utf8 = new TextDecoder("utf-8", { fatal: false });
|
||||
const text = utf8.decode(exifBytes);
|
||||
for (const key of ["workflow:", "prompt:"]) {
|
||||
const idx = text.indexOf(key + "{");
|
||||
if (idx < 0) continue;
|
||||
let jsonStr = text.slice(idx + key.length);
|
||||
const nullIdx = jsonStr.indexOf("\x00");
|
||||
if (nullIdx >= 0) jsonStr = jsonStr.slice(0, nullIdx);
|
||||
try { return JSON.parse(_sanitizeJSON(jsonStr)); } catch {
|
||||
const lb = jsonStr.lastIndexOf("}");
|
||||
if (lb > 0) { try { return JSON.parse(_sanitizeJSON(jsonStr.slice(0, lb + 1))); } catch {} }
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function _findNull(arr, start = 0) {
|
||||
for (let i = start; i < arr.length; i++) if (arr[i] === 0) return i;
|
||||
return -1;
|
||||
}
|
||||
function _parseTEXtChunk(data, latin1) {
|
||||
const np = _findNull(data);
|
||||
if (np === -1) return null;
|
||||
return { keyword: latin1.decode(data.slice(0, np)), text: latin1.decode(data.slice(np + 1)) };
|
||||
}
|
||||
function _parseITXtChunk(data, latin1, utf8) {
|
||||
const np = _findNull(data);
|
||||
if (np === -1) return null;
|
||||
const keyword = latin1.decode(data.slice(0, np));
|
||||
let pos = np + 3;
|
||||
pos = _findNull(data, pos); if (pos === -1) return null; pos++;
|
||||
pos = _findNull(data, pos); if (pos === -1) return null; pos++;
|
||||
return { keyword, text: utf8.decode(data.slice(pos)) };
|
||||
}
|
||||
async function _readAllPNGTextChunks(file) {
|
||||
const buffer = await file.arrayBuffer();
|
||||
const bytes = new Uint8Array(buffer);
|
||||
const PNG_SIG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
||||
for (let i = 0; i < 8; i++) if (bytes[i] !== PNG_SIG[i]) return null;
|
||||
const view = new DataView(buffer);
|
||||
const latin1 = new TextDecoder("latin1");
|
||||
const utf8 = new TextDecoder("utf-8");
|
||||
let offset = 8;
|
||||
const chunks = {};
|
||||
while (offset + 12 <= buffer.byteLength) {
|
||||
const length = view.getUint32(offset);
|
||||
if (offset + 12 + length > buffer.byteLength) break;
|
||||
const type = latin1.decode(bytes.slice(offset + 4, offset + 8));
|
||||
const data = bytes.slice(offset + 8, offset + 8 + length);
|
||||
if (type === "tEXt") { const c = _parseTEXtChunk(data, latin1); if (c) chunks[c.keyword] = c.text; }
|
||||
else if (type === "iTXt") { const c = _parseITXtChunk(data, latin1, utf8); if (c) chunks[c.keyword] = c.text; }
|
||||
offset += 12 + length;
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
function _collectUnique(arr) {
|
||||
const seen = new Set(), out = [];
|
||||
for (const v of arr) { if (v && typeof v === "string" && !seen.has(v)) { seen.add(v); out.push(v); } }
|
||||
return out;
|
||||
}
|
||||
function _collectAllNodes(wf) {
|
||||
if (!Array.isArray(wf.nodes)) return [];
|
||||
const all = [...wf.nodes];
|
||||
for (const sg of wf.definitions?.subgraphs ?? []) if (Array.isArray(sg.nodes)) all.push(...sg.nodes);
|
||||
return all;
|
||||
}
|
||||
const _META_NODE_TYPES = new Set(["ImageMetadataCheckpointLoader", "ImageMetadataPromptLoader"]);
|
||||
const _VAE_NONE = "None";
|
||||
|
||||
function _extractCheckpoints(wf) {
|
||||
if (!wf || typeof wf !== "object") return [];
|
||||
if (Array.isArray(wf.nodes)) return _collectUnique(_collectAllNodes(wf).filter(n => n.type?.toLowerCase().includes("checkpoint") || _META_NODE_TYPES.has(n.type)).map(n => n.widgets_values?.[0]));
|
||||
return _collectUnique(Object.values(wf).filter(n => n?.class_type?.toLowerCase().includes("checkpoint") || _META_NODE_TYPES.has(n?.class_type)).map(n => n.inputs?.ckpt_name));
|
||||
}
|
||||
function _extractVAEs(wf) {
|
||||
if (!wf || typeof wf !== "object") return [];
|
||||
if (Array.isArray(wf.nodes)) return _collectUnique(_collectAllNodes(wf).flatMap(n => { if (n.type === "VAELoader") return [n.widgets_values?.[0]]; if (_META_NODE_TYPES.has(n.type ?? "")) { const v = n.widgets_values?.[1]; return v && v !== _VAE_NONE ? [v] : []; } return []; }));
|
||||
return _collectUnique(Object.values(wf).flatMap(n => { if (!n || typeof n !== "object") return []; if (n.class_type === "VAELoader") return [n.inputs?.vae_name]; if (_META_NODE_TYPES.has(n.class_type ?? "")) { const v = n.inputs?.vae_name; return v && v !== _VAE_NONE ? [v] : []; } return []; }));
|
||||
}
|
||||
function _extractDiffusionModels(wf) {
|
||||
if (!wf || typeof wf !== "object") return [];
|
||||
if (Array.isArray(wf.nodes)) return _collectUnique(_collectAllNodes(wf).filter(n => n.type === "UNETLoader").map(n => n.widgets_values?.[0]));
|
||||
return _collectUnique(Object.values(wf).filter(n => n?.class_type === "UNETLoader").map(n => n.inputs?.unet_name));
|
||||
}
|
||||
function _extractTextEncoders(wf) {
|
||||
if (!wf || typeof wf !== "object") return [];
|
||||
const names = [];
|
||||
if (Array.isArray(wf.nodes)) {
|
||||
for (const n of _collectAllNodes(wf)) {
|
||||
if (n.type === "CLIPLoader") { if (n.widgets_values?.[0]) names.push(n.widgets_values[0]); }
|
||||
else if (n.type === "DualCLIPLoader") { [0,1].forEach(i => { if (n.widgets_values?.[i]) names.push(n.widgets_values[i]); }); }
|
||||
else if (n.type === "TripleCLIPLoader") { [0,1,2].forEach(i => { if (n.widgets_values?.[i]) names.push(n.widgets_values[i]); }); }
|
||||
}
|
||||
} else {
|
||||
for (const n of Object.values(wf)) {
|
||||
if (!n || typeof n !== "object") continue;
|
||||
const ct = n.class_type ?? "";
|
||||
if (ct === "CLIPLoader") { if (n.inputs?.clip_name) names.push(n.inputs.clip_name); }
|
||||
else if (ct === "DualCLIPLoader") { if (n.inputs?.clip_name1) names.push(n.inputs.clip_name1); if (n.inputs?.clip_name2) names.push(n.inputs.clip_name2); }
|
||||
else if (ct === "TripleCLIPLoader") { ["clip_name1","clip_name2","clip_name3"].forEach(k => { if (n.inputs?.[k]) names.push(n.inputs[k]); }); }
|
||||
}
|
||||
}
|
||||
return _collectUnique(names);
|
||||
}
|
||||
function _extractLoRAs(wf) {
|
||||
if (!wf || typeof wf !== "object") return [];
|
||||
const results = [], seen = new Set();
|
||||
function add(name, sm, sc) {
|
||||
if (!name || typeof name !== "string" || name === "None" || seen.has(name)) return;
|
||||
seen.add(name);
|
||||
results.push({ name, strength_model: typeof sm === "number" ? sm : 1.0, strength_clip: typeof sc === "number" ? sc : 1.0 });
|
||||
}
|
||||
if (Array.isArray(wf.nodes)) {
|
||||
for (const n of _collectAllNodes(wf)) {
|
||||
const type = n.type ?? "";
|
||||
if (type === "LoraLoader") add(n.widgets_values?.[0], n.widgets_values?.[1], n.widgets_values?.[2]);
|
||||
else if (type === "LoraLoaderModelOnly") add(n.widgets_values?.[0], n.widgets_values?.[1], 1.0);
|
||||
else if (type === "ImageMetadataLoRALoader") { for (let i = 0; i < 3; i++) add(n.widgets_values?.[i*3], n.widgets_values?.[i*3+1], n.widgets_values?.[i*3+2]); }
|
||||
else if (type === "Lora Loader (LoraManager)") { const list = n.widgets_values?.find(v => Array.isArray(v)); if (list) for (const l of list) { if (l?.active !== false) add(l?.name, l?.strength ?? 1.0, l?.clipStrength ?? l?.strength ?? 1.0); } }
|
||||
}
|
||||
} else {
|
||||
for (const n of Object.values(wf)) {
|
||||
if (!n || typeof n !== "object") continue;
|
||||
const ct = n.class_type ?? "";
|
||||
if (ct === "LoraLoader") add(n.inputs?.lora_name, n.inputs?.strength_model, n.inputs?.strength_clip);
|
||||
else if (ct === "LoraLoaderModelOnly") add(n.inputs?.lora_name, n.inputs?.strength, 1.0);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
function _isTextEncoderNode(ct) { return ct === "CLIPTextEncode" || ct.includes("TextEncode") || ct.includes("TextEncoderSD"); }
|
||||
function _isSamplerNode(ct) { return ct === "KSampler" || ct === "KSamplerAdvanced" || ct.includes("KSampler") || ct.includes("Sampler"); }
|
||||
function _isPromptStylerNode(ct) { return ct.includes("PromptStyler"); }
|
||||
|
||||
function _extractPromptsFromNodeSet(nodes, links) {
|
||||
const nodeMap = new Map();
|
||||
for (const n of nodes) nodeMap.set(n.id, n);
|
||||
const linkOrigin = new Map(), linkSlot = new Map();
|
||||
if (Array.isArray(links)) {
|
||||
for (const lk of links) {
|
||||
if (Array.isArray(lk)) { linkOrigin.set(lk[0], lk[1]); linkSlot.set(lk[0], lk[2] ?? 0); }
|
||||
else if (lk && typeof lk === "object") { const id = lk.id ?? lk[0], origin = lk.origin_id ?? lk[1], slot = lk.origin_slot ?? lk[2] ?? 0; if (id != null && origin != null) { linkOrigin.set(id, origin); linkSlot.set(id, slot); } }
|
||||
}
|
||||
}
|
||||
const textMap = new Map();
|
||||
for (const n of nodes) {
|
||||
if (!_isTextEncoderNode(n.type ?? "")) continue;
|
||||
const text = n.widgets_values?.[0];
|
||||
if (text && typeof text === "string") { textMap.set(n.id, text); }
|
||||
else if (Array.isArray(n.inputs)) {
|
||||
const textInput = n.inputs.find(inp => inp.name === "text" || inp.name === "text_g" || inp.name === "prompt");
|
||||
if (textInput?.link != null) {
|
||||
const originId = linkOrigin.get(textInput.link);
|
||||
const originSlot = linkSlot.get(textInput.link) ?? 0;
|
||||
const srcNode = originId != null ? nodeMap.get(originId) : null;
|
||||
if (srcNode) {
|
||||
const srcType = srcNode.type ?? "";
|
||||
if (_isPromptStylerNode(srcType)) { const v = srcNode.widgets_values?.[originSlot]; if (v && typeof v === "string") textMap.set(n.id, v); }
|
||||
else { const v = srcNode.widgets_values?.[originSlot] ?? srcNode.widgets_values?.[0]; if (v && typeof v === "string") textMap.set(n.id, v); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const pos = new Set(), neg = new Set();
|
||||
let foundSampler = false;
|
||||
for (const n of nodes) {
|
||||
if (!_isSamplerNode(n.type ?? "") || !Array.isArray(n.inputs)) continue;
|
||||
foundSampler = true;
|
||||
for (const inp of n.inputs) {
|
||||
if (!inp || inp.link == null) continue;
|
||||
const originId = linkOrigin.get(inp.link);
|
||||
if (originId == null) continue;
|
||||
const txt = textMap.get(originId);
|
||||
if (!txt) continue;
|
||||
const name = inp.name ?? "";
|
||||
if (name === "positive" || name.startsWith("positive")) pos.add(txt);
|
||||
else if (name === "negative" || name.startsWith("negative")) neg.add(txt);
|
||||
}
|
||||
}
|
||||
if (!foundSampler) return null;
|
||||
if (pos.size === 0 && neg.size === 0) {
|
||||
const allTexts = [...textMap.values()].filter(t => t.trim());
|
||||
if (allTexts.length > 0) return { positives: [], negatives: [], texts: allTexts };
|
||||
return null;
|
||||
}
|
||||
return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
|
||||
function _extractMarkdownNoteModels(wf) {
|
||||
const allNodes = [];
|
||||
if (Array.isArray(wf.nodes)) allNodes.push(...wf.nodes);
|
||||
for (const sg of wf.definitions?.subgraphs ?? []) if (Array.isArray(sg.nodes)) allNodes.push(...sg.nodes);
|
||||
const result = { checkpoints: [], vaes: [], diffusionModels: [], textEncoders: [], loras: [] };
|
||||
const seen = { checkpoints: new Set(), vaes: new Set(), diffusionModels: new Set(), textEncoders: new Set(), loras: new Set() };
|
||||
function addU(arr, set, name) { if (name && typeof name === "string" && !set.has(name)) { set.add(name); arr.push(name); } }
|
||||
for (const n of allNodes) {
|
||||
if (n.type !== "MarkdownNote") continue;
|
||||
const raw = n.widgets_values;
|
||||
const text = Array.isArray(raw) ? raw[0] : (typeof raw === "string" ? raw : null);
|
||||
if (!text) continue;
|
||||
const sRe = /\*\*([^*\n]+)\*\*/g;
|
||||
let sm;
|
||||
while ((sm = sRe.exec(text)) !== null) {
|
||||
const sec = sm[1].trim().toLowerCase().replace(/\s+/g, "_");
|
||||
if (!["text_encoders", "diffusion_models", "vae", "checkpoints", "loras"].includes(sec)) continue;
|
||||
const rest = text.slice(sm.index + sm[0].length);
|
||||
const end = rest.search(/\n\*\*|\n##/);
|
||||
const content = end >= 0 ? rest.slice(0, end) : rest;
|
||||
const lRe = /^- \[([^\]]+)\]/gm;
|
||||
let lm;
|
||||
while ((lm = lRe.exec(content)) !== null) {
|
||||
const name = lm[1].trim();
|
||||
if (sec === "text_encoders") addU(result.textEncoders, seen.textEncoders, name);
|
||||
else if (sec === "diffusion_models") addU(result.diffusionModels, seen.diffusionModels, name);
|
||||
else if (sec === "vae") addU(result.vaes, seen.vaes, name);
|
||||
else if (sec === "checkpoints") addU(result.checkpoints, seen.checkpoints, name);
|
||||
else if (sec === "loras") addU(result.loras, seen.loras, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
const hasAny = result.checkpoints.length || result.vaes.length || result.diffusionModels.length || result.textEncoders.length || result.loras.length;
|
||||
return hasAny ? result : null;
|
||||
}
|
||||
|
||||
function _resolveLinkedText(wf, srcId, slot) {
|
||||
const src = wf[String(srcId)];
|
||||
if (!src || typeof src !== "object") return null;
|
||||
const ct = src.class_type ?? "";
|
||||
if (_isPromptStylerNode(ct)) { const v = slot === 0 ? src.inputs?.text_positive : src.inputs?.text_negative; return (v && typeof v === "string") ? v : null; }
|
||||
const keys = slot === 0 ? ["text_positive", "text", "text_g", "prompt"] : ["text_negative", "text_l"];
|
||||
for (const k of keys) { const v = src.inputs?.[k]; if (v && typeof v === "string") return v; }
|
||||
return null;
|
||||
}
|
||||
|
||||
function _extractPromptsAPI(wf) {
|
||||
const metaNodes = Object.values(wf).filter(n => n?.class_type === "ImageMetadataPromptLoader");
|
||||
if (metaNodes.length > 0) {
|
||||
const pos = new Set(), neg = new Set();
|
||||
for (const n of metaNodes) { if (n.inputs?.positive_text) pos.add(n.inputs.positive_text); if (n.inputs?.negative_text) neg.add(n.inputs.negative_text); }
|
||||
if (pos.size > 0 || neg.size > 0) return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
const textMap = new Map();
|
||||
for (const [id, n] of Object.entries(wf)) {
|
||||
if (!n || !_isTextEncoderNode(n.class_type ?? "")) continue;
|
||||
const raw = n.inputs?.text ?? n.inputs?.text_g ?? null;
|
||||
if (raw && typeof raw === "string") { textMap.set(id, raw); }
|
||||
else if (Array.isArray(raw)) { const txt = _resolveLinkedText(wf, raw[0], raw[1] ?? 0); if (txt) textMap.set(id, txt); }
|
||||
}
|
||||
const pos = new Set(), neg = new Set();
|
||||
let foundSampler = false;
|
||||
for (const n of Object.values(wf)) {
|
||||
if (!n || !_isSamplerNode(n.class_type ?? "")) continue;
|
||||
foundSampler = true;
|
||||
for (const [key, val] of Object.entries(n.inputs ?? {})) {
|
||||
if (!Array.isArray(val)) continue;
|
||||
const txt = textMap.get(String(val[0]));
|
||||
if (!txt) continue;
|
||||
if (key === "positive" || key.startsWith("positive")) pos.add(txt);
|
||||
else if (key === "negative" || key.startsWith("negative")) neg.add(txt);
|
||||
}
|
||||
}
|
||||
if (!foundSampler || (pos.size === 0 && neg.size === 0)) { const all = [...textMap.values()].filter(t => t && t.trim()); return { positives: [], negatives: [], texts: all }; }
|
||||
return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
|
||||
function _extractPromptsLiteGraph(wf) {
|
||||
const { nodes, links } = wf;
|
||||
if (!Array.isArray(nodes)) return { positives: [], negatives: [] };
|
||||
const metaNodes = nodes.filter(n => n.type === "ImageMetadataPromptLoader");
|
||||
if (metaNodes.length > 0) {
|
||||
const pos = new Set(), neg = new Set();
|
||||
for (const n of metaNodes) { const p = n.widgets_values?.[2], ng = n.widgets_values?.[3]; if (p) pos.add(p); if (ng) neg.add(ng); }
|
||||
if (pos.size > 0 || neg.size > 0) return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
const wfsNodes = nodes.filter(n => n.type === "WFS_PromptText");
|
||||
if (wfsNodes.length > 0) {
|
||||
const pos = new Set(), neg = new Set();
|
||||
for (const n of wfsNodes) { const p = n.widgets_values?.[0], ng = n.widgets_values?.[1]; if (p) pos.add(p); if (ng) neg.add(ng); }
|
||||
if (pos.size > 0 || neg.size > 0) return { positives: [...pos], negatives: [...neg] };
|
||||
}
|
||||
const topResult = _extractPromptsFromNodeSet(nodes, links ?? []);
|
||||
if (topResult) return topResult;
|
||||
const primTexts = [];
|
||||
for (const n of _collectAllNodes(wf)) {
|
||||
if (n.type !== "PrimitiveStringMultiline") continue;
|
||||
const t = Array.isArray(n.widgets_values) ? n.widgets_values[0] : n.widgets_values;
|
||||
if (t && typeof t === "string" && t.trim()) primTexts.push(t.trim());
|
||||
}
|
||||
if (primTexts.length > 0) return { positives: [], negatives: [], texts: primTexts };
|
||||
for (const sg of wf.definitions?.subgraphs ?? []) {
|
||||
if (!Array.isArray(sg.nodes)) continue;
|
||||
const sgResult = _extractPromptsFromNodeSet(sg.nodes, sg.links ?? []);
|
||||
if (sgResult) return sgResult;
|
||||
}
|
||||
const stylerPos = new Set(), stylerNeg = new Set();
|
||||
for (const n of nodes) {
|
||||
if (!_isPromptStylerNode(n.type ?? "")) continue;
|
||||
const vals = n.widgets_values ?? [];
|
||||
for (let i = 0; i < vals.length; i++) { if (typeof vals[i] !== "string" || !vals[i].trim()) continue; if (i % 2 === 0) stylerPos.add(vals[i]); else stylerNeg.add(vals[i]); }
|
||||
}
|
||||
if (stylerPos.size > 0 || stylerNeg.size > 0) return { positives: [...stylerPos], negatives: [...stylerNeg] };
|
||||
const all = [];
|
||||
for (const n of _collectAllNodes(wf)) {
|
||||
if (!_isTextEncoderNode(n.type ?? "")) continue;
|
||||
const t = n.widgets_values?.[0];
|
||||
if (t && typeof t === "string" && t.trim()) all.push(t);
|
||||
}
|
||||
return { positives: [], negatives: [], texts: all };
|
||||
}
|
||||
|
||||
function _extractPrompts(wf) {
|
||||
if (!wf || typeof wf !== "object") return { positives: [], negatives: [] };
|
||||
return Array.isArray(wf.nodes) ? _extractPromptsLiteGraph(wf) : _extractPromptsAPI(wf);
|
||||
}
|
||||
|
||||
function _parseSDAParameters(raw) {
|
||||
const text = raw.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
||||
const stepsMatch = text.match(/\nSteps:\s+\d/);
|
||||
if (!stepsMatch) return null;
|
||||
const paramsStart = stepsMatch.index + 1;
|
||||
const promptSection = text.slice(0, paramsStart - 1);
|
||||
const paramsLine = text.slice(paramsStart);
|
||||
const negSep = "\nNegative prompt: ";
|
||||
const negIdx = promptSection.indexOf(negSep);
|
||||
let positive = "", negative = "";
|
||||
if (negIdx !== -1) { positive = promptSection.slice(0, negIdx).trim(); negative = promptSection.slice(negIdx + negSep.length).trim(); }
|
||||
else positive = promptSection.trim();
|
||||
const params = {};
|
||||
const re = /,?\s*([A-Za-z][A-Za-z0-9 ]*):\s*("(?:[^"\\]|\\.)*"|[^,]+)/g;
|
||||
let m;
|
||||
while ((m = re.exec(paramsLine)) !== null) params[m[1].trim()] = m[2].trim().replace(/^"|"$/g, "");
|
||||
return { positive, negative, params };
|
||||
}
|
||||
function _parseFooocusMetadata(raw) {
|
||||
let obj; try { obj = JSON.parse(raw); } catch { return null; }
|
||||
if (!obj?.base_model) return null;
|
||||
const toArray = v => !v ? [] : Array.isArray(v) ? v.filter(Boolean) : [String(v)];
|
||||
return { checkpoint: obj.base_model, vae: (obj.vae && obj.vae !== "Default") ? obj.vae : null, positives: toArray(obj.full_prompt ?? obj.prompt), negatives: toArray(obj.full_negative_prompt ?? obj.negative_prompt) };
|
||||
}
|
||||
|
||||
async function _extractAllMetadata(file) {
|
||||
const name = file.name.toLowerCase();
|
||||
const isJSON = file.type === "application/json" || name.endsWith(".json");
|
||||
const isWebP = file.type === "image/webp" || name.endsWith(".webp");
|
||||
|
||||
function fromWorkflow(wf, source) {
|
||||
const base = { source, checkpoints: _extractCheckpoints(wf), vaes: _extractVAEs(wf), diffusionModels: _extractDiffusionModels(wf), textEncoders: _extractTextEncoders(wf), loras: _extractLoRAs(wf), ..._extractPrompts(wf) };
|
||||
const mdm = _extractMarkdownNoteModels(wf);
|
||||
if (mdm) {
|
||||
if (!base.checkpoints.length) base.checkpoints = mdm.checkpoints;
|
||||
if (!base.vaes.length) base.vaes = mdm.vaes;
|
||||
if (!base.diffusionModels.length) base.diffusionModels = mdm.diffusionModels;
|
||||
if (!base.textEncoders.length) base.textEncoders = mdm.textEncoders;
|
||||
if (!base.loras.length) base.loras = mdm.loras;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
if (isJSON) {
|
||||
let wf; try { wf = JSON.parse(_sanitizeJSON(await file.text())); } catch { return null; }
|
||||
return wf ? fromWorkflow(wf, "comfyui") : null;
|
||||
}
|
||||
if (isWebP) {
|
||||
const exif = await _readWebPEXIFChunk(file);
|
||||
if (!exif) return null;
|
||||
const wf = _extractWorkflowFromEXIF(exif);
|
||||
return wf ? fromWorkflow(wf, "comfyui") : null;
|
||||
}
|
||||
// PNG
|
||||
const chunks = await _readAllPNGTextChunks(file);
|
||||
if (!chunks) return null;
|
||||
if (chunks.prompt) { let wf; try { wf = JSON.parse(_sanitizeJSON(chunks.prompt)); } catch { return null; } return wf ? fromWorkflow(wf, "comfyui") : null; }
|
||||
if (chunks.workflow) { let wf; try { wf = JSON.parse(_sanitizeJSON(chunks.workflow)); } catch { return null; } return wf ? fromWorkflow(wf, "comfyui") : null; }
|
||||
if (chunks.fooocus_scheme === "fooocus" && chunks.parameters) {
|
||||
const f = _parseFooocusMetadata(chunks.parameters);
|
||||
if (!f) return null;
|
||||
return { source: "fooocus", checkpoints: [f.checkpoint], vaes: f.vae ? [f.vae] : [], diffusionModels: [], textEncoders: [], loras: [], positives: f.positives, negatives: f.negatives };
|
||||
}
|
||||
if (chunks.parameters) {
|
||||
const p = _parseSDAParameters(chunks.parameters);
|
||||
if (!p) return null;
|
||||
const { positive, negative, params } = p;
|
||||
const modelName = params["Model"];
|
||||
if (!modelName) return null;
|
||||
if (params["Module 2"] != null) {
|
||||
const textEncoders = [];
|
||||
for (let i = 2; i <= 9; i++) { const mod = params[`Module ${i}`]; if (!mod) break; textEncoders.push(mod); }
|
||||
return { source: "sd_forge", checkpoints: [], vaes: params["Module 1"] ? [params["Module 1"]] : [], diffusionModels: [modelName], textEncoders, loras: [], positives: positive ? [positive] : [], negatives: negative ? [negative] : [] };
|
||||
}
|
||||
const vaeValue = params["Module 1"] ?? params["VAE"] ?? null;
|
||||
return { source: "sd", checkpoints: [modelName], vaes: vaeValue ? [vaeValue] : [], diffusionModels: [], textEncoders: [], loras: [], positives: positive ? [positive] : [], negatives: negative ? [negative] : [] };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Info Tab – UI rendering
|
||||
// ============================================
|
||||
|
||||
const handleInfoFile = async (file) => {
|
||||
if (!file || !panelEl) return;
|
||||
const fileInfo = panelEl.querySelector("#wfm-nlp-info-fileinfo");
|
||||
const previewImg = panelEl.querySelector("#wfm-nlp-info-preview-img");
|
||||
const dropLabel = panelEl.querySelector("#wfm-nlp-info-drop-label");
|
||||
|
||||
if (file.size > INFO_MAX_FILE_SIZE) {
|
||||
if (fileInfo) fileInfo.textContent = "File too large (max 50MB)";
|
||||
return;
|
||||
}
|
||||
if (fileInfo) fileInfo.textContent = "Parsing...";
|
||||
|
||||
const isImage = file.type.startsWith("image/") || /\.(png|webp|jpg|jpeg)$/i.test(file.name);
|
||||
if (isImage && previewImg && dropLabel) {
|
||||
const url = URL.createObjectURL(file);
|
||||
previewImg.src = url;
|
||||
previewImg.style.display = "block";
|
||||
dropLabel.style.display = "none";
|
||||
previewImg.onload = () => URL.revokeObjectURL(url);
|
||||
} else if (previewImg && dropLabel) {
|
||||
previewImg.style.display = "none";
|
||||
dropLabel.style.display = "";
|
||||
}
|
||||
|
||||
let meta;
|
||||
try { meta = await _extractAllMetadata(file); }
|
||||
catch (err) { if (fileInfo) fileInfo.textContent = "Parse error: " + err.message; return; }
|
||||
|
||||
if (!meta) {
|
||||
if (fileInfo) fileInfo.textContent = "No metadata found in file";
|
||||
state.infoMeta = null;
|
||||
renderInfoSubContent();
|
||||
return;
|
||||
}
|
||||
|
||||
state.infoMeta = meta;
|
||||
const sizeKB = (file.size / 1024).toFixed(1);
|
||||
const srcLabel = { comfyui: "ComfyUI", sd: "SD WebUI", sd_forge: "SD Forge", fooocus: "Fooocus" }[meta.source] ?? meta.source;
|
||||
if (fileInfo) fileInfo.textContent = `${file.name} (${sizeKB} KB · ${srcLabel})`;
|
||||
renderInfoSubContent();
|
||||
};
|
||||
|
||||
const setupInfoDropHandlers = (container) => {
|
||||
const dropZone = container.querySelector("#wfm-nlp-info-drop");
|
||||
const dropLabel = container.querySelector("#wfm-nlp-info-drop-label");
|
||||
const previewImg = container.querySelector("#wfm-nlp-info-preview-img");
|
||||
const fileInput = container.querySelector("#wfm-nlp-info-file-input");
|
||||
if (!dropZone) return;
|
||||
|
||||
dropZone.addEventListener("dragover", e => { e.preventDefault(); e.stopPropagation(); dropZone.classList.add("drag-over"); });
|
||||
dropZone.addEventListener("dragleave", e => { e.stopPropagation(); dropZone.classList.remove("drag-over"); });
|
||||
dropZone.addEventListener("drop", e => {
|
||||
e.preventDefault(); e.stopPropagation();
|
||||
dropZone.classList.remove("drag-over");
|
||||
handleInfoFile(e.dataTransfer.files?.[0]);
|
||||
});
|
||||
dropZone.addEventListener("click", e => { if (e.target === previewImg) return; fileInput.click(); });
|
||||
fileInput.addEventListener("change", () => { handleInfoFile(fileInput.files?.[0]); fileInput.value = ""; });
|
||||
|
||||
const copyBtn = container.querySelector("#wfm-nlp-info-copy-btn");
|
||||
if (copyBtn) {
|
||||
copyBtn.addEventListener("click", () => {
|
||||
const textarea = container.querySelector("#wfm-nlp-info-prompt-full");
|
||||
const text = textarea?.value;
|
||||
if (!text) return;
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
const orig = copyBtn.textContent;
|
||||
copyBtn.textContent = "Copied!";
|
||||
copyBtn.classList.add("wfm-nlp-info-copy-btn--done");
|
||||
setTimeout(() => { copyBtn.textContent = orig; copyBtn.classList.remove("wfm-nlp-info-copy-btn--done"); }, 1200);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const renderInfoModels = (container, meta) => {
|
||||
container.innerHTML = "";
|
||||
if (!meta) {
|
||||
container.innerHTML = `<div class="wfm-nlp-info-empty">Drop a PNG/WebP/JSON file to view model info</div>`;
|
||||
return;
|
||||
}
|
||||
const sections = [
|
||||
{ label: "Checkpoint", items: meta.checkpoints },
|
||||
{ label: "VAE", items: meta.vaes },
|
||||
{ label: "Diffusion Model", items: meta.diffusionModels },
|
||||
{ label: "Text Encoder", items: meta.textEncoders },
|
||||
];
|
||||
let hasAny = false;
|
||||
for (const { label, items } of sections) {
|
||||
if (!items || items.length === 0) continue;
|
||||
hasAny = true;
|
||||
const sec = document.createElement("div");
|
||||
sec.className = "wfm-nlp-info-section";
|
||||
sec.innerHTML = `<div class="wfm-nlp-info-section-title">${esc(label)}</div>`;
|
||||
for (const name of items) {
|
||||
const item = document.createElement("div");
|
||||
item.className = "wfm-nlp-info-item";
|
||||
item.title = name;
|
||||
item.innerHTML = `<span class="wfm-nlp-info-item-name">${esc(name)}</span>`;
|
||||
sec.appendChild(item);
|
||||
}
|
||||
container.appendChild(sec);
|
||||
}
|
||||
if (!hasAny) container.innerHTML = `<div class="wfm-nlp-info-empty">No model info found</div>`;
|
||||
};
|
||||
|
||||
const renderInfoLoras = (container, meta) => {
|
||||
container.innerHTML = "";
|
||||
if (!meta || !meta.loras || meta.loras.length === 0) {
|
||||
container.innerHTML = `<div class="wfm-nlp-info-empty">${meta ? "No LoRA found" : "Drop a PNG/WebP/JSON file to view LoRA info"}</div>`;
|
||||
return;
|
||||
}
|
||||
for (const lora of meta.loras) {
|
||||
const item = document.createElement("div");
|
||||
item.className = "wfm-nlp-info-item";
|
||||
item.title = lora.name;
|
||||
const sm = typeof lora.strength_model === "number" ? lora.strength_model.toFixed(2) : "—";
|
||||
const sc = typeof lora.strength_clip === "number" ? lora.strength_clip.toFixed(2) : "—";
|
||||
item.innerHTML = `<span class="wfm-nlp-info-item-name">${esc(lora.name)}</span><span class="wfm-nlp-info-item-badge">${sm}/${sc}</span>`;
|
||||
container.appendChild(item);
|
||||
}
|
||||
};
|
||||
|
||||
const renderInfoPrompts = (container, meta) => {
|
||||
container.innerHTML = "";
|
||||
const promptFull = panelEl?.querySelector("#wfm-nlp-info-prompt-full");
|
||||
const promptFullLabel = panelEl?.querySelector("#wfm-nlp-info-prompt-full-label");
|
||||
if (!meta) {
|
||||
container.innerHTML = `<div class="wfm-nlp-info-empty">Drop a PNG/WebP/JSON file to view prompts</div>`;
|
||||
return;
|
||||
}
|
||||
const allPrompts = [
|
||||
...(meta.positives || []).map(p => ({ type: "positive", text: p })),
|
||||
...(meta.negatives || []).map(p => ({ type: "negative", text: p })),
|
||||
...((meta.texts || []).map(p => ({ type: "text", text: p }))),
|
||||
];
|
||||
if (allPrompts.length === 0) {
|
||||
container.innerHTML = `<div class="wfm-nlp-info-empty">No prompts found</div>`;
|
||||
return;
|
||||
}
|
||||
for (const { type, text } of allPrompts) {
|
||||
const item = document.createElement("div");
|
||||
item.className = "wfm-nlp-info-prompt-item";
|
||||
const snippet = text.length > 55 ? text.slice(0, 55) + "…" : text;
|
||||
const badge = type === "positive"
|
||||
? `<span class="wfm-nlp-info-badge-pos">POS</span>`
|
||||
: type === "negative"
|
||||
? `<span class="wfm-nlp-info-badge-neg">NEG</span>`
|
||||
: "";
|
||||
item.innerHTML = `${badge}<span class="wfm-nlp-info-item-name">${esc(snippet)}</span>`;
|
||||
item.addEventListener("click", () => {
|
||||
container.querySelectorAll(".wfm-nlp-info-prompt-item").forEach(e => e.classList.remove("selected"));
|
||||
item.classList.add("selected");
|
||||
if (promptFull) promptFull.value = text;
|
||||
if (promptFullLabel) promptFullLabel.textContent = type === "positive" ? "Positive" : type === "negative" ? "Negative" : "Text";
|
||||
});
|
||||
container.appendChild(item);
|
||||
}
|
||||
const first = container.querySelector(".wfm-nlp-info-prompt-item");
|
||||
if (first) first.click();
|
||||
};
|
||||
|
||||
const renderInfoSubContent = () => {
|
||||
if (!panelEl) return;
|
||||
const subContent = panelEl.querySelector("#wfm-nlp-info-subcontent");
|
||||
const promptPreview = panelEl.querySelector("#wfm-nlp-info-prompt-preview");
|
||||
if (!subContent) return;
|
||||
const meta = state.infoMeta;
|
||||
if (state.infoSubTab === "info-prompt") {
|
||||
if (promptPreview) promptPreview.style.display = "flex";
|
||||
renderInfoPrompts(subContent, meta);
|
||||
} else {
|
||||
if (promptPreview) promptPreview.style.display = "none";
|
||||
if (state.infoSubTab === "info-model") renderInfoModels(subContent, meta);
|
||||
else renderInfoLoras(subContent, meta);
|
||||
}
|
||||
};
|
||||
|
||||
const renderInfoTab = (container) => {
|
||||
if (!container.querySelector(".wfm-nlp-info-layout")) {
|
||||
container.innerHTML = `
|
||||
<div class="wfm-nlp-info-layout">
|
||||
<div class="wfm-nlp-info-drop" id="wfm-nlp-info-drop">
|
||||
<img id="wfm-nlp-info-preview-img" style="display:none;max-width:100%;max-height:100%;object-fit:contain;pointer-events:none;">
|
||||
<span id="wfm-nlp-info-drop-label" style="font-size:11px;color:var(--descrip-text,#999);pointer-events:none;">Drop PNG / WebP / JSON</span>
|
||||
<input type="file" id="wfm-nlp-info-file-input" accept=".png,.webp,.json,image/png,image/webp,application/json" style="display:none;">
|
||||
</div>
|
||||
<div id="wfm-nlp-info-fileinfo" class="wfm-nlp-info-fileinfo">—</div>
|
||||
<div id="wfm-nlp-info-subcontent" class="wfm-nlp-info-subcontent"></div>
|
||||
<div id="wfm-nlp-info-prompt-preview" class="wfm-nlp-info-prompt-preview" style="display:none;">
|
||||
<div id="wfm-nlp-info-prompt-full-label" class="wfm-nlp-info-prompt-label"></div>
|
||||
<textarea id="wfm-nlp-info-prompt-full" class="wfm-nlp-info-prompt-textarea" readonly></textarea>
|
||||
<button id="wfm-nlp-info-copy-btn" class="wfm-nlp-info-copy-btn">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
setupInfoDropHandlers(container);
|
||||
}
|
||||
renderInfoSubContent();
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// Save selected nodes as Node Set (context menu)
|
||||
// ============================================
|
||||
@@ -2096,14 +2769,186 @@ const injectStyles = () => {
|
||||
border-bottom-color: var(--p-button-background, #4a9eff);
|
||||
}
|
||||
.wfm-nlp-top-tab {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
padding: 9px 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
padding: 6px 2px;
|
||||
border-radius: 3px;
|
||||
border: 1px solid transparent;
|
||||
margin: 3px 1px;
|
||||
}
|
||||
.wfm-nlp-top-tab.active {
|
||||
border-color: var(--p-button-background, #4a9eff);
|
||||
}
|
||||
.wfm-nlp-sub-tab {
|
||||
font-size: 10px;
|
||||
padding: 6px 4px;
|
||||
}
|
||||
/* Info tab layout */
|
||||
.wfm-nlp-info-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wfm-nlp-info-drop {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 54px;
|
||||
border: 2px dashed var(--border-color, #4e4e4e);
|
||||
border-radius: 6px;
|
||||
margin: 8px 8px 0;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
transition: border-color 0.15s;
|
||||
position: relative;
|
||||
}
|
||||
.wfm-nlp-info-drop:hover,
|
||||
.wfm-nlp-info-drop.drag-over {
|
||||
border-color: var(--p-button-background, #4a9eff);
|
||||
background: rgba(74,158,255,0.04);
|
||||
}
|
||||
.wfm-nlp-info-fileinfo {
|
||||
font-size: 10px;
|
||||
color: var(--descrip-text, #888);
|
||||
padding: 4px 10px 6px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid var(--border-color, #3a3a3a);
|
||||
}
|
||||
.wfm-nlp-info-subcontent {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px 0;
|
||||
}
|
||||
.wfm-nlp-info-section {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.wfm-nlp-info-section-title {
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
color: var(--descrip-text, #888);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.6px;
|
||||
padding: 6px 10px 2px;
|
||||
}
|
||||
.wfm-nlp-info-item {
|
||||
padding: 4px 10px;
|
||||
font-size: 11px;
|
||||
border-bottom: 1px solid var(--border-color, #3a3a3a);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
}
|
||||
.wfm-nlp-info-item-name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 11px;
|
||||
}
|
||||
.wfm-nlp-info-item-badge {
|
||||
font-size: 10px;
|
||||
color: var(--descrip-text, #aaa);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.wfm-nlp-info-empty {
|
||||
padding: 20px 10px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: var(--descrip-text, #888);
|
||||
line-height: 1.6;
|
||||
}
|
||||
.wfm-nlp-info-prompt-item {
|
||||
padding: 5px 10px;
|
||||
font-size: 11px;
|
||||
border-bottom: 1px solid var(--border-color, #3a3a3a);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.wfm-nlp-info-prompt-item:hover {
|
||||
background: var(--comfy-input-bg, #333);
|
||||
}
|
||||
.wfm-nlp-info-prompt-item.selected {
|
||||
background: rgba(74,158,255,0.15);
|
||||
}
|
||||
.wfm-nlp-info-badge-pos {
|
||||
font-size: 9px;
|
||||
font-weight: bold;
|
||||
padding: 1px 4px;
|
||||
border-radius: 3px;
|
||||
background: rgba(46,213,115,0.22);
|
||||
color: #2ed573;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.wfm-nlp-info-badge-neg {
|
||||
font-size: 9px;
|
||||
font-weight: bold;
|
||||
padding: 1px 4px;
|
||||
border-radius: 3px;
|
||||
background: rgba(255,71,87,0.22);
|
||||
color: #ff4757;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.wfm-nlp-info-prompt-preview {
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
border-top: 1px solid var(--border-color, #3a3a3a);
|
||||
padding: 6px 8px;
|
||||
gap: 3px;
|
||||
}
|
||||
.wfm-nlp-info-prompt-label {
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--descrip-text, #888);
|
||||
}
|
||||
.wfm-nlp-info-prompt-textarea {
|
||||
width: 100%;
|
||||
height: 160px;
|
||||
background: var(--comfy-input-bg, #1e1e1e);
|
||||
border: 1px solid var(--border-color, #4e4e4e);
|
||||
border-radius: 3px;
|
||||
color: var(--input-text, #ddd);
|
||||
font-size: 10px;
|
||||
padding: 5px 7px;
|
||||
box-sizing: border-box;
|
||||
resize: none;
|
||||
outline: none;
|
||||
font-family: monospace;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.wfm-nlp-info-copy-btn {
|
||||
align-self: flex-end;
|
||||
margin-top: 4px;
|
||||
padding: 3px 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--border-color, #555);
|
||||
border-radius: 3px;
|
||||
background: none;
|
||||
color: var(--descrip-text, #aaa);
|
||||
transition: background 0.15s, color 0.15s, border-color 0.15s;
|
||||
}
|
||||
.wfm-nlp-info-copy-btn:hover {
|
||||
background: rgba(74,158,255,0.2);
|
||||
color: #4a9eff;
|
||||
border-color: #4a9eff;
|
||||
}
|
||||
.wfm-nlp-info-copy-btn--done {
|
||||
background: rgba(46,213,115,0.2);
|
||||
color: #2ed573;
|
||||
border-color: #2ed573;
|
||||
}
|
||||
.wfm-nlp-search {
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid var(--border-color, #4e4e4e);
|
||||
|
||||
@@ -605,50 +605,33 @@ app.registerExtension({
|
||||
};
|
||||
injectStyles();
|
||||
|
||||
const applyButtonIcon = (button, className, getIconFn, extraStyles) => {
|
||||
if (button.querySelector("svg")) return;
|
||||
button.classList.add(className);
|
||||
button.innerHTML = getIconFn();
|
||||
button.style.borderRadius = "4px";
|
||||
button.style.padding = "6px";
|
||||
if (extraStyles) Object.assign(button.style, extraStyles);
|
||||
const svg = button.querySelector("svg");
|
||||
if (svg) {
|
||||
svg.style.width = "20px";
|
||||
svg.style.height = "20px";
|
||||
}
|
||||
};
|
||||
|
||||
const buttonConfigs = [
|
||||
{ tooltip: BUTTON_TOOLTIP, className: "wfm-top-menu-button", getIcon: getWfmIcon, styles: { backgroundColor: "var(--primary-bg)" } },
|
||||
{ tooltip: SNAPSHOT_TOOLTIP, className: "wfm-snapshot-button", getIcon: getSnapshotIcon, styles: null },
|
||||
{ tooltip: NODE_SETS_TOOLTIP, className: "wfm-node-sets-btn", getIcon: getNodeSetsIcon, styles: null },
|
||||
];
|
||||
|
||||
const replaceAllIcons = () => {
|
||||
const replaceButtonIcons = () => {
|
||||
let foundAny = false;
|
||||
for (const cfg of buttonConfigs) {
|
||||
document.querySelectorAll(`button[aria-label="${cfg.tooltip}"]`).forEach((btn) => {
|
||||
applyButtonIcon(btn, cfg.className, cfg.getIcon, cfg.styles);
|
||||
foundAny = true;
|
||||
btn.classList.add(cfg.className);
|
||||
btn.innerHTML = cfg.getIcon();
|
||||
btn.style.borderRadius = "4px";
|
||||
btn.style.padding = "6px";
|
||||
if (cfg.styles) Object.assign(btn.style, cfg.styles);
|
||||
const svg = btn.querySelector("svg");
|
||||
if (svg) {
|
||||
svg.style.width = "20px";
|
||||
svg.style.height = "20px";
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const waitAndObserve = () => {
|
||||
const firstBtn = document.querySelector(`button[aria-label="${BUTTON_TOOLTIP}"]`);
|
||||
if (!firstBtn) {
|
||||
requestAnimationFrame(waitAndObserve);
|
||||
return;
|
||||
}
|
||||
replaceAllIcons();
|
||||
|
||||
const container = firstBtn.closest(".actionbar-container") || firstBtn.parentElement;
|
||||
if (container) {
|
||||
new MutationObserver(() => replaceAllIcons()).observe(container, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
if (!foundAny) {
|
||||
requestAnimationFrame(replaceButtonIcons);
|
||||
}
|
||||
};
|
||||
requestAnimationFrame(waitAndObserve);
|
||||
requestAnimationFrame(replaceButtonIcons);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user