@yuneta/gobj-ui 7.27.28 → 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/index.js CHANGED
@@ -20,6 +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, yui_update_watch_language_changed } from "./src/c_yui_update_watch.js";
23
24
  export { register_c_yui_pager } from "./src/c_yui_pager.js";
24
25
  export { register_c_yui_wizard } from "./src/c_yui_wizard.js";
25
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.28",
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,10 +41,10 @@
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
- "vite": "^8.3.4",
47
+ "vite": "^8.3.5",
48
48
  "vitest": "^5.0.5"
49
49
  },
50
50
  "peerDependencies": {
@@ -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
 
@@ -295,7 +295,10 @@ function restore_view_state(gobj)
295
295
  done = true;
296
296
  }
297
297
  if(position !== null) {
298
- graph.translateTo(position);
298
+ /* What was saved is getPosition(), and translateTo() does
299
+ * not take it back: see translate_of_position(). */
300
+ graph.translateTo(translate_of_position(graph, position,
301
+ (zoom !== null)? zoom: graph.getZoom()));
299
302
  done = true;
300
303
  }
301
304
  if(state.anchor) {
@@ -317,14 +320,38 @@ function restore_view_state(gobj)
317
320
  return done;
318
321
  }
319
322
 
323
+ /* The translateTo() argument that puts the camera back where
324
+ * getPosition() answered `position`, at zoom `zoom` (the one the
325
+ * camera has when the translate is applied).
326
+ *
327
+ * The two are each other's inverse only at zoom 1. In G6 5.x, with C
328
+ * the canvas centre, Z the zoom and P the camera's own position,
329
+ * getPosition() answers S = C/Z - P, and an absolute translateTo(T)
330
+ * leaves P = C - T/Z. So the same camera is T = (S + C) * Z - C.
331
+ * Handing S to translateTo() as it came brought the zoom back and put
332
+ * the graph elsewhere, further on every close and open (and a camera
333
+ * saved at 0.3 was judged to show nothing, and framed again). The
334
+ * treedb graph met the same pair (c_g6_nodes_tree.js, "A camera is
335
+ * saved as a NODE at a VIEWPORT PIXEL"). */
336
+ function translate_of_position(graph, position, zoom)
337
+ {
338
+ let z = (zoom > 0)? zoom: 1;
339
+ let c = graph.getCanvasCenter();
340
+ return [
341
+ (position[0] + c[0]) * z - c[0],
342
+ (position[1] + c[1]) * z - c[1]
343
+ ];
344
+ }
345
+
320
346
  /* Would the centre of at least one card land inside the canvas under
321
347
  * this camera? `zoom` and `position` are what getZoom()/getPosition()
322
- * answer (a null one: the current). A camera absolute-translated to T
323
- * at zoom Z puts a point n of the graph at (n - C) * Z + T + C on the
324
- * canvas, C its centre -- the closed form of G6's own
325
- * getTranslateOptions(), the one yui_graph_center_on() relies on.
326
- * True when there is nothing to show or it cannot be computed: only a
327
- * camera KNOWN to show nothing is refused. */
348
+ * answer (a null one: the current). Under that camera a point n of the
349
+ * graph lands at (n + S) * Z on the canvas: from G6's closed forms
350
+ * (translate_of_position() above), v = (n - P) * Z + C with
351
+ * P = C/Z - S. NOT (n - C) * Z + S + C, which takes S for a translate
352
+ * and is right only at zoom 1. True when there is nothing to show or
353
+ * it cannot be computed: only a camera KNOWN to show nothing is
354
+ * refused. */
328
355
  function camera_shows_a_card(gobj, zoom, position)
329
356
  {
330
357
  let priv = gobj.priv;
@@ -335,9 +362,8 @@ function camera_shows_a_card(gobj, zoom, position)
335
362
  }
