peachsim 0.1.780 → 0.1.782

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 (83) hide show
  1. package/cli/commands/detox.ts +6 -2
  2. package/detox/expectations.ts +1 -1
  3. package/detox/gestures.ts +1 -1
  4. package/detox/index.ts +27 -3
  5. package/detox/navigation-lifecycle.ts +1 -1
  6. package/dist-lib/agent-daemon-client.cjs +1 -1
  7. package/dist-lib/agent-events.cjs +1 -1
  8. package/dist-lib/agent-identity.cjs +1 -1
  9. package/dist-lib/agent-sessions.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/capture-contract.cjs +1 -1
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cli-constants.cjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/detox/index.cjs +3533 -133
  31. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +6781 -2442
  34. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +4664 -1266
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +1114 -2
  50. package/dist-lib/native-app-identity.cjs +1 -1
  51. package/dist-lib/native-app-identity.mjs +1 -1
  52. package/dist-lib/native-firebase-metadata.cjs +1 -1
  53. package/dist-lib/native-firebase-metadata.mjs +1 -1
  54. package/dist-lib/plist.cjs +1 -1
  55. package/dist-lib/plist.mjs +1 -1
  56. package/dist-lib/profiles.cjs +1 -1
  57. package/dist-lib/public-brand.cjs +1 -1
  58. package/dist-lib/react-native-host-modules.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.mjs +1 -1
  60. package/dist-lib/render-mode.cjs +1 -1
  61. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  62. package/dist-lib/sdk.cjs +1 -1
  63. package/dist-lib/sdk.mjs +1 -1
  64. package/dist-lib/skills.cjs +9017 -366
  65. package/dist-lib/swift-compile.cjs +1 -1
  66. package/dist-lib/swift-compile.mjs +1 -1
  67. package/dist-lib/swift-package.cjs +1 -1
  68. package/dist-lib/swift-package.mjs +1 -1
  69. package/dist-lib/swift-submit.cjs +1 -1
  70. package/dist-lib/swift-submit.mjs +1 -1
  71. package/dist-lib/swift-toolchain.cjs +1 -1
  72. package/dist-lib/swift.cjs +1 -1
  73. package/dist-lib/vite-swift.cjs +2229 -583
  74. package/dist-lib/vite.cjs +38 -16
  75. package/package.json +1 -1
  76. package/skills/contrast/SKILL.md +2 -0
  77. package/src/one-widget-package.ts +202 -0
  78. package/src/oneWidgetContract.ts +16 -0
  79. package/src/swift-host.ts +56 -29
  80. package/src/swift-standin-emit.ts +471 -242
  81. package/src/swift-standins.ts +288 -40
  82. package/src/vite-plugin-one.ts +45 -17
  83. package/src/vite-plugin-swift.ts +2 -0
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.780 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.782 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -901,6 +901,36 @@ function rnxPlugin(options = {}) {
901
901
  swiftPackages ??= swiftPackageDirectories(server.config.root);
902
902
  return swiftPackages;
903
903
  };
904
+ let widgetPackage = null;
905
+ const servedPackage = async (packageName) => {
906
+ const host = await loadSwiftHost();
907
+ const existing = packageMap().get(packageName);
908
+ if (packageName !== host.ONE_WIDGET_PACKAGE) return existing;
909
+ widgetPackage = await host.oneWidgetPackage(server.config.root);
910
+ if (!widgetPackage) return existing;
911
+ if (existing)
912
+ throw new Error(
913
+ `swift package ${packageName} conflicts with One's generated widget extension`
914
+ );
915
+ server.watcher.add(widgetPackage.watched);
916
+ return widgetPackage.packagePath;
917
+ };
918
+ const packageMetadata = async (packageName, moduleRoot) => {
919
+ const packagePath = await servedPackage(packageName);
920
+ if (!packagePath) throw new Error(`swift package ${packageName} was not found`);
921
+ const host = await loadSwiftHost();
922
+ const metadata = await host.swiftPackageMetadata(
923
+ packagePath,
924
+ packageName,
925
+ moduleRoot,
926
+ devOrigin()
927
+ );
928
+ return {
929
+ ...metadata,
930
+ hmrPath,
931
+ ...packageName === host.ONE_WIDGET_PACKAGE && widgetPackage ? { widget: widgetPackage.widget } : {}
932
+ };
933
+ };
904
934
  const wsOptions = server.config.server.ws;
