@yuneta/gobj-ui 7.27.30 → 7.27.32

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
@@ -4449,7 +4449,12 @@ its third number, in the same edit), installs, builds, deploys
4449
4449
  and reads back the bundle each host serves (`--check` only reads back,
4450
4450
  `--only <name>` does one app, `--no-wait` skips the registry). The private
4451
4451
  consumers are listed in `~/.yuneta/gobj-ui-consumers.json` (see
4452
- `scripts/gobj-ui-consumers.example.json`); the demo (`test-app/`) is built in.
4452
+ `scripts/gobj-ui-consumers.example.json`). The round commits nothing: each
4453
+ app's commit carries its `package.json` and the `package-lock.json` the
4454
+ install rewrote (every app commits its lockfile, and a fresh checkout installs
4455
+ with `npm ci`). The demo is the one exception (below).
4456
+
4457
+ The demo (`test-app/`) is built in.
4453
4458
  It is built from the working trees of this repo and of the sibling `gobj-js`
4454
4459
  (`test-app/vite.config.js` bundles `../../gobj-js/src`), so it goes out only
4455
4460
  when each is a clean tree of its own (untracked files count; a copy with no
@@ -4457,7 +4462,11 @@ when each is a clean tree of its own (untracked files count; a copy with no
4457
4462
  holds on the remote; otherwise it is `NOT DEPLOYED`, with the reason, and the
4458
4463
  round exits 1 (since `7.26.55`, the sibling `gobj-js` since `7.26.57`; up to
4459
4464
  `7.26.54` any copy of the repo, on any commit, deployed the public demo). The
4460
- demo's target is named `test-app` (`--only test-app`).
4465
+ demo's target is named `test-app` (`--only test-app`). The round does not
4466
+ install it, and its `package-lock.json` is not in git, on purpose
4467
+ (`test-app/.gitignore` lists it): its two Yuneta dependencies are `file:`
4468
+ links to those working trees, which a lockfile cannot pin, and the lockfile
4469
+ would change with every version of gobj-ui or gobj-js.
4461
4470
 
4462
4471
  An app whose range cannot be raised safely is refused and left as it was --
4463
4472
  every package.json of it, since all are checked before any is written: a
@@ -17186,6 +17186,41 @@ function classify_press(press, x, y, t) {
17186
17186
  return "tap";
17187
17187
  }
17188
17188
  //#endregion
17189
+ //#region src/g6_replace_behavior.js
17190
+ /***********************************************************************
17191
+ * g6_replace_behavior.js
17192
+ *
17193
+ * Replace one of G6's built-in behaviors, without a warning on
17194
+ * every page load.
17195
+ *
17196
+ * gobj-ui replaces two built-ins on purpose (`drag-canvas` and
17197
+ * `zoom-canvas`, the touch round of 7.23.9), so that every graph
17198
+ * gets the fix without touching its behaviors list. G6's
17199
+ * `register()` warns whenever a type is registered again --
17200
+ * "The extension drag-canvas of behavior has been registered
17201
+ * before, and will be overridden" -- and its `print` is not
17202
+ * exported, so the warning cannot be muted. It went to the
17203
+ * console of every app that draws a graph, on every load.
17204
+ *
17205
+ * `getExtensions(category)` hands out G6's live registry, so the
17206
+ * replacement is written there. Whether it took is checked with
17207
+ * `getExtension()`: a G6 that hands out a copy one day gets the
17208
+ * replacement through `register()` -- with its warning, which
17209
+ * then says something -- instead of losing it in silence.
17210
+ *
17211
+ * Copyright (c) 2026, ArtGins.
17212
+ * All Rights Reserved.
17213
+ ***********************************************************************/
17214
+ /************************************************************
17215
+ * Make `Ctor` the behavior `type`, replacing the built-in.
17216
+ ************************************************************/
17217
+ function replace_g6_behavior(type, Ctor) {
17218
+ const category = _antv_g6.ExtensionCategory.BEHAVIOR;
17219
+ const behaviors = (0, _antv_g6.getExtensions)(category);
17220
+ if (behaviors && (0, _antv_g6.getExtension)(category, type)) behaviors[type] = Ctor;
17221
+ if ((0, _antv_g6.getExtension)(category, type) !== Ctor) (0, _antv_g6.register)(category, type, Ctor);
17222
+ }
17223
+ //#endregion
17189
17224
  //#region src/g6_touch_gestures.js
17190
17225
  /***********************************************************************
17191
17226
  * g6_touch_gestures.js
@@ -17387,7 +17422,7 @@ var ZoomCanvasPinch = class extends _antv_g6.ZoomCanvas {
17387
17422
  var __zoom_canvas_patched__ = false;
17388
17423
  function ensure_pinch_zoom_patch() {
17389
17424
  if (__zoom_canvas_patched__) return;
17390
- (0, _antv_g6.register)(_antv_g6.ExtensionCategory.BEHAVIOR, "zoom-canvas", ZoomCanvasPinch);
17425
+ replace_g6_behavior("zoom-canvas", ZoomCanvasPinch);
17391
17426
  __zoom_canvas_patched__ = true;
17392
17427
  }
17393
17428
  /***************************
@@ -17630,7 +17665,7 @@ var DragCanvasTouch = class extends _antv_g6.DragCanvas {
17630
17665
  var __drag_canvas_patched__ = false;
17631
17666
  function ensure_drag_canvas_patch() {
17632
17667
  if (__drag_canvas_patched__) return;
17633
- (0, _antv_g6.register)(_antv_g6.ExtensionCategory.BEHAVIOR, "drag-canvas", DragCanvasTouch);
17668
+ replace_g6_behavior("drag-canvas", DragCanvasTouch);
17634
17669
  __drag_canvas_patched__ = true;
17635
17670
  }
17636
17671
  //#endregion
@@ -52441,6 +52476,7 @@ var PRIVATE_DATA$9 = {
52441
52476
  popover_mode: "",
52442
52477
  viewer_awaits: "",
52443
52478
  viewer_stale: "",
52479
+ set_in_flight: null,
52444
52480
  view_refused: false
52445
52481
  };
52446
52482
  var __gclass__$9 = null;
@@ -54842,6 +54878,7 @@ function open_gclass_window(gobj, gclass, description, d) {
54842
54878
  priv.gclass_view = null;
54843
54879
  priv.viewer_awaits = "";
54844
54880
  priv.viewer_stale = "";
54881
+ if (priv.set_in_flight) lock_viewer_for_set(gobj, gclass, priv.set_in_flight);
54845
54882
  let opts = {
54846
54883
  title_prefix: is_remote(gobj) ? (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "yuno_name") || "" : (0, _yuneta_gobj_js.gobj_yuno_name)() || "",
54847
54884
  current_state: d && d.state || "",
@@ -54908,6 +54945,7 @@ function ac_trace_info(gobj, event, kw, src) {
54908
54945
  error: kw.error || ""
54909
54946
  };
54910
54947
  priv.trace_pending = false;
54948
+ if (priv.set_in_flight && priv.set_in_flight.gclass === kw.gclass) priv.set_in_flight = null;
54911
54949
  let d = priv.popover_node;
54912
54950
  let root = priv.remote_root;
54913
54951
  if (priv.popover_mode === "node" && d && d.gclass === kw.gclass || priv.popover_mode === "yuno" && root && root.gclass === kw.gclass) render_current_popover(gobj);
@@ -54919,6 +54957,10 @@ function ac_trace_info(gobj, event, kw, src) {
54919
54957
  if (priv.viewer_stale === shown && shown !== kw.gclass) {
54920
54958
  priv.viewer_stale = "";
54921
54959
  priv.viewer_awaits = shown;
54960
+ priv.set_in_flight = {
54961
+ gclass: shown,
54962
+ scope: "gclass"
54963
+ };
54922
54964
  (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54923
54965
  }
54924
54966
  }
@@ -55024,14 +55066,14 @@ function set_trace_levels(gobj, target, scope, levels, set) {
55024
55066
  let priv = gobj.priv;
55025
55067
  priv.trace_pending = true;
55026
55068
  render_current_popover(gobj);
55069
+ priv.set_in_flight = {
55070
+ gclass: target.gclass,
55071
+ scope
55072
+ };
55027
55073
  let viewer = gclass_viewer_gobj(gobj);
55028
55074
  if (viewer) {
55029
55075
  let shown = (0, _yuneta_gobj_js.gobj_read_str_attr)(viewer, "gclass_name");
55030
- if (shown === target.gclass || scope === "global") {
55031
- priv.viewer_awaits = target.gclass;
55032
- priv.viewer_stale = shown !== target.gclass ? shown : "";
55033
- (0, _yuneta_gobj_js.gobj_send_event)(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
55034
- }
55076
+ if (lock_viewer_for_set(gobj, shown, priv.set_in_flight)) (0, _yuneta_gobj_js.gobj_send_event)(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
55035
55077
  }
55036
55078
  (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_SET_TRACE_LEVEL", {
55037
55079
  scope,
@@ -55041,6 +55083,13 @@ function set_trace_levels(gobj, target, scope, levels, set) {
55041
55083
  set
55042
55084
  });
55043
55085
  }
55086
+ function lock_viewer_for_set(gobj, shown, set) {
55087
+ let priv = gobj.priv;
55088
+ if (!(shown === set.gclass || set.scope === "global")) return false;
55089
+ priv.viewer_awaits = set.gclass;
55090
+ priv.viewer_stale = shown !== set.gclass ? shown : "";
55091
+ return true;
55092
+ }
55044
55093
  /************************************************************
55045
55094
  * The toolbar's "traces of the yuno": the popover shows the
55046
55095
  * yuno's scope, read from the answer for the root's gclass.
@@ -5,7 +5,7 @@ import { createJSONEditor } from "vanilla-jsoneditor";
5
5
  import { TabulatorFull } from "tabulator-tables";
6
6
  import * as maplibregl from "maplibre-gl";
7
7
  import uPlot from "uplot";
8
- import { BaseLayout, BrushSelect, CanvasEvent, Circle, CommonEvent, DragCanvas, EdgeEvent, ExtensionCategory, Graph, GraphEvent, HTML, HistoryEvent, NodeEvent, Polyline, Toolbar, ZoomCanvas, register } from "@antv/g6";
8
+ import { BaseLayout, BrushSelect, CanvasEvent, Circle, CommonEvent, DragCanvas, EdgeEvent, ExtensionCategory, Graph, GraphEvent, HTML, HistoryEvent, NodeEvent, Polyline, Toolbar, ZoomCanvas, getExtension, getExtensions, register } from "@antv/g6";
9
9
  //#region \0rolldown/runtime.js
10
10
  var __create = Object.create;
11
11
  var __defProp = Object.defineProperty;
@@ -17181,6 +17181,41 @@ function classify_press(press, x, y, t) {
17181
17181
  return "tap";
17182
17182
  }
17183
17183
  //#endregion
17184
+ //#region src/g6_replace_behavior.js
17185
+ /***********************************************************************
17186
+ * g6_replace_behavior.js
17187
+ *
17188
+ * Replace one of G6's built-in behaviors, without a warning on
17189
+ * every page load.
17190
+ *
17191
+ * gobj-ui replaces two built-ins on purpose (`drag-canvas` and
17192
+ * `zoom-canvas`, the touch round of 7.23.9), so that every graph
17193
+ * gets the fix without touching its behaviors list. G6's
17194
+ * `register()` warns whenever a type is registered again --
17195
+ * "The extension drag-canvas of behavior has been registered
17196
+ * before, and will be overridden" -- and its `print` is not
17197
+ * exported, so the warning cannot be muted. It went to the
17198
+ * console of every app that draws a graph, on every load.
17199
+ *
17200
+ * `getExtensions(category)` hands out G6's live registry, so the
17201
+ * replacement is written there. Whether it took is checked with
17202
+ * `getExtension()`: a G6 that hands out a copy one day gets the
17203
+ * replacement through `register()` -- with its warning, which
17204
+ * then says something -- instead of losing it in silence.
17205
+ *
17206
+ * Copyright (c) 2026, ArtGins.
17207
+ * All Rights Reserved.
17208
+ ***********************************************************************/
17209
+ /************************************************************
17210
+ * Make `Ctor` the behavior `type`, replacing the built-in.
17211
+ ************************************************************/
17212
+ function replace_g6_behavior(type, Ctor) {
17213
+ const category = ExtensionCategory.BEHAVIOR;
17214
+ const behaviors = getExtensions(category);
17215
+ if (behaviors && getExtension(category, type)) behaviors[type] = Ctor;
17216
+ if (getExtension(category, type) !== Ctor) register(category, type, Ctor);
17217
+ }
17218
+ //#endregion
17184
17219
  //#region src/g6_touch_gestures.js
17185
17220
  /***********************************************************************
17186
17221
  * g6_touch_gestures.js
@@ -17382,7 +17417,7 @@ var ZoomCanvasPinch = class extends ZoomCanvas {
17382
17417
  var __zoom_canvas_patched__ = false;
17383
17418
  function ensure_pinch_zoom_patch() {
17384
17419
  if (__zoom_canvas_patched__) return;
17385
- register(ExtensionCategory.BEHAVIOR, "zoom-canvas", ZoomCanvasPinch);
17420
+ replace_g6_behavior("zoom-canvas", ZoomCanvasPinch);
17386
17421
  __zoom_canvas_patched__ = true;
17387
17422
  }
17388
17423
  /***************************
@@ -17625,7 +17660,7 @@ var DragCanvasTouch = class extends DragCanvas {
17625
17660
  var __drag_canvas_patched__ = false;
17626
17661
  function ensure_drag_canvas_patch() {
17627
17662
  if (__drag_canvas_patched__) return;
17628
- register(ExtensionCategory.BEHAVIOR, "drag-canvas", DragCanvasTouch);
17663
+ replace_g6_behavior("drag-canvas", DragCanvasTouch);
17629
17664
  __drag_canvas_patched__ = true;
17630
17665
  }
17631
17666
  //#endregion
@@ -52436,6 +52471,7 @@ var PRIVATE_DATA$9 = {
52436
52471
  popover_mode: "",
52437
52472
  viewer_awaits: "",
52438
52473
  viewer_stale: "",
52474
+ set_in_flight: null,
52439
52475
  view_refused: false
52440
52476
  };
52441
52477
  var __gclass__$9 = null;
@@ -54837,6 +54873,7 @@ function open_gclass_window(gobj, gclass, description, d) {
54837
54873
  priv.gclass_view = null;
54838
54874
  priv.viewer_awaits = "";
54839
54875
  priv.viewer_stale = "";
54876
+ if (priv.set_in_flight) lock_viewer_for_set(gobj, gclass, priv.set_in_flight);
54840
54877
  let opts = {
54841
54878
  title_prefix: is_remote(gobj) ? gobj_read_str_attr(gobj, "yuno_name") || "" : gobj_yuno_name() || "",
54842
54879
  current_state: d && d.state || "",
@@ -54903,6 +54940,7 @@ function ac_trace_info(gobj, event, kw, src) {
54903
54940
  error: kw.error || ""
54904
54941
  };
54905
54942
  priv.trace_pending = false;
54943
+ if (priv.set_in_flight && priv.set_in_flight.gclass === kw.gclass) priv.set_in_flight = null;
54906
54944
  let d = priv.popover_node;
54907
54945
  let root = priv.remote_root;
54908
54946
  if (priv.popover_mode === "node" && d && d.gclass === kw.gclass || priv.popover_mode === "yuno" && root && root.gclass === kw.gclass) render_current_popover(gobj);
@@ -54914,6 +54952,10 @@ function ac_trace_info(gobj, event, kw, src) {
54914
54952
  if (priv.viewer_stale === shown && shown !== kw.gclass) {
54915
54953
  priv.viewer_stale = "";
54916
54954
  priv.viewer_awaits = shown;
54955
+ priv.set_in_flight = {
54956
+ gclass: shown,
54957
+ scope: "gclass"
54958
+ };
54917
54959
  gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54918
54960
  }
54919
54961
  }
@@ -55019,14 +55061,14 @@ function set_trace_levels(gobj, target, scope, levels, set) {
55019
55061
  let priv = gobj.priv;
55020
55062
  priv.trace_pending = true;
55021
55063
  render_current_popover(gobj);
55064
+ priv.set_in_flight = {
55065
+ gclass: target.gclass,
55066
+ scope
55067
+ };
55022
55068
  let viewer = gclass_viewer_gobj(gobj);
55023
55069
  if (viewer) {
55024
55070
  let shown = gobj_read_str_attr(viewer, "gclass_name");
55025
- if (shown === target.gclass || scope === "global") {
55026
- priv.viewer_awaits = target.gclass;
55027
- priv.viewer_stale = shown !== target.gclass ? shown : "";
55028
- gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
55029
- }
55071
+ if (lock_viewer_for_set(gobj, shown, priv.set_in_flight)) gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
55030
55072
  }
55031
55073
  gobj_publish_event(gobj, "EV_SET_TRACE_LEVEL", {
55032
55074
  scope,
@@ -55036,6 +55078,13 @@ function set_trace_levels(gobj, target, scope, levels, set) {
55036
55078
  set
55037
55079
  });
55038
55080
  }
55081
+ function lock_viewer_for_set(gobj, shown, set) {
55082
+ let priv = gobj.priv;
55083
+ if (!(shown === set.gclass || set.scope === "global")) return false;
55084
+ priv.viewer_awaits = set.gclass;
55085
+ priv.viewer_stale = shown !== set.gclass ? shown : "";
55086
+ return true;
55087
+ }
55039
55088
  /************************************************************
55040
55089
  * The toolbar's "traces of the yuno": the popover shows the
55041
55090
  * yuno's scope, read from the answer for the root's gclass.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.27.30",
3
+ "version": "7.27.32",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -498,6 +498,7 @@ let PRIVATE_DATA = {
498
498
  popover_mode: "", // what the popover shows: "node" (a card) | "yuno" (the yuno's traces)
499
499
  viewer_awaits: "", // the gclass whose answer unlocks the open viewer ("" = not locked)
500
500
  viewer_stale: "", // a gclass whose open viewer must be asked again after a yuno set
501
+ set_in_flight: null, // {gclass, scope}: the set whose answer (EV_TRACE_INFO of gclass) is owed
501
502
  view_refused: false, // the saved camera showed no card: the opening's framing replaces it
502
503
  };
503
504
 
@@ -3597,6 +3598,11 @@ function open_gclass_window(gobj, gclass, description, d)
3597
3598
  priv.gclass_view = null;
3598
3599
  priv.viewer_awaits = "";
3599
3600
  priv.viewer_stale = "";
3601
+ /* A viewer opened while a set that moves what it shows is still
3602
+ * in flight opens locked, as the one it replaces was. */
3603
+ if(priv.set_in_flight) {
3604
+ lock_viewer_for_set(gobj, gclass, priv.set_in_flight);
3605
+ }
3600
3606
 
3601
3607
  let opts = {
3602
3608
  title_prefix: is_remote(gobj)?
@@ -3686,6 +3692,9 @@ function ac_trace_info(gobj, event, kw, src)
3686
3692
  error: kw.error || "",
3687
3693
  };
3688
3694
  priv.trace_pending = false;
3695
+ if(priv.set_in_flight && priv.set_in_flight.gclass === kw.gclass) {
3696
+ priv.set_in_flight = null;
3697
+ }
3689
3698
 
3690
3699
  let d = priv.popover_node;
3691
3700
  let root = priv.remote_root;
@@ -3708,6 +3717,9 @@ function ac_trace_info(gobj, event, kw, src)
3708
3717
  * only the root's gclass. Locked until its own. */
3709
3718
  priv.viewer_stale = "";
3710
3719
  priv.viewer_awaits = shown;
3720
+ /* Owed like a set of its own: a viewer of it reopened
3721
+ * before the answer opens locked too. */
3722
+ priv.set_in_flight = {gclass: shown, scope: "gclass"};
3711
3723
  gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: shown});
