peachsim 0.1.2679 → 0.1.2681

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 (138) 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 +1638 -983
  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 +2 -2
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-KT4EYLSJ.mjs → acorn-PR2XQSSU.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-UOT25QCP.mjs → chunk-4FLAV4CH.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-4ZQP7VPQ.mjs → chunk-7E6FTDFH.mjs} +5 -5
  29. package/dist-lib/esm-chunks/{chunk-FA5V3ZBF.mjs → chunk-AE55UVNN.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-4MQNNSXS.mjs → chunk-AN2MS7YE.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-7VK6K2OI.mjs → chunk-BMLK7CSL.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-DPFS4TZQ.mjs → chunk-COZNDKTJ.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-JK6VGS54.mjs → chunk-EULMEAZP.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-FLEDVCBF.mjs → chunk-FETYD3YY.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-AIMGU6I4.mjs → chunk-H6ZWWX3Q.mjs} +2 -2
  36. package/dist-lib/esm-chunks/{chunk-BMPYVWFP.mjs → chunk-HHGF6SPD.mjs} +8 -7
  37. package/dist-lib/esm-chunks/{chunk-WSX6WDGU.mjs → chunk-I6ET6AKV.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-YGGXAYBE.mjs → chunk-I7QX2CR7.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-DGARJVZC.mjs → chunk-J6HBVHOS.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-I77TXXX6.mjs → chunk-KTGBQAWI.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-XA22MMUJ.mjs → chunk-KZ6UAKVY.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-WLJU7OX2.mjs → chunk-LN55QJTY.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-4X7TCSFW.mjs → chunk-MCESDV7T.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-BHQ3JLKY.mjs → chunk-MIB25WM5.mjs} +4 -4
  45. package/dist-lib/esm-chunks/{chunk-HSSAEZKK.mjs → chunk-NET7R6JQ.mjs} +6 -6
  46. package/dist-lib/esm-chunks/{chunk-M4IBIRSF.mjs → chunk-QZIWFRDI.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-4T5622XC.mjs → chunk-RICNI6K7.mjs} +3 -3
  48. package/dist-lib/esm-chunks/{chunk-TJ5Y26RK.mjs → chunk-VRIDWK4F.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-4QDKSAM6.mjs → chunk-YHFSPPEY.mjs} +16 -16
  50. package/dist-lib/esm-chunks/{chunk-22IVJ37E.mjs → chunk-ZIU5CFK4.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-NZ5LDDDY.mjs → metro-layout-parser-IRQ5U7LT.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-YUCWJYTO.mjs → swift-package-prebuilt-I3H6PNXA.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-AJD2DGDE.mjs → swift-sdk-app-module-GVKIKJFL.mjs} +16 -16
  54. package/dist-lib/esm-chunks/{swift-sdk-image-7SWUP4QR.mjs → swift-sdk-image-SQUIDGQL.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-RISXYQ6A.mjs → swift-sdk-image-producer-HTOOFVQH.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +5923 -1534
  57. package/dist-lib/expo-swift-metadata.cjs +2 -2
  58. package/dist-lib/expo-swift-metadata.mjs +8 -8
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +832 -696
  61. package/dist-lib/host/fetch-proxy-handler.cjs +86 -83
  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 +410 -304
  75. package/dist-lib/native-app-identity-project.mjs +418 -312
  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 +87 -85
  87. package/dist-lib/public-origins-lib.json +84 -72
  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 +873 -736
  95. package/dist-lib/swift-compile.cjs +5 -4
  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/engine/native-image-pipeline.d.ts +3 -1
  123. package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +1 -1
  124. package/dist-types/packages/peach-engine/src/render-worker/webgpu-frame-transaction.d.ts +2 -1
  125. package/package.json +1 -1
  126. package/runtime-companion.json +1 -1
  127. package/src/expo-swift-bundle.ts +2 -7
  128. package/src/expo-swift-host.ts +93 -34
  129. package/src/expoSwiftContract.ts +9 -0
  130. package/src/native-bundles.ts +6 -0
  131. package/src/nitro-bundle.ts +5 -2
  132. package/src/swift-compile.ts +1 -1
  133. package/src/swift-host.ts +16 -0
  134. package/src/swift-sdk-surface.ts +3 -4
  135. package/src/swift-xcframework.ts +13 -7
  136. package/src/turbo-codegen-intake.ts +4 -1
  137. package/src/turbo-source.ts +61 -43
  138. package/src/xcode-project.ts +57 -0
@@ -64,6 +64,7 @@ import {
64
64
  icuUrl,
65
65
  installedWorkspaceInput,
66
66
  withXcodeProject,
67
+ prepareSwiftSdkEntryAssets,
67
68
  projectFor,
68
69
  serveSwiftPackageAsset,
69
70
  sourceContentStamp,
@@ -89,6 +90,7 @@ import { swiftRootLocksDir } from './swift-root-lock'
89
90
  import { standinGenerationInputs, swiftStandins } from './swift-standins'
90
91
  import { MAX_SWIFT_COMPILE_FILES, MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
91
92
  import { swiftCacheDir } from './swift-toolchain'
93
+ import { RENDERER_DEPENDENCY_PODS } from './turbo-codegen-intake'
92
94
  import { registersReactModule } from './turbo-source'
93
95
  import type { PeachConfig } from './config'
94
96
  import type {
@@ -655,6 +657,9 @@ function retarget(cached: PreparedEntry, base: string): ExpoSwiftCompilationResu
655
657
  for (const module of result.modules) {
656
658
  module.url = replaceBase(module.url, cached.base, base)
657
659
  module.icuUrl = replaceBase(module.icuUrl, cached.base, base)
660
+ if (module.sdkUrl) module.sdkUrl = replaceBase(module.sdkUrl, cached.base, base)
661
+ if (module.sdkBindingUrl)
662
+ module.sdkBindingUrl = replaceBase(module.sdkBindingUrl, cached.base, base)
658
663
  }
659
664
  return result
660
665
  }
@@ -755,6 +760,9 @@ function enrichInstalledUnits(
755
760
  : []
756
761
  }),
757
762
  )
763
+ // the prebuilt core compiles these from react native's podspecs.
764
+ for (const name of RENDERER_DEPENDENCY_PODS)
765
+ if (targetByName.has(name)) reactTargets.add(name)
758
766
  for (const [file, source] of Object.entries(installed.sourcePaths)) {
759
767
  if (!file.endsWith('.swift') || !fs.realpathSync(source).startsWith(reactNativeRoot))
760
768
  continue
@@ -790,10 +798,22 @@ function enrichInstalledUnits(
790
798
  map(file),
791
799
  ]),
792
800
  )
793
- // frameworks supplied by the runtime or the React Native provider still publish headers.
801
+ // frameworks supplied by the runtime or the React Native provider (and their
802
+ // transitive dependencies, such as ExpoModulesJSI under ExpoModulesCore) still
803
+ // publish headers even though their targets are not compiled into each unit.
804
+ const publishedFrameworkTargets = new Set<string>([...provided, ...reactTargets])
805
+ const frameworkQueue = [...publishedFrameworkTargets]
806
+ while (frameworkQueue.length > 0) {
807
+ const name = frameworkQueue.pop()!
808
+ for (const dependency of importedTargets.get(name) ?? []) {
809
+ if (publishedFrameworkTargets.has(dependency)) continue
810
+ publishedFrameworkTargets.add(dependency)
811
+ frameworkQueue.push(dependency)
812
+ }
813
+ }
794
814
  for (const target of input.nativeTargets ?? []) {
795
815
  const runtimeModule = provided.has(target.name)
796
- if (!runtimeModule && !reactTargets.has(target.name)) continue
816
+ if (!publishedFrameworkTargets.has(target.name)) continue
797
817
  const swift = runtimeModule ? swiftModuleInterface(moduleRoot, target.name) : null
798
818
  const refineClangTypes = clangTypeOwnership(moduleRoot, target.name)
799
819
  const interfaceName = `${target.name}-Swift.h`
@@ -2801,7 +2821,6 @@ async function compileExpoSwiftModulesTraced(
2801
2821
  linkedLibraries.set(name, library)
2802
2822
  }
2803
2823
  projectFor(packagePath).oneModule = false
2804
- projectFor(packagePath).standalone = true
2805
2824
  projectFor(packagePath).optimize = true
2806
2825
  projectFor(packagePath).staticClangTargets = provider?.staticClangTargets
2807
2826
  projectFor(packagePath).binaryModules = Object.fromEntries([
@@ -2993,8 +3012,8 @@ async function compileExpoSwiftModulesTraced(
2993
3012
  return prepared
2994
3013
  }
2995
3014
  }
2996
- const link = async (linked: ExpoSwiftSourceUnit[]) => {
2997
- const packagePath = expoSwiftPackage(key, 'linked-app')
3015
+ const link = async (linked: ExpoSwiftSourceUnit[], name = 'linked-app') => {
3016
+ const packagePath = expoSwiftPackage(key, name)
2998
3017
  preparePackage(linked, packagePath)
2999
3018
  signal.throwIfAborted()
3000
3019
  const stamp = sourceContentStamp(packagePath, module.root)
@@ -3046,12 +3065,9 @@ async function compileExpoSwiftModulesTraced(
3046
3065
  linkError instanceof Error ? linkError.message : String(linkError)
3047
3066
  report('linked build failed; isolating module diagnostics')
3048
3067
  for (const line of combined.split('\n')) report(line)
3049
- // each isolated build recompiles every native dependency, so checking
3050
- // all namespaces costs one full build apiece. a combined diagnostic
3051
- // names failing namespaces by build copy, app source or a module Peach
3052
- // lacks that they import: link the rest, narrowing again while each
3053
- // failed link names some of what it held, and isolate only the named,
3054
- // or every namespace when no narrowed link succeeds.
3068
+ // each isolated build recompiles every native dependency, so it costs one
3069
+ // full build. a combined diagnostic names failing namespaces by build
3070
+ // copy, app source, shared header or a module Peach lacks that they import.
3055
3071
  const namedBy = (error: unknown, pool: ExpoSwiftSourceUnit[]) => {
3056
3072
  const message = error instanceof Error ? error.message : String(error)
3057
3073
  const errorFiles = message.match(/^.+?(?=:\d+(?::\d+)?: error:)/gm) ?? []
@@ -3067,9 +3083,18 @@ async function compileExpoSwiftModulesTraced(
3067
3083
  ? [...message.matchAll(/^ (\S+)/gm)].map((match) => match[1])
3068
3084
  : [],
3069
3085
  )
3086
+ // a bridging or prefix header compiles into every unit of its target.
3070
3087
  return pool.filter(
3071
3088
  (unit) =>
3072
- [...Object.keys(unit.files), ...expoUnitAppPaths(unit)].some(
3089
+ [
3090
+ ...Object.keys(unit.files),
3091
+ ...expoUnitAppPaths(unit),
3092
+ ...(unit.nativeTargets ?? []).flatMap((native) =>
3093
+ [native.bridgingHeader, native.prefixHeader].filter(
3094
+ (file): file is string => file !== null,
3095
+ ),
3096
+ ),
3097
+ ].some(
3073
3098
  (name) =>
3074
3099
  nativeCopies.includes(name) ||
3075
3100
  errorFiles.some((file) => file === name || file.endsWith(`/${name}`)),
@@ -3079,28 +3104,14 @@ async function compileExpoSwiftModulesTraced(
3079
3104
  ),
3080
3105
  )
3081
3106
  }
3082
- let checked = candidates
3083
3107
  linked = []
3084
- let rest = candidates
3085
- let failure = linkError
3086
- for (;;) {
3087
- const named = namedBy(failure, rest)
3088
- if (named.length === 0 || named.length === rest.length) break
3089
- rest = rest.filter((unit) => !named.includes(unit))
3090
- report(`linking ${rest.length} namespaces the diagnostic does not name`)
3091
- try {
3092
- artifact = await link(rest)
3093
- linked = rest
3094
- checked = candidates.filter((unit) => !rest.includes(unit))
3095
- break
3096
- } catch (error) {
3097
- signal.throwIfAborted()
3098
- if (error instanceof ExpoSwiftLinkRefusal) throw error
3099
- failure = error
3100
- }
3101
- }
3102
- const linkedWithoutChecks = linked.length
3103
- for (const unit of checked) {
3108
+ let isolatedArtifact:
3109
+ | {
3110
+ units: ExpoSwiftSourceUnit[]
3111
+ artifact: import('./swift-host').SwiftArtifact
3112
+ }
3113
+ | undefined
3114
+ const check = async (unit: ExpoSwiftSourceUnit) => {
3104
3115
  signal.throwIfAborted()
3105
3116
  const packagePath = expoSwiftPackage(key, unit.moduleId)
3106
3117
  preparePackage([unit], packagePath)
@@ -3176,9 +3187,55 @@ async function compileExpoSwiftModulesTraced(
3176
3187
  )
3177
3188
  }
3178
3189
  }
3190
+ // a failed group splits into the namespaces its diagnostic names, each
3191
+ // built alone, and a group of the rest; one naming none splits in half.
3192
+ // k failing namespaces cost about k*log(n) builds, not one per namespace.
3193
+ const isolate = async (
3194
+ group: ExpoSwiftSourceUnit[],
3195
+ failure: unknown,
3196
+ ): Promise<void> => {
3197
+ const named = namedBy(failure, group)
3198
+ if (group !== candidates)
3199
+ report(
3200
+ `${group.length} namespaces failed${named.length ? `, naming ${named.map((unit) => unit.moduleId).join(', ')}` : ''}: ${(failure instanceof Error ? failure.message : String(failure)).match(/^.+: error: .*$/m)?.[0] ?? 'no source error'}`,
3201
+ )
3202
+ const half = Math.ceil(group.length / 2)
3203
+ const parts =
3204
+ named.length > 0 && named.length < group.length
3205
+ ? [
3206
+ ...named.map((unit) => [unit]),
3207
+ group.filter((unit) => !named.includes(unit)),
3208
+ ]
3209
+ : [group.slice(0, half), group.slice(half)]
3210
+ for (const part of parts) {
3211
+ signal.throwIfAborted()
3212
+ if (part.length === 0) continue
3213
+ if (part.length === 1) {
3214
+ await check(part[0]!)
3215
+ continue
3216
+ }
3217
+ const name = createHash('sha256')
3218
+ .update(part.map((unit) => unit.moduleId).join('\0'))
3219
+ .digest('hex')
3220
+ .slice(0, 16)
3221
+ report(`linking ${part.length} namespaces to isolate failures`)
3222
+ try {
3223
+ const built = await link(part, `isolate-${name}`)
3224
+ linked.push(...part)
3225
+ isolatedArtifact = { units: part, artifact: built }
3226
+ } catch (error) {
3227
+ signal.throwIfAborted()
3228
+ if (error instanceof ExpoSwiftLinkRefusal) throw error
3229
+ await isolate(part, error)
3230
+ }
3231
+ }
3232
+ }
3233
+ await isolate(candidates, linkError)
3179
3234
  // every namespace compiles alone, so the link itself is what failed.
3180
3235
  if (linked.length === candidates.length) throw linkError
3181
- if (linked.length > linkedWithoutChecks) {
3236
+ if (isolatedArtifact?.units.length === linked.length)
3237
+ artifact = isolatedArtifact.artifact
3238
+ else if (linked.length) {
3182
3239
  try {
3183
3240
  artifact = await link(linked)
3184
3241
  } catch (error) {
@@ -3211,10 +3268,12 @@ async function compileExpoSwiftModulesTraced(
3211
3268
  }
3212
3269
  if (artifact) {
3213
3270
  signal.throwIfAborted()
3271
+ const sdkAssets = await prepareSwiftSdkEntryAssets(base, artifact)
3214
3272
  await publishArtifact?.(artifact, signal)
3215
3273
  result.modules.push({
3216
3274
  namespaces: linked.map((unit) => unit.moduleId),
3217
3275
  url: `${base}/__peach/swift/${artifact.hash}.wasm`,
3276
+ ...sdkAssets,
3218
3277
  hash: artifact.hash,
3219
3278
  icuUrl: icuUrl(base, artifact),
3220
3279
  rootId: `${key}/Expo`,
@@ -58,6 +58,8 @@ export interface ExpoSwiftSourceUnit {
58
58
  export interface ExpoSwiftCompiledModule {
59
59
  namespaces: string[]
60
60
  url: string
61
+ sdkUrl?: string
62
+ sdkBindingUrl?: string
61
63
  hash: string
62
64
  icuUrl: string
63
65
  rootId: string
@@ -118,6 +120,13 @@ export function isExpoSwiftCompilationResult(
118
120
  artifact.namespaces.length === 0 ||
119
121
  !artifact.namespaces.every((namespace) => remaining.delete(namespace)) ||
120
122
  typeof artifact.url !== 'string' ||
123
+ !(
124
+ (artifact.sdkUrl === undefined && artifact.sdkBindingUrl === undefined) ||
125
+ (typeof artifact.sdkUrl === 'string' &&
126
+ artifact.sdkUrl.length > 0 &&
127
+ typeof artifact.sdkBindingUrl === 'string' &&
128
+ artifact.sdkBindingUrl.length > 0)
129
+ ) ||
121
130
  typeof artifact.hash !== 'string' ||
122
131
  typeof artifact.icuUrl !== 'string' ||
123
132
  typeof artifact.rootId !== 'string' ||
@@ -54,6 +54,8 @@ export async function buildIosSwiftBundles(
54
54
  url: linked.url,
55
55
  hash: linked.hash,
56
56
  icuUrl: linked.icuUrl,
57
+ ...(linked.sdkUrl ? { sdkUrl: linked.sdkUrl } : {}),
58
+ ...(linked.sdkBindingUrl ? { sdkBindingUrl: linked.sdkBindingUrl } : {}),
57
59
  rootId: `${linked.rootId.split('/')[0]}/OneSDK`,
58
60
  bundleFiles: linked.bundleFiles ?? {},
59
61
  modules: oneSDK.modules,
@@ -152,6 +154,10 @@ export function insertNativeBundleFooters(
152
154
  ...artifact,
153
155
  url: served(artifact.url),
154
156
  icuUrl: served(artifact.icuUrl),
157
+ ...(artifact.sdkUrl ? { sdkUrl: served(artifact.sdkUrl) } : {}),
158
+ ...(artifact.sdkBindingUrl
159
+ ? { sdkBindingUrl: served(artifact.sdkBindingUrl) }
160
+ : {}),
155
161
  })),
156
162
  }
157
163
  source = insertExpoSwiftFooter(source, metadata.expoSwift)
@@ -10,9 +10,9 @@ import { compileNitroModule } from './nitro-compile'
10
10
  import { swiftDistributionRoot } from './swift-distribution'
11
11
  import {
12
12
  icuUrl,
13
+ prepareSwiftSdkEntryAssets,
13
14
  swiftArtifactAssets,
14
15
  swiftArtifactIsAvailable,
15
- swiftSdkEntryAssets,
16
16
  type SwiftArtifact,
17
17
  } from './swift-host'
18
18
  import type { NitroBuildConfiguration, NitroCompiledModule } from './nitroContract'
@@ -107,7 +107,10 @@ export async function compileNitroApp(
107
107
  export async function compiledModuleAssets(
108
108
  artifact: SwiftArtifact,
109
109
  ): Promise<CompiledModuleAsset[]> {
110
- const assets = await swiftArtifactAssets(artifact, swiftSdkEntryAssets('', artifact))
110
+ const assets = await swiftArtifactAssets(
111
+ artifact,
112
+ await prepareSwiftSdkEntryAssets('', artifact),
113
+ )
111
114
  return [...assets].map(([address, asset]) => ({ path: address.slice(1), ...asset }))
112
115
  }
113
116
 
@@ -380,7 +380,7 @@ const SWIFTPM_NOISE =
380
380
  /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/
381
381
 
382
382
  function swiftCompilerJobs(): number {
383
- return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(os.totalmem() / 2 ** 31)))
383
+ return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(os.totalmem() / 2 ** 31)))
384
384
  }
385
385
 
386
386
  // swiftpm hashes the entire process environment into its build plan signature,
package/src/swift-host.ts CHANGED
@@ -4282,6 +4282,22 @@ export function swiftSdkEntryAssets(
4282
4282
  }
4283
4283
  }
4284
4284
 
4285
+ export async function prepareSwiftSdkEntryAssets(
4286
+ origin: string,
4287
+ image: SwiftArtifact,
4288
+ sdkDigest = image.sdk?.sha256,
4289
+ ) {
4290
+ if (image.sdk && !image.hostedSdk) {
4291
+ const published = publishedSwiftSdk(image.sdk.sha256)
4292
+ if (published?.dataPlan) {
4293
+ const { fetchSwiftSdkDataPlan } = await import('./swift-sdk-later-data')
4294
+ const plan = await fetchSwiftSdkDataPlan(published)
4295
+ if (plan) await splitSdkBinding(image.sdk, published.dataPlan, plan)
4296
+ }
4297
+ }
4298
+ return swiftSdkEntryAssets(origin, image, sdkDigest)
4299
+ }
4300
+
4285
4301
  // each app opened on an sdk image profiles its startup once; the split serves them all
4286
4302
  function swiftSdkStartup(
4287
4303
  sdk: SwiftSdkModuleAsset,
@@ -54,10 +54,9 @@ export function swiftBuildJobs(): number {
54
54
  process.env.TM_EXEC_ADMITTED === '1' && process.env.LINUX_BUILD_SCOPE
55
55
  ? Number(process.env.TM_EXEC_LINUX_MEMORY_MAX)
56
56
  : NaN
57
- const memoryJobs =
58
- Number.isSafeInteger(memory) && memory > 0
59
- ? Math.max(1, Math.floor(memory / (2 * 1024 ** 3)))
60
- : 8
57
+ const effectiveMemory =
58
+ Number.isSafeInteger(memory) && memory > 0 ? memory : os.totalmem()
59
+ const memoryJobs = Math.max(1, Math.floor(effectiveMemory / (2 * 1024 ** 3)))
61
60
  return Math.min(cores, memoryJobs)
62
61
  }
63
62
 
@@ -1,4 +1,5 @@
1
- // the original library declared for an iOS simulator slice.
1
+ // the original library declared for an iOS simulator slice, and the slice
2
+ // directory a copy of the xcframework installs.
2
3
  import fs from 'node:fs'
3
4
  import path from 'node:path'
4
5
  import { isRecord } from './is-record'
@@ -6,13 +7,18 @@ import { parsePlistBytes } from './plist-bytes'
6
7
  import { relativeInside } from './swift-source-file'
7
8
 
8
9
  type SimulatorNativeLibrary =
9
- | { name: string; file: string; kind: 'archive'; headers?: string }
10
- | { name: string; file: string; kind: 'framework' }
10
+ | { name: string; file: string; slice: string; kind: 'archive'; headers?: string }
11
+ | { name: string; file: string; slice: string; kind: 'framework' }
11
12
 
12
13
  export function simulatorNativeLibrary(dir: string): SimulatorNativeLibrary | null {
13
14
  if (dir.endsWith('.framework')) {
14
15
  const name = path.basename(dir, '.framework')
15
- return { name, file: path.join(dir, name), kind: 'framework' }
16
+ return {
17
+ name,
18
+ file: path.join(dir, name),
19
+ slice: path.dirname(dir),
20
+ kind: 'framework',
21
+ }
16
22
  }
17
23
  if (!dir.endsWith('.xcframework')) return null
18
24
  const info = parsePlistBytes(fs.readFileSync(path.join(dir, 'Info.plist')))
@@ -34,6 +40,7 @@ export function simulatorNativeLibrary(dir: string): SimulatorNativeLibrary | nu
34
40
  const archive = /\.a$/.test(entry.LibraryPath)
35
41
  const framework = /\.framework$/.test(entry.LibraryPath)
36
42
  if (!archive && !framework) continue
43
+ const slice = path.resolve(dir, entry.LibraryIdentifier)
37
44
  const bundle = path.resolve(dir, entry.LibraryIdentifier, entry.LibraryPath)
38
45
  const bundleRelative = path.relative(dir, bundle)
39
46
  if (bundleRelative.startsWith('..') || path.isAbsolute(bundleRelative))
@@ -48,17 +55,16 @@ export function simulatorNativeLibrary(dir: string): SimulatorNativeLibrary | nu
48
55
  if (relative.startsWith('..') || path.isAbsolute(relative))
49
56
  throw new Error(`${dir}: library escapes its XCFramework`)
50
57
  if (framework) {
51
- matches.push({ name, file, kind: 'framework' })
58
+ matches.push({ name, file, slice, kind: 'framework' })
52
59
  continue
53
60
  }
54
- const slice = path.resolve(dir, entry.LibraryIdentifier)
55
61
  const headers =
56
62
  typeof entry.HeadersPath === 'string'
57
63
  ? path.resolve(slice, entry.HeadersPath)
58
64
  : undefined
59
65
  if (headers && relativeInside(slice, headers) === null)
60
66
  throw new Error(`${dir}: headers escape their XCFramework slice`)
61
- matches.push({ name, file, kind: 'archive', headers })
67
+ matches.push({ name, file, slice, kind: 'archive', headers })
62
68
  }
63
69
  if (matches.length === 0) return null
64
70
  if (matches.length !== 1) throw new Error(`${dir}: ambiguous simulator library`)
@@ -27,12 +27,15 @@ import {
27
27
  const run = promisify(execFile)
28
28
 
29
29
  /** native source globs the installed third-party podspecs declare. */
30
+ /** the third-party pods react native's own podspecs vendor into the renderer core. */
31
+ export const RENDERER_DEPENDENCY_PODS = ['RCT-Folly', 'DoubleConversion', 'fmt']
32
+
30
33
  export function installedRendererDependencyGlobs(
31
34
  reactNativeRoot: string,
32
35
  appRoot: string,
33
36
  ): Record<string, string[]> {
34
37
  return Object.fromEntries(
35
- ['RCT-Folly', 'DoubleConversion', 'fmt'].map((name) => {
38
+ RENDERER_DEPENDENCY_PODS.map((name) => {
36
39
  const spec = loadPodspec(
37
40
  path.join(reactNativeRoot, 'third-party-podspecs', `${name}.podspec`),
38
41
  appRoot,
@@ -401,6 +401,22 @@ function walkFiles(root: string, base: string, into: Set<string>): void {
401
401
  }
402
402
 
403
403
  const podspecList = podspecAttribute
404
+ const reactNativePods = new Set([
405
+ 'React',
406
+ 'ReactCommon',
407
+ 'ReactCodegen',
408
+ 'ReactNativeDependencies',
409
+ 'hermes-engine',
410
+ 'FBLazyVector',
411
+ 'DoubleConversion',
412
+ 'glog',
413
+ 'boost',
414
+ 'fmt',
415
+ 'fast_float',
416
+ 'Yoga',
417
+ ])
418
+ const reactNativePod = (name: string) =>
419
+ reactNativePods.has(name) || name.startsWith('React-') || name.startsWith('RCT')
404
420
 
405
421
  /** the external pods a podspec depends on; "subspecs" holds every requested subspec path across its dependency lines, "" for the pod itself. */
406
422
  function podspecDependencies(
@@ -422,25 +438,7 @@ function podspecDependencies(
422
438
  )
423
439
  throw new Error(`${pod.file}: invalid requirements for ${name}`)
424
440
  const [root, ...subspec] = name.split('/')
425
- if (
426
- root === pod.name ||
427
- root === 'React' ||
428
- root === 'React-Core' ||
429
- root === 'ReactCommon' ||
430
- root === 'ReactCodegen' ||
431
- root === 'ReactNativeDependencies' ||
432
- root === 'hermes-engine' ||
433
- root!.startsWith('React-') ||
434
- root!.startsWith('RCT') ||
435
- root === 'FBLazyVector' ||
436
- root === 'DoubleConversion' ||
437
- root === 'glog' ||
438
- root === 'boost' ||
439
- root === 'fmt' ||
440
- root === 'fast_float' ||
441
- root === 'Yoga'
442
- )
443
- continue
441
+ if (root === pod.name || reactNativePod(root!)) continue
444
442
  // every declaration of a pod must hold: CocoaPods intersects their requirements
445
443
  const dep = deps.get(root!) ?? { name: root!, requirements: [], subspecs: [] }
446
444
  dep.requirements.push(...requirements)
@@ -1279,7 +1277,7 @@ export async function collectTurboSources(options: {
1279
1277
  ...folly.defines,
1280
1278
  ]
1281
1279
  const defines = [...baseDefines, 'RCT_NEW_ARCH_ENABLED=1', 'RCT_REMOVE_LEGACY_ARCH=1']
1282
- const target = (name: string, dependencies: string[]) => ({
1280
+ const target = (name: string, dependencies: string[], cxxDefines = defines) => ({
1283
1281
  name,
1284
1282
  path: targetPath(name),
1285
1283
  executable: false,
@@ -1290,7 +1288,7 @@ export async function collectTurboSources(options: {
1290
1288
  kind: 'target' as const,
1291
1289
  name: dependency,
1292
1290
  })),
1293
- cxxDefines: defines,
1291
+ cxxDefines,
1294
1292
  })
1295
1293
  const result: TurboSourceCollection = {
1296
1294
  coreMode: 'turbo-cxx',
@@ -1343,6 +1341,9 @@ export async function collectTurboSources(options: {
1343
1341
  installedPods: true,
1344
1342
  }).frameworks
1345
1343
  : []
1344
+ const installedByIdentity = new Map(
1345
+ installedTargets.map((target) => [target.targetIdentity, target]),
1346
+ )
1346
1347
  // a file the pod compiles with its own flags also keeps the pod's generated
1347
1348
  // prefix header, which imports UIKit for every unit as GCC_PREFIX_HEADER does.
1348
1349
  const fileFlags = new Map(
@@ -1552,6 +1553,22 @@ export async function collectTurboSources(options: {
1552
1553
  // header lookup takes regular files only, so <ios> passes over an ios directory
1553
1554
  const isHeaderFile = (file: string) =>
1554
1555
  fs.statSync(file, { throwIfNoEntry: false })?.isFile() ?? false
1556
+ const installedDependencyHeader = (from: Scan, root: string, relative: string) => {
1557
+ const provider = podHeaders.get(from.targetName)
1558
+ const providerFile = provider
1559
+ ? relativeInside(provider.root, path.join(root, relative))
1560
+ : null
1561
+ if (provider && providerFile !== null)
1562
+ return original(from.targetName, provider.label, provider.root, providerFile, false)
1563
+ // the workspace is a copy of the app. preserve the pod-relative identity
1564
+ // when a header arrives through a cocoapods search path or header map.
1565
+ for (const pod of installedHeaderPods) {
1566
+ const directory = relativeInside(options.appRoot, pod.root)
1567
+ const file = directory === null ? null : relativeInside(directory, relative)
1568
+ if (file !== null) return original(from.targetName, pod.name, pod.root, file, false)
1569
+ }
1570
+ return original(from.targetName, 'installed-dependency', root, relative, false)
1571
+ }
1555
1572
  const resolve = (from: Scan, include: string, quoted: boolean) => {
1556
1573
  if (quoted) {
1557
1574
  const relative = path.posix.normalize(
@@ -1732,19 +1749,7 @@ export async function collectTurboSources(options: {
1732
1749
  : (pod?.dependencyHeaderMaps.filter(({ flag }) => flag === '-I') ?? [])) {
1733
1750
  const relative = map.headers.get(include)
1734
1751
  if (relative === undefined) continue
1735
- // the workspace is a copy of the app. use the same pod-relative source
1736
- // identity as public-header lookup so pragma once sees one file.
1737
- const owner = installedHeaderPods.flatMap((candidate) => {
1738
- const root = relativeInside(options.appRoot, candidate.root)
1739
- const file = root === null ? null : relativeInside(root, relative)
1740
- return file === null ? [] : [{ pod: candidate, file }]
1741
- })[0]
1742
- alias(
1743
- own,
1744
- owner
1745
- ? original(from.targetName, owner.pod.name, owner.pod.root, owner.file, false)
1746
- : original(from.targetName, 'installed-dependency', map.root, relative, false),
1747
- )
1752
+ alias(own, installedDependencyHeader(from, map.root, relative))
1748
1753
  return
1749
1754
  }
1750
1755
  // preserve installed cross-pod search roots without copying every header
@@ -1756,10 +1761,7 @@ export async function collectTurboSources(options: {
1756
1761
  const relative = relativeInside(search.root, file)
1757
1762
  if (relative === null)
1758
1763
  throw new Error('installed dependency header escapes its workspace: ' + candidate)
1759
- alias(
1760
- own,
1761
- original(from.targetName, 'installed-dependency', search.root, relative, false),
1762
- )
1764
+ alias(own, installedDependencyHeader(from, search.root, relative))
1763
1765
  return
1764
1766
  }
1765
1767
  resolveDependency(include)
@@ -1898,16 +1900,18 @@ export async function collectTurboSources(options: {
1898
1900
  for (const provider of providers) {
1899
1901
  const targetName = providerTarget(provider.info.name)
1900
1902
  const label = provider.info.name
1901
- const providerTargetInput: SwiftPackageTarget = target(targetName, [
1902
- TURBO_CORE_TARGET,
1903
- ])
1903
+ const providerDefines = provider.paper ? baseDefines : defines
1904
+ const providerTargetInput: SwiftPackageTarget = target(
1905
+ targetName,
1906
+ [TURBO_CORE_TARGET],
1907
+ providerDefines,
1908
+ )
1904
1909
  result.targets.push(providerTargetInput)
1905
1910
  const pod = readPod(
1906
1911
  provider,
1907
1912
  options.appRoot,
1908
1913
  options.installedPods?.get(provider.name),
1909
1914
  )
1910
- if (provider.paper) providerTargetInput.cxxDefines = baseDefines
1911
1915
  if (pod.installed)
1912
1916
  providerTargetInput.clangSettings = [
1913
1917
  { tool: 'c', flags: pod.installed.preprocessorFlags.c },
@@ -2072,7 +2076,9 @@ export async function collectTurboSources(options: {
2072
2076
  files: string[]
2073
2077
  }[] = []
2074
2078
  const externalDefines: string[] = []
2075
- for (const dep of podspecDependencies(pod)) {
2079
+ const dependencies = podspecDependencies(pod)
2080
+ const seenDependencies = new Set([pod.name, ...dependencies.map(({ name }) => name)])
2081
+ for (const dep of dependencies) {
2076
2082
  const installed = installedHeaderPods.find(
2077
2083
  (candidate) => candidate.name === dep.name,
2078
2084
  )
@@ -2115,6 +2121,17 @@ export async function collectTurboSources(options: {
2115
2121
  if (!resolved) continue
2116
2122
  if (provider.reactModulesOnly && resolved.files.some((f) => f.endsWith('.swift')))
2117
2123
  continue
2124
+ for (const identity of installedTarget?.targetDependencies ?? []) {
2125
+ const dependency = installedByIdentity.get(identity)
2126
+ if (
2127
+ !dependency?.podRoot ||
2128
+ seenDependencies.has(dependency.name) ||
2129
+ reactNativePod(dependency.name)
2130
+ )
2131
+ continue
2132
+ seenDependencies.add(dependency.name)
2133
+ dependencies.push({ name: dependency.name, requirements: [], subspecs: [''] })
2134
+ }
2118
2135
  externalDefines.push(...resolved.defines)
2119
2136
  const mappings = installed ? podHeaderMappings(installed) : []
2120
2137
  const swiftFilesForDep: string[] = []
@@ -2200,6 +2217,7 @@ export async function collectTurboSources(options: {
2200
2217
  ...target(
2201
2218
  swiftModule,
2202
2219
  depSwiftPods.map((dep) => dep.moduleName),
2220
+ providerDefines,
2203
2221
  ),
2204
2222
  cxxInterop: true,
2205
2223
  })