ice-render 0.0.7 → 0.0.8

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/index.cjs.js CHANGED
@@ -3164,6 +3164,26 @@ class ICEEvent {
3164
3164
  }
3165
3165
  }
3166
3166
 
3167
+ composedPath() {
3168
+ throw new Error('Method not implemented.');
3169
+ }
3170
+
3171
+ initEvent(type, bubbles, cancelable) {
3172
+ throw new Error('Method not implemented.');
3173
+ }
3174
+
3175
+ preventDefault() {
3176
+ throw new Error('Method not implemented.');
3177
+ }
3178
+
3179
+ stopImmediatePropagation() {
3180
+ throw new Error('Method not implemented.');
3181
+ }
3182
+
3183
+ stopPropagation() {
3184
+ throw new Error('Method not implemented.');
3185
+ }
3186
+
3167
3187
  }
3168
3188
 
3169
3189
  var overArg = _overArg;
@@ -3616,10 +3636,13 @@ class ICEEventTarget {
3616
3636
  }
3617
3637
 
3618
3638
  } //增加别名,模拟 W3C 的 EventTarget 接口
3639
+ //@ts-ignore
3619
3640
 
3620
3641
 
3621
- ICEEventTarget.prototype.addEventListener = ICEEventTarget.prototype.on;
3622
- ICEEventTarget.prototype.removeEventListener = ICEEventTarget.prototype.off;
3642
+ ICEEventTarget.prototype.addEventListener = ICEEventTarget.prototype.on; //@ts-ignore
3643
+
3644
+ ICEEventTarget.prototype.removeEventListener = ICEEventTarget.prototype.off; //@ts-ignore
3645
+
3623
3646
  ICEEventTarget.prototype.dispatchEvent = ICEEventTarget.prototype.trigger;
3624
3647
 
