leafer-draw 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.
- package/dist/web.cjs +43 -36
- package/dist/web.esm.js +43 -36
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +90 -54
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +86 -54
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/web.cjs.map +0 -1
- package/dist/web.esm.js.map +0 -1
- package/dist/web.js.map +0 -1
- package/dist/web.module.js.map +0 -1
package/dist/web.module.js
CHANGED
|
@@ -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
|
|
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
|
|
4274
|
+
updateAllWorldOpacity(children[i]);
|
|
4265
4275
|
}
|
|
4266
4276
|
}
|
|
4267
4277
|
},
|
|
4268
|
-
|
|
4269
|
-
|
|
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:
|
|
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.
|
|
6145
|
+
const version = "1.6.2";
|
|
6129
6146
|
|
|
6130
6147
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6131
6148
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6491,7 +6508,7 @@ class Watcher {
|
|
|
6491
6508
|
}
|
|
6492
6509
|
}
|
|
6493
6510
|
|
|
6494
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
6511
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
|
|
6495
6512
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
6496
6513
|
function updateMatrix(updateList, levelList) {
|
|
6497
6514
|
let layout;
|
|
@@ -6534,15 +6551,7 @@ function updateBounds(boundsList) {
|
|
|
6534
6551
|
});
|
|
6535
6552
|
}
|
|
6536
6553
|
function updateChange(updateList) {
|
|
6537
|
-
|
|
6538
|
-
updateList.list.forEach(leaf => {
|
|
6539
|
-
layout = leaf.__layout;
|
|
6540
|
-
if (layout.opacityChanged)
|
|
6541
|
-
updateAllWorldOpacity(leaf);
|
|
6542
|
-
if (layout.stateStyleChanged)
|
|
6543
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
6544
|
-
leaf.__updateChange();
|
|
6545
|
-
});
|
|
6554
|
+
updateList.list.forEach(updateOneChange);
|
|
6546
6555
|
}
|
|
6547
6556
|
|
|
6548
6557
|
const { worldBounds } = LeafBoundsHelper;
|
|
@@ -7230,13 +7239,11 @@ class TextData extends UIData {
|
|
|
7230
7239
|
setFontWeight(value) {
|
|
7231
7240
|
if (typeof value === 'string') {
|
|
7232
7241
|
this.__setInput('fontWeight', value);
|
|
7233
|
-
|
|
7234
|
-
}
|
|
7235
|
-
else {
|
|
7236
|
-
if (this.__input)
|
|
7237
|
-
this.__removeInput('fontWeight');
|
|
7238
|
-
this._fontWeight = value;
|
|
7242
|
+
value = fontWeightMap[value] || 400;
|
|
7239
7243
|
}
|
|
7244
|
+
else if (this.__input)
|
|
7245
|
+
this.__removeInput('fontWeight');
|
|
7246
|
+
this._fontWeight = value;
|
|
7240
7247
|
}
|
|
7241
7248
|
setBoxStyle(value) {
|
|
7242
7249
|
let t = this.__leaf, box = t.__box;
|
|
@@ -7563,6 +7570,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7563
7570
|
else
|
|
7564
7571
|
drawer.rect(x, y, width, height);
|
|
7565
7572
|
}
|
|
7573
|
+
drawImagePlaceholder(canvas, _image) {
|
|
7574
|
+
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
7575
|
+
}
|
|
7566
7576
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7567
7577
|
return Plugin.need('animate');
|
|
7568
7578
|
}
|
|
@@ -7799,6 +7809,9 @@ __decorate([
|
|
|
7799
7809
|
__decorate([
|
|
7800
7810
|
effectType()
|
|
7801
7811
|
], UI.prototype, "filter", void 0);
|
|
7812
|
+
__decorate([
|
|
7813
|
+
surfaceType()
|
|
7814
|
+
], UI.prototype, "placeholderColor", void 0);
|
|
7802
7815
|
__decorate([
|
|
7803
7816
|
dataType({})
|
|
7804
7817
|
], UI.prototype, "data", void 0);
|
|
@@ -8629,10 +8642,11 @@ let Image$1 = class Image extends Rect {
|
|
|
8629
8642
|
get ready() { return this.image ? this.image.ready : false; }
|
|
8630
8643
|
constructor(data) {
|
|
8631
8644
|
super(data);
|
|
8632
|
-
this.
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8645
|
+
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8646
|
+
}
|
|
8647
|
+
__onLoaded(e) {
|
|
8648
|
+
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8649
|
+
this.image = e.image;
|
|
8636
8650
|
}
|
|
8637
8651
|
destroy() {
|
|
8638
8652
|
this.image = null;
|
|
@@ -8746,7 +8760,7 @@ let Text = class Text extends UI {
|
|
|
8746
8760
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8747
8761
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8748
8762
|
data.__clipText = textOverflow !== 'show' && !data.__autoSize;
|
|
8749
|
-
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8763
|
+
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
|
|
8750
8764
|
}
|
|
8751
8765
|
__updateBoxBounds() {
|
|
8752
8766
|
const data = this.__;
|
|
@@ -8844,6 +8858,9 @@ __decorate([
|
|
|
8844
8858
|
__decorate([
|
|
8845
8859
|
boundsType('')
|
|
8846
8860
|
], Text.prototype, "text", void 0);
|
|
8861
|
+
__decorate([
|
|
8862
|
+
boundsType('')
|
|
8863
|
+
], Text.prototype, "placeholder", void 0);
|
|
8847
8864
|
__decorate([
|
|
8848
8865
|
boundsType('caption')
|
|
8849
8866
|
], Text.prototype, "fontFamily", void 0);
|
|
@@ -8963,8 +8980,10 @@ function penPathType() {
|
|
|
8963
8980
|
}
|
|
8964
8981
|
|
|
8965
8982
|
function fillText(ui, canvas) {
|
|
8966
|
-
|
|
8967
|
-
|
|
8983
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
8984
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
8985
|
+
canvas.fillStyle = data.placeholderColor;
|
|
8986
|
+
let row;
|
|
8968
8987
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8969
8988
|
row = rows[i];
|
|
8970
8989
|
if (row.text)
|
|
@@ -8973,7 +8992,7 @@ function fillText(ui, canvas) {
|
|
|
8973
8992
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
8974
8993
|
}
|
|
8975
8994
|
if (decorationY) {
|
|
8976
|
-
const { decorationColor, decorationHeight } = data;
|
|
8995
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
8977
8996
|
if (decorationColor)
|
|
8978
8997
|
canvas.fillStyle = decorationColor;
|
|
8979
8998
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -8982,38 +9001,44 @@ function fillText(ui, canvas) {
|
|
|
8982
9001
|
|
|
8983
9002
|
function fill(fill, ui, canvas) {
|
|
8984
9003
|
canvas.fillStyle = fill;
|
|
8985
|
-
|
|
9004
|
+
fillPathOrText(ui, canvas);
|
|
8986
9005
|
}
|
|
8987
9006
|
function fills(fills, ui, canvas) {
|
|
8988
9007
|
let item;
|
|
8989
|
-
const { windingRule, __font } = ui.__;
|
|
8990
9008
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
8991
9009
|
item = fills[i];
|
|
8992
|
-
if (item.image
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
if (item.blendMode)
|
|
9000
|
-
canvas.blendMode = item.blendMode;
|
|
9001
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
9002
|
-
canvas.restore();
|
|
9010
|
+
if (item.image) {
|
|
9011
|
+
if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
9012
|
+
continue;
|
|
9013
|
+
if (!item.style) {
|
|
9014
|
+
if (!i && item.image.isPlacehold)
|
|
9015
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
9016
|
+
continue;
|
|
9003
9017
|
}
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9018
|
+
}
|
|
9019
|
+
canvas.fillStyle = item.style;
|
|
9020
|
+
if (item.transform) {
|
|
9021
|
+
canvas.save();
|
|
9022
|
+
canvas.transform(item.transform);
|
|
9023
|
+
if (item.blendMode)
|
|
9024
|
+
canvas.blendMode = item.blendMode;
|
|
9025
|
+
fillPathOrText(ui, canvas);
|
|
9026
|
+
canvas.restore();
|
|
9027
|
+
}
|
|
9028
|
+
else {
|
|
9029
|
+
if (item.blendMode) {
|
|
9030
|
+
canvas.saveBlendMode(item.blendMode);
|
|
9031
|
+
fillPathOrText(ui, canvas);
|
|
9032
|
+
canvas.restoreBlendMode();
|
|
9013
9033
|
}
|
|
9034
|
+
else
|
|
9035
|
+
fillPathOrText(ui, canvas);
|
|
9014
9036
|
}
|
|
9015
9037
|
}
|
|
9016
9038
|
}
|
|
9039
|
+
function fillPathOrText(ui, canvas) {
|
|
9040
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
9041
|
+
}
|
|
9017
9042
|
|
|
9018
9043
|
function strokeText(stroke, ui, canvas) {
|
|
9019
9044
|
const { strokeAlign } = ui.__;
|
|
@@ -9253,6 +9278,7 @@ const PaintModule = {
|
|
|
9253
9278
|
compute,
|
|
9254
9279
|
fill,
|
|
9255
9280
|
fills,
|
|
9281
|
+
fillPathOrText,
|
|
9256
9282
|
fillText,
|
|
9257
9283
|
stroke,
|
|
9258
9284
|
strokes,
|
|
@@ -9445,6 +9471,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9445
9471
|
onLoadError(ui, event, error);
|
|
9446
9472
|
leafPaint.loadId = null;
|
|
9447
9473
|
});
|
|
9474
|
+
if (ui.placeholderColor)
|
|
9475
|
+
setTimeout(() => {
|
|
9476
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
9477
|
+
image.isPlacehold = true;
|
|
9478
|
+
ui.forceUpdate('surface');
|
|
9479
|
+
}
|
|
9480
|
+
}, 100);
|
|
9448
9481
|
}
|
|
9449
9482
|
return leafPaint;
|
|
9450
9483
|
}
|
|
@@ -10478,4 +10511,3 @@ Object.assign(Effect, EffectModule);
|
|
|
10478
10511
|
useCanvas();
|
|
10479
10512
|
|
|
10480
10513
|
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, 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, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, 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, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, 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, WaitHelper, WatchEvent, Watcher, 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 };
|
|
10481
|
-
//# sourceMappingURL=web.module.js.map
|