peachsim 0.1.812 → 0.1.814

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 (84) hide show
  1. package/cli/commands/kotlin.ts +2 -27
  2. package/cli/outbound-endpoints.ts +26 -27
  3. package/dist-lib/agent-daemon-client.cjs +1 -1
  4. package/dist-lib/agent-events.cjs +1 -1
  5. package/dist-lib/agent-identity.cjs +1 -1
  6. package/dist-lib/agent-sessions.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +1 -1
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +1 -1
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +1 -1
  17. package/dist-lib/bundle-channel.cjs +8 -6
  18. package/dist-lib/capture-contract.cjs +11 -5
  19. package/dist-lib/capture-contract.mjs +11 -5
  20. package/dist-lib/cli-constants.cjs +1 -1
  21. package/dist-lib/cloud-contract.cjs +1 -1
  22. package/dist-lib/cloud-contract.mjs +1 -1
  23. package/dist-lib/cloud-test-args.cjs +1 -1
  24. package/dist-lib/cloud-test-args.mjs +1 -1
  25. package/dist-lib/cloud.cjs +1 -1
  26. package/dist-lib/cloud.mjs +1 -1
  27. package/dist-lib/config.cjs +1 -1
  28. package/dist-lib/detox/index.cjs +1 -1
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/expo-swift-bundle.cjs +8 -6
  31. package/dist-lib/expo-swift-metadata.cjs +1 -1
  32. package/dist-lib/expo-swift-metadata.mjs +1 -1
  33. package/dist-lib/home-paths.cjs +1 -1
  34. package/dist-lib/host/bridge-host.cjs +8 -6
  35. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  37. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  38. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  39. package/dist-lib/host/websocket-proxy.cjs +1 -1
  40. package/dist-lib/index.cjs +18 -10
  41. package/dist-lib/jump-to-source-babel.cjs +1 -1
  42. package/dist-lib/jump-to-source-native.cjs +1 -1
  43. package/dist-lib/kotlin-host.cjs +25 -24
  44. package/dist-lib/menu.cjs +1 -1
  45. package/dist-lib/menu.mjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  48. package/dist-lib/metro-production-bundle.cjs +1 -1
  49. package/dist-lib/metro-production-bundle.mjs +1 -1
  50. package/dist-lib/metro.cjs +8 -6
  51. package/dist-lib/native-app-identity.cjs +1 -1
  52. package/dist-lib/native-app-identity.mjs +1 -1
  53. package/dist-lib/native-firebase-metadata.cjs +1 -1
  54. package/dist-lib/native-firebase-metadata.mjs +1 -1
  55. package/dist-lib/plist.cjs +1 -1
  56. package/dist-lib/plist.mjs +1 -1
  57. package/dist-lib/profiles.cjs +1 -1
  58. package/dist-lib/public-brand.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.cjs +1 -1
  60. package/dist-lib/react-native-host-modules.mjs +1 -1
  61. package/dist-lib/render-mode.cjs +1 -1
  62. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  63. package/dist-lib/sdk.cjs +1 -1
  64. package/dist-lib/sdk.mjs +1 -1
  65. package/dist-lib/skills.cjs +8 -6
  66. package/dist-lib/swift-compile.cjs +1 -1
  67. package/dist-lib/swift-compile.mjs +1 -1
  68. package/dist-lib/swift-package.cjs +1 -1
  69. package/dist-lib/swift-package.mjs +1 -1
  70. package/dist-lib/swift-submit.cjs +1 -1
  71. package/dist-lib/swift-submit.mjs +1 -1
  72. package/dist-lib/swift-toolchain.cjs +1 -1
  73. package/dist-lib/swift.cjs +1 -1
  74. package/dist-lib/vite-swift.cjs +8 -6
  75. package/dist-lib/vite.cjs +1 -1
  76. package/dist-lib/worklet-executable.cjs +1 -1
  77. package/dist-lib/worklet-executable.mjs +1 -1
  78. package/package.json +1 -1
  79. package/src/android-theme.ts +22 -23
  80. package/src/capture-contract.ts +18 -4
  81. package/src/kotlin-app.ts +41 -13
  82. package/src/kotlin-host.ts +32 -23
  83. package/src/swift-host.ts +7 -7
  84. package/src/xcode-project.ts +11 -8
