react-native-nitro-buffer 0.0.4 → 0.0.11

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.
@@ -0,0 +1,25 @@
1
+ cmake_minimum_required(VERSION 3.10)
2
+ project(NitroBuffer)
3
+
4
+ set(CMAKE_CXX_STANDARD 20)
5
+
6
+ # Add custom implementation and JNI adapter
7
+ add_library(NitroBuffer SHARED
8
+ OnLoad.cpp
9
+ ../cpp/HybridNitroBuffer.cpp
10
+ )
11
+
12
+ # Include paths for our headers
13
+ include_directories(
14
+ ${CMAKE_CURRENT_SOURCE_DIR}/../cpp
15
+ )
16
+
17
+ # Include the Nitrogen-generated CMake file (handles defines, sources, and linking)
18
+ include(${CMAKE_CURRENT_SOURCE_DIR}/../nitrogen/generated/android/NitroBuffer+autolinking.cmake)
19
+
20
+ # Link additional libraries
21
+ find_library(LOG_LIB log)
22
+ target_link_libraries(
23
+ NitroBuffer
24
+ ${LOG_LIB}
25
+ )
@@ -0,0 +1,7 @@
1
+ #include "NitroBufferOnLoad.hpp"
2
+ #include <NitroModules/NitroDefines.hpp>
3
+ #include <jni.h>
4
+
5
+ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
6
+ return margelo::nitro::buffer::initialize(vm);
7
+ }
@@ -0,0 +1,81 @@
1
+ apply plugin: "com.android.library"
2
+ apply plugin: "org.jetbrains.kotlin.android"
3
+
4
+ def reactNativeArchitectures() {
5
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
6
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
7
+ }
8
+
9
+ def getExtOrDefault(name, defaultValue) {
10
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue
11
+ }
12
+
13
+ android {
14
+ namespace "com.margelo.nitro.buffer"
15
+ compileSdkVersion getExtOrDefault("compileSdkVersion", 34)
16
+
17
+ defaultConfig {
18
+ minSdkVersion getExtOrDefault("minSdkVersion", 21)
19
+ targetSdkVersion getExtOrDefault("targetSdkVersion", 34)
20
+
21
+ externalNativeBuild {
22
+ cmake {
23
+ cppFlags "-fexceptions -frtti -std=c++20"
24
+ arguments "-DANDROID_STL=c++_shared"
25
+ abiFilters (*reactNativeArchitectures())
26
+ }
27
+ }
28
+ }
29
+
30
+ buildFeatures {
31
+ buildConfig true
32
+ prefab true
33
+ }
34
+
35
+ externalNativeBuild {
36
+ cmake {
37
+ path "CMakeLists.txt"
38
+ }
39
+ }
40
+
41
+ compileOptions {
42
+ sourceCompatibility JavaVersion.VERSION_17
43
+ targetCompatibility JavaVersion.VERSION_17
44
+ }
45
+
46
+ kotlinOptions {
47
+ jvmTarget = "17"
48
+ }
49
+
50
+ sourceSets {
51
+ main {
52
+ jniLibs.srcDirs += ['libs']
53
+ }
54
+ }
55
+
56
+ packagingOptions {
57
+ excludes = [
58
+ "META-INF",
59
+ "META-INF/**",
60
+ "**/libc++_shared.so",
61
+ "**/libfbjni.so",
62
+ "**/libjsi.so",
63
+ "**/libreactnative.so",
64
+ "**/libreact_nativemodule_core.so",
65
+ "**/libturbomodulejsijni.so",
66
+ "**/libhermes.so",
67
+ "**/libhermes_executor.so"
68
+ ]
69
+ }
70
+ }
71
+
72
+ dependencies {
73
+ // Use project reference for Nitro Modules to ensure autolinking works correctly in this repo
74
+ implementation project(":react-native-nitro-modules")
75
+
76
+ // Use react-android instead of react-native for better compatibility with 0.71+
77
+ implementation "com.facebook.react:react-android"
78
+ }
79
+
80
+ // Apply the Nitrogen-generated Gradle file
81
+ apply from: "../nitrogen/generated/android/NitroBuffer+autolinking.gradle"
@@ -0,0 +1 @@
1
+ NitroBuffer_cmakeVersion=3.22.1
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,36 @@
1
+ package com.margelo.nitro.buffer
2
+
3
+ import com.facebook.react.TurboReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfoProvider
7
+ import com.facebook.react.module.model.ReactModuleInfo
8
+ import java.util.HashMap
9
+
10
+ class NitroBufferPackage : TurboReactPackage() {
11
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
+ return null
13
+ }
14
+
15
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
16
+ return ReactModuleInfoProvider {
17
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
18
+ moduleInfos["NitroBuffer"] = ReactModuleInfo(
19
+ "NitroBuffer",
20
+ "NitroBuffer",
21
+ false, // canOverrideExistingModule
22
+ false, // needsEagerInit
23
+ true, // hasConstants
24
+ false, // isCxxModule
25
+ true // isTurboModule
26
+ )
27
+ moduleInfos
28
+ }
29
+ }
30
+
31
+ companion object {
32
+ init {
33
+ System.loadLibrary("NitroBuffer")
34
+ }
35
+ }
36
+ }
@@ -5,7 +5,7 @@
5
5
  #include <iostream>