3712
3724
  }
3713
3725
  }
@@ -3846,14 +3858,14 @@ function set_trace_levels(gobj, target, scope, levels, set)
3846
3858
  /* The viewer is locked only by a set that moves what it shows:
3847
3859
  * one of its own gclass, or one of the yuno's scope. A gobj or
3848
3860
  * gclass set of ANOTHER gclass leaves it alone -- the answer that
3849
- * ends that set is not one the viewer would ever be sent. */
3861
+ * ends that set is not one the viewer would ever be sent. The set
3862
+ * is remembered for a viewer opened before its answer, and only
3863
+ * the LAST one: the host overtakes an earlier set in flight. */
3864
+ priv.set_in_flight = {gclass: target.gclass, scope: scope};
3850
3865
  let viewer = gclass_viewer_gobj(gobj);
3851
3866
  if(viewer) {
3852
3867
  let shown = gobj_read_str_attr(viewer, "gclass_name");
3853
- let concerned = (shown === target.gclass) || scope === "global";
3854
- if(concerned) {
3855
- priv.viewer_awaits = target.gclass;
3856
- priv.viewer_stale = (shown !== target.gclass)? shown: "";
3868
+ if(lock_viewer_for_set(gobj, shown, priv.set_in_flight)) {
3857
3869
  gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
3858
3870
  }
3859
3871
  }
@@ -3867,6 +3879,22 @@ function set_trace_levels(gobj, target, scope, levels, set)
3867
3879
  });
