peachsim 0.1.1813 → 0.1.1814

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 (121) hide show
  1. package/README.md +2 -1
  2. package/cli/cloud-client.ts +5 -4
  3. package/cli/cloud-session.ts +14 -1
  4. package/cli/commands/compat.ts +12 -2
  5. package/cli/commands/control.ts +5 -0
  6. package/cli/commands/flow.ts +10 -5
  7. package/cli/commands/inspect/env.ts +3 -2
  8. package/cli/commands/inspect/wait-selector.ts +30 -9
  9. package/dist-lib/agent-daemon-client.cjs +1 -1
  10. package/dist-lib/agent-events.cjs +1 -1
  11. package/dist-lib/attached-projects.cjs +1 -1
  12. package/dist-lib/auth/shared-session.cjs +1 -1
  13. package/dist-lib/backend-origin.cjs +1 -1
  14. package/dist-lib/beta.cjs +1 -1
  15. package/dist-lib/beta.mjs +1 -1
  16. package/dist-lib/bridge-constants.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.mjs +1 -1
  19. package/dist-lib/bridge-contract.cjs +1 -1
  20. package/dist-lib/bridge-contract.mjs +1 -1
  21. package/dist-lib/bundle-channel.cjs +584 -449
  22. package/dist-lib/capture-contract.cjs +1 -1
  23. package/dist-lib/capture-contract.mjs +1 -1
  24. package/dist-lib/cloud-contract.cjs +1 -1
  25. package/dist-lib/cloud-contract.mjs +1 -1
  26. package/dist-lib/cloud-test-args.cjs +1 -1
  27. package/dist-lib/cloud-test-args.mjs +1 -1
  28. package/dist-lib/cloud.cjs +1 -1
  29. package/dist-lib/cloud.mjs +1 -1
  30. package/dist-lib/config.cjs +1 -1
  31. package/dist-lib/config.mjs +1 -1
  32. package/dist-lib/detox/index.cjs +2 -2
  33. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  34. package/dist-lib/expo-swift-bundle.cjs +112 -52
  35. package/dist-lib/expo-swift-metadata.cjs +1 -17
  36. package/dist-lib/expo-swift-metadata.mjs +1 -16
  37. package/dist-lib/home-paths.cjs +1 -1
  38. package/dist-lib/host/bridge-host.cjs +1963 -1891
  39. package/dist-lib/host/fetch-proxy-handler.cjs +2 -4
  40. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  41. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  42. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  43. package/dist-lib/host/websocket-proxy.cjs +1 -1
  44. package/dist-lib/index.cjs +7 -10
  45. package/dist-lib/jump-to-source-babel.cjs +1 -1
  46. package/dist-lib/jump-to-source-native.cjs +1 -1
  47. package/dist-lib/kotlin-host.cjs +1 -1
  48. package/dist-lib/menu.cjs +1 -1
  49. package/dist-lib/menu.mjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  52. package/dist-lib/metro-production-bundle.cjs +1 -1
  53. package/dist-lib/metro-production-bundle.mjs +1 -1
  54. package/dist-lib/metro.cjs +4 -6
  55. package/dist-lib/native-app-identity-project.cjs +3 -3
  56. package/dist-lib/native-app-identity-project.mjs +6 -6
  57. package/dist-lib/native-app-identity.cjs +1 -1
  58. package/dist-lib/native-app-identity.mjs +1 -1
  59. package/dist-lib/native-firebase-metadata.cjs +1 -1
  60. package/dist-lib/native-firebase-metadata.mjs +1 -1
  61. package/dist-lib/pdfium-raster.cjs +1 -1
  62. package/dist-lib/pdfium-raster.mjs +1 -1
  63. package/dist-lib/plist.cjs +1 -1
  64. package/dist-lib/plist.mjs +1 -1
  65. package/dist-lib/profiles.cjs +1 -1
  66. package/dist-lib/public-brand.cjs +1 -1
  67. package/dist-lib/public-origins-lib-esm.json +24 -24
  68. package/dist-lib/public-origins-lib.json +64 -67
  69. package/dist-lib/react-native-host-modules.cjs +1 -1
  70. package/dist-lib/react-native-host-modules.mjs +1 -1
  71. package/dist-lib/reap-browser.cjs +1 -1
  72. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  73. package/dist-lib/sdk.cjs +1 -1
  74. package/dist-lib/sdk.mjs +1 -1
  75. package/dist-lib/skills.cjs +616 -467
  76. package/dist-lib/swift-compile.cjs +27 -26
  77. package/dist-lib/swift-compile.mjs +34 -33
  78. package/dist-lib/swift-package.cjs +1 -1
  79. package/dist-lib/swift-package.mjs +1 -1
  80. package/dist-lib/swift-submit.cjs +2 -2
  81. package/dist-lib/swift-submit.mjs +2 -2
  82. package/dist-lib/swift-toolchain.cjs +5 -3
  83. package/dist-lib/swift.cjs +1 -1
  84. package/dist-lib/vite-swift.cjs +87 -41
  85. package/dist-lib/vite.cjs +2 -4
  86. package/dist-lib/worklet-executable.cjs +1 -1
  87. package/dist-lib/worklet-executable.mjs +1 -1
  88. package/dist-types/packages/peach-engine/src/react-native/host-services.d.ts +7 -0
  89. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +14 -2
  90. package/install.mjs +21 -8
  91. package/package.json +1 -1
  92. package/runtime-companion.json +1 -1
  93. package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h +17 -0
  94. package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +5 -0
  95. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -0
  96. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +10 -1
  97. package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
  98. package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +11 -0
  99. package/sdk/ios/usr/lib/swift/UIKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +13 -0
  100. package/sdk/ios/wasm/include/string.h +1 -0
  101. package/src/expo-kotlin-host.ts +69 -35
  102. package/src/expo-swift-host.ts +45 -9
  103. package/src/expoSwiftContract.ts +2 -20
  104. package/src/nitro-adapter.lock.json +235 -235
  105. package/src/nitro-bundle.ts +2 -8
  106. package/src/nitro-superset.lock.json +14 -14
  107. package/src/nitro-superset.ts +2 -3
  108. package/src/nitroContract.ts +0 -29
  109. package/src/react-native-bridge-modules.ts +2 -9
  110. package/src/swift-compile.ts +2 -0
  111. package/src/swift-distribution.lock.json +8 -8
  112. package/src/swift-distribution.ts +1 -0
  113. package/src/swift-icu.ts +21 -27
  114. package/src/swift-project-user.ts +5 -0
  115. package/src/swift-shared-sdk.ts +4 -0
  116. package/src/swift-standins.ts +6 -1
  117. package/src/swift-submit.ts +2 -1
  118. package/src/swift-toolchain.ts +5 -2
  119. package/src/swift-wasm-prune.ts +10 -2
  120. package/src/turbo-runtime.lock.json +15 -15
  121. package/src/turbo-source.ts +160 -37
