peachsim 0.1.2368 → 0.1.2370

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 (105) 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 +173 -76
  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 +172 -75
  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 +173 -76
  31. package/dist-lib/host/fetch-proxy-handler.cjs +7 -5
  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 +7 -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 +7 -5
  47. package/dist-lib/native-app-identity-project.cjs +2 -2
  48. package/dist-lib/native-app-identity-project.mjs +2 -2
  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 +178 -81
  68. package/dist-lib/swift-compile.cjs +32 -13
  69. package/dist-lib/swift-compile.mjs +32 -13
  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 +1 -1
  75. package/dist-lib/swift.cjs +1 -1
  76. package/dist-lib/vite-swift.cjs +151 -72
  77. package/dist-lib/vite.cjs +7 -5
  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/render-worker/compositor-gpu.d.ts +1 -0
  81. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +14 -0
  82. package/kotlin/sdk.tar.gz +0 -0
  83. package/node-runtime.json +1 -1
  84. package/package.json +1 -1
  85. package/sdk/ios/System/Library/Frameworks/DeviceCheck.framework/Headers/DCAppAttestService.h +223 -0
  86. package/sdk/ios/System/Library/Frameworks/DeviceCheck.framework/Headers/DCDevice.h +90 -0
  87. package/sdk/ios/System/Library/Frameworks/DeviceCheck.framework/Headers/DCError.h +52 -0
  88. package/sdk/ios/System/Library/Frameworks/DeviceCheck.framework/Headers/DeviceCheck.h +13 -0
  89. package/sdk/ios/System/Library/Frameworks/DeviceCheck.framework/Modules/module.modulemap +6 -0
  90. package/sdk/ios/usr/include/_modules/_Availability.h +33 -0
  91. package/sdk/ios/usr/include/_modules/_os_availability.h +33 -0
  92. package/sdk/ios/usr/include/availability.modulemap +50 -0
  93. package/sdk/ios/usr/include/module.modulemap +4 -0
  94. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +77 -0
  95. package/sdk/ios/usr/lib/swift/StoreKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -0
  96. package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +23 -0
  97. package/sdk/ios/usr/lib/swift/UIKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
  98. package/src/native-static-libraries.ts +16 -16
  99. package/src/podspec-sources.ts +19 -1
  100. package/src/swift-compile.ts +38 -24
  101. package/src/swift-objc-standin.ts +11 -5
  102. package/src/swift-packages.ts +40 -28
  103. package/src/swift-shipped-binaries.ts +6 -2
  104. package/src/swift-standin-emit.ts +65 -11
  105. package/src/swift-standins.ts +30 -4
@@ -97,112 +97,112 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
97
97
  name: 'skia',
98
98
  nativeSha256: '5312f2b194b1f6b6721388028bf919e56400278245b039f47136aa98f0582333',
99
99
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
100
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
100
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
101
101
  archive: 'libskia.a',
102
102
  },
103
103
  {
104
104
  name: 'skia_svg',
105
105
  nativeSha256: '77adc498cff85db7850fb713c306681c6337f9b4ec42991b3764c8f3eff9d8d0',
106
106
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
107
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
107
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
108
108
  archive: 'libsvg.a',
109
109
  },
110
110
  {
111
111
  name: 'skia_skshaper',
112
112
  nativeSha256: '830bcf260bd24fd79ee5d323e26ec667638795e3a0e555f1093371b8342c345c',
113
113
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
114
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
114
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
115
115
  archive: 'libskshaper.a',
116
116
  },
117
117
  {
118
118
  name: 'skia_skparagraph',
119
119
  nativeSha256: '26afd4e5b11d46b0820a2cd7fd9918eb5a041946e1a1c0d4b91a5d54877e9dda',
120
120
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
121
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
121
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
122
122
  archive: 'libskparagraph.a',
123
123
  },
124
124
  {
125
125
  name: 'skia_skunicode_core',
126
126
  nativeSha256: '629f58c4e81157d42e353b2b255bebb2fd94d1f31d8f8157e982fa4367710526',
127
127
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
128
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
128
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
129
129
  archive: 'libskunicode_core.a',
130
130
  },
131
131
  {
132
132
  name: 'skia_skunicode_libgrapheme',
133
133
  nativeSha256: '047bd82306ba688453a3ff9dc02e203cdf16f2084551cca54f5d2b099baf1895',
134
134
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
135
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
135
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
136
136
  archive: 'libskunicode_libgrapheme.a',
137
137
  },
