@leafer-ui/worker 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
  class LeaferCanvas extends LeaferCanvasBase {
5965
5962
  get allowBackgroundColor() { return true; }
@@ -6678,7 +6675,8 @@ class Picker {
6678
6675
  path.add(leaf);
6679
6676
  leaf = leaf.parent;
6680
6677
  }
6681
- path.add(this.target);
6678
+ if (this.target)
6679
+ path.add(this.target);
6682
6680
  return path;
6683
6681
  }
6684
6682
  getHitablePath(leaf) {
@@ -6764,8 +6762,8 @@ class Selector {
6764
6762
  this.innerIdMap = {};
6765
6763
  this.idMap = {};
6766
6764
  this.methods = {
6767
- id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6768
- innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6765
+ id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
6766
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
6769
6767
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6770
6768
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6771
6769
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
@@ -6774,7 +6772,8 @@ class Selector {
6774
6772
  if (userConfig)
6775
6773
  this.config = DataHelper.default(userConfig, this.config);
6776
6774
  this.picker = new Picker(target, this);
6777
- this.__listenEvents();
6775
+ if (target)
6776
+ this.__listenEvents();
6778
6777
  }
6779
6778
  getBy(condition, branch, one, options) {
6780
6779
  switch (typeof condition) {
@@ -6809,7 +6808,7 @@ class Selector {
6809
6808
  }
6810
6809
  }
6811
6810
  getByPoint(hitPoint, hitRadius, options) {
6812
- if (Platform.name === 'node')
6811
+ if (Platform.name === 'node' && this.target)
6813
6812
  this.target.emit(LayoutEvent.CHECK_UPDATE);
6814
6813
  return this.picker.getByPoint(hitPoint, hitRadius, options);
6815
6814
  }
@@ -8651,9 +8650,8 @@ let Text = class Text extends UI {
8651
8650
  layout.renderChanged = true;
8652
8651
  setList(data.__textBoxBounds = {}, [b, bounds]);
8653
8652
  }
8654
- else {
8653
+ else
8655
8654
  data.__textBoxBounds = contentBounds;
8656
- }
8657
8655
  }
8658
8656
  __updateRenderSpread() {
8659
8657
  let width = super.__updateRenderSpread();
@@ -10327,17 +10325,20 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
10327
10325
  };
10328
10326
 
10329
10327
  const ui = UI.prototype, group = Group.prototype;
10328
+ function getSelector(ui) {
10329
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10330
+ }
10330
10331
  ui.find = function (condition, options) {
10331
- return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
10332
+ return getSelector(this).getBy(condition, this, false, options);
10332
10333
  };
10333
10334
  ui.findOne = function (condition, options) {
10334
- return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
10335
+ return getSelector(this).getBy(condition, this, true, options);
10335
10336
  };
10336
10337
  group.pick = function (hitPoint, options) {
10337
10338
  this.__layout.update();
10338
10339
  if (!options)
10339
10340
  options = {};
10340
- return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
10341
+ return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10341
10342
  };
10342
10343
 
10343
10344
  const canvas$1 = LeaferCanvasBase.prototype;