peachsim 0.1.2432 → 0.1.2434

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 (104) hide show
  1. package/cli/app-project.ts +5 -0
  2. package/cli/commands/box.ts +3 -0
  3. package/cli/commands/control.ts +14 -6
  4. package/cli/commands/platform.ts +3 -3
  5. package/cli/commands/stream.ts +8 -1
  6. package/dist-lib/agent-daemon-client.cjs +1 -1
  7. package/dist-lib/agent-events.cjs +1 -1
  8. package/dist-lib/attached-projects.cjs +1 -1
  9. package/dist-lib/auth/shared-session.cjs +1 -1
  10. package/dist-lib/backend-origin.cjs +1 -1
  11. package/dist-lib/beta.cjs +1 -1
  12. package/dist-lib/beta.mjs +1 -1
  13. package/dist-lib/bridge-constants.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.mjs +1 -1
  16. package/dist-lib/bridge-contract.cjs +1 -1
  17. package/dist-lib/bridge-contract.mjs +1 -1
  18. package/dist-lib/bundle-channel.cjs +105 -85
  19. package/dist-lib/capture-contract.cjs +1 -1
  20. package/dist-lib/capture-contract.mjs +1 -1
  21. package/dist-lib/cloud-contract.cjs +1 -1
  22. package/dist-lib/cloud-contract.mjs +1 -1
  23. package/dist-lib/cloud-test-args.cjs +1 -1
  24. package/dist-lib/cloud-test-args.mjs +1 -1
  25. package/dist-lib/cloud.cjs +1 -1
  26. package/dist-lib/cloud.mjs +1 -1
  27. package/dist-lib/config.cjs +1 -1
  28. package/dist-lib/config.mjs +1 -1
  29. package/dist-lib/detox/index.cjs +2 -2
  30. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  31. package/dist-lib/expo-swift-bundle.cjs +59 -18
  32. package/dist-lib/expo-swift-metadata.cjs +1 -1
  33. package/dist-lib/expo-swift-metadata.mjs +1 -1
  34. package/dist-lib/home-paths.cjs +1 -1
  35. package/dist-lib/host/bridge-host.cjs +96 -76
  36. package/dist-lib/host/fetch-proxy-handler.cjs +6 -4
  37. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  38. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  39. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  40. package/dist-lib/host/websocket-proxy.cjs +1 -1
  41. package/dist-lib/index.cjs +6 -4
  42. package/dist-lib/jump-to-source-babel.cjs +1 -1
  43. package/dist-lib/jump-to-source-native.cjs +1 -1
  44. package/dist-lib/kotlin-host.cjs +36 -57
  45. package/dist-lib/menu.cjs +1 -1
  46. package/dist-lib/menu.mjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  49. package/dist-lib/metro-production-bundle.cjs +1 -1
  50. package/dist-lib/metro-production-bundle.mjs +1 -1
  51. package/dist-lib/metro.cjs +6 -4
  52. package/dist-lib/native-app-identity-project.cjs +2 -2
  53. package/dist-lib/native-app-identity-project.mjs +2 -2
  54. package/dist-lib/native-app-identity.cjs +1 -1
  55. package/dist-lib/native-app-identity.mjs +1 -1
  56. package/dist-lib/native-firebase-metadata.cjs +1 -1
  57. package/dist-lib/native-firebase-metadata.mjs +1 -1
  58. package/dist-lib/pdfium-raster.cjs +1 -1
  59. package/dist-lib/pdfium-raster.mjs +1 -1
  60. package/dist-lib/plist.cjs +1 -1
  61. package/dist-lib/plist.mjs +1 -1
  62. package/dist-lib/profiles.cjs +1 -1
  63. package/dist-lib/public-brand.cjs +1 -1
  64. package/dist-lib/public-origins-lib-esm.json +25 -25
  65. package/dist-lib/public-origins-lib.json +56 -56
  66. package/dist-lib/react-native-host-modules.cjs +1 -1
  67. package/dist-lib/react-native-host-modules.mjs +1 -1
  68. package/dist-lib/reap-browser.cjs +1 -1
  69. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  70. package/dist-lib/sdk.cjs +1 -1
  71. package/dist-lib/sdk.mjs +1 -1
  72. package/dist-lib/skills.cjs +112 -79
  73. package/dist-lib/swift-compile.cjs +25 -16
  74. package/dist-lib/swift-compile.mjs +25 -16
  75. package/dist-lib/swift-package.cjs +1 -1
  76. package/dist-lib/swift-package.mjs +1 -1
  77. package/dist-lib/swift-submit.cjs +1 -1
  78. package/dist-lib/swift-submit.mjs +1 -1
  79. package/dist-lib/swift-toolchain.cjs +1 -1
  80. package/dist-lib/swift.cjs +1 -1
  81. package/dist-lib/vite-swift.cjs +61 -22
  82. package/dist-lib/vite.cjs +6 -4
  83. package/dist-lib/worklet-executable.cjs +1 -1
  84. package/dist-lib/worklet-executable.mjs +1 -1
  85. package/dist-types/packages/peach-engine/src/engine/image-loader-canvaskit.d.ts +3 -0
  86. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -0
  87. package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +2 -2
  88. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +3 -2
  89. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -1
  90. package/dist-types/packages/peach-globals/src/cameraInputBridgeContract.d.ts +26 -0
  91. package/dist-types/packages/peach-globals/src/globalsContract.d.ts +2 -0
  92. package/dist-types/packages/peach-globals/src/index.d.ts +1 -0
  93. package/kotlin/README.md +3 -1
  94. package/kotlin/sdk.tar.gz +0 -0
  95. package/package.json +1 -1
  96. package/runtime-companion.json +1 -1
  97. package/src/java-module-abi.ts +11 -28
  98. package/src/kotlin-host.ts +13 -32
  99. package/src/kotlin-toolchain.ts +25 -0
  100. package/src/react-native-coverage/native-typescript-parser.ts +29 -1
  101. package/src/swift-guest-source-inputs.ts +5 -1
  102. package/src/swift-guest-source-plan.ts +25 -9
  103. package/src/swift-host.ts +28 -5
  104. package/src/swift-xcframework.ts +24 -0
