force-graph 1.46.0 → 1.47.0

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 (39) hide show
  1. package/README.md +1 -2
  2. package/dist/force-graph.d.ts +4 -6
  3. package/dist/force-graph.js +13 -5
  4. package/dist/force-graph.js.map +1 -1
  5. package/dist/force-graph.min.js +2 -2
  6. package/example/auto-colored/index.html +1 -2
  7. package/example/basic/index.html +1 -1
  8. package/example/beeswarm/index.html +1 -2
  9. package/example/build-a-graph/index.html +1 -2
  10. package/example/click-to-focus/index.html +1 -1
  11. package/example/collision-detection/index.html +1 -2
  12. package/example/curved-links/index.html +1 -2
  13. package/example/curved-links-computed-curvature/index.html +1 -2
  14. package/example/custom-node-shape/index.html +1 -2
  15. package/example/dag-yarn/index.html +2 -3
  16. package/example/dagre/index.html +1 -1
  17. package/example/dash-odd-links/index.html +1 -1
  18. package/example/directional-links-arrows/index.html +1 -2
  19. package/example/directional-links-particles/index.html +1 -2
  20. package/example/dynamic/index.html +1 -1
  21. package/example/emit-particles/index.html +1 -2
  22. package/example/expandable-nodes/index.html +1 -1
  23. package/example/expandable-tree/index.html +1 -2
  24. package/example/fit-to-canvas/index.html +1 -2
  25. package/example/fix-dragged-nodes/index.html +1 -2
  26. package/example/highlight/index.html +1 -1
  27. package/example/huge-1M/index.html +1 -2
  28. package/example/img-nodes/index.html +1 -2
  29. package/example/large-graph/index.html +1 -2
  30. package/example/load-json/index.html +1 -2
  31. package/example/medium-graph/index.html +1 -1
  32. package/example/move-viewport/index.html +1 -2
  33. package/example/multi-selection/index.html +1 -2
  34. package/example/responsive/index.html +1 -2
  35. package/example/text-links/index.html +1 -2
  36. package/example/text-nodes/index.html +1 -2
  37. package/example/tree/index.html +2 -3
  38. package/package.json +5 -5
  39. package/src/index.d.ts +3 -5
package/README.md CHANGED
@@ -63,8 +63,7 @@ or using a *script* tag
63
63
  ```
64
64
  then
65
65
  ```js
66
- const myGraph = ForceGraph();
67
- myGraph(<myDOMElement>)
66
+ const myGraph = new ForceGraph(<myDOMElement>)
68
67
  .graphData(<myData>);
69
68
  ```
70
69
 
@@ -36,8 +36,8 @@ interface ForceFn<N = NodeObject> {
36
36
  [key: string]: any;
37
37
  }
38
38
 
39
- interface ForceGraphGenericInstance<ChainableInstance, N extends NodeObject = NodeObject, L extends LinkObject<N> = LinkObject<N>> {
40
- (element: HTMLElement): ChainableInstance;
39
+ declare class ForceGraphGeneric<ChainableInstance, N extends NodeObject = NodeObject, L extends LinkObject<N> = LinkObject<N>> {
40
+ constructor(element: HTMLElement);
41
41
  resetProps(): ChainableInstance;
42
42
  _destructor(): void;
43
43
 
@@ -190,8 +190,6 @@ interface ForceGraphGenericInstance<ChainableInstance, N extends NodeObject = No
190
190
  graph2ScreenCoords(x: number, y: number): { x: number, y: number };
191
191
  }
192
192
 
193
- type ForceGraphInstance<NodeType = NodeObject, LinkType = LinkObject<NodeType>> = ForceGraphGenericInstance<ForceGraphInstance<NodeType, LinkType>, NodeType, LinkType>;
193
+ declare class ForceGraph<NodeType = NodeObject, LinkType = LinkObject<NodeType>> extends ForceGraphGeneric<ForceGraph<NodeType, LinkType>, NodeType, LinkType> {}
194
194
 
195
- declare function ForceGraph<NodeType = NodeObject, LinkType = LinkObject<NodeType>>(): ForceGraphInstance<NodeType, LinkType>;
196
-
197
- export { type CanvasCustomRenderFn, type CanvasCustomRenderModeFn, type CanvasPointerAreaPaintFn, type ForceGraphGenericInstance, type ForceGraphInstance, type GraphData, type LinkObject, type NodeObject, ForceGraph as default };
195
+ export { type CanvasCustomRenderFn, type CanvasCustomRenderModeFn, type CanvasPointerAreaPaintFn, ForceGraphGeneric, type GraphData, type LinkObject, type NodeObject, ForceGraph as default };
@@ -1,4 +1,4 @@
1
- // Version 1.46.0 force-graph - https://github.com/vasturiano/force-graph
1
+ // Version 1.47.0 force-graph - https://github.com/vasturiano/force-graph
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -5496,8 +5496,15 @@
5496
5496
  var props = Object.keys(rawProps).map(function (propName) {
5497
5497
  return new Prop(propName, rawProps[propName]);
5498
5498
  });
5499
- return function () {
5500
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5499
+ return function KapsuleComp() {
5500
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5501
+ args[_key] = arguments[_key];
5502
+ }
5503
+ var classMode = !!(this instanceof KapsuleComp ? this.constructor : void 0);
5504
+ var nodeElement = classMode ? args.shift() : undefined;
5505
+ var _args$ = args[0],
5506
+ options = _args$ === void 0 ? {} : _args$;
5507
+
5501
5508
  // Holds component state
5502
5509
  var state = Object.assign({}, stateInit instanceof Function ? stateInit(options) : stateInit,
5503
5510
  // Support plain objects for backwards compatibility
@@ -5561,8 +5568,8 @@
5561
5568
  Object.keys(methods).forEach(function (methodName) {
5562
5569
  comp[methodName] = function () {
5563
5570
  var _methods$methodName;
5564
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5565
- args[_key] = arguments[_key];
5571
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5572
+ args[_key2] = arguments[_key2];
5566
5573
  }
5567
5574
  return (_methods$methodName = methods[methodName]).call.apply(_methods$methodName, [comp, state].concat(args));
5568
5575
  };
@@ -5589,6 +5596,7 @@
5589
5596
  comp.resetProps(); // Apply all prop defaults
5590
5597
  state._rerender = digest; // Expose digest method
5591
5598
 
5599
+ classMode && nodeElement && comp(nodeElement);
5592
5600
  return comp;
5593
5601
  };
5594
5602
  }