138
138
  {
139
139
  name: 'skia_skottie',
140
140
  nativeSha256: '75c0dfd82a256e761cddc45475b8109ed8c9a442767cf3a8bf8720eef0dd4af7',
141
141
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
142
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
142
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
143
143
  archive: 'libskottie.a',
144
144
  },
145
145
  {
146
146
  name: 'skia_sksg',
147
147
  nativeSha256: 'df9652a46505d3c5c74d55b52295ef39218d2b5856e074117461fa2348312c8d',
148
148
  upstream: '9f9e6beb751091ef69163d2b4fdcd1e711b594ac',
149
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
149
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
150
150
  archive: 'libsksg.a',
151
151
  },
152
152
  {
153
153
  name: 'skia',
154
154
  nativeSha256: 'c9b007c4da16f66d84b2f108af719b424ef91ee0759e58df0b76930bc6f82e31',
155
155
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
156
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
156
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
157
157
  archive: 'libskia.a',
158
158
  },
159
159
  {
160
160
  name: 'skia_svg',
161
161
  nativeSha256: '159705737769610b60216b114a28ba833840aa1df7833424df99edec4405b86f',
162
162
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
163
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
163
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
164
164
  archive: 'libsvg.a',
165
165
  },
166
166
  {
167
167
  name: 'skia_skshaper',
168
168
  nativeSha256: '934f3dbf3f38bca87b463b664a17c1588840f86ec89cf6961fb2a89b6336b35b',
169
169
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
170
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
170
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
171
171
  archive: 'libskshaper.a',
172
172
  },
173
173
  {
174
174
  name: 'skia_skparagraph',
175
175
  nativeSha256: '29a48349fc9b75c252b22fc6ca5ade90636900f82beec58780f03fd66ab345b3',
176
176
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
177
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
177
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
178
178
  archive: 'libskparagraph.a',
179
179
  },
180
180
  {
181
181
  name: 'skia_skunicode_core',
182
182
  nativeSha256: '096e5139c4de528dbba5a9605895f4c725853e48225503bdfa9c1d70241e5f58',
183
183
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
184
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
184
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
185
185
  archive: 'libskunicode_core.a',
186
186
  },
187
187
  {
188
188
  name: 'skia_skunicode_libgrapheme',
189
189
  nativeSha256: 'd1ec3c2d5ad6889eb4fbf4a6bab74f39946739501d40de903f7d8cb2181ac37d',
190
190
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
191
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
191
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
192
192
  archive: 'libskunicode_libgrapheme.a',
193
193
  },
194
194
  {
195
195
  name: 'skia_skottie',
196
196
  nativeSha256: '52ea2e046f45f51df6027d783e923864e8c4ef94a1fe4fc5971e436574d8ae57',
197
197
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
198
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
198
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
199
199
  archive: 'libskottie.a',
200
200
  },
201
201
  {
202
202
  name: 'skia_sksg',
203
203
  nativeSha256: '541a74d8f83dc411efe8eeac377486a5054fab4c7710afe406a20a27efe8f627',
204
204
  upstream: 'b94213a11b3a2edadfae89f0c57a7f4ab72772c9',
205
- recipe: '352165178eb75fa94a4378cb4593354b50ec5b53490f907e8d553a4d4c579364',
205
+ recipe: 'ebd819e6c4d81eac129954bbf27a3483c1830f73e3714a8ba72d4d19a563ec57',
206
206
  archive: 'libsksg.a',
207
207
  },
