@yuneta/gobj-ui 7.27.25 → 7.27.27

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.
@@ -191,11 +191,23 @@ function row_of(view, level)
191
191
  const $pop = view.priv.$popover;
192
192
  const $gobj = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GOBJ")
193
193
  .find((b) => b.getAttribute("data-level") === level);
194
- const $gclass = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GCLASS")
194
+ const $global = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GLOBAL")
195
195
  .find((b) => b.getAttribute("data-level") === level);
196
- return {$gobj, $gclass};
196
+ const $row = ($gobj || $global) ? ($gobj || $global).closest("tr") : null;
197
+ const $origin = $row ? $row.querySelector(".GOBJ_TREE_TRACES_ORIGIN") : null;
198
+ return {$gobj, $global, origin: $origin ? $origin.textContent : ""};
197
199
  }
198
200
 
201
+ /* What the host fetched for the root's gclass: it carries the yuno's
202
+ * own scope (`machine` on for every gobj). */
203
+ const YUNO_INFO = {
204
+ gclass: "C_YUNO",
205
+ gclass_levels: {},
206
+ global_levels: {machine: "Trace machine", ev_kw: "Trace event keywords"},
207
+ gclass_on: ["machine"],
208
+ global_on: ["machine"],
209
+ };
210
+
199
211
  async function open_tcp_card(view)
