@leafer-ui/miniapp 1.4.1 → 1.5.0

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.
@@ -3635,7 +3635,12 @@ const Resource = {
3635
3635
  return R.map[key];
3636
3636
  },
3637
3637
  remove(key) {
3638
- delete R.map[key];
3638
+ const r = R.map[key];
3639
+ if (r) {
3640
+ if (r.destroy)
3641
+ r.destroy();
3642
+ delete R.map[key];
3643
+ }
3639
3644
  },
3640
3645
  loadImage(key, format) {
3641
3646
  return new Promise((resolve, reject) => {
@@ -3661,6 +3666,7 @@ const Resource = {
3661
3666
  const R = Resource;
3662
3667
 
3663
3668
  const ImageManager = {
3669
+ maxRecycled: 100,
3664
3670
  recycledList: [],
3665
3671
  patternTasker: new TaskProcessor(),
3666
3672
  get(config) {
@@ -3677,13 +3683,8 @@ const ImageManager = {
3677
3683
  },
3678
3684
  clearRecycled() {
3679
3685
  const list = I$1.recycledList;
3680
- if (list.length > 100) {
3681
- list.forEach(image => {
3682
- if (!image.use && image.url) {
3683
- Resource.remove(image.url);
3684
- image.destroy();
3685
- }
3686
- });
3686
+ if (list.length > I$1.maxRecycled) {
3687
+ list.forEach(image => (!image.use && image.url) && Resource.remove(image.url));
3687
3688
  list.length = 0;
3688
3689
  }
3689
3690
  },
@@ -4069,12 +4070,11 @@ function defineDataProcessor(target, key, defaultValue) {
4069
4070
  if (defaultValue === undefined) {
4070
4071
  property.get = function () { return this[computedKey]; };
4071
4072
  }
4072
- else if (typeof defaultValue === 'object') {
4073
- const { clone } = DataHelper;
4073
+ else if (typeof defaultValue === 'function') {
4074
4074
  property.get = function () {
4075
4075
  let v = this[computedKey];
4076
4076
  if (v === undefined)
4077
- this[computedKey] = v = clone(defaultValue);
4077
+ this[computedKey] = v = defaultValue(this.__leaf);
4078
4078
  return v;
4079
4079
  };
4080
4080
  }
@@ -5721,10 +5721,10 @@ let Leaf = class Leaf {
5721
5721
  static changeAttr(attrName, defaultValue, fn) {
5722
5722
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5723
5723
  }
5724
- static addAttr(attrName, defaultValue, fn) {
5724
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5725
5725
  if (!fn)
5726
5726
  fn = boundsType;
5727
- fn(defaultValue)(this.prototype, attrName);
5727
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5728
5728
  }
5729
5729
  __emitLifeEvent(type) {
5730
5730
  if (this.hasEvent(type))
@@ -6051,7 +6051,7 @@ class LeafLevelList {
6051
6051
  }
6052
6052
  }
6053
6053
 
6054
- const version = "1.4.1";
6054
+ const version = "1.5.0";
6055
6055
 
6056
6056
  class LeaferCanvas extends LeaferCanvasBase {
6057
6057
  get allowBackgroundColor() { return false; }
@@ -7077,7 +7077,11 @@ const State = {
7077
7077
  setStyleName() { return Plugin.need('state'); },
7078
7078
  set() { return Plugin.need('state'); }
7079
7079
  };
7080
- const Transition = {};
7080
+ const Transition = {
7081
+ list: {},
7082
+ register(attrName, fn) { Transition.list[attrName] = fn; },
7083
+ get(attrName) { return Transition.list[attrName]; }
7084
+ };
7081
7085
 
7082
7086
  const { parse, objectToCanvasData } = PathConvert;
7083
7087
  const emptyPaint = {};
@@ -7501,9 +7505,6 @@ let UI = UI_1 = class UI extends Leaf {
7501
7505
  this.__drawPathByBox(pen);
7502
7506
  return pen;
7503
7507
  }
7504
- get editConfig() { return undefined; }
7505
- get editOuter() { return ''; }
7506
- get editInner() { return ''; }
7507
7508
  constructor(data) {
7508
7509
  super(data);
7509
7510
  }
@@ -7585,8 +7586,11 @@ let UI = UI_1 = class UI extends Leaf {
7585
7586
  export(_filename, _options) {
7586
7587
  return Plugin.need('export');
7587
7588
  }
7589
+ syncExport(_filename, _options) {
7590
+ return Plugin.need('export');
7591
+ }
7588
7592
  clone(data) {
7589
- const json = this.toJSON();
7593
+ const json = DataHelper.clone(this.toJSON());
7590
7594
  if (data)
7591
7595
  Object.assign(json, data);
7592
7596
  return UI_1.one(json);
@@ -7885,7 +7889,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7885
7889
  get layoutLocked() { return !this.layouter.running; }
7886
7890
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7887
7891
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7888
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7892
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
7889
7893
  constructor(userConfig, data) {
7890
7894
  super(data);
7891
7895
  this.config = {
@@ -8187,6 +8191,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8187
8191
  getPagePointByClient(clientPoint, updateClient) {
8188
8192
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
8189
8193
  }
8194
+ getClientPointByWorld(worldPoint) {
8195
+ const { x, y } = this.clientBounds;
8196
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
8197
+ }
8190
8198
  updateClientBounds() {
8191
8199
  this.canvas && this.canvas.updateClientBounds();
8192
8200
  }
@@ -10155,8 +10163,6 @@ ui$1.__updateHitCanvas = function () {
10155
10163
  h.setStrokeOptions(data);
10156
10164
  };
10157
10165
  ui$1.__hit = function (inner) {
10158
- if (Platform.name === 'miniapp')
10159
- this.__drawHitPath(this.__hitCanvas);
10160
10166
  const data = this.__;
10161
10167
  if (data.__isHitPixel && this.__hitPixel(inner))
10162
10168
  return true;
@@ -11616,13 +11622,14 @@ function toChar(data, charX, rowData, isOverflow) {
11616
11622
  }
11617
11623
 
11618
11624
  function layoutText(drawData, style) {
11619
- const { rows, bounds } = drawData;
11625
+ const { rows, bounds } = drawData, countRows = rows.length;
11620
11626
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11621
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11627
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11622
11628
  let starY = __baseLine;
11623
11629
  if (__clipText && realHeight > height) {
11624
11630
  realHeight = Math.max(height, __lineHeight);
11625
- drawData.overflow = rows.length;
11631
+ if (countRows > 1)
11632
+ drawData.overflow = countRows;
11626
11633
  }
11627
11634
  else if (height || autoSizeAlign) {
11628
11635
  switch (verticalAlign) {
@@ -11634,7 +11641,7 @@ function layoutText(drawData, style) {
11634
11641
  }
11635
11642
  starY += y;
11636
11643
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11637
- for (let i = 0, len = rows.length; i < len; i++) {
11644
+ for (let i = 0, len = countRows; i < len; i++) {
11638
11645
  row = rows[i];
11639
11646
  row.x = x;
11640
11647
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -11703,7 +11710,7 @@ function clipText(drawData, style, x, width) {
11703
11710
  if (i === end && charRight < right) {
11704
11711
  break;
11705
11712
  }
11706
- else if (charRight < right && char.char !== ' ') {
11713
+ else if ((charRight < right && char.char !== ' ') || !i) {
11707
11714
  row.data.splice(i + 1);
11708
11715
  row.width -= char.width;
11709
11716
  break;
@@ -11842,29 +11849,5 @@ try {
11842
11849
  }
11843
11850
  catch (_a) { }
11844
11851
 
11845
- const systemInfo = wx.getSystemInfoSync();
11846
- const platform = systemInfo.platform;
11847
- if (platform === 'ios') {
11848
- LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
11849
- const pattern = Platform.canvas.createPattern(this.view, repeat);
11850
- const { width, height } = canvas;
11851
- if (this.width !== width || this.height !== height) {
11852
- if (!transform)
11853
- transform = MatrixHelper.get();
11854
- MatrixHelper.scale(transform, width / this.width, height / this.height);
11855
- }
11856
- try {
11857
- if (transform && pattern.setTransform) {
11858
- pattern.setTransform(transform);
11859
- transform = null;
11860
- }
11861
- }
11862
- catch (_a) { }
11863
- if (paint)
11864
- paint.transform = transform;
11865
- return pattern;
11866
- };
11867
- }
11868
-
11869
11852
  export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
11870
11853
  //# sourceMappingURL=miniapp.module.js.map