peachsim 0.1.1808 → 0.1.1811

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 (229) hide show
  1. package/README.md +4 -2
  2. package/cli/app-bundle-resources.ts +15 -2
  3. package/cli/cloud-box-artifact.ts +115 -0
  4. package/cli/cloud-client.ts +95 -53
  5. package/cli/cloud-dispatch.ts +4 -4
  6. package/cli/cloud-session.ts +60 -22
  7. package/cli/commands/box.ts +8 -2
  8. package/cli/commands/compat.ts +7 -4
  9. package/cli/commands/control.ts +60 -3
  10. package/cli/commands/coverage.ts +14 -4
  11. package/cli/commands/daemon.ts +41 -0
  12. package/cli/commands/no-bridge-hint.ts +9 -0
  13. package/cli/commands/package.ts +31 -56
  14. package/cli/commands/platform.ts +70 -52
  15. package/cli/commands/preview.ts +73 -24
  16. package/cli/commands/record.ts +10 -2
  17. package/cli/commands/screenshot.ts +17 -60
  18. package/cli/commands/setup.ts +3 -1
  19. package/cli/commands/three-mode.ts +22 -12
  20. package/cli/commands/upload.ts +2 -1
  21. package/cli/desktop-companion.ts +6 -1
  22. package/cli/drivers/desktop.ts +4 -1
  23. package/cli/main.ts +12 -2
  24. package/cli/metro-bundle-assets.ts +14 -4
  25. package/cli/outbound-endpoints.ts +7 -3
  26. package/cli/output-redaction.ts +38 -0
  27. package/cli/privacy.ts +2 -2
  28. package/cli/recording-access.ts +5 -0
  29. package/cli/remote-project-bundle.ts +83 -0
  30. package/cli/shell-init.ts +7 -11
  31. package/cli/telemetry.ts +41 -4
  32. package/cli/usage-error.ts +3 -0
  33. package/cli/ws-bridge.ts +42 -6
  34. package/dist-lib/agent-daemon-client.cjs +1 -1
  35. package/dist-lib/agent-events.cjs +1 -1
  36. package/dist-lib/attached-projects.cjs +1 -1
  37. package/dist-lib/auth/shared-session.cjs +1 -1
  38. package/dist-lib/backend-origin.cjs +1 -1
  39. package/dist-lib/beta.cjs +1 -1
  40. package/dist-lib/beta.mjs +1 -1
  41. package/dist-lib/bridge-constants.cjs +1 -1
  42. package/dist-lib/bridge-contract-input.cjs +1 -1
  43. package/dist-lib/bridge-contract-input.mjs +1 -1
  44. package/dist-lib/bridge-contract.cjs +1 -1
  45. package/dist-lib/bridge-contract.mjs +1 -1
  46. package/dist-lib/bundle-channel.cjs +42783 -40717
  47. package/dist-lib/capture-contract.cjs +7 -8
  48. package/dist-lib/capture-contract.mjs +7 -8
  49. package/dist-lib/cloud-contract.cjs +1 -1
  50. package/dist-lib/cloud-contract.mjs +1 -1
  51. package/dist-lib/cloud-test-args.cjs +1 -1
  52. package/dist-lib/cloud-test-args.mjs +1 -1
  53. package/dist-lib/cloud.cjs +1 -1
  54. package/dist-lib/cloud.mjs +1 -1
  55. package/dist-lib/config.cjs +1 -1
  56. package/dist-lib/config.mjs +1 -1
  57. package/dist-lib/detox/index.cjs +13 -7
  58. package/dist-lib/dev-bundle-resolution.cjs +10 -4
  59. package/dist-lib/expo-swift-bundle.cjs +15819 -15559
  60. package/dist-lib/expo-swift-metadata.cjs +2 -1
  61. package/dist-lib/expo-swift-metadata.mjs +2 -1
  62. package/dist-lib/home-paths.cjs +2 -33
  63. package/dist-lib/host/bridge-host.cjs +20857 -18756
  64. package/dist-lib/host/fetch-proxy-handler.cjs +10 -10
  65. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  66. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  67. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  68. package/dist-lib/host/websocket-proxy.cjs +1 -1
  69. package/dist-lib/index.cjs +588 -544
  70. package/dist-lib/jump-to-source-babel.cjs +1 -1
  71. package/dist-lib/jump-to-source-native.cjs +1 -1
  72. package/dist-lib/kotlin-host.cjs +1 -1
  73. package/dist-lib/menu.cjs +1 -1
  74. package/dist-lib/menu.mjs +1 -1
  75. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  76. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  77. package/dist-lib/metro-production-bundle.cjs +1 -1
  78. package/dist-lib/metro-production-bundle.mjs +1 -1
  79. package/dist-lib/metro.cjs +25 -19
  80. package/dist-lib/native-app-identity-project.cjs +15 -6
  81. package/dist-lib/native-app-identity-project.mjs +23 -12
  82. package/dist-lib/native-app-identity.cjs +1 -1
  83. package/dist-lib/native-app-identity.mjs +1 -1
  84. package/dist-lib/native-firebase-metadata.cjs +1 -1
  85. package/dist-lib/native-firebase-metadata.mjs +1 -1
  86. package/dist-lib/pdfium-raster.cjs +1 -1
  87. package/dist-lib/pdfium-raster.mjs +1 -1
  88. package/dist-lib/plist.cjs +1 -1
  89. package/dist-lib/plist.mjs +1 -1
  90. package/dist-lib/profiles.cjs +1 -1
  91. package/dist-lib/public-brand.cjs +1 -1
  92. package/dist-lib/public-origins-lib-esm.json +27 -26
  93. package/dist-lib/public-origins-lib.json +104 -81
  94. package/dist-lib/react-native-host-modules.cjs +1 -1
  95. package/dist-lib/react-native-host-modules.mjs +1 -1
  96. package/dist-lib/reap-browser.cjs +1 -1
  97. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  98. package/dist-lib/sdk.cjs +1 -1
  99. package/dist-lib/sdk.mjs +1 -1
  100. package/dist-lib/skills.cjs +30496 -24309
  101. package/dist-lib/swift-compile.cjs +292 -213
  102. package/dist-lib/swift-compile.mjs +334 -254
  103. package/dist-lib/swift-package.cjs +8 -4
  104. package/dist-lib/swift-package.mjs +8 -4
  105. package/dist-lib/swift-submit.cjs +1 -1
  106. package/dist-lib/swift-submit.mjs +1 -1
  107. package/dist-lib/swift-toolchain.cjs +32 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vite-swift.cjs +19172 -18941
  110. package/dist-lib/vite.cjs +11 -11
  111. package/dist-lib/worklet-executable.cjs +1 -1
  112. package/dist-lib/worklet-executable.mjs +1 -1
  113. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
  114. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
  115. package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
  116. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
  117. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
  119. package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
  120. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  121. package/kotlin/sdk.tar.gz +0 -0
  122. package/package.json +1 -1
  123. package/runtime-companion.json +1 -1
  124. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
  125. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
  126. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
  127. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
  128. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
  129. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
  130. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
  131. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
  132. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
  133. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
  134. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
  135. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
  136. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
  137. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
  138. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
  139. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
  140. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
  141. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
  142. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
  143. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
  144. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
  145. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
  146. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
  147. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
  148. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
  149. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
  150. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
  151. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
  152. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
  153. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
  154. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
  155. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
  156. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
  157. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
  158. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
  159. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
  160. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
  161. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
  162. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
  163. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
  164. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
  165. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
  166. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
  167. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
  168. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
  169. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
  170. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
  171. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
  172. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
  173. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
  174. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
  175. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
  176. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
  177. package/sdk/ios/usr/include/dispatch.modulemap +22 -0
  178. package/sdk/ios/usr/include/net/if.h +24 -0
  179. package/sdk/ios/usr/include/sys/time.h +1 -1
  180. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
  181. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
  182. package/sdk/ios/wasm/include/fcntl.h +2 -0
  183. package/sdk/ios/wasm/include/pthread.h +3 -0
  184. package/sdk/ios/wasm/include/stdlib.h +2 -0
  185. package/sdk/ios/wasm/include/unistd.h +2 -2
  186. package/skills/contrast/SKILL.md +2 -2
  187. package/src/bundle-channel.mjs +9 -72
  188. package/src/capture-contract.ts +12 -9
  189. package/src/desktop-host-delivery.ts +16 -2
  190. package/src/dev-bundle-resolution.ts +12 -3
  191. package/src/expo-native-workspace.ts +57 -19
  192. package/src/expo-swift-host.ts +17 -12
  193. package/src/expo-swift-ready.ts +4 -1
  194. package/src/expoSwiftContract.ts +1 -0
  195. package/src/home-paths.ts +4 -48
  196. package/src/host/bridge-host.ts +1 -0
  197. package/src/installed-native-libraries.ts +2 -8
  198. package/src/metro-project-root.ts +2 -1
  199. package/src/native-bundles.ts +122 -0
  200. package/src/native-static-libraries.ts +65 -8
  201. package/src/nitro-adapter.lock.json +278 -278
  202. package/src/nitro-bundle.ts +2 -2
  203. package/src/nitro-compile.ts +68 -28
  204. package/src/nitro-source.ts +24 -6
  205. package/src/nitro-superset.lock.json +94 -34
  206. package/src/nitroContract.ts +2 -0
  207. package/src/podspec-sources.ts +1966 -0
  208. package/src/storageSnapshotContract.ts +40 -0
  209. package/src/swift-compile.ts +57 -20
  210. package/src/swift-design-time.ts +18 -1
  211. package/src/swift-distribution.lock.json +11 -11
  212. package/src/swift-distribution.ts +9 -6
  213. package/src/swift-host.ts +1 -2
  214. package/src/swift-objc-standin.ts +316 -112
  215. package/src/swift-package-manifest.ts +4 -3
  216. package/src/swift-package.ts +10 -3
  217. package/src/swift-root-lock.ts +11 -0
  218. package/src/swift-shared-sdk.ts +10 -9
  219. package/src/swift-source-pods.ts +2 -2
  220. package/src/swift-standins.ts +40 -143
  221. package/src/swift-toolchain.ts +42 -0
  222. package/src/swift-wasm-prune.ts +53 -21
  223. package/src/turbo-bundle.ts +2 -2
  224. package/src/turbo-codegen-intake.ts +111 -108
  225. package/src/turbo-compile.ts +63 -33
  226. package/src/turbo-runtime.lock.json +21 -21
  227. package/src/turbo-source.ts +171 -76
  228. package/src/wasm-optimize.ts +31 -2
  229. package/src/xcode-project.ts +36 -3
