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,126 @@
1
+ ///
2
+ /// HybridCesiumViewSpec.kt
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
+ package com.margelo.nitro.reactnativecesium
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.Promise
14
+ import com.margelo.nitro.core.HybridObject
15
+ import com.margelo.nitro.views.HybridView
16
+
17
+ /**
18
+ * A Kotlin class representing the CesiumView HybridObject.
19
+ * Implement this abstract class to create Kotlin-based instances of CesiumView.
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress(
24
+ "KotlinJniMissingFunction", "unused",
25
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
26
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
27
+ )
28
+ abstract class HybridCesiumViewSpec: HybridView() {
29
+ // Properties
30
+ @get:DoNotStrip
31
+ @get:Keep
32
+ @set:DoNotStrip
33
+ @set:Keep
34
+ abstract var ionAccessToken: String
35
+
36
+ @get:DoNotStrip
37
+ @get:Keep
38
+ @set:DoNotStrip
39
+ @set:Keep
40
+ abstract var ionAssetId: Double
41
+
42
+ @get:DoNotStrip
43
+ @get:Keep
44
+ @set:DoNotStrip
45
+ @set:Keep
46
+ abstract var initialCamera: CameraState
47
+
48
+ @get:DoNotStrip
49
+ @get:Keep
50
+ @set:DoNotStrip
51
+ @set:Keep
52
+ abstract var pauseRendering: Boolean
53
+
54
+ @get:DoNotStrip
55
+ @get:Keep
56
+ @set:DoNotStrip
57
+ @set:Keep
58
+ abstract var maximumScreenSpaceError: Double
59
+
60
+ @get:DoNotStrip
61
+ @get:Keep
62
+ @set:DoNotStrip
63
+ @set:Keep
64
+ abstract var maximumSimultaneousTileLoads: Double
65
+
66
+ @get:DoNotStrip
67
+ @get:Keep
68
+ @set:DoNotStrip
69
+ @set:Keep
70
+ abstract var loadingDescendantLimit: Double
71
+
72
+ @get:DoNotStrip
73
+ @get:Keep
74
+ @set:DoNotStrip
75
+ @set:Keep
76
+ abstract var msaaSampleCount: Double
77
+
78
+ @get:DoNotStrip
79
+ @get:Keep
80
+ @set:DoNotStrip
81
+ @set:Keep
82
+ abstract var ionImageryAssetId: Double
83
+
84
+ abstract var onMetrics: ((metrics: CesiumMetrics) -> Unit)?
85
+
86
+ private var onMetrics_cxx: Func_void_CesiumMetrics?
87
+ @Keep
88
+ @DoNotStrip
89
+ get() {
90
+ return onMetrics?.let { Func_void_CesiumMetrics_java(it) }
91
+ }
92
+ @Keep
93
+ @DoNotStrip
94
+ set(value) {
95
+ onMetrics = value?.let { it }
96
+ }
97
+
98
+ // Methods
99
+ @DoNotStrip
100
+ @Keep
101
+ abstract fun getCameraState(): Promise<CameraState>
102
+
103
+ @DoNotStrip
104
+ @Keep
105
+ abstract fun setCamera(camera: CameraState): Unit
106
+
107
+ // Default implementation of `HybridObject.toString()`
108
+ override fun toString(): String {
109
+ return "[HybridObject CesiumView]"
110
+ }
111
+
112
+ // C++ backing class
113
+ @DoNotStrip
114
+ @Keep
115
+ protected open class CxxPart(javaPart: HybridCesiumViewSpec): HybridObject.CxxPart(javaPart) {
116
+ // C++ JHybridCesiumViewSpec::CxxPart::initHybrid(...)
117
+ external override fun initHybrid(): HybridData
118
+ }
119
+ override fun createCxxPart(): CxxPart {
120
+ return CxxPart(this)
121
+ }
122
+
123
+ companion object {
124
+ protected const val TAG = "HybridCesiumViewSpec"
125
+ }
126
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// ReactNativeCesiumOnLoad.kt
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
+ package com.margelo.nitro.reactnativecesium
9
+
10
+ import android.util.Log
11
+
12
+ internal class ReactNativeCesiumOnLoad {
13
+ companion object {
14
+ private const val TAG = "ReactNativeCesiumOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "ReactNativeCesium".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading ReactNativeCesium C++ library...")
25
+ System.loadLibrary("ReactNativeCesium")
26
+ Log.i(TAG, "Successfully loaded ReactNativeCesium C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load ReactNativeCesium C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// HybridCesiumViewManager.kt
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
+ package com.margelo.nitro.reactnativecesium.views
9
+
10
+ import android.view.View
11
+ import com.facebook.react.uimanager.ReactStylesDiffMap
12
+ import com.facebook.react.uimanager.SimpleViewManager
13
+ import com.facebook.react.uimanager.StateWrapper
14
+ import com.facebook.react.uimanager.ThemedReactContext
15
+ import com.margelo.nitro.R.id.associated_hybrid_view_tag
16
+ import com.margelo.nitro.views.RecyclableView
17
+ import com.margelo.nitro.reactnativecesium.*
18
+
19
+ /**
20
+ * Represents the React Native `ViewManager` for the "CesiumView" Nitro HybridView.
21
+ */
22
+ public class HybridCesiumViewManager: SimpleViewManager<View>() {
23
+ init {
24
+ if (RecyclableView::class.java.isAssignableFrom(HybridCesiumView::class.java)) {
25
+ // Enable view recycling
26
+ super.setupViewRecycling()
27
+ }
28
+ }
29
+
30
+ override fun getName(): String {
31
+ return "CesiumView"
32
+ }
33
+
34
+ override fun createViewInstance(reactContext: ThemedReactContext): View {
35
+ val hybridView = HybridCesiumView(reactContext)
36
+ val view = hybridView.view
37
+ view.setTag(associated_hybrid_view_tag, hybridView)
38
+ return view
39
+ }
40
+
41
+ override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
42
+ val hybridView = getHybridView(view)
43
+ ?: throw Error("Couldn't find view $view in local views table!")
44
+
45
+ // 1. Update each prop individually
46
+ hybridView.beforeUpdate()
47
+ HybridCesiumViewStateUpdater.updateViewProps(hybridView, stateWrapper)
48
+ hybridView.afterUpdate()
49
+
50
+ // 2. Continue in base View props
51
+ return super.updateState(view, props, stateWrapper)
52
+ }
53
+
54
+ override fun onDropViewInstance(view: View) {
55
+ val hybridView = getHybridView(view)
56
+ hybridView?.onDropView()
57
+ return super.onDropViewInstance(view)
58
+ }
59
+
60
+ protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
61
+ super.prepareToRecycleView(reactContext, view)
62
+ val hybridView = getHybridView(view)
63
+ ?: return null
64
+
65
+ @Suppress("USELESS_IS_CHECK")
66
+ if (hybridView is RecyclableView) {
67
+ // Recycle in it's implementation
68
+ hybridView.prepareForRecycle()
69
+
70
+ // Maybe update the view if it changed
71
+ return hybridView.view
72
+ } else {
73
+ return null
74
+ }
75
+ }
76
+
77
+ private fun getHybridView(view: View): HybridCesiumView? {
78
+ return view.getTag(associated_hybrid_view_tag) as? HybridCesiumView
79
+ }
80
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// HybridCesiumViewStateUpdater.kt
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
+ package com.margelo.nitro.reactnativecesium.views
9
+
10
+ import com.facebook.react.uimanager.StateWrapper
11
+ import com.margelo.nitro.reactnativecesium.*
12
+
13
+ internal class HybridCesiumViewStateUpdater {
14
+ companion object {
15
+ /**
16
+ * Updates the props for [view] through C++.
17
+ * The [state] prop is expected to contain [view]'s props as wrapped Fabric state.
18
+ */
19
+ @Suppress("KotlinJniMissingFunction")
20
+ @JvmStatic
21
+ external fun updateViewProps(view: HybridCesiumViewSpec, state: StateWrapper)
22
+ }
23
+ }
@@ -0,0 +1,60 @@
1
+ #
2
+ # ReactNativeCesium+autolinking.rb
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
+ # This is a Ruby script that adds all files generated by Nitrogen
9
+ # to the given podspec.
10
+ #
11
+ # To use it, add this to your .podspec:
12
+ # ```ruby
13
+ # Pod::Spec.new do |spec|
14
+ # # ...
15
+ #
16
+ # # Add all files generated by Nitrogen
17
+ # load 'nitrogen/generated/ios/ReactNativeCesium+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 ReactNativeCesium is boosted by nitro!"
24
+
25
+ spec.dependency "NitroModules"
26
+
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
+ spec.source_files = current_source_files + [
29
+ # Generated cross-platform specs
30
+ "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
+ # Generated bridges for the cross-platform specs
32
+ "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
+ ]
34
+
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
+ spec.public_header_files = current_public_header_files + [
37
+ # Generated specs
38
+ "nitrogen/generated/shared/**/*.{h,hpp}",
39
+ # Swift to C++ bridging helpers
40
+ "nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.hpp"
41
+ ]
42
+
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
+ spec.private_header_files = current_private_header_files + [
45
+ # iOS specific specs
46
+ "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
+ # Views are framework-specific and should be private
48
+ "nitrogen/generated/shared/**/views/**/*"
49
+ ]
50
+
51
+ current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
+ spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
+ # Use C++ 20
54
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
+ # Enables C++ <-> Swift interop (by default it's only ObjC)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ })
60
+ end
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// ReactNativeCesium-Swift-Cxx-Bridge.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 "ReactNativeCesium-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridCesiumViewSpecSwift.hpp"
12
+ #include "ReactNativeCesium-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::reactnativecesium::bridge::swift {
16
+
17
+ // pragma MARK: std::function<void(const CesiumMetrics& /* metrics */)>
18
+ Func_void_CesiumMetrics create_Func_void_CesiumMetrics(void* NON_NULL swiftClosureWrapper) noexcept {
19
+ auto swiftClosure = ReactNativeCesium::Func_void_CesiumMetrics::fromUnsafe(swiftClosureWrapper);
20
+ return [swiftClosure = std::move(swiftClosure)](const CesiumMetrics& metrics) mutable -> void {
21
+ swiftClosure.call(metrics);
22
+ };
23
+ }
24
+
25
+ // pragma MARK: std::function<void(const CameraState& /* result */)>
26
+ Func_void_CameraState create_Func_void_CameraState(void* NON_NULL swiftClosureWrapper) noexcept {
27
+ auto swiftClosure = ReactNativeCesium::Func_void_CameraState::fromUnsafe(swiftClosureWrapper);
28
+ return [swiftClosure = std::move(swiftClosure)](const CameraState& result) mutable -> void {
29
+ swiftClosure.call(result);
30
+ };
31
+ }
32
+
33
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
34
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
35
+ auto swiftClosure = ReactNativeCesium::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
36
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
37
+ swiftClosure.call(error);
38
+ };
39
+ }
40
+
41
+ // pragma MARK: std::shared_ptr<HybridCesiumViewSpec>
42
+ std::shared_ptr<HybridCesiumViewSpec> create_std__shared_ptr_HybridCesiumViewSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
43
+ ReactNativeCesium::HybridCesiumViewSpec_cxx swiftPart = ReactNativeCesium::HybridCesiumViewSpec_cxx::fromUnsafe(swiftUnsafePointer);
44
+ return std::make_shared<margelo::nitro::reactnativecesium::HybridCesiumViewSpecSwift>(swiftPart);
45
+ }
46
+ void* NON_NULL get_std__shared_ptr_HybridCesiumViewSpec_(std__shared_ptr_HybridCesiumViewSpec_ cppType) {
47
+ std::shared_ptr<margelo::nitro::reactnativecesium::HybridCesiumViewSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::reactnativecesium::HybridCesiumViewSpecSwift>(cppType);
48
+ #ifdef NITRO_DEBUG
49
+ if (swiftWrapper == nullptr) [[unlikely]] {
50
+ throw std::runtime_error("Class \"HybridCesiumViewSpec\" is not implemented in Swift!");
51
+ }
52
+ #endif
53
+ ReactNativeCesium::HybridCesiumViewSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
54
+ return swiftPart.toUnsafe();
55
+ }
56
+
57
+ } // namespace margelo::nitro::reactnativecesium::bridge::swift
@@ -0,0 +1,164 @@
1
+ ///
2
+ /// ReactNativeCesium-Swift-Cxx-Bridge.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `CameraState` to properly resolve imports.
12
+ namespace margelo::nitro::reactnativecesium { struct CameraState; }
13
+ // Forward declaration of `CesiumMetrics` to properly resolve imports.
14
+ namespace margelo::nitro::reactnativecesium { struct CesiumMetrics; }
15
+ // Forward declaration of `HybridCesiumViewSpec` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativecesium { class HybridCesiumViewSpec; }
17
+
18
+ // Forward declarations of Swift defined types
19
+ // Forward declaration of `HybridCesiumViewSpec_cxx` to properly resolve imports.
20
+ namespace ReactNativeCesium { class HybridCesiumViewSpec_cxx; }
21
+
22
+ // Include C++ defined types
23
+ #include "CameraState.hpp"
24
+ #include "CesiumMetrics.hpp"
25
+ #include "HybridCesiumViewSpec.hpp"
26
+ #include <NitroModules/Promise.hpp>
27
+ #include <NitroModules/PromiseHolder.hpp>
28
+ #include <NitroModules/Result.hpp>
29
+ #include <exception>
30
+ #include <functional>
31
+ #include <memory>
32
+ #include <optional>
33
+ #include <string>
34
+
35
+ /**
36
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
37
+ * as well as helper functions to interact with those C++ types from Swift.
38
+ */
39
+ namespace margelo::nitro::reactnativecesium::bridge::swift {
40
+
41
+ // pragma MARK: std::function<void(const CesiumMetrics& /* metrics */)>
42
+ /**
43
+ * Specialized version of `std::function<void(const CesiumMetrics&)>`.
44
+ */
45
+ using Func_void_CesiumMetrics = std::function<void(const CesiumMetrics& /* metrics */)>;
46
+ /**
47
+ * Wrapper class for a `std::function<void(const CesiumMetrics& / * metrics * /)>`, this can be used from Swift.
48
+ */
49
+ class Func_void_CesiumMetrics_Wrapper final {
50
+ public:
51
+ explicit Func_void_CesiumMetrics_Wrapper(std::function<void(const CesiumMetrics& /* metrics */)>&& func): _function(std::make_unique<std::function<void(const CesiumMetrics& /* metrics */)>>(std::move(func))) {}
52
+ inline void call(CesiumMetrics metrics) const noexcept {
53
+ _function->operator()(metrics);
54
+ }
55
+ private:
56
+ std::unique_ptr<std::function<void(const CesiumMetrics& /* metrics */)>> _function;
57
+ } SWIFT_NONCOPYABLE;
58
+ Func_void_CesiumMetrics create_Func_void_CesiumMetrics(void* NON_NULL swiftClosureWrapper) noexcept;
59
+ inline Func_void_CesiumMetrics_Wrapper wrap_Func_void_CesiumMetrics(Func_void_CesiumMetrics value) noexcept {
60
+ return Func_void_CesiumMetrics_Wrapper(std::move(value));
61
+ }
62
+
63
+ // pragma MARK: std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>
64
+ /**
65
+ * Specialized version of `std::optional<std::function<void(const CesiumMetrics& / * metrics * /)>>`.
66
+ */
67
+ using std__optional_std__function_void_const_CesiumMetrics_____metrics______ = std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>;
68
+ inline std::optional<std::function<void(const CesiumMetrics& /* metrics */)>> create_std__optional_std__function_void_const_CesiumMetrics_____metrics______(const std::function<void(const CesiumMetrics& /* metrics */)>& value) noexcept {
69
+ return std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>(value);
70
+ }
71
+ inline bool has_value_std__optional_std__function_void_const_CesiumMetrics_____metrics______(const std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>& optional) noexcept {
72
+ return optional.has_value();
73
+ }
74
+ inline std::function<void(const CesiumMetrics& /* metrics */)> get_std__optional_std__function_void_const_CesiumMetrics_____metrics______(const std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>& optional) noexcept {
75
+ return optional.value();
76
+ }
77
+
78
+ // pragma MARK: std::shared_ptr<Promise<CameraState>>
79
+ /**
80
+ * Specialized version of `std::shared_ptr<Promise<CameraState>>`.
81
+ */
82
+ using std__shared_ptr_Promise_CameraState__ = std::shared_ptr<Promise<CameraState>>;
83
+ inline std::shared_ptr<Promise<CameraState>> create_std__shared_ptr_Promise_CameraState__() noexcept {
84
+ return Promise<CameraState>::create();
85
+ }
86
+ inline PromiseHolder<CameraState> wrap_std__shared_ptr_Promise_CameraState__(std::shared_ptr<Promise<CameraState>> promise) noexcept {
87
+ return PromiseHolder<CameraState>(std::move(promise));
88
+ }
89
+
90
+ // pragma MARK: std::function<void(const CameraState& /* result */)>
91
+ /**
92
+ * Specialized version of `std::function<void(const CameraState&)>`.
93
+ */
94
+ using Func_void_CameraState = std::function<void(const CameraState& /* result */)>;
95
+ /**
96
+ * Wrapper class for a `std::function<void(const CameraState& / * result * /)>`, this can be used from Swift.
97
+ */
98
+ class Func_void_CameraState_Wrapper final {
99
+ public:
100
+ explicit Func_void_CameraState_Wrapper(std::function<void(const CameraState& /* result */)>&& func): _function(std::make_unique<std::function<void(const CameraState& /* result */)>>(std::move(func))) {}
101
+ inline void call(CameraState result) const noexcept {
102
+ _function->operator()(result);
103
+ }
104
+ private:
105
+ std::unique_ptr<std::function<void(const CameraState& /* result */)>> _function;
106
+ } SWIFT_NONCOPYABLE;
107
+ Func_void_CameraState create_Func_void_CameraState(void* NON_NULL swiftClosureWrapper) noexcept;
108
+ inline Func_void_CameraState_Wrapper wrap_Func_void_CameraState(Func_void_CameraState value) noexcept {
109
+ return Func_void_CameraState_Wrapper(std::move(value));
110
+ }
111
+
112
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
113
+ /**
114
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
115
+ */
116
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
117
+ /**
118
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
119
+ */
120
+ class Func_void_std__exception_ptr_Wrapper final {
121
+ public:
122
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
123
+ inline void call(std::exception_ptr error) const noexcept {
124
+ _function->operator()(error);
125
+ }
126
+ private:
127
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
128
+ } SWIFT_NONCOPYABLE;
129
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
130
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
131
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
132
+ }
133
+
134
+ // pragma MARK: std::shared_ptr<HybridCesiumViewSpec>
135
+ /**
136
+ * Specialized version of `std::shared_ptr<HybridCesiumViewSpec>`.
137
+ */
138
+ using std__shared_ptr_HybridCesiumViewSpec_ = std::shared_ptr<HybridCesiumViewSpec>;
139
+ std::shared_ptr<HybridCesiumViewSpec> create_std__shared_ptr_HybridCesiumViewSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
140
+ void* NON_NULL get_std__shared_ptr_HybridCesiumViewSpec_(std__shared_ptr_HybridCesiumViewSpec_ cppType);
141
+
142
+ // pragma MARK: std::weak_ptr<HybridCesiumViewSpec>
143
+ using std__weak_ptr_HybridCesiumViewSpec_ = std::weak_ptr<HybridCesiumViewSpec>;
144
+ inline std__weak_ptr_HybridCesiumViewSpec_ weakify_std__shared_ptr_HybridCesiumViewSpec_(const std::shared_ptr<HybridCesiumViewSpec>& strong) noexcept { return strong; }
145
+
146
+ // pragma MARK: Result<std::shared_ptr<Promise<CameraState>>>
147
+ using Result_std__shared_ptr_Promise_CameraState___ = Result<std::shared_ptr<Promise<CameraState>>>;
148
+ inline Result_std__shared_ptr_Promise_CameraState___ create_Result_std__shared_ptr_Promise_CameraState___(const std::shared_ptr<Promise<CameraState>>& value) noexcept {
149
+ return Result<std::shared_ptr<Promise<CameraState>>>::withValue(value);
150
+ }
151
+ inline Result_std__shared_ptr_Promise_CameraState___ create_Result_std__shared_ptr_Promise_CameraState___(const std::exception_ptr& error) noexcept {
152
+ return Result<std::shared_ptr<Promise<CameraState>>>::withError(error);
153
+ }
154
+
155
+ // pragma MARK: Result<void>
156
+ using Result_void_ = Result<void>;
157
+ inline Result_void_ create_Result_void_() noexcept {
158
+ return Result<void>::withValue();
159
+ }
160
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
161
+ return Result<void>::withError(error);
162
+ }
163
+
164
+ } // namespace margelo::nitro::reactnativecesium::bridge::swift
@@ -0,0 +1,53 @@
1
+ ///
2
+ /// ReactNativeCesium-Swift-Cxx-Umbrella.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `CameraState` to properly resolve imports.
12
+ namespace margelo::nitro::reactnativecesium { struct CameraState; }
13
+ // Forward declaration of `CesiumMetrics` to properly resolve imports.
14
+ namespace margelo::nitro::reactnativecesium { struct CesiumMetrics; }
15
+ // Forward declaration of `HybridCesiumViewSpec` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativecesium { class HybridCesiumViewSpec; }
17
+
18
+ // Include C++ defined types
19
+ #include "CameraState.hpp"
20
+ #include "CesiumMetrics.hpp"
21
+ #include "HybridCesiumViewSpec.hpp"
22
+ #include <NitroModules/Promise.hpp>
23
+ #include <NitroModules/Result.hpp>
24
+ #include <exception>
25
+ #include <functional>
26
+ #include <memory>
27
+ #include <optional>
28
+ #include <string>
29
+
30
+ // C++ helpers for Swift
31
+ #include "ReactNativeCesium-Swift-Cxx-Bridge.hpp"
32
+
33
+ // Common C++ types used in Swift
34
+ #include <NitroModules/ArrayBufferHolder.hpp>
35
+ #include <NitroModules/AnyMapUtils.hpp>
36
+ #include <NitroModules/RuntimeError.hpp>
37
+ #include <NitroModules/DateToChronoDate.hpp>
38
+
39
+ // Forward declarations of Swift defined types
40
+ // Forward declaration of `HybridCesiumViewSpec_cxx` to properly resolve imports.
41
+ namespace ReactNativeCesium { class HybridCesiumViewSpec_cxx; }
42
+
43
+ // Include Swift defined types
44
+ #if __has_include("ReactNativeCesium-Swift.h")
45
+ // This header is generated by Xcode/Swift on every app build.
46
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "ReactNativeCesium".
47
+ #include "ReactNativeCesium-Swift.h"
48
+ // Same as above, but used when building with frameworks (`use_frameworks`)
49
+ #elif __has_include(<ReactNativeCesium/ReactNativeCesium-Swift.h>)
50
+ #include <ReactNativeCesium/ReactNativeCesium-Swift.h>
51
+ #else
52
+ #error ReactNativeCesium's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "ReactNativeCesium", and try building the app first.
53
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// ReactNativeCesiumAutolinking.mm
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
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "ReactNativeCesium-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridCesiumViewSpecSwift.hpp"
14
+
15
+ @interface ReactNativeCesiumAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation ReactNativeCesiumAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::reactnativecesium;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "CesiumView",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridCesiumViewSpec> hybridObject = ReactNativeCesium::ReactNativeCesiumAutolinking::createCesiumView();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// ReactNativeCesiumAutolinking.swift
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
+ import NitroModules
9
+
10
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class ReactNativeCesiumAutolinking {
13
+ public typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
14
+
15
+ public static func createCesiumView() -> bridge.std__shared_ptr_HybridCesiumViewSpec_ {
16
+ let hybridObject = HybridCesiumView()
17
+ return { () -> bridge.std__shared_ptr_HybridCesiumViewSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isCesiumViewRecyclable() -> Bool {
24
+ return HybridCesiumView.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridCesiumViewSpecSwift.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 "HybridCesiumViewSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::reactnativecesium {
11
+ } // namespace margelo::nitro::reactnativecesium