336
363
  try {
337
364
  let size = graph.getSize();
338
- let c = graph.getCanvasCenter();
339
365
  let z = (zoom !== null)? zoom: graph.getZoom();
340
- let t = (position !== null)? position: graph.getPosition();
366
+ let s = (position !== null)? position: graph.getPosition();
341
367
  let w = size[0];
342
368
  let h = size[1];
343
369
  if(!(w > 0 && h > 0) || !(z > 0)) {
@@ -345,8 +371,8 @@ function camera_shows_a_card(gobj, zoom, position)
345
371
  }
346
372
  for(let id of ids) {
347
373
  let n = graph.getElementPosition(id);
348
- let vx = (n[0] - c[0]) * z + t[0] + c[0];
349
- let vy = (n[1] - c[1]) * z + t[1] + c[1];
374
+ let vx = (n[0] + s[0]) * z;
375
+ let vy = (n[1] + s[1]) * z;
350
376
  if(vx >= 0 && vx <= w && vy >= 0 && vy <= h) {
351
377
  return true;
352
378
  }
@@ -470,6 +496,7 @@ let PRIVATE_DATA = {
470
496
  trace_info: {}, // gclass -> {gclass_levels, global_levels, gclass_on, global_on, error}
471
497
  trace_pending: false, // a trace was set: the block is locked until the host answers
472
498
  popover_mode: "", // what the popover shows: "node" (a card) | "yuno" (the yuno's traces)
499
+ viewer_awaits: "", // the gclass whose answer unlocks the open viewer ("" = not locked)
473
500
  viewer_stale: "", // a gclass whose open viewer must be asked again after a yuno set
474
501
  view_refused: false, // the saved camera showed no card: the opening's framing replaces it
475
502
  };
@@ -3568,6 +3595,8 @@ function open_gclass_window(gobj, gclass, description, d)
3568
3595
 
3569
3596
  close_gclass_view(priv.gclass_view);
3570
3597
  priv.gclass_view = null;
3598
+ priv.viewer_awaits = "";
3599
+ priv.viewer_stale = "";
3571
3600
 
3572
3601
  let opts = {
3573
3602
  title_prefix: is_remote(gobj)?
@@ -3668,16 +3697,24 @@ function ac_trace_info(gobj, event, kw, src)
3668
3697
  let viewer = gclass_viewer_gobj(gobj);
3669
3698
  if(viewer) {
3670
3699
  let shown = gobj_read_str_attr(viewer, "gclass_name");
3700
+ /* Only the answer the viewer waits for unlocks it: an answer
3701
+ * for another gclass (another card's set) is none of its
3702
+ * business. */
3703
+ if(priv.viewer_awaits === kw.gclass) {
3704
+ priv.viewer_awaits = "";
3705
+ if(priv.viewer_stale === shown && shown !== kw.gclass) {
3706
+ /* A set of the YUNO's scope: what the viewer shows as
3707
+ * held by the yuno moved too, and the host refreshed
3708
+ * only the root's gclass. Locked until its own. */
3709
+ priv.viewer_stale = "";
3710
+ priv.viewer_awaits = shown;
3711
+ gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: shown});
3712
+ }
3713
+ }
3671
3714
  if(shown === kw.gclass) {
3672
3715
  gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
3673
- } else if(priv.viewer_stale === shown) {
3674
- /* A set of the YUNO's scope: what the viewer shows as held by
3675
- * the yuno moved too, and the host refreshed only the root's
3676
- * gclass. */
3677
- gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: shown});
3678
3716
  }
3679
3717
  }
3680
- priv.viewer_stale = "";
3681
3718
  return 0;
3682
3719
  }
3683
3720
 
@@ -3693,14 +3730,15 @@ function gclass_viewer_gobj(gobj)
3693
3730
  /************************************************************
3694
3731
  * What the gclass viewer needs to draw the traces of `gclass`
3695
3732
  * for every gobj of it: the levels the host read, and whether a
3696
- * set is still in flight. Plain json: it rides in a kw.
3733
+ * set that concerns it is still in flight. Plain json: it rides
3734
+ * in a kw.
3697
3735
  ************************************************************/
3698
3736
  function viewer_traces(gobj, gclass)
3699
3737
  {
3700
3738
  let priv = gobj.priv;
3701
3739
  return {
3702
3740
  info: priv.trace_info[gclass] || null,
3703
- pending: !!priv.trace_pending,
3741
+ pending: !!priv.viewer_awaits,
3704
3742
  };
3705
3743
  }
3706
3744
 
@@ -3805,13 +3843,19 @@ function set_trace_levels(gobj, target, scope, levels, set)
3805
3843
  priv.trace_pending = true;
3806
3844
  render_current_popover(gobj);
3807
3845
 
3846
+ /* The viewer is locked only by a set that moves what it shows:
3847
+ * one of its own gclass, or one of the yuno's scope. A gobj or
3848
+ * gclass set of ANOTHER gclass leaves it alone -- the answer that
3849
+ * ends that set is not one the viewer would ever be sent. */
3808
3850
  let viewer = gclass_viewer_gobj(gobj);
