peachsim 0.1.2767 → 0.1.2769

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 (132) 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 +351 -77
  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-RDD3HI5C.mjs → acorn-GNB3RJH7.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-BY3E6CUM.mjs → chunk-3WG4L5YK.mjs} +372 -106
  28. package/dist-lib/esm-chunks/{chunk-YX56RZ26.mjs → chunk-3ZKE33FC.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-555YCJDH.mjs → chunk-4GHACZYW.mjs} +5 -5
  30. package/dist-lib/esm-chunks/{chunk-CBAMX2H3.mjs → chunk-4IJOKKT2.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-GKHSLOW6.mjs → chunk-53WFZATQ.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-H4KLP3QO.mjs → chunk-57JPQBQL.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-PDMYH4NT.mjs → chunk-ALLMPTWQ.mjs} +2 -2
  34. package/dist-lib/esm-chunks/{chunk-UGTY5DQQ.mjs → chunk-BFLH7V77.mjs} +6 -6
  35. package/dist-lib/esm-chunks/{chunk-LO5KFOI3.mjs → chunk-BP7TLKZD.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-WJKKLL2J.mjs → chunk-ETXC2XBY.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-C6YNOAXM.mjs → chunk-GHJPVQ3A.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-D6JZSVL7.mjs → chunk-L2U2IEHU.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-7G6WGJWR.mjs → chunk-MBLYJ74N.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-P2KN5U5O.mjs → chunk-MGIODRG3.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-XPSICY6F.mjs → chunk-OG5C2CN2.mjs} +3 -3
  42. package/dist-lib/esm-chunks/{chunk-4W67A7NE.mjs → chunk-OPIPPBGX.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-DFK4ZVNM.mjs → chunk-TI42U3CD.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-H5C5TZNB.mjs → chunk-TJNFADI5.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-OYMWLKPN.mjs → chunk-TTVQWJGW.mjs} +4 -4
  46. package/dist-lib/esm-chunks/{chunk-7VSU2AV7.mjs → chunk-VF3CWZTM.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-AC2RBU5N.mjs → chunk-WWANYYJG.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-EJWUFWN3.mjs → chunk-XX7VUACB.mjs} +26 -13
  49. package/dist-lib/esm-chunks/{chunk-BSN5R62H.mjs → chunk-ZGNNVEWM.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-3WJRW63F.mjs → chunk-ZLYAJ4CU.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-7POGDD5P.mjs → metro-layout-parser-LT2DPN6F.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-ULD72CI5.mjs → swift-package-prebuilt-ZFFWBI33.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-VXSTLD57.mjs → swift-sdk-app-module-UZ6BZSES.mjs} +22 -17
  54. package/dist-lib/esm-chunks/{swift-sdk-image-KDJATRA6.mjs → swift-sdk-image-J2DE3SBW.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-KNBUALWN.mjs → swift-sdk-image-producer-C4U4EQRW.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +351 -77
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +351 -77
  61. package/dist-lib/host/fetch-proxy-handler.cjs +24 -20
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +1 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +85 -85
  87. package/dist-lib/public-origins-lib.json +64 -64
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +351 -77
  95. package/dist-lib/swift-compile.cjs +331 -57
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/dist-types/packages/peach-engine/src/render-worker/aux-pointer-native.d.ts +4 -0
  123. package/dist-types/packages/peach-engine/src/render-worker/auxPointerContract.d.ts +4 -0
  124. package/package.json +1 -1
  125. package/src/case-insensitive-header-overlay.ts +9 -1
  126. package/src/native-static-libraries.ts +16 -16
  127. package/src/swift-compile.ts +158 -42
  128. package/src/swift-distribution-mirror.ts +273 -10
  129. package/src/swift-objc-prebuilt.ts +10 -1
  130. package/src/swift-objc-standin.ts +6 -1
  131. package/src/swift-sdk-app-module.ts +10 -3
  132. package/src/swift-sdk-surface.ts +5 -1
@@ -1,25 +1,46 @@
1
1
  import { randomUUID } from 'node:crypto'
2
2
  import {
3
+ chmodSync,
3
4
  constants,
4
5
  copyFileSync,
5
6
  existsSync,
7
+ lstatSync,
6
8
  mkdirSync,
7
9
  readdirSync,
8
10
  readFileSync,
11
+ readlinkSync,
9
12
  renameSync,
10
13
  rmSync,
14
+ statSync,
15
+ symlinkSync,
11
16
  writeFileSync,
12
17
  } from 'node:fs'
13
18
  import path from 'node:path'
19
+ import { clearCaseInsensitiveHeaderOverlayCache } from './case-insensitive-header-overlay'
14
20
  import { isRecord } from './is-record'
15
21
  import {
16
22
  SWIFT_DISTRIBUTION_MANIFEST,
17
23
  type SwiftDistributionManifest,
18
24
  } from './swift-distribution-contract'
19
- import { SWIFT_DISTRIBUTION_MIRROR_RECORD } from './swift-shared-sdk'
25
+ import {
26
+ SWIFT_DISTRIBUTION_MIRROR_RECORD,
27
+ swiftSharedSdkViewOptions,
28
+ } from './swift-shared-sdk'
20
29
  import { isSwiftResourcePath } from './swiftContract'
30
+ import { SWIFT_WASM_TRIPLE } from './swiftTargetContract'
21
31
 
22
32
  export const SWIFT_DISTRIBUTION_MIRROR = '.peach-distribution'
33
+ export const SWIFT_SDK_MIRROR = '.peach-sdk'
34
+ export const SWIFT_SDK_MIRROR_ID = 'peach-wasm-sdk'
35
+
36
+ const SWIFT_SDK_MIRROR_RECORD = '.peach-sdk-mirror.json'
37
+ const SWIFT_SDK_MIRROR_BUNDLE = 'peach-wasm.artifactbundle'
38
+
39
+ export interface SwiftMirrorSdk {
40
+ id: string
41
+ options: string[]
42
+ toolsetChanged: boolean
43
+ }
23
44
 
24
45
  /**
25
46
  * the build root's own copy of a distribution, at one path for every
@@ -61,10 +82,239 @@ export function syncSwiftDistributionMirror(
61
82
  const partial = `${record}.${randomUUID()}`
62
83
  writeFileSync(partial, JSON.stringify(manifest.files))
63
84
  renameSync(partial, record)
85
+ if (
86
+ [...changed, ...removed].some(
87
+ (file) => !file.startsWith('lib/') && !file.startsWith('modules/'),
88
+ )
89
+ ) {
90
+ clearCaseInsensitiveHeaderOverlayCache(mirror)
91
+ clearCaseInsensitiveHeaderOverlayCache(path.join(root, SWIFT_SDK_MIRROR))
92
+ }
64
93
  }
65
94
  return mirror
66
95
  }
67
96
 
97
+ /**
98
+ * the build root's own WASI SDK view at one fixed path and SDK id across
99
+ * distribution SDK bumps. files with unchanged bytes keep their inode and
100
+ * mtime, so a WASI SDK cut that updates only Darwin/Dispatch/Foundation
101
+ * swiftmodules and static archives keeps every Clang object and build.db warm.
102
+ */
103
+ export function syncSwiftSdkMirror(
104
+ root: string,
105
+ frameworkRoot: string,
106
+ toolchainBin: string,
107
+ sourceSdkId: string,
108
+ ): SwiftMirrorSdk {
109
+ const viewOptions = swiftSharedSdkViewOptions(
110
+ frameworkRoot,
111
+ true,
112
+ toolchainBin,
113
+ sourceSdkId,
114
+ )
115
+ const sourceView = viewOptions[1]!
116
+ return syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId)
117
+ }
118
+
119
+ export function syncSwiftSdkMirrorFromView(
120
+ root: string,
121
+ frameworkRoot: string,
122
+ sourceView: string,
123
+ sourceSdkId: string,
124
+ ): SwiftMirrorSdk {
125
+ const mirror = path.join(root, SWIFT_SDK_MIRROR)
126
+ const bundle = path.join(mirror, SWIFT_SDK_MIRROR_BUNDLE)
127
+ const destTriple = path.join(bundle, 'sdk', SWIFT_WASM_TRIPLE)
128
+ const bundleInfo = path.join(bundle, 'info.json')
129
+ const recordFile = path.join(mirror, SWIFT_SDK_MIRROR_RECORD)
130
+ const options = ['--swift-sdks-path', mirror]
131
+ const previous = readSdkRecord(recordFile)
132
+ if (
133
+ previous &&
134
+ previous.sourceView === sourceView &&
135
+ previous.sourceSdkId === sourceSdkId &&
136
+ existsSync(bundleInfo) &&
137
+ existsSync(path.join(destTriple, 'swift-sdk.json'))
138
+ ) {
139
+ return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged: false }
140
+ }
141
+ const sourceTriple = resolveSdkViewTripleDir(sourceView, sourceSdkId)
142
+ if (!previous) {
143
+ rmSync(mirror, { recursive: true, force: true })
144
+ rmSync(path.join(root, '.build'), { recursive: true, force: true })
145
+ }
146
+ const changed: string[] = []
147
+ const removed: string[] = []
148
+ const distributionPrefix = `${frameworkRoot}${path.sep}`
149
+ syncSdkTree(sourceTriple, destTriple, '', distributionPrefix, changed, removed)
150
+ const infoText =
151
+ JSON.stringify(
152
+ {
153
+ artifacts: {
154
+ [SWIFT_SDK_MIRROR_ID]: {
155
+ type: 'swiftSDK',
156
+ variants: [{ path: `sdk/${SWIFT_WASM_TRIPLE}/swift-sdk.json` }],
157
+ version: '0.0.1',
158
+ },
159
+ },
160
+ schemaVersion: '1.0',
161
+ },
162
+ null,
163
+ 2,
164
+ ) + '\n'
165
+ if (!existsSync(bundleInfo) || readFileSync(bundleInfo, 'utf8') !== infoText) {
166
+ mkdirSync(bundle, { recursive: true })
167
+ const partial = `${bundleInfo}.${randomUUID()}`
168
+ writeFileSync(partial, infoText)
169
+ renameSync(partial, bundleInfo)
170
+ }
171
+ const touched = [...changed, ...removed]
172
+ const toolsetChanged =
173
+ !previous ||
174
+ touched.some(
175
+ (file) =>
176
+ file === 'toolset.json' ||
177
+ file === 'swift-sdk.json' ||
178
+ file.startsWith('swift.xctoolchain/usr/bin/'),
179
+ )
180
+ if (previous) {
181
+ if (toolsetChanged) {
182
+ rmSync(path.join(root, '.build'), { recursive: true, force: true })
183
+ } else {
184
+ const compileTouched = touched.filter(
185
+ (file) =>
186
+ !file.endsWith('.a') &&
187
+ !file.endsWith('.o') &&
188
+ !file.startsWith('rust/') &&
189
+ file !== 'runtime-products.json',
190
+ )
191
+ const headersChanged = compileTouched.some(
192
+ (file) =>
193
+ !file.endsWith('.swiftmodule') &&
194
+ !file.endsWith('.swiftdoc') &&
195
+ !file.endsWith('.swiftsourceinfo') &&
196
+ !file.endsWith('.abi.json'),
197
+ )
198
+ if (compileTouched.length > 0) {
199
+ invalidateBuildDependents(
200
+ root,
201
+ [[Buffer.from(`${escapeDepPath(destTriple)}/`), '']],
202
+ new Set(compileTouched),
203
+ headersChanged,
204
+ )
205
+ }
206
+ if (headersChanged) clearCaseInsensitiveHeaderOverlayCache(mirror)
207
+ }
208
+ } else {
209
+ clearCaseInsensitiveHeaderOverlayCache(mirror)
210
+ }
211
+ mkdirSync(mirror, { recursive: true })
212
+ const partialRecord = `${recordFile}.${randomUUID()}`
213
+ writeFileSync(partialRecord, JSON.stringify({ version: 1, sourceView, sourceSdkId }))
214
+ renameSync(partialRecord, recordFile)
215
+ return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged }
216
+ }
217
+
218
+ function readSdkRecord(
219
+ file: string,
220
+ ): { version: number; sourceView: string; sourceSdkId: string } | null {
221
+ if (!existsSync(file)) return null
222
+ const value: unknown = JSON.parse(readFileSync(file, 'utf8'))
223
+ if (
224
+ !isRecord(value) ||
225
+ value.version !== 1 ||
226
+ typeof value.sourceView !== 'string' ||
227
+ typeof value.sourceSdkId !== 'string'
228
+ )
229
+ return null
230
+ return {
231
+ version: value.version,
232
+ sourceView: value.sourceView,
233
+ sourceSdkId: value.sourceSdkId,
234
+ }
235
+ }
236
+
237
+ function resolveSdkViewTripleDir(sourceView: string, sourceSdkId: string): string {
238
+ for (const entry of readdirSync(sourceView, { withFileTypes: true })) {
239
+ if (!entry.name.endsWith('.artifactbundle')) continue
240
+ const bundleDir = path.join(sourceView, entry.name)
241
+ const infoPath = path.join(bundleDir, 'info.json')
242
+ if (!existsSync(infoPath)) continue
243
+ const info: unknown = JSON.parse(readFileSync(infoPath, 'utf8'))
244
+ if (!isRecord(info) || !isRecord(info.artifacts)) continue
245
+ const artifact = info.artifacts[sourceSdkId]
246
+ if (!isRecord(artifact) || !Array.isArray(artifact.variants)) continue
247
+ const first = artifact.variants[0]
248
+ if (!isRecord(first) || typeof first.path !== 'string') continue
249
+ return path.dirname(path.join(bundleDir, first.path))
250
+ }
251
+ throw new Error(`Swift SDK ${sourceSdkId} not found in view ${sourceView}`)
252
+ }
253
+
254
+ function collectRemovedFiles(dir: string, prefix: string, out: string[]): void {
255
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
256
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name
257
+ const full = path.join(dir, entry.name)
258
+ if (entry.isDirectory()) collectRemovedFiles(full, rel, out)
259
+ else out.push(rel)
260
+ }
261
+ }
262
+
263
+ function syncSdkTree(
264
+ sourceDir: string,
265
+ destDir: string,
266
+ prefix: string,
267
+ distributionPrefix: string,
268
+ changed: string[],
269
+ removed: string[],
270
+ ): void {
271
+ mkdirSync(destDir, { recursive: true })
272
+ const wanted = new Set<string>()
273
+ for (const entry of readdirSync(sourceDir, { withFileTypes: true })) {
274
+ wanted.add(entry.name)
275
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name
276
+ const src = path.join(sourceDir, entry.name)
277
+ const dest = path.join(destDir, entry.name)
278
+ const destLstat = lstatSync(dest, { throwIfNoEntry: false })
279
+ if (entry.isSymbolicLink()) {
280
+ const target = readlinkSync(src)
281
+ if (target.startsWith(distributionPrefix)) {
282
+ if (destLstat?.isSymbolicLink() && readlinkSync(dest) === target) continue
283
+ if (destLstat) rmSync(dest, { recursive: true, force: true })
284
+ symlinkSync(target, dest)
285
+ changed.push(rel)
286
+ continue
287
+ }
288
+ }
289
+ const srcStat = statSync(src, { throwIfNoEntry: false })
290
+ if (!srcStat) continue
291
+ if (srcStat.isDirectory()) {
292
+ if (destLstat && (!destLstat.isDirectory() || destLstat.isSymbolicLink()))
293
+ rmSync(dest, { recursive: true, force: true })
294
+ syncSdkTree(src, dest, rel, distributionPrefix, changed, removed)
295
+ continue
296
+ }
297
+ if (
298
+ destLstat?.isFile() &&
299
+ !destLstat.isSymbolicLink() &&
300
+ destLstat.size === srcStat.size &&
301
+ readFileSync(src).equals(readFileSync(dest))
302
+ )
303
+ continue
304
+ if (destLstat?.isDirectory()) rmSync(dest, { recursive: true, force: true })
305
+ place(src, dest, (srcStat.mode & 0o111) !== 0 ? srcStat.mode & 0o777 : undefined)
306
+ changed.push(rel)
307
+ }
308
+ for (const entry of readdirSync(destDir, { withFileTypes: true })) {
309
+ if (wanted.has(entry.name)) continue
310
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name
311
+ const dest = path.join(destDir, entry.name)
312
+ if (entry.isDirectory()) collectRemovedFiles(dest, rel, removed)
313
+ else removed.push(rel)
314
+ rmSync(dest, { recursive: true, force: true })
315
+ }
316
+ }
317
+
68
318
  function readRecord(file: string): Record<string, string> | null {
69
319
  if (!existsSync(file)) return null
70
320
  const value: unknown = JSON.parse(readFileSync(file, 'utf8'))
@@ -77,13 +327,20 @@ function readRecord(file: string): Record<string, string> | null {
77
327
  return files
78
328
  }
79
329
 
80
- function place(from: string, to: string): void {
330
+ function place(from: string, to: string, mode?: number): void {
81
331
  mkdirSync(path.dirname(to), { recursive: true })
82
332
  const partial = `${to}.${randomUUID()}`
83
333
  copyFileSync(from, partial, constants.COPYFILE_FICLONE)
334
+ if (mode !== undefined) chmodSync(partial, mode)
84
335
  renameSync(partial, to)
85
336
  }
86
337
 
338
+ function escapeDepPath(directory: string): string {
339
+ return directory.replace(/[\\ #$]/g, (character) =>
340
+ character === '$' ? '$$' : `\\${character}`,
341
+ )
342
+ }
343
+
87
344
  function invalidateDependents(root: string, mirror: string, files: string[]): void {
88
345
  // objects only reach the link
89
346
  const read = new Set(files.filter((file) => !file.startsWith('lib/')))
@@ -91,14 +348,24 @@ function invalidateDependents(root: string, mirror: string, files: string[]): vo
91
348
  // compiles name a distribution file under the mirror, and an sdk header
92
349
  // through the sdk view's darwin tree; another darwin tree's file of the same
93
350
  // name can over-match, which only rebuilds.
94
- const escapedMirror = mirror.replace(/[\\ #$]/g, (character) =>
95
- character === '$' ? '$$' : `\\${character}`,
96
- )
97
351
  const spellings: [prefix: Buffer, base: string][] = [
98
- [Buffer.from(`${escapedMirror}/`), ''],
352
+ [Buffer.from(`${escapeDepPath(mirror)}/`), ''],
99
353
  ]
100
354
  if (files.some((file) => file.startsWith('sdk/ios/')))
101
355
  spellings.push([Buffer.from('/darwin/'), 'sdk/ios/'])
356
+ // clang validates neither system headers nor the modules built from them
357
+ const headersChanged = files.some(
358
+ (file) => !file.startsWith('lib/') && !file.startsWith('modules/'),
359
+ )
360
+ invalidateBuildDependents(root, spellings, read, headersChanged)
361
+ }
362
+
363
+ function invalidateBuildDependents(
364
+ root: string,
365
+ spellings: readonly [prefix: Buffer, base: string][],
366
+ read: ReadonlySet<string>,
367
+ headersChanged: boolean,
368
+ ): void {
102
369
  const names = (text: Buffer) =>
103
370
  spellings.some(([prefix, base]) => {
104
371
  let end = 0
@@ -114,10 +381,6 @@ function invalidateDependents(root: string, mirror: string, files: string[]): vo
114
381
  })
115
382
  const scratch = path.join(root, '.build')
116
383
  if (!existsSync(scratch)) return
117
- // clang validates neither system headers nor the modules built from them
118
- const headersChanged = files.some(
119
- (file) => !file.startsWith('lib/') && !file.startsWith('modules/'),
120
- )
121
384
  for (const triple of readdirSync(scratch, { withFileTypes: true })) {
122
385
  const products = path.join(scratch, triple.name, 'release')
123
386
  if (!triple.isDirectory() || !existsSync(products)) continue
@@ -8,7 +8,9 @@ import {
8
8
  } from '../cli/internal-child-contract'
9
9
  import { rnxSelfInvocation } from '../cli/self-invocation'
10
10
  import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
11
+ import { SWIFT_SDK_MIRROR } from './swift-distribution-mirror'
11
12
  import { swiftObjCPrebuiltPackages } from './swift-objc-prebuilt-catalog'
13
+ import { SWIFT_SDK_HEADER_CASE_OVERLAY } from './swift-objc-standin'
12
14
  import { swiftCacheDir } from './swift-toolchain'
13
15
 
14
16
  export const SWIFT_OBJC_PREBUILT_OBJECT = 'unit.o'
@@ -136,6 +138,11 @@ export function runSwiftObjCPrebuiltCompiler([
136
138
  JSON.stringify(normalize(file)),
137
139
  )
138
140
  const sdkCaseOverlay = path.join(swiftCacheDir(), 'swift-header-case') + path.sep
141
+ const mirroredSdkCaseOverlay = path.join(
142
+ root,
143
+ SWIFT_SDK_MIRROR,
144
+ SWIFT_SDK_HEADER_CASE_OVERLAY,
145
+ )
139
146
  const xcodeCaseOverlay = path.join(
140
147
  root,
141
148
  '.build',
@@ -180,7 +187,9 @@ export function runSwiftObjCPrebuiltCompiler([
180
187
  commandFlags.map((arg, index) => {
181
188
  if (
182
189
  commandFlags[index - 1] === '-ivfsoverlay' &&
183
- (arg.startsWith(sdkCaseOverlay) || arg.startsWith(xcodeCaseOverlay))
190
+ (arg.startsWith(sdkCaseOverlay) ||
191
+ arg === mirroredSdkCaseOverlay ||
192
+ arg.startsWith(xcodeCaseOverlay))
184
193
  ) {
185
194
  const overlay = normalizeQuotedPaths(fs.readFileSync(arg, 'utf8'))
186
195
  return createHash('sha256').update(overlay).digest('hex')
@@ -291,6 +291,8 @@ export function materializeObjcSdk(cacheDir: string): string {
291
291
  return sdk
292
292
  }
293
293
 
294
+ export const SWIFT_SDK_HEADER_CASE_OVERLAY = 'sdk-header-case.yaml'
295
+
294
296
  /** the libc intake of every original c and objective-c unit over the sdk at
295
297
  * `headers`: the iOS platform predefines for its deployment minimum, the
296
298
  * installed libc's emulated surfaces that every app links, the sdk
@@ -300,15 +302,18 @@ export function objcSdkIntakeFlags(
300
302
  headers: string,
301
303
  toolchainBin: string,
302
304
  minimum: number,
305
+ overlayDirectory?: string,
303
306
  ): string[] {
304
307
  const caseOverlay = caseInsensitiveHeaderOverlay(
305
- path.join(swiftCacheDir(), 'swift-header-case'),
308
+ overlayDirectory ?? path.join(swiftCacheDir(), 'swift-header-case'),
306
309
  [
307
310
  path.join(headers, 'System/Library/Frameworks'),
308
311
  path.join(headers, 'wasm/include'),
309
312
  path.join(headers, 'wasm/intrinsics'),
310
313
  path.join(headers, 'usr/include'),
311
314
  ],
315
+ undefined,
316
+ overlayDirectory ? SWIFT_SDK_HEADER_CASE_OVERLAY : undefined,
312
317
  )
313
318
  return [
314
319
  ...swiftObjCPlatformFlags(toolchainBin, minimum),
@@ -31,6 +31,7 @@ import {
31
31
  NATIVE_SDK_IMPORT_MODULE,
32
32
  NATIVE_SDK_THUNK_SECTION,
33
33
  } from '../../peach-kit/src/nativeWasmContract'
34
+ import { SWIFT_DISTRIBUTION_MIRROR, SWIFT_SDK_MIRROR } from './swift-distribution-mirror'
34
35
  import { guestLazyExports, placeGuestLazyFunctions } from './swift-guest-dyld-functions'
35
36
  import { guestWasmDataSegments, type GuestLinkedSpan } from './swift-guest-linked-spans'
36
37
  import { projectOutputFile, type SwiftProjectUser } from './swift-project-user'
@@ -243,9 +244,15 @@ export function swiftAppModuleInputs(
243
244
  buildRoot: string,
244
245
  sdkLibraries: readonly string[],
245
246
  ): string[] {
246
- const owned = (token: string) =>
247
- path.resolve(token).startsWith(`${buildRoot}/`) &&
248
- (!token.includes('/.peach-pruned-objs/') || token.endsWith('/swiftrt-patched.o'))
247
+ const owned = (token: string) => {
248
+ const resolved = path.resolve(token)
249
+ return (
250
+ resolved.startsWith(`${buildRoot}/`) &&
251
+ !resolved.startsWith(`${buildRoot}/${SWIFT_DISTRIBUTION_MIRROR}/`) &&
252
+ !resolved.startsWith(`${buildRoot}/${SWIFT_SDK_MIRROR}/`) &&
253
+ (!token.includes('/.peach-pruned-objs/') || token.endsWith('/swiftrt-patched.o'))
254
+ )
255
+ }
249
256
  const inputs: string[] = []
250
257
  for (const [index, token] of tokens.entries()) {
251
258
  if (token === '--start-lib') inputs.push(token)
@@ -920,12 +920,17 @@ const sdkPaths = new Map<
920
920
  }
921
921
  >()
922
922
 
923
+ export function clearSwiftSdkPathsCache(sdkDir: string): void {
924
+ for (const key of sdkPaths.keys()) if (key.includes(sdkDir)) sdkPaths.delete(key)
925
+ }
926
+
923
927
  /** the wasm SDK's sysroot, swift resource directory, and clang intake.
924
928
  * raw swiftc does not read the toolset, so stand-in compiles pass cFlags. */
925
929
  export function swiftSdkPaths(
926
930
  moduleRoot: string,
927
931
  toolchainBin: string,
928
932
  options = swiftCompileSdkOptions(moduleRoot, toolchainBin),
933
+ sdk = swiftModuleSdk(moduleRoot).wasmSdkId,
929
934
  ): {
930
935
  sysroot: string
931
936
  darwin: string
@@ -933,7 +938,6 @@ export function swiftSdkPaths(
933
938
  frameworks: string[]
934
939
  cFlags: string[]
935
940
  } {
936
- const sdk = swiftModuleSdk(moduleRoot).wasmSdkId
937
941
  const key = JSON.stringify([toolchainBin, sdk, options])
938
942
  const cached = sdkPaths.get(key)
939
943
  if (cached) return cached