@yuneta/gobj-ui 7.27.26 → 7.27.28

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.
@@ -21172,6 +21172,424 @@ function gclass_view_model(description) {
21172
21172
  };
21173
21173
  }
21174
21174
  //#endregion
21175
+ //#region src/gobj_tree_model.js
21176
+ /***********************************************************************
21177
+ * gobj_tree_model.js
21178
+ *
21179
+ * The gobj tree of a yuno, as plain data.
21180
+ *
21181
+ * The view (C_YUI_GOBJ_TREE_JS) draws NODE DESCRIPTORS, never
21182
+ * gobjs. There are two producers of a descriptor, because the
21183
+ * view has to show the gobjs of the BACKEND too:
21184
+ *
21185
+ * - describe_js_gobj() the gobj tree of THIS browser yuno
21186
+ * - describe_backend_tree() the answer of the backend command
21187
+ * `view-gobj-tree` of another yuno
21188
+ *
21189
+ * Both answer the SAME shape, and that shape is the backend's:
21190
+ * the field names are the ones `gobj2json()` writes in
21191
+ * `kernel/c/gobj-c/src/gobj.c` (fullname, shortname, gclass,
21192
+ * name, parent, state, running, playing, service, disabled,
21193
+ * volatil, bottom_gobj, gobj_flags, commands, gobj_trace_level,
21194
+ * play_methods). Anything the browser runtime cannot answer is
21195
+ * simply absent, and every reader here treats absent as "not
21196
+ * known", never as false -- `play_methods` included, which a
21197
+ * backend built before it was added does not answer.
21198
+ *
21199
+ * Copyright (c) 2026, ArtGins.
21200
+ * All Rights Reserved.
21201
+ ***********************************************************************/
21202
+ /************************************************************
21203
+ * The role of a node: "yuno" | "service" | "volatil" | "pure" | "child"
21204
+ ************************************************************/
21205
+ function node_role(d) {
21206
+ if (!d) return "child";
21207
+ if (d.is_yuno) return "yuno";
21208
+ if (d.service) return "service";
21209
+ if (d.volatil) return "volatil";
21210
+ if (d.pure_child) return "pure";
21211
+ return "child";
21212
+ }
21213
+ /************************************************************
21214
+ * What the node is doing: "stopped" | "running" | "playing"
21215
+ ************************************************************/
21216
+ function node_status(d) {
21217
+ if (!d || !d.running) return "stopped";
21218
+ return d.playing ? "playing" : "running";
21219
+ }
21220
+ /************************************************************
21221
+ * Whether play and pause MEAN something to the node: its
21222
+ * gclass has an mt_play or an mt_pause.
21223
+ *
21224
+ * Most gclasses have neither -- a C_TCP, a C_TIMER, a C_NODE
21225
+ * -- and nothing ever plays them, so a gobj of theirs that
21226
+ * runs is doing all it can. Calling it paused painted almost
21227
+ * every card of a backend yuno amber, which is the colour of
21228
+ * something to look at.
21229
+ *
21230
+ * `play_methods` is unknown (null) for a backend yuno that does
21231
+ * not answer it in `view-gobj-tree`, and then the node is taken
21232
+ * as one that can be paused, which is what was said before.
21233
+ ************************************************************/
21234
+ function node_can_pause(d) {
21235
+ return !d || d.play_methods !== false;
21236
+ }
21237
+ var STATUS_SYMBOLS = {
21238
+ "playing": "▶︎",
21239
+ "running": "‖",
21240
+ "stopped": "■︎"
21241
+ };
21242
+ var RUNNING_SYMBOL = "●";
21243
+ var DISABLED_SYMBOL = "⊘";
21244
+ /************************************************************
21245
+ * The symbol of a node's status, which is what the reader
21246
+ * actually sees first. `disabled` overrides the rest: a
21247
+ * disabled gobj is not going to run whatever it is doing now.
21248
+ ************************************************************/
21249
+ function node_status_symbol(d) {
21250
+ if (d && d.disabled) return DISABLED_SYMBOL;
21251
+ let status = node_status(d);
21252
+ if (status === "running" && !node_can_pause(d)) return RUNNING_SYMBOL;
21253
+ return STATUS_SYMBOLS[status] || STATUS_SYMBOLS.stopped;
21254
+ }
21255
+ /************************************************************
21256
+ * The i18n key of the status, which is NOT the status itself:
21257
+ * a gobj that runs and does not play is PAUSED to the reader,
21258
+ * and "running" alone never said which of the two it was --
21259
+ * unless play and pause mean nothing to it (node_can_pause()).
21260
+ ************************************************************/
21261
+ function node_status_key(d) {
21262
+ switch (node_status(d)) {
21263
+ case "playing": return "playing";
21264
+ case "running": return node_can_pause(d) ? "running (paused)" : "running";
21265
+ default: return "stopped";
21266
+ }
21267
+ }
21268
+ /******************************
21269
+ * Producers
21270
+ ******************************/
21271
+ /************************************************************
21272
+ * A descriptor of a LIVE gobj of this browser yuno, children
21273
+ * included (the whole subtree, depth-first).
21274
+ *
21275
+ * `is_root` marks the yuno itself: the JS runtime has no
21276
+ * gobj_flag_yuno test of its own.
21277
+ ************************************************************/
21278
+ function describe_js_gobj(target_gobj, is_root) {
21279
+ if (!target_gobj) return null;
21280
+ let parent_gobj = gobj_parent(target_gobj);
21281
+ let bottom = gobj_bottom_gobj(target_gobj);
21282
+ let d = {
21283
+ gclass: gobj_gclass_name(target_gobj) || "",
21284
+ name: gobj_name(target_gobj) || "",
21285
+ shortname: gobj_short_name(target_gobj) || "",
21286
+ fullname: gobj_full_name(target_gobj) || "",
21287
+ parent: parent_gobj ? gobj_short_name(parent_gobj) || "" : "",
21288
+ state: gobj_current_state(target_gobj) || "",
21289
+ running: !!gobj_is_running(target_gobj),
21290
+ playing: !!gobj_is_playing(target_gobj),
21291
+ service: !!gobj_is_service(target_gobj),
21292
+ volatil: !!gobj_is_volatil(target_gobj),
21293
+ pure_child: !!gobj_is_pure_child(target_gobj),
21294
+ disabled: !!target_gobj.disabled,
21295
+ bottom_gobj: bottom ? gobj_short_name(bottom) || "" : "",
21296
+ commands: !!(target_gobj.gclass && target_gobj.gclass.command_table),
21297
+ play_methods: !!(target_gobj.gclass && target_gobj.gclass.gmt && (target_gobj.gclass.gmt.mt_play || target_gobj.gclass.gmt.mt_pause)),
21298
+ is_yuno: !!is_root,
21299
+ children: []
21300
+ };
21301
+ let children = target_gobj.dl_children || [];
21302
+ for (let child of children) {
21303
+ let cd = describe_js_gobj(child, false);
21304
+ if (cd) d.children.push(cd);
21305
+ }
21306
+ return d;
21307
+ }
21308
+ /************************************************************
21309
+ * A descriptor from ONE node of the `view-gobj-tree` answer
21310
+ * of a backend yuno.
21311
+ *
21312
+ * `shortname` is the key the node hangs from in that answer;
21313
+ * the node itself repeats it, so the argument is only the
21314
+ * fallback for a filtered answer that dropped the field.
21315
+ ************************************************************/
21316
+ function describe_backend_node(shortname, node, is_root) {
21317
+ if (!node || typeof node !== "object") return null;
21318
+ let flags = Array.isArray(node.gobj_flags) ? node.gobj_flags : [];
21319
+ let has = (flag) => flags.indexOf(flag) !== -1;
21320
+ let d = {
21321
+ gclass: node.gclass || "",
21322
+ name: node.name || "",
21323
+ shortname: node.shortname || shortname || "",
21324
+ fullname: node.fullname || "",
21325
+ parent: node.parent || "",
21326
+ state: node.state || "",
21327
+ running: !!node.running,
21328
+ playing: !!node.playing,
21329
+ service: !!node.service || has("gobj_flag_service") || has("gobj_flag_default_service"),
21330
+ volatil: !!node.volatil || has("gobj_flag_volatil"),
21331
+ pure_child: has("gobj_flag_pure_child"),
21332
+ disabled: !!node.disabled,
21333
+ bottom_gobj: node.bottom_gobj || "",
21334
+ commands: !!node.commands,
21335
+ play_methods: typeof node.play_methods === "boolean" ? node.play_methods : null,
21336
+ gobj_flags: flags,
21337
+ gobj_trace_level: Array.isArray(node.gobj_trace_level) ? node.gobj_trace_level : [],
21338
+ is_yuno: is_root !== void 0 ? !!is_root : has("gobj_flag_yuno"),
21339
+ children: []
21340
+ };
21341
+ let children = node.children && typeof node.children === "object" ? node.children : null;
21342
+ if (children) for (let key of Object.keys(children)) {
21343
+ let cd = describe_backend_node(key, children[key], false);
21344
+ if (cd) d.children.push(cd);
21345
+ }
21346
+ return d;
21347
+ }
21348
+ /************************************************************
21349
+ * The whole `view-gobj-tree` answer -> the root descriptor.
21350
+ *
21351
+ * That answer is a dict of ONE key (the shortname of the gobj
21352
+ * the command was asked about) even though it is shaped as a
21353
+ * dict all the way down. Returns null for anything else, and
21354
+ * the caller reports it: an empty tree and a malformed answer
21355
+ * must not look the same.
21356
+ ************************************************************/
21357
+ function describe_backend_tree(data) {
21358
+ if (!data || typeof data !== "object" || Array.isArray(data)) return null;
21359
+ let keys = Object.keys(data);
21360
+ if (keys.length === 0) return null;
21361
+ return describe_backend_node(keys[0], data[keys[0]], true);
21362
+ }
21363
+ /******************************
21364
+ * Readouts
21365
+ ******************************/
21366
+ /************************************************************
21367
+ * The i18n key of a role. Two of the five roles are not the
21368
+ * word the reader wants ("pure" and "volatil" alone say
21369
+ * nothing), so the map is explicit.
21370
+ ************************************************************/
21371
+ function role_i18n_key(role) {
21372
+ switch (role) {
21373
+ case "yuno": return "yuno";
21374
+ case "service": return "service";
21375
+ case "volatil": return "volatil child";
21376
+ case "pure": return "pure child";
21377
+ default: return "child";
21378
+ }
21379
+ }
21380
+ /************************************************************
21381
+ * The marks a node carries besides its role: what the reader
21382
+ * would otherwise have to open the popover to learn.
21383
+ *
21384
+ * Returns i18n KEYS, in a fixed order, so the card and the
21385
+ * popover cannot disagree about what a node is.
21386
+ ************************************************************/
21387
+ function node_badge_keys(d) {
21388
+ let badges = [];
21389
+ if (!d) return badges;
21390
+ let role = node_role(d);
21391
+ if (role !== "child") badges.push(role_i18n_key(role));
21392
+ if (d.disabled) badges.push("disabled");
21393
+ if (d.bottom_gobj) badges.push("bottom");
21394
+ if (d.commands) badges.push("commands");
21395
+ if (Array.isArray(d.gobj_trace_level) && d.gobj_trace_level.length > 0) badges.push("traces");
21396
+ return badges;
21397
+ }
21398
+ /************************************************************
21399
+ * The vocabulary of this view, translated.
21400
+ *
21401
+ * Written as literal t("...") calls and not as t(key): a key
21402
+ * reached through a variable is invisible to the locale
21403
+ * validator, which is how a fixed vocabulary ships in one
21404
+ * language and never changes it.
21405
+ ************************************************************/
21406
+ function node_labels(t) {
21407
+ if (typeof t !== "function") t = (k) => k;
21408
+ return {
21409
+ role: {
21410
+ "yuno": t("yuno"),
21411
+ "service": t("service"),
21412
+ "volatil child": t("volatil child"),
21413
+ "pure child": t("pure child"),
21414
+ "child": t("child")
21415
+ },
21416
+ status: {
21417
+ "playing": t("playing"),
21418
+ "running (paused)": t("running (paused)"),
21419
+ "running": t("running"),
21420
+ "stopped": t("stopped")
21421
+ },
21422
+ status_short: {
21423
+ "playing": t("playing"),
21424
+ "running": t("running"),
21425
+ "stopped": t("stopped")
21426
+ },
21427
+ badge: {
21428
+ "yuno": t("yuno"),
21429
+ "service": t("service"),
21430
+ "volatil child": t("volatil child"),
21431
+ "pure child": t("pure child"),
21432
+ "disabled": t("disabled"),
21433
+ "bottom": t("bottom"),
21434
+ "commands": t("commands"),
21435
+ "traces": t("traces")
21436
+ },
21437
+ field: {
21438
+ gclass: t("gclass"),
21439
+ name: t("name"),
21440
+ full_name: t("full name"),
21441
+ role: t("role"),
21442
+ status: t("status"),
21443
+ fsm_state: t("fsm state"),
21444
+ disabled: t("disabled"),
21445
+ parent: t("parent"),
21446
+ bottom_gobj: t("bottom gobj"),
21447
+ commands: t("commands"),
21448
+ traces: t("traces"),
21449
+ flags: t("flags"),
21450
+ children: t("children"),
21451
+ yes: t("yes"),
21452
+ collapsed: t("(collapsed)")
21453
+ }
21454
+ };
21455
+ }
21456
+ /************************************************************
21457
+ * The rows of the popover: [label, value], both translated.
21458
+ *
21459
+ * `t` is the app's translator -- the library has none of its
21460
+ * own. Values that are a fixed vocabulary (the role, the
21461
+ * status, yes) go through it too; free text does not.
21462
+ ************************************************************/
21463
+ function node_info_rows(d, t) {
21464
+ let rows = [];
21465
+ if (!d) return rows;
21466
+ let L = node_labels(t);
21467
+ let f = L.field;
21468
+ rows.push([f.gclass, d.gclass || "—"]);
21469
+ rows.push([f.name, d.name || "—"]);
21470
+ if (d.fullname && d.fullname !== d.shortname) rows.push([f.full_name, d.fullname]);
21471
+ rows.push([f.role, L.role[role_i18n_key(node_role(d))]]);
21472
+ rows.push([f.status, node_status_symbol(d) + " " + L.status[node_status_key(d)]]);
21473
+ rows.push([f.fsm_state, d.state || "—"]);
21474
+ if (d.disabled) rows.push([f.disabled, f.yes]);
21475
+ if (d.parent) rows.push([f.parent, d.parent]);
21476
+ if (d.bottom_gobj) rows.push([f.bottom_gobj, d.bottom_gobj]);
21477
+ if (d.commands) rows.push([f.commands, f.yes]);
21478
+ if (Array.isArray(d.gobj_trace_level) && d.gobj_trace_level.length > 0) rows.push([f.traces, d.gobj_trace_level.join(", ")]);
21479
+ if (Array.isArray(d.gobj_flags) && d.gobj_flags.length > 0) rows.push([f.flags, d.gobj_flags.join(", ")]);
21480
+ let kids = Array.isArray(d.children) ? d.children.length : 0;
21481
+ if (kids > 0) rows.push([f.children, d.is_collapsed ? kids + " " + f.collapsed : String(kids)]);
21482
+ return rows;
21483
+ }
21484
+ /******************************
21485
+ * Trace levels
21486
+ ******************************/
21487
+ /************************************************************
21488
+ * The trace levels of a backend gobj, one row per level it
21489
+ * can trace: the gclass' own levels first (the ones that are
21490
+ * about this gobj), then the KERNEL's (`machine`,
21491
+ * `create_delete`, `ev_kw`...).
21492
+ *
21493
+ * Two families of levels and three scopes, and the words must
21494
+ * not mix them. The kernel's levels are the table of gobj.c
21495
+ * that the C side calls "global" -- but they are not global
21496
+ * TRACES: every one of them can be set for one gobj
21497
+ * (`set-gobj-trace`), for every gobj of a gclass
21498
+ * (`set-gclass-trace`, the way to trace the machine of C_TCP
21499
+ * alone) or for the whole yuno (`set-global-trace`). A
21500
+ * gclass' own levels have only the first two scopes.
21501
+ *
21502
+ * `d` is the descriptor (its `gobj_trace_level` is what the
21503
+ * gobj traces NOW, whatever the reason). `info` is what the
21504
+ * host fetched for its gclass:
21505
+ *
21506
+ * gclass_levels {name: description} info-gclass-trace
21507
+ * global_levels {name: description} info-global-trace
21508
+ * gclass_on [name, ...] get-gclass-trace
21509
+ * global_on [name, ...] get-global-trace
21510
+ *
21511
+ * `get-gclass-trace` answers the gclass' levels OR'ed with the
21512
+ * yuno's (gobj_get_gclass_trace_level), so a level on in both
21513
+ * is counted as the yuno's: that is the one that would still
21514
+ * hold it on if the gclass let go.
21515
+ *
21516
+ * Each row says, for each scope:
21517
+ *
21518
+ * group "gclass" | "kernel"
21519
+ * gobj_on, gobj_locked the gobj traces it; locked when
21520
+ * that comes from its gclass or
21521
+ * from the yuno -- turning the
21522
+ * gobj's own bit off would not
21523
+ * stop it
21524
+ * gclass_on, gclass_locked every gobj of the gclass traces
21525
+ * it; locked when the yuno does
21526
+ * global_on the whole yuno traces it
21527
+ * origin "global" | "gclass" | ""
21528
+ ************************************************************/
21529
+ function trace_rows(d, info) {
21530
+ let rows = [];
21531
+ if (!d || !info) return rows;
21532
+ let list = (x) => Array.isArray(x) ? x : [];
21533
+ let now = list(d.gobj_trace_level);
21534
+ let global_on = list(info.global_on);
21535
+ let gclass_on = list(info.gclass_on);
21536
+ let seen = {};
21537
+ let add = (group, levels) => {
21538
+ if (!levels || typeof levels !== "object") return;
21539
+ for (let level of Object.keys(levels)) {
21540
+ if (seen[level]) continue;
21541
+ seen[level] = true;
21542
+ let by_global = global_on.indexOf(level) >= 0;
21543
+ let by_gclass = !by_global && gclass_on.indexOf(level) >= 0;
21544
+ rows.push({
21545
+ level,
21546
+ description: String(levels[level] || ""),
21547
+ group,
21548
+ gobj_on: now.indexOf(level) >= 0 || by_global || by_gclass,
21549
+ gobj_locked: by_global || by_gclass,
21550
+ gclass_on: by_global || by_gclass,
21551
+ gclass_locked: by_global,
21552
+ global_on: by_global,
21553
+ origin: by_global ? "global" : by_gclass ? "gclass" : ""
21554
+ });
21555
+ }
21556
+ };
21557
+ add("gclass", info.gclass_levels);
21558
+ add("kernel", info.global_levels);
21559
+ return rows;
21560
+ }
21561
+ /************************************************************
21562
+ * The rows of the YUNO's scope: the kernel's levels, and
21563
+ * whether the whole yuno traces each one (`set-global-trace`).
21564
+ * A gclass' own levels have no such scope.
21565
+ ************************************************************/
21566
+ function global_trace_rows(info) {
21567
+ let rows = [];
21568
+ if (!info) return rows;
21569
+ let global_on = Array.isArray(info.global_on) ? info.global_on : [];
21570
+ let levels = info.global_levels && typeof info.global_levels === "object" ? info.global_levels : {};
21571
+ for (let level of Object.keys(levels)) rows.push({
21572
+ level,
21573
+ description: String(levels[level] || ""),
21574
+ group: "kernel",
21575
+ global_on: global_on.indexOf(level) >= 0
21576
+ });
21577
+ return rows;
21578
+ }
21579
+ /************************************************************
21580
+ * The levels a scope holds ON ITS OWN -- what "remove the
21581
+ * traces" of that scope has to turn off. Not the locked ones:
21582
+ * they are held by a wider scope, and turning them off here
21583
+ * would change nothing.
21584
+ ************************************************************/
21585
+ function own_trace_levels(rows, scope) {
21586
+ let out = [];
21587
+ for (let r of rows || []) if (scope === "gobj" && r.gobj_on && !r.gobj_locked) out.push(r.level);
21588
+ else if (scope === "gclass" && r.gclass_on && !r.gclass_locked) out.push(r.level);
21589
+ else if (scope === "global" && r.global_on) out.push(r.level);
21590
+ return out;
21591
+ }
21592
+ //#endregion
21175
21593
  //#region src/c_yui_fsm_graph.js