208
208
  {
@@ -2,7 +2,7 @@
2
2
  // macOS, peach's pinned bundle on linux. evaluations restored from a compiled
3
3
  // key artifact or a prepared workspace manifest answer without it.
4
4
  import { execFileSync } from 'node:child_process'
5
- import { createHash } from 'node:crypto'
5
+ import { createHash, randomUUID } from 'node:crypto'
6
6
  import fs from 'node:fs'
7
7
  import { createRequire } from 'node:module'
8
8
  import path from 'node:path'
@@ -145,6 +145,10 @@ interface PodspecPlan {
145
145
  receipt?: PodspecReceipt
146
146
  }
147
147
 
148
+ function receiptFile(key: string, environment: string) {
149
+ return path.join(cacheDir(), 'podspecs', 'receipts-v1', key, `${environment}.json`)
150
+ }
151
+
148
152
  /** the lookup key and evaluation context a receipt for this podspec must carry. */
149
153
  export function podspecReceiptIdentity(file: string, appRoot: string | null = null) {
150
154
  file = fs.realpathSync(file)
@@ -248,6 +252,15 @@ function planPodspec(podspec: string, appRoot: string | null): PodspecPlan {
248
252
  receipt !== undefined &&
249
253
  restoredReceipts.has(receipt)
250
254
  if (!restored && receipt?.environment !== environment) receipt = undefined
255
+ if (!receipt) {
256
+ const file = receiptFile(key, environment)
257
+ if (fs.existsSync(file)) {
258
+ receipt = podspecReceiptSchema.parse(JSON.parse(fs.readFileSync(file, 'utf8')))
259
+ if (receipt.key !== key || receipt.environment !== environment)
260
+ throw new Error(`podspec receipt identity mismatch: ${file}`)
261
+ receipts.set(key, receipt)
262
+ }
263
+ }
251
264
  return { file, app, key, environment, source: installed ?? file, receipt }
252
265
  }
253
266
 
@@ -372,6 +385,11 @@ export function loadPodspecs(
372
385
  spec: specs[index]!,
373
386
  }
374
387
  receipts.set(plan.key, plan.receipt)
388
+ const file = receiptFile(plan.key, plan.environment)
389
+ fs.mkdirSync(path.dirname(file), { recursive: true })
390
+ const temporary = `${file}.${randomUUID()}.tmp`
391
+ fs.writeFileSync(temporary, JSON.stringify(plan.receipt))
392
+ fs.renameSync(temporary, file)
375
393
  })
376
394
  }
377
395
  }
@@ -7082,16 +7082,7 @@ async function buildFrameworkProducts(
7082
7082
  // the way the builder's per-build-key roots do.
7083
7083
  const SWIFT_LINK_STAMP = '.peach-link-stamp'
7084
7084
 
7085
- // a few scratch slots at fixed paths hold the framework revisions in use; every
7086
- // app built against a revision reuses its slot's compiled products. a revision
7087
- // with no slot restages only the files that differ and rebuilds only the modules
7088
- // those files reach: swiftpm and llbuild key their plans on absolute paths, so a
7089
- // fresh path per revision recompiled every module. it takes the slot its own
7090
- // checkout built last, whose revision is its nearest, else the least recently
7091
- // built one: an edit restaged over another checkout's revision recompiled the
7092
- // whole framework. a slot is about 2 GB, and a shared Mac compiles six or more
7093
- // trees' revisions an hour: three slots evicted live rounds into 5 to 8 minute
7094
- // full rebuilds.
7085
+ // stable slot paths preserve swiftpm's incremental products across checkout paths.
7095
7086
  const SWIFT_FRAMEWORK_SLOTS = 8
7096
7087
  const SWIFT_FRAMEWORK_SLOT_KEY = '.peach-framework-key'
7097
7088
  const SWIFT_FRAMEWORK_SLOT_ORIGIN = '.peach-framework-origin'
@@ -7117,9 +7108,6 @@ function swiftFrameworkSlotKey(slot: string): string | null {
7117
7108
  return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_KEY)
7118
7109
  }
7119
7110
 
