peachsim 0.1.2065 → 0.1.2067

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 (100) 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 +1950 -1782
  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 +1435 -1284
  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 +2137 -1967
  31. package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
  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 +3 -3
  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 +3 -3
  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 +60 -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 +2660 -2481
  68. package/dist-lib/swift-compile.cjs +27 -9
  69. package/dist-lib/swift-compile.mjs +26 -9
  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 +1054 -917
  77. package/dist-lib/vite.cjs +3 -3
  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/map-command-channel.d.ts +1 -0
  81. package/package.json +1 -1
  82. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTiming.h +4 -4
  83. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +1 -0
  84. package/src/expo-pod-prebuilt.ts +21 -4
  85. package/src/expo-swift-host.ts +12 -0
  86. package/src/host/dev-server-package-versions.ts +5 -1
  87. package/src/native-swift-slices.ts +130 -0
  88. package/src/nitro-adapter.lock.json +280 -280
  89. package/src/nitro-compile.ts +2 -0
  90. package/src/nitro-source.ts +1 -0
  91. package/src/nitro-superset.lock.json +4 -4
  92. package/src/swift-compile.ts +47 -19
  93. package/src/swift-distribution.lock.json +11 -11
  94. package/src/swift-host.ts +24 -0
  95. package/src/swift-installed-targets.ts +5 -0
  96. package/src/swift-standins.ts +29 -11
  97. package/src/swift-xcframework.ts +4 -0
  98. package/src/turbo-compile.ts +2 -0
  99. package/src/turbo-runtime.lock.json +23 -23
  100. package/src/turbo-source.ts +1 -0
