peachsim 0.1.1674 → 0.1.1684

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 (190) hide show
  1. package/cli/commands/control.ts +13 -1
  2. package/cli/commands/coverage-swift.ts +83 -27
  3. package/cli/commands/coverage.ts +219 -20
  4. package/cli/commands/detect.ts +10 -6
  5. package/cli/commands/inspect/core.ts +2 -0
  6. package/cli/commands/inspect/wait-ready.ts +7 -0
  7. package/cli/outbound-endpoints.ts +12 -0
  8. package/detox/index.ts +11 -1
  9. package/detox/jest-environment.cjs +14 -0
  10. package/dist-lib/agent-daemon-client.cjs +1 -1
  11. package/dist-lib/agent-events.cjs +1 -1
  12. package/dist-lib/attached-projects.cjs +1 -1
  13. package/dist-lib/auth/shared-session.cjs +1 -1
  14. package/dist-lib/backend-origin.cjs +1 -1
  15. package/dist-lib/beta.cjs +1 -1
  16. package/dist-lib/beta.mjs +1 -1
  17. package/dist-lib/bridge-constants.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.mjs +1 -1
  20. package/dist-lib/bridge-contract.cjs +1 -1
  21. package/dist-lib/bridge-contract.mjs +1 -1
  22. package/dist-lib/bundle-channel.cjs +3274 -1663
  23. package/dist-lib/capture-contract.cjs +1 -1
  24. package/dist-lib/capture-contract.mjs +1 -1
  25. package/dist-lib/cloud-contract.cjs +1 -1
  26. package/dist-lib/cloud-contract.mjs +1 -1
  27. package/dist-lib/cloud-test-args.cjs +1 -1
  28. package/dist-lib/cloud-test-args.mjs +1 -1
  29. package/dist-lib/cloud.cjs +1 -1
  30. package/dist-lib/cloud.mjs +1 -1
  31. package/dist-lib/config.cjs +1 -1
  32. package/dist-lib/config.mjs +1 -1
  33. package/dist-lib/detox/index.cjs +6 -4
  34. package/dist-lib/detox/jest-environment.cjs +14 -0
  35. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  36. package/dist-lib/expo-swift-bundle.cjs +2407 -1126
  37. package/dist-lib/expo-swift-metadata.cjs +1 -1
  38. package/dist-lib/expo-swift-metadata.mjs +1 -1
  39. package/dist-lib/home-paths.cjs +1 -1
  40. package/dist-lib/host/bridge-host.cjs +2879 -1598
  41. package/dist-lib/host/fetch-proxy-handler.cjs +18 -5
  42. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  43. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  44. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  45. package/dist-lib/host/websocket-proxy.cjs +1 -1
  46. package/dist-lib/index.cjs +1904 -741
  47. package/dist-lib/jump-to-source-babel.cjs +1 -1
  48. package/dist-lib/jump-to-source-native.cjs +1 -1
  49. package/dist-lib/kotlin-host.cjs +1 -1
  50. package/dist-lib/menu.cjs +1 -1
  51. package/dist-lib/menu.mjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  54. package/dist-lib/metro-production-bundle.cjs +1 -1
  55. package/dist-lib/metro-production-bundle.mjs +1 -1
  56. package/dist-lib/metro.cjs +6215 -4283
  57. package/dist-lib/native-app-identity-project.cjs +31 -6
  58. package/dist-lib/native-app-identity-project.mjs +31 -6
  59. package/dist-lib/native-app-identity.cjs +1 -1
  60. package/dist-lib/native-app-identity.mjs +1 -1
  61. package/dist-lib/native-firebase-metadata.cjs +1 -1
  62. package/dist-lib/native-firebase-metadata.mjs +1 -1
  63. package/dist-lib/plist.cjs +1 -1
  64. package/dist-lib/plist.mjs +1 -1
  65. package/dist-lib/profiles.cjs +1 -1
  66. package/dist-lib/public-brand.cjs +1 -1
  67. package/dist-lib/public-origins-lib-esm.json +24 -23
  68. package/dist-lib/public-origins-lib-static.json +1 -1
  69. package/dist-lib/public-origins-lib.json +134 -78
  70. package/dist-lib/react-native-host-modules.cjs +1 -1
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/reap-browser.cjs +2 -2
  73. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  74. package/dist-lib/sdk.cjs +2 -1
  75. package/dist-lib/sdk.mjs +2 -1
  76. package/dist-lib/skills.cjs +3570 -2160
  77. package/dist-lib/swift-compile.cjs +473 -351
  78. package/dist-lib/swift-compile.mjs +471 -349
  79. package/dist-lib/swift-package.cjs +36 -6
  80. package/dist-lib/swift-package.mjs +35 -6
  81. package/dist-lib/swift-submit.cjs +1 -1
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift-toolchain.cjs +26 -11
  84. package/dist-lib/swift.cjs +1 -1
  85. package/dist-lib/vite-swift.cjs +2418 -1132
  86. package/dist-lib/vite.cjs +1907 -766
  87. package/dist-lib/worklet-executable.cjs +1 -1
  88. package/dist-lib/worklet-executable.mjs +1 -1
  89. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
  90. package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +9 -1
  91. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
  92. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
  93. package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +2 -0
  94. package/package.json +1 -1
  95. package/runtime-companion.json +1 -1
  96. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +51 -2
  97. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +21 -0
  98. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
  99. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
  100. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
  101. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
  102. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
  103. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
  104. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
  105. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
  106. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
  107. package/sdk/ios/usr/include/arm/param.h +151 -0
  108. package/sdk/ios/usr/include/dispatch/dispatch.h +3 -0
  109. package/sdk/ios/usr/include/dlfcn.h +1 -2
  110. package/sdk/ios/usr/include/machine/param.h +42 -0
  111. package/sdk/ios/usr/include/net/if.h +1 -2
  112. package/sdk/ios/usr/include/peach/pthread.h +4 -4
  113. package/sdk/ios/usr/include/pthread/qos.h +304 -0
  114. package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
  115. package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
  116. package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
  117. package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
  118. package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
  119. package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
  120. package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
  121. package/sdk/ios/usr/include/sys/cdefs.h +3 -0
  122. package/sdk/ios/usr/include/sys/param.h +235 -0
  123. package/sdk/ios/usr/include/sys/proc.h +1 -0
  124. package/sdk/ios/usr/include/sys/qos.h +151 -12
  125. package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
  126. package/sdk/ios/wasm/include/fcntl.h +11 -0
  127. package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
  128. package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
  129. package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
  130. package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
  131. package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
  132. package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
  133. package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
  134. package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
  135. package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
  136. package/sdk/ios/wasm/include/machine/_types.h +153 -0
  137. package/sdk/ios/wasm/include/machine/endian.h +2 -0
  138. package/sdk/ios/wasm/include/machine/limits.h +2 -0
  139. package/sdk/ios/wasm/include/machine/types.h +30 -0
  140. package/sdk/ios/wasm/include/poll.h +8 -0
  141. package/sdk/ios/wasm/include/pthread.h +50 -0
  142. package/sdk/ios/wasm/include/signal.h +72 -0
  143. package/sdk/ios/wasm/include/stdlib.h +3 -0
  144. package/sdk/ios/wasm/include/string.h +10 -0
  145. package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
  146. package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
  147. package/sdk/ios/wasm/include/sys/mman.h +122 -0
  148. package/sdk/ios/wasm/include/sys/select.h +37 -0
  149. package/sdk/ios/wasm/include/sys/signal.h +259 -0
  150. package/sdk/ios/wasm/include/sys/socket.h +8 -0
  151. package/sdk/ios/wasm/include/sys/types.h +14 -0
  152. package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
  153. package/sdk/ios/wasm/include/sys/uio.h +11 -0
  154. package/sdk/ios/wasm/include/sys/wait.h +89 -0
  155. package/sdk/ios/wasm/include/time.h +8 -0
  156. package/sdk/ios/wasm/include/unistd.h +17 -0
  157. package/src/bridge-contract.ts +2 -0
  158. package/src/chromium-admission.ts +10 -5
  159. package/src/device-catalog.ts +4 -4
  160. package/src/host/fetch-proxy-handler.ts +20 -0
  161. package/src/metro-plugin.ts +5 -2
  162. package/src/nitro-adapter.lock.json +6 -6
  163. package/src/nitro-compile.ts +63 -2
  164. package/src/numbered-lock.ts +72 -0
  165. package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
  166. package/src/react-native-coverage/capability-source-references.ts +50 -13
  167. package/src/react-native-coverage/native-source-credit.ts +126 -0
  168. package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
  169. package/src/react-native-coverage/native-surface.ts +49 -0
  170. package/src/react-native-coverage/verified-reach.ts +22 -2
  171. package/src/runtime-assets.ts +17 -0
  172. package/src/swift-compile.ts +84 -48
  173. package/src/swift-coverage/indexing.ts +17 -1
  174. package/src/swift-coverage/sdk.ts +71 -0
  175. package/src/swift-coverage/source.ts +74 -2
  176. package/src/swift-coverage/types.ts +6 -0
  177. package/src/swift-distribution.lock.json +12 -12
  178. package/src/swift-host.ts +133 -14
  179. package/src/swift-objc-compile.ts +6 -21
  180. package/src/swift-objc-metadata.ts +2 -8
  181. package/src/swift-objc-platform.ts +53 -0
  182. package/src/swift-objc-standin.ts +45 -1
  183. package/src/swift-package-manifest.ts +48 -3
  184. package/src/swift-package.ts +59 -9
  185. package/src/swift-packages.ts +157 -44
  186. package/src/swift-source-pods.ts +288 -0
  187. package/src/swift-toolchain.ts +32 -10
  188. package/src/vite-plugin-one.ts +5 -4
  189. package/src/worker-system-chunks.ts +7 -1
  190. package/src/xcode-project.ts +40 -11
