@yuneta/gobj-ui 7.27.23 → 7.27.24

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.
@@ -17946,8 +17946,8 @@ function load_json(gobj) {
17946
17946
  yui_graph_update_zoom((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container"), priv.graph);
17947
17947
  return;
17948
17948
  }
17949
- Promise.resolve(graph.zoomTo(1)).then(() => {
17950
- if (!yui_graph_center_on(graph, priv.anchor_id)) yui_graph_center_on(graph, root_id);
17949
+ Promise.resolve(graph.zoomTo(1)).then(async () => {
17950
+ if (!(priv.anchor_id ? await yui_graph_center_on(graph, priv.anchor_id) : false)) await yui_graph_center_on(graph, root_id);
17951
17951
  priv.last_zoom = 1;
17952
17952
  yui_graph_update_zoom((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container"), priv.graph);
17953
17953
  });
@@ -24404,16 +24404,23 @@ function restore_view_state(gobj) {
24404
24404
  let graph = priv.graph;
24405
24405
  let state = load_view_state(gobj);
24406
24406
  if (!graph || !state) return false;
24407
+ let zoom = Number.isFinite(state.zoom) && state.zoom > 0 ? state.zoom : null;
24408
+ let position = Array.isArray(state.position) && state.position.length >= 2 && Number.isFinite(state.position[0]) && Number.isFinite(state.position[1]) ? [state.position[0], state.position[1]] : null;
24409
+ if ((zoom !== null || position !== null) && !camera_shows_a_card(gobj, zoom, position)) {
24410
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: the saved view shows none of the ${Object.keys(priv.node_by_id || {}).length} gobjs, framed again`);
24411
+ zoom = null;
24412
+ position = null;
24413
+ }
24407
24414
  let done = false;
24408
24415
  priv.restoring = true;
24409
24416
  try {
24410
- if (Number.isFinite(state.zoom) && state.zoom > 0) {
24411
- graph.zoomTo(state.zoom);
24412
- priv.last_zoom = state.zoom;
24417
+ if (zoom !== null) {
24418
+ graph.zoomTo(zoom);
24419
+ priv.last_zoom = zoom;
24413
24420
  done = true;
24414
24421
  }
24415
- if (Array.isArray(state.position) && state.position.length >= 2 && Number.isFinite(state.position[0]) && Number.isFinite(state.position[1])) {
24416
- graph.translateTo([state.position[0], state.position[1]]);
24422
+ if (position !== null) {
24423
+ graph.translateTo(position);
24417
24424
  done = true;
24418
24425
  }
24419
24426
  if (state.anchor) {
@@ -24431,6 +24438,30 @@ function restore_view_state(gobj) {
24431
24438
  yui_graph_update_zoom((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container"), priv.graph);
24432
24439
  return done;
24433
24440
  }
24441
+ function camera_shows_a_card(gobj, zoom, position) {
24442
+ let priv = gobj.priv;
24443
+ let graph = priv.graph;
24444
+ let ids = Object.keys(priv.node_by_id || {});
24445
+ if (!graph || !ids.length) return true;
24446
+ try {
24447
+ let size = graph.getSize();
24448
+ let c = graph.getCanvasCenter();
24449
+ let z = zoom !== null ? zoom : graph.getZoom();
24450
+ let t = position !== null ? position : graph.getPosition();
24451
+ let w = size[0];
24452
+ let h = size[1];
24453
+ if (!(w > 0 && h > 0) || !(z > 0)) return true;
24454
+ for (let id of ids) {
24455
+ let n = graph.getElementPosition(id);
24456
+ let vx = (n[0] - c[0]) * z + t[0] + c[0];
24457
+ let vy = (n[1] - c[1]) * z + t[1] + c[1];
24458
+ if (vx >= 0 && vx <= w && vy >= 0 && vy <= h) return true;
24459
+ }
24460
+ } catch (e) {
24461
+ return true;
24462
+ }
24463
+ return false;
24464
+ }
24434
24465
  function save_view_state(gobj) {
24435
24466
  let priv = gobj.priv;
24436
24467
  let graph = priv.graph;
@@ -24441,8 +24472,9 @@ function save_view_state(gobj) {
24441
24472
  anchor: priv.anchor_state === "on" ? priv.anchor_name : ""
24442
24473
  };
24443
24474
  let camera = null;
24475
+ let has_nodes = !!priv.node_by_id && Object.keys(priv.node_by_id).length > 0;
24444
24476
  try {
24445
- camera = camera_of(graph.getZoom(), graph.getPosition());
24477
+ camera = has_nodes ? camera_of(graph.getZoom(), graph.getPosition()) : null;
24446
24478
  } catch (e) {}
24447
24479
  if (!camera) {
24448
24480
  let old = load_view_state(gobj);
@@ -25594,8 +25626,8 @@ function load_tree(gobj) {
25594
25626
  priv.restored = true;
25595
25627
  if (restore_view_state(gobj)) return;
25596
25628
  }
25597
- Promise.resolve(graph.zoomTo(1)).then(() => {
25598
- if (!yui_graph_center_on(graph, priv.anchor_id)) yui_graph_center_on(graph, root_id);
25629
+ Promise.resolve(graph.zoomTo(1)).then(async () => {
25630
+ if (!(priv.anchor_id ? await yui_graph_center_on(graph, priv.anchor_id) : false)) await yui_graph_center_on(graph, root_id);
25599
25631
  priv.last_zoom = 1;
25600
25632
  yui_graph_update_zoom((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container"), priv.graph);
25601
25633
  });
@@ -43482,8 +43514,8 @@ function _objectWithoutProperties(e, t) {
43482
43514
  /*!
43483
43515
  * @antv/g-lite
43484
43516
  * @description A core module for rendering engine implements DOM API.
43485
- * @version 2.7.0
43486
- * @date 12/24/2025, 11:55:20 AM
43517
+ * @version 2.7.2
43518
+ * @date 10/16/2026, 2:34:22 AM
43487
43519
  * @author AntVis
43488
43520
  * @docs https://g.antv.antgroup.com/
43489
43521
  */
@@ -43954,12 +43986,13 @@ function getAngle(angle) {
43954
43986
  }
43955
43987
  var $vec3$3 = create$3();
43956
43988
  function createVec3(x) {
43989
+ var _x$, _x$2, _x$3, _x$4;
43957
43990
  var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
43958
43991
  var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
43959
43992
  var clone$2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : true;
43960
43993
  if (Array.isArray(x) && x.length === 3) return clone$2 ? clone(x) : copy$3($vec3$3, x);
43961
43994
  if (isNumber(x)) return clone$2 ? fromValues$2(x, y, z) : set$3($vec3$3, x, y, z);
43962
- return clone$2 ? fromValues$2(x[0], x[1] || y, x[2] || z) : set$3($vec3$3, x[0], x[1] || y, x[2] || z);
43995
+ return clone$2 ? fromValues$2(x[0], (_x$ = x[1]) !== null && _x$ !== void 0 ? _x$ : y, (_x$2 = x[2]) !== null && _x$2 !== void 0 ? _x$2 : z) : set$3($vec3$3, x[0], (_x$3 = x[1]) !== null && _x$3 !== void 0 ? _x$3 : y, (_x$4 = x[2]) !== null && _x$4 !== void 0 ? _x$4 : z);
43963
43996
  }
43964
43997
  var DEG_RAD = Math.PI / 180;
43965
43998
  function deg2rad(deg) {
@@ -50218,7 +50251,7 @@ var FederatedEvent = /*#__PURE__*/ function() {
50218
50251
  }
50219
50252
  ]);
50220
50253
  }();
50221
- var FederatedMouseEvent = /*#__PURE__*/ function(_ref) {
50254
+ var FederatedMouseEvent = /*#__PURE__*/ function(_FederatedEvent) {
50222
50255
  function FederatedMouseEvent() {
50223
50256
  var _this;
50224
50257
  _classCallCheck(this, FederatedMouseEvent);
@@ -50254,7 +50287,7 @@ var FederatedMouseEvent = /*#__PURE__*/ function(_ref) {
50254
50287
  _this.screen = new Point();
50255
50288
  return _this;
50256
50289
  }
50257
- _inherits(FederatedMouseEvent, _ref);
50290
+ _inherits(FederatedMouseEvent, _FederatedEvent);
50258
50291
  return _createClass(FederatedMouseEvent, [
50259
50292
  {
50260
50293
  key: "clientX",
@@ -54907,9 +54940,18 @@ var PrepareRendererPlugin = /*#__PURE__*/ function() {
54907
54940
  renderingService.dirty();
54908
54941
  };
54909
54942
  var handleBoundsChanged = function handleBoundsChanged(e) {
54910
- var _this$mutationRecords;
54911
54943
  var records = e.detail;
54912
- (_this$mutationRecords = _this.mutationRecords).push.apply(_this$mutationRecords, _toConsumableArray(records));
54944
+ var _iterator = _createForOfIteratorHelper(records), _step;
54945
+ try {
54946
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
54947
+ var record = _step.value;
54948
+ _this.mutationRecords.push(record);
54949
+ }
54950
+ } catch (err) {
54951
+ _iterator.e(err);
54952
+ } finally {
54953
+ _iterator.f();
54954
+ }
54913
54955
  renderingService.dirty();
54914
54956
  };
54915
54957
  var handleMounted = function handleMounted(e) {
@@ -55910,8 +55952,8 @@ PERFORMANCE OF THIS SOFTWARE.
55910
55952
  /*!
55911
55953
  * @antv/g
55912
55954
  * @description A core module for rendering engine implements DOM API.
55913
- * @version 6.3.1
55914
- * @date 12/24/2025, 11:55:39 AM
55955
+ * @version 6.3.3
55956
+ * @date 10/16/2026, 2:34:40 AM
55915
55957
  * @author AntVis
55916
55958
  * @docs https://g.antv.antgroup.com/
55917
55959
  */
@@ -63073,74 +63115,43 @@ var Animation = /*#__PURE__*/ function() {
63073
63115
  /**
63074
63116
  * https://github.com/gre/bezier-easing
63075
63117
  * BezierEasing - use bezier curve for transition easing function
63076
- * by Gaëtan Renaudeau 2014 - 2015 – MIT License
63118
+ * by Gaëtan Renaudeau 2014 - 2026 – MIT License
63077
63119
  */
63078
- var NEWTON_ITERATIONS = 4;
63079
- var NEWTON_MIN_SLOPE = .001;
63080
- var SUBDIVISION_PRECISION = 1e-7;
63081
- var SUBDIVISION_MAX_ITERATIONS = 10;
63082
- var kSplineTableSize = 11;
63083
- var kSampleStepSize = 1 / (kSplineTableSize - 1);
63084
- var float32ArraySupported = typeof Float32Array === "function";
63085
- var A = function A(aA1, aA2) {
63086
- return 1 - 3 * aA2 + 3 * aA1;
63087
- };
63088
- var B = function B(aA1, aA2) {
63089
- return 3 * aA2 - 6 * aA1;
63090
- };
63091
- var C = function C(aA1) {
63092
- return 3 * aA1;
63093
- };
63094
- var calcBezier = function calcBezier(aT, aA1, aA2) {
63095
- return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
63096
- };
63097
- var getSlope = function getSlope(aT, aA1, aA2) {
63098
- return 3 * A(aA1, aA2) * aT * aT + 2 * B(aA1, aA2) * aT + C(aA1);
63099
- };
63100
- var binarySubdivide = function binarySubdivide(aX, aA, aB, mX1, mX2) {
63101
- var currentX;
63102
- var currentT;
63103
- var i = 0;
63104
- do {
63105
- currentT = aA + (aB - aA) / 2;
63106
- currentX = calcBezier(currentT, mX1, mX2) - aX;
63107
- if (currentX > 0) aB = currentT;
63108
- else aA = currentT;
63109
- } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
63110
- return currentT;
63111
- };
63112
- var newtonRaphsonIterate = function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
63113
- for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
63114
- var currentSlope = getSlope(aGuessT, mX1, mX2);
63115
- if (currentSlope === 0) return aGuessT;
63116
- var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
63117
- aGuessT -= currentX / currentSlope;
63118
- }
63119
- return aGuessT;
63120
+ var solveTForX = function solveTForX(x, a, b, c) {
63121
+ var j = 1 / Math.max(c, Math.sqrt(x));
63122
+ var k = x * j;
63123
+ var l = k * j;
63124
+ var s = c * j;
63125
+ var q = b * l;
63126
+ var m = s * s + q;
63127
+ var h = -s * (s * s + 1.5 * q) - a * k * l;
63128
+ var D = h * h - m * m * m;
63129
+ var v;
63130
+ if (m === 0 || D > 1e-12 * h * h) {
63131
+ var U = -Math.cbrt(h < 0 ? h - Math.sqrt(D) : h + Math.sqrt(D));
63132
+ v = U + m / U || 0;
63133
+ } else {
63134
+ var r = Math.sqrt(m);
63135
+ v = 2 * r * Math.cos(Math.acos(Math.max(-1, Math.min(1, -h / (m * r)))) / 3);
63136
+ }
63137
+ return Math.min(1, k / (v + s));
63120
63138
  };
63121
63139
  var bezier = function bezier(mX1, mY1, mX2, mY2) {
63122
63140
  if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) throw new Error("bezier x values must be in [0, 1] range");
63123
63141
  if (mX1 === mY1 && mX2 === mY2) return function(t) {
63124
63142
  return t;
63125
63143
  };
63126
- var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
63127
- for (var i = 0; i < kSplineTableSize; ++i) sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
63128
- var getTForX = function getTForX(aX) {
63129
- var intervalStart = 0;
63130
- var currentSample = 1;
63131
- var lastSample = kSplineTableSize - 1;
63132
- for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) intervalStart += kSampleStepSize;
63133
- --currentSample;
63134
- var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
63135
- var guessForT = intervalStart + dist * kSampleStepSize;
63136
- var initialSlope = getSlope(guessForT, mX1, mX2);
63137
- if (initialSlope >= NEWTON_MIN_SLOPE) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
63138
- if (initialSlope === 0) return guessForT;
63139
- return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
63140
- };
63144
+ var a = (3 * mX1 - 3 * mX2 + 1) / 2;
63145
+ var b = mX2 - 2 * mX1;
63146
+ var c = mX1;
63147
+ var ay = 3 * mY1 - 3 * mY2 + 1;
63148
+ var by = 3 * (mY2 - 2 * mY1);
63149
+ var cy = 3 * mY1;
63141
63150
  return function(t) {
63142
- if (t === 0 || t === 1) return t;
63143
- return calcBezier(getTForX(t), mY1, mY2);
63151
+ if (t <= 0) return 0;
63152
+ if (t >= 1) return 1;
63153
+ var u = solveTForX(t, a, b, c);
63154
+ return ((ay * u + by) * u + cy) * u;
63144
63155
  };
63145
63156
  };
63146
63157
  var convertToDash = function convertToDash(str) {
@@ -63882,9 +63893,11 @@ var AnimationTimeline = /*#__PURE__*/ function() {
63882
63893
  if (t < Number(_this.currentTime)) t = Number(_this.currentTime);
63883
63894
  _this.animations.sort(compareAnimations);
63884
63895
  _this.animations = _this.tick(t, true, _this.animations)[0];
63896
+ _this.updateAnimationsPromises();
63885
63897
  processing.forEach(function(entry) {
63886
63898
  entry[1](t);
63887
63899
  });
63900
+ _this.updateAnimationsPromises();
63888
63901
  _this.applyPendingEffects();
63889
63902
  };
63890
63903
  this.document = document;
@@ -63994,18 +64007,13 @@ var AnimationTimeline = /*#__PURE__*/ function() {
63994
64007
  {
63995
64008
  key: "requestAnimationFrame",
63996
64009
  value: function requestAnimationFrame(f) {
63997
- var _this3 = this;
63998
- return this.rAF(function(x) {
63999
- _this3.updateAnimationsPromises();
64000
- f(x);
64001
- _this3.updateAnimationsPromises();
64002
- });
64010
+ return this.rAF(f);
64003
64011
  }
64004
64012
  },
64005
64013
  {
64006
64014
  key: "tick",
64007
64015
  value: function tick(t, isAnimationFrame, updatingAnimations) {
64008
- var _this4 = this, _this$pendingEffects, _this$pendingEffects2;
64016
+ var _this3 = this, _this$pendingEffects, _this$pendingEffects2;
64009
64017
  this.inTick = true;
64010
64018
  this.hasRestartedThisFrame = false;
64011
64019
  this.currentTime = t;
@@ -64023,7 +64031,7 @@ var AnimationTimeline = /*#__PURE__*/ function() {
64023
64031
  newPendingEffects.push(animation.effect);
64024
64032
  animation.markTarget();
64025
64033
  }
64026
- if (animation._needsTick) _this4.ticking = true;
64034
+ if (animation._needsTick) _this3.ticking = true;
64027
64035
  var alive = animation._inEffect || animation._needsTick;
64028
64036
  animation._inTimeline = alive;
64029
64037
  if (alive) activeAnimations.push(animation);
@@ -17941,8 +17941,8 @@ function load_json(gobj) {
17941
17941
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
17942
17942
  return;
17943
17943
  }
17944
- Promise.resolve(graph.zoomTo(1)).then(() => {
17945
- if (!yui_graph_center_on(graph, priv.anchor_id)) yui_graph_center_on(graph, root_id);
17944
+ Promise.resolve(graph.zoomTo(1)).then(async () => {
17945
+ if (!(priv.anchor_id ? await yui_graph_center_on(graph, priv.anchor_id) : false)) await yui_graph_center_on(graph, root_id);
17946
17946
  priv.last_zoom = 1;
17947
17947
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
17948
17948
  });
@@ -24399,16 +24399,23 @@ function restore_view_state(gobj) {
24399
24399
  let graph = priv.graph;
24400
24400
  let state = load_view_state(gobj);
24401
24401
  if (!graph || !state) return false;
24402
+ let zoom = Number.isFinite(state.zoom) && state.zoom > 0 ? state.zoom : null;
24403
+ let position = Array.isArray(state.position) && state.position.length >= 2 && Number.isFinite(state.position[0]) && Number.isFinite(state.position[1]) ? [state.position[0], state.position[1]] : null;
24404
+ if ((zoom !== null || position !== null) && !camera_shows_a_card(gobj, zoom, position)) {
24405
+ log_warning(`${gobj_short_name(gobj)}: the saved view shows none of the ${Object.keys(priv.node_by_id || {}).length} gobjs, framed again`);
24406
+ zoom = null;
24407
+ position = null;
24408
+ }
24402
24409
  let done = false;
24403
24410
  priv.restoring = true;
24404
24411
  try {
24405
- if (Number.isFinite(state.zoom) && state.zoom > 0) {
24406
- graph.zoomTo(state.zoom);
24407
- priv.last_zoom = state.zoom;
24412
+ if (zoom !== null) {
24413
+ graph.zoomTo(zoom);
24414
+ priv.last_zoom = zoom;
24408
24415
  done = true;
24409
24416
  }
24410
- if (Array.isArray(state.position) && state.position.length >= 2 && Number.isFinite(state.position[0]) && Number.isFinite(state.position[1])) {
24411
- graph.translateTo([state.position[0], state.position[1]]);
24417
+ if (position !== null) {
24418
+ graph.translateTo(position);
24412
24419
  done = true;
24413
24420
  }
24414
24421
  if (state.anchor) {
@@ -24426,6 +24433,30 @@ function restore_view_state(gobj) {
24426
24433
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
24427
24434
  return done;
24428
24435
  }
24436
+ function camera_shows_a_card(gobj, zoom, position) {
24437
+ let priv = gobj.priv;
24438
+ let graph = priv.graph;
24439
+ let ids = Object.keys(priv.node_by_id || {});
24440
+ if (!graph || !ids.length) return true;
24441
+ try {
24442
+ let size = graph.getSize();
24443
+ let c = graph.getCanvasCenter();
24444
+ let z = zoom !== null ? zoom : graph.getZoom();
24445
+ let t = position !== null ? position : graph.getPosition();
24446
+ let w = size[0];
24447
+ let h = size[1];
24448
+ if (!(w > 0 && h > 0) || !(z > 0)) return true;
24449
+ for (let id of ids) {
24450
+ let n = graph.getElementPosition(id);
24451
+ let vx = (n[0] - c[0]) * z + t[0] + c[0];
24452
+ let vy = (n[1] - c[1]) * z + t[1] + c[1];
24453
+ if (vx >= 0 && vx <= w && vy >= 0 && vy <= h) return true;
24454
+ }
24455
+ } catch (e) {
24456
+ return true;
24457
+ }
24458
+ return false;
24459
+ }
24429
24460
  function save_view_state(gobj) {
24430
24461
  let priv = gobj.priv;
24431
24462
  let graph = priv.graph;
@@ -24436,8 +24467,9 @@ function save_view_state(gobj) {
24436
24467
  anchor: priv.anchor_state === "on" ? priv.anchor_name : ""
24437
24468
  };
24438
24469
  let camera = null;
24470
+ let has_nodes = !!priv.node_by_id && Object.keys(priv.node_by_id).length > 0;
24439
24471
  try {
24440
- camera = camera_of(graph.getZoom(), graph.getPosition());
24472
+ camera = has_nodes ? camera_of(graph.getZoom(), graph.getPosition()) : null;
24441
24473
  } catch (e) {}
24442
24474
  if (!camera) {
24443
24475
  let old = load_view_state(gobj);
@@ -25589,8 +25621,8 @@ function load_tree(gobj) {
25589
25621
  priv.restored = true;
25590
25622
  if (restore_view_state(gobj)) return;
25591
25623
  }
25592
- Promise.resolve(graph.zoomTo(1)).then(() => {
25593
- if (!yui_graph_center_on(graph, priv.anchor_id)) yui_graph_center_on(graph, root_id);
25624
+ Promise.resolve(graph.zoomTo(1)).then(async () => {
25625
+ if (!(priv.anchor_id ? await yui_graph_center_on(graph, priv.anchor_id) : false)) await yui_graph_center_on(graph, root_id);
25594
25626
  priv.last_zoom = 1;
25595
25627
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
25596
25628
  });
@@ -43477,8 +43509,8 @@ function _objectWithoutProperties(e, t) {
43477
43509
  /*!
43478
43510
  * @antv/g-lite
43479
43511
  * @description A core module for rendering engine implements DOM API.
43480
- * @version 2.7.0
43481
- * @date 12/24/2025, 11:55:20 AM
43512
+ * @version 2.7.2
43513
+ * @date 10/16/2026, 2:34:22 AM
43482
43514
  * @author AntVis
43483
43515
  * @docs https://g.antv.antgroup.com/
43484
43516
  */
@@ -43949,12 +43981,13 @@ function getAngle(angle) {
43949
43981
  }
43950
43982
  var $vec3$3 = create$3();
43951
43983
  function createVec3(x) {
43984
+ var _x$, _x$2, _x$3, _x$4;
43952
43985
  var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
43953
43986
  var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
43954
43987
  var clone$2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : true;
43955
43988
  if (Array.isArray(x) && x.length === 3) return clone$2 ? clone(x) : copy$3($vec3$3, x);
43956
43989
  if (isNumber(x)) return clone$2 ? fromValues$2(x, y, z) : set$3($vec3$3, x, y, z);
43957
- return clone$2 ? fromValues$2(x[0], x[1] || y, x[2] || z) : set$3($vec3$3, x[0], x[1] || y, x[2] || z);
43990
+ return clone$2 ? fromValues$2(x[0], (_x$ = x[1]) !== null && _x$ !== void 0 ? _x$ : y, (_x$2 = x[2]) !== null && _x$2 !== void 0 ? _x$2 : z) : set$3($vec3$3, x[0], (_x$3 = x[1]) !== null && _x$3 !== void 0 ? _x$3 : y, (_x$4 = x[2]) !== null && _x$4 !== void 0 ? _x$4 : z);
43958
43991
  }
43959
43992
  var DEG_RAD = Math.PI / 180;
43960
43993
  function deg2rad(deg) {
@@ -50213,7 +50246,7 @@ var FederatedEvent = /*#__PURE__*/ function() {
50213
50246
  }
50214
50247
  ]);
50215
50248
  }();
50216
- var FederatedMouseEvent = /*#__PURE__*/ function(_ref) {
50249
+ var FederatedMouseEvent = /*#__PURE__*/ function(_FederatedEvent) {
50217
50250
  function FederatedMouseEvent() {
50218
50251
  var _this;
50219
50252
  _classCallCheck(this, FederatedMouseEvent);
@@ -50249,7 +50282,7 @@ var FederatedMouseEvent = /*#__PURE__*/ function(_ref) {
50249
50282
  _this.screen = new Point();
50250
50283
  return _this;
50251
50284
  }
50252
- _inherits(FederatedMouseEvent, _ref);
50285
+ _inherits(FederatedMouseEvent, _FederatedEvent);
50253
50286
  return _createClass(FederatedMouseEvent, [
50254
50287
  {
50255
50288
  key: "clientX",
@@ -54902,9 +54935,18 @@ var PrepareRendererPlugin = /*#__PURE__*/ function() {
54902
54935
  renderingService.dirty();
54903
54936
  };
54904
54937
  var handleBoundsChanged = function handleBoundsChanged(e) {
54905
- var _this$mutationRecords;
54906
54938
  var records = e.detail;
54907
- (_this$mutationRecords = _this.mutationRecords).push.apply(_this$mutationRecords, _toConsumableArray(records));
54939
+ var _iterator = _createForOfIteratorHelper(records), _step;
54940
+ try {
54941
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
54942
+ var record = _step.value;
54943
+ _this.mutationRecords.push(record);
54944
+ }
54945
+ } catch (err) {
54946
+ _iterator.e(err);
54947
+ } finally {
54948
+ _iterator.f();
54949
+ }
54908
54950
  renderingService.dirty();
54909
54951
  };
54910
54952
  var handleMounted = function handleMounted(e) {
@@ -55905,8 +55947,8 @@ PERFORMANCE OF THIS SOFTWARE.
55905
55947
  /*!
55906
55948
  * @antv/g
55907
55949
  * @description A core module for rendering engine implements DOM API.
55908
- * @version 6.3.1
55909
- * @date 12/24/2025, 11:55:39 AM
55950
+ * @version 6.3.3
55951
+ * @date 10/16/2026, 2:34:40 AM
55910
55952
  * @author AntVis
55911
55953
  * @docs https://g.antv.antgroup.com/
55912
55954
  */
@@ -63068,74 +63110,43 @@ var Animation = /*#__PURE__*/ function() {
63068
63110
  /**
63069
63111
  * https://github.com/gre/bezier-easing
63070
63112
  * BezierEasing - use bezier curve for transition easing function
63071
- * by Gaëtan Renaudeau 2014 - 2015 – MIT License
63113
+ * by Gaëtan Renaudeau 2014 - 2026 – MIT License
63072
63114
  */
63073
- var NEWTON_ITERATIONS = 4;
63074
- var NEWTON_MIN_SLOPE = .001;
63075
- var SUBDIVISION_PRECISION = 1e-7;
63076
- var SUBDIVISION_MAX_ITERATIONS = 10;
63077
- var kSplineTableSize = 11;
63078
- var kSampleStepSize = 1 / (kSplineTableSize - 1);
63079
- var float32ArraySupported = typeof Float32Array === "function";
63080
- var A = function A(aA1, aA2) {
63081
- return 1 - 3 * aA2 + 3 * aA1;
63082
- };
63083
- var B = function B(aA1, aA2) {
63084
- return 3 * aA2 - 6 * aA1;
63085
- };
63086
- var C = function C(aA1) {
63087
- return 3 * aA1;
63088
- };
63089
- var calcBezier = function calcBezier(aT, aA1, aA2) {
63090
- return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
63091
- };
63092
- var getSlope = function getSlope(aT, aA1, aA2) {
63093
- return 3 * A(aA1, aA2) * aT * aT + 2 * B(aA1, aA2) * aT + C(aA1);
63094
- };
63095
- var binarySubdivide = function binarySubdivide(aX, aA, aB, mX1, mX2) {
63096
- var currentX;
63097
- var currentT;
63098
- var i = 0;
63099
- do {
63100
- currentT = aA + (aB - aA) / 2;
63101
- currentX = calcBezier(currentT, mX1, mX2) - aX;
63102
- if (currentX > 0) aB = currentT;
63103
- else aA = currentT;
63104
- } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
63105
- return currentT;
63106
- };
63107
- var newtonRaphsonIterate = function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
63108
- for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
63109
- var currentSlope = getSlope(aGuessT, mX1, mX2);
63110
- if (currentSlope === 0) return aGuessT;
63111
- var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
63112
- aGuessT -= currentX / currentSlope;
63113
- }
63114
- return aGuessT;
63115
+ var solveTForX = function solveTForX(x, a, b, c) {
63116
+ var j = 1 / Math.max(c, Math.sqrt(x));
63117
+ var k = x * j;
63118
+ var l = k * j;
63119
+ var s = c * j;
63120
+ var q = b * l;
63121
+ var m = s * s + q;
63122
+ var h = -s * (s * s + 1.5 * q) - a * k * l;
63123
+ var D = h * h - m * m * m;
63124
+ var v;
63125
+ if (m === 0 || D > 1e-12 * h * h) {
63126
+ var U = -Math.cbrt(h < 0 ? h - Math.sqrt(D) : h + Math.sqrt(D));
63127
+ v = U + m / U || 0;
63128
+ } else {
63129
+ var r = Math.sqrt(m);
63130
+ v = 2 * r * Math.cos(Math.acos(Math.max(-1, Math.min(1, -h / (m * r)))) / 3);
63131
+ }
63132
+ return Math.min(1, k / (v + s));
63115
63133
  };
63116
63134
  var bezier = function bezier(mX1, mY1, mX2, mY2) {
63117
63135
  if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) throw new Error("bezier x values must be in [0, 1] range");
63118
63136
  if (mX1 === mY1 && mX2 === mY2) return function(t) {
63119
63137
  return t;
63120
63138
  };
63121
- var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
63122
- for (var i = 0; i < kSplineTableSize; ++i) sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
63123
- var getTForX = function getTForX(aX) {
63124
- var intervalStart = 0;
63125
- var currentSample = 1;
63126
- var lastSample = kSplineTableSize - 1;
63127
- for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) intervalStart += kSampleStepSize;
63128
- --currentSample;
63129
- var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
63130
- var guessForT = intervalStart + dist * kSampleStepSize;
63131
- var initialSlope = getSlope(guessForT, mX1, mX2);
63132
- if (initialSlope >= NEWTON_MIN_SLOPE) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
63133
- if (initialSlope === 0) return guessForT;
63134
- return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
63135
- };
63139
+ var a = (3 * mX1 - 3 * mX2 + 1) / 2;
63140
+ var b = mX2 - 2 * mX1;
63141
+ var c = mX1;
63142
+ var ay = 3 * mY1 - 3 * mY2 + 1;
63143
+ var by = 3 * (mY2 - 2 * mY1);
63144
+ var cy = 3 * mY1;
63136
63145
  return function(t) {
63137
- if (t === 0 || t === 1) return t;
63138
- return calcBezier(getTForX(t), mY1, mY2);
63146
+ if (t <= 0) return 0;
63147
+ if (t >= 1) return 1;
63148
+ var u = solveTForX(t, a, b, c);
63149
+ return ((ay * u + by) * u + cy) * u;
63139
63150
  };
63140
63151
  };
63141
63152
  var convertToDash = function convertToDash(str) {
@@ -63877,9 +63888,11 @@ var AnimationTimeline = /*#__PURE__*/ function() {
63877
63888
  if (t < Number(_this.currentTime)) t = Number(_this.currentTime);
63878
63889
  _this.animations.sort(compareAnimations);
63879
63890
  _this.animations = _this.tick(t, true, _this.animations)[0];
63891
+ _this.updateAnimationsPromises();
63880
63892
  processing.forEach(function(entry) {
63881
63893
  entry[1](t);
63882
63894
  });
63895
+ _this.updateAnimationsPromises();
63883
63896
  _this.applyPendingEffects();
63884
63897
  };
63885
63898
  this.document = document;
@@ -63989,18 +64002,13 @@ var AnimationTimeline = /*#__PURE__*/ function() {
63989
64002
  {
63990
64003
  key: "requestAnimationFrame",
63991
64004
  value: function requestAnimationFrame(f) {
63992
- var _this3 = this;
63993
- return this.rAF(function(x) {
63994
- _this3.updateAnimationsPromises();
63995
- f(x);
63996
- _this3.updateAnimationsPromises();
63997
- });
64005
+ return this.rAF(f);
63998
64006
  }
63999
64007
  },
64000
64008
  {
64001
64009
  key: "tick",
64002
64010
  value: function tick(t, isAnimationFrame, updatingAnimations) {
64003
- var _this4 = this, _this$pendingEffects, _this$pendingEffects2;
64011
+ var _this3 = this, _this$pendingEffects, _this$pendingEffects2;
64004
64012
  this.inTick = true;
64005
64013
  this.hasRestartedThisFrame = false;
64006
64014
  this.currentTime = t;
@@ -64018,7 +64026,7 @@ var AnimationTimeline = /*#__PURE__*/ function() {
64018
64026
  newPendingEffects.push(animation.effect);
64019
64027
  animation.markTarget();
64020
64028
  }
64021
- if (animation._needsTick) _this4.ticking = true;
64029
+ if (animation._needsTick) _this3.ticking = true;
64022
64030
  var alive = animation._inEffect || animation._needsTick;
64023
64031
  animation._inTimeline = alive;
64024
64032
  if (alive) activeAnimations.push(animation);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.27.23",
3
+ "version": "7.27.24",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -35,6 +35,9 @@
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "dependencies": {
38
+ "@antv/g": "^6.3.3",
39
+ "@antv/g-canvas": "^2.2.2",
40
+ "@antv/g-plugin-dragndrop": "^2.1.3",
38
41
  "acorn": "^8.19.0"
39
42
  },
40
43
  "devDependencies": {
@@ -242,19 +242,37 @@ function restore_view_state(gobj)
242
242
  return false;
243
243
  }
244
244
 
245
+ /* A camera saved by an older version can hold nulls (a NaN written
246
+ * as json): what is not a number is not restored. */
247
+ let zoom = (Number.isFinite(state.zoom) && state.zoom > 0)? state.zoom: null;
248
+ let position = (Array.isArray(state.position) && state.position.length >= 2 &&
249
+ Number.isFinite(state.position[0]) && Number.isFinite(state.position[1]))?
250
+ [state.position[0], state.position[1]]: null;
251
+
252
+ /* Nor a camera that would show none of the tree. One was saved from
253
+ * an EMPTY graph -- a remote tree is empty until its host loads it,
254
+ * and a fit pressed then frames nothing -- and every opening after
255
+ * it went back to the same blank canvas. It is judged from the
256
+ * numbers BEFORE it is applied, so a refused camera never moves the
257
+ * graph: the opening frames the tree as a first one does, and the
258
+ * next move saves a good camera. */
259
+ if((zoom !== null || position !== null) && !camera_shows_a_card(gobj, zoom, position)) {
260
+ log_warning(`${gobj_short_name(gobj)}: the saved view shows none of the ` +
261
+ `${Object.keys(priv.node_by_id || {}).length} gobjs, framed again`);
262
+ zoom = null;
263
+ position = null;
264
+ }
265
+
245
266
  let done = false;
246
267
  priv.restoring = true;
247
268
  try {
248
- /* A camera saved by an older version can hold nulls (a NaN
249
- * written as json): what is not a number is not restored. */
250
- if(Number.isFinite(state.zoom) && state.zoom > 0) {
251
- graph.zoomTo(state.zoom);
252
- priv.last_zoom = state.zoom;
269
+ if(zoom !== null) {
270
+ graph.zoomTo(zoom);
271
+ priv.last_zoom = zoom;
253
272
  done = true;
254
273
  }
255
- if(Array.isArray(state.position) && state.position.length >= 2 &&
256
- Number.isFinite(state.position[0]) && Number.isFinite(state.position[1])) {
257
- graph.translateTo([state.position[0], state.position[1]]);
274
+ if(position !== null) {
275
+ graph.translateTo(position);
258
276
  done = true;
259
277
  }
260
278
  if(state.anchor) {
@@ -276,6 +294,46 @@ function restore_view_state(gobj)
276
294
  return done;
277
295
  }
278
296
 
297
+ /* Would the centre of at least one card land inside the canvas under
298
+ * this camera? `zoom` and `position` are what getZoom()/getPosition()
299
+ * answer (a null one: the current). A camera absolute-translated to T
300
+ * at zoom Z puts a point n of the graph at (n - C) * Z + T + C on the
301
+ * canvas, C its centre -- the closed form of G6's own
302
+ * getTranslateOptions(), the one yui_graph_center_on() relies on.
303
+ * True when there is nothing to show or it cannot be computed: only a
304
+ * camera KNOWN to show nothing is refused. */
305
+ function camera_shows_a_card(gobj, zoom, position)
306
+ {
307
+ let priv = gobj.priv;
308
+ let graph = priv.graph;
309
+ let ids = Object.keys(priv.node_by_id || {});
310
+ if(!graph || !ids.length) {
311
+ return true;
312
+ }
313
+ try {
314
+ let size = graph.getSize();
315
+ let c = graph.getCanvasCenter();
316
+ let z = (zoom !== null)? zoom: graph.getZoom();
317
+ let t = (position !== null)? position: graph.getPosition();
318
+ let w = size[0];
319
+ let h = size[1];
320
+ if(!(w > 0 && h > 0) || !(z > 0)) {
321
+ return true;
322
+ }
323
+ for(let id of ids) {
324
+ let n = graph.getElementPosition(id);
325
+ let vx = (n[0] - c[0]) * z + t[0] + c[0];
326
+ let vy = (n[1] - c[1]) * z + t[1] + c[1];
327
+ if(vx >= 0 && vx <= w && vy >= 0 && vy <= h) {
328
+ return true;
329
+ }
330
+ }
331
+ } catch(e) {
332
+ return true;
333
+ }
334
+ return false;
335
+ }
336
+
279
337
  function save_view_state(gobj)
280
338
  {
281
339
  let priv = gobj.priv;
@@ -291,8 +349,13 @@ function save_view_state(gobj)
291
349
  anchor: (priv.anchor_state === "on")? priv.anchor_name: "",
292
350
  };
293
351
  let camera = null;
352
+ /* The camera of an EMPTY graph frames nothing: a remote tree before
353
+ * its host loads it, where a fit or a zoom would save a view of no
354
+ * card that every later opening goes back to. Not saved; the one
355
+ * saved before stays (below). */
356
+ let has_nodes = !!priv.node_by_id && Object.keys(priv.node_by_id).length > 0;
294
357
  try {
295
- camera = camera_of(graph.getZoom(), graph.getPosition());
358
+ camera = has_nodes ? camera_of(graph.getZoom(), graph.getPosition()) : null;
296
359
  } catch(e) {
297
360
  /* between renders: keep the rest, the camera is not readable */
298
361
  }
@@ -1815,9 +1878,19 @@ function load_tree(gobj)
1815
1878
  * -- never parked at the layout's origin, which is a
1816
1879
  * corner with nothing in it.
1817
1880
  */
1818
- Promise.resolve(graph.zoomTo(1)).then(() => {
1819
- if(!yui_graph_center_on(graph, priv.anchor_id)) {
1820
- yui_graph_center_on(graph, root_id);
1881
+ Promise.resolve(graph.zoomTo(1)).then(async () => {
1882
+ /* yui_graph_center_on() is ASYNC: unawaited, its answer
1883
+ * is a promise, always truthy, so `!` of it was always
1884
+ * false and the root was never centred -- the opening
1885
+ * stayed wherever the camera happened to be. (And the
1886
+ * root is at y = 0, a camera coordinate @antv/g-lite
1887
+ * below 2.7.2 could not reach: its createVec3() read
1888
+ * `x[1] || y`, so a 0 kept the old value. package.json
1889
+ * holds the antv floors that bring 2.7.2.) */
1890
+ let on_anchor = priv.anchor_id?
1891
+ await yui_graph_center_on(graph, priv.anchor_id): false;
1892
+ if(!on_anchor) {
1893
+ await yui_graph_center_on(graph, root_id);
1821
1894
  }
1822
1895
  priv.last_zoom = 1;
1823
1896
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
@@ -1520,9 +1520,15 @@ function load_json(gobj)
1520
1520
  * -- never parked at the layout's origin, which is a corner
1521
1521
  * with nothing in it and is where `1:1` used to land.
1522
1522
  */
1523
- Promise.resolve(graph.zoomTo(1)).then(() => {
1524
- if(!yui_graph_center_on(graph, priv.anchor_id)) {
1525
- yui_graph_center_on(graph, root_id);
1523
+ Promise.resolve(graph.zoomTo(1)).then(async () => {
1524
+ /* yui_graph_center_on() is ASYNC: unawaited, its answer
1525
+ * is a promise, always truthy, so `!` of it was always
1526
+ * false and the root was never centred -- the opening
1527
+ * stayed wherever the camera happened to be. */
1528
+ let on_anchor = priv.anchor_id?
1529
+ await yui_graph_center_on(graph, priv.anchor_id): false;
1530
+ if(!on_anchor) {
1531
+ await yui_graph_center_on(graph, root_id);
1526
1532
  }
1527
1533
  priv.last_zoom = 1;
1528
1534
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
@@ -30,7 +30,8 @@ if(typeof globalThis.ResizeObserver === "undefined") {
30
30
  };
31
31
  }
32
32
 
33
- const camera = vi.hoisted(() => ({zoom: NaN, position: [NaN, NaN], zoomed: [], moved: []}));
33
+ const camera = vi.hoisted(() => ({zoom: NaN, position: [NaN, NaN], zoomed: [], moved: [],
34
+ size: null, viewport: null}));
34
35
  vi.mock("@antv/g6", async (importOriginal) => {
35
36
  const real = await importOriginal();
36
37
  class FakeGraph {
@@ -62,6 +63,27 @@ vi.mock("@antv/g6", async (importOriginal) => {
62
63
  camera.moved.push(p);
63
64
  return Promise.resolve();
64
65
  }
66
+ /* Where a card lands on screen: `camera.viewport` for every one
67
+ * of them, and the canvas `camera.size`. Unset, the camera cannot
68
+ * be read, which is what the older tests expect. */
69
+ getSize() {
70
+ if(!camera.size) {
71
+ throw new Error("no size");
72
+ }
73
+ return camera.size;
74
+ }
75
+ getElementPosition() {
76
+ return [0, 0];
77
+ }
78
+ getElementData() {
79
+ return {};
80
+ }
81
+ getCanvasCenter() {
82
+ return [400, 300];
83
+ }
84
+ getViewportByCanvas() {
85
+ return camera.viewport;
86
+ }
65
87
  getData() {
66
88
  return {nodes: [], edges: [], combos: []};
67
89
  }
@@ -122,6 +144,8 @@ beforeEach(() => {
122
144
  camera.position = [NaN, NaN];
123
145
  camera.zoomed = [];
124
146
  camera.moved = [];
147
+ camera.size = null;
148
+ camera.viewport = null;
125
149
  });
126
150
 
127
151
  function errors()
@@ -183,3 +207,49 @@ describe("C_YUI_GOBJ_TREE_JS saves only a camera of numbers", () => {
183
207
  expect(errors()).toEqual([]);
184
208
  });
185
209
  });
210
+
211
+ describe("C_YUI_GOBJ_TREE_JS does not restore a camera that shows nothing", () => {
212
+ test("a saved camera with every card off the canvas is framed again", async () => {
213
+ const name = `camera_${++seq}`;
214
+ window.localStorage.setItem(`yui_gobj_tree_view:${name}`,
215
+ JSON.stringify({layout: "", collapsed: {}, anchor: "", zoom: 0.18, position: [-20000, -20000]}));
216
+ camera.size = [800, 600];
217
+ camera.viewport = [-5000, -5000];
218
+ await mount(name);
219
+ await new Promise((resolve) => setTimeout(resolve, 0));
220
+ /* judged before it is applied: only the opening's own framing */
221
+ expect(camera.zoomed).toEqual([1]);
222
+ expect(logged.filter((l) => l.level === "warning").map((l) => l.msg).join(" "))
223
+ .toMatch(/the saved view shows none of the/);
224
+ expect(errors()).toEqual([]);
225
+ });
226
+
227
+ test("a saved camera that shows a card is kept", async () => {
228
+ const name = `camera_${++seq}`;
229
+ window.localStorage.setItem(`yui_gobj_tree_view:${name}`,
230
+ JSON.stringify({layout: "", collapsed: {}, anchor: "", zoom: 0.5, position: [10, 20]}));
231
+ camera.size = [800, 600];
232
+ camera.viewport = [400, 300];
233
+ await mount(name);
234
+ await new Promise((resolve) => setTimeout(resolve, 0));
235
+ expect(camera.zoomed).toEqual([0.5]);
236
+ expect(camera.moved).toEqual([[10, 20]]);
237
+ expect(errors()).toEqual([]);
238
+ });
239
+ });
240
+
241
+ describe("C_YUI_GOBJ_TREE_JS opens centred on its root", () => {
242
+ test("with nothing saved, the camera is moved onto the root", async () => {
243
+ /* yui_graph_center_on() is async, and its answer was read
244
+ * unawaited -- a promise, always truthy -- so the root was never
245
+ * centred and the opening stayed where the camera happened to be. */
246
+ const name = `camera_${++seq}`;
247
+ camera.viewport = [0, 0]; /* the root, 400x300 off the centre */
248
+ await mount(name);
249
+ await new Promise((resolve) => setTimeout(resolve, 0));
250
+ expect(camera.zoomed).toEqual([1]);
251
+ expect(camera.moved.length).toBeGreaterThan(0);
252
+ expect(camera.moved[0]).toEqual([400, 300]);
253
+ expect(errors()).toEqual([]);
254
+ });
255
+ });
@@ -295,4 +295,20 @@ describe("C_YUI_GOBJ_TREE_JS, source local", () => {
295
295
  expect(wanted).toEqual([]);
296
296
  expect(problems()).toEqual([]);
297
297
  });
298
+
299
+ test("an empty graph saves no camera: a fit before the tree loads frames nothing", async () => {
300
+ const view = await mount("remote", host);
301
+ const key = `yui_gobj_tree_view:tree_${seq}`;
302
+ gobj_send_event(view, "EV_REFRESH", {}, view);
303
+ const saved = JSON.parse(window.localStorage.getItem(key) || "null");
304
+ expect(saved).not.toBe(null);
305
+ expect("zoom" in saved).toBe(false);
306
+ expect("position" in saved).toBe(false);
307
+
308
+ gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
309
+ gobj_send_event(view, "EV_REFRESH", {}, view);
310
+ const after = JSON.parse(window.localStorage.getItem(key));
311
+ expect(after.zoom).toBe(1);
312
+ expect(problems()).toEqual([]);
313
+ });
298
314
  });