react-native-nitro-tracing 0.6.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.
Files changed (233) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/NitroTracing.podspec +32 -0
  4. package/README.md +75 -0
  5. package/android/CMakeLists.txt +49 -0
  6. package/android/build.gradle +133 -0
  7. package/android/fix-prefab.gradle +51 -0
  8. package/android/gradle.properties +5 -0
  9. package/android/proguard-rules.pro +5 -0
  10. package/android/src/main/AndroidManifest.xml +2 -0
  11. package/android/src/main/cpp/cpp-adapter.cpp +47 -0
  12. package/android/src/main/java/com/margelo/nitro/nitrotracing/HermesSamplingGuard.kt +43 -0
  13. package/android/src/main/java/com/margelo/nitro/nitrotracing/NitroTracingFrameSource.kt +36 -0
  14. package/android/src/main/java/com/margelo/nitro/nitrotracing/NitroTracingPackage.kt +31 -0
  15. package/client.ts +15 -0
  16. package/cpp/HermesSampling.cpp +26 -0
  17. package/cpp/HermesSampling.hpp +10 -0
  18. package/cpp/HybridRecording.cpp +66 -0
  19. package/cpp/HybridRecording.hpp +30 -0
  20. package/cpp/HybridTraceSpan.cpp +10 -0
  21. package/cpp/HybridTraceSpan.hpp +17 -0
  22. package/cpp/HybridTracing.cpp +10 -0
  23. package/cpp/HybridTracing.hpp +10 -0
  24. package/cpp/NativeConversions.cpp +77 -0
  25. package/cpp/NativeConversions.hpp +15 -0
  26. package/cpp/core/NativeSampler.cpp +152 -0
  27. package/cpp/core/NativeSampler.hpp +56 -0
  28. package/cpp/core/Recorder.cpp +218 -0
  29. package/cpp/core/Recorder.hpp +60 -0
  30. package/cpp/core/Retention.cpp +26 -0
  31. package/cpp/core/Retention.hpp +7 -0
  32. package/cpp/core/TraceJson.cpp +214 -0
  33. package/cpp/core/TraceJson.hpp +7 -0
  34. package/cpp/core/TraceTypes.hpp +62 -0
  35. package/expo.ts +2 -0
  36. package/ios/NitroTracingFrameSource.mm +35 -0
  37. package/lib/commonjs/client.cjs +767 -0
  38. package/lib/commonjs/client.cjs.map +7 -0
  39. package/lib/commonjs/expo.cjs +88 -0
  40. package/lib/commonjs/expo.cjs.map +7 -0
  41. package/lib/commonjs/index.cjs +28 -0
  42. package/lib/commonjs/index.cjs.map +7 -0
  43. package/lib/commonjs/performance.cjs +112 -0
  44. package/lib/commonjs/performance.cjs.map +7 -0
  45. package/lib/commonjs/plugins.cjs +477 -0
  46. package/lib/commonjs/plugins.cjs.map +7 -0
  47. package/lib/commonjs/react.cjs +3833 -0
  48. package/lib/commonjs/react.cjs.map +7 -0
  49. package/lib/commonjs/release-profiler.cjs +142 -0
  50. package/lib/commonjs/release-profiler.cjs.map +7 -0
  51. package/lib/commonjs/sentry.cjs +188 -0
  52. package/lib/commonjs/sentry.cjs.map +7 -0
  53. package/lib/module/client.mjs +768 -0
  54. package/lib/module/client.mjs.map +7 -0
  55. package/lib/module/expo.mjs +62 -0
  56. package/lib/module/expo.mjs.map +7 -0
  57. package/lib/module/index.mjs +7 -0
  58. package/lib/module/index.mjs.map +7 -0
  59. package/lib/module/performance.mjs +89 -0
  60. package/lib/module/performance.mjs.map +7 -0
  61. package/lib/module/plugins.mjs +461 -0
  62. package/lib/module/plugins.mjs.map +7 -0
  63. package/lib/module/react.mjs +3851 -0
  64. package/lib/module/react.mjs.map +7 -0
  65. package/lib/module/release-profiler.mjs +137 -0
  66. package/lib/module/release-profiler.mjs.map +7 -0
  67. package/lib/module/sentry.mjs +165 -0
  68. package/lib/module/sentry.mjs.map +7 -0
  69. package/lib/typescript/client.d.ts +4 -0
  70. package/lib/typescript/expo.d.ts +2 -0
  71. package/lib/typescript/performance.d.ts +2 -0
  72. package/lib/typescript/plugins.d.ts +12 -0
  73. package/lib/typescript/react.d.ts +5 -0
  74. package/lib/typescript/release-profiler.d.ts +2 -0
  75. package/lib/typescript/sentry.d.ts +2 -0
  76. package/lib/typescript/src/client/TracingSink.d.ts +10 -0
  77. package/lib/typescript/src/client/createTraceClient.d.ts +82 -0
  78. package/lib/typescript/src/client/playground.d.ts +12 -0
  79. package/lib/typescript/src/expo/ExpoAdapter.d.ts +15 -0
  80. package/lib/typescript/src/expo/index.d.ts +2 -0
  81. package/lib/typescript/src/index.d.ts +6 -0
  82. package/lib/typescript/src/plugins/TracePlugin.d.ts +22 -0
  83. package/lib/typescript/src/plugins/errors.d.ts +15 -0
  84. package/lib/typescript/src/plugins/nativeMetrics.d.ts +13 -0
  85. package/lib/typescript/src/plugins/navigation.d.ts +29 -0
  86. package/lib/typescript/src/plugins/network.d.ts +23 -0
  87. package/lib/typescript/src/plugins/orderSpans.d.ts +3 -0
  88. package/lib/typescript/src/plugins/performance.d.ts +13 -0
  89. package/lib/typescript/src/plugins/releaseProfiler.d.ts +25 -0
  90. package/lib/typescript/src/plugins/runtimeMetrics.d.ts +17 -0
  91. package/lib/typescript/src/plugins/sentry.d.ts +15 -0
  92. package/lib/typescript/src/plugins/startPlugins.d.ts +4 -0
  93. package/lib/typescript/src/react/DetailView.d.ts +11 -0
  94. package/lib/typescript/src/react/ExplorerFilters.d.ts +9 -0
  95. package/lib/typescript/src/react/ExplorerView.d.ts +9 -0
  96. package/lib/typescript/src/react/InspectorControls.d.ts +229 -0
  97. package/lib/typescript/src/react/InspectorHeader.d.ts +8 -0
  98. package/lib/typescript/src/react/InspectorSheet.d.ts +16 -0
  99. package/lib/typescript/src/react/MetricsView.d.ts +7 -0
  100. package/lib/typescript/src/react/SummaryView.d.ts +11 -0
  101. package/lib/typescript/src/react/TimelineView.d.ts +8 -0
  102. package/lib/typescript/src/react/TraceInspector.d.ts +11 -0
  103. package/lib/typescript/src/react/TraceOverlay.d.ts +17 -0
  104. package/lib/typescript/src/react/explorerModel.d.ts +38 -0
  105. package/lib/typescript/src/react/labels.d.ts +203 -0
  106. package/lib/typescript/src/react/native.d.ts +42 -0
  107. package/lib/typescript/src/react/readSnapshot.d.ts +4 -0
  108. package/lib/typescript/src/react/store.d.ts +9 -0
  109. package/lib/typescript/src/react/topics.d.ts +80 -0
  110. package/lib/typescript/src/react/useAppReadyMetric.d.ts +3 -0
  111. package/lib/typescript/src/react/useLiveRecording.d.ts +4 -0
  112. package/lib/typescript/src/react/useTraceViewer.d.ts +140 -0
  113. package/lib/typescript/src/react/viewerModel.d.ts +59 -0
  114. package/lib/typescript/src/specs/Recording.nitro.d.ts +31 -0
  115. package/lib/typescript/src/specs/TraceSpan.nitro.d.ts +14 -0
  116. package/lib/typescript/src/specs/Tracing.nitro.d.ts +17 -0
  117. package/lib/typescript/src/types/CompletedSpanOptions.d.ts +15 -0
  118. package/lib/typescript/src/types/EventContext.d.ts +8 -0
  119. package/lib/typescript/src/types/MarkEvent.d.ts +4 -0
  120. package/lib/typescript/src/types/MarkOptions.d.ts +6 -0
  121. package/lib/typescript/src/types/MetricEvent.d.ts +8 -0
  122. package/lib/typescript/src/types/MetricOptions.d.ts +10 -0
  123. package/lib/typescript/src/types/NativeSamplingOptions.d.ts +7 -0
  124. package/lib/typescript/src/types/ReadOptions.d.ts +7 -0
  125. package/lib/typescript/src/types/RecordingOptions.d.ts +11 -0
  126. package/lib/typescript/src/types/RecordingStats.d.ts +25 -0
  127. package/lib/typescript/src/types/SpanEvent.d.ts +13 -0
  128. package/lib/typescript/src/types/SpanOptions.d.ts +6 -0
  129. package/lib/typescript/src/types/SpanOutcome.d.ts +2 -0
  130. package/lib/typescript/src/types/TraceAttribute.d.ts +7 -0
  131. package/lib/typescript/src/types/TraceAttributes.d.ts +3 -0
  132. package/lib/typescript/src/types/TraceContext.d.ts +10 -0
  133. package/lib/typescript/src/types/TracePage.d.ts +18 -0
  134. package/lib/typescript/src/types.d.ts +17 -0
  135. package/nitro.json +20 -0
  136. package/nitrogen/generated/.gitattributes +1 -0
  137. package/nitrogen/generated/android/NitroTracing+autolinking.cmake +83 -0
  138. package/nitrogen/generated/android/NitroTracing+autolinking.gradle +27 -0
  139. package/nitrogen/generated/android/NitroTracingOnLoad.cpp +49 -0
  140. package/nitrogen/generated/android/NitroTracingOnLoad.hpp +34 -0
  141. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrotracing/NitroTracingOnLoad.kt +35 -0
  142. package/nitrogen/generated/ios/NitroTracing+autolinking.rb +62 -0
  143. package/nitrogen/generated/ios/NitroTracing-Swift-Cxx-Bridge.cpp +17 -0
  144. package/nitrogen/generated/ios/NitroTracing-Swift-Cxx-Bridge.hpp +27 -0
  145. package/nitrogen/generated/ios/NitroTracing-Swift-Cxx-Umbrella.hpp +38 -0
  146. package/nitrogen/generated/ios/NitroTracingAutolinking.mm +35 -0
  147. package/nitrogen/generated/ios/NitroTracingAutolinking.swift +16 -0
  148. package/nitrogen/generated/shared/c++/CompletedSpanOptions.hpp +122 -0
  149. package/nitrogen/generated/shared/c++/HybridRecordingSpec.cpp +31 -0
  150. package/nitrogen/generated/shared/c++/HybridRecordingSpec.hpp +100 -0
  151. package/nitrogen/generated/shared/c++/HybridTraceSpanSpec.cpp +23 -0
  152. package/nitrogen/generated/shared/c++/HybridTraceSpanSpec.hpp +65 -0
  153. package/nitrogen/generated/shared/c++/HybridTracingSpec.cpp +22 -0
  154. package/nitrogen/generated/shared/c++/HybridTracingSpec.hpp +68 -0
  155. package/nitrogen/generated/shared/c++/MarkEvent.hpp +102 -0
  156. package/nitrogen/generated/shared/c++/MarkOptions.hpp +99 -0
  157. package/nitrogen/generated/shared/c++/MetricEvent.hpp +110 -0
  158. package/nitrogen/generated/shared/c++/MetricOptions.hpp +107 -0
  159. package/nitrogen/generated/shared/c++/NativeSamplingOptions.hpp +87 -0
  160. package/nitrogen/generated/shared/c++/ReadOptions.hpp +87 -0
  161. package/nitrogen/generated/shared/c++/RecordingOptions.hpp +95 -0
  162. package/nitrogen/generated/shared/c++/RecordingStats.hpp +123 -0
  163. package/nitrogen/generated/shared/c++/SpanEvent.hpp +121 -0
  164. package/nitrogen/generated/shared/c++/SpanOptions.hpp +99 -0
  165. package/nitrogen/generated/shared/c++/SpanOutcome.hpp +84 -0
  166. package/nitrogen/generated/shared/c++/TraceAttribute.hpp +87 -0
  167. package/nitrogen/generated/shared/c++/TracePage.hpp +111 -0
  168. package/package.json +236 -0
  169. package/performance.ts +2 -0
  170. package/plugins.ts +24 -0
  171. package/react-native.config.js +16 -0
  172. package/react.ts +10 -0
  173. package/release-profiler.ts +6 -0
  174. package/sentry.ts +2 -0
  175. package/src/client/TracingSink.ts +25 -0
  176. package/src/client/createTraceClient.ts +439 -0
  177. package/src/client/playground.ts +143 -0
  178. package/src/expo/ExpoAdapter.ts +71 -0
  179. package/src/expo/index.ts +2 -0
  180. package/src/index.ts +8 -0
  181. package/src/plugins/TracePlugin.ts +22 -0
  182. package/src/plugins/errors.ts +69 -0
  183. package/src/plugins/nativeMetrics.ts +26 -0
  184. package/src/plugins/navigation.ts +111 -0
  185. package/src/plugins/network.ts +178 -0
  186. package/src/plugins/orderSpans.ts +22 -0
  187. package/src/plugins/performance.ts +120 -0
  188. package/src/plugins/releaseProfiler.ts +123 -0
  189. package/src/plugins/runtimeMetrics.ts +131 -0
  190. package/src/plugins/sentry.ts +176 -0
  191. package/src/plugins/startPlugins.ts +58 -0
  192. package/src/react/DetailView.tsx +514 -0
  193. package/src/react/ExplorerFilters.tsx +151 -0
  194. package/src/react/ExplorerView.tsx +243 -0
  195. package/src/react/InspectorControls.tsx +651 -0
  196. package/src/react/InspectorHeader.tsx +171 -0
  197. package/src/react/InspectorSheet.tsx +89 -0
  198. package/src/react/MetricsView.tsx +182 -0
  199. package/src/react/SummaryView.tsx +121 -0
  200. package/src/react/TimelineView.tsx +87 -0
  201. package/src/react/TraceInspector.tsx +196 -0
  202. package/src/react/TraceOverlay.tsx +585 -0
  203. package/src/react/explorerModel.ts +285 -0
  204. package/src/react/labels.ts +234 -0
  205. package/src/react/native.tsx +159 -0
  206. package/src/react/readSnapshot.ts +58 -0
  207. package/src/react/store.ts +31 -0
  208. package/src/react/topics.ts +427 -0
  209. package/src/react/useAppReadyMetric.ts +10 -0
  210. package/src/react/useLiveRecording.ts +43 -0
  211. package/src/react/useTraceViewer.ts +333 -0
  212. package/src/react/viewerModel.ts +172 -0
  213. package/src/specs/Recording.nitro.ts +40 -0
  214. package/src/specs/TraceSpan.nitro.ts +14 -0
  215. package/src/specs/Tracing.nitro.ts +14 -0
  216. package/src/types/CompletedSpanOptions.ts +15 -0
  217. package/src/types/EventContext.ts +8 -0
  218. package/src/types/MarkEvent.ts +3 -0
  219. package/src/types/MarkOptions.ts +6 -0
  220. package/src/types/MetricEvent.ts +8 -0
  221. package/src/types/MetricOptions.ts +10 -0
  222. package/src/types/NativeSamplingOptions.ts +7 -0
  223. package/src/types/ReadOptions.ts +7 -0
  224. package/src/types/RecordingOptions.ts +11 -0
  225. package/src/types/RecordingStats.ts +25 -0
  226. package/src/types/SpanEvent.ts +13 -0
  227. package/src/types/SpanOptions.ts +6 -0
  228. package/src/types/SpanOutcome.ts +2 -0
  229. package/src/types/TraceAttribute.ts +7 -0
  230. package/src/types/TraceAttributes.ts +4 -0
  231. package/src/types/TraceContext.ts +10 -0
  232. package/src/types/TracePage.ts +18 -0
  233. package/src/types.ts +17 -0
