@leafer-draw/miniapp 2.1.11 → 2.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.
@@ -817,6 +817,11 @@ const PointHelper = {
817
817
  toOuterOf(t, matrix, to) {
818
818
  toOuterPoint$3(matrix, t, to);
819
819
  },
820
+ toVertical(t, rotation, verticalDistance, to) {
821
+ const r = rotation * OneRadian;
822
+ t.x += -Math.sin(r) * verticalDistance;
823
+ t.y += Math.cos(r) * verticalDistance;
824
+ },
820
825
  getCenter(t, to) {
821
826
  return {
822
827
  x: t.x + (to.x - t.x) / 2,
@@ -4526,11 +4531,15 @@ function affectRenderBoundsType(defaultValue) {
4526
4531
  function surfaceType(defaultValue) {
4527
4532
  return decorateLeafAttr(defaultValue, key => attr({
4528
4533
  set(value) {
4529
- this.__setAttr(key, value) && (this.__layout.surfaceChanged || this.__layout.surfaceChange());
4534
+ this.__setAttr(key, value) && doSurfaceType(this);
4530
4535
  }
4531
4536
  }));
4532
4537
  }
4533
4538
 
4539
+ function doSurfaceType(leaf) {
4540
+ leaf.__layout.surfaceChanged || leaf.__layout.surfaceChange();
4541
+ }
4542
+
4534
4543
  function dimType(defaultValue) {
4535
4544
  return decorateLeafAttr(defaultValue, key => attr({
4536
4545
  set(value) {
@@ -4596,12 +4605,12 @@ function sortType(defaultValue) {
4596
4605
  }));
4597
4606
  }
4598
4607
 
4599
- function maskType(defaultValue) {
4608
+ function maskType(defaultValue, updateSelf) {
4600
4609
  return decorateLeafAttr(defaultValue, key => attr({
4601
4610
  set(value) {
4602
4611
  if (this.__setAttr(key, value)) {
4603
4612
  this.__layout.boxChanged || this.__layout.boxChange();
4604
- this.waitParent(() => {
4613
+ updateSelf ? this.__updateMask() : this.waitParent(() => {
4605
4614
  this.parent.__updateMask(value);
4606
4615
  });
4607
4616
  }
@@ -6253,7 +6262,8 @@ const BranchRender = {
6253
6262
  if (this.__worldOpacity && hasSize(nowWorld)) {
6254
6263
  const data = this.__;
6255
6264
  if (data.__useDim) {
6256
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
6265
+ if (data.bright && !options.topRendering) return options.topList.add(this);
6266
+ if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
6257
6267
  }
6258
6268
  if (data.__single && !this.isBranchLeaf) {
6259
6269
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
@@ -6277,6 +6287,7 @@ const BranchRender = {
6277
6287
  child = children[i];
6278
6288
  excludeRenderBounds$1(child, options) || (child.__hasComplex ? LeafHelper.renderComplex(child, canvas, options) : child.__render(canvas, options));
6279
6289
  }
6290
+ if (this.__hasMask === 0) this.__rerenderMask(canvas, options);
6280
6291
  }
6281
6292
  },
6282
6293
  __clip(canvas, options) {
@@ -6493,11 +6504,19 @@ let Leaf = class Leaf {
6493
6504
  updateLayout() {
6494
6505
  this.__layout.update();
6495
6506
  }
6496
- forceUpdate(attrName) {
6497
- if (isUndefined(attrName)) attrName = "width"; else if (attrName === "surface") attrName = "blendMode";
6498
- const value = this.__.__getInput(attrName);
6499
- this.__[attrName] = isUndefined(value) ? null : undefined;
6500
- this[attrName] = value;
6507
+ forceUpdate(typeOrAttrName) {
6508
+ let quick;
6509
+ if (!typeOrAttrName || typeOrAttrName === "bounds") doBoundsType(this), quick = true; else if (typeOrAttrName === "surface") doSurfaceType(this),
6510
+ quick = true; else if (typeOrAttrName === "stroke") doStrokeType(this), quick = true;
6511
+ if (quick) {
6512
+ const {leafer: leafer} = this;
6513
+ return leafer && leafer.watcher && leafer.watcher.__onAttrChange({
6514
+ target: this
6515
+ });
6516
+ }
6517
+ const value = this.__.__getInput(typeOrAttrName);
6518
+ this.__[typeOrAttrName] = isUndefined(value) ? null : undefined;
6519
+ this[typeOrAttrName] = value;
6501
6520
  }
6502
6521
  forceRender(_bounds, _sync) {
6503
6522
  this.forceUpdate("surface");
@@ -6516,7 +6535,8 @@ let Leaf = class Leaf {
6516
6535
  canvas.restore();
6517
6536
  }
6518
6537
  __updateMask(_value) {
6519
- this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6538
+ const hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6539
+ this.__hasMask = this.__.maskskip ? hasMask && 0 : hasMask;
6520
6540
  }
6521
6541
  __getNowWorld(options) {
6522
6542
  if (options.matrix) {
@@ -6985,7 +7005,7 @@ class LeafLevelList {
6985
7005
  }
6986
7006
  }
6987
7007
 
6988
- const version = "2.1.11";
7008
+ const version = "2.2.1";
6989
7009
 
6990
7010
  class LeaferCanvas extends LeaferCanvasBase {
6991
7011
  get allowBackgroundColor() {
@@ -8630,6 +8650,8 @@ __decorate([ dataType(false) ], UI.prototype, "editable", void 0);
8630
8650
 
8631
8651
  __decorate([ hitType(true) ], UI.prototype, "hittable", void 0);
8632
8652
 
8653
+ __decorate([ hitType() ], UI.prototype, "hitThrough", void 0);
8654
+
8633
8655
  __decorate([ hitType("path") ], UI.prototype, "hitFill", void 0);
8634
8656
 
8635
8657
  __decorate([ strokeType("path") ], UI.prototype, "hitStroke", void 0);
@@ -9588,7 +9610,7 @@ let Text = class Text extends UI {
9588
9610
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9589
9611
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9590
9612
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9591
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9613
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9592
9614
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9593
9615
  }
9594
9616
  __updateBoxBounds() {
@@ -9613,7 +9635,7 @@ let Text = class Text extends UI {
9613
9635
  this.__updateNaturalSize();
9614
9636
  } else super.__updateBoxBounds();
9615
9637
  if (italic) b.width += fontSize * .16;
9616
- DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9638
+ DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
9617
9639
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9618
9640
  }
9619
9641
  __updateRenderSpread() {
@@ -9798,7 +9820,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
9798
9820
  ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
9799
9821
  }
9800
9822
 
9801
- function fillText(ui, canvas, _renderOptions) {
9823
+ function fillText(ui, canvas, renderOptions) {
9824
+ if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
9802
9825
  const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
9803
9826
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
9804
9827
  let row;
@@ -10190,7 +10213,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10190
10213
  data.__naturalWidth = image.width / data.pixelRatio;
10191
10214
  data.__naturalHeight = image.height / data.pixelRatio;
10192
10215
  if (data.__autoSide) {
10193
- ui.forceUpdate("width");
10216
+ ui.forceUpdate();
10194
10217
  LeafHelper.updateBounds(ui);
10195
10218
  ui.__layout.boundsChanged = true;
10196
10219
  if (ui.__proxyData) {
@@ -11160,7 +11183,8 @@ const TextMode = 2;
11160
11183
 
11161
11184
  function layoutChar(drawData, style, width, _height) {
11162
11185
  const {rows: rows} = drawData;
11163
- const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
11186
+ const {textAlign: textAlign, paraIndent: paraIndent} = style;
11187
+ const useLetter = style.__letterSpacing || style.motionText;
11164
11188
  const justifyLast = width && textAlign.includes("both");
11165
11189
  const justify = justifyLast || width && textAlign.includes("justify");
11166
11190
  const justifyLetter = justify && textAlign.includes("letter");
@@ -11173,8 +11197,8 @@ function layoutChar(drawData, style, width, _height) {
11173
11197
  remainingWidth = width - row.width - indentWidth;
11174
11198
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
11175
11199
  }
11176
- mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11177
- if (row.isOverflow && !__letterSpacing) row.textMode = true;
11200
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11201
+ if (row.isOverflow && !useLetter) row.textMode = true;
11178
11202
  if (mode === TextMode) {
11179
11203
  row.x += indentWidth;
11180
11204
  toTextChar$1(row);
@@ -11375,6 +11399,7 @@ function getDrawData(content, style) {
11375
11399
  let width = style.__getInput("width") || 0;
11376
11400
  let height = style.__getInput("height") || 0;
11377
11401
  const {__padding: padding} = style;
11402
+ if (style.motionText) width = height = 0;
11378
11403
  if (padding) {
11379
11404
  if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
11380
11405
  if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
@@ -11464,4 +11489,4 @@ try {
11464
11489
  if (wx) useCanvas("miniapp", wx);
11465
11490
  } catch (_a) {}
11466
11491
 
11467
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
11492
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, doSurfaceType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };