| 12 | }; |
| 13 | }, |
| 14 | beforeRegisterNodeDef(nodeType) { |
| 15 | if (nodeType.comfyClass === "MathExpression|pysssss") { |
| 16 | const onDrawForeground = nodeType.prototype.onDrawForeground; |
| 17 | |
| 18 | nodeType.prototype.onNodeCreated = function() { |
| 19 | // These are typed as any to bypass backend validation |
| 20 | // update frontend to restrict types |
| 21 | for(const input of this.inputs) { |
| 22 | input.type = "INT,FLOAT,IMAGE,LATENT"; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | nodeType.prototype.onDrawForeground = function (ctx) { |
| 27 | const r = onDrawForeground?.apply?.(this, arguments); |
| 28 | |
| 29 | const v = app.nodeOutputs?.[this.id + ""]; |
| 30 | if (!this.flags.collapsed && v) { |
| 31 | const text = v.value[0] + ""; |
| 32 | ctx.save(); |
| 33 | ctx.font = "bold 12px sans-serif"; |
| 34 | ctx.fillStyle = "dodgerblue"; |
| 35 | const sz = ctx.measureText(text); |
| 36 | ctx.fillText(text, this.size[0] - sz.width - 5, LiteGraph.NODE_SLOT_HEIGHT * 3); |
| 37 | ctx.restore(); |
| 38 | } |
| 39 | |
| 40 | return r; |
| 41 | }; |
| 42 | } |
| 43 | }, |
| 44 | }); |