@yuneta/gobj-ui 7.27.20 → 7.27.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -606,6 +606,12 @@ view came back at the top of a page whose rows were drawn for the bottom, and
606
606
  showed nothing. Now only the node's chrome (navs, path) is rebuilt when the
607
607
  active child is the one already hanging in its body.
608
608
 
609
+ **A content shown again is told so** (7.27.21+). A node keeps the content it
610
+ built, as the shell keeps a `keep_alive` view, so a content that reads its data
611
+ only when it is created declares `EV_VIEW_SHOWN` and reads it again there: the
612
+ node sends it when it comes back to that content, and forwards the shell's down
613
+ its path when the whole tree is shown again (SHELL.md §4).
614
+
609
615
  **The tree is a contract, not runtime state.** Once published, a node's path
610
616
  is a url a client may have bookmarked, scripted, or been sold as another door
611
617
  into the system. So there is deliberately **no reparent/move API**: the shape
@@ -5071,7 +5077,7 @@ whose keys `validate-locales` reads in its `app_config.json`.
5071
5077
  **A key the reader cannot follow is PUBLISHED by its module** (since
5072
5078
  `7.26.27`): an exported `<NAME>_I18N_KEYS` array of string literals, which
5073
5079
  `validate-locales` reads in every module the app mounts and asks the locales
5074
- for. `yui_dev.js` publishes the 51 keys of the Developer window
5080
+ for. `yui_dev.js` publishes the 53 keys of the Developer window
5075
5081
  (`YUI_DEV_I18N_KEYS`) -- they used to be a comment each consumer copied, and
5076
5082
  one consumer lacked 35 --, `c_g6_nodes_tree.js` those of its shape tables,
5077
5083
  popover labels, floating buttons and error messages
@@ -1691,6 +1691,7 @@ function build_ui$19(gobj) {
1691
1691
  priv.stages[stage_name] = {
1692
1692
  el: priv.zones[zone],
1693
1693
  items: {},
1694
+ shown: {},
1694
1695
  active_route: null
1695
1696
  };
1696
1697
  if (priv.zones[zone]) priv.zones[zone].classList.add("yui-stage", `yui-stage-${stage_name}`);
@@ -1704,6 +1705,7 @@ function build_ui$19(gobj) {
1704
1705
  priv.stages[name] = {
1705
1706
  el: priv.zones[id],
1706
1707
  items: {},
1708
+ shown: {},
1707
1709
  active_route: null
1708
1710
  };
1709
1711
  if (priv.zones[id]) priv.zones[id].classList.add("yui-stage", `yui-stage-${name}`);
@@ -1714,6 +1716,7 @@ function build_ui$19(gobj) {
1714
1716
  priv.stages.main = {
1715
1717
  el: priv.zones.center,
1716
1718
  items: {},
1719
+ shown: {},
1717
1720
  active_route: null
1718
1721
  };
1719
1722
  priv.zones.center.classList.add("yui-stage", "yui-stage-main");
@@ -2102,9 +2105,11 @@ function navigate_to(gobj, route, depth, no_drain) {
2102
2105
  }
2103
2106
  if ($prev && $prev.parentNode) $prev.parentNode.removeChild($prev);
2104
2107
  delete stage.items[prev_route];
2108
+ delete stage.shown[prev_route];
2105
2109
  }
2106
2110
  }
2107
2111
  let cur = stage.items[matched_route];
2112
+ let reshown = !!cur && !!stage.shown[matched_route] && prev_route !== matched_route;
2108
2113
  if (!cur) {
2109
2114
  cur = build_view_gobj(gobj, entry, matched_route, stage);
2110
2115
  if (!cur) return;
@@ -2113,6 +2118,7 @@ function navigate_to(gobj, route, depth, no_drain) {
2113
2118
  let $c = (0, _yuneta_gobj_js.gobj_read_attr)(cur, "$container");
2114
2119
  if ($c) $c.classList.remove("is-hidden");
2115
2120
  stage.active_route = matched_route;
2121
+ stage.shown[matched_route] = true;
2116
2122
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "current_route", route);
2117
2123
  remember_position(gobj, route);
2118
2124
  remember_route(gobj, route);
@@ -2138,6 +2144,11 @@ function navigate_to(gobj, route, depth, no_drain) {
2138
2144
  stage: stage_name,
2139
2145
  menu_id: entry.menu_id || ""
2140
2146
  });
2147
+ if (reshown && (0, _yuneta_gobj_js.gobj_has_event)(cur, "EV_VIEW_SHOWN")) (0, _yuneta_gobj_js.gobj_send_event)(cur, "EV_VIEW_SHOWN", {
2148
+ route,
2149
+ base: matched_route,
2150
+ subpath
2151
+ }, gobj);
2141
2152
  }
