peachsim 0.1.1673 → 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 (213) 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/settling.ts +37 -4
  7. package/cli/commands/inspect/wait-ready.ts +7 -0
  8. package/cli/outbound-endpoints.ts +12 -0
  9. package/detox/index.ts +11 -1
  10. package/detox/jest-environment.cjs +14 -0
  11. package/dist-lib/agent-daemon-client.cjs +1 -1
  12. package/dist-lib/agent-events.cjs +1 -1
  13. package/dist-lib/attached-projects.cjs +1 -1
  14. package/dist-lib/auth/shared-session.cjs +1 -1
  15. package/dist-lib/backend-origin.cjs +1 -1
  16. package/dist-lib/beta.cjs +1 -1
  17. package/dist-lib/beta.mjs +1 -1
  18. package/dist-lib/bridge-constants.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.cjs +1 -1
  20. package/dist-lib/bridge-contract-input.mjs +1 -1
  21. package/dist-lib/bridge-contract.cjs +1 -1
  22. package/dist-lib/bridge-contract.mjs +1 -1
  23. package/dist-lib/bundle-channel.cjs +3299 -1665
  24. package/dist-lib/capture-contract.cjs +1 -1
  25. package/dist-lib/capture-contract.mjs +1 -1
  26. package/dist-lib/cloud-contract.cjs +1 -1
  27. package/dist-lib/cloud-contract.mjs +1 -1
  28. package/dist-lib/cloud-test-args.cjs +1 -1
  29. package/dist-lib/cloud-test-args.mjs +1 -1
  30. package/dist-lib/cloud.cjs +1 -1
  31. package/dist-lib/cloud.mjs +1 -1
  32. package/dist-lib/config.cjs +1 -1
  33. package/dist-lib/config.mjs +1 -1
  34. package/dist-lib/detox/index.cjs +43 -8
  35. package/dist-lib/detox/jest-environment.cjs +14 -0
  36. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  37. package/dist-lib/expo-swift-bundle.cjs +2432 -1128
  38. package/dist-lib/expo-swift-metadata.cjs +1 -1
  39. package/dist-lib/expo-swift-metadata.mjs +1 -1
  40. package/dist-lib/home-paths.cjs +1 -1
  41. package/dist-lib/host/bridge-host.cjs +2908 -1601
  42. package/dist-lib/host/fetch-proxy-handler.cjs +22 -6
  43. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  44. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  45. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  46. package/dist-lib/host/websocket-proxy.cjs +1 -1
  47. package/dist-lib/index.cjs +1941 -742
  48. package/dist-lib/jump-to-source-babel.cjs +1 -1
  49. package/dist-lib/jump-to-source-native.cjs +1 -1
  50. package/dist-lib/kotlin-host.cjs +1 -1
  51. package/dist-lib/menu.cjs +1 -1
  52. package/dist-lib/menu.mjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  54. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  55. package/dist-lib/metro-production-bundle.cjs +1 -1
  56. package/dist-lib/metro-production-bundle.mjs +1 -1
  57. package/dist-lib/metro.cjs +6215 -4283
  58. package/dist-lib/native-app-identity-project.cjs +31 -6
  59. package/dist-lib/native-app-identity-project.mjs +31 -6
  60. package/dist-lib/native-app-identity.cjs +1 -1
  61. package/dist-lib/native-app-identity.mjs +1 -1
  62. package/dist-lib/native-firebase-metadata.cjs +1 -1
  63. package/dist-lib/native-firebase-metadata.mjs +1 -1
  64. package/dist-lib/plist.cjs +1 -1
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +1 -1
  67. package/dist-lib/public-brand.cjs +1 -1
  68. package/dist-lib/public-origins-lib-esm.json +24 -23
  69. package/dist-lib/public-origins-lib-static.json +1 -1
  70. package/dist-lib/public-origins-lib.json +134 -78
  71. package/dist-lib/react-native-host-modules.cjs +1 -1
  72. package/dist-lib/react-native-host-modules.mjs +1 -1
  73. package/dist-lib/reap-browser.cjs +2 -2
  74. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  75. package/dist-lib/sdk.cjs +39 -5
  76. package/dist-lib/sdk.mjs +39 -5
  77. package/dist-lib/skills.cjs +3637 -2168
  78. package/dist-lib/swift-compile.cjs +496 -352
  79. package/dist-lib/swift-compile.mjs +494 -350
  80. package/dist-lib/swift-package.cjs +58 -9
  81. package/dist-lib/swift-package.mjs +57 -9
  82. package/dist-lib/swift-submit.cjs +1 -1
  83. package/dist-lib/swift-submit.mjs +1 -1
  84. package/dist-lib/swift-toolchain.cjs +26 -11
  85. package/dist-lib/swift.cjs +1 -1
  86. package/dist-lib/vite-swift.cjs +2443 -1134
  87. package/dist-lib/vite.cjs +1907 -763
  88. package/dist-lib/worklet-executable.cjs +1 -1
  89. package/dist-lib/worklet-executable.mjs +1 -1
  90. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
  91. package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +9 -1
  92. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +1 -0
  93. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
  94. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -1
  95. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
  96. package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +2 -0
  97. package/dist-types/packages/peach-globals/src/compositorBridgeContract.d.ts +10 -1
  98. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  99. package/package.json +1 -1
  100. package/runtime-companion.json +1 -1
  101. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +69 -2
  102. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +44 -4
  103. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
  104. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
  105. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
  106. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
  107. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
  108. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
  109. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
  110. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
  111. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
  112. package/sdk/ios/usr/include/_ctype.h +388 -0
  113. package/sdk/ios/usr/include/_inttypes.h +296 -0
  114. package/sdk/ios/usr/include/_locale.h +83 -0
  115. package/sdk/ios/usr/include/_locale_posix2008.h +65 -0
  116. package/sdk/ios/usr/include/_time.h +207 -0
  117. package/sdk/ios/usr/include/arm/param.h +151 -0
  118. package/sdk/ios/usr/include/ctype.h +70 -0
  119. package/sdk/ios/usr/include/dispatch/dispatch.h +72 -6
  120. package/sdk/ios/usr/include/dlfcn.h +1 -2
  121. package/sdk/ios/usr/include/inttypes.h +35 -0
  122. package/sdk/ios/usr/include/locale.h +59 -0
  123. package/sdk/ios/usr/include/machine/param.h +42 -0
  124. package/sdk/ios/usr/include/net/if.h +1 -2
  125. package/sdk/ios/usr/include/peach/pthread.h +4 -4
  126. package/sdk/ios/usr/include/pthread/qos.h +304 -0
  127. package/sdk/ios/usr/include/runetype.h +118 -0
  128. package/sdk/ios/usr/include/setjmp.h +99 -0
  129. package/sdk/ios/usr/include/sys/_types/_clock_t.h +32 -0
  130. package/sdk/ios/usr/include/sys/_types/_ct_rune_t.h +33 -0
  131. package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
  132. package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
  133. package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
  134. package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
  135. package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
  136. package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
  137. package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
  138. package/sdk/ios/usr/include/sys/_types/_rune_t.h +32 -0
  139. package/sdk/ios/usr/include/sys/_types/_time_t.h +32 -0
  140. package/sdk/ios/usr/include/sys/_types/_wint_t.h +33 -0
  141. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  142. package/sdk/ios/usr/include/sys/param.h +235 -0
  143. package/sdk/ios/usr/include/sys/proc.h +1 -0
  144. package/sdk/ios/usr/include/sys/qos.h +151 -12
  145. package/sdk/ios/usr/include/time.h +67 -2
  146. package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
  147. package/sdk/ios/wasm/include/fcntl.h +11 -0
  148. package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
  149. package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
  150. package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
  151. package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
  152. package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
  153. package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
  154. package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
  155. package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
  156. package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
  157. package/sdk/ios/wasm/include/machine/_types.h +153 -0
  158. package/sdk/ios/wasm/include/machine/endian.h +2 -0
  159. package/sdk/ios/wasm/include/machine/limits.h +2 -0
  160. package/sdk/ios/wasm/include/machine/types.h +30 -0
  161. package/sdk/ios/wasm/include/poll.h +8 -0
  162. package/sdk/ios/wasm/include/pthread.h +50 -0
  163. package/sdk/ios/wasm/include/signal.h +72 -0
  164. package/sdk/ios/wasm/include/stdlib.h +3 -0
  165. package/sdk/ios/wasm/include/string.h +10 -0
  166. package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
  167. package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
  168. package/sdk/ios/wasm/include/sys/mman.h +122 -0
  169. package/sdk/ios/wasm/include/sys/select.h +37 -0
  170. package/sdk/ios/wasm/include/sys/signal.h +259 -0
  171. package/sdk/ios/wasm/include/sys/socket.h +8 -0
  172. package/sdk/ios/wasm/include/sys/types.h +14 -0
  173. package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
  174. package/sdk/ios/wasm/include/sys/uio.h +11 -0
  175. package/sdk/ios/wasm/include/sys/wait.h +89 -0
  176. package/sdk/ios/wasm/include/time.h +8 -0
  177. package/sdk/ios/wasm/include/unistd.h +17 -0
  178. package/src/bridge-contract.ts +2 -0
  179. package/src/chromium-admission.ts +10 -5
  180. package/src/device-catalog.ts +4 -4
  181. package/src/host/fetch-proxy-handler.ts +20 -0
  182. package/src/host/rolldown-bundle-forward.ts +4 -1
  183. package/src/metro-plugin.ts +5 -2
  184. package/src/nitro-adapter.lock.json +6 -6
  185. package/src/nitro-compile.ts +63 -2
  186. package/src/numbered-lock.ts +72 -0
  187. package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
  188. package/src/react-native-coverage/capability-source-references.ts +50 -13
  189. package/src/react-native-coverage/native-source-credit.ts +126 -0
  190. package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
  191. package/src/react-native-coverage/native-surface.ts +49 -0
  192. package/src/react-native-coverage/verified-reach.ts +22 -2
  193. package/src/runtime-assets.ts +17 -0
  194. package/src/swift-compile.ts +84 -47
  195. package/src/swift-coverage/indexing.ts +17 -1
  196. package/src/swift-coverage/sdk.ts +71 -0
  197. package/src/swift-coverage/source.ts +74 -2
  198. package/src/swift-coverage/types.ts +6 -0
  199. package/src/swift-distribution.lock.json +12 -12
  200. package/src/swift-host.ts +133 -14
  201. package/src/swift-objc-compile.ts +11 -22
  202. package/src/swift-objc-metadata.ts +2 -8
  203. package/src/swift-objc-platform.ts +53 -0
  204. package/src/swift-objc-standin.ts +49 -0
  205. package/src/swift-package-manifest.ts +48 -3
  206. package/src/swift-package.ts +85 -12
  207. package/src/swift-packages.ts +157 -44
  208. package/src/swift-source-pods.ts +288 -0
  209. package/src/swift-standins.ts +4 -1
  210. package/src/swift-toolchain.ts +32 -10
  211. package/src/vite-plugin-one.ts +5 -4
  212. package/src/worker-system-chunks.ts +7 -1
  213. package/src/xcode-project.ts +40 -11