3868
3880
  }
3869
3881
 
3882
+ /* The viewer of `shown` waits for the answer of `set` when the set
3883
+ * moves what it shows: one of its own gclass, or one of the yuno's
3884
+ * scope (then its own levels are asked for again after the yuno's,
3885
+ * see ac_trace_info). Returns whether it was locked. */
3886
+ function lock_viewer_for_set(gobj, shown, set)
3887
+ {
3888
+ let priv = gobj.priv;
3889
+ let concerned = (shown === set.gclass) || set.scope === "global";
3890
+ if(!concerned) {
3891
+ return false;
3892
+ }
3893
+ priv.viewer_awaits = set.gclass;
3894
+ priv.viewer_stale = (shown !== set.gclass)? shown: "";
3895
+ return true;
3896
+ }
3897
+
3870
3898
  /************************************************************
3871
3899
  * The toolbar's "traces of the yuno": the popover shows the
3872
3900
  * yuno's scope, read from the answer for the root's gclass.
package/src/c_yui_node.js CHANGED
@@ -79,7 +79,9 @@
79
79
  * Only the ROOT node (the one whose parent is not a C_YUI_NODE)
80
80
  * talks to the shell: it subscribes to EV_ROUTE_CHANGED, resolves
81
81
  * the subpath and activates the branch. Inner nodes only ever
82
- * hear their parent.
82
+ * hear their parent. A route of ANOTHER stage (a secondary stage,
83
+ * SHELL.md §3) is not the root's business: the shell keeps showing
84
+ * the tree in its own stage, so the tree stays on its path.
83
85
  *
84
86
  * A path segment that names no living child is not silently
85
87
  * swallowed: it logs and the URL is rewritten (replace) to the
@@ -198,6 +200,7 @@ let PRIVATE_DATA = {
198
200
  distance: 0, /* segments from me down to the tip */
