leafer-ui 1.0.6 → 1.0.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.
@@ -4426,13 +4426,10 @@ class LeafLayout {
4426
4426
  update() {
4427
4427
  const { leafer } = this.leaf;
4428
4428
  if (leafer) {
4429
- if (leafer.ready) {
4430
- if (leafer.watcher.changed)
4431
- leafer.layouter.layout();
4432
- }
4433
- else {
4429
+ if (leafer.ready)
4430
+ leafer.watcher.changed && leafer.layouter.layout();
4431
+ else
4434
4432
  leafer.start();
4435
- }
4436
4433
  }
4437
4434
  else {
4438
4435
  let root = this.leaf;
@@ -5959,7 +5956,7 @@ class LeafLevelList {
5959
5956
  }
5960
5957
  }
5961
5958
 
5962
- const version = "1.0.6";
5959
+ const version = "1.0.7";
5963
5960
 
5964
5961
  const debug$7 = Debug.get('LeaferCanvas');
5965
5962
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6851,7 +6848,8 @@ class Picker {
6851
6848
  path.add(leaf);
6852
6849
  leaf = leaf.parent;
6853
6850
  }
6854
- path.add(this.target);
6851
+ if (this.target)
6852
+ path.add(this.target);
6855
6853
  return path;
6856
6854
  }
6857
6855
  getHitablePath(leaf) {
@@ -6937,8 +6935,8 @@ class Selector {
6937
6935
  this.innerIdMap = {};
6938
6936
  this.idMap = {};
6939
6937
  this.methods = {
6940
- id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6941
- innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6938
+ id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
6939
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
6942
6940
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6943
6941
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6944
6942
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
@@ -6947,7 +6945,8 @@ class Selector {
6947
6945
  if (userConfig)
6948
6946
  this.config = DataHelper.default(userConfig, this.config);
6949
6947
  this.picker = new Picker(target, this);
6950
- this.__listenEvents();
6948
+ if (target)
6949
+ this.__listenEvents();
6951
6950
  }
6952
6951
  getBy(condition, branch, one, options) {
6953
6952
  switch (typeof condition) {
@@ -6982,7 +6981,7 @@ class Selector {
6982
6981
  }
6983
6982
  }
6984
6983
  getByPoint(hitPoint, hitRadius, options) {
6985
- if (Platform.name === 'node')
6984
+ if (Platform.name === 'node' && this.target)
6986
6985
  this.target.emit(LayoutEvent.CHECK_UPDATE);
6987
6986
  return this.picker.getByPoint(hitPoint, hitRadius, options);
6988
6987
  }
@@ -8824,9 +8823,8 @@ let Text = class Text extends UI {
8824
8823
  layout.renderChanged = true;
8825
8824
  setList(data.__textBoxBounds = {}, [b, bounds]);
8826
8825
  }
8827
- else {
8826
+ else
8828
8827
  data.__textBoxBounds = contentBounds;
8829
- }
8830
8828
  }
8831
8829
  __updateRenderSpread() {
8832
8830
  let width = super.__updateRenderSpread();
@@ -10500,17 +10498,20 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
10500
10498
  };
10501
10499
 
10502
10500
  const ui = UI.prototype, group = Group.prototype;
10501
+ function getSelector(ui) {
10502
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10503
+ }
10503
10504
  ui.find = function (condition, options) {
10504
- return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
10505
+ return getSelector(this).getBy(condition, this, false, options);
10505
10506
  };
10506
10507
  ui.findOne = function (condition, options) {
10507
- return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
10508
+ return getSelector(this).getBy(condition, this, true, options);
10508
10509
  };
10509
10510
  group.pick = function (hitPoint, options) {
10510
10511
  this.__layout.update();
10511
10512
  if (!options)
10512
10513
  options = {};
10513
- return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
10514
+ return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10514
10515
  };
10515
10516
 
10516
10517
  const canvas$1 = LeaferCanvasBase.prototype;