html-overlay-node 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-overlay-node",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "A customizable, LiteGraph-style node editor library with canvas rendering, HTML overlays, and flexible execution control",
5
5
  "main": "dist/html-overlay-node.umd.js",
6
6
  "module": "dist/html-overlay-node.es.js",
@@ -221,7 +221,7 @@ describe("Graph", () => {
221
221
 
222
222
  describe("serialization", () => {
223
223
  it("should serialize graph to JSON", () => {
224
- const node = graph.addNode("test/node", { x: 100, y: 200 });
224
+ const _node = graph.addNode("test/node", { x: 100, y: 200 });
225
225
  const json = graph.toJSON();
226
226
 
227
227
  expect(json.nodes).toBeInstanceOf(Array);
@@ -235,7 +235,7 @@ describe("Graph", () => {
235
235
  it("should deserialize graph from JSON", () => {
236
236
  const node1 = graph.addNode("test/node", { x: 100, y: 200 });
237
237
  const node2 = graph.addNode("test/node", { x: 300, y: 400 });
238
- const edge = graph.addEdge(
238
+ const _edge = graph.addEdge(
239
239
  node1.id,
240
240
  node1.outputs[0].id,
241
241
  node2.id,
package/src/core/Hooks.js CHANGED
@@ -2,11 +2,18 @@ export function createHooks(names) {
2
2
  const map = Object.fromEntries(names.map((n) => [n, new Set()]));
3
3
  return {
4
4
  on(name, fn) {
5
+ if (!map[name]) map[name] = new Set();
5
6
  map[name].add(fn);
6
7
  return () => map[name].delete(fn);
7
8
  },
8
- async emit(name, ...args) {
9
- for (const fn of map[name]) await fn(...args);
9
+ off(name, fn) {
10
+ if (map[name]) {
11
+ map[name].delete(fn);
12
+ }
13
+ },
14
+ emit(name, ...args) {
15
+ if (!map[name]) return;
16
+ for (const fn of map[name]) fn(...args);
10
17
  },
11
18
  };
12
19
  }
@@ -53,7 +53,7 @@ export class GroupManager {
53
53
  return groupNode;
54
54
  }
55
55
 
56
- addGroupFromSelection({ title = "Group", margin = { x: 12, y: 12 } } = {}) {
56
+ addGroupFromSelection({ _title = "Group", _margin = { x: 12, y: 12 } } = {}) {
57
57
  // Controller에서 selection을 받아와야 함
58
58
  // 여기서는 간단히 graph.nodes를 순회하며 selected 상태를 확인한다고 가정하거나
59
59
  // 외부에서 members를 넘겨받는 것이 좋음
package/src/index.js CHANGED
@@ -263,7 +263,7 @@ export function createGraphEditor(
263
263
  },
264
264
 
265
265
  // 매 프레임(또는 필요시) 업데이트
266
- update(node, el, { header, body, selected }) {
266
+ update(node, el, { header, _body, selected }) {
267
267
  el.style.borderColor = selected ? "#6cf" : "#444";
268
268
  header.style.backgroundColor = selected ? "#3a4a5a" : "#333";
269
269
 
@@ -1,9 +1,7 @@
1
- import { hitTestNode, portRect } from "../render/hitTest.js";
1
+ import { portRect } from "../render/hitTest.js";
2
2
  import {
3
- MoveNodeCmd,
4
3
  AddEdgeCmd,
5
4
  RemoveEdgeCmd,
6
- CompoundCmd,
7
5
  RemoveNodeCmd,
8
6
  ResizeNodeCmd,
9
7
  } from "../core/commands.js";
@@ -456,8 +454,8 @@ export class Controller {
456
454
  continue;
457
455
  }
458
456
 
459
- let newWorldX = startWorldX + deltaX;
460
- let newWorldY = startWorldY + deltaY;
457
+ const newWorldX = startWorldX + deltaX;
458
+ const newWorldY = startWorldY + deltaY;
461
459
 
462
460
  // Convert to local position
463
461
  let parentWx = 0;
@@ -1,4 +1,4 @@
1
- import { hitTestNode, portRect } from "./hitTest.js";
1
+ import { portRect } from "./hitTest.js";
2
2
 
3
3
  export class CanvasRenderer {
4
4
  static FONT_SIZE = 12;
@@ -542,8 +542,6 @@ export class CanvasRenderer {
542
542
  }
543
543
 
544
544
  _drawOrthogonal(x1, y1, x2, y2) {
545
- const dx = Math.abs(x2 - x1);
546
- const dy = Math.abs(y2 - y1);
547
545
  // 중간 축을 결정 (더 짧은 축을 가운데에 두면 보기 좋음)
548
546
  const useHVH = true; // 가로-세로-가로(HVH) vs 세로-가로-세로(VHV)
549
547
  const midX = (x1 + x2) / 2;
@@ -24,7 +24,7 @@ export class HtmlOverlay {
24
24
  }
25
25
 
26
26
  /** 기본 노드 레이아웃 생성 (헤더 + 바디) */
27
- _createDefaultNodeLayout(node) {
27
+ _createDefaultNodeLayout(_node) {
28
28
  const container = document.createElement("div");
29
29
  container.className = "node-overlay";
30
30
  Object.assign(container.style, {
@@ -55,7 +55,7 @@ export class HtmlOverlay {
55
55
  flex: "1",
56
56
  position: "relative",
57
57
  overflow: "hidden",
58
- pointerEvents: "auto", // 바디 내부는 인터랙션 가능하게? 아니면 이것도 none하고 자식만 auto?
58
+ // 바디 내부는 인터랙션 가능하게? 아니면 이것도 none하고 자식만 auto?
59
59
  // 일단 바디는 auto로 두면 바디 영역 클릭시 드래그가 안됨.
60
60
  // 그래서 바디도 none으로 하고, 내부 컨텐츠(input 등)만 auto로 하는게 맞음.
61
61
  pointerEvents: "none",
@@ -81,7 +81,6 @@ export class PropertyPanel {
81
81
  if (!node) return;
82
82
 
83
83
  const content = this.panel.querySelector('.panel-content');
84
- const def = this.registry?.types?.get(node.type);
85
84
 
86
85
  content.innerHTML = `
87
86
  <div class="section">