@yuneta/gobj-ui 7.5.5 → 7.5.7

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.
@@ -52923,7 +52923,9 @@ var PRIVATE_DATA$1 = {
52923
52923
  _focus_ids: [],
52924
52924
  _pending_focus_topic: null,
52925
52925
  _pending_find: null,
52926
- _layout_asked: ""
52926
+ _layout_asked: "",
52927
+ _nodes_total: 0,
52928
+ _nodes_placed: 0
52927
52929
  };
52928
52930
  var __gclass__$1 = null;
52929
52931
  /******************************
@@ -53494,6 +53496,8 @@ function create_topic_node(gobj, desc, record) {
53494
53496
  let node_name = build_node_name(gobj, desc.topic_name, record.id);
53495
53497
  let xy = get_default_ne_xy(gobj);
53496
53498
  let geometry = get_node_graph_props(gobj, desc.topic_name, record.id, record);
53499
+ priv._nodes_total++;
53500
+ if (geometry_has_position(geometry)) priv._nodes_placed++;
53497
53501
  let x = (0, _yuneta_gobj_js.kw_get_int)(gobj, geometry, "x", xy, _yuneta_gobj_js.kw_flag_t.KW_CREATE);
53498
53502
  let y = (0, _yuneta_gobj_js.kw_get_int)(gobj, geometry, "y", xy, _yuneta_gobj_js.kw_flag_t.KW_CREATE);
53499
53503
  let ports = build_ports(gobj, desc);
@@ -55701,35 +55705,16 @@ function show_node_detail_popover(gobj, node_id) {
55701
55705
  * junction diamonds get their neutral fill/stroke re-themed.
55702
55706
  ************************************************************/
55703
55707
  /************************************************************
55704
- * How many nodes of this treedb carry a saved position, and how many
55705
- * there are. Positions live in `__graphs__` (per topic, per node) and,
55706
- * on older data, in a `_geometry` on the record itself; both are read.
55708
+ * Does this geometry carry a POSITION?
55709
+ *
55710
+ * An empty object does not. A treedb hands back `_geometry: {}` for a
55711
+ * record nobody ever moved, and a `__graphs__` node entry can hold a
55712
+ * port size and no coordinates — both are objects all the same.
55707
55713
  ************************************************************/
55708
55714
  function geometry_has_position(g) {
55709
55715
  if (!(0, _yuneta_gobj_js.is_object)(g)) return false;
55710
55716
  return (0, _yuneta_gobj_js.is_number)(g.x) || (0, _yuneta_gobj_js.is_number)(g.y);
55711
55717
  }
55712
- function count_saved_geometry(gobj) {
55713
- let priv = gobj.priv;
55714
- let saved = 0;
55715
- let total = 0;
55716
- for (let topic of Object.keys(priv.records || {})) {
55717
- let records = priv.records[topic];
55718
- if (!(0, _yuneta_gobj_js.is_array)(records)) continue;
55719
- let props = priv._graph_properties ? priv._graph_properties[topic] : null;
55720
- let nodes = props && (0, _yuneta_gobj_js.is_object)(props.nodes) ? props.nodes : null;
55721
- for (let record of records) {
55722
- if (!record) continue;
55723
- total++;
55724
- if (nodes && geometry_has_position(nodes[record.id])) saved++;
55725
- else if (geometry_has_position(record._geometry)) saved++;
55726
- }
55727
- }
55728
- return {
55729
- saved,
55730
- total
55731
- };
55732
- }
55733
55718
  /************************************************************
55734
55719
  * Choose a layout for a treedb nobody has arranged yet.
55735
55720
  *
@@ -55748,8 +55733,7 @@ function count_saved_geometry(gobj) {
55748
55733
  function auto_layout(gobj) {
55749
55734
  let priv = gobj.priv;
55750
55735
  if (priv._layout_asked) return;
55751
- let g = count_saved_geometry(gobj);
55752
- if (g.total > 0 && g.saved * 2 > g.total) return;
55736
+ if (priv._nodes_total > 0 && priv._nodes_placed * 2 > priv._nodes_total) return;
55753
55737
  if (!priv.graph) return;
55754
55738
  let name = "dagre";
55755
55739
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "layout", name);
@@ -56558,10 +56542,12 @@ function ac_descs(gobj, event, kw, src) {
56558
56542
  * Clear all graph data, from parent
56559
56543
  ************************************************************/
56560
56544
  function ac_clear_data(gobj, event, kw, src) {
56561
- gobj.priv;
56545
+ let priv = gobj.priv;
56562
56546
  deselect_node(gobj);
56563
56547
  hide_create_popover(gobj);
56564
56548
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "records", {});
56549
+ priv._nodes_total = 0;
56550
+ priv._nodes_placed = 0;
56565
56551
  graph_remove_plugin(gobj, "history");
56566
56552
  update_history_buttons(gobj);
56567
56553
  graph_clear(gobj);
