react-native-cesium 1.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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +12 -0
  3. package/README.md +308 -0
  4. package/ReactNativeCesium.podspec +54 -0
  5. package/android/CMakeLists.txt +146 -0
  6. package/android/build.gradle +178 -0
  7. package/android/fix-prefab.gradle +51 -0
  8. package/android/gradle.properties +5 -0
  9. package/android/src/main/AndroidManifest.xml +5 -0
  10. package/android/src/main/assets/cacert.pem +3529 -0
  11. package/android/src/main/cpp/CesiumBridgeAndroid.cpp +487 -0
  12. package/android/src/main/cpp/CesiumBridgeAndroid.h +94 -0
  13. package/android/src/main/cpp/cpp-adapter.cpp +17 -0
  14. package/android/src/main/cpp/vulkan/VulkanBackend.cpp +1781 -0
  15. package/android/src/main/cpp/vulkan/VulkanBackend.h +190 -0
  16. package/android/src/main/cpp/vulkan/shaders/sky.frag +86 -0
  17. package/android/src/main/cpp/vulkan/shaders/sky.vert +9 -0
  18. package/android/src/main/cpp/vulkan/shaders/terrain.frag +144 -0
  19. package/android/src/main/cpp/vulkan/shaders/terrain.vert +25 -0
  20. package/android/src/main/java/com/margelo/nitro/reactnativecesium/CesiumBridgeJNI.kt +84 -0
  21. package/android/src/main/java/com/margelo/nitro/reactnativecesium/HybridCesiumView.kt +225 -0
  22. package/android/src/main/java/com/reactnativecesium/ReactNativeCesiumPackage.kt +28 -0
  23. package/cpp/engine/CesiumEngine.cpp +413 -0
  24. package/cpp/engine/CesiumEngine.hpp +90 -0
  25. package/cpp/engine/DeletionQueue.cpp +28 -0
  26. package/cpp/engine/DeletionQueue.hpp +28 -0
  27. package/cpp/engine/GlobeCamera.cpp +181 -0
  28. package/cpp/engine/GlobeCamera.hpp +64 -0
  29. package/cpp/engine/GltfToMesh.cpp +154 -0
  30. package/cpp/engine/GltfToMesh.hpp +20 -0
  31. package/cpp/engine/ResourcePreparer.cpp +224 -0
  32. package/cpp/engine/ResourcePreparer.hpp +96 -0
  33. package/cpp/engine/TaskProcessor.cpp +61 -0
  34. package/cpp/engine/TaskProcessor.hpp +43 -0
  35. package/cpp/engine/TileLifecycleManager.cpp +30 -0
  36. package/cpp/engine/TileLifecycleManager.hpp +25 -0
  37. package/cpp/fmt/format.h +9 -0
  38. package/cpp/renderer/IGPUBackend.hpp +22 -0
  39. package/cpp/renderer/RenderTypes.hpp +112 -0
  40. package/cpp/renderer/ShaderTypes.hpp +29 -0
  41. package/example/README.md +43 -0
  42. package/example/react-native-cesium-example.jpg +0 -0
  43. package/ios/CesiumBridge.h +55 -0
  44. package/ios/CesiumBridge.mm +393 -0
  45. package/ios/HybridCesiumView.swift +299 -0
  46. package/ios/ReactNativeCesium-umbrella.h +16 -0
  47. package/ios/metal/MetalBackend.h +82 -0
  48. package/ios/metal/MetalBackend.mm +839 -0
  49. package/ios/react_native_cesium_ensure_native.rb +12 -0
  50. package/ios/react_native_cesium_post_install.rb +30 -0
  51. package/lib/commonjs/CesiumView.js +13 -0
  52. package/lib/commonjs/CesiumView.js.map +1 -0
  53. package/lib/commonjs/index.js +13 -0
  54. package/lib/commonjs/index.js.map +1 -0
  55. package/lib/commonjs/package.json +1 -0
  56. package/lib/commonjs/specs/cesium-view.nitro.js +6 -0
  57. package/lib/commonjs/specs/cesium-view.nitro.js.map +1 -0
  58. package/lib/module/CesiumView.js +9 -0
  59. package/lib/module/CesiumView.js.map +1 -0
  60. package/lib/module/index.js +4 -0
  61. package/lib/module/index.js.map +1 -0
  62. package/lib/module/specs/cesium-view.nitro.js +4 -0
  63. package/lib/module/specs/cesium-view.nitro.js.map +1 -0
  64. package/lib/typescript/src/CesiumView.d.ts +5 -0
  65. package/lib/typescript/src/CesiumView.d.ts.map +1 -0
  66. package/lib/typescript/src/index.d.ts +3 -0
  67. package/lib/typescript/src/index.d.ts.map +1 -0
  68. package/lib/typescript/src/specs/cesium-view.nitro.d.ts +43 -0
  69. package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -0
  70. package/nitro.json +30 -0
  71. package/nitrogen/generated/.gitattributes +1 -0
  72. package/nitrogen/generated/android/ReactNativeCesium+autolinking.cmake +83 -0
  73. package/nitrogen/generated/android/ReactNativeCesium+autolinking.gradle +27 -0
  74. package/nitrogen/generated/android/ReactNativeCesiumOnLoad.cpp +58 -0
  75. package/nitrogen/generated/android/ReactNativeCesiumOnLoad.hpp +34 -0
  76. package/nitrogen/generated/android/c++/JCameraState.hpp +81 -0
  77. package/nitrogen/generated/android/c++/JCesiumMetrics.hpp +81 -0
  78. package/nitrogen/generated/android/c++/JFunc_void_CesiumMetrics.hpp +78 -0
  79. package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.cpp +178 -0
  80. package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.hpp +83 -0
  81. package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.cpp +92 -0
  82. package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.hpp +49 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CameraState.kt +56 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CesiumMetrics.kt +56 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CesiumMetrics.kt +80 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/HybridCesiumViewSpec.kt +126 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/ReactNativeCesiumOnLoad.kt +35 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewManager.kt +80 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewStateUpdater.kt +23 -0
  90. package/nitrogen/generated/ios/ReactNativeCesium+autolinking.rb +60 -0
  91. package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.cpp +57 -0
  92. package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.hpp +164 -0
  93. package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Umbrella.hpp +53 -0
  94. package/nitrogen/generated/ios/ReactNativeCesiumAutolinking.mm +33 -0
  95. package/nitrogen/generated/ios/ReactNativeCesiumAutolinking.swift +26 -0
  96. package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.cpp +11 -0
  97. package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.hpp +157 -0
  98. package/nitrogen/generated/ios/c++/views/HybridCesiumViewComponent.mm +167 -0
  99. package/nitrogen/generated/ios/swift/CameraState.swift +59 -0
  100. package/nitrogen/generated/ios/swift/CesiumMetrics.swift +59 -0
  101. package/nitrogen/generated/ios/swift/Func_void_CameraState.swift +46 -0
  102. package/nitrogen/generated/ios/swift/Func_void_CesiumMetrics.swift +46 -0
  103. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  104. package/nitrogen/generated/ios/swift/HybridCesiumViewSpec.swift +65 -0
  105. package/nitrogen/generated/ios/swift/HybridCesiumViewSpec_cxx.swift +306 -0
  106. package/nitrogen/generated/shared/c++/CameraState.hpp +107 -0
  107. package/nitrogen/generated/shared/c++/CesiumMetrics.hpp +107 -0
  108. package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.cpp +42 -0
  109. package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.hpp +90 -0
  110. package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.cpp +182 -0
  111. package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.hpp +122 -0
  112. package/nitrogen/generated/shared/json/CesiumViewConfig.json +19 -0
  113. package/package.json +140 -0
  114. package/react-native.config.js +16 -0
  115. package/scripts/cesium/build.mjs +901 -0
  116. package/scripts/cesium/clean.mjs +35 -0
  117. package/scripts/cesium/clone.mjs +32 -0
  118. package/scripts/cesium/ensure-native.mjs +116 -0
  119. package/scripts/cesium/vcpkg-ports/zstd/fix-emscripten-and-clang-cl.patch +31 -0
  120. package/scripts/cesium/vcpkg-ports/zstd/fix-windows-rc-compile.patch +13 -0
  121. package/scripts/cesium/vcpkg-ports/zstd/no-static-suffix.patch +13 -0
  122. package/scripts/cesium/vcpkg-ports/zstd/portfile.cmake +77 -0
  123. package/scripts/cesium/vcpkg-ports/zstd/usage +4 -0
  124. package/scripts/cesium/vcpkg-ports/zstd/vcpkg.json +23 -0
  125. package/scripts/cesium/vcpkg-triplets/arm64-ios-simulator.cmake +10 -0
  126. package/scripts/cesium/vcpkg-triplets/arm64-ios.cmake +14 -0
  127. package/src/CesiumView.tsx +13 -0
  128. package/src/index.ts +7 -0
  129. package/src/specs/cesium-view.nitro.ts +51 -0