@@ -67,6 +67,46 @@ export const RESET_ASYNC_STORAGE_PREFIXES = [
67
67
  export const RESET_MMKV_STORAGE_PREFIX = '@sootsim_mmkv:'
68
68
  export const RESET_USER_DEFAULTS_PREFIX = 'rn-default-preference:'
69
69
 
70
+ // the record behind one UserDefaults key. Swift Foundation, PeachPreferences
71
+ // and every seam that fronts an app-group suite address it through this key,
72
+ // so a write from either side is the other side's read.
73
+ export function swiftPreferenceStorageKey(suiteName: string | null, key: string): string {
74
+ return RESET_USER_DEFAULTS_PREFIX + 'peach-swift:' + JSON.stringify([suiteName, key])
75
+ }
76
+
77
+ // app-group defaults were once kept per suite and key under this prefix as the
78
+ // raw string (`<encoded group>:<encoded key>`), outside the Swift record. Each
79
+ // storage object moves them into the record the first time a seam or the
80
+ // Swift host reaches it, so values persisted before the shared record stay
81
+ // readable. A value already in the record wins; the legacy copy is dropped
82
+ // either way. encodeURIComponent escapes ':', so the split is exact. A storage
83
+ // counts as migrated only after every legacy key moved, so a failed storage
84
+ // operation leaves the remaining copies in place and the next call retries
85
+ // them; the record-wins rule makes the retry safe after a partial pass.
86
+ const LEGACY_APP_GROUP_PREFIX = '@sootsim:shared-group-preferences:'
87
+ const legacyAppGroupMigrated = new WeakSet<Storage>()
88
+
89
+ export function migrateLegacyAppGroupDefaults(storage: Storage): void {
90
+ if (legacyAppGroupMigrated.has(storage)) return
91
+ const legacyKeys: string[] = []
92
+ for (let index = 0; index < storage.length; index++) {
93
+ const key = storage.key(index)
94
+ if (key?.startsWith(LEGACY_APP_GROUP_PREFIX)) legacyKeys.push(key)
95
+ }
96
+ for (const legacyKey of legacyKeys) {
97
+ const parts = legacyKey.slice(LEGACY_APP_GROUP_PREFIX.length).split(':')
98
+ if (parts.length !== 2) continue
99
+ const [group, key] = parts.map(decodeURIComponent)
100
+ const value = storage.getItem(legacyKey)
101
+ const recordKey = swiftPreferenceStorageKey(group, key)
102
+ if (value !== null && storage.getItem(recordKey) === null) {
103
+ storage.setItem(recordKey, JSON.stringify({ kind: 'string', string: value }))
104
+ }
105
+ storage.removeItem(legacyKey)
106
+ }
107
+ legacyAppGroupMigrated.add(storage)
108
+ }
109
+
70
110
  export type ResetStorageKind =
71
111
  | 'async-storage'
72
112
  | 'mmkv'
@@ -24,7 +24,6 @@ import os from 'node:os'
24
24
  import path from 'node:path'
25
25
  import { windowAdmission } from './admitted-mac-build'
26
26
  import cPredefinesJson from './generated/swift-c-predefines.json' with { type: 'json' }
27
- import { swiftCacheDir, swiftPackageCacheOptions } from './home-paths'
28
27
  import { terminateProcessGroup } from './process-group'
29
28
  import {
30
29
  reapRetiredCacheDirectory,
@@ -98,7 +97,9 @@ import {
98
97
  import {
99
98
  sourceSwiftCheckout,
100
99
  SWIFT_AUTOLINK_LINKER,
100
+ swiftCacheDir,
101
101
  swiftEnvironment,
102
+ swiftPackageCacheOptions,
102
103
  swiftSdkOptions,
103
104
  swiftSourceSdk,
104
105
  swiftToolchain,
@@ -363,8 +364,9 @@ export function swiftDistributionAt(root: string): SwiftDistributionManifest | n
363
364
  /**
364
365
  * the Objective-C interface an SDK module defines: the names Swift owns and
365
366
  * its generated header. a distribution ships the header; a source checkout
366
- * names them by `@objc(Name)` and builds the header with the module
367
- * (`.build/host`), so it stands as an empty header until that build.
367
+ * names them by `@objc(Name)` and reads the header its module build emitted
368
+ * (`.build/host`). a module with no emitted header has no interface in either,
369
+ * so its original Objective-C headers keep their declarations.
368
370
  */
369
371
  export function swiftModuleInterface(
370
372
  moduleRoot: string,
@@ -381,22 +383,21 @@ export function swiftModuleInterface(
381
383
  return { declared: swiftInterfaceDeclarations(header), header }
382
384
  }
383
385
  const sources = path.join(moduleRoot, 'Sources', name)
384
- if (!existsSync(sources)) return null
386
+ const built = path.join(moduleRoot, '.build/host', `${name}-Swift.h`)
387
+ if (!existsSync(sources) || !existsSync(built)) return null
385
388
  const declared = new Set<string>()
386
389
  for (const file of readdirSync(sources, { recursive: true, encoding: 'utf8' }))
387
390
  if (file.endsWith('.swift'))
388
- for (const [, objc] of readFileSync(path.join(sources, file), 'utf8').matchAll(
389
- /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s/g,
391
+ // an NSObject subclass is an Objective-C class named as it is in Swift
392
+ for (const [, objc, subclass] of readFileSync(
393
+ path.join(sources, file),
394
+ 'utf8',
395
+ ).matchAll(
396
+ /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm,
390
397
  ))
391
- declared.add(objc!)
398
+ declared.add((objc ?? subclass)!)
392
399
  if (declared.size === 0) return null
393
- const built = path.join(moduleRoot, '.build/host', `${name}-Swift.h`)
394
- return {
395
- declared,
396
- header: existsSync(built)
397
- ? clangInterfaceHeader(readFileSync(built, 'utf8'))
398
- : `// ${name}-Swift.h is generated when ${name} builds\n`,
399
- }
400
+ return { declared, header: clangInterfaceHeader(readFileSync(built, 'utf8')) }
400
401
  }
401
402
 
402
403
  // the compiler imports the module that defines a type, and UIKit's declarations
@@ -697,14 +698,16 @@ export function swiftProjectBuildKey(moduleRoot: string, release: string): strin
697
698
  // clang autolinks the library a system module map names when a unit imports
698
699
  // one of its headers, so an ios target links it without declaring it. swiftpm
699
700
  // on wasm reads no clang autolinks, so the target declares the library the ios
700
- // module map names: SQLite3 links sqlite3, which the wasm sdk ships.
701
+ // module map names: SQLite3 links sqlite3 and bzlib.h links bz2, which the wasm
702
+ // sdk ships.
701
703
  const SYSTEM_MODULE_LIBRARIES: Record<string, string> = {
702
704
  'sqlite3.h': 'sqlite3',
703
705
  'sqlite3ext.h': 'sqlite3',
706
+ 'bzlib.h': 'bz2',
704
707
  SQLite3: 'sqlite3',
705
708
  }
706
709
  const SYSTEM_MODULE_IMPORT =
707
- /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h)>|@import\s+(SQLite3)\b)/gm
710
+ /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h|bzlib\.h)>|@import\s+(SQLite3)\b)/gm
708
711
 
709
712
  export function compileTargets(input: SwiftCompileInput): SwiftPackageTarget[] {
710
713
  const manifest = input.files['Package.swift']
@@ -1251,6 +1254,17 @@ export function swiftTargetDependencies(
1251
1254
  const siblings = new Map<string, string[]>()
1252
1255
  for (const target of targets) {
1253
1256
  const prefix = target.path === '.' ? '' : `${target.path}/`
1257
+ const ownsHeader = (header: string) =>
1258
+ [`${prefix}${header}`, `${prefix}include/${header}`].some(
1259
+ (file) =>
1260
+ Object.hasOwn(files, file) &&
1261
+ !targets.some(
1262
+ (candidate) =>
1263
+ candidate.name !== target.name &&
1264
+ candidate.path !== '.' &&
1265
+ file.startsWith(`${candidate.path}/`),
1266
+ ),
1267
+ )
1254
1268
  const deps = new Set(
1255
1269
  (target.dependencies ?? []).flatMap((dependency) =>
1256
1270
  dependency.kind === 'target' &&
@@ -1275,7 +1289,7 @@ export function swiftTargetDependencies(
1275
1289
  const imports = file.endsWith('.swift')
1276
1290
  ? swiftImportNames(contents)
1277
1291
  : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension))
1278
- ? clangImportNames(contents)
1292
+ ? clangImportNames(contents, ownsHeader)
1279
1293
  : []
1280
1294
  for (const name of imports) {
1281
1295
  if (names.has(name) && name !== target.name) deps.add(name)
@@ -1344,7 +1358,7 @@ const darwinRecordsRegion = (quoted: readonly string[]): string[] =>
1344
1358
  const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
1345
1359
 
1346
1360
  /** bump with any change to the emitted multi-target manifest text. */
1347
- export const MULTI_MANIFEST_VERSION = 64
1361
+ export const MULTI_MANIFEST_VERSION = 65
1348
1362
  const SWIFT_HEADER_PRODUCTS_TARGET = 'PeachHeaderProducts'
1349
1363
 
1350
1364
  // build-cli replaces this in every bundle; source runs read the files directly.
@@ -4113,6 +4127,22 @@ export function writeSwiftProject(
4113
4127
  moduleInterfaces.set(name, value)
4114
4128
  return value
4115
4129
  }
4130
+ const podHeaders = new Map<string, { owner: string; content: unknown }[]>()
4131
+ for (const settings of input.nativeTargets ?? [])
4132
+ for (const file of settings.headers) {
4133
+ const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
4134
+ file,
4135
+ )?.[1]
4136
+ if (owner)
4137
+ podHeaders.set(path.basename(file), [
4138
+ ...(podHeaders.get(path.basename(file)) ?? []),
4139
+ { owner, content: input.files[file] },
4140
+ ])
4141
+ }
4142
+ const podHeaderOwner = (file: string, content: unknown): string | undefined =>
4143
+ /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ??
4144
+ podHeaders.get(path.basename(file))?.find((header) => header.content === content)
4145
+ ?.owner
4116
4146
  // headers keep their original project paths. an xcode target's product
4117
4147
  // headers additionally occupy the flat Module/Header.h namespace it
4118
4148
  // publishes; a swiftpm target's stay under its public headers directory.
@@ -4126,7 +4156,14 @@ export function writeSwiftProject(
4126
4156
  const frameworkHeader =
4127
4157
  !interfaceModule &&
4128
4158
  /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1]
4129
- const frameworkInterface = frameworkHeader ? moduleInterface(frameworkHeader) : null
4159
+ // a source pod whose module the distribution provides as Swift takes
4160
+ // the declarations Swift owns from the module's interface header. a pod
4161
+ // header is owned by the pod whose public header directory holds it, and
4162
+ // its original source by the same content there.
4163
+ const interfaceOwner =
4164
+ frameworkHeader ||
4165
+ (interfaceModule ? undefined : podHeaderOwner(file, input.files[file]))
4166
+ const frameworkInterface = interfaceOwner ? moduleInterface(interfaceOwner) : null
4130
4167
  const rawContents =
4131
4168
  (interfaceModule && moduleInterface(interfaceModule)?.header) || input.files[file]
4132
4169
  if (rawContents === undefined)
@@ -4136,7 +4173,7 @@ export function writeSwiftProject(
4136
4173
  ? withoutSwiftDeclarations(
4137
4174
  rawContents,
4138
4175
  frameworkInterface.declared,
4139
- `#import <${frameworkHeader}/${frameworkHeader}-Swift.h>`,
4176
+ `#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`,
4140
4177
  )
4141
4178
  : rawContents
4142
4179
  writeBuildFile(destination, contents)
@@ -291,7 +291,24 @@ export function designTimeSites(source: string): DesignTimeSite[] {
291
291
  while (t < to && tokens[t]!.kind !== 'newline') t++
292
292
  continue
293
293
  }
294
- t = text(source, tokens[t + 1]) === '(' ? skipGroup(t + 1) : t + 1
294
+ const availability = word === '#available' || word === '#unavailable'
295
+ t++
296
+ // expression macros may have generic arguments and a trailing closure.
297
+ // their expansion sees syntax, so keep all of that syntax intact.
298
+ if (
299
+ !availability &&
300
+ text(source, tokens[t]) === '<' &&
301
+ tokens[t]!.start === token.end
302
+ ) {
303
+ let depth = 0
304
+ do {
305
+ const p = text(source, tokens[t++])
306
+ if (p === '<') depth++
307
+ else if (p === '>') depth--
308
+ } while (t < to && depth > 0)
309
+ }
310
+ if (text(source, tokens[t]) === '(') t = skipGroup(t)
311
+ if (!availability && text(source, tokens[t]) === '{') t = skipGroup(t)
295
312
  continue
296
313
  }
297
314
  if (token.kind === 'at') {
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "2b51e77cc1e7cba5",
2
+ "id": "02d639ad58915e23",
3
3
  "release": "swift-6.4.0-RELEASE-custom-f6868fa6054e83d6",
4
- "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-9f75fa45",
5
- "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-9f75fa45.artifactbundle.tar.gz",
6
- "wasmSdkChecksum": "8bc5b9435ec5a2b68869fcab354263b2751cc10e8ff02f650e8cd92309e9f82c",
7
- "source": "7751b9cbc577167acb0d74260f74f28bdf0b2419",
4
+ "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-5d385b68",
5
+ "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-5d385b68.artifactbundle.tar.gz",
6
+ "wasmSdkChecksum": "d91882af99821a296c3db4459896b46ceaef37e9a30caad14e5f24cf6b964ae9",
7
+ "source": "f02ffbc1528ffd01668f4070775e17be3276bf8f",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -230,16 +230,16 @@
230
230
  },
231
231
  "hosts": {
232
232
  "darwin-arm64": {
233
- "sha256": "2ab6250d5b253169362652ae727832312da92f71d68010e7fca7bd36223dfa48",
234
- "size": 98426889
233
+ "sha256": "ebc19bfd827f24646f407e3f03229bb6abf4b25196630b08ecd47aa0e93124ce",
234
+ "size": 99046695
235
235
  },
236
236
  "linux-x64": {
237
- "sha256": "022ed342f51a6c668572a8a1f75d94a91383cf1d28183d0cc79fac4e9229cee8",
238
- "size": 101144410
237
+ "sha256": "3dfec8229ec882e90ff60b8ef3db267f2f405bb1bf36c1a7e61a3b0f09e02f67",
238
+ "size": 101763946
239
239
  },
240
240
  "linux-arm64": {
241
- "sha256": "cba6d2931a69ba006577bea6111af6bd3a6656d06d0a746af15546fe7181d77a",
242
- "size": 100638534
241
+ "sha256": "4a272ebeed698230c8ade27e5f8e30282f1ff58c37eaaf08f9ed8bc82185c449",
242
+ "size": 101257308
243
243
  }
244
244
  }
245
245
  }
@@ -319,16 +319,19 @@ export async function resolveSwiftModule({
319
319
  return { root, ...swiftModuleToolchain(root) }
320
320
  }
321
321
 
322
- /** the release a module root was built for and its installed toolchain. */
323
- export function swiftModuleToolchain(root: string): {
324
- release: string
325
- toolchainBin: string
326
- } {
322
+ /** the host compiler selected by a module root, without requiring a guest SDK. */
323
+ export function swiftModuleCompiler(root: string): Omit<SwiftModule, 'root'> {
327
324
  const pin: { release: string } =
328
325
  swiftDistributionAt(root) ??
329
326
  JSON.parse(fs.readFileSync(path.join(root, 'toolchain.json'), 'utf8'))
330
327
  return {
331
328
  release: pin.release,
332
- toolchainBin: swiftToolchain(pin.release, swiftModuleSdk(root)),
329
+ toolchainBin: swiftCompiler(pin.release),
333
330
  }
334
331
  }
332
+
333
+ /** the release a module root was built for and its installed toolchain. */
334
+ export function swiftModuleToolchain(root: string): Omit<SwiftModule, 'root'> {
335
+ const { release } = swiftModuleCompiler(root)
336
+ return { release, toolchainBin: swiftToolchain(release, swiftModuleSdk(root)) }
337
+ }
package/src/swift-host.ts CHANGED
@@ -14,7 +14,6 @@ import {
14
14
  resolveSwiftImageResourceUrls,
15
15
  } from '../../sootsim-swift/src/bundleAssets'
16
16
  import { compileStringCatalog } from '../../sootsim-swift/src/stringCatalog'
17
- import { swiftCacheDir } from './home-paths'
18
17
  import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
19
18
  import { type NativeAppIdentity } from './native-app-identity'
20
19
  import { readNativeAppIdentityFromXcodeTarget } from './native-app-identity-project'
@@ -112,7 +111,7 @@ import {
112
111
  type SwiftImageUpload,
113
112
  type SwiftNativeModules,
114
113
  } from './swift-submit'
115
- import { privateSwiftDistributionRoot } from './swift-toolchain'
114
+ import { privateSwiftDistributionRoot, swiftCacheDir } from './swift-toolchain'
116
115
  import { swiftProjectFileProblem } from './swiftContract'
117
116
  import {
118
117
  SWIFT_NATIVE_INPUT_ROOT,