@delali/narsil-react-native 0.0.0-stage → 0.3.1-next.151

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 (186) hide show
  1. package/LICENSE +201 -0
  2. package/NarsilReactNative.podspec +57 -0
  3. package/README.md +46 -2
  4. package/android/CMakeLists.txt +48 -0
  5. package/android/build.gradle +151 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/AndroidEnvironment.cpp +44 -0
  9. package/android/src/main/cpp/AndroidEnvironment.hpp +11 -0
  10. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  11. package/android/src/main/java/com/margelo/nitro/narsil/NarsilAndroidEnvironment.kt +29 -0
  12. package/android/src/main/java/com/margelo/nitro/narsil/NarsilReactNativePackage.kt +22 -0
  13. package/app.plugin.js +25 -0
  14. package/cpp/AttachedField.cpp +234 -0
  15. package/cpp/AttachedField.hpp +61 -0
  16. package/cpp/Compression.cpp +113 -0
  17. package/cpp/Compression.hpp +16 -0
  18. package/cpp/GraphHeldAlone.cpp +29 -0
  19. package/cpp/GraphHeldAlone.hpp +25 -0
  20. package/cpp/HostMemory.cpp +123 -0
  21. package/cpp/HostMemory.hpp +53 -0
  22. package/cpp/HybridNarsilCoreImpl.cpp +390 -0
  23. package/cpp/HybridNarsilCoreImpl.hpp +68 -0
  24. package/cpp/HybridNarsilFilesImpl.cpp +245 -0
  25. package/cpp/HybridNarsilFilesImpl.hpp +34 -0
  26. package/cpp/HybridNarsilHostImpl.cpp +126 -0
  27. package/cpp/HybridNarsilHostImpl.hpp +42 -0
  28. package/cpp/NativeAtomics.cpp +110 -0
  29. package/cpp/NativeAtomics.hpp +11 -0
  30. package/cpp/ProcessInfo.cpp +83 -0
  31. package/cpp/ProcessInfo.hpp +11 -0
  32. package/cpp/ThreadPriority.cpp +77 -0
  33. package/cpp/ThreadPriority.hpp +8 -0
  34. package/cpp/WorkletRuntimeDispatcher.cpp +61 -0
  35. package/cpp/WorkletRuntimeDispatcher.hpp +9 -0
  36. package/cpp/core/include/narsil_core.h +208 -0
  37. package/cpp/core/src/connect.c +213 -0
  38. package/cpp/core/src/distance.c +103 -0
  39. package/cpp/core/src/files.c +99 -0
  40. package/cpp/core/src/heap.c +84 -0
  41. package/cpp/core/src/internal.h +284 -0
  42. package/cpp/core/src/kernels_code.c +209 -0
  43. package/cpp/core/src/kernels_float.c +197 -0
  44. package/cpp/core/src/kernels_pair.c +133 -0
  45. package/cpp/core/src/last_links.c +145 -0
  46. package/cpp/core/src/links.c +195 -0
  47. package/cpp/core/src/locks.c +168 -0
  48. package/cpp/core/src/nearest_links.c +147 -0
  49. package/cpp/core/src/place.c +215 -0
  50. package/cpp/core/src/quantize.c +226 -0
  51. package/cpp/core/src/records.c +97 -0
  52. package/cpp/core/src/remove.c +205 -0
  53. package/cpp/core/src/vectors.c +139 -0
  54. package/cpp/core/src/walk.c +231 -0
  55. package/cpp/core/src/workspace.c +167 -0
  56. package/ios/PrivacyInfo.xcprivacy +23 -0
  57. package/lib/client.d.ts +19 -0
  58. package/lib/client.js +41 -0
  59. package/lib/constants.d.ts +9 -0
  60. package/lib/constants.js +9 -0
  61. package/lib/engine/byte-files.d.ts +5 -0
  62. package/lib/engine/byte-files.js +97 -0
  63. package/lib/engine/core.d.ts +3 -0
  64. package/lib/engine/core.js +113 -0
  65. package/lib/engine/files.d.ts +3 -0
  66. package/lib/engine/files.js +188 -0
  67. package/lib/engine/host.d.ts +13 -0
  68. package/lib/engine/host.js +102 -0
  69. package/lib/engine/install.d.ts +4 -0
  70. package/lib/engine/install.js +29 -0
  71. package/lib/engine/native-error.d.ts +1 -0
  72. package/lib/engine/native-error.js +12 -0
  73. package/lib/engine/stand-ins/atomics.d.ts +5 -0
  74. package/lib/engine/stand-ins/atomics.js +236 -0
  75. package/lib/engine/stand-ins/crypto.d.ts +2 -0
  76. package/lib/engine/stand-ins/crypto.js +65 -0
  77. package/lib/engine/stand-ins/process.d.ts +2 -0
  78. package/lib/engine/stand-ins/process.js +22 -0
  79. package/lib/engine/stand-ins/streams.d.ts +1 -0
  80. package/lib/engine/stand-ins/streams.js +31 -0
  81. package/lib/engine/stand-ins/structured-clone.d.ts +1 -0
  82. package/lib/engine/stand-ins/structured-clone.js +121 -0
  83. package/lib/engine/streamed.d.ts +6 -0
  84. package/lib/engine/streamed.js +29 -0
  85. package/lib/engine/transfer.d.ts +3 -0
  86. package/lib/engine/transfer.js +77 -0
  87. package/lib/errors.d.ts +25 -0
  88. package/lib/errors.js +59 -0
  89. package/lib/index.d.ts +3 -0
  90. package/lib/index.js +2 -0
  91. package/lib/methods.d.ts +5 -0
  92. package/lib/methods.js +47 -0
  93. package/lib/native-objects.d.ts +2 -0
  94. package/lib/native-objects.js +24 -0
  95. package/lib/specs/core.nitro.d.ts +79 -0
  96. package/lib/specs/core.nitro.js +1 -0
  97. package/lib/specs/files.nitro.d.ts +36 -0
  98. package/lib/specs/files.nitro.js +1 -0
  99. package/lib/specs/host.nitro.d.ts +24 -0
  100. package/lib/specs/host.nitro.js +1 -0
  101. package/lib/transferred.d.ts +15 -0
  102. package/lib/transferred.js +6 -0
  103. package/lib/types.d.ts +136 -0
  104. package/lib/types.js +1 -0
  105. package/lib/worklets/app-turns.d.ts +1 -0
  106. package/lib/worklets/app-turns.js +44 -0
  107. package/lib/worklets/client.d.ts +30 -0
  108. package/lib/worklets/client.js +144 -0
  109. package/lib/worklets/index.d.ts +4 -0
  110. package/lib/worklets/index.js +2 -0
  111. package/lib/worklets/instances.d.ts +15 -0
  112. package/lib/worklets/instances.js +194 -0
  113. package/lib/worklets/json-part.d.ts +1 -0
  114. package/lib/worklets/json-part.js +42 -0
  115. package/lib/worklets/runtime.d.ts +25 -0
  116. package/lib/worklets/runtime.js +80 -0
  117. package/lib/worklets/transfer-queue.d.ts +7 -0
  118. package/lib/worklets/transfer-queue.js +79 -0
  119. package/lib/worklets/types.d.ts +26 -0
  120. package/lib/worklets/types.js +1 -0
  121. package/nitro.json +32 -0
  122. package/nitrogen/generated/.gitattributes +1 -0
  123. package/nitrogen/generated/android/NarsilReactNative+autolinking.cmake +85 -0
  124. package/nitrogen/generated/android/NarsilReactNative+autolinking.gradle +27 -0
  125. package/nitrogen/generated/android/NarsilReactNativeOnLoad.cpp +69 -0
  126. package/nitrogen/generated/android/NarsilReactNativeOnLoad.hpp +34 -0
  127. package/nitrogen/generated/android/kotlin/com/margelo/nitro/narsil/NarsilReactNativeOnLoad.kt +35 -0
  128. package/nitrogen/generated/ios/NarsilReactNative+autolinking.rb +62 -0
  129. package/nitrogen/generated/ios/NarsilReactNative-Swift-Cxx-Bridge.cpp +17 -0
  130. package/nitrogen/generated/ios/NarsilReactNative-Swift-Cxx-Bridge.hpp +27 -0
  131. package/nitrogen/generated/ios/NarsilReactNative-Swift-Cxx-Umbrella.hpp +38 -0
  132. package/nitrogen/generated/ios/NarsilReactNativeAutolinking.mm +55 -0
  133. package/nitrogen/generated/ios/NarsilReactNativeAutolinking.swift +16 -0
  134. package/nitrogen/generated/shared/c++/DirectoryEntry.hpp +91 -0
  135. package/nitrogen/generated/shared/c++/FileStatus.hpp +103 -0
  136. package/nitrogen/generated/shared/c++/GraphMemory.hpp +120 -0
  137. package/nitrogen/generated/shared/c++/HybridNarsilAttachedGraphSpec.cpp +21 -0
  138. package/nitrogen/generated/shared/c++/HybridNarsilAttachedGraphSpec.hpp +62 -0
  139. package/nitrogen/generated/shared/c++/HybridNarsilAttachedStoreSpec.cpp +21 -0
  140. package/nitrogen/generated/shared/c++/HybridNarsilAttachedStoreSpec.hpp +62 -0
  141. package/nitrogen/generated/shared/c++/HybridNarsilCoreSpec.cpp +35 -0
  142. package/nitrogen/generated/shared/c++/HybridNarsilCoreSpec.hpp +100 -0
  143. package/nitrogen/generated/shared/c++/HybridNarsilFilesSpec.cpp +37 -0
  144. package/nitrogen/generated/shared/c++/HybridNarsilFilesSpec.hpp +86 -0
  145. package/nitrogen/generated/shared/c++/HybridNarsilHostSpec.cpp +34 -0
  146. package/nitrogen/generated/shared/c++/HybridNarsilHostSpec.hpp +78 -0
  147. package/nitrogen/generated/shared/c++/MemoryView.hpp +91 -0
  148. package/nitrogen/generated/shared/c++/NativeConnectOutcome.hpp +87 -0
  149. package/nitrogen/generated/shared/c++/NativeScores.hpp +87 -0
  150. package/nitrogen/generated/shared/c++/NativeSearchHits.hpp +91 -0
  151. package/nitrogen/generated/shared/c++/ProcessMemory.hpp +87 -0
  152. package/nitrogen/generated/shared/c++/StoreMemory.hpp +142 -0
  153. package/package.json +87 -3
  154. package/react-native.config.js +8 -0
  155. package/src/client.ts +44 -0
  156. package/src/constants.ts +9 -0
  157. package/src/engine/byte-files.ts +99 -0
  158. package/src/engine/core.ts +162 -0
  159. package/src/engine/files.ts +186 -0
  160. package/src/engine/host.ts +111 -0
  161. package/src/engine/install.ts +31 -0
  162. package/src/engine/native-error.ts +10 -0
  163. package/src/engine/stand-ins/atomics.ts +288 -0
  164. package/src/engine/stand-ins/crypto.ts +81 -0
  165. package/src/engine/stand-ins/process.ts +30 -0
  166. package/src/engine/stand-ins/streams.ts +45 -0
  167. package/src/engine/stand-ins/structured-clone.ts +118 -0
  168. package/src/engine/streamed.ts +40 -0
  169. package/src/engine/transfer.ts +72 -0
  170. package/src/errors.ts +73 -0
  171. package/src/index.ts +3 -0
  172. package/src/methods.ts +52 -0
  173. package/src/native-objects.ts +30 -0
  174. package/src/specs/core.nitro.ts +140 -0
  175. package/src/specs/files.nitro.ts +42 -0
  176. package/src/specs/host.nitro.ts +30 -0
  177. package/src/transferred.ts +18 -0
  178. package/src/types.ts +164 -0
  179. package/src/worklets/app-turns.ts +48 -0
  180. package/src/worklets/client.ts +165 -0
  181. package/src/worklets/index.ts +4 -0
  182. package/src/worklets/instances.ts +231 -0
  183. package/src/worklets/json-part.ts +38 -0
  184. package/src/worklets/runtime.ts +190 -0
  185. package/src/worklets/transfer-queue.ts +98 -0
  186. package/src/worklets/types.ts +37 -0
