@leafer-draw/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.
- package/dist/worker.cjs +43 -36
- package/dist/worker.esm.js +43 -36
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +90 -54
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +86 -54
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
- package/dist/worker.cjs.map +0 -1
- package/dist/worker.esm.js.map +0 -1
- package/dist/worker.js.map +0 -1
- package/dist/worker.module.js.map +0 -1
package/dist/worker.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
|
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,
|
|
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
|
-
|
|
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;
|
|
@@ -7049,13 +7058,11 @@ class TextData extends UIData {
|
|
|
7049
7058
|
setFontWeight(value) {
|
|
7050
7059
|
if (typeof value === 'string') {
|
|
7051
7060
|
this.__setInput('fontWeight', value);
|
|
7052
|
-
|
|
7053
|
-
}
|
|
7054
|
-
else {
|
|
7055
|
-
if (this.__input)
|
|
7056
|
-
this.__removeInput('fontWeight');
|
|
7057
|
-
this._fontWeight = value;
|
|
7061
|
+
value = fontWeightMap[value] || 400;
|
|
7058
7062
|
}
|
|
7063
|
+
else if (this.__input)
|
|
7064
|
+
this.__removeInput('fontWeight');
|
|
7065
|
+
this._fontWeight = value;
|
|
7059
7066
|
}
|
|
7060
7067
|
setBoxStyle(value) {
|
|
7061
7068
|
let t = this.__leaf, box = t.__box;
|
|
@@ -7382,6 +7389,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7382
7389
|
else
|
|
7383
7390
|
drawer.rect(x, y, width, height);
|
|
7384
7391
|
}
|
|
7392
|
+
drawImagePlaceholder(canvas, _image) {
|
|
7393
|
+
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
7394
|
+
}
|
|
7385
7395
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7386
7396
|
return Plugin.need('animate');
|
|
7387
7397
|
}
|
|
@@ -7618,6 +7628,9 @@ __decorate([
|
|
|
7618
7628
|
__decorate([
|
|
7619
7629
|
effectType()
|
|
7620
7630
|
], UI.prototype, "filter", void 0);
|
|
7631
|
+
__decorate([
|
|
7632
|
+
surfaceType()
|
|
7633
|
+
], UI.prototype, "placeholderColor", void 0);
|
|
7621
7634
|
__decorate([
|
|
7622
7635
|
dataType({})
|
|
7623
7636
|
], UI.prototype, "data", void 0);
|
|
@@ -8448,10 +8461,11 @@ let Image = class Image extends Rect {
|
|
|
8448
8461
|
get ready() { return this.image ? this.image.ready : false; }
|
|
8449
8462
|
constructor(data) {
|
|
8450
8463
|
super(data);
|
|
8451
|
-
this.
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8464
|
+
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8465
|
+
}
|
|
8466
|
+
__onLoaded(e) {
|
|
8467
|
+
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8468
|
+
this.image = e.image;
|
|
8455
8469
|
}
|
|
8456
8470
|
destroy() {
|
|
8457
8471
|
this.image = null;
|
|
@@ -8565,7 +8579,7 @@ let Text = class Text extends UI {
|
|
|
8565
8579
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8566
8580
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8567
8581
|
data.__clipText = textOverflow !== 'show' && !data.__autoSize;
|
|
8568
|
-
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8582
|
+
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
|
|
8569
8583
|
}
|
|
8570
8584
|
__updateBoxBounds() {
|
|
8571
8585
|
const data = this.__;
|
|
@@ -8663,6 +8677,9 @@ __decorate([
|
|
|
8663
8677
|
__decorate([
|
|
8664
8678
|
boundsType('')
|
|
8665
8679
|
], Text.prototype, "text", void 0);
|
|
8680
|
+
__decorate([
|
|
8681
|
+
boundsType('')
|
|
8682
|
+
], Text.prototype, "placeholder", void 0);
|
|
8666
8683
|
__decorate([
|
|
8667
8684
|
boundsType('caption')
|
|
8668
8685
|
], Text.prototype, "fontFamily", void 0);
|
|
@@ -8782,8 +8799,10 @@ function penPathType() {
|
|
|
8782
8799
|
}
|
|
8783
8800
|
|
|
8784
8801
|
function fillText(ui, canvas) {
|
|
8785
|
-
|
|
8786
|
-
|
|
8802
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
8803
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
8804
|
+
canvas.fillStyle = data.placeholderColor;
|
|
8805
|
+
let row;
|
|
8787
8806
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8788
8807
|
row = rows[i];
|
|
8789
8808
|
if (row.text)
|
|
@@ -8792,7 +8811,7 @@ function fillText(ui, canvas) {
|
|
|
8792
8811
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
8793
8812
|
}
|
|
8794
8813
|
if (decorationY) {
|
|
8795
|
-
const { decorationColor, decorationHeight } = data;
|
|
8814
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
8796
8815
|
if (decorationColor)
|
|
8797
8816
|
canvas.fillStyle = decorationColor;
|
|
8798
8817
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -8801,38 +8820,44 @@ function fillText(ui, canvas) {
|
|
|
8801
8820
|
|
|
8802
8821
|
function fill(fill, ui, canvas) {
|
|
8803
8822
|
canvas.fillStyle = fill;
|
|
8804
|
-
|
|
8823
|
+
fillPathOrText(ui, canvas);
|
|
8805
8824
|
}
|
|
8806
8825
|
function fills(fills, ui, canvas) {
|
|
8807
8826
|
let item;
|
|
8808
|
-
const { windingRule, __font } = ui.__;
|
|
8809
8827
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
8810
8828
|
item = fills[i];
|
|
8811
|
-
if (item.image
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
if (item.blendMode)
|
|
8819
|
-
canvas.blendMode = item.blendMode;
|
|
8820
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
8821
|
-
canvas.restore();
|
|
8829
|
+
if (item.image) {
|
|
8830
|
+
if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
8831
|
+
continue;
|
|
8832
|
+
if (!item.style) {
|
|
8833
|
+
if (!i && item.image.isPlacehold)
|
|
8834
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
8835
|
+
continue;
|
|
8822
8836
|
}
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8837
|
+
}
|
|
8838
|
+
canvas.fillStyle = item.style;
|
|
8839
|
+
if (item.transform) {
|
|
8840
|
+
canvas.save();
|
|
8841
|
+
canvas.transform(item.transform);
|
|
8842
|
+
if (item.blendMode)
|
|
8843
|
+
canvas.blendMode = item.blendMode;
|
|
8844
|
+
fillPathOrText(ui, canvas);
|
|
8845
|
+
canvas.restore();
|
|
8846
|
+
}
|
|
8847
|
+
else {
|
|
8848
|
+
if (item.blendMode) {
|
|
8849
|
+
canvas.saveBlendMode(item.blendMode);
|
|
8850
|
+
fillPathOrText(ui, canvas);
|
|
8851
|
+
canvas.restoreBlendMode();
|
|
8832
8852
|
}
|
|
8853
|
+
else
|
|
8854
|
+
fillPathOrText(ui, canvas);
|
|
8833
8855
|
}
|
|
8834
8856
|
}
|
|
8835
8857
|
}
|
|
8858
|
+
function fillPathOrText(ui, canvas) {
|
|
8859
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
8860
|
+
}
|
|
8836
8861
|
|
|
8837
8862
|
function strokeText(stroke, ui, canvas) {
|
|
8838
8863
|
const { strokeAlign } = ui.__;
|
|
@@ -9072,6 +9097,7 @@ const PaintModule = {
|
|
|
9072
9097
|
compute,
|
|
9073
9098
|
fill,
|
|
9074
9099
|
fills,
|
|
9100
|
+
fillPathOrText,
|
|
9075
9101
|
fillText,
|
|
9076
9102
|
stroke,
|
|
9077
9103
|
strokes,
|
|
@@ -9264,6 +9290,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9264
9290
|
onLoadError(ui, event, error);
|
|
9265
9291
|
leafPaint.loadId = null;
|
|
9266
9292
|
});
|
|
9293
|
+
if (ui.placeholderColor)
|
|
9294
|
+
setTimeout(() => {
|
|
9295
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
9296
|
+
image.isPlacehold = true;
|
|
9297
|
+
ui.forceUpdate('surface');
|
|
9298
|
+
}
|
|
9299
|
+
}, 100);
|
|
9267
9300
|
}
|
|
9268
9301
|
return leafPaint;
|
|
9269
9302
|
}
|
|
@@ -10297,4 +10330,3 @@ Object.assign(Effect, EffectModule);
|
|
|
10297
10330
|
useCanvas();
|
|
10298
10331
|
|
|
10299
10332
|
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, 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 };
|
|
10300
|
-
//# sourceMappingURL=worker.module.js.map
|