@@ -0,0 +1,89 @@
1
+ // darwin's sys/wait.h. the installed libc has no processes to wait for and
2
+ // owns struct rusage; union wait takes wasm's little-endian layout.
3
+ #ifndef _SYS_WAIT_H_
4
+ #define _SYS_WAIT_H_
5
+
6
+ #include <sys/cdefs.h>
7
+
8
+ typedef enum {
9
+ P_ALL,
10
+ P_PID,
11
+ P_PGID
12
+ } idtype_t;
13
+
14
+ #define __NEED_pid_t
15
+ #define __NEED_id_t
16
+ #include <bits/alltypes.h>
17
+ #include <sys/signal.h>
18
+ #include <sys/resource.h>
19
+
20
+ #define WNOHANG 0x00000001
21
+ #define WUNTRACED 0x00000002
22
+
23
+ #if defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)
24
+ #define _W_INT(i) (i)
25
+ #else
26
+ #define _W_INT(w) (*(int *)&(w))
27
+ #define WCOREFLAG 0200
28
+ #endif
29
+
30
+ #define _WSTATUS(x) (_W_INT(x) & 127)
31
+ #define _WSTOPPED 0177
32
+
33
+ #define WEXITSTATUS(x) ((_W_INT(x) >> 8) & 0x000000ff)
34
+ #define WSTOPSIG(x) (_W_INT(x) >> 8)
35
+ #define WIFCONTINUED(x) (_WSTATUS(x) == _WSTOPPED && WSTOPSIG(x) == 0x13)
36
+ #define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED && WSTOPSIG(x) != 0x13)
37
+ #define WIFEXITED(x) (_WSTATUS(x) == 0)
38
+ #define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
39
+ #define WTERMSIG(x) (_WSTATUS(x))
40
+ #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
41
+ #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
42
+
43
+ #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
44
+ #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
45
+ #endif
46
+
47
+ #define WEXITED 0x00000004
48
+ #define WSTOPPED 0x00000008
49
+ #define WCONTINUED 0x00000010
50
+ #define WNOWAIT 0x00000020
51
+
52
+ #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
53
+ #define WAIT_ANY (-1)
54
+ #define WAIT_MYPGRP 0
55
+
56
+ union wait {
57
+ int w_status;
58
+ struct {
59
+ unsigned int w_Termsig:7,
60
+ w_Coredump:1,
61
+ w_Retcode:8,
62
+ w_Filler:16;
63
+ } w_T;
64
+ struct {
65
+ unsigned int w_Stopval:8,
66
+ w_Stopsig:8,
67
+ w_Filler:16;
68
+ } w_S;
69
+ };
70
+ #define w_termsig w_T.w_Termsig
71
+ #define w_coredump w_T.w_Coredump
72
+ #define w_retcode w_T.w_Retcode
73
+ #define w_stopval w_S.w_Stopval
74
+ #define w_stopsig w_S.w_Stopsig
75
+ #endif
76
+
77
+ __BEGIN_DECLS
78
+ pid_t wait(int *);
79
+ pid_t waitpid(pid_t, int *, int);
80
+ #ifndef _ANSI_SOURCE
81
+ int waitid(idtype_t, id_t, siginfo_t *, int);
82
+ #endif
83
+ #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
84
+ pid_t wait3(int *, int, struct rusage *);
85
+ pid_t wait4(pid_t, int *, int, struct rusage *);
86
+ #endif
87
+ __END_DECLS
88
+
89
+ #endif
@@ -0,0 +1,8 @@
1
+ #pragma once
2
+ // darwin's cancellation points bind to the darwin provider, which acts on a
3
+ // pending cancel first.
4
+ #include_next <time.h>
5
+ #include <sys/cdefs.h>
6
+ __BEGIN_DECLS
7
+ int nanosleep(const struct timespec *, struct timespec *) __asm__("__peach_darwin_nanosleep");
8
+ __END_DECLS
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+ // the installed libc leaves getppid undeclared because wasi has no process
3
+ // ids; darwin declares it for every process. darwin's cancellation points bind
4
+ // to the darwin provider, which acts on a pending cancel first.
5
+ #include_next <unistd.h>
6
+ #include <sys/cdefs.h>
7
+ __BEGIN_DECLS
8
+ pid_t getppid(void);
9
+ int close(int) __asm__("__peach_darwin_close");
10
+ ssize_t read(int, void *, size_t) __asm__("__peach_darwin_read");
11
+ ssize_t write(int, const void *, size_t) __asm__("__peach_darwin_write");
12
+ ssize_t pread(int, void *, size_t, off_t) __asm__("__peach_darwin_pread");
13
+ ssize_t pwrite(int, const void *, size_t, off_t) __asm__("__peach_darwin_pwrite");
14
+ int fsync(int) __asm__("__peach_darwin_fsync");
15
+ unsigned sleep(unsigned) __asm__("__peach_darwin_sleep");
16
+ int usleep(unsigned) __asm__("__peach_darwin_usleep");
17
+ __END_DECLS
@@ -353,6 +353,8 @@ export interface SemanticWaitOptions {
353
353
  }
