Files
wraith-executioner-year-2-c…/js/utils/node-layout.js
T
wraith_executioner_year_2andCursor eb7bcaa385 ✨ ForEach / End ForEach と stabilize 共通化・Prettier 導入
- combined のリスト実行ループ(ForEach / End ForEach)を追加
- ForEach 出力 * と End ForEach value は接続後も常に *
- attachStabilizeHooks / pinWildcardSlot / scheduleStabilizeRetries で JS を整理
- Prettier(JS は trailing comma なし)、README 開発セクションを整理

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 03:11:45 +09:00

44 lines
1.0 KiB
JavaScript

/**
* 動的入出力ノードのキャンバス上サイズを内容に合わせる。
*/
/**
* 出力スロットのカスタム座標を外し、配列順と描画位置のずれを防ぐ。
*
* @param {object} node
*/
export function normalizeOutputSlotLayout(node) {
for (const output of node.outputs ?? []) {
delete output.pos;
if (output.hidden) {
output.hidden = false;
}
}
}
/**
* computeSize() の結果でノード枠を更新(出力増減後に接続点が枠外へ出るのを防ぐ)。
*
* @param {object} node
*/
export function syncNodeSizeToContent(node) {
if (node.removed || typeof node.computeSize !== "function") {
return;
}
normalizeOutputSlotLayout(node);
const size = node.computeSize();
if (!size?.length) {
return;
}
const current = node.size ?? [0, 0];
const nextW = size[0];
const nextH = size[1];
if (current[0] !== nextW || current[1] !== nextH) {
node.setSize([nextW, nextH]);
node.graph?.setDirtyCanvas?.(true, false);
}
}