@leafer-game/worker 1.1.2 → 1.2.1

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
@@ -1405,9 +1405,21 @@ var LeaferUI = (function (exports) {
1405
1405
  };
1406
1406
  const R = Run;
1407
1407
 
1408
- function needPlugin(name) {
1409
- console.error('need plugin: @leafer-in/' + name);
1410
- }
1408
+ const Plugin = {
1409
+ list: {},
1410
+ add(name) {
1411
+ this.list[name] = true;
1412
+ },
1413
+ check(name, tip) {
1414
+ const rs = this.list[name];
1415
+ if (!rs && tip)
1416
+ this.need(name);
1417
+ return rs;
1418
+ },
1419
+ need(name) {
1420
+ console.error('need plugin: @leafer-in/' + name);
1421
+ }
1422
+ };
1411
1423
 
1412
1424
  const debug$e = Debug.get('UICreator');
1413
1425
  const UICreator = {
@@ -5422,7 +5434,7 @@ var LeaferUI = (function (exports) {
5422
5434
  this.__[attrName] = value === undefined ? null : undefined;
5423
5435
  this[attrName] = value;
5424
5436
  }
5425
- forceRender(_bounds) {
5437
+ forceRender(_bounds, _sync) {
5426
5438
  this.forceUpdate('surface');
5427
5439
  }
5428
5440
  __updateWorldMatrix() { }
@@ -5632,10 +5644,10 @@ var LeaferUI = (function (exports) {
5632
5644
  __updatePath() { }
5633
5645
  __updateRenderPath() { }
5634
5646
  getMotionPathData() {
5635
- return needPlugin('path');
5647
+ return Plugin.need('path');
5636
5648
  }
5637
5649
  getMotionPoint(_motionDistance) {
5638
- return needPlugin('path');
5650
+ return Plugin.need('path');
5639
5651
  }
5640
5652
  getMotionTotal() {
5641
5653
  return 0;
@@ -5992,7 +6004,7 @@ var LeaferUI = (function (exports) {
5992
6004
  }
5993
6005
  }
5994
6006
 
5995
- const version = "1.1.1";
6007
+ const version = "1.2.1";
5996
6008
 
5997
6009
  class LeaferCanvas extends LeaferCanvasBase {
5998
6010
  get allowBackgroundColor() { return true; }
@@ -6990,8 +7002,8 @@ var LeaferUI = (function (exports) {
6990
7002
  const Effect = {};
6991
7003
  const Export = {};
6992
7004
  const State = {
6993
- setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
6994
- set(_leaf, _stateName) { return needPlugin('state'); }
7005
+ setStyleName(_leaf, _styleName, _value) { return Plugin.need('state'); },
7006
+ set(_leaf, _stateName) { return Plugin.need('state'); }
6995
7007
  };
6996
7008
  const Transition = {
6997
7009
  list: {},
@@ -7492,7 +7504,7 @@ var LeaferUI = (function (exports) {
7492
7504
  drawer.rect(x, y, width, height);
7493
7505
  }
7494
7506
  animate(_keyframe, _options, _type, _isTemp) {
7495
- return needPlugin('animate');
7507
+ return Plugin.need('animate');
7496
7508
  }
7497
7509
  killAnimate(_type) { }
7498
7510
  export(filename, options) {
@@ -7891,10 +7903,13 @@ var LeaferUI = (function (exports) {
7891
7903
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7892
7904
  Object.keys(data).forEach(key => this[key] = data[key]);
7893
7905
  }
7894
- forceRender(bounds) {
7895
- this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7896
- if (this.viewReady)
7897
- this.renderer.render();
7906
+ forceRender(bounds, sync) {
7907
+ const { renderer } = this;
7908
+ if (renderer) {
7909
+ renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7910
+ if (this.viewReady)
7911
+ sync ? renderer.render() : renderer.update();
7912
+ }
7898
7913
  }
7899
7914
  requestRender(change = false) {
7900
7915
  if (this.renderer)
@@ -8070,7 +8085,7 @@ var LeaferUI = (function (exports) {
8070
8085
  this.requestRender();
8071
8086
  }
8072
8087
  zoom(_zoomType, _padding, _fixedScale) {
8073
- return needPlugin('view');
8088
+ return Plugin.need('view');
8074
8089
  }
8075
8090
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
8076
8091
  getValidScale(changeScale) { return changeScale; }
@@ -8883,8 +8898,8 @@ var LeaferUI = (function (exports) {
8883
8898
  super.lockLayout();
8884
8899
  this.children.forEach(leafer => leafer.lockLayout());
8885
8900
  }
8886
- forceRender(bounds) {
8887
- this.children.forEach(leafer => leafer.forceRender(bounds));
8901
+ forceRender(bounds, sync) {
8902
+ this.children.forEach(leafer => leafer.forceRender(bounds, sync));
8888
8903
  }
8889
8904
  addLeafer(merge) {
8890
8905
  const leafer = new exports.Leafer(merge);
@@ -11965,6 +11980,8 @@ var LeaferUI = (function (exports) {
11965
11980
  registerUI()
11966
11981
  ], exports.Robot);
11967
11982
 
11983
+ Plugin.add('robot');
11984
+
11968
11985
  function stateType(defaultValue, styleName) {
11969
11986
  return decorateLeafAttr(defaultValue, (key) => attr({
11970
11987
  set(value) {
@@ -12234,6 +12251,7 @@ var LeaferUI = (function (exports) {
12234
12251
  return !!find;
12235
12252
  }
12236
12253
 
12254
+ Plugin.add('state');
12237
12255
  State.animateExcludes = {
12238
12256
  animation: 1,
12239
12257
  animationOut: 1,
@@ -13110,6 +13128,7 @@ var LeaferUI = (function (exports) {
13110
13128
  return { r: round$1(r * 255), g: round$1(g * 255), b: round$1(b * 255), a };
13111
13129
  }
13112
13130
 
13131
+ Plugin.add('color');
13113
13132
  ColorConvert.object = colorToRGBA;
13114
13133
 
13115
13134
  const { round } = Math;
@@ -13171,6 +13190,8 @@ var LeaferUI = (function (exports) {
13171
13190
  };
13172
13191
  }
13173
13192
 
13193
+ Plugin.add('animate');
13194
+ setTimeout(() => Plugin.check('color', true));
13174
13195
  State.canAnimate = true;
13175
13196
  Object.assign(Transition, TransitionModule);
13176
13197
  Object.assign(Transition.list, TransitionList);
@@ -13443,6 +13464,7 @@ var LeaferUI = (function (exports) {
13443
13464
  }));
13444
13465
  }
13445
13466
 
13467
+ Plugin.add('motion-path');
13446
13468
  Transition.register('motion', function (from, to, t, target) {
13447
13469
  if (!from)
13448
13470
  from = 0;
@@ -13630,6 +13652,7 @@ var LeaferUI = (function (exports) {
13630
13652
  exports.PathNumberCommandMap = PathNumberCommandMap;
13631
13653
  exports.PenData = PenData;
13632
13654
  exports.Platform = Platform;
13655
+ exports.Plugin = Plugin;
13633
13656
  exports.Point = Point;
13634
13657
  exports.PointHelper = PointHelper;
13635
13658
  exports.PointerButton = PointerButton;
@@ -13691,7 +13714,6 @@ var LeaferUI = (function (exports) {
13691
13714
  exports.maskType = maskType;
13692
13715
  exports.motionPathType = motionPathType;
13693
13716
  exports.naturalBoundsType = naturalBoundsType;
13694
- exports.needPlugin = needPlugin;
13695
13717
  exports.opacityType = opacityType;
13696
13718
  exports.pathInputType = pathInputType;
13697
13719
  exports.pathType = pathType;