wyreframe 0.1.0 → 0.1.5
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/LICENSE +692 -0
- package/README.md +65 -5
- package/package.json +8 -7
- package/src/index.ts +425 -0
- package/src/renderer/Renderer.gen.tsx +49 -0
- package/src/renderer/Renderer.mjs +41 -1
- package/src/renderer/Renderer.res +78 -0
- package/src/parser/Core/__tests__/Bounds_test.mjs +0 -326
- package/src/parser/Core/__tests__/Bounds_test.res +0 -412
- package/src/parser/Core/__tests__/Grid_test.mjs +0 -322
- package/src/parser/Core/__tests__/Grid_test.res +0 -319
- package/src/parser/Core/__tests__/Types_test.mjs +0 -614
- package/src/parser/Core/__tests__/Types_test.res +0 -650
- package/src/parser/Detector/__tests__/BoxTracer_test.mjs +0 -70
- package/src/parser/Detector/__tests__/BoxTracer_test.res +0 -92
- package/src/parser/Detector/__tests__/HierarchyBuilder_test.mjs +0 -489
- package/src/parser/Detector/__tests__/HierarchyBuilder_test.res +0 -849
- package/src/parser/Detector/__tests__/ShapeDetector_test.mjs +0 -377
- package/src/parser/Detector/__tests__/ShapeDetector_test.res +0 -563
- package/src/parser/Interactions/__tests__/InteractionMerger_test.mjs +0 -576
- package/src/parser/Interactions/__tests__/InteractionMerger_test.res +0 -646
- package/src/parser/Scanner/__tests__/Grid_manual.mjs +0 -214
- package/src/parser/Scanner/__tests__/Grid_manual.res +0 -141
- package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.mjs +0 -189
- package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.res +0 -257
- package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.mjs +0 -202
- package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.res +0 -250
- package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.mjs +0 -293
- package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.res +0 -134
- package/src/parser/Semantic/Elements/__tests__/InputParser_test.mjs +0 -253
- package/src/parser/Semantic/Elements/__tests__/InputParser_test.res +0 -304
- package/src/parser/Semantic/Elements/__tests__/LinkParser_test.mjs +0 -289
- package/src/parser/Semantic/Elements/__tests__/LinkParser_test.res +0 -402
- package/src/parser/Semantic/Elements/__tests__/TextParser_test.mjs +0 -149
- package/src/parser/Semantic/Elements/__tests__/TextParser_test.res +0 -167
- package/src/parser/Semantic/__tests__/ASTBuilder_test.mjs +0 -187
- package/src/parser/Semantic/__tests__/ASTBuilder_test.res +0 -192
- package/src/parser/Semantic/__tests__/ParserRegistry_test.mjs +0 -154
- package/src/parser/Semantic/__tests__/ParserRegistry_test.res +0 -191
- package/src/parser/Semantic/__tests__/SemanticParser_integration_test.mjs +0 -768
- package/src/parser/Semantic/__tests__/SemanticParser_integration_test.res +0 -1069
- package/src/parser/Semantic/__tests__/SemanticParser_manual.mjs +0 -1329
- package/src/parser/Semantic/__tests__/SemanticParser_manual.res +0 -544
- package/src/parser/__tests__/GridScanner_integration.test.mjs +0 -632
- package/src/parser/__tests__/GridScanner_integration.test.res +0 -816
- package/src/parser/__tests__/Performance.test.mjs +0 -244
- package/src/parser/__tests__/Performance.test.res +0 -371
- package/src/parser/__tests__/PerformanceFixtures.mjs +0 -200
- package/src/parser/__tests__/PerformanceFixtures.res +0 -284
- package/src/parser/__tests__/WyreframeParser_integration.test.mjs +0 -770
- package/src/parser/__tests__/WyreframeParser_integration.test.res +0 -1008
- package/src/parser/__tests__/fixtures/alignment-test.txt +0 -9
- package/src/parser/__tests__/fixtures/all-elements.txt +0 -16
- package/src/parser/__tests__/fixtures/login-scene.txt +0 -17
- package/src/parser/__tests__/fixtures/multi-scene.txt +0 -25
- package/src/parser/__tests__/fixtures/nested-boxes.txt +0 -15
- package/src/parser/__tests__/fixtures/simple-box.txt +0 -5
- package/src/parser/__tests__/fixtures/with-dividers.txt +0 -14
|
@@ -1,632 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Grid from "../Core/Grid.mjs";
|
|
4
|
-
import * as Types from "../Core/Types.mjs";
|
|
5
|
-
import * as Vitest from "rescript-vitest/src/Vitest.mjs";
|
|
6
|
-
import * as Core__Math from "@rescript/core/src/Core__Math.mjs";
|
|
7
|
-
import * as Core__Array from "@rescript/core/src/Core__Array.mjs";
|
|
8
|
-
|
|
9
|
-
Vitest.describe("GS-01: Simple Box Creation and Scanning", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
10
|
-
let simpleBox = [
|
|
11
|
-
"+----------+",
|
|
12
|
-
"| |",
|
|
13
|
-
"| Content |",
|
|
14
|
-
"| |",
|
|
15
|
-
"+----------+"
|
|
16
|
-
];
|
|
17
|
-
Vitest.test("creates grid with correct dimensions", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
18
|
-
let grid = Grid.fromLines(simpleBox);
|
|
19
|
-
t.expect(grid.width).toBe(12);
|
|
20
|
-
t.expect(grid.height).toBe(5);
|
|
21
|
-
});
|
|
22
|
-
Vitest.test("indexes all corner characters correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
23
|
-
let grid = Grid.fromLines(simpleBox);
|
|
24
|
-
t.expect(grid.cornerIndex.length).toBe(4);
|
|
25
|
-
let corners = grid.cornerIndex;
|
|
26
|
-
t.expect(corners[0]).toEqual({
|
|
27
|
-
row: 0,
|
|
28
|
-
col: 0
|
|
29
|
-
});
|
|
30
|
-
t.expect(corners[1]).toEqual({
|
|
31
|
-
row: 0,
|
|
32
|
-
col: 11
|
|
33
|
-
});
|
|
34
|
-
t.expect(corners[2]).toEqual({
|
|
35
|
-
row: 4,
|
|
36
|
-
col: 0
|
|
37
|
-
});
|
|
38
|
-
t.expect(corners[3]).toEqual({
|
|
39
|
-
row: 4,
|
|
40
|
-
col: 11
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
Vitest.test("indexes horizontal line characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
44
|
-
let grid = Grid.fromLines(simpleBox);
|
|
45
|
-
t.expect(grid.hLineIndex.length).toBe(20);
|
|
46
|
-
});
|
|
47
|
-
Vitest.test("indexes vertical line characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
48
|
-
let grid = Grid.fromLines(simpleBox);
|
|
49
|
-
t.expect(grid.vLineIndex.length).toBe(6);
|
|
50
|
-
});
|
|
51
|
-
Vitest.test("correctly accesses characters at specific positions", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
52
|
-
let grid = Grid.fromLines(simpleBox);
|
|
53
|
-
let match = Grid.get(grid, Types.Position.make(0, 0));
|
|
54
|
-
let exit = 0;
|
|
55
|
-
if (match !== "Corner" || typeof match === "object") {
|
|
56
|
-
exit = 1;
|
|
57
|
-
}
|
|
58
|
-
if (exit === 1) {
|
|
59
|
-
t.expect(true).toBe(false);
|
|
60
|
-
}
|
|
61
|
-
let match$1 = Grid.get(grid, Types.Position.make(0, 1));
|
|
62
|
-
let exit$1 = 0;
|
|
63
|
-
if (match$1 !== "HLine" || typeof match$1 === "object") {
|
|
64
|
-
exit$1 = 1;
|
|
65
|
-
}
|
|
66
|
-
if (exit$1 === 1) {
|
|
67
|
-
t.expect(true).toBe(false);
|
|
68
|
-
}
|
|
69
|
-
let match$2 = Grid.get(grid, Types.Position.make(1, 0));
|
|
70
|
-
let exit$2 = 0;
|
|
71
|
-
if (match$2 !== "VLine" || typeof match$2 === "object") {
|
|
72
|
-
exit$2 = 1;
|
|
73
|
-
}
|
|
74
|
-
if (exit$2 === 1) {
|
|
75
|
-
t.expect(true).toBe(false);
|
|
76
|
-
}
|
|
77
|
-
let match$3 = Grid.get(grid, Types.Position.make(1, 1));
|
|
78
|
-
let exit$3 = 0;
|
|
79
|
-
if (match$3 !== "Space" || typeof match$3 === "object") {
|
|
80
|
-
exit$3 = 1;
|
|
81
|
-
}
|
|
82
|
-
if (exit$3 === 1) {
|
|
83
|
-
t.expect(true).toBe(false);
|
|
84
|
-
}
|
|
85
|
-
let match$4 = Grid.get(grid, Types.Position.make(2, 3));
|
|
86
|
-
if (typeof match$4 === "object" && match$4._0 === "C") {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
t.expect(true).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
Vitest.test("scans right from top-left corner correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
92
|
-
let grid = Grid.fromLines(simpleBox);
|
|
93
|
-
let start = Types.Position.make(0, 0);
|
|
94
|
-
let results = Grid.scanRight(grid, start, cell => {
|
|
95
|
-
if (typeof cell === "object") {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
switch (cell) {
|
|
99
|
-
case "Corner" :
|
|
100
|
-
case "HLine" :
|
|
101
|
-
return true;
|
|
102
|
-
default:
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
t.expect(results.length).toBe(12);
|
|
107
|
-
});
|
|
108
|
-
Vitest.test("scans down from top-left corner correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
109
|
-
let grid = Grid.fromLines(simpleBox);
|
|
110
|
-
let start = Types.Position.make(0, 0);
|
|
111
|
-
let results = Grid.scanDown(grid, start, cell => {
|
|
112
|
-
if (typeof cell === "object") {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
switch (cell) {
|
|
116
|
-
case "Corner" :
|
|
117
|
-
case "VLine" :
|
|
118
|
-
return true;
|
|
119
|
-
default:
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
t.expect(results.length).toBe(5);
|
|
124
|
-
});
|
|
125
|
-
Vitest.test("finds all corners using findAll", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
126
|
-
let grid = Grid.fromLines(simpleBox);
|
|
127
|
-
let corners = Grid.findAll(grid, "Corner");
|
|
128
|
-
t.expect(corners.length).toBe(4);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
Vitest.describe("GS-02: Nested Boxes with Hierarchy", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
133
|
-
let nestedBoxes = [
|
|
134
|
-
"+--Outer--------------+",
|
|
135
|
-
"| |",
|
|
136
|
-
"| +--Inner-------+ |",
|
|
137
|
-
"| | | |",
|
|
138
|
-
"| | [ Button ] | |",
|
|
139
|
-
"| | | |",
|
|
140
|
-
"| +--------------+ |",
|
|
141
|
-
"| |",
|
|
142
|
-
"+---------------------+"
|
|
143
|
-
];
|
|
144
|
-
Vitest.test("creates grid with normalized dimensions", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
145
|
-
let grid = Grid.fromLines(nestedBoxes);
|
|
146
|
-
t.expect(grid.width).toBe(23);
|
|
147
|
-
t.expect(grid.height).toBe(9);
|
|
148
|
-
});
|
|
149
|
-
Vitest.test("indexes corners from both outer and inner boxes", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
150
|
-
let grid = Grid.fromLines(nestedBoxes);
|
|
151
|
-
t.expect(grid.cornerIndex.length).toBe(8);
|
|
152
|
-
});
|
|
153
|
-
Vitest.test("preserves spatial relationships between boxes", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
154
|
-
let grid = Grid.fromLines(nestedBoxes);
|
|
155
|
-
let match = Grid.get(grid, Types.Position.make(0, 0));
|
|
156
|
-
let exit = 0;
|
|
157
|
-
if (match !== "Corner" || typeof match === "object") {
|
|
158
|
-
exit = 1;
|
|
159
|
-
}
|
|
160
|
-
if (exit === 1) {
|
|
161
|
-
t.expect(true).toBe(false);
|
|
162
|
-
}
|
|
163
|
-
let match$1 = Grid.get(grid, Types.Position.make(2, 3));
|
|
164
|
-
let exit$1 = 0;
|
|
165
|
-
if (match$1 !== "Corner" || typeof match$1 === "object") {
|
|
166
|
-
exit$1 = 1;
|
|
167
|
-
}
|
|
168
|
-
if (exit$1 === 1) {
|
|
169
|
-
t.expect(true).toBe(false);
|
|
170
|
-
}
|
|
171
|
-
let match$2 = Grid.get(grid, Types.Position.make(1, 3));
|
|
172
|
-
if (match$2 === "Space" && typeof match$2 !== "object") {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
t.expect(true).toBe(false);
|
|
176
|
-
});
|
|
177
|
-
Vitest.test("handles button text inside nested box", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
178
|
-
let grid = Grid.fromLines(nestedBoxes);
|
|
179
|
-
let match = Grid.get(grid, Types.Position.make(4, 7));
|
|
180
|
-
if (typeof match === "object" && match._0 === "[") {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
t.expect(true).toBe(false);
|
|
184
|
-
});
|
|
185
|
-
Vitest.test("finds corners within specific bounds", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
186
|
-
let grid = Grid.fromLines(nestedBoxes);
|
|
187
|
-
let innerBounds = Types.Bounds.make(2, 3, 6, 18);
|
|
188
|
-
let cornersInRange = Grid.findInRange(grid, "Corner", innerBounds);
|
|
189
|
-
t.expect(cornersInRange.length).toBe(4);
|
|
190
|
-
});
|
|
191
|
-
Vitest.test("scans across nested structure correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
192
|
-
let grid = Grid.fromLines(nestedBoxes);
|
|
193
|
-
let start = Types.Position.make(4, 0);
|
|
194
|
-
let results = Grid.scanRight(grid, start, param => true);
|
|
195
|
-
t.expect(results.length).toBe(23);
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
Vitest.describe("GS-03: Divider Detection and Indexing", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
200
|
-
let boxWithDividers = [
|
|
201
|
-
"+--Section Box--+",
|
|
202
|
-
"| |",
|
|
203
|
-
"| Header |",
|
|
204
|
-
"| |",
|
|
205
|
-
"+===============+",
|
|
206
|
-
"| Body Content |",
|
|
207
|
-
"| |",
|
|
208
|
-
"+===============+",
|
|
209
|
-
"| Footer |",
|
|
210
|
-
"| |",
|
|
211
|
-
"+---------------+"
|
|
212
|
-
];
|
|
213
|
-
Vitest.test("indexes all divider characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
214
|
-
let grid = Grid.fromLines(boxWithDividers);
|
|
215
|
-
t.expect(grid.dividerIndex.length).toBe(30);
|
|
216
|
-
});
|
|
217
|
-
Vitest.test("divider positions are correct", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
218
|
-
let grid = Grid.fromLines(boxWithDividers);
|
|
219
|
-
let firstDivider = grid.dividerIndex[0];
|
|
220
|
-
t.expect(firstDivider.row).toBe(4);
|
|
221
|
-
let dividers = Grid.findAll(grid, "Divider");
|
|
222
|
-
let row7Dividers = dividers.filter(pos => pos.row === 7);
|
|
223
|
-
t.expect(row7Dividers.length).toBe(15);
|
|
224
|
-
});
|
|
225
|
-
Vitest.test("distinguishes dividers from horizontal lines", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
226
|
-
let grid = Grid.fromLines(boxWithDividers);
|
|
227
|
-
let match = Grid.get(grid, Types.Position.make(4, 1));
|
|
228
|
-
let exit = 0;
|
|
229
|
-
if (match !== "Divider" || typeof match === "object") {
|
|
230
|
-
exit = 1;
|
|
231
|
-
}
|
|
232
|
-
if (exit === 1) {
|
|
233
|
-
t.expect(true).toBe(false);
|
|
234
|
-
}
|
|
235
|
-
let match$1 = Grid.get(grid, Types.Position.make(10, 1));
|
|
236
|
-
if (match$1 === "HLine" && typeof match$1 !== "object") {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
t.expect(true).toBe(false);
|
|
240
|
-
});
|
|
241
|
-
Vitest.test("findAll returns all divider positions", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
242
|
-
let grid = Grid.fromLines(boxWithDividers);
|
|
243
|
-
let dividers = Grid.findAll(grid, "Divider");
|
|
244
|
-
t.expect(dividers.length).toBe(30);
|
|
245
|
-
});
|
|
246
|
-
Vitest.test("scans across divider line correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
247
|
-
let grid = Grid.fromLines(boxWithDividers);
|
|
248
|
-
let start = Types.Position.make(4, 0);
|
|
249
|
-
let results = Grid.scanRight(grid, start, cell => {
|
|
250
|
-
if (typeof cell === "object") {
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
switch (cell) {
|
|
254
|
-
case "Corner" :
|
|
255
|
-
case "Divider" :
|
|
256
|
-
return true;
|
|
257
|
-
default:
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
t.expect(results.length).toBe(17);
|
|
262
|
-
});
|
|
263
|
-
Vitest.test("dividers maintain consistent width with box", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
264
|
-
let grid = Grid.fromLines(boxWithDividers);
|
|
265
|
-
let row4Dividers = grid.dividerIndex.filter(pos => pos.row === 4);
|
|
266
|
-
let minCol = Core__Array.reduce(row4Dividers, 999, (min, pos) => Math.min(min, pos.col));
|
|
267
|
-
let maxCol = Core__Array.reduce(row4Dividers, 0, (max, pos) => Math.max(max, pos.col));
|
|
268
|
-
t.expect(minCol).toBe(1);
|
|
269
|
-
t.expect(maxCol).toBe(15);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
Vitest.describe("GS-04: Uneven Line Normalization", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
274
|
-
let unevenLines = [
|
|
275
|
-
"+-+",
|
|
276
|
-
"| |",
|
|
277
|
-
"+------+",
|
|
278
|
-
"| X",
|
|
279
|
-
"+--------+"
|
|
280
|
-
];
|
|
281
|
-
Vitest.test("sets grid width to maximum line length", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
282
|
-
let grid = Grid.fromLines(unevenLines);
|
|
283
|
-
t.expect(grid.width).toBe(10);
|
|
284
|
-
});
|
|
285
|
-
Vitest.test("pads shorter lines with spaces", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
286
|
-
let grid = Grid.fromLines(unevenLines);
|
|
287
|
-
let match = Grid.get(grid, Types.Position.make(0, 5));
|
|
288
|
-
let exit = 0;
|
|
289
|
-
if (match !== "Space" || typeof match === "object") {
|
|
290
|
-
exit = 1;
|
|
291
|
-
}
|
|
292
|
-
if (exit === 1) {
|
|
293
|
-
t.expect(true).toBe(false);
|
|
294
|
-
}
|
|
295
|
-
let match$1 = Grid.get(grid, Types.Position.make(0, 9));
|
|
296
|
-
if (match$1 === "Space" && typeof match$1 !== "object") {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
t.expect(true).toBe(false);
|
|
300
|
-
});
|
|
301
|
-
Vitest.test("preserves original content of each line", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
302
|
-
let grid = Grid.fromLines(unevenLines);
|
|
303
|
-
let match = Grid.get(grid, Types.Position.make(0, 0));
|
|
304
|
-
let exit = 0;
|
|
305
|
-
if (match !== "Corner" || typeof match === "object") {
|
|
306
|
-
exit = 1;
|
|
307
|
-
}
|
|
308
|
-
if (exit === 1) {
|
|
309
|
-
t.expect(true).toBe(false);
|
|
310
|
-
}
|
|
311
|
-
let match$1 = Grid.get(grid, Types.Position.make(0, 1));
|
|
312
|
-
let exit$1 = 0;
|
|
313
|
-
if (match$1 !== "HLine" || typeof match$1 === "object") {
|
|
314
|
-
exit$1 = 1;
|
|
315
|
-
}
|
|
316
|
-
if (exit$1 === 1) {
|
|
317
|
-
t.expect(true).toBe(false);
|
|
318
|
-
}
|
|
319
|
-
let match$2 = Grid.get(grid, Types.Position.make(0, 2));
|
|
320
|
-
if (match$2 === "Corner" && typeof match$2 !== "object") {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
t.expect(true).toBe(false);
|
|
324
|
-
});
|
|
325
|
-
Vitest.test("handles line with trailing content", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
326
|
-
let grid = Grid.fromLines(unevenLines);
|
|
327
|
-
let match = Grid.get(grid, Types.Position.make(3, 3));
|
|
328
|
-
let exit = 0;
|
|
329
|
-
if (typeof match !== "object" || match._0 !== "X") {
|
|
330
|
-
exit = 1;
|
|
331
|
-
}
|
|
332
|
-
if (exit === 1) {
|
|
333
|
-
t.expect(true).toBe(false);
|
|
334
|
-
}
|
|
335
|
-
let match$1 = Grid.get(grid, Types.Position.make(3, 4));
|
|
336
|
-
if (match$1 === "Space" && typeof match$1 !== "object") {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
t.expect(true).toBe(false);
|
|
340
|
-
});
|
|
341
|
-
Vitest.test("all lines accessible as full-width arrays", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
342
|
-
let grid = Grid.fromLines(unevenLines);
|
|
343
|
-
for (let row = 0; row <= 4; ++row) {
|
|
344
|
-
let line = Grid.getLine(grid, row);
|
|
345
|
-
if (line !== undefined) {
|
|
346
|
-
t.expect(line.length).toBe(10);
|
|
347
|
-
} else {
|
|
348
|
-
t.expect(true).toBe(false);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
Vitest.test("getRange works correctly with padding", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
353
|
-
let grid = Grid.fromLines(unevenLines);
|
|
354
|
-
let range = Grid.getRange(grid, 0, 3, 9);
|
|
355
|
-
if (range === undefined) {
|
|
356
|
-
return t.expect(true).toBe(false);
|
|
357
|
-
}
|
|
358
|
-
t.expect(range.length).toBe(7);
|
|
359
|
-
let allSpaces = range.every(cell => {
|
|
360
|
-
if (typeof cell !== "object") {
|
|
361
|
-
return cell === "Space";
|
|
362
|
-
} else {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
t.expect(allSpaces).toBe(true);
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
Vitest.describe("GS-05: Special Character Recognition", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
371
|
-
let specialChars = [
|
|
372
|
-
"+------|",
|
|
373
|
-
"| |",
|
|
374
|
-
"+======+"
|
|
375
|
-
];
|
|
376
|
-
Vitest.test("recognizes Corner characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
377
|
-
let grid = Grid.fromLines(specialChars);
|
|
378
|
-
t.expect(grid.cornerIndex.length).toBe(3);
|
|
379
|
-
let match = Grid.get(grid, Types.Position.make(0, 0));
|
|
380
|
-
if (match === "Corner" && typeof match !== "object") {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
t.expect(true).toBe(false);
|
|
384
|
-
});
|
|
385
|
-
Vitest.test("recognizes HLine characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
386
|
-
let grid = Grid.fromLines(specialChars);
|
|
387
|
-
let hLines = Grid.findAll(grid, "HLine");
|
|
388
|
-
t.expect(hLines.length).toBeGreaterThan(0);
|
|
389
|
-
let match = Grid.get(grid, Types.Position.make(0, 1));
|
|
390
|
-
if (match === "HLine" && typeof match !== "object") {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
t.expect(true).toBe(false);
|
|
394
|
-
});
|
|
395
|
-
Vitest.test("recognizes VLine characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
396
|
-
let grid = Grid.fromLines(specialChars);
|
|
397
|
-
let vLines = Grid.findAll(grid, "VLine");
|
|
398
|
-
t.expect(vLines.length).toBeGreaterThan(0);
|
|
399
|
-
let match = Grid.get(grid, Types.Position.make(1, 0));
|
|
400
|
-
if (match === "VLine" && typeof match !== "object") {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
t.expect(true).toBe(false);
|
|
404
|
-
});
|
|
405
|
-
Vitest.test("recognizes Divider characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
406
|
-
let grid = Grid.fromLines(specialChars);
|
|
407
|
-
t.expect(grid.dividerIndex.length).toBe(6);
|
|
408
|
-
let match = Grid.get(grid, Types.Position.make(2, 1));
|
|
409
|
-
if (match === "Divider" && typeof match !== "object") {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
t.expect(true).toBe(false);
|
|
413
|
-
});
|
|
414
|
-
Vitest.test("recognizes Space characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
415
|
-
let grid = Grid.fromLines(specialChars);
|
|
416
|
-
let match = Grid.get(grid, Types.Position.make(1, 1));
|
|
417
|
-
if (match === "Space" && typeof match !== "object") {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
t.expect(true).toBe(false);
|
|
421
|
-
});
|
|
422
|
-
Vitest.test("recognizes regular text as Char", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
423
|
-
let textGrid = Grid.fromLines(["Hello"]);
|
|
424
|
-
let match = Grid.get(textGrid, Types.Position.make(0, 0));
|
|
425
|
-
let exit = 0;
|
|
426
|
-
if (typeof match !== "object" || match._0 !== "H") {
|
|
427
|
-
exit = 1;
|
|
428
|
-
}
|
|
429
|
-
if (exit === 1) {
|
|
430
|
-
t.expect(true).toBe(false);
|
|
431
|
-
}
|
|
432
|
-
let match$1 = Grid.get(textGrid, Types.Position.make(0, 1));
|
|
433
|
-
if (typeof match$1 === "object" && match$1._0 === "e") {
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
t.expect(true).toBe(false);
|
|
437
|
-
});
|
|
438
|
-
Vitest.test("all special character indices are mutually exclusive", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
439
|
-
let grid = Grid.fromLines(specialChars);
|
|
440
|
-
let allPositions = grid.cornerIndex.concat(grid.hLineIndex).concat(grid.vLineIndex).concat(grid.dividerIndex);
|
|
441
|
-
let uniquePositions = new Set(allPositions.map(pos => Types.Position.toString(pos)));
|
|
442
|
-
t.expect(uniquePositions.size).toBe(allPositions.length);
|
|
443
|
-
});
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
Vitest.describe("GS-06: Empty Input Handling", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
447
|
-
Vitest.test("handles empty array", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
448
|
-
let grid = Grid.fromLines([]);
|
|
449
|
-
t.expect(grid.width).toBe(0);
|
|
450
|
-
t.expect(grid.height).toBe(0);
|
|
451
|
-
t.expect(grid.cornerIndex.length).toBe(0);
|
|
452
|
-
});
|
|
453
|
-
Vitest.test("handles array of empty strings", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
454
|
-
let grid = Grid.fromLines([
|
|
455
|
-
"",
|
|
456
|
-
"",
|
|
457
|
-
""
|
|
458
|
-
]);
|
|
459
|
-
t.expect(grid.width).toBe(0);
|
|
460
|
-
t.expect(grid.height).toBe(3);
|
|
461
|
-
});
|
|
462
|
-
Vitest.test("handles single character", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
463
|
-
let grid = Grid.fromLines(["a"]);
|
|
464
|
-
t.expect(grid.width).toBe(1);
|
|
465
|
-
t.expect(grid.height).toBe(1);
|
|
466
|
-
let match = Grid.get(grid, Types.Position.make(0, 0));
|
|
467
|
-
if (typeof match === "object" && match._0 === "a") {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
t.expect(true).toBe(false);
|
|
471
|
-
});
|
|
472
|
-
Vitest.test("handles single line with single special char", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
473
|
-
let grid = Grid.fromLines(["+"]);
|
|
474
|
-
t.expect(grid.width).toBe(1);
|
|
475
|
-
t.expect(grid.height).toBe(1);
|
|
476
|
-
t.expect(grid.cornerIndex.length).toBe(1);
|
|
477
|
-
});
|
|
478
|
-
Vitest.test("get returns None for invalid positions on empty grid", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
479
|
-
let grid = Grid.fromLines([]);
|
|
480
|
-
t.expect(Grid.get(grid, Types.Position.make(0, 0))).toBe(undefined);
|
|
481
|
-
t.expect(Grid.get(grid, Types.Position.make(5, 5))).toBe(undefined);
|
|
482
|
-
});
|
|
483
|
-
Vitest.test("isValidPosition returns false for empty grid", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
484
|
-
let grid = Grid.fromLines([]);
|
|
485
|
-
t.expect(Grid.isValidPosition(grid, Types.Position.make(0, 0))).toBe(false);
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
Vitest.describe("GS-07: Large Wireframe Performance", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
490
|
-
let generateLargeGrid = lines => {
|
|
491
|
-
let result = [];
|
|
492
|
-
for (let i = 0; i < lines; ++i) {
|
|
493
|
-
if (i % 10 === 0) {
|
|
494
|
-
result.push("+--------------------+");
|
|
495
|
-
} else if (i % 5 === 0) {
|
|
496
|
-
result.push("+====================+");
|
|
497
|
-
} else {
|
|
498
|
-
result.push("| Content Line |");
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return result;
|
|
502
|
-
};
|
|
503
|
-
Vitest.test("parses 1000-line grid in under 10ms", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
504
|
-
let largeInput = generateLargeGrid(1000);
|
|
505
|
-
let start = Date.now();
|
|
506
|
-
let grid = Grid.fromLines(largeInput);
|
|
507
|
-
let duration = Date.now() - start;
|
|
508
|
-
t.expect(duration).toBeLessThan(10.0);
|
|
509
|
-
t.expect(grid.height).toBe(1000);
|
|
510
|
-
});
|
|
511
|
-
Vitest.test("builds character indices for large grid", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
512
|
-
let largeInput = generateLargeGrid(1000);
|
|
513
|
-
let grid = Grid.fromLines(largeInput);
|
|
514
|
-
t.expect(grid.cornerIndex.length).toBeGreaterThan(0);
|
|
515
|
-
t.expect(grid.dividerIndex.length).toBeGreaterThan(0);
|
|
516
|
-
});
|
|
517
|
-
Vitest.test("random access is performant on large grid", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
518
|
-
let largeInput = generateLargeGrid(1000);
|
|
519
|
-
let grid = Grid.fromLines(largeInput);
|
|
520
|
-
let start = Date.now();
|
|
521
|
-
for (let _for = 0; _for <= 999; ++_for) {
|
|
522
|
-
let randomRow = Core__Math.Int.random(0, 999);
|
|
523
|
-
let randomCol = Core__Math.Int.random(0, 22);
|
|
524
|
-
Grid.get(grid, Types.Position.make(randomRow, randomCol));
|
|
525
|
-
}
|
|
526
|
-
let duration = Date.now() - start;
|
|
527
|
-
t.expect(duration).toBeLessThan(5.0);
|
|
528
|
-
});
|
|
529
|
-
Vitest.test("findAll is efficient on large grid", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
530
|
-
let largeInput = generateLargeGrid(1000);
|
|
531
|
-
let grid = Grid.fromLines(largeInput);
|
|
532
|
-
let start = Date.now();
|
|
533
|
-
let corners = Grid.findAll(grid, "Corner");
|
|
534
|
-
let duration = Date.now() - start;
|
|
535
|
-
t.expect(duration).toBeLessThan(5.0);
|
|
536
|
-
t.expect(corners.length).toBeGreaterThan(0);
|
|
537
|
-
});
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
Vitest.describe("GS-08: Complex Multi-Box Wireframe", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
541
|
-
let complexWireframe = [
|
|
542
|
-
"@scene: dashboard",
|
|
543
|
-
"",
|
|
544
|
-
"+--Header-----------------------+",
|
|
545
|
-
"| Logo [ Logout ] |",
|
|
546
|
-
"+===============================+",
|
|
547
|
-
"",
|
|
548
|
-
"+--Sidebar--+ +--Main Content-----------+",
|
|
549
|
-
"| | | |",
|
|
550
|
-
"| [ Home ] | | +--Card 1----------+ |",
|
|
551
|
-
"| | | | Title | |",
|
|
552
|
-
"| [ Data ] | | | Content here... | |",
|
|
553
|
-
"| | | +------------------+ |",
|
|
554
|
-
"| [Reports] | | |",
|
|
555
|
-
"| | | +--Card 2----------+ |",
|
|
556
|
-
"+-----------+ | | Title | |",
|
|
557
|
-
" | | More content... | |",
|
|
558
|
-
" | +------------------+ |",
|
|
559
|
-
" | |",
|
|
560
|
-
" +--------------------------+"
|
|
561
|
-
];
|
|
562
|
-
Vitest.test("parses entire complex structure", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
563
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
564
|
-
t.expect(grid.height).toBe(19);
|
|
565
|
-
t.expect(grid.width).toBeGreaterThan(0);
|
|
566
|
-
});
|
|
567
|
-
Vitest.test("indexes all box corners correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
568
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
569
|
-
t.expect(grid.cornerIndex.length).toBe(20);
|
|
570
|
-
});
|
|
571
|
-
Vitest.test("indexes divider line in header", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
572
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
573
|
-
let row4Dividers = grid.dividerIndex.filter(pos => pos.row === 4);
|
|
574
|
-
t.expect(row4Dividers.length).toBeGreaterThan(0);
|
|
575
|
-
});
|
|
576
|
-
Vitest.test("preserves spacing between sidebar and main content", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
577
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
578
|
-
let match = Grid.get(grid, Types.Position.make(6, 13));
|
|
579
|
-
if (match === "Space" && typeof match !== "object") {
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
t.expect(true).toBe(false);
|
|
583
|
-
});
|
|
584
|
-
Vitest.test("handles multiple adjacent boxes on same row", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
585
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
586
|
-
let row6Corners = grid.cornerIndex.filter(pos => pos.row === 6);
|
|
587
|
-
t.expect(row6Corners.length).toBe(4);
|
|
588
|
-
});
|
|
589
|
-
Vitest.test("character access works across all regions", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
590
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
591
|
-
let match = Grid.get(grid, Types.Position.make(2, 0));
|
|
592
|
-
let exit = 0;
|
|
593
|
-
if (match !== "Corner" || typeof match === "object") {
|
|
594
|
-
exit = 1;
|
|
595
|
-
}
|
|
596
|
-
if (exit === 1) {
|
|
597
|
-
t.expect(true).toBe(false);
|
|
598
|
-
}
|
|
599
|
-
let match$1 = Grid.get(grid, Types.Position.make(6, 0));
|
|
600
|
-
let exit$1 = 0;
|
|
601
|
-
if (match$1 !== "Corner" || typeof match$1 === "object") {
|
|
602
|
-
exit$1 = 1;
|
|
603
|
-
}
|
|
604
|
-
if (exit$1 === 1) {
|
|
605
|
-
t.expect(true).toBe(false);
|
|
606
|
-
}
|
|
607
|
-
let match$2 = Grid.get(grid, Types.Position.make(6, 15));
|
|
608
|
-
if (match$2 === "Corner" && typeof match$2 !== "object") {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
t.expect(true).toBe(false);
|
|
612
|
-
});
|
|
613
|
-
Vitest.test("scans across complex row with multiple boxes", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
614
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
615
|
-
let start = Types.Position.make(8, 0);
|
|
616
|
-
let results = Grid.scanRight(grid, start, param => true);
|
|
617
|
-
t.expect(results.length).toBe(grid.width);
|
|
618
|
-
});
|
|
619
|
-
Vitest.test("finds corners in nested card region", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
620
|
-
let grid = Grid.fromLines(complexWireframe);
|
|
621
|
-
let card1Bounds = Types.Bounds.make(8, 17, 11, 37);
|
|
622
|
-
let cornersInCard = Grid.findInRange(grid, "Corner", card1Bounds);
|
|
623
|
-
t.expect(cornersInCard.length).toBe(4);
|
|
624
|
-
});
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
let pass;
|
|
628
|
-
|
|
629
|
-
export {
|
|
630
|
-
pass,
|
|
631
|
-
}
|
|
632
|
-
/* Not a pure module */
|