@@ -0,0 +1,288 @@
1
+ import { createHash } from 'node:crypto'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import yaml from 'yaml'
5
+ import { cacheDir } from './home-paths'
6
+ import { compileInput, disposeSwiftProject, openXcodeProject } from './swift-host'
7
+ import { swiftManifestTargets } from './swift-package'
8
+ import { withSwiftRootLock } from './swift-root-lock'
9
+ import { readXcodeAppTarget } from './xcode-project'
10
+ import type { SwiftCompileInput } from './swift-compile'
11
+
12
+ const APP = 'PeachPodDependencies'
13
+ const record = (value: unknown): value is Record<string, unknown> =>
14
+ value !== null && typeof value === 'object' && !Array.isArray(value)
15
+
16
+ // this is an empty host project; CocoaPods alone writes every dependency target.
17
+ const project = `{
18
+ archiveVersion = 1;
19
+ objectVersion = 56;
20
+ objects = {
21
+ A00000000000000000000001 = { isa = PBXProject; buildConfigurationList = A00000000000000000000002; compatibilityVersion = "Xcode 14.0"; mainGroup = A00000000000000000000003; productRefGroup = A00000000000000000000004; projectDirPath = ""; projectRoot = ""; targets = (A00000000000000000000005,); };
22
+ A00000000000000000000002 = { isa = XCConfigurationList; buildConfigurations = (A00000000000000000000006,); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; };
23
+ A00000000000000000000003 = { isa = PBXGroup; children = (A00000000000000000000004,A00000000000000000000007,); sourceTree = "<group>"; };
24
+ A00000000000000000000004 = { isa = PBXGroup; children = (A00000000000000000000008,); name = Products; sourceTree = "<group>"; };
25
+ A00000000000000000000005 = { isa = PBXNativeTarget; buildConfigurationList = A00000000000000000000009; buildPhases = (A0000000000000000000000A,); buildRules = (); dependencies = (); name = ${APP}; productName = ${APP}; productReference = A00000000000000000000008; productType = "com.apple.product-type.application"; };
26
+ A00000000000000000000006 = { isa = XCBuildConfiguration; buildSettings = { SDKROOT = iphoneos; IPHONEOS_DEPLOYMENT_TARGET = 16.0; }; name = Release; };
27
+ A00000000000000000000007 = { isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
28
+ A00000000000000000000008 = { isa = PBXFileReference; explicitFileType = wrapper.application; path = ${APP}.app; sourceTree = BUILT_PRODUCTS_DIR; };
29
+ A00000000000000000000009 = { isa = XCConfigurationList; buildConfigurations = (A0000000000000000000000B,); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; };
30
+ A0000000000000000000000A = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = (A0000000000000000000000C,); runOnlyForDeploymentPostprocessing = 0; };
31
+ A0000000000000000000000B = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_BUNDLE_IDENTIFIER = dev.peach.dependencies; SWIFT_VERSION = 5.0; GENERATE_INFOPLIST_FILE = YES; CURRENT_PROJECT_VERSION = 1; MARKETING_VERSION = 1.0; }; name = Release; };
32
+ A0000000000000000000000C = { isa = PBXBuildFile; fileRef = A00000000000000000000007; };
33
+ };
34
+ rootObject = A00000000000000000000001;
35
+ }
36
+ `
37
+
38
+ interface LockedPod {
39
+ name: string
40
+ version: string
41
+ dependencies: string[]
42
+ }
43
+
44
+ function lockedPods(value: unknown): Map<string, LockedPod> {
45
+ if (!record(value) || !Array.isArray(value.PODS))
46
+ throw new Error('Podfile.lock has no PODS list')
47
+ const pods = new Map<string, LockedPod>()
48
+ for (const entry of value.PODS) {
49
+ const entries =
50
+ typeof entry === 'string'
51
+ ? [[entry, []]]
52
+ : record(entry)
53
+ ? Object.entries(entry)
54
+ : []
55
+ if (entries.length !== 1) throw new Error('Podfile.lock has an invalid pod entry')
56
+ const [label, dependencies] = entries[0]!
57
+ if (
58
+ typeof label !== 'string' ||
59
+ !Array.isArray(dependencies) ||
60
+ !dependencies.every((dep): dep is string => typeof dep === 'string')
61
+ )
62
+ throw new Error('Podfile.lock has invalid pod dependencies')
63
+ const match =
64
+ /^([A-Za-z_][A-Za-z0-9_.+-]*(?:\/[A-Za-z0-9_.+-]+)*) \(([A-Za-z0-9_.+-]+)\)$/.exec(
65
+ label,
66
+ )
67
+ if (!match) throw new Error(`Podfile.lock has an invalid version: ${label}`)
68
+ const name = match[1]!
69
+ if (pods.has(name)) throw new Error(`Podfile.lock repeats ${name}`)
70
+ pods.set(name, {
71
+ name,
72
+ version: match[2]!,
73
+ dependencies: dependencies.map((dep) => dep.split(' ')[0]!).sort(),
74
+ })
75
+ }
76
+ return pods
77
+ }
78
+
79
+ /** install only the locked closure of missing imports, then read CocoaPods' real project. */
80
+ export async function collectSwiftSourcePods(
81
+ appRoot: string,
82
+ modules: readonly string[],
83
+ moduleRoot: string,
84
+ ): Promise<SwiftCompileInput | null> {
85
+ const lockFile = path.join(appRoot, 'Podfile.lock')
86
+ if (modules.length === 0 || !fs.existsSync(lockFile)) return null
87
+ const original = fs.readFileSync(lockFile, 'utf8')
88
+ const lock: unknown = yaml.parse(original)
89
+ const pods = lockedPods(lock)
90
+ if (!record(lock) || !record(lock['SPEC CHECKSUMS']) || !record(lock['SPEC REPOS']))
91
+ throw new Error(
92
+ `${lockFile}: source pods require specification checksums and repositories`,
93
+ )
94
+ const checksums = lock['SPEC CHECKSUMS']
95
+ const repositories = lock['SPEC REPOS']
96
+ const selected = new Map<string, LockedPod>()
97
+ const visit = (name: string) => {
98
+ if (selected.has(name)) return
99
+ const pod = pods.get(name)
100
+ if (!pod) throw new Error(`${lockFile}: dependency ${name} is not locked`)
101
+ const root = name.split('/')[0]!
102
+ if (record(lock['EXTERNAL SOURCES']) && root in lock['EXTERNAL SOURCES'])
103
+ throw new Error(
104
+ `${lockFile}: ${root} requires its original installed CocoaPods workspace`,
105
+ )
106
+ selected.set(name, pod)
107
+ for (const dependency of pod.dependencies) visit(dependency)
108
+ }
109
+ for (const module of modules) {
110
+ const roots = [
111
+ ...new Set([...pods.keys()].map((name) => name.split('/')[0]!)),
112
+ ].filter((name) => name.replace(/[^A-Za-z0-9_]/g, '_') === module)
113
+ if (roots.length === 0) continue
114
+ if (roots.length !== 1) throw new Error(`${lockFile}: ambiguous pod module ${module}`)
115
+ const root = roots[0]!
116
+ if (pods.has(root)) visit(root)
117
+ else for (const name of pods.keys()) if (name.startsWith(`${root}/`)) visit(name)
118
+ }
119
+ if (selected.size === 0) return null
120
+ const roots = new Set([...selected.keys()].map((name) => name.split('/')[0]!))
121
+ const trunk = repositories.trunk
122
+ if (!Array.isArray(trunk) || [...roots].some((root) => !trunk.includes(root)))
123
+ throw new Error(
124
+ `${lockFile}: source pod intake requires checksum-pinned trunk JSON specifications`,
125
+ )
126
+ const specificationChecksums: Record<string, string> = {}
127
+ for (const root of roots)
128
+ if (typeof checksums[root] !== 'string' || !/^[a-f0-9]{40}$/.test(checksums[root]))
129
+ throw new Error(`${lockFile}: missing checksum for ${root}`)
130
+ else specificationChecksums[root] = checksums[root]
131
+ const podfile = [
132
+ "source 'https://cdn.cocoapods.org/'",
133
+ "platform :ios, '16.0'",
134
+ 'use_frameworks! :linkage => :static',
135
+ "install! 'cocoapods', :deterministic_uuids => true",
136
+ `target '${APP}' do`,
137
+ ...[...selected.values()]
138
+ .sort((a, b) => a.name.localeCompare(b.name))
139
+ .map(
140
+ (pod) =>
141
+ ` pod ${JSON.stringify(pod.name)}, :podspec => ${JSON.stringify(`${pod.name.split('/')[0]}.podspec.json`)}`,
142
+ ),
143
+ 'end',
144
+ '',
145
+ ].join('\n')
146
+ const key = createHash('sha256')
147
+ .update(project)
148
+ .update(podfile)
149
+ .update(JSON.stringify([...selected].sort(([a], [b]) => a.localeCompare(b))))
150
+ .update(
151
+ JSON.stringify(
152
+ Object.entries(specificationChecksums).sort(([a], [b]) => a.localeCompare(b)),
153
+ ),
154
+ )
155
+ .digest('hex')
156
+ const work = path.join(cacheDir(), 'swift-source-pods', key)
157
+ return withSwiftRootLock(work, async (lease) => {
158
+ fs.mkdirSync(path.join(work, `${APP}.xcodeproj`), { recursive: true })
159
+ const runPod = async (args: string[]): Promise<string> => {
160
+ const child = lease.spawn('pod', args, { cwd: work })
161
+ child.stdin.end()
162
+ const output: Buffer[] = []
163
+ const errors: Buffer[] = []
164
+ child.stdout.on('data', (bytes: Buffer) => output.push(bytes))
165
+ child.stderr.on('data', (bytes: Buffer) => errors.push(bytes))
166
+ await new Promise<void>((resolve, reject) => {
167
+ child.once('error', (error) =>
168
+ reject(
169
+ new Error(
170
+ `CocoaPods is required to install source dependencies: ${error.message}`,
171
+ { cause: error },
172
+ ),
173
+ ),
174
+ )
175
+ child.once('close', (status) =>
176
+ status === 0
177
+ ? resolve()
178
+ : reject(
179
+ new Error(
180
+ `CocoaPods command pod ${args.join(' ')} exited ${status}: ${Buffer.concat(errors).toString('utf8')}`,
181
+ ),
182
+ ),
183
+ )
184
+ })
185
+ if (args[0] === 'install')
186
+ fs.writeFileSync(
187
+ path.join(work, 'pod-install.log'),
188
+ Buffer.concat([...output, ...errors]),
189
+ )
190
+ return Buffer.concat(output).toString('utf8')
191
+ }
192
+ const installed = path.join(work, 'Pods/Manifest.lock')
193
+ const complete = path.join(work, 'pod-install-complete')
194
+ const installedChecksums: Record<string, string> = {}
195
+ // checksum-pinned JSON binds the original prepare_command too; CocoaPods owns execution.
196
+ for (const root of [...roots].sort()) {
197
+ const version = [...selected.values()].find(
198
+ (pod) => pod.name.split('/')[0] === root,
199
+ )!.version
200
+ const file = path.join(work, `${root}.podspec.json`)
201
+ let text: string
202
+ if (fs.existsSync(file)) text = fs.readFileSync(file, 'utf8')
203
+ else {
204
+ const shard = createHash('md5')
205
+ .update(root)
206
+ .digest('hex')
207
+ .slice(0, 3)
208
+ .split('')
209
+ .join('/')
210
+ const response = await fetch(
211
+ `https://cdn.cocoapods.org/Specs/${shard}/${root}/${version}/${root}.podspec.json`,
212
+ )
213
+ if (!response.ok)
214
+ throw new Error(
215
+ `CocoaPods specification ${root} ${version}: HTTP ${response.status}`,
216
+ )
217
+ text = await response.text()
218
+ }
219
+ if (createHash('sha1').update(text).digest('hex') !== specificationChecksums[root])
220
+ throw new Error(`${work}: ${root} podspec checksum differs from ${lockFile}`)
221
+ const spec: unknown = JSON.parse(text)
222
+ if (!record(spec) || spec.name !== root || spec.version !== version)
223
+ throw new Error(`${work}: specification identity differs for ${root} ${version}`)
224
+ if (!fs.existsSync(file)) fs.writeFileSync(file, text)
225
+ // CocoaPods serializes external JSON specs before computing their installed checksum.
226
+ const serialized = await runPod(['ipc', 'spec', file])
227
+ installedChecksums[root] = createHash('sha1').update(serialized).digest('hex')
228
+ }
229
+ if (!fs.existsSync(complete)) {
230
+ fs.writeFileSync(path.join(work, `${APP}.xcodeproj/project.pbxproj`), project)
231
+ fs.writeFileSync(path.join(work, 'main.swift'), 'import Foundation\n')
232
+ fs.writeFileSync(path.join(work, 'Podfile'), podfile)
233
+ await runPod(['install'])
234
+ fs.writeFileSync(complete, key)
235
+ }
236
+ const actualLock: unknown = yaml.parse(fs.readFileSync(installed, 'utf8'))
237
+ const actual = lockedPods(actualLock)
238
+ if (
239
+ JSON.stringify([...actual].sort(([a], [b]) => a.localeCompare(b))) !==
240
+ JSON.stringify([...selected].sort(([a], [b]) => a.localeCompare(b)))
241
+ )
242
+ throw new Error(
243
+ `${work}: installed pod versions or dependencies differ from ${lockFile}`,
244
+ )
245
+ if (!record(actualLock) || !record(actualLock['SPEC CHECKSUMS']))
246
+ throw new Error(`${work}: installed pod checksums missing`)
247
+ for (const root of roots)
248
+ if (actualLock['SPEC CHECKSUMS'][root] !== installedChecksums[root])
249
+ throw new Error(`${work}: ${root} podspec checksum differs from ${lockFile}`)
250
+ const workspace = path.join(work, `${APP}.xcworkspace`)
251
+ const app = readXcodeAppTarget(workspace, APP, 'Release', { installedPods: true })
252
+ if (app.binaryFrameworks.length > 0)
253
+ throw new Error(
254
+ `${work}: source pod intake does not replace vendored binary frameworks`,
255
+ )
256
+ const root = openXcodeProject(workspace, APP, moduleRoot, 'Release')
257
+ try {
258
+ const input = compileInput(root, 'main.swift')
259
+ if (
260
+ Object.keys(input.images ?? {}).length > 0 ||
261
+ Object.values(input.resources ?? {}).some((encoded) => {
262
+ const bytes = Buffer.from(encoded, 'base64')
263
+ return !Buffer.from(bytes.toString('utf8')).equals(bytes)
264
+ })
265
+ )
266
+ throw new Error(
267
+ `${work}: binary pod resources require original binary file transport`,
268
+ )
269
+ const targets = swiftManifestTargets(input.files['Package.swift']!).filter(
270
+ (target) => !target.executable,
271
+ )
272
+ // Nitro carries only parsed dependency target calls; its consumer owns the executable.
273
+ for (const file of Object.keys(input.files))
274
+ if (file.startsWith('__app__/')) delete input.files[file]
275
+ input.files['SourcePodfile.lock'] = original
276
+ input.nativeTargets = input.nativeTargets?.filter((target) => target.name !== APP)
277
+ input.resourceBundles = input.resourceBundles?.filter(
278
+ (bundle) => bundle.target !== APP,
279
+ )
280
+ for (const module of modules)
281
+ if (roots.has(module) && !targets.some((target) => target.name === module))
282
+ throw new Error(`${work}: CocoaPods did not provide module ${module}`)
283
+ return input
284
+ } finally {
285
+ disposeSwiftProject(root)
286
+ }
287
+ })
288
+ }
@@ -31,6 +31,8 @@ import {
31
31
  IOS_SDK_ID,
32
32
  NATIVE_GRAPH_ID,
33
33
  OBJC_IMPORT_VERSION,
34
+ WASI_EMULATION,
35
+ WASI_EMULATION_FLAGS,
34
36
  nativeInterfaceView,
35
37
  objcView,
36
38
  type ObjcSurface,
@@ -48,7 +50,6 @@ import { sourceSwiftCheckout, swiftEnvironment, swiftSdkOptions } from './swift-
48
50
  import type { SwiftPackageBinary } from './swift-packages'
49
51
 
50
52
  const TRIPLE = 'wasm32-unknown-wasip1'
51
- const WASI_EMULATION = ['_WASI_EMULATED_SIGNAL', '_WASI_EMULATED_MMAN']
52
53
  // every stand-in artifact and temporary workspace belongs to peach.
53
54
  const cacheDir = path.join(peachCacheDir(), 'swift-standins')
54
55
  // each binary stand-in is a target under its module's directory here.
@@ -822,6 +823,7 @@ function cStandin(
822
823
  TRIPLE,
823
824
  '--sysroot',
824
825
  sysroot,
826
+ ...WASI_EMULATION_FLAGS,
825
827
  '-fsyntax-only',
826
828
  '-I',
827
829
  include,
@@ -897,6 +899,7 @@ function cStandin(
897
899
  TRIPLE,
898
900
  '--sysroot',
899
901
  sysroot,
902
+ ...WASI_EMULATION_FLAGS,
900
903
  '-fsyntax-only',
901
904
  '-I',
902
905
  include,
@@ -49,20 +49,20 @@ export function swiftSdkOptions(): string[] {
49
49
  }
50
50
 
51
51
  // host archives include the official driver/runtime and the qualified patched frontend.
52
- export const SWIFT_HOST_COMPILER_RELEASE = 'swift-6.4.0-RELEASE-custom-0d775d32d7c74eae'
53
- export const SWIFT_HOST_COMPILER_ID = '0d775d32d7c74eae'
52
+ export const SWIFT_HOST_COMPILER_RELEASE = 'swift-6.4.0-RELEASE-custom-8be2e4a7a393b003'
53
+ export const SWIFT_HOST_COMPILER_ID = '8be2e4a7a393b003'
54
54
  const compilerArchives: Record<string, { checksum: string; manifest: string }> = {
55
55
  'darwin-arm64': {
56
- checksum: '957e85486f92327ee5cf8d3c5bb9336d17ab80145c87645c637c49130a50477a',
57
- manifest: 'c63e2f81694e8d8ad046d10c71d0638dbae4e5a36601294ed670988d1cb5b6f1',
56
+ checksum: '88d69b7ac912962adaadce9fdb2c57fe07cd19e4d8158088e0acbd247496ca6d',
57
+ manifest: '70d5e2be8c959eb5dd1d9b576e6c209e1f58bfb9089f90c38c2d7e087759f0b3',
58
58
  },
59
59
  'linux-x64': {
60
- checksum: '6302230fb126b79c9af5fc2bc0208a936bb573c343da7ae949c5c1687e761cd2',
61
- manifest: '31b507a6a8648a2266a187b9fed092e29a63cae99d57c5defdf2e82a7cbbc113',
60
+ checksum: '7c42ded03742d16816e64f8ae8fca478aaaff450d22ab3d698daf78c010854b2',
61
+ manifest: '90cfb09c5a0ba8c119066787cf47244a45bf3cda68dce94c6b1a16337b9b91bd',
62
62
  },
63
63
  'linux-arm64': {
64
- checksum: '9b40d39ea5ba82fd9a417868f0a449f5e98e37cf83acaac9cedd3a8b8d91a218',
65
- manifest: 'fe07a29d4f4374cad47b29de70e90aa2e3b7664e08c8b53d304585e65637da24',
64
+ checksum: 'f9f1d96fb1a6325d3bb30ab12a75fc06e4e8535aab58a91581e03f3d91f68fa6',
65
+ manifest: 'f988181dce795f6c8a6d4a8d86f7b61768f23a743b4e7bea76e64862ef328ad6',
66
66
  },
67
67
  }
68
68
 
@@ -349,7 +349,9 @@ function verifySwiftSdk(swift: string, sdk: SwiftWasmSdk): void {
349
349
  function installSwiftSdkArchive(swift: string, sdk: SwiftWasmSdk, archive: string): void {
350
350
  validateSwiftSdkIdentity(sdk)
351
351
  const staging = fs.realpathSync(
352
- fs.mkdtempSync(path.join(scratch?.directory ?? os.tmpdir(), 'peach-sdk-verification-')),
352
+ fs.mkdtempSync(
353
+ path.join(scratch?.directory ?? os.tmpdir(), 'peach-sdk-verification-'),
354
+ ),
353
355
  )
354
356
  try {
355
357
  if (swiftFileChecksum(archive) !== sdk.wasmSdkChecksum)
@@ -430,7 +432,9 @@ export function installSwiftWasmSdk(release: string, sdk: SwiftWasmSdk): void {
430
432
  // an unverified existing SDK must be compared with the declared archive.
431
433
  }
432
434
  const swift = path.join(swiftCompiler(release), 'swift')
433
- const staging = fs.mkdtempSync(path.join(scratch?.directory ?? os.tmpdir(), 'builder-swift-sdk-'))
435
+ const staging = fs.mkdtempSync(
436
+ path.join(scratch?.directory ?? os.tmpdir(), 'builder-swift-sdk-'),
437
+ )
434
438
  const archive = path.join(staging, 'sdk.artifactbundle.tar.gz')
435
439
  try {
436
440
  if (sdk.wasmSdkUrl.startsWith('file:'))
@@ -514,6 +518,24 @@ export function swiftCompiler(release: string): string {
514
518
  return bin
515
519
  }
516
520
 
521
+ /**
522
+ * admission's compiler check: the pinned compiler is installed, or this host
523
+ * has its qualified archive and no tree at its destination, so preparation
524
+ * installs it (install-host-compiler.mjs) as it installs a missing SDK.
525
+ */
526
+ export function swiftCompilerAdmissible(release: string): void {
527
+ try {
528
+ swiftCompiler(release)
529
+ } catch (error) {
530
+ if (
531
+ !release.includes('-custom-') ||
532
+ fs.existsSync(path.resolve(swiftToolchainBin(release), '../..'))
533
+ )
534
+ throw error
535
+ swiftHostCompilerArchive(release)
536
+ }
537
+ }
538
+
517
539
  /** the command that installs and qualifies the pinned SDK for an installed compiler. */
518
540
  export function swiftSdkInstallStep(release: string, wasmSdk: SwiftWasmSdk): string {
519
541
  return `install the pinned SDK:\n ${swiftSdkInstallCommand(release, wasmSdk)}`
@@ -23,6 +23,7 @@ import {
23
23
  tagRnxBundleForPlugin,
24
24
  } from './dev-server-open'
25
25
  import { isDaemonLockfileFresh, readDaemonLockfile } from './home-paths'
26
+ import { serveBrowserProxyRoute } from './host/fetch-proxy-handler'
26
27
  import { handleReplacementModuleRequest } from './host/replacement-module-handler'
27
28
  import { forwardRolldownBundleResponse } from './host/rolldown-bundle-forward'
28
29
  import { readInstalledNativePackageVersions } from './installed-package-versions'
@@ -35,6 +36,7 @@ import {
35
36
  isRootRuntimeAssetPath,
36
37
  resolveRuntimeFilePath,
37
38
  resolveRuntimeRootForRequestHost,
39
+ sendShellHtml,
38
40
  serveRuntimeFile,
39
41
  SOOTSIM_RUNTIME_MISSING_MESSAGE,
40
42
  } from './runtime-assets'
@@ -553,6 +555,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
553
555
  })
554
556
 
555
557
  server.middlewares.use((req, res, next) => {
558
+ if (serveBrowserProxyRoute(req, res)) return
556
559
  const url = req.url || ''
557
560
  const pathname = url.split('?')[0]
558
561
  const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers.host)
@@ -583,8 +586,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
583
586
 
584
587
  // serve the peach HTML shell — inject bundle URL + bridge port
585
588
  if (pathname === prefix || pathname === prefix + '/') {
586
- res.setHeader('content-type', 'text/html')
587
- res.end(buildShellHtml(runtimeRoot, requestOrigin(req)))
589
+ sendShellHtml(res, buildShellHtml(runtimeRoot, requestOrigin(req)))
588
590
  return
589
591
  }
590
592
 
@@ -602,8 +604,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
602
604
  // extensionless in-shell routes should still load the shell.
603
605
  const ext = path.extname(pathname)
604
606
  if (!ext) {
605
- res.setHeader('content-type', 'text/html')
606
- res.end(buildShellHtml(runtimeRoot, requestOrigin(req)))
607
+ sendShellHtml(res, buildShellHtml(runtimeRoot, requestOrigin(req)))
607
608
  return
608
609
  }
609
610
  }
@@ -78,12 +78,18 @@ type MinifierSlot = {
78
78
  // bound lowering and minification together so pending chunks retain no rollup asts.
79
79
  const minifiers = new Set<MinifierSlot>()
80
80
  const pendingMinifiers: MinifierJob[] = []
81
+ // the build's admitted native thread budget sizes the pool. a tenant build's
82
+ // lowering stopped getting faster past four isolates and only grew heavier.
83
+ const threadBudget = Number(process.env.RAYON_NUM_THREADS)
84
+ const minifierLimit = Number.isSafeInteger(threadBudget)
85
+ ? Math.min(4, Math.max(2, threadBudget))
86
+ : 2
81
87
 
82
88
  function runMinifiers() {
83
89
  while (pendingMinifiers.length) {
84
90
  let slot = [...minifiers].find((candidate) => !candidate.job && !candidate.failure)
85
91
  if (!slot) {
86
- if (minifiers.size === 2) return
92
+ if (minifiers.size === minifierLimit) return
87
93
  let worker: Worker
88
94
  try {
89
95
  worker = new Worker(minifierWorker, {
@@ -84,6 +84,8 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
84
84
  rootDir: string
85
85
  /** every project file (project.pbxproj or project.xcproj) and xcconfig the app's build reads. */
86
86
  projectFiles: string[]
87
+ /** the source root of every project the app builds, which owns its build directory. */
88
+ projectDirs: string[]
87
89
  /** the target's processed launch plist, including generated build settings. */
88
90
  infoPlist: string
89
91
  infoPlistFile: string | null
@@ -1588,8 +1590,8 @@ export function readXcodeAppTarget(
1588
1590
  }
1589
1591
  }
1590
1592
 
1591
- // linked products: a remote reference names its repository; one without a
1592
- // package comes from a local package folder a project or the workspace references.
1593
+ // linked products retain their package identity. an unqualified product
1594
+ // searches the packages the workspace's projects reference.
1593
1595
  const localPackageDirs = [
1594
1596
  ...listed.filter((reference) => fs.existsSync(path.join(reference, 'Package.swift'))),
1595
1597
  ...projects.flatMap((project) =>
@@ -1624,7 +1626,21 @@ export function readXcodeAppTarget(
1624
1626
  }),
1625
1627
  ),
1626
1628
  ]
1629
+ const remotePackageUrls = [
1630
+ ...new Set(
1631
+ projects.flatMap((project) =>
1632
+ list(project.project.packageReferences).flatMap((id) => {
1633
+ const reference = project.object(id)
1634
+ const url = str(reference?.repositoryURL)
1635
+ return reference?.isa === 'XCRemoteSwiftPackageReference' && url ? [url] : []
1636
+ }),
1637
+ ),
1638
+ ),
1639
+ ]
1627
1640
  const linkedProducts: SwiftLinkedProduct[] = []
1641
+ const productReferences: { project: string; linked: SwiftLinkedProduct }[] = []
1642
+ const qualifiedProductKeys = new Set<string>()
1643
+ const linkedProductKeys = new Set<string>()
1628
1644
  const binaryFrameworks = new Map<string, string | null>()
1629
1645
  for (const { project, target } of order) {
1630
1646
  const productDependencies = [
@@ -1637,14 +1653,9 @@ export function readXcodeAppTarget(
1637
1653
  for (const dependencyId of productDependencies) {
1638
1654
  const dependency = project.object(dependencyId)
1639
1655
  const product = str(dependency?.productName)?.replace(/^plugin:/, '')
1640
- if (
1641
- !dependency ||
1642
- !product ||
1643
- linkedProducts.some((entry) => entry.product === product)
1644
- )
1645
- continue
1656
+ if (!dependency || !product) continue
1646
1657
  const reference = project.object(str(dependency.package))
1647
- linkedProducts.push({
1658
+ const linked: SwiftLinkedProduct = {
1648
1659
  product,
1649
1660
  source:
1650
1661
  reference?.isa === 'XCRemoteSwiftPackageReference'
@@ -1657,8 +1668,11 @@ export function readXcodeAppTarget(
1657
1668
  str(reference.relativePath) ?? '',
1658
1669
  ),
1659
1670
  }
1660
- : { kind: 'unnamed' },
1661
- })
1671
+ : { kind: 'unnamed', remoteUrls: remotePackageUrls },
1672
+ }
1673
+ productReferences.push({ project: project.projectFile, linked })
1674
+ if (linked.source.kind !== 'unnamed')
1675
+ qualifiedProductKeys.add(`${project.projectFile}\0${product}`)
1662
1676
  }
1663
1677
  // prebuilt frameworks the project vendors, as opposed to built products
1664
1678
  // and the sdk's own
@@ -1683,6 +1697,20 @@ export function readXcodeAppTarget(
1683
1697
  }
1684
1698
  }
1685
1699
 
1700
+ for (const { project, linked } of productReferences) {
1701
+ // unqualified framework members share the project's qualified product
1702
+ // dependency, even when that dependency appears later in the file.
1703
+ if (
1704
+ linked.source.kind === 'unnamed' &&
1705
+ qualifiedProductKeys.has(`${project}\0${linked.product}`)
1706
+ )
1707
+ continue
1708
+ const key = JSON.stringify(linked)
1709
+ if (linkedProductKeys.has(key)) continue
1710
+ linkedProductKeys.add(key)
1711
+ linkedProducts.push(linked)
1712
+ }
1713
+
1686
1714
  // xcode keeps the pins in the workspace it opened: the named one, or the project's own
1687
1715
  const resolvedFile = path.join(
1688
1716
  workspace ?? path.join(xcodeprojOrWorkspace, 'project.xcworkspace'),
@@ -1722,6 +1750,7 @@ export function readXcodeAppTarget(
1722
1750
  : []),
1723
1751
  ]),
1724
1752
  ].sort(),
1753
+ projectDirs: [...new Set(used.map((project) => project.projectDir))].sort(),
1725
1754
  appIconName: settings('ASSETCATALOG_COMPILER_APPICON_NAME'),
1726
1755
  infoPlist: plist.build(info),
1727
1756
  infoPlistFile,