3625
3648
  /**
@@ -3855,10 +3878,15 @@ class ICEBoundingBox {
3855
3878
 
3856
3879
 
3857
3880
  transform(matrix) {
3858
- const tl = transformMat2d([], this.tl, matrix);
3859
- const tr = transformMat2d([], this.tr, matrix);
3860
- const bl = transformMat2d([], this.bl, matrix);
3861
- const br = transformMat2d([], this.br, matrix);
3881
+ //@ts-ignore
3882
+ const tl = transformMat2d([], this.tl, matrix); //@ts-ignore
3883
+
3884
+ const tr = transformMat2d([], this.tr, matrix); //@ts-ignore
3885
+
3886
+ const bl = transformMat2d([], this.bl, matrix); //@ts-ignore
3887
+
3888
+ const br = transformMat2d([], this.br, matrix); //@ts-ignore
3889
+
3862
3890
  const center = transformMat2d([], this.center, matrix);
3863
3891
  return new ICEBoundingBox([...tl, ...tr, ...bl, ...br, ...center]);
3864
3892
  }
@@ -4250,9 +4278,11 @@ class ICEComponent extends ICEEventTarget {
4250
4278
 
4251
4279
  if (this.parentNode) {
4252
4280
  let pLocalX = this.parentNode.state.localOrigin[0];
4253
- let pLocalY = this.parentNode.state.localOrigin[1];
4281
+ let pLocalY = this.parentNode.state.localOrigin[1]; //@ts-ignore
4282
+
4254
4283
  point = transformMat2d([], point, [1, 0, 0, 1, -pLocalX, -pLocalY]);
4255
- let pcm = this.parentNode.state.composedMatrix;
4284
+ let pcm = this.parentNode.state.composedMatrix; //@ts-ignore
4285
+
4256
4286
  point = transformMat2d([], point, pcm);
4257
4287
  }
4258
4288
 
@@ -4275,11 +4305,13 @@ class ICEComponent extends ICEEventTarget {
4275
4305
  const skewY = getVal(this, 'state.transform.skew.1');
4276
4306
  matrix = skew([], matrix, toRadian(skewX), toRadian(skewY)); //step2: rotate
4277
4307
 
4278
- let angle = getVal(this, 'state.transform.rotate');
4308
+ let angle = getVal(this, 'state.transform.rotate'); //@ts-ignore
4309
+
4279
4310
  matrix = rotate([], matrix, toRadian(angle)); //step3: scale
4280
4311
 
4281
4312
  const scaleX = getVal(this, 'state.transform.scale.0');
4282
- const scaleY = getVal(this, 'state.transform.scale.1');
4313
+ const scaleY = getVal(this, 'state.transform.scale.1'); //@ts-ignore
4314
+
4283
4315
  matrix = scale([], matrix, [scaleX, scaleY]);
4284
4316
  this.state.linearMatrix = matrix;
4285
4317
  return matrix;
@@ -4295,6 +4327,7 @@ class ICEComponent extends ICEEventTarget {
4295
4327
  let matrix = component.calcLinearMatrix();
4296
4328
 
4297
4329
  while (component.parentNode) {
4330
+ //@ts-ignore
4298
4331
  matrix = multiply([], component.parentNode.state.linearMatrix, matrix);
4299
4332
  component = component.parentNode;
4300
4333
  }
@@ -4322,6 +4355,7 @@ class ICEComponent extends ICEEventTarget {
4322
4355
  let translationMatrix = [1, 0, 0, 1, origin[0], origin[1]]; //step-2: 计算线性变换矩阵,包含了所有祖先节点的线性变换。
4323
4356
 
4324
4357
  let linearMatrix = this.calcAbsoluteLinearMatrix(); //step-3: 计算综合变换矩阵,相当于先在 canvas 默认原点(左上角位置)进行变换,然后在平移到计算出的原点位置。
4358
+ //@ts-ignore
4325
4359
 
4326
4360
  let composedMatrix = multiply([], translationMatrix, linearMatrix);
4327
4361
  this.state.composedMatrix = composedMatrix;
@@ -4474,8 +4508,10 @@ class ICEComponent extends ICEEventTarget {
4474
4508
 
4475
4509
  //如果组件存在嵌套,需要先用逆矩阵抵消所有祖先节点 transform 导致的坐标偏移。
4476
4510
  if (this.parentNode) {
4477
- let point = [tx, ty];
4478
- let matrix = invert([], this.parentNode.state.absoluteLinearMatrix);
4511
+ let point = [tx, ty]; //@ts-ignore
4512
+
4513
+ let matrix = invert([], this.parentNode.state.absoluteLinearMatrix); //@ts-ignore
4514
+
4479
4515
  point = transformMat2d([], point, matrix);
4480
4516
  tx = point[0];
4481
4517
  ty = point[1];
@@ -4500,8 +4536,10 @@ class ICEComponent extends ICEEventTarget {
4500
4536
 
4501
4537
  //如果组件存在嵌套,需要先用逆矩阵抵消所有祖先节点 transform 导致的坐标偏移。
4502
4538
  if (this.parentNode) {
4503
- let point = [left, top];
4504
- let matrix = invert([], this.parentNode.state.absoluteLinearMatrix);
4539
+ let point = [left, top]; //@ts-ignore
4540
+
4541
+ let matrix = invert([], this.parentNode.state.absoluteLinearMatrix); //@ts-ignore
4542
+
4505
4543
  point = transformMat2d([], point, matrix);
4506
4544
  left = point[0];
4507
4545
  top = point[1];
@@ -4543,7 +4581,8 @@ class ICEComponent extends ICEEventTarget {
4543
4581
 
4544
4582
  localToGlobal(localX, localY) {
4545
4583
  let point = [localX, localY];
4546
- let matrix = this.state.composedMatrix;
4584
+ let matrix = this.state.composedMatrix; //@ts-ignore
4585
+
4547
4586
  point = transformMat2d([], point, matrix);
4548
4587
  return point;
4549
4588
  }
@@ -4556,8 +4595,10 @@ class ICEComponent extends ICEEventTarget {
4556
4595
 
4557
4596
 
4558
4597
  globalToLocal(globalX, globalY) {
4559
- let point = [globalX, globalY];
4560
- let matrix = invert([], this.state.composedMatrix);
4598
+ let point = [globalX, globalY]; //@ts-ignore
4599
+
4600
+ let matrix = invert([], this.state.composedMatrix); //@ts-ignore
4601
+
4561
4602
  point = transformMat2d([], point, matrix);
4562
4603
  return point;
4563
4604
  }
@@ -5337,7 +5378,8 @@ class ICEDotPath extends ICEPath {
5337
5378
  let origin = super.calcLocalOrigin();
5338
5379
 
5339
5380
  for (let i = 0; i < this.state.dots.length; i++) {
5340
- let dot = this.state.dots[i];
5381
+ let dot = this.state.dots[i]; //@ts-ignore
5382
+
5341
5383
  dot = transformMat2d([], dot, [1, 0, 0, 1, -origin[0], -origin[1]]);
5342
5384
  this.state.dots[i] = dot;
5343
5385
  }
@@ -5430,7 +5472,8 @@ class ICEDotPath extends ICEPath {
5430
5472
  const result = [];
5431
5473
 
5432
5474
  for (let i = 0; i < dots.length; i++) {
5433
- const dot = dots[i];
5475
+ const dot = dots[i]; //@ts-ignore
5476
+
5434
5477
  const point = transformMat2d([], dot, matrix);
5435
5478
  result.push(point);
5436
5479
  }
@@ -5895,7 +5938,8 @@ class ICEPolyLine extends ICEDotPath {
5895
5938
 
5896
5939
  for (let i = 0; i < len; i++) {
5897
5940
  let p = this.state.points[i];
5898
- let vector2 = [p[0] - startX, p[1] - startY];
5941
+ let vector2 = [p[0] - startX, p[1] - startY]; //@ts-ignore
5942
+
5899
5943
  let crossProduct = cross([], vector1, vector2)[2];
5900
5944
 
5901
5945
  if (crossProduct === 0) {
@@ -6456,8 +6500,10 @@ class LineControlPanel extends ICEControlPanel {
6456
6500
  let newEndX = targetState.points[len - 1][0];
6457
6501
  let newEndY = targetState.points[len - 1][1]; //用逆矩阵补偿组件 transform 导致的坐标变换。
6458
6502
  //组件自身的 absoluteLinearMatrix 已经包含了所有层级上的 transform 。
6503
+ //@ts-ignore
6504
+
6505
+ let matrix = invert([], targetState.absoluteLinearMatrix); //@ts-ignore
6459
6506
 
6460
- let matrix = invert([], targetState.absoluteLinearMatrix);
6461
6507
  let point = transformMat2d([], [movementX, movementY], matrix);
6462
6508
  movementX = point[0];
6463
6509
  movementY = point[1];
@@ -6610,8 +6656,10 @@ class ResizeControl extends ICERect {
6610
6656
  let newWidth = parentState.width;
6611
6657
  let newHeight = parentState.height; //用 parentNode 的逆矩阵把全局坐标系中的移动量转换为组件本地的移动量。
6612
6658
  //组件自身的 absoluteLinearMatrix 已经包含了所有层级上的 transform 。
6659
+ //@ts-ignore
6660
+
6661
+ let matrix = invert([], parentState.absoluteLinearMatrix); //@ts-ignore
6613
6662
 
6614
- let matrix = invert([], parentState.absoluteLinearMatrix);
6615
6663
  let point = transformMat2d([], [movementX, movementY], matrix);
6616
6664
  movementX = point[0];
6617
6665
  movementY = point[1];
@@ -6702,8 +6750,10 @@ class ResizeControl extends ICERect {
6702
6750
  let parentState = this.parentNode.state;
6703
6751
  let parentLocalOrigin = parentState.localOrigin;
6704
6752
  let parentWidth = parentState.width;
6705
- let parentHeight = parentState.height;
6706
- let matrix = invert([], parentState.absoluteLinearMatrix);
6753
+ let parentHeight = parentState.height; //@ts-ignore
6754
+
6755
+ let matrix = invert([], parentState.absoluteLinearMatrix); //@ts-ignore
6756
+
6707
6757
  let point = transformMat2d([], [tx, ty], matrix);
6708
6758
  tx = point[0];
6709
6759
  ty = point[1];
@@ -7132,8 +7182,10 @@ class TransformControlPanel extends ICEControlPanel {
7132
7182
  let newLeft = targetState.left;
7133
7183
  let newTop = targetState.top;
7134
7184
  let newWidth = targetState.width;
7135
- let newHeight = targetState.height;
7136
- let matrix = invert([], targetState.absoluteLinearMatrix);
7185
+ let newHeight = targetState.height; //@ts-ignore
7186
+
7187
+ let matrix = invert([], targetState.absoluteLinearMatrix); //@ts-ignore
7188
+
7137
7189
  let point = transformMat2d([], [movementX, movementY], matrix);
7138
7190
  movementX = point[0];
7139
7191
  movementY = point[1];
@@ -9190,7 +9242,9 @@ class DDManager {
9190
9242
  // console.log('window.devicePixelRatio>', window.devicePixelRatio);
9191
9243
  // let tx = evt.movementX / window.devicePixelRatio; //FIXME: window.devicePixelRatio 需要移动到初始化参数中去
9192
9244
  // let ty = evt.movementY / window.devicePixelRatio; //FIXME: window.devicePixelRatio 需要移动到初始化参数中去
9193
- let tx = evt.movementX;
9245
+ //@ts-ignore
9246
+ let tx = evt.movementX; //@ts-ignore
9247
+
9194
9248
  let ty = evt.movementY;
9195
9249
  this.currentObj.moveGlobalPosition(tx, ty, evt);
9196
9250
  return true;
@@ -9363,7 +9417,9 @@ class ICELinkSlotManager {
9363
9417
  let slotBounding = component.getMaxBoundingBox();
9364
9418
 
9365
9419
  if (slotBounding.isIntersect(hookBounding)) {
9420
+ //@ts-ignore
9366
9421
  for (let i = 0; i < this.ice._linkSlots.length; i++) {
9422
+ //@ts-ignore
9367
9423
  this.ice._linkSlots[i].hostComponent = component;
9368
9424
  }
9369
9425
 
@@ -9378,6 +9434,7 @@ class ICELinkSlotManager {
9378
9434
 
9379
9435
 
9380
9436
  createLinkSlots() {
9437
+ //@ts-ignore
9381
9438
  if (this.ice._linkSlots && this.ice._linkSlots.length) {
9382
9439
  return;
9383
9440
  }
@@ -9437,7 +9494,8 @@ class ICELinkSlotManager {
9437
9494
  lineWidth: 1
9438
9495
  }
9439
9496
  });
9440
- this.ice.addTool(slot_4);
9497
+ this.ice.addTool(slot_4); //@ts-ignore
9498
+
9441
9499
  this.ice._linkSlots = [slot_1, slot_2, slot_3, slot_4];
9442
9500
  }
9443
9501
 
@@ -9455,10 +9513,21 @@ class ICELinkSlotManager {
9455
9513
  *
9456
9514
  * @author 大漠穷秋<damoqiongqiu@126.com>
9457
9515
  *
9458
- * //FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
9516
+ * FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
9459
9517
  */
