deephaven-plugin-query-graph 0.1.0__py3-none-any.whl
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.
- deephaven/query_graph/__init__.py +56 -0
- deephaven/query_graph/_collector.py +181 -0
- deephaven/query_graph/_js/dist/index.js +907 -0
- deephaven/query_graph/_js/package.json +50 -0
- deephaven/query_graph/_model.py +289 -0
- deephaven/query_graph/_register.py +31 -0
- deephaven/query_graph/_widget.py +218 -0
- deephaven_plugin_query_graph-0.1.0.dist-info/METADATA +187 -0
- deephaven_plugin_query_graph-0.1.0.dist-info/RECORD +13 -0
- deephaven_plugin_query_graph-0.1.0.dist-info/WHEEL +5 -0
- deephaven_plugin_query_graph-0.1.0.dist-info/entry_points.txt +2 -0
- deephaven_plugin_query_graph-0.1.0.dist-info/licenses/LICENSE +202 -0
- deephaven_plugin_query_graph-0.1.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const plugin = require("@deephaven/plugin");
|
|
4
|
+
const icons = require("@deephaven/icons");
|
|
5
|
+
const require$$0 = require("react");
|
|
6
|
+
const dashboard = require("@deephaven/dashboard");
|
|
7
|
+
const jsapiBootstrap = require("@deephaven/jsapi-bootstrap");
|
|
8
|
+
const Log = require("@deephaven/log");
|
|
9
|
+
var jsxRuntime = { exports: {} };
|
|
10
|
+
var reactJsxRuntime_production_min = {};
|
|
11
|
+
/**
|
|
12
|
+
* @license React
|
|
13
|
+
* react-jsx-runtime.production.min.js
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/
|
|
20
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
21
|
+
function q(c, a, g) {
|
|
22
|
+
var b, d = {}, e = null, h = null;
|
|
23
|
+
void 0 !== g && (e = "" + g);
|
|
24
|
+
void 0 !== a.key && (e = "" + a.key);
|
|
25
|
+
void 0 !== a.ref && (h = a.ref);
|
|
26
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
27
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
|
|
28
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
29
|
+
}
|
|
30
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
31
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
32
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
33
|
+
{
|
|
34
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
35
|
+
}
|
|
36
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
37
|
+
const DEFAULT_LAYOUT_OPTIONS = {
|
|
38
|
+
nodeWidth: 210,
|
|
39
|
+
nodeHeight: 58,
|
|
40
|
+
columnGap: 70,
|
|
41
|
+
rowGap: 18,
|
|
42
|
+
sweeps: 6
|
|
43
|
+
};
|
|
44
|
+
const collator = new Intl.Collator(void 0, { numeric: true });
|
|
45
|
+
function average(values) {
|
|
46
|
+
if (values.length === 0) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return values.reduce((sum, v) => sum + v, 0) / values.length;
|
|
50
|
+
}
|
|
51
|
+
function computeLayout(nodeIds, edges, options = {}) {
|
|
52
|
+
var _a;
|
|
53
|
+
const opts = { ...DEFAULT_LAYOUT_OPTIONS, ...options };
|
|
54
|
+
const ids = [...new Set(nodeIds)].sort(collator.compare);
|
|
55
|
+
const idSet = new Set(ids);
|
|
56
|
+
const parents = new Map(ids.map((id) => [id, []]));
|
|
57
|
+
const children = new Map(ids.map((id) => [id, []]));
|
|
58
|
+
edges.forEach(({ source, target }) => {
|
|
59
|
+
var _a2, _b;
|
|
60
|
+
if (source !== target && idSet.has(source) && idSet.has(target)) {
|
|
61
|
+
(_a2 = parents.get(target)) == null ? void 0 : _a2.push(source);
|
|
62
|
+
(_b = children.get(source)) == null ? void 0 : _b.push(target);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const layerOf = /* @__PURE__ */ new Map();
|
|
66
|
+
const indegree = new Map(ids.map((id) => {
|
|
67
|
+
var _a2;
|
|
68
|
+
return [id, ((_a2 = parents.get(id)) == null ? void 0 : _a2.length) ?? 0];
|
|
69
|
+
}));
|
|
70
|
+
const queue = ids.filter((id) => indegree.get(id) === 0);
|
|
71
|
+
queue.forEach((id) => layerOf.set(id, 0));
|
|
72
|
+
for (let i = 0; i < queue.length; i += 1) {
|
|
73
|
+
const id = queue[i];
|
|
74
|
+
const layer = layerOf.get(id) ?? 0;
|
|
75
|
+
(_a = children.get(id)) == null ? void 0 : _a.forEach((child) => {
|
|
76
|
+
layerOf.set(child, Math.max(layerOf.get(child) ?? 0, layer + 1));
|
|
77
|
+
const remaining = (indegree.get(child) ?? 0) - 1;
|
|
78
|
+
indegree.set(child, remaining);
|
|
79
|
+
if (remaining === 0) {
|
|
80
|
+
queue.push(child);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const maxLayer = Math.max(0, ...layerOf.values());
|
|
85
|
+
ids.forEach((id) => {
|
|
86
|
+
if (!layerOf.has(id)) {
|
|
87
|
+
layerOf.set(id, maxLayer + 1);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const layerCount = Math.max(0, ...layerOf.values()) + (ids.length > 0 ? 1 : 0);
|
|
91
|
+
const layers = Array.from({ length: layerCount }, () => []);
|
|
92
|
+
ids.forEach((id) => layers[layerOf.get(id) ?? 0].push(id));
|
|
93
|
+
const orderOf = /* @__PURE__ */ new Map();
|
|
94
|
+
const indexLayers = () => {
|
|
95
|
+
layers.forEach((layer) => layer.forEach((id, i) => orderOf.set(id, i)));
|
|
96
|
+
};
|
|
97
|
+
indexLayers();
|
|
98
|
+
const sortByNeighbors = (layer, neighbors) => {
|
|
99
|
+
const keyed = layer.map((id, i) => ({
|
|
100
|
+
id,
|
|
101
|
+
key: average(
|
|
102
|
+
(neighbors.get(id) ?? []).filter((n2) => orderOf.has(n2)).map((n2) => orderOf.get(n2) ?? 0)
|
|
103
|
+
) ?? i,
|
|
104
|
+
i
|
|
105
|
+
}));
|
|
106
|
+
keyed.sort((a, b) => a.key - b.key || a.i - b.i);
|
|
107
|
+
keyed.forEach(({ id }, i) => {
|
|
108
|
+
layer[i] = id;
|
|
109
|
+
orderOf.set(id, i);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
for (let sweep = 0; sweep < opts.sweeps; sweep += 1) {
|
|
113
|
+
if (sweep % 2 === 0) {
|
|
114
|
+
for (let l2 = 1; l2 < layers.length; l2 += 1) {
|
|
115
|
+
sortByNeighbors(layers[l2], parents);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
for (let l2 = layers.length - 2; l2 >= 0; l2 -= 1) {
|
|
119
|
+
sortByNeighbors(layers[l2], children);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const rowHeight = opts.nodeHeight + opts.rowGap;
|
|
124
|
+
const tallest = Math.max(0, ...layers.map((layer) => layer.length));
|
|
125
|
+
const positions = /* @__PURE__ */ new Map();
|
|
126
|
+
layers.forEach((layer, l2) => {
|
|
127
|
+
const offset = (tallest - layer.length) * rowHeight / 2;
|
|
128
|
+
layer.forEach((id, i) => {
|
|
129
|
+
positions.set(id, {
|
|
130
|
+
x: l2 * (opts.nodeWidth + opts.columnGap),
|
|
131
|
+
y: offset + i * rowHeight
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
positions,
|
|
137
|
+
layers,
|
|
138
|
+
width: layers.length > 0 ? layers.length * (opts.nodeWidth + opts.columnGap) - opts.columnGap : 0,
|
|
139
|
+
height: tallest > 0 ? tallest * rowHeight - opts.rowGap : 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function structureKey(nodeIds, edges) {
|
|
143
|
+
return `${[...nodeIds].sort().join(",")}|${edges.map((e) => `${e.source}>${e.target}`).sort().join(",")}`;
|
|
144
|
+
}
|
|
145
|
+
const SI = [
|
|
146
|
+
{ value: 1e12, suffix: "T" },
|
|
147
|
+
{ value: 1e9, suffix: "B" },
|
|
148
|
+
{ value: 1e6, suffix: "M" },
|
|
149
|
+
{ value: 1e3, suffix: "k" }
|
|
150
|
+
];
|
|
151
|
+
function formatCount(value) {
|
|
152
|
+
if (value == null || !Number.isFinite(value)) {
|
|
153
|
+
return "–";
|
|
154
|
+
}
|
|
155
|
+
const abs = Math.abs(value);
|
|
156
|
+
const unit = SI.find((u) => abs >= u.value);
|
|
157
|
+
if (unit == null) {
|
|
158
|
+
return Number.isInteger(value) ? `${value}` : value.toFixed(1);
|
|
159
|
+
}
|
|
160
|
+
const scaled = value / unit.value;
|
|
161
|
+
return `${scaled >= 100 ? scaled.toFixed(0) : scaled.toFixed(1)}${unit.suffix}`;
|
|
162
|
+
}
|
|
163
|
+
function formatPercent(fraction) {
|
|
164
|
+
if (!Number.isFinite(fraction) || fraction <= 0) {
|
|
165
|
+
return "0%";
|
|
166
|
+
}
|
|
167
|
+
const percent = fraction * 100;
|
|
168
|
+
if (percent < 0.1) {
|
|
169
|
+
return "<0.1%";
|
|
170
|
+
}
|
|
171
|
+
return `${percent >= 10 ? percent.toFixed(0) : percent.toFixed(1)}%`;
|
|
172
|
+
}
|
|
173
|
+
function formatNanos(nanos) {
|
|
174
|
+
if (!Number.isFinite(nanos) || nanos <= 0) {
|
|
175
|
+
return "0";
|
|
176
|
+
}
|
|
177
|
+
if (nanos >= 1e9) {
|
|
178
|
+
return `${(nanos / 1e9).toFixed(2)} s`;
|
|
179
|
+
}
|
|
180
|
+
if (nanos >= 1e6) {
|
|
181
|
+
return `${(nanos / 1e6).toFixed(1)} ms`;
|
|
182
|
+
}
|
|
183
|
+
if (nanos >= 1e3) {
|
|
184
|
+
return `${(nanos / 1e3).toFixed(0)} µs`;
|
|
185
|
+
}
|
|
186
|
+
return `${nanos.toFixed(0)} ns`;
|
|
187
|
+
}
|
|
188
|
+
function heat(usage, maxUsage, floor = 0.02) {
|
|
189
|
+
if (!Number.isFinite(usage) || usage <= 0) {
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
return Math.min(1, usage / Math.max(maxUsage, floor));
|
|
193
|
+
}
|
|
194
|
+
function heatColor(value) {
|
|
195
|
+
const hue = Math.round(120 * (1 - Math.min(1, Math.max(0, value))));
|
|
196
|
+
return `hsl(${hue}, 70%, 50%)`;
|
|
197
|
+
}
|
|
198
|
+
function sparklinePoints(values, width, height) {
|
|
199
|
+
if (values.length === 0) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
const max = Math.max(...values, Number.EPSILON);
|
|
203
|
+
const step = values.length > 1 ? width / (values.length - 1) : 0;
|
|
204
|
+
return values.map((v, i) => [
|
|
205
|
+
values.length > 1 ? i * step : width,
|
|
206
|
+
height - Math.max(0, v) / max * (height - 2) - 1
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
const { nodeWidth: NODE_W, nodeHeight: NODE_H } = DEFAULT_LAYOUT_OPTIONS;
|
|
210
|
+
const MIN_ZOOM = 0.15;
|
|
211
|
+
const MAX_ZOOM = 3;
|
|
212
|
+
const FIT_PADDING = 32;
|
|
213
|
+
function truncate(text, max) {
|
|
214
|
+
return text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
215
|
+
}
|
|
216
|
+
function edgePath(from, to) {
|
|
217
|
+
const x1 = from.x + NODE_W;
|
|
218
|
+
const y1 = from.y + NODE_H / 2;
|
|
219
|
+
const x2 = to.x;
|
|
220
|
+
const y2 = to.y + NODE_H / 2;
|
|
221
|
+
const dx = Math.max(30, (x2 - x1) / 2);
|
|
222
|
+
return `M${x1},${y1} C${x1 + dx},${y1} ${x2 - dx},${y2} ${x2},${y2}`;
|
|
223
|
+
}
|
|
224
|
+
function statsLine(node) {
|
|
225
|
+
if (node.kind === "table") {
|
|
226
|
+
return node.size != null ? `${formatCount(node.size)} rows` : "";
|
|
227
|
+
}
|
|
228
|
+
if (node.idle) {
|
|
229
|
+
return "idle";
|
|
230
|
+
}
|
|
231
|
+
return `${formatPercent(node.usage)} · ${formatCount(
|
|
232
|
+
node.rowsPerSecond
|
|
233
|
+
)} rows/s`;
|
|
234
|
+
}
|
|
235
|
+
function GraphCanvas({
|
|
236
|
+
nodes,
|
|
237
|
+
edges,
|
|
238
|
+
layout,
|
|
239
|
+
selectedId,
|
|
240
|
+
matches,
|
|
241
|
+
fitToken,
|
|
242
|
+
onSelect,
|
|
243
|
+
onOpen
|
|
244
|
+
}) {
|
|
245
|
+
const containerRef = require$$0.useRef(null);
|
|
246
|
+
const [transform, setTransform] = require$$0.useState({ x: 0, y: 0, k: 1 });
|
|
247
|
+
const dragRef = require$$0.useRef(null);
|
|
248
|
+
const lastNodeId = require$$0.useRef(null);
|
|
249
|
+
const fit = require$$0.useCallback(() => {
|
|
250
|
+
const el = containerRef.current;
|
|
251
|
+
if (el == null) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const { width, height } = el.getBoundingClientRect();
|
|
255
|
+
if (width <= 0 || height <= 0 || layout.width <= 0) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const k2 = Math.min(
|
|
259
|
+
1.1,
|
|
260
|
+
Math.max(
|
|
261
|
+
MIN_ZOOM,
|
|
262
|
+
Math.min(
|
|
263
|
+
(width - FIT_PADDING * 2) / layout.width,
|
|
264
|
+
(height - FIT_PADDING * 2) / layout.height
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
);
|
|
268
|
+
setTransform({
|
|
269
|
+
k: k2,
|
|
270
|
+
x: (width - layout.width * k2) / 2,
|
|
271
|
+
y: (height - layout.height * k2) / 2
|
|
272
|
+
});
|
|
273
|
+
}, [layout]);
|
|
274
|
+
require$$0.useLayoutEffect(fit, [fit, fitToken]);
|
|
275
|
+
require$$0.useEffect(() => {
|
|
276
|
+
const el = containerRef.current;
|
|
277
|
+
if (el == null) {
|
|
278
|
+
return void 0;
|
|
279
|
+
}
|
|
280
|
+
const onWheel = (event) => {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
const rect = el.getBoundingClientRect();
|
|
283
|
+
const mx = event.clientX - rect.left;
|
|
284
|
+
const my = event.clientY - rect.top;
|
|
285
|
+
setTransform((t) => {
|
|
286
|
+
const k2 = Math.min(
|
|
287
|
+
MAX_ZOOM,
|
|
288
|
+
Math.max(MIN_ZOOM, t.k * Math.exp(-event.deltaY * 15e-4))
|
|
289
|
+
);
|
|
290
|
+
return {
|
|
291
|
+
k: k2,
|
|
292
|
+
x: mx - (mx - t.x) * k2 / t.k,
|
|
293
|
+
y: my - (my - t.y) * k2 / t.k
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
298
|
+
return () => el.removeEventListener("wheel", onWheel);
|
|
299
|
+
}, []);
|
|
300
|
+
const handlePointerDown = (event) => {
|
|
301
|
+
var _a, _b, _c, _d;
|
|
302
|
+
if (event.button !== 0) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const target = (_b = (_a = event.target).closest) == null ? void 0 : _b.call(_a, "[data-node-id]");
|
|
306
|
+
lastNodeId.current = (target == null ? void 0 : target.getAttribute("data-node-id")) ?? null;
|
|
307
|
+
dragRef.current = {
|
|
308
|
+
x: event.clientX,
|
|
309
|
+
y: event.clientY,
|
|
310
|
+
moved: false,
|
|
311
|
+
nodeId: (target == null ? void 0 : target.getAttribute("data-node-id")) ?? null
|
|
312
|
+
};
|
|
313
|
+
(_d = (_c = event.currentTarget).setPointerCapture) == null ? void 0 : _d.call(_c, event.pointerId);
|
|
314
|
+
};
|
|
315
|
+
const handlePointerMove = (event) => {
|
|
316
|
+
const drag = dragRef.current;
|
|
317
|
+
if (drag == null) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const dx = event.clientX - drag.x;
|
|
321
|
+
const dy = event.clientY - drag.y;
|
|
322
|
+
if (!drag.moved && Math.abs(dx) + Math.abs(dy) < 3) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
drag.moved = true;
|
|
326
|
+
drag.x = event.clientX;
|
|
327
|
+
drag.y = event.clientY;
|
|
328
|
+
setTransform((t) => ({ ...t, x: t.x + dx, y: t.y + dy }));
|
|
329
|
+
};
|
|
330
|
+
const handlePointerUp = () => {
|
|
331
|
+
const drag = dragRef.current;
|
|
332
|
+
dragRef.current = null;
|
|
333
|
+
if (drag != null && !drag.moved) {
|
|
334
|
+
onSelect(drag.nodeId);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const maxUsage = Math.max(0, ...nodes.map((n2) => n2.usage));
|
|
338
|
+
const related = /* @__PURE__ */ new Set();
|
|
339
|
+
if (selectedId != null) {
|
|
340
|
+
related.add(selectedId);
|
|
341
|
+
edges.forEach((e) => {
|
|
342
|
+
if (e.source === selectedId) related.add(e.target);
|
|
343
|
+
if (e.target === selectedId) related.add(e.source);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
const nodeById = new Map(nodes.map((n2) => [n2.id, n2]));
|
|
347
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
348
|
+
"div",
|
|
349
|
+
{
|
|
350
|
+
ref: containerRef,
|
|
351
|
+
className: "qg-canvas",
|
|
352
|
+
onPointerDown: handlePointerDown,
|
|
353
|
+
onPointerMove: handlePointerMove,
|
|
354
|
+
onPointerUp: handlePointerUp,
|
|
355
|
+
onPointerCancel: () => {
|
|
356
|
+
dragRef.current = null;
|
|
357
|
+
},
|
|
358
|
+
onDoubleClick: () => {
|
|
359
|
+
const node = lastNodeId.current != null ? nodeById.get(lastNodeId.current) : void 0;
|
|
360
|
+
if (node != null && node.names.length > 0) {
|
|
361
|
+
onOpen(node.names[0]);
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
children: [
|
|
365
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "100%", height: "100%", children: [
|
|
366
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
367
|
+
"marker",
|
|
368
|
+
{
|
|
369
|
+
id: "qg-arrow",
|
|
370
|
+
viewBox: "0 0 10 10",
|
|
371
|
+
refX: "9",
|
|
372
|
+
refY: "5",
|
|
373
|
+
markerWidth: "6",
|
|
374
|
+
markerHeight: "6",
|
|
375
|
+
orient: "auto-start-reverse",
|
|
376
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M 0 0 L 10 5 L 0 10 z", className: "qg-arrow" })
|
|
377
|
+
}
|
|
378
|
+
) }),
|
|
379
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
380
|
+
"g",
|
|
381
|
+
{
|
|
382
|
+
transform: `translate(${transform.x},${transform.y}) scale(${transform.k})`,
|
|
383
|
+
children: [
|
|
384
|
+
edges.map((edge) => {
|
|
385
|
+
const from = layout.positions.get(edge.source);
|
|
386
|
+
const to = layout.positions.get(edge.target);
|
|
387
|
+
if (from == null || to == null) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
const source = nodeById.get(edge.source);
|
|
391
|
+
const classes = ["qg-edge"];
|
|
392
|
+
if (source != null && !source.idle) classes.push("active");
|
|
393
|
+
if (selectedId != null && (edge.source === selectedId || edge.target === selectedId)) {
|
|
394
|
+
classes.push("related");
|
|
395
|
+
}
|
|
396
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
397
|
+
"path",
|
|
398
|
+
{
|
|
399
|
+
className: classes.join(" "),
|
|
400
|
+
d: edgePath(from, to),
|
|
401
|
+
markerEnd: "url(#qg-arrow)"
|
|
402
|
+
},
|
|
403
|
+
`${edge.source}>${edge.target}`
|
|
404
|
+
);
|
|
405
|
+
}),
|
|
406
|
+
nodes.map((node) => {
|
|
407
|
+
const pos = layout.positions.get(node.id);
|
|
408
|
+
if (pos == null) {
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
const classes = ["qg-node", `qg-kind-${node.kind}`];
|
|
412
|
+
if (node.idle && node.kind !== "table") classes.push("idle");
|
|
413
|
+
if (node.id === selectedId) classes.push("selected");
|
|
414
|
+
if (matches != null && !matches.has(node.id)) classes.push("dim");
|
|
415
|
+
if (selectedId != null && matches == null && !related.has(node.id)) {
|
|
416
|
+
classes.push("faded");
|
|
417
|
+
}
|
|
418
|
+
const named = node.names.length > 0;
|
|
419
|
+
const title = named ? node.names.join(", ") : node.label;
|
|
420
|
+
const subtitle = named ? [node.label, node.subtitle].filter(Boolean).join(" · ") : node.subtitle;
|
|
421
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
422
|
+
"g",
|
|
423
|
+
{
|
|
424
|
+
"data-node-id": node.id,
|
|
425
|
+
className: classes.join(" "),
|
|
426
|
+
transform: `translate(${pos.x},${pos.y})`,
|
|
427
|
+
children: [
|
|
428
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("title", { children: node.description || node.label }),
|
|
429
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
430
|
+
"rect",
|
|
431
|
+
{
|
|
432
|
+
width: NODE_W,
|
|
433
|
+
height: NODE_H,
|
|
434
|
+
rx: 6,
|
|
435
|
+
style: {
|
|
436
|
+
stroke: node.idle ? void 0 : heatColor(heat(node.usage, maxUsage))
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
),
|
|
440
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
441
|
+
"rect",
|
|
442
|
+
{
|
|
443
|
+
className: "qg-usage-bar",
|
|
444
|
+
x: 0,
|
|
445
|
+
y: NODE_H - 4,
|
|
446
|
+
height: 4,
|
|
447
|
+
width: NODE_W * heat(node.usage, maxUsage),
|
|
448
|
+
style: { fill: heatColor(heat(node.usage, maxUsage)) }
|
|
449
|
+
}
|
|
450
|
+
),
|
|
451
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
452
|
+
"text",
|
|
453
|
+
{
|
|
454
|
+
className: named ? "qg-title qg-name" : "qg-title",
|
|
455
|
+
x: 10,
|
|
456
|
+
y: 18,
|
|
457
|
+
children: truncate(title, named ? 22 : 26)
|
|
458
|
+
}
|
|
459
|
+
),
|
|
460
|
+
node.size != null && node.kind !== "table" && /* @__PURE__ */ jsxRuntimeExports.jsx("text", { className: "qg-size", x: NODE_W - 10, y: 18, children: formatCount(node.size) }),
|
|
461
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("text", { className: "qg-sub", x: 10, y: 34, children: truncate(subtitle, 32) }),
|
|
462
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("text", { className: "qg-stats", x: 10, y: 49, children: statsLine(node) }),
|
|
463
|
+
node.ticked && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
464
|
+
"circle",
|
|
465
|
+
{
|
|
466
|
+
className: "qg-tick",
|
|
467
|
+
cx: NODE_W - 8,
|
|
468
|
+
cy: NODE_H - 14,
|
|
469
|
+
r: 4
|
|
470
|
+
},
|
|
471
|
+
`${node.id}-tick-${Date.now()}`
|
|
472
|
+
)
|
|
473
|
+
]
|
|
474
|
+
},
|
|
475
|
+
node.id
|
|
476
|
+
);
|
|
477
|
+
})
|
|
478
|
+
]
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
] }),
|
|
482
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-zoom", children: [
|
|
483
|
+
Math.round(transform.k * 100),
|
|
484
|
+
"%"
|
|
485
|
+
] })
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
function Sparkline({
|
|
491
|
+
values,
|
|
492
|
+
width = 260,
|
|
493
|
+
height = 40,
|
|
494
|
+
className = "qg-sparkline"
|
|
495
|
+
}) {
|
|
496
|
+
const points = sparklinePoints(values, width, height);
|
|
497
|
+
if (points.length === 0) {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
const line = points.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`);
|
|
501
|
+
const area = `M0,${height} L${line.join(" L")} L${width},${height} Z`;
|
|
502
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
503
|
+
"svg",
|
|
504
|
+
{
|
|
505
|
+
className,
|
|
506
|
+
width,
|
|
507
|
+
height,
|
|
508
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
509
|
+
role: "img",
|
|
510
|
+
"aria-label": "Usage history",
|
|
511
|
+
children: [
|
|
512
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { className: "qg-sparkline-area", d: area }),
|
|
513
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { className: "qg-sparkline-line", points: line.join(" ") })
|
|
514
|
+
]
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
const KIND_LABELS = {
|
|
519
|
+
op: "Operation",
|
|
520
|
+
source: "Source",
|
|
521
|
+
unknown: "Operation (not yet logged)",
|
|
522
|
+
table: "Table without update graph entry"
|
|
523
|
+
};
|
|
524
|
+
function NodeLink({
|
|
525
|
+
node,
|
|
526
|
+
onSelect
|
|
527
|
+
}) {
|
|
528
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
529
|
+
"button",
|
|
530
|
+
{
|
|
531
|
+
type: "button",
|
|
532
|
+
className: "qg-link",
|
|
533
|
+
onClick: () => onSelect(node.id),
|
|
534
|
+
title: node.description,
|
|
535
|
+
children: [
|
|
536
|
+
node.names.length > 0 ? `${node.names.join(", ")} · ` : "",
|
|
537
|
+
node.label,
|
|
538
|
+
node.subtitle !== "" ? ` ${node.subtitle}` : ""
|
|
539
|
+
]
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
function NodeDetails({
|
|
544
|
+
node,
|
|
545
|
+
nodes,
|
|
546
|
+
edges,
|
|
547
|
+
onSelect,
|
|
548
|
+
onOpen
|
|
549
|
+
}) {
|
|
550
|
+
const byId = new Map(nodes.map((n2) => [n2.id, n2]));
|
|
551
|
+
const upstream = edges.filter((e) => e.target === node.id).map((e) => byId.get(e.source)).filter((n2) => n2 != null);
|
|
552
|
+
const downstream = edges.filter((e) => e.source === node.id).map((e) => byId.get(e.target)).filter((n2) => n2 != null);
|
|
553
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-details", children: [
|
|
554
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-details-header", children: [
|
|
555
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
556
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "qg-details-title", children: node.names.length > 0 ? node.names.join(", ") : node.label }),
|
|
557
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-muted", children: [
|
|
558
|
+
KIND_LABELS[node.kind],
|
|
559
|
+
node.entryId != null ? ` · entry #${node.entryId}` : "",
|
|
560
|
+
node.updateGraph != null && node.updateGraph !== "" ? ` · ${node.updateGraph}` : ""
|
|
561
|
+
] })
|
|
562
|
+
] }),
|
|
563
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
564
|
+
"button",
|
|
565
|
+
{
|
|
566
|
+
type: "button",
|
|
567
|
+
className: "qg-button",
|
|
568
|
+
"aria-label": "Close details",
|
|
569
|
+
onClick: () => onSelect(null),
|
|
570
|
+
children: "×"
|
|
571
|
+
}
|
|
572
|
+
)
|
|
573
|
+
] }),
|
|
574
|
+
node.names.map((name) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
575
|
+
"button",
|
|
576
|
+
{
|
|
577
|
+
type: "button",
|
|
578
|
+
className: "qg-button qg-open",
|
|
579
|
+
onClick: () => onOpen(name),
|
|
580
|
+
children: [
|
|
581
|
+
"Open ",
|
|
582
|
+
name
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
name
|
|
586
|
+
)),
|
|
587
|
+
node.description && /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "qg-description", children: node.description }),
|
|
588
|
+
node.callerLine != null && node.callerLine !== "" && node.callerLine !== "Internal" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-muted", children: [
|
|
589
|
+
"Created at ",
|
|
590
|
+
node.callerLine
|
|
591
|
+
] }),
|
|
592
|
+
node.kind !== "table" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
593
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Last interval" }),
|
|
594
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("table", { className: "qg-stats-table", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tbody", { children: [
|
|
595
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
|
|
596
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: "Update time" }),
|
|
597
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { children: [
|
|
598
|
+
formatPercent(node.usage),
|
|
599
|
+
" (",
|
|
600
|
+
formatNanos(node.usageNanos),
|
|
601
|
+
")"
|
|
602
|
+
] })
|
|
603
|
+
] }),
|
|
604
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
|
|
605
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: "CPU" }),
|
|
606
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { children: formatNanos(node.cpuNanos) })
|
|
607
|
+
] }),
|
|
608
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
|
|
609
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: "Rows/s" }),
|
|
610
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { children: formatCount(node.rowsPerSecond) })
|
|
611
|
+
] }),
|
|
612
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
|
|
613
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: "Added / removed / modified" }),
|
|
614
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { children: [
|
|
615
|
+
formatCount(node.rowsAdded),
|
|
616
|
+
" /",
|
|
617
|
+
" ",
|
|
618
|
+
formatCount(node.rowsRemoved),
|
|
619
|
+
" /",
|
|
620
|
+
" ",
|
|
621
|
+
formatCount(node.rowsModified)
|
|
622
|
+
] })
|
|
623
|
+
] }),
|
|
624
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
|
|
625
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: "Invocations" }),
|
|
626
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { children: formatCount(node.invocations) })
|
|
627
|
+
] }),
|
|
628
|
+
node.size != null && /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
|
|
629
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: "Table size" }),
|
|
630
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { children: [
|
|
631
|
+
formatCount(node.size),
|
|
632
|
+
" rows"
|
|
633
|
+
] })
|
|
634
|
+
] })
|
|
635
|
+
] }) }),
|
|
636
|
+
node.history.length > 1 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
637
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { children: [
|
|
638
|
+
"Update time, last ",
|
|
639
|
+
node.history.length,
|
|
640
|
+
" intervals"
|
|
641
|
+
] }),
|
|
642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Sparkline, { values: node.history })
|
|
643
|
+
] })
|
|
644
|
+
] }),
|
|
645
|
+
upstream.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
646
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Inputs" }),
|
|
647
|
+
upstream.map((n2) => /* @__PURE__ */ jsxRuntimeExports.jsx(NodeLink, { node: n2, onSelect }, n2.id))
|
|
648
|
+
] }),
|
|
649
|
+
downstream.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
650
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Outputs" }),
|
|
651
|
+
downstream.map((n2) => /* @__PURE__ */ jsxRuntimeExports.jsx(NodeLink, { node: n2, onSelect }, n2.id))
|
|
652
|
+
] })
|
|
653
|
+
] });
|
|
654
|
+
}
|
|
655
|
+
function searchNodes(nodes, query) {
|
|
656
|
+
const q2 = query.trim().toLowerCase();
|
|
657
|
+
if (q2 === "") {
|
|
658
|
+
return null;
|
|
659
|
+
}
|
|
660
|
+
return new Set(
|
|
661
|
+
nodes.filter(
|
|
662
|
+
(n2) => [n2.label, n2.subtitle, n2.description, ...n2.names].some(
|
|
663
|
+
(text) => text == null ? void 0 : text.toLowerCase().includes(q2)
|
|
664
|
+
)
|
|
665
|
+
).map((n2) => n2.id)
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
const log = Log.module("@deephaven/js-plugin-query-graph.QueryGraphView");
|
|
669
|
+
function QueryGraphView({
|
|
670
|
+
fetch
|
|
671
|
+
}) {
|
|
672
|
+
var _a;
|
|
673
|
+
const dh = jsapiBootstrap.useApi();
|
|
674
|
+
const layoutManager = require$$0.useContext(dashboard.LayoutManagerContext);
|
|
675
|
+
const widgetRef = require$$0.useRef(null);
|
|
676
|
+
const [graph, setGraph] = require$$0.useState(null);
|
|
677
|
+
const [error, setError] = require$$0.useState(null);
|
|
678
|
+
const [mode, setMode] = require$$0.useState(null);
|
|
679
|
+
const [selectedId, setSelectedId] = require$$0.useState(null);
|
|
680
|
+
const [query, setQuery] = require$$0.useState("");
|
|
681
|
+
const [fitToken, setFitToken] = require$$0.useState(0);
|
|
682
|
+
const [showWarnings, setShowWarnings] = require$$0.useState(true);
|
|
683
|
+
const openTable = require$$0.useCallback(
|
|
684
|
+
(name, exported) => {
|
|
685
|
+
if (exported == null) {
|
|
686
|
+
setError(`Could not open ${name}`);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (layoutManager == null) {
|
|
690
|
+
setError(
|
|
691
|
+
`Open ${name} from the console: no dashboard is available here`
|
|
692
|
+
);
|
|
693
|
+
exported.close();
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
dashboard.emitPanelOpen(layoutManager.eventHub, {
|
|
697
|
+
widget: { type: exported.type ?? "Table", name },
|
|
698
|
+
fetch: () => exported.fetch()
|
|
699
|
+
});
|
|
700
|
+
},
|
|
701
|
+
[layoutManager]
|
|
702
|
+
);
|
|
703
|
+
const handleMessage = require$$0.useCallback(
|
|
704
|
+
(text, exported) => {
|
|
705
|
+
let message;
|
|
706
|
+
try {
|
|
707
|
+
message = JSON.parse(text);
|
|
708
|
+
} catch (e) {
|
|
709
|
+
log.warn("Ignoring malformed message", e);
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (message.type === "GRAPH") {
|
|
713
|
+
setGraph(message);
|
|
714
|
+
setMode((m2) => m2 ?? message.mode);
|
|
715
|
+
} else if (message.type === "TABLE") {
|
|
716
|
+
openTable(message.name, exported[0]);
|
|
717
|
+
} else if (message.type === "ERROR") {
|
|
718
|
+
setError(message.message);
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
[openTable]
|
|
722
|
+
);
|
|
723
|
+
require$$0.useEffect(() => {
|
|
724
|
+
let cancelled = false;
|
|
725
|
+
let removeListener;
|
|
726
|
+
let widget;
|
|
727
|
+
async function connect() {
|
|
728
|
+
widget = await fetch();
|
|
729
|
+
if (cancelled) {
|
|
730
|
+
widget.close();
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
widgetRef.current = widget;
|
|
734
|
+
removeListener = widget.addEventListener(
|
|
735
|
+
dh.Widget.EVENT_MESSAGE,
|
|
736
|
+
({ detail }) => handleMessage(detail.getDataAsString(), detail.exportedObjects)
|
|
737
|
+
);
|
|
738
|
+
handleMessage(widget.getDataAsString(), widget.exportedObjects);
|
|
739
|
+
}
|
|
740
|
+
connect().catch((e) => {
|
|
741
|
+
log.error("Failed to connect", e);
|
|
742
|
+
setError(`Failed to load the query graph: ${e}`);
|
|
743
|
+
});
|
|
744
|
+
return () => {
|
|
745
|
+
cancelled = true;
|
|
746
|
+
removeListener == null ? void 0 : removeListener();
|
|
747
|
+
widget == null ? void 0 : widget.close();
|
|
748
|
+
widgetRef.current = null;
|
|
749
|
+
};
|
|
750
|
+
}, [dh, fetch, handleMessage]);
|
|
751
|
+
const send = require$$0.useCallback((message) => {
|
|
752
|
+
var _a2;
|
|
753
|
+
(_a2 = widgetRef.current) == null ? void 0 : _a2.sendMessage(JSON.stringify(message), []);
|
|
754
|
+
}, []);
|
|
755
|
+
const changeMode = (newMode) => {
|
|
756
|
+
setMode(newMode);
|
|
757
|
+
setSelectedId(null);
|
|
758
|
+
send({ type: "MODE", mode: newMode });
|
|
759
|
+
};
|
|
760
|
+
const requestOpen = require$$0.useCallback(
|
|
761
|
+
(name) => send({ type: "OPEN", name }),
|
|
762
|
+
[send]
|
|
763
|
+
);
|
|
764
|
+
const nodes = require$$0.useMemo(() => (graph == null ? void 0 : graph.nodes) ?? [], [graph]);
|
|
765
|
+
const edges = require$$0.useMemo(() => (graph == null ? void 0 : graph.edges) ?? [], [graph]);
|
|
766
|
+
const key = structureKey(
|
|
767
|
+
nodes.map((n2) => n2.id),
|
|
768
|
+
edges
|
|
769
|
+
);
|
|
770
|
+
const layoutCache = require$$0.useRef(null);
|
|
771
|
+
if (((_a = layoutCache.current) == null ? void 0 : _a.key) !== key) {
|
|
772
|
+
layoutCache.current = {
|
|
773
|
+
key,
|
|
774
|
+
layout: computeLayout(
|
|
775
|
+
nodes.map((n2) => n2.id),
|
|
776
|
+
edges
|
|
777
|
+
)
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
const { layout } = layoutCache.current;
|
|
781
|
+
const matches = require$$0.useMemo(() => searchNodes(nodes, query), [nodes, query]);
|
|
782
|
+
const selected = nodes.find((n2) => n2.id === selectedId) ?? null;
|
|
783
|
+
const currentMode = mode ?? (graph == null ? void 0 : graph.mode) ?? "named";
|
|
784
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "dh-query-graph", children: [
|
|
785
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-toolbar", children: [
|
|
786
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-segmented", role: "group", "aria-label": "Graph scope", children: [
|
|
787
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
788
|
+
"button",
|
|
789
|
+
{
|
|
790
|
+
type: "button",
|
|
791
|
+
className: `qg-button ${currentMode === "named" ? "active" : ""}`,
|
|
792
|
+
onClick: () => changeMode("named"),
|
|
793
|
+
children: "Named tables"
|
|
794
|
+
}
|
|
795
|
+
),
|
|
796
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
797
|
+
"button",
|
|
798
|
+
{
|
|
799
|
+
type: "button",
|
|
800
|
+
className: `qg-button ${currentMode === "all" ? "active" : ""}`,
|
|
801
|
+
onClick: () => changeMode("all"),
|
|
802
|
+
children: "All operations"
|
|
803
|
+
}
|
|
804
|
+
)
|
|
805
|
+
] }),
|
|
806
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
807
|
+
"input",
|
|
808
|
+
{
|
|
809
|
+
className: "qg-search",
|
|
810
|
+
type: "search",
|
|
811
|
+
placeholder: "Search operations",
|
|
812
|
+
"aria-label": "Search operations",
|
|
813
|
+
value: query,
|
|
814
|
+
onChange: (e) => setQuery(e.target.value),
|
|
815
|
+
onKeyDown: (e) => {
|
|
816
|
+
if (e.key === "Enter" && matches != null && matches.size > 0) {
|
|
817
|
+
setSelectedId([...matches][0]);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
),
|
|
822
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
823
|
+
"button",
|
|
824
|
+
{
|
|
825
|
+
type: "button",
|
|
826
|
+
className: "qg-button",
|
|
827
|
+
onClick: () => setFitToken((t) => t + 1),
|
|
828
|
+
children: "Fit"
|
|
829
|
+
}
|
|
830
|
+
),
|
|
831
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "qg-summary", children: graph != null && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
832
|
+
nodes.length,
|
|
833
|
+
" nodes · update graph busy",
|
|
834
|
+
" ",
|
|
835
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: formatPercent(graph.totalUsage) }),
|
|
836
|
+
graph.intervalNanos > 0 && ` · ${(graph.intervalNanos / 1e9).toFixed(1)}s intervals`
|
|
837
|
+
] }) })
|
|
838
|
+
] }),
|
|
839
|
+
error != null && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-banner qg-error", children: [
|
|
840
|
+
error,
|
|
841
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
842
|
+
"button",
|
|
843
|
+
{
|
|
844
|
+
type: "button",
|
|
845
|
+
className: "qg-button",
|
|
846
|
+
onClick: () => setError(null),
|
|
847
|
+
children: "Dismiss"
|
|
848
|
+
}
|
|
849
|
+
)
|
|
850
|
+
] }),
|
|
851
|
+
graph != null && graph.warnings.length > 0 && showWarnings && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-banner qg-warning", children: [
|
|
852
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: graph.warnings.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: w }, w)) }),
|
|
853
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
854
|
+
"button",
|
|
855
|
+
{
|
|
856
|
+
type: "button",
|
|
857
|
+
className: "qg-button",
|
|
858
|
+
onClick: () => setShowWarnings(false),
|
|
859
|
+
children: "Hide"
|
|
860
|
+
}
|
|
861
|
+
)
|
|
862
|
+
] }),
|
|
863
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qg-main", children: [
|
|
864
|
+
graph == null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "qg-empty", children: "Loading…" }),
|
|
865
|
+
graph != null && nodes.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "qg-empty", children: currentMode === "named" ? "No ticking named tables yet. Create some tables, or switch to All operations." : "No operations have been logged yet." }),
|
|
866
|
+
nodes.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
867
|
+
GraphCanvas,
|
|
868
|
+
{
|
|
869
|
+
nodes,
|
|
870
|
+
edges,
|
|
871
|
+
layout,
|
|
872
|
+
selectedId,
|
|
873
|
+
matches,
|
|
874
|
+
fitToken,
|
|
875
|
+
onSelect: setSelectedId,
|
|
876
|
+
onOpen: requestOpen
|
|
877
|
+
}
|
|
878
|
+
),
|
|
879
|
+
selected != null && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
880
|
+
NodeDetails,
|
|
881
|
+
{
|
|
882
|
+
node: selected,
|
|
883
|
+
nodes,
|
|
884
|
+
edges,
|
|
885
|
+
onSelect: setSelectedId,
|
|
886
|
+
onOpen: requestOpen
|
|
887
|
+
}
|
|
888
|
+
)
|
|
889
|
+
] })
|
|
890
|
+
] });
|
|
891
|
+
}
|
|
892
|
+
const QueryGraphPlugin = {
|
|
893
|
+
name: "@deephaven/js-plugin-query-graph",
|
|
894
|
+
title: "Query Graph",
|
|
895
|
+
type: plugin.PluginType.WIDGET_PLUGIN,
|
|
896
|
+
supportedTypes: "deephaven.query_graph.QueryGraph",
|
|
897
|
+
component: QueryGraphView,
|
|
898
|
+
icon: icons.vsTypeHierarchySub
|
|
899
|
+
};
|
|
900
|
+
const styles = ".dh-query-graph {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n font-size: 12px;\n color: var(--dh-color-fg);\n background: var(--dh-color-content-bg);\n}\n\n.dh-query-graph .qg-toolbar {\n display: flex;\n flex: none;\n gap: 8px;\n align-items: center;\n padding: 6px 8px;\n border-bottom: 1px solid var(--dh-color-hr, var(--dh-color-border));\n}\n\n.dh-query-graph .qg-segmented {\n display: flex;\n}\n\n.dh-query-graph .qg-segmented .qg-button:first-child {\n border-radius: 4px 0 0 4px;\n}\n\n.dh-query-graph .qg-segmented .qg-button:last-child {\n border-radius: 0 4px 4px 0;\n border-left: none;\n}\n\n.dh-query-graph .qg-button {\n padding: 2px 10px;\n color: inherit;\n font: inherit;\n cursor: pointer;\n background: transparent;\n border: 1px solid var(--dh-color-border);\n border-radius: 4px;\n}\n\n.dh-query-graph .qg-button:hover {\n background: var(--dh-color-accent-hover-bg, rgba(127, 127, 127, 0.2));\n color: var(--dh-color-accent-contrast, inherit);\n}\n\n.dh-query-graph .qg-button.active {\n color: var(--dh-color-accent-contrast);\n background: var(--dh-color-accent-bg);\n border-color: var(--dh-color-accent-bg);\n}\n\n.dh-query-graph .qg-search {\n width: 200px;\n padding: 2px 6px;\n color: inherit;\n font: inherit;\n background: var(--dh-color-surface-bg);\n border: 1px solid var(--dh-color-border);\n border-radius: 4px;\n}\n\n.dh-query-graph .qg-summary {\n margin-left: auto;\n white-space: nowrap;\n opacity: 0.85;\n}\n\n.dh-query-graph .qg-banner {\n display: flex;\n flex: none;\n gap: 8px;\n align-items: flex-start;\n justify-content: space-between;\n padding: 4px 8px;\n}\n\n.dh-query-graph .qg-banner ul {\n margin: 0;\n padding-left: 16px;\n}\n\n.dh-query-graph .qg-warning {\n color: var(--dh-color-notice-contrast);\n background: var(--dh-color-notice-bg);\n}\n\n.dh-query-graph .qg-error {\n color: var(--dh-color-negative-contrast);\n background: var(--dh-color-negative-bg);\n}\n\n.dh-query-graph .qg-main {\n display: flex;\n flex: 1;\n min-height: 0;\n}\n\n.dh-query-graph .qg-empty {\n margin: auto;\n opacity: 0.7;\n}\n\n.dh-query-graph .qg-canvas {\n position: relative;\n flex: 1;\n min-width: 0;\n overflow: hidden;\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.dh-query-graph .qg-canvas:active {\n cursor: grabbing;\n}\n\n.dh-query-graph .qg-zoom {\n position: absolute;\n right: 8px;\n bottom: 6px;\n opacity: 0.5;\n pointer-events: none;\n}\n\n.dh-query-graph .qg-edge {\n fill: none;\n stroke: var(--dh-color-border);\n stroke-width: 1.5;\n}\n\n.dh-query-graph .qg-edge.active {\n stroke: var(--dh-color-accent);\n stroke-dasharray: 6 4;\n animation: qg-flow 0.6s linear infinite;\n}\n\n.dh-query-graph .qg-edge.related {\n stroke-width: 3;\n}\n\n.dh-query-graph .qg-arrow {\n fill: var(--dh-color-border);\n}\n\n@keyframes qg-flow {\n to {\n stroke-dashoffset: -10;\n }\n}\n\n.dh-query-graph .qg-node {\n cursor: pointer;\n}\n\n.dh-query-graph .qg-node rect:first-of-type {\n fill: var(--dh-color-surface-bg);\n stroke: var(--dh-color-border);\n stroke-width: 2;\n}\n\n.dh-query-graph .qg-node.qg-kind-source rect:first-of-type,\n.dh-query-graph .qg-node.qg-kind-table rect:first-of-type {\n stroke-dasharray: 4 2;\n}\n\n.dh-query-graph .qg-node.qg-kind-unknown rect:first-of-type {\n stroke-dasharray: 2 3;\n}\n\n.dh-query-graph .qg-node.idle {\n opacity: 0.6;\n}\n\n.dh-query-graph .qg-node.faded,\n.dh-query-graph .qg-node.dim {\n opacity: 0.25;\n}\n\n.dh-query-graph .qg-node.selected rect:first-of-type {\n stroke: var(--dh-color-accent) !important;\n stroke-width: 3;\n}\n\n.dh-query-graph .qg-node text {\n font-family: inherit;\n fill: var(--dh-color-fg);\n}\n\n.dh-query-graph .qg-node .qg-title {\n font-weight: 600;\n font-size: 12px;\n}\n\n.dh-query-graph .qg-node .qg-name {\n fill: var(--dh-color-accent);\n}\n\n.dh-query-graph .qg-node .qg-size {\n font-size: 11px;\n text-anchor: end;\n opacity: 0.7;\n}\n\n.dh-query-graph .qg-node .qg-sub {\n font-size: 11px;\n opacity: 0.7;\n}\n\n.dh-query-graph .qg-node .qg-stats {\n font-size: 11px;\n}\n\n.dh-query-graph .qg-tick {\n fill: var(--dh-color-visual-green);\n animation: qg-pulse 0.9s ease-out forwards;\n}\n\n@keyframes qg-pulse {\n from {\n opacity: 1;\n }\n to {\n opacity: 0.15;\n }\n}\n\n.dh-query-graph .qg-details {\n flex: none;\n width: 320px;\n padding: 8px 10px;\n overflow: auto;\n border-left: 1px solid var(--dh-color-hr, var(--dh-color-border));\n}\n\n.dh-query-graph .qg-details-header {\n display: flex;\n gap: 8px;\n align-items: flex-start;\n justify-content: space-between;\n margin-bottom: 6px;\n}\n\n.dh-query-graph .qg-details-title {\n font-weight: 600;\n font-size: 14px;\n}\n\n.dh-query-graph .qg-details h4 {\n margin: 12px 0 4px;\n font-size: 12px;\n opacity: 0.8;\n}\n\n.dh-query-graph .qg-muted {\n opacity: 0.7;\n}\n\n.dh-query-graph .qg-open {\n margin: 4px 6px 4px 0;\n}\n\n.dh-query-graph .qg-description {\n margin: 6px 0;\n padding: 6px;\n color: var(--dh-color-fg);\n font-size: 11px;\n white-space: pre-wrap;\n word-break: break-word;\n background: var(--dh-color-surface-bg);\n border-radius: 4px;\n}\n\n.dh-query-graph .qg-stats-table {\n width: 100%;\n border-collapse: collapse;\n}\n\n.dh-query-graph .qg-stats-table th {\n padding: 2px 8px 2px 0;\n font-weight: normal;\n text-align: left;\n opacity: 0.7;\n}\n\n.dh-query-graph .qg-stats-table td {\n text-align: right;\n}\n\n.dh-query-graph .qg-link {\n display: block;\n width: 100%;\n padding: 2px 0;\n overflow: hidden;\n color: var(--dh-color-accent);\n font: inherit;\n white-space: nowrap;\n text-align: left;\n text-overflow: ellipsis;\n cursor: pointer;\n background: none;\n border: none;\n}\n\n.dh-query-graph .qg-sparkline-line {\n fill: none;\n stroke: var(--dh-color-accent);\n stroke-width: 1.5;\n}\n\n.dh-query-graph .qg-sparkline-area {\n fill: var(--dh-color-accent);\n opacity: 0.15;\n}\n";
|
|
901
|
+
const styleElement = document.createElement("style");
|
|
902
|
+
styleElement.textContent = styles;
|
|
903
|
+
document.head.appendChild(styleElement);
|
|
904
|
+
exports.QueryGraphPlugin = QueryGraphPlugin;
|
|
905
|
+
exports.QueryGraphView = QueryGraphView;
|
|
906
|
+
exports.computeLayout = computeLayout;
|
|
907
|
+
exports.default = QueryGraphPlugin;
|