Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 1x 4x 4x 4x 4x 4x 4x 1x 5x 5x 5x 5x 5x 5x 1x 1x 3x 3x 1x 1x 2x 3x 3x 2x 3x 2x 2x 2x 2x 1x 1x 2x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | export function formatUiLabel(text) {
return String(text ?? '')
.replace(/_/g, ' ')
.replace(/\s+/g, ' ')
.trim()
.toLowerCase();
}
function normalizeInputNames(raw) {
if (!raw) return [];
return (Array.isArray(raw) ? raw : [raw])
.map((value) => String(value))
.filter((value) => value.length > 0);
}
export function getWidgetCombinedInputName(widget, dataInputByName) {
const explicitInputName = normalizeInputNames(widget?.opts?.top_socket_input)[0];
if (explicitInputName && dataInputByName?.has(explicitInputName)) {
return explicitInputName;
}
const widgetLabel = formatUiLabel(widget?.opts?.label || widget?.name);
if (!widgetLabel) return null;
for (const inputName of normalizeInputNames(widget?.opts?.hide_when_input_connected)) {
const input = dataInputByName?.get(inputName);
if (!input) continue;
const inputLabel = formatUiLabel(input.label || input.name);
if (inputLabel === widgetLabel) {
return input.name;
}
}
return null;
}
export function buildCombinedInputNameByWidgetName(widgets, dataInputs) {
const dataInputByName = new Map((dataInputs || []).map((input) => [input.name, input]));
const combinedInputNameByWidgetName = new Map();
for (const widget of widgets || []) {
const combinedInputName = getWidgetCombinedInputName(widget, dataInputByName);
if (combinedInputName) {
combinedInputNameByWidgetName.set(widget.name, combinedInputName);
}
}
return combinedInputNameByWidgetName;
}
|