peachsim 0.1.1813 → 0.1.1815

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 (136) hide show
  1. package/README.md +2 -1
  2. package/cli/cloud-client.ts +5 -4
  3. package/cli/cloud-session.ts +14 -1
  4. package/cli/commands/compat.ts +12 -2
  5. package/cli/commands/control.ts +10 -2
  6. package/cli/commands/flow.ts +10 -5
  7. package/cli/commands/inspect/env.ts +3 -2
  8. package/cli/commands/inspect/wait-selector.ts +30 -9
  9. package/cli/commands/inspect.ts +43 -385
  10. package/cli/commands/package.ts +6 -1
  11. package/cli/commands/runtime.ts +2 -2
  12. package/cli/outbound-endpoints.ts +1 -1
  13. package/dist-lib/agent-daemon-client.cjs +1 -1
  14. package/dist-lib/agent-events.cjs +1 -1
  15. package/dist-lib/attached-projects.cjs +1 -1
  16. package/dist-lib/auth/shared-session.cjs +1 -1
  17. package/dist-lib/backend-origin.cjs +1 -1
  18. package/dist-lib/beta.cjs +1 -1
  19. package/dist-lib/beta.mjs +1 -1
  20. package/dist-lib/bridge-constants.cjs +1 -1
  21. package/dist-lib/bridge-contract-input.cjs +1 -1
  22. package/dist-lib/bridge-contract-input.mjs +1 -1
  23. package/dist-lib/bridge-contract.cjs +1 -1
  24. package/dist-lib/bridge-contract.mjs +1 -1
  25. package/dist-lib/bundle-channel.cjs +769 -512
  26. package/dist-lib/capture-contract.cjs +1 -1
  27. package/dist-lib/capture-contract.mjs +1 -1
  28. package/dist-lib/cloud-contract.cjs +1 -1
  29. package/dist-lib/cloud-contract.mjs +1 -1
  30. package/dist-lib/cloud-test-args.cjs +1 -1
  31. package/dist-lib/cloud-test-args.mjs +1 -1
  32. package/dist-lib/cloud.cjs +1 -1
  33. package/dist-lib/cloud.mjs +1 -1
  34. package/dist-lib/config.cjs +1 -1
  35. package/dist-lib/config.mjs +1 -1
  36. package/dist-lib/detox/index.cjs +89 -14
  37. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  38. package/dist-lib/expo-swift-bundle.cjs +125 -57
  39. package/dist-lib/expo-swift-metadata.cjs +1 -17
  40. package/dist-lib/expo-swift-metadata.mjs +1 -16
  41. package/dist-lib/home-paths.cjs +1 -1
  42. package/dist-lib/host/bridge-host.cjs +2490 -2290
  43. package/dist-lib/host/fetch-proxy-handler.cjs +14 -14
  44. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  45. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  46. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  47. package/dist-lib/host/websocket-proxy.cjs +1 -1
  48. package/dist-lib/index.cjs +19 -21
  49. package/dist-lib/jump-to-source-babel.cjs +1 -1
  50. package/dist-lib/jump-to-source-native.cjs +1 -1
  51. package/dist-lib/kotlin-host.cjs +1 -1
  52. package/dist-lib/menu.cjs +1 -1
  53. package/dist-lib/menu.mjs +1 -1
  54. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  55. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  56. package/dist-lib/metro-production-bundle.cjs +1 -1
  57. package/dist-lib/metro-production-bundle.mjs +1 -1
  58. package/dist-lib/metro.cjs +16 -17
  59. package/dist-lib/native-app-identity-project.cjs +5 -4
  60. package/dist-lib/native-app-identity-project.mjs +8 -7
  61. package/dist-lib/native-app-identity.cjs +1 -1
  62. package/dist-lib/native-app-identity.mjs +1 -1
  63. package/dist-lib/native-firebase-metadata.cjs +1 -1
  64. package/dist-lib/native-firebase-metadata.mjs +1 -1
  65. package/dist-lib/pdfium-raster.cjs +1 -1
  66. package/dist-lib/pdfium-raster.mjs +1 -1
  67. package/dist-lib/plist.cjs +1 -1
  68. package/dist-lib/plist.mjs +1 -1
  69. package/dist-lib/profiles.cjs +1 -1
  70. package/dist-lib/public-brand.cjs +1 -1
  71. package/dist-lib/public-origins-lib-esm.json +24 -24
  72. package/dist-lib/public-origins-lib.json +77 -77
  73. package/dist-lib/react-native-host-modules.cjs +1 -1
  74. package/dist-lib/react-native-host-modules.mjs +1 -1
  75. package/dist-lib/reap-browser.cjs +1 -1
  76. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  77. package/dist-lib/sdk.cjs +1 -1
  78. package/dist-lib/sdk.mjs +1 -1
  79. package/dist-lib/skills.cjs +851 -541
  80. package/dist-lib/swift-compile.cjs +29 -27
  81. package/dist-lib/swift-compile.mjs +36 -34
  82. package/dist-lib/swift-package.cjs +1 -1
  83. package/dist-lib/swift-package.mjs +1 -1
  84. package/dist-lib/swift-submit.cjs +2 -2
  85. package/dist-lib/swift-submit.mjs +2 -2
  86. package/dist-lib/swift-toolchain.cjs +5 -3
  87. package/dist-lib/swift.cjs +1 -1
  88. package/dist-lib/vite-swift.cjs +100 -46
  89. package/dist-lib/vite.cjs +14 -14
  90. package/dist-lib/worklet-executable.cjs +1 -1
  91. package/dist-lib/worklet-executable.mjs +1 -1
  92. package/dist-types/packages/peach-engine/src/engine/nativeReplayContract.d.ts +2 -0
  93. package/dist-types/packages/peach-engine/src/react-native/host-services.d.ts +7 -0
  94. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +14 -2
  95. package/install.mjs +21 -8
  96. package/package.json +1 -1
  97. package/runtime-companion.json +1 -1
  98. package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h +17 -0
  99. package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +5 -0
  100. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -0
  101. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +10 -1
  102. package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
  103. package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +11 -0
  104. package/sdk/ios/usr/lib/swift/UIKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +13 -0
  105. package/sdk/ios/wasm/include/string.h +1 -0
  106. package/src/cli-runtime.ts +32 -4
  107. package/src/expo-kotlin-host.ts +69 -35
  108. package/src/expo-swift-host.ts +45 -9
  109. package/src/expo-swift-ready.ts +16 -2
  110. package/src/expoSwiftContract.ts +2 -20
  111. package/src/installed-native-libraries.ts +79 -18
  112. package/src/nitro-adapter.lock.json +251 -251
  113. package/src/nitro-bundle.ts +2 -8
  114. package/src/nitro-compile.ts +6 -3
  115. package/src/nitro-dependencies.ts +8 -2
  116. package/src/nitro-source.ts +34 -3
  117. package/src/nitro-superset.lock.json +14 -14
  118. package/src/nitro-superset.ts +2 -3
  119. package/src/nitroContract.ts +26 -32
  120. package/src/react-native-bridge-modules.ts +2 -9
  121. package/src/runtime-delivery.ts +2 -2
  122. package/src/swift-compile.ts +4 -1
  123. package/src/swift-distribution.lock.json +9 -8
  124. package/src/swift-distribution.ts +1 -0
  125. package/src/swift-icu.ts +21 -27
  126. package/src/swift-installed-targets.ts +13 -0
  127. package/src/swift-project-user.ts +5 -0
  128. package/src/swift-shared-sdk.ts +4 -0
  129. package/src/swift-standins.ts +14 -3
  130. package/src/swift-submit.ts +2 -1
  131. package/src/swift-toolchain.ts +5 -2
  132. package/src/swift-wasm-prune.ts +10 -2
  133. package/src/turbo-bundle.ts +20 -1
  134. package/src/turbo-compile.ts +6 -12
  135. package/src/turbo-runtime.lock.json +18 -18
  136. package/src/turbo-source.ts +176 -37
