peachsim 0.1.1728 → 0.1.1738

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 (172) hide show
  1. package/cli/commands/control.ts +1 -0
  2. package/cli/commands/coverage-swift.ts +112 -4
  3. package/cli/commands/package.ts +11 -1
  4. package/cli/commands/shell-url.ts +4 -0
  5. package/cli/scene-video.ts +24 -7
  6. package/detox/index.ts +9 -1
  7. package/dist-lib/agent-daemon-client.cjs +1 -1
  8. package/dist-lib/agent-events.cjs +1 -1
  9. package/dist-lib/attached-projects.cjs +5 -2
  10. package/dist-lib/auth/shared-session.cjs +5 -2
  11. package/dist-lib/backend-origin.cjs +1 -1
  12. package/dist-lib/beta.cjs +1 -1
  13. package/dist-lib/beta.mjs +1 -1
  14. package/dist-lib/bridge-constants.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.mjs +1 -1
  17. package/dist-lib/bridge-contract.cjs +1 -1
  18. package/dist-lib/bridge-contract.mjs +1 -1
  19. package/dist-lib/bundle-channel.cjs +3592 -1918
  20. package/dist-lib/capture-contract.cjs +1 -1
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cloud-contract.cjs +1 -1
  23. package/dist-lib/cloud-contract.mjs +1 -1
  24. package/dist-lib/cloud-test-args.cjs +1 -1
  25. package/dist-lib/cloud-test-args.mjs +1 -1
  26. package/dist-lib/cloud.cjs +1 -1
  27. package/dist-lib/cloud.mjs +1 -1
  28. package/dist-lib/config.cjs +1 -1
  29. package/dist-lib/config.mjs +1 -1
  30. package/dist-lib/detox/index.cjs +13 -5
  31. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  32. package/dist-lib/expo-swift-bundle.cjs +1329 -1022
  33. package/dist-lib/expo-swift-metadata.cjs +2 -2
  34. package/dist-lib/expo-swift-metadata.mjs +2 -2
  35. package/dist-lib/home-paths.cjs +7 -2
  36. package/dist-lib/host/bridge-host.cjs +3773 -2149
  37. package/dist-lib/host/fetch-proxy-handler.cjs +16 -5
  38. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  39. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  40. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  41. package/dist-lib/host/websocket-proxy.cjs +1 -1
  42. package/dist-lib/index.cjs +97 -68
  43. package/dist-lib/jump-to-source-babel.cjs +1 -1
  44. package/dist-lib/jump-to-source-native.cjs +1 -1
  45. package/dist-lib/kotlin-host.cjs +209 -32
  46. package/dist-lib/menu.cjs +7 -1
  47. package/dist-lib/menu.mjs +7 -1
  48. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  50. package/dist-lib/metro-production-bundle.cjs +1 -1
  51. package/dist-lib/metro-production-bundle.mjs +1 -1
  52. package/dist-lib/metro.cjs +93 -65
  53. package/dist-lib/native-app-identity-project.cjs +37 -31
  54. package/dist-lib/native-app-identity-project.mjs +37 -31
  55. package/dist-lib/native-app-identity.cjs +1 -1
  56. package/dist-lib/native-app-identity.mjs +1 -1
  57. package/dist-lib/native-firebase-metadata.cjs +1 -1
  58. package/dist-lib/native-firebase-metadata.mjs +1 -1
  59. package/dist-lib/plist.cjs +1 -1
  60. package/dist-lib/plist.mjs +1 -1
  61. package/dist-lib/profiles.cjs +5 -2
  62. package/dist-lib/public-brand.cjs +1 -1
  63. package/dist-lib/public-origins-lib-esm.json +23 -23
  64. package/dist-lib/public-origins-lib.json +79 -53
  65. package/dist-lib/react-native-host-modules.cjs +5 -2
  66. package/dist-lib/react-native-host-modules.mjs +5 -2
  67. package/dist-lib/reap-browser.cjs +1 -1
  68. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  69. package/dist-lib/sdk.cjs +1 -1
  70. package/dist-lib/sdk.mjs +1 -1
  71. package/dist-lib/skills.cjs +4486 -2789
  72. package/dist-lib/swift-compile.cjs +53 -60
  73. package/dist-lib/swift-compile.mjs +52 -60
  74. package/dist-lib/swift-package.cjs +1 -1
  75. package/dist-lib/swift-package.mjs +1 -1
  76. package/dist-lib/swift-submit.cjs +2 -2
  77. package/dist-lib/swift-submit.mjs +2 -2
  78. package/dist-lib/swift-toolchain.cjs +17 -17
  79. package/dist-lib/swift.cjs +1 -1
  80. package/dist-lib/vite-swift.cjs +1056 -870
  81. package/dist-lib/vite.cjs +20 -8
  82. package/dist-lib/worklet-executable.cjs +1 -1
  83. package/dist-lib/worklet-executable.mjs +1 -1
  84. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
  85. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -1
  86. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
  87. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +8 -0
  88. package/dist-types/packages/peach-engine/src/engine/node.d.ts +4 -1
  89. package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
  90. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
  91. package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
  92. package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
  93. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
  94. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +1 -0
  95. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +13 -1
  96. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  97. package/kotlin/README.md +3 -0
  98. package/kotlin/sdk.tar.gz +0 -0
  99. package/package.json +1 -1
  100. package/runtime-companion.json +1 -1
  101. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
  102. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
  103. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
  104. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
  105. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
  106. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
  107. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
  108. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
  109. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +1 -1
  110. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
  111. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +636 -37
  112. package/sdk/ios/usr/include/os/signpost.h +414 -0
  113. package/sdk/ios/usr/include/os.modulemap +5 -0
  114. package/sdk/ios/wasm/include/errno.h +4 -20
  115. package/sdk/ios/wasm/include/pthread.h +3 -0
  116. package/sdk/ios/wasm/include/setjmp.h +57 -0
  117. package/sdk/ios/wasm/include/sys/resource.h +2 -2
  118. package/sdk/native-hashes.json +3 -3
  119. package/skills/peach-debug/SKILL.md +0 -1
  120. package/skills/peach-perf/SKILL.md +0 -1
  121. package/skills/peach-setup/SKILL.md +0 -1
  122. package/skills/peach-test/SKILL.md +0 -1
  123. package/skills/peach-visual/SKILL.md +0 -1
  124. package/src/android-autolinking.ts +1 -0
  125. package/src/android-bridge-packages.ts +279 -0
  126. package/src/appPackageContract.ts +2 -0
  127. package/src/bundle-channel.mjs +20 -2
  128. package/src/cli-runtime.ts +9 -5
  129. package/src/expo-discovery-cache.ts +7 -3
  130. package/src/expo-kotlin-host.ts +97 -26
  131. package/src/expo-native-workspace.ts +135 -40
  132. package/src/expo-swift-host.ts +93 -20
  133. package/src/expo-swift-ready.ts +5 -1
  134. package/src/expoKotlinContract.ts +12 -2
  135. package/src/expoSwiftContract.ts +9 -2
  136. package/src/generated/swift-c-predefines.json +1 -1
  137. package/src/home-paths.ts +6 -1
  138. package/src/host/bridge-host.ts +5 -0
  139. package/src/host/fetch-proxy-handler.ts +10 -0
  140. package/src/kotlin-host.ts +204 -30
  141. package/src/kotlinSdkContract.ts +2 -1
  142. package/src/menu.ts +7 -0
  143. package/src/native-prebuilt.ts +154 -0
  144. package/src/nitro-adapter.lock.json +251 -251
  145. package/src/nitro-adapter.ts +56 -50
  146. package/src/nitro-bundle.ts +84 -74
  147. package/src/nitro-compile.ts +10 -5
  148. package/src/nitro-dependencies.ts +43 -28
  149. package/src/nitro-source.ts +60 -26
  150. package/src/nitroAdapterContract.ts +146 -98
  151. package/src/nitroContract.ts +64 -21
  152. package/src/react-native-bridge-modules.ts +2 -0
  153. package/src/react-native-host-modules.ts +4 -1
  154. package/src/settingsContract.ts +11 -0
  155. package/src/storageSnapshotContract.ts +29 -81
  156. package/src/swift-compile.ts +49 -50
  157. package/src/swift-coverage/indexdump.ts +22 -6
  158. package/src/swift-coverage/indexing.ts +4 -4
  159. package/src/swift-coverage/sdk.ts +104 -20
  160. package/src/swift-coverage/types.ts +34 -0
  161. package/src/swift-coverage/xcode.ts +9 -1
  162. package/src/swift-distribution.lock.json +15 -12
  163. package/src/swift-host.ts +3 -0
  164. package/src/swift-standin-emit.ts +6 -1
  165. package/src/swift-standins.ts +172 -10
  166. package/src/swift-submit.ts +5 -1
  167. package/src/swift-toolchain.ts +16 -16
  168. package/src/turbo-bundle.ts +81 -0
  169. package/src/turbo-compile.ts +120 -0
  170. package/src/turbo-runtime.lock.json +69 -0
  171. package/src/turbo-source.ts +754 -0
  172. package/src/vite-plugin-one.ts +4 -3