9460
9518
 
9461
- const componentTypeMap = Object.fromEntries(new Map([['ICERect', ICERect], ['ICECircle', ICECircle], ['ICEEllipse', ICEEllipse], ['ICEStar', ICEStar], ['ICEIsogon', ICEIsogon], ['ICEText', ICEText], ['ICEImage', ICEImage], ['ICEGroup', ICEGroup], ['ICEVisioLink', ICEVisioLink], ['ICEPolyLine', ICEPolyLine]]));
9519
+ const componentTypeMap = {
9520
+ ICERect: ICERect,
9521
+ ICECircle: ICECircle,
9522
+ ICEEllipse: ICEEllipse,
9523
+ ICEStar: ICEStar,
9524
+ ICEIsogon: ICEIsogon,
9525
+ ICEText: ICEText,
9526
+ ICEImage: ICEImage,
9527
+ ICEGroup: ICEGroup,
9528
+ ICEVisioLink: ICEVisioLink,
9529
+ ICEPolyLine: ICEPolyLine
9530
+ };
9462
9531
 
9463
9532
  /**
9464
9533
  * Copyright (c) 2022 大漠穷秋.
package/dist/index.js CHANGED
@@ -3160,6 +3160,26 @@ class ICEEvent {
3160
3160
  }
3161
3161
  }
3162
3162
 
3163
+ composedPath() {
3164
+ throw new Error('Method not implemented.');
3165
+ }
3166
+
3167
+ initEvent(type, bubbles, cancelable) {
3168
+ throw new Error('Method not implemented.');
3169
+ }
3170
+
3171
+ preventDefault() {
3172
+ throw new Error('Method not implemented.');
3173
+ }
3174
+
3175
+ stopImmediatePropagation() {
3176
+ throw new Error('Method not implemented.');
3177
+ }
3178
+
3179
+ stopPropagation() {
3180
+ throw new Error('Method not implemented.');
3181
+ }
3182
+
3163
3183
  }
3164
3184
 
3165
3185
  var overArg = _overArg;
@@ -3612,10 +3632,13 @@ class ICEEventTarget {
3612
3632
  }
3613
3633
 
3614
3634
  } //增加别名,模拟 W3C 的 EventTarget 接口
3635
+ //@ts-ignore
3615
3636
 
3616
3637
 
3617
- ICEEventTarget.prototype.addEventListener = ICEEventTarget.prototype.on;
3618
- ICEEventTarget.prototype.removeEventListener = ICEEventTarget.prototype.off;
3638
+ ICEEventTarget.prototype.addEventListener = ICEEventTarget.prototype.on; //@ts-ignore
3639
+
3640
+ ICEEventTarget.prototype.removeEventListener = ICEEventTarget.prototype.off; //@ts-ignore
3641
+
3619
3642
  ICEEventTarget.prototype.dispatchEvent = ICEEventTarget.prototype.trigger;
3620
3643
 
3621
3644
  /**
@@ -3851,10 +3874,15 @@ class ICEBoundingBox {
3851
3874
 
3852
3875
 
3853
3876
  transform(matrix) {
3854
- const tl = transformMat2d([], this.tl, matrix);
3855
- const tr = transformMat2d([], this.tr, matrix);
3856
- const bl = transformMat2d([], this.bl, matrix);
3857
- const br = transformMat2d([], this.br, matrix);
3877
+ //@ts-ignore
3878
+ const tl = transformMat2d([], this.tl, matrix); //@ts-ignore
3879
+
3880
+ const tr = transformMat2d([], this.tr, matrix); //@ts-ignore
3881
+
3882
+ const bl = transformMat2d([], this.bl, matrix); //@ts-ignore
3883
+
3884
+ const br = transformMat2d([], this.br, matrix); //@ts-ignore
3885
+
3858
3886
  const center = transformMat2d([], this.center, matrix);
3859
3887
  return new ICEBoundingBox([...tl, ...tr, ...bl, ...br, ...center]);
3860
3888
  }
@@ -4246,9 +4274,11 @@ class ICEComponent extends ICEEventTarget {
4246
4274
 
4247
4275
  if (this.parentNode) {
4248
4276
  let pLocalX = this.parentNode.state.localOrigin[0];
4249
- let pLocalY = this.parentNode.state.localOrigin[1];
4277
+ let pLocalY = this.parentNode.state.localOrigin[1]; //@ts-ignore
4278
+
4250
4279
  point = transformMat2d([], point, [1, 0, 0, 1, -pLocalX, -pLocalY]);
4251
- let pcm = this.parentNode.state.composedMatrix;
4280
+ let pcm = this.parentNode.state.composedMatrix; //@ts-ignore
4281
+
4252
4282
  point = transformMat2d([], point, pcm);
4253
4283
  }
4254
4284
 
@@ -4271,11 +4301,13 @@ class ICEComponent extends ICEEventTarget {
4271
4301
  const skewY = getVal(this, 'state.transform.skew.1');
4272
4302
  matrix = skew([], matrix, toRadian(skewX), toRadian(skewY)); //step2: rotate
4273
4303
 
4274
- let angle = getVal(this, 'state.transform.rotate');
4304
+ let angle = getVal(this, 'state.transform.rotate'); //@ts-ignore
4305
+
4275
4306
  matrix = rotate([], matrix, toRadian(angle)); //step3: scale
4276
4307
 
4277
4308
  const scaleX = getVal(this, 'state.transform.scale.0');
4278
- const scaleY = getVal(this, 'state.transform.scale.1');
4309
+ const scaleY = getVal(this, 'state.transform.scale.1'); //@ts-ignore
4310
+
4279
4311
  matrix = scale([], matrix, [scaleX, scaleY]);
4280
4312
  this.state.linearMatrix = matrix;
4281
4313
  return matrix;
@@ -4291,6 +4323,7 @@ class ICEComponent extends ICEEventTarget {
4291
4323
  let matrix = component.calcLinearMatrix();
4292
4324
 
4293
4325
  while (component.parentNode) {
4326
+ //@ts-ignore
4294
4327
  matrix = multiply([], component.parentNode.state.linearMatrix, matrix);
4295
4328
  component = component.parentNode;
4296
4329
  }
@@ -4318,6 +4351,7 @@ class ICEComponent extends ICEEventTarget {
4318
4351
  let translationMatrix = [1, 0, 0, 1, origin[0], origin[1]]; //step-2: 计算线性变换矩阵,包含了所有祖先节点的线性变换。
4319
4352
 
4320
4353
  let linearMatrix = this.calcAbsoluteLinearMatrix(); //step-3: 计算综合变换矩阵,相当于先在 canvas 默认原点(左上角位置)进行变换,然后在平移到计算出的原点位置。
4354
+ //@ts-ignore
4321
4355
 
4322
4356
  let composedMatrix = multiply([], translationMatrix, linearMatrix);
4323
4357
  this.state.composedMatrix = composedMatrix;
@@ -4470,8 +4504,10 @@ class ICEComponent extends ICEEventTarget {
4470
4504
 
4471
4505
  //如果组件存在嵌套,需要先用逆矩阵抵消所有祖先节点 transform 导致的坐标偏移。
4472
4506
  if (this.parentNode) {
4473
- let point = [tx, ty];
4474
- let matrix = invert([], this.parentNode.state.absoluteLinearMatrix);
4507
+ let point = [tx, ty]; //@ts-ignore
4508
+
4509
+ let matrix = invert([], this.parentNode.state.absoluteLinearMatrix); //@ts-ignore
4510
+
4475
4511
  point = transformMat2d([], point, matrix);
4476
4512
  tx = point[0];
4477
4513
  ty = point[1];
@@ -4496,8 +4532,10 @@ class ICEComponent extends ICEEventTarget {
4496
4532
 
4497
4533
  //如果组件存在嵌套,需要先用逆矩阵抵消所有祖先节点 transform 导致的坐标偏移。
4498
4534
  if (this.parentNode) {
4499
- let point = [left, top];
4500
- let matrix = invert([], this.parentNode.state.absoluteLinearMatrix);
4535
+ let point = [left, top]; //@ts-ignore
4536
+
4537
+ let matrix = invert([], this.parentNode.state.absoluteLinearMatrix); //@ts-ignore
4538
+
4501
4539
  point = transformMat2d([], point, matrix);
4502
4540
  left = point[0];
4503
4541
  top = point[1];
@@ -4539,7 +4577,8 @@ class ICEComponent extends ICEEventTarget {
4539
4577
 
4540
4578
  localToGlobal(localX, localY) {
4541
4579
  let point = [localX, localY];
4542
- let matrix = this.state.composedMatrix;
4580
+ let matrix = this.state.composedMatrix; //@ts-ignore
4581
+
4543
4582
  point = transformMat2d([], point, matrix);
4544
4583
  return point;
4545
4584
  }
@@ -4552,8 +4591,10 @@ class ICEComponent extends ICEEventTarget {
4552
4591
 
4553
4592
 
4554
4593
  globalToLocal(globalX, globalY) {
4555
- let point = [globalX, globalY];
4556
- let matrix = invert([], this.state.composedMatrix);
4594
+ let point = [globalX, globalY]; //@ts-ignore
4595
+
4596
+ let matrix = invert([], this.state.composedMatrix); //@ts-ignore
4597
+
4557
4598
  point = transformMat2d([], point, matrix);
4558
4599
  return point;
4559
4600
  }
@@ -5333,7 +5374,8 @@ class ICEDotPath extends ICEPath {
5333
5374
  let origin = super.calcLocalOrigin();
5334
5375
 
5335
5376
  for (let i = 0; i < this.state.dots.length; i++) {
5336
- let dot = this.state.dots[i];
5377
+ let dot = this.state.dots[i]; //@ts-ignore
5378
+
5337
5379
  dot = transformMat2d([], dot, [1, 0, 0, 1, -origin[0], -origin[1]]);
5338
5380
  this.state.dots[i] = dot;
5339
5381
  }
@@ -5426,7 +5468,8 @@ class ICEDotPath extends ICEPath {
5426
5468
  const result = [];
5427
5469
 
5428
5470
  for (let i = 0; i < dots.length; i++) {
5429
- const dot = dots[i];
5471
+ const dot = dots[i]; //@ts-ignore
5472
+
5430
5473
  const point = transformMat2d([], dot, matrix);
5431
5474
  result.push(point);
5432
5475
  }
@@ -5891,7 +5934,8 @@ class ICEPolyLine extends ICEDotPath {
5891
5934
 
5892
5935
  for (let i = 0; i < len; i++) {
5893
5936
  let p = this.state.points[i];
5894
- let vector2 = [p[0] - startX, p[1] - startY];
5937
+ let vector2 = [p[0] - startX, p[1] - startY]; //@ts-ignore
5938
+
5895
5939
  let crossProduct = cross([], vector1, vector2)[2];
5896
5940
 
5897
5941
  if (crossProduct === 0) {
@@ -6452,8 +6496,10 @@ class LineControlPanel extends ICEControlPanel {
6452
6496
  let newEndX = targetState.points[len - 1][0];
6453
6497
  let newEndY = targetState.points[len - 1][1]; //用逆矩阵补偿组件 transform 导致的坐标变换。
6454
6498
  //组件自身的 absoluteLinearMatrix 已经包含了所有层级上的 transform 。
6499
+ //@ts-ignore
6500
+
6501
+ let matrix = invert([], targetState.absoluteLinearMatrix); //@ts-ignore
6455
6502
 
6456
- let matrix = invert([], targetState.absoluteLinearMatrix);
6457
6503
  let point = transformMat2d([], [movementX, movementY], matrix);
6458
6504
  movementX = point[0];
6459
6505
  movementY = point[1];
@@ -6606,8 +6652,10 @@ class ResizeControl extends ICERect {
6606
6652
  let newWidth = parentState.width;
6607
6653
  let newHeight = parentState.height; //用 parentNode 的逆矩阵把全局坐标系中的移动量转换为组件本地的移动量。
6608
6654
  //组件自身的 absoluteLinearMatrix 已经包含了所有层级上的 transform 。
6655
+ //@ts-ignore
6656
+
6657
+ let matrix = invert([], parentState.absoluteLinearMatrix); //@ts-ignore
6609
6658
 
6610
- let matrix = invert([], parentState.absoluteLinearMatrix);
6611
6659
  let point = transformMat2d([], [movementX, movementY], matrix);
6612
6660
  movementX = point[0];
6613
6661
  movementY = point[1];
@@ -6698,8 +6746,10 @@ class ResizeControl extends ICERect {
6698
6746
  let parentState = this.parentNode.state;
6699
6747
  let parentLocalOrigin = parentState.localOrigin;
6700
6748
  let parentWidth = parentState.width;
6701
- let parentHeight = parentState.height;
6702
- let matrix = invert([], parentState.absoluteLinearMatrix);
6749
+ let parentHeight = parentState.height; //@ts-ignore
6750
+
6751
+ let matrix = invert([], parentState.absoluteLinearMatrix); //@ts-ignore
6752
+
6703
6753
  let point = transformMat2d([], [tx, ty], matrix);
6704
6754
  tx = point[0];
6705
6755
  ty = point[1];
@@ -7128,8 +7178,10 @@ class TransformControlPanel extends ICEControlPanel {
7128
7178
  let newLeft = targetState.left;
7129
7179
  let newTop = targetState.top;
7130
7180
  let newWidth = targetState.width;
7131
- let newHeight = targetState.height;
7132
- let matrix = invert([], targetState.absoluteLinearMatrix);
7181
+ let newHeight = targetState.height; //@ts-ignore
7182
+
7183
+ let matrix = invert([], targetState.absoluteLinearMatrix); //@ts-ignore
7184
+
7133
7185
  let point = transformMat2d([], [movementX, movementY], matrix);
7134
7186
  movementX = point[0];
7135
7187
  movementY = point[1];
@@ -9186,7 +9238,9 @@ class DDManager {
9186
9238
  // console.log('window.devicePixelRatio>', window.devicePixelRatio);
9187
9239
  // let tx = evt.movementX / window.devicePixelRatio; //FIXME: window.devicePixelRatio 需要移动到初始化参数中去
9188
9240
  // let ty = evt.movementY / window.devicePixelRatio; //FIXME: window.devicePixelRatio 需要移动到初始化参数中去
9189
- let tx = evt.movementX;
9241
+ //@ts-ignore
9242
+ let tx = evt.movementX; //@ts-ignore
9243
+
9190
9244
  let ty = evt.movementY;
9191
9245
  this.currentObj.moveGlobalPosition(tx, ty, evt);
9192
9246
  return true;
@@ -9359,7 +9413,9 @@ class ICELinkSlotManager {
9359
9413
  let slotBounding = component.getMaxBoundingBox();
9360
9414
 
9361
9415
  if (slotBounding.isIntersect(hookBounding)) {
9416
+ //@ts-ignore
9362
9417
  for (let i = 0; i < this.ice._linkSlots.length; i++) {
9418
+ //@ts-ignore
9363
9419
  this.ice._linkSlots[i].hostComponent = component;
9364
9420
  }
9365
9421
 
@@ -9374,6 +9430,7 @@ class ICELinkSlotManager {
9374
9430
 
9375
9431
 
9376
9432
  createLinkSlots() {
9433
+ //@ts-ignore
9377
9434
  if (this.ice._linkSlots && this.ice._linkSlots.length) {
9378
9435
  return;
9379
9436
  }
@@ -9433,7 +9490,8 @@ class ICELinkSlotManager {
9433
9490
  lineWidth: 1
9434
9491
  }
9435
9492
  });
9436
- this.ice.addTool(slot_4);
9493
+ this.ice.addTool(slot_4); //@ts-ignore
9494
+
9437
9495
  this.ice._linkSlots = [slot_1, slot_2, slot_3, slot_4];
9438
9496
  }
9439
9497
 
@@ -9451,10 +9509,21 @@ class ICELinkSlotManager {
9451
9509
  *
9452
9510
  * @author 大漠穷秋<damoqiongqiu@126.com>
9453
9511
  *
9454
- * //FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
9512
+ * FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
9455
9513
  */