905
935
  const httpServer = server.httpServer ?? (wsOptions && typeof wsOptions === "object" ? wsOptions.server : void 0);
906
936
  const swiftSockets = httpServer ? new import_ws.WebSocketServer({ noServer: true }) : void 0;
@@ -967,28 +997,20 @@ function rnxPlugin(options = {}) {
967
997
  try {
968
998
  packages = packageMap();
969
999
  } catch (error) {
970
- for (const packageName of activeSwiftPackages) {
1000
+ for (const packageName of activeSwiftPackages)
971
1001
  sendSwiftChange({
972
1002
  type: "error",
973
1003
  packageName,
974
1004
  message: error instanceof Error ? error.message : String(error)
975
1005
  });
976
- }
977
1006
  return;
978
1007
  }
979
1008
  for (const packageName of activeSwiftPackages) {
980
1009
  const packagePath = packages.get(packageName);
981
- if (!packagePath) continue;
982
- if (!file.startsWith(`${packagePath}${import_path2.default.sep}`) && !(moduleRoot && file.startsWith(`${moduleRoot}${import_path2.default.sep}`)))
1010
+ const widgetChanged = packageName === "OneWidgets" && widgetPackage?.watched.includes(file);
1011
+ if (!widgetChanged && !(packagePath && file.startsWith(`${packagePath}${import_path2.default.sep}`)) && !(moduleRoot && file.startsWith(`${moduleRoot}${import_path2.default.sep}`)))
983
1012
  continue;
984
- void loadSwiftHost().then(
985
- (host) => host.swiftPackageMetadata(
986
- packagePath,
987
- packageName,
988
- moduleRoot,
989
- devOrigin()
990
- )
991
- ).then((metadata) => {
1013
+ void packageMetadata(packageName, moduleRoot).then((metadata) => {
992
1014
  sendSwiftChange({
993
1015
  type: "package",
994
1016
  packageName,
@@ -1006,7 +1028,7 @@ function rnxPlugin(options = {}) {
1006
1028
  server.middlewares.use((req, res, next) => {
1007
1029
  const pathname = (req.url ?? "").split("?")[0];
1008
1030
  if (!pathname.startsWith(SWIFT_ROUTE_PREFIX)) return next();
1009
- loadSwiftHost().then((host) => {
1031
+ loadSwiftHost().then(async (host) => {
1010
1032
  if (host.serveSwiftPackageAsset(pathname, res)) return;
1011
1033
  const prefix2 = SWIFT_PACKAGE_PATH;
1012
1034
  if (!pathname.startsWith(prefix2)) return next();
@@ -1018,7 +1040,7 @@ function rnxPlugin(options = {}) {
1018
1040
  const packageName = pathname.slice(prefix2.length);
1019
1041
  let packagePath;
1020
1042
  try {
1021
- packagePath = packageMap().get(packageName);
1043
+ packagePath = await servedPackage(packageName);
1022
1044
  } catch (error) {
1023
1045
  res.statusCode = 500;
1024
1046
  res.end(error instanceof Error ? error.message : String(error));
@@ -1032,7 +1054,7 @@ function rnxPlugin(options = {}) {
1032
1054
  const moduleRoot = moduleRootFor();
1033
1055
  activeSwiftPackages.add(packageName);
1034
1056
  server.watcher.add(host.swiftPackageWatchFiles(packagePath, moduleRoot));
1035
- void host.swiftPackageMetadata(packagePath, packageName, moduleRoot, devOrigin()).then((metadata) => {
1057
+ void packageMetadata(packageName, moduleRoot).then((metadata) => {
1036
1058
  res.setHeader("access-control-allow-origin", "*");
1037
1059
  res.setHeader("content-type", "application/json");
1038
1060
  res.end(JSON.stringify({ ...metadata, hmrPath }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.780",
3
+ "version": "0.1.782",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -21,6 +21,7 @@ automation, inspecting the render tree, and managing sims.
21
21
  | --- | --- |
22
22
  | `peach swift` | preview a SwiftPM or Xcode app with live Swift edits, compiled on this machine |
23
23
  | `peach kotlin` | run an Android Compose app module from its launcher activity |
24
+ | `peach test` | run a Maestro flow or Detox suite against a peach app bundle |
24
25
  | `peach maestro` | author, generate, and run Maestro YAML flows against peach |
25
26
  | `peach detox` | run existing Detox suites against peach on headless Chromium |
26
27
  | `peach cleanup` | inspect and reclaim local peach disk usage |
@@ -48,6 +49,7 @@ automation, inspecting the render tree, and managing sims.
48
49
  | `peach box` | start a local Box or create a cloud Box |
49
50
  | `peach ios` | start an iOS simulator |
50
51
  | `peach android` | start an Android simulator |
52
+ | `peach remote` | run a prebuilt bundle on a remote simulator |
51
53
  | `peach open` | load a target into the current sim or open a new one |
52
54
  | `peach list` | list connected sims or available launch drivers |
53
55
  | `peach use` | select a connected sim |
@@ -0,0 +1,202 @@
1
+ // One's own config loader runs in the app's process; prebuild owns every source byte.
2
+ import { execFile } from 'node:child_process'
3
+ import { createHash } from 'node:crypto'
4
+ import fs from 'node:fs'
5
+ import { createRequire } from 'node:module'
6
+ import os from 'node:os'
7
+ import path from 'node:path'
8
+ import { promisify } from 'node:util'
9
+ import { RNX_FORKED_SCRIPT_ENV } from '../cli/internal-child'
10
+ import { isRecord } from './is-record'
11
+ import { syncSwiftTree } from './swift-compile'
12
+ import { readPackageFile } from './swift-host'
13
+ import { MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
14
+ import type { OneWidgetMetadata, OneWidgetPackage } from './oneWidgetContract'
15
+
16
+ const run = promisify(execFile)
17
+ export const ONE_WIDGET_PACKAGE = 'OneWidgets'
18
+
19
+ type WidgetConfig = Omit<OneWidgetMetadata, 'sources'>
20
+
21
+ interface ConfigRead {
22
+ widget: WidgetConfig | null
23
+ watched: string[]
24
+ stamp: string
25
+ }
26
+
27
+ const configs = new Map<string, ConfigRead>()
28
+ const reads = new Map<string, Promise<ConfigRead>>()
29
+ const CONFIG_CHILD = `
30
+ import fs from 'node:fs';
31
+ import { loadUserOneOptions } from 'one/vite';
32
+ const { config, oneOptions } = await loadUserOneOptions('serve', true);
33
+ const app = oneOptions.native?.app;
34
+ const widgets = app?.ios?.widgets;
35
+ fs.writeFileSync(process.argv[2], JSON.stringify({
36
+ widget: widgets ? { appName: app.name, bundleId: app.ios.bundleId,
37
+ suite: widgets.appGroup, kind: widgets.kind, displayName: widgets.displayName,
38
+ description: widgets.description } : null,
39
+ watched: [config.path, ...config.dependencies]
40
+ }));
41
+ `
42
+
43
+ function configStamp(files: string[]): string {
44
+ return JSON.stringify(
45
+ files.map((file) => {
46
+ if (!fs.existsSync(file)) return [file, null]
47
+ const stat = fs.statSync(file)
48
+ return [file, stat.mtimeMs, stat.ctimeMs, stat.size]
49
+ }),
50
+ )
51
+ }
52
+
53
+ async function readConfig(root: string): Promise<ConfigRead> {
54
+ const cached = configs.get(root)
55
+ if (cached && cached.stamp === configStamp(cached.watched)) return cached
56
+ const reading = reads.get(root)
57
+ if (reading) return reading
58
+ const promise = (async () => {
59
+ // resolve before launching: an app without One is not a configured One app.
60
+ createRequire(path.join(root, 'package.json')).resolve('one/vite')
61
+ const cache = path.join(root, 'node_modules/.cache/peach-widget-config')
62
+ fs.mkdirSync(cache, { recursive: true })
63
+ const directory = fs.mkdtempSync(path.join(cache, 'read-'))
64
+ const script = path.join(directory, 'read.mjs')
65
+ const result = path.join(directory, 'result.json')
66
+ fs.writeFileSync(script, CONFIG_CHILD)
67
+ try {
68
+ await run(process.execPath, [script, result], {
69
+ cwd: root,
70
+ env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: '1' },
71
+ timeout: 30_000,
72
+ maxBuffer: 1024 * 1024,
73
+ })
74
+ const value: unknown = JSON.parse(fs.readFileSync(result, 'utf8'))
75
+ if (
76
+ !isRecord(value) ||
77
+ !Array.isArray(value.watched) ||
78
+ !value.watched.every((file): file is string => typeof file === 'string')
79
+ )
80
+ throw new Error('One config loader returned invalid dependencies')
81
+ let widget: WidgetConfig | null = null
82
+ if (value.widget !== null) {
83
+ const entry = value.widget
84
+ if (
85
+ !isRecord(entry) ||
86
+ typeof entry.appName !== 'string' ||
87
+ !/^[A-Za-z][A-Za-z0-9_]*$/.test(entry.appName) ||
88
+ typeof entry.bundleId !== 'string' ||
89
+ !entry.bundleId ||
90
+ typeof entry.suite !== 'string' ||
91
+ !entry.suite ||
92
+ typeof entry.kind !== 'string' ||
93
+ !entry.kind ||
94
+ typeof entry.displayName !== 'string' ||
95
+ !entry.displayName ||
96
+ typeof entry.description !== 'string' ||
97
+ !entry.description
98
+ )
99
+ throw new Error('One config loader returned invalid native.app.ios.widgets')
100
+ widget = {
101
+ appName: entry.appName,
102
+ bundleId: entry.bundleId,
103
+ suite: entry.suite,
104
+ kind: entry.kind,
105
+ displayName: entry.displayName,
106
+ description: entry.description,
107
+ }
108
+ }
109
+ const watched = [
110
+ ...new Set([
111
+ path.join(root, 'package.json'),
112
+ ...value.watched.map((file) => path.resolve(root, file)),
113
+ ]),
114
+ ]
115
+ const loaded = { widget, watched, stamp: configStamp(watched) }
116
+ configs.set(root, loaded)
117
+ return loaded
118
+ } finally {
119
+ fs.rmSync(directory, { recursive: true, force: true })
120
+ }
121
+ })()
122
+ reads.set(root, promise)
123
+ try {
124
+ return await promise
125
+ } finally {
126
+ reads.delete(root)
127
+ }
128
+ }
129
+
130
+ export async function oneWidgetPackage(
131
+ appRoot: string,
132
+ ): Promise<OneWidgetPackage | null> {
133
+ const root = fs.realpathSync(appRoot)
134
+ const config = await readConfig(root)
135
+ if (!config.widget) return null
136
+ const widget = config.widget
137
+ const sourceFiles = {
138
+ 'OneWidget.swift': path.join(root, 'ios/OneWidgets/OneWidget.swift'),
139
+ 'OneWidgetContract.swift': path.join(
140
+ root,
141
+ 'ios',
142
+ widget.appName,
143
+ 'OneWidgetContract.swift',
144
+ ),
145
+ }
146
+ const files = new Map<string, string>()
147
+ const sources: Record<string, string> = {}
148
+ for (const [name, file] of Object.entries(sourceFiles)) {
149
+ if (!fs.existsSync(file))
150
+ throw new Error(`missing One widget prebuild source ${file}; run one prebuild`)
151
+ const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES)
152
+ const text = bytes.toString('utf8')
153
+ if (!Buffer.from(text).equals(bytes))
154
+ throw new Error(`One widget prebuild source is not UTF-8: ${file}`)
155
+ files.set(name, text)
156
+ sources[path.relative(root, file).split(path.sep).join('/')] = createHash('sha256')
157
+ .update(bytes)
158
+ .digest('hex')
159
+ }
160
+ const contract = files.get('OneWidgetContract.swift') ?? ''
161
+ const source = files.get('OneWidget.swift') ?? ''
162
+ if (
163
+ !contract.includes(`static let appGroup = ${JSON.stringify(widget.suite)}`) ||
164
+ !contract.includes(`static let kind = ${JSON.stringify(widget.kind)}`) ||
165
+ !source.includes(
166
+ `.configurationDisplayName(${JSON.stringify(widget.displayName)})`,
167
+ ) ||
168
+ !source.includes(`.description(${JSON.stringify(widget.description)})`)
169
+ )
170
+ throw new Error(
171
+ 'One widget prebuild sources disagree with native.app.ios.widgets; run one prebuild',
172
+ )
173
+ // configuration participates in the existing package stamp and compile address.
174
+ files.set(
175
+ 'Package.swift',
176
+ [
177
+ '// swift-tools-version: 6.2',
178
+ `// One widget config ${JSON.stringify(widget)}`,
179
+ 'import PackageDescription',
180
+ 'let package = Package(name: "OneWidgets", targets: [',
181
+ ' .executableTarget(name: "OneWidgets", path: ".", swiftSettings: [.swiftLanguageMode(.v5)]),',
182
+ '])',
183
+ '',
184
+ ].join('\n'),
185
+ )
186
+ const packagePath = path.join(
187
+ os.tmpdir(),
188
+ 'peach-one-widgets',
189
+ createHash('sha256').update(root).digest('hex'),
190
+ ONE_WIDGET_PACKAGE,
191
+ )
192
+ fs.mkdirSync(packagePath, { recursive: true })
193
+ syncSwiftTree(
194
+ packagePath,
195
+ new Map([...files].map(([file, text]) => [path.join(packagePath, file), text])),
196
+ )
197
+ return {
198
+ packagePath,
199
+ watched: [...config.watched, ...Object.values(sourceFiles)],
200
+ widget: { ...widget, sources },
201
+ }
202
+ }
@@ -0,0 +1,16 @@
1
+ // generated One widget package metadata carried by the Swift serving host.
2
+ export interface OneWidgetMetadata {
3
+ appName: string
4
+ bundleId: string
5
+ kind: string
6
+ suite: string
7
+ displayName: string
8
+ description: string
9
+ sources: Record<string, string>
10
+ }
11
+
12
+ export interface OneWidgetPackage {
13
+ packagePath: string
14
+ watched: string[]
15
+ widget: OneWidgetMetadata
16
+ }
package/src/swift-host.ts CHANGED
@@ -33,7 +33,11 @@ import {
33
33
  type SwiftPackageGap,
34
34
  type SwiftPackages,
35
35
  } from './swift-packages'
36
- import { swiftStandins, type SwiftStandin } from './swift-standins'
36
+ import {
37
+ standinGenerationInputs,
38
+ swiftStandins,
39
+ type SwiftStandin,
40
+ } from './swift-standins'
37
41
  import {
38
42
  MAX_SWIFT_COMPILE_FILES,
39
43
  MAX_SWIFT_COMPILE_SOURCE_BYTES,
@@ -187,7 +191,12 @@ interface XcodeProjectEntry {
187
191
  provided: ReadonlySet<string> | null
188
192
  /** the module root a local compile links, which builds binary stand-ins. */
189
193
  moduleRoot: string | null
190
- packages?: { key: string; packages: SwiftPackages; standins: SwiftStandin[] }
194
+ packages?: {
195
+ key: string
196
+ standinKey: string
197
+ packages: SwiftPackages
198
+ standins: SwiftStandin[]
199
+ }
191
200
  }
192
201
 
193
202
  const xcodeProjects = new Map<string, XcodeProjectEntry>()
@@ -230,39 +239,57 @@ function swiftPackages(
230
239
  source.kind === 'local' ? stamp(path.join(source.dir, 'Package.swift')) : 0,
231
240
  ),
232
241
  ])
233
- if (entry.packages?.key !== key) {
234
- const resolve = (
235
- provided: ReadonlySet<string> | null,
236
- binaryGaps?: Map<string, string>,
237
- ) =>
238
- resolveSwiftPackages({
242
+ // the package key is cheap stamps; the stand-in key covers the generation
243
+ // inputs the stamps cannot see (artifact contents, peach's modules, the
244
+ // emitter), so a changed input rebuilds instead of reusing stale output.
245
+ let cached = entry.packages
246
+ if (cached?.key !== key) {
247
+ cached = {
248
+ key,
249
+ standinKey: '',
250
+ packages: resolveSwiftPackages({
239
251
  rootDir: app.rootDir,
240
252
  resolved: app.packageResolved,
241
253
  products: app.linkedProducts,
242
254
  localDirs: app.localPackageDirs,
243
- provided,
244
- binaryGaps,
245
- })
246
- let packages = resolve(entry.provided)
247
- let standins: SwiftStandin[] = []
248
- // a reached binary target with stand-ins for every module it ships
249
- // resolves as provided, so what depends on it compiles; the rest keep
250
- // their reason with why no stand-in was built
251
- const reached = packages.binaries.filter((binary) => binary.reached)
252
- if (entry.moduleRoot && entry.provided && reached.length > 0) {
253
- const built = swiftStandins(reached, {
254
- moduleRoot: entry.moduleRoot,
255
- toolchainBin: swiftModuleToolchain(entry.moduleRoot).toolchainBin,
255
+ provided: entry.provided,
256
+ }),
257
+ standins: [],
258
+ }
259
+ entry.packages = cached
260
+ }
261
+ // a reached binary target with stand-ins for every module it ships
262
+ // resolves as provided, so what depends on it compiles; the rest keep
263
+ // their reason with why no stand-in was built. surfaces peach already
264
+ // ships are skipped up front, so no generated target overrides a shipped
265
+ // module.
266
+ const reached = cached.packages.binaries.filter((binary) => binary.reached)
267
+ if (entry.moduleRoot && entry.provided && reached.length > 0) {
268
+ const resolved = swiftModuleToolchain(entry.moduleRoot)
269
+ const toolchain = {
270
+ moduleRoot: entry.moduleRoot,
271
+ toolchainBin: resolved.toolchainBin,
272
+ release: resolved.release,
273
+ }
274
+ const generation = standinGenerationInputs(reached, toolchain)
275
+ if (cached.standinKey !== generation) {
276
+ const built = swiftStandins(reached, toolchain, entry.provided)
277
+ cached.packages = resolveSwiftPackages({
278
+ rootDir: app.rootDir,
279
+ resolved: app.packageResolved,
280
+ products: app.linkedProducts,
281
+ localDirs: app.localPackageDirs,
282
+ provided: new Set([
283
+ ...entry.provided,
284
+ ...built.standins.map((standin) => standin.target),
285
+ ]),
286
+ binaryGaps: built.gaps,
256
287
  })
257
- standins = built.standins
258
- packages = resolve(
259
- new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
260
- built.gaps,
261
- )
288
+ cached.standins = built.standins
289
+ cached.standinKey = generation
262
290
  }
263
- entry.packages = { key, packages, standins }
264
291
  }
265
- return entry.packages
292
+ return cached
266
293
  }
267
294
 
268
295
  // the app target's sources compile as one executable target under this
@@ -438,7 +465,7 @@ function sourceTreeFiles(dir: string, canonicalRoot: string): string[] {
438
465
  return found
439
466
  }
440
467
 
441
- function readPackageFile(root: string, file: string, maxBytes: number): Buffer {
468
+ export function readPackageFile(root: string, file: string, maxBytes: number): Buffer {
442
469
  const canonicalRoot = fs.realpathSync(root)
443
470
  const relative = path.relative(canonicalRoot, fs.realpathSync(file))
444
471
  if (