@ng-native/desktop 0.25.0 → 0.26.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 (66) hide show
  1. package/native/CMakeLists.txt +47 -4
  2. package/native/appkit/CMakeLists.txt +2 -1
  3. package/native/appkit/cg-canvas.h +5 -0
  4. package/native/appkit/cg-canvas.mm +21 -6
  5. package/native/appkit/desktop-expo.h +6 -0
  6. package/native/appkit/desktop-expo.mm +5 -0
  7. package/native/appkit/host-view.mm +32 -0
  8. package/native/appkit/image-request.h +2 -10
  9. package/native/appkit/image-request.mm +0 -22
  10. package/native/appkit/image-view.mm +94 -6
  11. package/native/appkit/main.mm +130 -185
  12. package/native/appkit/split-view.mm +3 -9
  13. package/native/appkit/system-access.mm +3 -0
  14. package/native/appkit/system.mm +33 -48
  15. package/native/appkit/view-effects.h +27 -0
  16. package/native/appkit/view-effects.mm +90 -0
  17. package/native/cmake/runtime-dependencies.cmake +11 -1
  18. package/native/core/include/ngn/app-info.h +3 -2
  19. package/native/core/include/ngn/app-menus.h +5 -11
  20. package/native/core/include/ngn/default-menu.h +16 -6
  21. package/native/core/include/ngn/desktop-expo.h +0 -5
  22. package/native/core/include/ngn/desktop-modules.h +144 -0
  23. package/native/core/include/ngn/dev-server.h +12 -3
  24. package/native/core/include/ngn/host-os.h +45 -0
  25. package/native/core/include/ngn/host-views.h +25 -0
  26. package/native/core/include/ngn/image-source.h +18 -0
  27. package/native/core/include/ngn/launch-settings.h +9 -7
  28. package/native/core/include/ngn/module-registry.h +2 -0
  29. package/native/core/include/ngn/notifications.h +6 -0
  30. package/native/core/include/ngn/runtime.h +4 -1
  31. package/native/core/include/ngn/spawn-rules.h +3 -2
  32. package/native/core/include/ngn/split-view.h +12 -0
  33. package/native/core/include/ngn/system.h +47 -0
  34. package/native/core/include/ngn/undo.h +27 -0
  35. package/native/core/include/ngn/updates.h +3 -2
  36. package/native/core/include/ngn/view-filter.h +33 -0
  37. package/native/core/src/app-menus.cpp +9 -11
  38. package/native/core/src/default-menu.cpp +6 -2
  39. package/native/core/src/dev-server-helper.cpp +3 -2
  40. package/native/core/src/dev-server.cpp +22 -5
  41. package/native/core/src/host-os.cpp +20 -0
  42. package/native/core/src/host-views.cpp +25 -0
  43. package/native/core/src/image-source.cpp +30 -0
  44. package/native/core/src/launch-settings.cpp +10 -6
  45. package/native/core/src/module-registry.cpp +9 -0
  46. package/native/core/src/modules/app-info.cpp +4 -4
  47. package/native/core/src/modules/desktop-expo.cpp +0 -5
  48. package/native/core/src/modules/desktop-modules.cpp +132 -0
  49. package/native/core/src/modules/notifications.cpp +4 -4
  50. package/native/core/src/runtime.cpp +2 -0
  51. package/native/core/src/spawn-rules.cpp +1 -4
  52. package/native/core/src/split-view.cpp +10 -0
  53. package/native/core/src/system.cpp +52 -0
  54. package/native/core/src/undo-stacks.cpp +71 -0
  55. package/native/core/src/view-filter.cpp +114 -0
  56. package/native/scripts/build-hermes.sh +19 -7
  57. package/native/scripts/build-icu.sh +36 -0
  58. package/native/scripts/build-lock.sh +21 -0
  59. package/native/scripts/build.sh +40 -7
  60. package/native/scripts/fetch.sh +24 -2
  61. package/native/scripts/hermes-built.sh +5 -4
  62. package/native/scripts/hermes-target.sh +18 -0
  63. package/native/scripts/icu-filter.json +22 -0
  64. package/native/shim/openssl/sha.h +108 -3
  65. package/package.json +2 -2
  66. package/prebuilt.json +6 -6