@@ -1,9 +1,10 @@
1
1
  // prepare Expo's own CocoaPods workspace in a private cache on the Mac.
2
- import { execFileSync, spawnSync } from 'node:child_process'
2
+ import { execFile, execFileSync } from 'node:child_process'
3
3
  import { createHash } from 'node:crypto'
4
4
  import fs from 'node:fs'
5
5
  import { createRequire } from 'node:module'
6
6
  import path from 'node:path'
7
+ import { promisify } from 'node:util'
7
8
  import { cacheDir } from './home-paths'
8
9
  import { withSwiftRootLock, type SwiftRootLease } from './swift-root-lock'
9
10
  import { findWorkspaceRoot } from './workspace-root'
@@ -20,19 +21,22 @@ const utf8Env = { ...process.env, LANG: 'en_US.UTF-8', LC_ALL: 'en_US.UTF-8' }
20
21
  // eas build archives a repository without its gitignored paths, so the prepare
21
22
  // neither copies nor hashes them: files a dev server generates into an ignored
22
23
  // directory never invalidate the prepared workspace.
23
- function workspaceExclusion(root: string) {
24
- const listed = spawnSync(
24
+ async function workspaceExclusion(root: string) {
25
+ const listed = await promisify(execFile)(
25
26
  'git',
26
27
  ['ls-files', '-z', '--others', '--ignored', '--exclude-standard', '--directory'],
27
- { cwd: root, encoding: 'utf8', env: { ...process.env, ...isolatedGitEnv } },
28
- )
28
+ {
29
+ cwd: root,
30
+ encoding: 'utf8',
31
+ maxBuffer: 256 * 1024 * 1024,
32
+ env: { ...process.env, ...isolatedGitEnv },
33
+ },
34
+ ).catch(() => ({ stdout: '' }))
29
35
  const ignored = new Set(
30
- listed.status === 0
31
- ? listed.stdout
32
- .split('\0')
33
- .filter(Boolean)
34
- .map((entry) => entry.replace(/\/$/, ''))
35
- : [],
36
+ listed.stdout
37
+ .split('\0')
38
+ .filter(Boolean)
39
+ .map((entry) => entry.replace(/\/$/, '')),
36
40
  )
37
41
  return (relative: string) => {
38
42
  const parts = relative.split(path.sep)
@@ -48,36 +52,37 @@ function workspaceExclusion(root: string) {
48
52
 
49
53
  // every file the native prepare can read, plus the toolchain that reads it.
50
54
  // node_modules stays out: the js install rebuilds it from the hashed lockfiles,
51
- // and the discovery cache keys the live native inventory separately.
52
- export function hashExpoWorkspace(
55
+ // and the discovery cache keys the live native inventory separately. the walk
56
+ // yields so the bridge that runs it keeps answering its other requests.
57
+ export async function hashExpoWorkspace(
53
58
  app: string,
54
59
  signal?: AbortSignal,
55
- ): {
60
+ ): Promise<{
56
61
  root: string
57
62
  appRelative: string
58
63
  hash: string
59
64
  excluded: (relative: string) => boolean
60
- } {
65
+ }> {
61
66
  const root = findWorkspaceRoot(app)
62
- const excluded = workspaceExclusion(root)
67
+ const excluded = await workspaceExclusion(root)
63
68
  const appRelative = path.relative(root, app)
64
69
  const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
65
70
  const hash = createHash('sha256')
66
- const walk = (directory: string) => {
67
- for (const entry of fs
68
- .readdirSync(directory, { withFileTypes: true })
69
- .sort((a, b) => a.name.localeCompare(b.name))) {
71
+ const walk = async (directory: string) => {
72
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true })
73
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
70
74
  signal?.throwIfAborted()
71
75
  const file = path.join(directory, entry.name)
72
76
  const relative = path.relative(root, file)
73
77
  if (excluded(relative)) continue
74
78
  hash.update(`${relative}\0`)
75
- if (entry.isSymbolicLink()) hash.update(`link\0${fs.readlinkSync(file)}\0`)
76
- else if (entry.isDirectory()) walk(file)
77
- else if (entry.isFile()) hash.update(fs.readFileSync(file))
79
+ if (entry.isSymbolicLink())
80
+ hash.update(`link\0${await fs.promises.readlink(file)}\0`)
81
+ else if (entry.isDirectory()) await walk(file)
82
+ else if (entry.isFile()) hash.update(await fs.promises.readFile(file))
78
83
  }
79
84
  }
80
- walk(root)
85
+ await walk(root)
81
86
  let podVersion: string
82
87
  try {
83
88
  podVersion = execFileSync('pod', ['--version'], { encoding: 'utf8', env: utf8Env })
@@ -96,6 +101,54 @@ export function hashExpoWorkspace(
96
101
  return { root, appRelative, hash: hash.digest('hex'), excluded }
97
102
  }
98
103
 
104
+ // each prepared workspace copies the app's repository with its installed
105
+ // dependencies and pods, often many gigabytes, and every source edit hashes to
106
+ // a new one. a prepare keeps the workspace it returns plus the newest other
107
+ // complete ones and retires the rest; a workspace used within the grace window
108
+ // always stays. a retired tree leaves the address space by rename before it is
109
+ // deleted, so a racing prepare sees a miss and rebuilds.
110
+ const KEPT_WORKSPACES = 2
111
+ const WORKSPACE_GRACE_MS = 3_600_000
112
+ // a prepare that died leaves an incomplete tree only a retry of its own hash
113
+ // would replace; no prepare runs for a day.
114
+ const ABANDONED_WORKSPACE_MS = 24 * 3_600_000
115
+ const RETIRED_PREFIX = '.retired-'
116
+
117
+ function pruneExpoNativeWorkspaces(parent: string, keep: string) {
118
+ const retire = (directory: string, used: number) => {
119
+ const retired = path.join(
120
+ parent,
121
+ `${RETIRED_PREFIX}${process.pid}-${path.basename(directory)}`,
122
+ )
123
+ // a workspace renewed since the scan is in use again.
124
+ if (fs.statSync(directory, { throwIfNoEntry: false })?.mtimeMs !== used) return
125
+ try {
126
+ fs.renameSync(directory, retired)
127
+ } catch (error) {
128
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return
129
+ throw error
130
+ }
131
+ fs.rmSync(retired, { recursive: true, force: true })
132
+ }
133
+ const complete: { directory: string; used: number }[] = []
134
+ for (const name of fs.readdirSync(parent)) {
135
+ const directory = path.join(parent, name)
136
+ if (name.startsWith(RETIRED_PREFIX)) {
137
+ fs.rmSync(directory, { recursive: true, force: true })
138
+ continue
139
+ }
140
+ const used = fs.statSync(directory, { throwIfNoEntry: false })?.mtimeMs
141
+ if (directory === keep || used === undefined) continue
142
+ if (fs.existsSync(path.join(directory, '.peach-complete')))
143
+ complete.push({ directory, used })
144
+ else if (Date.now() - used > ABANDONED_WORKSPACE_MS) retire(directory, used)
145
+ }
146
+ for (const { directory, used } of complete
147
+ .sort((a, b) => b.used - a.used)
148
+ .slice(KEPT_WORKSPACES - 1))
149
+ if (Date.now() - used > WORKSPACE_GRACE_MS) retire(directory, used)
150
+ }
151
+
99
152
  export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSignal) {
100
153
  if (process.platform !== 'darwin')
101
154
  throw new Error('Expo CocoaPods workspace preparation requires a Mac')
@@ -104,7 +157,7 @@ export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSign
104
157
  console.error(
105
158
  `[expo-native-workspace ${Math.round(performance.now() - started)}ms] ${message}`,
106
159
  )
107
- const { root, appRelative, hash, excluded } = hashExpoWorkspace(app, signal)
160
+ const { root, appRelative, hash, excluded } = await hashExpoWorkspace(app, signal)
108
161
  const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
109
162
  const appManifest = JSON.parse(fs.readFileSync(path.join(app, 'package.json'), 'utf8'))
110
163
  const work = path.join(cacheDir(), 'expo-native-workspaces', hash)
@@ -125,16 +178,36 @@ export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSign
125
178
  filter: (source) => !excluded(path.relative(root, source)),
126
179
  })
127
180
  fs.renameSync(partial, work)
128
- // a lifecycle script that installs git hooks needs a repository, and the copy gets its own
129
- execFileSync('git', ['init', '--quiet'], {
130
- cwd: work,
131
- env: { ...process.env, ...isolatedGitEnv },
132
- // init takes milliseconds; a wedged volume must fail loud, never hang discovery
133
- timeout: 60_000,
134
- })
181
+ // a lifecycle script that installs git hooks needs a repository, and the copy gets its own.
182
+ // an app config may read HEAD, so the repository carries one empty commit
183
+ for (const args of [
184
+ ['init', '--quiet'],
185
+ [
186
+ '-c',
187
+ 'user.name=peach',
188
+ '-c',
189
+ 'user.email=peach@localhost',
190
+ 'commit',
191
+ '--quiet',
192
+ '--allow-empty',
193
+ '--no-verify',
194
+ '-m',
195
+ 'prepared workspace',
196
+ ],
197
+ ])
198
+ execFileSync('git', args, {
199
+ cwd: work,
200
+ env: { ...process.env, ...isolatedGitEnv },
201
+ // these take milliseconds; a wedged volume must fail loud, never hang discovery
202
+ timeout: 60_000,
203
+ })
135
204
  report('copied workspace')
136
- const run = (command: string, args: string[], cwd: string) =>
137
- runAdmitted(lease, command, args, cwd, signal)
205
+ const run = (
206
+ command: string,
207
+ args: string[],
208
+ cwd: string,
209
+ env: Record<string, string> = {},
210
+ ) => runAdmitted(lease, command, args, cwd, env, signal)
138
211
  const manager =
139
212
  typeof manifest.packageManager === 'string' ? manifest.packageManager : 'npm'
140
213
  const nodeVersion =
@@ -167,18 +240,38 @@ export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSign
167
240
  }
168
241
  await execute(install, work)
169
242
  report('installed js dependencies')
170
- const expo = createRequire(path.join(preparedApp, 'package.json')).resolve(
171
- 'expo/bin/cli',
172
- )
243
+ const appRequire = createRequire(path.join(preparedApp, 'package.json'))
244
+ // an Expo-free One app declares its iOS project (deployment target
245
+ // included) in native.app, which only its own prebuild reads
246
+ const declares = (name: string) =>
247
+ ['dependencies', 'devDependencies'].some((field) =>
248
+ Object.hasOwn(appManifest[field] ?? {}, name),
249
+ )
250
+ const prebuild = declares('expo')
251
+ ? [appRequire.resolve('expo/bin/cli'), 'prebuild']
252
+ : [
253
+ path.join(path.dirname(appRequire.resolve('one/package.json')), 'run.mjs'),
254
+ 'prebuild',
255
+ ]
173
256
  await execute(
174
- ['node', expo, 'prebuild', '--platform', 'ios', '--no-install'],
257
+ ['node', ...prebuild, '--platform', 'ios', '--no-install'],
175
258
  preparedApp,
176
259
  )
177
- report('expo prebuild done')
178
- await run('pod', ['install'], path.join(preparedApp, 'ios'))
260
+ report('prebuild done')
261
+ // react-native-skia leaves Dawn to react-native-webgpu whenever that package
262
+ // is installed, but autolinking links it only into apps that declare it
263
+ await run(
264
+ 'pod',
265
+ ['install'],
266
+ path.join(preparedApp, 'ios'),
267
+ declares('react-native-webgpu') ? {} : { RNSKIA_VENDOR_DAWN: '1' },
268
+ )
179
269
  report('pod install done')
180
270
  fs.writeFileSync(marker, 'complete\n')
181
271
  }
272
+ const now = new Date()
273
+ fs.utimesSync(work, now, now)
274
+ pruneExpoNativeWorkspaces(path.dirname(work), work)
182
275
  const ios = path.join(preparedApp, 'ios')
183
276
  const workspaces = fs
184
277
  .readdirSync(ios)
@@ -196,6 +289,7 @@ async function runAdmitted(
196
289
  command: string,
197
290
  args: string[],
198
291
  cwd: string,
292
+ extraEnv: Record<string, string>,
199
293
  signal?: AbortSignal,
200
294
  ) {
201
295
  signal?.throwIfAborted()
@@ -210,6 +304,7 @@ async function runAdmitted(
210
304
  EXPO_NO_TELEMETRY: '1',
211
305
  LANG: 'en_US.UTF-8',
212
306
  LC_ALL: 'en_US.UTF-8',
307
+ ...extraEnv,
213
308
  },
214
309
  signal,
215
310
  },
@@ -521,6 +521,8 @@ function cloneUnits(units: ExpoSwiftSourceUnit[] | null): ExpoSwiftSourceUnit[]
521
521
  ...unit,
522
522
  classes: unit.classes.slice(),
523
523
  bridgeModules: unit.bridgeModules.slice(),
524
+ appDelegateSubscribers: unit.appDelegateSubscribers.slice(),
525
+ reactDelegateHandlers: unit.reactDelegateHandlers.slice(),
524
526
  frameworks: unit.frameworks.slice(),
525
527
  files: { ...unit.files },
526
528
  ...(unit.nativeFiles ? { nativeFiles: { ...unit.nativeFiles } } : {}),
@@ -590,11 +592,9 @@ function autolinkerAppleFlags(autolinkerManifest: string, appRoot: string) {
590
592
  )
591
593
  const atLeast = (m: number, n: number, p: number) =>
592
594
  major !== m ? major > m : minor !== n ? minor > n : patch >= p
593
- if (atLeast(1, 10, 3))
594
- return { args: ['--platform', 'apple', '--project-root', appRoot], cwd: undefined }
595
- if (atLeast(1, 8, 0))
596
- return { args: ['--platform', 'ios', '--project-root', appRoot], cwd: undefined }
597
- return { args: ['--platform', 'ios'], cwd: appRoot }
595
+ if (atLeast(1, 10, 3)) return ['--platform', 'apple', '--project-root', appRoot]
596
+ if (atLeast(1, 8, 0)) return ['--platform', 'ios', '--project-root', appRoot]
597
+ return ['--platform', 'ios']
598
598
  }
599
599
 
600
600
  // only omit a class when its module and every declared view have app-owned
@@ -740,11 +740,13 @@ async function collectExpoSwiftSourcesUncached(
740
740
  // before propagating errors so a failed request leaves no child running.
741
741
  const [searched, resolvedModules] = await Promise.allSettled(
742
742
  ['search', 'resolve'].map((command) =>
743
- run(process.execPath, [cli, command, ...flags.args, '--json'], {
743
+ run(process.execPath, [cli, command, ...flags, '--json'], {
744
744
  timeout: 120_000,
745
745
  maxBuffer: 8 * 1024 * 1024,
746
746
  env: scriptEnv,
747
- cwd: flags.cwd,
747
+ // autolinkers call process.cwd() at startup, which throws when the
748
+ // bridge's inherited cwd was deleted.
749
+ cwd: appRoot,
748
750
  signal,
749
751
  }),
750
752
  ),
@@ -780,7 +782,7 @@ async function collectExpoSwiftSourcesUncached(
780
782
  if (
781
783
  canonical.split(path.sep).includes('node_modules') &&
782
784
  (typeof packageName !== 'string' ||
783
- !COMPILED_EXPO_NATIVE_PACKAGES.includes(packageName))
785
+ !COMPILED_EXPO_NATIVE_PACKAGES.ios.includes(packageName))
784
786
  )
785
787
  continue
786
788
  // the autolinker read these in a child, so the parent can only stamp them
@@ -812,10 +814,22 @@ async function collectExpoSwiftSourcesUncached(
812
814
  resolution && typeof resolution === 'object'
813
815
  ? Reflect.get(resolution, 'pods')
814
816
  : null
817
+ const delegateNames = (key: string): unknown[] => {
818
+ const names =
819
+ resolution && typeof resolution === 'object' ? Reflect.get(resolution, key) : null
820
+ return Array.isArray(names) ? names : []
821
+ }
822
+ const subscriberNames = delegateNames('appDelegateSubscribers')
823
+ const handlerNames = delegateNames('reactDelegateHandlers')
815
824
  // a package with pods is rediscovered in the prepared workspace, which has no caps.
816
825
  const deferredToWorkspace =
817
826
  prepareNative && !installedWorkspace && Array.isArray(pods) && pods.length > 0
818
- if (!Array.isArray(modules) || modules.length === 0) continue
827
+ if (
828
+ (!Array.isArray(modules) || modules.length === 0) &&
829
+ subscriberNames.length === 0 &&
830
+ handlerNames.length === 0
831
+ )
832
+ continue
819
833
  if (
820
834
  !Array.isArray(namespaces) ||
821
835
  namespaces.length !== 1 ||
@@ -831,9 +845,14 @@ async function collectExpoSwiftSourcesUncached(
831
845
  namespacesSeen.add(namespace)
832
846
  const files: Record<string, string> = {}
833
847
  const frameworks = new Set<string>()
834
- const classes: { name: string; nativeName: string | null; registration: string }[] =
835
- []
836
- for (const module of modules) {
848
+ const classes: {
849
+ name: string
850
+ nativeName: string | null
851
+ registration: string | null
852
+ subscriber: string | null
853
+ handler: string | null
854
+ }[] = []
855
+ for (const module of Array.isArray(modules) ? modules : []) {
837
856
  const className =
838
857
  typeof module === 'string'
839
858
  ? module
@@ -855,9 +874,43 @@ async function collectExpoSwiftSourcesUncached(
855
874
  classes.push({
856
875
  name: className.split('.').pop()!,
857
876
  nativeName: name,
858
- registration: `(${className.includes('.') ? className : `${namespace}.${className}`}.self, ${name === null ? 'nil' : JSON.stringify(name)})`,
877
+ // a class named like its module shadows that module, so only the bare
878
+ // name reaches it; Swift's unqualified lookup finds the class.
879
+ registration: `(${className.includes('.') || className === namespace ? className : `${namespace}.${className}`}.self, ${name === null ? 'nil' : JSON.stringify(name)})`,
880
+ subscriber: null,
881
+ handler: null,
859
882
  })
860
883
  }
884
+ // a delegate class is compiled with its closure like a module class; one
885
+ // class may be both a module and a delegate
886
+ for (const [names, role] of [
887
+ [subscriberNames, 'subscriber'],
888
+ [handlerNames, 'handler'],
889
+ ] as const) {
890
+ for (const className of names) {
891
+ if (
892
+ typeof className !== 'string' ||
893
+ !/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(className)
894
+ )
895
+ throw new Error(`${sourceRoot}: invalid Expo Apple delegate descriptor`)
896
+ const name = className.split('.').pop()!
897
+ const reference = `${className.includes('.') || className === namespace ? className : `${namespace}.${className}`}.self`
898
+ const expression =
899
+ role === 'subscriber'
900
+ ? reference
901
+ : `(packageName: ${JSON.stringify(packageName)}, handler: ${reference})`
902
+ const existing = classes.find((item) => item.name === name)
903
+ if (existing) existing[role] = expression
904
+ else
905
+ classes.push({
906
+ name,
907
+ nativeName: null,
908
+ registration: null,
909
+ subscriber: role === 'subscriber' ? expression : null,
910
+ handler: role === 'handler' ? expression : null,
911
+ })
912
+ }
913
+ }
861
914
  const ios = path.join(canonical, 'ios')
862
915
  // an app's own module may share sources with its other native targets
863
916
  // through links that stay inside the app; installed packages stay sealed.
@@ -959,14 +1012,18 @@ async function collectExpoSwiftSourcesUncached(
959
1012
  walkFrameworks(canonical)
960
1013
  for (const module of classes) {
961
1014
  const closure = swiftSourceClosure(files, [module.name])
962
- if (configuredExpoSwiftModule(closure, module.name, module.nativeName, appConfig))
963
- continue
1015
+ const configured =
1016
+ module.registration !== null &&
1017
+ configuredExpoSwiftModule(closure, module.name, module.nativeName, appConfig)
1018
+ if (configured && !module.subscriber && !module.handler) continue
964
1019
  if (Array.isArray(pods) && pods.length > 0) needsNativeWorkspace = true
965
1020
  const unit: ExpoSwiftSourceUnit = {
966
1021
  namespace,
967
1022
  moduleId: `${namespace}.${module.name}`,
968
- classes: [module.registration],
1023
+ classes: module.registration && !configured ? [module.registration] : [],
969
1024
  bridgeModules: [],
1025
+ appDelegateSubscribers: module.subscriber ? [module.subscriber] : [],
1026
+ reactDelegateHandlers: module.handler ? [module.handler] : [],
970
1027
  files: closure,
971
1028
  frameworks: [...frameworks],
972
1029
  }
@@ -975,7 +1032,7 @@ async function collectExpoSwiftSourcesUncached(
975
1032
  }
976
1033
  }
977
1034
  if (prepareNative && !installedWorkspace && needsNativeWorkspace) {
978
- const discovery = expoDiscoveryKey({
1035
+ const discovery = await expoDiscoveryKey({
979
1036
  appRoot,
980
1037
  searchText: searched.value.stdout,
981
1038
  resolveText: resolvedText,
@@ -1071,6 +1128,8 @@ async function collectExpoSwiftSourcesUncached(
1071
1128
  moduleId: 'PeachExpoApp',
1072
1129
  classes: inlineClasses.map((name) => `(${name}.self, nil)`),
1073
1130
  bridgeModules: [],
1131
+ appDelegateSubscribers: [],
1132
+ reactDelegateHandlers: [],
1074
1133
  files: appFiles,
1075
1134
  frameworks: [],
1076
1135
  }
@@ -1094,9 +1153,13 @@ async function collectExpoSwiftSourcesUncached(
1094
1153
  const target = targets.find((item) => item.name === unit.namespace)
1095
1154
  const native = input.nativeTargets?.find((item) => item.name === unit.namespace)
1096
1155
  if (!target || !native) continue
1156
+ // cocoapods compiles each pod at its own SWIFT_VERSION
1157
+ unit.swiftLanguageMode = target.languageMode
1158
+ // package reads skip node_modules directories, so an installed pod's
1159
+ // unit takes its path below the package that ships it.
1097
1160
  const map = (file: string) =>
1098
1161
  file.startsWith(`${target.path}/`)
1099
- ? `Sources/${unit.namespace}/${file.slice(target.path.length + 1)}`
1162
+ ? `Sources/${unit.namespace}/${file.slice(target.path.length + 1).replace(/^(?:.*\/)?node_modules\//, '')}`
1100
1163
  : file
1101
1164
  const isDummyUnit = (file: string) =>
1102
1165
  /(?:^|\/)Target Support Files\/[^/]+\/[^/]+-dummy\.m$/.test(file)
@@ -1195,7 +1258,11 @@ async function collectExpoSwiftSourcesUncached(
1195
1258
  if (name.startsWith(`Sources/${namespace}/`)) unit.files[name] = source
1196
1259
  }
1197
1260
  }
1198
- unit.files['Package.swift'] = expoManifest(unit.files)
1261
+ unit.files['Package.swift'] = expoManifest(
1262
+ unit.files,
1263
+ '',
1264
+ languageModes([...included].flatMap((namespace) => byNamespace.get(namespace)!)),
1265
+ )
1199
1266
  }
1200
1267
  return units
1201
1268
  }
@@ -1238,7 +1305,13 @@ function expoEntry(units: ExpoSwiftSourceUnit[]): string {
1238
1305
  ),
1239
1306
  )
1240
1307
  const bridgeModules = units.flatMap((unit) => unit.bridgeModules)
1241
- return `import SwiftUI\nimport ExpoModulesCore\n${bridgeModules.length ? 'import React\n' : ''}${namespaces.map((namespace) => `import ${namespace}`).join('\n')}\n\n@main struct PeachExpoApp: PeachPackage {\n init() { MainActor.assumeIsolated { PeachExpoRuntime.register([${units.flatMap((unit) => unit.classes).join(', ')}])${bridgeModules.length ? `; RCTModuleHost.register([${bridgeModules.join(', ')}])` : ''} } }\n func view(props: JSON) -> PeachExpoNativeView { PeachExpoNativeView(props: props) }\n}\n\n@_expose(wasm, "peach_expo_call")\n@_cdecl("peach_expo_call")\n@MainActor public func peachExpoCall(_ payload: UnsafePointer<UInt8>?, _ length: Int32) -> UnsafeMutablePointer<UInt8>? {\n PeachExpoRuntime.dispatch(payload, length)\n}\n`
1308
+ const subscribers = units.flatMap((unit) => unit.appDelegateSubscribers)
1309
+ const handlers = units.flatMap((unit) => unit.reactDelegateHandlers)
1310
+ const delegates =
1311
+ subscribers.length + handlers.length > 0
1312
+ ? `; PeachExpoRuntime.registerDelegates(subscribers: [${subscribers.join(', ')}], handlers: [${handlers.join(', ')}])`
1313
+ : ''
1314
+ return `import SwiftUI\nimport ExpoModulesCore\n${bridgeModules.length ? 'import React\n' : ''}${namespaces.map((namespace) => `import ${namespace}`).join('\n')}\n\n@main struct PeachExpoApp: PeachPackage {\n init() { MainActor.assumeIsolated { PeachExpoRuntime.register([${units.flatMap((unit) => unit.classes).join(', ')}])${delegates}${bridgeModules.length ? `; RCTModuleHost.register([${bridgeModules.join(', ')}])` : ''} } }\n func view(props: JSON) -> PeachExpoNativeView { PeachExpoNativeView(props: props) }\n}\n\n@_expose(wasm, "peach_expo_call")\n@_cdecl("peach_expo_call")\n@MainActor public func peachExpoCall(_ payload: UnsafePointer<UInt8>?, _ length: Int32) -> UnsafeMutablePointer<UInt8>? {\n PeachExpoRuntime.dispatch(payload, length)\n}\n`
1242
1315
  }
1243
1316
 
1244
1317
  const compiling = new Map<
@@ -8,7 +8,7 @@ import { nodeHttpFetch } from './node-http-fetch'
8
8
  // 120s for its first tree. so `peach open` GETs the same endpoint the engine
9
9
  // will fetch and returns only once it answers. the bridge gives this open's
10
10
  // response to its first engine request. an app without local modules answers
11
- // null; the nitro endpoint is read the same way. a bridge older than this cli
11
+ // null; the nitro and turbo endpoints are read the same way. a bridge older than this cli
12
12
  // lacks the route and answers 404 without CORS headers, which the engine would report as
13
13
  // a guest CORS rejection, so a 404 reports the route and the possible cause.
14
14
  const EXPO_SWIFT_READY_PROGRESS_MS = 30_000
@@ -72,6 +72,7 @@ export async function awaitStampedExpoSwiftReady(
72
72
  const params = new URL(shellUrl).searchParams
73
73
  const expoSwift = params.get('expoSwift')
74
74
  const nitro = params.get('nitro')
75
+ const turbo = params.get('turbo')
75
76
  const preparationUrl = (address: string) => {
76
77
  const url = new URL(address)
77
78
  url.searchParams.set(NATIVE_PREPARE_QUERY_PARAM, openToken)
@@ -88,6 +89,9 @@ export async function awaitStampedExpoSwiftReady(
88
89
  nitro
89
90
  ? awaitExpoSwiftReady(preparationUrl(nitro), { signal: linked }, 'nitro modules')
90
91
  : null,
92
+ turbo
93
+ ? awaitExpoSwiftReady(preparationUrl(turbo), { signal: linked }, 'turbo modules')
94
+ : null,
91
95
  ])
92
96
  } catch (error) {
93
97
  siblings.abort(error)
@@ -9,6 +9,9 @@ export interface ExpoKotlinCompilationResult {
9
9
  namespaces: string[]
10
10
  module: { url: string; hash: string; compose: boolean } | null
11
11
  failures: { namespace: string; diagnostic: string }[]
12
+ // the namespaces the app's own legacy React Native modules answer for; the
13
+ // engine installs them as bridge modules, not as Expo modules
14
+ bridgeModules: string[]
12
15
  }
13
16
 
14
17
  export function readExpoKotlinMetadata(value: unknown): ExpoKotlinCompilationResult {
@@ -16,7 +19,8 @@ export function readExpoKotlinMetadata(value: unknown): ExpoKotlinCompilationRes
16
19
  if (
17
20
  !isRecord(value) ||
18
21
  !Array.isArray(value.namespaces) ||
19
- !Array.isArray(value.failures)
22
+ !Array.isArray(value.failures) ||
23
+ !Array.isArray(value.bridgeModules)
20
24
  )
21
25
  throw invalid()
22
26
  const namespaces: string[] = []
@@ -24,6 +28,11 @@ export function readExpoKotlinMetadata(value: unknown): ExpoKotlinCompilationRes
24
28
  if (typeof namespace !== 'string') throw invalid()
25
29
  namespaces.push(namespace)
26
30
  }
31
+ const bridgeModules: string[] = []
32
+ for (const namespace of value.bridgeModules) {
33
+ if (typeof namespace !== 'string') throw invalid()
34
+ bridgeModules.push(namespace)
35
+ }
27
36
  const failures: ExpoKotlinCompilationResult['failures'] = []
28
37
  for (const failure of value.failures) {
29
38
  if (
@@ -35,7 +44,7 @@ export function readExpoKotlinMetadata(value: unknown): ExpoKotlinCompilationRes
35
44
  failures.push({ namespace: failure.namespace, diagnostic: failure.diagnostic })
36
45
  }
37
46
  const module = value.module
38
- if (module === null) return { namespaces, module: null, failures }
47
+ if (module === null) return { namespaces, module: null, failures, bridgeModules }
39
48
  if (
40
49
  !isRecord(module) ||
41
50
  typeof module.url !== 'string' ||
@@ -47,6 +56,7 @@ export function readExpoKotlinMetadata(value: unknown): ExpoKotlinCompilationRes
47
56
  namespaces,
48
57
  module: { url: module.url, hash: module.hash, compose: module.compose },
49
58
  failures,
59
+ bridgeModules,
50
60
  }
51
61
  }
52
62
 
@@ -2,8 +2,11 @@ import { insertBundleGlobalFooter, readBundleGlobalFooter } from './bundleGlobal
2
2
  import { isRecord } from './is-record'
3
3
  import type { SwiftNativeTarget } from './swiftContract'
4
4
 
5
- // installed Expo modules whose native implementation is compiled by the shared host.
6
- export const COMPILED_EXPO_NATIVE_PACKAGES: readonly string[] = ['expo-app-intents']
5
+ // installed Expo packages whose unchanged native source the shared hosts compile
6
+ // on each platform; every other installed package keeps its native seam there.
7
+ export const COMPILED_EXPO_NATIVE_PACKAGES: Readonly<
8
+ Record<'ios' | 'android', readonly string[]>
9
+ > = { ios: ['expo-app-intents'], android: [] }
7
10
 
8
11
  export interface ExpoSwiftPreparationOptions {
9
12
  signal?: AbortSignal
@@ -16,6 +19,10 @@ export interface ExpoSwiftSourceUnit {
16
19
  classes: string[]
17
20
  // legacy bridge module registrations (react-native-bridge-modules.ts)
18
21
  bridgeModules: string[]
22
+ // expressions for the Expo app delegate subscribers and react delegate
23
+ // handlers the unit registers, as the autolinked Apple provider lists them
24
+ appDelegateSubscribers: string[]
25
+ reactDelegateHandlers: string[]
19
26
  files: Record<string, string>
20
27
  frameworks: string[]
21
28
  nativeTargets?: SwiftNativeTarget[]
@@ -1,5 +1,5 @@
1
1
  {
2
- "release": "swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66",
2
+ "release": "swift-6.4.0-RELEASE-custom-81b2c791c27276bf",
3
3
  "languages": {
4
4
  "c": {
5
5
  "TARGET_IPHONE_SIMULATOR": "1",
package/src/home-paths.ts CHANGED
@@ -46,10 +46,15 @@ export const CONFIG_FILE = 'config.json'
46
46
  export const CLI_UPDATE_FILE = 'cli-update.json'
47
47
  export const DAEMON_HEARTBEAT_STALE_MS = 30_000
48
48
 
49
+ // the user's own peach home, whatever PEACH_HOME isolates for this process.
50
+ export function ambientHomeDir(): string {
51
+ return path.join(homedir(), '.peach')
52
+ }
53
+
49
54
  export function rnxHomeDir(): string {
50
55
  const override = process.env[PEACH_HOME_ENV]
51
56
  if (override && override.length > 0) return path.resolve(override)
52
- return path.join(homedir(), '.peach')
57
+ return ambientHomeDir()
53
58
  }
54
59
 
55
60
  // detect when peach is running from a source checkout (the Contrast monorepo)
@@ -53,6 +53,7 @@ import {
53
53
  sendFileWithRanges,
54
54
  } from '../runtime-assets.ts'
55
55
  import { rnxRuntime } from '../runtime-delivery.ts'
56
+ import { handleTurboRequest, TURBO_ROUTE } from '../turbo-bundle.ts'
56
57
  import { AgentHost, type AgentHostOptions } from './agent-host.ts'
57
58
  import { serveAppPackageResource } from './app-package-handler'
58
59
  import {
@@ -1554,6 +1555,10 @@ export class SootSimBridgeHost {
1554
1555
  void handleNitroRequest(req, res)
1555
1556
  return
1556
1557
  }
1558
+ if (req.url?.split('?')[0] === TURBO_ROUTE) {
1559
+ void handleTurboRequest(req, res)
1560
+ return
1561
+ }
1557
1562
  if (
1558
1563
  req.url?.startsWith('/__peach/expo-swift') ||
1559
1564
  req.url?.startsWith('/__peach/swift')
@@ -485,6 +485,7 @@ async function proxyUpstream(
485
485
  else proxyReq.end(nextBody)
486
486
  })
487
487
  const proxyRes = await send().finally(() => req.off('aborted', markAborted))
488
+ upstreamAnswered = true
488
489
 
489
490
  const status = proxyRes.statusCode ?? 502
490
491
  const location = proxyRes.headers.location
@@ -547,6 +548,7 @@ async function proxyUpstream(
547
548
  await pipeline(proxyRes, res)
548
549
  }
549
550
 
551
+ let upstreamAnswered = false
550
552
  let body: Buffer | undefined
551
553
  try {
552
554
  if (req.method !== 'GET' && req.method !== 'HEAD') {
@@ -561,6 +563,10 @@ async function proxyUpstream(
561
563
  await proxy(upstreamUrl, originalMethod, body, 0, [])
562
564
  } catch (err) {
563
565
  const norm = normalizeHostname(upstreamUrl.hostname)
566
+ // an upstream that answered while this host then failed to forward it is a
567
+ // host defect the page can only see as a dropped connection, so name it
568
+ if (upstreamAnswered && !res.headersSent)
569
+ console.error(`[peach] fetch proxy could not forward ${upstreamUrl.href}:`, err)
564
570
  if (
565
571
  !res.headersSent &&
566
572
  isLoopbackHost(norm) &&
@@ -601,6 +607,10 @@ async function proxyUpstream(
601
607
  res.end()
602
608
  return
603
609
  }
610
+ // network errors carry a code; anything else is ours (a missing companion)
611
+ // and would otherwise leave only an empty reply
612
+ if (!(err instanceof Error && 'code' in err))
613
+ console.error('[peach] fetch proxy failed:', err)
604
614
  // an upstream that cannot be reached fails the page's request the way a
605
615
  // direct fetch would: as a network error, never a response. a synthetic
606
616
  // 5xx reads as a live server answering (the bundle loader then polls it as