@yuneta/gobj-ui 7.27.29 → 7.27.30

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
@@ -609,8 +609,11 @@ active child is the one already hanging in its body.
609
609
  **A content shown again is told so** (7.27.21+). A node keeps the content it
610
610
  built, as the shell keeps a `keep_alive` view, so a content that reads its data
611
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).
612
+ node sends it, with kw `{route}`, when it comes back to that content. That also
613
+ covers the whole tree shown again by the shell, because every node on the path
614
+ comes back with the shell's route change, so the node itself does not declare
615
+ `EV_VIEW_SHOWN` and the shell does not tell the tree a second time (7.27.30+).
616
+ Once per showing (SHELL.md §4).
614
617
 
615
618
  **The tree is a contract, not runtime state.** Once published, a node's path
616
619
  is a url a client may have bookmarked, scripted, or been sold as another door
@@ -3784,6 +3787,21 @@ if(update_watch) {
3784
3787
  `document.body` when there is no shell. It follows the shell across a logout.
3785
3788
  The ✕ hides it for that build only, and a later deploy shows it again. A
3786
3789
  rollback to the running build takes it away.
3790
+ - **Its language** follows the live shell's `EV_LANGUAGE_CHANGED`
3791
+ (`yui_shell_language_changed()`). On the login there is no shell to publish
3792
+ it, so the app's login language switch calls
3793
+ **`yui_update_watch_language_changed()`** after switching its i18next
3794
+ (7.27.30+). It sends `EV_LANGUAGE_CHANGED` to every live watch, so the bar
3795
+ is re-translated through the watch's FSM. With a shell up too, the second
3796
+ refresh is harmless:
3797
+
3798
+ ```js
3799
+ import {yui_update_watch_language_changed} from "@yuneta/gobj-ui/src/c_yui_update_watch.js";
3800
+
3801
+ // the login's language button, after switching the i18next language:
3802
+ switch_locale(locale);
3803
+ yui_update_watch_language_changed(); // or (gobj), the gobj that switched
3804
+ ```
3787
3805
  - **Attributes**: `min_interval_ms`, `period_ms` (0 = off), `with_bar`
3788
3806
  (false: no bar, the app listens to `EV_NEW_BUILD`), `$parent`, and
3789
3807
  `before_reload`, a function that can veto the reload when there are unsaved
@@ -7090,6 +7090,13 @@ function build_page_url(loc) {
7090
7090
  * next login) in document.body. It follows the shell across a
7091
7091
  * logout (yui_shell_watch_changes()), as the dock does.
7092
7092
  *
7093
+ * Its language: it hears the live shell's EV_LANGUAGE_CHANGED
7094
+ * (yui_shell_language_changed()). With NO shell there is nobody
7095
+ * to publish that, so an app whose login switches language
7096
+ * calls yui_update_watch_language_changed() after switching its
7097
+ * i18next -- it sends EV_LANGUAGE_CHANGED to every live watch.
7098
+ * Calling it with a shell up too is harmless.
7099
+ *
7093
7100
  * Usage (an app, once, after creating the yuno):
7094
7101
  *
7095
7102
  * register_c_yui_update_watch();
@@ -7101,12 +7108,21 @@ function build_page_url(loc) {
7101
7108
  * // on its backend's EV_ON_OPEN:
7102
7109
  * gobj_send_event(watch, "EV_CHECK_BUILD", {}, gobj);
7103
7110
  *
7111
+ * // the login's language switch (no shell yet):
7112
+ * switch_locale(locale);
7113
+ * yui_update_watch_language_changed();
7114
+ *
7104
7115
  * Input events:
7105
7116
  * EV_CHECK_BUILD {force?} ask the server (force skips
7106
7117
  * the minimum interval)
7107
7118
  * EV_RELOAD {} the bar's reload button
7108
7119
  * EV_DISMISS {} the bar's ✕: hidden for THIS
7109
7120
  * build, a later one shows it
7121
+ * EV_LANGUAGE_CHANGED {} the app's language changed:
7122
+ * the bar is re-translated
7123
+ * (the live shell publishes it;
7124
+ * with no shell,
7125
+ * yui_update_watch_language_changed())
7110
7126
  *
7111
7127
  * Output events (optional subscribers):
7112
7128
  * EV_NEW_BUILD {running, deployed, version}
@@ -7145,6 +7161,7 @@ var PRIVATE_DATA$20 = {
7145
7161
  dom_handlers: null
7146
7162
  };
7147
7163
  var __gclass__$20 = null;
7164
+ var __live_watches__ = [];
7148
7165
  /******************************
7149
7166
  * Framework Methods
7150
7167
  ******************************/
@@ -7155,6 +7172,7 @@ function mt_create$20(gobj) {
7155
7172
  let priv = gobj.priv;
7156
7173
  priv.running = running_build(typeof document !== "undefined" ? document : null);
7157
7174
  priv.dom_handlers = [];
7175
+ __live_watches__.push(gobj);
7158
7176
  priv.gobj_timer = (0, _yuneta_gobj_js.gobj_create_pure_child)((0, _yuneta_gobj_js.gobj_name)(gobj), "C_TIMER", {}, gobj);
7159
7177
  yui_shell_watch_changes(gobj);
7160
7178
  follow_language(gobj);
@@ -7203,6 +7221,8 @@ function mt_stop$20(gobj) {
7203
7221
  ***************************************************************/
7204
7222
  function mt_destroy$20(gobj) {
7205
7223
  let priv = gobj.priv;
7224
+ let idx = __live_watches__.indexOf(gobj);
7225
+ if (idx >= 0) __live_watches__.splice(idx, 1);
7206
7226
  yui_shell_unwatch_changes(gobj);
7207
7227
  if (priv.lang_shell) {
7208
7228
  if (!(0, _yuneta_gobj_js.gobj_is_destroying)(priv.lang_shell)) (0, _yuneta_gobj_js.gobj_unsubscribe_event)(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
@@ -7616,6 +7636,23 @@ function create_gclass$20(gclass_name) {
7616
7636
  function register_c_yui_update_watch() {
7617
7637
  return create_gclass$20(GCLASS_NAME$20);
7618
7638
  }
7639
+ /***************************************************************
7640
+ * The app switched its language (call it AFTER switching the
7641
+ * i18next): every live watch re-translates its bar.
7642
+ *
7643
+ * For the screens with no shell -- the login, the gap between a
7644
+ * logout and the next login -- where nobody publishes the
7645
+ * shell's EV_LANGUAGE_CHANGED that the watch hears otherwise.
7646
+ * It is an EVENT to each watch, so the switch is in its
7647
+ * machine trace. `src`: the gobj that switched, if the caller
7648
+ * has one.
7649
+ ***************************************************************/
7650
+ function yui_update_watch_language_changed(src) {
7651
+ for (let watch of __live_watches__.slice()) {
7652
+ if ((0, _yuneta_gobj_js.gobj_is_destroying)(watch)) continue;
7653
+ (0, _yuneta_gobj_js.gobj_send_event)(watch, "EV_LANGUAGE_CHANGED", {}, src || watch);
7654
+ }
7655
+ }
7619
7656
  //#endregion
7620
7657
  //#region src/pager_helpers.js
7621
7658
  /***************************************************************
@@ -23240,7 +23277,8 @@ var PRIVATE_DATA$10 = {
23240
23277
  $raw: null,
23241
23278
  $raw_body: null,
23242
23279
  $search: null,
23243
- $mode_btns: null
23280
+ $mode_btns: null,
23281
+ lang_shell: null
23244
23282
  };
23245
23283
  var __gclass__$10 = null;
23246
23284
  /******************************
@@ -23266,12 +23304,21 @@ function mt_create$10(gobj) {
23266
23304
  * Framework Method: Start
23267
23305
  ***************************************************************/
23268
23306
  function mt_start$10(gobj) {
23307
+ let priv = gobj.priv;
23308
+ let shell = yui_shell_of(gobj);
23309
+ if (shell) {
23310
+ (0, _yuneta_gobj_js.gobj_subscribe_event)(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
23311
+ priv.lang_shell = shell;
23312
+ }
23269
23313
  render_view(gobj);
23270
23314
  }
23271
23315
  /***************************************************************
23272
23316
  * Framework Method: Stop
23273
23317
  ***************************************************************/
23274
23318
  function mt_stop$10(gobj) {
23319
+ let priv = gobj.priv;
23320
+ if (priv.lang_shell && !(0, _yuneta_gobj_js.gobj_is_destroying)(priv.lang_shell)) (0, _yuneta_gobj_js.gobj_unsubscribe_event)(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
23321
+ priv.lang_shell = null;
23275
23322
  teardown_graph_child(gobj);
23276
23323
  }
23277
23324
  /***************************************************************
@@ -24877,6 +24924,7 @@ function ac_language_changed$6(gobj, event, kw, src) {
24877
24924
  apply_view_mode(gobj);
24878
24925
  }
24879
24926
  render_view(gobj);
24927
+ if (priv.graph_gobj && (0, _yuneta_gobj_js.gobj_is_running)(priv.graph_gobj)) (0, _yuneta_gobj_js.gobj_send_event)(priv.graph_gobj, "EV_LANGUAGE_CHANGED", {}, gobj);
24880
24928
  return 0;
24881
24929
  }
24882
24930
  /************************************************************
@@ -52273,7 +52321,7 @@ function restore_view_state(gobj) {
52273
52321
  done = true;
52274
52322
  }
52275
52323
  if (position !== null) {
52276
- graph.translateTo(position);
52324
+ graph.translateTo(translate_of_position(graph, position, zoom !== null ? zoom : graph.getZoom()));
52277
52325
  done = true;
52278
52326
  }
52279
52327
  if (state.anchor) {
@@ -52291,6 +52339,11 @@ function restore_view_state(gobj) {
52291
52339
  yui_graph_update_zoom((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container"), priv.graph);
52292
52340
  return done;
52293
52341
  }
52342
+ function translate_of_position(graph, position, zoom) {
52343
+ let z = zoom > 0 ? zoom : 1;
52344
+ let c = graph.getCanvasCenter();
52345
+ return [(position[0] + c[0]) * z - c[0], (position[1] + c[1]) * z - c[1]];
52346
+ }
52294
52347
  function camera_shows_a_card(gobj, zoom, position) {
52295
52348
  let priv = gobj.priv;
52296
52349
  let graph = priv.graph;
@@ -52298,16 +52351,15 @@ function camera_shows_a_card(gobj, zoom, position) {
52298
52351
  if (!graph || !ids.length) return true;
52299
52352
  try {
52300
52353
  let size = graph.getSize();
52301
- let c = graph.getCanvasCenter();
52302
52354
  let z = zoom !== null ? zoom : graph.getZoom();
52303
- let t = position !== null ? position : graph.getPosition();
52355
+ let s = position !== null ? position : graph.getPosition();
52304
52356
  let w = size[0];
52305
52357
  let h = size[1];
52306
52358
  if (!(w > 0 && h > 0) || !(z > 0)) return true;
52307
52359
  for (let id of ids) {
52308
52360
  let n = graph.getElementPosition(id);
52309
- let vx = (n[0] - c[0]) * z + t[0] + c[0];
52310
- let vy = (n[1] - c[1]) * z + t[1] + c[1];
52361
+ let vx = (n[0] + s[0]) * z;
52362
+ let vy = (n[1] + s[1]) * z;
52311
52363
  if (vx >= 0 && vx <= w && vy >= 0 && vy <= h) return true;
52312
52364
  }
52313
52365
  } catch (e) {
@@ -52387,6 +52439,7 @@ var PRIVATE_DATA$9 = {
52387
52439
  trace_info: {},
52388
52440
  trace_pending: false,
52389
52441
  popover_mode: "",
52442
+ viewer_awaits: "",
52390
52443
  viewer_stale: "",
52391
52444
  view_refused: false
52392
52445
  };
@@ -54787,6 +54840,8 @@ function open_gclass_window(gobj, gclass, description, d) {
54787
54840
  let priv = gobj.priv;
54788
54841
  close_gclass_view(priv.gclass_view);
54789
54842
  priv.gclass_view = null;
54843
+ priv.viewer_awaits = "";
54844
+ priv.viewer_stale = "";
54790
54845
  let opts = {
54791
54846
  title_prefix: is_remote(gobj) ? (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "yuno_name") || "" : (0, _yuneta_gobj_js.gobj_yuno_name)() || "",
54792
54847
  current_state: d && d.state || "",
@@ -54859,10 +54914,16 @@ function ac_trace_info(gobj, event, kw, src) {
54859
54914
  let viewer = gclass_viewer_gobj(gobj);
54860
54915
  if (viewer) {
54861
54916
  let shown = (0, _yuneta_gobj_js.gobj_read_str_attr)(viewer, "gclass_name");
54917
+ if (priv.viewer_awaits === kw.gclass) {
54918
+ priv.viewer_awaits = "";
54919
+ if (priv.viewer_stale === shown && shown !== kw.gclass) {
54920
+ priv.viewer_stale = "";
54921
+ priv.viewer_awaits = shown;
54922
+ (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54923
+ }
54924
+ }
54862
54925
  if (shown === kw.gclass) (0, _yuneta_gobj_js.gobj_send_event)(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
54863
- else if (priv.viewer_stale === shown) (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54864
54926
  }
54865
- priv.viewer_stale = "";
54866
54927
  return 0;
54867
54928
  }
54868
54929
  /************************************************************
@@ -54875,13 +54936,14 @@ function gclass_viewer_gobj(gobj) {
54875
54936
  /************************************************************
54876
54937
  * What the gclass viewer needs to draw the traces of `gclass`
54877
54938
  * for every gobj of it: the levels the host read, and whether a
54878
- * set is still in flight. Plain json: it rides in a kw.
54939
+ * set that concerns it is still in flight. Plain json: it rides
54940
+ * in a kw.
54879
54941
  ************************************************************/
54880
54942
  function viewer_traces(gobj, gclass) {
54881
54943
  let priv = gobj.priv;
54882
54944
  return {
54883
54945
  info: priv.trace_info[gclass] || null,
54884
- pending: !!priv.trace_pending
54946
+ pending: !!priv.viewer_awaits
54885
54947
  };
54886
54948
  }
54887
54949
  /************************************************************
@@ -54965,8 +55027,11 @@ function set_trace_levels(gobj, target, scope, levels, set) {
54965
55027
  let viewer = gclass_viewer_gobj(gobj);
54966
55028
  if (viewer) {
54967
55029
  let shown = (0, _yuneta_gobj_js.gobj_read_str_attr)(viewer, "gclass_name");
54968
- if (scope === "global" && shown !== target.gclass) priv.viewer_stale = shown;
54969
- (0, _yuneta_gobj_js.gobj_send_event)(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
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
+ }
54970
55035
  }
54971
55036
  (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_SET_TRACE_LEVEL", {
54972
55037
  scope,
@@ -89125,6 +89190,7 @@ exports.yui_svg_icon_element = yui_svg_icon_element;
89125
89190
  exports.yui_svg_sanitize = yui_svg_sanitize;
89126
89191
  exports.yui_theme_now = yui_theme_now;
89127
89192
  exports.yui_toolbar = yui_toolbar;
89193
+ exports.yui_update_watch_language_changed = yui_update_watch_language_changed;
89128
89194
  exports.yui_user_icon_class = yui_user_icon_class;
89129
89195
  exports.yui_watch_theme = yui_watch_theme;
89130
89196
 
@@ -7085,6 +7085,13 @@ function build_page_url(loc) {
7085
7085
  * next login) in document.body. It follows the shell across a
7086
7086
  * logout (yui_shell_watch_changes()), as the dock does.
7087
7087
  *
7088
+ * Its language: it hears the live shell's EV_LANGUAGE_CHANGED
7089
+ * (yui_shell_language_changed()). With NO shell there is nobody
7090
+ * to publish that, so an app whose login switches language
7091
+ * calls yui_update_watch_language_changed() after switching its
7092
+ * i18next -- it sends EV_LANGUAGE_CHANGED to every live watch.
7093
+ * Calling it with a shell up too is harmless.
7094
+ *
7088
7095
  * Usage (an app, once, after creating the yuno):
7089
7096
  *
7090
7097
  * register_c_yui_update_watch();
@@ -7096,12 +7103,21 @@ function build_page_url(loc) {
7096
7103
  * // on its backend's EV_ON_OPEN:
7097
7104
  * gobj_send_event(watch, "EV_CHECK_BUILD", {}, gobj);
7098
7105
  *
7106
+ * // the login's language switch (no shell yet):
7107
+ * switch_locale(locale);
7108
+ * yui_update_watch_language_changed();
7109
+ *
7099
7110
  * Input events:
7100
7111
  * EV_CHECK_BUILD {force?} ask the server (force skips
7101
7112
  * the minimum interval)
7102
7113
  * EV_RELOAD {} the bar's reload button
7103
7114
  * EV_DISMISS {} the bar's ✕: hidden for THIS
7104
7115
  * build, a later one shows it
7116
+ * EV_LANGUAGE_CHANGED {} the app's language changed:
7117
+ * the bar is re-translated
7118
+ * (the live shell publishes it;
7119
+ * with no shell,
7120
+ * yui_update_watch_language_changed())
7105
7121
  *
7106
7122
  * Output events (optional subscribers):
7107
7123
  * EV_NEW_BUILD {running, deployed, version}
@@ -7140,6 +7156,7 @@ var PRIVATE_DATA$20 = {
7140
7156
  dom_handlers: null
7141
7157
  };
7142
7158
  var __gclass__$20 = null;
7159
+ var __live_watches__ = [];
7143
7160
  /******************************
7144
7161
  * Framework Methods
7145
7162
  ******************************/
@@ -7150,6 +7167,7 @@ function mt_create$20(gobj) {
7150
7167
  let priv = gobj.priv;
7151
7168
  priv.running = running_build(typeof document !== "undefined" ? document : null);
7152
7169
  priv.dom_handlers = [];
7170
+ __live_watches__.push(gobj);
7153
7171
  priv.gobj_timer = gobj_create_pure_child(gobj_name(gobj), "C_TIMER", {}, gobj);
7154
7172
  yui_shell_watch_changes(gobj);
7155
7173
  follow_language(gobj);
@@ -7198,6 +7216,8 @@ function mt_stop$20(gobj) {
7198
7216
  ***************************************************************/
7199
7217
  function mt_destroy$20(gobj) {
7200
7218
  let priv = gobj.priv;
7219
+ let idx = __live_watches__.indexOf(gobj);
7220
+ if (idx >= 0) __live_watches__.splice(idx, 1);
7201
7221
  yui_shell_unwatch_changes(gobj);
7202
7222
  if (priv.lang_shell) {
7203
7223
  if (!gobj_is_destroying(priv.lang_shell)) gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
@@ -7611,6 +7631,23 @@ function create_gclass$20(gclass_name) {
7611
7631
  function register_c_yui_update_watch() {
7612
7632
  return create_gclass$20(GCLASS_NAME$20);
7613
7633
  }
7634
+ /***************************************************************
7635
+ * The app switched its language (call it AFTER switching the
7636
+ * i18next): every live watch re-translates its bar.
7637
+ *
7638
+ * For the screens with no shell -- the login, the gap between a
7639
+ * logout and the next login -- where nobody publishes the
7640
+ * shell's EV_LANGUAGE_CHANGED that the watch hears otherwise.
7641
+ * It is an EVENT to each watch, so the switch is in its
7642
+ * machine trace. `src`: the gobj that switched, if the caller
7643
+ * has one.
7644
+ ***************************************************************/
7645
+ function yui_update_watch_language_changed(src) {
7646
+ for (let watch of __live_watches__.slice()) {
7647
+ if (gobj_is_destroying(watch)) continue;
7648
+ gobj_send_event(watch, "EV_LANGUAGE_CHANGED", {}, src || watch);
7649
+ }
7650
+ }
7614
7651
  //#endregion
7615
7652
  //#region src/pager_helpers.js
7616
7653
  /***************************************************************
@@ -23235,7 +23272,8 @@ var PRIVATE_DATA$10 = {
23235
23272
  $raw: null,
23236
23273
  $raw_body: null,
23237
23274
  $search: null,
23238
- $mode_btns: null
23275
+ $mode_btns: null,
23276
+ lang_shell: null
23239
23277
  };
23240
23278
  var __gclass__$10 = null;
23241
23279
  /******************************
@@ -23261,12 +23299,21 @@ function mt_create$10(gobj) {
23261
23299
  * Framework Method: Start
23262
23300
  ***************************************************************/
23263
23301
  function mt_start$10(gobj) {
23302
+ let priv = gobj.priv;
23303
+ let shell = yui_shell_of(gobj);
23304
+ if (shell) {
23305
+ gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
23306
+ priv.lang_shell = shell;
23307
+ }
23264
23308
  render_view(gobj);
23265
23309
  }
23266
23310
  /***************************************************************
23267
23311
  * Framework Method: Stop
23268
23312
  ***************************************************************/
23269
23313
  function mt_stop$10(gobj) {
23314
+ let priv = gobj.priv;
23315
+ if (priv.lang_shell && !gobj_is_destroying(priv.lang_shell)) gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
23316
+ priv.lang_shell = null;
23270
23317
  teardown_graph_child(gobj);
23271
23318
  }
23272
23319
  /***************************************************************
@@ -24872,6 +24919,7 @@ function ac_language_changed$6(gobj, event, kw, src) {
24872
24919
  apply_view_mode(gobj);
24873
24920
  }
24874
24921
  render_view(gobj);
24922
+ if (priv.graph_gobj && gobj_is_running(priv.graph_gobj)) gobj_send_event(priv.graph_gobj, "EV_LANGUAGE_CHANGED", {}, gobj);
24875
24923
  return 0;
24876
24924
  }
24877
24925
  /************************************************************
@@ -52268,7 +52316,7 @@ function restore_view_state(gobj) {
52268
52316
  done = true;
52269
52317
  }
52270
52318
  if (position !== null) {
52271
- graph.translateTo(position);
52319
+ graph.translateTo(translate_of_position(graph, position, zoom !== null ? zoom : graph.getZoom()));
52272
52320
  done = true;
52273
52321
  }
52274
52322
  if (state.anchor) {
@@ -52286,6 +52334,11 @@ function restore_view_state(gobj) {
52286
52334
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
52287
52335
  return done;
52288
52336
  }
52337
+ function translate_of_position(graph, position, zoom) {
52338
+ let z = zoom > 0 ? zoom : 1;
52339
+ let c = graph.getCanvasCenter();
52340
+ return [(position[0] + c[0]) * z - c[0], (position[1] + c[1]) * z - c[1]];
52341
+ }
52289
52342
  function camera_shows_a_card(gobj, zoom, position) {
52290
52343
  let priv = gobj.priv;
52291
52344
  let graph = priv.graph;
@@ -52293,16 +52346,15 @@ function camera_shows_a_card(gobj, zoom, position) {
52293
52346
  if (!graph || !ids.length) return true;
52294
52347
  try {
52295
52348
  let size = graph.getSize();
52296
- let c = graph.getCanvasCenter();
52297
52349
  let z = zoom !== null ? zoom : graph.getZoom();
52298
- let t = position !== null ? position : graph.getPosition();
52350
+ let s = position !== null ? position : graph.getPosition();
52299
52351
  let w = size[0];
52300
52352
  let h = size[1];
52301
52353
  if (!(w > 0 && h > 0) || !(z > 0)) return true;
52302
52354
  for (let id of ids) {
52303
52355
  let n = graph.getElementPosition(id);
52304
- let vx = (n[0] - c[0]) * z + t[0] + c[0];
52305
- let vy = (n[1] - c[1]) * z + t[1] + c[1];
52356
+ let vx = (n[0] + s[0]) * z;
52357
+ let vy = (n[1] + s[1]) * z;
52306
52358
  if (vx >= 0 && vx <= w && vy >= 0 && vy <= h) return true;
52307
52359
  }
52308
52360
  } catch (e) {
@@ -52382,6 +52434,7 @@ var PRIVATE_DATA$9 = {
52382
52434
  trace_info: {},
52383
52435
  trace_pending: false,
52384
52436
  popover_mode: "",
52437
+ viewer_awaits: "",
52385
52438
  viewer_stale: "",
52386
52439
  view_refused: false
52387
52440
  };
@@ -54782,6 +54835,8 @@ function open_gclass_window(gobj, gclass, description, d) {
54782
54835
  let priv = gobj.priv;
54783
54836
  close_gclass_view(priv.gclass_view);
54784
54837
  priv.gclass_view = null;
54838
+ priv.viewer_awaits = "";
54839
+ priv.viewer_stale = "";
54785
54840
  let opts = {
54786
54841
  title_prefix: is_remote(gobj) ? gobj_read_str_attr(gobj, "yuno_name") || "" : gobj_yuno_name() || "",
54787
54842
  current_state: d && d.state || "",
@@ -54854,10 +54909,16 @@ function ac_trace_info(gobj, event, kw, src) {
54854
54909
  let viewer = gclass_viewer_gobj(gobj);
54855
54910
  if (viewer) {
54856
54911
  let shown = gobj_read_str_attr(viewer, "gclass_name");
54912
+ if (priv.viewer_awaits === kw.gclass) {
54913
+ priv.viewer_awaits = "";
54914
+ if (priv.viewer_stale === shown && shown !== kw.gclass) {
54915
+ priv.viewer_stale = "";
54916
+ priv.viewer_awaits = shown;
54917
+ gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54918
+ }
54919
+ }
54857
54920
  if (shown === kw.gclass) gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
54858
- else if (priv.viewer_stale === shown) gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", { gclass: shown });
54859
54921
  }
54860
- priv.viewer_stale = "";
54861
54922
  return 0;
54862
54923
  }
54863
54924
  /************************************************************
@@ -54870,13 +54931,14 @@ function gclass_viewer_gobj(gobj) {
54870
54931
  /************************************************************
54871
54932
  * What the gclass viewer needs to draw the traces of `gclass`
54872
54933
  * for every gobj of it: the levels the host read, and whether a
54873
- * set is still in flight. Plain json: it rides in a kw.
54934
+ * set that concerns it is still in flight. Plain json: it rides
54935
+ * in a kw.
54874
54936
  ************************************************************/
54875
54937
  function viewer_traces(gobj, gclass) {
54876
54938
  let priv = gobj.priv;
54877
54939
  return {
54878
54940
  info: priv.trace_info[gclass] || null,
54879
- pending: !!priv.trace_pending
54941
+ pending: !!priv.viewer_awaits
54880
54942
  };
54881
54943
  }
54882
54944
  /************************************************************
@@ -54960,8 +55022,11 @@ function set_trace_levels(gobj, target, scope, levels, set) {
54960
55022
  let viewer = gclass_viewer_gobj(gobj);
54961
55023
  if (viewer) {
54962
55024
  let shown = gobj_read_str_attr(viewer, "gclass_name");
54963
- if (scope === "global" && shown !== target.gclass) priv.viewer_stale = shown;
54964
- gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
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
+ }
54965
55030
  }
54966
55031
  gobj_publish_event(gobj, "EV_SET_TRACE_LEVEL", {
54967
55032
  scope,
@@ -88996,6 +89061,6 @@ function setup_json_pad(self) {
88996
89061
  return win;
88997
89062
  }
88998
89063
  //#endregion
88999
- export { EditControl, ICONS_TOPIC, MarkerControl, USER_ICON_PREFIX, YUI_FILE_ACCEPT, YUI_PERIODS, YUI_PERIODS_DEFAULT, YUI_ROLLING, addClasses, apply_dev_traces, attach_clear, build_dev_panel, dev_window_was_open, disableElements, enableElements, epoch_to_local_input, epoch_to_ms, expose_view_container, fmt_date_time, fmt_epoch, getStrokeColor, infer_period, info_traffic, inject_svg_icons, is_current_period, iso_week, local_input_to_epoch, ms_to_epoch, period_bounds, period_bounds_epoch, period_label, period_name, period_shift, period_spec, period_start, refresh_clear, register_c_g6_nodes_tree, register_c_yui_form, register_c_yui_fsm_graph, register_c_yui_gclass, register_c_yui_gobj_tree_js, register_c_yui_json, register_c_yui_json_graph, register_c_yui_json_pad, register_c_yui_map, register_c_yui_nav, register_c_yui_pager, register_c_yui_period, register_c_yui_schema_editor, register_c_yui_service_view, register_c_yui_shell, register_c_yui_treedb_graph, register_c_yui_treedb_schema, register_c_yui_treedb_topic_with_form, register_c_yui_treedb_topics, register_c_yui_update_watch, register_c_yui_uplot, register_c_yui_window, register_c_yui_window_manager, register_c_yui_wizard, removeChildElements, removeClasses, rolling_bounds, safe_locale, set_active_state, set_cancel_state, set_pressed_state, set_submit_state, setup_dev, setup_frontend_view, setup_json_pad, toggleClasses, yui_array_buffer_to_base64, yui_asset_element, yui_asset_id, yui_asset_ids, yui_asset_missing, yui_asset_src, yui_file_control, yui_file_id_label, yui_file_read, yui_file_sha256, yui_file_size_label, yui_files_manifest, yui_icon_is_defined, yui_icons_list, yui_icons_put_user, yui_icons_remove_user, yui_icons_set_user, yui_is_dark, yui_mount_service_view, yui_shell_close_drawer, yui_shell_close_dropdown, yui_shell_confirm_danger, yui_shell_confirm_ok, yui_shell_confirm_yesno, yui_shell_confirm_yesnocancel, yui_shell_escape_order, yui_shell_navigate, yui_shell_open_drawer, yui_shell_overlay_dismissed, yui_shell_pop_escape, yui_shell_push_escape, yui_shell_refresh_avatars, yui_shell_register_event_handler, yui_shell_register_overlay, yui_shell_set_avatar_provider, yui_shell_set_connection_state, yui_shell_set_nav_item_badge, yui_shell_set_sub_routes, yui_shell_set_toolbar_item_badge, yui_shell_set_toolbar_item_icon, yui_shell_set_translator, yui_shell_show_error, yui_shell_show_info, yui_shell_show_modal, yui_shell_show_route_map, yui_shell_show_warning, yui_shell_toggle_drawer, yui_shell_unpark_route, yui_svg_icon_element, yui_svg_sanitize, yui_theme_now, yui_toolbar, yui_user_icon_class, yui_watch_theme };
89064
+ export { EditControl, ICONS_TOPIC, MarkerControl, USER_ICON_PREFIX, YUI_FILE_ACCEPT, YUI_PERIODS, YUI_PERIODS_DEFAULT, YUI_ROLLING, addClasses, apply_dev_traces, attach_clear, build_dev_panel, dev_window_was_open, disableElements, enableElements, epoch_to_local_input, epoch_to_ms, expose_view_container, fmt_date_time, fmt_epoch, getStrokeColor, infer_period, info_traffic, inject_svg_icons, is_current_period, iso_week, local_input_to_epoch, ms_to_epoch, period_bounds, period_bounds_epoch, period_label, period_name, period_shift, period_spec, period_start, refresh_clear, register_c_g6_nodes_tree, register_c_yui_form, register_c_yui_fsm_graph, register_c_yui_gclass, register_c_yui_gobj_tree_js, register_c_yui_json, register_c_yui_json_graph, register_c_yui_json_pad, register_c_yui_map, register_c_yui_nav, register_c_yui_pager, register_c_yui_period, register_c_yui_schema_editor, register_c_yui_service_view, register_c_yui_shell, register_c_yui_treedb_graph, register_c_yui_treedb_schema, register_c_yui_treedb_topic_with_form, register_c_yui_treedb_topics, register_c_yui_update_watch, register_c_yui_uplot, register_c_yui_window, register_c_yui_window_manager, register_c_yui_wizard, removeChildElements, removeClasses, rolling_bounds, safe_locale, set_active_state, set_cancel_state, set_pressed_state, set_submit_state, setup_dev, setup_frontend_view, setup_json_pad, toggleClasses, yui_array_buffer_to_base64, yui_asset_element, yui_asset_id, yui_asset_ids, yui_asset_missing, yui_asset_src, yui_file_control, yui_file_id_label, yui_file_read, yui_file_sha256, yui_file_size_label, yui_files_manifest, yui_icon_is_defined, yui_icons_list, yui_icons_put_user, yui_icons_remove_user, yui_icons_set_user, yui_is_dark, yui_mount_service_view, yui_shell_close_drawer, yui_shell_close_dropdown, yui_shell_confirm_danger, yui_shell_confirm_ok, yui_shell_confirm_yesno, yui_shell_confirm_yesnocancel, yui_shell_escape_order, yui_shell_navigate, yui_shell_open_drawer, yui_shell_overlay_dismissed, yui_shell_pop_escape, yui_shell_push_escape, yui_shell_refresh_avatars, yui_shell_register_event_handler, yui_shell_register_overlay, yui_shell_set_avatar_provider, yui_shell_set_connection_state, yui_shell_set_nav_item_badge, yui_shell_set_sub_routes, yui_shell_set_toolbar_item_badge, yui_shell_set_toolbar_item_icon, yui_shell_set_translator, yui_shell_show_error, yui_shell_show_info, yui_shell_show_modal, yui_shell_show_route_map, yui_shell_show_warning, yui_shell_toggle_drawer, yui_shell_unpark_route, yui_svg_icon_element, yui_svg_sanitize, yui_theme_now, yui_toolbar, yui_update_watch_language_changed, yui_user_icon_class, yui_watch_theme };
89000
89065
 
89001
89066
  //# sourceMappingURL=gobj-ui.es.js.map
package/index.js CHANGED
@@ -20,7 +20,7 @@
20
20
  */
21
21
  export { register_c_yui_window } from "./src/c_yui_window.js";
22
22
  export { register_c_yui_window_manager } from "./src/c_yui_window_manager.js";
23
- export { register_c_yui_update_watch } from "./src/c_yui_update_watch.js";
23
+ export { register_c_yui_update_watch, yui_update_watch_language_changed } from "./src/c_yui_update_watch.js";
24
24
  export { register_c_yui_pager } from "./src/c_yui_pager.js";
25
25
  export { register_c_yui_wizard } from "./src/c_yui_wizard.js";
26
26
  export { register_c_yui_form } from "./src/c_yui_form.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.27.29",
3
+ "version": "7.27.30",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -41,7 +41,7 @@
41
41
  "acorn": "^8.19.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@rollup/plugin-terser": "^1.0.0",
44
+ "@rollup/plugin-terser": "^1.0.2",
45
45
  "@vitest/coverage-v8": "^5.0.5",
46
46
  "@yuneta/gobj-js": "^7.27.0",
47
47
  "vite": "^8.3.5",
@@ -77,6 +77,8 @@ import {
77
77
  gobj_read_pointer_attr,
78
78
  gobj_parent,
79
79
  gobj_subscribe_event,
80
+ gobj_unsubscribe_event,
81
+ gobj_is_destroying,
80
82
  gobj_read_attr,
81
83
  gobj_write_attr,
82
84
  gobj_read_str_attr,
@@ -102,6 +104,7 @@ import {json_text_dump} from "./json_view_helpers.js";
102
104
  import {yui_toolbar} from "./yui_toolbar.js";
103
105
  import {attach_clear} from "./yui_inputs.js";
104
106
  import {yui_copy_json, yui_button_mark_done} from "./yui_clipboard.js";
107
+ import {yui_shell_of} from "./c_yui_shell.js";
105
108
 
106
109
  import {t} from "i18next";
107
110
 
@@ -211,6 +214,7 @@ let PRIVATE_DATA = {
211
214
  $raw_body: null, // the <pre> inside it
212
215
  $search: null, // the search input
213
216
  $mode_btns: null, // Map<mode, HTMLElement> of the view switch
217
+ lang_shell: null, // the shell whose EV_LANGUAGE_CHANGED we hear
214
218
  };
215
219
 
216
220
  let __gclass__ = null;
@@ -256,6 +260,21 @@ function mt_create(gobj)
256
260
  ***************************************************************/
257
261
  function mt_start(gobj)
258
262
  {
263
+ let priv = gobj.priv;
264
+
265
+ /* The counted words ("4 instances", "show all 25", the machine's
266
+ * "3 states · 9 events") carry no key on purpose -- a key would
267
+ * make refresh_language() write the bare word over the count --
268
+ * so only a re-render changes their language. The viewer is
269
+ * created by open_gclass_view() as a service with no subscriber,
270
+ * and its host does not forward the language switch: it hears
271
+ * the shell's itself, as C_YUI_JSON does. */
272
+ let shell = yui_shell_of(gobj);
273
+ if(shell) {
274
+ gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
275
+ priv.lang_shell = shell;
276
+ }
277
+
259
278
  render_view(gobj);
260
279
  }
261
280
 
@@ -264,6 +283,15 @@ function mt_start(gobj)
264
283
  ***************************************************************/
265
284
  function mt_stop(gobj)
266
285
  {
286
+ let priv = gobj.priv;
287
+
288
+ /* The shell it subscribed to, if it is still there: a logout may
289
+ * have destroyed it, and its subscriptions with it. */
290
+ if(priv.lang_shell && !gobj_is_destroying(priv.lang_shell)) {
291
+ gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
292
+ }
293
+ priv.lang_shell = null;
294
+
267
295
  /*
268
296
  * The graph child dies with this gobj's RUNNING state, not with
269
297
  * its destruction: gobj_destroy() destroys the children BEFORE
@@ -1737,6 +1765,10 @@ function ac_language_changed(gobj, event, kw, src)
1737
1765
  apply_view_mode(gobj);
1738
1766
  }
1739
1767
  render_view(gobj);
1768
+ /* The machine's graph, when it is built, draws its own words. */
1769
+ if(priv.graph_gobj && gobj_is_running(priv.graph_gobj)) {
1770
+ gobj_send_event(priv.graph_gobj, "EV_LANGUAGE_CHANGED", {}, gobj);
1771
+ }
1740
1772
  return 0;
1741
1773
  }
1742
1774