@@ -1,5 +1,6 @@
1
- // The part of OpenSSL's <openssl/sha.h> React Native's DevServerHelper calls, over the system's
2
- // SHA-256 (CommonCrypto on Apple platforms). See cmake/runtime-dependencies.cmake.
1
+ // The part of OpenSSL's <openssl/sha.h> React Native's DevServerHelper calls: over the system's
2
+ // SHA-256 on Apple platforms (CommonCrypto), and elsewhere a portable SHA-256 (FIPS 180-4), since
3
+ // one device-id hash is no reason to link a crypto library. See cmake/runtime-dependencies.cmake.
3
4
  #pragma once
4
5
 
5
6
  #if defined(__APPLE__)
@@ -18,5 +19,109 @@ inline int SHA256_Final(unsigned char *digest, SHA256_CTX *context) {
18
19
  return CC_SHA256_Final(digest, context);
19
20
  }
20
21
  #else
21
- #error "No SHA-256 shim for this OS yet: the desktop host's runtime builds on macOS only."
22
+ #include <cstddef>
23
+ #include <cstdint>
24
+ #include <cstring>
25
+
26
+ #define SHA256_DIGEST_LENGTH 32
27
+
28
+ struct SHA256_CTX {
29
+ uint32_t state[8];
30
+ uint64_t length; // in bytes
31
+ unsigned char block[64];
32
+ size_t used;
33
+ };
34
+
35
+ namespace ngn::sha256 {
36
+
37
+ inline uint32_t rotr(uint32_t x, int n) {
38
+ return (x >> n) | (x << (32 - n));
39
+ }
40
+
41
+ inline void compress(uint32_t state[8], const unsigned char *block) {
42
+ static constexpr uint32_t k[64] = {
43
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
44
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
45
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
46
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
47
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
48
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
49
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
50
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
51
+ uint32_t w[64];
52
+ for (int i = 0; i < 16; i++) {
53
+ w[i] = (uint32_t(block[4 * i]) << 24) | (uint32_t(block[4 * i + 1]) << 16) |
54
+ (uint32_t(block[4 * i + 2]) << 8) | uint32_t(block[4 * i + 3]);
55
+ }
56
+ for (int i = 16; i < 64; i++) {
57
+ uint32_t s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >> 3);
58
+ uint32_t s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >> 10);
59
+ w[i] = w[i - 16] + s0 + w[i - 7] + s1;
60
+ }
61
+ uint32_t v[8];
62
+ std::memcpy(v, state, sizeof v);
63
+ for (int i = 0; i < 64; i++) {
64
+ uint32_t t1 = v[7] + (rotr(v[4], 6) ^ rotr(v[4], 11) ^ rotr(v[4], 25)) +
65
+ ((v[4] & v[5]) ^ (~v[4] & v[6])) + k[i] + w[i];
66
+ uint32_t t2 = (rotr(v[0], 2) ^ rotr(v[0], 13) ^ rotr(v[0], 22)) +
67
+ ((v[0] & v[1]) ^ (v[0] & v[2]) ^ (v[1] & v[2]));
68
+ std::memmove(v + 1, v, 7 * sizeof v[0]);
69
+ v[4] += t1;
70
+ v[0] = t1 + t2;
71
+ }
72
+ for (int i = 0; i < 8; i++) {
73
+ state[i] += v[i];
74
+ }
75
+ }
76
+
77
+ } // namespace ngn::sha256
78
+
79
+ inline int SHA256_Init(SHA256_CTX *context) {
80
+ static constexpr uint32_t initial[8] = {
81
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
82
+ std::memcpy(context->state, initial, sizeof initial);
83
+ context->length = 0;
84
+ context->used = 0;
85
+ return 1;
86
+ }
87
+
88
+ inline int SHA256_Update(SHA256_CTX *context, const void *data, size_t length) {
89
+ auto bytes = static_cast<const unsigned char *>(data);
90
+ context->length += length;
91
+ while (length > 0) {
92
+ size_t n = sizeof context->block - context->used;
93
+ if (n > length) {
94
+ n = length;
95
+ }
96
+ std::memcpy(context->block + context->used, bytes, n);
97
+ context->used += n;
98
+ bytes += n;
99
+ length -= n;
100
+ if (context->used == sizeof context->block) {
101
+ ngn::sha256::compress(context->state, context->block);
102
+ context->used = 0;
103
+ }
104
+ }
105
+ return 1;
106
+ }
107
+
108
+ inline int SHA256_Final(unsigned char *digest, SHA256_CTX *context) {
109
+ uint64_t bits = context->length * 8;
110
+ // A 1 bit, zeros up to 8 bytes short of a block, then the message's length in bits, big-endian.
111
+ static constexpr unsigned char padding[64] = {0x80};
112
+ size_t pad = context->used < 56 ? 56 - context->used : 120 - context->used;
113
+ SHA256_Update(context, padding, pad);
114
+ unsigned char length[8];
115
+ for (int i = 0; i < 8; i++) {
116
+ length[i] = static_cast<unsigned char>(bits >> (56 - 8 * i));
117
+ }
118
+ SHA256_Update(context, length, sizeof length);
119
+ for (int i = 0; i < 8; i++) {
120
+ digest[4 * i] = static_cast<unsigned char>(context->state[i] >> 24);
121
+ digest[4 * i + 1] = static_cast<unsigned char>(context->state[i] >> 16);
122
+ digest[4 * i + 2] = static_cast<unsigned char>(context->state[i] >> 8);
123
+ digest[4 * i + 3] = static_cast<unsigned char>(context->state[i]);
124
+ }
125
+ return 1;
126
+ }
22
127
  #endif
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/desktop",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "The macOS desktop host for Angular Native: React Native's C++ core and Hermes, mounting into AppKit views, and the ng-native-desktop command that builds and launches it.",
5
5
  "keywords": [
6
6
  "angular",
@@ -16,7 +16,7 @@
16
16
  "ng-native-desktop": "./bin/ng-native-desktop.mjs"
17
17
  },
18
18
  "dependencies": {
19
- "@ng-native/device": "0.25.0"
19
+ "@ng-native/device": "0.26.0"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react-native": "~0.88.0"
package/prebuilt.json CHANGED
@@ -4,8 +4,8 @@
4
4
  {
5
5
  "reactNative": "0.88.0",
6
6
  "flavour": "debug",
7
- "url": "https://github.com/ng-native/ng-native/releases/download/v0.25.0/ng-native-desktop-host-0.25.0-rn-0.88.0-macos-universal-debug.tar.gz",
8
- "sha256": "ed27065ecb02b16a533ae73ad894e1ef398ee88219ed72cc441e223de6a46022",
7
+ "url": "https://github.com/ng-native/ng-native/releases/download/v0.26.0/ng-native-desktop-host-0.26.0-rn-0.88.0-macos-universal-debug.tar.gz",
8
+ "sha256": "ff2af29a2d7046f7d5d0e4176c3f9c8e2be05e2bda57ea15c29cede2c0b494de",
9
9
  "libraries": {
10
10
  "react-native-screens": "4.30.0",
11
11
  "react-native-safe-area-context": "5.10.1",
@@ -13,13 +13,13 @@
13
13
  "react-native-worklets": "0.13.0",
14
14
  "react-native-reanimated": "4.7.1"
15
15
  },
16
- "inputs": "f891f249fcb9d7dea347f359361aefac1ff8b381aa2c216274f40c0e00942749"
16
+ "inputs": "a511221639ad9e0f0ce29a96aa32839dd251f5cfae6f74e8c8cf819ce25898c9"
17
17
  },
18
18
  {
19
19
  "reactNative": "0.88.0",
20
20
  "flavour": "release",
21
- "url": "https://github.com/ng-native/ng-native/releases/download/v0.25.0/ng-native-desktop-host-0.25.0-rn-0.88.0-macos-universal.tar.gz",
22
- "sha256": "bc1fd2540661e89eaf8f346522d197909c35f55d237bde52c0ab76bceab6cae9",
21
+ "url": "https://github.com/ng-native/ng-native/releases/download/v0.26.0/ng-native-desktop-host-0.26.0-rn-0.88.0-macos-universal.tar.gz",
22
+ "sha256": "ade1562cdc5409e4099eb38640f8d52b20be7254d115e2d069896d2f2d78f518",
23
23
  "libraries": {
24
24
  "react-native-screens": "4.30.0",
25
25
  "react-native-safe-area-context": "5.10.1",
@@ -27,7 +27,7 @@
27
27
  "react-native-worklets": "0.13.0",
28
28
  "react-native-reanimated": "4.7.1"
29
29
  },
30
- "inputs": "8176fcd27ee569b08a235f090a03d5de22625039cf48e904245b5248316abe4a"
30
+ "inputs": "689a371456085b1c3a8af2c7ab254db1db115e13063f1d0b81da6c6e23908080"
31
31
  }
32
32
  ]
33
33
  }