@meta2d/core 1.0.51 → 1.0.52
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/canvas/canvas.d.ts +2 -2
- package/src/canvas/canvas.js +48 -12
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +3 -3
- package/src/core.js +25 -10
- package/src/core.js.map +1 -1
- package/src/data.js +2 -1
- package/src/data.js.map +1 -1
- package/src/diagrams/iframe.js +2 -0
- package/src/diagrams/iframe.js.map +1 -1
- package/src/options.js +1 -1
- package/src/options.js.map +1 -1
- package/src/pen/model.d.ts +4 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +250 -1
- package/src/pen/render.js.map +1 -1
package/src/core.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ export declare class Meta2d {
|
|
|
156
156
|
* @param pens 组合的画笔们
|
|
157
157
|
* @param showChild 组合后展示第几个孩子
|
|
158
158
|
*/
|
|
159
|
-
combine(pens?: Pen[], showChild?: number):
|
|
159
|
+
combine(pens?: Pen[], showChild?: number): any;
|
|
160
160
|
uncombine(pen?: Pen): void;
|
|
161
161
|
appendChild(pens?: Pen[]): void;
|
|
162
162
|
isCombine(pen: Pen): boolean;
|
|
@@ -260,8 +260,8 @@ export declare class Meta2d {
|
|
|
260
260
|
pushChildren(parent: Pen, children: Pen[]): void;
|
|
261
261
|
renderPenRaw: typeof renderPenRaw;
|
|
262
262
|
toPng(padding?: Padding, callback?: BlobCallback, containBkImg?: boolean, maxWidth?: number): string;
|
|
263
|
-
activeToPng(padding?: Padding): string;
|
|
264
|
-
pensToPng(pens?: Pen[], padding?: Padding): string;
|
|
263
|
+
activeToPng(padding?: Padding, maxWidth?: number): string;
|
|
264
|
+
pensToPng(pens?: Pen[], padding?: Padding, maxWidth?: number): string;
|
|
265
265
|
/**
|
|
266
266
|
* 下载 png
|
|
267
267
|
* @param name 传入参数自带文件后缀名 例如:'test.png'
|
package/src/core.js
CHANGED
|
@@ -861,7 +861,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
861
861
|
value[key] = _pen[key];
|
|
862
862
|
}
|
|
863
863
|
}
|
|
864
|
-
value.id = _pen.id;
|
|
864
|
+
// value.id = _pen.id;
|
|
865
865
|
if (_pen.deviceId) {
|
|
866
866
|
value.deviceId = _pen.deviceId;
|
|
867
867
|
}
|
|
@@ -939,7 +939,8 @@ var Meta2d = /** @class */ (function () {
|
|
|
939
939
|
Meta2d.prototype.sendDataToNetWork = function (value, pen, e) {
|
|
940
940
|
var _a;
|
|
941
941
|
return __awaiter(this, void 0, void 0, function () {
|
|
942
|
-
var network, i, keys, params, res, data, fnJs, clients_1, mqttClient_1, websockets, websocket_1;
|
|
942
|
+
var network, i, keys, params, url_1, keys, res, data, fnJs, clients_1, mqttClient_1, websockets, websocket_1;
|
|
943
|
+
var _this = this;
|
|
943
944
|
return __generator(this, function (_b) {
|
|
944
945
|
switch (_b.label) {
|
|
945
946
|
case 0:
|
|
@@ -954,13 +955,16 @@ var Meta2d = /** @class */ (function () {
|
|
|
954
955
|
if (!(network.protocol === 'http')) return [3 /*break*/, 5];
|
|
955
956
|
if (typeof network.headers === 'object') {
|
|
956
957
|
for (i in network.headers) {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
958
|
+
if (typeof network.headers[i] === 'string') {
|
|
959
|
+
keys = network.headers[i].match(/(?<=\$\{).*?(?=\})/g);
|
|
960
|
+
if (keys) {
|
|
961
|
+
network.headers[i] = network.headers[i].replace("${" + keys[0] + "}", this.getDynamicParam(keys[0]));
|
|
962
|
+
}
|
|
960
963
|
}
|
|
961
964
|
}
|
|
962
965
|
}
|
|
963
966
|
params = undefined;
|
|
967
|
+
url_1 = network.url;
|
|
964
968
|
if (network.method === 'GET') {
|
|
965
969
|
params =
|
|
966
970
|
'?' +
|
|
@@ -968,7 +972,17 @@ var Meta2d = /** @class */ (function () {
|
|
|
968
972
|
.map(function (key) { return key + '=' + value[key]; })
|
|
969
973
|
.join('&');
|
|
970
974
|
}
|
|
971
|
-
|
|
975
|
+
if (network.method === 'POST') {
|
|
976
|
+
if (url_1.indexOf('${') > -1) {
|
|
977
|
+
keys = url_1.match(/(?<=\$\{).*?(?=\})/g);
|
|
978
|
+
if (keys) {
|
|
979
|
+
keys.forEach(function (key) {
|
|
980
|
+
url_1 = url_1.replace("${" + key + "}", getter(pen, key) || _this.getDynamicParam(key));
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return [4 /*yield*/, fetch(url_1 + (params ? params : ''), {
|
|
972
986
|
headers: network.headers || {},
|
|
973
987
|
method: network.method,
|
|
974
988
|
body: network.method === 'POST' ? JSON.stringify(value) : undefined,
|
|
@@ -1864,6 +1878,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1864
1878
|
}
|
|
1865
1879
|
this.store.emitter.emit('combine', [parent]);
|
|
1866
1880
|
this.render();
|
|
1881
|
+
return parent;
|
|
1867
1882
|
};
|
|
1868
1883
|
Meta2d.prototype.uncombine = function (pen) {
|
|
1869
1884
|
var _this = this;
|
|
@@ -3090,12 +3105,12 @@ var Meta2d = /** @class */ (function () {
|
|
|
3090
3105
|
if (containBkImg === void 0) { containBkImg = false; }
|
|
3091
3106
|
return this.canvas.toPng(padding, callback, containBkImg, maxWidth);
|
|
3092
3107
|
};
|
|
3093
|
-
Meta2d.prototype.activeToPng = function (padding) {
|
|
3094
|
-
return this.canvas.activeToPng(padding);
|
|
3108
|
+
Meta2d.prototype.activeToPng = function (padding, maxWidth) {
|
|
3109
|
+
return this.canvas.activeToPng(padding, maxWidth);
|
|
3095
3110
|
};
|
|
3096
|
-
Meta2d.prototype.pensToPng = function (pens, padding) {
|
|
3111
|
+
Meta2d.prototype.pensToPng = function (pens, padding, maxWidth) {
|
|
3097
3112
|
if (pens === void 0) { pens = this.store.active; }
|
|
3098
|
-
return this.canvas.pensToPng(pens, padding);
|
|
3113
|
+
return this.canvas.pensToPng(pens, padding, maxWidth);
|
|
3099
3114
|
};
|
|
3100
3115
|
/**
|
|
3101
3116
|
* 下载 png
|