peachsim 0.1.2187 → 0.1.2189

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 (86) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +1 -1
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +1 -1
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +1 -1
  13. package/dist-lib/bundle-channel.cjs +33 -27
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +1 -1
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +1 -1
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +1 -1
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +1 -1
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +1 -1
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/expo-swift-bundle.cjs +32 -26
  27. package/dist-lib/expo-swift-metadata.cjs +1 -1
  28. package/dist-lib/expo-swift-metadata.mjs +1 -1
  29. package/dist-lib/home-paths.cjs +1 -1
  30. package/dist-lib/host/bridge-host.cjs +33 -27
  31. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  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 +5 -5
  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 +5 -5
  47. package/dist-lib/native-app-identity-project.cjs +4 -4
  48. package/dist-lib/native-app-identity-project.mjs +4 -4
  49. package/dist-lib/native-app-identity.cjs +1 -1
  50. package/dist-lib/native-app-identity.mjs +1 -1
  51. package/dist-lib/native-firebase-metadata.cjs +1 -1
  52. package/dist-lib/native-firebase-metadata.mjs +1 -1
  53. package/dist-lib/pdfium-raster.cjs +1 -1
  54. package/dist-lib/pdfium-raster.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/public-origins-lib-esm.json +24 -24
  60. package/dist-lib/public-origins-lib.json +53 -53
  61. package/dist-lib/react-native-host-modules.cjs +1 -1
  62. package/dist-lib/react-native-host-modules.mjs +1 -1
  63. package/dist-lib/reap-browser.cjs +1 -1
  64. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  65. package/dist-lib/sdk.cjs +1 -1
  66. package/dist-lib/sdk.mjs +1 -1
  67. package/dist-lib/skills.cjs +33 -27
  68. package/dist-lib/swift-compile.cjs +28 -22
  69. package/dist-lib/swift-compile.mjs +28 -22
  70. package/dist-lib/swift-package.cjs +1 -1
  71. package/dist-lib/swift-package.mjs +1 -1
  72. package/dist-lib/swift-submit.cjs +1 -1
  73. package/dist-lib/swift-submit.mjs +1 -1
  74. package/dist-lib/swift-toolchain.cjs +4 -2
  75. package/dist-lib/swift.cjs +1 -1
  76. package/dist-lib/vite-swift.cjs +31 -25
  77. package/dist-lib/vite.cjs +4 -4
  78. package/dist-lib/worklet-executable.cjs +1 -1
  79. package/dist-lib/worklet-executable.mjs +1 -1
  80. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -1
  81. package/package.json +1 -1
  82. package/src/swift-compile.ts +28 -18
  83. package/src/swift-distribution-contract.ts +72 -0
  84. package/src/swift-guest-source-plan.ts +8 -4
  85. package/src/swift-toolchain.ts +4 -3
  86. package/src/xcode-project.ts +3 -1
@@ -4903,26 +4903,27 @@ export function writeSwiftProject(
4903
4903
  allowExisting: true,
4904
4904
  })
4905
4905
  // clang resolves a framework map loaded through extern module against
4906
- // the map directory, not the framework root, so mirror the umbrella there
4906
+ // the map directory, not the framework root, so mirror every header
4907
+ // the map names there. clang looks in Headers/ and PrivateHeaders/ for
4908
+ // a framework module's header, whatever its keyword (a podspec
4909
+ // module_map names private headers in explicit submodules).
4907
4910
  if (modulemap.endsWith('/Modules/module.modulemap')) {
4908
- const headers = path.posix.join(
4909
- path.posix.dirname(path.posix.dirname(modulemap)),
4910
- 'Headers',
4911
- )
4912
- const mirrored = path.posix.join(path.posix.dirname(modulemap), 'Headers')
4913
- for (const [, umbrella] of moduleContents
4911
+ const framework = path.posix.dirname(path.posix.dirname(modulemap))
4912
+ for (const [, header] of moduleContents
4914
4913
  .toString()
4915
- .matchAll(/\bumbrella\s+header\s+"([^"]+)"/g)) {
4916
- const source = settings.productHeaders[path.posix.join(headers, umbrella!)]
4917
- const contents = source === undefined ? undefined : input.files[source]
4918
- if (contents !== undefined)
4919
- stageTargetFile(
4920
- target.name,
4921
- path.join(layout.root, mirrored, umbrella!),
4922
- contents,
4923
- { allowExisting: true },
4924
- )
4925
- }
4914
+ .matchAll(/\bheader\s+"([^"]+)"/g))
4915
+ for (const folder of ['Headers', 'PrivateHeaders']) {
4916
+ const source =
4917
+ settings.productHeaders[path.posix.join(framework, folder, header!)]
4918
+ const contents = source === undefined ? undefined : input.files[source]
4919
+ if (contents !== undefined)
4920
+ stageTargetFile(
4921
+ target.name,
4922
+ path.join(layout.root, path.posix.dirname(modulemap), folder, header!),
4923
+ contents,
4924
+ { allowExisting: true },
4925
+ )
4926
+ }
4926
4927
  }