@@ -34,6 +34,26 @@ function swiftPackageLinkage(
34
34
  return linkage
35
35
  }
36
36
 
37
+ // a static SwiftPM product holds no code of its own: each client links the
38
+ // product's targets, so the product groups link edges and joins no image.
39
+ function linkEdges(
40
+ targets: ReadonlyMap<string, SwiftSourceLinkGraph['targets'][number]>,
41
+ id: string,
42
+ ): SwiftSourceLinkGraph['targets'][number]['dependencies'] {
43
+ const target = targets.get(id)
44
+ if (!target) throw new Error(`unknown source target ${id}`)
45
+ return target.dependencies.flatMap((edge) => {
46
+ if (edge.attributes.length)
47
+ throw new Error(`unsupported link attributes for ${id} -> ${edge.target}`)
48
+ const dependency = targets.get(edge.target)
49
+ if (!dependency) throw new Error(`unknown source target ${edge.target}`)
50
+ return dependency.productType.startsWith('swiftpm.library.') &&
51
+ swiftPackageLinkage(dependency) === 'static'
52
+ ? linkEdges(targets, edge.target)
53
+ : [edge]
54
+ })
55
+ }
56
+
37
57
  /** Build image membership from resolved source products and their direct links. */
38
58
  export function guestSourceImages(graph: SwiftSourceLinkGraph): GuestSourceImage[] {
39
59
  const targets = new Map(graph.targets.map((target) => [target.id, target]))
@@ -63,11 +83,8 @@ export function guestSourceImages(graph: SwiftSourceLinkGraph): GuestSourceImage
63
83
  ownership.set(id, image.id)
64
84
  image.members.push(id)
65
85
  active.add(id)
66
- for (const edge of target.dependencies) {
67
- if (edge.attributes.length)
68
- throw new Error(`unsupported link attributes for ${id} -> ${edge.target}`)
69
- const dependency = targets.get(edge.target)
70
- if (!dependency) throw new Error(`unknown source target ${edge.target}`)
86
+ for (const edge of linkEdges(targets, id)) {
87
+ const dependency = targets.get(edge.target)!
71
88
  const type = dependency.productType
72
89
  let dynamic: boolean
73
90
  if (type.startsWith('swiftpm.target.')) {
@@ -77,7 +94,8 @@ export function guestSourceImages(graph: SwiftSourceLinkGraph): GuestSourceImage
77
94
  type !== 'swiftpm.target.system'
78
95
  )
79
96
  throw new Error(`unsupported SwiftPM target ${edge.target}`)
80
- dynamic = false
97
+ // a binary target's dynamic framework is its own image
98
+ dynamic = type === 'swiftpm.target.binary' && dependency.machOType === 'mh_dylib'
81
99
  } else if (type.startsWith('swiftpm.library.')) {
82
100
  dynamic = swiftPackageLinkage(dependency) === 'dynamic'
83
101
  } else if (type === 'com.apple.product-type.library.static') {
@@ -251,9 +269,7 @@ export function planGuestSourceLink(
251
269
  )
252
270
  )
253
271
  throw new Error(`unsupported special link flag for ${id}`)
254
- for (const edge of target.dependencies) {
255
- if (edge.attributes.length)
256
- throw new Error(`unsupported link attributes for ${id} -> ${edge.target}`)
272
+ for (const edge of linkEdges(targets, id)) {
257
273
  const dependencyImage = ownerByTarget.get(edge.target)
258
274
  if (dependencyImage === undefined)
259
275
  throw new Error(`linked target ${edge.target} has no guest image`)
package/src/swift-host.ts CHANGED
@@ -100,6 +100,7 @@ import {
100
100
  standinGenerationInputs,
101
101
  standinLibrary,
102
102
  standinDependencies,
103
+ swiftBinaryFramework,
103
104
  swiftStandins,
104
105
  type SwiftStandin,
105
106
  type SwiftStandins,
@@ -125,6 +126,7 @@ import {
125
126
  type SwiftNativeModules,
126
127
  } from './swift-submit'
127
128
  import { privateSwiftDistributionRoot, swiftCacheDir } from './swift-toolchain'
129
+ import { isDynamicLibrary, simulatorNativeLibrary } from './swift-xcframework'
128
130
  import { swiftProjectFileProblem } from './swiftContract'
129
131
  import {
130
132
  type SwiftSourceLinkGraph,
@@ -349,6 +351,8 @@ interface XcodeProjectEntry {
349
351
  binaries: SwiftPackageBinary[]
350
352
  packages: SwiftPackages
351
353
  standins: SwiftStandin[]
354
+ /** the framework name of each stood-in binary target that ships a dynamic library. */
355
+ dynamicFrameworks: Map<string, string>
352
356
  /** why a framework the project vendors got no stand-in, by name. */
353
357
  projectGaps: Map<string, string>
354
358
  }
@@ -610,6 +614,7 @@ async function swiftPackages(
610
614
  ): Promise<{
611
615
  packages: SwiftPackages
612
616
  standins: SwiftStandin[]
617
+ dynamicFrameworks: Map<string, string>
613
618
  projectGaps: Map<string, string>
614
619
  binaries: SwiftPackageBinary[]
615
620
  }> {
@@ -648,6 +653,7 @@ async function swiftPackages(
648
653
  packages,
649
654
  binaries: packages.binaries,
650
655
  standins: [],
656
+ dynamicFrameworks: new Map(),
651
657
  projectGaps: new Map(),
652
658
  }
653
659
  entry.packages = cached
@@ -750,6 +756,18 @@ async function swiftPackages(
750
756
  for (const target of new Set(built.standins.map((standin) => standin.target)))
751
757
  console.error(`Peach: target ${target} was replaced with a stand-in`)
752
758
  cached.standins = built.standins
759
+ // a binary target shipping a dynamic framework is its own image: the app
760
+ // embeds the framework once for every client that links it.
761
+ const stoodIn = new Set(built.standins.map((standin) => standin.target))
762
+ cached.dynamicFrameworks = new Map(
763
+ cxxArtifacts.flatMap((binary) => {
764
+ if (!stoodIn.has(binary.target)) return []
765
+ const native = simulatorNativeLibrary(swiftBinaryFramework(binary).dir)
766
+ return native?.kind === 'framework' && isDynamicLibrary(native.file)
767
+ ? [[binary.target, native.name] as const]
768
+ : []
769
+ }),
770
+ )
753
771
  cached.projectGaps = new Map(
754
772
  vendored.flatMap(({ target }) => {
755
773
  const gap = built.gaps.get(target)
@@ -881,10 +899,8 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
881
899
  nativeModules: registered.nativeModules,
882
900
  },
883
901
  )
884
- const { packages, standins, projectGaps, binaries } = await swiftPackages(
885
- registered,
886
- appTarget,
887
- )
902
+ const { packages, standins, dynamicFrameworks, projectGaps, binaries } =
903
+ await swiftPackages(registered, appTarget)
888
904
  const sourceFrameworks = new Map(
889
905
  packages.sourceFrameworks.map(
890
906
  ({
@@ -1659,8 +1675,14 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
1659
1675
  )?.products ?? [])
1660
1676
  : []
1661
1677
  const packageTarget = target.productType.startsWith('swiftpm.')
1678
+ const binaryFramework =
1679
+ target.productType === 'swiftpm.target.binary'
1680
+ ? (dynamicFrameworks.get(target.productName) ?? null)
1681
+ : null
1662
1682
  const packageFramework =
1663
- target.productType === 'swiftpm.library.dynamic' ? target.productName : null
1683
+ target.productType === 'swiftpm.library.dynamic'
1684
+ ? target.productName
1685
+ : binaryFramework
1664
1686
  const buildVersion = {
1665
1687
  platform: packageTarget
1666
1688
  ? applicationBuildVersion.platform
@@ -1686,6 +1708,7 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
1686
1708
  packageFramework === null
1687
1709
  ? target.installName
1688
1710
  : `@rpath/${packageFramework}.framework/${packageFramework}`,
1711
+ machOType: binaryFramework === null ? target.machOType : 'mh_dylib',
1689
1712
  sourceTarget:
1690
1713
  target.sourceTarget === null
1691
1714
  ? (first ?? null)
@@ -50,3 +50,27 @@ export function simulatorNativeLibrary(
50
50
  if (matches.length !== 1) throw new Error(`${dir}: ambiguous simulator library`)
51
51
  return matches[0]!
52
52
  }
53
+
54
+ // a Mach-O dynamic library (MH_DYLIB), thin or read from a universal file's first slice
55
+ export function isDynamicLibrary(file: string): boolean {
56
+ const fd = fs.openSync(file, 'r')
57
+ try {
58
+ const read = (offset: number) => {
59
+ const bytes = Buffer.alloc(16)
60
+ fs.readSync(fd, bytes, 0, 16, offset)
61
+ return bytes
62
+ }
63
+ let header = read(0)
64
+ const universal = header.readUInt32BE(0)
65
+ if (universal === 0xcafebabe || universal === 0xcafebabf) {
66
+ const arch = read(8)
67
+ header = read(
68
+ universal === 0xcafebabe ? arch.readUInt32BE(8) : Number(arch.readBigUInt64BE(8)),
69
+ )
70
+ }
71
+ const magic = header.readUInt32LE(0)
72
+ return (magic === 0xfeedfacf || magic === 0xfeedface) && header.readUInt32LE(12) === 6
73
+ } finally {
74
+ fs.closeSync(fd)
75
+ }
76
+ }