From ca52e98b6ca21fcef462e29ee7ecb46018457e76 Mon Sep 17 00:00:00 2001 From: "Alexander G. Morano" Date: Sun, 4 May 2025 18:33:42 -0400 Subject: [PATCH] webhooks for dyanmic widget changes updated --- web/nodes/lerp.js | 5 +++-- web/nodes/{calc_binary.js => op_binary.js} | 5 +++-- web/nodes/op_unary.js | 11 +++++++++-- web/nodes/queue.js | 2 +- web/nodes/value.js | 5 +++-- web/util.js | 6 ++---- 6 files changed, 21 insertions(+), 13 deletions(-) rename web/nodes/{calc_binary.js => op_binary.js} (77%) diff --git a/web/nodes/lerp.js b/web/nodes/lerp.js index 40594bf..6a53042 100644 --- a/web/nodes/lerp.js +++ b/web/nodes/lerp.js @@ -1,7 +1,7 @@ /**/ import { app } from "../../../scripts/app.js" -import { widgetHookControl, widgetHookAB } from "../util.js" +import { widgetHookControl, widgetHookValue } from "../util.js" const _id = "LERP (JOV) 🔰" @@ -17,7 +17,8 @@ app.registerExtension({ const me = onNodeCreated?.apply(this); const alpha = this.widgets.find(w => w.name == 'ALPHA'); widgetHookControl(this, 'TYPE', alpha, true); - widgetHookAB(this, 'TYPE', false); + widgetHookValue(this, 'TYPE', 'AA'); + widgetHookValue(this, 'TYPE', 'BB'); return me; } return nodeType; diff --git a/web/nodes/calc_binary.js b/web/nodes/op_binary.js similarity index 77% rename from web/nodes/calc_binary.js rename to web/nodes/op_binary.js index 7e1ed9e..3e5d3d6 100644 --- a/web/nodes/calc_binary.js +++ b/web/nodes/op_binary.js @@ -1,7 +1,7 @@ /**/ import { app } from "../../../scripts/app.js" -import { widgetHookAB } from "../util.js" +import { widgetHookValue } from "../util.js" const _id = "OP BINARY (JOV) 🌟" @@ -15,7 +15,8 @@ app.registerExtension({ const onNodeCreated = nodeType.prototype.onNodeCreated nodeType.prototype.onNodeCreated = function () { const me = onNodeCreated?.apply(this); - widgetHookAB(this, '❓'); + widgetHookValue(this, 'TYPE', 'AA'); + widgetHookValue(this, 'TYPE', 'BB'); return me; } diff --git a/web/nodes/op_unary.js b/web/nodes/op_unary.js index d3f1761..bd2b711 100644 --- a/web/nodes/op_unary.js +++ b/web/nodes/op_unary.js @@ -1,7 +1,7 @@ /**/ import { app } from "../../../scripts/app.js" -import { TypeSlotEvent, TypeSlot, nodeFitHeight } from "../util.js" +import { TypeSlotEvent, TypeSlot, nodeFitHeight, widgetHookValue } from "../util.js" const _id = "OP UNARY (JOV) 🎲" @@ -13,6 +13,13 @@ app.registerExtension({ return; } + const onNodeCreated = nodeType.prototype.onNodeCreated + nodeType.prototype.onNodeCreated = function () { + const me = onNodeCreated?.apply(this); + widgetHookValue(this, 'TYPE', 'AA'); + return me; + } +/* const onConnectionsChange = nodeType.prototype.onConnectionsChange nodeType.prototype.onConnectionsChange = function (slotType, slot_idx, event, link_info, node_slot) { const me = onConnectionsChange?.apply(this, arguments); @@ -41,7 +48,7 @@ app.registerExtension({ nodeFitHeight(this); return me; } - +*/ return nodeType; } }) diff --git a/web/nodes/queue.js b/web/nodes/queue.js index 22e9c53..46678f2 100644 --- a/web/nodes/queue.js +++ b/web/nodes/queue.js @@ -8,7 +8,7 @@ import { flashBackgroundColor } from '../fun.js' const _id1 = "QUEUE (JOV) 🗃"; const _id2 = "QUEUE TOO (JOV) 🗃"; -const _prefix = '🦄'; +const _prefix = '❔'; const EVENT_JOVI_PING = "jovi-queue-ping"; const EVENT_JOVI_DONE = "jovi-queue-done"; diff --git a/web/nodes/value.js b/web/nodes/value.js index 68042c5..fb790ed 100644 --- a/web/nodes/value.js +++ b/web/nodes/value.js @@ -1,7 +1,7 @@ /**/ import { app } from "../../../scripts/app.js" -import { widgetHookAB, nodeFitHeight} from "../util.js" +import { widgetHookValue, nodeFitHeight} from "../util.js" const _id = "VALUE (JOV) 🧬" @@ -21,7 +21,8 @@ app.registerExtension({ this.outputs[3].type = "*"; this.outputs[4].type = "*"; - const ab_data = widgetHookAB(this, 'TYPE'); + const ab_data = widgetHookValue(this, 'TYPE', 'AA'); + widgetHookValue(this, 'TYPE', 'BB'); const oldCallback = ab_data.callback; ab_data.callback = () => { diff --git a/web/util.js b/web/util.js index 61b9f41..2617441 100644 --- a/web/util.js +++ b/web/util.js @@ -111,10 +111,9 @@ export function widgetOutputHookType(node, control_key, match_output=0) { /* * matchFloatSize forces the target to be float[n] based on its type size */ -export function widgetHookAB(node, control_key, output_type_match=true) { +export function widgetHookValue(node, control_key, child_key, output_type_match=true) { - const AA = node.widgets.find(w => w.name == 'AA'); - const BB = node.widgets.find(w => w.name == 'BB'); + const AA = node.widgets.find(w => w.name == child_key); const combo = node.widgets.find(w => w.name == control_key); if (combo === undefined) { @@ -122,7 +121,6 @@ export function widgetHookAB(node, control_key, output_type_match=true) { } widgetHookControl(node, control_key, AA); - widgetHookControl(node, control_key, BB); if (output_type_match) { widgetOutputHookType(node, control_key); }