@meta2d/core 1.0.42 → 1.0.43
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/package.json +1 -1
- package/src/core.d.ts +2 -0
- package/src/core.js +79 -19
- package/src/core.js.map +1 -1
- package/src/diagrams/line/arrow.js +47 -17
- package/src/diagrams/line/arrow.js.map +1 -1
- package/src/options.js +1 -1
- package/src/pen/model.d.ts +2 -1
- package/src/pen/model.js +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +15 -4
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +5 -0
- package/src/store/store.js +3 -0
- package/src/store/store.js.map +1 -1
- package/src/theme.d.ts +13 -0
- package/src/theme.js +23 -0
- package/src/theme.js.map +1 -0
package/package.json
CHANGED
package/src/core.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export declare class Meta2d {
|
|
|
55
55
|
set beforeRemoveAnchor(fn: (pen: Pen, anchor: Point) => Promise<boolean>);
|
|
56
56
|
setOptions(opts?: Options): void;
|
|
57
57
|
getOptions(): Options;
|
|
58
|
+
setTheme(theme: string): void;
|
|
58
59
|
setDatabyOptions(options?: Options): void;
|
|
59
60
|
private init;
|
|
60
61
|
initEventFns(): void;
|
|
@@ -201,6 +202,7 @@ export declare class Meta2d {
|
|
|
201
202
|
sendDatabyHttp(data: string): Promise<void>;
|
|
202
203
|
closeHttp(): void;
|
|
203
204
|
updateTimer: any;
|
|
205
|
+
updateTimerList: any[];
|
|
204
206
|
connectNetwork(): void;
|
|
205
207
|
randomString(e: number): string;
|
|
206
208
|
penMock(pen: Pen): void;
|
package/src/core.js
CHANGED
|
@@ -113,6 +113,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
113
113
|
this.registerCanvasDraw = registerCanvasDraw;
|
|
114
114
|
this.registerAnchors = registerAnchors;
|
|
115
115
|
this.httpTimerList = [];
|
|
116
|
+
this.updateTimerList = [];
|
|
116
117
|
this.onEvent = function (eventName, e) {
|
|
117
118
|
switch (eventName) {
|
|
118
119
|
case 'add':
|
|
@@ -187,11 +188,13 @@ var Meta2d = /** @class */ (function () {
|
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
this.doEvent = function (pen, eventName) {
|
|
190
|
-
var _a, _b;
|
|
191
|
+
var _a, _b, _c, _e;
|
|
191
192
|
if (!pen) {
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
|
-
|
|
195
|
+
var old = false; //是否是旧的事件
|
|
196
|
+
var indexArr = []; //事件条件成立的索引
|
|
197
|
+
(_a = pen.events) === null || _a === void 0 ? void 0 : _a.forEach(function (event, index) {
|
|
195
198
|
var _a;
|
|
196
199
|
if (event.actions && event.actions.length) {
|
|
197
200
|
if (event.name === eventName) {
|
|
@@ -213,15 +216,17 @@ var Meta2d = /** @class */ (function () {
|
|
|
213
216
|
flag = true;
|
|
214
217
|
}
|
|
215
218
|
if (flag) {
|
|
216
|
-
event.actions.forEach(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
219
|
+
// event.actions.forEach((action) => {
|
|
220
|
+
// if (this.events[action.action]) {
|
|
221
|
+
// this.events[action.action](pen, action);
|
|
222
|
+
// }
|
|
223
|
+
// });
|
|
224
|
+
indexArr.push(index);
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
else {
|
|
229
|
+
old = true;
|
|
225
230
|
if (_this.events[event.action] && event.name === eventName) {
|
|
226
231
|
var can = !((_a = event.where) === null || _a === void 0 ? void 0 : _a.type);
|
|
227
232
|
if (event.where) {
|
|
@@ -276,15 +281,37 @@ var Meta2d = /** @class */ (function () {
|
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
283
|
}
|
|
279
|
-
can &&
|
|
284
|
+
// can && this.events[event.action](pen, event);
|
|
285
|
+
if (can) {
|
|
286
|
+
indexArr.push(index);
|
|
287
|
+
}
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
290
|
});
|
|
291
|
+
//所有的条件判断后,再统一执行条件成立的事件
|
|
292
|
+
if (old) {
|
|
293
|
+
(_b = pen.events) === null || _b === void 0 ? void 0 : _b.forEach(function (event, index) {
|
|
294
|
+
if (indexArr.includes(index)) {
|
|
295
|
+
_this.events[event.action](pen, event);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
(_c = pen.events) === null || _c === void 0 ? void 0 : _c.forEach(function (event, index) {
|
|
301
|
+
if (indexArr.includes(index)) {
|
|
302
|
+
event.actions.forEach(function (action) {
|
|
303
|
+
if (_this.events[action.action]) {
|
|
304
|
+
_this.events[action.action](pen, action);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
283
310
|
if (eventName === 'valueUpdate') {
|
|
284
|
-
(
|
|
285
|
-
var _a;
|
|
286
|
-
|
|
287
|
-
|
|
311
|
+
(_e = pen.realTimes) === null || _e === void 0 ? void 0 : _e.forEach(function (realTime) {
|
|
312
|
+
var _a, _b;
|
|
313
|
+
var indexArr = [];
|
|
314
|
+
(_a = realTime.triggers) === null || _a === void 0 ? void 0 : _a.forEach(function (trigger, index) {
|
|
288
315
|
var flag = false;
|
|
289
316
|
if (trigger.conditionType === 'and') {
|
|
290
317
|
flag = trigger.conditions.every(function (condition) {
|
|
@@ -297,6 +324,16 @@ var Meta2d = /** @class */ (function () {
|
|
|
297
324
|
});
|
|
298
325
|
}
|
|
299
326
|
if (flag) {
|
|
327
|
+
indexArr.push(index);
|
|
328
|
+
// trigger.actions?.forEach((event) => {
|
|
329
|
+
// this.events[event.action](pen, event);
|
|
330
|
+
// });
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
//执行
|
|
334
|
+
(_b = realTime.triggers) === null || _b === void 0 ? void 0 : _b.forEach(function (trigger, index) {
|
|
335
|
+
var _a;
|
|
336
|
+
if (indexArr.includes(index)) {
|
|
300
337
|
(_a = trigger.actions) === null || _a === void 0 ? void 0 : _a.forEach(function (event) {
|
|
301
338
|
_this.events[event.action](pen, event);
|
|
302
339
|
});
|
|
@@ -428,6 +465,17 @@ var Meta2d = /** @class */ (function () {
|
|
|
428
465
|
Meta2d.prototype.getOptions = function () {
|
|
429
466
|
return this.store.options;
|
|
430
467
|
};
|
|
468
|
+
Meta2d.prototype.setTheme = function (theme) {
|
|
469
|
+
this.store.data.theme = theme;
|
|
470
|
+
this.setBackgroundColor(this.store.theme[theme].background);
|
|
471
|
+
this.canvas.parentElement.style.background = this.store.theme[theme].parentBackground;
|
|
472
|
+
this.store.data.color = this.store.theme[theme].color;
|
|
473
|
+
this.setOptions({
|
|
474
|
+
ruleColor: this.store.theme[theme].ruleColor,
|
|
475
|
+
ruleOptions: this.store.theme[theme].ruleOptions
|
|
476
|
+
});
|
|
477
|
+
this.render();
|
|
478
|
+
};
|
|
431
479
|
Meta2d.prototype.setDatabyOptions = function (options) {
|
|
432
480
|
if (options === void 0) { options = {}; }
|
|
433
481
|
var color = options.color, activeColor = options.activeColor, activeBackground = options.activeBackground, grid = options.grid, gridColor = options.gridColor, gridSize = options.gridSize, fromArrow = options.fromArrow, toArrow = options.toArrow, rule = options.rule, ruleColor = options.ruleColor, textColor = options.textColor;
|
|
@@ -1985,6 +2033,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1985
2033
|
else if (net.protocol === 'http') {
|
|
1986
2034
|
https.push({
|
|
1987
2035
|
url: net.url,
|
|
2036
|
+
interval: net.interval,
|
|
1988
2037
|
headers: net.headers || undefined,
|
|
1989
2038
|
method: net.method,
|
|
1990
2039
|
body: net.body,
|
|
@@ -2185,20 +2234,26 @@ var Meta2d = /** @class */ (function () {
|
|
|
2185
2234
|
});
|
|
2186
2235
|
}); });
|
|
2187
2236
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2237
|
+
if (enable) {
|
|
2238
|
+
this.updateTimer = setInterval(function () {
|
|
2239
|
+
//模拟数据
|
|
2191
2240
|
_this.store.data.pens.forEach(function (pen) {
|
|
2192
2241
|
_this.penMock(pen);
|
|
2193
2242
|
});
|
|
2194
|
-
|
|
2243
|
+
// https.forEach(async (_item) => {
|
|
2244
|
+
// this.requestHttp(_item);
|
|
2245
|
+
// });
|
|
2246
|
+
// this.render();
|
|
2247
|
+
}, this.store.data.networkInterval || 1000);
|
|
2248
|
+
}
|
|
2249
|
+
https.forEach(function (_item, index) {
|
|
2250
|
+
_this.updateTimerList[index] = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2195
2251
|
return __generator(this, function (_a) {
|
|
2196
2252
|
this.requestHttp(_item);
|
|
2197
2253
|
return [2 /*return*/];
|
|
2198
2254
|
});
|
|
2199
|
-
}); });
|
|
2200
|
-
|
|
2201
|
-
}, this.store.data.networkInterval || 1000);
|
|
2255
|
+
}); }, _item.interval || 1000);
|
|
2256
|
+
});
|
|
2202
2257
|
};
|
|
2203
2258
|
Meta2d.prototype.requestHttp = function (_req) {
|
|
2204
2259
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2255,6 +2310,11 @@ var Meta2d = /** @class */ (function () {
|
|
|
2255
2310
|
this.websockets = undefined;
|
|
2256
2311
|
clearInterval(this.updateTimer);
|
|
2257
2312
|
this.updateTimer = undefined;
|
|
2313
|
+
this.updateTimerList &&
|
|
2314
|
+
this.updateTimerList.forEach(function (_updateTimer) {
|
|
2315
|
+
clearInterval(_updateTimer);
|
|
2316
|
+
_updateTimer = undefined;
|
|
2317
|
+
});
|
|
2258
2318
|
};
|
|
2259
2319
|
Meta2d.prototype.socketCallback = function (message, context) {
|
|
2260
2320
|
var _this = this;
|