peachsim 0.1.1978 → 0.1.1980

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 (85) hide show
  1. package/cli/commands/inspect.ts +6 -2
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/attached-projects.cjs +1 -1
  5. package/dist-lib/auth/shared-session.cjs +1 -1
  6. package/dist-lib/backend-origin.cjs +1 -1
  7. package/dist-lib/beta.cjs +1 -1
  8. package/dist-lib/beta.mjs +1 -1
  9. package/dist-lib/bridge-constants.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.mjs +1 -1
  12. package/dist-lib/bridge-contract.cjs +1 -1
  13. package/dist-lib/bridge-contract.mjs +1 -1
  14. package/dist-lib/bundle-channel.cjs +134 -35
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cloud-contract.cjs +1 -1
  18. package/dist-lib/cloud-contract.mjs +1 -1
  19. package/dist-lib/cloud-test-args.cjs +1 -1
  20. package/dist-lib/cloud-test-args.mjs +1 -1
  21. package/dist-lib/cloud.cjs +1 -1
  22. package/dist-lib/cloud.mjs +1 -1
  23. package/dist-lib/config.cjs +1 -1
  24. package/dist-lib/config.mjs +1 -1
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/expo-swift-bundle.cjs +133 -34
  28. package/dist-lib/expo-swift-metadata.cjs +1 -1
  29. package/dist-lib/expo-swift-metadata.mjs +1 -1
  30. package/dist-lib/home-paths.cjs +1 -1
  31. package/dist-lib/host/bridge-host.cjs +134 -35
  32. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  33. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  34. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  35. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  36. package/dist-lib/host/websocket-proxy.cjs +1 -1
  37. package/dist-lib/index.cjs +1 -1
  38. package/dist-lib/jump-to-source-babel.cjs +1 -1
  39. package/dist-lib/jump-to-source-native.cjs +1 -1
  40. package/dist-lib/kotlin-host.cjs +1 -1
  41. package/dist-lib/menu.cjs +1 -1
  42. package/dist-lib/menu.mjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  45. package/dist-lib/metro-production-bundle.cjs +1 -1
  46. package/dist-lib/metro-production-bundle.mjs +1 -1
  47. package/dist-lib/metro.cjs +1 -1
  48. package/dist-lib/native-app-identity-project.cjs +1 -1
  49. package/dist-lib/native-app-identity-project.mjs +1 -1
  50. package/dist-lib/native-app-identity.cjs +1 -1
  51. package/dist-lib/native-app-identity.mjs +1 -1
  52. package/dist-lib/native-firebase-metadata.cjs +1 -1
  53. package/dist-lib/native-firebase-metadata.mjs +1 -1
  54. package/dist-lib/pdfium-raster.cjs +1 -1
  55. package/dist-lib/pdfium-raster.mjs +1 -1
  56. package/dist-lib/plist.cjs +1 -1
  57. package/dist-lib/plist.mjs +1 -1
  58. package/dist-lib/profiles.cjs +1 -1
  59. package/dist-lib/public-brand.cjs +1 -1
  60. package/dist-lib/public-origins-lib-esm.json +24 -24
  61. package/dist-lib/public-origins-lib.json +53 -53
  62. package/dist-lib/react-native-host-modules.cjs +1 -1
  63. package/dist-lib/react-native-host-modules.mjs +1 -1
  64. package/dist-lib/reap-browser.cjs +1 -1
  65. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  66. package/dist-lib/sdk.cjs +1 -1
  67. package/dist-lib/sdk.mjs +1 -1
  68. package/dist-lib/skills.cjs +134 -35
  69. package/dist-lib/swift-compile.cjs +1 -1
  70. package/dist-lib/swift-compile.mjs +1 -1
  71. package/dist-lib/swift-package.cjs +1 -1
  72. package/dist-lib/swift-package.mjs +1 -1
  73. package/dist-lib/swift-submit.cjs +1 -1
  74. package/dist-lib/swift-submit.mjs +1 -1
  75. package/dist-lib/swift-toolchain.cjs +1 -1
  76. package/dist-lib/swift.cjs +1 -1
  77. package/dist-lib/vite-swift.cjs +1 -1
  78. package/dist-lib/vite.cjs +1 -1
  79. package/dist-lib/worklet-executable.cjs +1 -1
  80. package/dist-lib/worklet-executable.mjs +1 -1
  81. package/package.json +1 -1
  82. package/src/expo-discovery-cache.ts +2 -0
  83. package/src/expo-native-workspace.ts +4 -1
  84. package/src/expo-swift-host.ts +144 -31
  85. package/src/expoSwiftContract.ts +1 -0
