@leafer-ui/miniapp 1.6.1 → 1.6.2

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.
@@ -2589,7 +2589,11 @@ const BezierHelper = {
2589
2589
  const point = {};
2590
2590
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, point);
2591
2591
  return point;
2592
- }
2592
+ },
2593
+ getDerivative(t, fromV, v1, v2, toV) {
2594
+ const o = 1 - t;
2595
+ return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2596
+ },
2593
2597
  };
2594
2598
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
2595
2599
 
@@ -3770,8 +3774,11 @@ class LeaferImage {
3770
3774
  load(onSuccess, onError) {
3771
3775
  if (!this.loading) {
3772
3776
  this.loading = true;
3777
+ let { loadImage, loadImageWithProgress } = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
3778
+ if (onProgress)
3779
+ loadImage = loadImageWithProgress;
3773
3780
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
3774
- return yield Platform.origin.loadImage(this.url).then(img => this.setView(img)).catch((e) => {
3781
+ return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch((e) => {
3775
3782
  this.error = e;
3776
3783
  this.onComplete(false);
3777
3784
  });
@@ -3796,6 +3803,9 @@ class LeaferImage {
3796
3803
  this.view = img;
3797
3804
  this.onComplete(true);
3798
3805
  }
3806
+ onProgress(progress) {
3807
+ this.progress = progress;
3808
+ }
3799
3809
  onComplete(isSuccess) {
3800
3810
  let odd;
3801
3811
  this.waitComplete.forEach((item, index) => {
@@ -4261,13 +4271,20 @@ const LeafHelper = {
4261
4271
  if (leaf.isBranch) {
4262
4272
  const { children } = leaf;
4263
4273
  for (let i = 0, len = children.length; i < len; i++) {
4264
- updateAllWorldOpacity$1(children[i]);
4274
+ updateAllWorldOpacity(children[i]);
4265
4275
  }
4266
4276
  }
4267
4277
  },
4268
- updateAllChange(leaf) {
4269
- updateAllWorldOpacity$1(leaf);
4278
+ updateChange(leaf) {
4279
+ const layout = leaf.__layout;
4280
+ if (layout.stateStyleChanged)
4281
+ leaf.updateState();
4282
+ if (layout.opacityChanged)
4283
+ updateAllWorldOpacity(leaf);
4270
4284
  leaf.__updateChange();
4285
+ },
4286
+ updateAllChange(leaf) {
4287
+ updateChange$1(leaf);
4271
4288
  if (leaf.isBranch) {
4272
4289
  const { children } = leaf;
4273
4290
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4403,7 +4420,7 @@ const LeafHelper = {
4403
4420
  }
4404
4421
  };
4405
4422
  const L = LeafHelper;
4406
- const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4423
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1 } = L;
4407
4424
  function getTempLocal(t, world) {
4408
4425
  t.__layout.update();
4409
4426
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
@@ -6125,7 +6142,7 @@ class LeafLevelList {
6125
6142
  }
6126
6143
  }
6127
6144
 
6128
- const version = "1.6.1";
6145
+ const version = "1.6.2";
6129
6146
 
6130
6147
  class LeaferCanvas extends LeaferCanvasBase {
6131
6148
  get allowBackgroundColor() { return false; }
@@ -6449,7 +6466,7 @@ class Watcher {
6449
6466
  }
6450
6467
  }
6451
6468
 
6452
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6469
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
6453
6470
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6454
6471
  function updateMatrix(updateList, levelList) {
6455
6472
  let layout;
@@ -6492,15 +6509,7 @@ function updateBounds(boundsList) {
6492
6509
  });
6493
6510
  }
6494
6511
  function updateChange(updateList) {
6495
- let layout;
6496
- updateList.list.forEach(leaf => {
6497
- layout = leaf.__layout;
6498
- if (layout.opacityChanged)
6499
- updateAllWorldOpacity(leaf);
6500
- if (layout.stateStyleChanged)
6501
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
6502
- leaf.__updateChange();
6503
- });
6512
+ updateList.list.forEach(updateOneChange);
6504
6513
  }
6505
6514
 
6506
6515
  const { worldBounds } = LeafBoundsHelper;
@@ -7345,13 +7354,11 @@ class TextData extends UIData {
7345
7354
  setFontWeight(value) {
7346
7355
  if (typeof value === 'string') {
7347
7356
  this.__setInput('fontWeight', value);
7348
- this._fontWeight = fontWeightMap[value] || 400;
7349
- }
7350
- else {
7351
- if (this.__input)
7352
- this.__removeInput('fontWeight');
7353
- this._fontWeight = value;
7357
+ value = fontWeightMap[value] || 400;
7354
7358
  }
7359
+ else if (this.__input)
7360
+ this.__removeInput('fontWeight');
7361
+ this._fontWeight = value;
7355
7362
  }
7356
7363
  setBoxStyle(value) {
7357
7364
  let t = this.__leaf, box = t.__box;
@@ -7678,6 +7685,9 @@ let UI = UI_1 = class UI extends Leaf {
7678
7685
  else
7679
7686
  drawer.rect(x, y, width, height);
7680
7687
  }
7688
+ drawImagePlaceholder(canvas, _image) {
7689
+ Paint.fill(this.__.placeholderColor, this, canvas);
7690
+ }
7681
7691
  animate(_keyframe, _options, _type, _isTemp) {
7682
7692
  return Plugin.need('animate');
7683
7693
  }
@@ -7914,6 +7924,9 @@ __decorate([
7914
7924
  __decorate([
7915
7925
  effectType()
7916
7926
  ], UI.prototype, "filter", void 0);
7927
+ __decorate([
7928
+ surfaceType()
7929
+ ], UI.prototype, "placeholderColor", void 0);
7917
7930
  __decorate([
7918
7931
  dataType({})
7919
7932
  ], UI.prototype, "data", void 0);
@@ -8744,10 +8757,11 @@ let Image = class Image extends Rect {
8744
8757
  get ready() { return this.image ? this.image.ready : false; }
8745
8758
  constructor(data) {
8746
8759
  super(data);
8747
- this.on(ImageEvent.LOADED, (e) => {
8748
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8749
- this.image = e.image;
8750
- });
8760
+ this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8761
+ }
8762
+ __onLoaded(e) {
8763
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
8764
+ this.image = e.image;
8751
8765
  }
8752
8766
  destroy() {
8753
8767
  this.image = null;
@@ -8861,7 +8875,7 @@ let Text = class Text extends UI {
8861
8875
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8862
8876
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8863
8877
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8864
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
8878
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
8865
8879
  }
8866
8880
  __updateBoxBounds() {
8867
8881
  const data = this.__;
@@ -8959,6 +8973,9 @@ __decorate([
8959
8973
  __decorate([
8960
8974
  boundsType('')
8961
8975
  ], Text.prototype, "text", void 0);
8976
+ __decorate([
8977
+ boundsType('')
8978
+ ], Text.prototype, "placeholder", void 0);
8962
8979
  __decorate([
8963
8980
  boundsType('caption')
8964
8981
  ], Text.prototype, "fontFamily", void 0);
@@ -10489,8 +10506,10 @@ class Interaction extends InteractionBase {
10489
10506
  }
10490
10507
 
10491
10508
  function fillText(ui, canvas) {
10492
- let row, data = ui.__.__textDrawData;
10493
- const { rows, decorationY } = data;
10509
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
10510
+ if (data.__isPlacehold && data.placeholderColor)
10511
+ canvas.fillStyle = data.placeholderColor;
10512
+ let row;
10494
10513
  for (let i = 0, len = rows.length; i < len; i++) {
10495
10514
  row = rows[i];
10496
10515
  if (row.text)
@@ -10499,7 +10518,7 @@ function fillText(ui, canvas) {
10499
10518
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10500
10519
  }
10501
10520
  if (decorationY) {
10502
- const { decorationColor, decorationHeight } = data;
10521
+ const { decorationColor, decorationHeight } = data.__textDrawData;
10503
10522
  if (decorationColor)
10504
10523
  canvas.fillStyle = decorationColor;
10505
10524
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -10508,38 +10527,44 @@ function fillText(ui, canvas) {
10508
10527
 
10509
10528
  function fill(fill, ui, canvas) {
10510
10529
  canvas.fillStyle = fill;
10511
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10530
+ fillPathOrText(ui, canvas);
10512
10531
  }
10513
10532
  function fills(fills, ui, canvas) {
10514
10533
  let item;
10515
- const { windingRule, __font } = ui.__;
10516
10534
  for (let i = 0, len = fills.length; i < len; i++) {
10517
10535
  item = fills[i];
10518
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
10519
- continue;
10520
- if (item.style) {
10521
- canvas.fillStyle = item.style;
10522
- if (item.transform) {
10523
- canvas.save();
10524
- canvas.transform(item.transform);
10525
- if (item.blendMode)
10526
- canvas.blendMode = item.blendMode;
10527
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10528
- canvas.restore();
10536
+ if (item.image) {
10537
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
10538
+ continue;
10539
+ if (!item.style) {
10540
+ if (!i && item.image.isPlacehold)
10541
+ ui.drawImagePlaceholder(canvas, item.image);
10542
+ continue;
10529
10543
  }
10530
- else {
10531
- if (item.blendMode) {
10532
- canvas.saveBlendMode(item.blendMode);
10533
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10534
- canvas.restoreBlendMode();
10535
- }
10536
- else {
10537
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10538
- }
10544
+ }
10545
+ canvas.fillStyle = item.style;
10546
+ if (item.transform) {
10547
+ canvas.save();
10548
+ canvas.transform(item.transform);
10549
+ if (item.blendMode)
10550
+ canvas.blendMode = item.blendMode;
10551
+ fillPathOrText(ui, canvas);
10552
+ canvas.restore();
10553
+ }
10554
+ else {
10555
+ if (item.blendMode) {
10556
+ canvas.saveBlendMode(item.blendMode);
10557
+ fillPathOrText(ui, canvas);
10558
+ canvas.restoreBlendMode();
10539
10559
  }
10560
+ else
10561
+ fillPathOrText(ui, canvas);
10540
10562
  }
10541
10563
  }
10542
10564
  }
10565
+ function fillPathOrText(ui, canvas) {
10566
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10567
+ }
10543
10568
 
10544
10569
  function strokeText(stroke, ui, canvas) {
10545
10570
  const { strokeAlign } = ui.__;
@@ -10779,6 +10804,7 @@ const PaintModule = {
10779
10804
  compute,
10780
10805
  fill,
10781
10806
  fills,
10807
+ fillPathOrText,
10782
10808
  fillText,
10783
10809
  stroke,
10784
10810
  strokes,
@@ -10971,6 +10997,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10971
10997
  onLoadError(ui, event, error);
10972
10998
  leafPaint.loadId = null;
10973
10999
  });
11000
+ if (ui.placeholderColor)
11001
+ setTimeout(() => {
11002
+ if (!(image.ready || image.isPlacehold)) {
11003
+ image.isPlacehold = true;
11004
+ ui.forceUpdate('surface');
11005
+ }
11006
+ }, 100);
10974
11007
  }
10975
11008
  return leafPaint;
10976
11009
  }
@@ -12016,4 +12049,3 @@ try {
12016
12049
  catch (_a) { }
12017
12050
 
12018
12051
  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, isEmptyData, 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 };
12019
- //# sourceMappingURL=miniapp.module.js.map