@ultrst-armada/kloks 1.0.2 → 1.1.1
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/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +19 -10
- package/packages/backend/dist/index.js +8 -8
- package/packages/contracts/dist/index.d.ts +552 -0
- package/packages/contracts/dist/index.js +422 -0
- package/packages/contracts/kloks.manifest.json +20 -0
- package/packages/contracts/package.json +33 -0
- package/packages/state-graph/dist/{BaseGraph-Bl2f7Pqx.d.ts → BaseGraph-BvkSYOTw.d.ts} +1 -1
- package/packages/state-graph/dist/{BaseNode-1HCEqmap.d.ts → BaseNode-DTcd3K1B.d.ts} +1 -1
- package/packages/state-graph/dist/{CompatibilityMatrix-DX307_vS.d.ts → CompatibilityMatrix-Dj-tCWUA.d.ts} +1 -1
- package/packages/state-graph/dist/chunk-JXDJZSFW.js +459 -0
- package/packages/state-graph/dist/chunk-RHRXPY2U.js +0 -0
- package/packages/state-graph/dist/domain/index.d.ts +3 -3
- package/packages/state-graph/dist/index.d.ts +8 -9
- package/packages/state-graph/dist/index.js +25 -16
- package/packages/state-graph/dist/rules/index.d.ts +3 -3
- package/packages/state-graph/dist/rules/index.js +2 -1
- package/packages/state-graph/dist/spatial/index.d.ts +53 -5
- package/packages/state-graph/dist/spatial/index.js +12 -3
- package/packages/state-graph/dist/store/index.d.ts +159 -6
- package/packages/state-graph/dist/types-VDoc4FIc.d.ts +150 -0
- package/packages/state-graph/dist/TraceEngine-CJVpUb80.d.ts +0 -18
- package/packages/state-graph/dist/chunk-YTWCH6P2.js +0 -109
- package/packages/state-graph/dist/index-CiekWEH3.d.ts +0 -272
- /package/packages/state-graph/dist/{chunk-QN74PLMF.js → chunk-TZOL3RN7.js} +0 -0
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AttractionEngine,
|
|
3
|
+
GhostInferenceEngine,
|
|
4
|
+
GhostLayoutResolver,
|
|
5
|
+
GhostTracePathBuilder,
|
|
3
6
|
calculateSocketCoordinates,
|
|
4
|
-
getBeamPoints
|
|
5
|
-
|
|
7
|
+
getBeamPoints,
|
|
8
|
+
useMagneticTraces
|
|
9
|
+
} from "../chunk-JXDJZSFW.js";
|
|
10
|
+
import "../chunk-TZOL3RN7.js";
|
|
6
11
|
import {
|
|
7
12
|
AutoSolidify,
|
|
8
13
|
SpatialEngine,
|
|
@@ -14,8 +19,12 @@ import "../chunk-3RG5ZIWI.js";
|
|
|
14
19
|
export {
|
|
15
20
|
AttractionEngine,
|
|
16
21
|
AutoSolidify,
|
|
22
|
+
GhostInferenceEngine,
|
|
23
|
+
GhostLayoutResolver,
|
|
24
|
+
GhostTracePathBuilder,
|
|
17
25
|
SpatialEngine,
|
|
18
26
|
TraceEngine,
|
|
19
27
|
calculateSocketCoordinates,
|
|
20
|
-
getBeamPoints
|
|
28
|
+
getBeamPoints,
|
|
29
|
+
useMagneticTraces
|
|
21
30
|
};
|
|
@@ -1,6 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
import '../
|
|
3
|
-
import '../
|
|
4
|
-
import '../
|
|
5
|
-
import '../
|
|
6
|
-
|
|
1
|
+
import { N as NodePosition, a as NodeSize, b as BaseNode, e as BaseNodeProps, h as HandleOffset } from '../BaseNode-DTcd3K1B.js';
|
|
2
|
+
import { V as ViewLink, S as SolidConnection } from '../BaseConnection-CMRrL6Fe.js';
|
|
3
|
+
import { a as BaseViewWindow, L as Landmark, e as GraphView, G as GraphSettings, f as Group } from '../BaseGraph-BvkSYOTw.js';
|
|
4
|
+
import { T as Trace, c as GhostNodeRecord, e as GhostTraceRecord } from '../types-VDoc4FIc.js';
|
|
5
|
+
import '../CompatibilityMatrix-Dj-tCWUA.js';
|
|
6
|
+
|
|
7
|
+
interface CreateViewWindowParams {
|
|
8
|
+
id?: string;
|
|
9
|
+
viewType: string;
|
|
10
|
+
sourceNodeId: string;
|
|
11
|
+
sourceViewHandleId: string;
|
|
12
|
+
position: NodePosition;
|
|
13
|
+
size?: NodeSize;
|
|
14
|
+
}
|
|
15
|
+
declare class ViewWindowManager {
|
|
16
|
+
private windows;
|
|
17
|
+
private links;
|
|
18
|
+
createWindow(params: CreateViewWindowParams): {
|
|
19
|
+
window: BaseViewWindow;
|
|
20
|
+
link: ViewLink;
|
|
21
|
+
};
|
|
22
|
+
selectWindow(id: string): void;
|
|
23
|
+
pinLive(id: string, pinned: boolean): void;
|
|
24
|
+
removeWindow(id: string): boolean;
|
|
25
|
+
getProcessingWindows(): BaseViewWindow[];
|
|
26
|
+
getWindow(id: string): BaseViewWindow | undefined;
|
|
27
|
+
getLink(windowId: string): ViewLink | undefined;
|
|
28
|
+
listWindows(): BaseViewWindow[];
|
|
29
|
+
listLinks(): ViewLink[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class LandmarkManager {
|
|
33
|
+
private landmarks;
|
|
34
|
+
constructor(initialLandmarks?: Landmark[]);
|
|
35
|
+
createLandmark(number: number, name: string, cameraPosition: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}, zoom: number): Landmark;
|
|
39
|
+
getByNumber(number: number): Landmark | undefined;
|
|
40
|
+
getById(id: string): Landmark | undefined;
|
|
41
|
+
updateLandmark(id: string, updates: Partial<Omit<Landmark, 'id'>>): Landmark | undefined;
|
|
42
|
+
deleteLandmark(id: string): boolean;
|
|
43
|
+
list(): Landmark[];
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface CaptureGraphSnapshotParams {
|
|
48
|
+
id?: string;
|
|
49
|
+
name: string;
|
|
50
|
+
nodes: BaseNode[];
|
|
51
|
+
viewWindows: BaseViewWindow[];
|
|
52
|
+
camera: {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
};
|
|
56
|
+
zoom: number;
|
|
57
|
+
selectedNodeIds: string[];
|
|
58
|
+
settingsOverrides?: Partial<GraphSettings>;
|
|
59
|
+
}
|
|
60
|
+
declare class ViewEngine {
|
|
61
|
+
private views;
|
|
62
|
+
constructor(initialViews?: GraphView[]);
|
|
63
|
+
captureView(params: CaptureGraphSnapshotParams): GraphView;
|
|
64
|
+
getView(id: string): GraphView | undefined;
|
|
65
|
+
listViews(): GraphView[];
|
|
66
|
+
deleteView(id: string): boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type GraphListener = () => void;
|
|
70
|
+
declare class GraphStore {
|
|
71
|
+
nodes: BaseNode[];
|
|
72
|
+
connections: SolidConnection[];
|
|
73
|
+
traces: Trace[];
|
|
74
|
+
groups: Group[];
|
|
75
|
+
settings: GraphSettings;
|
|
76
|
+
selectedNodeIds: Set<string>;
|
|
77
|
+
readonly viewWindows: ViewWindowManager;
|
|
78
|
+
readonly landmarks: LandmarkManager;
|
|
79
|
+
readonly views: ViewEngine;
|
|
80
|
+
private listeners;
|
|
81
|
+
subscribe(listener: GraphListener): () => void;
|
|
82
|
+
notify(): void;
|
|
83
|
+
refreshTraces(): void;
|
|
84
|
+
solidifyTrace(traceId: string): SolidConnection | undefined;
|
|
85
|
+
lockAllConnections(): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare class CommandApi {
|
|
89
|
+
private store;
|
|
90
|
+
constructor(store: GraphStore);
|
|
91
|
+
get nodes(): {
|
|
92
|
+
create: (props: BaseNodeProps) => BaseNode;
|
|
93
|
+
delete: (nodeId: string) => void;
|
|
94
|
+
move: (nodeId: string, x: number, y: number) => void;
|
|
95
|
+
lockPosition: (nodeId: string) => void;
|
|
96
|
+
unlockPosition: (nodeId: string) => void;
|
|
97
|
+
};
|
|
98
|
+
get handles(): {
|
|
99
|
+
move: (nodeId: string, handleId: string, offset: HandleOffset) => void;
|
|
100
|
+
resetOffset: (nodeId: string, handleId: string) => void;
|
|
101
|
+
};
|
|
102
|
+
get traces(): {
|
|
103
|
+
refresh: () => void;
|
|
104
|
+
enable: () => void;
|
|
105
|
+
disable: () => void;
|
|
106
|
+
solidify: (traceId: string) => SolidConnection;
|
|
107
|
+
};
|
|
108
|
+
get connections(): {
|
|
109
|
+
create: (sourceNodeId: string, sourceHandleId: string, targetNodeId: string, targetHandleId: string, wireType?: string) => SolidConnection;
|
|
110
|
+
delete: (connectionId: string) => void;
|
|
111
|
+
lock: (connectionId: string) => void;
|
|
112
|
+
unlock: (connectionId: string) => void;
|
|
113
|
+
lockAll: () => void;
|
|
114
|
+
};
|
|
115
|
+
get groups(): {
|
|
116
|
+
create: (group: Group) => void;
|
|
117
|
+
delete: (groupId: string) => void;
|
|
118
|
+
};
|
|
119
|
+
get landmarks(): {
|
|
120
|
+
create: (num: number, name: string, camera: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
}, zoom: number) => Landmark;
|
|
124
|
+
delete: (id: string) => boolean;
|
|
125
|
+
list: () => Landmark[];
|
|
126
|
+
};
|
|
127
|
+
get viewWindows(): {
|
|
128
|
+
create: (params: Parameters<typeof this$1.store.viewWindows.createWindow>[0]) => {
|
|
129
|
+
window: BaseViewWindow;
|
|
130
|
+
link: ViewLink;
|
|
131
|
+
};
|
|
132
|
+
close: (id: string) => boolean;
|
|
133
|
+
select: (id: string) => void;
|
|
134
|
+
pinLive: (id: string, pinned: boolean) => void;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
type GhostStoreListener = () => void;
|
|
139
|
+
declare class GhostStore {
|
|
140
|
+
private static instance;
|
|
141
|
+
isActive: boolean;
|
|
142
|
+
ghostNodes: GhostNodeRecord[];
|
|
143
|
+
ghostTraces: GhostTraceRecord[];
|
|
144
|
+
scenarioIndex: number;
|
|
145
|
+
hoveredGhostId: string | null;
|
|
146
|
+
sourceNodeIds: string[];
|
|
147
|
+
private listeners;
|
|
148
|
+
static getInstance(): GhostStore;
|
|
149
|
+
subscribe(listener: GhostStoreListener): () => void;
|
|
150
|
+
notify(): void;
|
|
151
|
+
setPredictions(nodes: GhostNodeRecord[], traces: GhostTraceRecord[], sourceNodeIds: string[]): void;
|
|
152
|
+
cycleScenario(maxScenarios?: number): void;
|
|
153
|
+
setHoveredGhostId(id: string | null): void;
|
|
154
|
+
getActiveGhostNodes(): GhostNodeRecord[];
|
|
155
|
+
getActiveGhostTraces(): GhostTraceRecord[];
|
|
156
|
+
clear(): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { CommandApi, GhostStore, type GhostStoreListener, type GraphListener, GraphStore };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { b as BaseNode, c as HandleDirection, B as BaseHandle } from './BaseNode-DTcd3K1B.js';
|
|
2
|
+
import { C as CompatibilityResolution } from './CompatibilityMatrix-Dj-tCWUA.js';
|
|
3
|
+
|
|
4
|
+
interface Trace {
|
|
5
|
+
id: string;
|
|
6
|
+
sourceNodeId: string;
|
|
7
|
+
sourceHandleId: string;
|
|
8
|
+
targetNodeId: string;
|
|
9
|
+
targetHandleId: string;
|
|
10
|
+
wireType: string;
|
|
11
|
+
compatibility: CompatibilityResolution;
|
|
12
|
+
spatialScore: number;
|
|
13
|
+
}
|
|
14
|
+
declare class TraceEngine {
|
|
15
|
+
static computeTraces(nodes: BaseNode[], cutoffDistance: number): Trace[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type SocketType = 'input' | 'output';
|
|
19
|
+
interface Socket {
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
type: SocketType;
|
|
23
|
+
dataType?: string;
|
|
24
|
+
direction?: HandleDirection;
|
|
25
|
+
offset?: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
basePosition?: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
connectionMode?: 'SINGLE' | 'MULTI';
|
|
34
|
+
}
|
|
35
|
+
interface GraphNode {
|
|
36
|
+
id: string;
|
|
37
|
+
type: string;
|
|
38
|
+
label: string;
|
|
39
|
+
position: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
size?: {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
data?: Record<string, unknown>;
|
|
48
|
+
inputs?: Socket[];
|
|
49
|
+
outputs?: Socket[];
|
|
50
|
+
width?: number;
|
|
51
|
+
height?: number;
|
|
52
|
+
positionLocked?: boolean;
|
|
53
|
+
minimized?: boolean;
|
|
54
|
+
handles?: BaseHandle[];
|
|
55
|
+
}
|
|
56
|
+
interface GraphEdge {
|
|
57
|
+
id: string;
|
|
58
|
+
source: string;
|
|
59
|
+
sourceSocket: string;
|
|
60
|
+
target: string;
|
|
61
|
+
targetSocket: string;
|
|
62
|
+
label?: string;
|
|
63
|
+
color?: string;
|
|
64
|
+
wireType?: string;
|
|
65
|
+
locked?: boolean;
|
|
66
|
+
deletable?: boolean;
|
|
67
|
+
}
|
|
68
|
+
interface ViewportState {
|
|
69
|
+
panX: number;
|
|
70
|
+
panY: number;
|
|
71
|
+
zoom: number;
|
|
72
|
+
}
|
|
73
|
+
interface NodeGraphConfig {
|
|
74
|
+
minZoom?: number;
|
|
75
|
+
maxZoom?: number;
|
|
76
|
+
gridSize?: number;
|
|
77
|
+
snapToGrid?: boolean;
|
|
78
|
+
wireStyle?: 'bezier' | 'straight' | 'step';
|
|
79
|
+
tracingEnabled?: boolean;
|
|
80
|
+
magneticTracesEnabled?: boolean;
|
|
81
|
+
autoSolidify?: boolean;
|
|
82
|
+
traceCutoffDistance?: number;
|
|
83
|
+
ghostRoutingEnabled?: boolean;
|
|
84
|
+
ghostScenarioCount?: number;
|
|
85
|
+
ghostDecayMs?: number;
|
|
86
|
+
}
|
|
87
|
+
interface NodeGraphPlugin {
|
|
88
|
+
registerNodeDefinition?: (def: unknown) => void;
|
|
89
|
+
registerHandleType?: (type: string) => void;
|
|
90
|
+
registerWireType?: (wire: unknown) => void;
|
|
91
|
+
registerCompatibilityRule?: (rule: unknown) => void;
|
|
92
|
+
registerViewType?: (view: unknown) => void;
|
|
93
|
+
registerTheme?: (theme: unknown) => void;
|
|
94
|
+
registerContextMenuAction?: (action: unknown) => void;
|
|
95
|
+
registerSpawnMenuItem?: (item: unknown) => void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface GhostSocketMapping {
|
|
99
|
+
sourceSocketId: string;
|
|
100
|
+
targetSocketId: string;
|
|
101
|
+
wireType: string;
|
|
102
|
+
}
|
|
103
|
+
interface GhostCandidate {
|
|
104
|
+
id: string;
|
|
105
|
+
nodeType: string;
|
|
106
|
+
label: string;
|
|
107
|
+
scenarioIndex: number;
|
|
108
|
+
score: number;
|
|
109
|
+
sourceNodeId: string;
|
|
110
|
+
socketMappings: GhostSocketMapping[];
|
|
111
|
+
relativeOffset: {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
interface GhostNodeRecord {
|
|
117
|
+
id: string;
|
|
118
|
+
nodeType: string;
|
|
119
|
+
label: string;
|
|
120
|
+
position: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
};
|
|
124
|
+
size: {
|
|
125
|
+
width: number;
|
|
126
|
+
height: number;
|
|
127
|
+
};
|
|
128
|
+
scenarioIndex: number;
|
|
129
|
+
sourceNodeId: string;
|
|
130
|
+
socketMappings: GhostSocketMapping[];
|
|
131
|
+
inputs?: Socket[];
|
|
132
|
+
outputs?: Socket[];
|
|
133
|
+
}
|
|
134
|
+
interface GhostTraceRecord {
|
|
135
|
+
id: string;
|
|
136
|
+
sourceNodeId: string;
|
|
137
|
+
sourceSocketId: string;
|
|
138
|
+
targetGhostNodeId: string;
|
|
139
|
+
targetSocketId: string;
|
|
140
|
+
wireType: string;
|
|
141
|
+
pathD: string;
|
|
142
|
+
scenarioIndex: number;
|
|
143
|
+
}
|
|
144
|
+
interface GhostInferenceOptions {
|
|
145
|
+
scenarioCount?: number;
|
|
146
|
+
maxSuggestionsPerNode?: number;
|
|
147
|
+
customScorer?: (sourceType: string, candidateType: string) => number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { type GraphNode as G, type NodeGraphConfig as N, type Socket as S, type Trace as T, type ViewportState as V, type GhostCandidate as a, type GhostInferenceOptions as b, type GhostNodeRecord as c, type GhostSocketMapping as d, type GhostTraceRecord as e, type GraphEdge as f, type NodeGraphPlugin as g, type SocketType as h, TraceEngine as i };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { B as BaseNode } from './BaseNode-1HCEqmap.js';
|
|
2
|
-
import { C as CompatibilityResolution } from './CompatibilityMatrix-DX307_vS.js';
|
|
3
|
-
|
|
4
|
-
interface Trace {
|
|
5
|
-
id: string;
|
|
6
|
-
sourceNodeId: string;
|
|
7
|
-
sourceHandleId: string;
|
|
8
|
-
targetNodeId: string;
|
|
9
|
-
targetHandleId: string;
|
|
10
|
-
wireType: string;
|
|
11
|
-
compatibility: CompatibilityResolution;
|
|
12
|
-
spatialScore: number;
|
|
13
|
-
}
|
|
14
|
-
declare class TraceEngine {
|
|
15
|
-
static computeTraces(nodes: BaseNode[], cutoffDistance: number): Trace[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { type Trace as T, TraceEngine as a };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// src/spatial/AttractionEngine.ts
|
|
2
|
-
var AttractionEngine = class {
|
|
3
|
-
static computeSimilarity(nodeA, nodeB) {
|
|
4
|
-
if (nodeA.id === nodeB.id) return 1;
|
|
5
|
-
let score = 0;
|
|
6
|
-
let factors = 0;
|
|
7
|
-
factors += 1;
|
|
8
|
-
if (nodeA.type === nodeB.type) {
|
|
9
|
-
score += 1;
|
|
10
|
-
}
|
|
11
|
-
factors += 1;
|
|
12
|
-
const inTypesA = new Set(nodeA.handles.filter((h) => h.direction === "INPUT").map((h) => h.dataType));
|
|
13
|
-
const inTypesB = new Set(nodeB.handles.filter((h) => h.direction === "INPUT").map((h) => h.dataType));
|
|
14
|
-
const sharedIn = [...inTypesA].filter((t) => inTypesB.has(t)).length;
|
|
15
|
-
const totalIn = Math.max(1, (/* @__PURE__ */ new Set([...inTypesA, ...inTypesB])).size);
|
|
16
|
-
score += sharedIn / totalIn;
|
|
17
|
-
factors += 1;
|
|
18
|
-
const outTypesA = new Set(nodeA.handles.filter((h) => h.direction === "OUTPUT").map((h) => h.dataType));
|
|
19
|
-
const outTypesB = new Set(nodeB.handles.filter((h) => h.direction === "OUTPUT").map((h) => h.dataType));
|
|
20
|
-
const sharedOut = [...outTypesA].filter((t) => outTypesB.has(t)).length;
|
|
21
|
-
const totalOut = Math.max(1, (/* @__PURE__ */ new Set([...outTypesA, ...outTypesB])).size);
|
|
22
|
-
score += sharedOut / totalOut;
|
|
23
|
-
return factors > 0 ? score / factors : 0;
|
|
24
|
-
}
|
|
25
|
-
static calculateStep(nodes, strength = 1, speed = 1) {
|
|
26
|
-
const updatedPositions = /* @__PURE__ */ new Map();
|
|
27
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
28
|
-
const nodeA = nodes[i];
|
|
29
|
-
if (nodeA.positionLocked) {
|
|
30
|
-
updatedPositions.set(nodeA.id, { ...nodeA.position });
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
let forceX = 0;
|
|
34
|
-
let forceY = 0;
|
|
35
|
-
for (let j = 0; j < nodes.length; j++) {
|
|
36
|
-
if (i === j) continue;
|
|
37
|
-
const nodeB = nodes[j];
|
|
38
|
-
const similarity = this.computeSimilarity(nodeA, nodeB);
|
|
39
|
-
if (similarity <= 0.1) continue;
|
|
40
|
-
const dx = nodeB.position.x - nodeA.position.x;
|
|
41
|
-
const dy = nodeB.position.y - nodeA.position.y;
|
|
42
|
-
const dist = Math.max(20, Math.sqrt(dx * dx + dy * dy));
|
|
43
|
-
const f = similarity * strength * speed;
|
|
44
|
-
forceX += dx / dist * f;
|
|
45
|
-
forceY += dy / dist * f;
|
|
46
|
-
}
|
|
47
|
-
updatedPositions.set(nodeA.id, {
|
|
48
|
-
x: nodeA.position.x + forceX,
|
|
49
|
-
y: nodeA.position.y + forceY
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return updatedPositions;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/spatial/socketCoordinates.ts
|
|
57
|
-
function calculateSocketCoordinates(baseY, options) {
|
|
58
|
-
const clearance = Math.max(12, options.clearance ?? 14);
|
|
59
|
-
const nudge = options.nudge ?? { x: 0, y: 0 };
|
|
60
|
-
const halfWidth = options.cardWidth / 2;
|
|
61
|
-
const halfHeight = (options.cardHeight ?? 80) / 2;
|
|
62
|
-
const baseX = options.isOutput ? halfWidth + clearance : -halfWidth - clearance;
|
|
63
|
-
let effectiveX = baseX + nudge.x;
|
|
64
|
-
let effectiveY = baseY + nudge.y;
|
|
65
|
-
const minMargin = 4;
|
|
66
|
-
const bodyLeft = -halfWidth;
|
|
67
|
-
const bodyRight = halfWidth;
|
|
68
|
-
const bodyTop = -halfHeight;
|
|
69
|
-
const bodyBottom = halfHeight;
|
|
70
|
-
if (effectiveX > bodyLeft - minMargin && effectiveX < bodyRight + minMargin && effectiveY > bodyTop - minMargin && effectiveY < bodyBottom + minMargin) {
|
|
71
|
-
if (options.isOutput) {
|
|
72
|
-
effectiveX = bodyRight + Math.max(minMargin, clearance / 2);
|
|
73
|
-
} else {
|
|
74
|
-
effectiveX = bodyLeft - Math.max(minMargin, clearance / 2);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
baseX,
|
|
79
|
-
effectiveX,
|
|
80
|
-
effectiveY,
|
|
81
|
-
nudge: {
|
|
82
|
-
x: effectiveX - baseX,
|
|
83
|
-
y: effectiveY - baseY
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
var getBeamPoints = (nudge, baseW = 5, headW = 1.2) => {
|
|
88
|
-
const vx = -nudge.x;
|
|
89
|
-
const vy = -nudge.y;
|
|
90
|
-
const d = Math.sqrt(vx * vx + vy * vy);
|
|
91
|
-
if (d < 1) return "";
|
|
92
|
-
const px = -vy / d;
|
|
93
|
-
const py = vx / d;
|
|
94
|
-
const hL_x = -px * headW;
|
|
95
|
-
const hL_y = -py * headW;
|
|
96
|
-
const hR_x = px * headW;
|
|
97
|
-
const hR_y = py * headW;
|
|
98
|
-
const bR_x = vx + px * baseW;
|
|
99
|
-
const bR_y = vy + py * baseW;
|
|
100
|
-
const bL_x = vx - px * baseW;
|
|
101
|
-
const bL_y = vy - py * baseW;
|
|
102
|
-
return `${hL_x},${hL_y} ${hR_x},${hR_y} ${bR_x},${bR_y} ${bL_x},${bL_y}`;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export {
|
|
106
|
-
AttractionEngine,
|
|
107
|
-
calculateSocketCoordinates,
|
|
108
|
-
getBeamPoints
|
|
109
|
-
};
|