@@ -0,0 +1,121 @@
1
+ ///
2
+ /// SpanEvent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `SpanOutcome` to properly resolve imports.
32
+ namespace margelo::nitro::nitrotracing { enum class SpanOutcome; }
33
+ // Forward declaration of `TraceAttribute` to properly resolve imports.
34
+ namespace margelo::nitro::nitrotracing { struct TraceAttribute; }
35
+
36
+ #include <string>
37
+ #include "SpanOutcome.hpp"
38
+ #include "TraceAttribute.hpp"
39
+ #include <vector>
40
+
41
+ namespace margelo::nitro::nitrotracing {
42
+
43
+ /**
44
+ * A struct which can be represented as a JavaScript object (SpanEvent).
45
+ */
46
+ struct SpanEvent final {
47
+ public:
48
+ std::string spanId SWIFT_PRIVATE;
49
+ std::string parentSpanId SWIFT_PRIVATE;
50
+ double durationMs SWIFT_PRIVATE;
51
+ SpanOutcome outcome SWIFT_PRIVATE;
52
+ double sequence SWIFT_PRIVATE;
53
+ double timestampMs SWIFT_PRIVATE;
54
+ std::string name SWIFT_PRIVATE;
55
+ std::string correlationId SWIFT_PRIVATE;
56
+ std::vector<TraceAttribute> attributes SWIFT_PRIVATE;
57
+
58
+ public:
59
+ SpanEvent() = default;
60
+ explicit SpanEvent(std::string spanId, std::string parentSpanId, double durationMs, SpanOutcome outcome, double sequence, double timestampMs, std::string name, std::string correlationId, std::vector<TraceAttribute> attributes): spanId(spanId), parentSpanId(parentSpanId), durationMs(durationMs), outcome(outcome), sequence(sequence), timestampMs(timestampMs), name(name), correlationId(correlationId), attributes(attributes) {}
61
+
62
+ public:
63
+ friend bool operator==(const SpanEvent& lhs, const SpanEvent& rhs) = default;
64
+ };
65
+
66
+ } // namespace margelo::nitro::nitrotracing
67
+
68
+ namespace margelo::nitro {
69
+
70
+ // C++ SpanEvent <> JS SpanEvent (object)
71
+ template <>
72
+ struct JSIConverter<margelo::nitro::nitrotracing::SpanEvent> final {
73
+ static inline margelo::nitro::nitrotracing::SpanEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
74
+ jsi::Object obj = arg.asObject(runtime);
75
+ return margelo::nitro::nitrotracing::SpanEvent(
76
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "spanId"))),
77
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentSpanId"))),
78
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs"))),
79
+ JSIConverter<margelo::nitro::nitrotracing::SpanOutcome>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome"))),
80
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sequence"))),
81
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestampMs"))),
82
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
83
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "correlationId"))),
84
+ JSIConverter<std::vector<margelo::nitro::nitrotracing::TraceAttribute>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "attributes")))
85
+ );
86
+ }
87
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrotracing::SpanEvent& arg) {
88
+ jsi::Object obj(runtime);
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "spanId"), JSIConverter<std::string>::toJSI(runtime, arg.spanId));
90
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "parentSpanId"), JSIConverter<std::string>::toJSI(runtime, arg.parentSpanId));
91
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "durationMs"), JSIConverter<double>::toJSI(runtime, arg.durationMs));
92
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "outcome"), JSIConverter<margelo::nitro::nitrotracing::SpanOutcome>::toJSI(runtime, arg.outcome));
93
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "sequence"), JSIConverter<double>::toJSI(runtime, arg.sequence));
94
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestampMs"), JSIConverter<double>::toJSI(runtime, arg.timestampMs));
95
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
96
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "correlationId"), JSIConverter<std::string>::toJSI(runtime, arg.correlationId));
97
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "attributes"), JSIConverter<std::vector<margelo::nitro::nitrotracing::TraceAttribute>>::toJSI(runtime, arg.attributes));
98
+ return obj;
99
+ }
100
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
101
+ if (!value.isObject()) {
102
+ return false;
103
+ }
104
+ jsi::Object obj = value.getObject(runtime);
105
+ if (!nitro::isPlainObject(runtime, obj)) {
106
+ return false;
107
+ }
108
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "spanId")))) return false;
109
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentSpanId")))) return false;
110
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))) return false;
111
+ if (!JSIConverter<margelo::nitro::nitrotracing::SpanOutcome>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome")))) return false;
112
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sequence")))) return false;
113
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestampMs")))) return false;
114
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
115
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "correlationId")))) return false;
116
+ if (!JSIConverter<std::vector<margelo::nitro::nitrotracing::TraceAttribute>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "attributes")))) return false;
117
+ return true;
118
+ }
119
+ };
120
+
121
+ } // namespace margelo::nitro
@@ -0,0 +1,99 @@
1
+ ///
2
+ /// SpanOptions.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `TraceAttribute` to properly resolve imports.
32
+ namespace margelo::nitro::nitrotracing { struct TraceAttribute; }
33
+
34
+ #include <string>
35
+ #include <optional>
36
+ #include "TraceAttribute.hpp"
37
+ #include <vector>
38
+
39
+ namespace margelo::nitro::nitrotracing {
40
+
41
+ /**
42
+ * A struct which can be represented as a JavaScript object (SpanOptions).
43
+ */
44
+ struct SpanOptions final {
45
+ public:
46
+ std::optional<std::string> parentSpanId SWIFT_PRIVATE;
47
+ std::string name SWIFT_PRIVATE;
48
+ std::string correlationId SWIFT_PRIVATE;
49
+ std::vector<TraceAttribute> attributes SWIFT_PRIVATE;
50
+
51
+ public:
52
+ SpanOptions() = default;
53
+ explicit SpanOptions(std::optional<std::string> parentSpanId, std::string name, std::string correlationId, std::vector<TraceAttribute> attributes): parentSpanId(parentSpanId), name(name), correlationId(correlationId), attributes(attributes) {}
54
+
55
+ public:
56
+ friend bool operator==(const SpanOptions& lhs, const SpanOptions& rhs) = default;
57
+ };
58
+
59
+ } // namespace margelo::nitro::nitrotracing
60
+
61
+ namespace margelo::nitro {
62
+
63
+ // C++ SpanOptions <> JS SpanOptions (object)
64
+ template <>
65
+ struct JSIConverter<margelo::nitro::nitrotracing::SpanOptions> final {
66
+ static inline margelo::nitro::nitrotracing::SpanOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
67
+ jsi::Object obj = arg.asObject(runtime);
68
+ return margelo::nitro::nitrotracing::SpanOptions(
69
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentSpanId"))),
70
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
71
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "correlationId"))),
72
+ JSIConverter<std::vector<margelo::nitro::nitrotracing::TraceAttribute>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "attributes")))
73
+ );
74
+ }
75
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrotracing::SpanOptions& arg) {
76
+ jsi::Object obj(runtime);
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "parentSpanId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.parentSpanId));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "correlationId"), JSIConverter<std::string>::toJSI(runtime, arg.correlationId));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "attributes"), JSIConverter<std::vector<margelo::nitro::nitrotracing::TraceAttribute>>::toJSI(runtime, arg.attributes));
81
+ return obj;
82
+ }
83
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
84
+ if (!value.isObject()) {
85
+ return false;
86
+ }
87
+ jsi::Object obj = value.getObject(runtime);
88
+ if (!nitro::isPlainObject(runtime, obj)) {
89
+ return false;
90
+ }
91
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentSpanId")))) return false;
92
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
93
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "correlationId")))) return false;
94
+ if (!JSIConverter<std::vector<margelo::nitro::nitrotracing::TraceAttribute>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "attributes")))) return false;
95
+ return true;
96
+ }
97
+ };
98
+
99
+ } // namespace margelo::nitro
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// SpanOutcome.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitrotracing {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (SpanOutcome).
30
+ */
31
+ enum class SpanOutcome {
32
+ SUCCESS SWIFT_NAME(success) = 0,
33
+ ERROR SWIFT_NAME(error) = 1,
34
+ CANCELLED SWIFT_NAME(cancelled) = 2,
35
+ INTERRUPTED SWIFT_NAME(interrupted) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::nitrotracing
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ SpanOutcome <> JS SpanOutcome (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::nitrotracing::SpanOutcome> final {
45
+ static inline margelo::nitro::nitrotracing::SpanOutcome fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
47
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
48
+ case hashString("success"): return margelo::nitro::nitrotracing::SpanOutcome::SUCCESS;
49
+ case hashString("error"): return margelo::nitro::nitrotracing::SpanOutcome::ERROR;
50
+ case hashString("cancelled"): return margelo::nitro::nitrotracing::SpanOutcome::CANCELLED;
51
+ case hashString("interrupted"): return margelo::nitro::nitrotracing::SpanOutcome::INTERRUPTED;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SpanOutcome - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrotracing::SpanOutcome arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::nitrotracing::SpanOutcome::SUCCESS: return JSIConverter<std::string>::toJSI(runtime, "success");
59
+ case margelo::nitro::nitrotracing::SpanOutcome::ERROR: return JSIConverter<std::string>::toJSI(runtime, "error");
60
+ case margelo::nitro::nitrotracing::SpanOutcome::CANCELLED: return JSIConverter<std::string>::toJSI(runtime, "cancelled");
61
+ case margelo::nitro::nitrotracing::SpanOutcome::INTERRUPTED: return JSIConverter<std::string>::toJSI(runtime, "interrupted");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert SpanOutcome to JS - invalid value: "
64
+ + std::to_string(static_cast<int>(arg)) + "!");
65
+ }
66
+ }
67
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
+ if (!value.isString()) {
69
+ return false;
70
+ }
71
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
72
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
73
+ case hashString("success"):
74
+ case hashString("error"):
75
+ case hashString("cancelled"):
76
+ case hashString("interrupted"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// TraceAttribute.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+
35
+ namespace margelo::nitro::nitrotracing {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (TraceAttribute).
39
+ */
40
+ struct TraceAttribute final {
41
+ public:
42
+ std::string key SWIFT_PRIVATE;
43
+ std::string value SWIFT_PRIVATE;
44
+
45
+ public:
46
+ TraceAttribute() = default;
47
+ explicit TraceAttribute(std::string key, std::string value): key(key), value(value) {}
48
+
49
+ public:
50
+ friend bool operator==(const TraceAttribute& lhs, const TraceAttribute& rhs) = default;
51
+ };
52
+
53
+ } // namespace margelo::nitro::nitrotracing
54
+
55
+ namespace margelo::nitro {
56
+
57
+ // C++ TraceAttribute <> JS TraceAttribute (object)
58
+ template <>
59
+ struct JSIConverter<margelo::nitro::nitrotracing::TraceAttribute> final {
60
+ static inline margelo::nitro::nitrotracing::TraceAttribute fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
61
+ jsi::Object obj = arg.asObject(runtime);
62
+ return margelo::nitro::nitrotracing::TraceAttribute(
63
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key"))),
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
65
+ );
66
+ }
67
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrotracing::TraceAttribute& arg) {
68
+ jsi::Object obj(runtime);
69
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "key"), JSIConverter<std::string>::toJSI(runtime, arg.key));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::string>::toJSI(runtime, arg.value));
71
+ return obj;
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isObject()) {
75
+ return false;
76
+ }
77
+ jsi::Object obj = value.getObject(runtime);
78
+ if (!nitro::isPlainObject(runtime, obj)) {
79
+ return false;
80
+ }
81
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key")))) return false;
82
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
83
+ return true;
84
+ }
85
+ };
86
+
87
+ } // namespace margelo::nitro
@@ -0,0 +1,111 @@
1
+ ///
2
+ /// TracePage.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `SpanEvent` to properly resolve imports.
32
+ namespace margelo::nitro::nitrotracing { struct SpanEvent; }
33
+ // Forward declaration of `MarkEvent` to properly resolve imports.
34
+ namespace margelo::nitro::nitrotracing { struct MarkEvent; }
35
+ // Forward declaration of `MetricEvent` to properly resolve imports.
36
+ namespace margelo::nitro::nitrotracing { struct MetricEvent; }
37
+
38
+ #include "SpanEvent.hpp"
39
+ #include <vector>
40
+ #include "MarkEvent.hpp"
41
+ #include "MetricEvent.hpp"
42
+
43
+ namespace margelo::nitro::nitrotracing {
44
+
45
+ /**
46
+ * A struct which can be represented as a JavaScript object (TracePage).
47
+ */
48
+ struct TracePage final {
49
+ public:
50
+ std::vector<SpanEvent> spans SWIFT_PRIVATE;
51
+ std::vector<MarkEvent> marks SWIFT_PRIVATE;
52
+ std::vector<MetricEvent> metrics SWIFT_PRIVATE;
53
+ double nextSequence SWIFT_PRIVATE;
54
+ double earliestSequence SWIFT_PRIVATE;
55
+ double droppedEvents SWIFT_PRIVATE;
56
+
57
+ public:
58
+ TracePage() = default;
59
+ explicit TracePage(std::vector<SpanEvent> spans, std::vector<MarkEvent> marks, std::vector<MetricEvent> metrics, double nextSequence, double earliestSequence, double droppedEvents): spans(spans), marks(marks), metrics(metrics), nextSequence(nextSequence), earliestSequence(earliestSequence), droppedEvents(droppedEvents) {}
60
+
61
+ public:
62
+ friend bool operator==(const TracePage& lhs, const TracePage& rhs) = default;
63
+ };
64
+
65
+ } // namespace margelo::nitro::nitrotracing
66
+
67
+ namespace margelo::nitro {
68
+
69
+ // C++ TracePage <> JS TracePage (object)
70
+ template <>
71
+ struct JSIConverter<margelo::nitro::nitrotracing::TracePage> final {
72
+ static inline margelo::nitro::nitrotracing::TracePage fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
73
+ jsi::Object obj = arg.asObject(runtime);
74
+ return margelo::nitro::nitrotracing::TracePage(
75
+ JSIConverter<std::vector<margelo::nitro::nitrotracing::SpanEvent>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "spans"))),
76
+ JSIConverter<std::vector<margelo::nitro::nitrotracing::MarkEvent>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "marks"))),
77
+ JSIConverter<std::vector<margelo::nitro::nitrotracing::MetricEvent>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metrics"))),
78
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "nextSequence"))),
79
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "earliestSequence"))),
80
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "droppedEvents")))
81
+ );
82
+ }
83
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrotracing::TracePage& arg) {
84
+ jsi::Object obj(runtime);
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "spans"), JSIConverter<std::vector<margelo::nitro::nitrotracing::SpanEvent>>::toJSI(runtime, arg.spans));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "marks"), JSIConverter<std::vector<margelo::nitro::nitrotracing::MarkEvent>>::toJSI(runtime, arg.marks));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "metrics"), JSIConverter<std::vector<margelo::nitro::nitrotracing::MetricEvent>>::toJSI(runtime, arg.metrics));
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "nextSequence"), JSIConverter<double>::toJSI(runtime, arg.nextSequence));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "earliestSequence"), JSIConverter<double>::toJSI(runtime, arg.earliestSequence));
90
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "droppedEvents"), JSIConverter<double>::toJSI(runtime, arg.droppedEvents));
91
+ return obj;
92
+ }
93
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
94
+ if (!value.isObject()) {
95
+ return false;
96
+ }
97
+ jsi::Object obj = value.getObject(runtime);
98
+ if (!nitro::isPlainObject(runtime, obj)) {
99
+ return false;
100
+ }
101
+ if (!JSIConverter<std::vector<margelo::nitro::nitrotracing::SpanEvent>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "spans")))) return false;
102
+ if (!JSIConverter<std::vector<margelo::nitro::nitrotracing::MarkEvent>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "marks")))) return false;
103
+ if (!JSIConverter<std::vector<margelo::nitro::nitrotracing::MetricEvent>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metrics")))) return false;
104
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "nextSequence")))) return false;
105
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "earliestSequence")))) return false;
106
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "droppedEvents")))) return false;
107
+ return true;
108
+ }
109
+ };
110
+
111
+ } // namespace margelo::nitro