6
6
  #include <vector>
7
7
 
8
- namespace margelo::nitro::nitro_buffer {
8
+ namespace margelo::nitro::buffer {
9
9
 
10
10
  static const char base64_chars[] =
11
11
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -702,4 +702,4 @@ void HybridNitroBuffer::fill(const std::shared_ptr<ArrayBuffer> &buffer,
702
702
  memset(data + start, (int)value, actualFill);
703
703
  }
704
704
 
705
- } // namespace margelo::nitro::nitro_buffer
705
+ } // namespace margelo::nitro::buffer
@@ -2,7 +2,7 @@
2
2
  #include "HybridNitroBufferSpec.hpp"
3
3
  #include <NitroModules/ArrayBuffer.hpp>
4
4
 
5
- namespace margelo::nitro::nitro_buffer {
5
+ namespace margelo::nitro::buffer {
6
6
 
7
7
  class HybridNitroBuffer : public HybridNitroBufferSpec {
8
8
  public:
@@ -41,4 +41,4 @@ public:
41
41
  double length) override;
42
42
  };
43
43
 
44
- } // namespace margelo::nitro::nitro_buffer
44
+ } // namespace margelo::nitro::buffer
@@ -17,11 +17,11 @@
17
17
 
18
18
  #include "HybridNitroBuffer.hpp"
19
19
 
