@leafer-ui/worker 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 true; }
@@ -6310,7 +6327,7 @@ class Watcher {
6310
6327
  }
6311
6328
  }
6312
6329
 
6313
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6330
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
6314
6331
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6315
6332
  function updateMatrix(updateList, levelList) {
6316
6333
  let layout;
@@ -6353,15 +6370,7 @@ function updateBounds(boundsList) {
6353
6370
  });
6354
6371
  }
6355
6372
  function updateChange(updateList) {
6356
- let layout;
6357
- updateList.list.forEach(leaf => {
6358
- layout = leaf.__layout;
6359
- if (layout.opacityChanged)
6360
- updateAllWorldOpacity(leaf);
6361
- if (layout.stateStyleChanged)
6362
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
6363
- leaf.__updateChange();
6364
- });
6373
+ updateList.list.forEach(updateOneChange);
6365
6374
  }
6366
6375
 
6367
6376
  const { worldBounds } = LeafBoundsHelper;
@@ -7206,13 +7215,11 @@ class TextData extends UIData {
7206
7215
  setFontWeight(value) {
7207
7216
  if (typeof value === 'string') {
7208
7217
  this.__setInput('fontWeight', value);
7209
- this._fontWeight = fontWeightMap[value] || 400;
7210
- }
7211
- else {
7212
- if (this.__input)
7213
- this.__removeInput('fontWeight');
7214
- this._fontWeight = value;
7218
+ value = fontWeightMap[value] || 400;
7215
7219
  }
7220
+ else if (this.__input)
7221
+ this.__removeInput('fontWeight');
7222
+ this._fontWeight = value;
7216
7223
  }
7217
7224
  setBoxStyle(value) {
7218
7225
  let t = this.__leaf, box = t.__box;
@@ -7539,6 +7546,9 @@ let UI = UI_1 = class UI extends Leaf {
7539
7546
  else
7540
7547
  drawer.rect(x, y, width, height);
7541
7548
  }
7549
+ drawImagePlaceholder(canvas, _image) {
7550
+ Paint.fill(this.__.placeholderColor, this, canvas);
7551
+ }
7542
7552
  animate(_keyframe, _options, _type, _isTemp) {
7543
7553
  return Plugin.need('animate');
7544
7554
  }
@@ -7775,6 +7785,9 @@ __decorate([
7775
7785
  __decorate([
7776
7786
  effectType()
7777
7787
  ], UI.prototype, "filter", void 0);
7788
+ __decorate([
7789
+ surfaceType()
7790
+ ], UI.prototype, "placeholderColor", void 0);
7778
7791
  __decorate([
7779
7792
  dataType({})
7780
7793
  ], UI.prototype, "data", void 0);
@@ -8605,10 +8618,11 @@ let Image = class Image extends Rect {
8605
8618
  get ready() { return this.image ? this.image.ready : false; }
8606
8619
  constructor(data) {
8607
8620
  super(data);
8608
- this.on(ImageEvent.LOADED, (e) => {
8609
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8610
- this.image = e.image;
8611
- });
8621
+ this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8622
+ }
8623
+ __onLoaded(e) {
8624
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
8625
+ this.image = e.image;
8612
8626
  }
8613
8627
  destroy() {
8614
8628
  this.image = null;
@@ -8722,7 +8736,7 @@ let Text = class Text extends UI {
8722
8736
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8723
8737
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8724
8738
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8725
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
8739
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
8726
8740
  }
8727
8741
  __updateBoxBounds() {
8728
8742
  const data = this.__;
@@ -8820,6 +8834,9 @@ __decorate([
8820
8834
  __decorate([
8821
8835
  boundsType('')
8822
8836
  ], Text.prototype, "text", void 0);
8837
+ __decorate([
8838
+ boundsType('')
8839
+ ], Text.prototype, "placeholder", void 0);
8823
8840
  __decorate([
8824
8841
  boundsType('caption')
8825
8842
  ], Text.prototype, "fontFamily", void 0);
@@ -10245,8 +10262,10 @@ canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
10245
10262
  };
10246
10263
 
10247
10264
  function fillText(ui, canvas) {
10248
- let row, data = ui.__.__textDrawData;
10249
- const { rows, decorationY } = data;
10265
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
10266
+ if (data.__isPlacehold && data.placeholderColor)
10267
+ canvas.fillStyle = data.placeholderColor;
10268
+ let row;
10250
10269
  for (let i = 0, len = rows.length; i < len; i++) {
10251
10270
  row = rows[i];
10252
10271
  if (row.text)
@@ -10255,7 +10274,7 @@ function fillText(ui, canvas) {
10255
10274
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10256
10275
  }
10257
10276
  if (decorationY) {
10258
- const { decorationColor, decorationHeight } = data;
10277
+ const { decorationColor, decorationHeight } = data.__textDrawData;
10259
10278
  if (decorationColor)
10260
10279
  canvas.fillStyle = decorationColor;
10261
10280
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -10264,38 +10283,44 @@ function fillText(ui, canvas) {
10264
10283
 
10265
10284
  function fill(fill, ui, canvas) {
10266
10285
  canvas.fillStyle = fill;
10267
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10286
+ fillPathOrText(ui, canvas);
10268
10287
  }
10269
10288
  function fills(fills, ui, canvas) {
10270
10289
  let item;
10271
- const { windingRule, __font } = ui.__;
10272
10290
  for (let i = 0, len = fills.length; i < len; i++) {
10273
10291
  item = fills[i];
10274
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
10275
- continue;
10276
- if (item.style) {
10277
- canvas.fillStyle = item.style;
10278
- if (item.transform) {
10279
- canvas.save();
10280
- canvas.transform(item.transform);
10281
- if (item.blendMode)
10282
- canvas.blendMode = item.blendMode;
10283
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10284
- canvas.restore();
10292
+ if (item.image) {
10293
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
10294
+ continue;
10295
+ if (!item.style) {
10296
+ if (!i && item.image.isPlacehold)
10297
+ ui.drawImagePlaceholder(canvas, item.image);
10298
+ continue;
10285
10299
  }
10286
- else {
10287
- if (item.blendMode) {
10288
- canvas.saveBlendMode(item.blendMode);
10289
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10290
- canvas.restoreBlendMode();
10291
- }
10292
- else {
10293
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10294
- }
10300
+ }
10301
+ canvas.fillStyle = item.style;
10302
+ if (item.transform) {
10303
+ canvas.save();
10304
+ canvas.transform(item.transform);
10305
+ if (item.blendMode)
10306
+ canvas.blendMode = item.blendMode;
10307
+ fillPathOrText(ui, canvas);
10308
+ canvas.restore();
10309
+ }
10310
+ else {
10311
+ if (item.blendMode) {
10312
+ canvas.saveBlendMode(item.blendMode);
10313
+ fillPathOrText(ui, canvas);
10314
+ canvas.restoreBlendMode();
10295
10315
  }
10316
+ else
10317
+ fillPathOrText(ui, canvas);
10296
10318
  }
10297
10319
  }
10298
10320
  }
10321
+ function fillPathOrText(ui, canvas) {
10322
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10323
+ }
10299
10324
 
10300
10325
  function strokeText(stroke, ui, canvas) {
10301
10326
  const { strokeAlign } = ui.__;
@@ -10535,6 +10560,7 @@ const PaintModule = {
10535
10560
  compute,
10536
10561
  fill,
10537
10562
  fills,
10563
+ fillPathOrText,
10538
10564
  fillText,
10539
10565
  stroke,
10540
10566
  strokes,
@@ -10727,6 +10753,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10727
10753
  onLoadError(ui, event, error);
10728
10754
  leafPaint.loadId = null;
10729
10755
  });
10756
+ if (ui.placeholderColor)
10757
+ setTimeout(() => {
10758
+ if (!(image.ready || image.isPlacehold)) {
10759
+ image.isPlacehold = true;
10760
+ ui.forceUpdate('surface');
10761
+ }
10762
+ }, 100);
10730
10763
  }
10731
10764
  return leafPaint;
10732
10765
  }
@@ -11765,4 +11798,3 @@ Object.assign(Creator, {
11765
11798
  useCanvas();
11766
11799
 
11767
11800
  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, 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 };
11768
- //# sourceMappingURL=worker.module.js.map