@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.
- package/README.md +93 -29
- package/dist/gobj-ui.cjs.js +38450 -37624
- package/dist/gobj-ui.es.js +38445 -37619
- package/package.json +4 -4
- package/src/c_g6_nodes_tree.js +36 -96
- package/src/c_yui_gclass.css +104 -22
- package/src/c_yui_gclass.js +413 -94
- package/src/c_yui_gobj_tree_js.js +544 -144
- package/src/gclass_traces.wiring.test.js +235 -0
- package/src/gobj_tree_camera.wiring.test.js +44 -4
- package/src/gobj_tree_model.js +93 -17
- package/src/gobj_tree_model.test.js +48 -3
- package/src/gobj_tree_remote.wiring.test.js +84 -7
- package/src/yui_gclass_view.js +11 -0
- package/src/yui_graph_minimap.js +128 -0
package/src/c_yui_gclass.js
CHANGED
|
@@ -39,11 +39,29 @@
|
|
|
39
39
|
* the host mounts `$container` wherever it wants (a C_YUI_WINDOW body
|
|
40
40
|
* on desktop, a dialog on a phone). `yui_gclass_view.js` does both.
|
|
41
41
|
*
|
|
42
|
+
* THE LAYOUT. The head says what the gclass is called, how many gobjs
|
|
43
|
+
* of it there are, the instance the reader came from with its state,
|
|
44
|
+
* and the methods it implements. Then the short zones (the machine,
|
|
45
|
+
* the trace levels), side by side when the VIEWER is wide -- a
|
|
46
|
+
* container query: a 720px window on a wide screen is narrow -- and
|
|
47
|
+
* the long tables (attributes, commands) across the whole width, each
|
|
48
|
+
* showing ROWS_CAP entries and a button for the rest (a search shows
|
|
49
|
+
* every match).
|
|
50
|
+
*
|
|
51
|
+
* ITS TRACES, when the host can set them (`traces` attr, {info,
|
|
52
|
+
* pending}): the trace levels zone has one box per level for every
|
|
53
|
+
* gobj of the gclass, own levels and the kernel's; a level the yuno
|
|
54
|
+
* holds is locked. A box publishes EV_SET_GCLASS_TRACE {gclass,
|
|
55
|
+
* levels, set} to the host (this gclass is its child; the gobj tree
|
|
56
|
+
* declares it) and locks the zone until EV_SET_TRACES hands back what
|
|
57
|
+
* the backend says now. Without `traces` the levels are only listed.
|
|
58
|
+
*
|
|
42
59
|
* DOM is self-describing (UPPER_SNAKE logical classes): GCLASS_VIEWER /
|
|
43
60
|
* GCLASS_TOOLBAR / GCLASS_SEARCH / GCLASS_VIEW_SWITCH / GCLASS_ZONES /
|
|
44
|
-
* GCLASS_HEAD /
|
|
61
|
+
* GCLASS_HEAD / GCLASS_METHODS / GCLASS_CURRENT / GCLASS_PAIR /
|
|
62
|
+
* GCLASS_FULL / GCLASS_ZONE / GCLASS_ZONE_TITLE / GCLASS_ZONE_BODY /
|
|
45
63
|
* GCLASS_TABLE / GCLASS_MATRIX / GCLASS_CELL / GCLASS_PUBLISHED /
|
|
46
|
-
* GCLASS_RAW.
|
|
64
|
+
* GCLASS_TRACE_TOGGLES / GCLASS_SHOW_ALL / GCLASS_RAW.
|
|
47
65
|
*
|
|
48
66
|
* Copyright (c) 2026, ArtGins.
|
|
49
67
|
* All Rights Reserved.
|
|
@@ -52,6 +70,7 @@ import {
|
|
|
52
70
|
SDATA,
|
|
53
71
|
SDATA_END,
|
|
54
72
|
data_type_t,
|
|
73
|
+
event_flag_t,
|
|
55
74
|
gclass_create,
|
|
56
75
|
gclass_find_by_name,
|
|
57
76
|
log_error,
|
|
@@ -62,6 +81,7 @@ import {
|
|
|
62
81
|
gobj_write_attr,
|
|
63
82
|
gobj_read_str_attr,
|
|
64
83
|
gobj_send_event,
|
|
84
|
+
gobj_publish_event,
|
|
65
85
|
gobj_create_pure_child,
|
|
66
86
|
gobj_start,
|
|
67
87
|
gobj_stop,
|
|
@@ -76,6 +96,7 @@ import {
|
|
|
76
96
|
} from "@yuneta/gobj-js";
|
|
77
97
|
|
|
78
98
|
import {gclass_view_model} from "./gclass_view_model.js";
|
|
99
|
+
import {trace_rows, own_trace_levels} from "./gobj_tree_model.js";
|
|
79
100
|
import {register_c_yui_fsm_graph} from "./c_yui_fsm_graph.js";
|
|
80
101
|
import {json_text_dump} from "./json_view_helpers.js";
|
|
81
102
|
import {yui_toolbar} from "./yui_toolbar.js";
|
|
@@ -124,18 +145,29 @@ const MACHINE_VIEWS = [
|
|
|
124
145
|
const MAX_RAW_CHARS = 2000000;
|
|
125
146
|
|
|
126
147
|
/*
|
|
127
|
-
* The zones, in the order they are laid out
|
|
128
|
-
*
|
|
129
|
-
*
|
|
148
|
+
* The zones, in the order they are laid out: the SHORT ones first,
|
|
149
|
+
* the long tables last. C_YUNO declares 64 attributes and a hundred
|
|
150
|
+
* commands, about 7000px of them, and when those came first its
|
|
151
|
+
* methods and its trace levels were at the bottom of all that, beside
|
|
152
|
+
* a machine of two events. `pair` zones sit side by side when the
|
|
153
|
+
* VIEWER is wide enough (a container query, not the screen's width:
|
|
154
|
+
* a 720px window on a wide screen is a narrow viewer); the rest take
|
|
155
|
+
* the whole width, which is what a table with a description needs.
|
|
156
|
+
* The methods are not a zone: a handful of chips, in the head.
|
|
130
157
|
*/
|
|
131
158
|
const ZONES = [
|
|
132
|
-
{id: "
|
|
133
|
-
{id: "
|
|
134
|
-
{id: "
|
|
135
|
-
{id: "
|
|
136
|
-
{id: "machine", key: "machine", col: "right"},
|
|
159
|
+
{id: "machine", key: "machine", pair: true},
|
|
160
|
+
{id: "traces", key: "trace levels", pair: true},
|
|
161
|
+
{id: "attrs", key: "attributes", pair: false},
|
|
162
|
+
{id: "commands", key: "commands", pair: false},
|
|
137
163
|
];
|
|
138
164
|
|
|
165
|
+
/*
|
|
166
|
+
* A long table shows this many entries, and a button for the rest. A
|
|
167
|
+
* search lifts it: what matches is shown whatever its place.
|
|
168
|
+
*/
|
|
169
|
+
const ROWS_CAP = 20;
|
|
170
|
+
|
|
139
171
|
/* The keys of VIEWS, MACHINE_VIEWS and ZONES: they reach t() as data
|
|
140
172
|
* (`v.key`, `zone.key`), where no scan of the source reads them, so
|
|
141
173
|
* they are published here for a consumer's validate-locales, which asks
|
|
@@ -158,6 +190,8 @@ SDATA(data_type_t.DTP_POINTER, "subscriber", 0, null, "Subscriber of outpu
|
|
|
158
190
|
SDATA(data_type_t.DTP_JSON, "description", 0, null, "The gclass description, as `view-gclass` answers it or `describe_local_gclass()` builds it"),
|
|
159
191
|
SDATA(data_type_t.DTP_STRING, "gclass_name", 0, "", "Name to head the view with when the description carries none"),
|
|
160
192
|
SDATA(data_type_t.DTP_STRING, "current_state",0, "", "State of the INSTANCE the host is showing, lit in the machine. Empty when the host is not showing one"),
|
|
193
|
+
SDATA(data_type_t.DTP_STRING, "instance_name",0, "", "Name of that instance, said beside its state: a gclass has several"),
|
|
194
|
+
SDATA(data_type_t.DTP_JSON, "traces", 0, null, "{info, pending}: the host can set this gclass' traces for every gobj of it (EV_SET_GCLASS_TRACE). `info` is what it read: {gclass_levels, global_levels, gclass_on, global_on, error}, null while it reads. Null: the levels are only listed"),
|
|
161
195
|
SDATA(data_type_t.DTP_STRING, "view_mode", 0, "zones","View: 'zones' or 'raw'"),
|
|
162
196
|
|
|
163
197
|
/*---------------- UI ----------------*/
|
|
@@ -169,6 +203,7 @@ let PRIVATE_DATA = {
|
|
|
169
203
|
model: null, // the view model built from the description
|
|
170
204
|
search: "", // current filter term (lower-cased)
|
|
171
205
|
collapsed: null, // Set<string> of collapsed zone ids
|
|
206
|
+
expanded: null, // Set<string> of zones showing every row (ROWS_CAP lifted)
|
|
172
207
|
machine_view: "matrix", // how the machine zone is read
|
|
173
208
|
graph_gobj: null, // hosted C_YUI_FSM_GRAPH child (built on first use)
|
|
174
209
|
$zones: null, // the scrollable zones body
|
|
@@ -198,6 +233,7 @@ function mt_create(gobj)
|
|
|
198
233
|
let priv = gobj.priv;
|
|
199
234
|
|
|
200
235
|
priv.collapsed = new Set();
|
|
236
|
+
priv.expanded = new Set();
|
|
201
237
|
priv.search = "";
|
|
202
238
|
priv.machine_view = "matrix";
|
|
203
239
|
priv.model = gclass_view_model(gobj_read_attr(gobj, "description"));
|
|
@@ -511,16 +547,13 @@ function render_zones(gobj)
|
|
|
511
547
|
/*
|
|
512
548
|
* The machine takes the WHOLE width in graph mode.
|
|
513
549
|
*
|
|
514
|
-
* Half
|
|
515
|
-
* scrolls sideways inside its own box. A graph does not: it is
|
|
516
|
-
* laid out left to right, and
|
|
517
|
-
*
|
|
518
|
-
* zones then stack in one column under it, which is what they do
|
|
519
|
-
* on a phone anyway.
|
|
550
|
+
* Half the viewer is enough for a matrix, which grows downwards
|
|
551
|
+
* and scrolls sideways inside its own box. A graph does not: it is
|
|
552
|
+
* laid out left to right, and half of a viewer is where six states
|
|
553
|
+
* stop fitting and start being panned. Its pair then stacks.
|
|
520
554
|
*/
|
|
521
555
|
let graph_mode = (priv.machine_view === "graph");
|
|
522
|
-
let
|
|
523
|
-
let right = [];
|
|
556
|
+
let pair = [];
|
|
524
557
|
let full = [];
|
|
525
558
|
|
|
526
559
|
for(let zone of ZONES) {
|
|
@@ -528,26 +561,18 @@ function render_zones(gobj)
|
|
|
528
561
|
if(!$zone) {
|
|
529
562
|
continue;
|
|
530
563
|
}
|
|
531
|
-
if(zone.
|
|
532
|
-
|
|
533
|
-
full.push($zone);
|
|
534
|
-
} else {
|
|
535
|
-
right.push($zone);
|
|
536
|
-
}
|
|
564
|
+
if(zone.pair) {
|
|
565
|
+
pair.push($zone);
|
|
537
566
|
} else {
|
|
538
|
-
|
|
567
|
+
full.push($zone);
|
|
539
568
|
}
|
|
540
569
|
}
|
|
541
570
|
|
|
542
571
|
let $root = createElement2(
|
|
543
572
|
['div', {class: 'GCLASS_BODY'}, [
|
|
544
573
|
build_head(gobj, model),
|
|
545
|
-
['div', {class: '
|
|
546
|
-
['div', {class: '
|
|
547
|
-
['div', {class: 'GCLASS_COL GCLASS_COL_LEFT'}, left],
|
|
548
|
-
['div', {class: 'GCLASS_COL GCLASS_COL_RIGHT' +
|
|
549
|
-
(graph_mode? ' is-hidden': '')}, right]
|
|
550
|
-
]]
|
|
574
|
+
['div', {class: 'GCLASS_PAIR' + (graph_mode? ' is-stacked': '')}, pair],
|
|
575
|
+
['div', {class: 'GCLASS_FULL'}, full]
|
|
551
576
|
]]
|
|
552
577
|
);
|
|
553
578
|
|
|
@@ -562,8 +587,11 @@ function render_zones(gobj)
|
|
|
562
587
|
}
|
|
563
588
|
|
|
564
589
|
/************************************************************
|
|
565
|
-
* The header: what this gclass is called,
|
|
566
|
-
*
|
|
590
|
+
* The header: what this gclass is called, how many gobjs
|
|
591
|
+
* of it there are, which instance the reader came from and
|
|
592
|
+
* the state it is in -- and the methods it implements, a
|
|
593
|
+
* handful of chips that used to be a zone at the bottom of
|
|
594
|
+
* every other.
|
|
567
595
|
************************************************************/
|
|
568
596
|
function build_head(gobj, model)
|
|
569
597
|
{
|
|
@@ -576,8 +604,8 @@ function build_head(gobj, model)
|
|
|
576
604
|
items.push(
|
|
577
605
|
['span', {class: 'GCLASS_INSTANCES tag'}, [
|
|
578
606
|
['span', {class: 'GCLASS_INSTANCES_N'}, String(model.instances)],
|
|
579
|
-
['span', {class: 'GCLASS_INSTANCES_LABEL'
|
|
580
|
-
t("instances")]
|
|
607
|
+
['span', {class: 'GCLASS_INSTANCES_LABEL'},
|
|
608
|
+
t("instances", {count: model.instances})]
|
|
581
609
|
]]);
|
|
582
610
|
}
|
|
583
611
|
|
|
@@ -585,15 +613,41 @@ function build_head(gobj, model)
|
|
|
585
613
|
items.push(['span', {class: 'GCLASS_CHIP GCLASS_GCFLAG'}, text_node(flag)]);
|
|
586
614
|
}
|
|
587
615
|
|
|
616
|
+
/* A state alone belongs to no instance: the gclass has several,
|
|
617
|
+
* and the matrix lights the column of the one the reader came
|
|
618
|
+
* from. So it goes with its name. */
|
|
588
619
|
let current = gobj_read_str_attr(gobj, "current_state");
|
|
589
620
|
if(current) {
|
|
621
|
+
let instance = gobj_read_str_attr(gobj, "instance_name");
|
|
622
|
+
let parts = [];
|
|
623
|
+
if(instance) {
|
|
624
|
+
parts.push(['span', {class: 'GCLASS_CURRENT_INSTANCE'}, text_node(instance)]);
|
|
625
|
+
}
|
|
626
|
+
parts.push(['span', {class: 'GCLASS_CURRENT_STATE'}, text_node(current)]);
|
|
590
627
|
items.push(
|
|
591
628
|
['span', {class: 'GCLASS_CHIP GCLASS_CURRENT',
|
|
592
629
|
title: t("current state"),
|
|
593
|
-
'data-i18n-title': 'current state'},
|
|
630
|
+
'data-i18n-title': 'current state'}, parts]);
|
|
594
631
|
}
|
|
595
632
|
|
|
596
|
-
|
|
633
|
+
let rows = [['div', {class: 'GCLASS_HEAD_ROW'}, items]];
|
|
634
|
+
|
|
635
|
+
let methods = function(names, cls, $label) {
|
|
636
|
+
if(!names.length) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
rows.push(['div', {class: `GCLASS_HEAD_ROW ${cls}`}, [
|
|
640
|
+
$label,
|
|
641
|
+
['span', {class: 'GCLASS_CHIPS'}, names.map((m) =>
|
|
642
|
+
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), text_node(m)])]
|
|
643
|
+
]]);
|
|
644
|
+
};
|
|
645
|
+
methods(model.methods, 'GCLASS_METHODS',
|
|
646
|
+
['span', {class: 'GCLASS_HEAD_LABEL', i18n: 'methods'}, t('methods')]);
|
|
647
|
+
methods(model.internal_methods, 'GCLASS_INTERNAL_METHODS',
|
|
648
|
+
['span', {class: 'GCLASS_HEAD_LABEL', i18n: 'internal methods'}, t('internal methods')]);
|
|
649
|
+
|
|
650
|
+
return ['div', {class: 'GCLASS_HEAD'}, rows];
|
|
597
651
|
}
|
|
598
652
|
|
|
599
653
|
/************************************************************
|
|
@@ -611,31 +665,40 @@ function build_zone(gobj, zone)
|
|
|
611
665
|
|
|
612
666
|
let body = null;
|
|
613
667
|
let count = 0;
|
|
668
|
+
let more = null;
|
|
614
669
|
|
|
615
670
|
switch(zone.id) {
|
|
616
671
|
case "attrs":
|
|
617
672
|
count = model.attrs.length;
|
|
618
673
|
body = build_attrs(model.attrs);
|
|
674
|
+
more = show_all_button(gobj, zone.id, count);
|
|
619
675
|
break;
|
|
620
676
|
case "commands":
|
|
621
677
|
count = model.commands.filter((c) => c.kind === "command").length;
|
|
622
678
|
body = build_commands(model.commands);
|
|
679
|
+
more = show_all_button(gobj, zone.id, count);
|
|
623
680
|
break;
|
|
624
|
-
case "
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
681
|
+
case "traces": {
|
|
682
|
+
let traces = gobj_read_attr(gobj, "traces");
|
|
683
|
+
if(traces && typeof traces === "object") {
|
|
684
|
+
let built = build_trace_toggles(gobj, model, traces);
|
|
685
|
+
count = built.count;
|
|
686
|
+
body = built.body;
|
|
687
|
+
} else {
|
|
688
|
+
count = model.trace_levels.length;
|
|
689
|
+
body = build_traces(model.trace_levels);
|
|
690
|
+
}
|
|
631
691
|
break;
|
|
692
|
+
}
|
|
632
693
|
case "machine":
|
|
633
694
|
/* Two numbers, because one of them alone says nothing
|
|
634
695
|
* about the shape: 13 events across 1 state and 13
|
|
635
|
-
* across 6 are different machines
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
model.fsm.
|
|
696
|
+
* across 6 are different machines -- and each says what
|
|
697
|
+
* it counts, which "1 · 2" did not. */
|
|
698
|
+
count = model.fsm.states.length?
|
|
699
|
+
`${t("machine states", {count: model.fsm.states.length})} · ` +
|
|
700
|
+
`${t("machine events", {count: model.fsm.rows.length})}`:
|
|
701
|
+
t("machine events", {count: model.fsm.rows.length});
|
|
639
702
|
body = build_machine(gobj, model.fsm);
|
|
640
703
|
break;
|
|
641
704
|
default:
|
|
@@ -668,10 +731,32 @@ function build_zone(gobj, zone)
|
|
|
668
731
|
'data-zone': zone.id}, [
|
|
669
732
|
$toggle,
|
|
670
733
|
['div', {class: 'GCLASS_ZONE_BODY' + (collapsed? ' is-hidden': '')},
|
|
671
|
-
[body]]
|
|
734
|
+
more? [body, more]: [body]]
|
|
672
735
|
]]);
|
|
673
736
|
}
|
|
674
737
|
|
|
738
|
+
/************************************************************
|
|
739
|
+
* The button under a long table: the entries past ROWS_CAP
|
|
740
|
+
* are drawn and hidden (apply_search() decides), so showing
|
|
741
|
+
* them is a class, not a rebuild. Null when there are none.
|
|
742
|
+
************************************************************/
|
|
743
|
+
function show_all_button(gobj, zone_id, count)
|
|
744
|
+
{
|
|
745
|
+
if(count <= ROWS_CAP || gobj.priv.expanded.has(zone_id)) {
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
return ['button', {class: 'GCLASS_SHOW_ALL button is-small', type: 'button',
|
|
749
|
+
'data-zone': zone_id,
|
|
750
|
+
title: t("show all {{n}}", {n: count}),
|
|
751
|
+
'aria-label': t("show all {{n}}", {n: count})},
|
|
752
|
+
t("show all {{n}}", {n: count}), {
|
|
753
|
+
click: function(evt) {
|
|
754
|
+
evt.stopPropagation();
|
|
755
|
+
gobj_send_event(gobj, "EV_SHOW_ALL", {zone: zone_id}, gobj);
|
|
756
|
+
}
|
|
757
|
+
}];
|
|
758
|
+
}
|
|
759
|
+
|
|
675
760
|
/************************************************************
|
|
676
761
|
* An "empty zone" line. It says WHY it is empty, which is
|
|
677
762
|
* never the same as saying nothing.
|
|
@@ -737,8 +822,9 @@ function build_attrs(attrs)
|
|
|
737
822
|
return empty_line("no attributes declared");
|
|
738
823
|
}
|
|
739
824
|
|
|
740
|
-
let rows = attrs.map(function(a) {
|
|
741
|
-
return ['tr', row_attrs(`${a.id} ${a.type} ${a.flags.join(" ")} ${a.description}
|
|
825
|
+
let rows = attrs.map(function(a, i) {
|
|
826
|
+
return ['tr', row_attrs(`${a.id} ${a.type} ${a.flags.join(" ")} ${a.description}`,
|
|
827
|
+
capped_attrs(i)), [
|
|
742
828
|
['td', {class: 'GCLASS_CELL_KEY'}, text_node(a.id)],
|
|
743
829
|
['td', {class: 'GCLASS_CELL_TYPE'}, text_node(a.type)],
|
|
744
830
|
['td', {class: 'GCLASS_CELL_FLAGS'}, flag_chips(a.flags)],
|
|
@@ -778,9 +864,17 @@ function build_commands(commands)
|
|
|
778
864
|
}
|
|
779
865
|
|
|
780
866
|
let rows = [];
|
|
867
|
+
let n = 0;
|
|
781
868
|
for(let c of commands) {
|
|
869
|
+
if(c.kind === "command") {
|
|
870
|
+
n++;
|
|
871
|
+
}
|
|
872
|
+
/* The cap counts COMMANDS: a section heading or a parameter
|
|
873
|
+
* past it goes with the command it belongs to. */
|
|
874
|
+
let capped = capped_attrs((c.kind === "command")? n - 1: n);
|
|
782
875
|
if(c.kind === "section") {
|
|
783
|
-
rows.push(['tr', row_attrs(c.label,
|
|
876
|
+
rows.push(['tr', row_attrs(c.label, Object.assign(
|
|
877
|
+
{class: 'GCLASS_ROW GCLASS_CMD_SECTION'}, capped)), [
|
|
784
878
|
['td', {colspan: '2'}, text_node(c.label)]
|
|
785
879
|
]]);
|
|
786
880
|
continue;
|
|
@@ -792,14 +886,14 @@ function build_commands(commands)
|
|
|
792
886
|
}
|
|
793
887
|
name_items = name_items.concat(flag_chips(c.flags));
|
|
794
888
|
|
|
795
|
-
rows.push(['tr', row_attrs(`${c.id} ${c.alias.join(" ")} ${c.description}
|
|
889
|
+
rows.push(['tr', row_attrs(`${c.id} ${c.alias.join(" ")} ${c.description}`, capped), [
|
|
796
890
|
['td', {class: 'GCLASS_CELL_KEY'}, name_items],
|
|
797
891
|
['td', {class: 'GCLASS_CELL_DESC'}, text_node(c.description)]
|
|
798
892
|
]]);
|
|
799
893
|
|
|
800
894
|
for(let p of c.parameters) {
|
|
801
895
|
rows.push(['tr', row_attrs(`${c.id} ${p.id} ${p.description}`,
|
|
802
|
-
{class: 'GCLASS_ROW GCLASS_CMD_PARAM'}), [
|
|
896
|
+
Object.assign({class: 'GCLASS_ROW GCLASS_CMD_PARAM'}, capped)), [
|
|
803
897
|
['td', {class: 'GCLASS_CELL_KEY'}, [
|
|
804
898
|
['span', {class: 'GCLASS_PARAM_MARK'}, "↳"],
|
|
805
899
|
['span', {class: 'GCLASS_PARAM_NAME'}, text_node(p.id)],
|
|
@@ -815,34 +909,11 @@ function build_commands(commands)
|
|
|
815
909
|
]]);
|
|
816
910
|
}
|
|
817
911
|
|
|
818
|
-
|
|
819
|
-
*
|
|
820
|
-
|
|
821
|
-
* A table of every possible method, mostly empty, tells the
|
|
822
|
-
* reader nothing -- so both sides send only what is wired,
|
|
823
|
-
* and this draws them as chips.
|
|
824
|
-
************************************************************/
|
|
825
|
-
function build_methods(model)
|
|
912
|
+
/* The extra attrs of the `i`-th entry of a long table: past the cap
|
|
913
|
+
* it is marked, and apply_search() hides it until the reader asks. */
|
|
914
|
+
function capped_attrs(i)
|
|
826
915
|
{
|
|
827
|
-
|
|
828
|
-
return empty_line("no methods declared");
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
let blocks = [];
|
|
832
|
-
if(model.methods.length) {
|
|
833
|
-
blocks.push(['div', {class: 'GCLASS_CHIPS'},
|
|
834
|
-
model.methods.map((m) =>
|
|
835
|
-
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), text_node(m)])]);
|
|
836
|
-
}
|
|
837
|
-
if(model.internal_methods.length) {
|
|
838
|
-
blocks.push(['div', {class: 'GCLASS_SUBTITLE', i18n: 'internal methods'},
|
|
839
|
-
t("internal methods")]);
|
|
840
|
-
blocks.push(['div', {class: 'GCLASS_CHIPS'},
|
|
841
|
-
model.internal_methods.map((m) =>
|
|
842
|
-
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), text_node(m)])]);
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
return ['div', {class: 'GCLASS_METHODS'}, blocks];
|
|
916
|
+
return (i >= ROWS_CAP)? {'data-capped': '1'}: {};
|
|
846
917
|
}
|
|
847
918
|
|
|
848
919
|
/************************************************************
|
|
@@ -866,6 +937,111 @@ function build_traces(levels)
|
|
|
866
937
|
]]);
|
|
867
938
|
}
|
|
868
939
|
|
|
940
|
+
/************************************************************
|
|
941
|
+
* The trace levels zone of a gclass whose host can SET its
|
|
942
|
+
* traces: every gobj of it at once (`set-gclass-trace`),
|
|
943
|
+
* one box per level -- its own, then the kernel's, which
|
|
944
|
+
* every gclass can trace on its own (the machine of C_TCP
|
|
945
|
+
* alone). A level the whole yuno traces shows on and locked,
|
|
946
|
+
* because unticking the gclass would not stop it; the yuno's
|
|
947
|
+
* scope is set from the gobj tree, not from here.
|
|
948
|
+
*
|
|
949
|
+
* A box is an action: the change goes to the FSM, which
|
|
950
|
+
* tells the host, and the zone stays locked until the host
|
|
951
|
+
* hands back what the backend says now (EV_SET_TRACES).
|
|
952
|
+
*
|
|
953
|
+
* Returns {body, count}.
|
|
954
|
+
************************************************************/
|
|
955
|
+
function build_trace_toggles(gobj, model, traces)
|
|
956
|
+
{
|
|
957
|
+
let info = traces.info;
|
|
958
|
+
if(!info) {
|
|
959
|
+
return {body: empty_line("loading"), count: 0};
|
|
960
|
+
}
|
|
961
|
+
if(info.error) {
|
|
962
|
+
return {body: ['div', {class: 'GCLASS_ZONE_EMPTY GCLASS_TRACES_ERROR'},
|
|
963
|
+
text_node(info.error)], count: 0};
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
let gclass = model.id || gobj_read_str_attr(gobj, "gclass_name");
|
|
967
|
+
let rows = trace_rows({gobj_trace_level: []}, info);
|
|
968
|
+
let pending = !!traces.pending;
|
|
969
|
+
|
|
970
|
+
let trs = [];
|
|
971
|
+
let group = "";
|
|
972
|
+
for(let r of rows) {
|
|
973
|
+
if(r.group !== group) {
|
|
974
|
+
group = r.group;
|
|
975
|
+
trs.push(['tr', {class: 'GCLASS_TRACE_GROUP'}, [
|
|
976
|
+
['td', {colspan: '3'}, (group === "gclass")?
|
|
977
|
+
[text_node(gclass)]:
|
|
978
|
+
[['span', {i18n: 'kernel levels'}, t('kernel levels')]]]
|
|
979
|
+
]]);
|
|
980
|
+
}
|
|
981
|
+
let $cb = createElement2(['input', {
|
|
982
|
+
type: 'checkbox', class: 'GCLASS_TRACE_GCLASS',
|
|
983
|
+
title: t('all of the gclass'), 'data-i18n-title': 'all of the gclass',
|
|
984
|
+
'aria-label': t('all of the gclass'), 'data-i18n-aria-label': 'all of the gclass',
|
|
985
|
+
}]);
|
|
986
|
+
/* Properties, not attributes: an attribute `checked="false"`
|
|
987
|
+
* is a checked box. */
|
|
988
|
+
$cb.setAttribute('data-level', r.level);
|
|
989
|
+
$cb.checked = !!r.gclass_on;
|
|
990
|
+
$cb.disabled = pending || !!r.gclass_locked;
|
|
991
|
+
$cb.addEventListener('change', function(evt) {
|
|
992
|
+
evt.stopPropagation();
|
|
993
|
+
gobj_send_event(gobj, "EV_GCLASS_TRACE_TOGGLED",
|
|
994
|
+
{level: r.level, set: !!evt.target.checked}, gobj);
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
let key_cell = [text_node(r.level)];
|
|
998
|
+
if(r.gclass_locked) {
|
|
999
|
+
key_cell.push(['span', {class: 'GCLASS_TRACE_ORIGIN', i18n: 'yuno',
|
|
1000
|
+
title: t('on for the whole yuno'),
|
|
1001
|
+
'data-i18n-title': 'on for the whole yuno'}, t('yuno')]);
|
|
1002
|
+
}
|
|
1003
|
+
trs.push(['tr', row_attrs(`${r.level} ${r.description}`), [
|
|
1004
|
+
['td', {class: 'GCLASS_CELL_KEY'}, key_cell],
|
|
1005
|
+
['td', {class: 'GCLASS_CELL_DESC'}, text_node(r.description)],
|
|
1006
|
+
['td', {class: 'GCLASS_CELL_BOX'}, [$cb]]
|
|
1007
|
+
]]);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
let none = pending || own_trace_levels(rows, "gclass").length === 0;
|
|
1011
|
+
let $clear = createElement2(['button', {
|
|
1012
|
+
type: 'button', class: 'GCLASS_TRACES_CLEAR button is-small',
|
|
1013
|
+
i18n: 'remove the traces of the gclass',
|
|
1014
|
+
title: t('remove the traces of the gclass'),
|
|
1015
|
+
'data-i18n-title': 'remove the traces of the gclass',
|
|
1016
|
+
'aria-label': t('remove the traces of the gclass'),
|
|
1017
|
+
'data-i18n-aria-label': 'remove the traces of the gclass',
|
|
1018
|
+
}, t('remove the traces of the gclass'), {
|
|
1019
|
+
click: function(evt) {
|
|
1020
|
+
evt.stopPropagation();
|
|
1021
|
+
gobj_send_event(gobj, "EV_GCLASS_TRACES_CLEARED", {}, gobj);
|
|
1022
|
+
}
|
|
1023
|
+
}]);
|
|
1024
|
+
$clear.disabled = none;
|
|
1025
|
+
|
|
1026
|
+
return {count: rows.length, body: ['div', {class: 'GCLASS_TRACE_TOGGLES'}, [
|
|
1027
|
+
scroller(['table', {class: 'GCLASS_TABLE GCLASS_TABLE_TRACES'}, [
|
|
1028
|
+
['thead', {}, [
|
|
1029
|
+
['tr', {}, [
|
|
1030
|
+
['th', {i18n: 'level'}, t("level")],
|
|
1031
|
+
['th', {i18n: 'description'}, t("description")],
|
|
1032
|
+
['th', {class: 'GCLASS_CELL_BOX', i18n: 'all of the gclass'},
|
|
1033
|
+
t("all of the gclass")]
|
|
1034
|
+
]]
|
|
1035
|
+
]],
|
|
1036
|
+
['tbody', {}, trs]
|
|
1037
|
+
]]),
|
|
1038
|
+
['div', {class: 'GCLASS_TRACES_NOTE',
|
|
1039
|
+
i18n: 'gclass traces survive a restart, gobj traces end with the yuno'},
|
|
1040
|
+
t('gclass traces survive a restart, gobj traces end with the yuno')],
|
|
1041
|
+
['div', {class: 'GCLASS_TRACES_TOOLS'}, [$clear]]
|
|
1042
|
+
]]};
|
|
1043
|
+
}
|
|
1044
|
+
|
|
869
1045
|
/************************************************************
|
|
870
1046
|
* The machine: the matrix, then what it publishes.
|
|
871
1047
|
************************************************************/
|
|
@@ -975,15 +1151,20 @@ function build_machine(gobj, fsm)
|
|
|
975
1151
|
|
|
976
1152
|
blocks.push(build_legend(fsm, current));
|
|
977
1153
|
|
|
1154
|
+
/* One event a row, its flags after it in their own quiet type:
|
|
1155
|
+
* as a line of chips, OUTPUT_EVENT and PUBLIC_EVENT read as two
|
|
1156
|
+
* more events. */
|
|
978
1157
|
if(fsm.published.length) {
|
|
979
1158
|
blocks.push(['div', {class: 'GCLASS_SUBTITLE', i18n: 'publishes'},
|
|
980
1159
|
t("publishes")]);
|
|
981
|
-
blocks.push(['
|
|
982
|
-
fsm.published.map(function(p) {
|
|
983
|
-
return ['
|
|
984
|
-
['
|
|
985
|
-
|
|
986
|
-
|
|
1160
|
+
blocks.push(['table', {class: 'GCLASS_TABLE GCLASS_PUBLISHED'}, [
|
|
1161
|
+
['tbody', {}, fsm.published.map(function(p) {
|
|
1162
|
+
return ['tr', row_attrs(p.event, {class: 'GCLASS_ROW GCLASS_PUB_ROW'}), [
|
|
1163
|
+
['td', {class: 'GCLASS_CELL_KEY GCLASS_PUB_EVENT'}, text_node(p.event)],
|
|
1164
|
+
['td', {class: 'GCLASS_PUB_FLAGS'}, event_flag_chips(p.flags)]
|
|
1165
|
+
]];
|
|
1166
|
+
})]
|
|
1167
|
+
]]);
|
|
987
1168
|
}
|
|
988
1169
|
|
|
989
1170
|
return ['div', {class: 'GCLASS_MACHINE'}, blocks];
|
|
@@ -1033,13 +1214,28 @@ function build_legend(fsm, current)
|
|
|
1033
1214
|
{
|
|
1034
1215
|
let items = [];
|
|
1035
1216
|
|
|
1036
|
-
|
|
1037
|
-
['
|
|
1038
|
-
|
|
1039
|
-
|
|
1217
|
+
if(fsm.rows.some((row) => row.cells.some((cell) => !cell))) {
|
|
1218
|
+
items.push(['span', {class: 'GCLASS_LEGEND_ITEM'}, [
|
|
1219
|
+
['i', {class: 'GCLASS_LEGEND_SWATCH is-none'}],
|
|
1220
|
+
['span', {i18n: 'not declared in this state'}, t("not declared in this state")]
|
|
1221
|
+
]]);
|
|
1222
|
+
}
|
|
1040
1223
|
|
|
1041
1224
|
/* Only if there is one on screen: a legend for a mark nobody drew
|
|
1042
1225
|
* is noise, and most gclasses declare no actionless event. */
|
|
1226
|
+
/* The mark of an action the backend does not name: every action
|
|
1227
|
+
* of a C gclass is one (`states2json()` cannot name them). */
|
|
1228
|
+
let has_unnamed = fsm.rows.some(
|
|
1229
|
+
(row) => row.cells.some((cell) => cell && cell.has_action && !cell.action)
|
|
1230
|
+
);
|
|
1231
|
+
if(has_unnamed) {
|
|
1232
|
+
items.push(['span', {class: 'GCLASS_LEGEND_ITEM'}, [
|
|
1233
|
+
['i', {class: 'GCLASS_LEGEND_SWATCH is-unnamed'}, "●"],
|
|
1234
|
+
['span', {i18n: 'action, its name not given by the backend'},
|
|
1235
|
+
t("action, its name not given by the backend")]
|
|
1236
|
+
]]);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1043
1239
|
let has_actionless = fsm.rows.some(
|
|
1044
1240
|
(row) => row.cells.some((cell) => cell && !cell.has_action)
|
|
1045
1241
|
);
|
|
@@ -1208,15 +1404,25 @@ function apply_search(gobj)
|
|
|
1208
1404
|
$zones.querySelectorAll('.GCLASS_ZONE').forEach(function($zone) {
|
|
1209
1405
|
let $rows = $zone.querySelectorAll('[data-find]');
|
|
1210
1406
|
let visible = 0;
|
|
1407
|
+
let all = priv.expanded.has($zone.getAttribute('data-zone'));
|
|
1211
1408
|
|
|
1409
|
+
/* A search shows every match, capped or not: the cap is for
|
|
1410
|
+
* READING a long table, and a reader who typed a name is not. */
|
|
1212
1411
|
$rows.forEach(function($row) {
|
|
1213
|
-
let hit =
|
|
1412
|
+
let hit = term?
|
|
1413
|
+
$row.getAttribute('data-find').indexOf(term) >= 0:
|
|
1414
|
+
(all || !$row.hasAttribute('data-capped'));
|
|
1214
1415
|
$row.classList.toggle('is-hidden', !hit);
|
|
1215
1416
|
if(hit) {
|
|
1216
1417
|
visible++;
|
|
1217
1418
|
}
|
|
1218
1419
|
});
|
|
1219
1420
|
|
|
1421
|
+
let $more = $zone.querySelector('.GCLASS_SHOW_ALL');
|
|
1422
|
+
if($more) {
|
|
1423
|
+
$more.classList.toggle('is-hidden', !!term || all);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1220
1426
|
/* A zone whose every row is filtered out reads as broken
|
|
1221
1427
|
* unless it says what happened. */
|
|
1222
1428
|
let $none = $zone.querySelector('.GCLASS_ZONE_NO_MATCH');
|
|
@@ -1407,6 +1613,108 @@ function ac_copy_all(gobj, event, kw, src)
|
|
|
1407
1613
|
return 0;
|
|
1408
1614
|
}
|
|
1409
1615
|
|
|
1616
|
+
/************************************************************
|
|
1617
|
+
* EV_SHOW_ALL {zone} -- the rows of a long table past the cap.
|
|
1618
|
+
************************************************************/
|
|
1619
|
+
function ac_show_all(gobj, event, kw, src)
|
|
1620
|
+
{
|
|
1621
|
+
let priv = gobj.priv;
|
|
1622
|
+
if(!ZONES.some((z) => z.id === kw.zone)) {
|
|
1623
|
+
log_error(`${GCLASS_NAME}: show all of no zone '${kw.zone}'`);
|
|
1624
|
+
return -1;
|
|
1625
|
+
}
|
|
1626
|
+
priv.expanded.add(kw.zone);
|
|
1627
|
+
apply_search(gobj);
|
|
1628
|
+
return 0;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
/************************************************************
|
|
1632
|
+
* EV_SET_TRACES {info, pending} -- the host, with what the
|
|
1633
|
+
* backend says the gclass traces now.
|
|
1634
|
+
************************************************************/
|
|
1635
|
+
function ac_set_traces(gobj, event, kw, src)
|
|
1636
|
+
{
|
|
1637
|
+
gobj_write_attr(gobj, "traces", {
|
|
1638
|
+
info: (kw && kw.info && typeof kw.info === "object")? json_deep_copy(kw.info): null,
|
|
1639
|
+
pending: !!(kw && kw.pending),
|
|
1640
|
+
});
|
|
1641
|
+
refresh_zone(gobj, "traces");
|
|
1642
|
+
return 0;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/************************************************************
|
|
1646
|
+
* A box of the trace levels zone: {level, set}.
|
|
1647
|
+
************************************************************/
|
|
1648
|
+
function ac_gclass_trace_toggled(gobj, event, kw, src)
|
|
1649
|
+
{
|
|
1650
|
+
if(!kw || !kw.level) {
|
|
1651
|
+
log_error(`${GCLASS_NAME}: a gclass trace set of no level`);
|
|
1652
|
+
return -1;
|
|
1653
|
+
}
|
|
1654
|
+
return ask_gclass_trace(gobj, [kw.level], !!kw.set);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/************************************************************
|
|
1658
|
+
* "Remove the traces of the gclass": every level it holds
|
|
1659
|
+
* on its own (not the yuno's, which it cannot let go).
|
|
1660
|
+
************************************************************/
|
|
1661
|
+
function ac_gclass_traces_cleared(gobj, event, kw, src)
|
|
1662
|
+
{
|
|
1663
|
+
let traces = gobj_read_attr(gobj, "traces");
|
|
1664
|
+
let info = traces && traces.info;
|
|
1665
|
+
let levels = own_trace_levels(trace_rows({gobj_trace_level: []}, info), "gclass");
|
|
1666
|
+
if(!levels.length) {
|
|
1667
|
+
/* The button is off when there is nothing: reaching here is a
|
|
1668
|
+
* button that did not follow the zone. */
|
|
1669
|
+
log_error(`${GCLASS_NAME}: no gclass trace to remove`);
|
|
1670
|
+
return -1;
|
|
1671
|
+
}
|
|
1672
|
+
return ask_gclass_trace(gobj, levels, false);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/* Lock the zone and tell the host. It is repainted from what the
|
|
1676
|
+
* backend says next (EV_SET_TRACES), never from the click. */
|
|
1677
|
+
function ask_gclass_trace(gobj, levels, set)
|
|
1678
|
+
{
|
|
1679
|
+
let priv = gobj.priv;
|
|
1680
|
+
let traces = gobj_read_attr(gobj, "traces");
|
|
1681
|
+
if(!traces || typeof traces !== "object") {
|
|
1682
|
+
log_error(`${GCLASS_NAME}: a gclass trace set, and no host that can set it`);
|
|
1683
|
+
return -1;
|
|
1684
|
+
}
|
|
1685
|
+
gobj_write_attr(gobj, "traces", {info: traces.info || null, pending: true});
|
|
1686
|
+
refresh_zone(gobj, "traces");
|
|
1687
|
+
gobj_publish_event(gobj, "EV_SET_GCLASS_TRACE", {
|
|
1688
|
+
gclass: (priv.model && priv.model.id) || gobj_read_str_attr(gobj, "gclass_name"),
|
|
1689
|
+
levels: levels,
|
|
1690
|
+
set: set,
|
|
1691
|
+
});
|
|
1692
|
+
return 0;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
/************************************************************
|
|
1696
|
+
* Draw ONE zone again, in place. The others stay as they
|
|
1697
|
+
* are: the machine's graph keeps its camera, and a table
|
|
1698
|
+
* keeps its scroll.
|
|
1699
|
+
************************************************************/
|
|
1700
|
+
function refresh_zone(gobj, zone_id)
|
|
1701
|
+
{
|
|
1702
|
+
let priv = gobj.priv;
|
|
1703
|
+
const zone = ZONES.find((z) => z.id === zone_id);
|
|
1704
|
+
let $old = priv.$zones?
|
|
1705
|
+
priv.$zones.querySelector(`.GCLASS_ZONE[data-zone="${zone_id}"]`): null;
|
|
1706
|
+
if(!zone || !$old || !priv.model) {
|
|
1707
|
+
return; /* not drawn (raw view, no description): drawn on the next render */
|
|
1708
|
+
}
|
|
1709
|
+
let $new = build_zone(gobj, /* i18n: C_YUI_GCLASS_I18N_KEYS */ zone);
|
|
1710
|
+
if(!$new) {
|
|
1711
|
+
return; // Error already logged
|
|
1712
|
+
}
|
|
1713
|
+
$old.replaceWith($new);
|
|
1714
|
+
refresh_language($new, t);
|
|
1715
|
+
apply_search(gobj);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1410
1718
|
/************************************************************
|
|
1411
1719
|
* EV_LANGUAGE_CHANGED -- re-translate chrome + re-render
|
|
1412
1720
|
*
|
|
@@ -1506,7 +1814,11 @@ function create_gclass(gclass_name)
|
|
|
1506
1814
|
["EV_LANGUAGE_CHANGED", ac_language_changed, null],
|
|
1507
1815
|
["EV_REFRESH", ac_refresh, null],
|
|
1508
1816
|
["EV_SHOW", ac_show, null],
|
|
1509
|
-
["EV_HIDE", ac_hide, null]
|
|
1817
|
+
["EV_HIDE", ac_hide, null],
|
|
1818
|
+
["EV_SHOW_ALL", ac_show_all, null],
|
|
1819
|
+
["EV_SET_TRACES", ac_set_traces, null],
|
|
1820
|
+
["EV_GCLASS_TRACE_TOGGLED", ac_gclass_trace_toggled, null],
|
|
1821
|
+
["EV_GCLASS_TRACES_CLEARED", ac_gclass_traces_cleared, null]
|
|
1510
1822
|
]]
|
|
1511
1823
|
];
|
|
1512
1824
|
|
|
@@ -1523,7 +1835,14 @@ function create_gclass(gclass_name)
|
|
|
1523
1835
|
["EV_LANGUAGE_CHANGED", 0],
|
|
1524
1836
|
["EV_REFRESH", 0],
|
|
1525
1837
|
["EV_SHOW", 0],
|
|
1526
|
-
["EV_HIDE", 0]
|
|
1838
|
+
["EV_HIDE", 0],
|
|
1839
|
+
["EV_SHOW_ALL", 0],
|
|
1840
|
+
["EV_SET_TRACES", 0],
|
|
1841
|
+
["EV_GCLASS_TRACE_TOGGLED", 0],
|
|
1842
|
+
["EV_GCLASS_TRACES_CLEARED", 0],
|
|
1843
|
+
/* Only when the host handed `traces`: it is the one that can
|
|
1844
|
+
* set them, and it declares this event (the gobj tree). */
|
|
1845
|
+
["EV_SET_GCLASS_TRACE", event_flag_t.EVF_OUTPUT_EVENT]
|
|
1527
1846
|
];
|
|
1528
1847
|
|
|
1529
1848
|
__gclass__ = gclass_create(
|