200
212
  {
201
213
  gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
@@ -228,13 +240,78 @@ describe("C_YUI_GOBJ_TREE_JS, source remote", () => {
228
240
  const machine = row_of(view, "machine");
229
241
 
230
242
  /* only tcp1: its own, so it can be turned off here */
231
- expect([traffic.$gobj.checked, traffic.$gobj.disabled]).toEqual([true, false]);
232
- expect([traffic.$gclass.checked, traffic.$gclass.disabled]).toEqual([false, false]);
233
- /* the gclass holds it: on and locked for the gobj */
234
- expect([connections.$gobj.checked, connections.$gobj.disabled]).toEqual([true, true]);
235
- expect([connections.$gclass.checked, connections.$gclass.disabled]).toEqual([true, false]);
243
+ expect([traffic.$gobj.checked, traffic.$gobj.disabled, traffic.origin]).toEqual([true, false, ""]);
244
+ /* the gclass holds it: on and locked for the gobj, saying which */
245
+ expect([connections.$gobj.checked, connections.$gobj.disabled, connections.origin])
246
+ .toEqual([true, true, "C_TCP"]);
236
247
  /* nobody */
237
248
  expect([machine.$gobj.checked, machine.$gobj.disabled]).toEqual([false, false]);
249
+ /* ONE scope in a card: the gclass' is the gclass viewer's, the
250
+ * yuno's is the toolbar's. */
251
+ expect(view.priv.$popover.querySelectorAll(".GOBJ_TREE_TRACE_GCLASS").length).toBe(0);
252
+ expect(view.priv.$popover.querySelector(".GOBJ_TREE_TRACES_CLEAR_GCLASS")).toBe(null);
253
+ expect(problems()).toEqual([]);
254
+ });
255
+
256
+ test("a level the whole yuno traces is locked in a card, said as the yuno's", async () => {
257
+ const view = await mount("remote", host);
258
+ await open_tcp_card(view);
259
+ gobj_send_event(view, "EV_TRACE_INFO", Object.assign({}, TCP_INFO,
260
+ {gclass_on: ["connections", "machine"], global_on: ["machine"]}), host);
261
+ const machine = row_of(view, "machine");
262
+ expect([machine.$gobj.checked, machine.$gobj.disabled, machine.origin])
263
+ .toEqual([true, true, "yuno"]);
264
+ expect(problems()).toEqual([]);
265
+ });
266
+
267
+ test("the yuno's traces open from the toolbar, from the root's gclass", async () => {
268
+ const view = await mount("remote", host);
269
+ gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
270
+ wanted.length = 0;
271
+
272
+ const $btn = gobj_read_attr(view, "$container").querySelector(".GOBJ_TREE_YUNO_TRACES_BUTTON");
273
+ expect($btn).toBeTruthy();
274
+ $btn.click();
275
+ expect(wanted.map((w) => [w.event, w.kw.gclass])).toEqual([["EV_TRACE_INFO_WANTED", "C_YUNO"]]);
276
+ expect(view.priv.popover_mode).toBe("yuno");
277
+
278
+ gobj_send_event(view, "EV_TRACE_INFO", YUNO_INFO, host);
279
+ const machine = row_of(view, "machine");
280
+ const ev_kw = row_of(view, "ev_kw");
281
+ expect([machine.$global.checked, machine.$global.disabled]).toEqual([true, false]);
282
+ expect([ev_kw.$global.checked, ev_kw.$global.disabled]).toEqual([false, false]);
283
+ expect(view.priv.$popover.querySelectorAll(".GOBJ_TREE_TRACE_GOBJ").length).toBe(0);
284
+ /* no gclass button: the yuno's traces are no gclass */
285
+ expect(view.priv.$popover_gclass.classList.contains("is-hidden")).toBe(true);
286
+
287
+ wanted.length = 0;
288
+ ev_kw.$global.checked = true;
289
+ ev_kw.$global.dispatchEvent(fake_event("change"));
290
+ expect(wanted).toEqual([{event: "EV_SET_TRACE_LEVEL", kw: {
291
+ scope: "global", gobj: "C_YUNO^gate", gclass: "C_YUNO",
292
+ levels: ["ev_kw"], set: true
293
+ }}]);
294
+ expect(row_of(view, "machine").$global.disabled).toBe(true);
295
+
296
+ /* The host reloads the tree: the yuno's traces stay open. */
297
+ gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
298
+ expect(view.priv.popover_mode).toBe("yuno");
299
+ expect(view.priv.$popover.style.display).toBe("block");
300
+
301
+ wanted.length = 0;
302
+ view.priv.$popover.querySelector(".GOBJ_TREE_TRACES_CLEAR_GLOBAL").click();
303
+ expect(wanted.map((w) => [w.kw.scope, w.kw.levels, w.kw.set])).toEqual([["global", ["machine"], false]]);
304
+ expect(problems()).toEqual([]);
305
+ });
306
+
307
+ test("the gclass viewer's set reaches the host as a set of the gclass", async () => {
308
+ const view = await mount("remote", host);
309
+ await open_tcp_card(view);
310
+ wanted.length = 0;
311
+ gobj_send_event(view, "EV_SET_GCLASS_TRACE", {gclass: "C_TCP", levels: ["machine"], set: true}, view);
312
+ expect(wanted).toEqual([{event: "EV_SET_TRACE_LEVEL", kw: {
313
+ scope: "gclass", gobj: "", gclass: "C_TCP", levels: ["machine"], set: true
314
+ }}]);
238
315
  expect(problems()).toEqual([]);
239
316
  });
240
317
 
@@ -85,6 +85,15 @@ function gclass_view_available()
85
85
  * current_state the state the INSTANCE the reader came
86
86
  * from is in, lit in the machine. Omitted,
87
87
  * nothing is lit.
88
+ * instance_name the name of that instance, said beside its
89
+ * state (a gclass has several).
90
+ * traces {info, pending}: the host can set this
91
+ * gclass' traces for every gobj of it. The
92
+ * viewer then publishes EV_SET_GCLASS_TRACE
93
+ * {gclass, levels, set} to the HOST (it is its
94
+ * child), which declares it, and is handed what
95
+ * the backend says next with EV_SET_TRACES.
96
+ * Omitted: the levels are only listed.
88
97
  * title_prefix what the window says before the gclass
89
98
  * name (the yuno it belongs to).
90
99
  * on_close called when the reader dismisses it.
@@ -134,6 +143,8 @@ function open_gclass_view(host, gclass_name, opts)
134
143
  * CLASS -- and the caller is the only party that knows,
135
144
  * so an omitted one simply lights nothing. */
136
145
  current_state: opts.current_state || "",
146
+ instance_name: opts.instance_name || "",
147
+ traces: opts.traces || null,
137
148
  subscriber: null,
138
149
  },
139
150
  host