@@ -147,22 +147,22 @@ export function resolveThemeAttribute(
147
147
  if (!found) throw new Error(`${theme}: ${value} is not set`)
148
148
  continue
149
149
  }
150
- const ref = /^@(?:(android):)?color\/(.+)$/.exec(value)
151
- if (ref?.[2]) {
152
- const colorNamespace: Namespace = ref[1] ? 'android' : namespace
153
- // system_ colors are the device's dynamic palette, set at runtime
154
- if (colorNamespace === 'android' && ref[2].startsWith('system_'))
155
- throw new Error(
156
- `${theme}: ${attribute} uses the dynamic color ${ref[2]}, which peach kotlin does not model`,
157
- )
158
- return resourceColor(colorNamespace, ref[2], sources)
159
- }
150
+ const ref = colorReference(value, namespace)
151
+ if (ref) return resourceColor(ref.namespace, ref.name, sources)
160
152
  throw new Error(`${theme}: ${attribute} has the unsupported value ${value}`)
161
153
  }
162
154
  // unset: the reader's own default applies, as PhoneWindow's getBoolean/getColor do
163
155
  return undefined
164
156
  }
165
157
 
158
+ // `@color/X` or `@android:color/X` as written in `namespace`'s files
159
+ function colorReference(value: string, namespace: Namespace): StyleRef | null {
160
+ const match = /^@(?:(android):)?color\/(.+)$/.exec(value)
161
+ return match?.[2]
162
+ ? { namespace: match[1] ? 'android' : namespace, name: match[2] }
163
+ : null
164
+ }
165
+
166
166
  // a color resource as context.getColor reads it, following references to
167
167
  // other colors in either namespace; a reference written in a framework file
168
168
  // stays in the framework
@@ -172,27 +172,26 @@ export function resourceColor(
172
172
  sources: ThemeSources,
173
173
  ): number {
174
174
  const seen = new Set<string>()
175
- let ref = { namespace, name }
175
+ let ref: StyleRef = { namespace, name }
176
176
  for (;;) {
177
177
  const key = `${ref.namespace}:${ref.name}`
178
+ // system_ colors are the device's dynamic palette, set at runtime
179
+ if (ref.namespace === 'android' && ref.name.startsWith('system_'))
180
+ throw new Error(
181
+ `@android:color/${ref.name} is the device's dynamic color, which peach kotlin does not model`,
182
+ )
178
183
  if (seen.has(key)) throw new Error(`@${key} refers to itself`)
179
184
  seen.add(key)
180
185
  const value = sources[ref.namespace].colors[ref.name]
181
186
  if (value === undefined)
182
187
  throw new Error(`@${ref.namespace}:color/${ref.name} is not defined`)
183
188
  if (value.startsWith('#')) return color(value)
184
- const next = /^@(?:(android):)?color\/(.+)$/.exec(value)
185
- if (!next?.[2])
189
+ const next = colorReference(value, ref.namespace)
190
+ if (!next)
186
191
  throw new Error(
187
192
  `@${ref.namespace}:color/${ref.name} has the unsupported value ${value}`,
188
193
  )
189
- const nextNamespace: Namespace = next[1] ? 'android' : ref.namespace
190
- // system_ colors are the device's dynamic palette, set at runtime
191
- if (nextNamespace === 'android' && next[2].startsWith('system_'))
192
- throw new Error(
193
- `@${ref.namespace}:color/${ref.name} uses the dynamic color ${next[2]}, which peach kotlin does not model`,
194
- )
195
- ref = { namespace: nextNamespace, name: next[2] }
194
+ ref = next
196
195
  }
197
196
  }