@@ -317,6 +317,8 @@ export interface SwiftCompileInput {
317
317
  * replace the stand-in's traps.
318
318
  */
319
319
  libraries?: Record<string, string>
320
+ /** compiled wasm Swift interfaces, base64 by module, beside their native libraries. */
321
+ binaryModules?: Record<string, string>
320
322
  /** size-optimize the linked executable: artifacts built once and fetched many times. */
321
323
  optimize?: boolean
322
324
  /** CocoaPods static targets whose C/C++ objects load only to resolve references. */
@@ -350,6 +352,8 @@ export interface SwiftCompileOptions {
350
352
  signal?: AbortSignal
351
353
  /** called as the compile reaches each stage, in addition to the stderr line. */
352
354
  onStage?: (stage: string) => void
355
+ /** archive producers need the local object, interface and header products. */
356
+ intermediates?: boolean
353
357
  }
354
358
 
355
359
  export interface SwiftCompileArtifact {
@@ -428,7 +432,7 @@ const clangInterfaceHeader = (header: string): string =>
428
432
  .replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, '')
429
433
 
430
434
  /** the Objective-C protocols and classes a generated interface header defines. */
431
- const swiftInterfaceDeclarations = (header: string): Set<string> =>
435
+ export const swiftInterfaceDeclarations = (header: string): Set<string> =>
432
436
  new Set([
433
437
  ...[
434
438
  ...header.matchAll(
@@ -462,7 +466,10 @@ export function withoutSwiftDeclarations(
462
466
  }
463
467
  if (regionStart < 0 && /^NS_ASSUME_NONNULL_BEGIN\b/.test(line))
464
468
  regionStart = out.length
465
- const name = /^@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(line)?.[1]
469
+ const name =
470
+ /^\s*(?:[A-Z_]\w*(?:\([^()\n]*\))?\s+)*@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(
471
+ line,
472
+ )?.[1]
466
473
  const enumeration =
467
474
  /^\s*typedef\s+(?:NS_ENUM|NS_OPTIONS|SWIFT_ENUM(?:_NAMED)?)\s*\(\s*\w+\s*,\s*(\w+)\b/.exec(
468
475
  line,
@@ -470,7 +477,10 @@ export function withoutSwiftDeclarations(
470
477
  if ((name && declared.has(name)) || (enumeration && declared.has(enumeration))) {
471
478
  skipping = name ? 'objc' : line.includes('};') ? undefined : 'enum'
472
479
  // generated Swift annotations belong to the declaration being removed.
473
- while (/^SWIFT_[A-Z_]+(?:\(.*\))?\s*$/.test(out.at(-1) ?? '')) out.pop()
480
+ while (
481
+ /^(?:SWIFT_[A-Z_]+|(?:NS|CF)_SWIFT_NAME)(?:\(.*\))?\s*$/.test(out.at(-1) ?? '')
482
+ )
483
+ out.pop()
474
484
  if (!imported)
475
485
  out.splice(regionStart < 0 ? out.length : regionStart, 0, interfaceImport)
476
486
  imported = true
@@ -1625,6 +1635,8 @@ export function swiftArtifactHash(
1625
1635
  .digest(),
1626
1636
  )
1627
1637
  }
1638
+ for (const [name, bytes] of Object.entries(input.binaryModules ?? {}).sort())
1639
+ hash.update(`binary-module\0${name}\0${bytes}\0`)
1628
1640
  const targets = compileTargets(input)
1629
1641
  if (targets.length > 0) {
1630
1642
  hash.update(`swift-multi/v${MULTI_MANIFEST_VERSION}\n`)
@@ -1766,6 +1778,7 @@ export function emitSwiftPackageManifest(args: {
1766
1778
  prebuilt?: { modules: string; linkFile: string; link: string[]; moduleMaps: string[] }
1767
1779
  /** the static library each target links, by target name. */
1768
1780
  libraries?: Map<string, string>
1781
+ binaryModules?: string
1769
1782
  /** the sdk toolset already searches libc++ before the darwin overlay. */
1770
1783
  deferDarwinOverlay?: boolean
1771
1784
  /** the development region SwiftPM needs as defaultLocalization beside localized resources. */
@@ -1983,19 +1996,24 @@ export function emitSwiftPackageManifest(args: {
1983
1996
  // clang loads configuration inputs before command-line libraries. forward
1984
1997
  // the file opaquely so swift neither expands it nor scans every framework
1985
1998
  // object for autolinks; distribution.link supplies those libraries.
1986
- const imports = distribution
1987
- ? `, "-Isystem", ${JSON.stringify(
1988
- providedModulesPath(
1989
- args.root,
1990
- path.join(moduleRoot, 'modules'),
1991
- args.moduleExcludes,
1992
- ),
1993
- )}`
1994
- : prebuilt
1995
- ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps
1996
- .map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`)
1997
- .join('')}`
1998
- : ''
1999
+ const binaryImports = args.binaryModules
2000
+ ? `, "-I", ${JSON.stringify(args.binaryModules)}`
2001
+ : ''
2002
+ const imports =
2003
+ binaryImports +
2004
+ (distribution
2005
+ ? `, "-Isystem", ${JSON.stringify(
2006
+ providedModulesPath(
2007
+ args.root,
2008
+ path.join(moduleRoot, 'modules'),
2009
+ args.moduleExcludes,
2010
+ ),
2011
+ )}`
2012
+ : prebuilt
2013
+ ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps
2014
+ .map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`)
2015
+ .join('')}`
2016
+ : '')
1999
2017
  const nativeFlags = [
2000
2018
  ...(args.nativeFlags?.get(target.name) ?? []),
2001
2019
  ...(args.nativeHeaderFlags ?? []),
@@ -5525,6 +5543,15 @@ export function writeSwiftProject(
5525
5543
  } else {
5526
5544
  const base = layout.multi ? layout.root : layout.sources
5527
5545
  const libraries = new Map<string, string>()
5546
+ const binaryModules = path.join(layout.root, '.peach-binary-modules')
5547
+ for (const [name, data] of Object.entries(input.binaryModules ?? {})) {
5548
+ if (!/^[A-Za-z_]\w*$/.test(name) || !input.libraries?.[name])
5549
+ throw new Error(`invalid native Swift module ${name}: its library is required`)
5550
+ files.set(
5551
+ path.join(binaryModules, `${name}.swiftmodule`),
5552
+ Buffer.from(data, 'base64'),
5553
+ )
5554
+ }
5528
5555
  for (const [target, data] of Object.entries(input.libraries ?? {})) {
5529
5556
  const bytes = Buffer.from(data, 'base64')
5530
5557
  const digest = createHash('sha256').update(bytes).digest('hex')
@@ -5703,6 +5730,7 @@ export function writeSwiftProject(
5703
5730
  }
5704
5731
  : {}),
5705
5732
  libraries,
5733
+ ...(Object.keys(input.binaryModules ?? {}).length > 0 ? { binaryModules } : {}),
5706
5734
  ...(input.defaultLocalization
5707
5735
  ? { defaultLocalization: input.defaultLocalization }
5708
5736
  : {}),
@@ -6811,7 +6839,7 @@ function compileSwiftProjectOnce(
6811
6839
  // reuse one verified result across server restarts before admission or
6812
6840
  // swiftpm. the address covers sources, framework inputs and toolchain.
6813
6841
  const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash)
6814
- if (retained) {
6842
+ if (retained && !options.intermediates) {
6815
6843
  report('reusing memory artifact')
6816
6844
  return retain(root, retained)
6817
6845
  }
@@ -6820,7 +6848,7 @@ function compileSwiftProjectOnce(
6820
6848
  const previous =
6821
6849
  cached ??
6822
6850
  (options.project ? null : readCompiledArtifact(path.join(root, 'artifact'), hash))
6823
- if (previous) {
6851
+ if (previous && !options.intermediates) {
6824
6852
  if (cached) renewSharedArtifact(sharedRoot)
6825
6853
  else saveSharedArtifact(sharedRoot, previous)
6826
6854
  report('reusing verified disk artifact')
@@ -6901,7 +6929,7 @@ function compileSwiftProjectOnce(
6901
6929
  // a process that held the root while this one waited may have built
6902
6930
  // this exact address.
6903
6931
  const built = readCompiledArtifact(path.join(sharedRoot, 'artifact'), hash)
6904
- if (built) {
6932
+ if (built && !options.intermediates) {
6905
6933
  report('reusing verified disk artifact')
6906
6934
  return retain(root, built)
6907
6935
  }
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "0857754dc7ba5afb",
2
+ "id": "cf3e849068255ca9",
3
3
  "release": "swift-6.4.0-RELEASE-custom-11345d60dca47496",
4
- "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-e855bc31",
5
- "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-e855bc31.artifactbundle.tar.gz",
6
- "wasmSdkChecksum": "78905bba0974f8340c20b752df9c5b0ee1b5449e33caccb5ad815e6a4abddf25",
7
- "source": "fcfd06661b2da64619fb70f9d9d27ae2df230aaa",
4
+ "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-2ef09643",
5
+ "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-2ef09643.artifactbundle.tar.gz",
6
+ "wasmSdkChecksum": "8a692c7dca8da69d31ea86774a91ea1d01b84ed1e80369481eb14a882ebae718",
7
+ "source": "42817bafea1b52d8c7c438f6a4e9fdf890e22ac6",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -238,16 +238,16 @@
238
238
  },
239
239
  "hosts": {
240
240
  "darwin-arm64": {
241
- "sha256": "94d247a0e841c3155c2733c46cecaba5f4c9139ea3184da42fa3054e9f6a491a",
242
- "size": 100483654
241
+ "sha256": "80852f392a2ba510bb27bcb565e68d88a9b5eac9e97caa935048c23b6120b7a3",
242
+ "size": 100509751
243
243
  },
244
244
  "linux-x64": {
245
- "sha256": "493e754c458908ad0a1ee1c1a390c3b3a14388f99fa19fdf230a4e5513dbde61",
246
- "size": 103201081
245
+ "sha256": "8ec29b02b6f2f29ceda1ec94134342806ff2689d74f8e8005b8c6cbf7b028bf9",
246
+ "size": 103228918
247
247
  },
248
248
  "linux-arm64": {
249
- "sha256": "2ed334ff0710e0e2593e169b867336125985523953199e52da868e30d4940e95",
250
- "size": 102694199
249
+ "sha256": "be938c2286f661a6f204bfd0cc6b1a792a6dbe933700de35d4e6e469b537d9ff",
250
+ "size": 102718602
251
251
  }
252
252
  }
253
253
  }
package/src/swift-host.ts CHANGED
@@ -246,6 +246,7 @@ export interface SwiftProject {
246
246
  hosted?: SwiftHostedCompileOptions
247
247
  signal?: AbortSignal
248
248
  libraries?: Record<string, string>
249
+ binaryModules?: SwiftCompileInput['binaryModules']
249
250
  optimize?: boolean
250
251
  staticClangTargets?: string[]
251
252
  nativeTargets?: SwiftNativeTarget[]
@@ -2244,6 +2245,7 @@ export function sourceStamp(
2244
2245
  hash.update(JSON.stringify(xcodeProjects().get(packagePath)?.behavior ?? {}))
2245
2246
  const libraries = projects().get(packagePath)?.libraries
2246
2247
  if (libraries) hash.update(JSON.stringify(libraries))
2248
+ hash.update(JSON.stringify(projects().get(packagePath)?.binaryModules ?? {}))
2247
2249
  if (projects().get(packagePath)?.optimize) hash.update('optimize')
2248
2250
  hash.update(JSON.stringify(projects().get(packagePath)?.staticClangTargets ?? []))
2249
2251
  hash.update(JSON.stringify(projects().get(packagePath)?.oneModule ?? true))
@@ -2273,6 +2275,7 @@ export function sourceContentStamp(
2273
2275
  hash.update(JSON.stringify(xcodeProjects().get(packagePath)?.behavior ?? {}))
2274
2276
  const libraries = projects().get(packagePath)?.libraries
2275
2277
  if (libraries) hash.update(JSON.stringify(libraries))
2278
+ hash.update(JSON.stringify(projects().get(packagePath)?.binaryModules ?? {}))
2276
2279
  if (projects().get(packagePath)?.optimize) hash.update('optimize')
2277
2280
  hash.update(JSON.stringify(projects().get(packagePath)?.staticClangTargets ?? []))
2278
2281
  hash.update(JSON.stringify(projects().get(packagePath)?.oneModule ?? true))
@@ -2349,10 +2352,21 @@ export function standinLibraries(
2349
2352
  toolchain?: { moduleRoot: string; release: string },
2350
2353
  ): Map<string, SwiftStandin[]> {
2351
2354
  const linked = new Map<string, SwiftStandin[]>()
2355
+ for (const standin of standins) {
2356
+ if (!standin.prebuilt) continue
2357
+ const bytes = Buffer.from(standin.prebuilt.library, 'base64')
2358
+ const digest = createHash('sha256').update(bytes).digest('hex')
2359
+ const dir = path.join(swiftCacheDir(), 'native-archives', digest)
2360
+ fs.mkdirSync(dir, { recursive: true })
2361
+ const library = path.join(dir, `lib${standin.module}.a`)
2362
+ if (!fs.existsSync(library)) fs.writeFileSync(library, bytes)
2363
+ linked.set(library, [standin])
2364
+ }
2352
2365
  for (const binary of binaries) {
2353
2366
  const modules = standins.filter(
2354
2367
  (standin) =>
2355
2368
  standin.target === binary.target &&
2369
+ !standin.prebuilt &&
2356
2370
  (`${standin.module}.c` in standin.files ||
2357
2371
  `${standin.module}.cpp` in standin.files),
2358
2372
  )
@@ -2425,6 +2439,7 @@ interface SwiftPackageSnapshot {
2425
2439
  native: SwiftNativeModules | null
2426
2440
  glue?: string
2427
2441
  libraries?: Record<string, string>
2442
+ binaryModules?: SwiftCompileInput['binaryModules']
2428
2443
  optimize?: boolean
2429
2444
  staticClangTargets?: string[]
2430
2445
  }
@@ -2501,6 +2516,14 @@ function packageSnapshot(
2501
2516
  return {
2502
2517
  files,
2503
2518
  oneModule: project.oneModule,
2519
+ binaryModules: {
2520
+ ...project.binaryModules,
2521
+ ...Object.fromEntries(
2522
+ (layout?.standins ?? []).flatMap((standin) =>
2523
+ standin.prebuilt ? [[standin.module, standin.prebuilt.module]] : [],
2524
+ ),
2525
+ ),
2526
+ },
2504
2527
  ...(Object.keys(headerAliases).length > 0 ? { headerAliases } : {}),
2505
2528
  nativeModules: (layout?.packages.nativePackages ?? []).flatMap(
2506
2529
  ({ guestTargets: targets }) =>
@@ -2614,6 +2637,7 @@ function snapshotCompileInput(snapshot: SwiftPackageSnapshot): SwiftCompileInput
2614
2637
  entry: snapshot.entry,
2615
2638
  oneModule: snapshot.oneModule,
2616
2639
  ...(snapshot.libraries ? { libraries: snapshot.libraries } : {}),
2640
+ ...(snapshot.binaryModules ? { binaryModules: snapshot.binaryModules } : {}),
2617
2641
  ...(snapshot.optimize ? { optimize: true } : {}),
2618
2642
  ...(snapshot.staticClangTargets
2619
2643
  ? { staticClangTargets: snapshot.staticClangTargets }
@@ -19,6 +19,7 @@ export function applyInstalledSwiftTargets(
19
19
  headerAliases?: SwiftCompileInput['headerAliases']
20
20
  nativeTargets?: SwiftCompileInput['nativeTargets']
21
21
  libraries?: SwiftCompileInput['libraries']
22
+ binaryModules?: SwiftCompileInput['binaryModules']
22
23
  resources?: SwiftCompileInput['resources']
23
24
  resourceBundles?: SwiftCompileInput['resourceBundles']
24
25
  viewComponentSources?: ReadonlySet<string>
@@ -32,6 +33,10 @@ export function applyInstalledSwiftTargets(
32
33
  const installedRoot = fs.realpathSync(roots.installed)
33
34
  const sourceRoots = [sourceRoot, installedRoot]
34
35
  const aliases: Record<string, string> = {}
36
+ collection.binaryModules = {
37
+ ...collection.binaryModules,
38
+ ...snapshot.input.binaryModules,
39
+ }
35
40
  collection.resources = { ...collection.resources, ...snapshot.input.resources }
36
41
  collection.resourceBundles = [
37
42
  ...new Map(
@@ -18,6 +18,7 @@ import { isRecord } from './is-record'
18
18
  import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
19
19
  import { nativeSliceEntry, NATIVE_SLICE_RECIPES } from './native-slices'
20
20
  import { nativeStaticLibrary, nativeStaticLibraryRecipe } from './native-static-libraries'
21
+ import { nativeSwiftSlice } from './native-swift-slices'
21
22
  import { outputLockStdio } from './output-lock-stdio'
22
23
  import {
23
24
  FOUNDATION_IMPLICIT_MODULES,
@@ -81,6 +82,8 @@ export interface SwiftStandin {
81
82
  target: string
82
83
  /** the target's files, relative to its directory. */
83
84
  files: Record<string, string>
85
+ /** compiled native implementation and its matching wasm Swift interface. */
86
+ prebuilt?: { module: string; library: string }
84
87
  /** target-relative directory containing the original public module map. */
85
88
  publicHeadersPath?: string
86
89
  /** other generated modules named by this target's public headers. */
@@ -196,7 +199,7 @@ function locateXcframework(tree: string): string | null {
196
199
  // remote) keeps its bytes and unpacks again when they change. the digest,
197
200
  // not the path, keys the stand-in cache, so a replaced same-path zip
198
201
  // rebuilds instead of reusing stale output.
199
- function xcframework(binary: SwiftPackageBinary): {
202
+ export function swiftBinaryFramework(binary: SwiftPackageBinary): {
200
203
  dir: string
201
204
  digest: string
202
205
  } {
@@ -398,7 +401,7 @@ export function binaryHeaderSearchPaths(
398
401
  root: string,
399
402
  declaredFrameworks?: SwiftDeclaredFrameworks,
400
403
  ): { frameworks: string[]; headers: string[] } {
401
- const artifact = xcframework(binary)
404
+ const artifact = swiftBinaryFramework(binary)
402
405
  const slice = simulatorSlice(artifact.dir)
403
406
  const found = surfaces(artifact.dir, binary.target, slice)
404
407
  const frameworks = [
@@ -1989,7 +1992,7 @@ async function cxxStandin(
1989
1992
  )
1990
1993
  if (language.status === 0) return cStandin(surface, binary, toolchain, work)
1991
1994
  if (binary.cxxHeaders.error) throw new Error(binary.cxxHeaders.error)
1992
- const slice = simulatorSlice(xcframework(binary).dir)
1995
+ const slice = simulatorSlice(swiftBinaryFramework(binary).dir)
1993
1996
  if (!slice) throw new Error('C++ stand-ins require a simulator library slice')
1994
1997
  if (
1995
1998
  headers !== path.join(slice, 'Headers') ||
@@ -2174,7 +2177,7 @@ export function standinLibrary(
2174
2177
  toolchain?: Pick<Toolchain, 'moduleRoot' | 'release'>,
2175
2178
  ): string | null {
2176
2179
  if (binary.publicHeaders !== undefined) return null
2177
- const dir = xcframework(binary).dir
2180
+ const dir = swiftBinaryFramework(binary).dir
2178
2181
  const native = simulatorNativeLibrary(dir)
2179
2182
  const library = native?.kind === 'archive' ? native.name : null
2180
2183
  const supplied = path.join(dir, RUST_TARGET)
@@ -2372,7 +2375,7 @@ async function sourceStandins(
2372
2375
  gaps.set(binary.target, absent)
2373
2376
  continue
2374
2377
  }
2375
- const resolved = xcframework(binary)
2378
+ const resolved = swiftBinaryFramework(binary)
2376
2379
  const dir = path.join(artifact, String(index), path.basename(resolved.dir))
2377
2380
  fs.cpSync(resolved.dir, dir, { recursive: true, dereference: true })
2378
2381
  local.push({ ...binary, dir, url: null, checksum: null })
@@ -2559,7 +2562,7 @@ export function standinGenerationInputs(
2559
2562
  try {
2560
2563
  return binary.publicHeaders !== undefined || binary.placeholder !== undefined
2561
2564
  ? [swiftTargetModuleName(binary.target)]
2562
- : surfaces(xcframework(binary).dir, binary.target).map(
2565
+ : surfaces(swiftBinaryFramework(binary).dir, binary.target).map(
2563
2566
  (surface) => surface.module,
2564
2567
  )
2565
2568
  } catch {
@@ -2605,7 +2608,7 @@ export function standinGenerationInputs(
2605
2608
  try {
2606
2609
  if (
2607
2610
  binary.publicHeaders === undefined &&
2608
- surfaces(xcframework(binary).dir, binary.target).some(
2611
+ surfaces(swiftBinaryFramework(binary).dir, binary.target).some(
2609
2612
  (surface) => surface.kind === 'swift',
2610
2613
  )
2611
2614
  )
@@ -2625,7 +2628,7 @@ export function standinGenerationInputs(
2625
2628
  ),
2626
2629
  ...(binary.assemblySources ?? []),
2627
2630
  ].join('\0')
2628
- : xcframework(binary).digest,
2631
+ : swiftBinaryFramework(binary).digest,
2629
2632
  )
2630
2633
  } catch {
2631
2634
  // unreadable here fails again below, where it becomes a gap
@@ -2716,7 +2719,7 @@ async function binaryStandins(
2716
2719
  ),
2717
2720
  ].join('\0')
2718
2721
  } else {
2719
- const artifact = xcframework(binary)
2722
+ const artifact = swiftBinaryFramework(binary)
2720
2723
  all = surfaces(artifact.dir, binary.target)
2721
2724
  digest = artifact.digest
2722
2725
  }
@@ -2881,10 +2884,25 @@ export async function swiftStandins(
2881
2884
  toolchain: Toolchain,
2882
2885
  provided: ReadonlySet<string> = new Set(),
2883
2886
  behavior: SwiftStandinBehaviors = {},
2887
+ options: { nativeSlices?: boolean } = {},
2884
2888
  ): Promise<SwiftStandins> {
2885
2889
  const built = await buildStandins(binaries, toolchain, provided, behavior)
2886
2890
  return {
2887
- standins: built.standins,
2891
+ standins:
2892
+ options.nativeSlices === false
2893
+ ? built.standins
2894
+ : built.standins.map((standin) => {
2895
+ const binary = binaries.find((item) => item.target === standin.target)
2896
+ return binary
2897
+ ? nativeSwiftSlice(
2898
+ standin,
2899
+ toolchain.moduleRoot,
2900
+ STANDIN_SOURCE_DIGEST,
2901
+ Object.keys(behavior[standin.module] ?? {}).length > 0,
2902
+ () => swiftBinaryFramework(binary).dir,
2903
+ )
2904
+ : standin
2905
+ }),
2888
2906
  gaps: new Map([...built.gaps].map(([target, gap]) => [target, gapText(gap)])),
2889
2907
  }
2890
2908
  }
@@ -2944,7 +2962,7 @@ async function buildStandins(
2944
2962
  }
2945
2963
  if (binary.publicHeaders !== undefined) continue
2946
2964
  try {
2947
- const artifact = xcframework(binary)
2965
+ const artifact = swiftBinaryFramework(binary)
2948
2966
  frameworkInputs.push(`${binary.target}\0${artifact.digest}`)
2949
2967
  const imports = new Set<string>()
2950
2968
  interfaceImports.set(binary, imports)
@@ -7,6 +7,10 @@ import { parsePlistBytes } from './plist-bytes'
7
7
  export function simulatorNativeLibrary(
8
8
  dir: string,
9
9
  ): { name: string; file: string; kind: 'archive' | 'framework' } | null {
10
+ if (dir.endsWith('.framework')) {
11
+ const name = path.basename(dir, '.framework')
12
+ return { name, file: path.join(dir, name), kind: 'framework' }
13
+ }
10
14
  if (!dir.endsWith('.xcframework')) return null
11
15
  const info = parsePlistBytes(fs.readFileSync(path.join(dir, 'Info.plist')))
12
16
  if (!isRecord(info) || !Array.isArray(info.AvailableLibraries))
@@ -150,6 +150,7 @@ export function collectTurboCompileInput(
150
150
  return {
151
151
  files,
152
152
  entry,
153
+ binaryModules: { ...dependencies?.binaryModules, ...collection.binaryModules },
153
154
  libraries: {
154
155
  ...dependencies?.libraries,
155
156
  ...collection.libraries,
@@ -407,6 +408,7 @@ export async function compileTurboModule(options: {
407
408
  const project = projectFor(packagePath)
408
409
  project.oneModule = false
409
410
  project.libraries = input.libraries
411
+ project.binaryModules = input.binaryModules
410
412
  project.optimize = input.optimize
411
413
  project.staticClangTargets = input.staticClangTargets
412
414
  project.nativeTargets = input.nativeTargets
@@ -8,11 +8,11 @@
8
8
  },
9
9
  "compiler": "swift-6.4.0-RELEASE-custom-11345d60dca47496",
10
10
  "sdk": {
11
- "id": "swift-6.4.0-RELEASE_wasm-peach-e855bc31",
12
- "checksum": "78905bba0974f8340c20b752df9c5b0ee1b5449e33caccb5ad815e6a4abddf25"
11
+ "id": "swift-6.4.0-RELEASE_wasm-peach-2ef09643",
12
+ "checksum": "8a692c7dca8da69d31ea86774a91ea1d01b84ed1e80369481eb14a882ebae718"
13
13
  },
14
14
  "framework": {
15
- "distribution": "0857754dc7ba5afb",
15
+ "distribution": "cf3e849068255ca9",
16
16
  "wireAbi": "246b8412514b644113e6a26252c8ebd6de49ab4156ac5f5c98bb9e4c2ff2568b"
17
17
  },
18
18
  "archives": [
@@ -20,71 +20,71 @@
20
20
  "headers": {
21
21
  "reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
22
22
  },
23
- "sha256": "aa35fd70f66aa82f5412ca205e4a9cf0683be4e4fdf5d71ced9d60fc5694eca5",
24
- "size": 25403
23
+ "sha256": "39c86fab30c062bac26457309416b03ad89a24298790779ff73093cd71d24c62",
24
+ "size": 25397
25
25
  },
26
26
  {
27
27
  "headers": {
28
28
  "reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
29
29
  },
30
- "sha256": "135f5faa2bef7f84c51aa93172ce431ffcc15637eca4686e18be081e6665ae47",
31
- "size": 26140
30
+ "sha256": "b5bb048bd11489530d8a0ad20ce7ffbbfa373c32354154a8e53fe8cefdaeecce",
31
+ "size": 26137
32
32
  },
33
33
  {
34
34
  "headers": {
35
35
  "reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
36
36
  },
37
- "sha256": "508cf803c6270863946d1d2b1eca44633f3c49e4a6bb2c0a2a59ef8ecb5a60e9",
38
- "size": 25399
37
+ "sha256": "48bedf7783a8418eef6a0f3b9402545ccee9f92e260af00ebdc9f295cdaeab46",
38
+ "size": 25394
39
39
  },
40
40
  {
41
41
  "headers": {
42
42
  "reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
43
43
  },
44
- "sha256": "b0b876fef8705a7811b8b714b64c5eb75c9a6b1a222c2d00ce08cbd386a62f52",
45
- "size": 25167
44
+ "sha256": "307c1add3c176c29a193d3f992d2271d9ce575c67c5a5ce19f89ca3f6925ee7b",
45
+ "size": 25165
46
46
  },
47
47
  {
48
48
  "headers": {
49
49
  "reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
50
50
  },
51
- "sha256": "89ff9fa1ae1ed71a28e4035db604d37f8bb22a81255758a6168c3711280b10a2",
52
- "size": 25403
51
+ "sha256": "777316b65d7b37427c2016e138806cec24744b9a5d8050ae3b1e30fc052b4841",
52
+ "size": 25398
53
53
  },
54
54
  {
55
55
  "headers": {
56
56
  "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
57
57
  },
58
- "sha256": "683a52814fe53977ada8e59b1785511b1ef25e3b6a33e868c51c2155fdde9a20",
59
- "size": 26142
58
+ "sha256": "1f069f00ac89d9bb96c53a0eb29bbae162db9a3198233c2b9c02a616cfe26269",
59
+ "size": 26139
60
60
  },
61
61
  {
62
62
  "headers": {
63
63
  "reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
64
64
  },
65
- "sha256": "44e7c5229984d6f7863456324479b12dcfd86e7b65eb1048b09f8757604e8110",
66
- "size": 26140
65
+ "sha256": "1362fae803138f9b6095473e3c0427afa6edfecef1e8624059de21f8d025dd46",
66
+ "size": 26138
67
67
  },
68
68
  {
69
69
  "headers": {
70
70
  "reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
71
71
  },
72
- "sha256": "35869391f7df2e70e6ccfdca3f6fa4ad2078b367bae67955b122a2ea4f58714e",
73
- "size": 25268
72
+ "sha256": "b98468fe6f876388a383160716247a99537764bb90f39de4c9258fac34b9f4bb",
73
+ "size": 25267
74
74
  },
75
75
  {
76
76
  "headers": {
77
77
  "reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
78
78
  },
79
- "sha256": "5746d8bc4209dd86e36d1eb69140c06875d5cd82b9074ea539966df3a1a2314a",
80
- "size": 26144
79
+ "sha256": "2611cfcc153f6f4cc57a725e53d9bd1870779f9e4b01f4b643287c6852c0b019",
80
+ "size": 26141
81
81
  },
82
82
  {
83
83
  "headers": {
84
84
  "reactNativeJsi": "c8270f1315745ecc204c4209a4f50f58ff6f14b4a385ad6820a69800270b53c6"
85
85
  },
86
- "sha256": "606a360d14417a70ba197ab07bbe7959e0e5b99116d03b9c712769dbf66888d0",
87
- "size": 25106
86
+ "sha256": "717e59285984e6747b1f3cb0fbc4b7375b1246a85989ecd5984a10c8030ab826",
87
+ "size": 25103
88
88
  }
89
89
  ]
90
90
  }
@@ -90,6 +90,7 @@ export interface TurboInstalledPod extends TurboInstalledSources {
90
90
  export interface TurboSourceCollection {
91
91
  files: SwiftCompileInput['files']
92
92
  libraries?: SwiftCompileInput['libraries']
93
+ binaryModules?: SwiftCompileInput['binaryModules']
93
94
  resources?: SwiftCompileInput['resources']
94
95
  resourceBundles?: SwiftCompileInput['resourceBundles']
95
96
  targets: SwiftPackageTarget[]