@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,84 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <mutex>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <unordered_map>
|
|
7
|
+
|
|
8
|
+
#include <react/renderer/core/ShadowNode.h>
|
|
9
|
+
|
|
10
|
+
namespace ennio {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* TestIDRegistry provides O(1) lookup of ShadowNodes by testID.
|
|
14
|
+
*
|
|
15
|
+
* This class maintains a hashmap from testID strings to weak pointers
|
|
16
|
+
* of ShadowNodes. The registry is updated on shadow tree commits and
|
|
17
|
+
* falls back to tree traversal if a cached entry is stale.
|
|
18
|
+
*/
|
|
19
|
+
class TestIDRegistry {
|
|
20
|
+
public:
|
|
21
|
+
using ShadowNodePtr = std::shared_ptr<const facebook::react::ShadowNode>;
|
|
22
|
+
using WeakShadowNodePtr = std::weak_ptr<const facebook::react::ShadowNode>;
|
|
23
|
+
|
|
24
|
+
static TestIDRegistry& getInstance();
|
|
25
|
+
|
|
26
|
+
// Prevent copying
|
|
27
|
+
TestIDRegistry(const TestIDRegistry&) = delete;
|
|
28
|
+
TestIDRegistry& operator=(const TestIDRegistry&) = delete;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Register a ShadowNode with a testID
|
|
32
|
+
*/
|
|
33
|
+
void registerNode(const std::string& testID, ShadowNodePtr node);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Remove a testID from the registry
|
|
37
|
+
*/
|
|
38
|
+
void unregisterNode(const std::string& testID);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Look up a ShadowNode by testID
|
|
42
|
+
* Returns nullptr if not found or if the weak_ptr is expired
|
|
43
|
+
*/
|
|
44
|
+
ShadowNodePtr findByTestID(const std::string& testID) const;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Check if a testID exists in the registry
|
|
48
|
+
*/
|
|
49
|
+
bool exists(const std::string& testID) const;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Clear all registered nodes
|
|
53
|
+
*/
|
|
54
|
+
void clear();
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get the number of registered testIDs
|
|
58
|
+
*/
|
|
59
|
+
size_t size() const;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Update registry from a shadow tree root
|
|
63
|
+
* Traverses the tree and updates all testID mappings
|
|
64
|
+
*/
|
|
65
|
+
void updateFromTree(ShadowNodePtr root);
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
TestIDRegistry() = default;
|
|
69
|
+
|
|
70
|
+
mutable std::mutex mutex_;
|
|
71
|
+
// `mutable` so `findByTestID` (const) can lazily evict expired
|
|
72
|
+
// entries during lookup — without it, a long-running session
|
|
73
|
+
// accumulates dead weak_ptrs forever between `updateFromTree`
|
|
74
|
+
// sweeps.
|
|
75
|
+
mutable std::unordered_map<std::string, WeakShadowNodePtr> registry_;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Recursively traverse and register nodes with testIDs
|
|
79
|
+
* Takes shared_ptr to properly create weak_ptr for storage
|
|
80
|
+
*/
|
|
81
|
+
void traverseAndRegister(ShadowNodePtr node);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace ennio
|