2142
2153
  function build_view_gobj(gobj, entry, route, stage) {
2143
2154
  let priv = gobj.priv;
@@ -26388,6 +26399,10 @@ function register_c_yui_gobj_tree_js() {
26388
26399
  * - flags EVF_PUBLIC_EVENT on what arrives from the backend
26389
26400
  * (EV_MT_COMMAND_ANSWER and anything the remote publishes): the
26390
26401
  * ievent drops events that are not public.
26402
+ * - MAY declare EV_VIEW_SHOWN: the shell (or a C_YUI_NODE) sends
26403
+ * it here when it shows a hidden view again, and this host
26404
+ * hands it on -- the place to read again the data the view
26405
+ * read only when it was created.
26391
26406
  *
26392
26407
  * NAMES: the service name must be UNIQUE per mount. A duplicate is
26393
26408
  * not fatal and that is the danger — gobj-js logs "service ALREADY
@@ -26553,6 +26568,18 @@ function mt_destroy$8(gobj) {
26553
26568
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "$container", null);
26554
26569
  }
26555
26570
  /***************************
26571
+ * Actions
26572
+ ***************************/
26573
+ /************************************************************
26574
+ * The shell shows me again after hiding me (`keep_alive`):
26575
+ * the hosted view is the one that may want to know.
26576
+ ************************************************************/
26577
+ function ac_view_shown(gobj, event, kw, src) {
26578
+ const view = gobj.priv.view;
26579
+ if (view && (0, _yuneta_gobj_js.gobj_has_event)(view, event)) (0, _yuneta_gobj_js.gobj_send_event)(view, event, kw, gobj);
26580
+ return 0;
26581
+ }
26582
+ /***************************
26556
26583
  * FSM
26557
26584
  ***************************/
26558
26585
  var gmt$8 = {
@@ -26566,7 +26593,11 @@ function create_gclass$8(gclass_name) {
26566
26593
  (0, _yuneta_gobj_js.log_error)(`GClass ALREADY created: ${gclass_name}`);
26567
26594
  return -1;
26568
26595
  }
26569
- __gclass__$8 = (0, _yuneta_gobj_js.gclass_create)(gclass_name, [], [["ST_IDLE", []]], gmt$8, 0, attrs_table$8, PRIVATE_DATA$8, 0, 0, 0, 0);
26596
+ __gclass__$8 = (0, _yuneta_gobj_js.gclass_create)(gclass_name, [["EV_VIEW_SHOWN", 0]], [["ST_IDLE", [[
26597
+ "EV_VIEW_SHOWN",
26598
+ ac_view_shown,
26599
+ null
26600
+ ]]]], gmt$8, 0, attrs_table$8, PRIVATE_DATA$8, 0, 0, 0, 0);
26570
26601
  return __gclass__$8 ? 0 : -1;
26571
26602
  }
26572
26603
  function register_c_yui_service_view() {
@@ -85150,8 +85181,11 @@ function dir_arrow(dir) {
85150
85181
  function dev_num(key, def) {
85151
85182
  return Number((0, _yuneta_gobj_js.kw_get_local_storage_value)(key, def === void 0 ? 0 : def, false));
85152
85183
  }
85184
+ function traffic_view_of(v) {
85185
+ return v === "expanded" || v === "line" ? v : "collapsed";
85186
+ }
85153
85187
  function dev_traffic_view() {
85154
- return (0, _yuneta_gobj_js.kw_get_local_storage_value)("dev_traffic_view", "collapsed", false) === "expanded" ? "expanded" : "collapsed";
85188
+ return traffic_view_of((0, _yuneta_gobj_js.kw_get_local_storage_value)("dev_traffic_view", "collapsed", false));
85155
85189
  }
85156
85190
  function dev_traces_payload() {
85157
85191
  return dev_num("dev_traces_payload", 1) ? 1 : 0;
@@ -85173,7 +85207,12 @@ function console_traffic(title, jn, direction, size) {
85173
85207
  let kw = jn && jn.kw && typeof jn.kw === "object" ? jn.kw : jn;
85174
85208
  let color = direction === 2 ? "#16a34a" : direction === 3 ? "#dc2626" : "#2563eb";
85175
85209
  let head = "%c" + dir_arrow(direction) + " " + (title ? "[" + title + "] " : "") + event + (size ? " (" + size + "b)" : "");
85176
- if (dev_traffic_view() === "expanded") {
85210
+ let view = dev_traffic_view();
85211
+ if (view === "line") {
85212
+ window.console.log(head, "color:" + color);
85213
+ return;
85214
+ }
85215
+ if (view === "expanded") {
85177
85216
  let text;
85178
85217
  try {
85179
85218
  text = JSON.stringify(full_sections(kw), null, 4);
@@ -85186,7 +85225,7 @@ function console_traffic(title, jn, direction, size) {
85186
85225
  window.console.log(head, "color:" + color, kw);
85187
85226
  }
85188
85227
  function set_traffic_view(v) {
85189
- (0, _yuneta_gobj_js.kw_set_local_storage_value)("dev_traffic_view", v === "expanded" ? "expanded" : "collapsed");
85228
+ (0, _yuneta_gobj_js.kw_set_local_storage_value)("dev_traffic_view", traffic_view_of(v));
85190
85229
  rerender_all();
85191
85230
  refresh_dev_chrome();
85192
85231
  }
@@ -85355,6 +85394,9 @@ function ensure_dev_style() {
85355
85394
  .TRAFFIC_ENTRY.dir-out { border-left-color: #2563eb; }
85356
85395
  .TRAFFIC_ENTRY.dir-in { border-left-color: #059669; }
85357
85396
  .TRAFFIC_ENTRY.dir-err { border-left-color: #dc2626; }
85397
+ /* The line view: one row per message, no margin between rows, so a burst
85398
+ of messages reads as a list. */
85399
+ .TRAFFIC_ENTRY.TRAFFIC_NAME { margin: 1px 0; padding: 1px 8px; line-height: 1.45; display: flex; align-items: baseline; gap: 8px; }
85358
85400
  .TRAFFIC_HEADER { display: flex; align-items: baseline; gap: 8px; }
85359
85401
  .TRAFFIC_ARROW { font-weight: 700; }
85360
85402
  .TRAFFIC_EVENT { font-weight: 700; }
@@ -85746,6 +85788,19 @@ function render_full(e) {
85746
85788
  children
85747
85789
  ]);
85748
85790
  }
85791
+ function render_name(e) {
85792
+ let kids = event_spans(e);
85793
+ kids.push([
85794
+ "span",
85795
+ { class: "TRAFFIC_META" },
85796
+ `${traffic_size(e.size)} · ${e.ts}`
85797
+ ]);
85798
+ return (0, _yuneta_gobj_js.createElement2)([
85799
+ "div",
85800
+ { class: "TRAFFIC_ENTRY TRAFFIC_NAME " + dir_class(e.dir) },
85801
+ kids
85802
+ ]);
85803
+ }
85749
85804
  function render_log(e) {
85750
85805
  let $row = (0, _yuneta_gobj_js.createElement2)([
85751
85806
  "div",
@@ -85774,7 +85829,9 @@ function render_log(e) {
85774
85829
  }
85775
85830
  function render_entry(e) {
85776
85831
  if (e.kind === "log") return render_log(e);
85777
- if (dev_traffic_view() === "expanded") return render_full(e);
85832
+ let view = dev_traffic_view();
85833
+ if (view === "line") return render_name(e);
85834
+ if (view === "expanded") return render_full(e);
85778
85835
  return render_detailed(e);
85779
85836
  }
85780
85837
  /******************************
@@ -86146,7 +86203,9 @@ function traffic_to_text() {
86146
86203
  }
86147
86204
  let head = `${e.ts} ${dir_arrow(e.dir)} ${e.title ? "[" + e.title + "] " : ""}${e.event}${e.command ? " " + e.command : ""}`;
86148
86205
  out.push(head);
86149
- if (dev_traffic_view() !== "expanded" && e.$node) {
86206
+ let view = dev_traffic_view();
86207
+ if (view === "line") continue;
86208
+ if (view !== "expanded" && e.$node) {
86150
86209
  out.push(...entry_shown_lines(e.$node));
86151
86210
  out.push("");
86152
86211
  continue;
@@ -86242,6 +86301,7 @@ function build_control_bar() {
86242
86301
  } }
86243
86302
  ];
86244
86303
  let VIEW_TITLES = {
86304
+ line: "traffic one line per message",
86245
86305
  collapsed: "traffic payload folded",
86246
86306
  expanded: "traffic payload laid out"
86247
86307
  };
@@ -86269,7 +86329,11 @@ function build_control_bar() {
86269
86329
  class: "YDEV_SEG",
86270
86330
  id: "ydev-seg"
86271
86331
  },
86272
- [mk_view("collapsed", "collapsed"), mk_view("expanded", "expanded")]
86332
+ [
86333
+ mk_view("line", "one line"),
86334
+ mk_view("collapsed", "collapsed"),
86335
+ mk_view("expanded", "expanded")
86336
+ ]
86273
86337
  ];
86274
86338
  let OUT_TITLES = {
86275
86339
  window: "dev window only",
@@ -1686,6 +1686,7 @@ function build_ui$19(gobj) {
1686
1686
  priv.stages[stage_name] = {
1687
1687
  el: priv.zones[zone],
1688
1688
  items: {},
1689
+ shown: {},
1689
1690
  active_route: null
1690
1691
  };
1691
1692
  if (priv.zones[zone]) priv.zones[zone].classList.add("yui-stage", `yui-stage-${stage_name}`);
@@ -1699,6 +1700,7 @@ function build_ui$19(gobj) {
1699
1700
  priv.stages[name] = {
1700
1701
  el: priv.zones[id],
1701
1702
  items: {},
1703
+ shown: {},
1702
1704
  active_route: null
1703
1705
  };
1704
1706
  if (priv.zones[id]) priv.zones[id].classList.add("yui-stage", `yui-stage-${name}`);
@@ -1709,6 +1711,7 @@ function build_ui$19(gobj) {
1709
1711
  priv.stages.main = {
1710
1712
  el: priv.zones.center,
1711
1713
  items: {},
1714
+ shown: {},
1712
1715
  active_route: null
1713
1716
  };
1714
1717
  priv.zones.center.classList.add("yui-stage", "yui-stage-main");
@@ -2097,9 +2100,11 @@ function navigate_to(gobj, route, depth, no_drain) {
2097
2100
  }
2098
2101
  if ($prev && $prev.parentNode) $prev.parentNode.removeChild($prev);
2099
2102
  delete stage.items[prev_route];
2103
+ delete stage.shown[prev_route];
2100
2104
  }
2101
2105
  }
2102
2106
  let cur = stage.items[matched_route];
2107
+ let reshown = !!cur && !!stage.shown[matched_route] && prev_route !== matched_route;
2103
2108
  if (!cur) {
2104
2109
  cur = build_view_gobj(gobj, entry, matched_route, stage);
2105
2110
  if (!cur) return;
@@ -2108,6 +2113,7 @@ function navigate_to(gobj, route, depth, no_drain) {
2108
2113
  let $c = gobj_read_attr(cur, "$container");
2109
2114
  if ($c) $c.classList.remove("is-hidden");
2110
2115
  stage.active_route = matched_route;
2116
+ stage.shown[matched_route] = true;
2111
2117
  gobj_write_attr(gobj, "current_route", route);
2112
2118
  remember_position(gobj, route);
2113
2119
  remember_route(gobj, route);
@@ -2133,6 +2139,11 @@ function navigate_to(gobj, route, depth, no_drain) {
2133
2139
  stage: stage_name,
2134
2140
  menu_id: entry.menu_id || ""
2135
2141
  });
2142
+ if (reshown && gobj_has_event(cur, "EV_VIEW_SHOWN")) gobj_send_event(cur, "EV_VIEW_SHOWN", {
2143
+ route,
2144
+ base: matched_route,
2145
+ subpath
2146
+ }, gobj);
2136
2147
  }
2137
2148
  function build_view_gobj(gobj, entry, route, stage) {
2138
2149
  let priv = gobj.priv;
@@ -26383,6 +26394,10 @@ function register_c_yui_gobj_tree_js() {
26383
26394
  * - flags EVF_PUBLIC_EVENT on what arrives from the backend
26384
26395
  * (EV_MT_COMMAND_ANSWER and anything the remote publishes): the
26385
26396
  * ievent drops events that are not public.
26397
+ * - MAY declare EV_VIEW_SHOWN: the shell (or a C_YUI_NODE) sends
26398
+ * it here when it shows a hidden view again, and this host
26399
+ * hands it on -- the place to read again the data the view
26400
+ * read only when it was created.
26386
26401
  *
26387
26402
  * NAMES: the service name must be UNIQUE per mount. A duplicate is
26388
26403
  * not fatal and that is the danger — gobj-js logs "service ALREADY
@@ -26548,6 +26563,18 @@ function mt_destroy$8(gobj) {
26548
26563
  gobj_write_attr(gobj, "$container", null);
26549
26564
  }
26550
26565
  /***************************
26566
+ * Actions
26567
+ ***************************/
26568
+ /************************************************************
26569
+ * The shell shows me again after hiding me (`keep_alive`):
26570
+ * the hosted view is the one that may want to know.
26571
+ ************************************************************/
26572
+ function ac_view_shown(gobj, event, kw, src) {
26573
+ const view = gobj.priv.view;
26574
+ if (view && gobj_has_event(view, event)) gobj_send_event(view, event, kw, gobj);
26575
+ return 0;
26576
+ }
26577
+ /***************************
26551
26578
  * FSM
26552
26579
  ***************************/
26553
26580
  var gmt$8 = {
@@ -26561,7 +26588,11 @@ function create_gclass$8(gclass_name) {
26561
26588
  log_error(`GClass ALREADY created: ${gclass_name}`);
26562
26589
  return -1;
26563
26590
  }
26564
- __gclass__$8 = gclass_create(gclass_name, [], [["ST_IDLE", []]], gmt$8, 0, attrs_table$8, PRIVATE_DATA$8, 0, 0, 0, 0);
26591
+ __gclass__$8 = gclass_create(gclass_name, [["EV_VIEW_SHOWN", 0]], [["ST_IDLE", [[
26592
+ "EV_VIEW_SHOWN",
26593
+ ac_view_shown,
26594
+ null
26595
+ ]]]], gmt$8, 0, attrs_table$8, PRIVATE_DATA$8, 0, 0, 0, 0);
26565
26596
  return __gclass__$8 ? 0 : -1;
26566
26597
  }
26567
26598
  function register_c_yui_service_view() {
@@ -85145,8 +85176,11 @@ function dir_arrow(dir) {
85145
85176
  function dev_num(key, def) {
85146
85177
  return Number(kw_get_local_storage_value(key, def === void 0 ? 0 : def, false));
85147
85178
  }
85179
+ function traffic_view_of(v) {
85180
+ return v === "expanded" || v === "line" ? v : "collapsed";
85181
+ }
85148
85182
  function dev_traffic_view() {
85149
- return kw_get_local_storage_value("dev_traffic_view", "collapsed", false) === "expanded" ? "expanded" : "collapsed";
85183
+ return traffic_view_of(kw_get_local_storage_value("dev_traffic_view", "collapsed", false));
85150
85184
  }
85151
85185
  function dev_traces_payload() {
85152
85186
  return dev_num("dev_traces_payload", 1) ? 1 : 0;
@@ -85168,7 +85202,12 @@ function console_traffic(title, jn, direction, size) {
85168
85202
  let kw = jn && jn.kw && typeof jn.kw === "object" ? jn.kw : jn;
85169
85203
  let color = direction === 2 ? "#16a34a" : direction === 3 ? "#dc2626" : "#2563eb";
85170
85204
  let head = "%c" + dir_arrow(direction) + " " + (title ? "[" + title + "] " : "") + event + (size ? " (" + size + "b)" : "");
85171
- if (dev_traffic_view() === "expanded") {
85205
+ let view = dev_traffic_view();
85206
+ if (view === "line") {
85207
+ window.console.log(head, "color:" + color);
85208
+ return;
85209
+ }
85210
+ if (view === "expanded") {
85172
85211
  let text;
85173
85212
  try {
85174
85213
  text = JSON.stringify(full_sections(kw), null, 4);
@@ -85181,7 +85220,7 @@ function console_traffic(title, jn, direction, size) {
85181
85220
  window.console.log(head, "color:" + color, kw);
85182
85221
  }
85183
85222
  function set_traffic_view(v) {
85184
- kw_set_local_storage_value("dev_traffic_view", v === "expanded" ? "expanded" : "collapsed");
85223
+ kw_set_local_storage_value("dev_traffic_view", traffic_view_of(v));
85185
85224
  rerender_all();
85186
85225
  refresh_dev_chrome();
85187
85226
  }
@@ -85350,6 +85389,9 @@ function ensure_dev_style() {
85350
85389
  .TRAFFIC_ENTRY.dir-out { border-left-color: #2563eb; }
85351
85390
  .TRAFFIC_ENTRY.dir-in { border-left-color: #059669; }
85352
85391
  .TRAFFIC_ENTRY.dir-err { border-left-color: #dc2626; }
85392
+ /* The line view: one row per message, no margin between rows, so a burst
85393
+ of messages reads as a list. */
85394
+ .TRAFFIC_ENTRY.TRAFFIC_NAME { margin: 1px 0; padding: 1px 8px; line-height: 1.45; display: flex; align-items: baseline; gap: 8px; }
85353
85395
  .TRAFFIC_HEADER { display: flex; align-items: baseline; gap: 8px; }
85354
85396
  .TRAFFIC_ARROW { font-weight: 700; }
85355
85397
  .TRAFFIC_EVENT { font-weight: 700; }
@@ -85741,6 +85783,19 @@ function render_full(e) {
85741
85783
  children
85742
85784
  ]);
85743
85785
  }
85786
+ function render_name(e) {
85787
+ let kids = event_spans(e);
85788
+ kids.push([
85789
+ "span",
85790
+ { class: "TRAFFIC_META" },
85791
+ `${traffic_size(e.size)} · ${e.ts}`
85792
+ ]);
85793
+ return createElement2([
85794
+ "div",
85795
+ { class: "TRAFFIC_ENTRY TRAFFIC_NAME " + dir_class(e.dir) },
85796
+ kids
85797
+ ]);
85798
+ }
85744
85799
  function render_log(e) {
85745
85800
  let $row = createElement2([
85746
85801
  "div",
@@ -85769,7 +85824,9 @@ function render_log(e) {
85769
85824
  }
85770
85825
  function render_entry(e) {
85771
85826
  if (e.kind === "log") return render_log(e);
85772
- if (dev_traffic_view() === "expanded") return render_full(e);
85827
+ let view = dev_traffic_view();
85828
+ if (view === "line") return render_name(e);
85829
+ if (view === "expanded") return render_full(e);
85773
85830
  return render_detailed(e);
85774
85831
  }
85775
85832
  /******************************
@@ -86141,7 +86198,9 @@ function traffic_to_text() {
86141
86198
  }
86142
86199
  let head = `${e.ts} ${dir_arrow(e.dir)} ${e.title ? "[" + e.title + "] " : ""}${e.event}${e.command ? " " + e.command : ""}`;
86143
86200
  out.push(head);
86144
- if (dev_traffic_view() !== "expanded" && e.$node) {
86201
+ let view = dev_traffic_view();
86202
+ if (view === "line") continue;
86203
+ if (view !== "expanded" && e.$node) {
86145
86204
  out.push(...entry_shown_lines(e.$node));
86146
86205
  out.push("");
86147
86206
  continue;
@@ -86237,6 +86296,7 @@ function build_control_bar() {
86237
86296
  } }
86238
86297
  ];
86239
86298
  let VIEW_TITLES = {
86299
+ line: "traffic one line per message",
86240
86300
  collapsed: "traffic payload folded",
86241
86301
  expanded: "traffic payload laid out"
86242
86302
  };
@@ -86264,7 +86324,11 @@ function build_control_bar() {
86264
86324
  class: "YDEV_SEG",
86265
86325
  id: "ydev-seg"
86266
86326
  },
86267
- [mk_view("collapsed", "collapsed"), mk_view("expanded", "expanded")]
86327
+ [
86328
+ mk_view("line", "one line"),
86329
+ mk_view("collapsed", "collapsed"),
86330
+ mk_view("expanded", "expanded")
86331
+ ]
86268
86332
  ];
86269
86333
  let OUT_TITLES = {
86270
86334
  window: "dev window only",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.27.20",
3
+ "version": "7.27.22",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_node.js CHANGED
@@ -113,6 +113,7 @@ import {
113
113
  gobj_unsubscribe_event,
114
114
  gobj_send_event,
115
115
  gobj_post_event,
116
+ gobj_has_event,
116
117
  gobj_change_state,
117
118
  gobj_current_state,
118
119
  createElement2,
@@ -1070,6 +1071,9 @@ function activate(gobj, subpath, inherited_depth)
1070
1071
  {
1071
1072
  let priv = gobj.priv;
1072
1073
  let {head, tail} = head_tail(subpath);
1074
+ /* Coming back to a content I already built: it is told (EV_VIEW_SHOWN) */
1075
+ let back_to_content = !!priv.content_gobj &&
1076
+ gobj_current_state(gobj) !== "ST_SELF";
1073
1077
 
1074
1078
  let info = resolve_path_info(gobj, subpath, inherited_depth);
1075
1079
  priv.distance = info.distance;
@@ -1100,6 +1104,9 @@ function activate(gobj, subpath, inherited_depth)
1100
1104
  render_self(gobj);
1101
1105
  }
1102
1106
  forward_subpath(gobj, subpath);
1107
+ if(back_to_content) {
1108
+ tell_content_shown(gobj);
1109
+ }
1103
1110
  return "ST_SELF";
1104
1111
  }
1105
1112
 
@@ -1109,6 +1116,9 @@ function activate(gobj, subpath, inherited_depth)
1109
1116
  priv.active_child = null;
1110
1117
  }
1111
1118
  render_self(gobj);
1119
+ if(back_to_content) {
1120
+ tell_content_shown(gobj);
1121
+ }
1112
1122
  return "ST_SELF";
1113
1123
  }
1114
1124
 
@@ -1161,6 +1171,21 @@ function activate(gobj, subpath, inherited_depth)
1161
1171
  return "ST_CHILD";
1162
1172
  }
1163
1173
 
1174
+ /************************************************************
1175
+ * My content is on screen again after being hidden: a node
1176
+ * keeps the content it built, as the shell keeps a
1177
+ * `keep_alive` view, so the content may want to read again
1178
+ * what it read when it was created. Only a content that
1179
+ * declares EV_VIEW_SHOWN is told.
1180
+ ************************************************************/
1181
+ function tell_content_shown(gobj)
1182
+ {
1183
+ let content = gobj.priv.content_gobj;
1184
+ if(content && gobj_has_event(content, "EV_VIEW_SHOWN")) {
1185
+ gobj_send_event(content, "EV_VIEW_SHOWN", {route: route_of(gobj)}, gobj);
1186
+ }
1187
+ }
1188
+
1164
1189
  /************************************************************
1165
1190
  * Hand the data tail to the viewer, in the SAME shape the shell
1166
1191
  * gives a view (ROUTING.md §5): `base` is this node's canonical
@@ -1295,6 +1320,24 @@ function ac_activate(gobj, event, kw, src)
1295
1320
  return 0;
1296
1321
  }
1297
1322
 
1323
+ /************************************************************
1324
+ * The shell (or my parent) shows the tree again after hiding
1325
+ * it: down the path to the node on screen, which tells its
1326
+ * content.
1327
+ ************************************************************/
1328
+ function ac_view_shown(gobj, event, kw, src)
1329
+ {
1330
+ let priv = gobj.priv;
1331
+ if(gobj_current_state(gobj) === "ST_CHILD") {
1332
+ if(priv.active_child) {
1333
+ gobj_send_event(priv.active_child, event, kw, gobj);
1334
+ }
1335
+ return 0;
1336
+ }
1337
+ tell_content_shown(gobj);
1338
+ return 0;
1339
+ }
1340
+
1298
1341
  /************************************************************
1299
1342
  * My parent took me off the path.
1300
1343
  ************************************************************/
@@ -1812,6 +1855,7 @@ function create_gclass(gclass_name)
1812
1855
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1813
1856
  ["EV_SET_CONTENT", ac_set_content, null],
1814
1857
  ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1858
+ ["EV_VIEW_SHOWN", ac_view_shown, null],
1815
1859
  ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1816
1860
  ]],
1817
1861
  ["ST_CHILD", [
@@ -1828,6 +1872,7 @@ function create_gclass(gclass_name)
1828
1872
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1829
1873
  ["EV_SET_CONTENT", ac_set_content, null],
1830
1874
  ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1875
+ ["EV_VIEW_SHOWN", ac_view_shown, null],
1831
1876
  ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1832
1877
  ]]
1833
1878
  ];
@@ -1849,6 +1894,8 @@ function create_gclass(gclass_name)
1849
1894
  ["EV_SET_NAV_MODE", 0],
1850
1895
  ["EV_SET_CONTENT", 0],
1851
1896
  ["EV_NODE_TREE_CHANGED", 0],
1897
+ /* the shell or the parent shows the tree again (keep_alive) */
1898
+ ["EV_VIEW_SHOWN", 0],
1852
1899
  /* internal: posted to itself, the navs a render left */
1853
1900
  ["EV_DESTROY_NAVS", 0]
1854
1901
  ];
@@ -45,6 +45,10 @@
45
45
  * - flags EVF_PUBLIC_EVENT on what arrives from the backend
46
46
  * (EV_MT_COMMAND_ANSWER and anything the remote publishes): the
47
47
  * ievent drops events that are not public.
48
+ * - MAY declare EV_VIEW_SHOWN: the shell (or a C_YUI_NODE) sends
49
+ * it here when it shows a hidden view again, and this host
50
+ * hands it on -- the place to read again the data the view
51
+ * read only when it was created.
48
52
  *
49
53
  * NAMES: the service name must be UNIQUE per mount. A duplicate is
50
54
  * not fatal and that is the danger — gobj-js logs "service ALREADY
@@ -75,6 +79,8 @@ import {
75
79
  gobj_stop,
76
80
  gobj_is_running,
77
81
  gobj_short_name,
82
+ gobj_has_event,
83
+ gobj_send_event,
78
84
  is_gobj,
79
85
  is_string,
80
86
  empty_string,
@@ -306,6 +312,29 @@ function mt_destroy(gobj)
306
312
 
307
313
 
308
314
 
315
+ /***************************
316
+ * Actions
317
+ ***************************/
318
+
319
+
320
+
321
+
322
+ /************************************************************
323
+ * The shell shows me again after hiding me (`keep_alive`):
324
+ * the hosted view is the one that may want to know.
325
+ ************************************************************/
326
+ function ac_view_shown(gobj, event, kw, src)
327
+ {
328
+ const view = gobj.priv.view;
329
+ if(view && gobj_has_event(view, event)) {
330
+ gobj_send_event(view, event, kw, gobj);
331
+ }
332
+ return 0;
333
+ }
334
+
335
+
336
+
337
+
309
338
  /***************************
310
339
  * FSM
311
340
  ***************************/
@@ -328,10 +357,14 @@ function create_gclass(gclass_name)
328
357
  }
329
358
 
330
359
  const states = [
331
- ["ST_IDLE", []]
360
+ ["ST_IDLE", [
361
+ ["EV_VIEW_SHOWN", ac_view_shown, null]
362
+ ]]
332
363
  ];
333
364
 
334
- const event_types = [];
365
+ const event_types = [
366
+ ["EV_VIEW_SHOWN", 0]
367
+ ];
335
368
 
336
369
  __gclass__ = gclass_create(
337
370
  gclass_name,
@@ -1010,6 +1010,7 @@ function build_ui(gobj)
1010
1010
  priv.stages[stage_name] = {
1011
1011
  el: priv.zones[zone],
1012
1012
  items: {},
1013
+ shown: {}, /* routes whose view has been on screen */
1013
1014
  active_route: null
1014
1015
  };
1015
1016
  if(priv.zones[zone]) {
@@ -1023,7 +1024,7 @@ function build_ui(gobj)
1023
1024
  if(m) {
1024
1025
  let name = m[1];
1025
1026
  if(!priv.stages[name]) {
1026
- priv.stages[name] = { el: priv.zones[id], items: {}, active_route: null };
1027
+ priv.stages[name] = { el: priv.zones[id], items: {}, shown: {}, active_route: null };
1027
1028
  if(priv.zones[id]) {
1028
1029
  priv.zones[id].classList.add("yui-stage", `yui-stage-${name}`);
1029
1030
  }
@@ -1031,7 +1032,7 @@ function build_ui(gobj)
1031
1032
  }
1032
1033
  }
1033
1034
  if(!priv.stages.main && priv.zones.center) {
1034
- priv.stages.main = { el: priv.zones.center, items: {}, active_route: null };
1035
+ priv.stages.main = { el: priv.zones.center, items: {}, shown: {}, active_route: null };
1035
1036
  priv.zones.center.classList.add("yui-stage", "yui-stage-main");
1036
1037
  }
1037
1038
 
@@ -1812,11 +1813,16 @@ function navigate_to(gobj, route, depth, no_drain)
1812
1813
  $prev.parentNode.removeChild($prev);
1813
1814
  }
1814
1815
  delete stage.items[prev_route];
1816
+ delete stage.shown[prev_route];
1815
1817
  }
1816
1818
  }
1817
1819
 
1818
1820
  /* Show or create current (keyed by base route) */
1819
1821
  let cur = stage.items[matched_route];
1822
+ /* Shown before, hidden since, and on screen again: what EV_VIEW_SHOWN
1823
+ * tells it, below. A move inside the view (a subpath) is not one. */
1824
+ let reshown = !!cur && !!stage.shown[matched_route] &&
1825
+ prev_route !== matched_route;
1820
1826
  if(!cur) {
1821
1827
  cur = build_view_gobj(gobj, entry, matched_route, stage);
1822
1828
  if(!cur) {
@@ -1830,6 +1836,7 @@ function navigate_to(gobj, route, depth, no_drain)
1830
1836
  }
1831
1837
 
1832
1838
  stage.active_route = matched_route;
1839
+ stage.shown[matched_route] = true;
1833
1840
  gobj_write_attr(gobj, "current_route", route);
1834
1841
  remember_position(gobj, route);
1835
1842
  remember_route(gobj, route);
@@ -1883,6 +1890,21 @@ function navigate_to(gobj, route, depth, no_drain)
1883
1890
  stage: stage_name,
1884
1891
  menu_id: entry.menu_id || ""
1885
1892
  });
1893
+
1894
+ /* A `keep_alive` (or `eager`) view is hidden on exit, not destroyed,
1895
+ * so it keeps what it had -- a camera, a scroll, a half-filled form --
1896
+ * and also the data it read when it was created. A view that reads
1897
+ * its data only then and gets no events from the backend declares
1898
+ * EV_VIEW_SHOWN and reads it again here, keeping the rest. Sent after
1899
+ * EV_ROUTE_CHANGED, so the view is already at its position. A view
1900
+ * that does not declare it is not told. */
1901
+ if(reshown && gobj_has_event(cur, "EV_VIEW_SHOWN")) {
1902
+ gobj_send_event(cur, "EV_VIEW_SHOWN", {
1903
+ route: route,
1904
+ base: matched_route,
1905
+ subpath: subpath
1906
+ }, gobj);
1907
+ }
1886
1908
  }
1887
1909
 
1888
1910
  function build_view_gobj(gobj, entry, route, stage)
@@ -4218,6 +4240,7 @@ function prune_route(shell_gobj, route)
4218
4240
  log_warning(`C_YUI_SHELL: prune_route destroy '${route}' failed: ${e}`);
4219
4241
  }
4220
4242
  delete stage.items[route];
4243
+ delete stage.shown[route];
4221
4244
  if(stage.active_route === route) {
4222
4245
  stage.active_route = "";
4223
4246
  }
@@ -0,0 +1,192 @@
1
+ /***********************************************************************
2
+ * shell_view_shown.wiring.test.js
3
+ *
4
+ * EV_VIEW_SHOWN: a view the shell shows AGAIN after hiding it
5
+ * (`keep_alive`) is told so, if it declares the event, and
6
+ * C_YUI_SERVICE_VIEW hands it on to the view it hosts.
7
+ *
8
+ * Driven through the real C_YUI_SHELL on a document double.
9
+ *
10
+ * Copyright (c) 2026, ArtGins.
11
+ * All Rights Reserved.
12
+ ***********************************************************************/
13
+ import {describe, test, expect, beforeAll, beforeEach, afterEach} from "vitest";
14
+ import {install_dom_double} from "../test/dom_double.js";
15
+
16
+ install_dom_double();
17
+
18
+ const {
19
+ SDATA, SDATA_END, data_type_t, gclass_create, gobj_write_attr,
20
+ gobj_start_up, gobj_create_yuno, gobj_create, gobj_create_service,
21
+ gobj_start, gobj_stop, gobj_destroy, gobj_is_running, gobj_name,
22
+ set_log_callback,
23
+ } = await import("@yuneta/gobj-js");
24
+ const {register_c_yui_shell, yui_shell_navigate} = await import("./c_yui_shell.js");
25
+ const {register_c_yui_service_view} = await import("./c_yui_service_view.js");
26
+ const {register_c_yui_nav} = await import("./c_yui_nav.js");
27
+
28
+ const logged = [];
29
+ const alive = [];
30
+ const shown = []; /* {name, kw} per EV_VIEW_SHOWN received */
31
+ let yuno = null;
32
+ let seq = 0;
33
+
34
+ beforeAll(async () => {
35
+ const i18next = (await import("i18next")).default;
36
+ await i18next.init({lng: "en", resources: {}});
37
+ gobj_start_up(null, null, null, null, null, null, null);
38
+ set_log_callback((level, msg) => {
39
+ logged.push({level: String(level), msg: String(msg)});
40
+ });
41
+ gclass_create("C_TEST_SHOWN_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
42
+
43
+ const attrs = [
44
+ SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "view root"),
45
+ SDATA(data_type_t.DTP_POINTER, "gobj_remote_yuno", 0, null, "transport"),
46
+ SDATA_END()
47
+ ];
48
+ const gmt = {
49
+ mt_create: (gobj) => {
50
+ gobj_write_attr(gobj, "$container", document.createElement("div"));
51
+ }
52
+ };
53
+ /* A view that reads its data when created, and again when shown */
54
+ gclass_create(
55
+ "C_TEST_SHOWN_VIEW",
56
+ [["EV_VIEW_SHOWN", 0]],
57
+ [["ST_IDLE", [
58
+ ["EV_VIEW_SHOWN", (gobj, event, kw) => {
59
+ shown.push({name: gobj_name(gobj), kw: kw});
60
+ return 0;
61
+ }, null]
62
+ ]]],
63
+ gmt, 0, attrs, {}, 0, 0, 0, 0
64
+ );
65
+ /* A view that does not care */
66
+ gclass_create("C_TEST_PLAIN_VIEW", [], [["ST_IDLE", []]], gmt, 0, attrs, {}, 0, 0, 0, 0);
67
+
68
+ register_c_yui_shell();
69
+ register_c_yui_nav();
70
+ register_c_yui_service_view();
71
+ yuno = gobj_create_yuno("view_shown_yuno", "C_TEST_SHOWN_HOST", {});
72
+ gobj_start(yuno);
73
+ gobj_create_service("test_transport", "C_TEST_SHOWN_HOST", {}, yuno);
74
+ });
75
+
76
+ beforeEach(() => {
77
+ logged.length = 0;
78
+ shown.length = 0;
79
+ });
80
+
81
+ afterEach(() => {
82
+ for(const gobj of alive.splice(0)) {
83
+ if(gobj_is_running(gobj)) {
84
+ gobj_stop(gobj);
85
+ }
86
+ gobj_destroy(gobj);
87
+ }
88
+ });
89
+
90
+ function target(gclass, lifecycle, name)
91
+ {
92
+ return {stage: "main", gclass: gclass, kw: {}, lifecycle: lifecycle, name: name};
93
+ }
94
+
95
+ function config()
96
+ {
97
+ return {
98
+ shell: {
99
+ zones: {
100
+ left: {host: "menu.primary"},
101
+ center: {host: "stage.main"}
102
+ },
103
+ stages: {main: {zone: "center", default_route: "/kept"}}
104
+ },
105
+ menu: {
106
+ primary: {
107
+ render: {left: {layout: "vertical", icon_pos: "left"}},
108
+ items: [
109
+ {id: "kept", name: "kept", route: "/kept",
110
+ target: target("C_TEST_SHOWN_VIEW", "keep_alive", "kept_view")},
111
+ {id: "plain", name: "plain", route: "/plain",
112
+ target: target("C_TEST_PLAIN_VIEW", "keep_alive", "plain_view")},
113
+ {id: "gone", name: "gone", route: "/gone",
114
+ target: target("C_TEST_SHOWN_VIEW", "lazy_destroy", "gone_view")},
115
+ {id: "hosted", name: "hosted", route: "/hosted",
116
+ target: {
117
+ stage: "main", gclass: "C_YUI_SERVICE_VIEW", lifecycle: "keep_alive",
118
+ name: "hosted_host",
119
+ kw: {
120
+ view_gclass: "C_TEST_SHOWN_VIEW",
121
+ service_name: "#hosted_view",
122
+ transport_service: "test_transport"
123
+ }
124
+ }}
125
+ ]
126
+ }
127
+ }
128
+ };
129
+ }
130
+
131
+ function new_shell()
132
+ {
133
+ const shell = gobj_create(`shown_shell_${++seq}`, "C_YUI_SHELL",
134
+ {config: config(), use_hash: false}, yuno);
135
+ gobj_start(shell);
136
+ alive.push(shell);
137
+ return shell;
138
+ }
139
+
140
+ function errors()
141
+ {
142
+ return logged.filter((l) => l.level === "error" || l.level === "warning").map((l) => l.msg);
143
+ }
144
+
145
+ describe("EV_VIEW_SHOWN", () => {
146
+ test("a keep_alive view is told when it is shown AGAIN, not the first time", () => {
147
+ const shell = new_shell();
148
+ yui_shell_navigate(shell, "/kept");
149
+ expect(shown).toEqual([]);
150
+
151
+ yui_shell_navigate(shell, "/plain");
152
+ yui_shell_navigate(shell, "/kept");
153
+ expect(shown.length).toBe(1);
154
+ expect(shown[0].name).toBe("kept_view");
155
+ expect(shown[0].kw.base).toBe("/kept");
156
+ expect(errors()).toEqual([]);
157
+ });
158
+
159
+ test("a move inside the view (a subpath) is not a new showing", () => {
160
+ const shell = new_shell();
161
+ yui_shell_navigate(shell, "/kept");
162
+ yui_shell_navigate(shell, "/kept/table");
163
+ yui_shell_navigate(shell, "/kept/cards");
164
+ expect(shown).toEqual([]);
165
+ });
166
+
167
+ test("a view that does not declare it is not told, and nothing complains", () => {
168
+ const shell = new_shell();
169
+ yui_shell_navigate(shell, "/plain");
170
+ yui_shell_navigate(shell, "/kept");
171
+ yui_shell_navigate(shell, "/plain");
172
+ expect(shown.filter((s) => s.name === "plain_view")).toEqual([]);
173
+ expect(errors()).toEqual([]);
174
+ });
175
+
176
+ test("a lazy_destroy view comes back NEW, and a new view is not told", () => {
177
+ const shell = new_shell();
178
+ yui_shell_navigate(shell, "/gone");
179
+ yui_shell_navigate(shell, "/kept");
180
+ yui_shell_navigate(shell, "/gone");
181
+ expect(shown.filter((s) => s.name === "gone_view")).toEqual([]);
182
+ });
183
+
184
+ test("C_YUI_SERVICE_VIEW hands it on to the view it hosts", () => {
185
+ const shell = new_shell();
186
+ yui_shell_navigate(shell, "/hosted");
187
+ yui_shell_navigate(shell, "/kept");
188
+ yui_shell_navigate(shell, "/hosted");
189
+ expect(shown.filter((s) => s.name === "#hosted_view").length).toBe(1);
190
+ expect(errors()).toEqual([]);
191
+ });
192
+ });
package/src/yui_dev.js CHANGED
@@ -86,7 +86,7 @@ export const YUI_DEV_I18N_KEYS = [
86
86
  "dev window and browser console", "dev window only", "developer",
87
87
  "clear the filter", "errors", "expand", "expanded",
88
88
  "filter events / payload", "find", "i18n", "i18next debug output",
89
- "incoming", "log", "machine trace shape", "metadata", "outgoing",
89
+ "incoming", "log", "machine trace shape", "metadata", "one line", "outgoing",
90
90
  "output", "payload", "periodic", "schema", "show",
91
91
  "show the payload of the traces",
92
92
  "show this section in the expanded view", "simple mach", "start / stop",
@@ -95,7 +95,7 @@ export const YUI_DEV_I18N_KEYS = [
95
95
  "trace the creation and destruction of gobjs",
96
96
  "trace the messages to and from the backend",
97
97
  "trace the periodic timer event", "trace the start and stop of gobjs",
98
- "traces", "traffic", "traffic payload folded",
98
+ "traces", "traffic", "traffic one line per message", "traffic payload folded",
99
99
  "traffic payload laid out", "view", "window", "yuno monitor"
100
100
  ];
101
101
 
@@ -202,13 +202,21 @@ function dev_num(key, def)
202
202
  * the traffic's lives in the VIEW group, the traces' in the TRACES row,
203
203
  * beside the chip that picks the machine-trace shape.
204
204
  *
205
- * The traffic payload is ALWAYS there; the view says whether it is folded.
206
- * The old `dev_view_mode` key is left where it is and simply stops being
207
- * read (same as SIMPLE_MACH_KEY below). */
205
+ * The view says how much room a message takes: `line` (its event name
206
+ * alone, one row per message), `collapsed` (the payload folded) or
207
+ * `expanded` (the payload laid out). `line` is the old `Name only`, back
208
+ * in 7.27.22 now that the selector is the traffic's alone: it is what you
209
+ * want to see WHICH messages go and come, and open one of the other two
210
+ * to read them. The old `dev_view_mode` key is left where it is and simply
211
+ * stops being read (same as SIMPLE_MACH_KEY below). */
212
+ function traffic_view_of(v)
213
+ {
214
+ return (v === "expanded" || v === "line") ? v : "collapsed";
215
+ }
216
+
208
217
  function dev_traffic_view()
209
218
  {
210
- let v = kw_get_local_storage_value("dev_traffic_view", "collapsed", false);
211
- return (v === "expanded") ? "expanded" : "collapsed";
219
+ return traffic_view_of(kw_get_local_storage_value("dev_traffic_view", "collapsed", false));
212
220
  }
213
221
 
214
222
  /* Whether the trace's PAYLOAD lines (level `json`: the kw a trace dumps
@@ -274,7 +282,7 @@ function apply_console_route()
274
282
  * It follows the VIEW, because the window and the console are two sinks of
275
283
  * ONE feed and may not disagree about what they are showing: `expanded`
276
284
  * prints the payload laid out, `collapsed` hands the object to the console
277
- * and lets it fold it. The same promise the log filter made in 7.23.33 --
285
+ * and lets it fold it, `line` prints the head alone. The same promise the log filter made in 7.23.33 --
278
286
  * one rule, two sinks -- which the traffic half had never kept. */
279
287
  function console_traffic(title, jn, direction, size)
280
288
  {
@@ -284,7 +292,12 @@ function console_traffic(title, jn, direction, size)
284
292
  let head = "%c" + dir_arrow(direction) + " " + (title ? "[" + title + "] " : "") + event +
285
293
  (size ? " (" + size + "b)" : "");
286
294
 
287
- if(dev_traffic_view() === "expanded") {
295
+ let view = dev_traffic_view();
296
+ if(view === "line") {
297
+ window.console.log(head, "color:" + color);
298
+ return;
299
+ }
300
+ if(view === "expanded") {
288
301
  let text;
289
302
  try {
290
303
  text = JSON.stringify(full_sections(kw), null, 4);
@@ -300,7 +313,7 @@ function console_traffic(title, jn, direction, size)
300
313
 
301
314
  function set_traffic_view(v)
302
315
  {
303
- kw_set_local_storage_value("dev_traffic_view", (v === "expanded") ? "expanded" : "collapsed");
316
+ kw_set_local_storage_value("dev_traffic_view", traffic_view_of(v));
304
317
  rerender_all();
305
318
  refresh_dev_chrome();
306
319
  }
@@ -508,6 +521,9 @@ function ensure_dev_style()
508
521
  .TRAFFIC_ENTRY.dir-out { border-left-color: #2563eb; }
509
522
  .TRAFFIC_ENTRY.dir-in { border-left-color: #059669; }
510
523
  .TRAFFIC_ENTRY.dir-err { border-left-color: #dc2626; }
524
+ /* The line view: one row per message, no margin between rows, so a burst
525
+ of messages reads as a list. */
526
+ .TRAFFIC_ENTRY.TRAFFIC_NAME { margin: 1px 0; padding: 1px 8px; line-height: 1.45; display: flex; align-items: baseline; gap: 8px; }
511
527
  .TRAFFIC_HEADER { display: flex; align-items: baseline; gap: 8px; }
512
528
  .TRAFFIC_ARROW { font-weight: 700; }
513
529
  .TRAFFIC_EVENT { font-weight: 700; }
@@ -895,6 +911,14 @@ function render_full(e)
895
911
  return createElement2(['div', {class: 'TRAFFIC_ENTRY ' + dir_class(e.dir)}, children]);
896
912
  }
897
913
 
914
+ /* Line view: the message's head and nothing else. */
915
+ function render_name(e)
916
+ {
917
+ let kids = event_spans(e);
918
+ kids.push(['span', {class: 'TRAFFIC_META'}, `${traffic_size(e.size)} · ${e.ts}`]);
919
+ return createElement2(['div', {class: 'TRAFFIC_ENTRY TRAFFIC_NAME ' + dir_class(e.dir)}, kids]);
920
+ }
921
+
898
922
  /* A mirrored framework log line (error/warning/info/debug/msg). */
899
923
  function render_log(e)
900
924
  {
@@ -923,8 +947,9 @@ function render_log(e)
923
947
  return $row;
924
948
  }
925
949
 
926
- /* A TRAFFIC entry always shows its payload -- folded (`collapsed`, the
927
- * bullets) or laid out (`expanded`, the JSON). A trace line is written by
950
+ /* A TRAFFIC entry shows its head alone (`line`), or with its payload --
951
+ * folded (`collapsed`, the bullets) or laid out (`expanded`, the JSON).
952
+ * A trace line is written by
928
953
  * the runtime and is painted as it comes; what shapes it is the TRACES row
929
954
  * (the machine-trace format chip and the payload chip), not this. */
930
955
  function render_entry(e)
@@ -932,7 +957,11 @@ function render_entry(e)
932
957
  if(e.kind === "log") {
933
958
  return render_log(e);
934
959
  }
935
- if(dev_traffic_view() === "expanded") {
960
+ let view = dev_traffic_view();
961
+ if(view === "line") {
962
+ return render_name(e);
963
+ }
964
+ if(view === "expanded") {
936
965
  return render_full(e);
937
966
  }
938
967
  return render_detailed(e);
@@ -1478,7 +1507,8 @@ function entry_shown_lines($entry)
1478
1507
  /* Serialize the currently-visible (filtered) traffic to plain text:
1479
1508
  * one header line per entry (time · direction · title · event/command)
1480
1509
  * followed by its payload AS THE VIEW SHOWS IT -- folded, what is on
1481
- * screen (entry_shown_lines()); laid out, the whole payload. Honours the
1510
+ * screen (entry_shown_lines()); laid out, the whole payload; in the line
1511
+ * view, none (the header line alone, no blank line). Honours the
1482
1512
  * active filters and search so the copy matches exactly what is on
1483
1513
  * screen. */
1484
1514
  function traffic_to_text()
@@ -1499,7 +1529,11 @@ function traffic_to_text()
1499
1529
  `${e.title ? "[" + e.title + "] " : ""}${e.event}` +
1500
1530
  `${e.command ? " " + e.command : ""}`;
1501
1531
  out.push(head);
1502
- if(dev_traffic_view() !== "expanded" && e.$node) {
1532
+ let view = dev_traffic_view();
1533
+ if(view === "line") {
1534
+ continue;
1535
+ }
1536
+ if(view !== "expanded" && e.$node) {
1503
1537
  out.push(...entry_shown_lines(e.$node));
1504
1538
  out.push("");
1505
1539
  continue;
@@ -1609,6 +1643,7 @@ function build_control_bar()
1609
1643
  * in the TRACES row (the machine-trace chip and `payload`), because
1610
1644
  * both feeds can be on at once and neither may steer the other. */
1611
1645
  let VIEW_TITLES = {
1646
+ line: 'traffic one line per message',
1612
1647
  collapsed: 'traffic payload folded',
1613
1648
  expanded: 'traffic payload laid out',
1614
1649
  };
@@ -1625,6 +1660,7 @@ function build_control_bar()
1625
1660
  }];
1626
1661
 
1627
1662
  let view_seg = ['div', {class: 'YDEV_SEG', id: 'ydev-seg'}, [
1663
+ mk_view('line', 'one line'),
1628
1664
  mk_view('collapsed', 'collapsed'),
1629
1665
  mk_view('expanded', 'expanded'),
1630
1666
  ]];
@@ -1964,4 +2000,6 @@ export {
1964
2000
  object_preview, object_preview_parts,
1965
2001
  /* And the copy of the folded view, with the renderer it reads. */
1966
2002
  entry_shown_lines, render_detailed,
2003
+ /* And the line view's row. */
2004
+ render_name,
1967
2005
  };
@@ -19,10 +19,11 @@ import {install_dom_double} from "../test/dom_double.js";
19
19
 
20
20
  let entry_shown_lines;
21
21
  let render_detailed;
22
+ let render_name;
22
23
 
23
24
  beforeAll(async () => {
24
25
  install_dom_double();
25
- ({entry_shown_lines, render_detailed} = await import("./yui_dev.js"));
26
+ ({entry_shown_lines, render_detailed, render_name} = await import("./yui_dev.js"));
26
27
  });
27
28
 
28
29
  function painted(kw)
@@ -59,3 +60,18 @@ describe("entry_shown_lines", () => {
59
60
  ]);
60
61
  });
61
62
  });
63
+
64
+ describe("render_name (the line view)", () => {
65
+ it("paints the head of the message alone, in one row", () => {
66
+ const $e = render_name({
67
+ kind: "traffic", dir: "in", event: "EV_YUNO_STATS", command: "",
68
+ title: "gui_agent_yuno <== wss://cc:1996", ts: "09:19:03.421", size: 1024,
69
+ kw: {result: 0, data: {yuno_id: "2046", kind: "cpu"}},
70
+ });
71
+ expect($e.classList.contains("TRAFFIC_NAME")).toBe(true);
72
+ expect($e.querySelector(".TRAFFIC_EVENT").textContent).toBe("EV_YUNO_STATS");
73
+ expect($e.querySelector(".TRAFFIC_KW")).toBe(null);
74
+ expect($e.querySelector(".TRAFFIC_FULL")).toBe(null);
75
+ expect(entry_shown_lines($e)).toEqual([]);
76
+ });
77
+ });