198
197
 
@@ -200,7 +199,7 @@ export function resourceColor(
200
199
  // to an app or framework color resource
201
200
  export function attributeColor(value: string, sources: ThemeSources): number {
202
201
  if (value.startsWith('#')) return color(value)
203
- const ref = /^@(?:(android):)?color\/(.+)$/.exec(value)
204
- if (!ref?.[2]) throw new Error(`the color ${value} is not resolved by peach kotlin yet`)
205
- return resourceColor(ref[1] ? 'android' : 'app', ref[2], sources)
202
+ const ref = colorReference(value, 'app')
203
+ if (!ref) throw new Error(`the color ${value} is not resolved by peach kotlin yet`)
204
+ return resourceColor(ref.namespace, ref.name, sources)
206
205
  }
@@ -414,10 +414,24 @@ export function packRnxCaptureRegions(
414
414
  surface: { pixelWidth: number; pixelHeight: number },
415
415
  ): RnxPackedCaptureAtlas {
416
416
  const physical = regions.map((region) => {
417
- const left = Math.floor(region.frame.x * pixelRatio)
418
- const top = Math.floor(region.frame.y * pixelRatio)
419
- const right = Math.ceil((region.frame.x + region.frame.width) * pixelRatio)
420
- const bottom = Math.ceil((region.frame.y + region.frame.height) * pixelRatio)
417
+ let left = Math.floor(region.frame.x * pixelRatio)
418
+ let top = Math.floor(region.frame.y * pixelRatio)
419
+ let right = Math.ceil((region.frame.x + region.frame.width) * pixelRatio)
420
+ let bottom = Math.ceil((region.frame.y + region.frame.height) * pixelRatio)
421
+ // multiplication can round onto an integer whose divided value lies inside
422
+ // the request. compare the returned logical edges to keep coverage outward.
423
+ if (left / pixelRatio > region.frame.x) left -= 1
424
+ if (top / pixelRatio > region.frame.y) top -= 1
425
+ if (
426
+ left / pixelRatio + (right - left) / pixelRatio <
427
+ region.frame.x + region.frame.width
428
+ )
429
+ right += 1
430
+ if (
431
+ top / pixelRatio + (bottom - top) / pixelRatio <
432
+ region.frame.y + region.frame.height
433
+ )
434
+ bottom += 1
421
435
  if (
422
436
  left < 0 ||
423
437
  top < 0 ||
package/src/kotlin-app.ts CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  } from './android-theme'
17
17
  import { parseXml, type XmlElement } from './android-xml'
18
18
  import frameworkThemes from './generated/android-framework-themes.json' with { type: 'json' }
19
+ import { isRecord } from './is-record'
19
20
 
20
21
  // statusBarColor and navigationBarColor are ARGB
21
22
  export interface KotlinWindowTheme {
@@ -97,6 +98,31 @@ const ANDROID_PIN: Record<string, keyof AndroidPins> = {
97
98
  'androidx.activity': 'activity',
98
99
  }
99
100
 
101
+ // the Android artifact versions Peach's Kotlin closure is pinned to, from
102
+ // peachsim's kotlin/toolchain.json
103
+ export function readAndroidPins(moduleRoot: string): AndroidPins {
104
+ const toolchain: unknown = JSON.parse(
105
+ fs.readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'),
106
+ )
107
+ const android =
108
+ isRecord(toolchain) && isRecord(toolchain.compose) ? toolchain.compose.android : null
109
+ const pin = (name: keyof AndroidPins) => {
110
+ const value = isRecord(android) ? android[name] : undefined
111
+ if (typeof value !== 'string')
112
+ throw new Error(`peachsim kotlin/toolchain.json has no Android ${name} pin`)
113
+ return value
114
+ }
115
+ return {
116
+ ui: pin('ui'),
117
+ foundation: pin('foundation'),
118
+ runtime: pin('runtime'),
119
+ material3: pin('material3'),
120
+ navigation: pin('navigation'),
121
+ activity: pin('activity'),
122
+ materialIcons: pin('materialIcons'),
123
+ }
124
+ }
125
+
100
126
  function readGradle(dir: string): { file: string; text: string } | null {
101
127
  for (const name of ['build.gradle.kts', 'build.gradle']) {
102
128
  const file = path.join(dir, name)
@@ -240,7 +266,10 @@ function valuesFiles(moduleDir: string, qualifier: string) {
240
266
  // configuration. only colors the default values define get an R field, as
241
267
  // AGP's compile R lists; a color under a qualifier other than night is
242
268
  // rejected by name
243
- function readAppColors(moduleDir: string): KotlinAppColor[] {
269
+ function readAppColors(
270
+ moduleDir: string,
271
+ theme: { day: ThemeSources; night: ThemeSources },
272
+ ): KotlinAppColor[] {
244
273
  const res = path.join(moduleDir, 'src/main/res')
245
274
  for (const dir of fs.existsSync(res) ? fs.readdirSync(res).sort() : []) {
246
275
  if (!dir.startsWith('values') || dir === 'values' || dir === 'values-night') continue
@@ -250,14 +279,12 @@ function readAppColors(moduleDir: string): KotlinAppColor[] {
250
279
  `${res}/${dir}: color ${colors[0]} is not resolved by peach kotlin yet (only values and values-night colors)`,
251
280
  )
252
281
  }
253
- const day = themeSources(moduleDir, false)
254
- const night = themeSources(moduleDir, true)
255
- return Object.keys(day.app.colors)
282
+ return Object.keys(theme.day.app.colors)
256
283
  .sort()
257
284
  .map((name) => ({
258
285
  name,
259
- day: resourceColor('app', name, day),
260
- night: resourceColor('app', name, night),
286
+ day: resourceColor('app', name, theme.day),
287
+ night: resourceColor('app', name, theme.night),
261
288
  }))
262
289
  }
263
290
 
@@ -526,6 +553,10 @@ export function readKotlinApp(
526
553
  }
527
554
  if (sources.length === 0)
528
555
  throw new Error(`${moduleDir}/src/main holds no Kotlin sources`)
556
+ const resources = {
557
+ day: themeSources(moduleDir, false),
558
+ night: themeSources(moduleDir, true),
559
+ }
529
560
  return {
530
561
  projectDir,
531
562
  moduleDir,
@@ -535,8 +566,8 @@ export function readKotlinApp(
535
566
  namespace: base,
536
567
  targetSdk,
537
568
  window: {
538
- day: readWindowTheme(theme, targetSdk, themeSources(moduleDir, false)),
539
- night: readWindowTheme(theme, targetSdk, themeSources(moduleDir, true)),
569
+ day: readWindowTheme(theme, targetSdk, resources.day),
570
+ night: readWindowTheme(theme, targetSdk, resources.night),
540
571
  },
541
572
  applicationClass: applicationName ? className(applicationName) : null,
542
573
  launcher: { name: launcherName, targetClass },
@@ -544,10 +575,7 @@ export function readKotlinApp(
544
575
  handlesUiMode,
545
576
  softInputAdjust,
546
577
  strings: readAndroidStrings(moduleDir),
547
- colors: readAppColors(moduleDir),
548
- drawables: readAndroidDrawables(moduleDir, {
549
- day: themeSources(moduleDir, false),
550
- night: themeSources(moduleDir, true),
551
- }),
578
+ colors: readAppColors(moduleDir, resources),
579
+ drawables: readAndroidDrawables(moduleDir, resources),
552
580
  }
553
581
  }
@@ -23,7 +23,7 @@ import type { ServerResponse } from 'node:http'
23
23
 
24
24
  const run = promisify(execFile)
25
25
 
26
- export const KOTLIN_ARTIFACT_PREFIX = '/__peach/kotlin-artifact/'
26
+ const KOTLIN_ARTIFACT_PREFIX = '/__peach/kotlin-artifact/'
27
27
 
28
28
  interface Download {
29
29
  url: string
@@ -347,8 +347,11 @@ function viewModelInitializer({ name, signature }: ViewModelClass): string {
347
347
  }
348
348
  }
349
349
 
350
+ // an ARGB color as a Kotlin Int literal
351
+ const argb = (color: number) =>
352
+ `0x${color.toString(16).padStart(8, '0').toUpperCase()}.toInt()`
353
+
350
354
  function windowTheme(window: KotlinWindowTheme): string[] {
351
- const argb = (color: number) => `0x${color.toString(16).padStart(8, '0')}.toInt()`
352
355
  return [
353
356
  ' android.view.WindowTheme(',
354
357
  ` ${window.edgeToEdgeEnforced}, ${argb(window.statusBarColor)}, ${argb(window.navigationBarColor)},`,
@@ -367,7 +370,6 @@ export async function kotlinAppArtifact(
367
370
  origin: string,
368
371
  ): Promise<KotlinArtifact> {
369
372
  const toolchain = readToolchain(moduleRoot)
370
- const kotlinString = (value: string) => JSON.stringify(value).replaceAll('$', '\\$')
371
373
  const appEntry = (viewModels: ViewModelClass[]) =>
372
374
  [
373
375
  '@file:OptIn(kotlin.js.ExperimentalJsExport::class)',
@@ -379,14 +381,14 @@ export async function kotlinAppArtifact(
379
381
  ' regular: String, medium: String, bold: String, insets: String, night: Boolean,',
380
382
  ' invalidate: (Boolean) -> Unit): String = dev.peach.app.peachStartApp(',
381
383
  ' dev.peach.app.PeachAppSpec(',
382
- ` android.content.ComponentName(${kotlinString(app.packageName)}, ${kotlinString(app.launcher.name)}),`,
383
- ` android.content.ComponentName(${kotlinString(app.packageName)}, ${kotlinString(app.launcher.targetClass)}),`,
384
+ ` android.content.ComponentName(${literal(app.packageName)}, ${literal(app.launcher.name)}),`,
385
+ ` android.content.ComponentName(${literal(app.packageName)}, ${literal(app.launcher.targetClass)}),`,
384
386
  ...windowTheme(app.window.day),
385
387
  ...windowTheme(app.window.night),
386
388
  ` { ${app.applicationClass ?? 'android.app.Application'}() },`,
387
389
  ` { ${app.launcher.targetClass}() },`,
388
390
  ` ${app.handlesUiMode},`,
389
- ` ${kotlinString(app.softInputAdjust)},`,
391
+ ` ${literal(app.softInputAdjust)},`,
390
392
  ' androidx.lifecycle.viewmodel.viewModelFactory {',
391
393
  ...viewModels.map(viewModelInitializer),
392
394
  ' },',
@@ -472,8 +474,6 @@ function appResourceSources(app: KotlinAppProject): Record<string, string> {
472
474
  .map(([locale, value]) => `${literal(locale)} to ${render(value)}`)
473
475
  .join(', ')})`,
474
476
  }))
475
- const argb = (value: number) =>
476
- `0x${value.toString(16).padStart(8, '0').toUpperCase()}.toInt()`
477
477
  const kinds = [
478
478
  {
479
479
  type: 'string',
@@ -581,8 +581,6 @@ function drawableInit(drawable: DrawableFile, file: string): string {
581
581
  )})`
582
582
  const vector = drawable.vector
583
583
  const float = (value: number) => `${value}f`
584
- const argb = (value: number) =>
585
- `0x${value.toString(16).padStart(8, '0').toUpperCase()}.toInt()`
586
584
  const pick = (value: DayNight) =>
587
585
  value.day === value.night
588
586
  ? argb(value.day)
@@ -664,7 +662,7 @@ async function compileKotlin(
664
662
  const digest = createHash('sha256')
665
663
  // BUILD_FORMAT moves when this host changes what it does to a build
666
664
  digest.update(JSON.stringify({ format: BUILD_FORMAT, toolchain, language }))
667
- for (const file of [...shims, ...sources])
665
+ for (const file of [...shims, ...sources, ...(viewModels ? [viewModels.script] : [])])
668
666
  digest.update(`${path.relative(root, file)}\0${fs.readFileSync(file, 'utf8')}\0`)
669
667
  for (const [name, text] of Object.entries(generated))
670
668
  digest.update(`${name}\0${text}\0`)
@@ -787,6 +785,7 @@ async function compileKotlin(
787
785
  // exact upstream ES modules beside the generated loader for workers.
788
786
  if (usesCompose) {
789
787
  for (const library of toolchain.composeJsLibraries) {
788
+ let imported = false
790
789
  for (const file of fs.readdirSync(path.join(work, 'js'))) {
791
790
  if (!file.endsWith('.mjs')) continue
792
791
  const target = path.join(work, 'js', file)
@@ -798,18 +797,20 @@ async function compileKotlin(
798
797
  `from ${quote}./${library.file}${quote}`,
799
798
  )
800
799
  if (next === source) continue
801
- const archive = path.join(
802
- kotlinHome(),
803
- toolchain.compiler.version,
804
- library.name,
805
- )
806
- await fetchVerified(library, archive)
807
- const { stdout } = await run('tar', ['-xOf', archive, library.archiveEntry], {
808
- maxBuffer: 16 * 1024 * 1024,
809
- })
810
- fs.writeFileSync(path.join(work, 'js', library.file), stdout)
811
800
  fs.writeFileSync(target, next)
801
+ imported = true
812
802
  }
803
+ if (!imported) continue
804
+ const archive = path.join(
805
+ kotlinHome(),
806
+ toolchain.compiler.version,
807
+ library.name,
808
+ )
809
+ await fetchVerified(library, archive)
810
+ const { stdout } = await run('tar', ['-xOf', archive, library.archiveEntry], {
811
+ maxBuffer: 16 * 1024 * 1024,
812
+ })
813
+ fs.writeFileSync(path.join(work, 'js', library.file), stdout)
813
814
  }
814
815
  }
815
816
  } catch (error) {
@@ -861,7 +862,15 @@ async function compileKotlin(
861
862
  `kotlin output no longer contains ${from}; recheck how it detects its host in Peach`,
862
863
  )
863
864
  }
864
- fs.renameSync(work, out)
865
+ // another host process (a second peach kotlin, the vite plugin) may have
866
+ // published this content address while this one compiled; its output is
867
+ // the same build, so this one's copy is discarded
868
+ try {
869
+ fs.renameSync(work, out)
870
+ } catch (error) {
871
+ if (!fs.existsSync(path.join(out, 'js', 'app.wasm'))) throw error
872
+ fs.rmSync(work, { recursive: true, force: true })
873
+ }
865
874
  return artifact
866
875
  })().finally(() => builds.delete(hash))
867
876
  builds.set(hash, build)
@@ -904,7 +913,7 @@ export function serveKotlinArtifact(pathname: string, res: ServerResponse): bool
904
913
  return true
905
914
  }
906
915
 
907
- export const KOTLIN_PACKAGE_PATH = '/__peach/kotlin-package'
916
+ const KOTLIN_PACKAGE_PATH = '/__peach/kotlin-package'
908
917
 
909
918
  // peachsim's own Kotlin module (toolchain pins and shims) beside the app's
910
919
  // installed peachsim
package/src/swift-host.ts CHANGED
@@ -898,13 +898,6 @@ async function compile(
898
898
  return { ...artifact, stamp, package: content }
899
899
  }
900
900
 
901
- // a peachsim with neither a module checkout nor a distribution compiles the
902
- // package where a Contrast project's compiles: Contrast's compile
903
- // route, authorized by `peach login` or PEACH_API_KEY. the service renders the
904
- // native dispatch glue itself under the package's id and answers the wasm at a
905
- // public content address, which is fetched once and served from this dev
906
- // server like a local build. resource bytes share the compile snapshot and
907
- // immutable local asset addresses.
908
901
  // the compiler stops a file at its errors, so its output reads one site at a
909
902
  // time. this groups every error by the api it names, so a project learns
910
903
  // which symbols Peach lacks, how often and where, from one run. paths are the
@@ -1047,6 +1040,13 @@ async function missingModulesMessage(
1047
1040
  ].join('\n')
1048
1041
  }
1049
1042
 
1043
+ // a peachsim with neither a module checkout nor a distribution compiles the
1044
+ // package where a Contrast project's compiles: Contrast's compile
1045
+ // route, authorized by `peach login` or PEACH_API_KEY. the service renders the
1046
+ // native dispatch glue itself under the package's id and answers the wasm at a
1047
+ // public content address, which is fetched once and served from this dev
1048
+ // server like a local build. resource bytes share the compile snapshot and
1049
+ // immutable local asset addresses.
1050
1050
  async function compileRemote(
1051
1051
  packagePath: string,
1052
1052
  entry: string,
@@ -648,9 +648,9 @@ function workspaceProjects(xcodeprojOrWorkspace: string): {
648
648
  const projects: LoadedProject[] = []
649
649
  const projectAt = new Map<string, LoadedProject>()
650
650
  const addProject = (xcodeproj: string) => {
651
- const key = path.resolve(xcodeproj)
651
+ if (!xcodeProjectFile(xcodeproj)) return
652
+ const key = fs.realpathSync(xcodeproj)
652
653
  if (projectAt.has(key) || key.split(path.sep).includes('Pods')) return
653
- if (!xcodeProjectFile(key)) return
654
654
  const project = loadProject(key)
655
655
  projectAt.set(key, project)
656
656
  projects.push(project)
@@ -699,10 +699,9 @@ export function listXcodeAppTargets(xcodeprojOrWorkspace: string): string[] {
699
699
  * listed fresh from disk, so a file added to a synchronized folder joins the
700
700
  * target without any project change.
701
701
  */
702
- export function readXcodeAppTarget(
703
- xcodeprojOrWorkspace: string,
704
- targetName?: string,
705
- ): XcodeAppTarget {
702
+ export function readXcodeAppTarget(input: string, targetName?: string): XcodeAppTarget {
703
+ // canonical, so every path returned agrees with the host's realpath checks
704
+ const xcodeprojOrWorkspace = fs.realpathSync(input)
706
705
  const workspace = xcodeprojOrWorkspace.endsWith('.xcworkspace')
707
706
  ? xcodeprojOrWorkspace
708
707
  : null
@@ -742,10 +741,13 @@ export function readXcodeAppTarget(
742
741
  const proxy = project.object(proxyId)
743
742
  if (proxy?.isa !== 'PBXContainerItemProxy') return undefined
744
743
  const portal = str(proxy.containerPortal)
744
+ const portalPath = project.resolvePath(portal ?? '')
745
745
  const owner =
746
746
  project.object(portal)?.isa === 'PBXProject'
747
747
  ? project
748
- : projectAt.get(path.resolve(project.resolvePath(portal ?? '') ?? ''))
748
+ : portalPath && fs.existsSync(portalPath)
749
+ ? projectAt.get(fs.realpathSync(portalPath))
750
+ : undefined
749
751
  const remote = str(proxy.remoteGlobalIDString)
750
752
  if (!owner || !remote) return undefined
751
753
  return nativeTargets(owner).find(
@@ -949,7 +951,8 @@ export function readXcodeAppTarget(
949
951
  'Package.resolved',
950
952
  )
951
953
 
952
- const used = [app, ...order].map((ref) => ref.project)
954
+ // the app is last in its own dependency order
955
+ const used = order.map((ref) => ref.project)
953
956
  return {
954
957
  ...module,
955
958
  rootDir: commonAncestor(