354
354
 
355
355
  export interface SemanticReadyProbe {
356
+ // owner-observed startup facts only; never a readiness condition.
357
+ startup?: string
356
358
  flag: unknown
357
359
  at: number
358
360
  nodes: number
@@ -54,11 +54,16 @@ export function readChromiumQueue(
54
54
  'chromium-admission',
55
55
  )
56
56
  fs.mkdirSync(dir, { recursive: true })
57
- // one GPU chrome per three cores: a sim chrome holds its gpu process, a
58
- // renderer and a compositor busy, and the box keeps cores for builds. the
59
- // queue is machine-wide, so every caller ranks against the machine's cores:
60
- // a caller pinned to a few cpus must not read a smaller limit than the rest
61
- const limit = Math.max(2, Math.floor(os.cpus().length / 3))
57
+ // one GPU chrome per two cores: a sim chrome holds its gpu process, a
58
+ // renderer and a compositor busy, and the box keeps half its cores for
59
+ // builds. eight concurrent Peach legs (a shell, jest and a transient
60
+ // browser each) ran clean on 16-18 core hosts with memory 85%+ free and
61
+ // at most three browsers overlapping, so two cores per ticket holds that
62
+ // fan-out; sixteen legs blocked on remote preflight admission before the
63
+ // host was the limit. the queue is machine-wide, so every caller ranks
64
+ // against the machine's cores: a caller pinned to a few cpus must not
65
+ // read a smaller limit than the rest
66
+ const limit = Math.max(2, Math.floor(os.cpus().length / 2))
62
67
 
63
68
  // a pid alone can be reused; the ticket's start second must match the
64
69
  // process's own start time, read once per ticket
@@ -743,10 +743,10 @@ export const devices: Record<DeviceModel, DeviceSpec> = {
743
743
  // 84pt trailing Vertical Bar on the outer display (Apple iOS 27 UI kit).
744
744
  safeAreaInsets: { top: 0, bottom: 34, left: 0, right: 84 },
745
745
  iosVersion: '27.1',
746
- // focused keyboard frames on the ios 27.1 duo simulator's cover: qwerty
747
- // (0,426,466,252), number pad 256, emoji (0,340,466,338)pt
748
- // (plans/contrast/duo-platform.md)
749
- keyboardPanelHeights: { qwerty: 252, pad: 256, emoji: 338 },
746
+ // ios 27.1 24a94425: ordinary qwerty host (0,413,466,265)pt;
747
+ // docs/ios-framework-oracle/keyboard-tray-accessibility-and-duo-recipes.md.
748
+ // number pad 256 and emoji 338 retain their separate measured frames.
749
+ keyboardPanelHeights: { qwerty: 265, pad: 256, emoji: 338 },
750
750
  physicalPPI: 460,
751
751
  // official model extraction for button positions is outside this slice.
752
752
  hardwareButtons: /* @__PURE__ */ modernButtons([0, 0], [0, 0], [0, 0], [0, 0]),
@@ -351,6 +351,26 @@ export function handleAppApiRequest(req: IncomingMessage, res: ServerResponse):
351
351
  return true
352
352
  }
353
353
 
354
+ // the engine routes some cross-origin images, fetches and bundles through
355
+ // these same-origin endpoints, since an isolated page cannot load a no-cors
356
+ // subresource that lacks CORP (direct, CORS and share paths do not come
357
+ // here). one helper serves them for each framework plugin that serves the
358
+ // page; it answers true when the request was a proxy route.
359
+ export function serveBrowserProxyRoute(
360
+ req: IncomingMessage,
361
+ res: ServerResponse,
362
+ ): boolean {
363
+ if (isBundleProxyRequestUrl(req.url) || isFetchProxyRequestUrl(req.url)) {
364
+ if (!rejectUntrustedBridgeOrigin(req, res)) void handleFetchProxyRequest(req, res)
365
+ return true
366
+ }
367
+ if (isAppApiRequestUrl(req.url)) {
368
+ if (rejectUntrustedBridgeOrigin(req, res)) return true
369
+ return handleAppApiRequest(req, res)
370
+ }
371
+ return false
372
+ }
373
+
354
374
  // one proxied request, made as URLSession makes it on a device: the request
355
375
  // body is buffered so a 307 or 308 can send it again, redirects are followed
356
376
  // here (the browser would resolve a relative Location against the proxy
@@ -16,6 +16,7 @@ import { resolveAppProject } from '../cli/app-project'
16
16
  import { collectAndroidAutolinkedPackages } from './android-autolinking'
17
17
  import { insertAndroidAutolinkingFooter } from './androidAutolinkingContract'
18
18
  import { tagRnxBundleForPlugin } from './dev-server-open'
19
+ import { serveBrowserProxyRoute } from './host/fetch-proxy-handler'
19
20
  import {
20
21
  handleReplacementModuleRequest,
21
22
  isReplacementModuleRequestUrl,
@@ -44,6 +45,7 @@ import {
44
45
  isRootRuntimeAssetPath,
45
46
  resolveRuntimeFilePath,
46
47
  resolveRuntimeRootForRequestHost,
48
+ sendShellHtml,
47
49
  serveRuntimeFile,
48
50
  SOOTSIM_RUNTIME_MISSING_MESSAGE,
49
51
  } from './runtime-assets'
@@ -474,6 +476,8 @@ export function withPeach<T extends Record<string, unknown>>(
474
476
  return
475
477
  }
476
478
 
479
+ if (serveBrowserProxyRoute(req, res)) return
480
+
477
481
  const url = req.url || ''
478
482
  const pathname = url.split('?')[0]
479
483
 
@@ -527,8 +531,7 @@ export function withPeach<T extends Record<string, unknown>>(
527
531
  html = html.includes('</head>')
528
532
  ? html.replace('</head>', `${script}</head>`)
529
533
  : `${html}${script}`
530
- res.setHeader('content-type', 'text/html')
531
- res.end(html)
534
+ sendShellHtml(res, html)
532
535
  return
533
536
  }
534
537
  }
@@ -10,17 +10,17 @@
10
10
  "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9",
11
11
  "nitroModules": "372b6f69fc063a0b316792eec9b26f36063868dc206f169acbb5d993c6572f65"
12
12
  },
