@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.
Files changed (42) hide show
  1. package/css/styles.css +1 -1
  2. package/dist/cjs/_virtual/elk-worker.js +1 -1
  3. package/dist/cjs/components/ContextMenu.js +7 -7
  4. package/dist/cjs/components/{Context.js → Provider.js} +2 -6
  5. package/dist/cjs/components/Tools.js +38 -38
  6. package/dist/cjs/components/Viewer.js +6 -5
  7. package/dist/cjs/components/context.js +34 -0
  8. package/dist/cjs/graph/index.js +15 -15
  9. package/dist/cjs/programs/node-badge/factory.js +3 -2
  10. package/dist/cjs/programs/node-badge/texture.js +30 -30
  11. package/dist/cjs/programs/node-image/factory.js +3 -2
  12. package/dist/cjs/programs/node-image/texture.js +36 -36
  13. package/dist/esm/_virtual/elk-worker.js +1 -1
  14. package/dist/esm/components/ContextMenu.js +3 -3
  15. package/dist/esm/components/{Context.js → Provider.js} +3 -6
  16. package/dist/esm/components/Tools.js +37 -37
  17. package/dist/esm/components/Viewer.js +4 -3
  18. package/dist/esm/components/context.js +33 -0
  19. package/dist/esm/graph/index.js +15 -15
  20. package/dist/esm/programs/node-badge/factory.js +3 -2
  21. package/dist/esm/programs/node-badge/texture.js +30 -30
  22. package/dist/esm/programs/node-image/factory.js +3 -2
  23. package/dist/esm/programs/node-image/texture.js +36 -36
  24. package/dist/types/components/Provider.d.ts +3 -0
  25. package/dist/types/components/{Context.d.ts → context.d.ts} +3 -4
  26. package/dist/types/i18n/index.d.ts +0 -0
  27. package/dist/types/programs/edge-curve/drawLabel.d.ts +1 -1
  28. package/package.json +12 -12
  29. package/src/components/ContextMenu.tsx +11 -47
  30. package/src/components/{Context.tsx → Provider.tsx} +3 -30
  31. package/src/components/Tools.tsx +13 -51
  32. package/src/components/Viewer.tsx +6 -7
  33. package/src/components/context.ts +43 -0
  34. package/src/i18n/index.ts +0 -0
  35. package/src/programs/arrow-head/index.ts +0 -1
  36. package/src/programs/edge-curve/drawLabel.ts +1 -1
  37. package/src/programs/edge-curve/index.ts +0 -2
  38. package/src/programs/edge-line/index.ts +0 -2
  39. package/src/programs/node-badge/factory.ts +0 -2
  40. package/src/programs/node-circle/base/index.ts +0 -2
  41. package/src/programs/node-image/factory.ts +0 -2
  42. 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( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(imageSource) {
52
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
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 = 2;
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 2:
73
+ case 1:
74
74
  return _context2.abrupt("return", _context2.sent);
75
- case 3:
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( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(imageSource) {
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 _callee3$(_context3) {
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 = 7;
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 7:
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 = 15;
144
+ _context3.next = 2;
145
145
  return res;
146
- case 15:
146
+ case 2:
147
147
  return _context3.abrupt("return", _context3.sent);
148
- case 16:
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( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(imageSource) {
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 _callee4$(_context4) {
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 = 8;
175
+ _context4.next = 2;
176
176
  break;
177
177
  }
178
- _context4.next = 5;
178
+ _context4.next = 1;
179
179
  return loadSVGImage(imageSource, {
180
180
  size: 128
181
181
  });
182
- case 5:
182
+ case 1:
183
183
  image = _context4.sent;
184
- _context4.next = 11;
184
+ _context4.next = 4;
185
185
  break;
186
- case 8:
187
- _context4.next = 10;
186
+ case 2:
187
+ _context4.next = 3;
188
188
  return loadRasterImage(imageSource);
189
- case 10:
189
+ case 3:
190
190
  image = _context4.sent;
191
- case 11:
191
+ case 4:
192
192
  return _context4.abrupt("return", image);
193
- case 12:
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( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(source) {
402
+ var _registerImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(source) {
403
403
  var size, image;
404
- return _regeneratorRuntime.wrap(function _callee$(_context) {
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 = 2;
408
+ _context.next = 1;
409
409
  break;
410
410
  }
411
411
  return _context.abrupt("return");
412
- case 2:
412
+ case 1:
413
413
  this.imageStates[source] = {
414
414
  status: "loading"
415
415
  };
416
- _context.prev = 3;
416
+ _context.prev = 2;
417
417
  size = this.options.size;
418
- _context.next = 7;
418
+ _context.next = 3;
419
419
  return loadImage(source, {
420
420
  size: size.mode === "force" ? size.value : undefined
421
421
  });
422
- case 7:
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 = 15;
429
+ _context.next = 5;
430
430
  break;
431
- case 12:
432
- _context.prev = 12;
433
- _context.t0 = _context["catch"](3);
431
+ case 4:
432
+ _context.prev = 4;
433
+ _context["catch"](2);
434
434
  this.imageStates[source] = {
435
435
  status: "error"
436
436
  };
437
- case 15:
437
+ case 5:
438
438
  case "end":
439
439
  return _context.stop();
440
440
  }
441
- }, _callee, this, [[3, 12]]);
441
+ }, _callee, this, [[2, 4]]);
442
442
  }));
443
443
  function registerImage(_x4) {
444
444
  return _registerImage.apply(this, arguments);