@@ -52910,7 +52910,9 @@ var PRIVATE_DATA$1 = {
52910
52910
  _focus_ids: [],
52911
52911
  _pending_focus_topic: null,
52912
52912
  _pending_find: null,
52913
- _layout_asked: ""
52913
+ _layout_asked: "",
52914
+ _nodes_total: 0,
52915
+ _nodes_placed: 0
52914
52916
  };
52915
52917
  var __gclass__$1 = null;
52916
52918
  /******************************
@@ -53481,6 +53483,8 @@ function create_topic_node(gobj, desc, record) {
53481
53483
  let node_name = build_node_name(gobj, desc.topic_name, record.id);
53482
53484
  let xy = get_default_ne_xy(gobj);
53483
53485
  let geometry = get_node_graph_props(gobj, desc.topic_name, record.id, record);
53486
+ priv._nodes_total++;
53487
+ if (geometry_has_position(geometry)) priv._nodes_placed++;
53484
53488
  let x = kw_get_int(gobj, geometry, "x", xy, kw_flag_t.KW_CREATE);
53485
53489
  let y = kw_get_int(gobj, geometry, "y", xy, kw_flag_t.KW_CREATE);
53486
53490
  let ports = build_ports(gobj, desc);
@@ -55688,35 +55692,16 @@ function show_node_detail_popover(gobj, node_id) {
55688
55692
  * junction diamonds get their neutral fill/stroke re-themed.
55689
55693
  ************************************************************/
55690
55694
  /************************************************************
55691
- * How many nodes of this treedb carry a saved position, and how many
55692
- * there are. Positions live in `__graphs__` (per topic, per node) and,
55693
- * on older data, in a `_geometry` on the record itself; both are read.
55695
+ * Does this geometry carry a POSITION?
55696
+ *
55697
+ * An empty object does not. A treedb hands back `_geometry: {}` for a
55698
+ * record nobody ever moved, and a `__graphs__` node entry can hold a
55699
+ * port size and no coordinates — both are objects all the same.
55694
55700
  ************************************************************/
55695
55701
  function geometry_has_position(g) {
55696
55702
  if (!is_object(g)) return false;
55697
55703
  return is_number(g.x) || is_number(g.y);
55698
55704
  }
55699
- function count_saved_geometry(gobj) {
55700
- let priv = gobj.priv;
55701
- let saved = 0;
55702
- let total = 0;
55703
- for (let topic of Object.keys(priv.records || {})) {
55704
- let records = priv.records[topic];
55705
- if (!is_array(records)) continue;
55706
- let props = priv._graph_properties ? priv._graph_properties[topic] : null;
55707
- let nodes = props && is_object(props.nodes) ? props.nodes : null;
55708
- for (let record of records) {
55709
- if (!record) continue;
55710
- total++;
55711
- if (nodes && geometry_has_position(nodes[record.id])) saved++;
55712
- else if (geometry_has_position(record._geometry)) saved++;
55713
- }
55714
- }
55715
- return {
55716
- saved,
55717
- total
55718
- };
55719
- }
55720
55705
  /************************************************************
55721
55706
  * Choose a layout for a treedb nobody has arranged yet.
55722
55707
  *
@@ -55735,8 +55720,7 @@ function count_saved_geometry(gobj) {
55735
55720
  function auto_layout(gobj) {
55736
55721
  let priv = gobj.priv;
55737
55722
  if (priv._layout_asked) return;
55738
- let g = count_saved_geometry(gobj);
55739
- if (g.total > 0 && g.saved * 2 > g.total) return;
55723
+ if (priv._nodes_total > 0 && priv._nodes_placed * 2 > priv._nodes_total) return;
55740
55724
  if (!priv.graph) return;
55741
55725
  let name = "dagre";
55742
55726
  gobj_write_attr(gobj, "layout", name);
@@ -56545,10 +56529,12 @@ function ac_descs(gobj, event, kw, src) {
56545
56529
  * Clear all graph data, from parent
56546
56530
  ************************************************************/