4927
4928
  if (nativeC && path.posix.basename(modulemap) !== 'module.modulemap') {
4928
4929
  stageTargetFile(
@@ -5342,7 +5343,16 @@ export function writeSwiftProject(
5342
5343
  swiftModules.delete(name)
5343
5344
  projectOverlayFrameworks.delete(name)
5344
5345
  }
5346
+ // a mixed target's framework map is the clang half of its own module
5347
+ // (swift imports it as the underlying module), not a framework a Swift
5348
+ // module replaces, so its submodule imports stay.
5349
+ const mixedModules = new Set(
5350
+ [...native].flatMap(([name, value]) =>
5351
+ value.mixed ? [swiftTargetModuleName(name)] : [],
5352
+ ),
5353
+ )
5345
5354
  for (const name of sourceModules) swiftModules.add(name)
5355
+ for (const name of mixedModules) swiftModules.delete(name)
5346
5356
  for (const [file, contents] of Object.entries(input.files))
5347
5357
  if (file.endsWith('.modulemap'))
5348
5358
  addSwiftOverlayFrameworks(contents, swiftModules, projectOverlayFrameworks)
@@ -161,3 +161,75 @@ export function parseSwiftDistributionLock(value: unknown): SwiftDistributionLoc
161
161
  export function swiftDistributionKey(id: string, host: SwiftDistributionHost): string {
162
162
  return `${id}/${host}.tar.gz`
163
163
  }
164
+
165
+ /** the canary index under PEACH_SWIFT_ENDPOINT: the newest unpinned builds. */
166
+ export const SWIFT_CANARY_INDEX = 'canary/index.json'
167
+
168
+ /** one unpinned distribution build any agent can fetch instead of rebuilding.
169
+ * its wasm SDK is a pinned public URL, or a local candidate uploaded beside it
170
+ * under `wasmSdkKey`. */
171
+ export interface SwiftDistributionCanary extends SwiftWasmSdk {
172
+ /** the distribution id plus the SDK checksum prefix: one set of build inputs. */
173
+ id: string
174
+ distribution: string
175
+ release: string
176
+ /** the commit the module sources were built from. */
177
+ source: string
178
+ builtBy: string
179
+ builtAt: string
180
+ wasmSdkKey?: string
181
+ hosts: Partial<Record<SwiftDistributionHost, { sha256: string; size: number }>>
182
+ }
183
+
184
+ export function swiftCanaryKey(id: string, host: SwiftDistributionHost): string {
185
+ return `canary/${id}/${host}.tar.gz`
186
+ }
187
+
188
+ export function parseSwiftCanaryIndex(value: unknown): SwiftDistributionCanary[] {
189
+ if (!Array.isArray(value)) throw new Error('invalid Swift canary index')
190
+ return value.map((item) => {
191
+ if (
192
+ !isRecord(item) ||
193
+ ![
194
+ item.id,
195
+ item.distribution,
196
+ item.release,
197
+ item.source,
198
+ item.builtBy,
199
+ item.builtAt,
200
+ item.wasmSdkId,
201
+ item.wasmSdkUrl,
202
+ item.wasmSdkChecksum,
203
+ ].every((field) => typeof field === 'string') ||
204
+ (item.wasmSdkKey !== undefined && typeof item.wasmSdkKey !== 'string') ||
205
+ !isRecord(item.hosts)
206
+ )
207
+ throw new Error('invalid Swift canary index entry')
208
+ const hosts: SwiftDistributionCanary['hosts'] = {}
209
+ for (const host of SWIFT_DISTRIBUTION_HOSTS) {
210
+ const archive = item.hosts[host]
211
+ if (archive === undefined) continue
212
+ if (
213
+ !isRecord(archive) ||
214
+ typeof archive.sha256 !== 'string' ||
215
+ !/^[a-f0-9]{64}$/.test(archive.sha256) ||
216
+ typeof archive.size !== 'number'
217
+ )
218
+ throw new Error(`invalid Swift canary archive for ${host}`)
219
+ hosts[host] = { sha256: archive.sha256, size: archive.size }
220
+ }
221
+ return {
222
+ id: String(item.id),
223
+ distribution: String(item.distribution),
224
+ release: String(item.release),
225
+ source: String(item.source),
226
+ builtBy: String(item.builtBy),
227
+ builtAt: String(item.builtAt),
228
+ wasmSdkId: String(item.wasmSdkId),
229
+ wasmSdkUrl: String(item.wasmSdkUrl),
230
+ wasmSdkChecksum: String(item.wasmSdkChecksum),
231
+ ...(typeof item.wasmSdkKey === 'string' ? { wasmSdkKey: item.wasmSdkKey } : {}),
232
+ hosts,
233
+ }
234
+ })
235
+ }
@@ -123,10 +123,14 @@ export function guestSourceObjects(
123
123
  target.sourceTarget === null ? [] : [target.sourceTarget],
124
124
  ),
125
125
  )
126
- // swiftpm names each build directory by its target's c99 module name
127
- const owners = new Map(
128
- [...generatedOwners].map(([name, owner]) => [swiftTargetModuleName(name), owner]),
129
- )
126
+ // swiftpm names each build directory by its target's c99 module name; a
127
+ // target of a package kept as a dependency builds into the same tree.
128
+ const owners = new Map([
129
+ ...[...names].map((name) => [swiftTargetModuleName(name), name] as const),
130
+ ...[...generatedOwners].map(
131
+ ([name, owner]) => [swiftTargetModuleName(name), owner] as const,
132
+ ),
133
+ ])
130
134
  // a binary target's prebuilt WebAssembly library is named for the target
131
135
  const libraries = new Map(
132
136
  graph.targets.flatMap((target) =>
@@ -529,7 +529,8 @@ export const SWIFT_AUTOLINK_LINKER = '.peach-wasm-ld'
529
529
  * for a 42MB output). the linker written here keeps the first copy of each
530
530
  * -l flag in clang's response file and runs the toolchain's wasm-ld, which
531
531
  * links the same bytes in about 1GiB. callers pass its path to clang with
532
- * `-Xclang-linker -fuse-ld=<path>`.
532
+ * `-Xclang-linker -fuse-ld=<path>`. it also drops apple ld's -ObjC, which wasm-ld
533
+ * rejects; the guest link loads objective-c archive members itself.
533
534
  */
534
535
  export function writeSwiftAutolinkLinker(
535
536
  directory: string,
@@ -543,7 +544,7 @@ for arg in "$@"; do
543
544
  case $arg in
544
545
  @*)
545
546
  rsp=\${arg#@}
546
- awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next }${omitLibraries.map((name) => ` $0 == "\\"-l${name}\\"" { next }`).join('')} { print }' "$rsp" > "$rsp.dedup"
547
+ awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next }${omitLibraries.map((name) => ` $0 == "\\"-l${name}\\"" { next }`).join('')} $0 == "\\"-ObjC\\"" { next } { print }' "$rsp" > "$rsp.dedup"
547
548
  mv "$rsp.dedup" "$rsp"
548
549
  if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
549
550
  cp "$rsp" ${JSON.stringify(path.join(directory, '.peach-link.rsp'))}
@@ -567,7 +568,7 @@ exec ${JSON.stringify(path.join(toolchainBin, 'wasm-ld'))} "$@"
567
568
  }
568
569
 
569
570
  // home-paths.ts's rnxHomeDir, repeated because this file imports node builtins only.
570
- function peachHome(): string {
571
+ export function peachHome(): string {
571
572
  const override = process.env.PEACH_HOME
572
573
  return override ? path.resolve(override) : path.join(os.homedir(), '.peach')
573
574
  }
@@ -3188,7 +3188,9 @@ export function readXcodeAppTarget(
3188
3188
  installName: settings('LD_DYLIB_INSTALL_NAME') || null,
3189
3189
  buildVersion: {
3190
3190
  platform: settings('PLATFORM_NAME') || null,
3191
- minimumOS: settings('IPHONEOS_DEPLOYMENT_TARGET') || null,
3191
+ minimumOS:
3192
+ settings('IPHONEOS_DEPLOYMENT_TARGET') ||
3193
+ XCODE_DEFAULT_IOS_DEPLOYMENT_TARGET,
3192
3194
  sdk: settings('SDK_VERSION') || null,
3193
3195
  },
3194
3196
  machOType: settings('MACH_O_TYPE') || null,