bare-buffer 2.5.9 → 2.5.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.
Files changed (55) hide show
  1. package/CMakeLists.txt +4 -11
  2. package/package.json +3 -8
  3. package/prebuilds/android-arm/bare-buffer.bare +0 -0
  4. package/prebuilds/android-arm64/bare-buffer.bare +0 -0
  5. package/prebuilds/android-ia32/bare-buffer.bare +0 -0
  6. package/prebuilds/android-x64/bare-buffer.bare +0 -0
  7. package/prebuilds/darwin-arm64/bare-buffer.bare +0 -0
  8. package/prebuilds/darwin-x64/bare-buffer.bare +0 -0
  9. package/prebuilds/ios-arm64/bare-buffer.bare +0 -0
  10. package/prebuilds/ios-arm64-simulator/bare-buffer.bare +0 -0
  11. package/prebuilds/ios-x64-simulator/bare-buffer.bare +0 -0
  12. package/prebuilds/linux-arm64/bare-buffer.bare +0 -0
  13. package/prebuilds/linux-x64/bare-buffer.bare +0 -0
  14. package/prebuilds/win32-arm64/bare-buffer.bare +0 -0
  15. package/prebuilds/win32-x64/bare-buffer.bare +0 -0
  16. package/vendor/libbase64/CMakeLists.txt +0 -70
  17. package/vendor/libbase64/include/base64.h +0 -22
  18. package/vendor/libbase64/src/base64.c +0 -107
  19. package/vendor/libhex/CMakeLists.txt +0 -71
  20. package/vendor/libhex/include/hex.h +0 -22
  21. package/vendor/libhex/src/hex.c +0 -67
  22. package/vendor/libutf/CMakeLists.txt +0 -93
  23. package/vendor/libutf/include/utf/string.h +0 -786
  24. package/vendor/libutf/include/utf.h +0 -132
  25. package/vendor/libutf/src/ascii/validate.c +0 -47
  26. package/vendor/libutf/src/endianness.c +0 -19
  27. package/vendor/libutf/src/endianness.h +0 -54
  28. package/vendor/libutf/src/latin1/convert-to-utf16.c +0 -37
  29. package/vendor/libutf/src/latin1/convert-to-utf32.c +0 -34
  30. package/vendor/libutf/src/latin1/convert-to-utf8.c +0 -58
  31. package/vendor/libutf/src/latin1/length-from-utf16.c +0 -26
  32. package/vendor/libutf/src/latin1/length-from-utf32.c +0 -26
  33. package/vendor/libutf/src/latin1/length-from-utf8.c +0 -34
  34. package/vendor/libutf/src/utf16/convert-to-latin1.c +0 -41
  35. package/vendor/libutf/src/utf16/convert-to-utf32.c +0 -56
  36. package/vendor/libutf/src/utf16/convert-to-utf8.c +0 -75
  37. package/vendor/libutf/src/utf16/length-from-latin1.c +0 -26
  38. package/vendor/libutf/src/utf16/length-from-utf32.c +0 -33
  39. package/vendor/libutf/src/utf16/length-from-utf8.c +0 -38
  40. package/vendor/libutf/src/utf16/validate.c +0 -53
  41. package/vendor/libutf/src/utf32/convert-to-latin1.c +0 -40
  42. package/vendor/libutf/src/utf32/convert-to-utf16.c +0 -56
  43. package/vendor/libutf/src/utf32/convert-to-utf8.c +0 -71
  44. package/vendor/libutf/src/utf32/length-from-latin1.c +0 -26
  45. package/vendor/libutf/src/utf32/length-from-utf16.c +0 -35
  46. package/vendor/libutf/src/utf32/length-from-utf8.c +0 -35
  47. package/vendor/libutf/src/utf32/validate.c +0 -39
  48. package/vendor/libutf/src/utf8/convert-to-latin1.c +0 -70
  49. package/vendor/libutf/src/utf8/convert-to-utf16.c +0 -95
  50. package/vendor/libutf/src/utf8/convert-to-utf32.c +0 -110
  51. package/vendor/libutf/src/utf8/length-from-latin1.c +0 -32
  52. package/vendor/libutf/src/utf8/length-from-utf16.c +0 -44
  53. package/vendor/libutf/src/utf8/length-from-utf32.c +0 -35
  54. package/vendor/libutf/src/utf8/string.c +0 -149
  55. package/vendor/libutf/src/utf8/validate.c +0 -107