56547
56531
  function ac_clear_data(gobj, event, kw, src) {
56548
- gobj.priv;
56532
+ let priv = gobj.priv;
56549
56533
  deselect_node(gobj);
56550
56534
  hide_create_popover(gobj);
56551
56535
  gobj_write_attr(gobj, "records", {});
56536
+ priv._nodes_total = 0;
56537
+ priv._nodes_placed = 0;
56552
56538
  graph_remove_plugin(gobj, "history");
56553
56539
  update_history_buttons(gobj);
56554
56540
  graph_clear(gobj);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.5.5",
3
+ "version": "7.5.7",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -293,6 +293,8 @@ let PRIVATE_DATA = {
293
293
  _pending_focus_topic: null, // focus requested before data was loaded
294
294
  _pending_find: null, // find requested before data was loaded
295
295
  _layout_asked: "", // layout the host asked for at create (see mt_create)
296
+ _nodes_total: 0, // nodes built so far (auto_layout)
297
+ _nodes_placed: 0, // ...of which carried a saved position
296
298
  };
297
299
 
298
300
  let __gclass__ = null;
@@ -1224,6 +1226,19 @@ function create_topic_node(gobj, desc, record)
1224
1226
  let node_name = build_node_name(gobj, desc.topic_name, record.id);
1225
1227
  let xy = get_default_ne_xy(gobj);
1226
1228
  let geometry = get_node_graph_props(gobj, desc.topic_name, record.id, record);
1229
+
1230
+ /* Counted HERE, and before the two kw_get_int() below, because those
1231
+ * carry KW_CREATE: `get_node_graph_props()` hands back the record's own
1232
+ * `_geometry` object when it has one — and `{}` is one — so the very
1233
+ * next lines WRITE the invented cascade coordinates into it. Ask the
1234
+ * question a moment later and every node of every treedb answers
1235
+ * "placed", which is exactly how the dagre default kept refusing to
1236
+ * fire: 126 of 126, all of them positions the app had just made up. */
1237
+ priv._nodes_total++;
1238
+ if(geometry_has_position(geometry)) {
1239
+ priv._nodes_placed++;
1240
+ }
1241
+
1227
1242
  let x = kw_get_int(gobj, geometry, "x", xy, kw_flag_t.KW_CREATE);
1228
1243
  let y = kw_get_int(gobj, geometry, "y", xy, kw_flag_t.KW_CREATE);
1229
1244
 
@@ -4495,52 +4510,20 @@ function show_node_detail_popover(gobj, node_id)
4495
4510
  * junction diamonds get their neutral fill/stroke re-themed.
4496
4511
  ************************************************************/
4497
4512
  /************************************************************
4498
- * How many nodes of this treedb carry a saved position, and how many
4499
- * there are. Positions live in `__graphs__` (per topic, per node) and,
4500
- * on older data, in a `_geometry` on the record itself; both are read.
4513
+ * Does this geometry carry a POSITION?
4514
+ *
4515
+ * An empty object does not. A treedb hands back `_geometry: {}` for a
4516
+ * record nobody ever moved, and a `__graphs__` node entry can hold a
4517
+ * port size and no coordinates — both are objects all the same.
4501
4518
  ************************************************************/
4502
4519
  function geometry_has_position(g)
4503
4520
  {
4504
- /* An EMPTY object is not a position. A treedb hands back
4505
- * `_geometry: {}` for a record nobody ever moved, and a `__graphs__`
4506
- * node entry can hold a port size with no coordinates — both are
4507
- * objects, and taking either for "this was placed" is wrong. */
4508
4521
  if(!is_object(g)) {
4509
4522
  return false;
4510
4523
  }
4511
4524
  return is_number(g.x) || is_number(g.y);
4512
4525
  }
4513
4526
 
4514
- function count_saved_geometry(gobj)
4515
- {
4516
- let priv = gobj.priv;
4517
- let saved = 0;
4518
- let total = 0;
4519
-
4520
- for(let topic of Object.keys(priv.records || {})) {
4521
- let records = priv.records[topic];
4522
- if(!is_array(records)) {
4523
- continue;
4524
- }
4525
- let props = priv._graph_properties? priv._graph_properties[topic] : null;
4526
- let nodes = (props && is_object(props.nodes))? props.nodes : null;
4527
-
4528
- for(let record of records) {
4529
- if(!record) {
4530
- continue;
4531
- }
4532
- total++;
4533
- if(nodes && geometry_has_position(nodes[record.id])) {
4534
- saved++;
4535
- } else if(geometry_has_position(record._geometry)) {
4536
- saved++;
4537
- }
4538
- }
4539
- }
4540
-
4541
- return {saved: saved, total: total};
4542
- }
4543
-
4544
4527
  /************************************************************
4545
4528
  * Choose a layout for a treedb nobody has arranged yet.
4546
4529
  *
@@ -4570,8 +4553,10 @@ function auto_layout(gobj)
4570
4553
  * that forced this had exactly ONE node of 126 carrying a geometry,
4571
4554
  * and it was `{x:100, y:100}` — the first cascade slot, saved. One
4572
4555
  * leftover is not an arrangement. A majority is. */
4573
- let g = count_saved_geometry(gobj);
4574
- if(g.total > 0 && g.saved * 2 > g.total) {
4556
+ /* MOST of the nodes, not one of them: the app saves a position it
4557
+ * invented as readily as one a human chose, so a single stored
4558
+ * coordinate proves nothing. One leftover is not an arrangement. */
4559
+ if(priv._nodes_total > 0 && priv._nodes_placed * 2 > priv._nodes_total) {
4575
4560
  return; /* somebody arranged it: leave it alone */
4576
4561
  }
4577
4562
  if(!priv.graph) {
@@ -5791,6 +5776,11 @@ function ac_clear_data(gobj, event, kw, src)
5791
5776
 
5792
5777
  gobj_write_attr(gobj, "records", {});
5793
5778
 
5779
+ /* The node counters belong to the data that is going away: a refresh
5780
+ * that kept them would decide the layout on the previous treedb. */
5781
+ priv._nodes_total = 0;
5782
+ priv._nodes_placed = 0;
5783
+
5794
5784
  graph_remove_plugin(gobj, "history");
5795
5785
  update_history_buttons(gobj);
5796
5786
  graph_clear(gobj);