9456
9514
 
9457
- const componentTypeMap = Object.fromEntries(new Map([['ICERect', ICERect], ['ICECircle', ICECircle], ['ICEEllipse', ICEEllipse], ['ICEStar', ICEStar], ['ICEIsogon', ICEIsogon], ['ICEText', ICEText], ['ICEImage', ICEImage], ['ICEGroup', ICEGroup], ['ICEVisioLink', ICEVisioLink], ['ICEPolyLine', ICEPolyLine]]));
9515
+ const componentTypeMap = {
9516
+ ICERect: ICERect,
9517
+ ICECircle: ICECircle,
9518
+ ICEEllipse: ICEEllipse,
9519
+ ICEStar: ICEStar,
9520
+ ICEIsogon: ICEIsogon,
9521
+ ICEText: ICEText,
9522
+ ICEImage: ICEImage,
9523
+ ICEGroup: ICEGroup,
9524
+ ICEVisioLink: ICEVisioLink,
9525
+ ICEPolyLine: ICEPolyLine
9526
+ };
9458
9527
 
9459
9528
  /**
9460
9529
  * Copyright (c) 2022 大漠穷秋.
package/dist/index.umd.js CHANGED
@@ -3166,6 +3166,26 @@
3166
3166
  }
3167
3167
  }
3168
3168
 
3169
+ composedPath() {
3170
+ throw new Error('Method not implemented.');
3171
+ }
3172
+
3173
+ initEvent(type, bubbles, cancelable) {
3174
+ throw new Error('Method not implemented.');
3175
+ }
3176
+
3177
+ preventDefault() {
3178
+ throw new Error('Method not implemented.');
3179
+ }
3180
+
3181
+ stopImmediatePropagation() {
3182
+ throw new Error('Method not implemented.');
3183
+ }
3184
+
3185
+ stopPropagation() {
3186
+ throw new Error('Method not implemented.');
3187
+ }
3188
+
3169
3189
  }
3170
3190
 
3171
3191
  var overArg = _overArg;
@@ -3618,10 +3638,13 @@
3618
3638
  }
3619
3639
 
3620
3640
  } //增加别名,模拟 W3C 的 EventTarget 接口
3641
+ //@ts-ignore
3621
3642
 
3622
3643
 
3623
- ICEEventTarget.prototype.addEventListener = ICEEventTarget.prototype.on;
3624
- ICEEventTarget.prototype.removeEventListener = ICEEventTarget.prototype.off;
3644
+ ICEEventTarget.prototype.addEventListener = ICEEventTarget.prototype.on; //@ts-ignore
3645
+
3646
+ ICEEventTarget.prototype.removeEventListener = ICEEventTarget.prototype.off; //@ts-ignore
3647
+
3625
3648
  ICEEventTarget.prototype.dispatchEvent = ICEEventTarget.prototype.trigger;
3626
3649
 
3627
3650
  /**
@@ -3857,10 +3880,15 @@
3857
3880
 
3858
3881
 
3859
3882
  transform(matrix) {
3860
- const tl = transformMat2d([], this.tl, matrix);
3861
- const tr = transformMat2d([], this.tr, matrix);
3862
- const bl = transformMat2d([], this.bl, matrix);
3863
- const br = transformMat2d([], this.br, matrix);
3883
+ //@ts-ignore
3884
+ const tl = transformMat2d([], this.tl, matrix); //@ts-ignore
3885
+
3886
+ const tr = transformMat2d([], this.tr, matrix); //@ts-ignore
3887
+
3888
+ const bl = transformMat2d([], this.bl, matrix); //@ts-ignore
3889
+
3890
+ const br = transformMat2d([], this.br, matrix); //@ts-ignore
3891
+
3864
3892
  const center = transformMat2d([], this.center, matrix);
3865
3893
  return new ICEBoundingBox([...tl, ...tr, ...bl, ...br, ...center]);
3866
3894
  }
@@ -4252,9 +4280,11 @@
4252
4280
 
4253
4281
  if (this.parentNode) {
4254
4282
  let pLocalX = this.parentNode.state.localOrigin[0];
4255
- let pLocalY = this.parentNode.state.localOrigin[1];
4283
+ let pLocalY = this.parentNode.state.localOrigin[1]; //@ts-ignore
4284
+
4256
4285
  point = transformMat2d([], point, [1, 0, 0, 1, -pLocalX, -pLocalY]);
4257
- let pcm = this.parentNode.state.composedMatrix;
4286
+ let pcm = this.parentNode.state.composedMatrix; //@ts-ignore
4287
+
4258
4288
  point = transformMat2d([], point, pcm);
4259
4289
  }
4260
4290
 
@@ -4277,11 +4307,13 @@
4277
4307
  const skewY = getVal(this, 'state.transform.skew.1');
4278
4308
  matrix = skew([], matrix, toRadian(skewX), toRadian(skewY)); //step2: rotate
4279
4309
 
4280
- let angle = getVal(this, 'state.transform.rotate');
4310
+ let angle = getVal(this, 'state.transform.rotate'); //@ts-ignore
4311
+
4281
4312
  matrix = rotate([], matrix, toRadian(angle)); //step3: scale
4282
4313
 
4283
4314
  const scaleX = getVal(this, 'state.transform.scale.0');
4284
- const scaleY = getVal(this, 'state.transform.scale.1');
4315
+ const scaleY = getVal(this, 'state.transform.scale.1'); //@ts-ignore
4316
+
4285
4317
  matrix = scale([], matrix, [scaleX, scaleY]);
4286
4318
  this.state.linearMatrix = matrix;
4287
4319
  return matrix;
@@ -4297,6 +4329,7 @@
4297
4329
  let matrix = component.calcLinearMatrix();
4298
4330
 
4299
4331
  while (component.parentNode) {
4332
+ //@ts-ignore
4300
4333
  matrix = multiply([], component.parentNode.state.linearMatrix, matrix);
4301
4334
  component = component.parentNode;
4302
4335
  }
@@ -4324,6 +4357,7 @@
4324
4357
  let translationMatrix = [1, 0, 0, 1, origin[0], origin[1]]; //step-2: 计算线性变换矩阵,包含了所有祖先节点的线性变换。
4325
4358
 
4326
4359
  let linearMatrix = this.calcAbsoluteLinearMatrix(); //step-3: 计算综合变换矩阵,相当于先在 canvas 默认原点(左上角位置)进行变换,然后在平移到计算出的原点位置。
4360
+ //@ts-ignore
4327
4361
 
4328
4362
  let composedMatrix = multiply([], translationMatrix, linearMatrix);
4329
4363
  this.state.composedMatrix = composedMatrix;
@@ -4476,8 +4510,10 @@
4476
4510
 
4477
4511
  //如果组件存在嵌套,需要先用逆矩阵抵消所有祖先节点 transform 导致的坐标偏移。
4478
4512
  if (this.parentNode) {
4479
- let point = [tx, ty];
4480
- let matrix = invert([], this.parentNode.state.absoluteLinearMatrix);
4513
+ let point = [tx, ty]; //@ts-ignore
4514
+
4515
+ let matrix = invert([], this.parentNode.state.absoluteLinearMatrix); //@ts-ignore
4516
+
4481
4517
  point = transformMat2d([], point, matrix);
4482
4518
  tx = point[0];
4483
4519
  ty = point[1];
@@ -4502,8 +4538,10 @@
4502
4538
 
4503
4539
  //如果组件存在嵌套,需要先用逆矩阵抵消所有祖先节点 transform 导致的坐标偏移。
4504
4540
  if (this.parentNode) {
4505
- let point = [left, top];
4506
- let matrix = invert([], this.parentNode.state.absoluteLinearMatrix);
4541
+ let point = [left, top]; //@ts-ignore
4542
+
4543
+ let matrix = invert([], this.parentNode.state.absoluteLinearMatrix); //@ts-ignore
4544
+
4507
4545
  point = transformMat2d([], point, matrix);
4508
4546
  left = point[0];
4509
4547
  top = point[1];
@@ -4545,7 +4583,8 @@
4545
4583
 
4546
4584
  localToGlobal(localX, localY) {
4547
4585
  let point = [localX, localY];
4548
- let matrix = this.state.composedMatrix;
4586
+ let matrix = this.state.composedMatrix; //@ts-ignore
4587
+
4549
4588
  point = transformMat2d([], point, matrix);
4550
4589
  return point;
4551
4590
  }
@@ -4558,8 +4597,10 @@
4558
4597
 
4559
4598
 
4560
4599
  globalToLocal(globalX, globalY) {
4561
- let point = [globalX, globalY];
4562
- let matrix = invert([], this.state.composedMatrix);
4600
+ let point = [globalX, globalY]; //@ts-ignore
4601
+
4602
+ let matrix = invert([], this.state.composedMatrix); //@ts-ignore
4603
+
4563
4604
  point = transformMat2d([], point, matrix);
4564
4605
  return point;
4565
4606
  }
@@ -5339,7 +5380,8 @@
5339
5380
  let origin = super.calcLocalOrigin();
5340
5381
 
5341
5382
  for (let i = 0; i < this.state.dots.length; i++) {
5342
- let dot = this.state.dots[i];
5383
+ let dot = this.state.dots[i]; //@ts-ignore
5384
+
5343
5385
  dot = transformMat2d([], dot, [1, 0, 0, 1, -origin[0], -origin[1]]);
5344
5386
  this.state.dots[i] = dot;
5345
5387
  }
@@ -5432,7 +5474,8 @@
5432
5474
  const result = [];
5433
5475
 
5434
5476
  for (let i = 0; i < dots.length; i++) {
5435
- const dot = dots[i];
5477
+ const dot = dots[i]; //@ts-ignore
5478
+
5436
5479
  const point = transformMat2d([], dot, matrix);
5437
5480
  result.push(point);
5438
5481
  }
@@ -5897,7 +5940,8 @@
5897
5940
 
5898
5941
  for (let i = 0; i < len; i++) {
5899
5942
  let p = this.state.points[i];
5900
- let vector2 = [p[0] - startX, p[1] - startY];
5943
+ let vector2 = [p[0] - startX, p[1] - startY]; //@ts-ignore
5944
+
5901
5945
  let crossProduct = cross([], vector1, vector2)[2];
5902
5946
 
5903
5947
  if (crossProduct === 0) {
@@ -6458,8 +6502,10 @@
6458
6502
  let newEndX = targetState.points[len - 1][0];
6459
6503
  let newEndY = targetState.points[len - 1][1]; //用逆矩阵补偿组件 transform 导致的坐标变换。
6460
6504
  //组件自身的 absoluteLinearMatrix 已经包含了所有层级上的 transform 。
6505
+ //@ts-ignore
6506
+
6507
+ let matrix = invert([], targetState.absoluteLinearMatrix); //@ts-ignore
6461
6508
 
6462
- let matrix = invert([], targetState.absoluteLinearMatrix);
6463
6509
  let point = transformMat2d([], [movementX, movementY], matrix);
6464
6510
  movementX = point[0];
6465
6511
  movementY = point[1];
@@ -6612,8 +6658,10 @@
6612
6658
  let newWidth = parentState.width;
6613
6659
  let newHeight = parentState.height; //用 parentNode 的逆矩阵把全局坐标系中的移动量转换为组件本地的移动量。
6614
6660
  //组件自身的 absoluteLinearMatrix 已经包含了所有层级上的 transform 。
6661
+ //@ts-ignore
6662
+
6663
+ let matrix = invert([], parentState.absoluteLinearMatrix); //@ts-ignore
6615
6664
 
6616
- let matrix = invert([], parentState.absoluteLinearMatrix);
6617
6665
  let point = transformMat2d([], [movementX, movementY], matrix);
6618
6666
  movementX = point[0];
6619
6667
  movementY = point[1];
@@ -6704,8 +6752,10 @@
6704
6752
  let parentState = this.parentNode.state;
6705
6753
  let parentLocalOrigin = parentState.localOrigin;
6706
6754
  let parentWidth = parentState.width;
6707
- let parentHeight = parentState.height;
6708
- let matrix = invert([], parentState.absoluteLinearMatrix);
6755
+ let parentHeight = parentState.height; //@ts-ignore
6756
+
6757
+ let matrix = invert([], parentState.absoluteLinearMatrix); //@ts-ignore
6758
+
6709
6759
  let point = transformMat2d([], [tx, ty], matrix);
6710
6760
  tx = point[0];
6711
6761
  ty = point[1];
@@ -7134,8 +7184,10 @@
7134
7184
  let newLeft = targetState.left;
7135
7185
  let newTop = targetState.top;
7136
7186
  let newWidth = targetState.width;
7137
- let newHeight = targetState.height;
7138
- let matrix = invert([], targetState.absoluteLinearMatrix);
7187
+ let newHeight = targetState.height; //@ts-ignore
7188
+
7189
+ let matrix = invert([], targetState.absoluteLinearMatrix); //@ts-ignore
7190
+
7139
7191
  let point = transformMat2d([], [movementX, movementY], matrix);
7140
7192
  movementX = point[0];
7141
7193
  movementY = point[1];
@@ -9192,7 +9244,9 @@
9192
9244
  // console.log('window.devicePixelRatio>', window.devicePixelRatio);
9193
9245
  // let tx = evt.movementX / window.devicePixelRatio; //FIXME: window.devicePixelRatio 需要移动到初始化参数中去
9194
9246
  // let ty = evt.movementY / window.devicePixelRatio; //FIXME: window.devicePixelRatio 需要移动到初始化参数中去
9195
- let tx = evt.movementX;
9247
+ //@ts-ignore
9248
+ let tx = evt.movementX; //@ts-ignore
9249
+
9196
9250
  let ty = evt.movementY;
9197
9251
  this.currentObj.moveGlobalPosition(tx, ty, evt);
9198
9252
  return true;
@@ -9365,7 +9419,9 @@
9365
9419
  let slotBounding = component.getMaxBoundingBox();
9366
9420
 
9367
9421
  if (slotBounding.isIntersect(hookBounding)) {
9422
+ //@ts-ignore
9368
9423
  for (let i = 0; i < this.ice._linkSlots.length; i++) {
9424
+ //@ts-ignore
9369
9425
  this.ice._linkSlots[i].hostComponent = component;
9370
9426
  }
9371
9427
 
@@ -9380,6 +9436,7 @@
9380
9436
 
9381
9437
 
9382
9438
  createLinkSlots() {
9439
+ //@ts-ignore
9383
9440
  if (this.ice._linkSlots && this.ice._linkSlots.length) {
9384
9441
  return;
9385
9442
  }
@@ -9439,7 +9496,8 @@
9439
9496
  lineWidth: 1
9440
9497
  }
9441
9498
  });
9442
- this.ice.addTool(slot_4);
9499
+ this.ice.addTool(slot_4); //@ts-ignore
9500
+
9443
9501
  this.ice._linkSlots = [slot_1, slot_2, slot_3, slot_4];
9444
9502
  }
9445
9503
 
@@ -9457,10 +9515,21 @@
9457
9515
  *
9458
9516
  * @author 大漠穷秋<damoqiongqiu@126.com>
9459
9517
  *
9460
- * //FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
9518
+ * FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
9461
9519
  */