13
- "compiler": "swift-6.4.0-RELEASE-custom-0d775d32d7c74eae",
13
+ "compiler": "swift-6.4.0-RELEASE-custom-8be2e4a7a393b003",
14
14
  "sdk": {
15
- "id": "swift-6.4.0-RELEASE_wasm-peach-f02bd198",
16
- "checksum": "1e19ea768fd4e821aae34b8966c4ddcee45615c4b3cf018979b061aee2fb5504"
15
+ "id": "swift-6.4.0-RELEASE_wasm-peach-2d2602d0",
16
+ "checksum": "05181637294f73285610478231c04d79c9710648198f5423ed26b718da6d3df6"
17
17
  },
18
18
  "framework": {
19
- "distribution": "433f607a19978269",
19
+ "distribution": "2a88c78372024d5a",
20
20
  "wireAbi": "ed0b01fcc0a79236d88ef9ac7950ac30932dfc19c19112c69d1d6a039a489292"
21
21
  },
22
22
  "archive": {
23
- "sha256": "17c176f0bee02e9aa3417d12328986d80c489c8734337d2af7b53f2393a5119c",
24
- "size": 31176
23
+ "sha256": "ab29e78d1f148563b5252059671f6dbe532c8b09e44d3ca28d3ded8732370658",
24
+ "size": 31171
25
25
  }
