@yh-ui/flow 1.0.25 → 1.0.30
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 +13 -11
- package/LICENSE +0 -21
- package/dist/__tests__/ai-workflow.ssr.test.cjs +0 -352
- package/dist/__tests__/ai-workflow.ssr.test.d.ts +0 -1
- package/dist/__tests__/ai-workflow.ssr.test.mjs +0 -283
- package/dist/__tests__/ai-workflow.test.cjs +0 -109
- package/dist/__tests__/ai-workflow.test.d.ts +0 -1
- package/dist/__tests__/ai-workflow.test.mjs +0 -112
- package/dist/__tests__/bpmn-engine.test.cjs +0 -357
- package/dist/__tests__/bpmn-engine.test.d.ts +0 -1
- package/dist/__tests__/bpmn-engine.test.mjs +0 -406
- package/dist/__tests__/bpmn-utils.test.cjs +0 -268
- package/dist/__tests__/bpmn-utils.test.d.ts +0 -1
- package/dist/__tests__/bpmn-utils.test.mjs +0 -227
- package/dist/__tests__/bpmn-xml.test.cjs +0 -150
- package/dist/__tests__/bpmn-xml.test.d.ts +0 -1
- package/dist/__tests__/bpmn-xml.test.mjs +0 -112
- package/dist/__tests__/bpmn.ssr.test.cjs +0 -278
- package/dist/__tests__/bpmn.ssr.test.d.ts +0 -1
- package/dist/__tests__/bpmn.ssr.test.mjs +0 -237
- package/dist/__tests__/bpmn.test.cjs +0 -103
- package/dist/__tests__/bpmn.test.d.ts +0 -1
- package/dist/__tests__/bpmn.test.mjs +0 -106
- package/dist/__tests__/collaboration.test.cjs +0 -487
- package/dist/__tests__/collaboration.test.d.ts +0 -1
- package/dist/__tests__/collaboration.test.mjs +0 -424
- package/dist/__tests__/custom-types.test.cjs +0 -300
- package/dist/__tests__/custom-types.test.d.ts +0 -1
- package/dist/__tests__/custom-types.test.mjs +0 -248
- package/dist/__tests__/edge-types.test.cjs +0 -275
- package/dist/__tests__/edge-types.test.d.ts +0 -1
- package/dist/__tests__/edge-types.test.mjs +0 -234
- package/dist/__tests__/edge-utils.test.cjs +0 -375
- package/dist/__tests__/edge-utils.test.d.ts +0 -1
- package/dist/__tests__/edge-utils.test.mjs +0 -376
- package/dist/__tests__/edge.test.cjs +0 -56
- package/dist/__tests__/edge.test.d.ts +0 -1
- package/dist/__tests__/edge.test.mjs +0 -69
- package/dist/__tests__/event-bus.test.cjs +0 -80
- package/dist/__tests__/event-bus.test.d.ts +0 -1
- package/dist/__tests__/event-bus.test.mjs +0 -51
- package/dist/__tests__/events-types.test.cjs +0 -184
- package/dist/__tests__/events-types.test.d.ts +0 -1
- package/dist/__tests__/events-types.test.mjs +0 -184
- package/dist/__tests__/export-image-plugin.test.cjs +0 -142
- package/dist/__tests__/export-image-plugin.test.d.ts +0 -1
- package/dist/__tests__/export-image-plugin.test.mjs +0 -118
- package/dist/__tests__/export.test.cjs +0 -237
- package/dist/__tests__/export.test.d.ts +0 -1
- package/dist/__tests__/export.test.mjs +0 -171
- package/dist/__tests__/flow-context.test.cjs +0 -16
- package/dist/__tests__/flow-context.test.d.ts +0 -1
- package/dist/__tests__/flow-context.test.mjs +0 -16
- package/dist/__tests__/flow-props.test.cjs +0 -94
- package/dist/__tests__/flow-props.test.d.ts +0 -1
- package/dist/__tests__/flow-props.test.mjs +0 -92
- package/dist/__tests__/flow.ssr.test.cjs +0 -156
- package/dist/__tests__/flow.ssr.test.d.ts +0 -1
- package/dist/__tests__/flow.ssr.test.mjs +0 -112
- package/dist/__tests__/geometry.test.cjs +0 -191
- package/dist/__tests__/geometry.test.d.ts +0 -1
- package/dist/__tests__/geometry.test.mjs +0 -105
- package/dist/__tests__/graph.test.cjs +0 -115
- package/dist/__tests__/graph.test.d.ts +0 -1
- package/dist/__tests__/graph.test.mjs +0 -85
- package/dist/__tests__/history-plugin.test.cjs +0 -191
- package/dist/__tests__/history-plugin.test.d.ts +0 -1
- package/dist/__tests__/history-plugin.test.mjs +0 -161
- package/dist/__tests__/history.test.cjs +0 -81
- package/dist/__tests__/history.test.d.ts +0 -1
- package/dist/__tests__/history.test.mjs +0 -43
- package/dist/__tests__/layout-plugin.test.cjs +0 -233
- package/dist/__tests__/layout-plugin.test.d.ts +0 -1
- package/dist/__tests__/layout-plugin.test.mjs +0 -215
- package/dist/__tests__/layout.test.cjs +0 -213
- package/dist/__tests__/layout.test.d.ts +0 -1
- package/dist/__tests__/layout.test.mjs +0 -170
- package/dist/__tests__/node-edit-panel.ssr.test.cjs +0 -168
- package/dist/__tests__/node-edit-panel.ssr.test.d.ts +0 -1
- package/dist/__tests__/node-edit-panel.ssr.test.mjs +0 -118
- package/dist/__tests__/node-group-plugin.test.cjs +0 -235
- package/dist/__tests__/node-group-plugin.test.d.ts +0 -1
- package/dist/__tests__/node-group-plugin.test.mjs +0 -187
- package/dist/__tests__/node-handles.test.cjs +0 -340
- package/dist/__tests__/node-handles.test.d.ts +0 -1
- package/dist/__tests__/node-handles.test.mjs +0 -230
- package/dist/__tests__/node-types.test.cjs +0 -368
- package/dist/__tests__/node-types.test.d.ts +0 -1
- package/dist/__tests__/node-types.test.mjs +0 -292
- package/dist/__tests__/performance.test.cjs +0 -313
- package/dist/__tests__/performance.test.d.ts +0 -1
- package/dist/__tests__/performance.test.mjs +0 -218
- package/dist/__tests__/plugin-advanced.test.cjs +0 -301
- package/dist/__tests__/plugin-advanced.test.d.ts +0 -1
- package/dist/__tests__/plugin-advanced.test.mjs +0 -225
- package/dist/__tests__/plugin.test.cjs +0 -151
- package/dist/__tests__/plugin.test.d.ts +0 -1
- package/dist/__tests__/plugin.test.mjs +0 -116
- package/dist/__tests__/plugins.test.cjs +0 -412
- package/dist/__tests__/plugins.test.d.ts +0 -1
- package/dist/__tests__/plugins.test.mjs +0 -402
- package/dist/__tests__/screenshot-capture.test.cjs +0 -183
- package/dist/__tests__/screenshot-capture.test.d.ts +0 -1
- package/dist/__tests__/screenshot-capture.test.mjs +0 -124
- package/dist/__tests__/screenshot.test.cjs +0 -74
- package/dist/__tests__/screenshot.test.d.ts +0 -1
- package/dist/__tests__/screenshot.test.mjs +0 -69
- package/dist/__tests__/theme.test.cjs +0 -185
- package/dist/__tests__/theme.test.d.ts +0 -1
- package/dist/__tests__/theme.test.mjs +0 -191
- package/dist/__tests__/transform.test.cjs +0 -384
- package/dist/__tests__/transform.test.d.ts +0 -1
- package/dist/__tests__/transform.test.mjs +0 -239
- package/dist/__tests__/useAlignment.test.cjs +0 -128
- package/dist/__tests__/useAlignment.test.d.ts +0 -1
- package/dist/__tests__/useAlignment.test.mjs +0 -72
- package/dist/__tests__/useEdges.test.cjs +0 -117
- package/dist/__tests__/useEdges.test.d.ts +0 -1
- package/dist/__tests__/useEdges.test.mjs +0 -80
- package/dist/__tests__/useKeyboard.test.cjs +0 -88
- package/dist/__tests__/useKeyboard.test.d.ts +0 -1
- package/dist/__tests__/useKeyboard.test.mjs +0 -56
- package/dist/__tests__/useNodeDistribution.test.cjs +0 -643
- package/dist/__tests__/useNodeDistribution.test.d.ts +0 -1
- package/dist/__tests__/useNodeDistribution.test.mjs +0 -297
- package/dist/__tests__/useNodes.test.cjs +0 -150
- package/dist/__tests__/useNodes.test.d.ts +0 -1
- package/dist/__tests__/useNodes.test.mjs +0 -80
- package/dist/__tests__/useSelection.test.cjs +0 -112
- package/dist/__tests__/useSelection.test.d.ts +0 -1
- package/dist/__tests__/useSelection.test.mjs +0 -76
- package/dist/__tests__/useViewport.test.cjs +0 -171
- package/dist/__tests__/useViewport.test.d.ts +0 -1
- package/dist/__tests__/useViewport.test.mjs +0 -82
- package/dist/__tests__/utils/ssr.cjs +0 -124
- package/dist/__tests__/utils/ssr.d.ts +0 -33
- package/dist/__tests__/utils/ssr.mjs +0 -129
- package/dist/__tests__/validation.test.cjs +0 -95
- package/dist/__tests__/validation.test.d.ts +0 -1
- package/dist/__tests__/validation.test.mjs +0 -36
- package/dist/__tests__/viewport-types.test.cjs +0 -324
- package/dist/__tests__/viewport-types.test.d.ts +0 -1
- package/dist/__tests__/viewport-types.test.mjs +0 -207
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _Flow = _interopRequireDefault(require("../Flow.vue"));
|
|
5
|
-
var _ssr = require("./utils/ssr.cjs");
|
|
6
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
(0, _vitest.describe)("Flow SSR", () => {
|
|
8
|
-
(0, _vitest.it)("should render Flow component in SSR", async () => {
|
|
9
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
10
|
-
nodes: [],
|
|
11
|
-
edges: []
|
|
12
|
-
});
|
|
13
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
14
|
-
});
|
|
15
|
-
(0, _vitest.it)("should render with custom class in SSR", async () => {
|
|
16
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
17
|
-
nodes: [],
|
|
18
|
-
edges: [],
|
|
19
|
-
class: "custom-flow"
|
|
20
|
-
});
|
|
21
|
-
(0, _ssr.expectSSRHasClass)(html, "custom-flow");
|
|
22
|
-
});
|
|
23
|
-
(0, _vitest.it)("should render nodes in SSR", async () => {
|
|
24
|
-
const nodes = [{
|
|
25
|
-
id: "1",
|
|
26
|
-
type: "default",
|
|
27
|
-
position: {
|
|
28
|
-
x: 0,
|
|
29
|
-
y: 0
|
|
30
|
-
},
|
|
31
|
-
data: {
|
|
32
|
-
label: "Node 1"
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
id: "2",
|
|
36
|
-
type: "default",
|
|
37
|
-
position: {
|
|
38
|
-
x: 100,
|
|
39
|
-
y: 100
|
|
40
|
-
},
|
|
41
|
-
data: {
|
|
42
|
-
label: "Node 2"
|
|
43
|
-
}
|
|
44
|
-
}];
|
|
45
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
46
|
-
nodes,
|
|
47
|
-
edges: []
|
|
48
|
-
});
|
|
49
|
-
(0, _ssr.expectSSRContains)(html, "Node 1");
|
|
50
|
-
(0, _ssr.expectSSRContains)(html, "Node 2");
|
|
51
|
-
});
|
|
52
|
-
(0, _vitest.it)("should render edges in SSR", async () => {
|
|
53
|
-
const nodes = [{
|
|
54
|
-
id: "1",
|
|
55
|
-
type: "default",
|
|
56
|
-
position: {
|
|
57
|
-
x: 0,
|
|
58
|
-
y: 0
|
|
59
|
-
},
|
|
60
|
-
data: {
|
|
61
|
-
label: "A"
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
id: "2",
|
|
65
|
-
type: "default",
|
|
66
|
-
position: {
|
|
67
|
-
x: 100,
|
|
68
|
-
y: 0
|
|
69
|
-
},
|
|
70
|
-
data: {
|
|
71
|
-
label: "B"
|
|
72
|
-
}
|
|
73
|
-
}];
|
|
74
|
-
const edges = [{
|
|
75
|
-
id: "e1",
|
|
76
|
-
source: "1",
|
|
77
|
-
target: "2"
|
|
78
|
-
}];
|
|
79
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
80
|
-
nodes,
|
|
81
|
-
edges
|
|
82
|
-
});
|
|
83
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow-edge");
|
|
84
|
-
});
|
|
85
|
-
(0, _vitest.it)("should render with fitView props in SSR", async () => {
|
|
86
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
87
|
-
nodes: [],
|
|
88
|
-
edges: [],
|
|
89
|
-
fitView: true
|
|
90
|
-
});
|
|
91
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
92
|
-
});
|
|
93
|
-
(0, _vitest.it)("should render with minZoom and maxZoom in SSR", async () => {
|
|
94
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
95
|
-
nodes: [],
|
|
96
|
-
edges: [],
|
|
97
|
-
minZoom: 0.5,
|
|
98
|
-
maxZoom: 2
|
|
99
|
-
});
|
|
100
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
101
|
-
});
|
|
102
|
-
(0, _vitest.it)("should render with nodesDraggable false in SSR", async () => {
|
|
103
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
104
|
-
nodes: [],
|
|
105
|
-
edges: [],
|
|
106
|
-
nodesDraggable: false
|
|
107
|
-
});
|
|
108
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
109
|
-
});
|
|
110
|
-
(0, _vitest.it)("should render with edgesEditable false in SSR", async () => {
|
|
111
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
112
|
-
nodes: [],
|
|
113
|
-
edges: [],
|
|
114
|
-
edgesEditable: false
|
|
115
|
-
});
|
|
116
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
117
|
-
});
|
|
118
|
-
(0, _vitest.it)("should render with snapToGrid in SSR", async () => {
|
|
119
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
120
|
-
nodes: [],
|
|
121
|
-
edges: [],
|
|
122
|
-
snapToGrid: true,
|
|
123
|
-
snapGrid: [20, 20]
|
|
124
|
-
});
|
|
125
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
126
|
-
});
|
|
127
|
-
(0, _vitest.it)("should render with connection line style in SSR", async () => {
|
|
128
|
-
const html = await (0, _ssr.renderSSR)(_Flow.default, {
|
|
129
|
-
nodes: [],
|
|
130
|
-
edges: [],
|
|
131
|
-
connectionLineStyle: {
|
|
132
|
-
stroke: "#ff0000",
|
|
133
|
-
strokeWidth: 2
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
(0, _ssr.expectSSRContains)(html, "yh-flow");
|
|
137
|
-
});
|
|
138
|
-
(0, _vitest.it)("should hydrate without mismatch", async () => {
|
|
139
|
-
const nodes = [{
|
|
140
|
-
id: "1",
|
|
141
|
-
type: "default",
|
|
142
|
-
position: {
|
|
143
|
-
x: 0,
|
|
144
|
-
y: 0
|
|
145
|
-
},
|
|
146
|
-
data: {
|
|
147
|
-
label: "Test"
|
|
148
|
-
}
|
|
149
|
-
}];
|
|
150
|
-
const result = await (0, _ssr.testHydration)(_Flow.default, {
|
|
151
|
-
nodes,
|
|
152
|
-
edges: []
|
|
153
|
-
});
|
|
154
|
-
(0, _vitest.expect)(result.isMatch).toBe(true);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import Flow from "../Flow.vue";
|
|
3
|
-
import { renderSSR, expectSSRHasClass, expectSSRContains, testHydration } from "./utils/ssr.mjs";
|
|
4
|
-
describe("Flow SSR", () => {
|
|
5
|
-
it("should render Flow component in SSR", async () => {
|
|
6
|
-
const html = await renderSSR(Flow, {
|
|
7
|
-
nodes: [],
|
|
8
|
-
edges: []
|
|
9
|
-
});
|
|
10
|
-
expectSSRContains(html, "yh-flow");
|
|
11
|
-
});
|
|
12
|
-
it("should render with custom class in SSR", async () => {
|
|
13
|
-
const html = await renderSSR(Flow, {
|
|
14
|
-
nodes: [],
|
|
15
|
-
edges: [],
|
|
16
|
-
class: "custom-flow"
|
|
17
|
-
});
|
|
18
|
-
expectSSRHasClass(html, "custom-flow");
|
|
19
|
-
});
|
|
20
|
-
it("should render nodes in SSR", async () => {
|
|
21
|
-
const nodes = [
|
|
22
|
-
{
|
|
23
|
-
id: "1",
|
|
24
|
-
type: "default",
|
|
25
|
-
position: { x: 0, y: 0 },
|
|
26
|
-
data: { label: "Node 1" }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: "2",
|
|
30
|
-
type: "default",
|
|
31
|
-
position: { x: 100, y: 100 },
|
|
32
|
-
data: { label: "Node 2" }
|
|
33
|
-
}
|
|
34
|
-
];
|
|
35
|
-
const html = await renderSSR(Flow, {
|
|
36
|
-
nodes,
|
|
37
|
-
edges: []
|
|
38
|
-
});
|
|
39
|
-
expectSSRContains(html, "Node 1");
|
|
40
|
-
expectSSRContains(html, "Node 2");
|
|
41
|
-
});
|
|
42
|
-
it("should render edges in SSR", async () => {
|
|
43
|
-
const nodes = [
|
|
44
|
-
{ id: "1", type: "default", position: { x: 0, y: 0 }, data: { label: "A" } },
|
|
45
|
-
{ id: "2", type: "default", position: { x: 100, y: 0 }, data: { label: "B" } }
|
|
46
|
-
];
|
|
47
|
-
const edges = [{ id: "e1", source: "1", target: "2" }];
|
|
48
|
-
const html = await renderSSR(Flow, {
|
|
49
|
-
nodes,
|
|
50
|
-
edges
|
|
51
|
-
});
|
|
52
|
-
expectSSRContains(html, "yh-flow-edge");
|
|
53
|
-
});
|
|
54
|
-
it("should render with fitView props in SSR", async () => {
|
|
55
|
-
const html = await renderSSR(Flow, {
|
|
56
|
-
nodes: [],
|
|
57
|
-
edges: [],
|
|
58
|
-
fitView: true
|
|
59
|
-
});
|
|
60
|
-
expectSSRContains(html, "yh-flow");
|
|
61
|
-
});
|
|
62
|
-
it("should render with minZoom and maxZoom in SSR", async () => {
|
|
63
|
-
const html = await renderSSR(Flow, {
|
|
64
|
-
nodes: [],
|
|
65
|
-
edges: [],
|
|
66
|
-
minZoom: 0.5,
|
|
67
|
-
maxZoom: 2
|
|
68
|
-
});
|
|
69
|
-
expectSSRContains(html, "yh-flow");
|
|
70
|
-
});
|
|
71
|
-
it("should render with nodesDraggable false in SSR", async () => {
|
|
72
|
-
const html = await renderSSR(Flow, {
|
|
73
|
-
nodes: [],
|
|
74
|
-
edges: [],
|
|
75
|
-
nodesDraggable: false
|
|
76
|
-
});
|
|
77
|
-
expectSSRContains(html, "yh-flow");
|
|
78
|
-
});
|
|
79
|
-
it("should render with edgesEditable false in SSR", async () => {
|
|
80
|
-
const html = await renderSSR(Flow, {
|
|
81
|
-
nodes: [],
|
|
82
|
-
edges: [],
|
|
83
|
-
edgesEditable: false
|
|
84
|
-
});
|
|
85
|
-
expectSSRContains(html, "yh-flow");
|
|
86
|
-
});
|
|
87
|
-
it("should render with snapToGrid in SSR", async () => {
|
|
88
|
-
const html = await renderSSR(Flow, {
|
|
89
|
-
nodes: [],
|
|
90
|
-
edges: [],
|
|
91
|
-
snapToGrid: true,
|
|
92
|
-
snapGrid: [20, 20]
|
|
93
|
-
});
|
|
94
|
-
expectSSRContains(html, "yh-flow");
|
|
95
|
-
});
|
|
96
|
-
it("should render with connection line style in SSR", async () => {
|
|
97
|
-
const html = await renderSSR(Flow, {
|
|
98
|
-
nodes: [],
|
|
99
|
-
edges: [],
|
|
100
|
-
connectionLineStyle: { stroke: "#ff0000", strokeWidth: 2 }
|
|
101
|
-
});
|
|
102
|
-
expectSSRContains(html, "yh-flow");
|
|
103
|
-
});
|
|
104
|
-
it("should hydrate without mismatch", async () => {
|
|
105
|
-
const nodes = [{ id: "1", type: "default", position: { x: 0, y: 0 }, data: { label: "Test" } }];
|
|
106
|
-
const result = await testHydration(Flow, {
|
|
107
|
-
nodes,
|
|
108
|
-
edges: []
|
|
109
|
-
});
|
|
110
|
-
expect(result.isMatch).toBe(true);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _geometry = require("../utils/geometry.cjs");
|
|
5
|
-
(0, _vitest.describe)("flow/utils/geometry", () => {
|
|
6
|
-
(0, _vitest.it)("isPointInRect", () => {
|
|
7
|
-
(0, _vitest.expect)((0, _geometry.isPointInRect)({
|
|
8
|
-
x: 50,
|
|
9
|
-
y: 50
|
|
10
|
-
}, {
|
|
11
|
-
x: 0,
|
|
12
|
-
y: 0,
|
|
13
|
-
width: 100,
|
|
14
|
-
height: 100
|
|
15
|
-
})).toBe(true);
|
|
16
|
-
(0, _vitest.expect)((0, _geometry.isPointInRect)({
|
|
17
|
-
x: 150,
|
|
18
|
-
y: 50
|
|
19
|
-
}, {
|
|
20
|
-
x: 0,
|
|
21
|
-
y: 0,
|
|
22
|
-
width: 100,
|
|
23
|
-
height: 100
|
|
24
|
-
})).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
(0, _vitest.it)("rectIntersect", () => {
|
|
27
|
-
(0, _vitest.expect)((0, _geometry.rectIntersect)({
|
|
28
|
-
x: 0,
|
|
29
|
-
y: 0,
|
|
30
|
-
width: 50,
|
|
31
|
-
height: 50
|
|
32
|
-
}, {
|
|
33
|
-
x: 25,
|
|
34
|
-
y: 25,
|
|
35
|
-
width: 50,
|
|
36
|
-
height: 50
|
|
37
|
-
})).toBe(true);
|
|
38
|
-
(0, _vitest.expect)((0, _geometry.rectIntersect)({
|
|
39
|
-
x: 0,
|
|
40
|
-
y: 0,
|
|
41
|
-
width: 10,
|
|
42
|
-
height: 10
|
|
43
|
-
}, {
|
|
44
|
-
x: 20,
|
|
45
|
-
y: 20,
|
|
46
|
-
width: 10,
|
|
47
|
-
height: 10
|
|
48
|
-
})).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
(0, _vitest.it)("getRectIntersection", () => {
|
|
51
|
-
const r = (0, _geometry.getRectIntersection)({
|
|
52
|
-
x: 0,
|
|
53
|
-
y: 0,
|
|
54
|
-
width: 100,
|
|
55
|
-
height: 100
|
|
56
|
-
}, {
|
|
57
|
-
x: 50,
|
|
58
|
-
y: 50,
|
|
59
|
-
width: 100,
|
|
60
|
-
height: 100
|
|
61
|
-
});
|
|
62
|
-
(0, _vitest.expect)(r).not.toBeNull();
|
|
63
|
-
(0, _vitest.expect)(r.x).toBe(50);
|
|
64
|
-
(0, _vitest.expect)(r.y).toBe(50);
|
|
65
|
-
(0, _vitest.expect)(r.width).toBe(50);
|
|
66
|
-
(0, _vitest.expect)(r.height).toBe(50);
|
|
67
|
-
});
|
|
68
|
-
(0, _vitest.it)("getBoundingBox empty returns zeros", () => {
|
|
69
|
-
const box = (0, _geometry.getBoundingBox)([]);
|
|
70
|
-
(0, _vitest.expect)(box).toEqual({
|
|
71
|
-
x: 0,
|
|
72
|
-
y: 0,
|
|
73
|
-
width: 0,
|
|
74
|
-
height: 0
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
(0, _vitest.it)("getBoundingBox multiple points", () => {
|
|
78
|
-
const box = (0, _geometry.getBoundingBox)([{
|
|
79
|
-
x: 10,
|
|
80
|
-
y: 20
|
|
81
|
-
}, {
|
|
82
|
-
x: 30,
|
|
83
|
-
y: 5
|
|
84
|
-
}]);
|
|
85
|
-
(0, _vitest.expect)(box.x).toBe(10);
|
|
86
|
-
(0, _vitest.expect)(box.y).toBe(5);
|
|
87
|
-
(0, _vitest.expect)(box.width).toBe(20);
|
|
88
|
-
(0, _vitest.expect)(box.height).toBe(15);
|
|
89
|
-
});
|
|
90
|
-
(0, _vitest.it)("getNodeBounds", () => {
|
|
91
|
-
const nodes = [{
|
|
92
|
-
position: {
|
|
93
|
-
x: 0,
|
|
94
|
-
y: 0
|
|
95
|
-
},
|
|
96
|
-
width: 50,
|
|
97
|
-
height: 50
|
|
98
|
-
}, {
|
|
99
|
-
position: {
|
|
100
|
-
x: 100,
|
|
101
|
-
y: 100
|
|
102
|
-
},
|
|
103
|
-
width: 50,
|
|
104
|
-
height: 50
|
|
105
|
-
}];
|
|
106
|
-
const bounds = (0, _geometry.getNodeBounds)(nodes);
|
|
107
|
-
(0, _vitest.expect)(bounds.x).toBe(0);
|
|
108
|
-
(0, _vitest.expect)(bounds.y).toBe(0);
|
|
109
|
-
(0, _vitest.expect)(bounds.width).toBe(150);
|
|
110
|
-
(0, _vitest.expect)(bounds.height).toBe(150);
|
|
111
|
-
});
|
|
112
|
-
(0, _vitest.it)("pointToLineDistance", () => {
|
|
113
|
-
const d = (0, _geometry.pointToLineDistance)({
|
|
114
|
-
x: 0,
|
|
115
|
-
y: 0
|
|
116
|
-
}, {
|
|
117
|
-
x: 10,
|
|
118
|
-
y: 0
|
|
119
|
-
}, {
|
|
120
|
-
x: 10,
|
|
121
|
-
y: 10
|
|
122
|
-
});
|
|
123
|
-
(0, _vitest.expect)(d).toBeGreaterThanOrEqual(0);
|
|
124
|
-
});
|
|
125
|
-
(0, _vitest.it)("pointToPointDistance", () => {
|
|
126
|
-
(0, _vitest.expect)((0, _geometry.pointToPointDistance)({
|
|
127
|
-
x: 0,
|
|
128
|
-
y: 0
|
|
129
|
-
}, {
|
|
130
|
-
x: 3,
|
|
131
|
-
y: 4
|
|
132
|
-
})).toBe(5);
|
|
133
|
-
});
|
|
134
|
-
(0, _vitest.it)("degToRad and radToDeg", () => {
|
|
135
|
-
(0, _vitest.expect)((0, _geometry.degToRad)(180)).toBeCloseTo(Math.PI);
|
|
136
|
-
(0, _vitest.expect)((0, _geometry.radToDeg)(Math.PI)).toBeCloseTo(180);
|
|
137
|
-
});
|
|
138
|
-
(0, _vitest.it)("getLineIntersection", () => {
|
|
139
|
-
const p = (0, _geometry.getLineIntersection)({
|
|
140
|
-
x: 0,
|
|
141
|
-
y: 0
|
|
142
|
-
}, {
|
|
143
|
-
x: 10,
|
|
144
|
-
y: 10
|
|
145
|
-
}, {
|
|
146
|
-
x: 0,
|
|
147
|
-
y: 10
|
|
148
|
-
}, {
|
|
149
|
-
x: 10,
|
|
150
|
-
y: 0
|
|
151
|
-
});
|
|
152
|
-
(0, _vitest.expect)(p).not.toBeNull();
|
|
153
|
-
(0, _vitest.expect)(typeof p.x).toBe("number");
|
|
154
|
-
(0, _vitest.expect)(typeof p.y).toBe("number");
|
|
155
|
-
});
|
|
156
|
-
(0, _vitest.it)("getAngle", () => {
|
|
157
|
-
const a = (0, _geometry.getAngle)({
|
|
158
|
-
x: 0,
|
|
159
|
-
y: 0
|
|
160
|
-
}, {
|
|
161
|
-
x: 1,
|
|
162
|
-
y: 0
|
|
163
|
-
});
|
|
164
|
-
(0, _vitest.expect)(a).toBe(0);
|
|
165
|
-
});
|
|
166
|
-
(0, _vitest.it)("pointToRectDistance", () => {
|
|
167
|
-
const d = (0, _geometry.pointToRectDistance)({
|
|
168
|
-
x: -10,
|
|
169
|
-
y: 50
|
|
170
|
-
}, {
|
|
171
|
-
x: 0,
|
|
172
|
-
y: 0,
|
|
173
|
-
width: 100,
|
|
174
|
-
height: 100
|
|
175
|
-
});
|
|
176
|
-
(0, _vitest.expect)(d).toBe(10);
|
|
177
|
-
});
|
|
178
|
-
(0, _vitest.it)("viewportIntersectsBounds", () => {
|
|
179
|
-
(0, _vitest.expect)((0, _geometry.viewportIntersectsBounds)({
|
|
180
|
-
x: 0,
|
|
181
|
-
y: 0,
|
|
182
|
-
width: 800,
|
|
183
|
-
height: 600
|
|
184
|
-
}, {
|
|
185
|
-
x: 0,
|
|
186
|
-
y: 0,
|
|
187
|
-
width: 1e3,
|
|
188
|
-
height: 1e3
|
|
189
|
-
}, 1)).toBe(true);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
isPointInRect,
|
|
4
|
-
rectIntersect,
|
|
5
|
-
getRectIntersection,
|
|
6
|
-
getBoundingBox,
|
|
7
|
-
getNodeBounds,
|
|
8
|
-
pointToLineDistance,
|
|
9
|
-
pointToPointDistance,
|
|
10
|
-
degToRad,
|
|
11
|
-
radToDeg,
|
|
12
|
-
getLineIntersection,
|
|
13
|
-
getAngle,
|
|
14
|
-
pointToRectDistance,
|
|
15
|
-
viewportIntersectsBounds
|
|
16
|
-
} from "../utils/geometry.mjs";
|
|
17
|
-
describe("flow/utils/geometry", () => {
|
|
18
|
-
it("isPointInRect", () => {
|
|
19
|
-
expect(isPointInRect({ x: 50, y: 50 }, { x: 0, y: 0, width: 100, height: 100 })).toBe(true);
|
|
20
|
-
expect(isPointInRect({ x: 150, y: 50 }, { x: 0, y: 0, width: 100, height: 100 })).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
it("rectIntersect", () => {
|
|
23
|
-
expect(
|
|
24
|
-
rectIntersect({ x: 0, y: 0, width: 50, height: 50 }, { x: 25, y: 25, width: 50, height: 50 })
|
|
25
|
-
).toBe(true);
|
|
26
|
-
expect(
|
|
27
|
-
rectIntersect({ x: 0, y: 0, width: 10, height: 10 }, { x: 20, y: 20, width: 10, height: 10 })
|
|
28
|
-
).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
it("getRectIntersection", () => {
|
|
31
|
-
const r = getRectIntersection(
|
|
32
|
-
{ x: 0, y: 0, width: 100, height: 100 },
|
|
33
|
-
{ x: 50, y: 50, width: 100, height: 100 }
|
|
34
|
-
);
|
|
35
|
-
expect(r).not.toBeNull();
|
|
36
|
-
expect(r.x).toBe(50);
|
|
37
|
-
expect(r.y).toBe(50);
|
|
38
|
-
expect(r.width).toBe(50);
|
|
39
|
-
expect(r.height).toBe(50);
|
|
40
|
-
});
|
|
41
|
-
it("getBoundingBox empty returns zeros", () => {
|
|
42
|
-
const box = getBoundingBox([]);
|
|
43
|
-
expect(box).toEqual({ x: 0, y: 0, width: 0, height: 0 });
|
|
44
|
-
});
|
|
45
|
-
it("getBoundingBox multiple points", () => {
|
|
46
|
-
const box = getBoundingBox([
|
|
47
|
-
{ x: 10, y: 20 },
|
|
48
|
-
{ x: 30, y: 5 }
|
|
49
|
-
]);
|
|
50
|
-
expect(box.x).toBe(10);
|
|
51
|
-
expect(box.y).toBe(5);
|
|
52
|
-
expect(box.width).toBe(20);
|
|
53
|
-
expect(box.height).toBe(15);
|
|
54
|
-
});
|
|
55
|
-
it("getNodeBounds", () => {
|
|
56
|
-
const nodes = [
|
|
57
|
-
{ position: { x: 0, y: 0 }, width: 50, height: 50 },
|
|
58
|
-
{ position: { x: 100, y: 100 }, width: 50, height: 50 }
|
|
59
|
-
];
|
|
60
|
-
const bounds = getNodeBounds(nodes);
|
|
61
|
-
expect(bounds.x).toBe(0);
|
|
62
|
-
expect(bounds.y).toBe(0);
|
|
63
|
-
expect(bounds.width).toBe(150);
|
|
64
|
-
expect(bounds.height).toBe(150);
|
|
65
|
-
});
|
|
66
|
-
it("pointToLineDistance", () => {
|
|
67
|
-
const d = pointToLineDistance({ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 10, y: 10 });
|
|
68
|
-
expect(d).toBeGreaterThanOrEqual(0);
|
|
69
|
-
});
|
|
70
|
-
it("pointToPointDistance", () => {
|
|
71
|
-
expect(pointToPointDistance({ x: 0, y: 0 }, { x: 3, y: 4 })).toBe(5);
|
|
72
|
-
});
|
|
73
|
-
it("degToRad and radToDeg", () => {
|
|
74
|
-
expect(degToRad(180)).toBeCloseTo(Math.PI);
|
|
75
|
-
expect(radToDeg(Math.PI)).toBeCloseTo(180);
|
|
76
|
-
});
|
|
77
|
-
it("getLineIntersection", () => {
|
|
78
|
-
const p = getLineIntersection(
|
|
79
|
-
{ x: 0, y: 0 },
|
|
80
|
-
{ x: 10, y: 10 },
|
|
81
|
-
{ x: 0, y: 10 },
|
|
82
|
-
{ x: 10, y: 0 }
|
|
83
|
-
);
|
|
84
|
-
expect(p).not.toBeNull();
|
|
85
|
-
expect(typeof p.x).toBe("number");
|
|
86
|
-
expect(typeof p.y).toBe("number");
|
|
87
|
-
});
|
|
88
|
-
it("getAngle", () => {
|
|
89
|
-
const a = getAngle({ x: 0, y: 0 }, { x: 1, y: 0 });
|
|
90
|
-
expect(a).toBe(0);
|
|
91
|
-
});
|
|
92
|
-
it("pointToRectDistance", () => {
|
|
93
|
-
const d = pointToRectDistance({ x: -10, y: 50 }, { x: 0, y: 0, width: 100, height: 100 });
|
|
94
|
-
expect(d).toBe(10);
|
|
95
|
-
});
|
|
96
|
-
it("viewportIntersectsBounds", () => {
|
|
97
|
-
expect(
|
|
98
|
-
viewportIntersectsBounds(
|
|
99
|
-
{ x: 0, y: 0, width: 800, height: 600 },
|
|
100
|
-
{ x: 0, y: 0, width: 1e3, height: 1e3 },
|
|
101
|
-
1
|
|
102
|
-
)
|
|
103
|
-
).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _graph = require("../utils/graph.cjs");
|
|
5
|
-
(0, _vitest.describe)("flow/utils/graph", () => {
|
|
6
|
-
(0, _vitest.it)("hasCycle should detect cycle", () => {
|
|
7
|
-
const edges = [{
|
|
8
|
-
source: "A",
|
|
9
|
-
target: "B"
|
|
10
|
-
}, {
|
|
11
|
-
source: "B",
|
|
12
|
-
target: "C"
|
|
13
|
-
}, {
|
|
14
|
-
source: "C",
|
|
15
|
-
target: "A"
|
|
16
|
-
}];
|
|
17
|
-
(0, _vitest.expect)((0, _graph.hasCycle)(edges, "A")).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
(0, _vitest.it)("hasCycle should return false for DAG", () => {
|
|
20
|
-
const edges = [{
|
|
21
|
-
source: "A",
|
|
22
|
-
target: "B"
|
|
23
|
-
}, {
|
|
24
|
-
source: "B",
|
|
25
|
-
target: "C"
|
|
26
|
-
}];
|
|
27
|
-
(0, _vitest.expect)((0, _graph.hasCycle)(edges, "A")).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
(0, _vitest.it)("topologicalSort should return order for DAG", () => {
|
|
30
|
-
const nodes = [{
|
|
31
|
-
id: "A"
|
|
32
|
-
}, {
|
|
33
|
-
id: "B"
|
|
34
|
-
}, {
|
|
35
|
-
id: "C"
|
|
36
|
-
}];
|
|
37
|
-
const edges = [{
|
|
38
|
-
source: "A",
|
|
39
|
-
target: "B"
|
|
40
|
-
}, {
|
|
41
|
-
source: "B",
|
|
42
|
-
target: "C"
|
|
43
|
-
}];
|
|
44
|
-
const order = (0, _graph.topologicalSort)(nodes, edges);
|
|
45
|
-
(0, _vitest.expect)(order).toHaveLength(3);
|
|
46
|
-
const ai = order.indexOf("A");
|
|
47
|
-
const bi = order.indexOf("B");
|
|
48
|
-
const ci = order.indexOf("C");
|
|
49
|
-
(0, _vitest.expect)(ai).toBeLessThan(bi);
|
|
50
|
-
(0, _vitest.expect)(bi).toBeLessThan(ci);
|
|
51
|
-
});
|
|
52
|
-
(0, _vitest.it)("findAllPaths should return paths between two nodes", () => {
|
|
53
|
-
const edges = [{
|
|
54
|
-
source: "1",
|
|
55
|
-
target: "2"
|
|
56
|
-
}, {
|
|
57
|
-
source: "1",
|
|
58
|
-
target: "3"
|
|
59
|
-
}, {
|
|
60
|
-
source: "2",
|
|
61
|
-
target: "4"
|
|
62
|
-
}, {
|
|
63
|
-
source: "3",
|
|
64
|
-
target: "4"
|
|
65
|
-
}];
|
|
66
|
-
const paths = (0, _graph.findAllPaths)(edges, "1", "4");
|
|
67
|
-
(0, _vitest.expect)(paths.length).toBeGreaterThanOrEqual(1);
|
|
68
|
-
(0, _vitest.expect)(paths.every(p => p[0] === "1" && p[p.length - 1] === "4")).toBe(true);
|
|
69
|
-
});
|
|
70
|
-
(0, _vitest.it)("findConnectedComponents should return components", () => {
|
|
71
|
-
const nodes = [{
|
|
72
|
-
id: "A"
|
|
73
|
-
}, {
|
|
74
|
-
id: "B"
|
|
75
|
-
}, {
|
|
76
|
-
id: "C"
|
|
77
|
-
}, {
|
|
78
|
-
id: "D"
|
|
79
|
-
}];
|
|
80
|
-
const edges = [{
|
|
81
|
-
source: "A",
|
|
82
|
-
target: "B"
|
|
83
|
-
}, {
|
|
84
|
-
source: "C",
|
|
85
|
-
target: "D"
|
|
86
|
-
}];
|
|
87
|
-
const components = (0, _graph.findConnectedComponents)(nodes, edges);
|
|
88
|
-
(0, _vitest.expect)(components).toHaveLength(2);
|
|
89
|
-
(0, _vitest.expect)(components.some(c => c.includes("A") && c.includes("B"))).toBe(true);
|
|
90
|
-
(0, _vitest.expect)(components.some(c => c.includes("C") && c.includes("D"))).toBe(true);
|
|
91
|
-
});
|
|
92
|
-
(0, _vitest.it)("bfs should traverse in breadth order", () => {
|
|
93
|
-
const adj = /* @__PURE__ */new Map();
|
|
94
|
-
adj.set("1", ["2", "3"]);
|
|
95
|
-
adj.set("2", ["4"]);
|
|
96
|
-
adj.set("3", []);
|
|
97
|
-
adj.set("4", []);
|
|
98
|
-
const result = (0, _graph.bfs)(adj, "1");
|
|
99
|
-
(0, _vitest.expect)(result).toContain("1");
|
|
100
|
-
(0, _vitest.expect)(result).toContain("2");
|
|
101
|
-
(0, _vitest.expect)(result).toContain("3");
|
|
102
|
-
(0, _vitest.expect)(result).toContain("4");
|
|
103
|
-
(0, _vitest.expect)(result[0]).toBe("1");
|
|
104
|
-
});
|
|
105
|
-
(0, _vitest.it)("dfs should traverse in depth order", () => {
|
|
106
|
-
const adj = /* @__PURE__ */new Map();
|
|
107
|
-
adj.set("1", ["2", "3"]);
|
|
108
|
-
adj.set("2", ["4"]);
|
|
109
|
-
adj.set("3", []);
|
|
110
|
-
adj.set("4", []);
|
|
111
|
-
const result = (0, _graph.dfs)(adj, "1");
|
|
112
|
-
(0, _vitest.expect)(result).toHaveLength(4);
|
|
113
|
-
(0, _vitest.expect)(result[0]).toBe("1");
|
|
114
|
-
});
|
|
115
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|