@leafer-editor/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.
package/dist/worker.js CHANGED
@@ -4429,13 +4429,10 @@ var LeaferUI = (function (exports) {
4429
4429
  update() {
4430
4430
  const { leafer } = this.leaf;
4431
4431
  if (leafer) {
4432
- if (leafer.ready) {
4433
- if (leafer.watcher.changed)
4434
- leafer.layouter.layout();
4435
- }
4436
- else {
4432
+ if (leafer.ready)
4433
+ leafer.watcher.changed && leafer.layouter.layout();
4434
+ else
4437
4435
  leafer.start();
4438
- }
4439
4436
  }
4440
4437
  else {
4441
4438
  let root = this.leaf;
@@ -5962,7 +5959,7 @@ var LeaferUI = (function (exports) {
5962
5959
  }
5963
5960
  }
5964
5961
 
5965
- const version = "1.0.6";
5962
+ const version = "1.0.7";
5966
5963
 
5967
5964
  class LeaferCanvas extends LeaferCanvasBase {
5968
5965
  get allowBackgroundColor() { return true; }
@@ -6681,7 +6678,8 @@ var LeaferUI = (function (exports) {
6681
6678
  path.add(leaf);
6682
6679
  leaf = leaf.parent;
6683
6680
  }
6684
- path.add(this.target);
6681
+ if (this.target)
6682
+ path.add(this.target);
6685
6683
  return path;
6686
6684
  }
6687
6685
  getHitablePath(leaf) {
@@ -6767,8 +6765,8 @@ var LeaferUI = (function (exports) {
6767
6765
  this.innerIdMap = {};
6768
6766
  this.idMap = {};
6769
6767
  this.methods = {
6770
- id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6771
- innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6768
+ id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
6769
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
6772
6770
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6773
6771
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6774
6772
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
@@ -6777,7 +6775,8 @@ var LeaferUI = (function (exports) {
6777
6775
  if (userConfig)
6778
6776
  this.config = DataHelper.default(userConfig, this.config);
6779
6777
  this.picker = new Picker(target, this);
6780
- this.__listenEvents();
6778
+ if (target)
6779
+ this.__listenEvents();
6781
6780
  }
6782
6781
  getBy(condition, branch, one, options) {
6783
6782
  switch (typeof condition) {
@@ -6812,7 +6811,7 @@ var LeaferUI = (function (exports) {
6812
6811
  }
6813
6812
  }
6814
6813
  getByPoint(hitPoint, hitRadius, options) {
6815
- if (Platform.name === 'node')
6814
+ if (Platform.name === 'node' && this.target)
6816
6815
  this.target.emit(LayoutEvent.CHECK_UPDATE);
6817
6816
  return this.picker.getByPoint(hitPoint, hitRadius, options);
6818
6817
  }
@@ -8654,9 +8653,8 @@ var LeaferUI = (function (exports) {
8654
8653
  layout.renderChanged = true;
8655
8654
  setList(data.__textBoxBounds = {}, [b, bounds]);
8656
8655
  }
8657
- else {
8656
+ else
8658
8657
  data.__textBoxBounds = contentBounds;
8659
- }
8660
8658
  }
8661
8659
  __updateRenderSpread() {
8662
8660
  let width = super.__updateRenderSpread();
@@ -10330,17 +10328,20 @@ var LeaferUI = (function (exports) {
10330
10328
  };
10331
10329
 
10332
10330
  const ui$1 = exports.UI.prototype, group = exports.Group.prototype;
10331
+ function getSelector(ui) {
10332
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10333
+ }
10333
10334
  ui$1.find = function (condition, options) {
10334
- return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
10335
+ return getSelector(this).getBy(condition, this, false, options);
10335
10336
  };
10336
10337
  ui$1.findOne = function (condition, options) {
10337
- return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
10338
+ return getSelector(this).getBy(condition, this, true, options);
10338
10339
  };
10339
10340
  group.pick = function (hitPoint, options) {
10340
10341
  this.__layout.update();
10341
10342
  if (!options)
10342
10343
  options = {};
10343
- return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
10344
+ return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10344
10345
  };
10345
10346
 
10346
10347
  const canvas$1 = LeaferCanvasBase.prototype;