@meta2d/core 1.0.52 → 1.0.53

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/src/core.js CHANGED
@@ -612,6 +612,9 @@ var Meta2d = /** @class */ (function () {
612
612
  }
613
613
  if (opts.width !== undefined || opts.height !== undefined) {
614
614
  this.canvas && (this.canvas.canvasTemplate.bgPatchFlags = true);
615
+ if (this.canvas && this.canvas.canvasTemplate.canvas.style.backgroundImage) {
616
+ this.canvas.canvasTemplate.canvas.style.backgroundImage = '';
617
+ }
615
618
  }
616
619
  this.store.options = Object.assign(this.store.options, opts);
617
620
  if (this.canvas && opts.scroll !== undefined) {
@@ -1177,7 +1180,7 @@ var Meta2d = /** @class */ (function () {
1177
1180
  this.store.patchFlagsTop = true;
1178
1181
  };
1179
1182
  Meta2d.prototype.open = function (data, render) {
1180
- var e_3, _a, e_4, _b, e_5, _c, e_6, _e;
1183
+ var e_3, _a, e_4, _b, e_5, _c;
1181
1184
  var _this = this;
1182
1185
  if (render === void 0) { render = true; }
1183
1186
  this.clear(false, data === null || data === void 0 ? void 0 : data.template);
@@ -1188,8 +1191,8 @@ var Meta2d = /** @class */ (function () {
1188
1191
  this.store.data.pens = [];
1189
1192
  try {
1190
1193
  // 第一遍赋初值
1191
- for (var _f = __values(data.pens), _g = _f.next(); !_g.done; _g = _f.next()) {
1192
- var pen = _g.value;
1194
+ for (var _e = __values(data.pens), _f = _e.next(); !_f.done; _f = _e.next()) {
1195
+ var pen = _f.value;
1193
1196
  if (!pen.id) {
1194
1197
  pen.id = s8();
1195
1198
  }
@@ -1200,36 +1203,27 @@ var Meta2d = /** @class */ (function () {
1200
1203
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
1201
1204
  finally {
1202
1205
  try {
1203
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
1206
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
1204
1207
  }
1205
1208
  finally { if (e_3) throw e_3.error; }
1206
1209
  }
1207
1210
  try {
1208
- for (var _h = __values(data.pens), _j = _h.next(); !_j.done; _j = _h.next()) {
1209
- var pen = _j.value;
1211
+ for (var _g = __values(data.pens), _h = _g.next(); !_h.done; _h = _g.next()) {
1212
+ var pen = _h.value;
1210
1213
  this.canvas.makePen(pen);
1211
1214
  }
1212
1215
  }
1213
1216
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
1214
1217
  finally {
1215
1218
  try {
1216
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
1219
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
1217
1220
  }
1218
1221
  finally { if (e_4) throw e_4.error; }
1219
1222
  }
1220
- try {
1221
- for (var _k = __values(data.pens), _l = _k.next(); !_l.done; _l = _k.next()) {
1222
- var pen = _l.value;
1223
- this.canvas.updateLines(pen);
1224
- }
1225
- }
1226
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1227
- finally {
1228
- try {
1229
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
1230
- }
1231
- finally { if (e_5) throw e_5.error; }
1232
- }
1223
+ //首次计算连线bug
1224
+ // for (const pen of data.pens) {
1225
+ // this.canvas.updateLines(pen);
1226
+ // }
1233
1227
  }
1234
1228
  this.canvas.patchFlagsLines.forEach(function (pen) {
1235
1229
  if (pen.type) {
@@ -1256,19 +1250,19 @@ var Meta2d = /** @class */ (function () {
1256
1250
  this.doInitJS();
1257
1251
  if (this.store.data.iconUrls) {
1258
1252
  try {
1259
- for (var _m = __values(this.store.data.iconUrls), _o = _m.next(); !_o.done; _o = _m.next()) {
1260
- var item = _o.value;
1253
+ for (var _j = __values(this.store.data.iconUrls), _k = _j.next(); !_k.done; _k = _j.next()) {
1254
+ var item = _k.value;
1261
1255
  loadCss(item, function () {
1262
1256
  _this.render();
1263
1257
  });
1264
1258
  }
1265
1259
  }
1266
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1260
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1267
1261
  finally {
1268
1262
  try {
1269
- if (_o && !_o.done && (_e = _m.return)) _e.call(_m);
1263
+ if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
1270
1264
  }
1271
- finally { if (e_6) throw e_6.error; }
1265
+ finally { if (e_5) throw e_5.error; }
1272
1266
  }
1273
1267
  }
1274
1268
  this.canvas.autoPolylineFlag = false;
@@ -1509,7 +1503,7 @@ var Meta2d = /** @class */ (function () {
1509
1503
  * @param render 是否重绘
1510
1504
  */
1511
1505
  Meta2d.prototype.clear = function (render, template) {
1512
- var e_7, _a;
1506
+ var e_6, _a;
1513
1507
  var _b;
1514
1508
  if (render === void 0) { render = true; }
1515
1509
  try {
@@ -1518,12 +1512,12 @@ var Meta2d = /** @class */ (function () {
1518
1512
  (_b = pen.onDestroy) === null || _b === void 0 ? void 0 : _b.call(pen, pen);
1519
1513
  }
1520
1514
  }
1521
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1515
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1522
1516
  finally {
1523
1517
  try {
1524
1518
  if (_e && !_e.done && (_a = _c.return)) _a.call(_c);
1525
1519
  }
1526
- finally { if (e_7) throw e_7.error; }
1520
+ finally { if (e_6) throw e_6.error; }
1527
1521
  }
1528
1522
  clearStore(this.store, template);
1529
1523
  this.hideInput();
@@ -1829,7 +1823,7 @@ var Meta2d = /** @class */ (function () {
1829
1823
  if (index < minIndex) {
1830
1824
  minIndex = index;
1831
1825
  }
1832
- if (pen === parent || pen.parentId === parent.id) {
1826
+ if (pen === parent || pen.parentId === parent.id || pen.id === parent.id) {
1833
1827
  return;
1834
1828
  }
1835
1829
  // pen 来自于 store.active ,不存在有 parentId 的情况
@@ -2089,16 +2083,31 @@ var Meta2d = /** @class */ (function () {
2089
2083
  !this.store.data.mqttOptions.customClientId) {
2090
2084
  this.store.data.mqttOptions.clientId = s8();
2091
2085
  }
2092
- this.mqttClient = mqtt.connect(this.store.data.mqtt, this.store.data.mqttOptions);
2093
- this.mqttClient.on('message', function (topic, message) {
2094
- _this.socketCallback(message.toString(), {
2095
- topic: topic,
2096
- type: 'mqtt',
2097
- url: _this.store.data.mqtt,
2086
+ var mqttOptions = __assign({}, this.store.data.mqttOptions);
2087
+ // 如果没有username/password或为空字符串则删除username/password
2088
+ if (!mqttOptions.username) {
2089
+ delete mqttOptions.username;
2090
+ }
2091
+ if (!mqttOptions.password) {
2092
+ delete mqttOptions.password;
2093
+ }
2094
+ var username = mqttOptions.username, password = mqttOptions.password;
2095
+ // username 和 password 必须同时存在或者同时不存在才去建立mqtt连接
2096
+ if ((username && password) || (!username && !password)) {
2097
+ this.mqttClient = mqtt.connect(this.store.data.mqtt, mqttOptions);
2098
+ this.mqttClient.on('message', function (topic, message) {
2099
+ _this.socketCallback(message.toString(), {
2100
+ topic: topic,
2101
+ type: 'mqtt',
2102
+ url: _this.store.data.mqtt,
2103
+ });
2098
2104
  });
2099
- });
2100
- if (this.store.data.mqttTopics) {
2101
- this.mqttClient.subscribe(this.store.data.mqttTopics.split(','));
2105
+ if (this.store.data.mqttTopics) {
2106
+ this.mqttClient.subscribe(this.store.data.mqttTopics.split(','));
2107
+ }
2108
+ }
2109
+ else {
2110
+ console.warn('缺少用户名或密码');
2102
2111
  }
2103
2112
  }
2104
2113
  };
@@ -3118,7 +3127,7 @@ var Meta2d = /** @class */ (function () {
3118
3127
  * @param padding 上右下左的内边距
3119
3128
  */
3120
3129
  Meta2d.prototype.downloadPng = function (name, padding, maxWidth) {
3121
- var e_8, _a;
3130
+ var e_7, _a;
3122
3131
  var _this = this;
3123
3132
  var _b;
3124
3133
  try {
@@ -3130,12 +3139,12 @@ var Meta2d = /** @class */ (function () {
3130
3139
  }
3131
3140
  }
3132
3141
  }
3133
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
3142
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
3134
3143
  finally {
3135
3144
  try {
3136
3145
  if (_e && !_e.done && (_a = _c.return)) _a.call(_c);
3137
3146
  }
3138
- finally { if (e_8) throw e_8.error; }
3147
+ finally { if (e_7) throw e_7.error; }
3139
3148
  }
3140
3149
  setTimeout(function () {
3141
3150
  var a = document.createElement('a');
@@ -3147,7 +3156,7 @@ var Meta2d = /** @class */ (function () {
3147
3156
  }, 1000);
3148
3157
  };
3149
3158
  Meta2d.prototype.downloadSvg = function () {
3150
- var e_9, _a;
3159
+ var e_8, _a;
3151
3160
  if (!window.C2S) {
3152
3161
  console.error('请先加载乐吾乐官网下的canvas2svg.js', 'https://assets.le5lecdn.com/2d/canvas2svg.js');
3153
3162
  throw new Error('请先加载乐吾乐官网下的canvas2svg.js');
@@ -3166,12 +3175,12 @@ var Meta2d = /** @class */ (function () {
3166
3175
  renderPenRaw(ctx, pen, rect, true);
3167
3176
  }
3168
3177
  }
3169
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
3178
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
3170
3179
  finally {
3171
3180
  try {
3172
3181
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3173
3182
  }
3174
- finally { if (e_9) throw e_9.error; }
3183
+ finally { if (e_8) throw e_8.error; }
3175
3184
  }
3176
3185
  var mySerializedSVG = ctx.getSerializedSvg();
3177
3186
  if (this.store.data.background) {
@@ -3219,6 +3228,7 @@ var Meta2d = /** @class */ (function () {
3219
3228
  * @param fit true,填满但完整展示;false,填满,但长边可能截取(即显示不完整)
3220
3229
  */
3221
3230
  Meta2d.prototype.fitView = function (fit, viewPadding) {
3231
+ var _a, _b;
3222
3232
  if (fit === void 0) { fit = true; }
3223
3233
  if (viewPadding === void 0) { viewPadding = 10; }
3224
3234
  // 默认垂直填充,两边留白
@@ -3243,10 +3253,194 @@ var Meta2d = /** @class */ (function () {
3243
3253
  else {
3244
3254
  ratio = w > h ? w : h;
3245
3255
  }
3256
+ if ((_a = this.store.data.fits) === null || _a === void 0 ? void 0 : _a.length) {
3257
+ this.canvas.opening = true;
3258
+ }
3246
3259
  // 该方法直接更改画布的 scale 属性,所以比率应该乘以当前 scale
3247
3260
  this.scale(ratio * this.store.data.scale);
3248
3261
  // 5. 居中
3249
3262
  this.centerView();
3263
+ if ((_b = this.store.data.fits) === null || _b === void 0 ? void 0 : _b.length) {
3264
+ this.fillView();
3265
+ }
3266
+ };
3267
+ Meta2d.prototype.fillView = function () {
3268
+ var _this = this;
3269
+ var _a, _b;
3270
+ var rect = this.getRect();
3271
+ var wGap = this.canvas.width - rect.width;
3272
+ var hGap = this.canvas.height - rect.height;
3273
+ //宽度拉伸
3274
+ if (Math.abs(wGap) > 10) {
3275
+ (_a = this.store.data.fits) === null || _a === void 0 ? void 0 : _a.forEach(function (fit) {
3276
+ var pens = [];
3277
+ fit.children.forEach(function (id) {
3278
+ _this.store.pens[id].locked = LockState.None;
3279
+ pens.push(_this.store.pens[id]);
3280
+ });
3281
+ var r = wGap / 2;
3282
+ if (fit.left && fit.right) {
3283
+ //整体拉伸
3284
+ var left_1 = fit.leftValue;
3285
+ var right = fit.rightValue;
3286
+ if (left_1) {
3287
+ left_1 = Math.abs(left_1) < 1 ? left_1 * _this.canvas.width : left_1;
3288
+ }
3289
+ else {
3290
+ left_1 = 0;
3291
+ }
3292
+ if (right) {
3293
+ right = Math.abs(right) < 1 ? right * _this.canvas.width : right;
3294
+ }
3295
+ else {
3296
+ right = 0;
3297
+ }
3298
+ var ratio_1 = (_this.canvas.width - left_1 - right) / (rect.width - left_1 - right);
3299
+ pens.forEach(function (pen) {
3300
+ var _a;
3301
+ if (pen.image && pen.imageRatio) {
3302
+ if (pen.calculative.worldRect.width / _this.canvas.width > 0.1) {
3303
+ pen.imageRatio = false;
3304
+ }
3305
+ }
3306
+ pen.calculative.worldRect.x = rect.x - wGap / 2 + left_1 + (pen.calculative.worldRect.x - rect.x) * ratio_1; //(fit.leftValue || 0)+ (pen.calculative.worldRect.x + pen.calculative.worldRect.width/2)-( pen.calculative.worldRect.width*ratio)*(range/2- (fit.rightValue || 0))/(range- (fit.leftValue || 0)-(fit.rightValue || 0));
3307
+ pen.calculative.worldRect.width *= ratio_1;
3308
+ pen.calculative.worldRect.ex = pen.calculative.worldRect.x + pen.calculative.worldRect.width;
3309
+ pen.calculative.width = pen.calculative.worldRect.width;
3310
+ pen.calculative.x = pen.calculative.worldRect.x;
3311
+ pen.width = pen.calculative.worldRect.width;
3312
+ pen.x = pen.calculative.worldRect.x;
3313
+ _this.canvas.updatePenRect(pen, { worldRectIsReady: false });
3314
+ if (pen.externElement) {
3315
+ (_a = pen.onResize) === null || _a === void 0 ? void 0 : _a.call(pen, pen);
3316
+ }
3317
+ });
3318
+ }
3319
+ else if (fit.left) {
3320
+ //左移
3321
+ r = -r;
3322
+ if (fit.leftValue) {
3323
+ r += (Math.abs(fit.leftValue) < 1 ? fit.leftValue * _this.canvas.width : fit.leftValue);
3324
+ }
3325
+ _this.translatePens(pens, r, 0);
3326
+ }
3327
+ else if (fit.right) {
3328
+ //右移
3329
+ if (fit.rightValue) {
3330
+ r = r - (Math.abs(fit.rightValue) < 1 ? fit.rightValue * _this.canvas.width : fit.rightValue);
3331
+ }
3332
+ _this.translatePens(pens, r, 0);
3333
+ }
3334
+ });
3335
+ var iframePens = this.store.data.pens.filter(function (pen) { return pen.name === 'iframe'; });
3336
+ iframePens === null || iframePens === void 0 ? void 0 : iframePens.forEach(function (pen) {
3337
+ var _a, _b;
3338
+ var worldRect = pen.calculative.worldRect;
3339
+ if (worldRect.width / _this.store.data.scale > rect.width * 0.8) {
3340
+ var bfW = worldRect.width;
3341
+ pen.calculative.worldRect.x = worldRect.x - wGap / 2;
3342
+ pen.calculative.worldRect.width =
3343
+ worldRect.width + wGap;
3344
+ pen.calculative.worldRect.ex = worldRect.ex + wGap;
3345
+ pen.operationalRect.x =
3346
+ (pen.operationalRect.x * bfW) / pen.calculative.worldRect.width;
3347
+ pen.operationalRect.width =
3348
+ (pen.calculative.worldRect.width -
3349
+ (1 - pen.operationalRect.width) * bfW) /
3350
+ pen.calculative.worldRect.width;
3351
+ (_a = pen.onBeforeValue) === null || _a === void 0 ? void 0 : _a.call(pen, pen, {
3352
+ operationalRect: pen.operationalRect,
3353
+ });
3354
+ (_b = pen.onResize) === null || _b === void 0 ? void 0 : _b.call(pen, pen);
3355
+ }
3356
+ });
3357
+ }
3358
+ //高度拉伸
3359
+ if (Math.abs(hGap) > 10) {
3360
+ (_b = this.store.data.fits) === null || _b === void 0 ? void 0 : _b.forEach(function (fit) {
3361
+ var pens = [];
3362
+ fit.children.forEach(function (id) {
3363
+ _this.store.pens[id].locked = LockState.None;
3364
+ pens.push(_this.store.pens[id]);
3365
+ });
3366
+ var r = hGap / 2;
3367
+ if (fit.top && fit.bottom) {
3368
+ var top_1 = fit.topValue;
3369
+ var bottom = fit.bottomValue;
3370
+ if (top_1) {
3371
+ top_1 = Math.abs(top_1) < 1 ? top_1 * _this.canvas.height : top_1;
3372
+ }
3373
+ else {
3374
+ top_1 = 0;
3375
+ }
3376
+ if (bottom) {
3377
+ bottom = Math.abs(bottom) < 1 ? bottom * _this.canvas.height : bottom;
3378
+ }
3379
+ else {
3380
+ bottom = 0;
3381
+ }
3382
+ var ratio_2 = (_this.canvas.height - top_1 - bottom) / (rect.height - top_1 - bottom);
3383
+ pens.forEach(function (pen) {
3384
+ var _a;
3385
+ if (pen.image && pen.imageRatio) {
3386
+ if (pen.calculative.worldRect.height / _this.canvas.height > 0.1) {
3387
+ pen.imageRatio = false;
3388
+ }
3389
+ }
3390
+ pen.calculative.worldRect.y = rect.y - hGap / 2 + top_1 + (pen.calculative.worldRect.y - rect.y) * ratio_2; //(fit.leftValue || 0)+ (pen.calculative.worldRect.x + pen.calculative.worldRect.width/2)-( pen.calculative.worldRect.width*ratio)*(range/2- (fit.rightValue || 0))/(range- (fit.leftValue || 0)-(fit.rightValue || 0));
3391
+ pen.calculative.worldRect.height *= ratio_2;
3392
+ pen.calculative.worldRect.ey = pen.calculative.worldRect.y + pen.calculative.worldRect.height;
3393
+ pen.calculative.height = pen.calculative.worldRect.height;
3394
+ pen.calculative.y = pen.calculative.worldRect.y;
3395
+ pen.height = pen.calculative.worldRect.height;
3396
+ pen.y = pen.calculative.worldRect.y;
3397
+ _this.canvas.updatePenRect(pen, { worldRectIsReady: false });
3398
+ if (pen.externElement) {
3399
+ (_a = pen.onResize) === null || _a === void 0 ? void 0 : _a.call(pen, pen);
3400
+ }
3401
+ });
3402
+ }
3403
+ else if (fit.top) {
3404
+ r = -r;
3405
+ if (fit.topValue) {
3406
+ r += (Math.abs(fit.topValue) < 1 ? fit.topValue * _this.canvas.height : fit.topValue);
3407
+ }
3408
+ _this.translatePens(pens, 0, r);
3409
+ }
3410
+ else if (fit.bottom) {
3411
+ if (fit.bottomValue) {
3412
+ r = r - (Math.abs(fit.bottomValue) < 1 ? fit.bottomValue * _this.canvas.height : fit.bottomValue);
3413
+ }
3414
+ _this.translatePens(pens, 0, r);
3415
+ }
3416
+ });
3417
+ var iframePens = this.store.data.pens.filter(function (pen) { return pen.name === 'iframe'; });
3418
+ iframePens === null || iframePens === void 0 ? void 0 : iframePens.forEach(function (pen) {
3419
+ var _a, _b;
3420
+ var worldRect = pen.calculative.worldRect;
3421
+ if (worldRect.height / _this.store.data.scale > rect.height * 0.8) {
3422
+ var bfH = worldRect.height;
3423
+ pen.calculative.worldRect.y = worldRect.y - hGap / 2;
3424
+ pen.calculative.worldRect.height =
3425
+ worldRect.height + hGap;
3426
+ pen.calculative.worldRect.ey = worldRect.ey + hGap;
3427
+ pen.operationalRect.y =
3428
+ (pen.operationalRect.y * bfH) / pen.calculative.worldRect.width;
3429
+ pen.operationalRect.height =
3430
+ (pen.calculative.worldRect.height -
3431
+ (1 - pen.operationalRect.height) * bfH) /
3432
+ pen.calculative.worldRect.height;
3433
+ (_a = pen.onBeforeValue) === null || _a === void 0 ? void 0 : _a.call(pen, pen, {
3434
+ operationalRect: pen.operationalRect,
3435
+ });
3436
+ (_b = pen.onResize) === null || _b === void 0 ? void 0 : _b.call(pen, pen);
3437
+ }
3438
+ });
3439
+ }
3440
+ this.canvas.canvasTemplate.init();
3441
+ this.canvas.canvasImage.init();
3442
+ this.canvas.canvasImageBottom.init();
3443
+ this.render(true);
3250
3444
  };
3251
3445
  Meta2d.prototype.trimPens = function () {
3252
3446
  //去除空连线
@@ -3299,6 +3493,7 @@ var Meta2d = /** @class */ (function () {
3299
3493
  this.centerView();
3300
3494
  };
3301
3495
  Meta2d.prototype.fitSizeView = function (fit, viewPadding) {
3496
+ var _a, _b;
3302
3497
  if (fit === void 0) { fit = true; }
3303
3498
  if (viewPadding === void 0) { viewPadding = 10; }
3304
3499
  // 默认垂直填充,两边留白
@@ -3332,10 +3527,16 @@ var Meta2d = /** @class */ (function () {
3332
3527
  ratio = w > h ? w : h;
3333
3528
  }
3334
3529
  }
3530
+ if ((_a = this.store.data.fits) === null || _a === void 0 ? void 0 : _a.length) {
3531
+ this.canvas.opening = true;
3532
+ }
3335
3533
  // 该方法直接更改画布的 scale 属性,所以比率应该乘以当前 scale
3336
3534
  this.scale(ratio * this.store.data.scale);
3337
3535
  // 5. 居中
3338
3536
  this.centerSizeView();
3537
+ if ((_b = this.store.data.fits) === null || _b === void 0 ? void 0 : _b.length) {
3538
+ this.fillView();
3539
+ }
3339
3540
  };
3340
3541
  Meta2d.prototype.centerSizeView = function () {
3341
3542
  // if (!this.hasView()) return;
@@ -3564,9 +3765,9 @@ var Meta2d = /** @class */ (function () {
3564
3765
  var firstPen_1 = pens[0];
3565
3766
  formatAttrs.forEach(function (attr) {
3566
3767
  attrs[attr] =
3567
- firstPen_1[attr] ||
3568
- _this.store.options.defaultFormat[attr] ||
3569
- _this.store.options[attr];
3768
+ firstPen_1[attr] !== undefined ? firstPen_1[attr] :
3769
+ (_this.store.options.defaultFormat[attr] ||
3770
+ _this.store.options[attr]);
3570
3771
  });
3571
3772
  }
3572
3773
  else {
@@ -3630,7 +3831,7 @@ var Meta2d = /** @class */ (function () {
3630
3831
  });
3631
3832
  };
3632
3833
  Meta2d.prototype.alignNodes = function (align, pens, rect) {
3633
- var e_10, _a;
3834
+ var e_9, _a;
3634
3835
  if (pens === void 0) { pens = this.store.data.pens; }
3635
3836
  !rect && (rect = this.getPenRect(this.getRect(pens)));
3636
3837
  var initPens = deepClone(pens); // 原 pens ,深拷贝一下
@@ -3640,12 +3841,12 @@ var Meta2d = /** @class */ (function () {
3640
3841
  this.alignPen(align, item, rect);
3641
3842
  }
3642
3843
  }
3643
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
3844
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
3644
3845
  finally {
3645
3846
  try {
3646
3847
  if (pens_1_1 && !pens_1_1.done && (_a = pens_1.return)) _a.call(pens_1);
3647
3848
  }
3648
- finally { if (e_10) throw e_10.error; }
3849
+ finally { if (e_9) throw e_9.error; }
3649
3850
  }
3650
3851
  this.initImageCanvas(pens);
3651
3852
  this.initTemplateCanvas(pens);
@@ -3658,7 +3859,7 @@ var Meta2d = /** @class */ (function () {
3658
3859
  };
3659
3860
  //对齐大屏
3660
3861
  Meta2d.prototype.alignNodesV = function (align, pens) {
3661
- var e_11, _a;
3862
+ var e_10, _a;
3662
3863
  if (pens === void 0) { pens = this.store.data.pens; }
3663
3864
  var width = this.store.data.width || this.store.options.width;
3664
3865
  var height = this.store.data.height || this.store.options.height;
@@ -3675,12 +3876,12 @@ var Meta2d = /** @class */ (function () {
3675
3876
  this.alignPen(align, item, rect);
3676
3877
  }
3677
3878
  }
3678
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
3879
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
3679
3880
  finally {
3680
3881
  try {
3681
3882
  if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
3682
3883
  }
3683
- finally { if (e_11) throw e_11.error; }
3884
+ finally { if (e_10) throw e_10.error; }
3684
3885
  }
3685
3886
  this.initImageCanvas(pens);
3686
3887
  this.initTemplateCanvas(pens);
@@ -3775,7 +3976,7 @@ var Meta2d = /** @class */ (function () {
3775
3976
  * @param distance 总的宽 or 高
3776
3977
  */
3777
3978
  Meta2d.prototype.spaceBetweenByDirection = function (direction, pens, distance) {
3778
- var e_12, _a;
3979
+ var e_11, _a;
3779
3980
  var _this = this;
3780
3981
  if (pens === void 0) { pens = this.store.data.pens; }
3781
3982
  !distance && (distance = this.getPenRect(this.getRect(pens))[direction]);
@@ -3809,12 +4010,12 @@ var Meta2d = /** @class */ (function () {
3809
4010
  this.setValue(__assign({ id: pen.id }, penRect), { render: false, doEvent: false });
3810
4011
  }
3811
4012
  }
3812
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
4013
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
3813
4014
  finally {
3814
4015
  try {
3815
4016
  if (pens_3_1 && !pens_3_1.done && (_a = pens_3.return)) _a.call(pens_3);
3816
4017
  }
3817
- finally { if (e_12) throw e_12.error; }
4018
+ finally { if (e_11) throw e_11.error; }
3818
4019
  }
3819
4020
  this.initImageCanvas(pens);
3820
4021
  this.initTemplateCanvas(pens);
@@ -3878,7 +4079,7 @@ var Meta2d = /** @class */ (function () {
3878
4079
  });
3879
4080
  };
3880
4081
  Meta2d.prototype.gotoView = function (pen) {
3881
- var e_13, _a;
4082
+ var e_12, _a;
3882
4083
  var center = this.getViewCenter();
3883
4084
  var x = center.x -
3884
4085
  pen.calculative.worldRect.x -
@@ -3897,12 +4098,12 @@ var Meta2d = /** @class */ (function () {
3897
4098
  calcInView(pen_1);
3898
4099
  }
3899
4100
  }
3900
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
4101
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
3901
4102
  finally {
3902
4103
  try {
3903
4104
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3904
4105
  }
3905
- finally { if (e_13) throw e_13.error; }
4106
+ finally { if (e_12) throw e_12.error; }
3906
4107
  }
3907
4108
  this.canvas.canvasImage.init();
3908
4109
  this.canvas.canvasImageBottom.init();
@@ -3949,7 +4150,7 @@ var Meta2d = /** @class */ (function () {
3949
4150
  * @param pens pen 置顶的画笔
3950
4151
  */
3951
4152
  Meta2d.prototype.top = function (pens) {
3952
- var e_14, _a;
4153
+ var e_13, _a;
3953
4154
  var _this = this;
3954
4155
  if (!pens)
3955
4156
  pens = this.store.active;
@@ -3978,12 +4179,12 @@ var Meta2d = /** @class */ (function () {
3978
4179
  _loop_3(pen);
3979
4180
  }
3980
4181
  }
3981
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
4182
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
3982
4183
  finally {
3983
4184
  try {
3984
4185
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3985
4186
  }
3986
- finally { if (e_14) throw e_14.error; }
4187
+ finally { if (e_13) throw e_13.error; }
3987
4188
  }
3988
4189
  this.store.emitter.emit('layer', { type: 'top', pens: pens });
3989
4190
  };
@@ -4007,7 +4208,7 @@ var Meta2d = /** @class */ (function () {
4007
4208
  * @param pens 画笔们,注意 pen 必须在该数组内才有效
4008
4209
  */
4009
4210
  Meta2d.prototype.bottom = function (pens) {
4010
- var e_15, _a;
4211
+ var e_14, _a;
4011
4212
  if (!pens)
4012
4213
  pens = this.store.active;
4013
4214
  if (!Array.isArray(pens))
@@ -4039,12 +4240,12 @@ var Meta2d = /** @class */ (function () {
4039
4240
  _loop_4(pen);
4040
4241
  }
4041
4242
  }
4042
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
4243
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
4043
4244
  finally {
4044
4245
  try {
4045
4246
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4046
4247
  }
4047
- finally { if (e_15) throw e_15.error; }
4248
+ finally { if (e_14) throw e_14.error; }
4048
4249
  }
4049
4250
  this.store.emitter.emit('layer', { type: 'bottom', pens: pens });
4050
4251
  };
@@ -4054,7 +4255,7 @@ var Meta2d = /** @class */ (function () {
4054
4255
  * @param pen 画笔
4055
4256
  */
4056
4257
  Meta2d.prototype.upByArea = function (pen) {
4057
- var _a, e_16, _b;
4258
+ var _a, e_15, _b;
4058
4259
  var _this = this;
4059
4260
  var index = this.store.data.pens.findIndex(function (p) { return p.id === pen.id; });
4060
4261
  if (index === -1) {
@@ -4104,12 +4305,12 @@ var Meta2d = /** @class */ (function () {
4104
4305
  _loop_6(pen_3);
4105
4306
  }
4106
4307
  }
4107
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
4308
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
4108
4309
  finally {
4109
4310
  try {
4110
4311
  if (allPens_1_1 && !allPens_1_1.done && (_b = allPens_1.return)) _b.call(allPens_1);
4111
4312
  }
4112
- finally { if (e_16) throw e_16.error; }
4313
+ finally { if (e_15) throw e_15.error; }
4113
4314
  }
4114
4315
  this.initImageCanvas([pen]);
4115
4316
  };
@@ -4163,7 +4364,7 @@ var Meta2d = /** @class */ (function () {
4163
4364
  * @param pens 画笔
4164
4365
  */
4165
4366
  Meta2d.prototype.up = function (pens) {
4166
- var e_17, _a;
4367
+ var e_16, _a;
4167
4368
  var _this = this;
4168
4369
  if (!pens)
4169
4370
  pens = this.store.active;
@@ -4218,12 +4419,12 @@ var Meta2d = /** @class */ (function () {
4218
4419
  _loop_7(pen);
4219
4420
  }
4220
4421
  }
4221
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
4422
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
4222
4423
  finally {
4223
4424
  try {
4224
4425
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4225
4426
  }
4226
- finally { if (e_17) throw e_17.error; }
4427
+ finally { if (e_16) throw e_16.error; }
4227
4428
  }
4228
4429
  this.store.emitter.emit('layer', { type: 'up', pens: pens });
4229
4430
  };
@@ -4232,7 +4433,7 @@ var Meta2d = /** @class */ (function () {
4232
4433
  * @param pen 画笔
4233
4434
  */
4234
4435
  Meta2d.prototype.down = function (pens) {
4235
- var e_18, _a;
4436
+ var e_17, _a;
4236
4437
  var _this = this;
4237
4438
  if (!pens)
4238
4439
  pens = this.store.active;
@@ -4289,12 +4490,12 @@ var Meta2d = /** @class */ (function () {
4289
4490
  _loop_9(pen);
4290
4491
  }
4291
4492
  }
4292
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
4493
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
4293
4494
  finally {
4294
4495
  try {
4295
4496
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4296
4497
  }
4297
- finally { if (e_18) throw e_18.error; }
4498
+ finally { if (e_17) throw e_17.error; }
4298
4499
  }
4299
4500
  this.store.emitter.emit('layer', { type: 'down', pens: pens });
4300
4501
  };
@@ -4374,7 +4575,7 @@ var Meta2d = /** @class */ (function () {
4374
4575
  var nextNodes_1 = [];
4375
4576
  // 2. 遍历出线的 nextNode
4376
4577
  lines.forEach(function (line) {
4377
- var e_19, _a;
4578
+ var e_18, _a;
4378
4579
  var lineNextNode = _this.nextNode(line);
4379
4580
  var _loop_11 = function (node) {
4380
4581
  var have = nextNodes_1.find(function (next) { return next.id === node.id; });
@@ -4387,12 +4588,12 @@ var Meta2d = /** @class */ (function () {
4387
4588
  _loop_11(node);
4388
4589
  }
4389
4590
  }
4390
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
4591
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
4391
4592
  finally {
4392
4593
  try {
4393
4594
  if (lineNextNode_1_1 && !lineNextNode_1_1.done && (_a = lineNextNode_1.return)) _a.call(lineNextNode_1);
4394
4595
  }
4395
- finally { if (e_19) throw e_19.error; }
4596
+ finally { if (e_18) throw e_18.error; }
4396
4597
  }
4397
4598
  });
4398
4599
  return nextNodes_1;
@@ -4415,7 +4616,7 @@ var Meta2d = /** @class */ (function () {
4415
4616
  var preNodes_1 = [];
4416
4617
  // 2. 遍历入线的 preNode
4417
4618
  lines.forEach(function (line) {
4418
- var e_20, _a;
4619
+ var e_19, _a;
4419
4620
  var linePreNode = _this.previousNode(line);
4420
4621
  var _loop_12 = function (node) {
4421
4622
  var have = preNodes_1.find(function (pre) { return pre.id === node.id; });
@@ -4428,12 +4629,12 @@ var Meta2d = /** @class */ (function () {
4428
4629
  _loop_12(node);
4429
4630
  }
4430
4631
  }
4431
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
4632
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
4432
4633
  finally {
4433
4634
  try {
4434
4635
  if (linePreNode_1_1 && !linePreNode_1_1.done && (_a = linePreNode_1.return)) _a.call(linePreNode_1);
4435
4636
  }
4436
- finally { if (e_20) throw e_20.error; }
4637
+ finally { if (e_19) throw e_19.error; }
4437
4638
  }
4438
4639
  });
4439
4640
  return preNodes_1;
@@ -4780,7 +4981,7 @@ var Meta2d = /** @class */ (function () {
4780
4981
  });
4781
4982
  };
4782
4983
  Meta2d.prototype.setVisible = function (pen, visible, render) {
4783
- var e_21, _a;
4984
+ var e_20, _a;
4784
4985
  if (render === void 0) { render = true; }
4785
4986
  this.onSizeUpdate();
4786
4987
  this.setValue({ id: pen.id, visible: visible }, { render: false, doEvent: false });
@@ -4792,12 +4993,12 @@ var Meta2d = /** @class */ (function () {
4792
4993
  child && this.setVisible(child, visible, false);
4793
4994
  }
4794
4995
  }
4795
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
4996
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
4796
4997
  finally {
4797
4998
  try {
4798
4999
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4799
5000
  }
4800
- finally { if (e_21) throw e_21.error; }
5001
+ finally { if (e_20) throw e_20.error; }
4801
5002
  }
4802
5003
  }
4803
5004
  var allPens = getAllChildren(pen, this.store);