21176
21594
  /***********************************************************************
21177
21595
  * c_yui_fsm_graph.js
@@ -22055,11 +22473,29 @@ function yui_button_mark_done($button, label) {
22055
22473
  * the host mounts `$container` wherever it wants (a C_YUI_WINDOW body
22056
22474
  * on desktop, a dialog on a phone). `yui_gclass_view.js` does both.
22057
22475
  *
22476
+ * THE LAYOUT. The head says what the gclass is called, how many gobjs
22477
+ * of it there are, the instance the reader came from with its state,
22478
+ * and the methods it implements. Then the short zones (the machine,
22479
+ * the trace levels), side by side when the VIEWER is wide -- a
22480
+ * container query: a 720px window on a wide screen is narrow -- and
22481
+ * the long tables (attributes, commands) across the whole width, each
22482
+ * showing ROWS_CAP entries and a button for the rest (a search shows
22483
+ * every match).
22484
+ *
22485
+ * ITS TRACES, when the host can set them (`traces` attr, {info,
22486
+ * pending}): the trace levels zone has one box per level for every
22487
+ * gobj of the gclass, own levels and the kernel's; a level the yuno
22488
+ * holds is locked. A box publishes EV_SET_GCLASS_TRACE {gclass,
22489
+ * levels, set} to the host (this gclass is its child; the gobj tree
22490
+ * declares it) and locks the zone until EV_SET_TRACES hands back what
22491
+ * the backend says now. Without `traces` the levels are only listed.
22492
+ *
22058
22493
  * DOM is self-describing (UPPER_SNAKE logical classes): GCLASS_VIEWER /
22059
22494
  * GCLASS_TOOLBAR / GCLASS_SEARCH / GCLASS_VIEW_SWITCH / GCLASS_ZONES /
22060
- * GCLASS_HEAD / GCLASS_ZONE / GCLASS_ZONE_TITLE / GCLASS_ZONE_BODY /
22495
+ * GCLASS_HEAD / GCLASS_METHODS / GCLASS_CURRENT / GCLASS_PAIR /
22496
+ * GCLASS_FULL / GCLASS_ZONE / GCLASS_ZONE_TITLE / GCLASS_ZONE_BODY /
22061
22497
  * GCLASS_TABLE / GCLASS_MATRIX / GCLASS_CELL / GCLASS_PUBLISHED /
22062
- * GCLASS_RAW.
22498
+ * GCLASS_TRACE_TOGGLES / GCLASS_SHOW_ALL / GCLASS_RAW.
22063
22499
  *
22064
22500
  * Copyright (c) 2026, ArtGins.
22065
22501
  * All Rights Reserved.
@@ -22089,31 +22525,27 @@ var MACHINE_VIEWS = [{
22089
22525
  var MAX_RAW_CHARS = 2e6;
22090
22526
  var ZONES = [
22091
22527
  {
22092
- id: "attrs",
22093
- key: "attributes",
22094
- col: "left"
22095
- },
22096
- {
22097
- id: "commands",
22098
- key: "commands",
22099
- col: "left"
22100
- },
22101
- {
22102
- id: "methods",
22103
- key: "methods",
22104
- col: "left"
22528
+ id: "machine",
22529
+ key: "machine",
22530
+ pair: true
22105
22531
  },
22106
22532
  {
22107
22533
  id: "traces",
22108
22534
  key: "trace levels",
22109
- col: "left"
22535
+ pair: true
22110
22536
  },
22111
22537
  {
22112
- id: "machine",
22113
- key: "machine",
22114
- col: "right"
22538
+ id: "attrs",
22539
+ key: "attributes",
22540
+ pair: false
22541
+ },
22542
+ {
22543
+ id: "commands",
22544
+ key: "commands",
22545
+ pair: false
22115
22546
  }
22116
22547
  ];
22548
+ var ROWS_CAP = 20;
22117
22549
  /***************************************************************
22118
22550
  * Data
22119
22551
  ***************************************************************/
@@ -22122,6 +22554,8 @@ var attrs_table$10 = [
22122
22554
  SDATA(data_type_t.DTP_JSON, "description", 0, null, "The gclass description, as `view-gclass` answers it or `describe_local_gclass()` builds it"),
22123
22555
  SDATA(data_type_t.DTP_STRING, "gclass_name", 0, "", "Name to head the view with when the description carries none"),
22124
22556
  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"),
22557
+ SDATA(data_type_t.DTP_STRING, "instance_name", 0, "", "Name of that instance, said beside its state: a gclass has several"),
22558
+ 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"),
22125
22559
  SDATA(data_type_t.DTP_STRING, "view_mode", 0, "zones", "View: 'zones' or 'raw'"),
22126
22560
  SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "HTMLElement root, mounted by the parent"),
22127
22561
  SDATA_END()