7120
- /** runs `work` holding the slot that builds `frameworkKey`'s products: the slot
7121
- * already staged for it, else an idle one, `moduleRoot`'s own newest first,
7122
- * then an empty one, then the least recently built. */
7123
7111
  async function withSwiftFrameworkSlot<T>(
7124
7112
  frameworkKey: string,
7125
7113
  moduleRoot: string,
@@ -7142,25 +7130,51 @@ async function withSwiftFrameworkSlot<T>(
7142
7130
  const built = new Map(slots.map((slot) => [slot, statSync(slot).mtimeMs]))
7143
7131
  const own = (slot: string) =>
7144
7132
  swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot
7145
- const oldest = slots.sort(
7146
- (left, right) => (built.get(left) ?? 0) - (built.get(right) ?? 0),
7133
+ const inputs = new Map(
7134
+ swiftModuleInputFiles(moduleRoot).map((file) => [
7135
+ file,
7136
+ readFileSync(path.join(moduleRoot, file)),
7137
+ ]),
7147
7138
  )
7148
- for (const slot of [
7149
- ...oldest.filter(own).reverse(),
7150
- // a slot created this run is empty but carries a fresh mtime, so it would
7151
- // otherwise sort behind an occupied slot it should spare
7152
- ...oldest.filter((slot) => !own(slot) && swiftFrameworkSlotKey(slot) === null),
7153
- ...oldest.filter((slot) => !own(slot) && swiftFrameworkSlotKey(slot) !== null),
7154
- ]) {
7139
+ // a new builder workspace has no origin match; choose by source bytes so it
7140
+ // inherits the nearest revision's products instead of an empty or old tree.
7141
+ const ranked = slots
7142
+ .map((slot) => {
7143
+ let changes = 0
7144
+ if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity }
7145
+ const source = path.join(slot, 'source', 'packages', path.basename(moduleRoot))
7146
+ for (const [file, contents] of inputs) {
7147
+ try {
7148
+ if (!readFileSync(path.join(source, file)).equals(contents)) changes++
7149
+ } catch (error) {
7150
+ if (!vanished(error)) throw error
7151
+ changes++
7152
+ }
7153
+ }
7154
+ return { slot, changes }
7155
+ })
7156
+ .sort(
7157
+ (left, right) =>
7158
+ left.changes - right.changes ||
7159
+ Number(own(right.slot)) - Number(own(left.slot)) ||
7160
+ (built.get(right.slot) ?? 0) - (built.get(left.slot) ?? 0),
7161
+ )
7162
+ for (const { slot, changes } of ranked) {
7155
7163
  const result = await withSwiftRootLock(
7156
7164
  slot,
7157
- async (lease) => ({ value: await run(slot)(lease) }),
7165
+ async (lease) => {
7166
+ console.error(
7167
+ `[swift-framework-cache] ${path.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`,
7168
+ )
7169
+ return { value: await run(slot)(lease) }
7170
+ },
7158
7171
  signal,
7159
7172
  false,
7160
7173
  )
7161
7174
  if (result) return result.value
7162
7175
  }
7163
- return withSwiftRootLock(oldest[0]!, run(oldest[0]!), signal)
7176
+ const nearest = ranked[0]!.slot
7177
+ return withSwiftRootLock(nearest, run(nearest), signal)
7164
7178
  }
7165
7179
 
7166
7180
  // copies the files of `source` that differ into `target` and removes the rest of
@@ -366,7 +366,7 @@ const headerFiles = (dir: string): string[] =>
366
366
  */
367
367
  export function moduleMapHeaders(
368
368
  modulemap: string,
369
- directoryHeaders: readonly string[] = [],
369
+ directoryHeaders: readonly string[],
370
370
  ): string[] {
371
371
  const tokens = moduleMapTokens(fs.readFileSync(modulemap, 'utf8'))
372
372
  // each open brace holds its module index, or -1 for any other block
@@ -503,7 +503,11 @@ function stageVendorFrameworks(dir: string, stage: string): string {
503
503
  fs.mkdirSync(target, { recursive: true })
504
504
  for (const child of fs.readdirSync(source)) {
505
505
  if (child !== 'Modules') {
506
- fs.symlinkSync(path.join(source, child), path.join(target, child))
506
+ if (child === 'Headers')
507
+ fs.cpSync(path.join(source, child), path.join(target, child), {
508
+ recursive: true,
509
+ })
510
+ else fs.symlinkSync(path.join(source, child), path.join(target, child))
507
511
  continue
508
512
  }
509
513
  for (const file of fs.readdirSync(path.join(source, child), {
@@ -1364,7 +1368,9 @@ function protocolProperties(
1364
1368
  // the module's own roots first: a defining header may rely on the
1365
1369
  // declarations its umbrella imports before it, as NS_ENUM does
1366
1370
  [
1367
- ...moduleMapHeaders(surface.modulemap).map((file) => path.join(headersDir, file)),
1371
+ ...moduleMapHeaders(surface.modulemap, headerFiles(headersDir)).map((file) =>
1372
+ path.join(headersDir, file),
1373
+ ),
1368
1374
  ...candidates.map(({ file }) => file),
1369
1375
  ]
1370
1376
  .map((file) => `#import ${JSON.stringify(file)}\n`)
@@ -1450,7 +1456,7 @@ function objcDeclarationAST(
1450
1456
  originalFlags: readonly string[],
1451
1457
  target: string,
1452
1458
  ): unknown {
1453
- const roots = moduleMapHeaders(surface.modulemap)
1459
+ const roots = moduleMapHeaders(surface.modulemap, headerFiles(surface.headers))
1454
1460
  const probe = path.join(work, 'declarations.m')
1455
1461
  fs.writeFileSync(
1456
1462
  probe,
@@ -1573,7 +1579,7 @@ function enumValues(
1573
1579
  if (wanted.size === 0) return values
1574
1580
  // the module's own headers compile as part of the file, so their
1575
1581
  // declarations are the file's, where the AST dump reaches them
1576
- const roots = moduleMapHeaders(surface.modulemap)
1582
+ const roots = moduleMapHeaders(surface.modulemap, headerFiles(surface.headers))
1577
1583
  const probe = path.join(work, 'values.m')
1578
1584
  fs.writeFileSync(
1579
1585
  probe,
@@ -815,50 +815,62 @@ export function resolveSwiftPackages(options: {
815
815
  return pkg
816
816
  }
817
817
  // linked source owns its regular targets and their source dependencies.
818
- // binary and placeholder targets retain their existing providers.
818
+ // matching binaries and placeholder targets retain their existing providers.
819
819
  const claimed = new Set<string>()
820
- const claimTarget = (pkg: LoadedPackage, name: string): boolean => {
820
+ const claimDependencies = (
821
+ pkg: LoadedPackage,
822
+ target: SwiftManifestTarget,
823
+ binaryOnly = false,
824
+ ): boolean =>
825
+ target.dependencies
826
+ .map((dependency) => {
827
+ if (dependency.kind === 'target')
828
+ return claimTarget(pkg, dependency.name, binaryOnly)
829
+ const nested = dependencyPackage(pkg, dependency)
830
+ return nested && typeof nested !== 'string'
831
+ ? claimProduct(nested, dependency.name, binaryOnly)
832
+ : false
833
+ })
834
+ .some(Boolean)
835
+ const claimTarget = (pkg: LoadedPackage, name: string, binaryOnly = false): boolean => {
821
836
  const key = `${pkg.manifest.dir}\0${name}`
822
- if (claimed.has(key)) return true
837
+ if (!binaryOnly && claimed.has(key)) return true
823
838
  const target = pkg.manifest.targets.get(name)
839
+ if (target?.type === 'binary') {
840
+ const changed =
841
+ !options.standinTargets?.has(name) && shippedBinaryDiffers(name, target.checksum)
842
+ if (changed) providedTargets.delete(name)
843
+ return changed
844
+ }
824
845
  if (!target || target.type !== 'regular' || placeholderPackage(pkg)) return false
825
- // a wrapper target with empty sources only groups binary dependencies,
826
- // which the module peach ships already covers
846
+ // empty wrapper targets still carry their binary dependencies.
827
847
  const files = swiftTargetFiles(pkg.manifest, target)
828
848
  if (
849
+ binaryOnly ||
829
850
  files.every(
830
851
  (file) => file.endsWith('.swift') && fs.readFileSync(file, 'utf8').trim() === '',
831
852
  )
832
- )
833
- return false
853
+ ) {
854
+ const changed = claimDependencies(pkg, target, true)
855
+ if (changed) providedTargets.delete(name)
856
+ return changed
857
+ }
834
858
  // a target whose headers stand in for its unlowered sources stays with the stand-in
835
859
  if (unloweredSources(files, target, portableAssembly)) return false
836
860
  claimed.add(key)
837
861
  providedTargets.delete(name)
838
- for (const dependency of target.dependencies) {
839
- if (dependency.kind === 'target') claimTarget(pkg, dependency.name)
840
- else {
841
- const nested = dependencyPackage(pkg, dependency)
842
- if (nested && typeof nested !== 'string') claimProduct(nested, dependency.name)
843
- }
844
- }
862
+ claimDependencies(pkg, target)
845
863
  return true
846
864
  }
847
- const claimProduct = (pkg: LoadedPackage, product: string): void => {
865
+ const claimProduct = (
866
+ pkg: LoadedPackage,
867
+ product: string,
868
+ binaryOnly = false,
869
+ ): boolean => {
848
870
  const roots = pkg.manifest.products.get(product)?.targets ?? []
849
- for (const root of roots) {
850
- const target = pkg.manifest.targets.get(root)
851
- if (
852
- target?.type === 'binary' &&
853
- !options.standinTargets?.has(root) &&
854
- shippedBinaryDiffers(root, target.checksum)
855
- ) {
856
- providedTargets.delete(root)
857
- providedProducts.delete(product)
858
- }
859
- }
860
- if (roots.map((name) => claimTarget(pkg, name)).some(Boolean))
861
- providedProducts.delete(product)
871
+ const changed = roots.map((name) => claimTarget(pkg, name, binaryOnly)).some(Boolean)
872
+ if (changed) providedProducts.delete(product)
873
+ return changed
862
874
  }
863
875
  for (const { product, source } of products) {
864
876
  if (source.kind === 'remote' && !options.provided) continue
@@ -4,9 +4,13 @@ import archives from './swift-shipped-archives.json' with { type: 'json' }
4
4
  // (scripts/debug/swift-binary-standin-generate.ts writes the table). a package pinning a
5
5
  // different archive gets its own stand-in, since the shipped module declares another version's API.
6
6
  const SHIPPED_ARCHIVES = new Map<string, string>(Object.entries(archives))
7
+ const SHIPPED_CHECKSUMS = new Set(SHIPPED_ARCHIVES.values())
7
8
 
8
- /** true when `target` is a binary peach ships and the app's pinned archive is another one. */
9
+ /** compare the archive even when a package target aliases its module name. */
9
10
  export function shippedBinaryDiffers(target: string, checksum: string | null): boolean {
10
11
  const shipped = SHIPPED_ARCHIVES.get(target)
11
- return shipped !== undefined && checksum !== null && checksum !== shipped
12
+ return (
13
+ checksum !== null &&
14
+ (shipped !== undefined ? checksum !== shipped : !SHIPPED_CHECKSUMS.has(checksum))
15
+ )
12
16
  }
@@ -38,7 +38,7 @@ export type GraphRelationship = {
38
38
  source: string
39
39
  target: string
40
40
  targetFallback?: string
41
- swiftConstraints?: { kind: string; lhs: string; rhs: string }[]
41
+ swiftConstraints?: { kind: string; lhs: string; rhs: string; rhsPrecise?: string }[]
42
42
  sourceOrigin?: { identifier: string; displayName: string }
43
43
  }
44
44
  export type SymbolGraph = {
@@ -668,7 +668,18 @@ export function emitSwiftStandin(
668
668
  options: StandinOptions,
669
669
  ): StandinResult {
670
670
  const imported = new Set(options.imports)
671
- const importedTypeModules = options.importedTypeModules ?? new Map<string, string>()
671
+ const importedTypeModules = new Map(options.importedTypeModules)
672
+ // extension targets retain clang ownership that signature fragments omit.
673
+ for (const graph of sourceGraphs)
674
+ for (const edge of graph.relationships) {
675
+ if (!/^c:objc\((?:cs|pl)\)/.test(edge.target)) continue
676
+ const qualified = /^(\w+)\.\w+$/.exec(edge.targetFallback ?? '')
677
+ if (qualified)
678
+ importedTypeModules.set(
679
+ edge.target,
680
+ qualified[1] === 'ObjectiveC' ? 'Foundation' : qualified[1]!,
681
+ )
682
+ }
672
683
  const ownIds = new Set(
673
684
  sourceGraphs.flatMap((graph) =>
674
685
  graph.symbols.map((symbol) => symbol.identifier.precise),
@@ -733,11 +744,18 @@ export function emitSwiftStandin(
733
744
  const superclass = new Map<string, string>()
734
745
  const superId = new Map<string, string>()
735
746
  const conforms = new Map<string, string[]>()
736
- const conditional: { source: GraphSymbol; name: string; where: string }[] = []
747
+ const conditional: {
748
+ source: GraphSymbol
749
+ name: string
750
+ constraints: NonNullable<GraphRelationship['swiftConstraints']>
751
+ }[] = []
737
752
  const conformanceTargets = new Map<string, Map<string, string>>()
738
753
  const objectConformers = new Set<string>()
739
754
  const conformIds = new Map<string, string[]>()
740
- const protocolParents = new Map<string, string[]>()
755
+ const protocolParents = new Map<string, string[]>([
756
+ ['s:SH', ['s:SQ']],
757
+ ['s:SL', ['s:SQ']],
758
+ ])
741
759
  const requirement = new Set<string>()
742
760
  const optional = new Set<string>()
743
761
  const overrides = new Set<string>()
@@ -819,11 +837,7 @@ export function emitSwiftStandin(
819
837
  conditional.push({
820
838
  source,
821
839
  name,
822
- where: edge.swiftConstraints
823
- .map(({ kind, lhs, rhs }) =>
824
- kind === 'sameType' ? `${lhs} == ${rhs}` : `${lhs}: ${rhs}`,
825
- )
826
- .join(', '),
840
+ constraints: edge.swiftConstraints,
827
841
  })
828
842
  } else if (name) {
829
843
  conforms.set(edge.source, [...(conforms.get(edge.source) ?? []), name])
@@ -1399,7 +1413,7 @@ export function emitSwiftStandin(
1399
1413
  return
1400
1414
  }
1401
1415
  emit(
1402
- `${head}${computed} { get${effects} { ${getter} }${settable && !effects ? ` ${parsed.nonmutating ? 'nonmutating ' : ''}set { ${measured?.set ?? (options.inert ? '' : trap(path))} }` : ''} }`,
1416
+ `${head.replace(/@NSCopying\b\s*/g, '')}${computed} { get${effects} { ${getter} }${settable && !effects ? ` ${parsed.nonmutating ? 'nonmutating ' : ''}set { ${measured?.set ?? (options.inert ? '' : trap(path))} }` : ''} }`,
1403
1417
  )
1404
1418
  return
1405
1419
  }
@@ -2099,8 +2113,48 @@ export function emitSwiftStandin(
2099
2113
  emitWitness(witness.member, ' ', witness.path)
2100
2114
  emit('}')
2101
2115
  }
2102
- for (const { source, name, where } of conditional)
2116
+ const refines = (child: string, parent: string, seen = new Set<string>()): boolean => {
2117
+ if (child === parent) return true
2118
+ if (seen.has(child)) return false
2119
+ seen.add(child)
2120
+ return (protocolParents.get(child) ?? []).some((id) => refines(id, parent, seen))
2121
+ }
2122
+ const implies = (
2123
+ stronger: NonNullable<GraphRelationship['swiftConstraints']>,
2124
+ weaker: NonNullable<GraphRelationship['swiftConstraints']>,
2125
+ ) =>
2126
+ weaker.every((wanted) =>
2127
+ stronger.some(
2128
+ (given) =>
2129
+ given.kind === wanted.kind &&
2130
+ given.lhs === wanted.lhs &&
2131
+ (given.rhs === wanted.rhs ||
2132
+ (given.kind === 'conformance' &&
2133
+ given.rhsPrecise !== undefined &&
2134
+ wanted.rhsPrecise !== undefined &&
2135
+ refines(given.rhsPrecise, wanted.rhsPrecise))),
2136
+ ),
2137
+ )
2138
+ for (const [index, { source, name, constraints }] of conditional.entries()) {
2139
+ // graphs repeat inherited conformances under stronger conditional bounds.
2140
+ if (
2141
+ conditional.some(
2142
+ (other, at) =>
2143
+ at !== index &&
2144
+ other.source === source &&
2145
+ other.name === name &&
2146
+ implies(constraints, other.constraints) &&
2147
+ (at < index || !implies(other.constraints, constraints)),
2148
+ )
2149
+ )
2150
+ continue
2151
+ const where = constraints
2152
+ .map(({ kind, lhs, rhs }) =>
2153
+ kind === 'sameType' ? `${lhs} == ${rhs}` : `${lhs}: ${rhs}`,
2154
+ )
2155
+ .join(', ')
2103
2156
  emitAt(pathOf(source), `extension ${pathOf(source)}: ${name} where ${where} {}`)
2157
+ }
2104
2158
  const banner = [
2105
2159
  ...(options.placeholder
2106
2160
  ? [
@@ -62,6 +62,7 @@ import {
62
62
  } from './swift-package'
63
63
  import { swiftBinaryOnDisk, type SwiftPackageBinary } from './swift-packages'
64
64
  import { swiftSharedSdkRoot } from './swift-shared-sdk'
65
+ import { shippedBinaryDiffers } from './swift-shipped-binaries'
65
66
  import { withBuiltinStandinBehavior } from './swift-standin-builtin-behavior'
66
67
  import { STANDIN_SOURCE_DIGEST, standinSourceDigest } from './swift-standin-digest'
67
68
  import {
@@ -117,6 +118,7 @@ interface Toolchain {
117
118
  release: string
118
119
  /** modules generated earlier in this dependency closure. */
119
120
  standinModules?: string
121
+ standinIncludes?: readonly string[]
120
122
  }
121
123
 
122
124
  interface NativeFrameworkInputs {
@@ -1525,6 +1527,7 @@ function externalConformances(module: string, interfaceText: string): string {
1525
1527
  .split(',')
1526
1528
  .map((name) => name.trim())
1527
1529
  .filter((name) => name.startsWith(`${module}.`))
1530
+ .map((name) => name.slice(module.length + 1))
1528
1531
  const type = extended!.startsWith('Swift.')
1529
1532
  ? extended!
1530
1533
  : extended!.split('.').slice(1).join('.')
@@ -1568,8 +1571,9 @@ function wasmFlags(toolchain: Toolchain, imports: string[]): string[] {
1568
1571
  // submodules (os.log), so a vendor interface naming one resolves as the
1569
1572
  // ios sdk resolves it; a second `os` map on the path is a redefinition.
1570
1573
  ...cFlags.flatMap((flag) => ['-Xcc', flag]),
1571
- ...peachModuleDirs(toolchain, imports, sdkIncludes).flatMap((dir) => ['-I', dir]),
1572
1574
  ...(toolchain.standinModules ? ['-I', toolchain.standinModules] : []),
1575
+ ...(toolchain.standinIncludes ?? []).flatMap((dir) => ['-I', dir, '-F', dir]),
1576
+ ...peachModuleDirs(toolchain, imports, sdkIncludes).flatMap((dir) => ['-I', dir]),
1573
1577
  ]
1574
1578
  }
1575
1579
 
@@ -3386,7 +3390,11 @@ async function buildStandins(
3386
3390
  provided: ReadonlySet<string>,
3387
3391
  behavior: SwiftStandinBehaviors,
3388
3392
  ): Promise<SwiftStandins> {
3389
- const requested = binaries.filter((binary) => !provided.has(binary.target))
3393
+ const requested = binaries.filter(
3394
+ (binary) =>
3395
+ !provided.has(binary.target) ||
3396
+ shippedBinaryDiffers(binary.target, binary.checksum),
3397
+ )
3390
3398
  if (requested.length === 0) return { standins: [], gaps: new Map() }
3391
3399
  if (
3392
3400
  process.platform === 'darwin' &&
@@ -3409,6 +3417,7 @@ async function buildStandins(
3409
3417
  )
3410
3418
  // the modules each binary's swift interfaces import
3411
3419
  const interfaceImports = new Map<SwiftPackageBinary, Set<string>>()
3420
+ const retained = new Set(provided)
3412
3421
  for (const binary of binaries) {
3413
3422
  const swiftSources = binary.placeholder ?? binary.moduleSources
3414
3423
  if (swiftSources !== undefined) {
@@ -3439,8 +3448,9 @@ async function buildStandins(
3439
3448
  interfaceImports.set(binary, imports)
3440
3449
  for (const surface of surfaces(artifact.dir, binary.target)) {
3441
3450
  byModule.set(surface.module, binary)
3451
+ if (shippedBinaryDiffers(surface.module, binary.checksum))
3452
+ retained.delete(surface.module)
3442
3453
  for (const module of surfaceImports(surface)) imports.add(module)
3443
- if (surface.kind === 'c') continue
3444
3454
  if (surface.kind === 'objc' || surface.kind === 'mixed')
3445
3455
  frameworkSurfaces.set(surface.module, surface)
3446
3456
  if (
@@ -3458,7 +3468,13 @@ async function buildStandins(
3458
3468
  // the target reports its artifact gap when visited below.
3459
3469
  }
3460
3470
  }
3461
- const generatedToolchain = { ...toolchain, standinModules: modules }
3471
+ provided = retained
3472
+ const includes: string[] = []
3473
+ const generatedToolchain = {
3474
+ ...toolchain,
3475
+ standinModules: modules,
3476
+ standinIncludes: includes,
3477
+ }
3462
3478
  // the iOS simulator interfaces of the source modules binaries import
3463
3479
  const sourceFrameworks = path.join(modules, 'ios-frameworks')
3464
3480
  fs.mkdirSync(sourceFrameworks)
@@ -3544,6 +3560,16 @@ async function buildStandins(
3544
3560
  // that the app links, including on cache hits.
3545
3561
  if (prerequisites.has(standin.module)) {
3546
3562
  const source = standin.files[`${standin.module}.swift`]
3563
+ if (source === undefined) {
3564
+ const dir = path.join(modules, standin.module, 'include')
3565
+ for (const [name, text] of Object.entries(standin.files)) {
3566
+ if (!name.startsWith('include/')) continue
3567
+ const file = path.join(modules, standin.module, name)
3568
+ fs.mkdirSync(path.dirname(file), { recursive: true })
3569
+ fs.writeFileSync(file, text)
3570
+ }
3571
+ includes.push(dir)
3572
+ }
3547
3573
  if (source !== undefined) {
3548
3574
  const file = path.join(modules, `${standin.module}.swift`)
3549
3575
  fs.writeFileSync(file, source)