199
201
  chain: null, /* nodes from my child down to the tip */
200
202
  is_root: false,
203
+ stage: "", /* root: the shell stage that shows me ("" = not shown yet) */
201
204
  $chrome: null,
202
205
  $body: null
203
206
  };
@@ -1179,8 +1182,10 @@ function activate(gobj, subpath, inherited_depth)
1179
1182
  * declares EV_VIEW_SHOWN is told.
1180
1183
  *
1181
1184
  * This is the ONLY way it is told: a tree the shell shows
1182
- * again comes back here too (each node on the path leaves
1183
- * ST_OFF with the shell's EV_ROUTE_CHANGED), so the node
1185
+ * again comes back here too (the shell hides it only for a
1186
+ * route of its own stage, which takes the root to ST_OFF, and
1187
+ * each node on the path leaves ST_OFF with the shell's
1188
+ * EV_ROUTE_CHANGED that shows it again), so the node
1184
1189
  * does not declare EV_VIEW_SHOWN and the shell does not send
1185
1190
  * the tree a second one.
1186
1191
  ************************************************************/
@@ -1302,17 +1307,25 @@ function notify_tree_changed(gobj)
1302
1307
  ************************************************************/
1303
1308
  function ac_route_changed(gobj, event, kw, src)
1304
1309
  {
1310
+ let priv = gobj.priv;
1305
1311
  let base = kw.base || "";
1306
1312
  let my_base = gobj_read_attr(gobj, "base_route");
1313
+ let stage = kw.stage || "main";
1307
1314
 
1308
1315
  if(base !== my_base) {
1309
- /* Another view owns the URL now. A keep_alive tree stays
1316
+ /* A route of ANOTHER stage changes what that stage shows, not
1317
+ * mine: the shell keeps showing me, so I stay on my path. */
1318
+ if(priv.stage && stage !== priv.stage) {
1319
+ return 0;
1320
+ }
1321
+ /* Another view owns my stage now. A keep_alive tree stays
1310
1322
  * created but must not keep painting a stale branch. */
1311
1323
  deactivate(gobj);
1312
1324
  gobj_change_state(gobj, "ST_OFF");
1313
1325
  return 0;
1314
1326
  }
1315
1327
 
1328
+ priv.stage = stage;
1316
1329
  gobj_change_state(gobj, activate(gobj, kw.subpath || "", null));
1317
1330
  return 0;
1318
1331
  }
@@ -53,11 +53,10 @@
53
53
  import {
54
54
  DragCanvas,
55
55
  CommonEvent,
56
- ExtensionCategory,
57
- register,
58
56
  } from '@antv/g6';
59
57
 
60
58
  import {is_pinching} from './g6_touch_gestures.js';
59
+ import {replace_g6_behavior} from './g6_replace_behavior.js';
61
60
 
62
61
  /************************************************************
63
62
  * Custom drag-canvas: same behavior, reliable delta source
@@ -155,7 +154,7 @@ function ensure_drag_canvas_patch()
155
154
  if(__drag_canvas_patched__) {
156
155
  return;
157
156
  }
158
- register(ExtensionCategory.BEHAVIOR, 'drag-canvas', DragCanvasTouch);
157
+ replace_g6_behavior('drag-canvas', DragCanvasTouch);
159
158
  __drag_canvas_patched__ = true;
160
159
  }
161
160
 
@@ -0,0 +1,47 @@
1
+ /***********************************************************************
2
+ * g6_replace_behavior.js
3
+ *
4
+ * Replace one of G6's built-in behaviors, without a warning on
5
+ * every page load.
6
+ *
7
+ * gobj-ui replaces two built-ins on purpose (`drag-canvas` and
8
+ * `zoom-canvas`, the touch round of 7.23.9), so that every graph
9
+ * gets the fix without touching its behaviors list. G6's
10
+ * `register()` warns whenever a type is registered again --
11
+ * "The extension drag-canvas of behavior has been registered
12
+ * before, and will be overridden" -- and its `print` is not
13
+ * exported, so the warning cannot be muted. It went to the
14
+ * console of every app that draws a graph, on every load.
15
+ *
16
+ * `getExtensions(category)` hands out G6's live registry, so the
17
+ * replacement is written there. Whether it took is checked with
18
+ * `getExtension()`: a G6 that hands out a copy one day gets the
19
+ * replacement through `register()` -- with its warning, which
20
+ * then says something -- instead of losing it in silence.
21
+ *
22
+ * Copyright (c) 2026, ArtGins.
23
+ * All Rights Reserved.
24
+ ***********************************************************************/
25
+ import {
26
+ ExtensionCategory,
27
+ getExtension,
28
+ getExtensions,
29
+ register,
30
+ } from '@antv/g6';
31
+
32
+ /************************************************************
33
+ * Make `Ctor` the behavior `type`, replacing the built-in.
34
+ ************************************************************/
35
+ function replace_g6_behavior(type, Ctor)
36
+ {
37
+ const category = ExtensionCategory.BEHAVIOR;
38
+ const behaviors = getExtensions(category);
39
+ if(behaviors && getExtension(category, type)) {
40
+ behaviors[type] = Ctor;
41
+ }
42
+ if(getExtension(category, type) !== Ctor) {
43
+ register(category, type, Ctor);
44
+ }
45
+ }
46
+
47
+ export {replace_g6_behavior};
@@ -0,0 +1,38 @@
1
+ /*
2
+ * gobj-ui replaces G6's built-in drag-canvas and zoom-canvas on purpose;
3
+ * G6's register() warned "has been registered before" for each, on every
4
+ * page load, in every app that draws a graph.
5
+ */
6
+ import {describe, it, expect, vi, afterEach} from "vitest";
7
+ import {ExtensionCategory, getExtension} from "@antv/g6";
8
+ import {ensure_drag_canvas_patch} from "./g6_drag_canvas_touch.js";
9
+ import {ensure_pinch_zoom_patch} from "./g6_touch_gestures.js";
10
+ import {replace_g6_behavior} from "./g6_replace_behavior.js";
11
+
12
+ afterEach(() => {
13
+ vi.restoreAllMocks();
14
+ });
15
+
16
+ describe("replacing G6's built-in behaviors", () => {
17
+ it("puts gobj-ui's drag-canvas and zoom-canvas in place, with no warning", () => {
18
+ const builtin_drag = getExtension(ExtensionCategory.BEHAVIOR, "drag-canvas");
19
+ const builtin_zoom = getExtension(ExtensionCategory.BEHAVIOR, "zoom-canvas");
20
+ const warn = vi.spyOn(console, "warn");
21
+ ensure_drag_canvas_patch();
22
+ ensure_pinch_zoom_patch();
23
+ const said = warn.mock.calls.map((c) => String(c[0]));
24
+ expect(said.filter((m) => m.includes("registered before"))).toEqual([]);
25
+ const drag = getExtension(ExtensionCategory.BEHAVIOR, "drag-canvas");
26
+ const zoom = getExtension(ExtensionCategory.BEHAVIOR, "zoom-canvas");
27
+ expect(drag).not.toBe(builtin_drag);
28
+ expect(zoom).not.toBe(builtin_zoom);
29
+ expect(Object.getPrototypeOf(drag)).toBe(builtin_drag);
30
+ expect(Object.getPrototypeOf(zoom)).toBe(builtin_zoom);
31
+ });
32
+
33
+ it("registers a type G6 does not have", () => {
34
+ class Probe {}
35
+ replace_g6_behavior("gobj-ui-probe-behavior", Probe);
36
+ expect(getExtension(ExtensionCategory.BEHAVIOR, "gobj-ui-probe-behavior")).toBe(Probe);
37
+ });
38
+ });
@@ -61,11 +61,10 @@
61
61
  import {
62
62
  ZoomCanvas,
63
63
  CommonEvent,
64
- ExtensionCategory,
65
- register,
66
64
  } from '@antv/g6';
67
65
 
68
66
  import {press_moved, classify_press, LONG_PRESS_MS} from "./press_arbiter.js";
67
+ import {replace_g6_behavior} from "./g6_replace_behavior.js";
69
68
 
70
69
 
71
70
  /***************************************************************
@@ -309,7 +308,7 @@ export function ensure_pinch_zoom_patch()
309
308
  if(__zoom_canvas_patched__) {
310
309
  return;
311
310
  }
312
- register(ExtensionCategory.BEHAVIOR, 'zoom-canvas', ZoomCanvasPinch);
311
+ replace_g6_behavior('zoom-canvas', ZoomCanvasPinch);
313
312
  __zoom_canvas_patched__ = true;
314
313
  }
315
314
 
@@ -477,8 +477,79 @@ describe("C_YUI_GOBJ_TREE_JS, source remote: the open gclass viewer", () => {
477
477
  .toEqual([true, true]);
478
478
  expect(problems()).toEqual([]);
479
479
  });
480
+
481
+ test("reopened while a set of ITS gclass is in flight, it opens locked until that answer", async () => {
482
+ const {view, viewer} = await open_tcp_viewer();
483
+ gobj_send_event(view, "EV_SET_GCLASS_TRACE", {gclass: "C_TCP", levels: ["traffic"], set: true}, viewer);
484
+ expect(viewer_box(viewer, "traffic").disabled).toBe(true);
485
+
486
+ /* The card's gclass button, while the set is in flight: the
487
+ * viewer is replaced by a new one of the same gclass. */
488
+ const reopened = reopen_tcp_viewer(view);
489
+ expect(reopened).not.toBe(viewer);
490
+ expect(viewer_box(reopened, "traffic").disabled).toBe(true);
491
+
492
+ gobj_send_event(view, "EV_TRACE_INFO", Object.assign({}, TCP_INFO, {gclass: "C_TIMER"}), host);
493
+ expect(viewer_box(reopened, "traffic").disabled).toBe(true);
494
+
495
+ gobj_send_event(view, "EV_TRACE_INFO", Object.assign({}, TCP_INFO,
496
+ {gclass_on: ["connections", "traffic"]}), host);
497
+ expect([viewer_box(reopened, "traffic").checked, viewer_box(reopened, "traffic").disabled])
498
+ .toEqual([true, false]);
499
+ expect(problems()).toEqual([]);
500
+ });
501
+
502
+ test("reopened after the answer, or with a set of ANOTHER gclass in flight, it opens unlocked", async () => {
503
+ const {view, viewer} = await open_tcp_viewer();
504
+ gobj_send_event(view, "EV_SET_GCLASS_TRACE", {gclass: "C_TCP", levels: ["traffic"], set: true}, viewer);
505
+ gobj_send_event(view, "EV_TRACE_INFO", TCP_INFO, host);
506
+ expect(viewer_box(reopen_tcp_viewer(view), "traffic").disabled).toBe(false);
507
+
508
+ gobj_send_event(view, "EV_SET_GCLASS_TRACE", {gclass: "C_TIMER", levels: ["traffic"], set: true}, view);
509
+ expect(viewer_box(reopen_tcp_viewer(view), "traffic").disabled).toBe(false);
510
+ expect(problems()).toEqual([]);
511
+ });
512
+
513
+ test("reopened while a set of the yuno's scope is in flight, it waits for the yuno's answer AND its own", async () => {
514
+ const {view, viewer} = await open_tcp_viewer();
515
+ gobj_read_attr(view, "$container").querySelector(".GOBJ_TREE_YUNO_TRACES_BUTTON").click();
516
+ gobj_send_event(view, "EV_TRACE_INFO", YUNO_INFO, host);
517
+ const ev_kw = row_of(view, "ev_kw");
518
+ ev_kw.$global.checked = true;
519
+ ev_kw.$global.dispatchEvent(fake_event("change"));
520
+ expect(viewer_box(viewer, "traffic").disabled).toBe(true);
521
+
522
+ const reopened = reopen_tcp_viewer(view);
523
+ expect(viewer_box(reopened, "traffic").disabled).toBe(true);
524
+ wanted.length = 0;
525
+
526
+ gobj_send_event(view, "EV_TRACE_INFO", Object.assign({}, YUNO_INFO,
527
+ {global_on: ["machine", "ev_kw"]}), host);
528
+ expect(wanted.map((w) => [w.event, w.kw.gclass])).toEqual([["EV_TRACE_INFO_WANTED", "C_TCP"]]);
529
+ expect(viewer_box(reopened, "traffic").disabled).toBe(true);
530
+
531
+ gobj_send_event(view, "EV_TRACE_INFO", Object.assign({}, TCP_INFO,
532
+ {global_levels: YUNO_INFO.global_levels,
533
+ gclass_on: ["connections", "ev_kw"], global_on: ["ev_kw"]}), host);
534
+ expect(viewer_box(reopened, "traffic").disabled).toBe(false);
535
+ expect(problems()).toEqual([]);
536
+ });
480
537
  });