3809
3851
  if(viewer) {
3810
3852
  let shown = gobj_read_str_attr(viewer, "gclass_name");
3811
- if(scope === "global" && shown !== target.gclass) {
3812
- priv.viewer_stale = shown;
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: "";
3857
+ gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
3813
3858
  }
3814
- gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
3815
3859
  }
3816
3860
 
3817
3861
  gobj_publish_event(gobj, "EV_SET_TRACE_LEVEL", {
package/src/c_yui_node.js CHANGED
@@ -1177,6 +1177,12 @@ function activate(gobj, subpath, inherited_depth)
1177
1177
  * `keep_alive` view, so the content may want to read again
1178
1178
  * what it read when it was created. Only a content that
1179
1179
  * declares EV_VIEW_SHOWN is told.
1180
+ *
1181
+ * 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
1184
+ * does not declare EV_VIEW_SHOWN and the shell does not send
1185
+ * the tree a second one.
1180
1186
  ************************************************************/
1181
1187
  function tell_content_shown(gobj)
1182
1188
  {
@@ -1320,24 +1326,6 @@ function ac_activate(gobj, event, kw, src)
1320
1326
  return 0;
1321
1327
  }
1322
1328
 
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
-
1341
1329
  /************************************************************
1342
1330
  * My parent took me off the path.
1343
1331
  ************************************************************/
@@ -1855,7 +1843,6 @@ function create_gclass(gclass_name)
1855
1843
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1856
1844
  ["EV_SET_CONTENT", ac_set_content, null],
1857
1845
  ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1858
- ["EV_VIEW_SHOWN", ac_view_shown, null],
1859
1846
  ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1860
1847
  ]],
1861
1848
  ["ST_CHILD", [
@@ -1872,7 +1859,6 @@ function create_gclass(gclass_name)
1872
1859
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1873
1860
  ["EV_SET_CONTENT", ac_set_content, null],
1874
1861
  ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1875
- ["EV_VIEW_SHOWN", ac_view_shown, null],
1876
1862
  ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1877
1863
  ]]
1878
1864
  ];
@@ -1894,8 +1880,6 @@ function create_gclass(gclass_name)
1894
1880
  ["EV_SET_NAV_MODE", 0],
1895
1881
  ["EV_SET_CONTENT", 0],
1896
1882
  ["EV_NODE_TREE_CHANGED", 0],
1897
- /* the shell or the parent shows the tree again (keep_alive) */
1898
- ["EV_VIEW_SHOWN", 0],
1899
1883
  /* internal: posted to itself, the navs a render left */
1900
1884
  ["EV_DESTROY_NAVS", 0]
1901
1885
  ];
@@ -0,0 +1,45 @@
1
+ /***********************************************************************
2
+ * c_yui_update_watch.css
3
+ *
4
+ * The bar of C_YUI_UPDATE_WATCH: a newer build is deployed.
5
+ *
6
+ * Fixed at the foot of the viewport, centred, over the floating
7
+ * dock's band and the phone's safe area. It lives in the shell's
8
+ * notification layer (above the dialogs) or, with no shell, in
9
+ * the body -- where the z-index puts it over the login. It
10
+ * appears and goes instantly.
11
+ *
12
+ * Copyright (c) 2026, ArtGins.
13
+ * All Rights Reserved.
14
+ ***********************************************************************/
15
+ .UPDATE_BAR.notification {
16
+ position: fixed;
17
+ left: 50%;
18
+ transform: translateX(-50%);
19
+ bottom: calc(1rem + var(--yui-dock-inset-bottom, 0px) + env(safe-area-inset-bottom, 0px));
20
+ z-index: 2000;
21
+ display: flex;
22
+ flex-wrap: wrap;
23
+ align-items: center;
24
+ gap: 0.5rem 0.75rem;
25
+ width: max-content;
26
+ max-width: calc(100vw - 2rem);
27
+ margin: 0;
28
+ padding: 0.75rem 2.5rem 0.75rem 1rem;
29
+ box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
30
+ pointer-events: auto;
31
+ transition: none;
32
+ }
33
+ .UPDATE_BAR .UPDATE_VERSION {
34
+ font-variant-numeric: tabular-nums;
35
+ font-weight: 600;
36
+ }
37
+ .UPDATE_BAR .UPDATE_VERSION:empty {
38
+ display: none;
39
+ }
40
+ .UPDATE_BAR.notification > .UPDATE_DISMISS {
41
+ position: absolute;
42
+ top: 50%;
43
+ right: 0.75rem;
44
+ transform: translateY(-50%);
45
+ }