package/CMakeLists.txt CHANGED
@@ -1,20 +1,13 @@
1
1
  cmake_minimum_required(VERSION 3.25)
2
2
 
3
3
  find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare)
4
+ find_package(cmake-fetch REQUIRED PATHS node_modules/cmake-fetch)
4
5
 
5
6
  project(bare_buffer C)
6
7
 
7
- if(NOT TARGET utf)
8
- add_subdirectory(vendor/libutf EXCLUDE_FROM_ALL)
9
- endif()
10
-
11
- if(NOT TARGET base64)
12
- add_subdirectory(vendor/libbase64 EXCLUDE_FROM_ALL)
13
- endif()
14
-
15
- if(NOT TARGET hex)
16
- add_subdirectory(vendor/libhex EXCLUDE_FROM_ALL)
17
- endif()
8
+ fetch_package("github:holepunchto/libutf#65b6ba0")
9
+ fetch_package("github:holepunchto/libbase64#4cd8d8b")
10
+ fetch_package("github:holepunchto/libhex#939999b")
18
11
 
19
12
  add_bare_module(bare_buffer)
20
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-buffer",
3
- "version": "2.5.9",
3
+ "version": "2.5.11",
4
4
  "description": "Native buffers for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -13,13 +13,7 @@
13
13
  "binding.js",
14
14
  "CMakeLists.txt",
15
15
  "lib",
16
- "prebuilds",
17
- "vendor/libbase64/include",
18
- "vendor/libbase64/src",
19
- "vendor/libhex/include",
20
- "vendor/libhex/src",
21
- "vendor/libutf/include",
22
- "vendor/libutf/src"
16
+ "prebuilds"
23
17
  ],
24
18
  "addon": true,
25
19
  "scripts": {
@@ -38,6 +32,7 @@
38
32
  "devDependencies": {
39
33
  "brittle": "^3.1.1",
40
34
  "cmake-bare": "^1.1.6",
35
+ "cmake-fetch": "^1.0.0",
41
36
  "standard": "^17.0.0"
42
37
  }
43
38
  }
