@leafer-draw/worker 1.0.0-rc.16 → 1.0.0-rc.18

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.
@@ -38,6 +38,18 @@ const MathHelper = {
38
38
  value = max;
39
39
  return value;
40
40
  },
41
+ minus(value, isFourNumber) {
42
+ if (value instanceof Array) {
43
+ if (isFourNumber)
44
+ value = MathHelper.fourNumber(value);
45
+ for (let i = 0; i < value.length; i++)
46
+ value[i] = -value[i];
47
+ }
48
+ else {
49
+ value = -value;
50
+ }
51
+ return value;
52
+ },
41
53
  fourNumber(num, maxValue) {
42
54
  let data;
43
55
  if (num instanceof Array) {
@@ -721,7 +733,7 @@ const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
721
733
 
722
734
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
723
735
  const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
724
- const { float } = MathHelper;
736
+ const { float, fourNumber } = MathHelper;
725
737
  const { floor, ceil: ceil$2 } = Math;
726
738
  let right$1, bottom$1, boundsRight, boundsBottom;
727
739
  const point = {};
@@ -741,9 +753,15 @@ const BoundsHelper = {
741
753
  t.height = bounds.height;
742
754
  },
743
755
  copyAndSpread(t, bounds, spreadX, spreadY) {
744
- if (!spreadY)
745
- spreadY = spreadX;
746
- B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
756
+ if (spreadX instanceof Array) {
757
+ const four = fourNumber(spreadX);
758
+ B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
759
+ }
760
+ else {
761
+ if (!spreadY)
762
+ spreadY = spreadX;
763
+ B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
764
+ }
747
765
  },
748
766
  minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
749
767
  minY(t) { return t.height > 0 ? t.y : t.y + t.height; },
@@ -1021,8 +1039,12 @@ class Bounds {
1021
1039
  getFitMatrix(put) {
1022
1040
  return BoundsHelper.getFitMatrix(this, put);
1023
1041
  }
1024
- spread(spreadX, spreadY) {
1025
- BoundsHelper.spread(this, spreadX, spreadY);
1042
+ spread(fourNumber, spreadY) {
1043
+ BoundsHelper.spread(this, fourNumber, spreadY);
1044
+ return this;
1045
+ }
1046
+ shrink(fourNumber) {
1047
+ BoundsHelper.spread(this, MathHelper.minus(fourNumber, true));
1026
1048
  return this;
1027
1049
  }
1028
1050
  ceil() {
@@ -1447,17 +1469,30 @@ class LeafData {
1447
1469
  if (this.__input && this.__input[name] !== undefined)
1448
1470
  this.__input[name] = undefined;
1449
1471
  }
1450
- __getInputData() {
1451
- const data = { tag: this.__leaf.tag }, { __input } = this;
1452
- let value, inputValue;
1453
- for (let key in this) {
1454
- if (key[0] !== '_') {
1455
- value = this['_' + key];
1456
- if (value !== undefined) {
1457
- if (key === 'path' && !this.__pathInputed)
1458
- continue;
1459
- inputValue = __input ? __input[key] : undefined;
1460
- data[key] = (inputValue === undefined) ? value : inputValue;
1472
+ __getInputData(names) {
1473
+ const data = {};
1474
+ if (names) {
1475
+ if (names instanceof Array) {
1476
+ for (let name of names)
1477
+ data[name] = this.__getInput(name);
1478
+ }
1479
+ else {
1480
+ for (let name in names)
1481
+ data[name] = this.__getInput(name);
1482
+ }
1483
+ }
1484
+ else {
1485
+ let value, inputValue, { __input } = this;
1486
+ data.tag = this.__leaf.tag;
1487
+ for (let key in this) {
1488
+ if (key[0] !== '_') {
1489
+ value = this['_' + key];
1490
+ if (value !== undefined) {
1491
+ if (key === 'path' && !this.__pathInputed)
1492
+ continue;
1493
+ inputValue = __input ? __input[key] : undefined;
1494
+ data[key] = (inputValue === undefined) ? value : inputValue;
1495
+ }
1461
1496
  }
1462
1497
  }
1463
1498
  }
@@ -2818,12 +2853,16 @@ class PathCreator {
2818
2853
  set path(value) { this.__path = value; }
2819
2854
  get path() { return this.__path; }
2820
2855
  constructor(path) {
2856
+ this.set(path);
2857
+ }
2858
+ set(path) {
2821
2859
  if (path) {
2822
2860
  this.__path = typeof path === 'string' ? PathHelper.parse(path) : path;
2823
2861
  }
2824
2862
  else {
2825
2863
  this.__path = [];
2826
2864
  }
2865
+ return this;
2827
2866
  }
2828
2867
  beginPath() {
2829
2868
  beginPath(this.__path);
@@ -3137,6 +3176,7 @@ const PathCorner = {
3137
3176
  PathHelper.creator = new PathCreator();
3138
3177
  PathHelper.parse = PathConvert.parse;
3139
3178
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3179
+ const pen = new PathCreator();
3140
3180
 
3141
3181
  const { drawRoundRect } = RectHelper;
3142
3182
  function roundRect(drawer) {
@@ -3421,7 +3461,7 @@ const ImageManager = {
3421
3461
  },
3422
3462
  clearRecycled() {
3423
3463
  const list = I.recycledList;
3424
- if (list.length) {
3464
+ if (list.length > 100) {
3425
3465
  list.forEach(image => {
3426
3466
  if (!image.use && image.url) {
3427
3467
  delete I.map[image.url];
@@ -3673,6 +3713,8 @@ function affectStrokeBoundsType(defaultValue) {
3673
3713
  }
3674
3714
  function doStrokeType(leaf) {
3675
3715
  leaf.__layout.strokeChanged || leaf.__layout.strokeChange();
3716
+ if (leaf.__.__useArrow)
3717
+ doBoundsType(leaf);
3676
3718
  }
3677
3719
  const strokeType = affectStrokeBoundsType;
3678
3720
  function affectRenderBoundsType(defaultValue) {
@@ -3876,131 +3918,411 @@ function registerUIEvent() {
3876
3918
  };
3877
3919
  }
3878
3920
 
3879
- const tempMatrix = new Matrix();
3880
- const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
3881
- class LeafLayout {
3882
- get strokeBounds() { return this._strokeBounds || this.boxBounds; }
3883
- get renderBounds() { return this._renderBounds || this.boxBounds; }
3884
- get localStrokeBounds() { return this._localStrokeBounds || this; }
3885
- get localRenderBounds() { return this._localRenderBounds || this; }
3886
- get a() { return 1; }
3887
- get b() { return 0; }
3888
- get c() { return 0; }
3889
- get d() { return 1; }
3890
- get e() { return this.leaf.__.x; }
3891
- get f() { return this.leaf.__.y; }
3892
- get x() { return this.e + this.boxBounds.x; }
3893
- get y() { return this.f + this.boxBounds.y; }
3894
- get width() { return this.boxBounds.width; }
3895
- get height() { return this.boxBounds.height; }
3896
- constructor(leaf) {
3897
- this.leaf = leaf;
3898
- this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
3899
- if (this.leaf.__local)
3900
- this._localRenderBounds = this._localStrokeBounds = this.leaf.__local;
3901
- this.boxChange();
3902
- this.matrixChange();
3903
- }
3904
- createLocal() {
3905
- const local = this.leaf.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
3906
- if (!this._localStrokeBounds)
3907
- this._localStrokeBounds = local;
3908
- if (!this._localRenderBounds)
3909
- this._localRenderBounds = local;
3910
- }
3911
- update() {
3912
- const { leafer } = this.leaf;
3913
- if (leafer) {
3914
- if (leafer.ready) {
3915
- if (leafer.watcher.changed)
3916
- leafer.layouter.layout();
3921
+ const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3922
+ const matrix = {};
3923
+ const LeafHelper = {
3924
+ updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
3925
+ if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
3926
+ waitAutoLayout = true;
3927
+ updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
3928
+ if (leaf.isBranch) {
3929
+ const { children } = leaf;
3930
+ for (let i = 0, len = children.length; i < len; i++) {
3931
+ updateAllMatrix$3(children[i], checkAutoLayout, waitAutoLayout);
3917
3932
  }
3918
- else {
3919
- leafer.start();
3933
+ }
3934
+ },
3935
+ updateMatrix(leaf, checkAutoLayout, waitAutoLayout) {
3936
+ const layout = leaf.__layout;
3937
+ if (checkAutoLayout) {
3938
+ if (waitAutoLayout) {
3939
+ layout.waitAutoLayout = true;
3940
+ if (leaf.__hasAutoLayout)
3941
+ layout.matrixChanged = false;
3920
3942
  }
3921
3943
  }
3922
- else {
3923
- let root = this.leaf;
3924
- while (root.parent && !root.parent.leafer) {
3925
- root = root.parent;
3944
+ else if (layout.waitAutoLayout) {
3945
+ layout.waitAutoLayout = false;
3946
+ }
3947
+ if (layout.matrixChanged)
3948
+ leaf.__updateLocalMatrix();
3949
+ if (!layout.waitAutoLayout)
3950
+ leaf.__updateWorldMatrix();
3951
+ },
3952
+ updateBounds(leaf) {
3953
+ const layout = leaf.__layout;
3954
+ if (layout.boundsChanged)
3955
+ leaf.__updateLocalBounds();
3956
+ if (!layout.waitAutoLayout)
3957
+ leaf.__updateWorldBounds();
3958
+ },
3959
+ updateAllWorldOpacity(leaf) {
3960
+ leaf.__updateWorldOpacity();
3961
+ if (leaf.isBranch) {
3962
+ const { children } = leaf;
3963
+ for (let i = 0, len = children.length; i < len; i++) {
3964
+ updateAllWorldOpacity$1(children[i]);
3926
3965
  }
3927
- Platform.layout(root);
3928
3966
  }
3929
- }
3930
- getTransform(relative = 'world') {
3931
- this.update();
3932
- switch (relative) {
3933
- case 'world':
3934
- return this.leaf.__world;
3935
- case 'local':
3936
- return this.leaf.__localMatrix;
3937
- case 'inner':
3938
- return MatrixHelper.defaultMatrix;
3939
- default:
3940
- return new Matrix(this.leaf.__world).divideParent(relative.__world);
3967
+ },
3968
+ updateAllChange(leaf) {
3969
+ updateAllWorldOpacity$1(leaf);
3970
+ leaf.__updateChange();
3971
+ if (leaf.isBranch) {
3972
+ const { children } = leaf;
3973
+ for (let i = 0, len = children.length; i < len; i++) {
3974
+ updateAllChange$1(children[i]);
3975
+ }
3941
3976
  }
3942
- }
3943
- getBounds(type, relative = 'world') {
3944
- this.update();
3945
- switch (relative) {
3946
- case 'world':
3947
- return this.getWorldBounds(type);
3948
- case 'local':
3949
- return this.getLocalBounds(type);
3950
- case 'inner':
3951
- return this.getInnerBounds(type);
3952
- default:
3953
- return new Bounds(this.getInnerBounds(type)).toOuterOf(this.getTransform(relative));
3977
+ },
3978
+ worldHittable(t) {
3979
+ while (t) {
3980
+ if (!t.__.hittable)
3981
+ return false;
3982
+ t = t.parent;
3954
3983
  }
3955
- }
3956
- getInnerBounds(type = 'box') {
3957
- switch (type) {
3958
- case 'render':
3959
- return this.renderBounds;
3960
- case 'content':
3961
- if (this.contentBounds)
3962
- return this.contentBounds;
3963
- case 'margin':
3964
- case 'box':
3965
- return this.boxBounds;
3966
- case 'stroke':
3967
- return this.strokeBounds;
3984
+ return true;
3985
+ },
3986
+ moveWorld(t, x, y) {
3987
+ const local = { x, y };
3988
+ if (t.parent)
3989
+ toInnerPoint$1(t.parent.worldTransform, local, local, true);
3990
+ L.moveLocal(t, local.x, local.y);
3991
+ },
3992
+ moveLocal(t, x, y = 0) {
3993
+ t.x += x;
3994
+ t.y += y;
3995
+ },
3996
+ zoomOfWorld(t, origin, scaleX, scaleY, resize) {
3997
+ L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
3998
+ },
3999
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4000
+ copy$5(matrix, t.__localMatrix);
4001
+ scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4002
+ moveByMatrix(t, matrix);
4003
+ t.scaleResize(scaleX, scaleY, resize !== true);
4004
+ },
4005
+ rotateOfWorld(t, origin, angle) {
4006
+ L.rotateOfLocal(t, getTempLocal(t, origin), angle);
4007
+ },
4008
+ rotateOfLocal(t, origin, angle) {
4009
+ copy$5(matrix, t.__localMatrix);
4010
+ rotateOfOuter$3(matrix, origin, angle);
4011
+ moveByMatrix(t, matrix);
4012
+ t.rotation = MathHelper.formatRotation(t.rotation + angle);
4013
+ },
4014
+ skewOfWorld(t, origin, skewX, skewY, resize) {
4015
+ L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4016
+ },
4017
+ skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4018
+ copy$5(matrix, t.__localMatrix);
4019
+ skewOfOuter(matrix, origin, skewX, skewY);
4020
+ L.setTransform(t, matrix, resize);
4021
+ },
4022
+ transformWorld(t, transform, resize) {
4023
+ copy$5(matrix, t.worldTransform);
4024
+ multiplyParent$2(matrix, transform);
4025
+ if (t.parent)
4026
+ divideParent(matrix, t.parent.worldTransform);
4027
+ L.setTransform(t, matrix, resize);
4028
+ },
4029
+ transform(t, transform, resize) {
4030
+ copy$5(matrix, t.localTransform);
4031
+ multiplyParent$2(matrix, transform);
4032
+ L.setTransform(t, matrix, resize);
4033
+ },
4034
+ setTransform(t, transform, resize) {
4035
+ const layout = getLayout(transform);
4036
+ if (resize) {
4037
+ t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
4038
+ delete layout.scaleX;
4039
+ delete layout.scaleY;
3968
4040
  }
3969
- }
3970
- getLocalBounds(type = 'box') {
3971
- switch (type) {
3972
- case 'render':
3973
- return this.localRenderBounds;
3974
- case 'stroke':
3975
- return this.localStrokeBounds;
3976
- case 'margin':
3977
- case 'content':
3978
- case 'box':
3979
- return this.leaf.__localBoxBounds;
4041
+ t.set(layout);
4042
+ },
4043
+ getRelativeWorld(t, relative, temp) {
4044
+ copy$5(matrix, t.worldTransform);
4045
+ divideParent(matrix, relative.worldTransform);
4046
+ return temp ? matrix : Object.assign({}, matrix);
4047
+ },
4048
+ drop(t, parent, index, resize) {
4049
+ t.setTransform(L.getRelativeWorld(t, parent, true), resize);
4050
+ parent.add(t, index);
4051
+ },
4052
+ hasParent(p, parent) {
4053
+ if (!parent)
4054
+ return false;
4055
+ while (p) {
4056
+ if (parent === p)
4057
+ return true;
4058
+ p = p.parent;
3980
4059
  }
3981
- }
3982
- getWorldBounds(type = 'box') {
3983
- switch (type) {
3984
- case 'render':
3985
- return this.leaf.__world;
3986
- case 'content':
3987
- if (this.contentBounds)
3988
- return this.getWorldContentBounds();
3989
- case 'margin':
3990
- case 'box':
3991
- return this.getWorldBoxBounds();
3992
- case 'margin':
3993
- case 'stroke':
3994
- return this.getWorldStrokeBounds();
4060
+ },
4061
+ hasParentAutoLayout(p) {
4062
+ while (p.parent) {
4063
+ p = p.parent;
4064
+ if (p.__hasAutoLayout)
4065
+ return true;
3995
4066
  }
3996
4067
  }
3997
- getLayoutBounds(type, relative = 'world', unscale) {
3998
- const { leaf } = this;
3999
- let point, matrix, bounds = this.getInnerBounds(type);
4000
- switch (relative) {
4001
- case 'world':
4002
- point = leaf.getWorldPoint(bounds);
4003
- matrix = leaf.__world;
4068
+ };
4069
+ const L = LeafHelper;
4070
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4071
+ function moveByMatrix(t, matrix) {
4072
+ const { e, f } = t.__localMatrix;
4073
+ t.x += matrix.e - e;
4074
+ t.y += matrix.f - f;
4075
+ }
4076
+ function getTempLocal(t, world) {
4077
+ t.__layout.update();
4078
+ return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
4079
+ }
4080
+
4081
+ const LeafBoundsHelper = {
4082
+ worldBounds(target) {
4083
+ return target.__world;
4084
+ },
4085
+ localBoxBounds(target) {
4086
+ return target.__.eraser ? null : (target.__local || target.__layout);
4087
+ },
4088
+ localStrokeBounds(target) {
4089
+ return target.__.eraser ? null : target.__layout.localStrokeBounds;
4090
+ },
4091
+ localRenderBounds(target) {
4092
+ return target.__.eraser ? null : target.__layout.localRenderBounds;
4093
+ },
4094
+ maskLocalBoxBounds(target) {
4095
+ return target.__.mask ? target.__localBoxBounds : null;
4096
+ },
4097
+ maskLocalStrokeBounds(target) {
4098
+ return target.__.mask ? target.__layout.localStrokeBounds : null;
4099
+ },
4100
+ maskLocalRenderBounds(target) {
4101
+ return target.__.mask ? target.__layout.localRenderBounds : null;
4102
+ },
4103
+ excludeRenderBounds(child, options) {
4104
+ if (options.bounds && !options.bounds.hit(child.__world, options.matrix))
4105
+ return true;
4106
+ if (options.hideBounds && options.hideBounds.includes(child.__world, options.matrix))
4107
+ return true;
4108
+ return false;
4109
+ }
4110
+ };
4111
+
4112
+ const { updateBounds: updateBounds$2 } = LeafHelper;
4113
+ const BranchHelper = {
4114
+ sort(a, b) {
4115
+ return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
4116
+ },
4117
+ pushAllChildBranch(branch, leafList) {
4118
+ branch.__tempNumber = 1;
4119
+ if (branch.__.__childBranchNumber) {
4120
+ const { children } = branch;
4121
+ for (let i = 0, len = children.length; i < len; i++) {
4122
+ branch = children[i];
4123
+ if (branch.isBranch) {
4124
+ branch.__tempNumber = 1;
4125
+ leafList.add(branch);
4126
+ pushAllChildBranch$1(branch, leafList);
4127
+ }
4128
+ }
4129
+ }
4130
+ },
4131
+ pushAllParent(leaf, leafList) {
4132
+ const { keys } = leafList;
4133
+ if (keys) {
4134
+ while (leaf.parent) {
4135
+ if (keys[leaf.parent.innerId] === undefined) {
4136
+ leafList.add(leaf.parent);
4137
+ leaf = leaf.parent;
4138
+ }
4139
+ else {
4140
+ break;
4141
+ }
4142
+ }
4143
+ }
4144
+ else {
4145
+ while (leaf.parent) {
4146
+ leafList.add(leaf.parent);
4147
+ leaf = leaf.parent;
4148
+ }
4149
+ }
4150
+ },
4151
+ pushAllBranchStack(branch, pushList) {
4152
+ let start = pushList.length;
4153
+ const { children } = branch;
4154
+ for (let i = 0, len = children.length; i < len; i++) {
4155
+ if (children[i].isBranch) {
4156
+ pushList.push(children[i]);
4157
+ }
4158
+ }
4159
+ for (let i = start, len = pushList.length; i < len; i++) {
4160
+ pushAllBranchStack(pushList[i], pushList);
4161
+ }
4162
+ },
4163
+ updateBounds(branch, exclude) {
4164
+ const branchStack = [branch];
4165
+ pushAllBranchStack(branch, branchStack);
4166
+ updateBoundsByBranchStack(branchStack, exclude);
4167
+ },
4168
+ updateBoundsByBranchStack(branchStack, exclude) {
4169
+ let branch, children;
4170
+ for (let i = branchStack.length - 1; i > -1; i--) {
4171
+ branch = branchStack[i];
4172
+ children = branch.children;
4173
+ for (let j = 0, len = children.length; j < len; j++) {
4174
+ updateBounds$2(children[j]);
4175
+ }
4176
+ if (exclude && exclude === branch)
4177
+ continue;
4178
+ updateBounds$2(branch);
4179
+ }
4180
+ }
4181
+ };
4182
+ const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack, updateBoundsByBranchStack } = BranchHelper;
4183
+
4184
+ const WaitHelper = {
4185
+ run(wait) {
4186
+ if (wait.length) {
4187
+ const len = wait.length;
4188
+ for (let i = 0; i < len; i++) {
4189
+ wait[i]();
4190
+ }
4191
+ wait.length === len ? wait.length = 0 : wait.splice(0, len);
4192
+ }
4193
+ }
4194
+ };
4195
+
4196
+ const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4197
+ const { toOuterOf: toOuterOf$2, getPoints, copy: copy$4 } = BoundsHelper;
4198
+ class LeafLayout {
4199
+ get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4200
+ get renderBounds() { return this._renderBounds || this.boxBounds; }
4201
+ get localStrokeBounds() { return this._localStrokeBounds || this; }
4202
+ get localRenderBounds() { return this._localRenderBounds || this; }
4203
+ get a() { return 1; }
4204
+ get b() { return 0; }
4205
+ get c() { return 0; }
4206
+ get d() { return 1; }
4207
+ get e() { return this.leaf.__.x; }
4208
+ get f() { return this.leaf.__.y; }
4209
+ get x() { return this.e + this.boxBounds.x; }
4210
+ get y() { return this.f + this.boxBounds.y; }
4211
+ get width() { return this.boxBounds.width; }
4212
+ get height() { return this.boxBounds.height; }
4213
+ constructor(leaf) {
4214
+ this.leaf = leaf;
4215
+ this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
4216
+ if (this.leaf.__local)
4217
+ this._localRenderBounds = this._localStrokeBounds = this.leaf.__local;
4218
+ this.boxChange();
4219
+ this.matrixChange();
4220
+ }
4221
+ createLocal() {
4222
+ const local = this.leaf.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
4223
+ if (!this._localStrokeBounds)
4224
+ this._localStrokeBounds = local;
4225
+ if (!this._localRenderBounds)
4226
+ this._localRenderBounds = local;
4227
+ }
4228
+ update() {
4229
+ const { leafer } = this.leaf;
4230
+ if (leafer) {
4231
+ if (leafer.ready) {
4232
+ if (leafer.watcher.changed)
4233
+ leafer.layouter.layout();
4234
+ }
4235
+ else {
4236
+ leafer.start();
4237
+ }
4238
+ }
4239
+ else {
4240
+ let root = this.leaf;
4241
+ while (root.parent && !root.parent.leafer) {
4242
+ root = root.parent;
4243
+ }
4244
+ Platform.layout(root);
4245
+ }
4246
+ }
4247
+ getTransform(relative = 'world') {
4248
+ this.update();
4249
+ const { leaf } = this;
4250
+ switch (relative) {
4251
+ case 'world':
4252
+ return leaf.__world;
4253
+ case 'local':
4254
+ return leaf.__localMatrix;
4255
+ case 'inner':
4256
+ return MatrixHelper.defaultMatrix;
4257
+ case 'page':
4258
+ relative = leaf.zoomLayer;
4259
+ default:
4260
+ return getRelativeWorld$1(leaf, relative);
4261
+ }
4262
+ }
4263
+ getBounds(type, relative = 'world') {
4264
+ this.update();
4265
+ switch (relative) {
4266
+ case 'world':
4267
+ return this.getWorldBounds(type);
4268
+ case 'local':
4269
+ return this.getLocalBounds(type);
4270
+ case 'inner':
4271
+ return this.getInnerBounds(type);
4272
+ case 'page':
4273
+ relative = this.leaf.zoomLayer;
4274
+ default:
4275
+ return new Bounds(this.getInnerBounds(type)).toOuterOf(this.getTransform(relative));
4276
+ }
4277
+ }
4278
+ getInnerBounds(type = 'box') {
4279
+ switch (type) {
4280
+ case 'render':
4281
+ return this.renderBounds;
4282
+ case 'content':
4283
+ if (this.contentBounds)
4284
+ return this.contentBounds;
4285
+ case 'margin':
4286
+ case 'box':
4287
+ return this.boxBounds;
4288
+ case 'stroke':
4289
+ return this.strokeBounds;
4290
+ }
4291
+ }
4292
+ getLocalBounds(type = 'box') {
4293
+ switch (type) {
4294
+ case 'render':
4295
+ return this.localRenderBounds;
4296
+ case 'stroke':
4297
+ return this.localStrokeBounds;
4298
+ case 'margin':
4299
+ case 'content':
4300
+ case 'box':
4301
+ return this.leaf.__localBoxBounds;
4302
+ }
4303
+ }
4304
+ getWorldBounds(type = 'box') {
4305
+ switch (type) {
4306
+ case 'render':
4307
+ return this.leaf.__world;
4308
+ case 'content':
4309
+ if (this.contentBounds)
4310
+ return this.getWorldContentBounds();
4311
+ case 'margin':
4312
+ case 'box':
4313
+ return this.getWorldBoxBounds();
4314
+ case 'margin':
4315
+ case 'stroke':
4316
+ return this.getWorldStrokeBounds();
4317
+ }
4318
+ }
4319
+ getLayoutBounds(type, relative = 'world', unscale) {
4320
+ const { leaf } = this;
4321
+ let point, matrix, bounds = this.getInnerBounds(type);
4322
+ switch (relative) {
4323
+ case 'world':
4324
+ point = leaf.getWorldPoint(bounds);
4325
+ matrix = leaf.__world;
4004
4326
  break;
4005
4327
  case 'local':
4006
4328
  point = leaf.getLocalPointByInner(bounds);
@@ -4010,12 +4332,14 @@ class LeafLayout {
4010
4332
  point = bounds;
4011
4333
  matrix = MatrixHelper.defaultMatrix;
4012
4334
  break;
4335
+ case 'page':
4336
+ relative = leaf.zoomLayer;
4013
4337
  default:
4014
4338
  point = leaf.getWorldPoint(bounds, relative);
4015
- matrix = tempMatrix.set(leaf.__world).divideParent(relative.__world);
4339
+ matrix = getRelativeWorld$1(leaf, relative, true);
4016
4340
  }
4017
4341
  const layoutBounds = MatrixHelper.getLayout(matrix);
4018
- copy$5(layoutBounds, bounds);
4342
+ copy$4(layoutBounds, bounds);
4019
4343
  PointHelper.copy(layoutBounds, point);
4020
4344
  if (unscale) {
4021
4345
  const { scaleX, scaleY } = layoutBounds;
@@ -4043,6 +4367,8 @@ class LeafLayout {
4043
4367
  break;
4044
4368
  case 'inner':
4045
4369
  break;
4370
+ case 'page':
4371
+ relative = leaf.zoomLayer;
4046
4372
  default:
4047
4373
  relativeLeaf = relative;
4048
4374
  }
@@ -4378,363 +4704,91 @@ AnimateEvent.FRAME = 'animate.frame';
4378
4704
  class RenderEvent extends Event {
4379
4705
  constructor(type, times, bounds, options) {
4380
4706
  super(type);
4381
- if (times)
4382
- this.times = times;
4383
- if (bounds) {
4384
- this.renderBounds = bounds;
4385
- this.renderOptions = options;
4386
- }
4387
- }
4388
- }
4389
- RenderEvent.REQUEST = 'render.request';
4390
- RenderEvent.START = 'render.start';
4391
- RenderEvent.BEFORE = 'render.before';
4392
- RenderEvent.RENDER = 'render';
4393
- RenderEvent.AFTER = 'render.after';
4394
- RenderEvent.AGAIN = 'render.again';
4395
- RenderEvent.END = 'render.end';
4396
- RenderEvent.NEXT = 'render.next';
4397
-
4398
- class LeaferEvent extends Event {
4399
- }
4400
- LeaferEvent.START = 'leafer.start';
4401
- LeaferEvent.BEFORE_READY = 'leafer.before_ready';
4402
- LeaferEvent.READY = 'leafer.ready';
4403
- LeaferEvent.AFTER_READY = 'leafer.after_ready';
4404
- LeaferEvent.VIEW_READY = 'leafer.view_ready';
4405
- LeaferEvent.VIEW_COMPLETED = 'leafer.view_completed';
4406
- LeaferEvent.STOP = 'leafer.stop';
4407
- LeaferEvent.RESTART = 'leafer.restart';
4408
- LeaferEvent.END = 'leafer.end';
4409
-
4410
- const LeafDataProxy = {
4411
- __setAttr(name, newValue) {
4412
- if (this.leafer && this.leafer.created) {
4413
- const oldValue = this.__.__getInput(name);
4414
- if (typeof newValue === 'object' || oldValue !== newValue) {
4415
- this.__[name] = newValue;
4416
- if (this.__proxyData)
4417
- this.setProxyAttr(name, newValue);
4418
- const { CHANGE } = PropertyEvent;
4419
- const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
4420
- if (this.isLeafer) {
4421
- this.emitEvent(new PropertyEvent(PropertyEvent.LEAFER_CHANGE, this, name, oldValue, newValue));
4422
- }
4423
- else {
4424
- if (this.hasEvent(CHANGE))
4425
- this.emitEvent(event);
4426
- }
4427
- this.leafer.emitEvent(event);
4428
- }
4429
- }
4430
- else {
4431
- this.__[name] = newValue;
4432
- if (this.__proxyData)
4433
- this.setProxyAttr(name, newValue);
4434
- }
4435
- },
4436
- __getAttr(name) {
4437
- if (this.__proxyData)
4438
- return this.getProxyAttr(name);
4439
- return this.__.__get(name);
4440
- }
4441
- };
4442
-
4443
- const { setLayout, multiplyParent: multiplyParent$2, translateInner, defaultWorld } = MatrixHelper;
4444
- const { toPoint, tempPoint } = AroundHelper;
4445
- const LeafMatrix = {
4446
- __updateWorldMatrix() {
4447
- multiplyParent$2(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
4448
- },
4449
- __updateLocalMatrix() {
4450
- if (this.__local) {
4451
- const layout = this.__layout, local = this.__local, data = this.__;
4452
- if (layout.affectScaleOrRotation) {
4453
- if (layout.scaleChanged || layout.rotationChanged) {
4454
- setLayout(local, data, null, layout.affectRotation);
4455
- layout.scaleChanged = layout.rotationChanged = false;
4456
- }
4457
- }
4458
- local.e = data.x;
4459
- local.f = data.y;
4460
- if (data.around) {
4461
- toPoint(data.around, layout.boxBounds, tempPoint);
4462
- translateInner(local, -tempPoint.x, -tempPoint.y);
4463
- }
4464
- }
4465
- this.__layout.matrixChanged = false;
4466
- }
4467
- };
4468
-
4469
- const { copy: copy$4, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$1, divideParent, getLayout } = MatrixHelper;
4470
- const matrix = {};
4471
- const LeafHelper = {
4472
- updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4473
- if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
4474
- waitAutoLayout = true;
4475
- updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4476
- if (leaf.isBranch) {
4477
- const { children } = leaf;
4478
- for (let i = 0, len = children.length; i < len; i++) {
4479
- updateAllMatrix$3(children[i], checkAutoLayout, waitAutoLayout);
4480
- }
4481
- }
4482
- },
4483
- updateMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4484
- const layout = leaf.__layout;
4485
- if (checkAutoLayout) {
4486
- if (waitAutoLayout) {
4487
- layout.waitAutoLayout = true;
4488
- if (leaf.__hasAutoLayout)
4489
- layout.matrixChanged = false;
4490
- }
4491
- }
4492
- else if (layout.waitAutoLayout) {
4493
- layout.waitAutoLayout = false;
4494
- }
4495
- if (layout.matrixChanged)
4496
- leaf.__updateLocalMatrix();
4497
- if (!layout.waitAutoLayout)
4498
- leaf.__updateWorldMatrix();
4499
- },
4500
- updateBounds(leaf) {
4501
- const layout = leaf.__layout;
4502
- if (layout.boundsChanged)
4503
- leaf.__updateLocalBounds();
4504
- if (!layout.waitAutoLayout)
4505
- leaf.__updateWorldBounds();
4506
- },
4507
- updateAllWorldOpacity(leaf) {
4508
- leaf.__updateWorldOpacity();
4509
- if (leaf.isBranch) {
4510
- const { children } = leaf;
4511
- for (let i = 0, len = children.length; i < len; i++) {
4512
- updateAllWorldOpacity$1(children[i]);
4513
- }
4514
- }
4515
- },
4516
- updateAllChange(leaf) {
4517
- updateAllWorldOpacity$1(leaf);
4518
- leaf.__updateChange();
4519
- if (leaf.isBranch) {
4520
- const { children } = leaf;
4521
- for (let i = 0, len = children.length; i < len; i++) {
4522
- updateAllChange$1(children[i]);
4523
- }
4524
- }
4525
- },
4526
- worldHittable(t) {
4527
- while (t) {
4528
- if (!t.__.hittable)
4529
- return false;
4530
- t = t.parent;
4531
- }
4532
- return true;
4533
- },
4534
- moveWorld(t, x, y) {
4535
- const local = { x, y };
4536
- if (t.parent)
4537
- toInnerPoint$1(t.parent.worldTransform, local, local, true);
4538
- L.moveLocal(t, local.x, local.y);
4539
- },
4540
- moveLocal(t, x, y = 0) {
4541
- t.x += x;
4542
- t.y += y;
4543
- },
4544
- zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4545
- L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
4546
- },
4547
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4548
- copy$4(matrix, t.__localMatrix);
4549
- scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4550
- moveByMatrix(t, matrix);
4551
- t.scaleResize(scaleX, scaleY, resize !== true);
4552
- },
4553
- rotateOfWorld(t, origin, angle) {
4554
- L.rotateOfLocal(t, getTempLocal(t, origin), angle);
4555
- },
4556
- rotateOfLocal(t, origin, angle) {
4557
- copy$4(matrix, t.__localMatrix);
4558
- rotateOfOuter$3(matrix, origin, angle);
4559
- moveByMatrix(t, matrix);
4560
- t.rotation = MathHelper.formatRotation(t.rotation + angle);
4561
- },
4562
- skewOfWorld(t, origin, skewX, skewY, resize) {
4563
- L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4564
- },
4565
- skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4566
- copy$4(matrix, t.__localMatrix);
4567
- skewOfOuter(matrix, origin, skewX, skewY);
4568
- L.setTransform(t, matrix, resize);
4569
- },
4570
- transformWorld(t, transform, resize) {
4571
- copy$4(matrix, t.worldTransform);
4572
- multiplyParent$1(matrix, transform);
4573
- if (t.parent)
4574
- divideParent(matrix, t.parent.worldTransform);
4575
- L.setTransform(t, matrix, resize);
4576
- },
4577
- transform(t, transform, resize) {
4578
- copy$4(matrix, t.localTransform);
4579
- multiplyParent$1(matrix, transform);
4580
- L.setTransform(t, matrix, resize);
4581
- },
4582
- setTransform(t, transform, resize) {
4583
- const layout = getLayout(transform);
4584
- if (resize) {
4585
- t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
4586
- delete layout.scaleX;
4587
- delete layout.scaleY;
4588
- }
4589
- t.set(layout);
4590
- },
4591
- drop(t, parent, index, resize) {
4592
- copy$4(matrix, t.worldTransform);
4593
- divideParent(matrix, parent.worldTransform);
4594
- t.setTransform(matrix, resize);
4595
- parent.add(t, index);
4596
- },
4597
- hasParent(p, parent) {
4598
- if (!parent)
4599
- return false;
4600
- while (p) {
4601
- if (parent === p)
4602
- return true;
4603
- p = p.parent;
4604
- }
4605
- },
4606
- hasParentAutoLayout(p) {
4607
- while (p.parent) {
4608
- p = p.parent;
4609
- if (p.__hasAutoLayout)
4610
- return true;
4707
+ if (times)
4708
+ this.times = times;
4709
+ if (bounds) {
4710
+ this.renderBounds = bounds;
4711
+ this.renderOptions = options;
4611
4712
  }
4612
4713
  }
4613
- };
4614
- const L = LeafHelper;
4615
- const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4616
- function moveByMatrix(t, matrix) {
4617
- const { e, f } = t.__localMatrix;
4618
- t.x += matrix.e - e;
4619
- t.y += matrix.f - f;
4620
- }
4621
- function getTempLocal(t, world) {
4622
- t.__layout.update();
4623
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
4624
4714
  }
4715
+ RenderEvent.REQUEST = 'render.request';
4716
+ RenderEvent.START = 'render.start';
4717
+ RenderEvent.BEFORE = 'render.before';
4718
+ RenderEvent.RENDER = 'render';
4719
+ RenderEvent.AFTER = 'render.after';
4720
+ RenderEvent.AGAIN = 'render.again';
4721
+ RenderEvent.END = 'render.end';
4722
+ RenderEvent.NEXT = 'render.next';
4625
4723
 
4626
- const LeafBoundsHelper = {
4627
- worldBounds(target) {
4628
- return target.__world;
4629
- },
4630
- localBoxBounds(target) {
4631
- return target.__.eraser ? null : (target.__local || target.__layout);
4632
- },
4633
- localStrokeBounds(target) {
4634
- return target.__.eraser ? null : target.__layout.localStrokeBounds;
4635
- },
4636
- localRenderBounds(target) {
4637
- return target.__.eraser ? null : target.__layout.localRenderBounds;
4638
- },
4639
- maskLocalBoxBounds(target) {
4640
- return target.__.mask ? target.__localBoxBounds : null;
4641
- },
4642
- maskLocalStrokeBounds(target) {
4643
- return target.__.mask ? target.__layout.localStrokeBounds : null;
4644
- },
4645
- maskLocalRenderBounds(target) {
4646
- return target.__.mask ? target.__layout.localRenderBounds : null;
4647
- },
4648
- excludeRenderBounds(child, options) {
4649
- if (options.bounds && !options.bounds.hit(child.__world, options.matrix))
4650
- return true;
4651
- if (options.hideBounds && options.hideBounds.includes(child.__world, options.matrix))
4652
- return true;
4653
- return false;
4654
- }
4655
- };
4724
+ class LeaferEvent extends Event {
4725
+ }
4726
+ LeaferEvent.START = 'leafer.start';
4727
+ LeaferEvent.BEFORE_READY = 'leafer.before_ready';
4728
+ LeaferEvent.READY = 'leafer.ready';
4729
+ LeaferEvent.AFTER_READY = 'leafer.after_ready';
4730
+ LeaferEvent.VIEW_READY = 'leafer.view_ready';
4731
+ LeaferEvent.VIEW_COMPLETED = 'leafer.view_completed';
4732
+ LeaferEvent.STOP = 'leafer.stop';
4733
+ LeaferEvent.RESTART = 'leafer.restart';
4734
+ LeaferEvent.END = 'leafer.end';
4656
4735
 
4657
- const { updateBounds: updateBounds$2 } = LeafHelper;
4658
- const BranchHelper = {
4659
- sort(a, b) {
4660
- return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
4661
- },
4662
- pushAllChildBranch(branch, leafList) {
4663
- branch.__tempNumber = 1;
4664
- if (branch.__.__childBranchNumber) {
4665
- const { children } = branch;
4666
- for (let i = 0, len = children.length; i < len; i++) {
4667
- branch = children[i];
4668
- if (branch.isBranch) {
4669
- branch.__tempNumber = 1;
4670
- leafList.add(branch);
4671
- pushAllChildBranch$1(branch, leafList);
4672
- }
4673
- }
4674
- }
4675
- },
4676
- pushAllParent(leaf, leafList) {
4677
- const { keys } = leafList;
4678
- if (keys) {
4679
- while (leaf.parent) {
4680
- if (keys[leaf.parent.innerId] === undefined) {
4681
- leafList.add(leaf.parent);
4682
- leaf = leaf.parent;
4736
+ const LeafDataProxy = {
4737
+ __setAttr(name, newValue) {
4738
+ if (this.leafer && this.leafer.created) {
4739
+ const oldValue = this.__.__getInput(name);
4740
+ if (typeof newValue === 'object' || oldValue !== newValue) {
4741
+ this.__[name] = newValue;
4742
+ if (this.__proxyData)
4743
+ this.setProxyAttr(name, newValue);
4744
+ const { CHANGE } = PropertyEvent;
4745
+ const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
4746
+ if (this.isLeafer) {
4747
+ this.emitEvent(new PropertyEvent(PropertyEvent.LEAFER_CHANGE, this, name, oldValue, newValue));
4683
4748
  }
4684
4749
  else {
4685
- break;
4750
+ if (this.hasEvent(CHANGE))
4751
+ this.emitEvent(event);
4686
4752
  }
4753
+ this.leafer.emitEvent(event);
4687
4754
  }
4688
4755
  }
4689
4756
  else {
4690
- while (leaf.parent) {
4691
- leafList.add(leaf.parent);
4692
- leaf = leaf.parent;
4693
- }
4694
- }
4695
- },
4696
- pushAllBranchStack(branch, pushList) {
4697
- let start = pushList.length;
4698
- const { children } = branch;
4699
- for (let i = 0, len = children.length; i < len; i++) {
4700
- if (children[i].isBranch) {
4701
- pushList.push(children[i]);
4702
- }
4703
- }
4704
- for (let i = start, len = pushList.length; i < len; i++) {
4705
- pushAllBranchStack(pushList[i], pushList);
4757
+ this.__[name] = newValue;
4758
+ if (this.__proxyData)
4759
+ this.setProxyAttr(name, newValue);
4706
4760
  }
4707
4761
  },
4708
- updateBounds(branch, exclude) {
4709
- const branchStack = [branch];
4710
- pushAllBranchStack(branch, branchStack);
4711
- updateBoundsByBranchStack(branchStack, exclude);
4712
- },
4713
- updateBoundsByBranchStack(branchStack, exclude) {
4714
- let branch, children;
4715
- for (let i = branchStack.length - 1; i > -1; i--) {
4716
- branch = branchStack[i];
4717
- children = branch.children;
4718
- for (let j = 0, len = children.length; j < len; j++) {
4719
- updateBounds$2(children[j]);
4720
- }
4721
- if (exclude && exclude === branch)
4722
- continue;
4723
- updateBounds$2(branch);
4724
- }
4762
+ __getAttr(name) {
4763
+ if (this.__proxyData)
4764
+ return this.getProxyAttr(name);
4765
+ return this.__.__get(name);
4725
4766
  }
4726
4767
  };
4727
- const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack, updateBoundsByBranchStack } = BranchHelper;
4728
4768
 
4729
- const WaitHelper = {
4730
- run(wait) {
4731
- if (wait.length) {
4732
- const len = wait.length;
4733
- for (let i = 0; i < len; i++) {
4734
- wait[i]();
4769
+ const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4770
+ const { toPoint, tempPoint } = AroundHelper;
4771
+ const LeafMatrix = {
4772
+ __updateWorldMatrix() {
4773
+ multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
4774
+ },
4775
+ __updateLocalMatrix() {
4776
+ if (this.__local) {
4777
+ const layout = this.__layout, local = this.__local, data = this.__;
4778
+ if (layout.affectScaleOrRotation) {
4779
+ if (layout.scaleChanged || layout.rotationChanged) {
4780
+ setLayout(local, data, null, layout.affectRotation);
4781
+ layout.scaleChanged = layout.rotationChanged = false;
4782
+ }
4783
+ }
4784
+ local.e = data.x;
4785
+ local.f = data.y;
4786
+ if (data.around) {
4787
+ toPoint(data.around, layout.boxBounds, tempPoint);
4788
+ translateInner(local, -tempPoint.x, -tempPoint.y);
4735
4789
  }
4736
- wait.length === len ? wait.length = 0 : wait.splice(0, len);
4737
4790
  }
4791
+ this.__layout.matrixChanged = false;
4738
4792
  }
4739
4793
  };
4740
4794
 
@@ -4951,7 +5005,7 @@ const { LEAF, create } = IncrementId;
4951
5005
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
4952
5006
  const { toOuterOf } = BoundsHelper;
4953
5007
  const { tempToOuterOf, copy: copy$3 } = PointHelper;
4954
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, transform, setTransform, drop } = LeafHelper;
5008
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getRelativeWorld, drop } = LeafHelper;
4955
5009
  let Leaf = class Leaf {
4956
5010
  get tag() { return this.__tag; }
4957
5011
  set tag(_value) { }
@@ -4989,21 +5043,31 @@ let Leaf = class Leaf {
4989
5043
  this.__layout = new this.__LayoutProcessor(this);
4990
5044
  if (this.__level)
4991
5045
  this.resetCustom();
4992
- if (data)
5046
+ if (data) {
5047
+ if (data.__)
5048
+ data = data.toJSON();
4993
5049
  data.children ? this.set(data) : Object.assign(this, data);
5050
+ }
4994
5051
  }
4995
5052
  resetCustom() {
4996
5053
  this.__hasMask = this.__hasEraser = null;
4997
5054
  this.forceUpdate();
4998
5055
  }
4999
- waitParent(item) {
5056
+ waitParent(item, bind) {
5057
+ if (bind)
5058
+ item = item.bind(bind);
5000
5059
  this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]);
5001
5060
  }
5002
- waitLeafer(item) {
5061
+ waitLeafer(item, bind) {
5062
+ if (bind)
5063
+ item = item.bind(bind);
5003
5064
  this.leafer ? item() : (this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item]);
5004
5065
  }
5005
- nextRender(item, off) {
5006
- this.leafer ? this.leafer.nextRender(item, off) : this.waitLeafer(() => this.leafer.nextRender(item, off));
5066
+ nextRender(item, bind, off) {
5067
+ this.leafer ? this.leafer.nextRender(item, bind, off) : this.waitLeafer(() => this.leafer.nextRender(item, bind, off));
5068
+ }
5069
+ removeNextRender(item) {
5070
+ this.nextRender(item, null, 'off');
5007
5071
  }
5008
5072
  __bindLeafer(leafer) {
5009
5073
  if (this.isLeafer) {
@@ -5040,6 +5104,7 @@ let Leaf = class Leaf {
5040
5104
  getProxyAttr(_attrName) { return undefined; }
5041
5105
  find(_condition, _options) { return undefined; }
5042
5106
  findOne(_condition, _options) { return undefined; }
5107
+ focus(_value) { }
5043
5108
  forceUpdate(attrName) {
5044
5109
  if (attrName === undefined)
5045
5110
  attrName = 'width';
@@ -5095,6 +5160,9 @@ let Leaf = class Leaf {
5095
5160
  return this.__world.f;
5096
5161
  return this.getLayoutBounds()[attrName];
5097
5162
  }
5163
+ getTransform(relative) {
5164
+ return this.__layout.getTransform(relative || 'local');
5165
+ }
5098
5166
  getBounds(type, relative) {
5099
5167
  return this.__layout.getBounds(type, relative);
5100
5168
  }
@@ -5104,6 +5172,12 @@ let Leaf = class Leaf {
5104
5172
  getLayoutPoints(type, relative) {
5105
5173
  return this.__layout.getLayoutPoints(type, relative);
5106
5174
  }
5175
+ getWorldBounds(inner, relative, change) {
5176
+ const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
5177
+ const to = change ? inner : {};
5178
+ toOuterOf(inner, matrix, to);
5179
+ return to;
5180
+ }
5107
5181
  worldToLocal(world, to, distance, relative) {
5108
5182
  if (this.parent) {
5109
5183
  this.parent.worldToInner(world, to, distance, relative);
@@ -5186,6 +5260,21 @@ let Leaf = class Leaf {
5186
5260
  skewOf(origin, skewX, skewY, resize) {
5187
5261
  skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
5188
5262
  }
5263
+ transformWorld(worldTransform, resize) {
5264
+ transformWorld(this, worldTransform, resize);
5265
+ }
5266
+ moveWorld(x, y) {
5267
+ moveWorld(this, x, y);
5268
+ }
5269
+ scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5270
+ zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
5271
+ }
5272
+ rotateOfWorld(worldOrigin, rotation) {
5273
+ rotateOfWorld(this, worldOrigin, rotation);
5274
+ }
5275
+ skewOfWorld(worldOrigin, skewX, skewY, resize) {
5276
+ skewOfWorld(this, worldOrigin, skewX, skewY, resize);
5277
+ }
5189
5278
  scaleResize(scaleX, scaleY = scaleX, _noResize) {
5190
5279
  this.scaleX *= scaleX;
5191
5280
  this.scaleY *= scaleY;
@@ -5317,7 +5406,8 @@ let Branch = class Branch extends Leaf {
5317
5406
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
5318
5407
  if (child.isBranch)
5319
5408
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5320
- child.__layout.boundsChanged || child.__layout.matrixChange();
5409
+ child.__layout.boxChanged || child.__layout.boxChange();
5410
+ child.__layout.matrixChanged || child.__layout.matrixChange();
5321
5411
  if (child.__parentWait)
5322
5412
  WaitHelper.run(child.__parentWait);
5323
5413
  if (this.leafer) {
@@ -6048,6 +6138,10 @@ class Renderer {
6048
6138
  }
6049
6139
  else {
6050
6140
  this.requestLayout();
6141
+ if (this.ignore) {
6142
+ this.ignore = this.rendering = false;
6143
+ return;
6144
+ }
6051
6145
  this.emitRender(RenderEvent.BEFORE);
6052
6146
  if (this.config.usePartRender && this.totalTimes > 1) {
6053
6147
  this.partRender();
@@ -6195,9 +6289,7 @@ class Renderer {
6195
6289
  if (this.target) {
6196
6290
  this.stop();
6197
6291
  this.__removeListenEvents();
6198
- this.target = null;
6199
- this.canvas = null;
6200
- this.config = null;
6292
+ this.target = this.canvas = this.config = null;
6201
6293
  }
6202
6294
  }
6203
6295
  }
@@ -6211,14 +6303,36 @@ Object.assign(Creator, {
6211
6303
  });
6212
6304
  Platform.layout = Layouter.fullLayout;
6213
6305
 
6306
+ const TextConvert = {};
6307
+ const ColorConvert = {};
6308
+ const PathArrow = {};
6309
+ const Paint = {};
6310
+ const PaintImage = {};
6311
+ const PaintGradient = {};
6312
+ const Effect = {};
6313
+ const Export = {};
6314
+ const State = {};
6315
+
6316
+ function stateType(defaultValue) {
6317
+ return (target, key) => {
6318
+ const stateType = key + 'Style';
6319
+ defineLeafAttr(target, key, defaultValue, {
6320
+ set(value) {
6321
+ this.__setAttr(key, value);
6322
+ this.waitLeafer(() => { if (State.setStyle)
6323
+ State.setStyle(this, stateType, value); });
6324
+ }
6325
+ });
6326
+ };
6327
+ }
6214
6328
  function arrowType(defaultValue) {
6215
6329
  return (target, key) => {
6216
6330
  defineLeafAttr(target, key, defaultValue, {
6217
6331
  set(value) {
6218
6332
  this.__setAttr(key, value);
6219
- doStrokeType(this);
6220
6333
  const data = this.__;
6221
6334
  data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6335
+ doStrokeType(this);
6222
6336
  }
6223
6337
  });
6224
6338
  };
@@ -6246,15 +6360,16 @@ function resizeType(defaultValue) {
6246
6360
  });
6247
6361
  };
6248
6362
  }
6249
-
6250
- const TextConvert = {};
6251
- const ColorConvert = {};
6252
- const PathArrow = {};
6253
- const Paint = {};
6254
- const PaintImage = {};
6255
- const PaintGradient = {};
6256
- const Effect = {};
6257
- const Export = {};
6363
+ function zoomLayerType() {
6364
+ return (target, key) => {
6365
+ const privateKey = '_' + key;
6366
+ defineKey(target, key, {
6367
+ set(value) { if (this.isLeafer)
6368
+ this[privateKey] = value; },
6369
+ get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6370
+ });
6371
+ };
6372
+ }
6258
6373
 
6259
6374
  const { parse } = PathConvert;
6260
6375
  const emptyPaint = {};
@@ -6263,7 +6378,7 @@ class UIData extends LeafData {
6263
6378
  get __strokeWidth() {
6264
6379
  const { strokeWidth, strokeWidthFixed } = this;
6265
6380
  if (strokeWidthFixed) {
6266
- let { scaleX } = this.__leaf.__world;
6381
+ let { scaleX } = this.__leaf.__nowWorld;
6267
6382
  if (scaleX < 0)
6268
6383
  scaleX = -scaleX;
6269
6384
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
@@ -6537,18 +6652,11 @@ const UIRender = {
6537
6652
  }
6538
6653
  },
6539
6654
  __drawFast(canvas, options) {
6540
- const { fill, stroke, __drawAfterFill } = this.__;
6541
- this.__drawRenderPath(canvas);
6542
- if (fill)
6543
- Paint.fill(fill, this, canvas);
6544
- if (__drawAfterFill)
6545
- this.__drawAfterFill(canvas, options);
6546
- if (stroke)
6547
- Paint.stroke(stroke, this, canvas);
6655
+ drawFast(this, canvas, options);
6548
6656
  },
6549
6657
  __draw(canvas, options) {
6550
- if (this.__.__complex) {
6551
- const data = this.__;
6658
+ const data = this.__;
6659
+ if (data.__complex) {
6552
6660
  if (data.__needComputePaint)
6553
6661
  data.__computePaint();
6554
6662
  const { fill, stroke, __drawAfterFill } = data;
@@ -6581,7 +6689,12 @@ const UIRender = {
6581
6689
  }
6582
6690
  }
6583
6691
  else {
6584
- this.__drawFast(canvas, options);
6692
+ if (data.__pathInputed) {
6693
+ drawFast(this, canvas, options);
6694
+ }
6695
+ else {
6696
+ this.__drawFast(canvas, options);
6697
+ }
6585
6698
  }
6586
6699
  },
6587
6700
  __renderShape(canvas, options) {
@@ -6596,6 +6709,16 @@ const UIRender = {
6596
6709
  }
6597
6710
  }
6598
6711
  };
6712
+ function drawFast(ui, canvas, options) {
6713
+ const { fill, stroke, __drawAfterFill } = ui.__;
6714
+ ui.__drawRenderPath(canvas);
6715
+ if (fill)
6716
+ Paint.fill(fill, ui, canvas);
6717
+ if (__drawAfterFill)
6718
+ ui.__drawAfterFill(canvas, options);
6719
+ if (stroke)
6720
+ Paint.stroke(stroke, ui, canvas);
6721
+ }
6599
6722
 
6600
6723
  const RectRender = {
6601
6724
  __drawFast(canvas, options) {
@@ -6644,6 +6767,10 @@ let UI = UI_1 = class UI extends Leaf {
6644
6767
  const { scaleX, scaleY } = this;
6645
6768
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
6646
6769
  }
6770
+ get pen() {
6771
+ pen.set(this.path = this.__.path || []);
6772
+ return pen;
6773
+ }
6647
6774
  constructor(data) {
6648
6775
  super(data);
6649
6776
  }
@@ -6652,7 +6779,7 @@ let UI = UI_1 = class UI extends Leaf {
6652
6779
  Object.assign(this, data);
6653
6780
  }
6654
6781
  get(name) {
6655
- return name ? this.__.__getInput(name) : this.__.__getInputData();
6782
+ return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
6656
6783
  }
6657
6784
  createProxyData() { return undefined; }
6658
6785
  find(_condition, _options) { return undefined; }
@@ -6661,10 +6788,11 @@ let UI = UI_1 = class UI extends Leaf {
6661
6788
  this.__layout.update();
6662
6789
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
6663
6790
  if (!path) {
6664
- path = [];
6665
6791
  const { width, height } = this.boxBounds;
6666
- if (width || height)
6667
- this.__drawPathByBox(new PathCreator(path));
6792
+ if (width || height) {
6793
+ pen.set(path = []);
6794
+ this.__drawPathByBox(pen);
6795
+ }
6668
6796
  }
6669
6797
  return curve ? PathConvert.toCanvasData(path, true) : path;
6670
6798
  }
@@ -6736,6 +6864,9 @@ let UI = UI_1 = class UI extends Leaf {
6736
6864
  __decorate([
6737
6865
  dataProcessor(UIData)
6738
6866
  ], UI.prototype, "__", void 0);
6867
+ __decorate([
6868
+ zoomLayerType()
6869
+ ], UI.prototype, "zoomLayer", void 0);
6739
6870
  __decorate([
6740
6871
  dataType('')
6741
6872
  ], UI.prototype, "id", void 0);
@@ -6754,6 +6885,12 @@ __decorate([
6754
6885
  __decorate([
6755
6886
  opacityType(true)
6756
6887
  ], UI.prototype, "visible", void 0);
6888
+ __decorate([
6889
+ stateType(false)
6890
+ ], UI.prototype, "selected", void 0);
6891
+ __decorate([
6892
+ stateType(false)
6893
+ ], UI.prototype, "disabled", void 0);
6757
6894
  __decorate([
6758
6895
  dataType(false)
6759
6896
  ], UI.prototype, "locked", void 0);
@@ -6901,6 +7038,24 @@ __decorate([
6901
7038
  __decorate([
6902
7039
  effectType()
6903
7040
  ], UI.prototype, "grayscale", void 0);
7041
+ __decorate([
7042
+ dataType()
7043
+ ], UI.prototype, "normalStyle", void 0);
7044
+ __decorate([
7045
+ dataType()
7046
+ ], UI.prototype, "hoverStyle", void 0);
7047
+ __decorate([
7048
+ dataType()
7049
+ ], UI.prototype, "pressStyle", void 0);
7050
+ __decorate([
7051
+ dataType()
7052
+ ], UI.prototype, "focusStyle", void 0);
7053
+ __decorate([
7054
+ dataType()
7055
+ ], UI.prototype, "selectedStyle", void 0);
7056
+ __decorate([
7057
+ dataType()
7058
+ ], UI.prototype, "disabledStyle", void 0);
6904
7059
  __decorate([
6905
7060
  rewrite(Leaf.prototype.reset)
6906
7061
  ], UI.prototype, "reset", null);
@@ -6937,7 +7092,7 @@ let Group = class Group extends UI {
6937
7092
  super.set(data);
6938
7093
  let child;
6939
7094
  children.forEach(childData => {
6940
- child = UICreator.get(childData.tag, childData);
7095
+ child = childData.__ ? childData : UICreator.get(childData.tag, childData);
6941
7096
  this.add(child);
6942
7097
  });
6943
7098
  data.children = children;
@@ -6986,7 +7141,6 @@ let Leafer = class Leafer extends Group {
6986
7141
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
6987
7142
  constructor(userConfig, data) {
6988
7143
  super(data);
6989
- this.zoomLayer = this;
6990
7144
  this.config = {
6991
7145
  type: 'design',
6992
7146
  start: true,
@@ -6999,7 +7153,6 @@ let Leafer = class Leafer extends Group {
6999
7153
  move: {
7000
7154
  holdSpaceKey: true,
7001
7155
  holdMiddleKey: true,
7002
- dragOut: true,
7003
7156
  autoDistance: 2
7004
7157
  }
7005
7158
  };
@@ -7130,9 +7283,6 @@ let Leafer = class Leafer extends Group {
7130
7283
  this.leafer = leafer;
7131
7284
  this.__level = 1;
7132
7285
  }
7133
- setZoomLayer(zoomLayer) {
7134
- this.zoomLayer = zoomLayer;
7135
- }
7136
7286
  __checkAutoLayout(config) {
7137
7287
  if (!config.width || !config.height) {
7138
7288
  this.autoLayout = new AutoBounds(config);
@@ -7218,13 +7368,19 @@ let Leafer = class Leafer extends Group {
7218
7368
  this.nextRender(() => this.interaction.updateCursor());
7219
7369
  }
7220
7370
  }
7221
- waitReady(item) {
7371
+ waitReady(item, bind) {
7372
+ if (bind)
7373
+ item = item.bind(bind);
7222
7374
  this.ready ? item() : this.__readyWait.push(item);
7223
7375
  }
7224
- waitViewReady(item) {
7376
+ waitViewReady(item, bind) {
7377
+ if (bind)
7378
+ item = item.bind(bind);
7225
7379
  this.viewReady ? item() : this.__viewReadyWait.push(item);
7226
7380
  }
7227
- waitViewCompleted(item) {
7381
+ waitViewCompleted(item, bind) {
7382
+ if (bind)
7383
+ item = item.bind(bind);
7228
7384
  this.__viewCompletedWait.push(item);
7229
7385
  if (this.viewCompleted) {
7230
7386
  this.__checkViewCompleted(false);
@@ -7234,7 +7390,9 @@ let Leafer = class Leafer extends Group {
7234
7390
  this.start();
7235
7391
  }
7236
7392
  }
7237
- nextRender(item, off) {
7393
+ nextRender(item, bind, off) {
7394
+ if (bind)
7395
+ item = item.bind(bind);
7238
7396
  const list = this.__nextRenderWait;
7239
7397
  if (off) {
7240
7398
  for (let i = 0; i < list.length; i++) {
@@ -7248,6 +7406,15 @@ let Leafer = class Leafer extends Group {
7248
7406
  list.push(item);
7249
7407
  }
7250
7408
  }
7409
+ zoom(_zoomType, _padding, _fixedScale) { return undefined; }
7410
+ validScale(changeScale) {
7411
+ const { scaleX } = this.zoomLayer.__, { min, max } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
7412
+ if (absScale < min)
7413
+ changeScale = min / scaleX;
7414
+ else if (absScale > max)
7415
+ changeScale = max / scaleX;
7416
+ return changeScale;
7417
+ }
7251
7418
  __checkUpdateLayout() {
7252
7419
  this.__layout.update();
7253
7420
  }
@@ -8377,10 +8544,6 @@ function createData(leafPaint, image, paint, box) {
8377
8544
  case 'strench':
8378
8545
  if (!sameBox)
8379
8546
  width = box.width, height = box.height;
8380
- if (box.x || box.y) {
8381
- data.transform = get$3();
8382
- translate(data.transform, box.x, box.y);
8383
- }
8384
8547
  break;
8385
8548
  case 'clip':
8386
8549
  if (offset || scaleX || rotation)
@@ -8398,6 +8561,12 @@ function createData(leafPaint, image, paint, box) {
8398
8561
  if (!sameBox || rotation)
8399
8562
  fillOrFitMode(data, mode, box, width, height, rotation);
8400
8563
  }
8564
+ if (!data.transform) {
8565
+ if (box.x || box.y) {
8566
+ data.transform = get$3();
8567
+ translate(data.transform, box.x, box.y);
8568
+ }
8569
+ }
8401
8570
  data.width = width;
8402
8571
  data.height = height;
8403
8572
  if (opacity)
@@ -8415,8 +8584,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
8415
8584
  leafPaint = cache.leafPaint;
8416
8585
  }
8417
8586
  else {
8418
- leafPaint = { type: paint.type };
8419
- leafPaint.image = image;
8587
+ leafPaint = { type: paint.type, image };
8420
8588
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
8421
8589
  }
8422
8590
  if (firstUse || image.loading)
@@ -8433,9 +8601,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
8433
8601
  onLoadError(ui, event, image.error);
8434
8602
  }
8435
8603
  else {
8604
+ ignoreRender(ui, true);
8436
8605
  if (firstUse)
8437
8606
  onLoad(ui, event);
8438
8607
  leafPaint.loadId = image.load(() => {
8608
+ ignoreRender(ui, false);
8439
8609
  if (!ui.destroyed) {
8440
8610
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
8441
8611
  ui.forceUpdate('surface');
@@ -8443,6 +8613,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
8443
8613
  }
8444
8614
  leafPaint.loadId = null;
8445
8615
  }, (error) => {
8616
+ ignoreRender(ui, false);
8446
8617
  onLoadError(ui, event, error);
8447
8618
  leafPaint.loadId = null;
8448
8619
  });
@@ -8482,11 +8653,16 @@ function emit(ui, type, data) {
8482
8653
  if (ui.hasEvent(type))
8483
8654
  ui.emitEvent(new ImageEvent(type, data));
8484
8655
  }
8656
+ function ignoreRender(ui, value) {
8657
+ const { leafer } = ui;
8658
+ if (leafer && leafer.viewReady)
8659
+ leafer.renderer.ignore = value;
8660
+ }
8485
8661
 
8486
8662
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
8487
8663
  const { ceil, abs: abs$1 } = Math;
8488
8664
  function createPattern(ui, paint, pixelRatio) {
8489
- let { scaleX, scaleY } = ui.__world;
8665
+ let { scaleX, scaleY } = ui.__nowWorld;
8490
8666
  const id = scaleX + '-' + scaleY;
8491
8667
  if (paint.patternId !== id && !ui.destroyed) {
8492
8668
  scaleX = abs$1(scaleX);
@@ -8548,7 +8724,7 @@ function createPattern(ui, paint, pixelRatio) {
8548
8724
 
8549
8725
  const { abs } = Math;
8550
8726
  function checkImage(ui, canvas, paint, allowPaint) {
8551
- const { scaleX, scaleY } = ui.__world;
8727
+ const { scaleX, scaleY } = ui.__nowWorld;
8552
8728
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
8553
8729
  return false;
8554
8730
  }
@@ -8590,7 +8766,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
8590
8766
  if (!paint.patternTask) {
8591
8767
  paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
8592
8768
  paint.patternTask = null;
8593
- if (canvas.bounds.hit(ui.__world))
8769
+ if (canvas.bounds.hit(ui.__nowWorld))
8594
8770
  createPattern(ui, paint, canvas.pixelRatio);
8595
8771
  ui.forceUpdate('surface');
8596
8772
  }), 300);
@@ -8827,8 +9003,8 @@ function innerShadow(ui, current, shape) {
8827
9003
 
8828
9004
  function blur(ui, current, origin) {
8829
9005
  const { blur } = ui.__;
8830
- origin.setWorldBlur(blur * ui.__world.a);
8831
- origin.copyWorldToInner(current, ui.__world, ui.__layout.renderBounds);
9006
+ origin.setWorldBlur(blur * ui.__nowWorld.a);
9007
+ origin.copyWorldToInner(current, ui.__nowWorld, ui.__layout.renderBounds);
8832
9008
  origin.filter = 'none';
8833
9009
  }
8834
9010
 
@@ -9459,10 +9635,10 @@ const ExportModule = {
9459
9635
  renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
9460
9636
  }
9461
9637
  else {
9462
- const location = options.location || ((isLeafer || isFrame) ? 'inner' : 'local');
9638
+ let relative = options.relative || (isLeafer ? 'inner' : 'local');
9463
9639
  scaleX = worldTransform.scaleX;
9464
9640
  scaleY = worldTransform.scaleY;
9465
- switch (location) {
9641
+ switch (relative) {
9466
9642
  case 'inner':
9467
9643
  matrix.set(worldTransform).invert();
9468
9644
  break;
@@ -9475,11 +9651,18 @@ const ExportModule = {
9475
9651
  scaleX = 1;
9476
9652
  scaleY = 1;
9477
9653
  break;
9654
+ case 'page':
9655
+ relative = leaf.leafer;
9656
+ default:
9657
+ matrix.set(worldTransform).divide(leaf.getTransform(relative)).invert();
9658
+ const l = relative.worldTransform;
9659
+ scaleX /= scaleX / l.scaleX;
9660
+ scaleY /= scaleY / l.scaleY;
9478
9661
  }
9479
- renderBounds = leaf.getBounds('render', location);
9662
+ renderBounds = leaf.getBounds('render', relative);
9480
9663
  }
9481
- const { x, y, width, height } = new Bounds(renderBounds).scale(scale).ceil();
9482
- let canvas = Creator.canvas({ width, height, pixelRatio });
9664
+ const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
9665
+ let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
9483
9666
  const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
9484
9667
  if (slice) {
9485
9668
  leaf = leafer;
@@ -9536,4 +9719,4 @@ Object.assign(Export, ExportModule);
9536
9719
 
9537
9720
  useCanvas();
9538
9721
 
9539
- export { AnimateEvent, 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, Export, FileHelper, 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, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule };
9722
+ export { AnimateEvent, 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, Export, FileHelper, 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, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, useCanvas, useModule, zoomLayerType };