react-native-nitro-buffer 0.0.13 → 0.0.15
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.
- package/android/CMakeLists.txt +3 -0
- package/cpp/HybridNitroBuffer.cpp +69 -7
- package/lib/Buffer.d.ts +1 -0
- package/lib/Buffer.d.ts.map +1 -0
- package/lib/Buffer.js +3 -7
- package/lib/NitroBuffer.nitro.d.ts +1 -0
- package/lib/NitroBuffer.nitro.d.ts.map +1 -0
- package/lib/NitroBuffer.nitro.js +1 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -28
- package/lib/utils.d.ts +1 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +12 -20
- package/nitrogen/generated/android/NitroBuffer+autolinking.cmake +1 -1
- package/nitrogen/generated/android/NitroBuffer+autolinking.gradle +1 -1
- package/nitrogen/generated/android/NitroBufferOnLoad.cpp +1 -1
- package/nitrogen/generated/android/NitroBufferOnLoad.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/buffer/NitroBufferOnLoad.kt +1 -1
- package/nitrogen/generated/ios/NitroBuffer+autolinking.rb +1 -1
- package/nitrogen/generated/ios/NitroBuffer-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/NitroBuffer-Swift-Cxx-Bridge.hpp +1 -1
- package/nitrogen/generated/ios/NitroBuffer-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/NitroBufferAutolinking.mm +1 -1
- package/nitrogen/generated/ios/NitroBufferAutolinking.swift +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroBufferSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroBufferSpec.hpp +1 -1
- package/package.json +2 -1
package/android/CMakeLists.txt
CHANGED
|
@@ -9,6 +9,9 @@ add_library(NitroBuffer SHARED
|
|
|
9
9
|
../cpp/HybridNitroBuffer.cpp
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
+
# Force both hash styles (sysv and gnu) for Android loader compatibility
|
|
13
|
+
target_link_options(NitroBuffer PRIVATE "-Wl,--hash-style=both")
|
|
14
|
+
|
|
12
15
|
# Include paths for our headers
|
|
13
16
|
include_directories(
|
|
14
17
|
${CMAKE_CURRENT_SOURCE_DIR}/../cpp
|
|
@@ -158,7 +158,7 @@ std::shared_ptr<ArrayBuffer> HybridNitroBuffer::allocUnsafe(double size) {
|
|
|
158
158
|
double HybridNitroBuffer::byteLength(const std::string &string,
|
|
159
159
|
const std::string &encoding) {
|
|
160
160
|
if (encoding == "hex") {
|
|
161
|
-
return string.length() / 2;
|
|
161
|
+
return (double)(string.length() / 2);
|
|
162
162
|
} else if (encoding == "base64") {
|
|
163
163
|
size_t len = string.length();
|
|
164
164
|
if (len == 0)
|
|
@@ -168,10 +168,33 @@ double HybridNitroBuffer::byteLength(const std::string &string,
|
|
|
168
168
|
padding++;
|
|
169
169
|
if (len > 1 && string[len - 2] == '=')
|
|
170
170
|
padding++;
|
|
171
|
-
return (len * 3) / 4 - padding;
|
|
171
|
+
return (double)((len * 3) / 4 - padding);
|
|
172
|
+
} else if (encoding == "binary" || encoding == "latin1") {
|
|
173
|
+
// Each character in the original string (0-255) maps to one byte.
|
|
174
|
+
// The input 'string' is UTF-8 encoded. We count Unicode code points.
|
|
175
|
+
size_t count = 0;
|
|
176
|
+
size_t i = 0;
|
|
177
|
+
size_t len = string.length();
|
|
178
|
+
const char *str = string.c_str();
|
|
179
|
+
while (i < len) {
|
|
180
|
+
unsigned char byte = static_cast<unsigned char>(str[i]);
|
|
181
|
+
if (byte <= 0x7F) {
|
|
182
|
+
i += 1;
|
|
183
|
+
} else if ((byte & 0xE0) == 0xC0) {
|
|
184
|
+
i += 2;
|
|
185
|
+
} else if ((byte & 0xF0) == 0xE0) {
|
|
186
|
+
i += 3;
|
|
187
|
+
} else if ((byte & 0xF8) == 0xF0) {
|
|
188
|
+
i += 4;
|
|
189
|
+
} else {
|
|
190
|
+
i += 1;
|
|
191
|
+
}
|
|
192
|
+
count++;
|
|
193
|
+
}
|
|
194
|
+
return (double)count;
|
|
172
195
|
}
|
|
173
196
|
// utf8 (default)
|
|
174
|
-
return string.length();
|
|
197
|
+
return (double)string.length();
|
|
175
198
|
}
|
|
176
199
|
|
|
177
200
|
double HybridNitroBuffer::write(const std::shared_ptr<ArrayBuffer> &buffer,
|
|
@@ -191,7 +214,7 @@ double HybridNitroBuffer::write(const std::shared_ptr<ArrayBuffer> &buffer,
|
|
|
191
214
|
size_t strLen = string.length();
|
|
192
215
|
size_t actualWrite = std::min(toWrite, strLen);
|
|
193
216
|
memcpy(data + start, string.c_str(), actualWrite);
|
|
194
|
-
return actualWrite;
|
|
217
|
+
return (double)actualWrite;
|
|
195
218
|
} else if (encoding == "hex") {
|
|
196
219
|
size_t strLen = string.length();
|
|
197
220
|
size_t bytesCount = strLen / 2;
|
|
@@ -202,19 +225,58 @@ double HybridNitroBuffer::write(const std::shared_ptr<ArrayBuffer> &buffer,
|
|
|
202
225
|
(unsigned char)strtol(byteString.c_str(), nullptr, 16);
|
|
203
226
|
data[start + i] = byte;
|
|
204
227
|
}
|
|
205
|
-
return actualWrite;
|
|
228
|
+
return (double)actualWrite;
|
|
206
229
|
} else if (encoding == "base64") {
|
|
207
230
|
std::vector<unsigned char> decoded = base64_decode(string);
|
|
208
231
|
size_t actualWrite = std::min(toWrite, decoded.size());
|
|
209
232
|
memcpy(data + start, decoded.data(), actualWrite);
|
|
210
|
-
return actualWrite;
|
|
233
|
+
return (double)actualWrite;
|
|
234
|
+
} else if (encoding == "binary" || encoding == "latin1") {
|
|
235
|
+
// Decode UTF-8 string back to raw bytes (0x00-0xFF)
|
|
236
|
+
size_t written = 0;
|
|
237
|
+
size_t i = 0;
|
|
238
|
+
const char *str = string.c_str();
|
|
239
|
+
size_t utf8Len = string.length();
|
|
240
|
+
|
|
241
|
+
while (i < utf8Len && written < toWrite) {
|
|
242
|
+
unsigned char byte = static_cast<unsigned char>(str[i]);
|
|
243
|
+
uint32_t codePoint = 0;
|
|
244
|
+
size_t seqLen = 0;
|
|
245
|
+
|
|
246
|
+
if (byte <= 0x7F) {
|
|
247
|
+
codePoint = byte;
|
|
248
|
+
seqLen = 1;
|
|
249
|
+
} else if ((byte & 0xE0) == 0xC0 && i + 1 < utf8Len) {
|
|
250
|
+
codePoint = ((byte & 0x1F) << 6) |
|
|
251
|
+
(static_cast<unsigned char>(str[i + 1]) & 0x3F);
|
|
252
|
+
seqLen = 2;
|
|
253
|
+
} else if ((byte & 0xF0) == 0xE0 && i + 2 < utf8Len) {
|
|
254
|
+
codePoint = ((byte & 0x0F) << 12) |
|
|
255
|
+
((static_cast<unsigned char>(str[i + 1]) & 0x3F) << 6) |
|
|
256
|
+
(static_cast<unsigned char>(str[i + 2]) & 0x3F);
|
|
257
|
+
seqLen = 3;
|
|
258
|
+
} else if ((byte & 0xF8) == 0xF0 && i + 3 < utf8Len) {
|
|
259
|
+
codePoint = ((byte & 0x07) << 18) |
|
|
260
|
+
((static_cast<unsigned char>(str[i + 1]) & 0x3F) << 12) |
|
|
261
|
+
((static_cast<unsigned char>(str[i + 2]) & 0x3F) << 6) |
|
|
262
|
+
(static_cast<unsigned char>(str[i + 3]) & 0x3F);
|
|
263
|
+
seqLen = 4;
|
|
264
|
+
} else {
|
|
265
|
+
codePoint = byte;
|
|
266
|
+
seqLen = 1;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
data[start + written++] = static_cast<uint8_t>(codePoint & 0xFF);
|
|
270
|
+
i += seqLen;
|
|
271
|
+
}
|
|
272
|
+
return (double)written;
|
|
211
273
|
}
|
|
212
274
|
|
|
213
275
|
// Fallback utf8
|
|
214
276
|
size_t strLen = string.length();
|
|
215
277
|
size_t actualWrite = std::min(toWrite, strLen);
|
|
216
278
|
memcpy(data + start, string.c_str(), actualWrite);
|
|
217
|
-
return actualWrite;
|
|
279
|
+
return (double)actualWrite;
|
|
218
280
|
}
|
|
219
281
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MAAM;IAKvD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM;IAKxD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM;IAKxD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAoBrE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAoBrE,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAgBtE,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAgBtE,MAAM,IAAI;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;IAO5C,OAAO,IAAI,MAAM;IAgBjB,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAiB5C,MAAM,IAAI,MAAM;IAWhB,MAAM,IAAI,MAAM;IAUhB,MAAM,IAAI,MAAM;IAYhB,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAqBnG"}
|
package/lib/Buffer.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Buffer = void 0;
|
|
4
|
-
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
5
2
|
// Lazily load the native module
|
|
6
3
|
let _native;
|
|
7
4
|
function getNative() {
|
|
8
5
|
if (!_native) {
|
|
9
|
-
_native =
|
|
6
|
+
_native = NitroModules.createHybridObject('NitroBuffer');
|
|
10
7
|
}
|
|
11
8
|
return _native;
|
|
12
9
|
}
|
|
13
|
-
class Buffer extends Uint8Array {
|
|
10
|
+
export class Buffer extends Uint8Array {
|
|
14
11
|
constructor(arg, encodingOrOffset, length) {
|
|
15
12
|
// Handling different constructor arguments roughly
|
|
16
13
|
if (typeof arg === 'number') {
|
|
@@ -664,5 +661,4 @@ class Buffer extends Uint8Array {
|
|
|
664
661
|
return len;
|
|
665
662
|
}
|
|
666
663
|
}
|
|
667
|
-
exports.Buffer = Buffer;
|
|
668
664
|
Buffer.poolSize = 8192;
|
|
@@ -16,3 +16,4 @@ export interface NitroBuffer extends HybridObject<{
|
|
|
16
16
|
lastIndexOfBuffer(buffer: ArrayBuffer, needle: ArrayBuffer, offset: number, length: number): number;
|
|
17
17
|
fillBuffer(buffer: ArrayBuffer, value: ArrayBuffer, offset: number, length: number): void;
|
|
18
18
|
}
|
|
19
|
+
//# sourceMappingURL=NitroBuffer.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroBuffer.nitro.d.ts","sourceRoot":"","sources":["../src/NitroBuffer.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,WAAY,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IAE7E,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;IAChC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;IAGtC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;IACpD,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE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
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,cAAc,SAAS,CAAA;AAEvB,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,UAAU,aAAa,CAAA;AACpC,eAAO,MAAM,gBAAgB,YAAY,CAAA;AAEzC,eAAO,MAAM,SAAS;;;CAGrB,CAAA;AAED,qBAAa,UAAW,SAAQ,UAAU;gBAC1B,IAAI,EAAE,MAAM;CAI3B"}
|
package/lib/index.js
CHANGED
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SlowBuffer = exports.constants = exports.kStringMaxLength = exports.kMaxLength = exports.INSPECT_MAX_BYTES = exports.Buffer = void 0;
|
|
18
|
-
var Buffer_1 = require("./Buffer");
|
|
19
|
-
Object.defineProperty(exports, "Buffer", { enumerable: true, get: function () { return Buffer_1.Buffer; } });
|
|
20
|
-
__exportStar(require("./utils"), exports);
|
|
21
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
22
|
-
exports.kMaxLength = 2147483647;
|
|
23
|
-
exports.kStringMaxLength = 536870888;
|
|
24
|
-
exports.constants = {
|
|
25
|
-
MAX_LENGTH: exports.kMaxLength,
|
|
26
|
-
MAX_STRING_LENGTH: exports.kStringMaxLength
|
|
1
|
+
export { Buffer } from './Buffer';
|
|
2
|
+
export * from './utils';
|
|
3
|
+
export const INSPECT_MAX_BYTES = 50;
|
|
4
|
+
export const kMaxLength = 2147483647;
|
|
5
|
+
export const kStringMaxLength = 536870888;
|
|
6
|
+
export const constants = {
|
|
7
|
+
MAX_LENGTH: kMaxLength,
|
|
8
|
+
MAX_STRING_LENGTH: kStringMaxLength
|
|
27
9
|
};
|
|
28
|
-
class SlowBuffer extends Uint8Array {
|
|
10
|
+
export class SlowBuffer extends Uint8Array {
|
|
29
11
|
constructor(size) {
|
|
30
12
|
super(size);
|
|
31
13
|
Object.setPrototypeOf(this, require('./Buffer').Buffer.prototype);
|
|
32
14
|
}
|
|
33
15
|
}
|
|
34
|
-
exports.SlowBuffer = SlowBuffer;
|
package/lib/utils.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function isAscii(input: Buffer | Uint8Array | ArrayBuffer): boole
|
|
|
5
5
|
export declare function isUtf8(input: Buffer | Uint8Array | ArrayBuffer): boolean;
|
|
6
6
|
export declare function transcode(source: Uint8Array, fromEnc: string, toEnc: string): Buffer;
|
|
7
7
|
export declare function resolveObjectURL(id: string): string | undefined;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzC;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzC;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAMzE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CA0CxE;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAOpF;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG/D"}
|
package/lib/utils.js
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.atob = atob;
|
|
4
|
-
exports.btoa = btoa;
|
|
5
|
-
exports.isAscii = isAscii;
|
|
6
|
-
exports.isUtf8 = isUtf8;
|
|
7
|
-
exports.transcode = transcode;
|
|
8
|
-
exports.resolveObjectURL = resolveObjectURL;
|
|
9
|
-
const Buffer_1 = require("./Buffer");
|
|
10
|
-
function atob(data) {
|
|
1
|
+
import { Buffer } from './Buffer';
|
|
2
|
+
export function atob(data) {
|
|
11
3
|
if (typeof global.atob === 'function') {
|
|
12
4
|
return global.atob(data);
|
|
13
5
|
}
|
|
14
|
-
return
|
|
6
|
+
return Buffer.from(data, 'base64').toString('binary');
|
|
15
7
|
}
|
|
16
|
-
function btoa(data) {
|
|
8
|
+
export function btoa(data) {
|
|
17
9
|
if (typeof global.btoa === 'function') {
|
|
18
10
|
return global.btoa(data);
|
|
19
11
|
}
|
|
20
|
-
return
|
|
12
|
+
return Buffer.from(data, 'binary').toString('base64');
|
|
21
13
|
}
|
|
22
|
-
function isAscii(input) {
|
|
14
|
+
export function isAscii(input) {
|
|
23
15
|
const arr = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
24
16
|
for (let i = 0; i < arr.length; i++) {
|
|
25
17
|
if (arr[i] > 127)
|
|
@@ -27,7 +19,7 @@ function isAscii(input) {
|
|
|
27
19
|
}
|
|
28
20
|
return true;
|
|
29
21
|
}
|
|
30
|
-
function isUtf8(input) {
|
|
22
|
+
export function isUtf8(input) {
|
|
31
23
|
const arr = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
32
24
|
try {
|
|
33
25
|
// Fast path: TextDecoder if available
|
|
@@ -82,15 +74,15 @@ function isUtf8(input) {
|
|
|
82
74
|
}
|
|
83
75
|
return true;
|
|
84
76
|
}
|
|
85
|
-
function transcode(source, fromEnc, toEnc) {
|
|
86
|
-
if (!
|
|
77
|
+
export function transcode(source, fromEnc, toEnc) {
|
|
78
|
+
if (!Buffer.isEncoding(fromEnc) || !Buffer.isEncoding(toEnc)) {
|
|
87
79
|
throw new TypeError('Invalid encoding');
|
|
88
80
|
}
|
|
89
|
-
const buf = source instanceof
|
|
81
|
+
const buf = source instanceof Buffer ? source : Buffer.from(source);
|
|
90
82
|
const str = buf.toString(fromEnc);
|
|
91
|
-
return
|
|
83
|
+
return Buffer.from(str, toEnc);
|
|
92
84
|
}
|
|
93
|
-
function resolveObjectURL(id) {
|
|
85
|
+
export function resolveObjectURL(id) {
|
|
94
86
|
// Not implemented in RN context usually, stub or return undefined
|
|
95
87
|
return undefined;
|
|
96
88
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# NitroBuffer+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a CMake file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroBuffer+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroBufferOnLoad.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_NITROBUFFER_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroBufferOnLoad.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.buffer
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# NitroBuffer+autolinking.rb
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a Ruby script that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroBuffer-Swift-Cxx-Bridge.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "NitroBuffer-Swift-Cxx-Bridge.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroBufferAutolinking.mm
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroBufferAutolinking.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
public final class NitroBufferAutolinking {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridNitroBufferSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridNitroBufferSpec.hpp"
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-buffer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "The fastest, 100% Node.js-compatible Buffer implementation for React Native, powered by Nitro Modules and C++.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"module": "lib/index.js",
|
|
7
8
|
"types": "lib/index.d.ts",
|