@reactiive/ennio 0.0.1
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/EnnioCore.podspec +61 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/android/CMakeLists.txt +40 -0
- package/android/build.gradle +64 -0
- package/cpp/ElementMatcher.cpp +661 -0
- package/cpp/ElementMatcher.hpp +244 -0
- package/cpp/EnnioLog.hpp +182 -0
- package/cpp/HybridEnnio.cpp +1161 -0
- package/cpp/HybridEnnio.hpp +174 -0
- package/cpp/IdleMonitor.hpp +277 -0
- package/cpp/Protocol.cpp +135 -0
- package/cpp/Protocol.hpp +47 -0
- package/cpp/SelectorCriteria.hpp +281 -0
- package/cpp/SelectorParser.cpp +649 -0
- package/cpp/SelectorParser.hpp +94 -0
- package/cpp/ShadowTreeTraverser.cpp +305 -0
- package/cpp/ShadowTreeTraverser.hpp +142 -0
- package/cpp/TestIDRegistry.cpp +109 -0
- package/cpp/TestIDRegistry.hpp +84 -0
- package/dist/cli.js +16221 -0
- package/ios/EnnioAutoInit.mm +338 -0
- package/ios/EnnioDebugBanner.h +19 -0
- package/ios/EnnioDebugBanner.mm +178 -0
- package/ios/EnnioRuntimeHelper.h +264 -0
- package/ios/EnnioRuntimeHelper.mm +2443 -0
- package/lib/Ennio.nitro.d.ts +263 -0
- package/lib/Ennio.nitro.d.ts.map +1 -0
- package/lib/Ennio.nitro.js +2 -0
- package/lib/Ennio.nitro.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +45 -0
- package/lib/index.js.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/EnnioCore+autolinking.cmake +81 -0
- package/nitrogen/generated/android/EnnioCore+autolinking.gradle +27 -0
- package/nitrogen/generated/android/EnnioCoreOnLoad.cpp +49 -0
- package/nitrogen/generated/android/EnnioCoreOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/ennio/EnnioCoreOnLoad.kt +35 -0
- package/nitrogen/generated/ios/EnnioCore+autolinking.rb +62 -0
- package/nitrogen/generated/ios/EnnioCore-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/EnnioCore-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/EnnioCore-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/EnnioCoreAutolinking.mm +35 -0
- package/nitrogen/generated/ios/EnnioCoreAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/ExtendedElementInfo.hpp +118 -0
- package/nitrogen/generated/shared/c++/HybridEnnioSpec.cpp +44 -0
- package/nitrogen/generated/shared/c++/HybridEnnioSpec.hpp +93 -0
- package/nitrogen/generated/shared/c++/LayoutMetrics.hpp +103 -0
- package/nitrogen/generated/shared/c++/ScrollDirection.hpp +84 -0
- package/package.json +78 -0
- package/react-native.config.js +14 -0
- package/src/Ennio.nitro.ts +363 -0
- package/src/cli/hid-daemon.py +129 -0
- package/src/index.ts +72 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <regex>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace ennio {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Text matching mode for text selectors
|
|
13
|
+
*/
|
|
14
|
+
enum class TextMatchMode {
|
|
15
|
+
Exact, // Exact match
|
|
16
|
+
Contains, // Contains substring
|
|
17
|
+
Regex, // Regular expression
|
|
18
|
+
StartsWith, // Starts with prefix
|
|
19
|
+
EndsWith // Ends with suffix
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Text matcher configuration
|
|
24
|
+
*/
|
|
25
|
+
struct TextMatcher {
|
|
26
|
+
std::string pattern;
|
|
27
|
+
TextMatchMode mode = TextMatchMode::Exact;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Check if the given text matches this matcher
|
|
31
|
+
*/
|
|
32
|
+
bool matches(const std::string& text) const {
|
|
33
|
+
switch (mode) {
|
|
34
|
+
case TextMatchMode::Exact:
|
|
35
|
+
return text == pattern;
|
|
36
|
+
case TextMatchMode::Contains:
|
|
37
|
+
return text.find(pattern) != std::string::npos;
|
|
38
|
+
case TextMatchMode::StartsWith:
|
|
39
|
+
return text.size() >= pattern.size() &&
|
|
40
|
+
text.compare(0, pattern.size(), pattern) == 0;
|
|
41
|
+
case TextMatchMode::EndsWith:
|
|
42
|
+
return text.size() >= pattern.size() &&
|
|
43
|
+
text.compare(text.size() - pattern.size(), pattern.size(), pattern) == 0;
|
|
44
|
+
case TextMatchMode::Regex:
|
|
45
|
+
try {
|
|
46
|
+
std::regex re(pattern);
|
|
47
|
+
return std::regex_search(text, re);
|
|
48
|
+
} catch (...) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Point for coordinate-based selection
|
|
58
|
+
*/
|
|
59
|
+
struct Point {
|
|
60
|
+
float x;
|
|
61
|
+
float y;
|
|
62
|
+
bool isPercentage = false; // If true, x/y are percentages (0-100)
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Supported trait types for trait-based selection
|
|
67
|
+
*/
|
|
68
|
+
enum class Trait {
|
|
69
|
+
Text, // Element has text content
|
|
70
|
+
LongText, // Element has 200+ characters
|
|
71
|
+
Square // Element width ≈ height (within 10%)
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Forward declaration for recursive selectors
|
|
75
|
+
struct SelectorCriteria;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Shared pointer to SelectorCriteria for recursive references
|
|
79
|
+
*/
|
|
80
|
+
using SelectorCriteriaPtr = std::shared_ptr<SelectorCriteria>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* SelectorCriteria - Complete Maestro selector parity
|
|
84
|
+
*
|
|
85
|
+
* Supports:
|
|
86
|
+
* - Primary: id, text, index, point
|
|
87
|
+
* - State: enabled, checked, focused, selected
|
|
88
|
+
* - Spatial: below, above, leftOf, rightOf
|
|
89
|
+
* - Hierarchical: containsChild, childOf, containsDescendants
|
|
90
|
+
* - Dimensions: width, height, tolerance
|
|
91
|
+
* - Traits: text, long-text, square
|
|
92
|
+
*/
|
|
93
|
+
struct SelectorCriteria {
|
|
94
|
+
// ============================================
|
|
95
|
+
// Primary Selectors
|
|
96
|
+
// ============================================
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Match by testID (O(1) lookup when used alone)
|
|
100
|
+
*/
|
|
101
|
+
std::optional<std::string> id;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Match by text content
|
|
105
|
+
*/
|
|
106
|
+
std::optional<TextMatcher> text;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Return the nth matching element (0-indexed)
|
|
110
|
+
*/
|
|
111
|
+
std::optional<int> index;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Select element at specific coordinates
|
|
115
|
+
*/
|
|
116
|
+
std::optional<Point> point;
|
|
117
|
+
|
|
118
|
+
// ============================================
|
|
119
|
+
// State Selectors
|
|
120
|
+
// ============================================
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Match by enabled state
|
|
124
|
+
*/
|
|
125
|
+
std::optional<bool> enabled;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Match by checked state (checkboxes, switches)
|
|
129
|
+
*/
|
|
130
|
+
std::optional<bool> checked;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Match by focused state
|
|
134
|
+
*/
|
|
135
|
+
std::optional<bool> focused;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Match by selected state
|
|
139
|
+
*/
|
|
140
|
+
std::optional<bool> selected;
|
|
141
|
+
|
|
142
|
+
// ============================================
|
|
143
|
+
// Spatial Selectors (relative positioning)
|
|
144
|
+
// ============================================
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Match elements below the reference element
|
|
148
|
+
*/
|
|
149
|
+
SelectorCriteriaPtr below;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Match elements above the reference element
|
|
153
|
+
*/
|
|
154
|
+
SelectorCriteriaPtr above;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Match elements to the left of the reference element
|
|
158
|
+
*/
|
|
159
|
+
SelectorCriteriaPtr leftOf;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Match elements to the right of the reference element
|
|
163
|
+
*/
|
|
164
|
+
SelectorCriteriaPtr rightOf;
|
|
165
|
+
|
|
166
|
+
// ============================================
|
|
167
|
+
// Hierarchical Selectors
|
|
168
|
+
// ============================================
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Match elements that contain a direct child matching criteria
|
|
172
|
+
*/
|
|
173
|
+
SelectorCriteriaPtr containsChild;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Match elements that are children of an element matching criteria
|
|
177
|
+
*/
|
|
178
|
+
SelectorCriteriaPtr childOf;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Match elements that contain all descendants matching each criteria
|
|
182
|
+
*/
|
|
183
|
+
std::vector<SelectorCriteriaPtr> containsDescendants;
|
|
184
|
+
|
|
185
|
+
// ============================================
|
|
186
|
+
// Dimension Selectors
|
|
187
|
+
// ============================================
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Match by width (in points)
|
|
191
|
+
*/
|
|
192
|
+
std::optional<float> width;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Match by height (in points)
|
|
196
|
+
*/
|
|
197
|
+
std::optional<float> height;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Tolerance for width/height matching (default: 0)
|
|
201
|
+
*/
|
|
202
|
+
std::optional<float> tolerance;
|
|
203
|
+
|
|
204
|
+
// ============================================
|
|
205
|
+
// Trait Selectors
|
|
206
|
+
// ============================================
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Match elements with specified traits
|
|
210
|
+
*/
|
|
211
|
+
std::vector<Trait> traits;
|
|
212
|
+
|
|
213
|
+
// ============================================
|
|
214
|
+
// Helpers
|
|
215
|
+
// ============================================
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Check if this is an id-only selector (fast path)
|
|
219
|
+
*/
|
|
220
|
+
bool isIdOnly() const {
|
|
221
|
+
return id.has_value() &&
|
|
222
|
+
!text.has_value() &&
|
|
223
|
+
!index.has_value() &&
|
|
224
|
+
!point.has_value() &&
|
|
225
|
+
!enabled.has_value() &&
|
|
226
|
+
!checked.has_value() &&
|
|
227
|
+
!focused.has_value() &&
|
|
228
|
+
!selected.has_value() &&
|
|
229
|
+
!below &&
|
|
230
|
+
!above &&
|
|
231
|
+
!leftOf &&
|
|
232
|
+
!rightOf &&
|
|
233
|
+
!containsChild &&
|
|
234
|
+
!childOf &&
|
|
235
|
+
containsDescendants.empty() &&
|
|
236
|
+
!width.has_value() &&
|
|
237
|
+
!height.has_value() &&
|
|
238
|
+
traits.empty();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Check if any spatial selectors are used
|
|
243
|
+
*/
|
|
244
|
+
bool hasSpatialCriteria() const {
|
|
245
|
+
return below || above || leftOf || rightOf;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Check if any hierarchical selectors are used
|
|
250
|
+
*/
|
|
251
|
+
bool hasHierarchicalCriteria() const {
|
|
252
|
+
return containsChild || childOf || !containsDescendants.empty();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Check if any dimension selectors are used
|
|
257
|
+
*/
|
|
258
|
+
bool hasDimensionCriteria() const {
|
|
259
|
+
return width.has_value() || height.has_value();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Create an id-only selector (convenience factory)
|
|
264
|
+
*/
|
|
265
|
+
static SelectorCriteria fromId(const std::string& testID) {
|
|
266
|
+
SelectorCriteria criteria;
|
|
267
|
+
criteria.id = testID;
|
|
268
|
+
return criteria;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Create a text selector (convenience factory)
|
|
273
|
+
*/
|
|
274
|
+
static SelectorCriteria fromText(const std::string& textContent, TextMatchMode mode = TextMatchMode::Exact) {
|
|
275
|
+
SelectorCriteria criteria;
|
|
276
|
+
criteria.text = TextMatcher{textContent, mode};
|
|
277
|
+
return criteria;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
} // namespace ennio
|