peachsim 0.1.2440 → 0.1.2441

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 (135) 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 +2 -2
  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 +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +8154 -8386
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-B27MTHKJ.mjs → acorn-FRQNHKFC.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-H6QIEJRC.mjs → chunk-4BZ3Z3IQ.mjs} +2 -2
  28. package/dist-lib/esm-chunks/{chunk-HIK3VREC.mjs → chunk-4HEUXQGM.mjs} +4 -4
  29. package/dist-lib/esm-chunks/{chunk-EATI62W3.mjs → chunk-4ZRMJ5YO.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-5CZQZKYU.mjs → chunk-6A6JEVIF.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-HP7DHONL.mjs → chunk-ABMB3G7I.mjs} +3 -3
  32. package/dist-lib/esm-chunks/{chunk-D4Z36DQQ.mjs → chunk-BAYRN7ZL.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-R5FNLCBO.mjs → chunk-DJMWTW2B.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-X6UKJ5AX.mjs → chunk-IRMC5BCX.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-6HFWZJ6C.mjs → chunk-NPLEBOWJ.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-ADE23YGG.mjs → chunk-O4EOBXAP.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-WQISIGIX.mjs → chunk-ORYS5CC4.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-PRZI3CFF.mjs → chunk-PMGJ7FLI.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-ZXNBC3PZ.mjs → chunk-QUBR7LHU.mjs} +2025 -1915
  40. package/dist-lib/esm-chunks/{chunk-4U7IGWPB.mjs → chunk-QYYJESMK.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-SJFNKW3W.mjs → chunk-VAQJQDWI.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-6JGALQD5.mjs → chunk-VCAJFWZD.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-RVMUQQWC.mjs → chunk-XO5GX4PI.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-QECVPSP3.mjs → chunk-ZCMAKWHN.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{metro-layout-parser-ZOI5PO4E.mjs → metro-layout-parser-AUAVE5VL.mjs} +3 -3
  46. package/dist-lib/expo-swift-bundle.cjs +5558 -5761
  47. package/dist-lib/expo-swift-metadata.cjs +1 -1
  48. package/dist-lib/expo-swift-metadata.mjs +7 -7
  49. package/dist-lib/home-paths.cjs +1 -1
  50. package/dist-lib/host/bridge-host.cjs +6305 -6490
  51. package/dist-lib/host/fetch-proxy-handler.cjs +13890 -13918
  52. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  53. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  54. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  55. package/dist-lib/host/websocket-proxy.cjs +1 -1
  56. package/dist-lib/index.cjs +1 -1
  57. package/dist-lib/jump-to-source-babel.cjs +1 -1
  58. package/dist-lib/jump-to-source-native.cjs +1 -1
  59. package/dist-lib/kotlin-host.cjs +1 -1
  60. package/dist-lib/menu.cjs +1 -1
  61. package/dist-lib/menu.mjs +3 -3
  62. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  63. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  64. package/dist-lib/metro-production-bundle.cjs +1 -1
  65. package/dist-lib/metro-production-bundle.mjs +4 -4
  66. package/dist-lib/native-app-identity-project.cjs +784 -536
  67. package/dist-lib/native-app-identity-project.mjs +543 -408
  68. package/dist-lib/native-app-identity.cjs +1 -1
  69. package/dist-lib/native-app-identity.mjs +6 -6
  70. package/dist-lib/native-firebase-metadata.cjs +1 -1
  71. package/dist-lib/native-firebase-metadata.mjs +3 -3
  72. package/dist-lib/pdfium-raster.cjs +1 -1
  73. package/dist-lib/pdfium-raster.mjs +2 -2
  74. package/dist-lib/plist.cjs +1 -1
  75. package/dist-lib/plist.mjs +3 -3
  76. package/dist-lib/profiles.cjs +1 -1
  77. package/dist-lib/public-brand.cjs +1 -1
  78. package/dist-lib/public-origins-lib-esm.json +72 -70
  79. package/dist-lib/public-origins-lib.json +176 -186
  80. package/dist-lib/react-native-host-modules.cjs +1 -1
  81. package/dist-lib/react-native-host-modules.mjs +2 -2
  82. package/dist-lib/reap-browser.cjs +1 -1
  83. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  84. package/dist-lib/sdk.cjs +1 -1
  85. package/dist-lib/sdk.mjs +7 -7
  86. package/dist-lib/skills.cjs +7542 -7739
  87. package/dist-lib/swift-compile.cjs +1967 -1919
  88. package/dist-lib/swift-compile.mjs +8 -8
  89. package/dist-lib/swift-package.cjs +1 -1
  90. package/dist-lib/swift-package.mjs +3 -3
  91. package/dist-lib/swift-submit.cjs +1 -1
  92. package/dist-lib/swift-submit.mjs +5 -5
  93. package/dist-lib/swift-toolchain.cjs +3 -1
  94. package/dist-lib/swift.cjs +1 -1
  95. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  96. package/dist-lib/vendor/acorn.cjs +1 -1
  97. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  98. package/dist-lib/vendor/ignore.cjs +1 -1
  99. package/dist-lib/vendor/magic-string.cjs +1 -1
  100. package/dist-lib/vendor/plist.cjs +1 -1
  101. package/dist-lib/vendor/smol-toml.cjs +1 -1
  102. package/dist-lib/vendor/stream-json.cjs +1 -1
  103. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  104. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  105. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  106. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  107. package/dist-lib/vendor/sucrase.cjs +1 -1
  108. package/dist-lib/vendor/terser.cjs +1 -1
  109. package/dist-lib/vendor/valibot.cjs +1 -1
  110. package/dist-lib/vendor/zod.cjs +1 -1
  111. package/dist-lib/worklet-executable.cjs +1 -1
  112. package/dist-lib/worklet-executable.mjs +3 -3
  113. package/package.json +1 -1
  114. package/src/expo-discovery-cache.ts +9 -45
  115. package/src/expo-native-compiler-digest.ts +8 -0
  116. package/src/expo-native-prebuilt.ts +1 -10
  117. package/src/expo-native-workspace.ts +5 -120
  118. package/src/expo-pod-prebuilt.ts +1 -1
  119. package/src/expo-swift-host.ts +48 -35
  120. package/src/installed-native-libraries.ts +10 -20
  121. package/src/pod-graph-specifications.ts +11 -0
  122. package/src/pods-install.ts +10 -7
  123. package/src/podspec-cocoapods.ts +8 -3
  124. package/src/podspec-sources.ts +19 -15
  125. package/src/swift-clang-type-ownership.ts +118 -0
  126. package/src/swift-compile.ts +7 -5
  127. package/src/swift-guest-image-ledger.ts +48 -0
  128. package/src/swift-guest-link.ts +11 -1
  129. package/src/swift-host.ts +5 -8
  130. package/src/swift-packages.ts +0 -5
  131. package/src/swift-toolchain.ts +1 -1
  132. package/src/xcode-project.ts +64 -46
  133. package/src/portable-expo-contract.ts +0 -108
  134. package/src/portable-expo-workspace.ts +0 -100
  135. package/src/prepared-xcode-phases.ts +0 -194
package/src/swift-host.ts CHANGED
@@ -20,7 +20,6 @@ import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
20
20
  import { type NativeAppIdentity } from './native-app-identity'
21
21
  import { readNativeAppIdentityFromXcodeTarget } from './native-app-identity-project'
22
22
  import { parsePlistSource } from './plist'
23
- import { preparedSwiftCheckouts } from './prepared-xcode-phases'
24
23
  import { swiftBinaryModules } from './swift-binary-modules'
25
24
  import { normalizeSwiftCatalogPng } from './swift-catalog-png'
26
25
  import {
@@ -433,9 +432,7 @@ function readXcodeAppTargetPrepared(
433
432
  deferPackageResolution: true,
434
433
  })
435
434
  const key = JSON.stringify([input, target, configuration, options.nativeModules])
436
- // a transported workspace consumes attested outputs and pinned checkouts
437
- // directly. readers must not relink its shared, already relocated tree.
438
- if (!preparedScriptInputs.has(key) && !preparedSwiftCheckouts(input)) {
435
+ if (!preparedScriptInputs.has(key)) {
439
436
  const probe = readXcodeAppTarget(input, target, configuration, {
440
437
  ...options,
441
438
  prepareGeneratedSources: false,
@@ -2462,10 +2459,10 @@ export function buildSwiftBundleFiles(
2462
2459
  for (const [name, bytes] of Object.entries(compileCoreDataModel(model)))
2463
2460
  addFile(`${prefix}${name}`, bytes)
2464
2461
  }
2465
- for (const { base, file } of enumerateBundleResources(
2466
- [...members.keys()],
2467
- bundlePath.endsWith('.bundle'),
2468
- )) {
2462
+ for (const { base, file } of enumerateBundleResources([...members.keys()], {
2463
+ copiedBundle: bundlePath.endsWith('.bundle'),
2464
+ copyLooseRasters: !hosted,
2465
+ })) {
2469
2466
  const disk = members.get(file)!
2470
2467
  watched.push(path.relative(packagePath, disk).split(path.sep).join('/'))
2471
2468
  const bytes = readPackageFile(packagePath, disk, limits.resourceBytes)
@@ -19,7 +19,6 @@ import { UNATTENDED_GIT_ENV, withoutGitRepositoryEnv } from './git-repo-env'
19
19
  import { cacheDir } from './home-paths'
20
20
  import { requireNativeGit } from './native-git'
21
21
  import { tryAcquireNumberedLock } from './numbered-lock'
22
- import { preparedSwiftCheckouts, preparedSwiftPin } from './prepared-xcode-phases'
23
22
  import { swiftCTakesReturnAddress } from './swift-compile'
24
23
  import {
25
24
  isSwiftNativeTranslationUnit,
@@ -220,8 +219,6 @@ const sourceFrameworkRecipes = new Map<
220
219
 
221
220
  /** dependency checkouts belong to peach, isolated by the canonical app root. */
222
221
  export function remoteSwiftCheckouts(root: string): string {
223
- const prepared = preparedSwiftCheckouts(root)
224
- if (prepared) return prepared
225
222
  const key = createHash('sha256')
226
223
  .update(fs.realpathSync(root))
227
224
  .digest('hex')
@@ -412,7 +409,6 @@ async function fetchCheckout(
412
409
  signal: AbortSignal | undefined,
413
410
  ): Promise<void> {
414
411
  const dir = path.join(checkouts, identity)
415
- if (preparedSwiftPin(checkouts, identity, pin.location, pin.revision)) return
416
412
  requireNativeGit()
417
413
  const key = checkoutKey(dir, pin)
418
414
  const gitEnv: NodeJS.ProcessEnv = {
@@ -544,7 +540,6 @@ const checkoutKey = (dir: string, pin: Pin) => `${dir}\0${pin.revision}`
544
540
  // `checkout FETCH_HEAD`) must still be the pin.
545
541
  function fetchedCheckout(checkouts: string, identity: string, pin: Pin): string {
546
542
  const dir = path.join(checkouts, identity)
547
- if (preparedSwiftPin(checkouts, identity, pin.location, pin.revision)) return dir
548
543
  const head = path.join(dir, '.git', 'HEAD')
549
544
  if (
550
545
  !verified.has(checkoutKey(dir, pin)) ||
@@ -153,7 +153,7 @@ export function privateSwiftCompilerRelease(): string | null {
153
153
  return process.env.PEACH_SWIFT_PRIVATE_COMPILER_RELEASE?.trim() || null
154
154
  }
155
155
 
156
- function privateSwiftRelease(): string | null {
156
+ export function privateSwiftRelease(): string | null {
157
157
  const compiler = privateSwiftCompilerRelease()
158
158
  if (compiler) return compiler
159
159
  const root = privateSwiftDistributionRoot()
@@ -16,14 +16,23 @@ import { isBazelPackage, readBazelAppTarget } from './bazel-project'
16
16
  import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
17
17
  import { isRecord } from './is-record'
18
18
  import { readKeychainAccessGroups } from './native-app-identity'
19
- import { preparedXcodePhase } from './prepared-xcode-phases'
19
+ import {
20
+ POD_GRAPH_SPECIFICATIONS,
21
+ readPodGraphSpecifications,
22
+ } from './pod-graph-specifications'
20
23
  import { localSwiftBinaryModules } from './swift-binary-modules'
21
24
  import { assetSymbolSettingKeys } from './swift-coverage/xcode-assets'
25
+ import { swiftNativePin } from './swift-native-pin'
22
26
  import { isSwiftNativeTranslationUnit, moduleMapName } from './swift-package'
23
27
  import {
24
28
  resolveSwiftPackageRequirementsAsync,
25
29
  type SwiftRemoteRequirement,
26
30
  } from './swift-package-manifest'
31
+ import {
32
+ privateSwiftRelease,
33
+ swiftEnvironment,
34
+ swiftToolchainBin,
35
+ } from './swift-toolchain'
27
36
  import { readXcodeJsonProject } from './xcode-json-project'
28
37
  import {
29
38
  xcodeBuildFileBuildsForIos,
@@ -229,7 +238,8 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
229
238
  /** each installed pod's specification checksum, as the lock records it. */
230
239
  specChecksums: Record<string, string>
231
240
  /** the specifications of pods installed from a local path or a repository. */
232
- localPodspecs: string[]
241
+ localPodspecs: ReadonlyMap<string, string>
242
+ specificationFiles: string[]
233
243
  } | null
234
244
  }
235
245
 
@@ -520,8 +530,7 @@ export function selectXcodeWorkspace(
520
530
  return named.length === 1 ? path.join(directory, named[0]!) : null
521
531
  }
522
532
 
523
- /** the CocoaPods workspace in a project's ios directory, or null while no pods
524
- * are installed: off a Mac, prebuild alone produces the Xcode project. */
533
+ /** the workspace in a project's ios directory, or null before pods are installed. */
525
534
  export function installedXcodeWorkspace(projectRoot: string): string | null {
526
535
  const ios = path.join(projectRoot, 'ios')
527
536
  if (!fs.existsSync(ios)) return null
@@ -531,8 +540,7 @@ export function installedXcodeWorkspace(projectRoot: string): string | null {
531
540
  )
532
541
  }
533
542
 
534
- /** the installed workspace for a compile step that cannot proceed from
535
- * podspecs alone, with the reason it is missing off a Mac. */
543
+ /** the installed workspace for a compile step that needs resolved pod targets. */
536
544
  export function requireInstalledXcodeWorkspace(
537
545
  projectRoot: string,
538
546
  needed: string,
@@ -540,7 +548,7 @@ export function requireInstalledXcodeWorkspace(
540
548
  const workspace = installedXcodeWorkspace(projectRoot)
541
549
  if (!workspace)
542
550
  throw new Error(
543
- `${needed} needs the installed CocoaPods workspace in ${path.join(projectRoot, 'ios')}, which only a Mac prepares or PEACH_PREPARED_NATIVE_WORKSPACES supplies`,
551
+ `${needed} needs an installed pod workspace in ${path.join(projectRoot, 'ios')}`,
544
552
  )
545
553
  return workspace
546
554
  }
@@ -1155,18 +1163,6 @@ function targetMembers(
1155
1163
  if (allOutputs.some((file) => file.endsWith('.swift') || file === infoPlistOutput))
1156
1164
  for (const file of inputFiles) if (fs.existsSync(file)) projectInputs.add(file)
1157
1165
  if (options.prepareGeneratedSources === true && allOutputs.some(isPreparedOutput)) {
1158
- const configuration = settings('CONFIGURATION')
1159
- if (
1160
- preparedXcodePhase(
1161
- project.projectFile,
1162
- targetId,
1163
- phaseId,
1164
- configuration,
1165
- allOutputs,
1166
- false,
1167
- )
1168
- )
1169
- continue
1170
1166
  const phaseDir = path.join(settings('TARGET_TEMP_DIR'), `Script-${phaseId}`)
1171
1167
  for (const lists of fileLists.values())
1172
1168
  for (const { file } of lists)
@@ -1212,18 +1208,26 @@ function targetMembers(
1212
1208
  if (
1213
1209
  preparedSourcePhases.get(key) === stamp &&
1214
1210
  allOutputs.every((file) => fs.existsSync(file))
1215
- ) {
1216
- preparedXcodePhase(
1217
- project.projectFile,
1218
- targetId,
1219
- phaseId,
1220
- configuration,
1221
- allOutputs,
1222
- true,
1223
- )
1211
+ )
1224
1212
  continue
1225
- }
1226
1213
  fs.mkdirSync(phaseDir, { recursive: true })
1214
+ if (process.platform === 'linux') {
1215
+ const bin = swiftToolchainBin(
1216
+ privateSwiftRelease() ?? swiftNativePin().distribution.release,
1217
+ )
1218
+ // Expo runs bash -l, whose login profile can replace the inherited PATH.
1219
+ const startup = path.join(phaseDir, 'peach-tools.sh')
1220
+ fs.writeFileSync(
1221
+ startup,
1222
+ 'if [[ -n "$PEACH_PHASE_BASH_ENV" ]]; then source "$PEACH_PHASE_BASH_ENV"; fi\nexport PATH="$PEACH_PHASE_TOOLCHAIN:$PATH"\n',
1223
+ )
1224
+ const { LD_LIBRARY_PATH } = swiftEnvironment(env)
1225
+ env.LD_LIBRARY_PATH = LD_LIBRARY_PATH
1226
+ env.PEACH_PHASE_TOOLCHAIN = bin
1227
+ env.PEACH_PHASE_BASH_ENV = env.BASH_ENV
1228
+ env.BASH_ENV = startup
1229
+ env.PATH = [bin, env.PATH].filter(Boolean).join(path.delimiter)
1230
+ }
1227
1231
  fs.mkdirSync(settings('BUILT_PRODUCTS_DIR'), { recursive: true })
1228
1232
  fs.mkdirSync(settings('DERIVED_FILE_DIR'), { recursive: true })
1229
1233
  // xcode creates declared output directories before executing the script.
@@ -1294,14 +1298,6 @@ function targetMembers(
1294
1298
  `${targetName}: Run Script "${script}" did not produce ${missing.join(', ')}`,
1295
1299
  )
1296
1300
  preparedSourcePhases.set(key, stamp)
1297
- preparedXcodePhase(
1298
- project.projectFile,
1299
- targetId,
1300
- phaseId,
1301
- configuration,
1302
- allOutputs,
1303
- true,
1304
- )
1305
1301
  }
1306
1302
  }
1307
1303
  project.visitMembers(
@@ -1548,17 +1544,33 @@ function installedPodsSandbox(pods: string): NonNullable<XcodeAppTarget['cocoapo
1548
1544
  specChecksums[entry[1]!] = entry[2]!
1549
1545
  }
1550
1546
  const specs = path.join(pods, 'Local Podspecs')
1547
+ const generated = path.join(pods, POD_GRAPH_SPECIFICATIONS)
1548
+ if (fs.existsSync(generated))
1549
+ return {
1550
+ podfileLock,
1551
+ manifestLock,
1552
+ specChecksums,
1553
+ localPodspecs: readPodGraphSpecifications(generated),
1554
+ specificationFiles: [generated],
1555
+ }
1556
+ const specificationFiles = isDirectory(specs)
1557
+ ? fs
1558
+ .readdirSync(specs)
1559
+ .filter((name) => name.endsWith('.podspec.json'))
1560
+ .sort()
1561
+ .map((name) => path.join(specs, name))
1562
+ : []
1551
1563
  return {
1552
1564
  podfileLock,
1553
1565
  manifestLock,
1554
1566
  specChecksums,
1555
- localPodspecs: isDirectory(specs)
1556
- ? fs
1557
- .readdirSync(specs)
1558
- .filter((name) => name.endsWith('.podspec.json'))
1559
- .sort()
1560
- .map((name) => path.join(specs, name))
1561
- : [],
1567
+ localPodspecs: new Map(
1568
+ specificationFiles.map((file) => [
1569
+ path.basename(file, '.podspec.json'),
1570
+ fs.readFileSync(file, 'utf8'),
1571
+ ]),
1572
+ ),
1573
+ specificationFiles,
1562
1574
  }
1563
1575
  }
1564
1576
 
@@ -2391,7 +2403,9 @@ export function readXcodeAppTarget(
2391
2403
  const { headers, allSources, ...members } = targetMembers(
2392
2404
  ref,
2393
2405
  settings,
2394
- options,
2406
+ ref === app && options.nativeModules
2407
+ ? { ...options, requireSources: false }
2408
+ : options,
2395
2409
  keys,
2396
2410
  xcconfigs,
2397
2411
  )
@@ -3453,7 +3467,11 @@ export function readXcodeAppTarget(
3453
3467
  ...xcconfigs,
3454
3468
  ...(entitlementsFile ? [entitlementsFile] : []),
3455
3469
  ...(cocoapods
3456
- ? [cocoapods.podfileLock, cocoapods.manifestLock, ...cocoapods.localPodspecs]
3470
+ ? [
3471
+ cocoapods.podfileLock,
3472
+ cocoapods.manifestLock,
3473
+ ...cocoapods.specificationFiles,
3474
+ ]
3457
3475
  : []),
3458
3476
  ]),
3459
3477
  ].sort(),
@@ -1,108 +0,0 @@
1
- import { createHash } from 'node:crypto'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
- import { z } from 'zod'
5
- import { isRecord } from './is-record'
6
- import { podspecReceiptSchema, type PodspecReceipt } from './podspec-sources'
7
- import type { PreparedSwiftPin, PreparedXcodePhase } from './prepared-xcode-phases'
8
-
9
- export interface PortableExpoWorkspaceManifest {
10
- format: 'peach-expo-workspace-v1'
11
- sourceHash: string
12
- configHash: string
13
- archiveHash: string
14
- checkoutsArchiveHash: string
15
- interfacesArchiveHash: string
16
- interfacesHash: string
17
- producerRoot: string
18
- swiftDistribution: string
19
- selected: string[]
20
- inventory: { name: string; sha256: string }[]
21
- app: string
22
- workspace: string
23
- interfaces: string
24
- checkouts: string
25
- pins: PreparedSwiftPin[]
26
- phases: PreparedXcodePhase[]
27
- podspecs: PodspecReceipt[]
28
- }
29
-
30
- const digest = (value: unknown): value is string =>
31
- typeof value === 'string' && /^[a-f0-9]{64}$/.test(value)
32
-
33
- function isManifest(
34
- value: unknown,
35
- ): value is Omit<PortableExpoWorkspaceManifest, 'podspecs'> & { podspecs: unknown } {
36
- return (
37
- isRecord(value) &&
38
- value.format === 'peach-expo-workspace-v1' &&
39
- digest(value.sourceHash) &&
40
- digest(value.configHash) &&
41
- digest(value.archiveHash) &&
42
- digest(value.checkoutsArchiveHash) &&
43
- digest(value.interfacesArchiveHash) &&
44
- digest(value.interfacesHash) &&
45
- typeof value.producerRoot === 'string' &&
46
- path.isAbsolute(value.producerRoot) &&
47
- typeof value.swiftDistribution === 'string' &&
48
- typeof value.app === 'string' &&
49
- typeof value.workspace === 'string' &&
50
- typeof value.interfaces === 'string' &&
51
- typeof value.checkouts === 'string' &&
52
- Array.isArray(value.pins) &&
53
- value.pins.every(
54
- (pin) =>
55
- isRecord(pin) &&
56
- typeof pin.identity === 'string' &&
57
- /^[a-z0-9][a-z0-9._-]*$/.test(pin.identity) &&
58
- !pin.identity.includes('..') &&
59
- typeof pin.location === 'string' &&
60
- typeof pin.revision === 'string' &&
61
- /^[a-f0-9]{40,64}$/.test(pin.revision),
62
- ) &&
63
- Array.isArray(value.selected) &&
64
- value.selected.every((item) => typeof item === 'string') &&
65
- Array.isArray(value.inventory) &&
66
- value.inventory.every(
67
- (item) => isRecord(item) && typeof item.name === 'string' && digest(item.sha256),
68
- ) &&
69
- Array.isArray(value.phases) &&
70
- value.phases.every(
71
- (phase) =>
72
- isRecord(phase) &&
73
- typeof phase.project === 'string' &&
74
- typeof phase.target === 'string' &&
75
- typeof phase.phase === 'string' &&
76
- typeof phase.configuration === 'string' &&
77
- Array.isArray(phase.outputs) &&
78
- phase.outputs.every(
79
- (item) =>
80
- isRecord(item) &&
81
- typeof item.path === 'string' &&
82
- (item.sha256 === null || digest(item.sha256)),
83
- ),
84
- )
85
- )
86
- }
87
-
88
- export function readPortableExpoManifest(file: string): PortableExpoWorkspaceManifest {
89
- const value: unknown = JSON.parse(fs.readFileSync(file, 'utf8'))
90
- if (!isManifest(value))
91
- throw new Error(`invalid prepared Expo workspace manifest: ${file}`)
92
- return { ...value, podspecs: z.array(podspecReceiptSchema).parse(value.podspecs) }
93
- }
94
-
95
- export function portableInterfaceHash(directory: string): string {
96
- const hash = createHash('sha256')
97
- for (const entry of fs
98
- .readdirSync(directory, { withFileTypes: true })
99
- .sort((a, b) => a.name.localeCompare(b.name))) {
100
- if (!entry.isFile())
101
- throw new Error(`invalid prepared Swift interface: ${entry.name}`)
102
- const bytes = fs.readFileSync(path.join(directory, entry.name))
103
- hash
104
- .update(`${Buffer.byteLength(entry.name)}:${entry.name}:${bytes.length}:`)
105
- .update(bytes)
106
- }
107
- return hash.digest('hex')
108
- }
@@ -1,100 +0,0 @@
1
- import { createHash } from 'node:crypto'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
- import { isRecord } from './is-record'
5
- import { readExpoConfigAsync } from './native-firebase-config'
6
- import { restoreEvaluatedPodspecs } from './podspec-sources'
7
- import { portableInterfaceHash, readPortableExpoManifest } from './portable-expo-contract'
8
- import { preparedNativeInventory } from './prepared-native-inventory'
9
- import { registerPreparedXcodePhases } from './prepared-xcode-phases'
10
- import { swiftDistributionAt } from './swift-compile'
11
- import { swiftDistributionRoot } from './swift-distribution'
12
-
13
- function stable(value: unknown, app: string): string {
14
- if (typeof value === 'string') return JSON.stringify(value.split(app).join('$APP'))
15
- if (Array.isArray(value)) return `[${value.map((item) => stable(item, app)).join(',')}]`
16
- if (isRecord(value))
17
- return `{${Object.keys(value)
18
- .sort()
19
- .map((key) => `${JSON.stringify(key)}:${stable(value[key], app)}`)
20
- .join(',')}}`
21
- return JSON.stringify(value) ?? 'null'
22
- }
23
-
24
- export async function portableExpoConfigHash(app: string): Promise<string> {
25
- const config = await readExpoConfigAsync(app)
26
- return createHash('sha256')
27
- .update(stable(config, fs.realpathSync(app)))
28
- .digest('hex')
29
- }
30
-
31
- function contained(root: string, relative: string): string {
32
- if (path.isAbsolute(relative))
33
- throw new Error(`absolute prepared workspace path: ${relative}`)
34
- const file = fs.realpathSync(path.resolve(root, relative))
35
- const within = path.relative(root, file)
36
- if (within === '..' || within.startsWith(`..${path.sep}`) || path.isAbsolute(within))
37
- throw new Error(`prepared workspace path escapes its archive: ${relative}`)
38
- return file
39
- }
40
-
41
- // the directory is supplied by the private producer's verified archive handoff.
42
- // a miss is an error: using a different app or silently preparing locally
43
- // would change the selected source graph.
44
- export async function portableExpoWorkspace(
45
- app: string,
46
- sourceHash: string,
47
- signal?: AbortSignal,
48
- ): Promise<{ app: string; workspace: string; work: string; identity: string }> {
49
- const directory = process.env.PEACH_PREPARED_NATIVE_WORKSPACES
50
- if (!directory) throw new Error(`missing prepared Expo workspace for ${sourceHash}`)
51
- const configHash = await portableExpoConfigHash(app)
52
- const mismatches: string[] = []
53
- for (const name of fs.readdirSync(directory).sort()) {
54
- signal?.throwIfAborted()
55
- const root = fs.realpathSync(path.join(directory, name))
56
- const file = path.join(root, 'manifest.json')
57
- if (!fs.existsSync(file)) continue
58
- const value = readPortableExpoManifest(file)
59
- if (value.sourceHash !== sourceHash) continue
60
- if (value.configHash !== configHash) {
61
- mismatches.push(
62
- `${name}: Expo config ${configHash} differs from ${value.configHash}`,
63
- )
64
- continue
65
- }
66
- const distribution = swiftDistributionAt(await swiftDistributionRoot(signal))
67
- if (!distribution) throw new Error('missing prepared Swift distribution')
68
- const { id } = distribution
69
- if (value.swiftDistribution !== id) {
70
- mismatches.push(
71
- `${name}: Swift distribution ${id} differs from ${value.swiftDistribution}`,
72
- )
73
- continue
74
- }
75
- const actual = await preparedNativeInventory(app, value.selected, signal)
76
- if (JSON.stringify(actual) !== JSON.stringify(value.inventory)) {
77
- const expected = new Map(value.inventory.map(({ name, sha256 }) => [name, sha256]))
78
- const found = new Map(actual.map(({ name, sha256 }) => [name, sha256]))
79
- const changed = [...new Set([...expected.keys(), ...found.keys()])].filter(
80
- (packageName) => expected.get(packageName) !== found.get(packageName),
81
- )
82
- mismatches.push(`${name}: native packages differ: ${changed.join(', ')}`)
83
- continue
84
- }
85
- const work = contained(root, 'work')
86
- const preparedApp = contained(work, value.app)
87
- const workspace = contained(work, value.workspace)
88
- const interfaces = contained(root, value.interfaces)
89
- const checkouts = contained(root, value.checkouts)
90
- if (portableInterfaceHash(interfaces) !== value.interfacesHash)
91
- throw new Error(`prepared Swift interface digest mismatch: ${interfaces}`)
92
- registerPreparedXcodePhases(work, value.phases, interfaces, checkouts, value.pins)
93
- for (const root of [app, preparedApp]) restoreEvaluatedPodspecs(root, value.podspecs)
94
- const identity = createHash('sha256').update(JSON.stringify(value)).digest('hex')
95
- return { app: preparedApp, workspace, work, identity }
96
- }
97
- throw new Error(
98
- `missing matching prepared Expo workspace for ${sourceHash}${mismatches.length ? ` (${mismatches.join('; ')})` : ''}`,
99
- )
100
- }
@@ -1,194 +0,0 @@
1
- import { createHash } from 'node:crypto'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
-
5
- export interface PreparedXcodePhase {
6
- project: string
7
- target: string
8
- phase: string
9
- configuration: string
10
- outputs: { path: string; sha256: string | null }[]
11
- }
12
-
13
- export interface PreparedSwiftPin {
14
- identity: string
15
- location: string
16
- revision: string
17
- }
18
-
19
- const workspaces = new Map<
20
- string,
21
- {
22
- phases: PreparedXcodePhase[]
23
- interfaces: string
24
- checkouts: string
25
- pins: PreparedSwiftPin[]
26
- }
27
- >()
28
- let recording: { root: string; phases: PreparedXcodePhase[] } | undefined
29
-
30
- function relativeFile(root: string, file: string): string {
31
- const relative = path.relative(root, file)
32
- if (
33
- !relative ||
34
- relative === '..' ||
35
- relative.startsWith(`..${path.sep}`) ||
36
- path.isAbsolute(relative)
37
- )
38
- throw new Error(`prepared Xcode output is outside its workspace: ${file}`)
39
- return relative.split(path.sep).join('/')
40
- }
41
-
42
- function output(root: string, file: string) {
43
- const relative = relativeFile(root, file)
44
- const stat = fs.statSync(file, { throwIfNoEntry: false })
45
- if (!stat) return { path: relative, sha256: null }
46
- if (!stat.isFile()) throw new Error(`prepared Xcode output is not a file: ${file}`)
47
- relativeFile(root, fs.realpathSync(file))
48
- const bytes = fs.readFileSync(file)
49
- const prefix = Buffer.from(root)
50
- const hash = createHash('sha256')
51
- let offset = 0
52
- for (
53
- let index = bytes.indexOf(prefix);
54
- index !== -1;
55
- index = bytes.indexOf(prefix, offset)
56
- ) {
57
- hash.update(bytes.subarray(offset, index)).update('\0workspace\0')
58
- offset = index + prefix.length
59
- }
60
- hash.update(bytes.subarray(offset))
61
- return {
62
- path: relative,
63
- sha256: hash.digest('hex'),
64
- }
65
- }
66
-
67
- export async function recordPreparedXcodePhases<T>(root: string, run: () => T) {
68
- if (recording) throw new Error('already recording prepared Xcode phases')
69
- const current: { root: string; phases: PreparedXcodePhase[] } = {
70
- root: fs.realpathSync(root),
71
- phases: [],
72
- }
73
- recording = current
74
- try {
75
- const result = await run()
76
- return { result, phases: current.phases }
77
- } finally {
78
- recording = undefined
79
- }
80
- }
81
-
82
- export function registerPreparedXcodePhases(
83
- root: string,
84
- phases: PreparedXcodePhase[],
85
- interfaces: string,
86
- checkouts: string,
87
- pins: PreparedSwiftPin[],
88
- ) {
89
- workspaces.set(fs.realpathSync(root), { phases, interfaces, checkouts, pins })
90
- }
91
-
92
- export function preparedXcodeInterfaces(project: string): string | undefined {
93
- for (const [root, workspace] of workspaces) {
94
- const relative = path.relative(root, project)
95
- if (
96
- relative !== '..' &&
97
- !relative.startsWith(`..${path.sep}`) &&
98
- !path.isAbsolute(relative)
99
- )
100
- return workspace.interfaces
101
- }
102
- return undefined
103
- }
104
-
105
- export function preparedSwiftCheckouts(project: string): string | undefined {
106
- for (const [root, workspace] of workspaces) {
107
- const relative = path.relative(root, project)
108
- if (
109
- relative !== '..' &&
110
- !relative.startsWith(`..${path.sep}`) &&
111
- !path.isAbsolute(relative)
112
- )
113
- return workspace.checkouts
114
- }
115
- return undefined
116
- }
117
-
118
- export function preparedSwiftPin(
119
- checkouts: string,
120
- identity: string,
121
- location: string,
122
- revision: string,
123
- ): boolean {
124
- for (const workspace of workspaces.values()) {
125
- if (workspace.checkouts !== checkouts) continue
126
- const pin = workspace.pins.find((item) => item.identity === identity)
127
- if (!pin || pin.location !== location || pin.revision !== revision)
128
- throw new Error(`prepared Swift package pin mismatch: ${identity}`)
129
- if (!fs.existsSync(path.join(checkouts, identity, 'Package.swift')))
130
- throw new Error(`prepared Swift package is missing: ${identity}`)
131
- return true
132
- }
133
- return false
134
- }
135
-
136
- export function preparedXcodePhase(
137
- project: string,
138
- target: string,
139
- phase: string,
140
- configuration: string,
141
- outputs: string[],
142
- recorded: boolean,
143
- ): boolean {
144
- const root =
145
- recording?.root ??
146
- [...workspaces.keys()].find((root) => {
147
- const relative = path.relative(root, project)
148
- return (
149
- relative !== '..' &&
150
- !relative.startsWith(`..${path.sep}`) &&
151
- !path.isAbsolute(relative)
152
- )
153
- })
154
- if (!root) return false
155
- const entry = {
156
- project: relativeFile(root, project),
157
- target,
158
- phase,
159
- configuration,
160
- outputs: outputs.map((file) => output(root, file)),
161
- }
162
- if (recorded) {
163
- if (recording) {
164
- const previous = recording.phases.find(
165
- (item) =>
166
- item.project === entry.project &&
167
- item.target === target &&
168
- item.phase === phase &&
169
- item.configuration === configuration,
170
- )
171
- if (previous && JSON.stringify(previous.outputs) !== JSON.stringify(entry.outputs))
172
- throw new Error(
173
- `Xcode phase produced inconsistent outputs: ${project} ${target} ${phase}`,
174
- )
175
- if (!previous) recording.phases.push(entry)
176
- }
177
- return false
178
- }
179
- if (recording) return false
180
- const expected = workspaces
181
- .get(root)
182
- ?.phases.find(
183
- (item) =>
184
- item.project === entry.project &&
185
- item.target === target &&
186
- item.phase === phase &&
187
- item.configuration === configuration,
188
- )
189
- if (!expected || JSON.stringify(expected.outputs) !== JSON.stringify(entry.outputs))
190
- throw new Error(
191
- `prepared Xcode phase does not match its attested outputs: ${project} ${target} ${phase}`,
192
- )
193
- return true
194
- }