@yuneta/gobj-ui 7.27.21 → 7.27.23
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/README.md +70 -4
- package/dist/gobj-ui.cjs.js +706 -40
- package/dist/gobj-ui.es.js +706 -40
- package/package.json +1 -1
- package/src/c_yui_gobj_tree_js.js +455 -13
- package/src/gobj_tree_model.js +104 -0
- package/src/gobj_tree_model.test.js +52 -1
- package/src/gobj_tree_remote.wiring.test.js +298 -0
- package/src/i18n_key_functions.js +2 -0
- package/src/yui_dev.js +53 -15
- package/src/yui_dev_copy.test.js +17 -1
- package/src/yui_gobj_tree_view.js +246 -0
package/src/gobj_tree_model.js
CHANGED
|
@@ -331,6 +331,11 @@ function node_badge_keys(d)
|
|
|
331
331
|
if(d.commands) {
|
|
332
332
|
badges.push("commands");
|
|
333
333
|
}
|
|
334
|
+
/* Only a backend answers it (`view-gobj-tree`): a card that traces
|
|
335
|
+
* is the one a reader is looking for when the log fills up. */
|
|
336
|
+
if(Array.isArray(d.gobj_trace_level) && d.gobj_trace_level.length > 0) {
|
|
337
|
+
badges.push("traces");
|
|
338
|
+
}
|
|
334
339
|
|
|
335
340
|
return badges;
|
|
336
341
|
}
|
|
@@ -379,6 +384,7 @@ function node_labels(t)
|
|
|
379
384
|
"disabled": t("disabled"),
|
|
380
385
|
"bottom": t("bottom"),
|
|
381
386
|
"commands": t("commands"),
|
|
387
|
+
"traces": t("traces"),
|
|
382
388
|
},
|
|
383
389
|
field: {
|
|
384
390
|
gclass: t("gclass"),
|
|
@@ -463,6 +469,102 @@ function node_info_rows(d, t)
|
|
|
463
469
|
return rows;
|
|
464
470
|
}
|
|
465
471
|
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
/******************************
|
|
475
|
+
* Trace levels
|
|
476
|
+
******************************/
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
/************************************************************
|
|
480
|
+
* The rows of the TRACES block of a backend gobj, one per
|
|
481
|
+
* level it can trace: the gclass' own levels first (the ones
|
|
482
|
+
* that are about this gobj), then the global ones.
|
|
483
|
+
*
|
|
484
|
+
* `d` is the descriptor (its `gobj_trace_level` is what the
|
|
485
|
+
* gobj traces NOW, whatever the reason). `info` is what the
|
|
486
|
+
* host fetched for its gclass:
|
|
487
|
+
*
|
|
488
|
+
* gclass_levels {name: description} info-gclass-trace
|
|
489
|
+
* global_levels {name: description} info-global-trace
|
|
490
|
+
* gclass_on [name, ...] get-gclass-trace
|
|
491
|
+
* global_on [name, ...] get-global-trace
|
|
492
|
+
*
|
|
493
|
+
* `get-gclass-trace` answers the gclass' levels OR'ed with the
|
|
494
|
+
* global ones (gobj_get_gclass_trace_level), so a level on in
|
|
495
|
+
* both is counted as global: that is the one that would still
|
|
496
|
+
* hold it on if the gclass let go.
|
|
497
|
+
*
|
|
498
|
+
* Each row says, for the two columns of the block:
|
|
499
|
+
*
|
|
500
|
+
* gobj_on, gobj_locked the gobj traces it; locked when
|
|
501
|
+
* that comes from its gclass or
|
|
502
|
+
* from the global level -- turning
|
|
503
|
+
* the gobj's own bit off would not
|
|
504
|
+
* stop it
|
|
505
|
+
* gclass_on, gclass_locked every gobj of the gclass traces
|
|
506
|
+
* it; locked when it is global
|
|
507
|
+
* origin "global" | "gclass" | ""
|
|
508
|
+
************************************************************/
|
|
509
|
+
function trace_rows(d, info)
|
|
510
|
+
{
|
|
511
|
+
let rows = [];
|
|
512
|
+
if(!d || !info) {
|
|
513
|
+
return rows;
|
|
514
|
+
}
|
|
515
|
+
let list = (x) => Array.isArray(x)? x: [];
|
|
516
|
+
let now = list(d.gobj_trace_level);
|
|
517
|
+
let global_on = list(info.global_on);
|
|
518
|
+
let gclass_on = list(info.gclass_on);
|
|
519
|
+
let seen = {};
|
|
520
|
+
|
|
521
|
+
let add = (group, levels) => {
|
|
522
|
+
if(!levels || typeof levels !== "object") {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
for(let level of Object.keys(levels)) {
|
|
526
|
+
if(seen[level]) {
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
seen[level] = true;
|
|
530
|
+
let by_global = global_on.indexOf(level) >= 0;
|
|
531
|
+
let by_gclass = !by_global && gclass_on.indexOf(level) >= 0;
|
|
532
|
+
rows.push({
|
|
533
|
+
level: level,
|
|
534
|
+
description: String(levels[level] || ""),
|
|
535
|
+
group: group,
|
|
536
|
+
gobj_on: now.indexOf(level) >= 0 || by_global || by_gclass,
|
|
537
|
+
gobj_locked: by_global || by_gclass,
|
|
538
|
+
gclass_on: by_global || by_gclass,
|
|
539
|
+
gclass_locked: by_global,
|
|
540
|
+
origin: by_global? "global": (by_gclass? "gclass": ""),
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
add("gclass", info.gclass_levels);
|
|
545
|
+
add("global", info.global_levels);
|
|
546
|
+
return rows;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/************************************************************
|
|
550
|
+
* The levels a scope holds ON ITS OWN -- what "remove the
|
|
551
|
+
* traces" of that scope has to turn off. Not the locked ones:
|
|
552
|
+
* they are held by a wider scope, and turning them off here
|
|
553
|
+
* would change nothing.
|
|
554
|
+
************************************************************/
|
|
555
|
+
function own_trace_levels(rows, scope)
|
|
556
|
+
{
|
|
557
|
+
let out = [];
|
|
558
|
+
for(let r of (rows || [])) {
|
|
559
|
+
if(scope === "gobj" && r.gobj_on && !r.gobj_locked) {
|
|
560
|
+
out.push(r.level);
|
|
561
|
+
} else if(scope === "gclass" && r.gclass_on && !r.gclass_locked) {
|
|
562
|
+
out.push(r.level);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return out;
|
|
566
|
+
}
|
|
567
|
+
|
|
466
568
|
export {
|
|
467
569
|
ROLES,
|
|
468
570
|
STATUSES,
|
|
@@ -478,4 +580,6 @@ export {
|
|
|
478
580
|
describe_js_gobj,
|
|
479
581
|
describe_backend_node,
|
|
480
582
|
describe_backend_tree,
|
|
583
|
+
trace_rows,
|
|
584
|
+
own_trace_levels,
|
|
481
585
|
};
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
node_info_rows,
|
|
9
9
|
describe_backend_node,
|
|
10
10
|
describe_backend_tree,
|
|
11
|
+
trace_rows,
|
|
12
|
+
own_trace_levels,
|
|
11
13
|
} from "./gobj_tree_model.js";
|
|
12
14
|
|
|
13
15
|
/* A `view-gobj-tree` answer, trimmed to what the view reads. */
|
|
@@ -123,7 +125,7 @@ describe("node_status", () => {
|
|
|
123
125
|
describe("node_badge_keys", () => {
|
|
124
126
|
it("marks the role and every extra fact, in a fixed order", () => {
|
|
125
127
|
let root = describe_backend_tree(BACKEND_TREE);
|
|
126
|
-
expect(node_badge_keys(root)).toEqual(["yuno", "commands"]);
|
|
128
|
+
expect(node_badge_keys(root)).toEqual(["yuno", "commands", "traces"]);
|
|
127
129
|
|
|
128
130
|
let tcp = root.children.find(c => c.gclass === "C_TCP");
|
|
129
131
|
expect(node_badge_keys(tcp))
|
|
@@ -133,6 +135,55 @@ describe("node_badge_keys", () => {
|
|
|
133
135
|
it("a plain child carries no role badge", () => {
|
|
134
136
|
expect(node_badge_keys({})).toEqual([]);
|
|
135
137
|
});
|
|
138
|
+
|
|
139
|
+
it("a gobj that traces says so, last", () => {
|
|
140
|
+
expect(node_badge_keys({gobj_trace_level: ["machine"]})).toEqual(["traces"]);
|
|
141
|
+
expect(node_badge_keys({gobj_trace_level: []})).toEqual([]);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe("trace_rows", () => {
|
|
146
|
+
const INFO = {
|
|
147
|
+
gclass_levels: {traffic: "dump", connections: "connections"},
|
|
148
|
+
global_levels: {machine: "machine", connections: "never listed twice"},
|
|
149
|
+
gclass_on: ["connections", "machine"], /* OR'ed with the global ones */
|
|
150
|
+
global_on: ["machine"],
|
|
151
|
+
};
|
|
152
|
+
const by_level = (rows) => {
|
|
153
|
+
let map = {};
|
|
154
|
+
for(let r of rows) {
|
|
155
|
+
map[r.level] = r;
|
|
156
|
+
}
|
|
157
|
+
return map;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
it("lists the gclass levels first, then the global ones, each once", () => {
|
|
161
|
+
let rows = trace_rows({gobj_trace_level: []}, INFO);
|
|
162
|
+
expect(rows.map((r) => [r.level, r.group])).toEqual([
|
|
163
|
+
["traffic", "gclass"], ["connections", "gclass"], ["machine", "global"]
|
|
164
|
+
]);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("locks a level held by a wider scope, and says which", () => {
|
|
168
|
+
let r = by_level(trace_rows({gobj_trace_level: ["traffic", "connections", "machine"]}, INFO));
|
|
169
|
+
expect(r.traffic).toMatchObject({gobj_on: true, gobj_locked: false,
|
|
170
|
+
gclass_on: false, gclass_locked: false, origin: ""});
|
|
171
|
+
expect(r.connections).toMatchObject({gobj_on: true, gobj_locked: true,
|
|
172
|
+
gclass_on: true, gclass_locked: false, origin: "gclass"});
|
|
173
|
+
expect(r.machine).toMatchObject({gobj_on: true, gobj_locked: true,
|
|
174
|
+
gclass_on: true, gclass_locked: true, origin: "global"});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("what each scope holds on its own is what its remove turns off", () => {
|
|
178
|
+
let rows = trace_rows({gobj_trace_level: ["traffic", "connections", "machine"]}, INFO);
|
|
179
|
+
expect(own_trace_levels(rows, "gobj")).toEqual(["traffic"]);
|
|
180
|
+
expect(own_trace_levels(rows, "gclass")).toEqual(["connections"]);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("no info, no rows", () => {
|
|
184
|
+
expect(trace_rows({gobj_trace_level: ["machine"]}, null)).toEqual([]);
|
|
185
|
+
expect(own_trace_levels(null, "gobj")).toEqual([]);
|
|
186
|
+
});
|
|
136
187
|
});
|
|
137
188
|
|
|
138
189
|
describe("node_info_rows", () => {
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* gobj_tree_remote.wiring.test.js
|
|
3
|
+
*
|
|
4
|
+
* C_YUI_GOBJ_TREE_JS with `source: "remote"`: the tree of a BACKEND
|
|
5
|
+
* yuno, which the view cannot fetch itself. It publishes what it
|
|
6
|
+
* wants (the tree, the trace levels of a gclass, a trace set) and
|
|
7
|
+
* the host loads the answers. Asserted here: what reaches the host,
|
|
8
|
+
* what the TRACES block of a card shows for each origin of a level,
|
|
9
|
+
* that a reload keeps the card open, and that a LOCAL tree publishes
|
|
10
|
+
* none of it (its hosts declare none of these events).
|
|
11
|
+
*
|
|
12
|
+
* The real gclass, on a G6 Graph double.
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2026, ArtGins.
|
|
15
|
+
* All Rights Reserved.
|
|
16
|
+
***********************************************************************/
|
|
17
|
+
import {describe, test, expect, beforeAll, beforeEach, vi} from "vitest";
|
|
18
|
+
import {install_dom_double, fake_event} from "../test/dom_double.js";
|
|
19
|
+
|
|
20
|
+
install_dom_double();
|
|
21
|
+
|
|
22
|
+
if(typeof globalThis.ResizeObserver === "undefined") {
|
|
23
|
+
globalThis.ResizeObserver = class {
|
|
24
|
+
observe() {
|
|
25
|
+
}
|
|
26
|
+
unobserve() {
|
|
27
|
+
}
|
|
28
|
+
disconnect() {
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
vi.mock("@antv/g6", async (importOriginal) => {
|
|
34
|
+
const real = await importOriginal();
|
|
35
|
+
class FakeGraph {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.options = options;
|
|
38
|
+
return new Proxy(this, {
|
|
39
|
+
get: (t, k) => (k in t) ? t[k] : (() => undefined),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
}
|
|
45
|
+
draw() {
|
|
46
|
+
return Promise.resolve();
|
|
47
|
+
}
|
|
48
|
+
on() {
|
|
49
|
+
}
|
|
50
|
+
getZoom() {
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
getPosition() {
|
|
54
|
+
return [0, 0];
|
|
55
|
+
}
|
|
56
|
+
zoomTo() {
|
|
57
|
+
return Promise.resolve();
|
|
58
|
+
}
|
|
59
|
+
translateTo() {
|
|
60
|
+
return Promise.resolve();
|
|
61
|
+
}
|
|
62
|
+
getData() {
|
|
63
|
+
return {nodes: [], edges: [], combos: []};
|
|
64
|
+
}
|
|
65
|
+
getNodeData() {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
getEdgeData() {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
getPlugins() {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
getBehaviors() {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
getOptions() {
|
|
78
|
+
return {behaviors: []};
|
|
79
|
+
}
|
|
80
|
+
getCanvas() {
|
|
81
|
+
return {getLayers: () => ({}), getContainer: () => null};
|
|
82
|
+
}
|
|
83
|
+
fitView() {
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
}
|
|
86
|
+
destroy() {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {...real, Graph: FakeGraph};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
SDATA_END, gclass_create, gobj_start_up, gobj_create_yuno, gobj_create,
|
|
94
|
+
gobj_start, gobj_read_attr, gobj_send_event, set_log_callback, register_c_timer,
|
|
95
|
+
} = await import("@yuneta/gobj-js");
|
|
96
|
+
const {register_c_yui_gobj_tree_js} = await import("./c_yui_gobj_tree_js.js");
|
|
97
|
+
|
|
98
|
+
const logged = [];
|
|
99
|
+
const wanted = [];
|
|
100
|
+
let yuno = null;
|
|
101
|
+
let host = null;
|
|
102
|
+
let seq = 0;
|
|
103
|
+
|
|
104
|
+
/* The `view-gobj-tree` answer of a small backend yuno. */
|
|
105
|
+
const TREE = {
|
|
106
|
+
"C_YUNO^gate": {
|
|
107
|
+
gclass: "C_YUNO", name: "gate", shortname: "C_YUNO^gate", fullname: "C_YUNO^gate",
|
|
108
|
+
state: "ST_YUNO_RUNNING", running: true, playing: true,
|
|
109
|
+
gobj_flags: ["gobj_flag_yuno"], gobj_trace_level: [],
|
|
110
|
+
children: {
|
|
111
|
+
"C_TCP^tcp1": {
|
|
112
|
+
gclass: "C_TCP", name: "tcp1", shortname: "C_TCP^tcp1",
|
|
113
|
+
fullname: "C_YUNO^gate`C_TCP^tcp1", parent: "C_YUNO^gate",
|
|
114
|
+
state: "ST_CONNECTED", running: true, playing: true,
|
|
115
|
+
gobj_trace_level: ["traffic", "connections"],
|
|
116
|
+
children: {}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/* What the host fetched for C_TCP: `connections` is on for the gclass,
|
|
123
|
+
* `traffic` only for tcp1, `machine` for nobody. */
|
|
124
|
+
const TCP_INFO = {
|
|
125
|
+
gclass: "C_TCP",
|
|
126
|
+
gclass_levels: {traffic: "Trace dump traffic", connections: "Trace connections"},
|
|
127
|
+
global_levels: {machine: "Trace machine"},
|
|
128
|
+
gclass_on: ["connections"],
|
|
129
|
+
global_on: [],
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
function record(gobj, event, kw, src)
|
|
133
|
+
{
|
|
134
|
+
wanted.push({event: event, kw: kw});
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
beforeAll(async () => {
|
|
139
|
+
const i18next = (await import("i18next")).default;
|
|
140
|
+
await i18next.init({lng: "en", resources: {en: {translation: {}}}});
|
|
141
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
142
|
+
set_log_callback((level, msg) => {
|
|
143
|
+
logged.push({level: String(level), msg: String(msg)});
|
|
144
|
+
});
|
|
145
|
+
register_c_timer();
|
|
146
|
+
register_c_yui_gobj_tree_js();
|
|
147
|
+
gclass_create("C_TEST_TREE_YUNO", [], [["ST_IDLE", []]], {}, 0,
|
|
148
|
+
[SDATA_END()], {}, 0, 0, 0, 0);
|
|
149
|
+
gclass_create("C_TEST_TREE_HOST",
|
|
150
|
+
[["EV_TREE_WANTED", 0], ["EV_TRACE_INFO_WANTED", 0],
|
|
151
|
+
["EV_SET_TRACE_LEVEL", 0], ["EV_GCLASS_WANTED", 0]],
|
|
152
|
+
[["ST_IDLE", [
|
|
153
|
+
["EV_TREE_WANTED", record, null],
|
|
154
|
+
["EV_TRACE_INFO_WANTED", record, null],
|
|
155
|
+
["EV_SET_TRACE_LEVEL", record, null],
|
|
156
|
+
["EV_GCLASS_WANTED", record, null],
|
|
157
|
+
]]],
|
|
158
|
+
{}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
159
|
+
yuno = gobj_create_yuno("tree_yuno", "C_TEST_TREE_YUNO", {});
|
|
160
|
+
host = gobj_create("host", "C_TEST_TREE_HOST", {}, yuno);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
beforeEach(() => {
|
|
164
|
+
logged.length = 0;
|
|
165
|
+
wanted.length = 0;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
function problems()
|
|
169
|
+
{
|
|
170
|
+
return logged.filter((l) => l.level === "error" || l.level === "warning").map((l) => l.msg);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function mount(source, parent)
|
|
174
|
+
{
|
|
175
|
+
const view = gobj_create(`tree_${++seq}`, "C_YUI_GOBJ_TREE_JS",
|
|
176
|
+
{source: source, yuno_name: "gate^1"}, parent);
|
|
177
|
+
document.body.appendChild(gobj_read_attr(view, "$container"));
|
|
178
|
+
gobj_start(view);
|
|
179
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
180
|
+
return view;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function node_id_of(view, fullname)
|
|
184
|
+
{
|
|
185
|
+
const by_id = view.priv.node_by_id || {};
|
|
186
|
+
return Object.keys(by_id).find((id) => by_id[id].full_name === fullname);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function row_of(view, level)
|
|
190
|
+
{
|
|
191
|
+
const $pop = view.priv.$popover;
|
|
192
|
+
const $gobj = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GOBJ")
|
|
193
|
+
.find((b) => b.getAttribute("data-level") === level);
|
|
194
|
+
const $gclass = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GCLASS")
|
|
195
|
+
.find((b) => b.getAttribute("data-level") === level);
|
|
196
|
+
return {$gobj, $gclass};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function open_tcp_card(view)
|
|
200
|
+
{
|
|
201
|
+
gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
|
|
202
|
+
const id = node_id_of(view, "C_YUNO^gate`C_TCP^tcp1");
|
|
203
|
+
expect(id).toBeTruthy();
|
|
204
|
+
gobj_send_event(view, "EV_NODE_CLICK", {id: id, client_x: 10, client_y: 10}, view);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
describe("C_YUI_GOBJ_TREE_JS, source remote", () => {
|
|
208
|
+
test("draws nothing until the host loads a tree, and asks for it on Refresh", async () => {
|
|
209
|
+
const view = await mount("remote", host);
|
|
210
|
+
expect(view.priv.node_by_id && Object.keys(view.priv.node_by_id).length || 0).toBe(0);
|
|
211
|
+
gobj_send_event(view, "EV_REFRESH", {}, view);
|
|
212
|
+
expect(wanted.map((w) => w.event)).toEqual(["EV_TREE_WANTED"]);
|
|
213
|
+
|
|
214
|
+
gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
|
|
215
|
+
expect(Object.keys(view.priv.node_by_id).length).toBe(2);
|
|
216
|
+
expect(problems()).toEqual([]);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("a card asks for the trace levels of its gclass, and shows where each comes from", async () => {
|
|
220
|
+
const view = await mount("remote", host);
|
|
221
|
+
await open_tcp_card(view);
|
|
222
|
+
expect(wanted.map((w) => [w.event, w.kw.gclass])).toEqual([["EV_TRACE_INFO_WANTED", "C_TCP"]]);
|
|
223
|
+
expect(view.priv.$popover.querySelectorAll(".GOBJ_TREE_TRACES_TABLE").length).toBe(0);
|
|
224
|
+
|
|
225
|
+
gobj_send_event(view, "EV_TRACE_INFO", TCP_INFO, host);
|
|
226
|
+
const traffic = row_of(view, "traffic");
|
|
227
|
+
const connections = row_of(view, "connections");
|
|
228
|
+
const machine = row_of(view, "machine");
|
|
229
|
+
|
|
230
|
+
/* 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]);
|
|
236
|
+
/* nobody */
|
|
237
|
+
expect([machine.$gobj.checked, machine.$gobj.disabled]).toEqual([false, false]);
|
|
238
|
+
expect(problems()).toEqual([]);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("a box sends the set to the host and locks the block until the backend answers", async () => {
|
|
242
|
+
const view = await mount("remote", host);
|
|
243
|
+
await open_tcp_card(view);
|
|
244
|
+
gobj_send_event(view, "EV_TRACE_INFO", TCP_INFO, host);
|
|
245
|
+
wanted.length = 0;
|
|
246
|
+
|
|
247
|
+
const {$gobj} = row_of(view, "machine");
|
|
248
|
+
$gobj.checked = true;
|
|
249
|
+
$gobj.dispatchEvent(fake_event("change"));
|
|
250
|
+
expect(wanted).toEqual([{event: "EV_SET_TRACE_LEVEL", kw: {
|
|
251
|
+
scope: "gobj", gobj: "C_YUNO^gate`C_TCP^tcp1", gclass: "C_TCP",
|
|
252
|
+
levels: ["machine"], set: true
|
|
253
|
+
}}]);
|
|
254
|
+
expect(row_of(view, "traffic").$gobj.disabled).toBe(true);
|
|
255
|
+
|
|
256
|
+
/* The host loads what the backend says now: the card is still
|
|
257
|
+
* open on tcp1, and unlocked. */
|
|
258
|
+
const tree = JSON.parse(JSON.stringify(TREE));
|
|
259
|
+
tree["C_YUNO^gate"].children["C_TCP^tcp1"].gobj_trace_level.push("machine");
|
|
260
|
+
gobj_send_event(view, "EV_LOAD_TREE", {tree: tree}, host);
|
|
261
|
+
expect(view.priv.popover_node.full_name).toBe("C_YUNO^gate`C_TCP^tcp1");
|
|
262
|
+
expect(view.priv.$popover.style.display).toBe("block");
|
|
263
|
+
expect([row_of(view, "machine").$gobj.checked, row_of(view, "machine").$gobj.disabled])
|
|
264
|
+
.toEqual([true, false]);
|
|
265
|
+
expect(problems()).toEqual([]);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test("remove the traces of the gobj turns off what it holds on its own, not what the gclass holds", async () => {
|
|
269
|
+
const view = await mount("remote", host);
|
|
270
|
+
await open_tcp_card(view);
|
|
271
|
+
gobj_send_event(view, "EV_TRACE_INFO", TCP_INFO, host);
|
|
272
|
+
wanted.length = 0;
|
|
273
|
+
|
|
274
|
+
const $clear = view.priv.$popover.querySelector(".GOBJ_TREE_TRACES_CLEAR_GOBJ");
|
|
275
|
+
expect($clear.disabled).toBe(false);
|
|
276
|
+
$clear.click();
|
|
277
|
+
expect(wanted.map((w) => [w.kw.scope, w.kw.levels, w.kw.set])).toEqual([["gobj", ["traffic"], false]]);
|
|
278
|
+
expect(problems()).toEqual([]);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("the gclass button asks the host for the backend gclass", async () => {
|
|
282
|
+
const view = await mount("remote", host);
|
|
283
|
+
await open_tcp_card(view);
|
|
284
|
+
wanted.length = 0;
|
|
285
|
+
gobj_send_event(view, "EV_OPEN_GCLASS", {}, view);
|
|
286
|
+
expect(wanted.map((w) => [w.event, w.kw.gclass])).toEqual([["EV_GCLASS_WANTED", "C_TCP"]]);
|
|
287
|
+
expect(view.priv.gclass_view).toBe(null);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
describe("C_YUI_GOBJ_TREE_JS, source local", () => {
|
|
292
|
+
test("publishes nothing: its host declares none of the remote events", async () => {
|
|
293
|
+
const view = await mount("local", yuno);
|
|
294
|
+
gobj_send_event(view, "EV_REFRESH", {}, view);
|
|
295
|
+
expect(wanted).toEqual([]);
|
|
296
|
+
expect(problems()).toEqual([]);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
@@ -160,6 +160,8 @@ export const I18N_KEY_FUNCTIONS = Object.freeze([
|
|
|
160
160
|
fallbacks: {"0[].id": ["0[].name", "0[].aria_label"]}},
|
|
161
161
|
/* yui_gclass_view.js -- the dialog's title is the gclass name */
|
|
162
162
|
{module: "yui_gclass_view.js", name: "open_gclass_view", exported: true, keys: ["1"]},
|
|
163
|
+
/* yui_gobj_tree_view.js -- the window's title is a key */
|
|
164
|
+
{module: "yui_gobj_tree_view.js", name: "open_gobj_tree_view", exported: true, keys: ["1.title"]},
|
|
163
165
|
/* g6_canvas_tab_order.js -- the name of a graph's main canvas, the
|
|
164
166
|
* one control of the graph in the Tab order */
|
|
165
167
|
{module: "g6_canvas_tab_order.js", name: "set_canvas_tab_order", exported: true, keys: ["2"]},
|
package/src/yui_dev.js
CHANGED
|
@@ -86,7 +86,7 @@ export const YUI_DEV_I18N_KEYS = [
|
|
|
86
86
|
"dev window and browser console", "dev window only", "developer",
|
|
87
87
|
"clear the filter", "errors", "expand", "expanded",
|
|
88
88
|
"filter events / payload", "find", "i18n", "i18next debug output",
|
|
89
|
-
"incoming", "log", "machine trace shape", "metadata", "outgoing",
|
|
89
|
+
"incoming", "log", "machine trace shape", "metadata", "one line", "outgoing",
|
|
90
90
|
"output", "payload", "periodic", "schema", "show",
|
|
91
91
|
"show the payload of the traces",
|
|
92
92
|
"show this section in the expanded view", "simple mach", "start / stop",
|
|
@@ -95,7 +95,7 @@ export const YUI_DEV_I18N_KEYS = [
|
|
|
95
95
|
"trace the creation and destruction of gobjs",
|
|
96
96
|
"trace the messages to and from the backend",
|
|
97
97
|
"trace the periodic timer event", "trace the start and stop of gobjs",
|
|
98
|
-
"traces", "traffic", "traffic payload folded",
|
|
98
|
+
"traces", "traffic", "traffic one line per message", "traffic payload folded",
|
|
99
99
|
"traffic payload laid out", "view", "window", "yuno monitor"
|
|
100
100
|
];
|
|
101
101
|
|
|
@@ -202,13 +202,21 @@ function dev_num(key, def)
|
|
|
202
202
|
* the traffic's lives in the VIEW group, the traces' in the TRACES row,
|
|
203
203
|
* beside the chip that picks the machine-trace shape.
|
|
204
204
|
*
|
|
205
|
-
* The
|
|
206
|
-
*
|
|
207
|
-
*
|
|
205
|
+
* The view says how much room a message takes: `line` (its event name
|
|
206
|
+
* alone, one row per message), `collapsed` (the payload folded) or
|
|
207
|
+
* `expanded` (the payload laid out). `line` is the old `Name only`, back
|
|
208
|
+
* in 7.27.22 now that the selector is the traffic's alone: it is what you
|
|
209
|
+
* want to see WHICH messages go and come, and open one of the other two
|
|
210
|
+
* to read them. The old `dev_view_mode` key is left where it is and simply
|
|
211
|
+
* stops being read (same as SIMPLE_MACH_KEY below). */
|
|
212
|
+
function traffic_view_of(v)
|
|
213
|
+
{
|
|
214
|
+
return (v === "expanded" || v === "line") ? v : "collapsed";
|
|
215
|
+
}
|
|
216
|
+
|
|
208
217
|
function dev_traffic_view()
|
|
209
218
|
{
|
|
210
|
-
|
|
211
|
-
return (v === "expanded") ? "expanded" : "collapsed";
|
|
219
|
+
return traffic_view_of(kw_get_local_storage_value("dev_traffic_view", "collapsed", false));
|
|
212
220
|
}
|
|
213
221
|
|
|
214
222
|
/* Whether the trace's PAYLOAD lines (level `json`: the kw a trace dumps
|
|
@@ -274,7 +282,7 @@ function apply_console_route()
|
|
|
274
282
|
* It follows the VIEW, because the window and the console are two sinks of
|
|
275
283
|
* ONE feed and may not disagree about what they are showing: `expanded`
|
|
276
284
|
* prints the payload laid out, `collapsed` hands the object to the console
|
|
277
|
-
* and lets it fold it. The same promise the log filter made in 7.23.33 --
|
|
285
|
+
* and lets it fold it, `line` prints the head alone. The same promise the log filter made in 7.23.33 --
|
|
278
286
|
* one rule, two sinks -- which the traffic half had never kept. */
|
|
279
287
|
function console_traffic(title, jn, direction, size)
|
|
280
288
|
{
|
|
@@ -284,7 +292,12 @@ function console_traffic(title, jn, direction, size)
|
|
|
284
292
|
let head = "%c" + dir_arrow(direction) + " " + (title ? "[" + title + "] " : "") + event +
|
|
285
293
|
(size ? " (" + size + "b)" : "");
|
|
286
294
|
|
|
287
|
-
|
|
295
|
+
let view = dev_traffic_view();
|
|
296
|
+
if(view === "line") {
|
|
297
|
+
window.console.log(head, "color:" + color);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if(view === "expanded") {
|
|
288
301
|
let text;
|
|
289
302
|
try {
|
|
290
303
|
text = JSON.stringify(full_sections(kw), null, 4);
|
|
@@ -300,7 +313,7 @@ function console_traffic(title, jn, direction, size)
|
|
|
300
313
|
|
|
301
314
|
function set_traffic_view(v)
|
|
302
315
|
{
|
|
303
|
-
kw_set_local_storage_value("dev_traffic_view", (v
|
|
316
|
+
kw_set_local_storage_value("dev_traffic_view", traffic_view_of(v));
|
|
304
317
|
rerender_all();
|
|
305
318
|
refresh_dev_chrome();
|
|
306
319
|
}
|
|
@@ -508,6 +521,9 @@ function ensure_dev_style()
|
|
|
508
521
|
.TRAFFIC_ENTRY.dir-out { border-left-color: #2563eb; }
|
|
509
522
|
.TRAFFIC_ENTRY.dir-in { border-left-color: #059669; }
|
|
510
523
|
.TRAFFIC_ENTRY.dir-err { border-left-color: #dc2626; }
|
|
524
|
+
/* The line view: one row per message, no margin between rows, so a burst
|
|
525
|
+
of messages reads as a list. */
|
|
526
|
+
.TRAFFIC_ENTRY.TRAFFIC_NAME { margin: 1px 0; padding: 1px 8px; line-height: 1.45; display: flex; align-items: baseline; gap: 8px; }
|
|
511
527
|
.TRAFFIC_HEADER { display: flex; align-items: baseline; gap: 8px; }
|
|
512
528
|
.TRAFFIC_ARROW { font-weight: 700; }
|
|
513
529
|
.TRAFFIC_EVENT { font-weight: 700; }
|
|
@@ -895,6 +911,14 @@ function render_full(e)
|
|
|
895
911
|
return createElement2(['div', {class: 'TRAFFIC_ENTRY ' + dir_class(e.dir)}, children]);
|
|
896
912
|
}
|
|
897
913
|
|
|
914
|
+
/* Line view: the message's head and nothing else. */
|
|
915
|
+
function render_name(e)
|
|
916
|
+
{
|
|
917
|
+
let kids = event_spans(e);
|
|
918
|
+
kids.push(['span', {class: 'TRAFFIC_META'}, `${traffic_size(e.size)} · ${e.ts}`]);
|
|
919
|
+
return createElement2(['div', {class: 'TRAFFIC_ENTRY TRAFFIC_NAME ' + dir_class(e.dir)}, kids]);
|
|
920
|
+
}
|
|
921
|
+
|
|
898
922
|
/* A mirrored framework log line (error/warning/info/debug/msg). */
|
|
899
923
|
function render_log(e)
|
|
900
924
|
{
|
|
@@ -923,8 +947,9 @@ function render_log(e)
|
|
|
923
947
|
return $row;
|
|
924
948
|
}
|
|
925
949
|
|
|
926
|
-
/* A TRAFFIC entry
|
|
927
|
-
* bullets) or laid out (`expanded`, the JSON).
|
|
950
|
+
/* A TRAFFIC entry shows its head alone (`line`), or with its payload --
|
|
951
|
+
* folded (`collapsed`, the bullets) or laid out (`expanded`, the JSON).
|
|
952
|
+
* A trace line is written by
|
|
928
953
|
* the runtime and is painted as it comes; what shapes it is the TRACES row
|
|
929
954
|
* (the machine-trace format chip and the payload chip), not this. */
|
|
930
955
|
function render_entry(e)
|
|
@@ -932,7 +957,11 @@ function render_entry(e)
|
|
|
932
957
|
if(e.kind === "log") {
|
|
933
958
|
return render_log(e);
|
|
934
959
|
}
|
|
935
|
-
|
|
960
|
+
let view = dev_traffic_view();
|
|
961
|
+
if(view === "line") {
|
|
962
|
+
return render_name(e);
|
|
963
|
+
}
|
|
964
|
+
if(view === "expanded") {
|
|
936
965
|
return render_full(e);
|
|
937
966
|
}
|
|
938
967
|
return render_detailed(e);
|
|
@@ -1478,7 +1507,8 @@ function entry_shown_lines($entry)
|
|
|
1478
1507
|
/* Serialize the currently-visible (filtered) traffic to plain text:
|
|
1479
1508
|
* one header line per entry (time · direction · title · event/command)
|
|
1480
1509
|
* followed by its payload AS THE VIEW SHOWS IT -- folded, what is on
|
|
1481
|
-
* screen (entry_shown_lines()); laid out, the whole payload
|
|
1510
|
+
* screen (entry_shown_lines()); laid out, the whole payload; in the line
|
|
1511
|
+
* view, none (the header line alone, no blank line). Honours the
|
|
1482
1512
|
* active filters and search so the copy matches exactly what is on
|
|
1483
1513
|
* screen. */
|
|
1484
1514
|
function traffic_to_text()
|
|
@@ -1499,7 +1529,11 @@ function traffic_to_text()
|
|
|
1499
1529
|
`${e.title ? "[" + e.title + "] " : ""}${e.event}` +
|
|
1500
1530
|
`${e.command ? " " + e.command : ""}`;
|
|
1501
1531
|
out.push(head);
|
|
1502
|
-
|
|
1532
|
+
let view = dev_traffic_view();
|
|
1533
|
+
if(view === "line") {
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
if(view !== "expanded" && e.$node) {
|
|
1503
1537
|
out.push(...entry_shown_lines(e.$node));
|
|
1504
1538
|
out.push("");
|
|
1505
1539
|
continue;
|
|
@@ -1609,6 +1643,7 @@ function build_control_bar()
|
|
|
1609
1643
|
* in the TRACES row (the machine-trace chip and `payload`), because
|
|
1610
1644
|
* both feeds can be on at once and neither may steer the other. */
|
|
1611
1645
|
let VIEW_TITLES = {
|
|
1646
|
+
line: 'traffic one line per message',
|
|
1612
1647
|
collapsed: 'traffic payload folded',
|
|
1613
1648
|
expanded: 'traffic payload laid out',
|
|
1614
1649
|
};
|
|
@@ -1625,6 +1660,7 @@ function build_control_bar()
|
|
|
1625
1660
|
}];
|
|
1626
1661
|
|
|
1627
1662
|
let view_seg = ['div', {class: 'YDEV_SEG', id: 'ydev-seg'}, [
|
|
1663
|
+
mk_view('line', 'one line'),
|
|
1628
1664
|
mk_view('collapsed', 'collapsed'),
|
|
1629
1665
|
mk_view('expanded', 'expanded'),
|
|
1630
1666
|
]];
|
|
@@ -1964,4 +2000,6 @@ export {
|
|
|
1964
2000
|
object_preview, object_preview_parts,
|
|
1965
2001
|
/* And the copy of the folded view, with the renderer it reads. */
|
|
1966
2002
|
entry_shown_lines, render_detailed,
|
|
2003
|
+
/* And the line view's row. */
|
|
2004
|
+
render_name,
|
|
1967
2005
|
};
|