@@ -0,0 +1,128 @@
1
+ /***********************************************************************
2
+ * yui_graph_minimap.js
3
+ *
4
+ * The minimap of a G6 graph, drawn the same way in every graph of the
5
+ * library: where it sits, the frame it wears in each theme, and how
6
+ * it shows the part of the graph that is on screen.
7
+ *
8
+ * It came from the treedb graph (`c_g6_nodes_tree.js`), where each of
9
+ * these decisions was paid for, and moved here when the gobj tree
10
+ * needed one too: two graphs side by side in the same console with
11
+ * two different minimaps is the drift `yui_graph_camera.js` exists to
12
+ * stop.
13
+ *
14
+ * What stays with each graph is WHEN it shows one (both decide by the
15
+ * number of nodes) and the colour of each block -- a topic's colour
16
+ * in one, a role's in the other.
17
+ *
18
+ * Copyright (c) 2026, ArtGins.
19
+ * All Rights Reserved.
20
+ ***********************************************************************/
21
+ import {Rect as RectGeometry} from '@antv/g';
22
+
23
+
24
+ /************************************************************
25
+ * The options of G6's `minimap` plugin, with `shape` drawing
26
+ * each element: `(id, element_type, element) => shape`.
27
+ *
28
+ * The shapes are the caller's because G6's minimap clones each
29
+ * element's KEY shape into its own canvas, and in an `html` node
30
+ * the key shape is a DOM element, which clones into nothing. A
31
+ * block of the node's size (yui_graph_minimap_block()) is also
32
+ * what a minimap of cards should show: at that scale a card is a
33
+ * rectangle anyway.
34
+ ************************************************************/
35
+ export function yui_graph_minimap_options(shape)
36
+ {
37
+ return {
38
+ size: [200, 140],
39
+ position: "bottom-left",
40
+ /*
41
+ * The anchor has to be CSS, not the pixels G6 computes.
42
+ *
43
+ * `createPluginCanvas` turns `position` into `left`/`top`
44
+ * in PIXELS, once, from the canvas size at creation
45
+ * (`xRatio * (W - width)`). The container then grows --
46
+ * full screen, a window resize, a panel closing -- and the
47
+ * minimap stays at the `top` it was given: measured going
48
+ * full screen, `top` was still `511px` over a container
49
+ * that had become 768 tall, which put it floating halfway
50
+ * up the left edge, on top of the graph it is there to
51
+ * explain.
52
+ *
53
+ * `containerStyle` is merged AFTER those pixels, so
54
+ * `top: auto` + `bottom` is a real anchor the browser
55
+ * keeps for every size the container ever takes.
56
+ *
57
+ * And it follows the theme: G6's default is a `#fff` box
58
+ * with a `#ddd` border in BOTH themes, which over a
59
+ * near-black canvas is the brightest thing on screen.
60
+ */
61
+ containerStyle: {
62
+ top: "auto",
63
+ bottom: "12px",
64
+ left: "12px",
65
+ background: "var(--bulma-scheme-main, #fff)",
66
+ /* A mid grey and not a `--bulma-border-*` token: those
67
+ * are made for a line INSIDE a surface, and this one has
68
+ * to separate a floating panel from the CANVAS behind
69
+ * it -- which is near-black in one scheme and white in
70
+ * the other. `border-weak` was 1.43:1 over the dark
71
+ * canvas and 1.18 over the light one; every border token
72
+ * fails at least one of them. This one is 4.6 on both.
73
+ * (The box-shadow below separates it only where there
74
+ * is light to cast a shadow on.) */
75
+ border: "1px solid var(--bulma-text-weak, #94a3b8)",
76
+ borderRadius: "6px",
77
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
78
+ },
79
+ /* The viewport rectangle: G6 washes it in black, which is
80
+ * invisible over a dark minimap. A link-coloured outline
81
+ * reads on both. */
82
+ maskStyle: {
83
+ border: "2px solid var(--bulma-link-on-scheme, var(--bulma-link, #3b82f6))",
84
+ background: "rgba(59, 130, 246, 0.12)",
85
+ },
86
+ shape: shape,
87
+ };
88
+ }
89
+
90
+ /************************************************************
91
+ * One node of the minimap: a block of the node's size,
92
+ * centred where the node is, filled with `fill`.
93
+ *
94
+ * `node_data` is G6's (graph.getNodeData(id)); a node with no
95
+ * size of its own gets a card's.
96
+ ************************************************************/
97
+ export function yui_graph_minimap_block(node_data, fill)
98
+ {
99
+ let size = (node_data && node_data.style && node_data.style.size) || [120, 60];
100
+ return new RectGeometry({
101
+ style: {
102
+ x: -size[0] / 2,
103
+ y: -size[1] / 2,
104
+ width: size[0],
105
+ height: size[1],
106
+ fill: fill,
107
+ radius: 4
108
+ }
109
+ });
110
+ }
111
+
112
+ /************************************************************
113
+ * Paint a minimap again from where the nodes are NOW.
114
+ *
115
+ * It repaints off the graph's draw events, and a layout emits
116
+ * none: G6 moves the nodes with a SILENT draw. So after a layout
117
+ * the minimap goes on showing the arrangement before it until it
118
+ * is told. It throws what G6 throws: the caller catches it, and
119
+ * its log says whose minimap it was.
120
+ ************************************************************/
121
+ export function yui_graph_minimap_repaint(plugin)
122
+ {
123
+ if(!plugin || plugin.destroyed) {
124
+ return;
125
+ }
126
+ plugin.renderMinimap();
127
+ plugin.renderMask();
128
+ }