@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.
Files changed (57) hide show
  1. package/EnnioCore.podspec +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -0
  4. package/android/CMakeLists.txt +40 -0
  5. package/android/build.gradle +64 -0
  6. package/cpp/ElementMatcher.cpp +661 -0
  7. package/cpp/ElementMatcher.hpp +244 -0
  8. package/cpp/EnnioLog.hpp +182 -0
  9. package/cpp/HybridEnnio.cpp +1161 -0
  10. package/cpp/HybridEnnio.hpp +174 -0
  11. package/cpp/IdleMonitor.hpp +277 -0
  12. package/cpp/Protocol.cpp +135 -0
  13. package/cpp/Protocol.hpp +47 -0
  14. package/cpp/SelectorCriteria.hpp +281 -0
  15. package/cpp/SelectorParser.cpp +649 -0
  16. package/cpp/SelectorParser.hpp +94 -0
  17. package/cpp/ShadowTreeTraverser.cpp +305 -0
  18. package/cpp/ShadowTreeTraverser.hpp +142 -0
  19. package/cpp/TestIDRegistry.cpp +109 -0
  20. package/cpp/TestIDRegistry.hpp +84 -0
  21. package/dist/cli.js +16221 -0
  22. package/ios/EnnioAutoInit.mm +338 -0
  23. package/ios/EnnioDebugBanner.h +19 -0
  24. package/ios/EnnioDebugBanner.mm +178 -0
  25. package/ios/EnnioRuntimeHelper.h +264 -0
  26. package/ios/EnnioRuntimeHelper.mm +2443 -0
  27. package/lib/Ennio.nitro.d.ts +263 -0
  28. package/lib/Ennio.nitro.d.ts.map +1 -0
  29. package/lib/Ennio.nitro.js +2 -0
  30. package/lib/Ennio.nitro.js.map +1 -0
  31. package/lib/index.d.ts +16 -0
  32. package/lib/index.d.ts.map +1 -0
  33. package/lib/index.js +45 -0
  34. package/lib/index.js.map +1 -0
  35. package/nitro.json +24 -0
  36. package/nitrogen/generated/.gitattributes +1 -0
  37. package/nitrogen/generated/android/EnnioCore+autolinking.cmake +81 -0
  38. package/nitrogen/generated/android/EnnioCore+autolinking.gradle +27 -0
  39. package/nitrogen/generated/android/EnnioCoreOnLoad.cpp +49 -0
  40. package/nitrogen/generated/android/EnnioCoreOnLoad.hpp +34 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/ennio/EnnioCoreOnLoad.kt +35 -0
  42. package/nitrogen/generated/ios/EnnioCore+autolinking.rb +62 -0
  43. package/nitrogen/generated/ios/EnnioCore-Swift-Cxx-Bridge.cpp +17 -0
  44. package/nitrogen/generated/ios/EnnioCore-Swift-Cxx-Bridge.hpp +27 -0
  45. package/nitrogen/generated/ios/EnnioCore-Swift-Cxx-Umbrella.hpp +38 -0
  46. package/nitrogen/generated/ios/EnnioCoreAutolinking.mm +35 -0
  47. package/nitrogen/generated/ios/EnnioCoreAutolinking.swift +16 -0
  48. package/nitrogen/generated/shared/c++/ExtendedElementInfo.hpp +118 -0
  49. package/nitrogen/generated/shared/c++/HybridEnnioSpec.cpp +44 -0
  50. package/nitrogen/generated/shared/c++/HybridEnnioSpec.hpp +93 -0
  51. package/nitrogen/generated/shared/c++/LayoutMetrics.hpp +103 -0
  52. package/nitrogen/generated/shared/c++/ScrollDirection.hpp +84 -0
  53. package/package.json +78 -0
  54. package/react-native.config.js +14 -0
  55. package/src/Ennio.nitro.ts +363 -0
  56. package/src/cli/hid-daemon.py +129 -0
  57. 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