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,178 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:8.8.0"
9
+ }
10
+ }
11
+
12
+ // Cesium Native vendor/android is arm64-v8a only (`yarn run build` / ensure-native). Do not follow the app’s
13
+ // reactNativeArchitectures list: a typical RN template sets all ABIs and CMake would run for
14
+ // armeabi-v7a/x86/… and fail (no matching libs). The JNI library is only built for arm64.
15
+ def cesiumNativeAbiFilters() {
16
+ return ["arm64-v8a"]
17
+ }
18
+
19
+ def isNewArchitectureEnabled() {
20
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
21
+ }
22
+
23
+ apply plugin: "com.android.library"
24
+ apply plugin: 'org.jetbrains.kotlin.android'
25
+ apply from: '../nitrogen/generated/android/ReactNativeCesium+autolinking.gradle'
26
+ apply from: "./fix-prefab.gradle"
27
+
28
+ if (isNewArchitectureEnabled()) {
29
+ apply plugin: "com.facebook.react"
30
+ }
31
+
32
+ def reactNativeCesiumPackageDir = projectDir.parentFile
33
+
34
+ tasks.register('ensureCesiumNativeAndroid') {
35
+ group 'cesium'
36
+ description 'If vendor/android Cesium Native is missing, runs scripts/cesium/ensure-native.mjs (update + build). Can take a long time.'
37
+ doLast {
38
+ def marker = new File(reactNativeCesiumPackageDir, 'vendor/android/share/cesium-native/cmake/cesium-nativeConfig.cmake')
39
+ if (marker.exists()) {
40
+ return
41
+ }
42
+ if (System.getenv('REACT_NATIVE_CESIUM_SKIP_NATIVE_BUILD') == '1') {
43
+ throw new RuntimeException(
44
+ 'react-native-cesium: Android Cesium Native artifacts are missing under vendor/android. ' +
45
+ 'Install the Android NDK (ANDROID_NDK_HOME), then from node_modules/react-native-cesium run: npm run update && CESIUM_BUILD_ONLY=android npm run build. ' +
46
+ 'Or unset REACT_NATIVE_CESIUM_SKIP_NATIVE_BUILD to allow automatic build during Gradle. See package README.'
47
+ )
48
+ }
49
+ project.exec {
50
+ workingDir reactNativeCesiumPackageDir
51
+ commandLine 'node', 'scripts/cesium/ensure-native.mjs', '--android'
52
+ }
53
+ }
54
+ }
55
+
56
+ tasks.preBuild {
57
+ dependsOn 'ensureCesiumNativeAndroid'
58
+ }
59
+
60
+ def getExtOrDefault(name) {
61
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNativeCesium_" + name]
62
+ }
63
+
64
+ def getExtOrIntegerDefault(name) {
65
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeCesium_" + name]).toInteger()
66
+ }
67
+
68
+ android {
69
+ namespace "com.reactnativecesium"
70
+
71
+ ndkVersion getExtOrDefault("ndkVersion")
72
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
73
+
74
+ defaultConfig {
75
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
76
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
77
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
78
+
79
+ externalNativeBuild {
80
+ cmake {
81
+ cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
82
+ arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
83
+ abiFilters (*cesiumNativeAbiFilters())
84
+
85
+ buildTypes {
86
+ debug {
87
+ cppFlags "-O1 -g"
88
+ }
89
+ release {
90
+ cppFlags "-O2"
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ externalNativeBuild {
98
+ cmake {
99
+ path "CMakeLists.txt"
100
+ }
101
+ }
102
+
103
+ packagingOptions {
104
+ excludes = [
105
+ "META-INF",
106
+ "META-INF/**",
107
+ "**/libc++_shared.so",
108
+ "**/libfbjni.so",
109
+ "**/libjsi.so",
110
+ "**/libfolly_json.so",
111
+ "**/libfolly_runtime.so",
112
+ "**/libglog.so",
113
+ "**/libhermes.so",
114
+ "**/libhermes-executor-debug.so",
115
+ "**/libhermes_executor.so",
116
+ "**/libreactnative.so",
117
+ "**/libreactnativejni.so",
118
+ "**/libturbomodulejsijni.so",
119
+ "**/libreact_nativemodule_core.so",
120
+ "**/libjscexecutor.so"
121
+ ]
122
+ }
123
+
124
+ buildFeatures {
125
+ buildConfig true
126
+ prefab true
127
+ }
128
+
129
+ buildTypes {
130
+ release {
131
+ minifyEnabled false
132
+ }
133
+ }
134
+
135
+ lintOptions {
136
+ disable "GradleCompatible"
137
+ }
138
+
139
+ compileOptions {
140
+ sourceCompatibility JavaVersion.VERSION_1_8
141
+ targetCompatibility JavaVersion.VERSION_1_8
142
+ }
143
+
144
+ sourceSets {
145
+ main {
146
+ if (isNewArchitectureEnabled()) {
147
+ java.srcDirs += [
148
+ // React Codegen files
149
+ "${project.buildDir}/generated/source/codegen/java"
150
+ ]
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ repositories {
157
+ mavenCentral()
158
+ google()
159
+ }
160
+
161
+
162
+ dependencies {
163
+ // For < 0.71, this will be from the local maven repo
164
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
165
+ //noinspection GradleDynamicVersion
166
+ implementation "com.facebook.react:react-native:+"
167
+
168
+ // Add a dependency on NitroModules
169
+ implementation project(":react-native-nitro-modules")
170
+ }
171
+
172
+ if (isNewArchitectureEnabled()) {
173
+ react {
174
+ jsRootDir = file("../src/")
175
+ libraryName = "ReactNativeCesium"
176
+ codegenJavaPackageName = "com.reactnativecesium"
177
+ }
178
+ }
@@ -0,0 +1,51 @@
1
+ tasks.configureEach { task ->
2
+ // Make sure that we generate our prefab publication file only after having built the native library
3
+ // so that not a header publication file, but a full configuration publication will be generated, which
4
+ // will include the .so file
5
+
6
+ def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
7
+ def matcher = task.name =~ prefabConfigurePattern
8
+ if (matcher.matches()) {
9
+ def variantName = matcher[0][1]
10
+ task.outputs.upToDateWhen { false }
11
+ task.dependsOn("externalNativeBuild${variantName}")
12
+ }
13
+ }
14
+
15
+ afterEvaluate {
16
+ def abis = cesiumNativeAbiFilters()
17
+ rootProject.allprojects.each { proj ->
18
+ if (proj === rootProject) return
19
+
20
+ def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
21
+ config.dependencies.any { dep ->
22
+ dep.group == project.group && dep.name == project.name
23
+ }
24
+ }
25
+ if (!dependsOnThisLib && proj != project) return
26
+
27
+ if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
28
+ return
29
+ }
30
+
31
+ def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
32
+ // Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
33
+ // generate a libnameConfig.cmake file that will contain our native library (.so).
34
+ // See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
35
+ variants.all { variant ->
36
+ def variantName = variant.name
37
+ abis.each { abi ->
38
+ def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
39
+ if (!searchDir.exists()) return
40
+ def matches = []
41
+ searchDir.eachDir { randomDir ->
42
+ def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
43
+ if (prefabFile.exists()) matches << prefabFile
44
+ }
45
+ matches.each { prefabConfig ->
46
+ prefabConfig.setLastModified(System.currentTimeMillis())
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,5 @@
1
+ ReactNativeCesium_kotlinVersion=2.1.20
2
+ ReactNativeCesium_minSdkVersion=23
3
+ ReactNativeCesium_targetSdkVersion=35
4
+ ReactNativeCesium_compileSdkVersion=34
5
+ ReactNativeCesium_ndkVersion=27.1.12297006
@@ -0,0 +1,5 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <!-- Optional: declares Vulkan may be used; not required so the app still installs on devices without Vulkan. -->
3
+ <uses-feature android:name="android.hardware.vulkan.level" android:required="false" />
4
+ <uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
5
+ </manifest>