peachsim 0.1.759 → 0.1.760
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.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +823 -728
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +37 -220
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +37 -220
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +1120 -1019
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -110
- package/dist-lib/swift-package.mjs +1 -109
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +607 -512
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/native-seam-manifest.ts +8 -0
- package/src/swift-host.ts +64 -64
- package/src/swift-package-manifest.ts +307 -0
- package/src/swift-package.ts +2 -135
- package/src/swift-packages.ts +341 -0
- package/src/xcode-project.ts +57 -70
- package/src/swift-remote-packages.ts +0 -255
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
// the remote swift packages an app links, compiled from source: each package
|
|
2
|
-
// is fetched at the revision the project's Package.resolved pins, into the
|
|
3
|
-
// project's .build/peach/checkouts, and each linked product resolves to the
|
|
4
|
-
// source targets that build it. peach compiles swift source only, so a
|
|
5
|
-
// product reaching a binary or c-family target stays missing, with the reason.
|
|
6
|
-
|
|
7
|
-
import { execFileSync } from 'node:child_process'
|
|
8
|
-
import fs from 'node:fs'
|
|
9
|
-
import path from 'node:path'
|
|
10
|
-
import {
|
|
11
|
-
swiftManifestGraph,
|
|
12
|
-
swiftManifestTargets,
|
|
13
|
-
swiftPackageIdentity,
|
|
14
|
-
type SwiftManifestGraph,
|
|
15
|
-
type SwiftPackageTarget,
|
|
16
|
-
} from './swift-package'
|
|
17
|
-
|
|
18
|
-
export interface RemoteProduct {
|
|
19
|
-
product: string
|
|
20
|
-
repositoryURL: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** a source target from a remote checkout, its path absolute. */
|
|
24
|
-
export interface RemotePackageTarget extends SwiftPackageTarget {
|
|
25
|
-
dir: string
|
|
26
|
-
/** every file under the target directory. */
|
|
27
|
-
files: string[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface RemotePackages {
|
|
31
|
-
targets: RemotePackageTarget[]
|
|
32
|
-
/** linked products peach cannot compile, with why. */
|
|
33
|
-
unavailable: Map<string, { repositoryURL: string; reason: string }>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** where checkouts live, relative to the project directory. */
|
|
37
|
-
export const REMOTE_CHECKOUTS = path.join('.build', 'peach', 'checkouts')
|
|
38
|
-
|
|
39
|
-
interface Pin {
|
|
40
|
-
location: string
|
|
41
|
-
revision: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// sources the swift compile cannot build: c, c++, objective-c and assembly.
|
|
45
|
-
const C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/
|
|
46
|
-
|
|
47
|
-
function readPins(resolved: string): Map<string, Pin> {
|
|
48
|
-
const data: unknown = JSON.parse(fs.readFileSync(resolved, 'utf8'))
|
|
49
|
-
const pins =
|
|
50
|
-
data && typeof data === 'object' && 'pins' in data && Array.isArray(data.pins)
|
|
51
|
-
? data.pins
|
|
52
|
-
: null
|
|
53
|
-
if (!pins)
|
|
54
|
-
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`)
|
|
55
|
-
const out = new Map<string, Pin>()
|
|
56
|
-
for (const pin of pins) {
|
|
57
|
-
const identity = pin?.identity
|
|
58
|
-
const location = pin?.location
|
|
59
|
-
const revision = pin?.state?.revision
|
|
60
|
-
if (
|
|
61
|
-
typeof identity === 'string' &&
|
|
62
|
-
typeof location === 'string' &&
|
|
63
|
-
typeof revision === 'string'
|
|
64
|
-
)
|
|
65
|
-
out.set(identity, { location, revision })
|
|
66
|
-
}
|
|
67
|
-
return out
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function walk(dir: string): string[] {
|
|
71
|
-
if (!fs.existsSync(dir)) return []
|
|
72
|
-
const out: string[] = []
|
|
73
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
74
|
-
if (entry.name.startsWith('.')) continue
|
|
75
|
-
const full = path.join(dir, entry.name)
|
|
76
|
-
if (entry.isDirectory()) out.push(...walk(full))
|
|
77
|
-
else if (entry.isFile()) out.push(full)
|
|
78
|
-
}
|
|
79
|
-
return out.sort()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const verified = new Set<string>()
|
|
83
|
-
|
|
84
|
-
// a shallow checkout of exactly the pinned revision, reused while HEAD is it.
|
|
85
|
-
function checkout(checkouts: string, identity: string, pin: Pin): string {
|
|
86
|
-
const dir = path.join(checkouts, identity)
|
|
87
|
-
const key = `${dir}\0${pin.revision}`
|
|
88
|
-
if (verified.has(key)) return dir
|
|
89
|
-
const git = (...args: string[]) =>
|
|
90
|
-
execFileSync('git', ['-C', dir, ...args], {
|
|
91
|
-
encoding: 'utf8',
|
|
92
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
93
|
-
}).trim()
|
|
94
|
-
const current = fs.existsSync(path.join(dir, '.git')) ? git('rev-parse', 'HEAD') : ''
|
|
95
|
-
if (current !== pin.revision) {
|
|
96
|
-
fs.rmSync(dir, { recursive: true, force: true })
|
|
97
|
-
fs.mkdirSync(dir, { recursive: true })
|
|
98
|
-
try {
|
|
99
|
-
git('init', '-q')
|
|
100
|
-
git('fetch', '-q', '--depth', '1', pin.location, pin.revision)
|
|
101
|
-
git('checkout', '-q', 'FETCH_HEAD')
|
|
102
|
-
} catch (error) {
|
|
103
|
-
fs.rmSync(dir, { recursive: true, force: true })
|
|
104
|
-
const stderr =
|
|
105
|
-
error instanceof Error && 'stderr' in error ? String(error.stderr).trim() : ''
|
|
106
|
-
throw new Error(
|
|
107
|
-
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ''}`,
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
verified.add(key)
|
|
112
|
-
return dir
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* fetches and resolves `products` against the pins in `resolved`. products
|
|
117
|
-
* named in `provided` are peach modules and link as those instead.
|
|
118
|
-
*/
|
|
119
|
-
export function resolveRemotePackages(
|
|
120
|
-
projectDir: string,
|
|
121
|
-
resolved: string | null,
|
|
122
|
-
products: readonly RemoteProduct[],
|
|
123
|
-
provided: ReadonlySet<string>,
|
|
124
|
-
): RemotePackages {
|
|
125
|
-
const result: RemotePackages = { targets: [], unavailable: new Map() }
|
|
126
|
-
const wanted = products.filter((entry) => !provided.has(entry.product))
|
|
127
|
-
if (wanted.length === 0) return result
|
|
128
|
-
if (!resolved) {
|
|
129
|
-
for (const entry of wanted)
|
|
130
|
-
result.unavailable.set(entry.product, {
|
|
131
|
-
repositoryURL: entry.repositoryURL,
|
|
132
|
-
reason: 'no Package.resolved pins it; resolve packages in Xcode once',
|
|
133
|
-
})
|
|
134
|
-
return result
|
|
135
|
-
}
|
|
136
|
-
const pins = readPins(resolved)
|
|
137
|
-
const checkouts = path.join(projectDir, REMOTE_CHECKOUTS)
|
|
138
|
-
fs.mkdirSync(checkouts, { recursive: true })
|
|
139
|
-
// fetched sources never show up as changes in the app's repository
|
|
140
|
-
fs.writeFileSync(path.join(path.dirname(checkouts), '.gitignore'), '*\n')
|
|
141
|
-
|
|
142
|
-
const packages = new Map<
|
|
143
|
-
string,
|
|
144
|
-
{ dir: string; manifest: string; graph: SwiftManifestGraph }
|
|
145
|
-
>()
|
|
146
|
-
const load = (identity: string) => {
|
|
147
|
-
const cached = packages.get(identity)
|
|
148
|
-
if (cached) return cached
|
|
149
|
-
const pin = pins.get(identity)
|
|
150
|
-
if (!pin) return null
|
|
151
|
-
const dir = checkout(checkouts, identity, pin)
|
|
152
|
-
const manifest = fs.readFileSync(path.join(dir, 'Package.swift'), 'utf8')
|
|
153
|
-
const loaded = { dir, manifest, graph: swiftManifestGraph(manifest) }
|
|
154
|
-
packages.set(identity, loaded)
|
|
155
|
-
return loaded
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const targets = new Map<string, RemotePackageTarget>()
|
|
159
|
-
// product key to the reason it cannot compile, or null once it can
|
|
160
|
-
const outcomes = new Map<string, string | null>()
|
|
161
|
-
const resolveProduct = (identity: string, product: string): string | null => {
|
|
162
|
-
const key = `${identity}\0${product}`
|
|
163
|
-
if (outcomes.has(key)) return outcomes.get(key)!
|
|
164
|
-
outcomes.set(key, null)
|
|
165
|
-
const pkg = load(identity)
|
|
166
|
-
if (!pkg) {
|
|
167
|
-
outcomes.set(key, `package ${identity} is not pinned in Package.resolved`)
|
|
168
|
-
return outcomes.get(key)!
|
|
169
|
-
}
|
|
170
|
-
const roots = pkg.graph.products.get(product)
|
|
171
|
-
if (!roots) {
|
|
172
|
-
outcomes.set(key, `package ${identity} has no library ${product}`)
|
|
173
|
-
return outcomes.get(key)!
|
|
174
|
-
}
|
|
175
|
-
const declared = new Map(
|
|
176
|
-
swiftManifestTargets(pkg.manifest).map((target) => [target.name, target]),
|
|
177
|
-
)
|
|
178
|
-
const reached: SwiftPackageTarget[] = []
|
|
179
|
-
const seen = new Set<string>()
|
|
180
|
-
const pending = [...roots]
|
|
181
|
-
let reason: string | null = null
|
|
182
|
-
while (pending.length > 0 && !reason) {
|
|
183
|
-
const name = pending.pop()!
|
|
184
|
-
if (seen.has(name) || provided.has(name)) continue
|
|
185
|
-
seen.add(name)
|
|
186
|
-
if (pkg.graph.binaryTargets.has(name)) {
|
|
187
|
-
reason = `${name} is a binary framework`
|
|
188
|
-
break
|
|
189
|
-
}
|
|
190
|
-
if (pkg.graph.systemLibraries.has(name)) {
|
|
191
|
-
reason = `${name} is a system C library`
|
|
192
|
-
break
|
|
193
|
-
}
|
|
194
|
-
const target = declared.get(name)
|
|
195
|
-
if (!target) {
|
|
196
|
-
reason = `${identity} declares no target ${name}`
|
|
197
|
-
break
|
|
198
|
-
}
|
|
199
|
-
const files = walk(path.join(pkg.dir, target.path))
|
|
200
|
-
if (files.some((file) => C_FAMILY.test(file))) {
|
|
201
|
-
reason = `${name} is a C or Objective-C target`
|
|
202
|
-
break
|
|
203
|
-
}
|
|
204
|
-
reached.push(target)
|
|
205
|
-
for (const dependency of pkg.graph.dependencies.get(name) ?? []) {
|
|
206
|
-
if (dependency.kind === 'target') pending.push(dependency.name)
|
|
207
|
-
else if (!provided.has(dependency.name)) {
|
|
208
|
-
const url = pkg.graph.packageURLs.get(dependency.package)
|
|
209
|
-
const nested = resolveProduct(
|
|
210
|
-
url ? swiftPackageIdentity(url) : dependency.package,
|
|
211
|
-
dependency.name,
|
|
212
|
-
)
|
|
213
|
-
if (nested) reason = `${dependency.name}: ${nested}`
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (reason) {
|
|
218
|
-
outcomes.set(key, reason)
|
|
219
|
-
return reason
|
|
220
|
-
}
|
|
221
|
-
// resources need the files each target holds, relative to its package
|
|
222
|
-
const relative = reached.flatMap((target) =>
|
|
223
|
-
walk(path.join(pkg.dir, target.path)).map((file) =>
|
|
224
|
-
path.relative(pkg.dir, file).split(path.sep).join(path.posix.sep),
|
|
225
|
-
),
|
|
226
|
-
)
|
|
227
|
-
const withResources = new Map(
|
|
228
|
-
swiftManifestTargets(pkg.manifest, relative).map((target) => [target.name, target]),
|
|
229
|
-
)
|
|
230
|
-
for (const target of reached) {
|
|
231
|
-
const dir = path.join(pkg.dir, target.path)
|
|
232
|
-
targets.set(target.name, {
|
|
233
|
-
...(withResources.get(target.name) ?? target),
|
|
234
|
-
executable: false,
|
|
235
|
-
dir,
|
|
236
|
-
files: walk(dir),
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
return null
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
for (const entry of wanted) {
|
|
243
|
-
const reason = resolveProduct(
|
|
244
|
-
swiftPackageIdentity(entry.repositoryURL),
|
|
245
|
-
entry.product,
|
|
246
|
-
)
|
|
247
|
-
if (reason)
|
|
248
|
-
result.unavailable.set(entry.product, {
|
|
249
|
-
repositoryURL: entry.repositoryURL,
|
|
250
|
-
reason,
|
|
251
|
-
})
|
|
252
|
-
}
|
|
253
|
-
result.targets = [...targets.values()]
|
|
254
|
-
return result
|
|
255
|
-
}
|