@@ -1,70 +0,0 @@
1
- cmake_minimum_required(VERSION 3.22)
2
-
3
- project(base64 C)
4
-
5
- if(NOT TARGET utf)
6
- add_subdirectory(vendor/libutf EXCLUDE_FROM_ALL)
7
- endif()
8
-
9
- add_library(base64 OBJECT)
10
-
11
- set_target_properties(
12
- base64
13
- PROPERTIES
14
- C_STANDARD 99
15
- POSITION_INDEPENDENT_CODE ON
16
- )
17
-
18
- target_sources(
19
- base64
20
- INTERFACE
21
- include/base64.h
22
- PRIVATE
23
- src/base64.c
24
- )
25
-
26
- target_include_directories(
27
- base64
28
- PUBLIC
29
- include
30
- $<TARGET_PROPERTY:utf,INTERFACE_INCLUDE_DIRECTORIES>
31
- )
32
-
33
- add_library(base64_shared SHARED)
34
-
35
- set_target_properties(
36
- base64_shared
37
- PROPERTIES
38
- OUTPUT_NAME base64
39
- WINDOWS_EXPORT_ALL_SYMBOLS ON
40
- )
41
-
42
- target_link_libraries(
43
- base64_shared
44
- PUBLIC
45
- base64
46
- )
47
-
48
- add_library(base64_static STATIC)
49
-
50
- set_target_properties(
51
- base64_static
52
- PROPERTIES
53
- OUTPUT_NAME base64
54
- PREFIX lib
55
- )
56
-
57
- target_link_libraries(
58
- base64_static
59
- PUBLIC
60
- base64
61
- )
62
-
63
- install(TARGETS base64_shared base64_static)
64
-
65
- install(FILES include/base64.h DESTINATION include)
66
-
67
- if(PROJECT_IS_TOP_LEVEL)
68
- enable_testing()
69
- add_subdirectory(test)
70
- endif()
@@ -1,22 +0,0 @@
1
- #ifndef BASE64_H
2
- #define BASE64_H
3
-
4
- #include <stddef.h>
5
- #include <stdint.h>
6
- #include <utf.h>
7
-
8
- #ifdef __cplusplus
9
- extern "C" {
10
- #endif
11
-
12
- int
13
- base64_encode (const uint8_t *buffer, size_t buffer_len, utf8_t *string, size_t *string_len);
14
-
15
- int
16
- base64_decode (const utf8_t *string, size_t string_len, uint8_t *buffer, size_t *buffer_len);
17
-
18
- #ifdef __cplusplus
19
- }
20
- #endif
21
-
22
- #endif // BASE64_H
@@ -1,107 +0,0 @@
1
- #include <stdbool.h>
2
- #include <stddef.h>
3
- #include <stdint.h>
4
- #include <utf.h>
5
-
6
- #include "../include/base64.h"
7
-
8
- static const char base64_alphabet[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
9
-
10
- static const char base64_inverse_alphabet[256] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
11
-
12
- int
13
- base64_encode (const uint8_t *buffer, size_t buffer_len, utf8_t *string, size_t *string_len) {
14
- size_t len = 4 * ((buffer_len + 2) / 3);
15
-
16
- if (string == NULL) {
17
- *string_len = len;
18
- return 0;
19
- }
20
-
21
- if (*string_len < len) return -1;
22
-
23
- bool terminate = *string_len > len;
24
-
25
- *string_len = len;
26
-
27
- size_t k = 0, i = 0, n = buffer_len;
28
-
29
- uint8_t a, b, c;
30
-
31
- for (; i + 2 < n; i += 3) {
32
- a = buffer[i];
33
- b = buffer[i + 1];
34
- c = buffer[i + 2];
35
-
36
- string[k++] = base64_alphabet[a >> 2];
37
- string[k++] = base64_alphabet[((a & 0x03) << 4) | (b >> 4)];
38
- string[k++] = base64_alphabet[((b & 0x0f) << 2) | (c >> 6)];
39
- string[k++] = base64_alphabet[c & 0x3f];
40
- }
41
-
42
- if (i < n) {
43
- a = buffer[i];
44
-
45
- string[k++] = base64_alphabet[a >> 2];
46
-
47
- if (i + 1 < n) {
48
- b = buffer[i + 1];
49
-
50
- string[k++] = base64_alphabet[((a & 0x03) << 4) | (b >> 4)];
51
- string[k++] = base64_alphabet[(b & 0x0f) << 2];
52
- } else {
53
- string[k++] = base64_alphabet[(a & 0x03) << 4];
54
- string[k++] = '=';
55
- }
56
-
57
- string[k++] = '=';
58
- }
59
-
60
- if (terminate) string[k] = '\0';
61
-
62
- return 0;
63
- }
64
-
65
- int
66
- base64_decode (const utf8_t *string, size_t string_len, uint8_t *buffer, size_t *buffer_len) {
67
- if (string_len % 4 != 0) return -1;
68
-
69
- if (string_len == 0) {
70
- *buffer_len = 0;
71
- return 0;
72
- }
73
-
74
- size_t len = string_len / 4 * 3;
75
-
76
- if (string[string_len - 1] == '=') len--;
77
- if (string[string_len - 2] == '=') len--;
78
-
79
- if (buffer == NULL) {
80
- *buffer_len = len;
81
- return 0;
82
- }
83
-
84
- if (*buffer_len < len) return -1;
85
-
86
- *buffer_len = len;
87
-
88
- size_t k = 0;
89
-
90
- for (size_t i = 0, n = string_len; i < n; i += 4) {
91
- char chunk[4];
92
-
93
- for (size_t j = 0; j < 4; j++) {
94
- chunk[j] = string[i + j] == '=' ? 0 : base64_inverse_alphabet[string[i + j]];
95
-
96
- if (chunk[j] == (char) -1) return -1;
97
- }
98
-
99
- uint32_t triple = (chunk[0] << 3 * 6) + (chunk[1] << 2 * 6) + (chunk[2] << 1 * 6) + (chunk[3] << 0 * 6);
100
-
101
- if (k < len) buffer[k++] = (triple >> 2 * 8) & 0xFF;
102
- if (k < len) buffer[k++] = (triple >> 1 * 8) & 0xFF;
103
- if (k < len) buffer[k++] = (triple >> 0 * 8) & 0xFF;
104
- }
105
-
106
- return 0;
107
- }
@@ -1,71 +0,0 @@
1
- cmake_minimum_required(VERSION 3.22)
2
-
3
- project(hex C)
4
-
5
- if(NOT TARGET utf)
6
- add_subdirectory(vendor/libutf EXCLUDE_FROM_ALL)
7
- endif()
8
-
9
- add_library(hex OBJECT)
10
-
11
- set_target_properties(
12
- hex
13
- PROPERTIES
14
- C_STANDARD 99
15
- POSITION_INDEPENDENT_CODE ON
16
- )
17
-
18
- target_sources(
19
- hex
20
- INTERFACE
21
- include/hex.h
22
- PRIVATE
23
- src/hex.c
24
- )
25
-
26
- target_include_directories(
27
- hex
28
- PUBLIC
29
- include
30
- $<TARGET_PROPERTY:utf,INTERFACE_INCLUDE_DIRECTORIES>
31
- )
32
-
33
- add_library(hex_shared SHARED)
34
-
35
- set_target_properties(
36
- hex_shared
37
- PROPERTIES
38
- OUTPUT_NAME hex
39
- WINDOWS_EXPORT_ALL_SYMBOLS ON
40
- )
41
-
42
- target_link_libraries(
43
- hex_shared
44
- PUBLIC
45
- hex
46
- )
47
-
48
- add_library(hex_static STATIC)
49
-
50
- set_target_properties(
51
- hex_static
52
- PROPERTIES
53
- OUTPUT_NAME hex
54
- PREFIX lib
55
- )
56
-
57
- target_link_libraries(
58
- hex_static
59
- PUBLIC
60
- hex
61
- )
62
-
63
- install(TARGETS hex_shared hex_static)
64
-
65
- install(FILES include/hex.h DESTINATION include)
66
-
67
- if(PROJECT_IS_TOP_LEVEL)
68
- enable_testing()
69
-
70
- add_subdirectory(test)
71
- endif()
@@ -1,22 +0,0 @@
1
- #ifndef HEX_H
2
- #define HEX_H
3
-
4
- #include <stddef.h>
5
- #include <stdint.h>
6
- #include <utf.h>
7
-
8
- #ifdef __cplusplus
9
- extern "C" {
10
- #endif
11
-
12
- int
13
- hex_encode (const uint8_t *buffer, size_t buffer_len, utf8_t *string, size_t *string_len);
14
-
15
- int
16
- hex_decode (const utf8_t *string, size_t string_len, uint8_t *buffer, size_t *buffer_len);
17
-
18
- #ifdef __cplusplus
19
- }
20
- #endif
21
-
22
- #endif // HEX_H
@@ -1,67 +0,0 @@
1
- #include <stdbool.h>
2
- #include <stddef.h>
3
- #include <stdint.h>
4
- #include <utf.h>
5
-
6
- #include "../include/hex.h"
7
-
8
- static const char hex_alphabet[16] = "0123456789abcdef";
9
-
10
- static const char hex_inverse_alphabet[256] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
11
-
12
- int
13
- hex_encode (const uint8_t *buffer, size_t buffer_len, utf8_t *string, size_t *string_len) {
14
- size_t len = buffer_len * 2;
15
-
16
- if (string == NULL) {
17
- *string_len = len;
18
- return 0;
19
- }
20
-
21
- if (*string_len < len) return -1;
22
-
23
- bool terminate = *string_len > len;
24
-
25
- *string_len = len;
26
-
27
- size_t k = 0;
28
-
29
- for (size_t i = 0, n = buffer_len; i < n; i++) {
30
- string[k++] = hex_alphabet[buffer[i] >> 4];
31
- string[k++] = hex_alphabet[buffer[i] & 0x0f];
32
- }
33
-
34
- if (terminate) string[k] = '\0';
35
-
36
- return 0;
37
- }
38
-
39
- int
40
- hex_decode (const utf8_t *string, size_t string_len, uint8_t *buffer, size_t *buffer_len) {
41
- size_t len = string_len >> 1;
42
-
43
- if (buffer == NULL) {
44
- *buffer_len = len;
45
- return 0;
46
- }
47
-
48
- if (*buffer_len < len) return -1;
49
-
50
- *buffer_len = len;
51
-
52
- size_t k = 0;
53
-
54
- for (size_t i = 0, n = string_len; i < n; i += 2) {
55
- char chunk[2];
56
-
57
- for (size_t j = 0; j < 2; j++) {
58
- chunk[j] = i + j < n ? hex_inverse_alphabet[string[i + j]] : 0;
59
-
60
- if (chunk[j] == (char) -1) return -1;
61
- }
62
-
63
- buffer[k++] = (chunk[0] << 4) | chunk[1];
64
- }
65
-
66
- return 0;
67
- }
@@ -1,93 +0,0 @@
1
- cmake_minimum_required(VERSION 3.25)
2
-
3
- project(utf C)
4
-
5
- add_library(utf OBJECT)
6
-
7
- set_target_properties(
8
- utf
9
- PROPERTIES
10
- C_STANDARD 99
11
- POSITION_INDEPENDENT_CODE ON
12
- )
13
-
14
- target_sources(
15
- utf
16
- INTERFACE
17
- include/utf.h
18
- include/utf/string.h
19
- PRIVATE
20
- src/endianness.c
21
- src/endianness.h
22
- src/ascii/validate.c
23
- src/utf8/convert-to-latin1.c
24
- src/utf8/convert-to-utf16.c
25
- src/utf8/convert-to-utf32.c
26
- src/utf8/length-from-latin1.c
27
- src/utf8/length-from-utf16.c
28
- src/utf8/length-from-utf32.c
29
- src/utf8/string.c
30
- src/utf8/validate.c
31
- src/utf16/convert-to-latin1.c
32
- src/utf16/convert-to-utf8.c
33
- src/utf16/convert-to-utf32.c
34
- src/utf16/length-from-latin1.c
35
- src/utf16/length-from-utf8.c
36
- src/utf16/length-from-utf32.c
37
- src/utf16/validate.c
38
- src/utf32/convert-to-latin1.c
39
- src/utf32/convert-to-utf8.c
40
- src/utf32/convert-to-utf16.c
41
- src/utf32/length-from-latin1.c
42
- src/utf32/length-from-utf8.c
43
- src/utf32/length-from-utf16.c
44
- src/utf32/validate.c
45
- )
46
-
47
- target_include_directories(
48
- utf
49
- PUBLIC
50
- include
51
- )
52
-
53
- add_library(utf_shared SHARED)
54
-
55
- set_target_properties(
56
- utf_shared
57
- PROPERTIES
58
- OUTPUT_NAME utf
59
- WINDOWS_EXPORT_ALL_SYMBOLS ON
60
- )
61
-
62
- target_link_libraries(
63
- utf_shared
64
- PUBLIC
65
- utf
66
- )
67
-
68
- add_library(utf_static STATIC)
69
-
70
- set_target_properties(
71
- utf_static
72
- PROPERTIES
73
- OUTPUT_NAME utf
74
- PREFIX lib
75
- )
76
-
77
- target_link_libraries(
78
- utf_static
79
- PUBLIC
80
- utf
81
- )
82
-
83
- install(TARGETS utf_shared utf_static)
84
-
85
- install(FILES include/utf.h DESTINATION include)
86
-
87
- install(DIRECTORY include/utf DESTINATION include)
88
-
89
- if(PROJECT_IS_TOP_LEVEL)
90
- enable_testing()
91
-
92
- add_subdirectory(test)
93
- endif()