@dxos/react-ui-graph 0.8.4-main.b97322e → 0.8.4-main.bc2380dfbc

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 (118) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +5 -7
  3. package/dist/lib/browser/chunk-EASNZZ7B.mjs +52 -0
  4. package/dist/lib/browser/chunk-EASNZZ7B.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +1129 -298
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +16 -16
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/node-esm/chunk-JSE2X4ML.mjs +54 -0
  11. package/dist/lib/node-esm/chunk-JSE2X4ML.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +1129 -298
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +16 -16
  16. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  17. package/dist/types/src/components/Graph/Graph.d.ts +4 -5
  18. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  19. package/dist/types/src/components/Graph/Graph.stories.d.ts +20 -11
  20. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Mesh/Mesh.d.ts.map +1 -1
  22. package/dist/types/src/components/Mesh/Mesh.stories.d.ts +9 -5
  23. package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/SVG/Grid.d.ts.map +1 -1
  25. package/dist/types/src/components/SVG/Markers.d.ts.map +1 -1
  26. package/dist/types/src/components/SVG/Root.d.ts +8 -4
  27. package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
  28. package/dist/types/src/components/SVG/SVG.d.ts +14 -17
  29. package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
  30. package/dist/types/src/components/SVG/Svg.stories.d.ts +11 -9
  31. package/dist/types/src/components/SVG/Svg.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/SVG/Zoom.d.ts.map +1 -1
  33. package/dist/types/src/fx/fx.stories.d.ts +16 -15
  34. package/dist/types/src/fx/fx.stories.d.ts.map +1 -1
  35. package/dist/types/src/fx/pulsar.d.ts.map +1 -1
  36. package/dist/types/src/graph/markers.d.ts.map +1 -1
  37. package/dist/types/src/graph/projector/graph-drag.d.ts +1 -1
  38. package/dist/types/src/graph/projector/graph-drag.d.ts.map +1 -1
  39. package/dist/types/src/graph/projector/graph-force-projector.d.ts +2 -2
  40. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  41. package/dist/types/src/graph/projector/graph-forces.d.ts.map +1 -1
  42. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts +2 -2
  43. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
  44. package/dist/types/src/graph/projector/graph-projector.d.ts +4 -4
  45. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  46. package/dist/types/src/graph/projector/graph-radial-projector.d.ts +2 -2
  47. package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
  48. package/dist/types/src/graph/projector/graph-relational-projector.d.ts +2 -2
  49. package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
  50. package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
  51. package/dist/types/src/graph/renderer/bullets.d.ts.map +1 -1
  52. package/dist/types/src/graph/renderer/graph-renderer.d.ts +1 -1
  53. package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
  54. package/dist/types/src/graph/renderer/renderer.d.ts +6 -1
  55. package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
  56. package/dist/types/src/graph/types.d.ts +1 -1
  57. package/dist/types/src/graph/types.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useGrid.d.ts.map +1 -1
  59. package/dist/types/src/hooks/useStateRef.d.ts.map +1 -1
  60. package/dist/types/src/hooks/useSvgContext.d.ts.map +1 -1
  61. package/dist/types/src/hooks/useZoom.d.ts.map +1 -1
  62. package/dist/types/src/stories/hooks.stories.d.ts +14 -9
  63. package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
  64. package/dist/types/src/testing/data.d.ts +5 -5
  65. package/dist/types/src/testing/data.d.ts.map +1 -1
  66. package/dist/types/src/testing/hooks.d.ts +2 -16
  67. package/dist/types/src/testing/hooks.d.ts.map +1 -1
  68. package/dist/types/src/testing/model.d.ts +4 -8
  69. package/dist/types/src/testing/model.d.ts.map +1 -1
  70. package/dist/types/src/util/events.d.ts.map +1 -1
  71. package/dist/types/src/util/fraction.d.ts +1 -1
  72. package/dist/types/src/util/fraction.d.ts.map +1 -1
  73. package/dist/types/src/util/points.d.ts.map +1 -1
  74. package/dist/types/src/util/scale.d.ts.map +1 -1
  75. package/dist/types/src/util/screen.d.ts +1 -1
  76. package/dist/types/src/util/screen.d.ts.map +1 -1
  77. package/dist/types/src/util/vector.d.ts +1 -1
  78. package/dist/types/src/util/vector.d.ts.map +1 -1
  79. package/dist/types/tsconfig.tsbuildinfo +1 -1
  80. package/package.json +33 -35
  81. package/src/components/Graph/Graph.stories.tsx +73 -69
  82. package/src/components/Graph/Graph.tsx +25 -20
  83. package/src/components/Mesh/Mesh.stories.tsx +16 -13
  84. package/src/components/Mesh/Mesh.tsx +44 -36
  85. package/src/components/SVG/Grid.tsx +2 -2
  86. package/src/components/SVG/Markers.tsx +1 -1
  87. package/src/components/SVG/Root.tsx +41 -9
  88. package/src/components/SVG/SVG.tsx +13 -4
  89. package/src/components/SVG/Svg.stories.tsx +23 -19
  90. package/src/components/SVG/Zoom.tsx +1 -1
  91. package/src/fx/fx.stories.tsx +18 -15
  92. package/src/graph/projector/graph-drag.ts +1 -1
  93. package/src/graph/projector/graph-force-projector.ts +2 -2
  94. package/src/graph/projector/graph-forces.ts +1 -1
  95. package/src/graph/projector/graph-hierarchical-projector.ts +4 -4
  96. package/src/graph/projector/graph-projector.ts +5 -5
  97. package/src/graph/projector/graph-radial-projector.ts +3 -3
  98. package/src/graph/projector/graph-relational-projector.ts +4 -4
  99. package/src/graph/projector/projector.ts +1 -1
  100. package/src/graph/renderer/bullets.ts +1 -1
  101. package/src/graph/renderer/graph-renderer.ts +16 -7
  102. package/src/graph/renderer/renderer.ts +7 -5
  103. package/src/graph/types.ts +1 -1
  104. package/src/hooks/useStateRef.ts +1 -1
  105. package/src/hooks/useZoom.ts +1 -1
  106. package/src/stories/hooks.stories.tsx +49 -37
  107. package/src/testing/data.ts +14 -14
  108. package/src/testing/hooks.ts +5 -5
  109. package/src/testing/model.ts +6 -6
  110. package/src/util/fraction.ts +1 -1
  111. package/src/util/screen.test.ts +1 -1
  112. package/src/util/screen.ts +1 -1
  113. package/src/util/vector.ts +1 -1
  114. package/styles/graph.css +292 -43
  115. package/dist/lib/browser/chunk-MGVY54T5.mjs +0 -979
  116. package/dist/lib/browser/chunk-MGVY54T5.mjs.map +0 -7
  117. package/dist/lib/node-esm/chunk-X5YVOSXZ.mjs +0 -981
  118. package/dist/lib/node-esm/chunk-X5YVOSXZ.mjs.map +0 -7
