()
| 13 | registerCustomNodes() { |
| 14 | class MetadataNode extends TLGraphNode { |
| 15 | constructor() { |
| 16 | super(`${commonPrefix} Show Metadata `); |
| 17 | Object.defineProperty(this, "fillMetadataWidget", { |
| 18 | enumerable: true, |
| 19 | configurable: true, |
| 20 | writable: true, |
| 21 | value: () => { |
| 22 | return app.graphToPrompt() |
| 23 | .then((workflow) => { |
| 24 | let result = 'inactive'; |
| 25 | if (this.widgets?.length !== 4) { |
| 26 | console.error('Something is wrong with the widgets, should be 4!'); |
| 27 | return 'error'; |
| 28 | } |
| 29 | const output = this.widgets[0]; |
| 30 | const active = this.widgets[1]?.value; |
| 31 | const parsed = this.widgets[2]?.value; |
| 32 | let what = this.widgets[3]?.value.toLowerCase(); |
| 33 | if (active) { |
| 34 | what = what === 'prompt' ? 'output' : what; |
| 35 | result = workflow[what]; |
| 36 | if (parsed) { |
| 37 | result = JSON.stringify(result, null, 2); |
| 38 | } |
| 39 | else { |
| 40 | result = JSON.stringify(result); |
| 41 | } |
| 42 | } |
| 43 | if (output) { |
| 44 | output.value = result; |
| 45 | } |
| 46 | else { |
| 47 | console.error('Something is wrong with the widgets, output is undefined!'); |
| 48 | return 'error'; |
| 49 | } |
| 50 | return result; |
| 51 | }); |
| 52 | } |
| 53 | }); |
| 54 | this.serialize_widgets = false; |
| 55 | this.isVirtualNode = true; |
| 56 | const widget = ComfyWidgets.STRING(this, '', [ |
| 57 | '', { default: '', multiline: true }, |
| 58 | ], app).widget; |
| 59 | widget.inputEl.readOnly = true; |
| 60 | ComfyWidgets.BOOLEAN(this, 'Active', [ |
| 61 | '', { default: true }, |
| 62 | ]); |
| 63 | ComfyWidgets.BOOLEAN(this, 'Parsed', [ |
| 64 | '', { default: true }, |
| 65 | ]); |
| 66 | ComfyWidgets.COMBO(this, 'What', [ |
| 67 | ['Prompt', 'Workflow'], { default: 'Prompt' }, |
| 68 | ]); |
| 69 | api.addEventListener('executed', this.fillMetadataWidget, false); |
| 70 | } |
| 71 | } |
| 72 | LiteGraph.registerNodeType('Show Metadata [Crystools]', MetadataNode); |
nothing calls this directly
no test coverage detected