20
- namespace margelo::nitro::nitro_buffer {
20
+ namespace margelo::nitro::buffer {
21
21
 
22
22
  int initialize(JavaVM* vm) {
23
23
  using namespace margelo::nitro;
24
- using namespace margelo::nitro::nitro_buffer;
24
+ using namespace margelo::nitro::buffer;
25
25
  using namespace facebook;
26
26
 
27
27
  return facebook::jni::initialize(vm, [] {
@@ -41,4 +41,4 @@ int initialize(JavaVM* vm) {
41
41
  });
42
42
  }
43
43
 
44
- } // namespace margelo::nitro::nitro_buffer
44
+ } // namespace margelo::nitro::buffer
@@ -8,7 +8,7 @@
8
8
  #include <jni.h>
9
9
  #include <NitroModules/NitroDefines.hpp>
10
10
 
11
- namespace margelo::nitro::nitro_buffer {
11
+ namespace margelo::nitro::buffer {
12
12
 
13
13
  /**
14
14
  * Initializes the native (C++) part of NitroBuffer, and autolinks all Hybrid Objects.
@@ -16,10 +16,10 @@ namespace margelo::nitro::nitro_buffer {
16
16
  * Example:
17
17
  * ```cpp (cpp-adapter.cpp)
18
18
  * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
- * return margelo::nitro::nitro_buffer::initialize(vm);
19
+ * return margelo::nitro::buffer::initialize(vm);
20
20
  * }
21
21
  * ```
22
22
  */
23
23
  int initialize(JavaVM* vm);
24
24
 
25
- } // namespace margelo::nitro::nitro_buffer
25
+ } // namespace margelo::nitro::buffer
@@ -5,7 +5,7 @@
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- package com.margelo.nitro.nitro_buffer
8
+ package com.margelo.nitro.buffer
9
9
 
10
10
  import android.util.Log
11
11
 
@@ -52,7 +52,7 @@ def add_nitrogen_files(spec)
52
52
  spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
53
  # Use C++ 20
54
54
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
- # Enables C++ <-> Swift interop (by default it's only C)
55
+ # Enables C++ <-> Swift interop (by default it's only ObjC)
56
56
  "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
57
  # Enables stricter modular headers
58
58
  "DEFINES_MODULE" => "YES",
@@ -10,8 +10,8 @@
10
10
  // Include C++ implementation defined types
11
11
 
12
12
 
13
- namespace margelo::nitro::nitro_buffer::bridge::swift {
13
+ namespace margelo::nitro::buffer::bridge::swift {
14
14
 
15
15
 
16
16
 
17
- } // namespace margelo::nitro::nitro_buffer::bridge::swift
17
+ } // namespace margelo::nitro::buffer::bridge::swift
@@ -20,8 +20,8 @@
20
20
  * Contains specialized versions of C++ templated types so they can be accessed from Swift,
21
21
  * as well as helper functions to interact with those C++ types from Swift.
22
22
  */
23
- namespace margelo::nitro::nitro_buffer::bridge::swift {
23
+ namespace margelo::nitro::buffer::bridge::swift {
24
24
 
25
25
 
26
26
 
27
- } // namespace margelo::nitro::nitro_buffer::bridge::swift
27
+ } // namespace margelo::nitro::buffer::bridge::swift
@@ -19,7 +19,7 @@
19
19
 
20
20
  + (void) load {
21
21
  using namespace margelo::nitro;
22
- using namespace margelo::nitro::nitro_buffer;
22
+ using namespace margelo::nitro::buffer;
23
23
 
24
24
  HybridObjectRegistry::registerHybridObjectConstructor(
25
25
  "NitroBuffer",
@@ -6,7 +6,7 @@
6
6
  ///
7
7
 
8
8
  public final class NitroBufferAutolinking {
9
- public typealias bridge = margelo.nitro.nitro_buffer.bridge.swift
9
+ public typealias bridge = margelo.nitro.buffer.bridge.swift
10
10
 
11
11
 
12
12
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  #include "HybridNitroBufferSpec.hpp"
9
9
 
10
- namespace margelo::nitro::nitro_buffer {
10
+ namespace margelo::nitro::buffer {
11
11
 
12
12
  void HybridNitroBufferSpec::loadHybridMethods() {
13
13
  // load base methods/properties
@@ -29,4 +29,4 @@ namespace margelo::nitro::nitro_buffer {
29
29
  });
30
30
  }
31
31
 
32
- } // namespace margelo::nitro::nitro_buffer
32
+ } // namespace margelo::nitro::buffer
@@ -18,7 +18,7 @@
18
18
  #include <NitroModules/ArrayBuffer.hpp>
19
19
  #include <string>
20
20
 
21
- namespace margelo::nitro::nitro_buffer {
21
+ namespace margelo::nitro::buffer {
22
22
 
23
23
  using namespace margelo::nitro;
24
24
 
@@ -71,4 +71,4 @@ namespace margelo::nitro::nitro_buffer {
71
71
  static constexpr auto TAG = "NitroBuffer";
72
72
  };
73
73
 
74
- } // namespace margelo::nitro::nitro_buffer
74
+ } // namespace margelo::nitro::buffer
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "react-native-nitro-buffer",
3
- "version": "0.0.4",
4
- "description": "Node.js compatible buffer module for React Native",
3
+ "version": "0.0.11",
4
+ "description": "The fastest, 100% Node.js-compatible Buffer implementation for React Native, powered by Nitro Modules and C++.",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
8
+ "react-native": "src/index.ts",
8
9
  "scripts": {
9
- "build": "tsc",
10
+ "build": "npx nitrogen@0.32.0 && tsc",
10
11
  "test": "jest",
11
12
  "prepublishOnly": "npm run build"
12
13
  },
@@ -23,19 +24,17 @@
23
24
  "peerDependencies": {
24
25
  "react": "*",
25
26
  "react-native": "*",
26
- "react-native-nitro-modules": "*"
27
+ "react-native-nitro-modules": "^0.32.0"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@types/jest": "^30.0.0",
30
31
  "@types/node": "^18.19.130",
31
32
  "@types/react": "*",
32
33
  "jest": "^29.0.0",
34
+ "react-native-nitro-modules": "^0.32.0",
33
35
  "ts-jest": "^29.0.0",
34
36
  "typescript": "^5.0.0"
35
37
  },
36
- "dependencies": {
37
- "react-native-nitro-modules": "*"
38
- },
39
38
  "packageManager": "yarn@4.12.0",
40
39
  "files": [
41
40
  "lib/",
@@ -46,4 +45,4 @@
46
45
  "nitrogen/",
47
46
  "*.podspec"
48
47
  ]
49
- }
48
+ }