@@ -0,0 +1,182 @@
1
+ ///
2
+ /// HybridCesiumViewComponent.cpp
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
+ #include "HybridCesiumViewComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <NitroModules/PropNameIDCache.hpp>
16
+ #include <react/renderer/core/RawValue.h>
17
+ #include <react/renderer/core/ShadowNode.h>
18
+ #include <react/renderer/core/ComponentDescriptor.h>
19
+ #include <react/renderer/components/view/ViewProps.h>
20
+
21
+ namespace margelo::nitro::reactnativecesium::views {
22
+
23
+ extern const char HybridCesiumViewComponentName[] = "CesiumView";
24
+
25
+ HybridCesiumViewProps::HybridCesiumViewProps(const react::PropsParserContext& context,
26
+ const HybridCesiumViewProps& sourceProps,
27
+ const react::RawProps& rawProps):
28
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
+ ionAccessToken([&]() -> CachedProp<std::string> {
30
+ try {
31
+ const react::RawValue* rawValue = rawProps.at("ionAccessToken", nullptr, nullptr);
32
+ if (rawValue == nullptr) return sourceProps.ionAccessToken;
33
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
+ return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.ionAccessToken);
35
+ } catch (const std::exception& exc) {
36
+ throw std::runtime_error(std::string("CesiumView.ionAccessToken: ") + exc.what());
37
+ }
38
+ }()),
39
+ ionAssetId([&]() -> CachedProp<double> {
40
+ try {
41
+ const react::RawValue* rawValue = rawProps.at("ionAssetId", nullptr, nullptr);
42
+ if (rawValue == nullptr) return sourceProps.ionAssetId;
43
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.ionAssetId);
45
+ } catch (const std::exception& exc) {
46
+ throw std::runtime_error(std::string("CesiumView.ionAssetId: ") + exc.what());
47
+ }
48
+ }()),
49
+ initialCamera([&]() -> CachedProp<CameraState> {
50
+ try {
51
+ const react::RawValue* rawValue = rawProps.at("initialCamera", nullptr, nullptr);
52
+ if (rawValue == nullptr) return sourceProps.initialCamera;
53
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
+ return CachedProp<CameraState>::fromRawValue(*runtime, value, sourceProps.initialCamera);
55
+ } catch (const std::exception& exc) {
56
+ throw std::runtime_error(std::string("CesiumView.initialCamera: ") + exc.what());
57
+ }
58
+ }()),
59
+ pauseRendering([&]() -> CachedProp<bool> {
60
+ try {
61
+ const react::RawValue* rawValue = rawProps.at("pauseRendering", nullptr, nullptr);
62
+ if (rawValue == nullptr) return sourceProps.pauseRendering;
63
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
+ return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.pauseRendering);
65
+ } catch (const std::exception& exc) {
66
+ throw std::runtime_error(std::string("CesiumView.pauseRendering: ") + exc.what());
67
+ }
68
+ }()),
69
+ maximumScreenSpaceError([&]() -> CachedProp<double> {
70
+ try {
71
+ const react::RawValue* rawValue = rawProps.at("maximumScreenSpaceError", nullptr, nullptr);
72
+ if (rawValue == nullptr) return sourceProps.maximumScreenSpaceError;
73
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.maximumScreenSpaceError);
75
+ } catch (const std::exception& exc) {
76
+ throw std::runtime_error(std::string("CesiumView.maximumScreenSpaceError: ") + exc.what());
77
+ }
78
+ }()),
79
+ maximumSimultaneousTileLoads([&]() -> CachedProp<double> {
80
+ try {
81
+ const react::RawValue* rawValue = rawProps.at("maximumSimultaneousTileLoads", nullptr, nullptr);
82
+ if (rawValue == nullptr) return sourceProps.maximumSimultaneousTileLoads;
83
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.maximumSimultaneousTileLoads);
85
+ } catch (const std::exception& exc) {
86
+ throw std::runtime_error(std::string("CesiumView.maximumSimultaneousTileLoads: ") + exc.what());
87
+ }
88
+ }()),
89
+ loadingDescendantLimit([&]() -> CachedProp<double> {
90
+ try {
91
+ const react::RawValue* rawValue = rawProps.at("loadingDescendantLimit", nullptr, nullptr);
92
+ if (rawValue == nullptr) return sourceProps.loadingDescendantLimit;
93
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.loadingDescendantLimit);
95
+ } catch (const std::exception& exc) {
96
+ throw std::runtime_error(std::string("CesiumView.loadingDescendantLimit: ") + exc.what());
97
+ }
98
+ }()),
99
+ msaaSampleCount([&]() -> CachedProp<double> {
100
+ try {
101
+ const react::RawValue* rawValue = rawProps.at("msaaSampleCount", nullptr, nullptr);
102
+ if (rawValue == nullptr) return sourceProps.msaaSampleCount;
103
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.msaaSampleCount);
105
+ } catch (const std::exception& exc) {
106
+ throw std::runtime_error(std::string("CesiumView.msaaSampleCount: ") + exc.what());
107
+ }
108
+ }()),
109
+ ionImageryAssetId([&]() -> CachedProp<double> {
110
+ try {
111
+ const react::RawValue* rawValue = rawProps.at("ionImageryAssetId", nullptr, nullptr);
112
+ if (rawValue == nullptr) return sourceProps.ionImageryAssetId;
113
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.ionImageryAssetId);
115
+ } catch (const std::exception& exc) {
116
+ throw std::runtime_error(std::string("CesiumView.ionImageryAssetId: ") + exc.what());
117
+ }
118
+ }()),
119
+ onMetrics([&]() -> CachedProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>> {
120
+ try {
121
+ const react::RawValue* rawValue = rawProps.at("onMetrics", nullptr, nullptr);
122
+ if (rawValue == nullptr) return sourceProps.onMetrics;
123
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
124
+ return CachedProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onMetrics);
125
+ } catch (const std::exception& exc) {
126
+ throw std::runtime_error(std::string("CesiumView.onMetrics: ") + exc.what());
127
+ }
128
+ }()),
129
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>> {
130
+ try {
131
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
132
+ if (rawValue == nullptr) return sourceProps.hybridRef;
133
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
134
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
135
+ } catch (const std::exception& exc) {
136
+ throw std::runtime_error(std::string("CesiumView.hybridRef: ") + exc.what());
137
+ }
138
+ }()) { }
139
+
140
+ bool HybridCesiumViewProps::filterObjectKeys(const std::string& propName) {
141
+ switch (hashString(propName)) {
142
+ case hashString("ionAccessToken"): return true;
143
+ case hashString("ionAssetId"): return true;
144
+ case hashString("initialCamera"): return true;
145
+ case hashString("pauseRendering"): return true;
146
+ case hashString("maximumScreenSpaceError"): return true;
147
+ case hashString("maximumSimultaneousTileLoads"): return true;
148
+ case hashString("loadingDescendantLimit"): return true;
149
+ case hashString("msaaSampleCount"): return true;
150
+ case hashString("ionImageryAssetId"): return true;
151
+ case hashString("onMetrics"): return true;
152
+ case hashString("hybridRef"): return true;
153
+ default: return false;
154
+ }
155
+ }
156
+
157
+ HybridCesiumViewComponentDescriptor::HybridCesiumViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
158
+ : ConcreteComponentDescriptor(parameters,
159
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
160
+
161
+ std::shared_ptr<const react::Props> HybridCesiumViewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
162
+ const std::shared_ptr<const react::Props>& props,
163
+ react::RawProps rawProps) const {
164
+ // 1. Prepare raw props parser
165
+ rawProps.parse(rawPropsParser_);
166
+ // 2. Copy props with Nitro's cached copy constructor
167
+ return HybridCesiumViewShadowNode::Props(context, /* & */ rawProps, props);
168
+ }
169
+
170
+ #ifdef ANDROID
171
+ void HybridCesiumViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
172
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
173
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
174
+ auto& concreteShadowNode = static_cast<HybridCesiumViewShadowNode&>(shadowNode);
175
+ const std::shared_ptr<const HybridCesiumViewProps>& constProps = concreteShadowNode.getConcreteSharedProps();
176
+ const std::shared_ptr<HybridCesiumViewProps>& props = std::const_pointer_cast<HybridCesiumViewProps>(constProps);
177
+ HybridCesiumViewState state{props};
178
+ concreteShadowNode.setStateData(std::move(state));
179
+ }
180
+ #endif
181
+
182
+ } // namespace margelo::nitro::reactnativecesium::views
@@ -0,0 +1,122 @@
1
+ ///
2
+ /// HybridCesiumViewComponent.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
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include <string>
20
+ #include "CameraState.hpp"
21
+ #include "CesiumMetrics.hpp"
22
+ #include <functional>
23
+ #include <optional>
24
+ #include <memory>
25
+ #include "HybridCesiumViewSpec.hpp"
26
+
27
+ namespace margelo::nitro::reactnativecesium::views {
28
+
29
+ using namespace facebook;
30
+
31
+ /**
32
+ * The name of the actual native View.
33
+ */
34
+ extern const char HybridCesiumViewComponentName[];
35
+
36
+ /**
37
+ * Props for the "CesiumView" View.
38
+ */
39
+ class HybridCesiumViewProps final: public react::ViewProps {
40
+ public:
41
+ HybridCesiumViewProps() = default;
42
+ HybridCesiumViewProps(const react::PropsParserContext& context,
43
+ const HybridCesiumViewProps& sourceProps,
44
+ const react::RawProps& rawProps);
45
+
46
+ public:
47
+ CachedProp<std::string> ionAccessToken;
48
+ CachedProp<double> ionAssetId;
49
+ CachedProp<CameraState> initialCamera;
50
+ CachedProp<bool> pauseRendering;
51
+ CachedProp<double> maximumScreenSpaceError;
52
+ CachedProp<double> maximumSimultaneousTileLoads;
53
+ CachedProp<double> loadingDescendantLimit;
54
+ CachedProp<double> msaaSampleCount;
55
+ CachedProp<double> ionImageryAssetId;
56
+ CachedProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>> onMetrics;
57
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>> hybridRef;
58
+
59
+ private:
60
+ static bool filterObjectKeys(const std::string& propName);
61
+ };
62
+
63
+ /**
64
+ * State for the "CesiumView" View.
65
+ */
66
+ class HybridCesiumViewState final {
67
+ public:
68
+ HybridCesiumViewState() = default;
69
+ explicit HybridCesiumViewState(const std::shared_ptr<HybridCesiumViewProps>& props):
70
+ _props(props) {}
71
+
72
+ public:
73
+ [[nodiscard]]
74
+ const std::shared_ptr<HybridCesiumViewProps>& getProps() const {
75
+ return _props;
76
+ }
77
+
78
+ public:
79
+ #ifdef ANDROID
80
+ HybridCesiumViewState(const HybridCesiumViewState& /* previousState */, folly::dynamic /* data */) {}
81
+ folly::dynamic getDynamic() const {
82
+ throw std::runtime_error("HybridCesiumViewState does not support folly!");
83
+ }
84
+ react::MapBuffer getMapBuffer() const {
85
+ throw std::runtime_error("HybridCesiumViewState does not support MapBuffer!");
86
+ };
87
+ #endif
88
+
89
+ private:
90
+ std::shared_ptr<HybridCesiumViewProps> _props;
91
+ };
92
+
93
+ /**
94
+ * The Shadow Node for the "CesiumView" View.
95
+ */
96
+ using HybridCesiumViewShadowNode = react::ConcreteViewShadowNode<HybridCesiumViewComponentName /* "HybridCesiumView" */,
97
+ HybridCesiumViewProps /* custom props */,
98
+ react::ViewEventEmitter /* default */,
99
+ HybridCesiumViewState /* custom state */>;
100
+
101
+ /**
102
+ * The Component Descriptor for the "CesiumView" View.
103
+ */
104
+ class HybridCesiumViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridCesiumViewShadowNode> {
105
+ public:
106
+ explicit HybridCesiumViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
107
+
108
+ public:
109
+ /**
110
+ * A faster path for cloning props - reuses the caching logic from `HybridCesiumViewProps`.
111
+ */
112
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
113
+ const std::shared_ptr<const react::Props>& props,
114
+ react::RawProps rawProps) const override;
115
+ #ifdef ANDROID
116
+ void adopt(react::ShadowNode& shadowNode) const override;
117
+ #endif
118
+ };
119
+
120
+ /* The actual view for "CesiumView" needs to be implemented in platform-specific code. */
121
+
122
+ } // namespace margelo::nitro::reactnativecesium::views
@@ -0,0 +1,19 @@
1
+ {
2
+ "uiViewClassName": "CesiumView",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "ionAccessToken": true,
8
+ "ionAssetId": true,
9
+ "initialCamera": true,
10
+ "pauseRendering": true,
11
+ "maximumScreenSpaceError": true,
12
+ "maximumSimultaneousTileLoads": true,
13
+ "loadingDescendantLimit": true,
14
+ "msaaSampleCount": true,
15
+ "ionImageryAssetId": true,
16
+ "onMetrics": true,
17
+ "hybridRef": true
18
+ }
19
+ }
package/package.json ADDED
@@ -0,0 +1,140 @@
1
+ {
2
+ "name": "react-native-cesium",
3
+ "version": "1.0.1",
4
+ "description": "Experimental Cesium rendering for React Native via Nitro (iOS/Metal today; Android planned)",
5
+ "main": "./lib/commonjs/index.js",
6
+ "module": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
+ "react-native": "./src/index.ts",
9
+ "source": "src/index",
10
+ "scripts": {
11
+ "typecheck": "tsc --noEmit",
12
+ "clean": "node scripts/cesium/clean.mjs",
13
+ "release": "semantic-release --no-ci --repository-url \"git@github.com:dpyeates/react-native-cesium.git\"",
14
+ "release:dry": "semantic-release --dry-run --no-ci --repository-url \"git@github.com:dpyeates/react-native-cesium.git\"",
15
+ "build": "node scripts/cesium/build.mjs",
16
+ "build:js": "npm run typecheck && bob build",
17
+ "update": "node scripts/cesium/clone.mjs",
18
+ "ensure-native": "node scripts/cesium/ensure-native.mjs",
19
+ "cesium:update": "npm run update",
20
+ "codegen": "nitrogen --logLevel=\"debug\" && npm run build:js && node post-script.js",
21
+ "prepublishOnly": "npm run build:js"
22
+ },
23
+ "keywords": [
24
+ "react-native",
25
+ "react-native-cesium",
26
+ "nitro-modules",
27
+ "cesium",
28
+ "metal",
29
+ "vulkan"
30
+ ],
31
+ "files": [
32
+ "src",
33
+ "react-native.config.js",
34
+ "lib",
35
+ "LICENSE",
36
+ "NOTICE",
37
+ "nitrogen",
38
+ "scripts/cesium",
39
+ "cpp",
40
+ "nitro.json",
41
+ "android/build.gradle",
42
+ "android/fix-prefab.gradle",
43
+ "android/gradle.properties",
44
+ "android/CMakeLists.txt",
45
+ "android/src",
46
+ "example/react-native-cesium-example.jpg",
47
+ "ios/**/*.h",
48
+ "ios/**/*.m",
49
+ "ios/**/*.mm",
50
+ "ios/**/*.cpp",
51
+ "ios/**/*.rb",
52
+ "ios/**/*.swift",
53
+ "*.podspec",
54
+ "README.md"
55
+ ],
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "https://github.com/dpyeates/react-native-cesium.git"
59
+ },
60
+ "author": "Darren Yeates",
61
+ "license": "MIT",
62
+ "bugs": "https://github.com/dpyeates/react-native-cesium/issues",
63
+ "homepage": "https://github.com/dpyeates/react-native-cesium#readme",
64
+ "engines": {
65
+ "node": ">=18"
66
+ },
67
+ "dependencies": {
68
+ "react-native-nitro-modules": "^0.35.4"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public",
72
+ "registry": "https://registry.npmjs.org/"
73
+ },
74
+ "devDependencies": {
75
+ "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
76
+ "@semantic-release/changelog": "^6.0.3",
77
+ "@semantic-release/git": "^10.0.1",
78
+ "@types/jest": "^29.5.14",
79
+ "@types/react": "19.2.14",
80
+ "conventional-changelog-conventionalcommits": "^9.3.1",
81
+ "nitrogen": "0.35.4",
82
+ "react": "19.2.3",
83
+ "react-native": "0.85.1",
84
+ "react-native-builder-bob": "^0.41.0",
85
+ "semantic-release": "^25.0.3",
86
+ "typescript": "^5.9.3"
87
+ },
88
+ "peerDependencies": {
89
+ "react": ">=18.0.0",
90
+ "react-native": ">=0.76.0"
91
+ },
92
+ "eslintConfig": {
93
+ "root": true,
94
+ "extends": [
95
+ "@react-native",
96
+ "prettier"
97
+ ],
98
+ "plugins": [
99
+ "prettier"
100
+ ],
101
+ "rules": {
102
+ "prettier/prettier": [
103
+ "warn",
104
+ {
105
+ "quoteProps": "consistent",
106
+ "singleQuote": true,
107
+ "tabWidth": 2,
108
+ "trailingComma": "es5",
109
+ "useTabs": false
110
+ }
111
+ ]
112
+ }
113
+ },
114
+ "eslintIgnore": [
115
+ "node_modules/",
116
+ "lib/"
117
+ ],
118
+ "prettier": {
119
+ "quoteProps": "consistent",
120
+ "singleQuote": true,
121
+ "tabWidth": 2,
122
+ "trailingComma": "es5",
123
+ "useTabs": false,
124
+ "semi": false
125
+ },
126
+ "react-native-builder-bob": {
127
+ "source": "src",
128
+ "output": "lib",
129
+ "targets": [
130
+ "commonjs",
131
+ "module",
132
+ [
133
+ "typescript",
134
+ {
135
+ "project": "tsconfig.json"
136
+ }
137
+ ]
138
+ ]
139
+ }
140
+ }
@@ -0,0 +1,16 @@
1
+ // https://github.com/react-native-community/cli/blob/main/docs/dependencies.md
2
+
3
+ module.exports = {
4
+ dependency: {
5
+ platforms: {
6
+ /**
7
+ * @type {import('@react-native-community/cli-types').IOSDependencyParams}
8
+ */
9
+ ios: {},
10
+ /**
11
+ * @type {import('@react-native-community/cli-types').AndroidDependencyParams}
12
+ */
13
+ android: {},
14
+ },
15
+ },
16
+ }