@yuneta/gobj-ui 7.27.24 → 7.27.26
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 +10 -2
- package/dist/gobj-ui.cjs.js +34665 -34515
- package/dist/gobj-ui.es.js +34538 -34388
- package/package.json +4 -4
- package/src/c_g6_nodes_tree.js +36 -96
- package/src/c_yui_gobj_tree_js.js +95 -1
- package/src/gobj_tree_camera.wiring.test.js +50 -4
- package/src/gobj_tree_model.js +42 -7
- package/src/gobj_tree_model.test.js +34 -0
- package/src/yui_graph_minimap.js +128 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.27.
|
|
3
|
+
"version": "7.27.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/gobj-ui.cjs.js",
|
|
6
6
|
"module": "dist/gobj-ui.es.js",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@rollup/plugin-terser": "^1.0.0",
|
|
45
|
-
"@vitest/coverage-v8": "^
|
|
46
|
-
"@yuneta/gobj-js": "^7.
|
|
45
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
46
|
+
"@yuneta/gobj-js": "^7.27.0",
|
|
47
47
|
"vite": "^8.3.4",
|
|
48
|
-
"vitest": "^
|
|
48
|
+
"vitest": "^5.0.5"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@antv/g6": "^5.1.0",
|
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -159,7 +159,7 @@ import {
|
|
|
159
159
|
Polyline,
|
|
160
160
|
} from '@antv/g6';
|
|
161
161
|
|
|
162
|
-
import {Circle as CircleGeometry
|
|
162
|
+
import {Circle as CircleGeometry} from '@antv/g';
|
|
163
163
|
import {t} from "i18next";
|
|
164
164
|
|
|
165
165
|
import {inject_svg_icons} from "./lib_icons.js";
|
|
@@ -179,6 +179,11 @@ import {yui_shell_show_error} from "./shell_modals.js";
|
|
|
179
179
|
import {g6_event_kw} from "./g6_event_kw.js";
|
|
180
180
|
import {css_color_or_null} from "./yui_data_color.js";
|
|
181
181
|
import {keep_canvas_tab_order} from "./g6_canvas_tab_order.js";
|
|
182
|
+
import {
|
|
183
|
+
yui_graph_minimap_options,
|
|
184
|
+
yui_graph_minimap_block,
|
|
185
|
+
yui_graph_minimap_repaint,
|
|
186
|
+
} from "./yui_graph_minimap.js";
|
|
182
187
|
|
|
183
188
|
/***************************************************************
|
|
184
189
|
* The markup of one toolbar item. Everything that goes into it is
|
|
@@ -8051,13 +8056,8 @@ function auto_layout(gobj)
|
|
|
8051
8056
|
************************************************************/
|
|
8052
8057
|
function repaint_minimap(gobj)
|
|
8053
8058
|
{
|
|
8054
|
-
let plugin = graph_get_plugin(gobj, "minimap");
|
|
8055
|
-
if(!plugin || plugin.destroyed) {
|
|
8056
|
-
return;
|
|
8057
|
-
}
|
|
8058
8059
|
try {
|
|
8059
|
-
|
|
8060
|
-
plugin.renderMask();
|
|
8060
|
+
yui_graph_minimap_repaint(graph_get_plugin(gobj, "minimap"));
|
|
8061
8061
|
} catch(e) {
|
|
8062
8062
|
log_error(`${gobj_short_name(gobj)}: repaint_minimap failed: ${e}`);
|
|
8063
8063
|
}
|
|
@@ -8107,97 +8107,37 @@ function refresh_minimap(gobj)
|
|
|
8107
8107
|
graph_add_plugin(
|
|
8108
8108
|
gobj,
|
|
8109
8109
|
"minimap",
|
|
8110
|
-
{
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
containerStyle: {
|
|
8135
|
-
top: "auto",
|
|
8136
|
-
bottom: "12px",
|
|
8137
|
-
left: "12px",
|
|
8138
|
-
background: "var(--bulma-scheme-main, #fff)",
|
|
8139
|
-
/* A mid grey and not a `--bulma-border-*` token: those
|
|
8140
|
-
* are made for a line INSIDE a surface, and this one has
|
|
8141
|
-
* to separate a floating panel from the CANVAS behind
|
|
8142
|
-
* it -- which is near-black in one scheme and white in
|
|
8143
|
-
* the other. `border-weak` was 1.43:1 over the dark
|
|
8144
|
-
* canvas and 1.18 over the light one; every border token
|
|
8145
|
-
* fails at least one of them. This one is 4.6 on both.
|
|
8146
|
-
* (The box-shadow below separates it only where there
|
|
8147
|
-
* is light to cast a shadow on.) */
|
|
8148
|
-
border: "1px solid var(--bulma-text-weak, #94a3b8)",
|
|
8149
|
-
borderRadius: "6px",
|
|
8150
|
-
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
8151
|
-
},
|
|
8152
|
-
/* The viewport rectangle: G6 washes it in black, which is
|
|
8153
|
-
* invisible over a dark minimap. A link-coloured outline
|
|
8154
|
-
* reads on both. */
|
|
8155
|
-
maskStyle: {
|
|
8156
|
-
border: "2px solid var(--bulma-link-on-scheme, var(--bulma-link, #3b82f6))",
|
|
8157
|
-
background: "rgba(59, 130, 246, 0.12)",
|
|
8158
|
-
},
|
|
8159
|
-
shape: (id, element_type, element) => {
|
|
8160
|
-
if(element_type !== "node") {
|
|
8161
|
-
return element; /* edges clone themselves fine */
|
|
8162
|
-
}
|
|
8163
|
-
try {
|
|
8164
|
-
let nd = graph.getNodeData(id);
|
|
8165
|
-
let size = (nd && nd.style && nd.style.size) || [120, 60];
|
|
8166
|
-
/* The topic's colour PUSHED TOWARDS THE SURFACE, the
|
|
8167
|
-
* same treatment a port's rim takes: a block here is
|
|
8168
|
-
* the topic colour on the panel's own background, and
|
|
8169
|
-
* on the light scheme the palette's yellow was 1.61:1
|
|
8170
|
-
* on white -- a minimap whose content could not be
|
|
8171
|
-
* told from its paper. 3.80 in light, 9.11 in dark. */
|
|
8172
|
-
let color = port_rim(
|
|
8173
|
-
(nd && nd.data && nd.data.desc && nd.data.desc.color) || "#94a3b8",
|
|
8174
|
-
priv.theme
|
|
8175
|
-
);
|
|
8176
|
-
if(is_more_node(nd)) {
|
|
8177
|
-
/* A `+N` chip is a cut, not a card: quieter than a
|
|
8178
|
-
* block, and still visible. The slate had to become
|
|
8179
|
-
* a DARK slate on a white panel -- raising the alpha
|
|
8180
|
-
* of the light one only ever reached 1.86. */
|
|
8181
|
-
color = (priv.theme === "dark")
|
|
8182
|
-
? "rgba(148, 163, 184, 0.60)" /* 3.35:1 */
|
|
8183
|
-
: "rgba(71, 85, 105, 0.65)"; /* 3.19:1 */
|
|
8184
|
-
}
|
|
8185
|
-
return new RectGeometry({
|
|
8186
|
-
style: {
|
|
8187
|
-
x: -size[0] / 2,
|
|
8188
|
-
y: -size[1] / 2,
|
|
8189
|
-
width: size[0],
|
|
8190
|
-
height: size[1],
|
|
8191
|
-
fill: color,
|
|
8192
|
-
radius: 4
|
|
8193
|
-
}
|
|
8194
|
-
});
|
|
8195
|
-
} catch(e) {
|
|
8196
|
-
log_error(`${gobj_short_name(gobj)}: minimap shape failed: ${e}`);
|
|
8197
|
-
return element;
|
|
8110
|
+
yui_graph_minimap_options((id, element_type, element) => {
|
|
8111
|
+
if(element_type !== "node") {
|
|
8112
|
+
return element; /* edges clone themselves fine */
|
|
8113
|
+
}
|
|
8114
|
+
try {
|
|
8115
|
+
let nd = graph.getNodeData(id);
|
|
8116
|
+
/* The topic's colour PUSHED TOWARDS THE SURFACE, the
|
|
8117
|
+
* same treatment a port's rim takes: a block here is
|
|
8118
|
+
* the topic colour on the panel's own background, and
|
|
8119
|
+
* on the light scheme the palette's yellow was 1.61:1
|
|
8120
|
+
* on white -- a minimap whose content could not be
|
|
8121
|
+
* told from its paper. 3.80 in light, 9.11 in dark. */
|
|
8122
|
+
let color = port_rim(
|
|
8123
|
+
(nd && nd.data && nd.data.desc && nd.data.desc.color) || "#94a3b8",
|
|
8124
|
+
priv.theme
|
|
8125
|
+
);
|
|
8126
|
+
if(is_more_node(nd)) {
|
|
8127
|
+
/* A `+N` chip is a cut, not a card: quieter than a
|
|
8128
|
+
* block, and still visible. The slate had to become
|
|
8129
|
+
* a DARK slate on a white panel -- raising the alpha
|
|
8130
|
+
* of the light one only ever reached 1.86. */
|
|
8131
|
+
color = (priv.theme === "dark")
|
|
8132
|
+
? "rgba(148, 163, 184, 0.60)" /* 3.35:1 */
|
|
8133
|
+
: "rgba(71, 85, 105, 0.65)"; /* 3.19:1 */
|
|
8198
8134
|
}
|
|
8135
|
+
return yui_graph_minimap_block(nd, color);
|
|
8136
|
+
} catch(e) {
|
|
8137
|
+
log_error(`${gobj_short_name(gobj)}: minimap shape failed: ${e}`);
|
|
8138
|
+
return element;
|
|
8199
8139
|
}
|
|
8200
|
-
}
|
|
8140
|
+
})
|
|
8201
8141
|
);
|
|
8202
8142
|
}
|
|
8203
8143
|
|
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
kw_set_local_storage_value,
|
|
62
62
|
gobj_write_str_attr,
|
|
63
63
|
gobj_read_str_attr,
|
|
64
|
+
gobj_read_integer_attr,
|
|
64
65
|
gobj_yuno,
|
|
65
66
|
gobj_yuno_name,
|
|
66
67
|
gobj_short_name,
|
|
@@ -83,6 +84,7 @@ import {
|
|
|
83
84
|
node_status,
|
|
84
85
|
node_status_key,
|
|
85
86
|
node_status_symbol,
|
|
87
|
+
node_can_pause,
|
|
86
88
|
trace_rows,
|
|
87
89
|
own_trace_levels,
|
|
88
90
|
} from "./gobj_tree_model.js";
|
|
@@ -123,6 +125,7 @@ import { ensure_pinch_zoom_patch } from "./g6_touch_gestures.js";
|
|
|
123
125
|
import { yui_is_dark, yui_theme_now, yui_watch_theme } from "./yui_theme.js";
|
|
124
126
|
import {g6_event_kw} from "./g6_event_kw.js";
|
|
125
127
|
import {keep_canvas_tab_order} from "./g6_canvas_tab_order.js";
|
|
128
|
+
import {yui_graph_minimap_options, yui_graph_minimap_block} from "./yui_graph_minimap.js";
|
|
126
129
|
|
|
127
130
|
/***************************************************************
|
|
128
131
|
* Constants
|
|
@@ -148,6 +151,7 @@ SDATA(data_type_t.DTP_STRING, "yuno_name", 0, "", "remote: the nam
|
|
|
148
151
|
SDATA(data_type_t.DTP_STRING, "wide", 0, "40px", "Height of header. 40px and not 36: it is what an untouched Bulma control measures, so the find box stood 4px taller than every button beside it, and it is what the third graph of the family (C_YUI_TREEDB_GRAPH) uses"),
|
|
149
152
|
SDATA(data_type_t.DTP_STRING, "layout", 0, "vertical-compact", "Current layout key"),
|
|
150
153
|
SDATA(data_type_t.DTP_INTEGER, "collapse_threshold", 0, 10, "Auto-collapse a node whose direct children exceed this number. 0 disables auto-collapse."),
|
|
154
|
+
SDATA(data_type_t.DTP_INTEGER, "minimap_min_nodes", 0, 20, "Show the minimap from this many cards on (0 = never). Lower than the treedb graph's 30: this tree opens at actual size, not fitted, so the reader is past its edge sooner"),
|
|
151
155
|
|
|
152
156
|
SDATA_END()
|
|
153
157
|
];
|
|
@@ -261,6 +265,7 @@ function restore_view_state(gobj)
|
|
|
261
265
|
`${Object.keys(priv.node_by_id || {}).length} gobjs, framed again`);
|
|
262
266
|
zoom = null;
|
|
263
267
|
position = null;
|
|
268
|
+
priv.view_refused = true; /* the framing saves its camera over it */
|
|
264
269
|
}
|
|
265
270
|
|
|
266
271
|
let done = false;
|
|
@@ -446,6 +451,7 @@ let PRIVATE_DATA = {
|
|
|
446
451
|
remote_root: null, // the descriptor of the backend tree, as last loaded
|
|
447
452
|
trace_info: {}, // gclass -> {gclass_levels, global_levels, gclass_on, global_on, error}
|
|
448
453
|
trace_pending: false, // a trace was set: the block is locked until the host answers
|
|
454
|
+
view_refused: false, // the saved camera showed no card: the opening's framing replaces it
|
|
449
455
|
};
|
|
450
456
|
|
|
451
457
|
let __gclass__ = null;
|
|
@@ -567,7 +573,13 @@ function status_card_style(d, dark)
|
|
|
567
573
|
if(d.disabled) {
|
|
568
574
|
return table.disabled;
|
|
569
575
|
}
|
|
570
|
-
|
|
576
|
+
let status = node_status(d);
|
|
577
|
+
if(status === "running" && !node_can_pause(d)) {
|
|
578
|
+
/* Nothing to play: running is all it does, so it wears the
|
|
579
|
+
* green of a gobj at work, not the amber of a pause. */
|
|
580
|
+
return table.playing;
|
|
581
|
+
}
|
|
582
|
+
return table[status] || table.stopped;
|
|
571
583
|
}
|
|
572
584
|
|
|
573
585
|
/***************************************************************
|
|
@@ -1414,6 +1426,76 @@ function apply_layout(gobj)
|
|
|
1414
1426
|
});
|
|
1415
1427
|
}
|
|
1416
1428
|
|
|
1429
|
+
/************************************************************
|
|
1430
|
+
* The minimap plugin of the graph, or null when it has none.
|
|
1431
|
+
************************************************************/
|
|
1432
|
+
function minimap_plugin(gobj)
|
|
1433
|
+
{
|
|
1434
|
+
let graph = gobj.priv.graph;
|
|
1435
|
+
let plugins = graph.getPlugins() || [];
|
|
1436
|
+
if(!plugins.some((p) => typeof p === "object" && p.key === "minimap")) {
|
|
1437
|
+
return null;
|
|
1438
|
+
}
|
|
1439
|
+
return graph.getPluginInstance("minimap") || null;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/************************************************************
|
|
1443
|
+
* Show or hide the minimap, deciding by the number of cards
|
|
1444
|
+
* about to be drawn (`n`).
|
|
1445
|
+
*
|
|
1446
|
+
* A minimap of a tree that fits on screen is decoration; one of
|
|
1447
|
+
* a yuno with a thousand gobjs is the only way to know where you
|
|
1448
|
+
* are. So it is not a setting the reader has to find: it appears
|
|
1449
|
+
* from `minimap_min_nodes` cards on.
|
|
1450
|
+
*
|
|
1451
|
+
* Called BEFORE the render, not after it: the minimap builds its
|
|
1452
|
+
* canvas off the graph's render events, so one added after the
|
|
1453
|
+
* last render is bound and never painted. Its frame and anchor
|
|
1454
|
+
* are the library's (yui_graph_minimap.js); its blocks wear the
|
|
1455
|
+
* ROLE colour of their card, the one the card's border wears --
|
|
1456
|
+
* read at each paint, so a change of theme repaints them with
|
|
1457
|
+
* the tree.
|
|
1458
|
+
************************************************************/
|
|
1459
|
+
function refresh_minimap(gobj, n)
|
|
1460
|
+
{
|
|
1461
|
+
let graph = gobj.priv.graph;
|
|
1462
|
+
let threshold = gobj_read_integer_attr(gobj, "minimap_min_nodes");
|
|
1463
|
+
let plugin = minimap_plugin(gobj);
|
|
1464
|
+
|
|
1465
|
+
if(!threshold || n < threshold) {
|
|
1466
|
+
if(plugin) {
|
|
1467
|
+
graph.setPlugins((graph.getPlugins() || []).filter(
|
|
1468
|
+
(p) => !(typeof p === "object" && p.key === "minimap")
|
|
1469
|
+
));
|
|
1470
|
+
if(!plugin.destroyed && plugin.destroy) {
|
|
1471
|
+
plugin.destroy();
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
if(plugin) {
|
|
1477
|
+
return; /* already up */
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
let shape = (id, element_type, element) => {
|
|
1481
|
+
if(element_type !== "node") {
|
|
1482
|
+
return element; /* edges clone themselves fine */
|
|
1483
|
+
}
|
|
1484
|
+
try {
|
|
1485
|
+
let nd = graph.getNodeData(id);
|
|
1486
|
+
let colors = get_role_colors(nd && nd.data);
|
|
1487
|
+
return yui_graph_minimap_block(nd, yui_is_dark()? colors.accent: colors.stroke);
|
|
1488
|
+
} catch(e) {
|
|
1489
|
+
log_error(`${gobj_short_name(gobj)}: minimap shape failed: ${e}`);
|
|
1490
|
+
return element;
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
graph.setPlugins((plugins) => [
|
|
1494
|
+
...plugins,
|
|
1495
|
+
{key: "minimap", type: "minimap", ...yui_graph_minimap_options(shape)}
|
|
1496
|
+
]);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1417
1499
|
/************************************************************
|
|
1418
1500
|
* The role colours of a node.
|
|
1419
1501
|
*
|
|
@@ -1836,6 +1918,12 @@ function load_tree(gobj)
|
|
|
1836
1918
|
|
|
1837
1919
|
build_gobj_nodes(gobj, root, nodes, edges, null, layout_cfg.compact, labels);
|
|
1838
1920
|
|
|
1921
|
+
try {
|
|
1922
|
+
refresh_minimap(gobj, nodes.length);
|
|
1923
|
+
} catch(e) {
|
|
1924
|
+
log_error(`${gobj_short_name(gobj)}: refresh_minimap failed: ${e}`);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1839
1927
|
if(nodes.length > 0) {
|
|
1840
1928
|
let root_id = nodes[0].id; /* built before its children */
|
|
1841
1929
|
graph.setData({nodes: nodes, edges: edges});
|
|
@@ -1894,6 +1982,12 @@ function load_tree(gobj)
|
|
|
1894
1982
|
}
|
|
1895
1983
|
priv.last_zoom = 1;
|
|
1896
1984
|
yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
|
|
1985
|
+
/* A refused camera is replaced now, not at the reader's
|
|
1986
|
+
* next move: left saved, every opening refused it again. */
|
|
1987
|
+
if(priv.view_refused) {
|
|
1988
|
+
priv.view_refused = false;
|
|
1989
|
+
save_view_state(gobj);
|
|
1990
|
+
}
|
|
1897
1991
|
});
|
|
1898
1992
|
});
|
|
1899
1993
|
}
|
|
@@ -31,7 +31,7 @@ if(typeof globalThis.ResizeObserver === "undefined") {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const camera = vi.hoisted(() => ({zoom: NaN, position: [NaN, NaN], zoomed: [], moved: [],
|
|
34
|
-
size: null, viewport: null}));
|
|
34
|
+
size: null, viewport: null, plugins: []}));
|
|
35
35
|
vi.mock("@antv/g6", async (importOriginal) => {
|
|
36
36
|
const real = await importOriginal();
|
|
37
37
|
class FakeGraph {
|
|
@@ -93,8 +93,16 @@ vi.mock("@antv/g6", async (importOriginal) => {
|
|
|
93
93
|
getEdgeData() {
|
|
94
94
|
return [];
|
|
95
95
|
}
|
|
96
|
+
/* The plugins the view asked for, kept so a test can read
|
|
97
|
+
* them (camera.plugins). */
|
|
96
98
|
getPlugins() {
|
|
97
|
-
return
|
|
99
|
+
return camera.plugins;
|
|
100
|
+
}
|
|
101
|
+
setPlugins(arg) {
|
|
102
|
+
camera.plugins = (typeof arg === "function")? arg(camera.plugins) : arg;
|
|
103
|
+
}
|
|
104
|
+
getPluginInstance(key) {
|
|
105
|
+
return camera.plugins.some((p) => p.key === key)? {destroyed: false} : undefined;
|
|
98
106
|
}
|
|
99
107
|
getBehaviors() {
|
|
100
108
|
return [];
|
|
@@ -119,6 +127,7 @@ const {
|
|
|
119
127
|
gobj_start, gobj_read_attr, gobj_send_event, set_log_callback, register_c_timer,
|
|
120
128
|
} = await import("@yuneta/gobj-js");
|
|
121
129
|
const {register_c_yui_gobj_tree_js} = await import("./c_yui_gobj_tree_js.js");
|
|
130
|
+
const {describe_js_gobj} = await import("./gobj_tree_model.js");
|
|
122
131
|
|
|
123
132
|
const logged = [];
|
|
124
133
|
let yuno = null;
|
|
@@ -146,6 +155,7 @@ beforeEach(() => {
|
|
|
146
155
|
camera.moved = [];
|
|
147
156
|
camera.size = null;
|
|
148
157
|
camera.viewport = null;
|
|
158
|
+
camera.plugins = [];
|
|
149
159
|
});
|
|
150
160
|
|
|
151
161
|
function errors()
|
|
@@ -153,10 +163,10 @@ function errors()
|
|
|
153
163
|
return logged.filter((l) => l.level === "error").map((l) => l.msg);
|
|
154
164
|
}
|
|
155
165
|
|
|
156
|
-
async function mount(name)
|
|
166
|
+
async function mount(name, kw)
|
|
157
167
|
{
|
|
158
168
|
const view = gobj_create_pure_child(name, "C_YUI_GOBJ_TREE_JS",
|
|
159
|
-
{$container: document.createElement("div")}, yuno);
|
|
169
|
+
{$container: document.createElement("div"), ...(kw || {})}, yuno);
|
|
160
170
|
document.body.appendChild(gobj_read_attr(view, "$container"));
|
|
161
171
|
gobj_start(view);
|
|
162
172
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
@@ -215,10 +225,16 @@ describe("C_YUI_GOBJ_TREE_JS does not restore a camera that shows nothing", () =
|
|
|
215
225
|
JSON.stringify({layout: "", collapsed: {}, anchor: "", zoom: 0.18, position: [-20000, -20000]}));
|
|
216
226
|
camera.size = [800, 600];
|
|
217
227
|
camera.viewport = [-5000, -5000];
|
|
228
|
+
/* what G6 answers once the opening has framed the tree */
|
|
229
|
+
camera.zoom = 1;
|
|
230
|
+
camera.position = [5, 6];
|
|
218
231
|
await mount(name);
|
|
219
232
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
220
233
|
/* judged before it is applied: only the opening's own framing */
|
|
221
234
|
expect(camera.zoomed).toEqual([1]);
|
|
235
|
+
/* and the refused camera is replaced by the framing's, so the
|
|
236
|
+
* next opening does not refuse it again */
|
|
237
|
+
expect(saved(name)).toMatchObject({zoom: 1, position: [5, 6]});
|
|
222
238
|
expect(logged.filter((l) => l.level === "warning").map((l) => l.msg).join(" "))
|
|
223
239
|
.toMatch(/the saved view shows none of the/);
|
|
224
240
|
expect(errors()).toEqual([]);
|
|
@@ -253,3 +269,33 @@ describe("C_YUI_GOBJ_TREE_JS opens centred on its root", () => {
|
|
|
253
269
|
expect(errors()).toEqual([]);
|
|
254
270
|
});
|
|
255
271
|
});
|
|
272
|
+
|
|
273
|
+
describe("C_YUI_GOBJ_TREE_JS shows a minimap when the tree is big enough", () => {
|
|
274
|
+
test("from minimap_min_nodes cards on, anchored by css at the bottom left", async () => {
|
|
275
|
+
await mount(`camera_${++seq}`, {minimap_min_nodes: 1});
|
|
276
|
+
const minimap = camera.plugins.find((p) => p.key === "minimap");
|
|
277
|
+
expect(minimap).toBeTruthy();
|
|
278
|
+
expect(minimap.type).toBe("minimap");
|
|
279
|
+
expect(minimap.containerStyle).toMatchObject({top: "auto", bottom: "12px", left: "12px"});
|
|
280
|
+
expect(typeof minimap.shape).toBe("function");
|
|
281
|
+
expect(errors()).toEqual([]);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("none below the threshold, and none at all with 0", async () => {
|
|
285
|
+
await mount(`camera_${++seq}`, {minimap_min_nodes: 100000});
|
|
286
|
+
expect(camera.plugins.some((p) => p.key === "minimap")).toBe(false);
|
|
287
|
+
await mount(`camera_${++seq}`, {minimap_min_nodes: 0});
|
|
288
|
+
expect(camera.plugins.some((p) => p.key === "minimap")).toBe(false);
|
|
289
|
+
expect(errors()).toEqual([]);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe("a gobj of this browser says whether play and pause mean anything to it", () => {
|
|
294
|
+
test("play_methods follows the gclass' mt_play / mt_pause", () => {
|
|
295
|
+
gclass_create("C_TEST_WITH_PLAY", [], [["ST_IDLE", []]],
|
|
296
|
+
{mt_play: () => 0}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
297
|
+
const player = gobj_create_pure_child(`player_${++seq}`, "C_TEST_WITH_PLAY", {}, yuno);
|
|
298
|
+
expect(describe_js_gobj(player, false).play_methods).toBe(true);
|
|
299
|
+
expect(describe_js_gobj(yuno, true).play_methods).toBe(false);
|
|
300
|
+
});
|
|
301
|
+
});
|
package/src/gobj_tree_model.js
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* the field names are the ones `gobj2json()` writes in
|
|
16
16
|
* `kernel/c/gobj-c/src/gobj.c` (fullname, shortname, gclass,
|
|
17
17
|
* name, parent, state, running, playing, service, disabled,
|
|
18
|
-
* volatil, bottom_gobj, gobj_flags, commands, gobj_trace_level
|
|
19
|
-
* Anything the browser runtime cannot answer is
|
|
20
|
-
* and every reader here treats absent as "not
|
|
21
|
-
* false
|
|
18
|
+
* volatil, bottom_gobj, gobj_flags, commands, gobj_trace_level,
|
|
19
|
+
* play_methods). Anything the browser runtime cannot answer is
|
|
20
|
+
* simply absent, and every reader here treats absent as "not
|
|
21
|
+
* known", never as false -- `play_methods` included, which a
|
|
22
|
+
* backend built before it was added does not answer.
|
|
22
23
|
*
|
|
23
24
|
* Copyright (c) 2026, ArtGins.
|
|
24
25
|
* All Rights Reserved.
|
|
@@ -88,6 +89,25 @@ function node_status(d)
|
|
|
88
89
|
return d.playing? "playing": "running";
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
/************************************************************
|
|
93
|
+
* Whether play and pause MEAN something to the node: its
|
|
94
|
+
* gclass has an mt_play or an mt_pause.
|
|
95
|
+
*
|
|
96
|
+
* Most gclasses have neither -- a C_TCP, a C_TIMER, a C_NODE
|
|
97
|
+
* -- and nothing ever plays them, so a gobj of theirs that
|
|
98
|
+
* runs is doing all it can. Calling it paused painted almost
|
|
99
|
+
* every card of a backend yuno amber, which is the colour of
|
|
100
|
+
* something to look at.
|
|
101
|
+
*
|
|
102
|
+
* `play_methods` is unknown (null) for a backend yuno that does
|
|
103
|
+
* not answer it in `view-gobj-tree`, and then the node is taken
|
|
104
|
+
* as one that can be paused, which is what was said before.
|
|
105
|
+
************************************************************/
|
|
106
|
+
function node_can_pause(d)
|
|
107
|
+
{
|
|
108
|
+
return !d || d.play_methods !== false;
|
|
109
|
+
}
|
|
110
|
+
|
|
91
111
|
/*
|
|
92
112
|
* What the status LOOKS like, before any word is read.
|
|
93
113
|
*
|
|
@@ -110,6 +130,10 @@ const STATUS_SYMBOLS = {
|
|
|
110
130
|
"stopped": "\u25A0\uFE0E", /* stop */
|
|
111
131
|
};
|
|
112
132
|
|
|
133
|
+
/* Running, for a gobj with nothing to play: ON, a shape of its own,
|
|
134
|
+
* neither the play it never gets nor the pause it is not in. */
|
|
135
|
+
const RUNNING_SYMBOL = "\u25CF"; /* a filled circle */
|
|
136
|
+
|
|
113
137
|
const DISABLED_SYMBOL = "\u2298"; /* a slashed circle */
|
|
114
138
|
|
|
115
139
|
/************************************************************
|
|
@@ -122,13 +146,18 @@ function node_status_symbol(d)
|
|
|
122
146
|
if(d && d.disabled) {
|
|
123
147
|
return DISABLED_SYMBOL;
|
|
124
148
|
}
|
|
125
|
-
|
|
149
|
+
let status = node_status(d);
|
|
150
|
+
if(status === "running" && !node_can_pause(d)) {
|
|
151
|
+
return RUNNING_SYMBOL;
|
|
152
|
+
}
|
|
153
|
+
return STATUS_SYMBOLS[status] || STATUS_SYMBOLS.stopped;
|
|
126
154
|
}
|
|
127
155
|
|
|
128
156
|
/************************************************************
|
|
129
157
|
* The i18n key of the status, which is NOT the status itself:
|
|
130
158
|
* a gobj that runs and does not play is PAUSED to the reader,
|
|
131
|
-
* and "running" alone never said which of the two it was
|
|
159
|
+
* and "running" alone never said which of the two it was --
|
|
160
|
+
* unless play and pause mean nothing to it (node_can_pause()).
|
|
132
161
|
************************************************************/
|
|
133
162
|
function node_status_key(d)
|
|
134
163
|
{
|
|
@@ -136,7 +165,7 @@ function node_status_key(d)
|
|
|
136
165
|
case "playing":
|
|
137
166
|
return "playing";
|
|
138
167
|
case "running":
|
|
139
|
-
return "running (paused)";
|
|
168
|
+
return node_can_pause(d)? "running (paused)": "running";
|
|
140
169
|
default:
|
|
141
170
|
return "stopped";
|
|
142
171
|
}
|
|
@@ -185,6 +214,8 @@ function describe_js_gobj(target_gobj, is_root)
|
|
|
185
214
|
|
|
186
215
|
bottom_gobj: bottom? (gobj_short_name(bottom) || ""): "",
|
|
187
216
|
commands: !!(target_gobj.gclass && target_gobj.gclass.command_table),
|
|
217
|
+
play_methods: !!(target_gobj.gclass && target_gobj.gclass.gmt &&
|
|
218
|
+
(target_gobj.gclass.gmt.mt_play || target_gobj.gclass.gmt.mt_pause)),
|
|
188
219
|
is_yuno: !!is_root,
|
|
189
220
|
children: [],
|
|
190
221
|
};
|
|
@@ -233,6 +264,8 @@ function describe_backend_node(shortname, node, is_root)
|
|
|
233
264
|
disabled: !!node.disabled,
|
|
234
265
|
bottom_gobj: node.bottom_gobj || "",
|
|
235
266
|
commands: !!node.commands,
|
|
267
|
+
/* Unknown (null) for a yuno that does not answer it. */
|
|
268
|
+
play_methods: (typeof node.play_methods === "boolean")? node.play_methods: null,
|
|
236
269
|
gobj_flags: flags,
|
|
237
270
|
gobj_trace_level: Array.isArray(node.gobj_trace_level)?
|
|
238
271
|
node.gobj_trace_level: [],
|
|
@@ -365,6 +398,7 @@ function node_labels(t)
|
|
|
365
398
|
status: {
|
|
366
399
|
"playing": t("playing"),
|
|
367
400
|
"running (paused)": t("running (paused)"),
|
|
401
|
+
"running": t("running"),
|
|
368
402
|
"stopped": t("stopped"),
|
|
369
403
|
},
|
|
370
404
|
/* The glanceable ones, for the pill on the card, which has
|
|
@@ -571,6 +605,7 @@ export {
|
|
|
571
605
|
STATUS_SYMBOLS,
|
|
572
606
|
node_role,
|
|
573
607
|
node_status,
|
|
608
|
+
node_can_pause,
|
|
574
609
|
node_status_key,
|
|
575
610
|
node_status_symbol,
|
|
576
611
|
node_badge_keys,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
node_status,
|
|
5
5
|
node_status_symbol,
|
|
6
6
|
node_status_key,
|
|
7
|
+
node_can_pause,
|
|
7
8
|
node_badge_keys,
|
|
8
9
|
node_info_rows,
|
|
9
10
|
describe_backend_node,
|
|
@@ -120,6 +121,26 @@ describe("node_status", () => {
|
|
|
120
121
|
it("a gobj that plays without running cannot happen, and reads stopped", () => {
|
|
121
122
|
expect(node_status({running: false, playing: true})).toBe("stopped");
|
|
122
123
|
});
|
|
124
|
+
|
|
125
|
+
it("never says paused for a gobj with nothing to play", () => {
|
|
126
|
+
let d = {running: true, playing: false, play_methods: false};
|
|
127
|
+
expect(node_can_pause(d)).toBe(false);
|
|
128
|
+
expect(node_status(d)).toBe("running");
|
|
129
|
+
expect(node_status_key(d)).toBe("running");
|
|
130
|
+
expect(node_status_symbol(d)).toBe("\u25CF");
|
|
131
|
+
/* Played anyway, it says so; stopped is stopped. */
|
|
132
|
+
expect(node_status_key({running: true, playing: true, play_methods: false}))
|
|
133
|
+
.toBe("playing");
|
|
134
|
+
expect(node_status_key({running: false, play_methods: false}))
|
|
135
|
+
.toBe("stopped");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("an unknown play_methods keeps the old word: paused", () => {
|
|
139
|
+
expect(node_can_pause({running: true, play_methods: null})).toBe(true);
|
|
140
|
+
expect(node_can_pause({running: true})).toBe(true);
|
|
141
|
+
expect(node_status_key({running: true, playing: false, play_methods: true}))
|
|
142
|
+
.toBe("running (paused)");
|
|
143
|
+
});
|
|
123
144
|
});
|
|
124
145
|
|
|
125
146
|
describe("node_badge_keys", () => {
|
|
@@ -221,6 +242,19 @@ describe("node_info_rows", () => {
|
|
|
221
242
|
expect(r["flags"]).toBe("gobj_flag_yuno, gobj_flag_service");
|
|
222
243
|
});
|
|
223
244
|
|
|
245
|
+
it("reads play_methods from the backend only when it answers a boolean", () => {
|
|
246
|
+
expect(describe_backend_node("C_X^x", {play_methods: false}, false).play_methods)
|
|
247
|
+
.toBe(false);
|
|
248
|
+
expect(describe_backend_node("C_X^x", {play_methods: true}, false).play_methods)
|
|
249
|
+
.toBe(true);
|
|
250
|
+
expect(describe_backend_node("C_X^x", {}, false).play_methods).toBe(null);
|
|
251
|
+
expect(describe_backend_node("C_X^x", {play_methods: 1}, false).play_methods)
|
|
252
|
+
.toBe(null);
|
|
253
|
+
let r = rows_of(describe_backend_node("C_TCP^x",
|
|
254
|
+
{gclass: "C_TCP", running: true, playing: false, play_methods: false}, false));
|
|
255
|
+
expect(r["status"]).toBe("\u25CF running");
|
|
256
|
+
});
|
|
257
|
+
|
|
224
258
|
it("omits every row whose fact is absent", () => {
|
|
225
259
|
let r = rows_of(describe_backend_node("C_X^x", {gclass: "C_X"}, false));
|
|
226
260
|
expect(r["bottom gobj"]).toBeUndefined();
|