@@ -33,7 +33,6 @@ import {
33
33
  } from './nitro-dependencies'
34
34
  import { iosAutolinkedDependencies } from './nitro-source'
35
35
  import { TURBO_RUNTIME_HEADER } from './nitroAdapterContract'
36
- import { COMPILED_TURBO_NATIVE_PACKAGES } from './nitroContract'
37
36
  import {
38
37
  loadPodspec,
39
38
  podspecLinksBinaries,
@@ -141,6 +140,8 @@ const REACT_NATIVE_INCLUDE_ROOTS = [
141
140
  'ReactCommon',
142
141
  'ReactCommon/callinvoker',
143
142
  'ReactCommon/jsiexecutor',
143
+ // React-jsitooling's header_dir is react/runtime under its own root
144
+ 'ReactCommon/jsitooling',
144
145
  'ReactCommon/react/nativemodule/core',
145
146
  'ReactCommon/react/nativemodule/core/platform/ios',
146
147
  'ReactCommon/runtimeexecutor',
@@ -325,20 +326,25 @@ function podspecList(text: string, attribute: string): string[] | 'computed' | n
325
326
  return items
326
327
  }
327
328
 
328
- function podspecDependencies(text: string): { name: string; version?: string }[] {
329
- const deps: { name: string; version?: string }[] = []
330
- const seen = new Set<string>()
329
+ /** the external pods a podspec depends on; "subspecs" holds every requested subspec path across its dependency lines, "" for the pod itself. */
330
+ function podspecDependencies(
331
+ text: string,
332
+ ): { name: string; requirements: string[]; subspecs: string[] }[] {
333
+ const deps = new Map<
334
+ string,
335
+ { name: string; requirements: string[]; subspecs: string[] }
336
+ >()
331
337
  for (const match of text.matchAll(
332
- /^\s*\w+\.dependency\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/gm,
338
+ /^\s*\w+\.dependency\s+['"]([^'"]+)['"]((?:\s*,\s*['"][^'"]+['"])*)/gm,
333
339
  )) {
334
- const root = match[1]!.split('/')[0]!
340
+ const requirements = [...match[2]!.matchAll(/['"]([^'"]+)['"]/g)].map((m) => m[1]!)
341
+ const [root, ...subspec] = match[1]!.split('/')
335
342
  if (
336
- seen.has(root) ||
337
343
  root === 'React' ||
338
344
  root === 'React-Core' ||
339
345
  root === 'ReactCommon' ||
340
- root.startsWith('React-') ||
341
- root.startsWith('RCT') ||
346
+ root!.startsWith('React-') ||
347
+ root!.startsWith('RCT') ||
342
348
  root === 'FBLazyVector' ||
343
349
  root === 'DoubleConversion' ||
344
350
  root === 'glog' ||
@@ -348,10 +354,56 @@ function podspecDependencies(text: string): { name: string; version?: string }[]
348
354
  root === 'Yoga'
349
355
  )
350
356
  continue
351
- seen.add(root)
352
- deps.push({ name: root, ...(match[2] ? { version: match[2] } : {}) })
357
+ // every declaration of a pod must hold: CocoaPods intersects their requirements
358
+ const dep = deps.get(root!) ?? { name: root!, requirements: [], subspecs: [] }
359
+ dep.requirements.push(...requirements)
360
+ dep.subspecs.push(subspec.join('/'))
361
+ deps.set(root!, dep)
353
362
  }
354
- return deps
363
+ return [...deps.values()]
364
+ }
365
+
366
+ const versionParts = (version: string) => version.split(/[.-]/).map((p) => Number(p) || 0)
367
+
368
+ function compareVersions(a: string, b: string): number {
369
+ const left = versionParts(a)
370
+ const right = versionParts(b)
371
+ for (let i = 0; i < Math.max(left.length, right.length); i++) {
372
+ const diff = (left[i] ?? 0) - (right[i] ?? 0)
373
+ if (diff !== 0) return diff
374
+ }
375
+ return 0
376
+ }
377
+
378
+ /** the highest published version that satisfies every CocoaPods requirement ("~> 3", ">= 1.2", "2.0"), stable before prerelease; undefined when one cannot be read. */
379
+ function satisfyingPodVersion(versions: string[], requirements: string[]) {
380
+ const parsed = requirements.map((requirement) => {
381
+ const match = /^\s*(~>|>=|<=|>|<|=|!=)?\s*(\d+(?:\.\d+)*)\s*$/.exec(requirement)
382
+ return match ? { operator: match[1] ?? '=', bound: match[2]! } : null
383
+ })
384
+ if (parsed.some((requirement) => !requirement)) return undefined
385
+ const admits = (version: string) =>
386
+ parsed.every((requirement) =>
387
+ admitsOne(version, requirement!.operator, requirement!.bound),
388
+ )
389
+ const candidates = versions.filter(admits).sort(compareVersions)
390
+ const stable = candidates.filter((version) => !version.includes('-'))
391
+ return (stable.length > 0 ? stable : candidates).at(-1)
392
+ }
393
+
394
+ function admitsOne(version: string, operator: string, bound: string) {
395
+ const order = compareVersions(version, bound)
396
+ if (operator === '=') return order === 0
397
+ if (operator === '!=') return order !== 0
398
+ if (operator === '>') return order > 0
399
+ if (operator === '>=') return order >= 0
400
+ if (operator === '<') return order < 0
401
+ if (operator === '<=') return order <= 0
402
+ // pessimistic: at least the bound, below the bound with its last part dropped and the one before it raised
403
+ const segments = bound.split('.')
404
+ const ceiling = segments.length > 1 ? segments.slice(0, -1) : segments
405
+ ceiling[ceiling.length - 1] = String(Number(ceiling[ceiling.length - 1]) + 1)
406
+ return order >= 0 && compareVersions(version, ceiling.join('.')) < 0
355
407
  }
356
408
 
357
409
  function stringList(value: unknown): string[] {
@@ -361,20 +413,71 @@ function stringList(value: unknown): string[] {
361
413
  return []
362
414
  }
363
415
 
416
+ /**
417
+ * the spec JSON members CocoaPods compiles for a dependency: each requested subspec ("" is the
418
+ * pod itself) with its ancestors, the subspecs it activates (Specification#subspec_dependencies:
419
+ * default_subspecs, none, else every child) and the sibling subspecs its dependencies name,
420
+ * followed until nothing new is selected.
421
+ */
422
+ function externalSpecMembers(
423
+ root: Record<string, unknown>,
424
+ requested: string[],
425
+ ): Record<string, unknown>[] {
426
+ const children = (spec: Record<string, unknown>) =>
427
+ Array.isArray(spec.subspecs) ? spec.subspecs.filter(object) : []
428
+ const chains = new Map<string, Record<string, unknown>[]>()
429
+ const select = (path: string[]) => {
430
+ const key = path.join('/')
431
+ if (chains.has(key)) return
432
+ const chain = [root]
433
+ for (const part of path) {
434
+ const child = children(chain.at(-1)!).find((sub) => sub.name === part)
435
+ if (!child) throw new Error(`${String(root.name)} has no subspec ${key}`)
436
+ chain.push(child)
437
+ }
438
+ chains.set(key, chain)
439
+ const spec = chain.at(-1)!
440
+ const defaults = stringList(spec.default_subspecs ?? spec.default_subspec)
441
+ const activated =
442
+ defaults[0] === 'none'
443
+ ? []
444
+ : defaults.length > 0
445
+ ? defaults
446
+ : children(spec).map((sub) => String(sub.name))
447
+ for (const name of activated) select([...path, ...name.split('/')])
448
+ for (const member of chain)
449
+ for (const dependencies of [member.dependencies, iosOf(member)?.dependencies])
450
+ for (const dependency of object(dependencies) ? Object.keys(dependencies) : []) {
451
+ const [pod, ...rest] = dependency.split('/')
452
+ if (pod === root.name) select(rest)
453
+ }
454
+ }
455
+ for (const name of requested) select(name ? name.split('/') : [])
456
+ return [...new Set([...chains.values()].flat())]
457
+ }
458
+
459
+ const iosOf = (member: Record<string, unknown>) =>
460
+ object(member.ios) ? member.ios : null
461
+
364
462
  async function resolveExternalTurboPod(
365
463
  name: string,
366
- versionHint: string | undefined,
464
+ requirements: string[],
465
+ requestedSubspecs: string[],
367
466
  ): Promise<{
368
467
  name: string
369
468
  moduleName: string
370
469
  root: string
371
470
  files: string[]
471
+ /** the pod's own GCC_PREPROCESSOR_DEFINITIONS, which CocoaPods builds it with */
472
+ defines: string[]
372
473
  } | null> {
373
474
  const shard = createHash('md5').update(name).digest('hex').slice(0, 3).split('')
374
475
  const baseDir = path.join(rnxHomeDir(), 'turbo-pods')
476
+ const [only] = requirements
375
477
  let version =
376
- versionHint && /^\d+\.\d+(?:\.\d+)*(?:-[0-9A-Za-z.-]+)?$/.test(versionHint.trim())
377
- ? versionHint.trim()
478
+ requirements.length === 1 &&
479
+ /^\d+\.\d+(?:\.\d+)*(?:-[0-9A-Za-z.-]+)?$/.test(only!.trim())
480
+ ? only!.trim()
378
481
  : undefined
379
482
  if (!version) {
380
483
  const versionsFile = path.join(baseDir, 'versions', `${shard.join('_')}.txt`)
@@ -392,12 +495,13 @@ async function resolveExternalTurboPod(
392
495
  }
393
496
  const line = versionsText.split('\n').find((entry) => entry.startsWith(`${name}/`))
394
497
  if (!line) return null
395
- const allVersions = line
396
- .slice(name.length + 1)
397
- .split('/')
398
- .filter(Boolean)
399
- const stable = allVersions.filter((v) => !v.includes('-'))
400
- version = (stable.length > 0 ? stable : allVersions).at(-1)
498
+ version = satisfyingPodVersion(
499
+ line
500
+ .slice(name.length + 1)
501
+ .split('/')
502
+ .filter(Boolean),
503
+ requirements,
504
+ )
401
505
  if (!version) return null
402
506
  }
403
507
  const specFile = path.join(baseDir, 'specs', `${name}-${version}.podspec.json`)
@@ -444,15 +548,15 @@ async function resolveExternalTurboPod(
444
548
  fs.rmSync(staging, { recursive: true, force: true })
445
549
  fs.writeFileSync(marker, version)
446
550
  }
447
- const iosSpec = object(spec.ios) ? spec.ios : null
448
- const sourceGlobs = [
449
- ...stringList(spec.source_files),
450
- ...stringList(iosSpec?.source_files),
451
- ]
452
- const excludeGlobs = [
453
- ...stringList(spec.exclude_files),
454
- ...stringList(iosSpec?.exclude_files),
455
- ]
551
+ const members = externalSpecMembers(spec, requestedSubspecs)
552
+ const sourceGlobs = members.flatMap((member) => [
553
+ ...stringList(member.source_files),
554
+ ...stringList(iosOf(member)?.source_files),
555
+ ])
556
+ const excludeGlobs = members.flatMap((member) => [
557
+ ...stringList(member.exclude_files),
558
+ ...stringList(iosOf(member)?.exclude_files),
559
+ ])
456
560
  if (sourceGlobs.length === 0) return null
457
561
  const candidates = new Set<string>()
458
562
  for (const glob of sourceGlobs) walkFiles(treeDir, globBase(glob), candidates)
@@ -465,13 +569,22 @@ async function resolveExternalTurboPod(
465
569
  !excluded.some((glob) => glob.test(file)),
466
570
  )
467
571
  .sort()
572
+ const iosSpec = iosOf(spec)
468
573
  const moduleName =
469
574
  typeof spec.module_name === 'string'
470
575
  ? spec.module_name
471
576
  : typeof iosSpec?.module_name === 'string'
472
577
  ? iosSpec.module_name
473
578
  : name
474
- return { name, moduleName, root: treeDir, files }
579
+ const defines = members.flatMap((member) =>
580
+ [member.pod_target_xcconfig, iosOf(member)?.pod_target_xcconfig].flatMap((config) => {
581
+ const value = object(config) ? config.GCC_PREPROCESSOR_DEFINITIONS : undefined
582
+ return typeof value === 'string'
583
+ ? value.split(/\s+/).filter((token) => token && token !== '$(inherited)')
584
+ : []
585
+ }),
586
+ )
587
+ return { name, moduleName, root: treeDir, files, defines }
475
588
  }
476
589
 
477
590
  type Pod = {
@@ -772,10 +885,8 @@ function registers(root: string, files: Iterable<string>, objc = true): boolean
772
885
  export async function discoverTurboProviders(appRoot: string): Promise<TurboProvider[]> {
773
886
  const providers: TurboProvider[] = []
774
887
  for (const { name, root, podspecPath } of await iosAutolinkedDependencies(appRoot)) {
775
- // a package peach-compat answers keeps its answer, Fabric views included,
776
- // until COMPILED_TURBO_NATIVE_PACKAGES moves it to its original source.
777
- if (answeredPackages.has(name) && !COMPILED_TURBO_NATIVE_PACKAGES.includes(name))
778
- continue
888
+ // a package peach-compat answers keeps its answer, Fabric views included.
889
+ if (answeredPackages.has(name)) continue
779
890
  // a pod can register Nitro objects and Fabric components independently.
780
891
  const fabric = fabricComponents(root)
781
892
  if (!podspecPath) continue
@@ -785,7 +896,7 @@ export async function discoverTurboProviders(appRoot: string): Promise<TurboProv
785
896
  if (fabric || (files !== null && registers(pod.root, files))) {
786
897
  const dependencies = await Promise.all(
787
898
  podspecDependencies(pod.text).map((dep) =>
788
- resolveExternalTurboPod(dep.name, dep.version),
899
+ resolveExternalTurboPod(dep.name, dep.requirements, dep.subspecs),
789
900
  ),
790
901
  )
791
902
  if (!dependencies.some((dep) => dep?.files.some((file) => file.endsWith('.swift'))))
@@ -1453,6 +1564,7 @@ export async function collectTurboSources(options: {
1453
1564
  root: string
1454
1565
  files: string[]
1455
1566
  }[] = []
1567
+ const externalDefines: string[] = []
1456
1568
  for (const dep of podspecDependencies(pod.text)) {
1457
1569
  const installed = installedHeaderPods.find(
1458
1570
  (candidate) => candidate.name === dep.name,
@@ -1466,9 +1578,11 @@ export async function collectTurboSources(options: {
1466
1578
  moduleName: moduleNames?.[0] ?? installed.name,
1467
1579
  root: installed.root,
1468
1580
  files: podFiles(installed),
1581
+ defines: [],
1469
1582
  }
1470
- : await resolveExternalTurboPod(dep.name, dep.version)
1583
+ : await resolveExternalTurboPod(dep.name, dep.requirements, dep.subspecs)
1471
1584
  if (!resolved) continue
1585
+ externalDefines.push(...resolved.defines)
1472
1586
  const mappings = installed ? podHeaderMappings(installed) : []
1473
1587
  const swiftFilesForDep: string[] = []
1474
1588
  for (const file of resolved.files) {
@@ -1521,6 +1635,15 @@ export async function collectTurboSources(options: {
1521
1635
  })
1522
1636
  }
1523
1637
  }
1638
+ // an external pod's units compile inside the provider target with the defines its podspec sets
1639
+ if (externalDefines.length > 0) {
1640
+ const flags = [...new Set(externalDefines)].map((define) => `-D${define}`)
1641
+ providerTargetInput.clangSettings = [
1642
+ ...(providerTargetInput.clangSettings ?? []),
1643
+ { tool: 'c', flags },
1644
+ { tool: 'cxx', flags },
1645
+ ]
1646
+ }
1524
1647
  for (const depPod of depSwiftPods) {
1525
1648
  if (!result.targets.some((t) => t.name === depPod.moduleName)) {
1526
1649
  result.targets.push(target(depPod.moduleName, []))