@@ -0,0 +1,85 @@
1
+ #
2
+ # NarsilReactNative+autolinking.cmake
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 CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NarsilReactNative+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NARSILREACTNATIVE_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ NarsilReactNative PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/NarsilReactNativeOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridNarsilAttachedGraphSpec.cpp
37
+ ../nitrogen/generated/shared/c++/HybridNarsilAttachedStoreSpec.cpp
38
+ ../nitrogen/generated/shared/c++/HybridNarsilCoreSpec.cpp
39
+ ../nitrogen/generated/shared/c++/HybridNarsilFilesSpec.cpp
40
+ ../nitrogen/generated/shared/c++/HybridNarsilHostSpec.cpp
41
+ # Android-specific Nitrogen C++ sources
42
+
43
+ )
44
+
45
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
46
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
47
+ target_compile_definitions(
48
+ NarsilReactNative PRIVATE
49
+ -DFOLLY_NO_CONFIG=1
50
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
51
+ -DFOLLY_USE_LIBCPP=1
52
+ -DFOLLY_CFG_NO_COROUTINES=1
53
+ -DFOLLY_MOBILE=1
54
+ -DFOLLY_HAVE_RECVMMSG=1
55
+ -DFOLLY_HAVE_PTHREAD=1
56
+ # Once we target android-23 above, we can comment
57
+ # the following line. NDK uses GNU style stderror_r() after API 23.
58
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
59
+ )
60
+
61
+ # Add all libraries required by the generated specs
62
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
63
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
64
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
65
+
66
+ # Link all libraries together
67
+ target_link_libraries(
68
+ NarsilReactNative
69
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
70
+ ReactAndroid::jsi # <-- RN: JSI
71
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
72
+ )
73
+
74
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
75
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
76
+ target_link_libraries(
77
+ NarsilReactNative
78
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
79
+ )
80
+ else()
81
+ target_link_libraries(
82
+ NarsilReactNative
83
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
84
+ )
85
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// NarsilReactNative+autolinking.gradle
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 Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/NarsilReactNative+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 NarsilReactNative is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// NarsilReactNativeOnLoad.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
+ #ifndef BUILDING_NARSILREACTNATIVE_WITH_GENERATED_CMAKE_PROJECT
9
+ #error NarsilReactNativeOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "NarsilReactNativeOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "HybridNarsilHostImpl.hpp"
19
+ #include "HybridNarsilFilesImpl.hpp"
20
+ #include "HybridNarsilCoreImpl.hpp"
21
+
22
+ namespace margelo::nitro::narsil {
23
+
24
+ int initialize(JavaVM* vm) {
25
+ return facebook::jni::initialize(vm, []() {
26
+ ::margelo::nitro::narsil::registerAllNatives();
27
+ });
28
+ }
29
+
30
+
31
+
32
+ void registerAllNatives() {
33
+ using namespace margelo::nitro;
34
+ using namespace margelo::nitro::narsil;
35
+
36
+ // Register native JNI methods
37
+
38
+
39
+ // Register Nitro Hybrid Objects
40
+ HybridObjectRegistry::registerHybridObjectConstructor(
41
+ "NarsilHost",
42
+ []() -> std::shared_ptr<HybridObject> {
43
+ static_assert(std::is_default_constructible_v<HybridNarsilHostImpl>,
44
+ "The HybridObject \"HybridNarsilHostImpl\" is not default-constructible! "
45
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
46
+ return std::make_shared<HybridNarsilHostImpl>();
47
+ }
48
+ );
49
+ HybridObjectRegistry::registerHybridObjectConstructor(
50
+ "NarsilFiles",
51
+ []() -> std::shared_ptr<HybridObject> {
52
+ static_assert(std::is_default_constructible_v<HybridNarsilFilesImpl>,
53
+ "The HybridObject \"HybridNarsilFilesImpl\" is not default-constructible! "
54
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
55
+ return std::make_shared<HybridNarsilFilesImpl>();
56
+ }
57
+ );
58
+ HybridObjectRegistry::registerHybridObjectConstructor(
59
+ "NarsilCore",
60
+ []() -> std::shared_ptr<HybridObject> {
61
+ static_assert(std::is_default_constructible_v<HybridNarsilCoreImpl>,
62
+ "The HybridObject \"HybridNarsilCoreImpl\" is not default-constructible! "
63
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
64
+ return std::make_shared<HybridNarsilCoreImpl>();
65
+ }
66
+ );
67
+ }
68
+
69
+ } // namespace margelo::nitro::narsil
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// NarsilReactNativeOnLoad.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
+ #include <jni.h>
9
+ #include <functional>
10
+ #include <NitroModules/NitroDefines.hpp>
11
+
12
+ namespace margelo::nitro::narsil {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of NarsilReactNative, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
21
+ * Example:
22
+ * ```cpp (cpp-adapter.cpp)
23
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all NarsilReactNative HybridObjects
26
+ * margelo::nitro::narsil::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::narsil
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// NarsilReactNativeOnLoad.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.narsil
9
+
10
+ import android.util.Log
11
+
12
+ internal class NarsilReactNativeOnLoad {
13
+ companion object {
14
+ private const val TAG = "NarsilReactNativeOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "NarsilReactNative".
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 NarsilReactNative C++ library...")
25
+ System.loadLibrary("NarsilReactNative")
26
+ Log.i(TAG, "Successfully loaded NarsilReactNative C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load NarsilReactNative 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,62 @@
1
+ #
2
+ # NarsilReactNative+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/NarsilReactNative+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 NarsilReactNative 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/NarsilReactNative-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
+ # Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
60
+ "SWIFT_INSTALL_OBJC_HEADER" => "NO",
61
+ })
62
+ end
@@ -0,0 +1,17 @@
1
+ ///
2
+ /// NarsilReactNative-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 "NarsilReactNative-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+
12
+
13
+ namespace margelo::nitro::narsil::bridge::swift {
14
+
15
+
16
+
17
+ } // namespace margelo::nitro::narsil::bridge::swift
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// NarsilReactNative-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
+
12
+
13
+ // Forward declarations of Swift defined types
14
+
15
+
16
+ // Include C++ defined types
17
+
18
+
19
+ /**
20
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
21
+ * as well as helper functions to interact with those C++ types from Swift.
22
+ */
23
+ namespace margelo::nitro::narsil::bridge::swift {
24
+
25
+
26
+
27
+ } // namespace margelo::nitro::narsil::bridge::swift
@@ -0,0 +1,38 @@
1
+ ///
2
+ /// NarsilReactNative-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
+
12
+
13
+ // Include C++ defined types
14
+
15
+
16
+ // C++ helpers for Swift
17
+ #include "NarsilReactNative-Swift-Cxx-Bridge.hpp"
18
+
19
+ // Common C++ types used in Swift
20
+ #include <NitroModules/ArrayBufferHolder.hpp>
21
+ #include <NitroModules/AnyMapUtils.hpp>
22
+ #include <NitroModules/RuntimeError.hpp>
23
+ #include <NitroModules/DateToChronoDate.hpp>
24
+
25
+ // Forward declarations of Swift defined types
26
+
27
+
28
+ // Include Swift defined types
29
+ #if __has_include("NarsilReactNative-Swift.h")
30
+ // This header is generated by Xcode/Swift on every app build.
31
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NarsilReactNative".
32
+ #include "NarsilReactNative-Swift.h"
33
+ // Same as above, but used when building with frameworks (`use_frameworks`)
34
+ #elif __has_include(<NarsilReactNative/NarsilReactNative-Swift.h>)
35
+ #include <NarsilReactNative/NarsilReactNative-Swift.h>
36
+ #else
37
+ #error NarsilReactNative's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NarsilReactNative", and try building the app first.
38
+ #endif
@@ -0,0 +1,55 @@
1
+ ///
2
+ /// NarsilReactNativeAutolinking.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
+
11
+ #import <type_traits>
12
+
13
+ #include "HybridNarsilHostImpl.hpp"
14
+ #include "HybridNarsilFilesImpl.hpp"
15
+ #include "HybridNarsilCoreImpl.hpp"
16
+
17
+ @interface NarsilReactNativeAutolinking : NSObject
18
+ @end
19
+
20
+ @implementation NarsilReactNativeAutolinking
21
+
22
+ + (void) load {
23
+ using namespace margelo::nitro;
24
+ using namespace margelo::nitro::narsil;
25
+
26
+ HybridObjectRegistry::registerHybridObjectConstructor(
27
+ "NarsilHost",
28
+ []() -> std::shared_ptr<HybridObject> {
29
+ static_assert(std::is_default_constructible_v<HybridNarsilHostImpl>,
30
+ "The HybridObject \"HybridNarsilHostImpl\" is not default-constructible! "
31
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
32
+ return std::make_shared<HybridNarsilHostImpl>();
33
+ }
34
+ );
35
+ HybridObjectRegistry::registerHybridObjectConstructor(
36
+ "NarsilFiles",
37
+ []() -> std::shared_ptr<HybridObject> {
38
+ static_assert(std::is_default_constructible_v<HybridNarsilFilesImpl>,
39
+ "The HybridObject \"HybridNarsilFilesImpl\" is not default-constructible! "
40
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
41
+ return std::make_shared<HybridNarsilFilesImpl>();
42
+ }
43
+ );
44
+ HybridObjectRegistry::registerHybridObjectConstructor(
45
+ "NarsilCore",
46
+ []() -> std::shared_ptr<HybridObject> {
47
+ static_assert(std::is_default_constructible_v<HybridNarsilCoreImpl>,
48
+ "The HybridObject \"HybridNarsilCoreImpl\" is not default-constructible! "
49
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
50
+ return std::make_shared<HybridNarsilCoreImpl>();
51
+ }
52
+ );
53
+ }
54
+
55
+ @end
@@ -0,0 +1,16 @@
1
+ ///
2
+ /// NarsilReactNativeAutolinking.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 NarsilReactNativeAutolinking {
13
+ public typealias bridge = margelo.nitro.narsil.bridge.swift
14
+
15
+
16
+ }
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// DirectoryEntry.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::narsil {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (DirectoryEntry).
39
+ */
40
+ struct DirectoryEntry final {
41
+ public:
42
+ std::string name SWIFT_PRIVATE;
43
+ bool isDirectory SWIFT_PRIVATE;
44
+ bool isFile SWIFT_PRIVATE;
45
+
46
+ public:
47
+ DirectoryEntry() = default;
48
+ explicit DirectoryEntry(std::string name, bool isDirectory, bool isFile): name(name), isDirectory(isDirectory), isFile(isFile) {}
49
+
50
+ public:
51
+ friend bool operator==(const DirectoryEntry& lhs, const DirectoryEntry& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::narsil
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ DirectoryEntry <> JS DirectoryEntry (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::narsil::DirectoryEntry> final {
61
+ static inline margelo::nitro::narsil::DirectoryEntry fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::narsil::DirectoryEntry(
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
65
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isDirectory"))),
66
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isFile")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::narsil::DirectoryEntry& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isDirectory"), JSIConverter<bool>::toJSI(runtime, arg.isDirectory));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isFile"), JSIConverter<bool>::toJSI(runtime, arg.isFile));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
85
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isDirectory")))) return false;
86
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isFile")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro
@@ -0,0 +1,103 @@
1
+ ///
2
+ /// FileStatus.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::narsil {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (FileStatus).
39
+ */
40
+ struct FileStatus final {
41
+ public:
42
+ double size SWIFT_PRIVATE;
43
+ bool isDirectory SWIFT_PRIVATE;
44
+ bool isFile SWIFT_PRIVATE;
45
+ std::string device SWIFT_PRIVATE;
46
+ std::string inode SWIFT_PRIVATE;
47
+ double modifiedMs SWIFT_PRIVATE;
48
+
49
+ public:
50
+ FileStatus() = default;
51
+ explicit FileStatus(double size, bool isDirectory, bool isFile, std::string device, std::string inode, double modifiedMs): size(size), isDirectory(isDirectory), isFile(isFile), device(device), inode(inode), modifiedMs(modifiedMs) {}
52
+
53
+ public:
54
+ friend bool operator==(const FileStatus& lhs, const FileStatus& rhs) = default;
55
+ };
56
+
57
+ } // namespace margelo::nitro::narsil
58
+
59
+ namespace margelo::nitro {
60
+
61
+ // C++ FileStatus <> JS FileStatus (object)
62
+ template <>
63
+ struct JSIConverter<margelo::nitro::narsil::FileStatus> final {
64
+ static inline margelo::nitro::narsil::FileStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
65
+ jsi::Object obj = arg.asObject(runtime);
66
+ return margelo::nitro::narsil::FileStatus(
67
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size"))),
68
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isDirectory"))),
69
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isFile"))),
70
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "device"))),
71
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inode"))),
72
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modifiedMs")))
73
+ );
74
+ }
75
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::narsil::FileStatus& arg) {
76
+ jsi::Object obj(runtime);
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "size"), JSIConverter<double>::toJSI(runtime, arg.size));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isDirectory"), JSIConverter<bool>::toJSI(runtime, arg.isDirectory));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isFile"), JSIConverter<bool>::toJSI(runtime, arg.isFile));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "device"), JSIConverter<std::string>::toJSI(runtime, arg.device));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "inode"), JSIConverter<std::string>::toJSI(runtime, arg.inode));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "modifiedMs"), JSIConverter<double>::toJSI(runtime, arg.modifiedMs));
83
+ return obj;
84
+ }
85
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
86
+ if (!value.isObject()) {
87
+ return false;
88
+ }
89
+ jsi::Object obj = value.getObject(runtime);
90
+ if (!nitro::isPlainObject(runtime, obj)) {
91
+ return false;
92
+ }
93
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size")))) return false;
94
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isDirectory")))) return false;
95
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isFile")))) return false;
96
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "device")))) return false;
97
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inode")))) return false;
98
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modifiedMs")))) return false;
99
+ return true;
100
+ }
101
+ };
102
+
103
+ } // namespace margelo::nitro