@meta2d/core 1.0.54 → 1.0.55

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.d.ts CHANGED
@@ -92,6 +92,7 @@ export declare class Meta2d {
92
92
  * open 后执行初始化 Js ,每个图纸可配置一个初始化 js
93
93
  */
94
94
  private doInitJS;
95
+ doInitFn(): void;
95
96
  drawLine(lineName?: string): void;
96
97
  alignPenToGrid(pen: Pen): void;
97
98
  drawingPencil(): void;
@@ -251,6 +252,7 @@ export declare class Meta2d {
251
252
  clearRuleLines(): void;
252
253
  private onEvent;
253
254
  private doEvent;
255
+ doMessageEvent(eventName: string): void;
254
256
  doDataEvent: (datas: {
255
257
  dataId?: string;
256
258
  id?: string;
package/src/core.js CHANGED
@@ -193,31 +193,7 @@ var Meta2d = /** @class */ (function () {
193
193
  _this.store.data.locked && e && (!e.disabled) && _this.doEvent(e, eventName);
194
194
  break;
195
195
  }
196
- if (_this.store.messageEvents[eventName]) {
197
- _this.store.messageEvents[eventName].forEach(function (item) {
198
- var flag = false;
199
- if (item.event.conditions && item.event.conditions.length) {
200
- if (item.event.conditionType === 'and') {
201
- flag = item.event.conditions.every(function (condition) {
202
- return _this.judgeCondition(item.pen, condition.key, condition);
203
- });
204
- }
205
- else if (item.event.conditionType === 'or') {
206
- flag = item.event.conditions.some(function (condition) {
207
- return _this.judgeCondition(item.pen, condition.key, condition);
208
- });
209
- }
210
- }
211
- else {
212
- flag = true;
213
- }
214
- if (flag) {
215
- item.event.actions.forEach(function (action) {
216
- _this.events[action.action](item.pen, action);
217
- });
218
- }
219
- });
220
- }
196
+ _this.doMessageEvent(eventName);
221
197
  };
222
198
  this.doEvent = function (pen, eventName) {
223
199
  var e_1, _a, e_2, _b;
@@ -856,10 +832,17 @@ var Meta2d = /** @class */ (function () {
856
832
  };
857
833
  this.events[EventAction.Dialog] = function (pen, e) {
858
834
  if (e.params &&
859
- typeof e.params === 'string' &&
860
- e.value &&
861
- typeof e.value === 'string') {
862
- _this.canvas.dialog.show(e.value, e.params);
835
+ typeof e.params === 'string') {
836
+ var url_1 = e.params;
837
+ if (e.params.includes('${')) {
838
+ var keys = e.params.match(/(?<=\$\{).*?(?=\})/g);
839
+ if (keys) {
840
+ keys === null || keys === void 0 ? void 0 : keys.forEach(function (key) {
841
+ url_1 = url_1.replace("${" + key + "}", pen[key]);
842
+ });
843
+ }
844
+ }
845
+ _this.canvas.dialog.show(e.value, url_1, e.extend);
863
846
  }
864
847
  };
865
848
  this.events[EventAction.SendData] = function (pen, e) {
@@ -950,7 +933,7 @@ var Meta2d = /** @class */ (function () {
950
933
  Meta2d.prototype.sendDataToNetWork = function (value, pen, e) {
951
934
  var _a;
952
935
  return __awaiter(this, void 0, void 0, function () {
953
- var network, i, keys, params, url_1, keys, res, data, fnJs, clients_1, mqttClient_1, websockets, websocket_1;
936
+ var network, i, keys, params, url_2, keys, res, data, fnJs, clients_1, mqttClient_1, websockets, websocket_1;
954
937
  var _this = this;
955
938
  return __generator(this, function (_b) {
956
939
  switch (_b.label) {
@@ -975,7 +958,7 @@ var Meta2d = /** @class */ (function () {
975
958
  }
976
959
  }
977
960
  params = undefined;
978
- url_1 = network.url;
961
+ url_2 = network.url;
979
962
  if (network.method === 'GET') {
980
963
  params =
981
964
  '?' +
@@ -984,16 +967,16 @@ var Meta2d = /** @class */ (function () {
984
967
  .join('&');
985
968
  }
986
969
  if (network.method === 'POST') {
987
- if (url_1.indexOf('${') > -1) {
988
- keys = url_1.match(/(?<=\$\{).*?(?=\})/g);
970
+ if (url_2.indexOf('${') > -1) {
971
+ keys = url_2.match(/(?<=\$\{).*?(?=\})/g);
989
972
  if (keys) {
990
973
  keys.forEach(function (key) {
991
- url_1 = url_1.replace("${" + key + "}", getter(pen, key) || _this.getDynamicParam(key));
974
+ url_2 = url_2.replace("${" + key + "}", getter(pen, key) || _this.getDynamicParam(key));
992
975
  });
993
976
  }
994
977
  }
995
978
  }
996
- return [4 /*yield*/, fetch(url_1 + (params ? params : ''), {
979
+ return [4 /*yield*/, fetch(url_2 + (params ? params : ''), {
997
980
  headers: network.headers || {},
998
981
  method: network.method,
999
982
  body: network.method === 'POST' ? JSON.stringify(value) : undefined,
@@ -1256,6 +1239,7 @@ var Meta2d = /** @class */ (function () {
1256
1239
  this.startAnimate();
1257
1240
  this.startVideo();
1258
1241
  this.doInitJS();
1242
+ this.doInitFn();
1259
1243
  if (this.store.data.iconUrls) {
1260
1244
  try {
1261
1245
  for (var _j = __values(this.store.data.iconUrls), _k = _j.next(); !_k.done; _k = _j.next()) {
@@ -1394,6 +1378,24 @@ var Meta2d = /** @class */ (function () {
1394
1378
  }
1395
1379
  }
1396
1380
  };
1381
+ Meta2d.prototype.doInitFn = function () {
1382
+ var params = queryURLParams();
1383
+ var binds = [];
1384
+ for (var key in params) {
1385
+ if (params.hasOwnProperty(key)) {
1386
+ if (key.startsWith('bind-')) {
1387
+ binds.push({
1388
+ id: key.replace('bind-', ''),
1389
+ dataId: key.replace('bind-', ''),
1390
+ value: params[key]
1391
+ });
1392
+ }
1393
+ }
1394
+ }
1395
+ if (binds.length) {
1396
+ this.setDatas(binds, { history: false });
1397
+ }
1398
+ };
1397
1399
  Meta2d.prototype.drawLine = function (lineName) {
1398
1400
  lineName && lockedError(this.store);
1399
1401
  this.canvas.drawingLineName = lineName;
@@ -3023,6 +3025,34 @@ var Meta2d = /** @class */ (function () {
3023
3025
  Meta2d.prototype.clearRuleLines = function () {
3024
3026
  this.canvas.clearRuleLines();
3025
3027
  };
3028
+ Meta2d.prototype.doMessageEvent = function (eventName) {
3029
+ var _this = this;
3030
+ if (this.store.messageEvents[eventName]) {
3031
+ this.store.messageEvents[eventName].forEach(function (item) {
3032
+ var flag = false;
3033
+ if (item.event.conditions && item.event.conditions.length) {
3034
+ if (item.event.conditionType === 'and') {
3035
+ flag = item.event.conditions.every(function (condition) {
3036
+ return _this.judgeCondition(item.pen, condition.key, condition);
3037
+ });
3038
+ }
3039
+ else if (item.event.conditionType === 'or') {
3040
+ flag = item.event.conditions.some(function (condition) {
3041
+ return _this.judgeCondition(item.pen, condition.key, condition);
3042
+ });
3043
+ }
3044
+ }
3045
+ else {
3046
+ flag = true;
3047
+ }
3048
+ if (flag) {
3049
+ item.event.actions.forEach(function (action) {
3050
+ _this.events[action.action](item.pen, action);
3051
+ });
3052
+ }
3053
+ });
3054
+ }
3055
+ };
3026
3056
  Meta2d.prototype.initGlobalTriggers = function () {
3027
3057
  var _this = this;
3028
3058
  var _a;
@@ -3215,6 +3245,7 @@ var Meta2d = /** @class */ (function () {
3215
3245
  var childRect = calcRelativeRect(pen.calculative.worldRect, parent.calculative.worldRect);
3216
3246
  Object.assign(pen, childRect);
3217
3247
  pen.locked = (_a = pen.lockedOnCombine) !== null && _a !== void 0 ? _a : LockState.DisableMove;
3248
+ pen.locked = (pen.interaction || isInteraction.includes(pen.name)) ? 0 : pen.locked;
3218
3249
  if (!oldPen) {
3219
3250
  addPens.push(deepClone(pen, true));
3220
3251
  }