peachsim 0.1.769 → 0.1.771

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 (77) hide show
  1. package/cli/main.ts +5 -1
  2. package/cli/outbound-endpoints.ts +14 -0
  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/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cli-constants.cjs +1 -1
  20. package/dist-lib/cloud-contract.cjs +1 -1
  21. package/dist-lib/cloud-contract.mjs +1 -1
  22. package/dist-lib/cloud-test-args.cjs +1 -1
  23. package/dist-lib/cloud-test-args.mjs +1 -1
  24. package/dist-lib/cloud.cjs +1 -1
  25. package/dist-lib/cloud.mjs +1 -1
  26. package/dist-lib/config.cjs +1 -1
  27. package/dist-lib/detox/index.cjs +1 -1
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/home-paths.cjs +1 -1
  30. package/dist-lib/host/bridge-host.cjs +563 -439
  31. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  32. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  33. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  34. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  35. package/dist-lib/host/websocket-proxy.cjs +1 -1
  36. package/dist-lib/index.cjs +1 -1
  37. package/dist-lib/jump-to-source-babel.cjs +1 -1
  38. package/dist-lib/jump-to-source-native.cjs +1 -1
  39. package/dist-lib/kotlin-host.cjs +1 -1
  40. package/dist-lib/menu.cjs +1 -1
  41. package/dist-lib/menu.mjs +1 -1
  42. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  44. package/dist-lib/metro-production-bundle.cjs +1 -1
  45. package/dist-lib/metro-production-bundle.mjs +1 -1
  46. package/dist-lib/metro.cjs +1 -1
  47. package/dist-lib/native-app-identity.cjs +1 -1
  48. package/dist-lib/native-app-identity.mjs +1 -1
  49. package/dist-lib/native-firebase-metadata.cjs +1 -1
  50. package/dist-lib/native-firebase-metadata.mjs +1 -1
  51. package/dist-lib/plist.cjs +1 -1
  52. package/dist-lib/plist.mjs +1 -1
  53. package/dist-lib/profiles.cjs +1 -1
  54. package/dist-lib/public-brand.cjs +1 -1
  55. package/dist-lib/react-native-host-modules.cjs +1 -1
  56. package/dist-lib/react-native-host-modules.mjs +1 -1
  57. package/dist-lib/render-mode.cjs +1 -1
  58. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  59. package/dist-lib/sdk.cjs +1 -1
  60. package/dist-lib/sdk.mjs +1 -1
  61. package/dist-lib/skills.cjs +832 -701
  62. package/dist-lib/swift-compile.cjs +18 -4
  63. package/dist-lib/swift-compile.mjs +17 -4
  64. package/dist-lib/swift-package.cjs +1 -1
  65. package/dist-lib/swift-package.mjs +1 -1
  66. package/dist-lib/swift-submit.cjs +1 -1
  67. package/dist-lib/swift-submit.mjs +1 -1
  68. package/dist-lib/swift-toolchain.cjs +1 -1
  69. package/dist-lib/swift.cjs +1 -1
  70. package/dist-lib/vite-swift.cjs +396 -272
  71. package/dist-lib/vite.cjs +1 -1
  72. package/package.json +1 -1
  73. package/src/swift-binary-modules.ts +116 -0
  74. package/src/swift-compile.ts +28 -3
  75. package/src/swift-host.ts +28 -4
  76. package/src/swift-package-manifest.ts +3 -0
  77. package/src/swift-packages.ts +32 -4
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.769 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.771 | (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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.769",
3
+ "version": "0.1.771",
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",
@@ -0,0 +1,116 @@
1
+ // the modules a swift package's binary target ships. an xcframework's module
2
+ // is the framework inside it, often named apart from the target
3
+ // (_FirebaseCore holds FirebaseCore.framework), so a missing-module report
4
+ // reads the names from the artifact: a local one's slices, a remote archive's
5
+ // zip central directory through range requests, never the archive itself.
6
+
7
+ import { createHash } from 'node:crypto'
8
+ import fs from 'node:fs'
9
+ import os from 'node:os'
10
+ import path from 'node:path'
11
+ import type { SwiftPackageBinary } from './swift-packages'
12
+
13
+ const cacheDir = path.join(os.tmpdir(), 'peach-swift-binary-modules')
14
+
15
+ // the first `<name>.framework` segment of each path: a framework's own
16
+ // nested frameworks and macOS Versions/ trees are not modules of the target
17
+ function frameworkModules(paths: string[]): string[] {
18
+ const modules = new Set<string>()
19
+ for (const file of paths) {
20
+ const segment = file.split('/').find((part) => part.endsWith('.framework'))
21
+ if (segment) modules.add(segment.slice(0, -'.framework'.length))
22
+ }
23
+ return [...modules].sort()
24
+ }
25
+
26
+ async function range(url: string, spec: string) {
27
+ const response = await fetch(url, {
28
+ headers: { range: `bytes=${spec}` },
29
+ signal: AbortSignal.timeout(20_000),
30
+ })
31
+ const match = /^bytes (\d+)-\d+\/(\d+)$/.exec(
32
+ response.headers.get('content-range') ?? '',
33
+ )
34
+ if (response.status !== 206 || !match)
35
+ throw new Error(`${url} answered ${response.status} to a range request`)
36
+ return {
37
+ bytes: Buffer.from(await response.arrayBuffer()),
38
+ start: Number(match[1]),
39
+ total: Number(match[2]),
40
+ }
41
+ }
42
+
43
+ const signature = (bytes: Buffer, value: number) => {
44
+ const needle = Buffer.alloc(4)
45
+ needle.writeUInt32LE(value)
46
+ return bytes.lastIndexOf(needle)
47
+ }
48
+
49
+ // a zip's entry names from its central directory: the end record (at most
50
+ // 22 bytes plus a 64k comment from the end), zip64's when the classic
51
+ // fields overflow, then the directory itself. github's release storage
52
+ // rejects suffix ranges, so the length comes from a first byte's range.
53
+ async function zipEntries(url: string): Promise<string[]> {
54
+ const { total } = await range(url, '0-0')
55
+ const tail = await range(url, `${Math.max(0, total - 65558)}-${total - 1}`)
56
+ const end = signature(tail.bytes, 0x06054b50)
57
+ if (end < 0) throw new Error(`${url} has no zip end record`)
58
+ let size = tail.bytes.readUInt32LE(end + 12)
59
+ let offset = tail.bytes.readUInt32LE(end + 16)
60
+ if (offset === 0xffffffff || size === 0xffffffff) {
61
+ const locator = end - 20
62
+ if (locator < 0 || tail.bytes.readUInt32LE(locator) !== 0x07064b50)
63
+ throw new Error(`${url} has no zip64 locator`)
64
+ const recordAt = Number(tail.bytes.readBigUInt64LE(locator + 8))
65
+ const record =
66
+ recordAt >= tail.start
67
+ ? tail.bytes.subarray(recordAt - tail.start)
68
+ : (await range(url, `${recordAt}-${recordAt + 55}`)).bytes
69
+ size = Number(record.readBigUInt64LE(40))
70
+ offset = Number(record.readBigUInt64LE(48))
71
+ }
72
+ const directory =
73
+ offset >= tail.start
74
+ ? tail.bytes.subarray(offset - tail.start, offset - tail.start + size)
75
+ : (await range(url, `${offset}-${offset + size - 1}`)).bytes
76
+ const names: string[] = []
77
+ for (let at = 0; at + 46 <= directory.length; ) {
78
+ if (directory.readUInt32LE(at) !== 0x02014b50) break
79
+ const nameLength = directory.readUInt16LE(at + 28)
80
+ names.push(directory.toString('utf8', at + 46, at + 46 + nameLength))
81
+ at +=
82
+ 46 + nameLength + directory.readUInt16LE(at + 30) + directory.readUInt16LE(at + 32)
83
+ }
84
+ return names
85
+ }
86
+
87
+ function localEntries(dir: string): string[] {
88
+ if (!fs.existsSync(dir)) return []
89
+ return fs
90
+ .readdirSync(dir, { withFileTypes: true })
91
+ .filter((slice) => slice.isDirectory())
92
+ .flatMap((slice) =>
93
+ fs.readdirSync(path.join(dir, slice.name)).map((entry) => `${slice.name}/${entry}`),
94
+ )
95
+ }
96
+
97
+ /** the modules a binary target ships, cached per archive url. */
98
+ export async function swiftBinaryModules(binary: SwiftPackageBinary): Promise<string[]> {
99
+ if (!binary.url) return frameworkModules(localEntries(binary.dir))
100
+ const cached = path.join(
101
+ cacheDir,
102
+ `${createHash('sha256').update(binary.url).digest('hex').slice(0, 32)}.json`,
103
+ )
104
+ if (fs.existsSync(cached)) {
105
+ const value: unknown = JSON.parse(fs.readFileSync(cached, 'utf8'))
106
+ if (
107
+ Array.isArray(value) &&
108
+ value.every((name): name is string => typeof name === 'string')
109
+ )
110
+ return value
111
+ }
112
+ const modules = frameworkModules(await zipEntries(binary.url))
113
+ fs.mkdirSync(cacheDir, { recursive: true })
114
+ fs.writeFileSync(cached, JSON.stringify(modules))
115
+ return modules
116
+ }
@@ -521,6 +521,7 @@ export function swiftArtifactHash(
521
521
  moduleRoot: string,
522
522
  ): string {
523
523
  const hash = createHash('sha256')
524
+ // v18: NSValue(time:) constructs NSStructBox through NSValue.boxedTime
524
525
  // v17: AVAsset(url:) constructs AVURLAsset for the class cluster
525
526
  // v16: overrides of @objc extension members rename to __peach_ovr_
526
527
  // v15: Foundation-only sources see the platform libc (WASILibc, including
@@ -535,7 +536,7 @@ export function swiftArtifactHash(
535
536
  // v6: app and scene delegate classes compile final
536
537
  // (v5: a target declaring resources gets SwiftPM's Bundle.module accessor;
537
538
  // v4: sources compile through swiftSourceAsIOS)
538
- hash.update(`swift-compile/v17\n${release}\n`)
539
+ hash.update(`swift-compile/v18\n${release}\n`)
539
540
  if (input.oneModule) hash.update('one-module\n')
540
541
  hash.update(swiftModuleDigest(moduleRoot))
541
542
  for (const file of Object.keys(input.files).sort()) {
@@ -1272,6 +1273,30 @@ export function lowerAVAssetURLCluster(source: string): string {
1272
1273
  return out
1273
1274
  }
1274
1275
 
1276
+ // NSValue(time:) boxes a CMTime struct, which the sdk's NSValue cluster
1277
+ // cannot encode (its concrete value traps on struct objCType strings), and
1278
+ // a convenience initializer cannot substitute the box subclass, so compiled
1279
+ // sources construct the landed NSStructBox through NSValue.boxedTime
1280
+ // instead; only the token changes, spacing and the argument list stay as
1281
+ // written. NSValue.boxedTime keeps the time: label for exactly this reason.
1282
+ // every other NSValue construction keeps its spelling: timeRange:,
1283
+ // timeMapping: and the struct-taking siblings stay on their trapping stubs,
1284
+ // the explicit .init(time:) spelling stays on the shim, and the sdk's own
1285
+ // NSValue(bytes:objCType:) still traps on struct encodings (the probe's
1286
+ // sdk-trap negative pins that wall as the one the box avoids).
1287
+ export function lowerNSValueTimeBox(source: string): string {
1288
+ const masked = swiftCodeMask(source)
1289
+ const pattern = /\bNSValue\s*\(\s*time\s*:/g
1290
+ const edits: [number, number, string][] = []
1291
+ let hit: RegExpExecArray | null
1292
+ while ((hit = pattern.exec(masked)) !== null)
1293
+ edits.push([hit.index, 'NSValue'.length, 'NSValue.boxedTime'])
1294
+ let out = source
1295
+ for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
1296
+ out = out.slice(0, at) + insert + out.slice(at + remove)
1297
+ return out
1298
+ }
1299
+
1275
1300
  // the index-preserving view lowerAnyObjectDoubleValue matches on: every
1276
1301
  // char outside code (comments, strings, regex literals) reads as a space,
1277
1302
  // so an identifier that survives is code. newlines stay, keeping every
@@ -1507,8 +1532,8 @@ export function swiftSourceAsIOS(
1507
1532
  out += conditioned.slice(copied, at) + replacement
1508
1533
  copied = at + match[0].length
1509
1534
  }
1510
- return lowerAVAssetURLCluster(
1511
- lowerAnyObjectDoubleValue(out + conditioned.slice(copied)),
1535
+ return lowerNSValueTimeBox(
1536
+ lowerAVAssetURLCluster(lowerAnyObjectDoubleValue(out + conditioned.slice(copied))),
1512
1537
  )
1513
1538
  }
1514
1539
 
package/src/swift-host.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  import { authHeaderValue, resolveCliAuth } from '../cli/auth'
15
15
  import { resolveContrastBackendOrigin } from './backend-origin'
16
16
  import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
17
+ import { swiftBinaryModules } from './swift-binary-modules'
17
18
  import {
18
19
  compileSwiftProjectUnit,
19
20
  compileTargets,
@@ -29,6 +30,7 @@ import { swiftImplicitResourcePaths, type SwiftPackageTarget } from './swift-pac
29
30
  import {
30
31
  REMOTE_CHECKOUTS,
31
32
  resolveSwiftPackages,
33
+ type SwiftPackageGap,
32
34
  type SwiftPackages,
33
35
  } from './swift-packages'
34
36
  import {
@@ -835,7 +837,7 @@ async function compile(
835
837
  ...(targets.length > 0 ? targets : ['App']),
836
838
  ]),
837
839
  )
838
- if (missing.size > 0) throw new Error(missingModulesMessage(packagePath, missing))
840
+ if (missing.size > 0) throw new Error(await missingModulesMessage(packagePath, missing))
839
841
  const artifact = await compileSwiftProjectUnit(input, {
840
842
  // the compile rewrites Sources/App in its root before swiftpm builds, and
841
843
  // its lock orders one process only: two vites on one root (a lane's dev
@@ -950,12 +952,12 @@ const IOS_SDK_FRAMEWORKS = new Set(iosSdk.frameworks)
950
952
 
951
953
  // one report of every module the app imports that Peach lacks, so a project
952
954
  // learns its whole gap from one run instead of one compile error at a time.
953
- function missingModulesMessage(
955
+ async function missingModulesMessage(
954
956
  packagePath: string,
955
957
  missing: Map<string, string[]>,
956
- ): string {
958
+ ): Promise<string> {
957
959
  const layout = xcodeLayout(packagePath)
958
- const gaps = new Map([
960
+ const gaps = new Map<string, SwiftPackageGap>([
959
961
  ...(layout?.app.binaryFrameworks ?? []).map(
960
962
  (name) =>
961
963
  [name, { source: 'the project', reason: 'a vendored binary framework' }] as const,
@@ -980,6 +982,28 @@ function missingModulesMessage(
980
982
  ...(layout?.packages.modules ?? []),
981
983
  ...(layout?.packages.unavailable ?? []),
982
984
  ])
985
+ // a binary target's archive names the modules it ships, which a target's
986
+ // reason cannot: a wrapper product depends on many binaries, and a module
987
+ // such as FirebaseCore ships inside _FirebaseCore with no target of its
988
+ // own. the archives are read only for a module the sdk does not explain.
989
+ const packaged = new Set(
990
+ [...missing.keys()].filter(
991
+ (name) => !UNPROVIDED_PLATFORM_MODULES[name] && !IOS_SDK_FRAMEWORKS.has(name),
992
+ ),
993
+ )
994
+ if (packaged.size > 0)
995
+ await Promise.all(
996
+ (layout?.packages.binaries ?? []).map(async (binary) => {
997
+ // the report stands without a name an unreachable archive would add
998
+ const modules = await swiftBinaryModules(binary).catch(() => [])
999
+ for (const name of modules)
1000
+ if (packaged.has(name))
1001
+ gaps.set(name, {
1002
+ source: binary.source,
1003
+ reason: `${binary.target} is a binary framework`,
1004
+ })
1005
+ }),
1006
+ )
983
1007
  const width = Math.max(...[...missing.keys()].map((name) => name.length))
984
1008
  return [
985
1009
  `Peach does not provide ${missing.size} module${missing.size === 1 ? '' : 's'} this app imports:`,
@@ -42,6 +42,8 @@ export interface SwiftManifestTarget {
42
42
  mainActorIsolation: boolean
43
43
  /** true when the target declares `resources:`. */
44
44
  declaresResources: boolean
45
+ /** a binary target's archive url; a local one's artifact is `dir`. */
46
+ url: string | null
45
47
  }
46
48
 
47
49
  export interface SwiftPackageManifest {
@@ -257,6 +259,7 @@ export function swiftPackageManifest(dir: string): SwiftPackageManifest {
257
259
  languageMode,
258
260
  mainActorIsolation,
259
261
  declaresResources: array(target.resources).length > 0,
262
+ url: string(target.url) ?? null,
260
263
  })
261
264
  }
262
265
  const manifest = { dir, products, targets, packages }
@@ -53,6 +53,18 @@ export interface SwiftPackages {
53
53
  unavailable: Map<string, SwiftPackageGap>
54
54
  /** every module a reached package declares that does not compile. */
55
55
  modules: Map<string, SwiftPackageGap>
56
+ /** binary targets of reached packages, whose archives name the modules
57
+ * they ship under other names than the target's (_FirebaseCore vends
58
+ * FirebaseCore). */
59
+ binaries: SwiftPackageBinary[]
60
+ }
61
+
62
+ export interface SwiftPackageBinary {
63
+ target: string
64
+ source: string
65
+ /** the archive url, or null for a local artifact at `dir`. */
66
+ url: string | null
67
+ dir: string
56
68
  }
57
69
 
58
70
  /** where checkouts live, relative to the app's root. */
@@ -61,6 +73,15 @@ export const REMOTE_CHECKOUTS = path.join('.build', 'peach', 'checkouts')
61
73
  // sources the swift compile cannot build: c, c++, objective-c and assembly.
62
74
  const C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/
63
75
 
76
+ const BINARY = 'is a binary framework'
77
+ // of the reasons a target or product cannot compile, a binary framework's
78
+ // leads: no source exists for it, while a c target beside it (often an
79
+ // umbrella header) is source peach could one day build
80
+ const blocker = (reasons: (string | null)[]): string | null =>
81
+ reasons.find((reason) => reason?.includes(BINARY)) ??
82
+ reasons.find((reason) => reason !== null) ??
83
+ null
84
+
64
85
  interface Pin {
65
86
  location: string
66
87
  revision: string
@@ -150,6 +171,7 @@ export function resolveSwiftPackages(options: {
150
171
  targets: [],
151
172
  unavailable: new Map(),
152
173
  modules: new Map(),
174
+ binaries: [],
153
175
  }
154
176
  const pins = resolved ? readPins(resolved) : null
155
177
  const checkouts = path.join(rootDir, REMOTE_CHECKOUTS)
@@ -197,7 +219,7 @@ export function resolveSwiftPackages(options: {
197
219
  if (provided.has(name)) return null
198
220
  const target = pkg.manifest.targets.get(name)
199
221
  if (!target) return `${path.basename(pkg.manifest.dir)} declares no target ${name}`
200
- if (target.type === 'binary') return `${name} is a binary framework`
222
+ if (target.type === 'binary') return `${name} ${BINARY}`
201
223
  if (target.type === 'system') return `${name} is a system C library`
202
224
  if (target.type !== 'regular') return `${name} is a ${target.type} target`
203
225
  const files = swiftTargetFiles(pkg.manifest, target)
@@ -210,7 +232,7 @@ export function resolveSwiftPackages(options: {
210
232
  const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name)
211
233
  return nested && `${dependency.name}: ${nested}`
212
234
  })
213
- const blocked = reasons.find((reason) => reason !== null)
235
+ const blocked = blocker(reasons)
214
236
  if (blocked) return blocked
215
237
  const relative = files.map((file) => path.relative(target.dir, file))
216
238
  targets.set(`${pkg.manifest.dir}\0${name}`, {
@@ -239,8 +261,7 @@ export function resolveSwiftPackages(options: {
239
261
  const roots = pkg.manifest.products.get(product)
240
262
  const reason = !roots
241
263
  ? `${path.basename(pkg.manifest.dir)} has no library ${product}`
242
- : (roots.map((name) => resolveTarget(pkg, name)).find((value) => value !== null) ??
243
- null)
264
+ : blocker(roots.map((name) => resolveTarget(pkg, name)))
244
265
  productOutcomes.set(`${pkg.manifest.dir}\0${product}`, { pkg, reason })
245
266
  return reason
246
267
  }
@@ -302,6 +323,13 @@ export function resolveSwiftPackages(options: {
302
323
  if (target.type === 'test' || target.type === 'plugin' || target.type === 'macro')
303
324
  continue
304
325
  if (target.type === 'executable') continue
326
+ if (target.type === 'binary')
327
+ result.binaries.push({
328
+ target: name,
329
+ source: pkg.source,
330
+ url: target.url,
331
+ dir: target.dir,
332
+ })
305
333
  const reason = resolveTarget(pkg, name)
306
334
  if (reason && !result.modules.has(name))
307
335
  result.modules.set(name, { source: pkg.source, reason })