wyreframe 0.1.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.
- package/README.md +123 -0
- package/dist/index.d.ts +267 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +195 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
- package/src/parser/Core/Bounds.mjs +61 -0
- package/src/parser/Core/Bounds.res +65 -0
- package/src/parser/Core/Grid.mjs +268 -0
- package/src/parser/Core/Grid.res +265 -0
- package/src/parser/Core/Position.mjs +83 -0
- package/src/parser/Core/Position.res +54 -0
- package/src/parser/Core/Types.mjs +435 -0
- package/src/parser/Core/Types.res +331 -0
- package/src/parser/Core/__tests__/Bounds_test.mjs +326 -0
- package/src/parser/Core/__tests__/Bounds_test.res +412 -0
- package/src/parser/Core/__tests__/Grid_test.mjs +322 -0
- package/src/parser/Core/__tests__/Grid_test.res +319 -0
- package/src/parser/Core/__tests__/Types_test.mjs +614 -0
- package/src/parser/Core/__tests__/Types_test.res +650 -0
- package/src/parser/Detector/BoxTracer.mjs +302 -0
- package/src/parser/Detector/BoxTracer.res +374 -0
- package/src/parser/Detector/HierarchyBuilder.mjs +158 -0
- package/src/parser/Detector/HierarchyBuilder.res +315 -0
- package/src/parser/Detector/ShapeDetector.mjs +134 -0
- package/src/parser/Detector/ShapeDetector.res +236 -0
- package/src/parser/Detector/__tests__/BoxTracer_test.mjs +70 -0
- package/src/parser/Detector/__tests__/BoxTracer_test.res +92 -0
- package/src/parser/Detector/__tests__/HierarchyBuilder_test.mjs +489 -0
- package/src/parser/Detector/__tests__/HierarchyBuilder_test.res +849 -0
- package/src/parser/Detector/__tests__/ShapeDetector_test.mjs +377 -0
- package/src/parser/Detector/__tests__/ShapeDetector_test.res +563 -0
- package/src/parser/Errors/ErrorContext.mjs +106 -0
- package/src/parser/Errors/ErrorContext.res +191 -0
- package/src/parser/Errors/ErrorMessages.mjs +289 -0
- package/src/parser/Errors/ErrorMessages.res +303 -0
- package/src/parser/Errors/ErrorTypes.mjs +105 -0
- package/src/parser/Errors/ErrorTypes.res +169 -0
- package/src/parser/Interactions/InteractionMerger.mjs +266 -0
- package/src/parser/Interactions/InteractionMerger.res +450 -0
- package/src/parser/Interactions/InteractionParser.mjs +88 -0
- package/src/parser/Interactions/InteractionParser.res +127 -0
- package/src/parser/Interactions/SimpleInteractionParser.mjs +278 -0
- package/src/parser/Interactions/SimpleInteractionParser.res +262 -0
- package/src/parser/Interactions/__tests__/InteractionMerger_test.mjs +576 -0
- package/src/parser/Interactions/__tests__/InteractionMerger_test.res +646 -0
- package/src/parser/Parser.gen.tsx +96 -0
- package/src/parser/Parser.mjs +212 -0
- package/src/parser/Parser.res +481 -0
- package/src/parser/Scanner/__tests__/Grid_manual.mjs +214 -0
- package/src/parser/Scanner/__tests__/Grid_manual.res +141 -0
- package/src/parser/Semantic/ASTBuilder.mjs +197 -0
- package/src/parser/Semantic/ASTBuilder.res +288 -0
- package/src/parser/Semantic/AlignmentCalc.mjs +41 -0
- package/src/parser/Semantic/AlignmentCalc.res +104 -0
- package/src/parser/Semantic/Elements/ButtonParser.mjs +58 -0
- package/src/parser/Semantic/Elements/ButtonParser.res +131 -0
- package/src/parser/Semantic/Elements/CheckboxParser.mjs +58 -0
- package/src/parser/Semantic/Elements/CheckboxParser.res +79 -0
- package/src/parser/Semantic/Elements/CodeTextParser.mjs +50 -0
- package/src/parser/Semantic/Elements/CodeTextParser.res +111 -0
- package/src/parser/Semantic/Elements/ElementParser.mjs +15 -0
- package/src/parser/Semantic/Elements/ElementParser.res +83 -0
- package/src/parser/Semantic/Elements/EmphasisParser.mjs +46 -0
- package/src/parser/Semantic/Elements/EmphasisParser.res +67 -0
- package/src/parser/Semantic/Elements/InputParser.mjs +41 -0
- package/src/parser/Semantic/Elements/InputParser.res +97 -0
- package/src/parser/Semantic/Elements/LinkParser.mjs +60 -0
- package/src/parser/Semantic/Elements/LinkParser.res +156 -0
- package/src/parser/Semantic/Elements/TextParser.mjs +19 -0
- package/src/parser/Semantic/Elements/TextParser.res +42 -0
- package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.mjs +189 -0
- package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.res +257 -0
- package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.mjs +202 -0
- package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.res +250 -0
- package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.mjs +293 -0
- package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.res +134 -0
- package/src/parser/Semantic/Elements/__tests__/InputParser_test.mjs +253 -0
- package/src/parser/Semantic/Elements/__tests__/InputParser_test.res +304 -0
- package/src/parser/Semantic/Elements/__tests__/LinkParser_test.mjs +289 -0
- package/src/parser/Semantic/Elements/__tests__/LinkParser_test.res +402 -0
- package/src/parser/Semantic/Elements/__tests__/TextParser_test.mjs +149 -0
- package/src/parser/Semantic/Elements/__tests__/TextParser_test.res +167 -0
- package/src/parser/Semantic/ParserRegistry.mjs +82 -0
- package/src/parser/Semantic/ParserRegistry.res +145 -0
- package/src/parser/Semantic/SemanticParser.mjs +850 -0
- package/src/parser/Semantic/SemanticParser.res +1368 -0
- package/src/parser/Semantic/__tests__/ASTBuilder_test.mjs +187 -0
- package/src/parser/Semantic/__tests__/ASTBuilder_test.res +192 -0
- package/src/parser/Semantic/__tests__/ParserRegistry_test.mjs +154 -0
- package/src/parser/Semantic/__tests__/ParserRegistry_test.res +191 -0
- package/src/parser/Semantic/__tests__/SemanticParser_integration_test.mjs +768 -0
- package/src/parser/Semantic/__tests__/SemanticParser_integration_test.res +1069 -0
- package/src/parser/Semantic/__tests__/SemanticParser_manual.mjs +1329 -0
- package/src/parser/Semantic/__tests__/SemanticParser_manual.res +544 -0
- package/src/parser/TestMain.mjs +21 -0
- package/src/parser/TestMain.res +14 -0
- package/src/parser/TextExtractor.mjs +179 -0
- package/src/parser/TextExtractor.res +264 -0
- package/src/parser/__tests__/GridScanner_integration.test.mjs +632 -0
- package/src/parser/__tests__/GridScanner_integration.test.res +816 -0
- package/src/parser/__tests__/Performance.test.mjs +244 -0
- package/src/parser/__tests__/Performance.test.res +371 -0
- package/src/parser/__tests__/PerformanceFixtures.mjs +200 -0
- package/src/parser/__tests__/PerformanceFixtures.res +284 -0
- package/src/parser/__tests__/WyreframeParser_integration.test.mjs +770 -0
- package/src/parser/__tests__/WyreframeParser_integration.test.res +1008 -0
- package/src/parser/__tests__/fixtures/alignment-test.txt +9 -0
- package/src/parser/__tests__/fixtures/all-elements.txt +16 -0
- package/src/parser/__tests__/fixtures/login-scene.txt +17 -0
- package/src/parser/__tests__/fixtures/multi-scene.txt +25 -0
- package/src/parser/__tests__/fixtures/nested-boxes.txt +15 -0
- package/src/parser/__tests__/fixtures/simple-box.txt +5 -0
- package/src/parser/__tests__/fixtures/with-dividers.txt +14 -0
- package/src/renderer/Renderer.gen.tsx +32 -0
- package/src/renderer/Renderer.mjs +391 -0
- package/src/renderer/Renderer.res +558 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function make(row, col) {
|
|
5
|
+
return {
|
|
6
|
+
row: row,
|
|
7
|
+
col: col
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function right(pos, nOpt) {
|
|
12
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
13
|
+
return {
|
|
14
|
+
row: pos.row,
|
|
15
|
+
col: pos.col + n | 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function down(pos, nOpt) {
|
|
20
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
21
|
+
return {
|
|
22
|
+
row: pos.row + n | 0,
|
|
23
|
+
col: pos.col
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function left(pos, nOpt) {
|
|
28
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
29
|
+
return {
|
|
30
|
+
row: pos.row,
|
|
31
|
+
col: pos.col - n | 0
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function up(pos, nOpt) {
|
|
36
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
37
|
+
return {
|
|
38
|
+
row: pos.row - n | 0,
|
|
39
|
+
col: pos.col
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function equals(a, b) {
|
|
44
|
+
if (a.row === b.row) {
|
|
45
|
+
return a.col === b.col;
|
|
46
|
+
} else {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function toString(pos) {
|
|
52
|
+
let rowStr = (pos.row + 1 | 0).toString();
|
|
53
|
+
let colStr = (pos.col + 1 | 0).toString();
|
|
54
|
+
return "(" + rowStr + ", " + colStr + ")";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function fromUserCoords(row, col) {
|
|
58
|
+
return {
|
|
59
|
+
row: row - 1 | 0,
|
|
60
|
+
col: col - 1 | 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isWithin(pos, bounds) {
|
|
65
|
+
if (pos.row >= bounds.top && pos.row <= bounds.bottom && pos.col >= bounds.left) {
|
|
66
|
+
return pos.col <= bounds.right;
|
|
67
|
+
} else {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
make,
|
|
74
|
+
right,
|
|
75
|
+
down,
|
|
76
|
+
left,
|
|
77
|
+
up,
|
|
78
|
+
equals,
|
|
79
|
+
toString,
|
|
80
|
+
fromUserCoords,
|
|
81
|
+
isWithin,
|
|
82
|
+
}
|
|
83
|
+
/* No side effect */
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Position.res
|
|
2
|
+
// Represents a position in the 2D grid with row and column coordinates
|
|
3
|
+
|
|
4
|
+
type t = {
|
|
5
|
+
row: int,
|
|
6
|
+
col: int,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Create a position
|
|
10
|
+
let make = (row: int, col: int): t => {
|
|
11
|
+
{row, col}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Navigation functions
|
|
15
|
+
let right = (pos: t, ~n: int=1): t => {
|
|
16
|
+
{row: pos.row, col: pos.col + n}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let down = (pos: t, ~n: int=1): t => {
|
|
20
|
+
{row: pos.row + n, col: pos.col}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let left = (pos: t, ~n: int=1): t => {
|
|
24
|
+
{row: pos.row, col: pos.col - n}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let up = (pos: t, ~n: int=1): t => {
|
|
28
|
+
{row: pos.row - n, col: pos.col}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Equality
|
|
32
|
+
let equals = (a: t, b: t): bool => {
|
|
33
|
+
a.row == b.row && a.col == b.col
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// String representation (1-indexed for user display)
|
|
37
|
+
let toString = (pos: t): string => {
|
|
38
|
+
let rowStr = Int.toString(pos.row + 1)
|
|
39
|
+
let colStr = Int.toString(pos.col + 1)
|
|
40
|
+
"(" ++ rowStr ++ ", " ++ colStr ++ ")"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Create from user-friendly 1-indexed coordinates
|
|
44
|
+
let fromUserCoords = (row: int, col: int): t => {
|
|
45
|
+
{row: row - 1, col: col - 1}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Check if position is within bounds (inclusive)
|
|
49
|
+
let isWithin = (pos: t, bounds: Types.Bounds.t): bool => {
|
|
50
|
+
pos.row >= bounds.top &&
|
|
51
|
+
pos.row <= bounds.bottom &&
|
|
52
|
+
pos.col >= bounds.left &&
|
|
53
|
+
pos.col <= bounds.right
|
|
54
|
+
}
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Core__Int from "@rescript/core/src/Core__Int.mjs";
|
|
4
|
+
import * as Primitive_module from "@rescript/runtime/lib/es6/Primitive_module.js";
|
|
5
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
6
|
+
|
|
7
|
+
let Position = Primitive_module.init([
|
|
8
|
+
"Types.res",
|
|
9
|
+
19,
|
|
10
|
+
4
|
|
11
|
+
], {
|
|
12
|
+
TAG: "Module",
|
|
13
|
+
_0: [
|
|
14
|
+
[
|
|
15
|
+
"Function",
|
|
16
|
+
"make"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"Function",
|
|
20
|
+
"right"
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"Function",
|
|
24
|
+
"down"
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"Function",
|
|
28
|
+
"left"
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"Function",
|
|
32
|
+
"up"
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"Function",
|
|
36
|
+
"equals"
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"Function",
|
|
40
|
+
"isWithin"
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
"Function",
|
|
44
|
+
"toString"
|
|
45
|
+
]
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let Bounds = Primitive_module.init([
|
|
50
|
+
"Types.res",
|
|
51
|
+
76,
|
|
52
|
+
4
|
|
53
|
+
], {
|
|
54
|
+
TAG: "Module",
|
|
55
|
+
_0: [
|
|
56
|
+
[
|
|
57
|
+
"Function",
|
|
58
|
+
"make"
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"Function",
|
|
62
|
+
"width"
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
"Function",
|
|
66
|
+
"height"
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
"Function",
|
|
70
|
+
"area"
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
"Function",
|
|
74
|
+
"contains"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"Function",
|
|
78
|
+
"overlaps"
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
"Function",
|
|
82
|
+
"equals"
|
|
83
|
+
]
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
function make(row, col) {
|
|
88
|
+
return {
|
|
89
|
+
row: row,
|
|
90
|
+
col: col
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function right(pos, nOpt) {
|
|
95
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
96
|
+
return {
|
|
97
|
+
row: pos.row,
|
|
98
|
+
col: pos.col + n | 0
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function down(pos, nOpt) {
|
|
103
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
104
|
+
return {
|
|
105
|
+
row: pos.row + n | 0,
|
|
106
|
+
col: pos.col
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function left(pos, nOpt) {
|
|
111
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
112
|
+
return {
|
|
113
|
+
row: pos.row,
|
|
114
|
+
col: pos.col - n | 0
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function up(pos, nOpt) {
|
|
119
|
+
let n = nOpt !== undefined ? nOpt : 1;
|
|
120
|
+
return {
|
|
121
|
+
row: pos.row - n | 0,
|
|
122
|
+
col: pos.col
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function equals(a, b) {
|
|
127
|
+
if (a.row === b.row) {
|
|
128
|
+
return a.col === b.col;
|
|
129
|
+
} else {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isWithin(pos, bounds) {
|
|
135
|
+
if (pos.row >= bounds.top && pos.row <= bounds.bottom && pos.col >= bounds.left) {
|
|
136
|
+
return pos.col <= bounds.right;
|
|
137
|
+
} else {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function toString(pos) {
|
|
143
|
+
return `(` + pos.row.toString() + `, ` + pos.col.toString() + `)`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
Primitive_module.update({
|
|
147
|
+
TAG: "Module",
|
|
148
|
+
_0: [
|
|
149
|
+
[
|
|
150
|
+
"Function",
|
|
151
|
+
"make"
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
"Function",
|
|
155
|
+
"right"
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
"Function",
|
|
159
|
+
"down"
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
"Function",
|
|
163
|
+
"left"
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
"Function",
|
|
167
|
+
"up"
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
"Function",
|
|
171
|
+
"equals"
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
"Function",
|
|
175
|
+
"isWithin"
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
"Function",
|
|
179
|
+
"toString"
|
|
180
|
+
]
|
|
181
|
+
]
|
|
182
|
+
}, Position, {
|
|
183
|
+
make: make,
|
|
184
|
+
right: right,
|
|
185
|
+
down: down,
|
|
186
|
+
left: left,
|
|
187
|
+
up: up,
|
|
188
|
+
equals: equals,
|
|
189
|
+
isWithin: isWithin,
|
|
190
|
+
toString: toString
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
function make$1(top, left, bottom, right) {
|
|
194
|
+
return {
|
|
195
|
+
top: top,
|
|
196
|
+
left: left,
|
|
197
|
+
bottom: bottom,
|
|
198
|
+
right: right
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function width(bounds) {
|
|
203
|
+
return bounds.right - bounds.left | 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function height(bounds) {
|
|
207
|
+
return bounds.bottom - bounds.top | 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function area(bounds) {
|
|
211
|
+
return width(bounds) * height(bounds) | 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function contains(outer, inner) {
|
|
215
|
+
if (outer.top < inner.top && outer.left < inner.left && outer.bottom > inner.bottom) {
|
|
216
|
+
return outer.right > inner.right;
|
|
217
|
+
} else {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function overlaps(a, b) {
|
|
223
|
+
return !(a.right < b.left || b.right < a.left || a.bottom < b.top || b.bottom < a.top);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function equals$1(a, b) {
|
|
227
|
+
if (a.top === b.top && a.left === b.left && a.bottom === b.bottom) {
|
|
228
|
+
return a.right === b.right;
|
|
229
|
+
} else {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
Primitive_module.update({
|
|
235
|
+
TAG: "Module",
|
|
236
|
+
_0: [
|
|
237
|
+
[
|
|
238
|
+
"Function",
|
|
239
|
+
"make"
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
"Function",
|
|
243
|
+
"width"
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
"Function",
|
|
247
|
+
"height"
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
"Function",
|
|
251
|
+
"area"
|
|
252
|
+
],
|
|
253
|
+
[
|
|
254
|
+
"Function",
|
|
255
|
+
"contains"
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
"Function",
|
|
259
|
+
"overlaps"
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
"Function",
|
|
263
|
+
"equals"
|
|
264
|
+
]
|
|
265
|
+
]
|
|
266
|
+
}, Bounds, {
|
|
267
|
+
make: make$1,
|
|
268
|
+
width: width,
|
|
269
|
+
height: height,
|
|
270
|
+
area: area,
|
|
271
|
+
contains: contains,
|
|
272
|
+
overlaps: overlaps,
|
|
273
|
+
equals: equals$1
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
function getDeviceDimensions(device) {
|
|
277
|
+
if (typeof device !== "object") {
|
|
278
|
+
switch (device) {
|
|
279
|
+
case "Desktop" :
|
|
280
|
+
return {
|
|
281
|
+
width: 1440,
|
|
282
|
+
height: 900,
|
|
283
|
+
ratio: 16.0 / 10.0,
|
|
284
|
+
name: "desktop"
|
|
285
|
+
};
|
|
286
|
+
case "Laptop" :
|
|
287
|
+
return {
|
|
288
|
+
width: 1280,
|
|
289
|
+
height: 800,
|
|
290
|
+
ratio: 16.0 / 10.0,
|
|
291
|
+
name: "laptop"
|
|
292
|
+
};
|
|
293
|
+
case "Tablet" :
|
|
294
|
+
return {
|
|
295
|
+
width: 768,
|
|
296
|
+
height: 1024,
|
|
297
|
+
ratio: 3.0 / 4.0,
|
|
298
|
+
name: "tablet"
|
|
299
|
+
};
|
|
300
|
+
case "TabletLandscape" :
|
|
301
|
+
return {
|
|
302
|
+
width: 1024,
|
|
303
|
+
height: 768,
|
|
304
|
+
ratio: 4.0 / 3.0,
|
|
305
|
+
name: "tablet-landscape"
|
|
306
|
+
};
|
|
307
|
+
case "Mobile" :
|
|
308
|
+
return {
|
|
309
|
+
width: 375,
|
|
310
|
+
height: 812,
|
|
311
|
+
ratio: 375.0 / 812.0,
|
|
312
|
+
name: "mobile"
|
|
313
|
+
};
|
|
314
|
+
case "MobileLandscape" :
|
|
315
|
+
return {
|
|
316
|
+
width: 812,
|
|
317
|
+
height: 375,
|
|
318
|
+
ratio: 812.0 / 375.0,
|
|
319
|
+
name: "mobile-landscape"
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
let h = device._1;
|
|
324
|
+
let w = device._0;
|
|
325
|
+
return {
|
|
326
|
+
width: w,
|
|
327
|
+
height: h,
|
|
328
|
+
ratio: w / h,
|
|
329
|
+
name: "custom-" + w.toString() + "x" + h.toString()
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function parseDeviceType(str) {
|
|
335
|
+
let normalized = str.trim().toLowerCase();
|
|
336
|
+
switch (normalized) {
|
|
337
|
+
case "desktop" :
|
|
338
|
+
return "Desktop";
|
|
339
|
+
case "laptop" :
|
|
340
|
+
return "Laptop";
|
|
341
|
+
case "mobile" :
|
|
342
|
+
case "phone" :
|
|
343
|
+
return "Mobile";
|
|
344
|
+
case "mobile-landscape" :
|
|
345
|
+
case "mobilelandscape" :
|
|
346
|
+
case "phone-landscape" :
|
|
347
|
+
return "MobileLandscape";
|
|
348
|
+
case "tablet" :
|
|
349
|
+
return "Tablet";
|
|
350
|
+
case "tablet-landscape" :
|
|
351
|
+
case "tabletlandscape" :
|
|
352
|
+
return "TabletLandscape";
|
|
353
|
+
default:
|
|
354
|
+
let customPattern = /^(\d+)\s*x\s*(\d+)$/i;
|
|
355
|
+
let result = customPattern.exec(normalized);
|
|
356
|
+
if (result === null) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
let match = result[1];
|
|
360
|
+
let match$1 = result[2];
|
|
361
|
+
if (match === undefined) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (match$1 === undefined) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
let hNullable = Primitive_option.valFromOption(match$1);
|
|
368
|
+
let wNullable = Primitive_option.valFromOption(match);
|
|
369
|
+
if (wNullable == null) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (hNullable == null) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
let match$2 = Core__Int.fromString(wNullable, undefined);
|
|
376
|
+
let match$3 = Core__Int.fromString(hNullable, undefined);
|
|
377
|
+
if (match$2 !== undefined && match$3 !== undefined) {
|
|
378
|
+
return {
|
|
379
|
+
TAG: "Custom",
|
|
380
|
+
_0: match$2,
|
|
381
|
+
_1: match$3
|
|
382
|
+
};
|
|
383
|
+
} else {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function getElementType(elem) {
|
|
390
|
+
switch (elem.TAG) {
|
|
391
|
+
case "Box" :
|
|
392
|
+
return "Box";
|
|
393
|
+
case "Button" :
|
|
394
|
+
return "Button";
|
|
395
|
+
case "Input" :
|
|
396
|
+
return "Input";
|
|
397
|
+
case "Link" :
|
|
398
|
+
return "Link";
|
|
399
|
+
case "Checkbox" :
|
|
400
|
+
return "Checkbox";
|
|
401
|
+
case "Text" :
|
|
402
|
+
return "Text";
|
|
403
|
+
case "Divider" :
|
|
404
|
+
return "Divider";
|
|
405
|
+
case "Row" :
|
|
406
|
+
return "Row";
|
|
407
|
+
case "Section" :
|
|
408
|
+
return "Section";
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function getElementId(elem) {
|
|
413
|
+
switch (elem.TAG) {
|
|
414
|
+
case "Box" :
|
|
415
|
+
return elem.name;
|
|
416
|
+
case "Button" :
|
|
417
|
+
case "Input" :
|
|
418
|
+
case "Link" :
|
|
419
|
+
return elem.id;
|
|
420
|
+
case "Section" :
|
|
421
|
+
return elem.name;
|
|
422
|
+
default:
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export {
|
|
428
|
+
Position,
|
|
429
|
+
Bounds,
|
|
430
|
+
getDeviceDimensions,
|
|
431
|
+
parseDeviceType,
|
|
432
|
+
getElementType,
|
|
433
|
+
getElementId,
|
|
434
|
+
}
|
|
435
|
+
/* Position Not a pure module */
|