9462
9520
 
9463
- const componentTypeMap = Object.fromEntries(new Map([['ICERect', ICERect], ['ICECircle', ICECircle], ['ICEEllipse', ICEEllipse], ['ICEStar', ICEStar], ['ICEIsogon', ICEIsogon], ['ICEText', ICEText], ['ICEImage', ICEImage], ['ICEGroup', ICEGroup], ['ICEVisioLink', ICEVisioLink], ['ICEPolyLine', ICEPolyLine]]));
9521
+ const componentTypeMap = {
9522
+ ICERect: ICERect,
9523
+ ICECircle: ICECircle,
9524
+ ICEEllipse: ICEEllipse,
9525
+ ICEStar: ICEStar,
9526
+ ICEIsogon: ICEIsogon,
9527
+ ICEText: ICEText,
9528
+ ICEImage: ICEImage,
9529
+ ICEGroup: ICEGroup,
9530
+ ICEVisioLink: ICEVisioLink,
9531
+ ICEPolyLine: ICEPolyLine
9532
+ };
9464
9533
 
9465
9534
  /**
9466
9535
  * Copyright (c) 2022 大漠穷秋.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "大漠穷秋",
3
3
  "name": "ice-render",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "description": "A canvas engine for interactive graphics.",
6
6
  "repository": "https://gitee.com/ice-render/ice-render",
7
7
  "browser": "dist/index.umd.js",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "start": "rollup -c -w --environment NODE_ENV:development",
19
- "build": "npm run clean && npm run build:js",
19
+ "build": "npm run clean && npm run build:types && npm run build:js",
20
20
  "build:js": "rollup -c --environment NODE_ENV:production",
21
21
  "build:types": "tsc --emitDeclarationOnly",
22
22
  "clean": "rimraf dist",