26
26
  }
@@ -12,8 +12,19 @@ import {
12
12
  type NitroSourceCollection,
13
13
  type NitroSourceOptions,
14
14
  } from './nitro-source'
15
- import { syncSwiftTree } from './swift-compile'
15
+ import {
16
+ missingSwiftModules,
17
+ swiftAvailableModules,
18
+ syncSwiftTree,
19
+ } from './swift-compile'
20
+ import { swiftModuleToolchain } from './swift-distribution'
16
21
  import { artifactFor, projectFor, type SwiftArtifact } from './swift-host'
22
+ import {
23
+ manifestCalls,
24
+ swiftManifestCxxLanguageStandard,
25
+ swiftManifestTargets,
26
+ } from './swift-package'
27
+ import { collectSwiftSourcePods } from './swift-source-pods'
17
28
  import type { SwiftCompileInput } from './swift-compile'
18
29
 
19
30
  // every selected installed implementation, its generated registration and the
@@ -23,8 +34,30 @@ import type { SwiftCompileInput } from './swift-compile'
23
34
  export function collectNitroCompileInput(
24
35
  collection: NitroSourceCollection,
25
36
  adapter: NitroAdapterArchive,
37
+ dependencies?: SwiftCompileInput | null,
26
38
  ): SwiftCompileInput {
27
39
  const files = { ...collection.files }
40
+ for (const [file, source] of Object.entries(dependencies?.files ?? {})) {
41
+ if (file === 'Package.swift') continue
42
+ if (Object.hasOwn(files, file))
43
+ throw new Error(`Nitro dependency source collision: ${file}`)
44
+ files[file] = source
45
+ }
46
+ const manifest = dependencies?.files['Package.swift'] ?? ''
47
+ const dependencyTargets = manifestCalls(manifest, ['target', 'systemLibrary']).map(
48
+ ({ kind, call }) => `.${kind}(${call},`,
49
+ )
50
+ const targets = swiftManifestTargets(manifest).filter((target) => !target.executable)
51
+ const cxxStandard = swiftManifestCxxLanguageStandard(manifest)
52
+ if (cxxStandard && cxxStandard !== 'cxx20')
53
+ throw new Error(`Nitro pod C++ standard ${cxxStandard} differs from cxx20`)
54
+ if (
55
+ targets.length !== dependencyTargets.length ||
56
+ targets.some((target) =>
57
+ collection.targets.some((provider) => provider.name === target.name),
58
+ )
59
+ )
60
+ throw new Error('Nitro pod targets have ambiguous names or declarations')
28
61
  // the archive has no module, so NitroCore's module map declares its entry.
29
62
  files['Sources/NitroCore/include/PeachNitroEntry.hpp'] =
30
63
  '#pragma once\nextern "C" void peachNitroInitialize();\n'
@@ -43,6 +76,7 @@ export function collectNitroCompileInput(
43
76
  '// swift-tools-version: 6.2',
44
77
  'import PackageDescription',
45
78
  'let package = Package(name: "PeachNativeModule", targets: [',
79
+ ...dependencyTargets,
46
80
  ...collection.targets.map(
47
81
  (target) =>
48
82
  `.target(name: ${JSON.stringify(target.name)}, dependencies: ${JSON.stringify(target.dependencies?.map((dependency) => dependency.name) ?? [])}, path: ${JSON.stringify(target.path)}, ${target.cxxInterop ? 'swiftSettings: [.interoperabilityMode(.Cxx)]' : 'cxxSettings: [.define("DEBUG")]'}),`,
@@ -51,16 +85,41 @@ export function collectNitroCompileInput(
51
85
  '], cxxLanguageStandard: .cxx20)',
52
86
  '',
53
87
  ].join('\n')
54
- return { files, entry, libraries: { NitroCore: adapter.base64 } }
88
+ return {
89
+ files,
90
+ entry,
91
+ libraries: { NitroCore: adapter.base64 },
92
+ ...(dependencies?.nativeTargets ? { nativeTargets: dependencies.nativeTargets } : {}),
93
+ ...(dependencies?.resourceBundles
94
+ ? { resourceBundles: dependencies.resourceBundles }
95
+ : {}),
96
+ }
55
97
  }
56
98
 
57
99
  export async function compileNitroModule(
58
100
  options: NitroSourceOptions & { moduleRoot: string },
59
101
  ): Promise<{ artifact: SwiftArtifact; collection: NitroSourceCollection }> {
60
102
  const collection = collectNitroSources(options)
103
+ let dependencies: SwiftCompileInput | null = null
104
+ if (options.appRoot && fs.existsSync(path.join(options.appRoot, 'Podfile.lock'))) {
105
+ const available = new Set(
106
+ swiftAvailableModules(
107
+ options.moduleRoot,
108
+ swiftModuleToolchain(options.moduleRoot).toolchainBin,
109
+ ),
110
+ )
111
+ for (const target of collection.targets) available.add(target.name)
112
+ const missing = [...missingSwiftModules(collection.files, available).keys()]
113
+ dependencies = await collectSwiftSourcePods(
114
+ options.appRoot,
115
+ missing,
116
+ options.moduleRoot,
117
+ )
118
+ }
61
119
  const input = collectNitroCompileInput(
62
120
  collection,
63
121
  await resolveNitroAdapter(collection, options.moduleRoot, committedNitroAdapterLock),
122
+ dependencies,
64
123
  )
65
124
  const key = createHash('sha256')
66
125
  .update(
@@ -83,6 +142,8 @@ export async function compileNitroModule(
83
142
  )
84
143
  const project = projectFor(packagePath)
85
144
  project.libraries = input.libraries
145
+ project.nativeTargets = input.nativeTargets
146
+ project.resourceBundles = input.resourceBundles
86
147
  return {
87
148
  artifact: await artifactFor(project, input.entry, options.moduleRoot),
88
149
  collection,
@@ -0,0 +1,72 @@
1
+ import { randomUUID } from 'node:crypto'
2
+ import {
3
+ linkSync,
4
+ mkdirSync,
5
+ readFileSync,
6
+ readdirSync,
7
+ renameSync,
8
+ rmSync,
9
+ writeFileSync,
10
+ } from 'node:fs'
11
+ import { join } from 'node:path'
12
+
13
+ const errorCode = (error: unknown) =>
14
+ error instanceof Error && 'code' in error ? error.code : undefined
15
+
16
+ function alive(pid: number): boolean {
17
+ try {
18
+ process.kill(pid, 0)
19
+ return true
20
+ } catch (error) {
21
+ return errorCode(error) !== 'ESRCH'
22
+ }
23
+ }
24
+
25
+ // the highest number is never deleted until a higher claim exists. linking a fully
26
+ // written pid elects one owner; stale readers that recreate pruned numbers withdraw.
27
+ export function tryAcquireNumberedLock(
28
+ directory: string,
29
+ detail = '',
30
+ ): (() => void) | null {
31
+ mkdirSync(directory, { recursive: true })
32
+ const claim = join(directory, `claim-${process.pid}-${randomUUID()}`)
33
+ for (;;) {
34
+ const numbers = readdirSync(directory)
35
+ .filter((name) => /^\d+$/.test(name))
36
+ .map(Number)
37
+ const top = Math.max(-1, ...numbers)
38
+ let holder = 'free'
39
+ if (top >= 0) {
40
+ try {
41
+ holder = readFileSync(join(directory, String(top)), 'utf8')
42
+ } catch (error) {
43
+ if (errorCode(error) === 'ENOENT') continue
44
+ throw error
45
+ }
46
+ }
47
+ if (holder !== 'free' && alive(Number(holder.split('\n')[0]))) return null
48
+ const held = join(directory, String(top + 1))
49
+ writeFileSync(claim, `${process.pid}${detail ? `\n${detail}` : ''}`)
50
+ try {
51
+ linkSync(claim, held)
52
+ } catch (error) {
53
+ if (errorCode(error) === 'EEXIST') continue
54
+ throw error
55
+ } finally {
56
+ rmSync(claim, { force: true })
57
+ }
58
+ if (readdirSync(directory).some((name) => Number(name) > top + 1)) {
59
+ rmSync(held, { force: true })
60
+ continue
61
+ }
62
+ for (const number of numbers) rmSync(join(directory, String(number)), { force: true })
63
+ let released = false
64
+ return () => {
65
+ if (released) return
66
+ released = true
67
+ // publish free atomically so readers never mistake a partial write for a dead pid.
68
+ writeFileSync(claim, 'free')
69
+ renameSync(claim, held)
70
+ }
71
+ }
72
+ }
@@ -21,6 +21,10 @@ type MatchDefinition = {
21
21
 
22
22
  function propOwners(contract: string): string[] {
23
23
  if (contract === 'Style') return []
24
+ // this internal wrapper's props belong to the sticky header, not ScrollView.
25
+ if (contract === 'ScrollViewStickyHeaderProps') return []
26
+ if (contract.includes('KeyboardAvoidingView')) return ['KeyboardAvoidingView']
27
+ if (contract.includes('ImageBackground')) return ['ImageBackground']
24
28
  if (/TextInput|InputAccessory/.test(contract)) {
25
29
  return contract.includes('InputAccessory') ? ['InputAccessoryView'] : ['TextInput']
26
30
  }
@@ -284,7 +288,15 @@ export function capabilityReferenceDefinition(
284
288
  const exportName = commandOwner
285
289
  ? (commandExports[commandOwner] ?? commandOwner)
286
290
  : contract
287
- const publicExport = exportName === 'ReactNativeElement' ? 'View' : exportName
291
+ const publicOwners: Record<string, string> = {
292
+ ReactNativeElement: 'View',
293
+ AppStateImpl: 'AppState',
294
+ KeyboardImpl: 'Keyboard',
295
+ LinkingImpl: 'Linking',
296
+ StyleSheetProperties: 'StyleSheet',
297
+ IOSPlatform: 'Platform',
298
+ }
299
+ const publicExport = publicOwners[exportName] ?? exportName
288
300
  if (
289
301
  !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(publicExport) ||
290
302
  !reactNativePublicExports.has(publicExport)
@@ -325,6 +337,29 @@ export type CapabilitySourceDefinition = Pick<
325
337
  'id' | 'packageName' | 'upstreamKind' | 'upstreamName' | 'publicReferencePaths'
326
338
  >
327
339
 
340
+ const REACT_NATIVE_EXCLUSIONS = [
341
+ {
342
+ kind: 'prop',
343
+ exportName: null,
344
+ members: ['key'],
345
+ reason: 'React reconciliation key; no independent native behavior cell',
346
+ },
347
+ {
348
+ kind: 'member',
349
+ exportName: 'StyleSheet',
350
+ members: ['create', 'flatten', 'compose', 'absoluteFill', 'absoluteFillObject'],
351
+ reason:
352
+ 'published JavaScript helper or constant; native effects belong to its consumers',
353
+ },
354
+ {
355
+ kind: 'member',
356
+ exportName: 'Platform',
357
+ members: ['OS', 'select'],
358
+ reason:
359
+ 'published JavaScript helper or constant; native effects belong to its consumers',
360
+ },
361
+ ]
362
+
328
363
  export function resolveCapabilityReferences(
329
364
  rows: readonly CapabilitySourceDefinition[],
330
365
  candidates: readonly CapabilityReferenceCandidate[],
@@ -338,6 +373,7 @@ export function resolveCapabilityReferences(
338
373
  .map((row) => row.upstreamName),
339
374
  )
340
375
  const index = new Map<string, Set<string>>()
376
+ const priorities = new Map<string, number>()
341
377
  for (const row of rows) {
342
378
  const definition = capabilityReferenceDefinition(row, publicExports)
343
379
  if (!definition.source) continue
@@ -362,16 +398,29 @@ export function resolveCapabilityReferences(
362
398
  `${definition.source}:${definition.upstreamKind === 'prop' || definition.upstreamKind === 'event' ? 'prop' : 'member'}:${owner}:${definition.memberName}`,
363
399
  )
364
400
  for (const key of keys) {
401
+ // a component's own public prop overrides the inherited View prop and
402
+ // its lower-level codegen declaration. unrelated equal matches stay unknown.
403
+ const owner = key.split(':')[2]
404
+ const contract = row.upstreamName.slice(0, row.upstreamName.lastIndexOf('.'))
405
+ const priority =
406
+ row.packageName === 'react-native' &&
407
+ (row.upstreamKind === 'prop' || row.upstreamKind === 'event')
408
+ ? (owner && contract.includes(owner) ? 2 : 0) +
409
+ (row.id.includes(':prop:host-prop-') || row.id.includes(':event:event-')
410
+ ? 1
411
+ : 0)
412
+ : 0
413
+ const previous = priorities.get(key)
414
+ if (previous !== undefined && previous > priority) continue
415
+ if (previous === undefined || previous < priority) index.delete(key)
416
+ priorities.set(key, priority)
365
417
  const matches = index.get(key) ?? new Set<string>()
366
418
  matches.add(row.id)
367
419
  index.set(key, matches)
368
420
  }
369
421
  }
370
422
  for (const door of sourceApiDoors) {
371
- const key =
372
- door.memberName === null
373
- ? `${door.module}:export:${door.exportName}:`
374
- : `${door.module}:member:${door.exportName}:${door.memberName}`
423
+ const key = `${door.module}:${door.referenceKind}:${door.exportName}:${door.memberName ?? ''}`
375
424
  const matches = index.get(key) ?? new Set<string>()
376
425
  matches.add(door.id)
377
426
  index.set(key, matches)
@@ -383,6 +432,14 @@ export function resolveCapabilityReferences(
383
432
  seen.add(candidate.id)
384
433
  if (candidate.exclusion)
385
434
  return { ...candidate, state: 'excluded', reason: candidate.exclusion }
435
+ const exclusion = REACT_NATIVE_EXCLUSIONS.find(
436
+ (rule) =>
437
+ candidate.module === 'react-native' &&
438
+ candidate.kind === rule.kind &&
439
+ (rule.exportName === null || candidate.exportName === rule.exportName) &&
440
+ rule.members.includes(candidate.memberName ?? ''),
441
+ )
442
+ if (exclusion) return { ...candidate, state: 'excluded', reason: exclusion.reason }
386
443
  const matches = index.get(
387
444
  `${candidate.module}:${candidate.kind}:${candidate.exportName}:${candidate.memberName ?? ''}`,
388
445
  )