@angadie/chittie-react-native 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/ChittieReactNative.podspec +32 -0
  2. package/LICENSE +24 -0
  3. package/README.md +80 -0
  4. package/android/CMakeLists.txt +25 -0
  5. package/android/build.gradle +100 -0
  6. package/android/fix-prefab.gradle +37 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/chittie/HybridChittieRasterizer.kt +53 -0
  10. package/app.plugin.js +5 -0
  11. package/ios/HybridChittieRasterizer.swift +48 -0
  12. package/lib/commonjs/adapter.js +33 -0
  13. package/lib/commonjs/adapter.js.map +1 -0
  14. package/lib/commonjs/index.js +34 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/ChittieRasterizer.nitro.js +6 -0
  18. package/lib/commonjs/specs/ChittieRasterizer.nitro.js.map +1 -0
  19. package/lib/module/adapter.js +29 -0
  20. package/lib/module/adapter.js.map +1 -0
  21. package/lib/module/index.js +25 -0
  22. package/lib/module/index.js.map +1 -0
  23. package/lib/module/specs/ChittieRasterizer.nitro.js +4 -0
  24. package/lib/module/specs/ChittieRasterizer.nitro.js.map +1 -0
  25. package/lib/typescript/src/adapter.d.ts +11 -0
  26. package/lib/typescript/src/adapter.d.ts.map +1 -0
  27. package/lib/typescript/src/index.d.ts +15 -0
  28. package/lib/typescript/src/index.d.ts.map +1 -0
  29. package/lib/typescript/src/specs/ChittieRasterizer.nitro.d.ts +23 -0
  30. package/lib/typescript/src/specs/ChittieRasterizer.nitro.d.ts.map +1 -0
  31. package/nitro.json +23 -0
  32. package/nitrogen/generated/.gitattributes +1 -0
  33. package/nitrogen/generated/android/ChittieReactNative+autolinking.cmake +81 -0
  34. package/nitrogen/generated/android/ChittieReactNative+autolinking.gradle +27 -0
  35. package/nitrogen/generated/android/ChittieReactNativeOnLoad.cpp +54 -0
  36. package/nitrogen/generated/android/ChittieReactNativeOnLoad.hpp +34 -0
  37. package/nitrogen/generated/android/c++/JHybridChittieRasterizerSpec.cpp +58 -0
  38. package/nitrogen/generated/android/c++/JHybridChittieRasterizerSpec.hpp +63 -0
  39. package/nitrogen/generated/android/c++/JRasterBitmap.hpp +66 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chittie/ChittieReactNativeOnLoad.kt +35 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chittie/HybridChittieRasterizerSpec.kt +54 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chittie/RasterBitmap.kt +44 -0
  43. package/nitrogen/generated/ios/ChittieReactNative+autolinking.rb +60 -0
  44. package/nitrogen/generated/ios/ChittieReactNative-Swift-Cxx-Bridge.cpp +33 -0
  45. package/nitrogen/generated/ios/ChittieReactNative-Swift-Cxx-Bridge.hpp +54 -0
  46. package/nitrogen/generated/ios/ChittieReactNative-Swift-Cxx-Umbrella.hpp +48 -0
  47. package/nitrogen/generated/ios/ChittieReactNativeAutolinking.mm +33 -0
  48. package/nitrogen/generated/ios/ChittieReactNativeAutolinking.swift +26 -0
  49. package/nitrogen/generated/ios/c++/HybridChittieRasterizerSpecSwift.cpp +11 -0
  50. package/nitrogen/generated/ios/c++/HybridChittieRasterizerSpecSwift.hpp +88 -0
  51. package/nitrogen/generated/ios/swift/HybridChittieRasterizerSpec.swift +55 -0
  52. package/nitrogen/generated/ios/swift/HybridChittieRasterizerSpec_cxx.swift +138 -0
  53. package/nitrogen/generated/ios/swift/RasterBitmap.swift +39 -0
  54. package/nitrogen/generated/shared/c++/HybridChittieRasterizerSpec.cpp +21 -0
  55. package/nitrogen/generated/shared/c++/HybridChittieRasterizerSpec.hpp +64 -0
  56. package/nitrogen/generated/shared/c++/RasterBitmap.hpp +91 -0
  57. package/package.json +77 -0
  58. package/src/adapter.ts +25 -0
  59. package/src/index.ts +27 -0
  60. package/src/specs/ChittieRasterizer.nitro.ts +21 -0