@@ -17,35 +17,6 @@ export const NITRO_GUEST_PLATFORM = 'ios'
17
17
  * (react-native-xcode.sh), so the guest bundle's mode selects it. */
18
18
  export type NitroBuildConfiguration = 'Debug' | 'Release'
19
19
 
20
- /** installed Nitro providers whose original native source Peach compiles in
21
- * place of any hand-written answer. */
22
- export const COMPILED_NITRO_NATIVE_PACKAGES: readonly string[] = [
23
- 'react-native-nitro-base64',
24
- 'react-native-nitro-buffer',
25
- 'react-native-nitro-geocoder',
26
- 'react-native-nitro-haptics',
27
- 'react-native-nitro-sound',
28
- 'react-native-nitro-cookies',
29
- 'react-native-nitro-geolocation',
30
- 'react-native-nitro-markdown',
31
- 'react-native-nitro-network-info',
32
- 'react-native-nitro-audio-manager',
33
- 'react-native-nitro-sqlite',
34
- 'react-native-nitro-sensors-kit',
35
- 'react-native-nitro-speech',
36
- ]
37
-
38
- /** installed C++ TurboModule providers whose original native source Peach
39
- * compiles in place of any hand-written answer. */
40
- export const COMPILED_TURBO_NATIVE_PACKAGES: readonly string[] = [
41
- '@expensify/react-native-wallet',
42
- 'react-native-background-actions',
43
- 'react-native-get-random-values',
44
- 'react-native-quick-base64',
45
- 'react-native-screenshot-aware',
46
- 'stream-chat-expo',
47
- ]
48
-
49
20
  interface CompiledModule<Package> {
50
21
  platform: typeof NITRO_GUEST_PLATFORM
51
22
  /** the original providers this one executable registers, by package name. */
@@ -76,7 +47,10 @@ export type NitroCompiledModule = CompiledModule<
76
47
  >
77
48
  /** an app's compiled C++ TurboModule providers. the module names they
78
49
  * register are read from the executable, as React Native reads its map. */
79
- export type TurboCompiledModule = CompiledModule<CompiledPackage>
50
+ export type TurboCompiledModule = CompiledModule<CompiledPackage> & {
51
+ /** installed providers left out because they link a prebuilt binary, with why. */
52
+ unavailable?: { name: string; diagnostic: string }[]
53
+ }
80
54
 
81
55
  function readCompiledPackage(value: unknown): CompiledPackage | null {
82
56
  if (typeof value !== 'object' || value === null) return null
@@ -172,8 +146,28 @@ function readCompiledMetadata<Package extends CompiledPackage>(
172
146
 
173
147
  export const readNitroMetadata = (value: unknown): NitroCompiledModule | null =>
174
148
  readCompiledMetadata('Nitro', value, readNitroPackage, (entry) => entry.hybridObjects)
175
- export const readTurboMetadata = (value: unknown): TurboCompiledModule | null =>
176
- readCompiledMetadata('TurboModule', value, readCompiledPackage, () => [])
149
+ export function readTurboMetadata(value: unknown): TurboCompiledModule | null {
150
+ const metadata = readCompiledMetadata(
151
+ 'TurboModule',
152
+ value,
153
+ readCompiledPackage,
154
+ () => [],
155
+ )
156
+ if (!metadata) return null
157
+ const listed = Reflect.get(Object(value), 'unavailable')
158
+ if (listed === undefined) return metadata
159
+ if (!Array.isArray(listed)) throw new Error('invalid TurboModule compilation metadata')
160
+ const unavailable = listed.map((entry) => {
161
+ if (
162
+ !isRecord(entry) ||
163
+ typeof entry.name !== 'string' ||
164
+ typeof entry.diagnostic !== 'string'
165
+ )
166
+ throw new Error('invalid TurboModule compilation metadata')
167
+ return { name: entry.name, diagnostic: entry.diagnostic }
168
+ })
169
+ return { ...metadata, unavailable }
170
+ }
177
171
 
178
172
  export function readNitroFooter(source: string): NitroCompiledModule | null {
179
173
  return readNitroMetadata(readBundleMetadataFooter(source, 'nitro'))
@@ -9,10 +9,6 @@ import path from 'node:path'
9
9
  import { PEACH_ANSWERED_NATIVE_PACKAGE_NAMES } from '../../peach-compat/src/generated/supported-native-packages'
10
10
 
11
11
  const answeredPackages: ReadonlySet<string> = new Set(PEACH_ANSWERED_NATIVE_PACKAGE_NAMES)
12
- import {
13
- COMPILED_EXPO_NATIVE_PACKAGES,
14
- type ExpoSwiftSourceUnit,
15
- } from './expoSwiftContract'
16
12
  import { swiftCodeMask, swiftSourceClosure } from './swift-compile'
17
13
  import { xcodeNativeFlags, xcodeObjCInputs } from './swift-objc-compile'
18
14
  import { SWIFT_NATIVE_INPUT_ROOT, SWIFT_NATIVE_SDK_INCLUDE } from './swiftContract'
@@ -21,6 +17,7 @@ import {
21
17
  listXcodeAppTargets,
22
18
  readXcodeAppTarget,
23
19
  } from './xcode-project'
20
+ import type { ExpoSwiftSourceUnit } from './expoSwiftContract'
24
21
 
25
22
  interface MethodInfo {
26
23
  jsName: string
@@ -620,11 +617,7 @@ function collectInstalledSwiftBridgeUnits(
620
617
  const namespacesSeen = new Set(units.map((unit) => unit.namespace))
621
618
  for (const packageName of Object.keys(dependencies).sort()) {
622
619
  signal?.throwIfAborted()
623
- if (
624
- answeredPackages.has(packageName) &&
625
- !COMPILED_EXPO_NATIVE_PACKAGES.ios.includes(packageName)
626
- )
627
- continue
620
+ if (answeredPackages.has(packageName)) continue
628
621
  let pkgRoot: string | null = null
629
622
  try {
630
623
  pkgRoot = fs.realpathSync(
@@ -11,7 +11,7 @@
11
11
  // out as a bare require.
12
12
 
13
13
  import { createRuntimeDelivery, type RuntimeProduct } from '@contrast/runtime-delivery'
14
- import { verifyCliCompanion } from './cli-runtime'
14
+ import { ensureCliCompanion } from './cli-runtime'
15
15
  import {
16
16
  cacheDir,
17
17
  configFilePath,
@@ -38,7 +38,7 @@ export const RNX_RUNTIME_PRODUCT: RuntimeProduct = {
38
38
  // engine-tenant/ beneath it. index.html is what the daemon and the
39
39
  // vite/metro plugins serve, so its absence means the tarball is not one.
40
40
  installedMarker: 'index.html',
41
- verifyInstall: verifyCliCompanion,
41
+ verifyInstall: ensureCliCompanion,
42
42
  env: {
43
43
  cdnOrigin: 'PEACH_CDN_ORIGIN',
44
44
  channel: 'PEACH_RUNTIME_CHANNEL',
@@ -174,6 +174,7 @@ async function runCompiler(
174
174
  const child = options.lease
175
175
  ? options.lease.spawn(command, args, launch, options.frameworkLease)
176
176
  : spawn(command, args, launch)
177
+ // cross-request-promise: one child process owns this stop, inside the call that spawned it
177
178
  let stopping: Promise<void> | undefined
178
179
  try {
179
180
  return await new Promise<string>((resolve, reject) => {
@@ -795,7 +796,8 @@ const OPTIONAL_FRAMEWORK_DEPENDENCIES: Record<string, string[]> = {
795
796
  TOCropViewController: [],
796
797
  RiveRuntime: ['MetalKit'],
797
798
  MetalKit: ['ModelIO'],
798
- DatadogCore: [],
799
+ DatadogInternal: [],
800
+ DatadogCore: ['DatadogInternal'],
799
801
  DatadogLogs: ['DatadogCore'],
800
802
  DatadogRUM: ['DatadogCore'],
801
803
  DatadogTrace: ['DatadogCore'],
@@ -5511,6 +5513,7 @@ function projectDiagnostic(
5511
5513
  }
5512
5514
 
5513
5515
  const ROOT_LOCKS = Symbol.for('peachsim.swiftCompile.rootLocks')
5516
+ // cross-request-promise: swift builds run only in node (cli, dev server, build container), never a worker
5514
5517
  const host = globalThis as typeof globalThis & {
5515
5518
  [ROOT_LOCKS]?: Map<string, Promise<unknown>>
5516
5519
  }
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "af69e0877dcfc948",
2
+ "id": "92d08dea86eafc17",
3
3
  "release": "swift-6.4.0-RELEASE-custom-a560ff35bf882b5c",
4
4
  "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-5d385b68",
5
5
  "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-5d385b68.artifactbundle.tar.gz",
6
6
  "wasmSdkChecksum": "d91882af99821a296c3db4459896b46ceaef37e9a30caad14e5f24cf6b964ae9",
7
- "source": "85e7a5155755f4400d2bd7010abdd09f62dd6f34",
7
+ "source": "e5fb86f09228f6a9802a802657fea000ed6a3118",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -138,6 +138,7 @@
138
138
  "ModelIOEnums",
139
139
  "ModelIO",
140
140
  "MetalKit",
141
+ "DatadogInternal",
141
142
  "DatadogCore",
142
143
  "DatadogLogs",
143
144
  "DatadogRUM",
@@ -230,16 +231,16 @@
230
231
  },
231
232
  "hosts": {
232
233
  "darwin-arm64": {
233
- "sha256": "dd96208b7ea40e1d8e93d61a716e30191a5e57800074e65837222c042617b96e",
234
- "size": 99097618
234
+ "sha256": "b97c1ef24c74d88fe5b03240ac21017959884861a7ab3d298bc4b97e74e1bd02",
235
+ "size": 98848007
235
236
  },
236
237
  "linux-x64": {
237
- "sha256": "bd0ef2a7d0fab414a415a9c2619c0c8c890b792856b1cbdb158a6f74b8d75502",
238
- "size": 101817050
238
+ "sha256": "2beb12ad379dc2e618029a69c36b92d55c8f1b43b78e9600d97c13f17a1dab8f",
239
+ "size": 101566420
239
240
  },
240
241
  "linux-arm64": {
241
- "sha256": "37006a7363e6af15a31c65afaa3d6e0480bdd59c5d835f923e44e69dcae81e53",
242
- "size": 101308927
242
+ "sha256": "5ea72a514d3f67aaf477babb848c14177b57b6cbc1671ea075075586a4c38d6a",
243
+ "size": 101056003
243
244
  }
244
245
  }
245
246
  }
@@ -57,6 +57,7 @@ export interface SwiftModule {
57
57
  toolchainBin: string
58
58
  }
59
59
 
60
+ // cross-request-promise: distribution installs run only in node (cli, build container), never a worker
60
61
  const installs = new Map<
61
62
  string,
62
63
  {
package/src/swift-icu.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { execFile } from 'node:child_process'
2
- import { createHash } from 'node:crypto'
2
+ import { createHash, randomUUID } from 'node:crypto'
3
3
  import { existsSync, readFileSync } from 'node:fs'
4
4
  import { mkdir, readFile, rename, writeFile } from 'node:fs/promises'
5
5
  import os from 'node:os'
@@ -34,10 +34,10 @@ const compressBrotli = promisify(brotliCompress)
34
34
  const inflateGzip = promisify(gunzip)
35
35
  const ARCHIVE = 'wasi/lib_FoundationICU.a'
36
36
  const MEMBER = 'icu_packaged_data.cpp.obj'
37
- const raw = new Map<string, Promise<Buffer>>()
38
- const assets = new Map<string, Promise<SwiftIcuAsset>>()
39
- const brotliMemoryCache = new Map<string, Promise<Buffer>>()
40
- function cachedBrotli(
37
+ const raw = new Map<string, Buffer>()
38
+ const assets = new Map<string, SwiftIcuAsset>()
39
+ const brotliMemoryCache = new Map<string, Buffer>()
40
+ async function cachedBrotli(
41
41
  bytes: Buffer,
42
42
  quality: 4 | 11,
43
43
  cacheKey?: string,
@@ -51,13 +51,11 @@ function cachedBrotli(
51
51
  if (cached) return cached
52
52
  const dir = path.join(os.homedir(), '.peach', 'cache', 'swift-brotli')
53
53
  const file = path.join(dir, `${key}${quality === 11 ? '' : '-q4'}.br`)
54
- const pending = (async () => {
55
- try {
56
- return await readFile(file)
57
- } catch {
58
- // an unreadable cache entry is recomputed
59
- }
60
- const compressed = await compressBrotli(bytes, {
54
+ let compressed: Buffer
55
+ try {
56
+ compressed = await readFile(file)
57
+ } catch {
58
+ compressed = await compressBrotli(bytes, {
61
59
  params: {
62
60
  [zlibConstants.BROTLI_PARAM_QUALITY]: quality,
63
61
  [zlibConstants.BROTLI_PARAM_LGWIN]: 24,
@@ -65,17 +63,15 @@ function cachedBrotli(
65
63
  })
66
64
  try {
67
65
  await mkdir(dir, { recursive: true })
68
- const tmp = `${file}.${process.pid}.${Date.now()}.tmp`
66
+ const tmp = `${file}.${randomUUID()}.tmp`
69
67
  await writeFile(tmp, compressed)
70
68
  await rename(tmp, file)
71
69
  } catch {
72
70
  // cache persistence is opportunistic
73
71
  }
74
- return compressed
75
- })()
76
- brotliMemoryCache.set(cacheId, pending)
77
- void pending.catch(() => brotliMemoryCache.delete(cacheId))
78
- return pending
72
+ }
73
+ brotliMemoryCache.set(cacheId, compressed)
74
+ return compressed
79
75
  }
80
76
 
81
77
  // release assets pay the quality 11 cost once; dev requests use quality 4 so
@@ -102,18 +98,16 @@ export async function swiftIcuBrotliQ4(icu: SwiftIcuAsset): Promise<Buffer> {
102
98
  )
103
99
  }
104
100
 
105
- function memo<T>(
106
- cache: Map<string, Promise<T>>,
101
+ async function memo<T>(
102
+ cache: Map<string, T>,
107
103
  key: string,
108
104
  load: () => Promise<T>,
109
105
  ): Promise<T> {
110
- let pending = cache.get(key)
111
- if (!pending) {
112
- pending = load()
113
- pending.catch(() => cache.delete(key))
114
- cache.set(key, pending)
115
- }
116
- return pending
106
+ const cached = cache.get(key)
107
+ if (cached !== undefined) return cached
108
+ const value = await load()
109
+ cache.set(key, value)
110
+ return value
117
111
  }
118
112
 
119
113
  /** the raw blob, for a harness that fills an artifact in node. */
@@ -137,6 +137,19 @@ export function applyInstalledSwiftTargets(
137
137
  const module = moduleMapName(snapshot.input.files[file] ?? '')
138
138
  return !collection.targets.some((target) => target.name === module)
139
139
  })
140
+ // a header the installed search paths already supply, and its module covers,
141
+ // must not also reach the target as a second textual copy
142
+ for (const file of Object.keys(collection.files)) {
143
+ const prefix = `${generated.path}/include/`
144
+ if (!file.startsWith(prefix)) continue
145
+ const include = file.slice(prefix.length)
146
+ if (
147
+ native.headerSearchPaths.some(
148
+ (directory) => snapshot.input.files[`${directory}/${include}`] !== undefined,
149
+ )
150
+ )
151
+ delete collection.files[file]
152
+ }
140
153
  const flags = originalModuleFlags(native.flags)
141
154
  generated.clangSettings = [
142
155
  { tool: 'c', flags: [...flags, ...ndebug, ...search] },
@@ -161,6 +161,11 @@ export function resetSwiftProjectState(root: string, user: SwiftProjectUser): vo
161
161
  '-ignore_readdir_race',
162
162
  '-user',
163
163
  String(user.uid),
164
+ // the build root is the user's after prepareSwiftProjectProcess; removing
165
+ // it would fail every later build in this container
166
+ '!',
167
+ '-path',
168
+ root,
164
169
  '-delete',
165
170
  ])
166
171
  }
@@ -29,6 +29,8 @@ export function swiftSharedSdkRoot(moduleRoot: string, distribution: boolean): s
29
29
  if (!fs.existsSync(headers)) {
30
30
  fs.mkdirSync(path.dirname(headers), { recursive: true })
31
31
  const staging = fs.mkdtempSync(`${headers}-`)
32
+ // mkdtemp is owner-only; the unprivileged project compiler reads the view
33
+ fs.chmodSync(staging, 0o755)
32
34
  fs.cpSync(root, staging, { recursive: true, preserveTimestamps: true })
33
35
  try {
34
36
  fs.renameSync(staging, headers)
@@ -292,6 +294,8 @@ export function swiftSharedSdkViewOptions(
292
294
  if (!fs.existsSync(manifest)) {
293
295
  fs.mkdirSync(path.dirname(view), { recursive: true })
294
296
  const staging = fs.mkdtempSync(`${view}-`)
297
+ // mkdtemp is owner-only; the unprivileged project compiler reads the view
298
+ fs.chmodSync(staging, 0o755)
295
299
  const realRoot = path.dirname(bundle)
296
300
  // headers in the sysroot include each other through "..", and the os resolves ".."
297
301
  // through a symlinked directory into the real bundle, which would make one file's
@@ -305,12 +305,18 @@ function stageDeclaredFramework(
305
305
  ): void {
306
306
  const name = path.basename(framework, '.framework')
307
307
  const own = `${name}-Swift.h`
308
- const modulemap = fs.readFileSync(
308
+ const declaration = fs.readFileSync(
309
309
  path.join(framework, 'Modules/module.modulemap'),
310
310
  'utf8',
311
311
  )
312
+ // expo's use_frameworks setup removes React's framework module from the pod's
313
+ // module map, so the module is declared again from the umbrella the framework ships.
314
+ const modulemap = declaration.includes(`framework module ${name}`)
315
+ ? declaration
316
+ : `framework module ${name} {\n umbrella header "${name}-umbrella.h"\n export *\n}\n`
312
317
  const umbrella = /umbrella header "([^"]+)"/.exec(modulemap)?.[1]
313
- if (!umbrella) throw new Error(`${name} module map names no umbrella header`)
318
+ if (!umbrella || !fs.existsSync(path.join(framework, 'Headers', umbrella)))
319
+ throw new Error(`${name} module map names no umbrella header`)
314
320
  const headers = new Map(
315
321
  fs
316
322
  .readdirSync(path.join(framework, 'Headers'))
@@ -680,12 +686,17 @@ function peachModuleDirs(
680
686
  peach.has(name),
681
687
  )
682
688
  const plugins = swiftMacroPlugins(moduleRoot)
683
- if (plugins.stale)
689
+ if (plugins.stale) {
684
690
  exec('sh', [
685
691
  path.join(moduleRoot, 'scripts/build-preview-plugin.sh'),
686
692
  toolchainBin,
687
693
  plugins.libraries[0]!,
688
694
  ])
695
+ fs.writeFileSync(
696
+ path.join(path.dirname(plugins.libraries[0]!), 'compiler-release'),
697
+ `${toolchain.release}\n`,
698
+ )
699
+ }
689
700
  for (const target of targets)
690
701
  exec(
691
702
  path.join(toolchainBin, 'swift'),
@@ -135,7 +135,8 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
135
135
  // UIApplication.isIdleTimerDisabled.
136
136
  // 60: `peach.net_en0_ipv4` answers the en0 IPv4 address getifaddrs lists.
137
137
  // 61: `peach.dyld_image_uuid` supplies the compiled app image identity.
138
- export const SWIFT_HOST_ABI = 61
138
+ // 62: fetch headers replies carry `setCookies`, the response's Set-Cookie list.
139
+ export const SWIFT_HOST_ABI = 62
139
140
 
140
141
  export interface SwiftImageUpload {
141
142
  /** the raster file picked for the asset (has the extension). */
@@ -345,8 +345,11 @@ export function ensureSwiftLinuxRuntime(release: string): void {
345
345
  fs.rmSync(download, { force: true })
346
346
  }
347
347
  }
348
- fs.rmSync(plan.link, { force: true })
349
- fs.symlinkSync('../../libxml2.so.2', plan.link)
348
+ // a concurrent compile reads this link, so replace it by rename, never remove it first
349
+ const staged = `${plan.link}.${process.pid}.tmp`
350
+ fs.rmSync(staged, { force: true })
351
+ fs.symlinkSync('../../libxml2.so.2', staged)
352
+ fs.renameSync(staged, plan.link)
350
353
  // the archive's merged-usr sysroot supplies native manifest startup objects.
351
354
  for (const name of ['lib', 'lib64']) {
352
355
  try {
@@ -1066,6 +1066,13 @@ export function pruneSwiftWasmLink(
1066
1066
  }
1067
1067
  }
1068
1068
 
1069
+ // a nested type's descriptor reaches its parent by a relative offset the
1070
+ // assembler resolves without a relocation when both sit in one segment.
1071
+ for (let n = pref.length - 1; n > 2; n--) {
1072
+ const outer = pref.slice(0, n)
1073
+ if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer)
1074
+ }
1075
+
1069
1076
  const mnName = `${pref}Mn`
1070
1077
  for (let i = 0; i < obj.symNames.length; i++) {
1071
1078
  if (obj.symNames[i] === mnName && (obj.symFlags[i]! & 0x10) === 0) {
@@ -1744,9 +1751,10 @@ export function pruneSwiftWasmLink(
1744
1751
  prunedMap.set(o.file, outPath)
1745
1752
  }
1746
1753
 
1747
- const extraCoreConcurrencyObjs = allSdkObjFiles
1754
+ const extraSdkObjs = allSdkObjFiles
1748
1755
  .filter(
1749
1756
  (f) =>
1757
+ f.startsWith('libDarwin__') ||
1750
1758
  (f.startsWith('libswiftCore__') && f !== 'libswiftCore__Swift.o') ||
1751
1759
  (f.startsWith('libswift_Concurrency__') &&
1752
1760
  f !== 'libswift_Concurrency___Concurrency.o'),
@@ -1786,7 +1794,7 @@ export function pruneSwiftWasmLink(
1786
1794
  }
1787
1795
  }
1788
1796
  }
1789
- outTokens.push(...extraCoreConcurrencyObjs)
1797
+ outTokens.push(...extraSdkObjs)
1790
1798
  continue
1791
1799
  }
1792
1800
  if (t === '--end-lib') {
@@ -1,6 +1,7 @@
1
1
  import { createRequire } from 'node:module'
2
2
  import path from 'node:path'
3
3
  import { prepareNativeAppRoot } from './expo-native-workspace'
4
+ import { installedNativeLibraries } from './installed-native-libraries'
4
5
  import {
5
6
  compiledModuleAssets,
6
7
  compiledModuleRequestHandler,
@@ -10,6 +11,7 @@ import { swiftDistributionRoot } from './swift-distribution'
10
11
  import { icuUrl, type SwiftArtifact } from './swift-host'
11
12
  import { compileTurboModule } from './turbo-compile'
12
13
  import { discoverTurboProviders } from './turbo-source'
14
+ import { installedXcodeWorkspace } from './xcode-project'
13
15
  import type { TurboCompiledModule } from './nitroContract'
14
16
 
15
17
  export const TURBO_ROUTE = '/__peach/turbo'
@@ -38,6 +40,21 @@ export async function compileTurboApp(
38
40
  // the app's own committed ios directory has no installed pods: the compile
39
41
  // reads the prepared workspace, as the Nitro compile does
40
42
  const projectRoot = await prepareNativeAppRoot(appRoot)
43
+ const installed = installedXcodeWorkspace(projectRoot)
44
+ ? installedNativeLibraries(providers, projectRoot, module, iosTarget)
45
+ : null
46
+ // a provider that links a prebuilt binary stays out of the executable, so
47
+ // the app finds its modules absent where it calls them, as on a device
48
+ // that never linked the pod.
49
+ const unavailable = [...(installed?.unavailable ?? [])].map(([name, diagnostic]) => ({
50
+ name,
51
+ diagnostic,
52
+ }))
53
+ const compiled = providers.filter(({ name }) => !installed?.unavailable.has(name))
54
+ if (compiled.length === 0) {
55
+ for (const { diagnostic } of unavailable) console.warn(`[peach] ${diagnostic}`)
56
+ return null
57
+ }
41
58
  const { artifact, collection } = await compileTurboModule({
42
59
  appRoot,
43
60
  reactNativeRoot: path.dirname(
@@ -45,10 +62,11 @@ export async function compileTurboApp(
45
62
  'react-native/package.json',
46
63
  ),
47
64
  ),
48
- providers,
65
+ providers: compiled,
49
66
  moduleRoot: module,
50
67
  projectRoot,
51
68
  iosTarget,
69
+ installedPods: installed?.pods,
52
70
  })
53
71
  return {
54
72
  artifact,
@@ -59,6 +77,7 @@ export async function compileTurboApp(
59
77
  hash: artifact.hash,
60
78
  icuUrl: icuUrl(origin, artifact),
61
79
  bundleFiles: artifact.package.bundleFiles.files,
80
+ ...(unavailable.length > 0 ? { unavailable } : {}),
62
81
  },
63
82
  }
64
83
  }
@@ -2,7 +2,6 @@ import { createHash } from 'node:crypto'
2
2
  import fs from 'node:fs'
3
3
  import os from 'node:os'
4
4
  import path from 'node:path'
5
- import { installedNativeLibraries } from './installed-native-libraries'
6
5
  import { readIosAppTarget } from './native-app-identity-project'
7
6
  import {
8
7
  committedAdapterLocks,
@@ -36,6 +35,7 @@ import {
36
35
  collectTurboSources,
37
36
  prepareTurboSourceDependencies,
38
37
  TURBO_CORE_TARGET,
38
+ type TurboInstalledPod,
39
39
  type TurboProvider,
40
40
  type TurboSourceCollection,
41
41
  } from './turbo-source'
@@ -171,6 +171,8 @@ export async function compileTurboModule(options: {
171
171
  moduleRoot: string
172
172
  projectRoot: string
173
173
  iosTarget?: string
174
+ /** the installed workspace's pods; without them the podspecs' literal source membership applies. */
175
+ installedPods?: ReadonlyMap<string, TurboInstalledPod>
174
176
  }): Promise<{ artifact: SwiftArtifact; collection: TurboSourceCollection }> {
175
177
  await prepareTurboSourceDependencies(options.reactNativeRoot)
176
178
  const key = createHash('sha256')
@@ -186,15 +188,7 @@ export async function compileTurboModule(options: {
186
188
  reactNativeRoot: options.reactNativeRoot,
187
189
  providers: options.providers,
188
190
  codegenDir: path.join(scratch, 'codegen'),
189
- // without installed pods the podspecs' literal source membership applies
190
- installedPods: installedXcodeWorkspace(options.projectRoot)
191
- ? installedNativeLibraries(
192
- options.providers,
193
- options.projectRoot,
194
- options.moduleRoot,
195
- options.iosTarget,
196
- )
197
- : undefined,
191
+ installedPods: options.installedPods,
198
192
  })
199
193
  const swiftTargets = collection.targets.filter((target) =>
200
194
  Object.keys(collection.files).some(
@@ -211,7 +205,7 @@ export async function compileTurboModule(options: {
211
205
  options.projectRoot,
212
206
  `Swift TurboModule providers (${workspaceSwift.map(({ name }) => name).join(', ')})`,
213
207
  )
214
- await prepareXcodeSwiftPackages(workspace)
208
+ await prepareXcodeSwiftPackages(workspace, options.iosTarget)
215
209
  await withXcodeProject(
216
210
  workspace,
217
211
  {
@@ -298,7 +292,7 @@ export async function compileTurboModule(options: {
298
292
  options.projectRoot,
299
293
  `the modules no collected source provides (${missing.join(', ')})`,
300
294
  )
301
- await prepareXcodeSwiftPackages(workspace)
295
+ await prepareXcodeSwiftPackages(workspace, options.iosTarget)
302
296
  dependencies = await withXcodeProject(
303
297
  workspace,
304
298
  {
@@ -12,7 +12,7 @@
12
12
  "checksum": "d91882af99821a296c3db4459896b46ceaef37e9a30caad14e5f24cf6b964ae9"
13
13
  },
14
14
  "framework": {
15
- "distribution": "af69e0877dcfc948",
15
+ "distribution": "92d08dea86eafc17",
16
16
  "wireAbi": "246b8412514b644113e6a26252c8ebd6de49ab4156ac5f5c98bb9e4c2ff2568b"
17
17
  },
18
18
  "archives": [
@@ -20,64 +20,64 @@
20
20
  "headers": {
21
21
  "reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
22
22
  },
23
- "sha256": "42f42eaba0cbbc305c26bc45b64b19a9c22a1782550873707cc2a94d5226450e",
24
- "size": 25406
23
+ "sha256": "1c025e16714e307807927e6dc402e5969380379348b81239ae0e51893579bf86",
24
+ "size": 25410
25
25
  },
26
26
  {
27
27
  "headers": {
28
28
  "reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
29
29
  },
30
- "sha256": "5de281f851fc5bcc41103be001ac54fd3380fdbe508a306a80ef50065a828d4f",
31
- "size": 26142
30
+ "sha256": "5f3ff09bd19438a4241b04886b8faed29653c9a0496f71456fed04773024743d",
31
+ "size": 26143
32
32
  },
33
33
  {
34
34
  "headers": {
35
35
  "reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
36
36
  },
37
- "sha256": "a15c6b4b615e997e449bbc26c237d7b01c17518e290ec2d25290dd1afe5d8fec",
38
- "size": 25398
37
+ "sha256": "f338727cb59425568a5431cb46fee1929a0eeb7e74e137784c3a6b4032e3b8f7",
38
+ "size": 25399
39
39
  },
40
40
  {
41
41
  "headers": {
42
42
  "reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
43
43
  },
44
- "sha256": "d7e2c1bb4ae3f9e7ae7d72123b9ad32e2c0662607b124cbf42c47aa229e252c0",
44
+ "sha256": "aa26e40d43b57677bae9770d4fae08005974d97727ede149a6075ec1e9f49330",
45
45
  "size": 25175
46
46
  },
47
47
  {
48
48
  "headers": {
49
49
  "reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
50
50
  },
51
- "sha256": "ad4a1e580e01af0f0af9d4f60c4cff765e8208297148674d0904c5a4bbb9bb0f",
52
- "size": 25407
51
+ "sha256": "b16b3f3357aa86ad40c207bbb81d4a4ce21152f7c9dfdc092e4d070895dd1868",
52
+ "size": 25410
53
53
  },
54
54
  {
55
55
  "headers": {
56
56
  "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
57
57
  },
58
- "sha256": "59746bf6932eb3ac91e52a1117c7a03f3b7c2eedf4747dd9aa3cbfd2edc23daa",
59
- "size": 26142
58
+ "sha256": "38ea876c785d0febcf2428d98d539e7394c0fd25b930843750a8a24352973736",
59
+ "size": 26143
60
60
  },
61
61
  {
62
62
  "headers": {
63
63
  "reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
64
64
  },
65
- "sha256": "6c9e3167ca6aa79c95ba785803d07548dc2f5f437f071128888ee7cca695b630",
66
- "size": 26143
65
+ "sha256": "a5874458a8784cfa5aaea1f4e2ca3b5a5de1c1f0192daae419a4b1b0d4d921f4",
66
+ "size": 26144
67
67
  },
68
68
  {
69
69
  "headers": {
70
70
  "reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
71
71
  },
72
- "sha256": "a19e57ff608a43a42d5832eda613cde0bd23c17de5580237681e92d891f8f90d",
73
- "size": 25273
72
+ "sha256": "d2032854a6a40112f989cc819eb08ea810872bf8f0493da984ac73baffb68381",
73
+ "size": 25275
74
74
  },
75
75
  {
76
76
  "headers": {
77
77
  "reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
78
78
  },
79
- "sha256": "8df00d552caf87b6ca0119a827ed3ac63a1b2852f14541ec0edb63dc79d35df7",
80
- "size": 26147
79
+ "sha256": "6c0ef47aa726477eeb9fd3968287b90aca798f47777eaaccb526ca41dce1430e",
80
+ "size": 26149
81
81
  }
82
82
  ]
83
83
  }