peachsim 0.1.769 → 0.1.770

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 (75) hide show
  1. package/cli/outbound-endpoints.ts +14 -0
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/agent-identity.cjs +1 -1
  5. package/dist-lib/agent-sessions.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cli-constants.cjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/detox/index.cjs +1 -1
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/home-paths.cjs +1 -1
  29. package/dist-lib/host/bridge-host.cjs +548 -436
  30. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  32. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  33. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  34. package/dist-lib/host/websocket-proxy.cjs +1 -1
  35. package/dist-lib/index.cjs +1 -1
  36. package/dist-lib/jump-to-source-babel.cjs +1 -1
  37. package/dist-lib/jump-to-source-native.cjs +1 -1
  38. package/dist-lib/kotlin-host.cjs +1 -1
  39. package/dist-lib/menu.cjs +1 -1
  40. package/dist-lib/menu.mjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  42. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  43. package/dist-lib/metro-production-bundle.cjs +1 -1
  44. package/dist-lib/metro-production-bundle.mjs +1 -1
  45. package/dist-lib/metro.cjs +1 -1
  46. package/dist-lib/native-app-identity.cjs +1 -1
  47. package/dist-lib/native-app-identity.mjs +1 -1
  48. package/dist-lib/native-firebase-metadata.cjs +1 -1
  49. package/dist-lib/native-firebase-metadata.mjs +1 -1
  50. package/dist-lib/plist.cjs +1 -1
  51. package/dist-lib/plist.mjs +1 -1
  52. package/dist-lib/profiles.cjs +1 -1
  53. package/dist-lib/public-brand.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.cjs +1 -1
  55. package/dist-lib/react-native-host-modules.mjs +1 -1
  56. package/dist-lib/render-mode.cjs +1 -1
  57. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  58. package/dist-lib/sdk.cjs +1 -1
  59. package/dist-lib/sdk.mjs +1 -1
  60. package/dist-lib/skills.cjs +817 -698
  61. package/dist-lib/swift-compile.cjs +1 -1
  62. package/dist-lib/swift-compile.mjs +1 -1
  63. package/dist-lib/swift-package.cjs +1 -1
  64. package/dist-lib/swift-package.mjs +1 -1
  65. package/dist-lib/swift-submit.cjs +1 -1
  66. package/dist-lib/swift-submit.mjs +1 -1
  67. package/dist-lib/swift-toolchain.cjs +1 -1
  68. package/dist-lib/swift.cjs +1 -1
  69. package/dist-lib/vite-swift.cjs +381 -269
  70. package/dist-lib/vite.cjs +1 -1
  71. package/package.json +1 -1
  72. package/src/swift-binary-modules.ts +116 -0
  73. package/src/swift-host.ts +28 -4
  74. package/src/swift-package-manifest.ts +3 -0
  75. 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.770 | (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.770",
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
+ }
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 })