peachsim 0.1.2674 → 0.1.2676

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 (142) 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 +105 -67
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-7UZN4VYK.mjs → acorn-YQ2Y333V.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-BVXC4YET.mjs → chunk-25EMRCS4.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-ASL76C2M.mjs → chunk-3TL2TT2H.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-Y3Y67ML7.mjs → chunk-4Q6YODSW.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-6MQE6NHP.mjs → chunk-5EH6JZZK.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-5HLALTZU.mjs → chunk-626GTL22.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-UR4364IC.mjs → chunk-A35OFKUL.mjs} +15 -15
  33. package/dist-lib/esm-chunks/{chunk-JN5AITFW.mjs → chunk-B3U6FXEV.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-K6YX77B2.mjs → chunk-D575CGCI.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-TCJINVW7.mjs → chunk-DG6QGBQR.mjs} +6 -6
  36. package/dist-lib/esm-chunks/{chunk-PGWO5WJS.mjs → chunk-FVUPL6XV.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-DDKNMOMP.mjs → chunk-FWXP663K.mjs} +5 -5
  38. package/dist-lib/esm-chunks/{chunk-64GNURGG.mjs → chunk-HKPMHGF2.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-OICCOALD.mjs → chunk-JSIHMPMM.mjs} +4 -4
  40. package/dist-lib/esm-chunks/{chunk-S6FAF3O6.mjs → chunk-KLFBECKK.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-YTLETAHS.mjs → chunk-LF6SZQV5.mjs} +2 -2
  42. package/dist-lib/esm-chunks/{chunk-UQLURJW5.mjs → chunk-MPFHNHE7.mjs} +6 -6
  43. package/dist-lib/esm-chunks/{chunk-7LVYKI6B.mjs → chunk-QGE6LXQT.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-GY2LAJOJ.mjs → chunk-QRFI6Y4S.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-JGCL2DFM.mjs → chunk-RADKK7SO.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-GR6LZLL3.mjs → chunk-S6J4D2JN.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-UYNBXPDJ.mjs → chunk-UANRG6RG.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-OSSY6ZNV.mjs → chunk-VBRL6FF3.mjs} +3 -3
  49. package/dist-lib/esm-chunks/{chunk-YTVAFL2C.mjs → chunk-VUPCH2NW.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-54JOIACB.mjs → chunk-ZK5FTTPS.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-SIV4DJUF.mjs → metro-layout-parser-AVSCGHIP.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-U4TO4A5N.mjs → swift-package-prebuilt-WAUVHTJ6.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-J5OL6AQS.mjs → swift-sdk-app-module-SMITHJSE.mjs} +16 -16
  54. package/dist-lib/esm-chunks/{swift-sdk-image-CV5NS7AQ.mjs → swift-sdk-image-A3PUVC5O.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-I4HX7YZO.mjs → swift-sdk-image-producer-5OLYXCL2.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +75 -42
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +3181 -865
  61. package/dist-lib/host/fetch-proxy-handler.cjs +12 -11
  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 +20 -4
  75. package/dist-lib/native-app-identity-project.mjs +34 -18
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +85 -85
  87. package/dist-lib/public-origins-lib.json +68 -64
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +3569 -1253
  95. package/dist-lib/swift-compile.cjs +2 -2
  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/remote-stream/client-config.d.ts +4 -0
  123. package/package.json +1 -1
  124. package/sdk/ios/System/Library/Frameworks/AssetsLibrary.framework/Headers/ALAsset.h +14 -0
  125. package/sdk/ios/System/Library/Frameworks/AssetsLibrary.framework/Headers/ALAssetRepresentation.h +20 -0
  126. package/sdk/ios/System/Library/Frameworks/AssetsLibrary.framework/Headers/ALAssetsLibrary.h +71 -0
  127. package/sdk/ios/System/Library/Frameworks/AssetsLibrary.framework/Headers/AssetsLibrary.h +5 -0
  128. package/sdk/ios/System/Library/Frameworks/AssetsLibrary.framework/Modules/module.modulemap +5 -0
  129. package/sdk/ios/System/Library/Frameworks/BackgroundTasks.framework/Headers/BGTask.h +21 -0
  130. package/sdk/ios/System/Library/Frameworks/BackgroundTasks.framework/Headers/BGTaskRequest.h +24 -0
  131. package/sdk/ios/System/Library/Frameworks/BackgroundTasks.framework/Headers/BGTaskScheduler.h +32 -0
  132. package/sdk/ios/System/Library/Frameworks/BackgroundTasks.framework/Headers/BackgroundTasks.h +5 -0
  133. package/sdk/ios/System/Library/Frameworks/BackgroundTasks.framework/Modules/module.modulemap +5 -0
  134. package/sdk/ios/System/Library/Frameworks/LinkPresentation.framework/Headers/LPLinkMetadata.h +17 -0
  135. package/sdk/ios/System/Library/Frameworks/LinkPresentation.framework/Headers/LPMetadataProvider.h +18 -0
  136. package/sdk/ios/System/Library/Frameworks/LinkPresentation.framework/Headers/LinkPresentation.h +4 -0
  137. package/sdk/ios/System/Library/Frameworks/LinkPresentation.framework/Modules/module.modulemap +5 -0
  138. package/src/expo-native-workspace.ts +3 -4
  139. package/src/one-direct-host-source.ts +1934 -0
  140. package/src/one-native-controls-package.ts +157 -21
  141. package/src/turbo-source.ts +60 -23
  142. package/src/xcode-project.ts +30 -2
@@ -6,6 +6,12 @@ import { createRequire } from 'node:module'
6
6
  import path from 'node:path'
7
7
  import { fileURLToPath } from 'node:url'
8
8
  import { swiftGuestControls } from '../../peach-globals/build/one-swift-control-source'
9
+ import { swiftUIControls } from '../../peach-globals/build/one-swift-ui-controls'
10
+ import {
11
+ ONE_DIRECT_STAGE_SWIFT,
12
+ PEACH_ONE_DIRECT_HOST_MM,
13
+ PEACH_ONE_HOST_SHIMS,
14
+ } from './one-direct-host-source'
9
15
  import {
10
16
  shardOneSDKBindingSource,
11
17
  translateShardedOneSDKDiagnostic,
@@ -1077,26 +1083,43 @@ private let tabStartupProfileSpec: Spec = [
1077
1083
  ],
1078
1084
  ]
1079
1085
 
1080
- @main
1081
- struct OneNativeControlsGuest: PeachPackage {
1082
- @ViewBuilder func view(props: JSON) -> some View {
1083
- #if PEACH_ONE_SDK
1084
- if props["oneSDKHost"] != nil {
1085
- OneSDKUIKitHost(props: props)
1086
- } else {
1087
- startupProfile
1088
- }
1089
- #else
1090
- startupProfile
1091
- #endif
1092
- }
1093
-
1094
- private var startupProfile: some View {
1086
+ public func oneStartupProfileView() -> AnyView {
1087
+ AnyView(
1095
1088
  VStack(spacing: 0) {
1096
1089
  NavigationStackBridge(spec: startupProfileSpec, emit: { _, _ in })
1097
1090
  TabViewBridge(spec: tabStartupProfileSpec, emit: { _, _ in })
1098
1091
  }
1099
1092
  .frame(maxWidth: .infinity, maxHeight: .infinity)
1093
+ )
1094
+ }
1095
+ `
1096
+
1097
+ const GUEST_MAIN_SWIFT = `import SwiftUI
1098
+ import PeachJSON
1099
+ import OneNativeControlsCore
1100
+ import OneNativeControlsHost
1101
+
1102
+ @main
1103
+ struct OneNativeControlsGuest: PeachPackage {
1104
+ init() {
1105
+ PeachOneDirectHostInit()
1106
+ _ = peach_register_views
1107
+ }
1108
+
1109
+ @ViewBuilder func view(props: JSON) -> some View {
1110
+ if props["oneDirectStage"] != nil {
1111
+ OneDirectStageView()
1112
+ } else {
1113
+ #if PEACH_ONE_SDK
1114
+ if props["oneSDKHost"] != nil {
1115
+ OneSDKUIKitHost(props: props)
1116
+ } else {
1117
+ oneStartupProfileView()
1118
+ }
1119
+ #else
1120
+ oneStartupProfileView()
1121
+ #endif
1122
+ }
1100
1123
  }
1101
1124
  }
1102
1125
  `
@@ -1205,12 +1228,62 @@ function excludedGroupSource(source: string, defines: ReadonlySet<string>): bool
1205
1228
  return false
1206
1229
  }
1207
1230
 
1231
+ function resolveCoreAbiIosDir(): string {
1232
+ const dir = path.resolve(
1233
+ path.dirname(fileURLToPath(import.meta.url)),
1234
+ '../../peach-engine/core-abi/ios',
1235
+ )
1236
+ if (!fs.existsSync(path.join(dir, 'PeachSwiftUI.mm'))) {
1237
+ throw new Error(`Peach core-abi iOS sources not found at ${dir}`)
1238
+ }
1239
+ return dir
1240
+ }
1241
+
1242
+ const DIRECT_HOST_SWIFT_SEEDS = [
1243
+ 'OneNativeControlsGuest',
1244
+ 'oneStartupProfileView',
1245
+ 'peach_register_views',
1246
+ 'PeachLeafMeasure',
1247
+ 'PeachOneDirectStage',
1248
+ 'OneDirectStageView',
1249
+ 'OneNativeAsyncActionModule',
1250
+ 'OneNativeArrangementView',
1251
+ 'OneNativeArrangementItem',
1252
+ 'OneNativeArrangementModifiers',
1253
+ 'OneNativeNavigationStackView',
1254
+ 'OneNativeNavigationSplitViewView',
1255
+ 'OneNativeNavigationSplitViewColumnView',
1256
+ 'OneNativeTabViewView',
1257
+ 'OneNativeTabItem',
1258
+ 'OneNativeToolbarView',
1259
+ 'OneNativeToolbarMarkerView',
1260
+ 'OneNativeUIKitHostView',
1261
+ 'OneNativeContainerSlotView',
1262
+ 'OneNativeSheetView',
1263
+ 'OneNativeMenuView',
1264
+ 'OneNativeSwiftPagerView',
1265
+ 'OneNativeDeferredRow',
1266
+ ] as const
1267
+
1268
+ const DIRECT_HOST_IOS_FILES = [
1269
+ 'PeachContainer.h',
1270
+ 'PeachSwiftUI.h',
1271
+ 'PeachSwiftUI.mm',
1272
+ 'PeachSheet.h',
1273
+ 'PeachSheet.mm',
1274
+ 'PeachMenu.h',
1275
+ 'PeachMenu.mm',
1276
+ 'PeachPopover.h',
1277
+ 'PeachPopover.mm',
1278
+ ] as const
1279
+
1208
1280
  export async function oneNativeControlsPackage(
1209
1281
  appRoot?: string,
1210
1282
  linkedGroups?: readonly string[],
1211
1283
  sdk?: OneNativeControlsSDKInput | null,
1212
1284
  ): Promise<OneNativeControlsPackage> {
1213
1285
  const iosDir = resolveOneNativeAppleIosDir(appRoot)
1286
+ const coreAbiIosDir = resolveCoreAbiIosDir()
1214
1287
  const generated = swiftGuestControls(
1215
1288
  path.dirname(iosDir),
1216
1289
  [
@@ -1246,9 +1319,21 @@ export async function oneNativeControlsPackage(
1246
1319
  ],
1247
1320
  linkedGroups,
1248
1321
  )
1322
+ // match the optional control groups Peach's Swift SDK actually supports (from generated.defines)
1323
+ const hostLinkedGroups = generated.defines
1324
+ .filter((flag) => flag.startsWith('ONE_GROUP_'))
1325
+ .map((flag) => flag.slice('ONE_GROUP_'.length).toLowerCase())
1326
+ const hostControls = swiftUIControls(path.dirname(iosDir), {
1327
+ basenameImports: true,
1328
+ linkedGroups: hostLinkedGroups,
1329
+ })
1249
1330
  const sources: Record<string, string> = {}
1250
1331
  const paths = new Map<string, string>()
1251
- const defines = new Set([...ONE_SDK_DEFINES, ...generated.defines])
1332
+ const defines = new Set([
1333
+ ...ONE_SDK_DEFINES,
1334
+ ...generated.defines,
1335
+ ...hostControls.defines,
1336
+ ])
1252
1337
  const bindings = sdk && sdk.files.size && sdk.modules.length ? sdk : undefined
1253
1338
  const sdkSources = new Set(ONE_SDK_RUNTIME_SOURCES.map((file) => path.basename(file)))
1254
1339
  for (const folder of ['', 'Generated', 'SDK']) {
@@ -1265,28 +1350,68 @@ export async function oneNativeControlsPackage(
1265
1350
  sources[name] = source
1266
1351
  }
1267
1352
  }
1353
+ const leafMeasurePath = path.join(coreAbiIosDir, 'PeachLeafMeasure.swift')
1354
+ sources['PeachLeafMeasure.swift'] = fs.readFileSync(leafMeasurePath, 'utf8')
1355
+ sources['OneDirectStage.swift'] = ONE_DIRECT_STAGE_SWIFT
1268
1356
  sources['OneNativeGuestControls.swift'] = generated.source
1269
1357
  sources['OneNativeControlsBridge.swift'] = BRIDGE_SWIFT
1270
1358
  const controls = new Map(
1271
1359
  Object.entries(
1272
1360
  collectSwiftSourceClosure(
1273
1361
  sources,
1274
- ['OneNativeControlsGuest'],
1362
+ [...DIRECT_HOST_SWIFT_SEEDS, ...hostControls.viewClasses],
1275
1363
  swiftCodeMask,
1276
1364
  new Set(['View']),
1277
1365
  ),
1278
1366
  ),
1279
1367
  )
1280
1368
  const watched = new Set(generated.watched)
1369
+ watched.add(leafMeasurePath)
1281
1370
  const files = new Map<string, string>()
1282
- const prefix = bindings ? 'Sources/Controls/' : ''
1283
1371
  for (const [name, source] of controls) {
1284
- files.set(prefix + name, source)
1372
+ files.set('Sources/ControlsCore/' + name, source)
1285
1373
  const full = paths.get(name)
1286
1374
  if (full) watched.add(full)
1287
1375
  }
1288
1376
 
1377
+ const rewriteSwiftHeaderInclude = (source: string) =>
1378
+ source.replace(/#(include|import)\s+"One-Swift\.h"/g, '#$1 "PeachOneControlsSwift.h"')
1289
1379
  const oneSDKShards = new Map<string, ShardedBindingFile>()
1380
+ for (const [rel, content] of Object.entries(PEACH_ONE_HOST_SHIMS)) {
1381
+ const staged =
1382
+ rel === 'ios/PeachOneControlsSwift.h' && bindings
1383
+ ? content.replace('#pragma once\n', '#pragma once\n#include "One-Swift.h"\n')
1384
+ : content
1385
+ files.set('Sources/ControlsHost/' + rel, staged)
1386
+ }
1387
+ for (const name of DIRECT_HOST_IOS_FILES) {
1388
+ const full = path.join(coreAbiIosDir, name)
1389
+ files.set(
1390
+ 'Sources/ControlsHost/ios/' + name,
1391
+ rewriteSwiftHeaderInclude(fs.readFileSync(full, 'utf8')),
1392
+ )
1393
+ watched.add(full)
1394
+ }
1395
+ files.set(
1396
+ 'Sources/ControlsHost/ios/PeachSwiftUIControls.h',
1397
+ rewriteSwiftHeaderInclude(hostControls.header),
1398
+ )
1399
+ for (const headerPath of hostControls.headers) {
1400
+ files.set(
1401
+ 'Sources/ControlsHost/ios/' + path.basename(headerPath),
1402
+ rewriteSwiftHeaderInclude(fs.readFileSync(headerPath, 'utf8')),
1403
+ )
1404
+ watched.add(headerPath)
1405
+ }
1406
+ for (const sourcePath of hostControls.nativeSources) {
1407
+ files.set(
1408
+ 'Sources/ControlsHost/ios/' + path.basename(sourcePath),
1409
+ rewriteSwiftHeaderInclude(fs.readFileSync(sourcePath, 'utf8')),
1410
+ )
1411
+ watched.add(sourcePath)
1412
+ }
1413
+ files.set('Sources/ControlsHost/ios/PeachOneDirectHost.mm', PEACH_ONE_DIRECT_HOST_MM)
1414
+ files.set('Sources/Controls/OneNativeControlsGuest.swift', GUEST_MAIN_SWIFT)
1290
1415
  if (bindings) {
1291
1416
  files.set('Sources/One/One.swift', oneSDKModule)
1292
1417
  for (const relative of ONE_SDK_RUNTIME_SOURCES) {
@@ -1313,6 +1438,10 @@ export async function oneNativeControlsPackage(
1313
1438
 
1314
1439
  const swiftDefines = (flags: Iterable<string>) =>
1315
1440
  Array.from(flags, (flag) => '.define(' + JSON.stringify(flag) + ')')
1441
+ const groupDefines = [...defines].filter((flag) => flag.startsWith('ONE_GROUP_'))
1442
+ const hostClangDefines = groupDefines.map(
1443
+ (flag) => '.define(' + JSON.stringify(flag) + ', to: "1")',
1444
+ )
1316
1445
  const bindingSettings = [
1317
1446
  ...swiftDefines(bindings?.defines ?? []),
1318
1447
  '.unsafeFlags(["-suppress-warnings"])',
@@ -1324,6 +1453,9 @@ export async function oneNativeControlsPackage(
1324
1453
  ? ['.unsafeFlags(["-Xfrontend", "-import-module", "-Xfrontend", "One"])']
1325
1454
  : []),
1326
1455
  ]
1456
+ const hostSettings = hostClangDefines.length
1457
+ ? `, cSettings: [${hostClangDefines.join(', ')}], cxxSettings: [${hostClangDefines.join(', ')}]`
1458
+ : ''
1327
1459
 
1328
1460
  let manifest: string
1329
1461
  if (bindings) {
@@ -1333,7 +1465,9 @@ export async function oneNativeControlsPackage(
1333
1465
  `let package = Package(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", platforms: [.iOS(.v17)], targets: [`,
1334
1466
  ' .target(name: "One", path: "Sources/One"),',
1335
1467
  ` .target(name: "OneSDKBindings", dependencies: ["One"], path: "Sources/OneSDKBindings", swiftSettings: [${bindingSettings.join(', ')}]),`,
1336
- ` .executableTarget(name: "Controls", dependencies: ["One", "OneSDKBindings"], path: "Sources/Controls", swiftSettings: [${controlSettings.join(', ')}]),`,
1468
+ ` .target(name: "OneNativeControlsCore", dependencies: ["One", "OneSDKBindings"], path: "Sources/ControlsCore", swiftSettings: [${controlSettings.join(', ')}]),`,
1469
+ ` .target(name: "OneNativeControlsHost", dependencies: ["One", "OneNativeControlsCore"], path: "Sources/ControlsHost", publicHeadersPath: "include"${hostSettings}),`,
1470
+ ` .executableTarget(name: "Controls", dependencies: ["One", "OneSDKBindings", "OneNativeControlsCore", "OneNativeControlsHost"], path: "Sources/Controls", swiftSettings: [${controlSettings.join(', ')}]),`,
1337
1471
  '])',
1338
1472
  '',
1339
1473
  ].join('\n')
@@ -1342,7 +1476,9 @@ export async function oneNativeControlsPackage(
1342
1476
  '// swift-tools-version: 6.2',
1343
1477
  'import PackageDescription',
1344
1478
  `let package = Package(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", platforms: [.iOS(.v17)], targets: [`,
1345
- ` .executableTarget(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", path: ".", swiftSettings: [${controlSettings.join(', ')}]),`,
1479
+ ` .target(name: "OneNativeControlsCore", path: "Sources/ControlsCore", swiftSettings: [${controlSettings.join(', ')}]),`,
1480
+ ` .target(name: "OneNativeControlsHost", dependencies: ["OneNativeControlsCore"], path: "Sources/ControlsHost", publicHeadersPath: "include"${hostSettings}),`,
1481
+ ` .executableTarget(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", dependencies: ["OneNativeControlsCore", "OneNativeControlsHost"], path: "Sources/Controls", swiftSettings: [${controlSettings.join(', ')}]),`,
1346
1482
  '])',
1347
1483
  '',
1348
1484
  ].join('\n')
@@ -9,6 +9,7 @@
9
9
  // classes are left out: React Native never reaches them for a C++ module.
10
10
  import { createHash } from 'node:crypto'
11
11
  import fs from 'node:fs'
12
+ import { createRequire } from 'node:module'
12
13
  import path from 'node:path'
13
14
  import { trunkSpecificationFile, trunkVersions } from './cocoapods-trunk'
14
15
  import { installedNativeSources } from './installed-native-libraries'
@@ -896,7 +897,11 @@ function transcribeLoad(text: string, file: string) {
896
897
  return { includes, usings, body }
897
898
  }
898
899
 
899
- function viewManagers(root: string, files: Iterable<string>): Set<string> {
900
+ function viewManagers(
901
+ root: string,
902
+ files: Iterable<string>,
903
+ inherited?: ReadonlySet<string>,
904
+ ): Set<string> {
900
905
  const classes = new Map<string, string>()
901
906
  for (const file of files) {
902
907
  if (!HEADER.test(file) && !OBJC.test(file)) continue
@@ -908,7 +913,7 @@ function viewManagers(root: string, files: Iterable<string>): Set<string> {
908
913
  ))
909
914
  classes.set(name!, parent!)
910
915
  }
911
- const managers = new Set(['RCTViewManager'])
916
+ const managers = new Set(inherited ?? ['RCTViewManager'])
912
917
  for (let remaining = classes.size; remaining > 0; remaining--) {
913
918
  let changed = false
914
919
  for (const [name, parent] of classes) {
@@ -922,12 +927,23 @@ function viewManagers(root: string, files: Iterable<string>): Set<string> {
922
927
  return managers
923
928
  }
924
929
 
930
+ function reactNativeViewManagers(root: string): Set<string> {
931
+ const files = new Set<string>()
932
+ for (const { from, to } of REACT_NATIVE_HEADER_DIRS)
933
+ if (to === 'React') walkFiles(root, from, files)
934
+ return viewManagers(root, files)
935
+ }
936
+
925
937
  /** the RCTViewManager subclasses a pod registers (RCT_EXPORT_MODULE in its
926
938
  * @implementation, or a Swift manager's RCT_EXTERN_MODULE): Fabric mounts
927
939
  * each through React Native's legacy view manager interop. */
928
- function paperViewManagers(root: string, files: Iterable<string>): string[] {
940
+ function paperViewManagers(
941
+ root: string,
942
+ files: Iterable<string>,
943
+ inherited: ReadonlySet<string>,
944
+ ): string[] {
929
945
  const sources = [...files]
930
- const managers = viewManagers(root, sources)
946
+ const managers = viewManagers(root, sources, inherited)
931
947
  const exported = new Set<string>()
932
948
  for (const file of sources) {
933
949
  if (!OBJC.test(file)) continue
@@ -945,16 +961,19 @@ function paperViewManagers(root: string, files: Iterable<string>): string[] {
945
961
  return [...exported].sort()
946
962
  }
947
963
 
948
- function registers(root: string, files: Iterable<string>, objc = true): boolean {
964
+ function registers(
965
+ root: string,
966
+ files: Iterable<string>,
967
+ inherited: ReadonlySet<string>,
968
+ ): boolean {
949
969
  const sources = [...files]
950
- const managers = objc ? viewManagers(root, sources) : new Set<string>()
970
+ const managers = viewManagers(root, sources, inherited)
951
971
  for (const file of sources) {
952
972
  if (!UNIT.test(file) && !OBJC.test(file)) continue
953
973
  const text = fs.readFileSync(path.join(root, file), 'utf8')
954
974
  if (text.includes(REGISTRATION)) return true
955
975
  const stripped = stripComments(text)
956
976
  if (
957
- objc &&
958
977
  OBJC.test(file) &&
959
978
  !CODEGEN_OBJC.test(text) &&
960
979
  (OBJC_TURBO.test(stripped) ||
@@ -1004,6 +1023,11 @@ export async function discoverTurboProviders(
1004
1023
  ): Promise<TurboProvider[]> {
1005
1024
  const providers: TurboProvider[] = []
1006
1025
  const candidates = await turboProviderCandidates(appRoot, answeredPackages)
1026
+ if (!candidates.length) return providers
1027
+ const appRequire = createRequire(path.join(appRoot, 'package.json'))
1028
+ const nativeManagers = reactNativeViewManagers(
1029
+ path.dirname(appRequire.resolve('react-native/package.json')),
1030
+ )
1007
1031
  const installed =
1008
1032
  projectRoot && installedXcodeWorkspace(projectRoot)
1009
1033
  ? installedNativeSources(
@@ -1022,7 +1046,8 @@ export async function discoverTurboProviders(
1022
1046
  if (
1023
1047
  fabric ||
1024
1048
  (files !== null &&
1025
- (registers(root, files) || paperViewManagers(root, files).length > 0))
1049
+ (registers(root, files, nativeManagers) ||
1050
+ paperViewManagers(root, files, nativeManagers).length > 0))
1026
1051
  ) {
1027
1052
  const nameFiles = files ?? podGlobFiles(pod)
1028
1053
  if (
@@ -1126,12 +1151,24 @@ export async function collectTurboSources(options: {
1126
1151
  const reactNative = packageInfo(options.reactNativeRoot)
1127
1152
  if (reactNative.name !== 'react-native')
1128
1153
  throw new Error(`${options.reactNativeRoot} is not react-native`)
1154
+ const nativeManagers = reactNativeViewManagers(reactNative.root)
1155
+ const paperWorkspace = process.env.RCT_NEW_ARCH_ENABLED === '0'
1129
1156
  const rawProviders = options.providers
1130
- .map((provider) => ({
1131
- ...provider,
1132
- info: packageInfo(provider.root),
1133
- libraries: packageCodegenLibraries(provider.root),
1134
- }))
1157
+ .map((provider) => {
1158
+ const installed = options.installedPods?.get(provider.name)
1159
+ const paper =
1160
+ paperWorkspace &&
1161
+ installed !== undefined &&
1162
+ !/(?:^| )-D ?RCT_NEW_ARCH_ENABLED(?:=[^ ]+)?(?: |$)/.test(
1163
+ installed.preprocessorFlags.cxx.join(' '),
1164
+ )
1165
+ return {
1166
+ ...provider,
1167
+ info: packageInfo(provider.root),
1168
+ libraries: packageCodegenLibraries(provider.root),
1169
+ paper,
1170
+ }
1171
+ })
1135
1172
  .sort((a, b) => a.info.name.localeCompare(b.info.name))
1136
1173
  const installedHeaderPods = (
1137
1174
  options.reactNativeProvider || options.reactNativeCore
@@ -1169,7 +1206,7 @@ export async function collectTurboSources(options: {
1169
1206
  const providers: ((typeof rawProviders)[number] & { providerFabric: boolean })[] = []
1170
1207
  for (const provider of rawProviders) {
1171
1208
  const componentLibraries = provider.libraries.filter((library) => library.components)
1172
- if (componentLibraries.length === 0) {
1209
+ if (componentLibraries.length === 0 || provider.paper) {
1173
1210
  providers.push({ ...provider, providerFabric: false })
1174
1211
  continue
1175
1212
  }
@@ -1216,8 +1253,8 @@ export async function collectTurboSources(options: {
1216
1253
  return registersReactModule(text) || CODEGEN_OBJC.test(text)
1217
1254
  })
1218
1255
  if (
1219
- !registers(pod.root, filteredFiles) &&
1220
- paperViewManagers(pod.root, filteredFiles).length === 0
1256
+ !registers(pod.root, filteredFiles, nativeManagers) &&
1257
+ paperViewManagers(pod.root, filteredFiles, nativeManagers).length === 0
1221
1258
  )
1222
1259
  continue
1223
1260
  }
@@ -1235,13 +1272,12 @@ export async function collectTurboSources(options: {
1235
1272
  const targetPath = (name: string) => `Sources/${name}`
1236
1273
  const providerTarget = (name: string) => `TurboPackage_${sha256(name).slice(0, 16)}`
1237
1274
  const folly = readFollyConfig(reactNative.root)
1238
- const defines = [
1275
+ const baseDefines = [
1239
1276
  options.configuration === 'Debug' ? 'DEBUG=1' : 'NDEBUG',
1240
- 'RCT_NEW_ARCH_ENABLED=1',
1241
- 'RCT_REMOVE_LEGACY_ARCH=1',
1242
1277
  'RCT_REMOTE_PROFILE=0',
1243
1278
  ...folly.defines,
1244
1279
  ]
1280
+ const defines = [...baseDefines, 'RCT_NEW_ARCH_ENABLED=1', 'RCT_REMOVE_LEGACY_ARCH=1']
1245
1281
  const target = (name: string, dependencies: string[]) => ({
1246
1282
  name,
1247
1283
  path: targetPath(name),
@@ -1870,6 +1906,7 @@ export async function collectTurboSources(options: {
1870
1906
  options.appRoot,
1871
1907
  options.installedPods?.get(provider.name),
1872
1908
  )
1909
+ if (provider.paper) providerTargetInput.cxxDefines = baseDefines
1873
1910
  if (pod.installed)
1874
1911
  providerTargetInput.clangSettings = [
1875
1912
  { tool: 'c', flags: pod.installed.preprocessorFlags.c },
@@ -1895,8 +1932,8 @@ export async function collectTurboSources(options: {
1895
1932
  const text = fs.readFileSync(path.join(root, file), 'utf8')
1896
1933
  return registersReactModule(text) || CODEGEN_OBJC.test(text)
1897
1934
  })
1898
- const managers = viewManagers(root, files)
1899
- const paper = paperViewManagers(root, files)
1935
+ const managers = viewManagers(root, files, nativeManagers)
1936
+ const paper = paperViewManagers(root, files, nativeManagers)
1900
1937
  if (paper.length > 0) {
1901
1938
  // RCTLegacyViewManagerInteropComponentView, from the renderer pods, mounts them
1902
1939
  fabric = true
@@ -2197,7 +2234,7 @@ export async function collectTurboSources(options: {
2197
2234
  }
2198
2235
  if (
2199
2236
  loads.length === 0 &&
2200
- !registers(root, files) &&
2237
+ !registers(root, files, nativeManagers) &&
2201
2238
  !provider.providerFabric &&
2202
2239
  paper.length === 0
2203
2240
  )
@@ -4629,7 +4666,7 @@ std::array<double, 10> fabricAdoptedStyle(const PeachFabricView &view) {
4629
4666
  // the event type and its payload with the target tag and timestamp
4630
4667
  const auto fabricDispatchEvent = [](
4631
4668
  jsi::Runtime &rt,
4632
- react::EventTarget *target,
4669
+ const react::EventTarget *target,
4633
4670
  const std::string &type,
4634
4671
  react::ReactEventPriority,
4635
4672
  const react::EventPayload &eventPayload,
@@ -862,7 +862,10 @@ function targetSettings(
862
862
  if (resolving.has(marker))
863
863
  throw new Error(`${str(target.name)} has a cyclic build setting ${key}`)
864
864
  resolving.add(marker)
865
- const value = expand(levels[at]![key]!, (name) =>
865
+ // xcode splices the inherited list where a quoted word is only $(inherited);
866
+ // cocoapods writes gRPC's header search paths that way
867
+ const raw = levels[at]![key]!.replace(/"(\$\(inherited\)|\$\{inherited\})"/g, '$1')
868
+ const value = expand(raw, (name) =>
866
869
  name === 'inherited' || name === key
867
870
  ? valueAt(key, at - 1, packaging)
868
871
  : valueAt(name, levels.length - 1, packaging),
@@ -1281,8 +1284,25 @@ function targetMembers(
1281
1284
  const isPreparedOutput = (file: string) =>
1282
1285
  file === infoPlistOutput ||
1283
1286
  (options.requireSources !== false && file.endsWith('.swift'))
1287
+ // xcode runs every script phase each build, and one declaring no outputs ahead
1288
+ // of the sources phase is how a target writes sources it never declares
1289
+ // (apollo-ios codegen). peach runs such phases only while sources are absent.
1290
+ let absentSources = false
1291
+ if (options.prepareGeneratedSources === true && options.requireSources !== false)
1292
+ project.visitMembers(
1293
+ targetId,
1294
+ xcodePathResolver(project.objects, project.projectDir, path.join, settings),
1295
+ (file) => (isDirectory(file) ? walkFiles(file) : fs.existsSync(file) ? [file] : []),
1296
+ path.join,
1297
+ (file, kind) => {
1298
+ if (kind !== 'header' && kind !== 'resource' && !fs.existsSync(file))
1299
+ absentSources = true
1300
+ },
1301
+ )
1302
+ let beforeSources = true
1284
1303
  for (const phaseId of list(target.buildPhases)) {
1285
1304
  const phase = project.object(phaseId)
1305
+ if (phase?.isa === 'PBXSourcesBuildPhase') beforeSources = false
1286
1306
  if (phase?.isa !== 'PBXShellScriptBuildPhase') continue
1287
1307
  const script = str(phase.name) ?? phaseId
1288
1308
  for (const catalog of shellAssetCatalogs(
@@ -1326,7 +1346,15 @@ function targetMembers(
1326
1346
  ]
1327
1347
  if (allOutputs.some((file) => file.endsWith('.swift') || file === infoPlistOutput))
1328
1348
  for (const file of inputFiles) if (fs.existsSync(file)) projectInputs.add(file)
1329
- if (options.prepareGeneratedSources === true && allOutputs.some(isPreparedOutput)) {
1349
+ const undeclaredGenerator =
1350
+ absentSources &&
1351
+ beforeSources &&
1352
+ allOutputs.length === 0 &&
1353
+ str(phase.runOnlyForDeploymentPostprocessing) !== '1'
1354
+ if (
1355
+ options.prepareGeneratedSources === true &&
1356
+ (allOutputs.some(isPreparedOutput) || undeclaredGenerator)
1357
+ ) {
1330
1358
  const phaseDir = path.join(settings('TARGET_TEMP_DIR'), `Script-${phaseId}`)
1331
1359
  for (const lists of fileLists.values())
1332
1360
  for (const { file } of lists)