481
538
 
539
+ /* The card of tcp1 again, and its gclass button: the host's answer
540
+ * replaces the open viewer with a new one of C_TCP. */
541
+ function reopen_tcp_viewer(view)
542
+ {
543
+ const id = node_id_of(view, "C_YUNO^gate`C_TCP^tcp1");
544
+ gobj_send_event(view, "EV_NODE_CLICK", {id: id, client_x: 10, client_y: 10}, view);
545
+ gobj_send_event(view, "EV_OPEN_GCLASS", {}, view);
546
+ gobj_send_event(view, "EV_GCLASS_DESCRIPTION",
547
+ {gclass: "C_TCP", description: TCP_DESCRIPTION}, host);
548
+ const viewer = view.priv.gclass_view && view.priv.gclass_view.json_gobj;
549
+ expect(viewer).toBeTruthy();
550
+ return viewer;
551
+ }
552
+
482
553
  describe("C_YUI_GOBJ_TREE_JS, source local", () => {
483
554
  test("publishes nothing: its host declares none of the remote events", async () => {
484
555
  const view = await mount("local", yuno);
@@ -0,0 +1,199 @@
1
+ /***********************************************************************
2
+ * node_stages.wiring.test.js
3
+ *
4
+ * A shell with TWO stages (SHELL.md §3: `right` as a secondary
5
+ * stage). A route of the second stage changes what THAT stage
6
+ * shows and nothing else: the C_YUI_NODE tree the main stage still
7
+ * shows stays on its path. Up to 7.27.30 the root compared only the
8
+ * base of the route, so a route of the other stage sent it to
9
+ * ST_OFF and emptied it while the shell kept it on screen.
10
+ *
11
+ * A route of its OWN stage still takes it off the path, and the
12
+ * showing that follows tells its content once (EV_VIEW_SHOWN).
13
+ *
14
+ * Driven through the real C_YUI_SHELL on a document double.
15
+ *
16
+ * Copyright (c) 2026, ArtGins.
17
+ * All Rights Reserved.
18
+ ***********************************************************************/
19
+ import {describe, test, expect, beforeAll, beforeEach, afterEach} from "vitest";
20
+ import {install_dom_double} from "../test/dom_double.js";
21
+
22
+ install_dom_double();
23
+
24
+ const {
25
+ SDATA, SDATA_END, data_type_t, gclass_create, gobj_write_attr, gobj_read_attr,
26
+ gobj_start_up, gobj_create_yuno, gobj_create, gobj_find_child,
27
+ gobj_start, gobj_stop, gobj_destroy, gobj_is_running, gobj_name,
28
+ gobj_current_state, set_log_callback,
29
+ } = await import("@yuneta/gobj-js");
30
+ const {register_c_yui_shell, yui_shell_navigate} = await import("./c_yui_shell.js");
31
+ const {register_c_yui_node} = await import("./c_yui_node.js");
32
+ const {register_c_yui_nav} = await import("./c_yui_nav.js");
33
+
34
+ const logged = [];
35
+ const alive = [];
36
+ const shown = []; /* {name, kw} per EV_VIEW_SHOWN received */
37
+ let yuno = null;
38
+ let seq = 0;
39
+
40
+ beforeAll(async () => {
41
+ const i18next = (await import("i18next")).default;
42
+ await i18next.init({lng: "en", resources: {}});
43
+ gobj_start_up(null, null, null, null, null, null, null);
44
+ set_log_callback((level, msg) => {
45
+ logged.push({level: String(level), msg: String(msg)});
46
+ });
47
+ gclass_create("C_TEST_STAGES_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
48
+
49
+ const attrs = [
50
+ SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "view root"),
51
+ SDATA_END()
52
+ ];
53
+ const gmt = {
54
+ mt_create: (gobj) => {
55
+ gobj_write_attr(gobj, "$container", document.createElement("div"));
56
+ }
57
+ };
58
+ gclass_create(
59
+ "C_TEST_STAGES_VIEW",
60
+ [["EV_VIEW_SHOWN", 0]],
61
+ [["ST_IDLE", [
62
+ ["EV_VIEW_SHOWN", (gobj, event, kw) => {
63
+ shown.push({name: gobj_name(gobj), kw: kw});
64
+ return 0;
65
+ }, null]
66
+ ]]],
67
+ gmt, 0, attrs, {}, 0, 0, 0, 0
68
+ );
69
+
70
+ register_c_yui_shell();
71
+ register_c_yui_nav();
72
+ register_c_yui_node();
73
+ yuno = gobj_create_yuno("node_stages_yuno", "C_TEST_STAGES_HOST", {});
74
+ gobj_start(yuno);
75
+ });
76
+
77
+ beforeEach(() => {
78
+ logged.length = 0;
79
+ shown.length = 0;
80
+ });
81
+
82
+ afterEach(() => {
83
+ for(const gobj of alive.splice(0)) {
84
+ if(gobj_is_running(gobj)) {
85
+ gobj_stop(gobj);
86
+ }
87
+ gobj_destroy(gobj);
88
+ }
89
+ });
90
+
91
+ function config()
92
+ {
93
+ const view = (stage, name) => ({
94
+ stage: stage, gclass: "C_TEST_STAGES_VIEW", kw: {}, lifecycle: "keep_alive", name: name
95
+ });
96
+ return {
97
+ shell: {
98
+ zones: {
99
+ left: {host: "menu.primary"},
100
+ center: {host: "stage.main"},
101
+ right: {host: "stage.detail"}
102
+ },
103
+ stages: {
104
+ main: {zone: "center", default_route: "/plain"},
105
+ detail: {zone: "right"}
106
+ }
107
+ },
108
+ menu: {
109
+ primary: {
110
+ render: {left: {layout: "vertical", icon_pos: "left"}},
111
+ items: [
112
+ {id: "plain", name: "plain", route: "/plain", target: view("main", "plain_view")},
113
+ {id: "detail", name: "detail", route: "/detail", target: view("detail", "detail_view")},
114
+ {id: "tree", name: "tree", route: "/tree",
115
+ target: {
116
+ stage: "main", gclass: "C_YUI_NODE", lifecycle: "keep_alive",
117
+ name: "the_tree",
118
+ kw: {
119
+ node_id: "tree", base_route: "/tree",
120
+ children: [
121
+ {id: "acc", label: "acc",
122
+ content: {gclass: "C_TEST_STAGES_VIEW", kw: {}}}
123
+ ]
124
+ }
125
+ }}
126
+ ]
127
+ }
128
+ }
129
+ };
130
+ }
131
+
132
+ function new_shell()
133
+ {
134
+ const shell = gobj_create(`stages_shell_${++seq}`, "C_YUI_SHELL",
135
+ {config: config(), use_hash: false}, yuno);
136
+ gobj_start(shell);
137
+ alive.push(shell);
138
+ return shell;
139
+ }
140
+
141
+ function problems()
142
+ {
143
+ return logged.filter((l) => l.level === "error" || l.level === "warning").map((l) => l.msg);
144
+ }
145
+
146
+ /* What the main stage shows of the tree: its state, whether its
147
+ * container is visible, and whether the content of `acc` is in it. */
148
+ function tree_on_screen(shell)
149
+ {
150
+ const tree = gobj_find_child(shell, {__gobj_name__: "the_tree"});
151
+ expect(tree).toBeTruthy();
152
+ const $c = gobj_read_attr(tree, "$container");
153
+ const acc = tree.priv.children.find((c) => gobj_read_attr(c, "node_id") === "acc");
154
+ const content = acc && acc.priv.content_gobj;
155
+ const $content = content ? gobj_read_attr(content, "$container") : null;
156
+ return {
157
+ state: gobj_current_state(tree),
158
+ visible: !$c.classList.contains("is-hidden"),
159
+ content_drawn: !!$content && $c.contains($content),
160
+ };
161
+ }
162
+
163
+ describe("C_YUI_NODE under a shell with two stages", () => {
164
+ test("a route of ANOTHER stage leaves the tree on its path", () => {
165
+ const shell = new_shell();
166
+ yui_shell_navigate(shell, "/tree/acc");
167
+ const before = tree_on_screen(shell);
168
+ expect(before.state).not.toBe("ST_OFF");
169
+ expect(before.visible).toBe(true);
170
+ expect(before.content_drawn).toBe(true);
171
+
172
+ yui_shell_navigate(shell, "/detail");
173
+ expect(tree_on_screen(shell)).toEqual(before);
174
+
175
+ /* Back to the tree: it was never hidden, so it is not told
176
+ * it is shown again. */
177
+ yui_shell_navigate(shell, "/tree/acc");
178
+ expect(tree_on_screen(shell)).toEqual(before);
179
+ expect(shown).toEqual([]);
180
+ expect(problems()).toEqual([]);
181
+ });
182
+
183
+ test("a route of ITS stage takes it off the path, and the next showing tells the content once", () => {
184
+ const shell = new_shell();
185
+ yui_shell_navigate(shell, "/tree/acc");
186
+ yui_shell_navigate(shell, "/detail");
187
+ yui_shell_navigate(shell, "/plain");
188
+ const off = tree_on_screen(shell);
189
+ expect([off.state, off.visible, off.content_drawn]).toEqual(["ST_OFF", false, false]);
190
+
191
+ yui_shell_navigate(shell, "/tree/acc");
192
+ expect(tree_on_screen(shell).content_drawn).toBe(true);
193
+ /* (plain_view, the default route the shell opened on, is
194
+ * told too: it was shown before.) */
195
+ expect(shown.filter((s) => s.name !== "plain_view").map((s) => s.kw.route))
196
+ .toEqual(["/tree/acc"]);
197
+ expect(problems()).toEqual([]);
198
+ });
199
+ });