@@ -577,12 +577,17 @@ function cloneUnits(units: ExpoSwiftSourceUnit[] | null): ExpoSwiftSourceUnit[]
577
577
  appDelegateSubscribers: unit.appDelegateSubscribers.slice(),
578
578
  reactDelegateHandlers: unit.reactDelegateHandlers.slice(),
579
579
  frameworks: unit.frameworks.slice(),
580
+ ...(unit.workspaceSources ? { workspaceSources: unit.workspaceSources.slice() } : {}),
580
581
  files: { ...unit.files },
581
582
  ...(unit.nativeFiles ? { nativeFiles: { ...unit.nativeFiles } } : {}),
582
583
  ...(unit.headerAliases ? { headerAliases: { ...unit.headerAliases } } : {}),
583
584
  ...(unit.resources ? { resources: { ...unit.resources } } : {}),
584
585
  ...(unit.resourceBundles
585
- ? { resourceBundles: unit.resourceBundles.map((bundle) => ({ ...bundle })) }
586
+ ? {
587
+ resourceBundles: unit.resourceBundles.map((bundle) => ({
588
+ ...bundle,
589
+ })),
590
+ }
586
591
  : {}),
587
592
  ...(unit.nativeTargets
588
593
  ? { nativeTargets: unit.nativeTargets.map(cloneNativeTarget) }
@@ -1152,6 +1157,8 @@ async function collectExpoSwiftSourcesUncached(
1152
1157
  installed?.input.files['Package.swift'] ?? '',
1153
1158
  )
1154
1159
  const units: ExpoSwiftSourceUnit[] = []
1160
+ const dependencyUnits: ExpoSwiftSourceUnit[] = []
1161
+ const processed = new Set<string>()
1155
1162
  const namespacesSeen = new Set<string>()
1156
1163
  const namespaceGroups = new Map<string, string[]>()
1157
1164
  let answeredInstalled = false
@@ -1160,9 +1167,19 @@ async function collectExpoSwiftSourcesUncached(
1160
1167
  let fileCount = 0
1161
1168
  // native Expo resolves packages by name before generating its Apple provider.
1162
1169
  // the search result is keyed by that name; older autolinkers add no name field.
1163
- for (const [packageName, entry] of Object.entries(search).sort(([a], [b]) =>
1164
- a.localeCompare(b),
1165
- )) {
1170
+ const entries = Object.entries(search).sort(([a], [b]) => a.localeCompare(b))
1171
+ const queue = entries.slice()
1172
+ const queued = new Set(entries.map(([name]) => name))
1173
+ const reconsider = () => {
1174
+ for (const entry of entries)
1175
+ if (!processed.has(entry[0]) && !queued.has(entry[0])) {
1176
+ queue.push(entry)
1177
+ queued.add(entry[0])
1178
+ }
1179
+ }
1180
+ for (const [packageName, entry] of queue) {
1181
+ queued.delete(packageName)
1182
+ if (processed.has(packageName)) continue
1166
1183
  if (!entry || typeof entry !== 'object')
1167
1184
  throw new Error('invalid Expo autolinking entry')
1168
1185
  const sourceRoot = Reflect.get(entry, 'path')
@@ -1171,12 +1188,15 @@ async function collectExpoSwiftSourcesUncached(
1171
1188
  const canonical = fs.realpathSync(sourceRoot)
1172
1189
  // an installed package with a native seam keeps it; one without compiles
1173
1190
  // through the same autolinker-selected route as app-local modules.
1174
- if (
1191
+ const answered =
1175
1192
  canonical.split(path.sep).includes('node_modules') &&
1176
1193
  peachAnsweredNativePackages().has(packageName)
1177
- ) {
1194
+ if (answered) {
1178
1195
  answeredInstalled = true
1179
- continue
1196
+ if (installed || prepareNative) {
1197
+ processed.add(packageName)
1198
+ continue
1199
+ }
1180
1200
  }
1181
1201
  // the autolinker read these in a child, so the parent can only stamp them
1182
1202
  // afterwards. one modified since the child started may be newer than what
@@ -1223,12 +1243,25 @@ async function collectExpoSwiftSourcesUncached(
1223
1243
  // a package with pods is rediscovered in the prepared workspace, which has no caps.
1224
1244
  const deferredToWorkspace =
1225
1245
  prepareNative && !installedWorkspace && Array.isArray(pods) && pods.length > 0
1226
- if (
1227
- (!Array.isArray(modules) || modules.length === 0) &&
1228
- subscriberNames.length === 0 &&
1229
- handlerNames.length === 0
1230
- )
1231
- continue
1246
+ const dependencyOnly =
1247
+ answered ||
1248
+ ((!Array.isArray(modules) || modules.length === 0) &&
1249
+ subscriberNames.length === 0 &&
1250
+ handlerNames.length === 0)
1251
+ if (dependencyOnly) {
1252
+ if (installed || prepareNative || !Array.isArray(namespaces)) {
1253
+ processed.add(packageName)
1254
+ continue
1255
+ }
1256
+ const imports = new Set(
1257
+ [...units, ...dependencyUnits].flatMap((unit) =>
1258
+ Object.values(unit.files).flatMap((source) => swiftImportNames(source)),
1259
+ ),
1260
+ )
1261
+ if (!namespaces.some((name) => typeof name === 'string' && imports.has(name)))
1262
+ continue
1263
+ }
1264
+ processed.add(packageName)
1232
1265
  if (
1233
1266
  !Array.isArray(namespaces) ||
1234
1267
  namespaces.length === 0 ||
@@ -1252,9 +1285,10 @@ async function collectExpoSwiftSourcesUncached(
1252
1285
  // without that membership the package's natives cannot be split, so it
1253
1286
  // stays unbuilt and the app reports it like any module Peach lacks.
1254
1287
  if (!nativeWorkspaceAvailable()) {
1255
- report(
1256
- `${packageName}: ${namespaces.join(', ')} need CocoaPods target membership, which only a Mac prepares; not compiled`,
1257
- )
1288
+ if (!answered)
1289
+ report(
1290
+ `${packageName}: ${namespaces.join(', ')} need CocoaPods target membership, which only a Mac prepares; not compiled`,
1291
+ )
1258
1292
  continue
1259
1293
  }
1260
1294
  const prepared = await prepareExpoNativeWorkspace(appRoot, signal, iosTarget)
@@ -1382,8 +1416,16 @@ async function collectExpoSwiftSourcesUncached(
1382
1416
  walk(file, binary || framework)
1383
1417
  continue
1384
1418
  }
1385
- if (!binary && target.isFile() && /\.(?:mm?|c|cc|cpp)$/.test(child.name))
1386
- nativeSources.add(path.relative(ios, file))
1419
+ if (!binary && target.isFile() && /\.(?:mm?|c|cc|cpp)$/.test(child.name)) {
1420
+ const source = linked ?? resolveSource(file)
1421
+ if (
1422
+ fs.statSync(source).size > 4096 ||
1423
+ !/^(?:\s|\/\/[^\n]*|\/\*[\s\S]*?\*\/)*$/.test(
1424
+ fs.readFileSync(source, 'utf8'),
1425
+ )
1426
+ )
1427
+ nativeSources.add(path.relative(ios, file))
1428
+ }
1387
1429
  if (!target.isFile() || !child.name.endsWith('.swift')) continue
1388
1430
  const source = linked ?? resolveSource(file)
1389
1431
  if (sources.has(source)) continue
@@ -1493,6 +1535,26 @@ async function collectExpoSwiftSourcesUncached(
1493
1535
  fs.readFileSync(path.join(ios, podspec), 'utf8'),
1494
1536
  )?.[1]
1495
1537
  : undefined
1538
+ if (dependencyOnly && Object.keys(files).length > 0) {
1539
+ dependencyUnits.push({
1540
+ namespace,
1541
+ moduleId: namespace,
1542
+ classes: [],
1543
+ bridgeModules: [],
1544
+ appDelegateSubscribers: [],
1545
+ reactDelegateHandlers: [],
1546
+ files,
1547
+ frameworks: [...frameworks],
1548
+ ...(nativeSources.size ? { workspaceSources: [namespace] } : {}),
1549
+ ...(podspecFloor
1550
+ ? {
1551
+ nativeTargets: [synthesizedNativeTarget(namespace, podspecFloor)],
1552
+ }
1553
+ : {}),
1554
+ })
1555
+ reconsider()
1556
+ }
1557
+ if (dependencyOnly) continue
1496
1558
  for (const declaration of declarations) {
1497
1559
  const className = declaration.reference
1498
1560
  const owner = className.split('.')[0]!
@@ -1536,11 +1598,14 @@ async function collectExpoSwiftSourcesUncached(
1536
1598
  frameworks: [...frameworks],
1537
1599
  ...(absentFrameworks.length > 0 ? { absentFrameworks } : {}),
1538
1600
  ...(podspecFloor
1539
- ? { nativeTargets: [synthesizedNativeTarget(namespace, podspecFloor)] }
1601
+ ? {
1602
+ nativeTargets: [synthesizedNativeTarget(namespace, podspecFloor)],
1603
+ }
1540
1604
  : {}),
1541
1605
  }
1542
1606
  unit.files[EXPO_SWIFT_ENTRY] = expoEntry([unit])
1543
1607
  units.push(unit)
1608
+ reconsider()
1544
1609
  }
1545
1610
  }
1546
1611
  if (namespaces.length > 1) {
@@ -1675,23 +1740,29 @@ async function collectExpoSwiftSourcesUncached(
1675
1740
  )
1676
1741
  const allFiles: Record<string, string> = Object.assign(
1677
1742
  {},
1678
- ...units.map((unit) => unit.files),
1743
+ ...[...units, ...dependencyUnits].map((unit) => unit.files),
1679
1744
  )
1680
- const targets = [...new Set(units.map((unit) => unit.namespace))].map((namespace) => ({
1745
+ const targets = [
1746
+ ...new Set([...units, ...dependencyUnits].map((unit) => unit.namespace)),
1747
+ ].map((namespace) => ({
1681
1748
  name: namespace,
1682
1749
  path: `Sources/${namespace}`,
1683
1750
  }))
1684
1751
  const dependencies = swiftTargetDependencies(allFiles, targets)
1685
1752
  const byNamespace = new Map<string, ExpoSwiftSourceUnit[]>()
1686
- for (const unit of units) {
1753
+ for (const unit of [...units, ...dependencyUnits]) {
1687
1754
  const entries = byNamespace.get(unit.namespace) ?? []
1688
1755
  entries.push(unit)
1689
1756
  byNamespace.set(unit.namespace, entries)
1690
1757
  }
1691
1758
  for (const unit of units) {
1692
1759
  const included = new Set([unit.namespace])
1760
+ const ownDependencies =
1761
+ swiftTargetDependencies(unit.files, targets).get(unit.namespace) ?? []
1693
1762
  const visit = (namespace: string) => {
1694
- for (const dependency of dependencies.get(namespace) ?? []) {
1763
+ for (const dependency of namespace === unit.namespace
1764
+ ? ownDependencies
1765
+ : (dependencies.get(namespace) ?? [])) {
1695
1766
  if (!byNamespace.has(dependency) || included.has(dependency)) continue
1696
1767
  included.add(dependency)
1697
1768
  visit(dependency)
@@ -1708,6 +1779,12 @@ async function collectExpoSwiftSourcesUncached(
1708
1779
  ...dependency.flatMap((item) => item.frameworks),
1709
1780
  ]),
1710
1781
  ]
1782
+ unit.workspaceSources = [
1783
+ ...new Set([
1784
+ ...(unit.workspaceSources ?? []),
1785
+ ...dependency.flatMap((item) => item.workspaceSources ?? []),
1786
+ ]),
1787
+ ]
1711
1788
  unit.nativeTargets = [
1712
1789
  ...new Map(
1713
1790
  [
@@ -1730,11 +1807,24 @@ async function collectExpoSwiftSourcesUncached(
1730
1807
  if (name.startsWith(`Sources/${namespace}/`)) unit.files[name] = source
1731
1808
  }
1732
1809
  }
1733
- unit.files['Package.swift'] = expoManifest(
1734
- unit.files,
1735
- '',
1736
- targetSettings([...included].flatMap((namespace) => byNamespace.get(namespace)!)),
1810
+ const settings = targetSettings(
1811
+ [...included].flatMap((namespace) => byNamespace.get(namespace)!),
1737
1812
  )
1813
+ if (!installed)
1814
+ for (const namespace of included)
1815
+ settings.set(namespace, {
1816
+ languageMode: 5,
1817
+ mainActorIsolation: false,
1818
+ resources: false,
1819
+ ...settings.get(namespace),
1820
+ dependencies: (namespace === unit.namespace
1821
+ ? ownDependencies
1822
+ : (dependencies.get(namespace) ?? [])
1823
+ )
1824
+ .filter((name) => included.has(name))
1825
+ .map((name) => ({ kind: 'target', name })),
1826
+ })
1827
+ unit.files['Package.swift'] = expoManifest(unit.files, '', settings)
1738
1828
  }
1739
1829
  if (nativeAppIdentity)
1740
1830
  for (const unit of units) unit.nativeAppIdentity = nativeAppIdentity
@@ -1790,8 +1880,21 @@ function targetSettings(units: ExpoSwiftSourceUnit[]) {
1790
1880
  Partial<Pick<SwiftPackageTarget, 'resources'>>
1791
1881
  >()
1792
1882
  for (const unit of units) {
1793
- for (const target of swiftManifestTargets(unit.files['Package.swift'] ?? ''))
1794
- settings.set(target.name, target)
1883
+ for (const target of swiftManifestTargets(unit.files['Package.swift'] ?? '')) {
1884
+ const previous = settings.get(target.name)
1885
+ const dependencies = [
1886
+ ...(previous?.dependencies ?? []),
1887
+ ...(target.dependencies ?? []),
1888
+ ]
1889
+ settings.set(target.name, {
1890
+ ...target,
1891
+ dependencies: [
1892
+ ...new Map(
1893
+ dependencies.map((dependency) => [JSON.stringify(dependency), dependency]),
1894
+ ).values(),
1895
+ ],
1896
+ })
1897
+ }
1795
1898
  if (unit.swiftLanguageMode !== undefined)
1796
1899
  settings.set(unit.namespace, {
1797
1900
  ...settings.get(unit.namespace),
@@ -2248,7 +2351,11 @@ async function compileExpoSwiftModulesTraced(
2248
2351
  projectFor(packagePath).headerAliases = unit.headerAliases
2249
2352
  projectFor(packagePath).resourceBundles = unit.resourceBundles
2250
2353
  projectFor(packagePath).bundleFiles = unit.resources
2251
- ? { files: unit.resources, bundles: unit.resourceBundles ?? [], watched: [] }
2354
+ ? {
2355
+ files: unit.resources,
2356
+ bundles: unit.resourceBundles ?? [],
2357
+ watched: [],
2358
+ }
2252
2359
  : undefined
2253
2360
  const stamp = sourceContentStamp(packagePath, module.root)
2254
2361
  const failed = readFailedCompilation(packagePath)
@@ -2451,8 +2558,14 @@ async function compileExpoSwiftModulesTraced(
2451
2558
  linked.push(unit)
2452
2559
  } catch (error) {
2453
2560
  signal.throwIfAborted()
2561
+ const message = error instanceof Error ? error.message : String(error)
2562
+ const missingImports = [...message.matchAll(/^ (\S+)/gm)].map(
2563
+ (match) => match[1],
2564
+ )
2454
2565
  const diagnostic = [
2455
- error instanceof Error ? error.message : String(error),
2566
+ error instanceof SwiftMissingModulesError && unit.workspaceSources?.length
2567
+ ? `${unit.workspaceSources.map((name) => `${name} needs a Mac-prepared workspace`).join('; ')}; unresolved imports: ${missingImports.join(', ')}`
2568
+ : message,
2456
2569
  ...(gaps.get(unit) ?? []),
2457
2570
  ].join('\n')
2458
2571
  // a unit from the installed workspace carries no app source
@@ -27,6 +27,7 @@ export interface ExpoSwiftSourceUnit {
27
27
  reactDelegateHandlers: string[]
28
28
  files: Record<string, string>
29
29
  frameworks: string[]
30
+ workspaceSources?: string[]
30
31
  // vendored_frameworks the module's podspec declares that are not on disk
31
32
  absentFrameworks?: string[]
32
33
  nativeTargets?: SwiftNativeTarget[]