package/nitro.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://nitro.margelo.com/nitro.schema.json",
3
+ "cxxNamespace": ["chittie"],
4
+ "ios": {
5
+ "iosModuleName": "ChittieReactNative"
6
+ },
7
+ "android": {
8
+ "androidNamespace": ["chittie"],
9
+ "androidCxxLibName": "ChittieReactNative"
10
+ },
11
+ "autolinking": {
12
+ "ChittieRasterizer": {
13
+ "ios": {
14
+ "language": "swift",
15
+ "implementationClassName": "HybridChittieRasterizer"
16
+ },
17
+ "android": {
18
+ "language": "kotlin",
19
+ "implementationClassName": "HybridChittieRasterizer"
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1 @@
1
+ ** linguist-generated=true
@@ -0,0 +1,81 @@
1
+ #
2
+ # ChittieReactNative+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/ChittieReactNative+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_CHITTIEREACTNATIVE_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
+ ChittieReactNative PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/ChittieReactNativeOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridChittieRasterizerSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridChittieRasterizerSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ ChittieReactNative PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ ChittieReactNative
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ ChittieReactNative
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ ChittieReactNative
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// ChittieReactNative+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/ChittieReactNative+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 ChittieReactNative 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,54 @@
1
+ ///
2
+ /// ChittieReactNativeOnLoad.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_CHITTIEREACTNATIVE_WITH_GENERATED_CMAKE_PROJECT
9
+ #error ChittieReactNativeOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "ChittieReactNativeOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridChittieRasterizerSpec.hpp"
19
+ #include <NitroModules/DefaultConstructableObject.hpp>
20
+
21
+ namespace margelo::nitro::chittie {
22
+
23
+ int initialize(JavaVM* vm) {
24
+ return facebook::jni::initialize(vm, []() {
25
+ ::margelo::nitro::chittie::registerAllNatives();
26
+ });
27
+ }
28
+
29
+ struct JHybridChittieRasterizerSpecImpl: public jni::JavaClass<JHybridChittieRasterizerSpecImpl, JHybridChittieRasterizerSpec::JavaPart> {
30
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/chittie/HybridChittieRasterizer;";
31
+ static std::shared_ptr<JHybridChittieRasterizerSpec> create() {
32
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridChittieRasterizerSpecImpl::javaobject()>();
33
+ jni::local_ref<JHybridChittieRasterizerSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
34
+ return javaPart->getJHybridChittieRasterizerSpec();
35
+ }
36
+ };
37
+
38
+ void registerAllNatives() {
39
+ using namespace margelo::nitro;
40
+ using namespace margelo::nitro::chittie;
41
+
42
+ // Register native JNI methods
43
+ margelo::nitro::chittie::JHybridChittieRasterizerSpec::CxxPart::registerNatives();
44
+
45
+ // Register Nitro Hybrid Objects
46
+ HybridObjectRegistry::registerHybridObjectConstructor(
47
+ "ChittieRasterizer",
48
+ []() -> std::shared_ptr<HybridObject> {
49
+ return JHybridChittieRasterizerSpecImpl::create();
50
+ }
51
+ );
52
+ }
53
+
54
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// ChittieReactNativeOnLoad.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::chittie {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of ChittieReactNative, 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 ChittieReactNative HybridObjects
26
+ * margelo::nitro::chittie::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// JHybridChittieRasterizerSpec.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 "JHybridChittieRasterizerSpec.hpp"
9
+
10
+ // Forward declaration of `RasterBitmap` to properly resolve imports.
11
+ namespace margelo::nitro::chittie { struct RasterBitmap; }
12
+
13
+ #include "RasterBitmap.hpp"
14
+ #include "JRasterBitmap.hpp"
15
+ #include <NitroModules/ArrayBuffer.hpp>
16
+ #include <NitroModules/JArrayBuffer.hpp>
17
+ #include <string>
18
+
19
+ namespace margelo::nitro::chittie {
20
+
21
+ std::shared_ptr<JHybridChittieRasterizerSpec> JHybridChittieRasterizerSpec::JavaPart::getJHybridChittieRasterizerSpec() {
22
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
23
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridChittieRasterizerSpec>(hybridObject);
24
+ if (castHybridObject == nullptr) [[unlikely]] {
25
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridChittieRasterizerSpec!");
26
+ }
27
+ return castHybridObject;
28
+ }
29
+
30
+ jni::local_ref<JHybridChittieRasterizerSpec::CxxPart::jhybriddata> JHybridChittieRasterizerSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
31
+ return makeCxxInstance(jThis);
32
+ }
33
+
34
+ std::shared_ptr<JHybridObject> JHybridChittieRasterizerSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
35
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridChittieRasterizerSpec::JavaPart>(javaPart);
36
+ if (castJavaPart == nullptr) [[unlikely]] {
37
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridChittieRasterizerSpec::JavaPart!");
38
+ }
39
+ return std::make_shared<JHybridChittieRasterizerSpec>(castJavaPart);
40
+ }
41
+
42
+ void JHybridChittieRasterizerSpec::CxxPart::registerNatives() {
43
+ registerHybrid({
44
+ makeNativeMethod("initHybrid", JHybridChittieRasterizerSpec::CxxPart::initHybrid),
45
+ });
46
+ }
47
+
48
+ // Properties
49
+
50
+
51
+ // Methods
52
+ RasterBitmap JHybridChittieRasterizerSpec::rasterize(const std::string& text, double fontSize, double maxWidth, bool bold) {
53
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JRasterBitmap>(jni::alias_ref<jni::JString> /* text */, double /* fontSize */, double /* maxWidth */, jboolean /* bold */)>("rasterize");
54
+ auto __result = method(_javaPart, jni::make_jstring(text), fontSize, maxWidth, bold);
55
+ return __result->toCpp();
56
+ }
57
+
58
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpec.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 <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridChittieRasterizerSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::chittie {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridChittieRasterizerSpec: public virtual HybridChittieRasterizerSpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/chittie/HybridChittieRasterizerSpec;";
25
+ std::shared_ptr<JHybridChittieRasterizerSpec> getJHybridChittieRasterizerSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/chittie/HybridChittieRasterizerSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridChittieRasterizerSpec(const jni::local_ref<JHybridChittieRasterizerSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridChittieRasterizerSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridChittieRasterizerSpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridChittieRasterizerSpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ RasterBitmap rasterize(const std::string& text, double fontSize, double maxWidth, bool bold) override;
58
+
59
+ private:
60
+ jni::global_ref<JHybridChittieRasterizerSpec::JavaPart> _javaPart;
61
+ };
62
+
63
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// JRasterBitmap.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 <fbjni/fbjni.h>
11
+ #include "RasterBitmap.hpp"
12
+
13
+ #include <NitroModules/ArrayBuffer.hpp>
14
+ #include <NitroModules/JArrayBuffer.hpp>
15
+
16
+ namespace margelo::nitro::chittie {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * The C++ JNI bridge between the C++ struct "RasterBitmap" and the the Kotlin data class "RasterBitmap".
22
+ */
23
+ struct JRasterBitmap final: public jni::JavaClass<JRasterBitmap> {
24
+ public:
25
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/chittie/RasterBitmap;";
26
+
27
+ public:
28
+ /**
29
+ * Convert this Java/Kotlin-based struct to the C++ struct RasterBitmap by copying all values to C++.
30
+ */
31
+ [[maybe_unused]]
32
+ [[nodiscard]]
33
+ RasterBitmap toCpp() const {
34
+ static const auto clazz = javaClassStatic();
35
+ static const auto fieldData = clazz->getField<JArrayBuffer::javaobject>("data");
36
+ jni::local_ref<JArrayBuffer::javaobject> data = this->getFieldValue(fieldData);
37
+ static const auto fieldWidth = clazz->getField<double>("width");
38
+ double width = this->getFieldValue(fieldWidth);
39
+ static const auto fieldHeight = clazz->getField<double>("height");
40
+ double height = this->getFieldValue(fieldHeight);
41
+ return RasterBitmap(
42
+ data->cthis()->getArrayBuffer(),
43
+ width,
44
+ height
45
+ );
46
+ }
47
+
48
+ public:
49
+ /**
50
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
51
+ */
52
+ [[maybe_unused]]
53
+ static jni::local_ref<JRasterBitmap::javaobject> fromCpp(const RasterBitmap& value) {
54
+ using JSignature = JRasterBitmap(jni::alias_ref<JArrayBuffer::javaobject>, double, double);
55
+ static const auto clazz = javaClassStatic();
56
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
57
+ return create(
58
+ clazz,
59
+ JArrayBuffer::wrap(value.data),
60
+ value.width,
61
+ value.height
62
+ );
63
+ }
64
+ };
65
+
66
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// ChittieReactNativeOnLoad.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.chittie
9
+
10
+ import android.util.Log
11
+
12
+ internal class ChittieReactNativeOnLoad {
13
+ companion object {
14
+ private const val TAG = "ChittieReactNativeOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "ChittieReactNative".
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 ChittieReactNative C++ library...")
25
+ System.loadLibrary("ChittieReactNative")
26
+ Log.i(TAG, "Successfully loaded ChittieReactNative C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load ChittieReactNative 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,54 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpec.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.chittie
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.HybridObject
14
+
15
+ /**
16
+ * A Kotlin class representing the ChittieRasterizer HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of ChittieRasterizer.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridChittieRasterizerSpec: HybridObject() {
27
+ // Properties
28
+
29
+
30
+ // Methods
31
+ @DoNotStrip
32
+ @Keep
33
+ abstract fun rasterize(text: String, fontSize: Double, maxWidth: Double, bold: Boolean): RasterBitmap
34
+
35
+ // Default implementation of `HybridObject.toString()`
36
+ override fun toString(): String {
37
+ return "[HybridObject ChittieRasterizer]"
38
+ }
39
+
40
+ // C++ backing class
41
+ @DoNotStrip
42
+ @Keep
43
+ protected open class CxxPart(javaPart: HybridChittieRasterizerSpec): HybridObject.CxxPart(javaPart) {
44
+ // C++ JHybridChittieRasterizerSpec::CxxPart::initHybrid(...)
45
+ external override fun initHybrid(): HybridData
46
+ }
47
+ override fun createCxxPart(): CxxPart {
48
+ return CxxPart(this)
49
+ }
50
+
51
+ companion object {
52
+ protected const val TAG = "HybridChittieRasterizerSpec"
53
+ }
54
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// RasterBitmap.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.chittie
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.ArrayBuffer
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "RasterBitmap".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class RasterBitmap(
20
+ @DoNotStrip
21
+ @Keep
22
+ val data: ArrayBuffer,
23
+ @DoNotStrip
24
+ @Keep
25
+ val width: Double,
26
+ @DoNotStrip
27
+ @Keep
28
+ val height: Double
29
+ ) {
30
+ /* primary constructor */
31
+
32
+ companion object {
33
+ /**
34
+ * Constructor called from C++
35
+ */
36
+ @DoNotStrip
37
+ @Keep
38
+ @Suppress("unused")
39
+ @JvmStatic
40
+ private fun fromCpp(data: ArrayBuffer, width: Double, height: Double): RasterBitmap {
41
+ return RasterBitmap(data, width, height)
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,60 @@
1
+ #
2
+ # ChittieReactNative+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/ChittieReactNative+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 ChittieReactNative 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/ChittieReactNative-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,33 @@
1
+ ///
2
+ /// ChittieReactNative-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 "ChittieReactNative-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "ChittieReactNative-Swift-Cxx-Umbrella.hpp"
12
+ #include "HybridChittieRasterizerSpecSwift.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::chittie::bridge::swift {
16
+
17
+ // pragma MARK: std::shared_ptr<HybridChittieRasterizerSpec>
18
+ std::shared_ptr<HybridChittieRasterizerSpec> create_std__shared_ptr_HybridChittieRasterizerSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
19
+ ChittieReactNative::HybridChittieRasterizerSpec_cxx swiftPart = ChittieReactNative::HybridChittieRasterizerSpec_cxx::fromUnsafe(swiftUnsafePointer);
20
+ return std::make_shared<margelo::nitro::chittie::HybridChittieRasterizerSpecSwift>(swiftPart);
21
+ }
22
+ void* NON_NULL get_std__shared_ptr_HybridChittieRasterizerSpec_(std__shared_ptr_HybridChittieRasterizerSpec_ cppType) {
23
+ std::shared_ptr<margelo::nitro::chittie::HybridChittieRasterizerSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::chittie::HybridChittieRasterizerSpecSwift>(cppType);
24
+ #ifdef NITRO_DEBUG
25
+ if (swiftWrapper == nullptr) [[unlikely]] {
26
+ throw std::runtime_error("Class \"HybridChittieRasterizerSpec\" is not implemented in Swift!");
27
+ }
28
+ #endif
29
+ ChittieReactNative::HybridChittieRasterizerSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
30
+ return swiftPart.toUnsafe();
31
+ }
32
+
33
+ } // namespace margelo::nitro::chittie::bridge::swift