@react-fabric/graph 1.0.0-beta.61 → 1.0.0-beta.63
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/css/styles.css +1 -1
- package/dist/cjs/_virtual/elk-worker.js +1 -1
- package/dist/cjs/components/ContextMenu.js +7 -7
- package/dist/cjs/components/{Context.js → Provider.js} +2 -6
- package/dist/cjs/components/Tools.js +38 -38
- package/dist/cjs/components/Viewer.js +6 -5
- package/dist/cjs/components/context.js +34 -0
- package/dist/cjs/graph/index.js +15 -15
- package/dist/cjs/programs/node-badge/factory.js +3 -2
- package/dist/cjs/programs/node-badge/texture.js +30 -30
- package/dist/cjs/programs/node-image/factory.js +3 -2
- package/dist/cjs/programs/node-image/texture.js +36 -36
- package/dist/esm/_virtual/elk-worker.js +1 -1
- package/dist/esm/components/ContextMenu.js +3 -3
- package/dist/esm/components/{Context.js → Provider.js} +3 -6
- package/dist/esm/components/Tools.js +37 -37
- package/dist/esm/components/Viewer.js +4 -3
- package/dist/esm/components/context.js +33 -0
- package/dist/esm/graph/index.js +15 -15
- package/dist/esm/programs/node-badge/factory.js +3 -2
- package/dist/esm/programs/node-badge/texture.js +30 -30
- package/dist/esm/programs/node-image/factory.js +3 -2
- package/dist/esm/programs/node-image/texture.js +36 -36
- package/dist/types/components/Provider.d.ts +3 -0
- package/dist/types/components/{Context.d.ts → context.d.ts} +3 -4
- package/dist/types/i18n/index.d.ts +0 -0
- package/dist/types/programs/edge-curve/drawLabel.d.ts +1 -1
- package/package.json +12 -12
- package/src/components/ContextMenu.tsx +11 -47
- package/src/components/{Context.tsx → Provider.tsx} +3 -30
- package/src/components/Tools.tsx +13 -51
- package/src/components/Viewer.tsx +6 -7
- package/src/components/context.ts +43 -0
- package/src/i18n/index.ts +0 -0
- package/src/programs/arrow-head/index.ts +0 -1
- package/src/programs/edge-curve/drawLabel.ts +1 -1
- package/src/programs/edge-curve/index.ts +0 -2
- package/src/programs/edge-line/index.ts +0 -2
- package/src/programs/node-badge/factory.ts +0 -2
- package/src/programs/node-circle/base/index.ts +0 -2
- package/src/programs/node-image/factory.ts +0 -2
- package/src/programs/node-rect/base/index.ts +0 -2
|
@@ -48,11 +48,11 @@ function loadRasterImage(_x) {
|
|
|
48
48
|
return _loadRasterImage.apply(this, arguments);
|
|
49
49
|
}
|
|
50
50
|
function _loadRasterImage() {
|
|
51
|
-
_loadRasterImage = _asyncToGenerator(
|
|
52
|
-
return _regeneratorRuntime.wrap(function
|
|
51
|
+
_loadRasterImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(imageSource) {
|
|
52
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
53
53
|
while (1) switch (_context2.prev = _context2.next) {
|
|
54
54
|
case 0:
|
|
55
|
-
_context2.next =
|
|
55
|
+
_context2.next = 1;
|
|
56
56
|
return new Promise(function (resolve, reject) {
|
|
57
57
|
var image = new Image();
|
|
58
58
|
image.addEventListener("load", function () {
|
|
@@ -70,9 +70,9 @@ function _loadRasterImage() {
|
|
|
70
70
|
image.setAttribute("crossOrigin", "");
|
|
71
71
|
image.src = imageSource;
|
|
72
72
|
});
|
|
73
|
-
case
|
|
73
|
+
case 1:
|
|
74
74
|
return _context2.abrupt("return", _context2.sent);
|
|
75
|
-
case
|
|
75
|
+
case 2:
|
|
76
76
|
case "end":
|
|
77
77
|
return _context2.stop();
|
|
78
78
|
}
|
|
@@ -98,7 +98,7 @@ function loadSVGImage(_x2) {
|
|
|
98
98
|
* This helper loads an image using the proper function.
|
|
99
99
|
*/
|
|
100
100
|
function _loadSVGImage() {
|
|
101
|
-
_loadSVGImage = _asyncToGenerator(
|
|
101
|
+
_loadSVGImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(imageSource) {
|
|
102
102
|
var _ref,
|
|
103
103
|
size,
|
|
104
104
|
svg,
|
|
@@ -110,7 +110,7 @@ function _loadSVGImage() {
|
|
|
110
110
|
url,
|
|
111
111
|
res,
|
|
112
112
|
_args3 = arguments;
|
|
113
|
-
return _regeneratorRuntime.wrap(function
|
|
113
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
114
114
|
while (1) switch (_context3.prev = _context3.next) {
|
|
115
115
|
case 0:
|
|
116
116
|
_ref = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {}, size = _ref.size;
|
|
@@ -119,11 +119,11 @@ function _loadSVGImage() {
|
|
|
119
119
|
originalWidth = root.getAttribute("width");
|
|
120
120
|
originalHeight = root.getAttribute("height");
|
|
121
121
|
if (!(!originalWidth || !originalHeight)) {
|
|
122
|
-
_context3.next =
|
|
122
|
+
_context3.next = 1;
|
|
123
123
|
break;
|
|
124
124
|
}
|
|
125
125
|
throw new Error("loadSVGImage: cannot use `size` if target SVG has no definite dimensions.");
|
|
126
|
-
case
|
|
126
|
+
case 1:
|
|
127
127
|
if (typeof size === "number") {
|
|
128
128
|
root.setAttribute("width", "" + size);
|
|
129
129
|
root.setAttribute("height", "" + size);
|
|
@@ -141,11 +141,11 @@ function _loadSVGImage() {
|
|
|
141
141
|
void res["finally"](function () {
|
|
142
142
|
return URL.revokeObjectURL(url);
|
|
143
143
|
});
|
|
144
|
-
_context3.next =
|
|
144
|
+
_context3.next = 2;
|
|
145
145
|
return res;
|
|
146
|
-
case
|
|
146
|
+
case 2:
|
|
147
147
|
return _context3.abrupt("return", _context3.sent);
|
|
148
|
-
case
|
|
148
|
+
case 3:
|
|
149
149
|
case "end":
|
|
150
150
|
return _context3.stop();
|
|
151
151
|
}
|
|
@@ -161,36 +161,36 @@ function loadImage(_x3) {
|
|
|
161
161
|
* This helper computes exact coordinates to draw an image onto a texture.
|
|
162
162
|
*/
|
|
163
163
|
function _loadImage() {
|
|
164
|
-
_loadImage = _asyncToGenerator(
|
|
164
|
+
_loadImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(imageSource) {
|
|
165
165
|
var _ref2,
|
|
166
166
|
isSVG,
|
|
167
167
|
image,
|
|
168
168
|
_args4 = arguments;
|
|
169
|
-
return _regeneratorRuntime.wrap(function
|
|
169
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
170
170
|
while (1) switch (_context4.prev = _context4.next) {
|
|
171
171
|
case 0:
|
|
172
172
|
_ref2 = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}, _ref2.size;
|
|
173
173
|
isSVG = utilities.isSvgPath(imageSource);
|
|
174
174
|
if (!isSVG) {
|
|
175
|
-
_context4.next =
|
|
175
|
+
_context4.next = 2;
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
|
-
_context4.next =
|
|
178
|
+
_context4.next = 1;
|
|
179
179
|
return loadSVGImage(imageSource, {
|
|
180
180
|
size: 128
|
|
181
181
|
});
|
|
182
|
-
case
|
|
182
|
+
case 1:
|
|
183
183
|
image = _context4.sent;
|
|
184
|
-
_context4.next =
|
|
184
|
+
_context4.next = 4;
|
|
185
185
|
break;
|
|
186
|
-
case
|
|
187
|
-
_context4.next =
|
|
186
|
+
case 2:
|
|
187
|
+
_context4.next = 3;
|
|
188
188
|
return loadRasterImage(imageSource);
|
|
189
|
-
case
|
|
189
|
+
case 3:
|
|
190
190
|
image = _context4.sent;
|
|
191
|
-
case
|
|
191
|
+
case 4:
|
|
192
192
|
return _context4.abrupt("return", image);
|
|
193
|
-
case
|
|
193
|
+
case 5:
|
|
194
194
|
case "end":
|
|
195
195
|
return _context4.stop();
|
|
196
196
|
}
|
|
@@ -399,46 +399,46 @@ var TextureManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
399
399
|
}, {
|
|
400
400
|
key: "registerImage",
|
|
401
401
|
value: function () {
|
|
402
|
-
var _registerImage = _asyncToGenerator(
|
|
402
|
+
var _registerImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(source) {
|
|
403
403
|
var size, image;
|
|
404
|
-
return _regeneratorRuntime.wrap(function
|
|
404
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
405
405
|
while (1) switch (_context.prev = _context.next) {
|
|
406
406
|
case 0:
|
|
407
407
|
if (!this.imageStates[source]) {
|
|
408
|
-
_context.next =
|
|
408
|
+
_context.next = 1;
|
|
409
409
|
break;
|
|
410
410
|
}
|
|
411
411
|
return _context.abrupt("return");
|
|
412
|
-
case
|
|
412
|
+
case 1:
|
|
413
413
|
this.imageStates[source] = {
|
|
414
414
|
status: "loading"
|
|
415
415
|
};
|
|
416
|
-
_context.prev =
|
|
416
|
+
_context.prev = 2;
|
|
417
417
|
size = this.options.size;
|
|
418
|
-
_context.next =
|
|
418
|
+
_context.next = 3;
|
|
419
419
|
return loadImage(source, {
|
|
420
420
|
size: size.mode === "force" ? size.value : undefined
|
|
421
421
|
});
|
|
422
|
-
case
|
|
422
|
+
case 3:
|
|
423
423
|
image = _context.sent;
|
|
424
424
|
this.imageStates[source] = _objectSpread({
|
|
425
425
|
status: "ready",
|
|
426
426
|
image: image
|
|
427
427
|
}, refineImage(image, this.corrector, this.options));
|
|
428
428
|
this.scheduleGenerateTexture();
|
|
429
|
-
_context.next =
|
|
429
|
+
_context.next = 5;
|
|
430
430
|
break;
|
|
431
|
-
case
|
|
432
|
-
_context.prev =
|
|
433
|
-
_context
|
|
431
|
+
case 4:
|
|
432
|
+
_context.prev = 4;
|
|
433
|
+
_context["catch"](2);
|
|
434
434
|
this.imageStates[source] = {
|
|
435
435
|
status: "error"
|
|
436
436
|
};
|
|
437
|
-
case
|
|
437
|
+
case 5:
|
|
438
438
|
case "end":
|
|
439
439
|
return _context.stop();
|
|
440
440
|
}
|
|
441
|
-
}, _callee, this, [[
|
|
441
|
+
}, _callee, this, [[2, 4]]);
|
|
442
442
|
}));
|
|
443
443
|
function registerImage(_x4) {
|
|
444
444
|
return _registerImage.apply(this, arguments);
|