@@ -22130,6 +22564,7 @@ var PRIVATE_DATA$10 = {
22130
22564
  model: null,
22131
22565
  search: "",
22132
22566
  collapsed: null,
22567
+ expanded: null,
22133
22568
  machine_view: "matrix",
22134
22569
  graph_gobj: null,
22135
22570
  $zones: null,
@@ -22148,6 +22583,7 @@ var __gclass__$10 = null;
22148
22583
  function mt_create$10(gobj) {
22149
22584
  let priv = gobj.priv;
22150
22585
  priv.collapsed = /* @__PURE__ */ new Set();
22586
+ priv.expanded = /* @__PURE__ */ new Set();
22151
22587
  priv.search = "";
22152
22588
  priv.machine_view = "matrix";
22153
22589
  priv.model = gclass_view_model(gobj_read_attr(gobj, "description"));
@@ -22463,16 +22899,13 @@ function render_zones(gobj) {
22463
22899
  return;
22464
22900
  }
22465
22901
  let graph_mode = priv.machine_view === "graph";
22466
- let left = [];
22467
- let right = [];
22902
+ let pair = [];
22468
22903
  let full = [];
22469
22904
  for (let zone of ZONES) {
22470
22905
  let $zone = build_zone(gobj, zone);
22471
22906
  if (!$zone) continue;
22472
- if (zone.col === "right") {
22473
- if (graph_mode) full.push($zone);
22474
- else right.push($zone);
22475
- } else left.push($zone);
22907
+ if (zone.pair) pair.push($zone);
22908
+ else full.push($zone);
22476
22909
  }
22477
22910
  let $root = createElement2([
22478
22911
  "div",
@@ -22481,21 +22914,13 @@ function render_zones(gobj) {
22481
22914
  build_head(gobj, model),
22482
22915
  [
22483
22916
  "div",
22484
- { class: "GCLASS_FULL" + (graph_mode ? "" : " is-hidden") },
22485
- full
22917
+ { class: "GCLASS_PAIR" + (graph_mode ? " is-stacked" : "") },
22918
+ pair
22486
22919
  ],
22487
22920
  [
22488
22921
  "div",
22489
- { class: "GCLASS_COLS" + (graph_mode ? " is-stacked" : "") },
22490
- [[
22491
- "div",
22492
- { class: "GCLASS_COL GCLASS_COL_LEFT" },
22493
- left
22494
- ], [
22495
- "div",
22496
- { class: "GCLASS_COL GCLASS_COL_RIGHT" + (graph_mode ? " is-hidden" : "") },
22497
- right
22498
- ]]
22922
+ { class: "GCLASS_FULL" },
22923
+ full
22499
22924
  ]
22500
22925
  ]
22501
22926
  ]);
@@ -22506,8 +22931,11 @@ function render_zones(gobj) {
22506
22931
  if (priv.machine_view === "graph" && !priv.collapsed.has("machine")) build_graph_child(gobj);
22507
22932
  }
22508
22933
  /************************************************************
22509
- * The header: what this gclass is called, and the two
22510
- * numbers a reader asks for before anything else.
22934
+ * The header: what this gclass is called, how many gobjs
22935
+ * of it there are, which instance the reader came from and
22936
+ * the state it is in -- and the methods it implements, a
22937
+ * handful of chips that used to be a zone at the bottom of
22938
+ * every other.
22511
22939
  ************************************************************/
22512
22940
  function build_head(gobj, model) {
22513
22941
  let items = [[
@@ -22524,11 +22952,8 @@ function build_head(gobj, model) {
22524
22952
  String(model.instances)
22525
22953
  ], [
22526
22954
  "span",
22527
- {
22528
- class: "GCLASS_INSTANCES_LABEL",
22529
- i18n: "instances"
22530
- },
22531
- t("instances")
22955
+ { class: "GCLASS_INSTANCES_LABEL" },
22956
+ t("instances", { count: model.instances })
22532
22957
  ]]
22533
22958
  ]);
22534
22959
  for (let flag of model.gcflag) items.push([
@@ -22537,19 +22962,70 @@ function build_head(gobj, model) {
22537
22962
  text_node(flag)
22538
22963
  ]);
22539
22964
  let current = gobj_read_str_attr(gobj, "current_state");
22540
- if (current) items.push([
22965
+ if (current) {
22966
+ let instance = gobj_read_str_attr(gobj, "instance_name");
22967
+ let parts = [];
22968
+ if (instance) parts.push([
22969
+ "span",
22970
+ { class: "GCLASS_CURRENT_INSTANCE" },
22971
+ text_node(instance)
22972
+ ]);
22973
+ parts.push([
22974
+ "span",
22975
+ { class: "GCLASS_CURRENT_STATE" },
22976
+ text_node(current)
22977
+ ]);
22978
+ items.push([
22979
+ "span",
22980
+ {
22981
+ class: "GCLASS_CHIP GCLASS_CURRENT",
22982
+ title: t("current state"),
22983
+ "data-i18n-title": "current state"
22984
+ },
22985
+ parts
22986
+ ]);
22987
+ }
22988
+ let rows = [[
22989
+ "div",
22990
+ { class: "GCLASS_HEAD_ROW" },
22991
+ items
22992
+ ]];
22993
+ let methods = function(names, cls, $label) {
22994
+ if (!names.length) return;
22995
+ rows.push([
22996
+ "div",
22997
+ { class: `GCLASS_HEAD_ROW ${cls}` },
22998
+ [$label, [
22999
+ "span",
23000
+ { class: "GCLASS_CHIPS" },
23001
+ names.map((m) => [
23002
+ "span",
23003
+ row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
23004
+ text_node(m)
23005
+ ])
23006
+ ]]
23007
+ ]);
23008
+ };
23009
+ methods(model.methods, "GCLASS_METHODS", [
23010
+ "span",
23011
+ {
23012
+ class: "GCLASS_HEAD_LABEL",
23013
+ i18n: "methods"
23014
+ },
23015
+ t("methods")
23016
+ ]);
23017
+ methods(model.internal_methods, "GCLASS_INTERNAL_METHODS", [
22541
23018
  "span",
22542
23019
  {
22543
- class: "GCLASS_CHIP GCLASS_CURRENT",
22544
- title: t("current state"),
22545
- "data-i18n-title": "current state"
23020
+ class: "GCLASS_HEAD_LABEL",
23021
+ i18n: "internal methods"
22546
23022
  },
22547
- text_node(current)
23023
+ t("internal methods")
22548
23024
  ]);
22549
23025
  return [
22550
23026
  "div",
22551
23027
  { class: "GCLASS_HEAD" },
22552
- items
23028
+ rows
22553
23029
  ];
22554
23030
  }
22555
23031
  /************************************************************
@@ -22565,25 +23041,32 @@ function build_zone(gobj, zone) {
22565
23041
  let model = priv.model;
22566
23042
  let body = null;
22567
23043
  let count = 0;
23044
+ let more = null;
22568
23045
  switch (zone.id) {
22569
23046
  case "attrs":
22570
23047
  count = model.attrs.length;
22571
23048
  body = build_attrs(model.attrs);
23049
+ more = show_all_button(gobj, zone.id, count);
22572
23050
  break;
22573
23051
  case "commands":
22574
23052
  count = model.commands.filter((c) => c.kind === "command").length;
22575
23053
  body = build_commands(model.commands);
23054
+ more = show_all_button(gobj, zone.id, count);
22576
23055
  break;
22577
- case "methods":
22578
- count = model.methods.length + model.internal_methods.length;
22579
- body = build_methods(model);
22580
- break;
22581
- case "traces":
22582
- count = model.trace_levels.length;
22583
- body = build_traces(model.trace_levels);
23056
+ case "traces": {
23057
+ let traces = gobj_read_attr(gobj, "traces");
23058
+ if (traces && typeof traces === "object") {
23059
+ let built = build_trace_toggles(gobj, model, traces);
23060
+ count = built.count;
23061
+ body = built.body;
23062
+ } else {
23063
+ count = model.trace_levels.length;
23064
+ body = build_traces(model.trace_levels);
23065
+ }
22584
23066
  break;
23067
+ }
22585
23068
  case "machine":
22586
- count = model.fsm.states.length ? `${model.fsm.states.length} · ${model.fsm.rows.length}` : model.fsm.rows.length;
23069
+ count = model.fsm.states.length ? `${t("machine states", { count: model.fsm.states.length })} · ${t("machine events", { count: model.fsm.rows.length })}` : t("machine events", { count: model.fsm.rows.length });
22587
23070
  body = build_machine(gobj, model.fsm);
22588
23071
  break;
22589
23072
  default:
@@ -22636,11 +23119,34 @@ function build_zone(gobj, zone) {
22636
23119
  [$toggle, [
22637
23120
  "div",
22638
23121
  { class: "GCLASS_ZONE_BODY" + (collapsed ? " is-hidden" : "") },
22639
- [body]
23122
+ more ? [body, more] : [body]
22640
23123
  ]]
22641
23124
  ]);
22642
23125
  }
22643
23126
  /************************************************************
23127
+ * The button under a long table: the entries past ROWS_CAP
23128
+ * are drawn and hidden (apply_search() decides), so showing
23129
+ * them is a class, not a rebuild. Null when there are none.
23130
+ ************************************************************/
23131
+ function show_all_button(gobj, zone_id, count) {
23132
+ if (count <= ROWS_CAP || gobj.priv.expanded.has(zone_id)) return null;
23133
+ return [
23134
+ "button",
23135
+ {
23136
+ class: "GCLASS_SHOW_ALL button is-small",
23137
+ type: "button",
23138
+ "data-zone": zone_id,
23139
+ title: t("show all {{n}}", { n: count }),
23140
+ "aria-label": t("show all {{n}}", { n: count })
23141
+ },
23142
+ t("show all {{n}}", { n: count }),
23143
+ { click: function(evt) {
23144
+ evt.stopPropagation();
23145
+ gobj_send_event(gobj, "EV_SHOW_ALL", { zone: zone_id }, gobj);
23146
+ } }
23147
+ ];
23148
+ }
23149
+ /************************************************************
22644
23150
  * An "empty zone" line. It says WHY it is empty, which is
22645
23151
  * never the same as saying nothing.
22646
23152
  ************************************************************/
@@ -22706,10 +23212,10 @@ function flag_chips(flags) {
22706
23212
  ************************************************************/
22707
23213
  function build_attrs(attrs) {
22708
23214
  if (!attrs.length) return empty_line("no attributes declared");
22709
- let rows = attrs.map(function(a) {
23215
+ let rows = attrs.map(function(a, i) {
22710
23216
  return [
22711
23217
  "tr",
22712
- row_attrs(`${a.id} ${a.type} ${a.flags.join(" ")} ${a.description}`),
23218
+ row_attrs(`${a.id} ${a.type} ${a.flags.join(" ")} ${a.description}`, capped_attrs(i)),
22713
23219
  [
22714
23220
  [
22715
23221
  "td",
@@ -22794,11 +23300,14 @@ function build_attrs(attrs) {
22794
23300
  function build_commands(commands) {
22795
23301
  if (!commands.length) return empty_line("no commands declared");
22796
23302
  let rows = [];
23303
+ let n = 0;
22797
23304
  for (let c of commands) {
23305
+ if (c.kind === "command") n++;
23306
+ let capped = capped_attrs(c.kind === "command" ? n - 1 : n);
22798
23307
  if (c.kind === "section") {
22799
23308
  rows.push([
22800
23309
  "tr",
22801
- row_attrs(c.label, { class: "GCLASS_ROW GCLASS_CMD_SECTION" }),
23310
+ row_attrs(c.label, Object.assign({ class: "GCLASS_ROW GCLASS_CMD_SECTION" }, capped)),
22802
23311
  [[
22803
23312
  "td",
22804
23313
  { colspan: "2" },
@@ -22820,7 +23329,7 @@ function build_commands(commands) {
22820
23329
  name_items = name_items.concat(flag_chips(c.flags));
22821
23330
  rows.push([
22822
23331
  "tr",
22823
- row_attrs(`${c.id} ${c.alias.join(" ")} ${c.description}`),
23332
+ row_attrs(`${c.id} ${c.alias.join(" ")} ${c.description}`, capped),
22824
23333
  [[
22825
23334
  "td",
22826
23335
  { class: "GCLASS_CELL_KEY" },
@@ -22833,7 +23342,7 @@ function build_commands(commands) {
22833
23342
  ]);
22834
23343
  for (let p of c.parameters) rows.push([
22835
23344
  "tr",
22836
- row_attrs(`${c.id} ${p.id} ${p.description}`, { class: "GCLASS_ROW GCLASS_CMD_PARAM" }),
23345
+ row_attrs(`${c.id} ${p.id} ${p.description}`, Object.assign({ class: "GCLASS_ROW GCLASS_CMD_PARAM" }, capped)),
22837
23346
  [[
22838
23347
  "td",
22839
23348
  { class: "GCLASS_CELL_KEY" },
@@ -22871,78 +23380,217 @@ function build_commands(commands) {
22871
23380
  ]]
22872
23381
  ]);
22873
23382
  }
23383
+ function capped_attrs(i) {
23384
+ return i >= ROWS_CAP ? { "data-capped": "1" } : {};
23385
+ }
22874
23386
  /************************************************************
22875
- * The methods zone: the ones the gclass IMPLEMENTS.
22876
- *
22877
- * A table of every possible method, mostly empty, tells the
22878
- * reader nothing -- so both sides send only what is wired,
22879
- * and this draws them as chips.
23387
+ * The trace levels zone.
22880
23388
  ************************************************************/
22881
- function build_methods(model) {
22882
- if (!model.methods.length && !model.internal_methods.length) return empty_line("no methods declared");
22883
- let blocks = [];
22884
- if (model.methods.length) blocks.push([
22885
- "div",
22886
- { class: "GCLASS_CHIPS" },
22887
- model.methods.map((m) => [
22888
- "span",
22889
- row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
22890
- text_node(m)
22891
- ])
23389
+ function build_traces(levels) {
23390
+ if (!levels.length) return empty_line("no trace levels declared");
23391
+ return scroller([
23392
+ "table",
23393
+ { class: "GCLASS_TABLE GCLASS_TABLE_TRACES" },
23394
+ [[
23395
+ "tbody",
23396
+ {},
23397
+ levels.map(function(l) {
23398
+ return [
23399
+ "tr",
23400
+ row_attrs(`${l.id} ${l.description}`),
23401
+ [[
23402
+ "td",
23403
+ { class: "GCLASS_CELL_KEY" },
23404
+ text_node(l.id)
23405
+ ], [
23406
+ "td",
23407
+ { class: "GCLASS_CELL_DESC" },
23408
+ text_node(l.description)
23409
+ ]]
23410
+ ];
23411
+ })
23412
+ ]]
22892
23413
  ]);
22893
- if (model.internal_methods.length) {
22894
- blocks.push([
23414
+ }
23415
+ /************************************************************
23416
+ * The trace levels zone of a gclass whose host can SET its
23417
+ * traces: every gobj of it at once (`set-gclass-trace`),
23418
+ * one box per level -- its own, then the kernel's, which
23419
+ * every gclass can trace on its own (the machine of C_TCP
23420
+ * alone). A level the whole yuno traces shows on and locked,
23421
+ * because unticking the gclass would not stop it; the yuno's
23422
+ * scope is set from the gobj tree, not from here.
23423
+ *
23424
+ * A box is an action: the change goes to the FSM, which
23425
+ * tells the host, and the zone stays locked until the host
23426
+ * hands back what the backend says now (EV_SET_TRACES).
23427
+ *
23428
+ * Returns {body, count}.
23429
+ ************************************************************/
23430
+ function build_trace_toggles(gobj, model, traces) {
23431
+ let info = traces.info;
23432
+ if (!info) return {
23433
+ body: empty_line("loading"),
23434
+ count: 0
23435
+ };
23436
+ if (info.error) return {
23437
+ body: [
22895
23438
  "div",
23439
+ { class: "GCLASS_ZONE_EMPTY GCLASS_TRACES_ERROR" },
23440
+ text_node(info.error)
23441
+ ],
23442
+ count: 0
23443
+ };
23444
+ let gclass = model.id || gobj_read_str_attr(gobj, "gclass_name");
23445
+ let rows = trace_rows({ gobj_trace_level: [] }, info);
23446
+ let pending = !!traces.pending;
23447
+ let trs = [];
23448
+ let group = "";
23449
+ for (let r of rows) {
23450
+ if (r.group !== group) {
23451
+ group = r.group;
23452
+ trs.push([
23453
+ "tr",
23454
+ { class: "GCLASS_TRACE_GROUP" },
23455
+ [[
23456
+ "td",
23457
+ { colspan: "3" },
23458
+ group === "gclass" ? [text_node(gclass)] : [[
23459
+ "span",
23460
+ { i18n: "kernel levels" },
23461
+ t("kernel levels")
23462
+ ]]
23463
+ ]]
23464
+ ]);
23465
+ }
23466
+ let $cb = createElement2(["input", {
23467
+ type: "checkbox",
23468
+ class: "GCLASS_TRACE_GCLASS",
23469
+ title: t("all of the gclass"),
23470
+ "data-i18n-title": "all of the gclass",
23471
+ "aria-label": t("all of the gclass"),
23472
+ "data-i18n-aria-label": "all of the gclass"
23473
+ }]);
23474
+ $cb.setAttribute("data-level", r.level);
23475
+ $cb.checked = !!r.gclass_on;
23476
+ $cb.disabled = pending || !!r.gclass_locked;
23477
+ $cb.addEventListener("change", function(evt) {
23478
+ evt.stopPropagation();
23479
+ gobj_send_event(gobj, "EV_GCLASS_TRACE_TOGGLED", {
23480
+ level: r.level,
23481
+ set: !!evt.target.checked
23482
+ }, gobj);
23483
+ });
23484
+ let key_cell = [text_node(r.level)];
23485
+ if (r.gclass_locked) key_cell.push([
23486
+ "span",
22896
23487
  {
22897
- class: "GCLASS_SUBTITLE",
22898
- i18n: "internal methods"
23488
+ class: "GCLASS_TRACE_ORIGIN",
23489
+ i18n: "yuno",
23490
+ title: t("on for the whole yuno"),
23491
+ "data-i18n-title": "on for the whole yuno"
22899
23492
  },
22900
- t("internal methods")
23493
+ t("yuno")
22901
23494
  ]);
22902
- blocks.push([
22903
- "div",
22904
- { class: "GCLASS_CHIPS" },
22905
- model.internal_methods.map((m) => [
22906
- "span",
22907
- row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
22908
- text_node(m)
22909
- ])
23495
+ trs.push([
23496
+ "tr",
23497
+ row_attrs(`${r.level} ${r.description}`),
23498
+ [
23499
+ [
23500
+ "td",
23501
+ { class: "GCLASS_CELL_KEY" },
23502
+ key_cell
23503
+ ],
23504
+ [
23505
+ "td",
23506
+ { class: "GCLASS_CELL_DESC" },
23507
+ text_node(r.description)
23508
+ ],
23509
+ [
23510
+ "td",
23511
+ { class: "GCLASS_CELL_BOX" },
23512
+ [$cb]
23513
+ ]
23514
+ ]
22910
23515
  ]);
22911
23516
  }
22912
- return [
22913
- "div",
22914
- { class: "GCLASS_METHODS" },
22915
- blocks
22916
- ];
22917
- }
22918
- /************************************************************
22919
- * The trace levels zone.
22920
- ************************************************************/
22921
- function build_traces(levels) {
22922
- if (!levels.length) return empty_line("no trace levels declared");
22923
- return scroller([
22924
- "table",
22925
- { class: "GCLASS_TABLE GCLASS_TABLE_TRACES" },
22926
- [[
22927
- "tbody",
22928
- {},
22929
- levels.map(function(l) {
22930
- return [
22931
- "tr",
22932
- row_attrs(`${l.id} ${l.description}`),
23517
+ let none = pending || own_trace_levels(rows, "gclass").length === 0;
23518
+ let $clear = createElement2([
23519
+ "button",
23520
+ {
23521
+ type: "button",
23522
+ class: "GCLASS_TRACES_CLEAR button is-small",
23523
+ i18n: "remove the traces of the gclass",
23524
+ title: t("remove the traces of the gclass"),
23525
+ "data-i18n-title": "remove the traces of the gclass",
23526
+ "aria-label": t("remove the traces of the gclass"),
23527
+ "data-i18n-aria-label": "remove the traces of the gclass"
23528
+ },
23529
+ t("remove the traces of the gclass"),
23530
+ { click: function(evt) {
23531
+ evt.stopPropagation();
23532
+ gobj_send_event(gobj, "EV_GCLASS_TRACES_CLEARED", {}, gobj);
23533
+ } }
23534
+ ]);
23535
+ $clear.disabled = none;
23536
+ return {
23537
+ count: rows.length,
23538
+ body: [
23539
+ "div",
23540
+ { class: "GCLASS_TRACE_TOGGLES" },
23541
+ [
23542
+ scroller([
23543
+ "table",
23544
+ { class: "GCLASS_TABLE GCLASS_TABLE_TRACES" },
22933
23545
  [[
22934
- "td",
22935
- { class: "GCLASS_CELL_KEY" },
22936
- text_node(l.id)
23546
+ "thead",
23547
+ {},
23548
+ [[
23549
+ "tr",
23550
+ {},
23551
+ [
23552
+ [
23553
+ "th",
23554
+ { i18n: "level" },
23555
+ t("level")
23556
+ ],
23557
+ [
23558
+ "th",
23559
+ { i18n: "description" },
23560
+ t("description")
23561
+ ],
23562
+ [
23563
+ "th",
23564
+ {
23565
+ class: "GCLASS_CELL_BOX",
23566
+ i18n: "all of the gclass"
23567
+ },
23568
+ t("all of the gclass")
23569
+ ]
23570
+ ]
23571
+ ]]
22937
23572
  ], [
22938
- "td",
22939
- { class: "GCLASS_CELL_DESC" },
22940
- text_node(l.description)
23573
+ "tbody",
23574
+ {},
23575
+ trs
22941
23576
  ]]
22942
- ];
22943
- })
22944
- ]]
22945
- ]);
23577
+ ]),
23578
+ [
23579
+ "div",
23580
+ {
23581
+ class: "GCLASS_TRACES_NOTE",
23582
+ i18n: "the traces of a gclass survive a restart"
23583
+ },
23584
+ t("the traces of a gclass survive a restart")
23585
+ ],
23586
+ [
23587
+ "div",
23588
+ { class: "GCLASS_TRACES_TOOLS" },
23589
+ [$clear]
23590
+ ]
23591
+ ]
23592
+ ]
23593
+ };
22946
23594
  }
22947
23595
  /************************************************************
22948
23596
  * The machine: the matrix, then what it publishes.
@@ -23098,19 +23746,27 @@ function build_machine(gobj, fsm) {
23098
23746
  t("publishes")
23099
23747
  ]);
23100
23748
  blocks.push([
23101
- "div",
23102
- { class: "GCLASS_CHIPS GCLASS_PUBLISHED" },
23103
- fsm.published.map(function(p) {
23104
- return [
23105
- "span",
23106
- row_attrs(p.event, { class: "GCLASS_PUB_ROW" }),
23107
- [[
23108
- "span",
23109
- { class: "GCLASS_CHIP GCLASS_PUB_EVENT" },
23110
- text_node(p.event)
23111
- ]].concat(event_flag_chips(p.flags))
23112
- ];
23113
- })
23749
+ "table",
23750
+ { class: "GCLASS_TABLE GCLASS_PUBLISHED" },
23751
+ [[
23752
+ "tbody",
23753
+ {},
23754
+ fsm.published.map(function(p) {
23755
+ return [
23756
+ "tr",
23757
+ row_attrs(p.event, { class: "GCLASS_ROW GCLASS_PUB_ROW" }),
23758
+ [[
23759
+ "td",
23760
+ { class: "GCLASS_CELL_KEY GCLASS_PUB_EVENT" },
23761
+ text_node(p.event)
23762
+ ], [
23763
+ "td",
23764
+ { class: "GCLASS_PUB_FLAGS" },
23765
+ event_flag_chips(p.flags)
23766
+ ]]
23767
+ ];
23768
+ })
23769
+ ]]
23114
23770
  ]);
23115
23771
  }
23116
23772
  return [
@@ -23165,7 +23821,7 @@ function machine_view_switch(gobj) {
23165
23821
  ************************************************************/
23166
23822
  function build_legend(fsm, current) {
23167
23823
  let items = [];
23168
- items.push([
23824
+ if (fsm.rows.some((row) => row.cells.some((cell) => !cell))) items.push([
23169
23825
  "span",
23170
23826
  { class: "GCLASS_LEGEND_ITEM" },
23171
23827
  [["i", { class: "GCLASS_LEGEND_SWATCH is-none" }], [
@@ -23174,6 +23830,19 @@ function build_legend(fsm, current) {
23174
23830
  t("not declared in this state")
23175
23831
  ]]
23176
23832
  ]);
23833
+ if (fsm.rows.some((row) => row.cells.some((cell) => cell && cell.has_action && !cell.action))) items.push([
23834
+ "span",
23835
+ { class: "GCLASS_LEGEND_ITEM" },
23836
+ [[
23837
+ "i",
23838
+ { class: "GCLASS_LEGEND_SWATCH is-unnamed" },
23839
+ "●"
23840
+ ], [
23841
+ "span",
23842
+ { i18n: "action, its name not given by the backend" },
23843
+ t("action, its name not given by the backend")
23844
+ ]]
23845
+ ]);
23177
23846
  if (fsm.rows.some((row) => row.cells.some((cell) => cell && !cell.has_action))) items.push([
23178
23847
  "span",
23179
23848
  { class: "GCLASS_LEGEND_ITEM" },
@@ -23281,676 +23950,403 @@ function build_graph_child(gobj) {
23281
23950
  gobj_destroy(graph);
23282
23951
  return false;
23283
23952
  }
23284
- $mount.appendChild($box);
23285
- priv.graph_gobj = graph;
23286
- gobj_start(graph);
23287
- return true;
23288
- }
23289
- /************************************************************
23290
- * Destroy the hosted graph child, if any.
23291
- ************************************************************/
23292
- function teardown_graph_child(gobj) {
23293
- let priv = gobj.priv;
23294
- if (priv.graph_gobj) {
23295
- if (gobj_is_running(priv.graph_gobj)) gobj_stop(priv.graph_gobj);
23296
- gobj_destroy(priv.graph_gobj);
23297
- priv.graph_gobj = null;
23298
- }
23299
- }
23300
- /************************************************************
23301
- * Apply the current filter to what is drawn.
23302
- *
23303
- * Rows carry their own haystack (`data-find`), so this hides
23304
- * rows and never re-renders: a filter that rebuilt the view
23305
- * would lose the scroll position on every keystroke.
23306
- ************************************************************/
23307
- function apply_search(gobj) {
23308
- let priv = gobj.priv;
23309
- let $zones = priv.$zones;
23310
- if (!$zones) return;
23311
- let term = priv.search;
23312
- $zones.querySelectorAll(".GCLASS_ZONE").forEach(function($zone) {
23313
- let $rows = $zone.querySelectorAll("[data-find]");
23314
- let visible = 0;
23315
- $rows.forEach(function($row) {
23316
- let hit = !term || $row.getAttribute("data-find").indexOf(term) >= 0;
23317
- $row.classList.toggle("is-hidden", !hit);
23318
- if (hit) visible++;
23319
- });
23320
- let $none = $zone.querySelector(".GCLASS_ZONE_NO_MATCH");
23321
- let show_none = term && $rows.length > 0 && visible === 0;
23322
- if (show_none && !$none) {
23323
- let $body = $zone.querySelector(".GCLASS_ZONE_BODY");
23324
- if ($body) $body.appendChild(createElement2([
23325
- "div",
23326
- {
23327
- class: "GCLASS_ZONE_EMPTY GCLASS_ZONE_NO_MATCH",
23328
- i18n: "no matches"
23329
- },
23330
- t("no matches")
23331
- ]));
23332
- } else if (!show_none && $none) $none.parentNode.removeChild($none);
23333
- });
23334
- }
23335
- /***************************
23336
- * Actions
23337
- ***************************/
23338
- /************************************************************
23339
- * EV_SET_DESCRIPTION {description, current_state}
23340
- ************************************************************/
23341
- function ac_set_description(gobj, event, kw, src) {
23342
- let priv = gobj.priv;
23343
- let description = kw.description;
23344
- if (description === void 0) {
23345
- log_error(`${GCLASS_NAME$10}: EV_SET_DESCRIPTION without a description`);
23346
- return -1;
23347
- }
23348
- gobj_write_attr(gobj, "description", description === null ? null : json_deep_copy(description));
23349
- if (typeof kw.current_state === "string") gobj_write_attr(gobj, "current_state", kw.current_state);
23350
- priv.model = gclass_view_model(gobj_read_attr(gobj, "description"));
23351
- render_view(gobj);
23352
- return 0;
23353
- }
23354
- /************************************************************
23355
- * EV_SET_VIEW_MODE {mode}
23356
- ************************************************************/
23357
- function ac_set_view_mode(gobj, event, kw, src) {
23358
- let mode = kw.mode;
23359
- if (!VIEWS.some((v) => v.mode === mode)) {
23360
- log_error(`${GCLASS_NAME$10}: unknown view_mode '${mode}'`);
23361
- return -1;
23362
- }
23363
- if (mode === current_view_mode(gobj)) return 0;
23364
- gobj_write_attr(gobj, "view_mode", mode);
23365
- apply_view_mode(gobj);
23366
- render_view(gobj);
23367
- return 0;
23368
- }
23369
- /************************************************************
23370
- * EV_TOGGLE_ZONE {zone}
23371
- ************************************************************/
23372
- function ac_toggle_zone(gobj, event, kw, src) {
23373
- let priv = gobj.priv;
23374
- let zone = kw.zone;
23375
- if (!ZONES.some((z) => z.id === zone)) {
23376
- log_error(`${GCLASS_NAME$10}: unknown zone '${zone}'`);
23377
- return -1;
23378
- }
23379
- let collapsed = !priv.collapsed.has(zone);
23380
- if (collapsed) priv.collapsed.add(zone);
23381
- else priv.collapsed.delete(zone);
23382
- let $zone = priv.$zones ? priv.$zones.querySelector(`.GCLASS_ZONE[data-zone="${zone}"]`) : null;
23383
- if (!$zone) {
23384
- log_error(`${GCLASS_NAME$10}: zone '${zone}' is not drawn`);
23385
- return -1;
23386
- }
23387
- $zone.classList.toggle("is-collapsed", collapsed);
23388
- let $body = $zone.querySelector(".GCLASS_ZONE_BODY");
23389
- if ($body) $body.classList.toggle("is-hidden", collapsed);
23390
- let $toggle = $zone.querySelector(".GCLASS_ZONE_TOGGLE");
23391
- if ($toggle) $toggle.setAttribute("aria-expanded", collapsed ? "false" : "true");
23392
- let $arrow = $zone.querySelector(".GCLASS_ZONE_ARROW i");
23393
- if ($arrow) $arrow.className = collapsed ? "yi-chevron-right" : "yi-chevron-down";
23394
- if (zone === "machine" && priv.machine_view === "graph") {
23395
- if (collapsed) teardown_graph_child(gobj);
23396
- else if (!priv.graph_gobj) build_graph_child(gobj);
23397
- }
23398
- return 0;
23399
- }
23400
- /************************************************************
23401
- * EV_SET_MACHINE_VIEW {mode}
23402
- ************************************************************/
23403
- function ac_set_machine_view(gobj, event, kw, src) {
23404
- let priv = gobj.priv;
23405
- let mode = kw.mode;
23406
- if (!MACHINE_VIEWS.some((v) => v.mode === mode)) {
23407
- log_error(`${GCLASS_NAME$10}: unknown machine view '${mode}'`);
23408
- return -1;
23409
- }
23410
- if (mode === priv.machine_view) return 0;
23411
- priv.machine_view = mode;
23412
- render_zones(gobj);
23413
- return 0;
23414
- }
23415
- /************************************************************
23416
- * EV_SEARCH {text}
23417
- ************************************************************/
23418
- function ac_search$1(gobj, event, kw, src) {
23419
- let priv = gobj.priv;
23420
- priv.search = String(kw.text || "").trim().toLowerCase();
23421
- apply_search(gobj);
23422
- return 0;
23953
+ $mount.appendChild($box);
23954
+ priv.graph_gobj = graph;
23955
+ gobj_start(graph);
23956
+ return true;
23423
23957
  }
23424
23958
  /************************************************************
23425
- * EV_COPY_ALL -- the description, as the backend answered it.
23959
+ * Destroy the hosted graph child, if any.
23426
23960
  ************************************************************/
23427
- function ac_copy_all(gobj, event, kw, src) {
23428
- let description = gobj_read_attr(gobj, "description");
23429
- let $container = gobj_read_attr(gobj, "$container");
23430
- if (description === null || description === void 0) return 0;
23431
- yui_copy_json(description);
23432
- if ($container) {
23433
- let $btn = $container.querySelector(".EV_COPY_ALL");
23434
- if ($btn) yui_button_mark_done($btn, t("copied"));
23961
+ function teardown_graph_child(gobj) {
23962
+ let priv = gobj.priv;
23963
+ if (priv.graph_gobj) {
23964
+ if (gobj_is_running(priv.graph_gobj)) gobj_stop(priv.graph_gobj);
23965
+ gobj_destroy(priv.graph_gobj);
23966
+ priv.graph_gobj = null;
23435
23967
  }
23436
- return 0;
23437
23968
  }
23438
23969
  /************************************************************
23439
- * EV_LANGUAGE_CHANGED -- re-translate chrome + re-render
23970
+ * Apply the current filter to what is drawn.
23440
23971
  *
23441
- * The tables are BUILT with t(): their headers and their
23442
- * empty lines carry keys, but the matrix draws state and
23443
- * event names that are not translatable and legend text that
23444
- * is. Re-rendering is the only way both end up in the same
23445
- * language.
23972
+ * Rows carry their own haystack (`data-find`), so this hides
23973
+ * rows and never re-renders: a filter that rebuilt the view
23974
+ * would lose the scroll position on every keystroke.
23446
23975
  ************************************************************/
23447
- function ac_language_changed$6(gobj, event, kw, src) {
23976
+ function apply_search(gobj) {
23448
23977
  let priv = gobj.priv;
23449
- let $container = gobj_read_attr(gobj, "$container");
23450
- if ($container) {
23451
- refresh_language($container, t);
23452
- if (priv.$search) priv.$search.setAttribute("placeholder", t("search"));
23453
- apply_view_mode(gobj);
23454
- }
23455
- render_view(gobj);
23456
- return 0;
23978
+ let $zones = priv.$zones;
23979
+ if (!$zones) return;
23980
+ let term = priv.search;
23981
+ $zones.querySelectorAll(".GCLASS_ZONE").forEach(function($zone) {
23982
+ let $rows = $zone.querySelectorAll("[data-find]");
23983
+ let visible = 0;
23984
+ let all = priv.expanded.has($zone.getAttribute("data-zone"));
23985
+ $rows.forEach(function($row) {
23986
+ let hit = term ? $row.getAttribute("data-find").indexOf(term) >= 0 : all || !$row.hasAttribute("data-capped");
23987
+ $row.classList.toggle("is-hidden", !hit);
23988
+ if (hit) visible++;
23989
+ });
23990
+ let $more = $zone.querySelector(".GCLASS_SHOW_ALL");
23991
+ if ($more) $more.classList.toggle("is-hidden", !!term || all);
23992
+ let $none = $zone.querySelector(".GCLASS_ZONE_NO_MATCH");
23993
+ let show_none = term && $rows.length > 0 && visible === 0;
23994
+ if (show_none && !$none) {
23995
+ let $body = $zone.querySelector(".GCLASS_ZONE_BODY");
23996
+ if ($body) $body.appendChild(createElement2([
23997
+ "div",
23998
+ {
23999
+ class: "GCLASS_ZONE_EMPTY GCLASS_ZONE_NO_MATCH",
24000
+ i18n: "no matches"
24001
+ },
24002
+ t("no matches")
24003
+ ]));
24004
+ } else if (!show_none && $none) $none.parentNode.removeChild($none);
24005
+ });
23457
24006
  }
24007
+ /***************************
24008
+ * Actions
24009
+ ***************************/
23458
24010
  /************************************************************
23459
- * EV_REFRESH
24011
+ * EV_SET_DESCRIPTION {description, current_state}
23460
24012
  ************************************************************/
23461
- function ac_refresh$4(gobj, event, kw, src) {
24013
+ function ac_set_description(gobj, event, kw, src) {
24014
+ let priv = gobj.priv;
24015
+ let description = kw.description;
24016
+ if (description === void 0) {
24017
+ log_error(`${GCLASS_NAME$10}: EV_SET_DESCRIPTION without a description`);
24018
+ return -1;
24019
+ }
24020
+ gobj_write_attr(gobj, "description", description === null ? null : json_deep_copy(description));
24021
+ if (typeof kw.current_state === "string") gobj_write_attr(gobj, "current_state", kw.current_state);
24022
+ priv.model = gclass_view_model(gobj_read_attr(gobj, "description"));
23462
24023
  render_view(gobj);
23463
24024
  return 0;
23464
24025
  }
23465
24026
  /************************************************************
23466
- * EV_SHOW / EV_HIDE -- host visibility
24027
+ * EV_SET_VIEW_MODE {mode}
23467
24028
  ************************************************************/
23468
- function ac_show$7(gobj, event, kw, src) {
23469
- let $container = gobj_read_attr(gobj, "$container");
23470
- if ($container) $container.classList.remove("is-hidden");
23471
- return 0;
23472
- }
23473
- function ac_hide$6(gobj, event, kw, src) {
23474
- let $container = gobj_read_attr(gobj, "$container");
23475
- if ($container) $container.classList.add("is-hidden");
23476
- return 0;
23477
- }
23478
- /***************************
23479
- * FSM
23480
- ***************************/
23481
- var gmt$10 = {
23482
- mt_create: mt_create$10,
23483
- mt_start: mt_start$10,
23484
- mt_stop: mt_stop$10,
23485
- mt_destroy: mt_destroy$10
23486
- };
23487
- /***************************************************************
23488
- * Create the GClass
23489
- ***************************************************************/
23490
- function create_gclass$10(gclass_name) {
23491
- if (__gclass__$10) {
23492
- log_error(`GClass ALREADY created: ${gclass_name}`);
24029
+ function ac_set_view_mode(gobj, event, kw, src) {
24030
+ let mode = kw.mode;
24031
+ if (!VIEWS.some((v) => v.mode === mode)) {
24032
+ log_error(`${GCLASS_NAME$10}: unknown view_mode '${mode}'`);
23493
24033
  return -1;
23494
24034
  }
23495
- __gclass__$10 = gclass_create(gclass_name, [
23496
- ["EV_SET_DESCRIPTION", 0],
23497
- ["EV_SET_VIEW_MODE", 0],
23498
- ["EV_TOGGLE_ZONE", 0],
23499
- ["EV_SET_MACHINE_VIEW", 0],
23500
- ["EV_SEARCH", 0],
23501
- ["EV_COPY_ALL", 0],
23502
- ["EV_LANGUAGE_CHANGED", 0],
23503
- ["EV_REFRESH", 0],
23504
- ["EV_SHOW", 0],
23505
- ["EV_HIDE", 0]
23506
- ], [["ST_IDLE", [
23507
- [
23508
- "EV_SET_DESCRIPTION",
23509
- ac_set_description,
23510
- null
23511
- ],
23512
- [
23513
- "EV_SET_VIEW_MODE",
23514
- ac_set_view_mode,
23515
- null
23516
- ],
23517
- [
23518
- "EV_TOGGLE_ZONE",
23519
- ac_toggle_zone,
23520
- null
23521
- ],
23522
- [
23523
- "EV_SET_MACHINE_VIEW",
23524
- ac_set_machine_view,
23525
- null
23526
- ],
23527
- [
23528
- "EV_SEARCH",
23529
- ac_search$1,
23530
- null
23531
- ],
23532
- [
23533
- "EV_COPY_ALL",
23534
- ac_copy_all,
23535
- null
23536
- ],
23537
- [
23538
- "EV_LANGUAGE_CHANGED",
23539
- ac_language_changed$6,
23540
- null
23541
- ],
23542
- [
23543
- "EV_REFRESH",
23544
- ac_refresh$4,
23545
- null
23546
- ],
23547
- [
23548
- "EV_SHOW",
23549
- ac_show$7,
23550
- null
23551
- ],
23552
- [
23553
- "EV_HIDE",
23554
- ac_hide$6,
23555
- null
23556
- ]
23557
- ]]], gmt$10, 0, attrs_table$10, PRIVATE_DATA$10, 0, 0, 0, 0);
23558
- if (!__gclass__$10) return -1;
23559
- return 0;
23560
- }
23561
- /***************************************************************
23562
- * Register GClass
23563
- ***************************************************************/
23564
- function register_c_yui_gclass() {
23565
- if (gclass_find_by_name(GCLASS_NAME$10, false)) return 0;
23566
- if (!gclass_find_by_name("C_YUI_FSM_GRAPH", false)) register_c_yui_fsm_graph();
23567
- return create_gclass$10(GCLASS_NAME$10);
23568
- }
23569
- //#endregion
23570
- //#region src/gobj_tree_model.js
23571
- /***********************************************************************
23572
- * gobj_tree_model.js
23573
- *
23574
- * The gobj tree of a yuno, as plain data.
23575
- *
23576
- * The view (C_YUI_GOBJ_TREE_JS) draws NODE DESCRIPTORS, never
23577
- * gobjs. There are two producers of a descriptor, because the
23578
- * view has to show the gobjs of the BACKEND too:
23579
- *
23580
- * - describe_js_gobj() the gobj tree of THIS browser yuno
23581
- * - describe_backend_tree() the answer of the backend command
23582
- * `view-gobj-tree` of another yuno
23583
- *
23584
- * Both answer the SAME shape, and that shape is the backend's:
23585
- * the field names are the ones `gobj2json()` writes in
23586
- * `kernel/c/gobj-c/src/gobj.c` (fullname, shortname, gclass,
23587
- * name, parent, state, running, playing, service, disabled,
23588
- * volatil, bottom_gobj, gobj_flags, commands, gobj_trace_level,
23589
- * play_methods). Anything the browser runtime cannot answer is
23590
- * simply absent, and every reader here treats absent as "not
23591
- * known", never as false -- `play_methods` included, which a
23592
- * backend built before it was added does not answer.
23593
- *
23594
- * Copyright (c) 2026, ArtGins.
23595
- * All Rights Reserved.
23596
- ***********************************************************************/
23597
- /************************************************************
23598
- * The role of a node: "yuno" | "service" | "volatil" | "pure" | "child"
23599
- ************************************************************/
23600
- function node_role(d) {
23601
- if (!d) return "child";
23602
- if (d.is_yuno) return "yuno";
23603
- if (d.service) return "service";
23604
- if (d.volatil) return "volatil";
23605
- if (d.pure_child) return "pure";
23606
- return "child";
23607
- }
23608
- /************************************************************
23609
- * What the node is doing: "stopped" | "running" | "playing"
23610
- ************************************************************/
23611
- function node_status(d) {
23612
- if (!d || !d.running) return "stopped";
23613
- return d.playing ? "playing" : "running";
23614
- }
23615
- /************************************************************
23616
- * Whether play and pause MEAN something to the node: its
23617
- * gclass has an mt_play or an mt_pause.
23618
- *
23619
- * Most gclasses have neither -- a C_TCP, a C_TIMER, a C_NODE
23620
- * -- and nothing ever plays them, so a gobj of theirs that
23621
- * runs is doing all it can. Calling it paused painted almost
23622
- * every card of a backend yuno amber, which is the colour of
23623
- * something to look at.
23624
- *
23625
- * `play_methods` is unknown (null) for a backend yuno that does
23626
- * not answer it in `view-gobj-tree`, and then the node is taken
23627
- * as one that can be paused, which is what was said before.
23628
- ************************************************************/
23629
- function node_can_pause(d) {
23630
- return !d || d.play_methods !== false;
23631
- }
23632
- var STATUS_SYMBOLS = {
23633
- "playing": "▶︎",
23634
- "running": "‖",
23635
- "stopped": "■︎"
23636
- };
23637
- var RUNNING_SYMBOL = "●";
23638
- var DISABLED_SYMBOL = "⊘";
24035
+ if (mode === current_view_mode(gobj)) return 0;
24036
+ gobj_write_attr(gobj, "view_mode", mode);
24037
+ apply_view_mode(gobj);
24038
+ render_view(gobj);
24039
+ return 0;
24040
+ }
23639
24041
  /************************************************************
23640
- * The symbol of a node's status, which is what the reader
23641
- * actually sees first. `disabled` overrides the rest: a
23642
- * disabled gobj is not going to run whatever it is doing now.
24042
+ * EV_TOGGLE_ZONE {zone}
23643
24043
  ************************************************************/
23644
- function node_status_symbol(d) {
23645
- if (d && d.disabled) return DISABLED_SYMBOL;
23646
- let status = node_status(d);
23647
- if (status === "running" && !node_can_pause(d)) return RUNNING_SYMBOL;
23648
- return STATUS_SYMBOLS[status] || STATUS_SYMBOLS.stopped;
24044
+ function ac_toggle_zone(gobj, event, kw, src) {
24045
+ let priv = gobj.priv;
24046
+ let zone = kw.zone;
24047
+ if (!ZONES.some((z) => z.id === zone)) {
24048
+ log_error(`${GCLASS_NAME$10}: unknown zone '${zone}'`);
24049
+ return -1;
24050
+ }
24051
+ let collapsed = !priv.collapsed.has(zone);
24052
+ if (collapsed) priv.collapsed.add(zone);
24053
+ else priv.collapsed.delete(zone);
24054
+ let $zone = priv.$zones ? priv.$zones.querySelector(`.GCLASS_ZONE[data-zone="${zone}"]`) : null;
24055
+ if (!$zone) {
24056
+ log_error(`${GCLASS_NAME$10}: zone '${zone}' is not drawn`);
24057
+ return -1;
24058
+ }
24059
+ $zone.classList.toggle("is-collapsed", collapsed);
24060
+ let $body = $zone.querySelector(".GCLASS_ZONE_BODY");
24061
+ if ($body) $body.classList.toggle("is-hidden", collapsed);
24062
+ let $toggle = $zone.querySelector(".GCLASS_ZONE_TOGGLE");
24063
+ if ($toggle) $toggle.setAttribute("aria-expanded", collapsed ? "false" : "true");
24064
+ let $arrow = $zone.querySelector(".GCLASS_ZONE_ARROW i");
24065
+ if ($arrow) $arrow.className = collapsed ? "yi-chevron-right" : "yi-chevron-down";
24066
+ if (zone === "machine" && priv.machine_view === "graph") {
24067
+ if (collapsed) teardown_graph_child(gobj);
24068
+ else if (!priv.graph_gobj) build_graph_child(gobj);
24069
+ }
24070
+ return 0;
23649
24071
  }
23650
24072
  /************************************************************
23651
- * The i18n key of the status, which is NOT the status itself:
23652
- * a gobj that runs and does not play is PAUSED to the reader,
23653
- * and "running" alone never said which of the two it was --
23654
- * unless play and pause mean nothing to it (node_can_pause()).
24073
+ * EV_SET_MACHINE_VIEW {mode}
23655
24074
  ************************************************************/
23656
- function node_status_key(d) {
23657
- switch (node_status(d)) {
23658
- case "playing": return "playing";
23659
- case "running": return node_can_pause(d) ? "running (paused)" : "running";
23660
- default: return "stopped";
24075
+ function ac_set_machine_view(gobj, event, kw, src) {
24076
+ let priv = gobj.priv;
24077
+ let mode = kw.mode;
24078
+ if (!MACHINE_VIEWS.some((v) => v.mode === mode)) {
24079
+ log_error(`${GCLASS_NAME$10}: unknown machine view '${mode}'`);
24080
+ return -1;
23661
24081
  }
24082
+ if (mode === priv.machine_view) return 0;
24083
+ priv.machine_view = mode;
24084
+ render_zones(gobj);
24085
+ return 0;
23662
24086
  }
23663
- /******************************
23664
- * Producers
23665
- ******************************/
23666
24087
  /************************************************************
23667
- * A descriptor of a LIVE gobj of this browser yuno, children
23668
- * included (the whole subtree, depth-first).
23669
- *
23670
- * `is_root` marks the yuno itself: the JS runtime has no
23671
- * gobj_flag_yuno test of its own.
24088
+ * EV_SEARCH {text}
23672
24089
  ************************************************************/
23673
- function describe_js_gobj(target_gobj, is_root) {
23674
- if (!target_gobj) return null;
23675
- let parent_gobj = gobj_parent(target_gobj);
23676
- let bottom = gobj_bottom_gobj(target_gobj);
23677
- let d = {
23678
- gclass: gobj_gclass_name(target_gobj) || "",
23679
- name: gobj_name(target_gobj) || "",
23680
- shortname: gobj_short_name(target_gobj) || "",
23681
- fullname: gobj_full_name(target_gobj) || "",
23682
- parent: parent_gobj ? gobj_short_name(parent_gobj) || "" : "",
23683
- state: gobj_current_state(target_gobj) || "",
23684
- running: !!gobj_is_running(target_gobj),
23685
- playing: !!gobj_is_playing(target_gobj),
23686
- service: !!gobj_is_service(target_gobj),
23687
- volatil: !!gobj_is_volatil(target_gobj),
23688
- pure_child: !!gobj_is_pure_child(target_gobj),
23689
- disabled: !!target_gobj.disabled,
23690
- bottom_gobj: bottom ? gobj_short_name(bottom) || "" : "",
23691
- commands: !!(target_gobj.gclass && target_gobj.gclass.command_table),
23692
- play_methods: !!(target_gobj.gclass && target_gobj.gclass.gmt && (target_gobj.gclass.gmt.mt_play || target_gobj.gclass.gmt.mt_pause)),
23693
- is_yuno: !!is_root,
23694
- children: []
23695
- };
23696
- let children = target_gobj.dl_children || [];
23697
- for (let child of children) {
23698
- let cd = describe_js_gobj(child, false);
23699
- if (cd) d.children.push(cd);
23700
- }
23701
- return d;
24090
+ function ac_search$1(gobj, event, kw, src) {
24091
+ let priv = gobj.priv;
24092
+ priv.search = String(kw.text || "").trim().toLowerCase();
24093
+ apply_search(gobj);
24094
+ return 0;
23702
24095
  }
23703
24096
  /************************************************************
23704
- * A descriptor from ONE node of the `view-gobj-tree` answer
23705
- * of a backend yuno.
23706
- *
23707
- * `shortname` is the key the node hangs from in that answer;
23708
- * the node itself repeats it, so the argument is only the
23709
- * fallback for a filtered answer that dropped the field.
24097
+ * EV_COPY_ALL -- the description, as the backend answered it.
23710
24098
  ************************************************************/
23711
- function describe_backend_node(shortname, node, is_root) {
23712
- if (!node || typeof node !== "object") return null;
23713
- let flags = Array.isArray(node.gobj_flags) ? node.gobj_flags : [];
23714
- let has = (flag) => flags.indexOf(flag) !== -1;
23715
- let d = {
23716
- gclass: node.gclass || "",
23717
- name: node.name || "",
23718
- shortname: node.shortname || shortname || "",
23719
- fullname: node.fullname || "",
23720
- parent: node.parent || "",
23721
- state: node.state || "",
23722
- running: !!node.running,
23723
- playing: !!node.playing,
23724
- service: !!node.service || has("gobj_flag_service") || has("gobj_flag_default_service"),
23725
- volatil: !!node.volatil || has("gobj_flag_volatil"),
23726
- pure_child: has("gobj_flag_pure_child"),
23727
- disabled: !!node.disabled,
23728
- bottom_gobj: node.bottom_gobj || "",
23729
- commands: !!node.commands,
23730
- play_methods: typeof node.play_methods === "boolean" ? node.play_methods : null,
23731
- gobj_flags: flags,
23732
- gobj_trace_level: Array.isArray(node.gobj_trace_level) ? node.gobj_trace_level : [],
23733
- is_yuno: is_root !== void 0 ? !!is_root : has("gobj_flag_yuno"),
23734
- children: []
23735
- };
23736
- let children = node.children && typeof node.children === "object" ? node.children : null;
23737
- if (children) for (let key of Object.keys(children)) {
23738
- let cd = describe_backend_node(key, children[key], false);
23739
- if (cd) d.children.push(cd);
24099
+ function ac_copy_all(gobj, event, kw, src) {
24100
+ let description = gobj_read_attr(gobj, "description");
24101
+ let $container = gobj_read_attr(gobj, "$container");
24102
+ if (description === null || description === void 0) return 0;
24103
+ yui_copy_json(description);
24104
+ if ($container) {
24105
+ let $btn = $container.querySelector(".EV_COPY_ALL");
24106
+ if ($btn) yui_button_mark_done($btn, t("copied"));
23740
24107
  }
23741
- return d;
24108
+ return 0;
23742
24109
  }
23743
24110
  /************************************************************
23744
- * The whole `view-gobj-tree` answer -> the root descriptor.
23745
- *
23746
- * That answer is a dict of ONE key (the shortname of the gobj
23747
- * the command was asked about) even though it is shaped as a
23748
- * dict all the way down. Returns null for anything else, and
23749
- * the caller reports it: an empty tree and a malformed answer
23750
- * must not look the same.
24111
+ * EV_SHOW_ALL {zone} -- the rows of a long table past the cap.
23751
24112
  ************************************************************/
23752
- function describe_backend_tree(data) {
23753
- if (!data || typeof data !== "object" || Array.isArray(data)) return null;
23754
- let keys = Object.keys(data);
23755
- if (keys.length === 0) return null;
23756
- return describe_backend_node(keys[0], data[keys[0]], true);
24113
+ function ac_show_all(gobj, event, kw, src) {
24114
+ let priv = gobj.priv;
24115
+ if (!ZONES.some((z) => z.id === kw.zone)) {
24116
+ log_error(`${GCLASS_NAME$10}: show all of no zone '${kw.zone}'`);
24117
+ return -1;
24118
+ }
24119
+ priv.expanded.add(kw.zone);
24120
+ apply_search(gobj);
24121
+ return 0;
23757
24122
  }
23758
- /******************************
23759
- * Readouts
23760
- ******************************/
23761
24123
  /************************************************************
23762
- * The i18n key of a role. Two of the five roles are not the
23763
- * word the reader wants ("pure" and "volatil" alone say
23764
- * nothing), so the map is explicit.
24124
+ * EV_SET_TRACES {info, pending} -- the host, with what the
24125
+ * backend says the gclass traces now.
23765
24126
  ************************************************************/
23766
- function role_i18n_key(role) {
23767
- switch (role) {
23768
- case "yuno": return "yuno";
23769
- case "service": return "service";
23770
- case "volatil": return "volatil child";
23771
- case "pure": return "pure child";
23772
- default: return "child";
23773
- }
24127
+ function ac_set_traces(gobj, event, kw, src) {
24128
+ gobj_write_attr(gobj, "traces", {
24129
+ info: kw && kw.info && typeof kw.info === "object" ? json_deep_copy(kw.info) : null,
24130
+ pending: !!(kw && kw.pending)
24131
+ });
24132
+ refresh_zone(gobj, "traces");
24133
+ return 0;
23774
24134
  }
23775
24135
  /************************************************************
23776
- * The marks a node carries besides its role: what the reader
23777
- * would otherwise have to open the popover to learn.
23778
- *
23779
- * Returns i18n KEYS, in a fixed order, so the card and the
23780
- * popover cannot disagree about what a node is.
24136
+ * A box of the trace levels zone: {level, set}.
23781
24137
  ************************************************************/
23782
- function node_badge_keys(d) {
23783
- let badges = [];
23784
- if (!d) return badges;
23785
- let role = node_role(d);
23786
- if (role !== "child") badges.push(role_i18n_key(role));
23787
- if (d.disabled) badges.push("disabled");
23788
- if (d.bottom_gobj) badges.push("bottom");
23789
- if (d.commands) badges.push("commands");
23790
- if (Array.isArray(d.gobj_trace_level) && d.gobj_trace_level.length > 0) badges.push("traces");
23791
- return badges;
24138
+ function ac_gclass_trace_toggled(gobj, event, kw, src) {
24139
+ if (!kw || !kw.level) {
24140
+ log_error(`${GCLASS_NAME$10}: a gclass trace set of no level`);
24141
+ return -1;
24142
+ }
24143
+ return ask_gclass_trace(gobj, [kw.level], !!kw.set);
23792
24144
  }
23793
24145
  /************************************************************
23794
- * The vocabulary of this view, translated.
23795
- *
23796
- * Written as literal t("...") calls and not as t(key): a key
23797
- * reached through a variable is invisible to the locale
23798
- * validator, which is how a fixed vocabulary ships in one
23799
- * language and never changes it.
24146
+ * "Remove the traces of the gclass": every level it holds
24147
+ * on its own (not the yuno's, which it cannot let go).
23800
24148
  ************************************************************/
23801
- function node_labels(t) {
23802
- if (typeof t !== "function") t = (k) => k;
23803
- return {
23804
- role: {
23805
- "yuno": t("yuno"),
23806
- "service": t("service"),
23807
- "volatil child": t("volatil child"),
23808
- "pure child": t("pure child"),
23809
- "child": t("child")
23810
- },
23811
- status: {
23812
- "playing": t("playing"),
23813
- "running (paused)": t("running (paused)"),
23814
- "running": t("running"),
23815
- "stopped": t("stopped")
23816
- },
23817
- status_short: {
23818
- "playing": t("playing"),
23819
- "running": t("running"),
23820
- "stopped": t("stopped")
23821
- },
23822
- badge: {
23823
- "yuno": t("yuno"),
23824
- "service": t("service"),
23825
- "volatil child": t("volatil child"),
23826
- "pure child": t("pure child"),
23827
- "disabled": t("disabled"),
23828
- "bottom": t("bottom"),
23829
- "commands": t("commands"),
23830
- "traces": t("traces")
23831
- },
23832
- field: {
23833
- gclass: t("gclass"),
23834
- name: t("name"),
23835
- full_name: t("full name"),
23836
- role: t("role"),
23837
- status: t("status"),
23838
- fsm_state: t("fsm state"),
23839
- disabled: t("disabled"),
23840
- parent: t("parent"),
23841
- bottom_gobj: t("bottom gobj"),
23842
- commands: t("commands"),
23843
- traces: t("traces"),
23844
- flags: t("flags"),
23845
- children: t("children"),
23846
- yes: t("yes"),
23847
- collapsed: t("(collapsed)")
23848
- }
23849
- };
24149
+ function ac_gclass_traces_cleared(gobj, event, kw, src) {
24150
+ let traces = gobj_read_attr(gobj, "traces");
24151
+ let levels = own_trace_levels(trace_rows({ gobj_trace_level: [] }, traces && traces.info), "gclass");
24152
+ if (!levels.length) {
24153
+ log_error(`${GCLASS_NAME$10}: no gclass trace to remove`);
24154
+ return -1;
24155
+ }
24156
+ return ask_gclass_trace(gobj, levels, false);
24157
+ }
24158
+ function ask_gclass_trace(gobj, levels, set) {
24159
+ let priv = gobj.priv;
24160
+ let traces = gobj_read_attr(gobj, "traces");
24161
+ if (!traces || typeof traces !== "object") {
24162
+ log_error(`${GCLASS_NAME$10}: a gclass trace set, and no host that can set it`);
24163
+ return -1;
24164
+ }
24165
+ gobj_write_attr(gobj, "traces", {
24166
+ info: traces.info || null,
24167
+ pending: true
24168
+ });
24169
+ refresh_zone(gobj, "traces");
24170
+ gobj_publish_event(gobj, "EV_SET_GCLASS_TRACE", {
24171
+ gclass: priv.model && priv.model.id || gobj_read_str_attr(gobj, "gclass_name"),
24172
+ levels,
24173
+ set
24174
+ });
24175
+ return 0;
23850
24176
  }
23851
24177
  /************************************************************
23852
- * The rows of the popover: [label, value], both translated.
23853
- *
23854
- * `t` is the app's translator -- the library has none of its
23855
- * own. Values that are a fixed vocabulary (the role, the
23856
- * status, yes) go through it too; free text does not.
24178
+ * Draw ONE zone again, in place. The others stay as they
24179
+ * are: the machine's graph keeps its camera, and a table
24180
+ * keeps its scroll.
23857
24181
  ************************************************************/
23858
- function node_info_rows(d, t) {
23859
- let rows = [];
23860
- if (!d) return rows;
23861
- let L = node_labels(t);
23862
- let f = L.field;
23863
- rows.push([f.gclass, d.gclass || "—"]);
23864
- rows.push([f.name, d.name || "—"]);
23865
- if (d.fullname && d.fullname !== d.shortname) rows.push([f.full_name, d.fullname]);
23866
- rows.push([f.role, L.role[role_i18n_key(node_role(d))]]);
23867
- rows.push([f.status, node_status_symbol(d) + " " + L.status[node_status_key(d)]]);
23868
- rows.push([f.fsm_state, d.state || "—"]);
23869
- if (d.disabled) rows.push([f.disabled, f.yes]);
23870
- if (d.parent) rows.push([f.parent, d.parent]);
23871
- if (d.bottom_gobj) rows.push([f.bottom_gobj, d.bottom_gobj]);
23872
- if (d.commands) rows.push([f.commands, f.yes]);
23873
- if (Array.isArray(d.gobj_trace_level) && d.gobj_trace_level.length > 0) rows.push([f.traces, d.gobj_trace_level.join(", ")]);
23874
- if (Array.isArray(d.gobj_flags) && d.gobj_flags.length > 0) rows.push([f.flags, d.gobj_flags.join(", ")]);
23875
- let kids = Array.isArray(d.children) ? d.children.length : 0;
23876
- if (kids > 0) rows.push([f.children, d.is_collapsed ? kids + " " + f.collapsed : String(kids)]);
23877
- return rows;
24182
+ function refresh_zone(gobj, zone_id) {
24183
+ let priv = gobj.priv;
24184
+ const zone = ZONES.find((z) => z.id === zone_id);
24185
+ let $old = priv.$zones ? priv.$zones.querySelector(`.GCLASS_ZONE[data-zone="${zone_id}"]`) : null;
24186
+ if (!zone || !$old || !priv.model) return;
24187
+ let $new = build_zone(gobj, zone);
24188
+ if (!$new) return;
24189
+ $old.replaceWith($new);
24190
+ refresh_language($new, t);
24191
+ apply_search(gobj);
23878
24192
  }
23879
- /******************************
23880
- * Trace levels
23881
- ******************************/
23882
24193
  /************************************************************
23883
- * The rows of the TRACES block of a backend gobj, one per
23884
- * level it can trace: the gclass' own levels first (the ones
23885
- * that are about this gobj), then the global ones.
23886
- *
23887
- * `d` is the descriptor (its `gobj_trace_level` is what the
23888
- * gobj traces NOW, whatever the reason). `info` is what the
23889
- * host fetched for its gclass:
23890
- *
23891
- * gclass_levels {name: description} info-gclass-trace
23892
- * global_levels {name: description} info-global-trace
23893
- * gclass_on [name, ...] get-gclass-trace
23894
- * global_on [name, ...] get-global-trace
23895
- *
23896
- * `get-gclass-trace` answers the gclass' levels OR'ed with the
23897
- * global ones (gobj_get_gclass_trace_level), so a level on in
23898
- * both is counted as global: that is the one that would still
23899
- * hold it on if the gclass let go.
23900
- *
23901
- * Each row says, for the two columns of the block:
24194
+ * EV_LANGUAGE_CHANGED -- re-translate chrome + re-render
23902
24195
  *
23903
- * gobj_on, gobj_locked the gobj traces it; locked when
23904
- * that comes from its gclass or
23905
- * from the global level -- turning
23906
- * the gobj's own bit off would not
23907
- * stop it
23908
- * gclass_on, gclass_locked every gobj of the gclass traces
23909
- * it; locked when it is global
23910
- * origin "global" | "gclass" | ""
24196
+ * The tables are BUILT with t(): their headers and their
24197
+ * empty lines carry keys, but the matrix draws state and
24198
+ * event names that are not translatable and legend text that
24199
+ * is. Re-rendering is the only way both end up in the same
24200
+ * language.
23911
24201
  ************************************************************/
23912
- function trace_rows(d, info) {
23913
- let rows = [];
23914
- if (!d || !info) return rows;
23915
- let list = (x) => Array.isArray(x) ? x : [];
23916
- let now = list(d.gobj_trace_level);
23917
- let global_on = list(info.global_on);
23918
- let gclass_on = list(info.gclass_on);
23919
- let seen = {};
23920
- let add = (group, levels) => {
23921
- if (!levels || typeof levels !== "object") return;
23922
- for (let level of Object.keys(levels)) {
23923
- if (seen[level]) continue;
23924
- seen[level] = true;
23925
- let by_global = global_on.indexOf(level) >= 0;
23926
- let by_gclass = !by_global && gclass_on.indexOf(level) >= 0;
23927
- rows.push({
23928
- level,
23929
- description: String(levels[level] || ""),
23930
- group,
23931
- gobj_on: now.indexOf(level) >= 0 || by_global || by_gclass,
23932
- gobj_locked: by_global || by_gclass,
23933
- gclass_on: by_global || by_gclass,
23934
- gclass_locked: by_global,
23935
- origin: by_global ? "global" : by_gclass ? "gclass" : ""
23936
- });
23937
- }
23938
- };
23939
- add("gclass", info.gclass_levels);
23940
- add("global", info.global_levels);
23941
- return rows;
24202
+ function ac_language_changed$6(gobj, event, kw, src) {
24203
+ let priv = gobj.priv;
24204
+ let $container = gobj_read_attr(gobj, "$container");
24205
+ if ($container) {
24206
+ refresh_language($container, t);
24207
+ if (priv.$search) priv.$search.setAttribute("placeholder", t("search"));
24208
+ apply_view_mode(gobj);
24209
+ }
24210
+ render_view(gobj);
24211
+ return 0;
23942
24212
  }
23943
24213
  /************************************************************
23944
- * The levels a scope holds ON ITS OWN -- what "remove the
23945
- * traces" of that scope has to turn off. Not the locked ones:
23946
- * they are held by a wider scope, and turning them off here
23947
- * would change nothing.
24214
+ * EV_REFRESH
23948
24215
  ************************************************************/
23949
- function own_trace_levels(rows, scope) {
23950
- let out = [];
23951
- for (let r of rows || []) if (scope === "gobj" && r.gobj_on && !r.gobj_locked) out.push(r.level);
23952
- else if (scope === "gclass" && r.gclass_on && !r.gclass_locked) out.push(r.level);
23953
- return out;
24216
+ function ac_refresh$4(gobj, event, kw, src) {
24217
+ render_view(gobj);
24218
+ return 0;
24219
+ }
24220
+ /************************************************************
24221
+ * EV_SHOW / EV_HIDE -- host visibility
24222
+ ************************************************************/
24223
+ function ac_show$7(gobj, event, kw, src) {
24224
+ let $container = gobj_read_attr(gobj, "$container");
24225
+ if ($container) $container.classList.remove("is-hidden");
24226
+ return 0;
24227
+ }
24228
+ function ac_hide$6(gobj, event, kw, src) {
24229
+ let $container = gobj_read_attr(gobj, "$container");
24230
+ if ($container) $container.classList.add("is-hidden");
24231
+ return 0;
24232
+ }
24233
+ /***************************
24234
+ * FSM
24235
+ ***************************/
24236
+ var gmt$10 = {
24237
+ mt_create: mt_create$10,
24238
+ mt_start: mt_start$10,
24239
+ mt_stop: mt_stop$10,
24240
+ mt_destroy: mt_destroy$10
24241
+ };
24242
+ /***************************************************************
24243
+ * Create the GClass
24244
+ ***************************************************************/
24245
+ function create_gclass$10(gclass_name) {
24246
+ if (__gclass__$10) {
24247
+ log_error(`GClass ALREADY created: ${gclass_name}`);
24248
+ return -1;
24249
+ }
24250
+ const states = [["ST_IDLE", [
24251
+ [
24252
+ "EV_SET_DESCRIPTION",
24253
+ ac_set_description,
24254
+ null
24255
+ ],
24256
+ [
24257
+ "EV_SET_VIEW_MODE",
24258
+ ac_set_view_mode,
24259
+ null
24260
+ ],
24261
+ [
24262
+ "EV_TOGGLE_ZONE",
24263
+ ac_toggle_zone,
24264
+ null
24265
+ ],
24266
+ [
24267
+ "EV_SET_MACHINE_VIEW",
24268
+ ac_set_machine_view,
24269
+ null
24270
+ ],
24271
+ [
24272
+ "EV_SEARCH",
24273
+ ac_search$1,
24274
+ null
24275
+ ],
24276
+ [
24277
+ "EV_COPY_ALL",
24278
+ ac_copy_all,
24279
+ null
24280
+ ],
24281
+ [
24282
+ "EV_LANGUAGE_CHANGED",
24283
+ ac_language_changed$6,
24284
+ null
24285
+ ],
24286
+ [
24287
+ "EV_REFRESH",
24288
+ ac_refresh$4,
24289
+ null
24290
+ ],
24291
+ [
24292
+ "EV_SHOW",
24293
+ ac_show$7,
24294
+ null
24295
+ ],
24296
+ [
24297
+ "EV_HIDE",
24298
+ ac_hide$6,
24299
+ null
24300
+ ],
24301
+ [
24302
+ "EV_SHOW_ALL",
24303
+ ac_show_all,
24304
+ null
24305
+ ],
24306
+ [
24307
+ "EV_SET_TRACES",
24308
+ ac_set_traces,
24309
+ null
24310
+ ],
24311
+ [
24312
+ "EV_GCLASS_TRACE_TOGGLED",
24313
+ ac_gclass_trace_toggled,
24314
+ null
24315
+ ],
24316
+ [
24317
+ "EV_GCLASS_TRACES_CLEARED",
24318
+ ac_gclass_traces_cleared,
24319
+ null
24320
+ ]
24321
+ ]]];
24322
+ const event_types = [
24323
+ ["EV_SET_DESCRIPTION", 0],
24324
+ ["EV_SET_VIEW_MODE", 0],
24325
+ ["EV_TOGGLE_ZONE", 0],
24326
+ ["EV_SET_MACHINE_VIEW", 0],
24327
+ ["EV_SEARCH", 0],
24328
+ ["EV_COPY_ALL", 0],
24329
+ ["EV_LANGUAGE_CHANGED", 0],
24330
+ ["EV_REFRESH", 0],
24331
+ ["EV_SHOW", 0],
24332
+ ["EV_HIDE", 0],
24333
+ ["EV_SHOW_ALL", 0],
24334
+ ["EV_SET_TRACES", 0],
24335
+ ["EV_GCLASS_TRACE_TOGGLED", 0],
24336
+ ["EV_GCLASS_TRACES_CLEARED", 0],
24337
+ ["EV_SET_GCLASS_TRACE", event_flag_t.EVF_OUTPUT_EVENT]
24338
+ ];
24339
+ __gclass__$10 = gclass_create(gclass_name, event_types, states, gmt$10, 0, attrs_table$10, PRIVATE_DATA$10, 0, 0, 0, 0);
24340
+ if (!__gclass__$10) return -1;
24341
+ return 0;
24342
+ }
24343
+ /***************************************************************
24344
+ * Register GClass
24345
+ ***************************************************************/
24346
+ function register_c_yui_gclass() {
24347
+ if (gclass_find_by_name(GCLASS_NAME$10, false)) return 0;
24348
+ if (!gclass_find_by_name("C_YUI_FSM_GRAPH", false)) register_c_yui_fsm_graph();
24349
+ return create_gclass$10(GCLASS_NAME$10);
23954
24350
  }
23955
24351
  //#endregion
23956
24352
  //#region src/gclass_describe.js
@@ -24167,6 +24563,15 @@ function gclass_view_available() {
24167
24563
  * current_state the state the INSTANCE the reader came
24168
24564
  * from is in, lit in the machine. Omitted,
24169
24565
  * nothing is lit.
24566
+ * instance_name the name of that instance, said beside its
24567
+ * state (a gclass has several).
24568
+ * traces {info, pending}: the host can set this
24569
+ * gclass' traces for every gobj of it. The
24570
+ * viewer then publishes EV_SET_GCLASS_TRACE
24571
+ * {gclass, levels, set} to the HOST (it is its
24572
+ * child), which declares it, and is handed what
24573
+ * the backend says next with EV_SET_TRACES.
24574
+ * Omitted: the levels are only listed.
24170
24575
  * title_prefix what the window says before the gclass
24171
24576
  * name (the yuno it belongs to).
24172
24577
  * on_close called when the reader dismisses it.
@@ -24196,6 +24601,8 @@ function open_gclass_view(host, gclass_name, opts) {
24196
24601
  description,
24197
24602
  gclass_name,
24198
24603
  current_state: opts.current_state || "",
24604
+ instance_name: opts.instance_name || "",
24605
+ traces: opts.traces || null,
24199
24606
  subscriber: null
24200
24607
  }, host);
24201
24608
  if (!jv) {
@@ -51093,24 +51500,41 @@ function yui_graph_minimap_repaint(plugin) {
51093
51500
  * out EV_TRACE_INFO_WANTED {gclass} a card was opened
51094
51501
  * in EV_TRACE_INFO {gclass, gclass_levels, global_levels,
51095
51502
  * gclass_on, global_on, error}
51096
- * out EV_SET_TRACE_LEVEL {scope: "gobj"|"gclass", gobj,
51097
- * gclass, levels: [...], set}
51503
+ * out EV_SET_TRACE_LEVEL {scope: "gobj"|"gclass"|"global",
51504
+ * gobj, gclass, levels: [...], set}
51098
51505
  * out EV_GCLASS_WANTED {gclass} the gclass button
51099
51506
  * in EV_GCLASS_DESCRIPTION {gclass, description}
51100
51507
  *
51101
51508
  * The host loads the FIRST tree on its own (it opened the
51102
51509
  * view); the view asks again only when Refresh is pressed.
51103
51510
  * After a trace is set the host loads the tree and the
51104
- * trace info again: the card the reader is on stays open.
51105
- *
51106
- * In "remote" the popover of a card has a TRACES block: one
51107
- * row per level (the gclass' own, then the global ones), a
51108
- * checkbox for THIS gobj (`set-gobj-trace`) and one for every
51109
- * gobj of its gclass (`set-gclass-trace`). A level that is on
51110
- * for the gclass, or globally, is shown on and locked in the
51111
- * gobj column, with where it comes from: it cannot be turned
51112
- * off from one gobj. A gclass level is saved by the yuno and
51113
- * survives a restart; a gobj level lasts until the yuno ends.
51511
+ * trace info of `gclass` again: what the reader is on stays
51512
+ * open.
51513
+ *
51514
+ * TRACES, in "remote": three scopes, each where it belongs.
51515
+ * The kernel's levels (`machine`, `create_delete`...; the
51516
+ * table gobj.c calls "global") are valid in all three, a
51517
+ * gclass' own levels in the first two:
51518
+ *
51519
+ * this gobj the popover of its card: one box per
51520
+ * level (`set-gobj-trace`). A level its
51521
+ * gclass or the yuno holds is on and
51522
+ * locked, saying which.
51523
+ * every gobj of the gclass viewer the card's GClass
51524
+ * the gclass button opens: its `trace levels` zone
51525
+ * (`set-gclass-trace`). The viewer is this
51526
+ * view's child and publishes
51527
+ * EV_SET_GCLASS_TRACE {gclass, levels, set},
51528
+ * which goes out as EV_SET_TRACE_LEVEL.
51529
+ * the whole yuno the toolbar's `traces of the yuno`, in
51530
+ * the popover (`set-global-trace`). Its
51531
+ * levels are read with EV_TRACE_INFO_WANTED
51532
+ * of the ROOT's gclass, whose answer
51533
+ * carries them like every other one.
51534
+ *
51535
+ * A gclass or yuno level is saved by the yuno and survives a
51536
+ * restart; so does a gobj level of a named service (SDK
51537
+ * 7.27.3+). Any other gobj's level lasts until the yuno ends.
51114
51538
  *
51115
51539
  * The output events are published ONLY in "remote", so a host
51116
51540
  * of a local tree (the Frontend view) declares none of them.
@@ -51293,6 +51717,8 @@ var PRIVATE_DATA$9 = {
51293
51717
  remote_root: null,
51294
51718
  trace_info: {},
51295
51719
  trace_pending: false,
51720
+ popover_mode: "",
51721
+ viewer_stale: "",
51296
51722
  view_refused: false
51297
51723
  };
51298
51724
  var __gclass__$9 = null;
@@ -51946,12 +52372,43 @@ function make_toolbar$1(gobj) {
51946
52372
  },
51947
52373
  options
51948
52374
  ]],
51949
- { change: (evt) => {
51950
- let value = evt.target.value;
51951
- gobj_send_event(gobj, "EV_CHANGE_LAYOUT", { layout: value }, gobj);
52375
+ { change: (evt) => {
52376
+ let value = evt.target.value;
52377
+ gobj_send_event(gobj, "EV_CHANGE_LAYOUT", { layout: value }, gobj);
52378
+ } }
52379
+ ]);
52380
+ priv.$layout_select = $wrap.querySelector("select");
52381
+ if (is_remote(gobj)) right_items.push(createElement2([
52382
+ "button",
52383
+ {
52384
+ type: "button",
52385
+ class: "GOBJ_TREE_YUNO_TRACES_BUTTON button",
52386
+ style: {
52387
+ height: toolbar_wide,
52388
+ "margin-left": "0.5em"
52389
+ },
52390
+ title: t("traces of the yuno"),
52391
+ "data-i18n-title": "traces of the yuno",
52392
+ "aria-label": t("traces of the yuno"),
52393
+ "data-i18n-aria-label": "traces of the yuno"
52394
+ },
52395
+ [[
52396
+ "span",
52397
+ { class: "icon" },
52398
+ [["i", { class: "yi-list-check" }]]
52399
+ ], [
52400
+ "span",
52401
+ {
52402
+ class: "is-hidden-mobile",
52403
+ i18n: "traces of the yuno"
52404
+ },
52405
+ t("traces of the yuno")
52406
+ ]],
52407
+ { click: (evt) => {
52408
+ evt.stopPropagation();
52409
+ gobj_send_event(gobj, "EV_OPEN_YUNO_TRACES", {}, gobj);
51952
52410
  } }
51953
- ]);
51954
- priv.$layout_select = $wrap.querySelector("select");
52411
+ ]));
51955
52412
  right_items.push($wrap);
51956
52413
  const $toolbar = yui_toolbar({}, [
51957
52414
  [
@@ -52562,18 +53019,110 @@ function is_remote(gobj) {
52562
53019
  return gobj_read_str_attr(gobj, "source") === "remote";
52563
53020
  }
52564
53021
  /************************************************************
52565
- * The TRACES block of a backend gobj's popover.
53022
+ * Paint again whatever the popover is showing: a card, or
53023
+ * the yuno's traces.
53024
+ ************************************************************/
53025
+ function render_current_popover(gobj) {
53026
+ let priv = gobj.priv;
53027
+ if (!priv.$popover || priv.$popover.style.display !== "block") return;
53028
+ if (priv.popover_mode === "yuno") {
53029
+ priv.$popover_body.textContent = "";
53030
+ priv.$popover_body.appendChild(build_yuno_traces_block(gobj));
53031
+ } else if (priv.popover_node) render_popover_body(gobj, priv.popover_node);
53032
+ }
53033
+ /************************************************************
53034
+ * The TRACES block of a backend gobj's popover: what THIS
53035
+ * gobj traces (`set-gobj-trace`), one row per level -- the
53036
+ * gclass' own, then the kernel's (trace_rows() in the model).
52566
53037
  *
52567
- * Two columns of checkboxes, THIS gobj and every gobj of its
52568
- * gclass, one row per level (trace_rows() in the model says
52569
- * what each row holds). A box is an action: its change is
52570
- * sent to the FSM, which publishes it to the host, and the
52571
- * block stays locked until the host has loaded what the
52572
- * backend says now -- the box shows the backend's state, not
52573
- * the click.
53038
+ * ONE scope here, the gobj's. The other two live where they
53039
+ * belong: every gobj of the gclass in the gclass viewer (its
53040
+ * `trace levels` zone), the whole yuno behind the toolbar's
53041
+ * `traces of the yuno`. A level one of them holds is shown on
53042
+ * and LOCKED here, saying which one, because unticking the
53043
+ * gobj's own bit would not stop it.
53044
+ *
53045
+ * A box is an action: its change goes to the FSM, which
53046
+ * publishes it to the host, and the block stays locked until
53047
+ * the host has loaded what the backend says now -- the box
53048
+ * shows the backend's state, not the click.
52574
53049
  ************************************************************/
52575
53050
  var TRACES_NOTE_STYLE = "color:var(--bulma-text-weak, #6B7280); margin:4px 0;";
52576
53051
  var TRACES_CELL_STYLE = "padding:1px 4px; text-align:center;";
53052
+ var TRACES_ORIGIN_STYLE = "margin-left:6px; color:var(--bulma-text-weak, #6B7280);";
53053
+ var TRACES_BUTTON_STYLE = "padding:0 8px; height:22px; font-size:11px; white-space:nowrap;";
53054
+ function traces_state_note(info) {
53055
+ if (!info) return [
53056
+ "div",
53057
+ {
53058
+ class: "GOBJ_TREE_TRACES_NOTE",
53059
+ i18n: "loading",
53060
+ style: TRACES_NOTE_STYLE
53061
+ },
53062
+ t("loading")
53063
+ ];
53064
+ if (info.error) return [
53065
+ "div",
53066
+ {
53067
+ class: "GOBJ_TREE_TRACES_ERROR",
53068
+ style: "color:var(--bulma-danger, #dc2626); margin:4px 0;"
53069
+ },
53070
+ text_node(info.error)
53071
+ ];
53072
+ return null;
53073
+ }
53074
+ function trace_level_cell(level, description, $origin) {
53075
+ let $level = createElement2([
53076
+ "td",
53077
+ {
53078
+ class: "GOBJ_TREE_TRACES_LEVEL",
53079
+ style: "padding:1px 4px; word-break:break-all;"
53080
+ },
53081
+ []
53082
+ ]);
53083
+ $level.appendChild(text_node(level));
53084
+ if ($origin) $level.appendChild($origin);
53085
+ $level.setAttribute("title", description);
53086
+ return $level;
53087
+ }
53088
+ function trace_group_row(span, $label) {
53089
+ return [
53090
+ "tr",
53091
+ { class: "GOBJ_TREE_TRACES_GROUP" },
53092
+ [[
53093
+ "td",
53094
+ {
53095
+ colspan: span,
53096
+ style: "padding:4px 4px 1px 4px; font-weight:600; color:var(--bulma-text-weak, #6B7280);"
53097
+ },
53098
+ [$label]
53099
+ ]]
53100
+ ];
53101
+ }
53102
+ function traces_remove_button(gobj, scope, names, $label, disabled) {
53103
+ let $b = createElement2([
53104
+ "button",
53105
+ Object.assign({
53106
+ type: "button",
53107
+ class: `GOBJ_TREE_TRACES_CLEAR_${scope.toUpperCase()} button is-small`,
53108
+ style: TRACES_BUTTON_STYLE
53109
+ }, names),
53110
+ [$label],
53111
+ { click: (evt) => {
53112
+ evt.stopPropagation();
53113
+ gobj_send_event(gobj, "EV_TRACES_CLEARED", { scope }, gobj);
53114
+ } }
53115
+ ]);
53116
+ $b.disabled = !!disabled;
53117
+ return createElement2([
53118
+ "div",
53119
+ {
53120
+ class: "GOBJ_TREE_TRACES_TOOLS",
53121
+ style: "display:flex; flex-wrap:wrap; gap:4px; margin-top:4px;"
53122
+ },
53123
+ [$b]
53124
+ ]);
53125
+ }
52577
53126
  function build_traces_block(gobj, d) {
52578
53127
  let priv = gobj.priv;
52579
53128
  let info = priv.trace_info[d.gclass] || null;
@@ -52581,36 +53130,14 @@ function build_traces_block(gobj, d) {
52581
53130
  "div",
52582
53131
  {
52583
53132
  class: "GOBJ_TREE_TRACES_HEAD",
52584
- i18n: "traces",
53133
+ i18n: "traces of this gobj",
52585
53134
  style: "font-weight:700; margin:8px 0 2px 0; padding-top:6px; border-top:1px solid var(--bulma-border-weak, #E5E7EB);"
52586
53135
  },
52587
- t("traces")
53136
+ t("traces of this gobj")
52588
53137
  ]];
52589
- if (!info) {
52590
- kids.push([
52591
- "div",
52592
- {
52593
- class: "GOBJ_TREE_TRACES_NOTE",
52594
- i18n: "loading",
52595
- style: TRACES_NOTE_STYLE
52596
- },
52597
- t("loading")
52598
- ]);
52599
- return createElement2([
52600
- "div",
52601
- { class: "GOBJ_TREE_TRACES" },
52602
- kids
52603
- ]);
52604
- }
52605
- if (info.error) {
52606
- kids.push([
52607
- "div",
52608
- {
52609
- class: "GOBJ_TREE_TRACES_ERROR",
52610
- style: "color:var(--bulma-danger, #dc2626); margin:4px 0;"
52611
- },
52612
- text_node(info.error)
52613
- ]);
53138
+ let state = traces_state_note(info);
53139
+ if (state) {
53140
+ kids.push(state);
52614
53141
  return createElement2([
52615
53142
  "div",
52616
53143
  { class: "GOBJ_TREE_TRACES" },
@@ -52624,70 +53151,42 @@ function build_traces_block(gobj, d) {
52624
53151
  for (let r of rows) {
52625
53152
  if (r.group !== group) {
52626
53153
  group = r.group;
52627
- let $label = group === "gclass" ? text_node(d.gclass) : createElement2([
53154
+ trs.push(trace_group_row(2, group === "gclass" ? text_node(d.gclass) : createElement2([
52628
53155
  "span",
52629
- { i18n: "global" },
52630
- t("global")
52631
- ]);
52632
- trs.push([
52633
- "tr",
52634
- { class: "GOBJ_TREE_TRACES_GROUP" },
52635
- [[
52636
- "td",
52637
- {
52638
- colspan: 3,
52639
- style: "padding:4px 4px 1px 4px; font-weight:600; color:var(--bulma-text-weak, #6B7280);"
52640
- },
52641
- [$label]
52642
- ]]
52643
- ]);
53156
+ { i18n: "kernel levels" },
53157
+ t("kernel levels")
53158
+ ])));
52644
53159
  }
52645
- let origin = null;
52646
- if (r.origin === "global") origin = [
53160
+ let $origin = null;
53161
+ if (r.origin === "global") $origin = createElement2([
52647
53162
  "span",
52648
53163
  {
52649
53164
  class: "GOBJ_TREE_TRACES_ORIGIN",
52650
- i18n: "global",
52651
- style: "margin-left:6px; color:var(--bulma-text-weak, #6B7280);"
53165
+ i18n: "yuno",
53166
+ style: TRACES_ORIGIN_STYLE,
53167
+ title: t("on for the whole yuno"),
53168
+ "data-i18n-title": "on for the whole yuno"
52652
53169
  },
52653
- t("global")
52654
- ];
52655
- else if (r.origin === "gclass") origin = [
53170
+ t("yuno")
53171
+ ]);
53172
+ else if (r.origin === "gclass") $origin = createElement2([
52656
53173
  "span",
52657
53174
  {
52658
53175
  class: "GOBJ_TREE_TRACES_ORIGIN",
52659
- i18n: "gclass",
52660
- style: "margin-left:6px; color:var(--bulma-text-weak, #6B7280);"
52661
- },
52662
- t("gclass")
52663
- ];
52664
- let $level = createElement2([
52665
- "td",
52666
- {
52667
- class: "GOBJ_TREE_TRACES_LEVEL",
52668
- style: "padding:1px 4px; word-break:break-all;"
53176
+ style: TRACES_ORIGIN_STYLE,
53177
+ title: t("on for all of the gclass"),
53178
+ "data-i18n-title": "on for all of the gclass"
52669
53179
  },
52670
- []
53180
+ [text_node(d.gclass)]
52671
53181
  ]);
52672
- $level.appendChild(text_node(r.level));
52673
- if (origin) $level.appendChild(createElement2(origin));
52674
- $level.setAttribute("title", r.description);
52675
53182
  trs.push([
52676
53183
  "tr",
52677
53184
  { class: "GOBJ_TREE_TRACES_ROW" },
52678
- [
52679
- $level,
52680
- [
52681
- "td",
52682
- { style: TRACES_CELL_STYLE },
52683
- [trace_checkbox(gobj, "gobj", r.level, r.gobj_on, pending || r.gobj_locked)]
52684
- ],
52685
- [
52686
- "td",
52687
- { style: TRACES_CELL_STYLE },
52688
- [trace_checkbox(gobj, "gclass", r.level, r.gclass_on, pending || r.gclass_locked)]
52689
- ]
52690
- ]
53185
+ [trace_level_cell(r.level, r.description, $origin), [
53186
+ "td",
53187
+ { style: TRACES_CELL_STYLE },
53188
+ [trace_checkbox(gobj, "gobj", r.level, r.gobj_on, pending || r.gobj_locked)]
53189
+ ]]
52691
53190
  ]);
52692
53191
  }
52693
53192
  kids.push([
@@ -52702,32 +53201,21 @@ function build_traces_block(gobj, d) {
52702
53201
  [[
52703
53202
  "tr",
52704
53203
  {},
52705
- [
52706
- [
52707
- "th",
52708
- {
52709
- i18n: "level",
52710
- style: "padding:1px 4px; text-align:left;"
52711
- },
52712
- t("level")
52713
- ],
52714
- [
52715
- "th",
52716
- {
52717
- i18n: "this gobj",
52718
- style: TRACES_CELL_STYLE
52719
- },
52720
- t("this gobj")
52721
- ],
52722
- [
52723
- "th",
52724
- {
52725
- i18n: "all of the gclass",
52726
- style: TRACES_CELL_STYLE
52727
- },
52728
- t("all of the gclass")
52729
- ]
52730
- ]
53204
+ [[
53205
+ "th",
53206
+ {
53207
+ i18n: "level",
53208
+ style: "padding:1px 4px; text-align:left;"
53209
+ },
53210
+ t("level")
53211
+ ], [
53212
+ "th",
53213
+ {
53214
+ i18n: "this gobj",
53215
+ style: TRACES_CELL_STYLE
53216
+ },
53217
+ t("this gobj")
53218
+ ]]
52731
53219
  ]]
52732
53220
  ], [
52733
53221
  "tbody",
@@ -52735,87 +53223,149 @@ function build_traces_block(gobj, d) {
52735
53223
  trs
52736
53224
  ]]
52737
53225
  ]);
52738
- kids.push([
53226
+ kids.push(d.service ? [
52739
53227
  "div",
52740
53228
  {
52741
53229
  class: "GOBJ_TREE_TRACES_NOTE",
52742
- i18n: "gclass traces survive a restart, gobj traces end with the yuno",
53230
+ i18n: "the traces of a service survive a restart",
52743
53231
  style: TRACES_NOTE_STYLE
52744
53232
  },
52745
- t("gclass traces survive a restart, gobj traces end with the yuno")
52746
- ]);
52747
- let none_gobj = pending || own_trace_levels(rows, "gobj").length === 0;
52748
- let none_gclass = pending || own_trace_levels(rows, "gclass").length === 0;
52749
- let btn_style = "padding:0 8px; height:22px; font-size:11px; white-space:nowrap;";
52750
- let clear = (scope) => {
52751
- return { click: (evt) => {
52752
- evt.stopPropagation();
52753
- gobj_send_event(gobj, "EV_TRACES_CLEARED", { scope }, gobj);
52754
- } };
52755
- };
52756
- let $clear_gobj = createElement2([
52757
- "button",
53233
+ t("the traces of a service survive a restart")
53234
+ ] : [
53235
+ "div",
52758
53236
  {
52759
- type: "button",
52760
- class: "GOBJ_TREE_TRACES_CLEAR_GOBJ button is-small",
52761
- style: btn_style,
52762
- i18n: "remove the traces of this gobj",
52763
- title: t("remove the traces of this gobj"),
52764
- "data-i18n-title": "remove the traces of this gobj",
52765
- "aria-label": t("remove the traces of this gobj"),
52766
- "data-i18n-aria-label": "remove the traces of this gobj"
52767
- },
52768
- t("remove the traces of this gobj"),
52769
- clear("gobj")
53237
+ class: "GOBJ_TREE_TRACES_NOTE",
53238
+ i18n: "the traces of a gobj that is not a service end with the yuno",
53239
+ style: TRACES_NOTE_STYLE
53240
+ },
53241
+ t("the traces of a gobj that is not a service end with the yuno")
52770
53242
  ]);
52771
- let $clear_gclass = createElement2([
52772
- "button",
53243
+ kids.push(traces_remove_button(gobj, "gobj", {
53244
+ title: t("remove the traces of this gobj"),
53245
+ "data-i18n-title": "remove the traces of this gobj",
53246
+ "aria-label": t("remove the traces of this gobj"),
53247
+ "data-i18n-aria-label": "remove the traces of this gobj"
53248
+ }, createElement2([
53249
+ "span",
53250
+ { i18n: "remove the traces of this gobj" },
53251
+ t("remove the traces of this gobj")
53252
+ ]), pending || own_trace_levels(rows, "gobj").length === 0));
53253
+ return createElement2([
53254
+ "div",
53255
+ { class: "GOBJ_TREE_TRACES" },
53256
+ kids
53257
+ ]);
53258
+ }
53259
+ /************************************************************
53260
+ * The yuno's traces (`set-global-trace`): the kernel's levels,
53261
+ * and whether every gobj of the yuno traces each one. Drawn in
53262
+ * the popover, opened from the toolbar, and read from the
53263
+ * answer for the ROOT's gclass -- the yuno itself, whose
53264
+ * answer carries the yuno's levels like every other one.
53265
+ ************************************************************/
53266
+ function build_yuno_traces_block(gobj) {
53267
+ let priv = gobj.priv;
53268
+ let root = priv.remote_root;
53269
+ let info = root && priv.trace_info[root.gclass] || null;
53270
+ let kids = [];
53271
+ let state = traces_state_note(info);
53272
+ if (state) {
53273
+ kids.push(state);
53274
+ return createElement2([
53275
+ "div",
53276
+ { class: "GOBJ_TREE_YUNO_TRACES" },
53277
+ kids
53278
+ ]);
53279
+ }
53280
+ let rows = global_trace_rows(info);
53281
+ let pending = !!priv.trace_pending;
53282
+ let trs = rows.map((r) => [
53283
+ "tr",
53284
+ { class: "GOBJ_TREE_TRACES_ROW" },
53285
+ [trace_level_cell(r.level, r.description, null), [
53286
+ "td",
53287
+ { style: TRACES_CELL_STYLE },
53288
+ [trace_checkbox(gobj, "global", r.level, r.global_on, pending)]
53289
+ ]]
53290
+ ]);
53291
+ kids.push([
53292
+ "table",
52773
53293
  {
52774
- type: "button",
52775
- class: "GOBJ_TREE_TRACES_CLEAR_GCLASS button is-small",
52776
- style: btn_style,
52777
- i18n: "remove the traces of the gclass",
52778
- title: t("remove the traces of the gclass"),
52779
- "data-i18n-title": "remove the traces of the gclass",
52780
- "aria-label": t("remove the traces of the gclass"),
52781
- "data-i18n-aria-label": "remove the traces of the gclass"
53294
+ class: "GOBJ_TREE_TRACES_TABLE",
53295
+ style: "width:100%; border-collapse:collapse;"
52782
53296
  },
52783
- t("remove the traces of the gclass"),
52784
- clear("gclass")
53297
+ [[
53298
+ "thead",
53299
+ {},
53300
+ [[
53301
+ "tr",
53302
+ {},
53303
+ [[
53304
+ "th",
53305
+ {
53306
+ i18n: "kernel levels",
53307
+ style: "padding:1px 4px; text-align:left;"
53308
+ },
53309
+ t("kernel levels")
53310
+ ], [
53311
+ "th",
53312
+ {
53313
+ i18n: "the whole yuno",
53314
+ style: TRACES_CELL_STYLE
53315
+ },
53316
+ t("the whole yuno")
53317
+ ]]
53318
+ ]]
53319
+ ], [
53320
+ "tbody",
53321
+ {},
53322
+ trs
53323
+ ]]
52785
53324
  ]);
52786
- $clear_gobj.disabled = none_gobj;
52787
- $clear_gclass.disabled = none_gclass;
52788
53325
  kids.push([
52789
53326
  "div",
52790
53327
  {
52791
- class: "GOBJ_TREE_TRACES_TOOLS",
52792
- style: "display:flex; flex-wrap:wrap; gap:4px; margin-top:4px;"
53328
+ class: "GOBJ_TREE_TRACES_NOTE",
53329
+ i18n: "the yuno's traces survive a restart",
53330
+ style: TRACES_NOTE_STYLE
52793
53331
  },
52794
- [$clear_gobj, $clear_gclass]
53332
+ t("the yuno's traces survive a restart")
52795
53333
  ]);
53334
+ kids.push(traces_remove_button(gobj, "global", {
53335
+ title: t("remove the traces of the yuno"),
53336
+ "data-i18n-title": "remove the traces of the yuno",
53337
+ "aria-label": t("remove the traces of the yuno"),
53338
+ "data-i18n-aria-label": "remove the traces of the yuno"
53339
+ }, createElement2([
53340
+ "span",
53341
+ { i18n: "remove the traces of the yuno" },
53342
+ t("remove the traces of the yuno")
53343
+ ]), pending || own_trace_levels(rows, "global").length === 0));
52796
53344
  return createElement2([
52797
53345
  "div",
52798
- { class: "GOBJ_TREE_TRACES" },
53346
+ { class: "GOBJ_TREE_YUNO_TRACES" },
52799
53347
  kids
52800
53348
  ]);
52801
53349
  }
53350
+ var TRACE_BOX = {
53351
+ gobj: {
53352
+ cls: "GOBJ_TREE_TRACE_GOBJ",
53353
+ key: "this gobj"
53354
+ },
53355
+ global: {
53356
+ cls: "GOBJ_TREE_TRACE_GLOBAL",
53357
+ key: "the whole yuno"
53358
+ }
53359
+ };
52802
53360
  function trace_checkbox(gobj, scope, level, on, locked) {
52803
- let $cb = null;
52804
- if (scope === "gobj") $cb = createElement2(["input", {
52805
- type: "checkbox",
52806
- class: "GOBJ_TREE_TRACE_GOBJ",
52807
- title: t("this gobj"),
52808
- "data-i18n-title": "this gobj",
52809
- "aria-label": t("this gobj"),
52810
- "data-i18n-aria-label": "this gobj"
52811
- }]);
52812
- else $cb = createElement2(["input", {
53361
+ const box = TRACE_BOX[scope];
53362
+ let $cb = createElement2(["input", {
52813
53363
  type: "checkbox",
52814
- class: "GOBJ_TREE_TRACE_GCLASS",
52815
- title: t("all of the gclass"),
52816
- "data-i18n-title": "all of the gclass",
52817
- "aria-label": t("all of the gclass"),
52818
- "data-i18n-aria-label": "all of the gclass"
53364
+ class: box.cls,
53365
+ title: t(box.key),
53366
+ "data-i18n-title": box.key,
53367
+ "aria-label": t(box.key),
53368
+ "data-i18n-aria-label": box.key
52819
53369
  }]);
52820
53370
  $cb.setAttribute("data-level", level);
52821
53371
  $cb.checked = !!on;
@@ -52838,21 +53388,28 @@ function trace_checkbox(gobj, scope, level, on, locked) {
52838
53388
  function reload_keeping_popover(gobj, opts) {
52839
53389
  let priv = gobj.priv;
52840
53390
  let $popover = priv.$popover;
52841
- let keep = priv.popover_node && $popover && $popover.style.display === "block" ? priv.popover_node.full_name : null;
53391
+ let shown = !!($popover && $popover.style.display === "block");
53392
+ let keep = shown && priv.popover_mode === "node" && priv.popover_node ? priv.popover_node.full_name : null;
53393
+ let keep_yuno = shown && priv.popover_mode === "yuno";
52842
53394
  let left = $popover ? $popover.style.left : "";
52843
53395
  let top = $popover ? $popover.style.top : "";
52844
53396
  refresh_tree(gobj, opts);
53397
+ if (keep_yuno) {
53398
+ open_popover_frame(gobj, "yuno", t("traces of the yuno"));
53399
+ $popover.style.left = left;
53400
+ $popover.style.top = top;
53401
+ render_current_popover(gobj);
53402
+ return;
53403
+ }
52845
53404
  if (!keep || !priv.node_by_id) return;
52846
53405
  for (let id of Object.keys(priv.node_by_id)) {
52847
53406
  let d = priv.node_by_id[id];
52848
53407
  if (d.full_name === keep) {
52849
53408
  priv.popover_node = d;
52850
- priv.$popover_title.textContent = d.short_name || d.gclass + (d.name ? "^" + d.name : "");
52851
- priv.$popover_title.title = priv.$popover_title.textContent;
53409
+ open_popover_frame(gobj, "node", d.short_name || d.gclass + (d.name ? "^" + d.name : ""));
52852
53410
  render_popover_body(gobj, d);
52853
53411
  $popover.style.left = left;
52854
53412
  $popover.style.top = top;
52855
- $popover.style.display = "block";
52856
53413
  return;
52857
53414
  }
52858
53415
  }
@@ -52869,8 +53426,7 @@ function show_popover(gobj, node_data, client_x, client_y) {
52869
53426
  let $container = gobj_read_attr(gobj, "$container");
52870
53427
  if (!$popover || !$title || !$container) return;
52871
53428
  priv.popover_node = node_data;
52872
- $title.textContent = node_data.short_name || node_data.gclass + (node_data.name ? "^" + node_data.name : "");
52873
- $title.title = $title.textContent;
53429
+ open_popover_frame(gobj, "node", node_data.short_name || node_data.gclass + (node_data.name ? "^" + node_data.name : ""));
52874
53430
  render_popover_body(gobj, node_data);
52875
53431
  let rect = $container.getBoundingClientRect();
52876
53432
  let offset = 10;
@@ -52900,6 +53456,41 @@ function hide_popover(gobj) {
52900
53456
  if (priv.$popover_body) priv.$popover_body.innerHTML = "";
52901
53457
  if (priv.$popover_title) priv.$popover_title.textContent = "";
52902
53458
  priv.popover_node = null;
53459
+ priv.popover_mode = "";
53460
+ }
53461
+ /************************************************************
53462
+ * The popover's frame for what it is about to show: its
53463
+ * title, and the gclass button only for a card -- the yuno's
53464
+ * traces are no gclass of their own.
53465
+ ************************************************************/
53466
+ function open_popover_frame(gobj, mode, title) {
53467
+ let priv = gobj.priv;
53468
+ priv.popover_mode = mode;
53469
+ priv.$popover_title.textContent = title;
53470
+ priv.$popover_title.title = title;
53471
+ if (priv.$popover_gclass) priv.$popover_gclass.classList.toggle("is-hidden", mode !== "node");
53472
+ priv.$popover.style.display = "block";
53473
+ }
53474
+ /************************************************************
53475
+ * The yuno's traces, in the popover, under the toolbar
53476
+ * button that opened them.
53477
+ ************************************************************/
53478
+ function show_yuno_traces(gobj) {
53479
+ let priv = gobj.priv;
53480
+ let $popover = priv.$popover;
53481
+ let $container = gobj_read_attr(gobj, "$container");
53482
+ if (!$popover || !$container) return;
53483
+ priv.popover_node = null;
53484
+ open_popover_frame(gobj, "yuno", t("traces of the yuno"));
53485
+ render_current_popover(gobj);
53486
+ let rect = $container.getBoundingClientRect();
53487
+ let $btn = $container.querySelector(".GOBJ_TREE_YUNO_TRACES_BUTTON");
53488
+ let b = $btn ? $btn.getBoundingClientRect() : null;
53489
+ let pop = $popover.getBoundingClientRect();
53490
+ let left = b ? b.right - rect.left - pop.width : rect.width - pop.width - 8;
53491
+ let top = b ? b.bottom - rect.top + 6 : 8;
53492
+ $popover.style.left = Math.max(4, left) + "px";
53493
+ $popover.style.top = Math.max(4, top) + "px";
52903
53494
  }
52904
53495
  /************************************************************
52905
53496
  * Generic tree layout engine.
@@ -53507,7 +54098,7 @@ function ac_open_gclass(gobj, event, kw, src) {
53507
54098
  gobj_publish_event(gobj, "EV_GCLASS_WANTED", { gclass: node_data.gclass });
53508
54099
  return 0;
53509
54100
  }
53510
- open_gclass_window(gobj, node_data.gclass, null, node_data.state || "");
54101
+ open_gclass_window(gobj, node_data.gclass, null, node_data);
53511
54102
  return 0;
53512
54103
  }
53513
54104
  /************************************************************
@@ -53520,22 +54111,24 @@ function ac_gclass_description(gobj, event, kw, src) {
53520
54111
  return -1;
53521
54112
  }
53522
54113
  let d = priv.popover_node;
53523
- open_gclass_window(gobj, kw.gclass, kw.description, d && d.gclass === kw.gclass ? d.state || "" : "");
54114
+ open_gclass_window(gobj, kw.gclass, kw.description, d && d.gclass === kw.gclass ? d : null);
53524
54115
  return 0;
53525
54116
  }
53526
- function open_gclass_window(gobj, gclass, description, state) {
54117
+ function open_gclass_window(gobj, gclass, description, d) {
53527
54118
  let priv = gobj.priv;
53528
54119
  close_gclass_view(priv.gclass_view);
53529
54120
  priv.gclass_view = null;
53530
54121
  let opts = {
53531
54122
  title_prefix: is_remote(gobj) ? gobj_read_str_attr(gobj, "yuno_name") || "" : gobj_yuno_name() || "",
53532
- current_state: state,
54123
+ current_state: d && d.state || "",
54124
+ instance_name: d && d.name || "",
53533
54125
  on_close: () => {
53534
54126
  if (gobj_is_destroying(gobj)) return;
53535
54127
  gobj_send_event(gobj, "EV_GCLASS_CLOSED", {}, gobj);
53536
54128
  }
53537
54129
  };
53538
54130
  if (description) opts.description = description;
54131
+ if (is_remote(gobj)) opts.traces = viewer_traces(gobj, gclass);
53539
54132
  priv.gclass_view = open_gclass_view(gobj, gclass, opts);
53540
54133
  }
53541
54134
  /************************************************************
@@ -53592,57 +54185,143 @@ function ac_trace_info(gobj, event, kw, src) {
53592
54185
  };
53593
54186
  priv.trace_pending = false;
53594
54187
  let d = priv.popover_node;
53595
- if (d && d.gclass === kw.gclass && priv.$popover && priv.$popover.style.display === "block") render_popover_body(gobj, d);
54188
+ let root = priv.remote_root;
54189
+ if (priv.popover_mode === "node" && d && d.gclass === kw.gclass || priv.popover_mode === "yuno" && root && root.gclass === kw.gclass) render_current_popover(gobj);
54190
+ let viewer = gclass_viewer_gobj(gobj);
54191
+ if (viewer) {
54192
+ let shown = gobj_read_str_attr(viewer, "gclass_name");
54193
+ if (shown === kw.gclass) gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
54194
+ else if (priv.viewer_stale === shown) gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54195
+ }
54196
+ priv.viewer_stale = "";
53596
54197
  return 0;
53597
54198
  }
53598
54199
  /************************************************************
54200
+ * The gclass viewer this view opened, while it is open.
54201
+ ************************************************************/
54202
+ function gclass_viewer_gobj(gobj) {
54203
+ let h = gobj.priv.gclass_view;
54204
+ return h && h.json_gobj && !gobj_is_destroying(h.json_gobj) ? h.json_gobj : null;
54205
+ }
54206
+ /************************************************************
54207
+ * What the gclass viewer needs to draw the traces of `gclass`
54208
+ * for every gobj of it: the levels the host read, and whether a
54209
+ * set is still in flight. Plain json: it rides in a kw.
54210
+ ************************************************************/
54211
+ function viewer_traces(gobj, gclass) {
54212
+ let priv = gobj.priv;
54213
+ return {
54214
+ info: priv.trace_info[gclass] || null,
54215
+ pending: !!priv.trace_pending
54216
+ };
54217
+ }
54218
+ /************************************************************
53599
54219
  * A box of the TRACES block was ticked or cleared.
53600
54220
  ************************************************************/
53601
54221
  function ac_trace_toggled(gobj, event, kw, src) {
53602
- let d = gobj.priv.popover_node;
53603
- if (!is_remote(gobj) || !d) {
53604
- log_error(`${gobj_short_name(gobj)}: a trace set with no backend card open`);
54222
+ if (!kw.level) {
54223
+ log_error(`${gobj_short_name(gobj)}: a trace set of no level, scope '${kw.scope}'`);
53605
54224
  return -1;
53606
54225
  }
53607
- if (!kw.level || kw.scope !== "gobj" && kw.scope !== "gclass") {
53608
- log_error(`${gobj_short_name(gobj)}: a trace set of no level or scope: '${kw.scope}' '${kw.level}'`);
53609
- return -1;
53610
- }
53611
- set_trace_levels(gobj, d, kw.scope, [kw.level], !!kw.set);
54226
+ let target = trace_target(gobj, kw.scope);
54227
+ if (!target) return -1;
54228
+ set_trace_levels(gobj, target, kw.scope, [kw.level], !!kw.set);
53612
54229
  return 0;
53613
54230
  }
53614
54231
  /************************************************************
54232
+ * What a set of `scope` acts on: the card the popover is on
54233
+ * (gobj), or the yuno itself, the root (global). Null, and
54234
+ * logged, when the popover is not showing it.
54235
+ ************************************************************/
54236
+ function trace_target(gobj, scope) {
54237
+ let priv = gobj.priv;
54238
+ if (!is_remote(gobj)) {
54239
+ log_error(`${gobj_short_name(gobj)}: a trace set on a tree that is not remote`);
54240
+ return null;
54241
+ }
54242
+ if (scope === "gobj") {
54243
+ if (priv.popover_mode !== "node" || !priv.popover_node) {
54244
+ log_error(`${gobj_short_name(gobj)}: a gobj trace set with no backend card open`);
54245
+ return null;
54246
+ }
54247
+ return priv.popover_node;
54248
+ }
54249
+ if (scope === "global") {
54250
+ if (priv.popover_mode !== "yuno" || !priv.remote_root) {
54251
+ log_error(`${gobj_short_name(gobj)}: a yuno trace set with the yuno's traces closed`);
54252
+ return null;
54253
+ }
54254
+ return priv.remote_root;
54255
+ }
54256
+ log_error(`${gobj_short_name(gobj)}: a trace set of no scope the popover has: '${scope}'`);
54257
+ return null;
54258
+ }
54259
+ /************************************************************
53615
54260
  * "Remove the traces" of the gobj or of its gclass: every
53616
54261
  * level that scope holds on its own.
53617
54262
  ************************************************************/
53618
54263
  function ac_traces_cleared(gobj, event, kw, src) {
53619
54264
  let priv = gobj.priv;
53620
- let d = priv.popover_node;
53621
- if (!is_remote(gobj) || !d) {
53622
- log_error(`${gobj_short_name(gobj)}: traces removed with no backend card open`);
54265
+ let target = trace_target(gobj, kw.scope);
54266
+ if (!target) return -1;
54267
+ let info = priv.trace_info[target.gclass];
54268
+ let levels = own_trace_levels(kw.scope === "global" ? global_trace_rows(info) : trace_rows(target, info), kw.scope);
54269
+ if (!levels.length) {
54270
+ log_error(`${gobj_short_name(gobj)}: no ${kw.scope} trace of ${target.full_name} to remove`);
53623
54271
  return -1;
53624
54272
  }
53625
- let levels = own_trace_levels(trace_rows(d, priv.trace_info[d.gclass]), kw.scope);
53626
- if (!levels.length) {
53627
- log_error(`${gobj_short_name(gobj)}: no ${kw.scope} trace of ${d.full_name} to remove`);
54273
+ set_trace_levels(gobj, target, kw.scope, levels, false);
54274
+ return 0;
54275
+ }
54276
+ /************************************************************
54277
+ * The gclass viewer asked for a set of every gobj of its
54278
+ * gclass ({gclass, levels, set}).
54279
+ ************************************************************/
54280
+ function ac_set_gclass_trace(gobj, event, kw, src) {
54281
+ let levels = kw && Array.isArray(kw.levels) ? kw.levels : [];
54282
+ if (!is_remote(gobj) || !kw.gclass || !levels.length) {
54283
+ log_error(`${gobj_short_name(gobj)}: a gclass trace set of no gclass or level, or on a tree that is not remote: '${kw && kw.gclass}'`);
53628
54284
  return -1;
53629
54285
  }
53630
- set_trace_levels(gobj, d, kw.scope, levels, false);
54286
+ set_trace_levels(gobj, {
54287
+ full_name: "",
54288
+ gclass: kw.gclass
54289
+ }, "gclass", levels, !!kw.set);
53631
54290
  return 0;
53632
54291
  }
53633
- function set_trace_levels(gobj, d, scope, levels, set) {
54292
+ function set_trace_levels(gobj, target, scope, levels, set) {
53634
54293
  let priv = gobj.priv;
53635
54294
  priv.trace_pending = true;
53636
- render_popover_body(gobj, d);
54295
+ render_current_popover(gobj);
54296
+ let viewer = gclass_viewer_gobj(gobj);
54297
+ if (viewer) {
54298
+ let shown = gobj_read_str_attr(viewer, "gclass_name");
54299
+ if (scope === "global" && shown !== target.gclass) priv.viewer_stale = shown;
54300
+ gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
54301
+ }
53637
54302
  gobj_publish_event(gobj, "EV_SET_TRACE_LEVEL", {
53638
54303
  scope,
53639
- gobj: d.full_name,
53640
- gclass: d.gclass,
54304
+ gobj: target.full_name || "",
54305
+ gclass: target.gclass,
53641
54306
  levels,
53642
54307
  set
53643
54308
  });
53644
54309
  }
53645
54310
  /************************************************************
54311
+ * The toolbar's "traces of the yuno": the popover shows the
54312
+ * yuno's scope, read from the answer for the root's gclass.
54313
+ ************************************************************/
54314
+ function ac_open_yuno_traces(gobj, event, kw, src) {
54315
+ let root = gobj.priv.remote_root;
54316
+ if (!is_remote(gobj) || !root) {
54317
+ log_error(`${gobj_short_name(gobj)}: the yuno's traces asked with no backend tree loaded`);
54318
+ return -1;
54319
+ }
54320
+ show_yuno_traces(gobj);
54321
+ gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", { gclass: root.gclass });
54322
+ return 0;
54323
+ }
54324
+ /************************************************************
53646
54325
  * The app switched language.
53647
54326
  *
53648
54327
  * A rebuild, not a re-translation: the words live inside the
@@ -53798,6 +54477,16 @@ function create_gclass$9(gclass_name) {
53798
54477
  "EV_GCLASS_DESCRIPTION",
53799
54478
  ac_gclass_description,
53800
54479
  null
54480
+ ],
54481
+ [
54482
+ "EV_OPEN_YUNO_TRACES",
54483
+ ac_open_yuno_traces,
54484
+ null
54485
+ ],
54486
+ [
54487
+ "EV_SET_GCLASS_TRACE",
54488
+ ac_set_gclass_trace,
54489
+ null
53801
54490
  ]
53802
54491
  ]]];
53803
54492
  const event_types = [
@@ -53826,6 +54515,8 @@ function create_gclass$9(gclass_name) {
53826
54515
  ["EV_TRACE_TOGGLED", 0],
53827
54516
  ["EV_TRACES_CLEARED", 0],
53828
54517
  ["EV_GCLASS_DESCRIPTION", 0],
54518
+ ["EV_OPEN_YUNO_TRACES", 0],
54519
+ ["EV_SET_GCLASS_TRACE", 0],
53829
54520
  ["EV_TREE_WANTED", event_flag_t.EVF_OUTPUT_EVENT],
53830
54521
  ["EV_TRACE_INFO_WANTED", event_flag_t.EVF_OUTPUT_EVENT],
53831
54522
  ["EV_SET_TRACE_LEVEL", event_flag_t.EVF_OUTPUT_EVENT],