@@ -4,10 +4,8 @@
4
4
 
5
5
  import { type RefObject } from 'react';
6
6
 
7
- import { invariant } from '@dxos/invariant';
8
-
9
7
  import { type SVGContext } from '../../hooks';
10
- import { defaultIdAccessor, type IdAccessor } from '../types';
8
+ import { type IdAccessor, defaultIdAccessor } from '../types';
11
9
 
12
10
  export type RendererOptions<T = any> = {
13
11
  idAccessor: IdAccessor;
@@ -36,8 +34,12 @@ export abstract class Renderer<LAYOUT, OPTIONS extends RendererOptions> {
36
34
  return this._context;
37
35
  }
38
36
 
39
- get root(): SVGGElement {
40
- invariant(this._root.current, 'SVG root is not initialized');
37
+ /**
38
+ * Returns the SVG group root if mounted.
39
+ * The ref may be null between mount/unmount cycles or before the SVG container has sized.
40
+ * Callers should treat null as "skip this render" rather than as an error.
41
+ */
42
+ get root(): SVGGElement | null {
41
43
  return this._root.current;
42
44
  }
43
45
 
@@ -19,7 +19,7 @@ export const defaultIdAccessor: IdAccessor = (node: any) => {
19
19
  return node.id;
20
20
  };
21
21
 
22
- export const emptyGraph: Graph = {
22
+ export const emptyGraph: Graph.Any = {
23
23
  nodes: [],
24
24
  edges: [],
25
25
  };
@@ -16,7 +16,7 @@ export const useStateRef = <V>(
16
16
  initialValue?: V | (() => V),
17
17
  ): [V | undefined, Dispatch<SetStateAction<V | undefined>>, RefObject<V | undefined>] => {
18
18
  const [value, setValue] = useState<V | undefined>(initialValue);
19
- const ref = useRef<V>();
19
+ const ref = useRef<V>(null);
20
20
  useEffect(() => {
21
21
  ref.current = value;
22
22
  }, [initialValue, value]);
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { select, zoom, type ZoomBehavior, zoomIdentity, type ZoomTransform } from 'd3';
5
+ import { type ZoomBehavior, type ZoomTransform, select, zoom, zoomIdentity } from 'd3';
6
6
  import defaultsDeep from 'lodash.defaultsdeep';
7
7
  import { type RefObject, useEffect, useMemo, useRef } from 'react';
8
8
 
@@ -2,34 +2,35 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
5
+ import '../../styles/graph.css';
6
6
 
7
- import { type StoryObj } from '@storybook/react-vite';
7
+ import { RegistryContext } from '@effect-atom/atom-react';
8
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
9
  import { select } from 'd3';
9
- import React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
10
+ import React, { type PropsWithChildren, useContext, useEffect, useMemo, useRef } from 'react';
10
11
 
11
12
  import { combine } from '@dxos/async';
13
+ import { type Graph } from '@dxos/graph';
12
14
  import { log } from '@dxos/log';
13
- import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
15
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
16
+ import { withRegistry } from '@dxos/storybook-utils';
14
17
 
15
18
  import { SVG } from '../components';
16
19
  import {
17
20
  GraphForceProjector,
18
- type GraphLayoutNode,
21
+ type GraphForceProjectorOptions,
19
22
  type GraphLayoutEdge,
23
+ type GraphLayoutNode,
20
24
  GraphRenderer,
21
- type GraphForceProjectorOptions,
22
- createMarkers,
23
25
  createGraphDrag,
26
+ createMarkers,
24
27
  linkerRenderer,
25
28
  } from '../graph';
26
- import { useSvgContext, useZoom, useGrid } from '../hooks';
27
- import { convertTreeToGraph, createTree, TestGraphModel, type TestNode } from '../testing';
29
+ import { useGrid, useSvgContext, useZoom } from '../hooks';
30
+ import { TestGraphModel, type TestNode, convertTreeToGraph, createTree } from '../testing';
28
31
 
29
- import '../../styles/graph.css';
30
-
31
- type StoryProps = PropsWithChildren<{
32
- model: TestGraphModel;
32
+ type ComponentProps = PropsWithChildren<{
33
+ graph: () => Graph.Graph<TestNode, Graph.Edge.Any>;
33
34
  projectorOptions?: GraphForceProjectorOptions;
34
35
  count?: number;
35
36
  interval?: number;
@@ -37,28 +38,20 @@ type StoryProps = PropsWithChildren<{
37
38
  grid?: boolean;
38
39
  }>;
39
40
 
40
- const DefaultStory = ({ children, ...props }: StoryProps) => {
41
- return (
42
- <>
43
- <SVG.Root>
44
- <StoryComponent {...props} />
45
- </SVG.Root>
46
- {children && <div className='absolute left-4 bottom-4 font-mono text-green-500 text-xs'>{children}</div>}
47
- </>
48
- );
49
- };
50
-
51
- const StoryComponent = ({
52
- model,
41
+ const Component = ({
42
+ graph: graphFactory,
53
43
  projectorOptions,
54
44
  count = 0,
55
45
  interval = 200,
56
46
  link = false,
57
47
  grid: showGrid = false,
58
- }: StoryProps) => {
48
+ }: ComponentProps) => {
49
+ const registry = useContext(RegistryContext);
50
+ const model = useMemo(() => new TestGraphModel(registry, graphFactory()), [registry, graphFactory]);
51
+
59
52
  const context = useSvgContext();
60
- const graphRef = useRef<SVGGElement>();
61
- const markersRef = useRef<SVGGElement>();
53
+ const graphRef = useRef<SVGGElement>(null);
54
+ const markersRef = useRef<SVGGElement>(null);
62
55
  const grid = useGrid({ visible: showGrid });
63
56
  const zoom = useZoom();
64
57
 
@@ -94,7 +87,7 @@ const StoryComponent = ({
94
87
  labels: {
95
88
  text: (node: GraphLayoutNode<TestNode>) => node.id.substring(0, 4),
96
89
  },
97
- onNodeClick: (node: GraphLayoutNode<TestNode>, event: MouseEvent) => {
90
+ onNodeClick: (node: GraphLayoutNode<TestNode>) => {
98
91
  renderer.fireBullet(node);
99
92
  },
100
93
  onLinkClick: (edge: GraphLayoutEdge<TestNode>, event: MouseEvent) => {
@@ -116,9 +109,14 @@ const StoryComponent = ({
116
109
  }, [markersRef]);
117
110
 
118
111
  useEffect(() => {
112
+ // Prime the projector with the initial graph — `model.subscribe` only fires on changes by default,
113
+ // so without this the simulation starts empty and the renderer never sees any nodes.
114
+ // The subscribe callback receives `(model, graph)` from GraphModel; use the model reference
115
+ // we already have to fetch the current snapshot.
116
+ projector.updateData(model.graph);
119
117
  void projector.start();
120
118
  return combine(
121
- model.subscribe((graph) => projector.updateData(graph)),
119
+ model.subscribe(() => projector.updateData(model.graph)),
122
120
  projector.updated.on(({ layout }) => renderer.render(layout)),
123
121
  () => projector.stop(),
124
122
  );
@@ -151,19 +149,33 @@ const StoryComponent = ({
151
149
  );
152
150
  };
153
151
 
154
- const meta: Meta = {
152
+ const DefaultStory = ({ children, ...props }: ComponentProps) => {
153
+ return (
154
+ <>
155
+ <SVG.Root>
156
+ <Component {...props} />
157
+ </SVG.Root>
158
+ {children && <div className='absolute left-4 bottom-4 font-mono text-green-500 text-xs'>{children}</div>}
159
+ </>
160
+ );
161
+ };
162
+
163
+ const meta = {
155
164
  title: 'ui/react-ui-graph/hooks',
156
165
  render: DefaultStory,
157
- decorators: [withTheme, withLayout({ fullscreen: true })],
158
- };
166
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'fullscreen' })],
167
+ parameters: {
168
+ layout: 'fullscreen',
169
+ },
170
+ } satisfies Meta<typeof DefaultStory>;
159
171
 
160
172
  export default meta;
161
173
 
162
- type Story = StoryObj<typeof DefaultStory>;
174
+ type Story = StoryObj<typeof meta>;
163
175
 
164
176
  export const Default: Story = {
165
177
  args: {
166
- model: new TestGraphModel(convertTreeToGraph(createTree({ depth: 3 }))),
178
+ graph: () => convertTreeToGraph(createTree({ depth: 3 })),
167
179
  grid: true,
168
180
  count: 300,
169
181
  interval: 20,
@@ -188,7 +200,7 @@ export const Default: Story = {
188
200
 
189
201
  export const Bullets: Story = {
190
202
  args: {
191
- model: new TestGraphModel(convertTreeToGraph(createTree({ depth: 4 }))),
203
+ graph: () => convertTreeToGraph(createTree({ depth: 4 })),
192
204
  children: <span>⌘-DRAG to edge or create node; ⌘-CLICK to delete edge.</span>,
193
205
  link: true,
194
206
  grid: false,
@@ -2,28 +2,28 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type BaseGraphEdge, type Graph } from '@dxos/graph';
6
- import { faker } from '@dxos/random';
5
+ import { type Graph } from '@dxos/graph';
6
+ import { random } from '@dxos/random';
7
7
 
8
8
  import { type TestNode } from './model';
9
9
 
10
- // https://www.npmjs.com/package/faker#setting-a-randomness-seed
11
- export const seed = (seed: number) => faker.seed(seed);
10
+ // https://www.npmjs.com/package/random#setting-a-randomness-seed
11
+ export const seed = (seed: number) => random.seed(seed);
12
12
 
13
13
  //
14
14
  // Create data.
15
15
  //
16
16
 
17
17
  export const createNode = (type: string = undefined): TestNode => ({
18
- id: faker.string.uuid(),
18
+ id: random.string.uuid(),
19
19
  type,
20
- label: faker.lorem.words(3).replace(/ /g, '-'),
20
+ label: random.lorem.words(3).replace(/ /g, '-'),
21
21
  });
22
22
 
23
23
  export const createNodes = (n = 0, types?: string[]): TestNode[] =>
24
- Array.from({ length: n }, () => createNode(types ? faker.helpers.arrayElement(types) : undefined));
24
+ Array.from({ length: n }, () => createNode(types ? random.helpers.arrayElement(types) : undefined));
25
25
 
26
- export const createEdge = (source: TestNode, target: TestNode): BaseGraphEdge => ({
26
+ export const createEdge = (source: TestNode, target: TestNode): Graph.Edge.Any => ({
27
27
  id: `${source.id}-${target.id}`,
28
28
  source: source.id,
29
29
  target: target.id,
@@ -38,7 +38,7 @@ export const createTree = ({ depth = 2, children = 3 } = {}): TestNode => {
38
38
  const createChildren = (root: TestNode, d = 0) => {
39
39
  if (d < depth) {
40
40
  const max = Math.round(Math.log(depth + 1 - d) * children);
41
- const num = faker.number.int({ min: 1, max });
41
+ const num = random.number.int({ min: 1, max });
42
42
  root.children = [...new Array(num)].map(() => {
43
43
  return createChildren(createNode(), d + 1);
44
44
  });
@@ -54,8 +54,8 @@ export const createTree = ({ depth = 2, children = 3 } = {}): TestNode => {
54
54
  * Converts a tree into a graph.
55
55
  * @param root
56
56
  */
57
- export const convertTreeToGraph = (root: TestNode): Graph => {
58
- const traverse = (node: TestNode, graph: Graph) => {
57
+ export const convertTreeToGraph = (root: TestNode): Graph.Any => {
58
+ const traverse = (node: TestNode, graph: Graph.Any) => {
59
59
  graph.nodes.push(node);
60
60
  node.children?.forEach((child) => {
61
61
  graph.edges.push(createEdge(node, child));
@@ -76,14 +76,14 @@ export const convertTreeToGraph = (root: TestNode): Graph => {
76
76
  * @param numNodes
77
77
  * @param numEdges
78
78
  */
79
- export const createGraph = (numNodes = 0, numEdges = 0, types?: string[]): Graph => {
79
+ export const createGraph = (numNodes = 0, numEdges = 0, types?: string[]): Graph.Any => {
80
80
  const nodes = createNodes(numNodes, types);
81
81
 
82
82
  const edges = new Map();
83
83
  if (numEdges && nodes.length >= 2) {
84
84
  for (let i = 0; i < numEdges; i++) {
85
- const source = faker.helpers.arrayElement(nodes);
86
- const target = faker.helpers.arrayElement(nodes);
85
+ const source = random.helpers.arrayElement(nodes);
86
+ const target = random.helpers.arrayElement(nodes);
87
87
  if (source.id !== target.id) {
88
88
  const edge = createEdge(source, target);
89
89
  if (!edges.get(edge.id)) {
@@ -5,11 +5,11 @@
5
5
  import update from 'immutability-helper';
6
6
 
7
7
  import { type Graph } from '@dxos/graph';
8
- import { faker } from '@dxos/random';
8
+ import { random } from '@dxos/random';
9
9
 
10
- import { createNode, createEdge } from './data';
11
- import { type TestNode } from './model';
12
10
  import { useStateRef } from '../hooks';
11
+ import { createEdge, createNode } from './data';
12
+ import { type TestNode } from './model';
13
13
 
14
14
  export type ObjectMutator<T> = [
15
15
  T, // Current value.
@@ -46,13 +46,13 @@ export const useObjectMutator = <T>(initalValue: T): ObjectMutator<T> => {
46
46
  /**
47
47
  * Test data set generator and mutator.
48
48
  */
49
- export const useGraphGenerator = (options: { data?: Graph } = {}) => {
49
+ export const useGraphGenerator = (options: { data?: Graph.Any } = {}) => {
50
50
  const [data, setData, updateData] = useObjectMutator(options.data || { nodes: [], edges: [] });
51
51
 
52
52
  let interval;
53
53
 
54
54
  const mutator = () => {
55
- const parent = data.nodes.length ? faker.helpers.arrayElement(data.nodes) : undefined;
55
+ const parent = data.nodes.length ? random.helpers.arrayElement(data.nodes) : undefined;
56
56
  const node = createNode();
57
57
 
58
58
  updateData({
@@ -2,25 +2,25 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { type BaseGraphNode, ReactiveGraphModel } from '@dxos/graph';
6
- import { faker } from '@dxos/random';
5
+ import { type Graph, GraphModel } from '@dxos/graph';
6
+ import { random } from '@dxos/random';
7
7
 
8
8
  import { createEdge, createNode } from './data';
9
9
 
10
- export type TestNode = BaseGraphNode & {
10
+ export type TestNode = Graph.Node.Any & {
11
11
  label?: string;
12
12
  children?: TestNode[];
13
13
  };
14
14
 
15
- export class TestGraphModel extends ReactiveGraphModel<TestNode> {
15
+ export class TestGraphModel extends GraphModel.ReactiveGraphModel<TestNode> {
16
16
  getRandomNode() {
17
- return faker.helpers.arrayElement(this._graph.nodes);
17
+ return random.helpers.arrayElement(this._graph.nodes);
18
18
  }
19
19
 
20
20
  createNodes(node: TestNode = undefined, n = 1): void {
21
21
  Array.from({ length: n }).forEach(() => {
22
22
  const child = this.addNode(createNode());
23
- const parent = node || faker.helpers.arrayElement(this._graph.nodes);
23
+ const parent = node || random.helpers.arrayElement(this._graph.nodes);
24
24
  if (parent) {
25
25
  this.addEdge(createEdge(parent, child));
26
26
  }
@@ -30,7 +30,7 @@ export class FractionUtil {
30
30
 
31
31
  /**
32
32
  * @param {Fraction}
33
- * Convert to rounded number.
33
+ * Convert to rounded-sm number.
34
34
  */
35
35
  static toNumber = ([n, d]: Fraction): number => {
36
36
  FractionUtil.validate([n, d]);
@@ -5,7 +5,7 @@
5
5
  import { expect, test } from 'vitest';
6
6
 
7
7
  import { Screen } from './screen';
8
- import { type Rect, type Point } from './types';
8
+ import { type Point, type Rect } from './types';
9
9
 
10
10
  test('createBounds', () => {
11
11
  const tests: { p1: Point; p2: Point; bounds: Rect }[] = [
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type Rect, type Point } from './types';
5
+ import { type Point, type Rect } from './types';
6
6
 
7
7
  export type Modifiers = {
8
8
  center?: boolean;
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type Num, type Fraction, FractionUtil } from './fraction';
5
+ import { type Fraction, FractionUtil, type Num } from './fraction';
6
6
 
7
7
  export type Vertex = { x: Fraction; y: Fraction };
8
8