peachsim 0.1.1899 → 0.1.1902

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 (106) hide show
  1. package/README.md +2 -2
  2. package/cli/account-gate.ts +1 -1
  3. package/cli/app-stubs.ts +1 -1
  4. package/cli/commands/box/checkout-plane.ts +1 -1
  5. package/cli/commands/box/search-command.ts +1 -1
  6. package/cli/commands/perf-record.ts +1 -1
  7. package/dist-lib/agent-daemon-client.cjs +1 -1
  8. package/dist-lib/agent-events.cjs +1 -1
  9. package/dist-lib/attached-projects.cjs +1 -1
  10. package/dist-lib/auth/shared-session.cjs +1 -1
  11. package/dist-lib/backend-origin.cjs +1 -1
  12. package/dist-lib/beta.cjs +1 -1
  13. package/dist-lib/beta.mjs +1 -1
  14. package/dist-lib/bridge-constants.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.mjs +1 -1
  17. package/dist-lib/bridge-contract.cjs +1 -1
  18. package/dist-lib/bridge-contract.mjs +1 -1
  19. package/dist-lib/bundle-channel.cjs +128 -58
  20. package/dist-lib/capture-contract.cjs +1 -1
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cloud-contract.cjs +1 -1
  23. package/dist-lib/cloud-contract.mjs +1 -1
  24. package/dist-lib/cloud-test-args.cjs +1 -1
  25. package/dist-lib/cloud-test-args.mjs +1 -1
  26. package/dist-lib/cloud.cjs +1 -1
  27. package/dist-lib/cloud.mjs +1 -1
  28. package/dist-lib/config.cjs +1 -1
  29. package/dist-lib/config.mjs +1 -1
  30. package/dist-lib/detox/index.cjs +1 -1
  31. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  32. package/dist-lib/expo-swift-bundle.cjs +49 -33
  33. package/dist-lib/expo-swift-metadata.cjs +1 -1
  34. package/dist-lib/expo-swift-metadata.mjs +1 -1
  35. package/dist-lib/home-paths.cjs +1 -1
  36. package/dist-lib/host/bridge-host.cjs +138 -69
  37. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  38. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  39. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  40. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  41. package/dist-lib/host/websocket-proxy.cjs +1 -1
  42. package/dist-lib/index.cjs +31 -30
  43. package/dist-lib/jump-to-source-babel.cjs +1 -1
  44. package/dist-lib/jump-to-source-native.cjs +1 -1
  45. package/dist-lib/kotlin-host.cjs +1 -1
  46. package/dist-lib/menu.cjs +1 -1
  47. package/dist-lib/menu.mjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  50. package/dist-lib/metro-production-bundle.cjs +1 -1
  51. package/dist-lib/metro-production-bundle.mjs +1 -1
  52. package/dist-lib/metro.cjs +29 -28
  53. package/dist-lib/native-app-identity-project.cjs +21 -20
  54. package/dist-lib/native-app-identity-project.mjs +21 -20
  55. package/dist-lib/native-app-identity.cjs +1 -1
  56. package/dist-lib/native-app-identity.mjs +1 -1
  57. package/dist-lib/native-firebase-metadata.cjs +1 -1
  58. package/dist-lib/native-firebase-metadata.mjs +1 -1
  59. package/dist-lib/pdfium-raster.cjs +1 -1
  60. package/dist-lib/pdfium-raster.mjs +1 -1
  61. package/dist-lib/plist.cjs +1 -1
  62. package/dist-lib/plist.mjs +1 -1
  63. package/dist-lib/profiles.cjs +1 -1
  64. package/dist-lib/public-brand.cjs +1 -1
  65. package/dist-lib/public-origins-lib-esm.json +24 -24
  66. package/dist-lib/public-origins-lib.json +53 -53
  67. package/dist-lib/react-native-host-modules.cjs +1 -1
  68. package/dist-lib/react-native-host-modules.mjs +1 -1
  69. package/dist-lib/reap-browser.cjs +1 -1
  70. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  71. package/dist-lib/sdk.cjs +1 -1
  72. package/dist-lib/sdk.mjs +1 -1
  73. package/dist-lib/skills.cjs +173 -103
  74. package/dist-lib/swift-compile.cjs +25 -9
  75. package/dist-lib/swift-compile.mjs +25 -9
  76. package/dist-lib/swift-package.cjs +1 -1
  77. package/dist-lib/swift-package.mjs +1 -1
  78. package/dist-lib/swift-submit.cjs +1 -1
  79. package/dist-lib/swift-submit.mjs +1 -1
  80. package/dist-lib/swift-toolchain.cjs +3 -3
  81. package/dist-lib/swift.cjs +1 -1
  82. package/dist-lib/vite-swift.cjs +35 -19
  83. package/dist-lib/vite.cjs +1 -1
  84. package/dist-lib/worklet-executable.cjs +1 -1
  85. package/dist-lib/worklet-executable.mjs +1 -1
  86. package/kotlin/README.md +4 -4
  87. package/kotlin/sdk.tar.gz +0 -0
  88. package/package.json +1 -1
  89. package/src/assetCatalogContract.ts +1 -1
  90. package/src/bundle-channel.mjs +1 -1
  91. package/src/config.ts +2 -2
  92. package/src/device-catalog.ts +4 -4
  93. package/src/expo-native-prebuilt.ts +1 -1
  94. package/src/nitro-adapter.ts +1 -1
  95. package/src/nitro-dependencies.ts +1 -1
  96. package/src/settingsContract.ts +1 -1
  97. package/src/swift-compile.ts +23 -4
  98. package/src/swift-darwin-records.ts +1 -1
  99. package/src/swift-distribution-contract.ts +1 -1
  100. package/src/swift-distribution.ts +1 -1
  101. package/src/swift-guest-compile.ts +7 -1
  102. package/src/swift-guest-link.ts +3 -2
  103. package/src/swift-toolchain.ts +3 -2
  104. package/src/turbo-codegen-intake.ts +3 -0
  105. package/src/turbo-compile.ts +1 -0
  106. package/src/turbo-source.ts +62 -2
@@ -25,6 +25,7 @@ import {
25
25
  } from 'node:fs'
26
26
  import os from 'node:os'
27
27
  import path from 'node:path'
28
+ import * as v from 'valibot'
28
29
  import { windowAdmission } from './admitted-mac-build'
29
30
  import cPredefinesJson from './generated/swift-c-predefines.json' with { type: 'json' }
30
31
  import { terminateProcessGroup } from './process-group'
@@ -133,6 +134,10 @@ import {
133
134
  type SwiftHeaderAliases,
134
135
  type SwiftProjectPreparation,
135
136
  } from './swiftContract'
137
+ import {
138
+ SWIFT_FRAMEWORK_PRODUCT_FILE,
139
+ swiftFrameworkProductSchema,
140
+ } from './swiftRuntimeProductContract'
136
141
  import { optimizeWasm, WASM_OPTIMIZE_IDENTITY } from './wasm-optimize'
137
142
  import { writeBuildFile } from './write-build-file'
138
143
  import { writeXcodeHeaderSearch } from './xcode-header-search'
@@ -362,7 +367,7 @@ export interface SwiftProjectLayout {
362
367
  * the prebuilt distribution at a module root, or null for a sootsim-swift
363
368
  * source checkout. an installed peach links the distribution: compiled
364
369
  * modules, one static library and host macro plugins, and no source
365
- * (docs/swift-distribution.md).
370
+ * (docs/peach/swift/distribution.md).
366
371
  */
367
372
  export function swiftDistributionAt(root: string): SwiftDistributionManifest | null {
368
373
  const file = path.join(root, SWIFT_DISTRIBUTION_MANIFEST)
@@ -1503,7 +1508,7 @@ const FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
1503
1508
  const ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
1504
1509
 
1505
1510
  // the executable link lines the template path and every emitted executable
1506
- // target share (specs/peach-swift/build-plans.md). clang runs `wasm-opt -Os`
1511
+ // target share (specs/peach/swift/build-plans.md). clang runs `wasm-opt -Os`
1507
1512
  // after a wasm link whenever the machine has one on PATH, which makes every
1508
1513
  // edit pay for an optimizer pass and the artifact depend on the machine, so
1509
1514
  // -O0 on the clang link turns that pass off everywhere. the build root's
@@ -1523,7 +1528,7 @@ const executableLinkFlags = (root: string) => ` "-Xclang-linker", "-O0"
1523
1528
  `
1524
1529
  // the Darwin module's providers link as an archive does, ahead of the sdk's
1525
1530
  // libDarwinRecords.a, which supplies only what remains undefined
1526
- // (specs/peach-swift/darwin-libc-providers.md).
1531
+ // (specs/peach/swift/darwin-libc-providers.md).
1527
1532
  const darwinRecordsRegion = (quoted: readonly string[]): string[] =>
1528
1533
  quoted.length ? ['-Wl,--start-lib', ...quoted, '-Wl,--end-lib'] : []
1529
1534
  const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
@@ -6956,7 +6961,21 @@ function compileSwiftProjectOnce(
6956
6961
  report('framework revision changed; rebuilding the app link')
6957
6962
  const nativeToolset = needsNativeToolset(input, prebuilt)
6958
6963
  const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt)
6959
- writeSwiftAutolinkLinker(root, options.toolchainBin)
6964
+ // the framework objects link as inputs, so the product name its
6965
+ // modules autolink has no archive to load
6966
+ const productFile = path.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE)
6967
+ writeSwiftAutolinkLinker(
6968
+ root,
6969
+ options.toolchainBin,
6970
+ existsSync(productFile)
6971
+ ? [
6972
+ v.parse(
6973
+ swiftFrameworkProductSchema,
6974
+ JSON.parse(readFileSync(productFile, 'utf8')),
6975
+ ).product.name,
6976
+ ]
6977
+ : [],
6978
+ )
6960
6979
  const projectProcess = options.project
6961
6980
  ? prepareSwiftProjectProcess(root, options.project)
6962
6981
  : undefined
@@ -3,7 +3,7 @@
3
3
  // they compile in its view, with the records' shared sdk tree. the wasm sdk
4
4
  // ships them as libDarwinRecords.a for its own clients; a distribution and a
5
5
  // source checkout compile them from the same source as their Darwin module and
6
- // link them ahead of that archive (specs/peach-swift/darwin-libc-providers.md).
6
+ // link them ahead of that archive (specs/peach/swift/darwin-libc-providers.md).
7
7
  import { execFileSync } from 'node:child_process'
8
8
  import { mkdtempSync, readdirSync, rmSync, symlinkSync } from 'node:fs'
9
9
  import { tmpdir } from 'node:os'
@@ -1,7 +1,7 @@
1
1
  // the prebuilt Swift distribution's shapes, shared by its builder
2
2
  // (packages/sootsim-swift/scripts/build-distribution.ts), its publisher
3
3
  // (scripts/ops/swift-distribution-publish.ts) and the CLI that installs it
4
- // (swift-distribution.ts). docs/swift-distribution.md owns the design.
4
+ // (swift-distribution.ts). docs/peach/swift/distribution.md owns the design.
5
5
  import { isRecord } from './is-record'
6
6
  import type { SwiftWasmSdk } from './swift-toolchain'
7
7
 
@@ -4,7 +4,7 @@
4
4
  // distribution from PEACH_SWIFT_ENDPOINT, or the public default when it is
5
5
  // unset, verifies it against the lock this build carries, and unpacks it under
6
6
  // the peach home
7
- // (docs/swift-distribution.md). no path here asks Contrast to compile.
7
+ // (docs/peach/swift/distribution.md). no path here asks Contrast to compile.
8
8
  import fs from 'node:fs'
9
9
  import os from 'node:os'
10
10
  import path from 'node:path'
@@ -421,9 +421,15 @@ export async function compileGuestLink(options: {
421
421
  systemProviders,
422
422
  hostImports: scope.hostImports,
423
423
  })
424
+ // wasm-ld applies a --wrap by name, so the wrapped symbol and its wrapper keep theirs
425
+ const wrapped = new Set(
426
+ prepared.args.flatMap((arg) =>
427
+ arg.startsWith('--wrap=') ? [arg.slice(7), `__wrap_${arg.slice(7)}`] : [],
428
+ ),
429
+ )
424
430
  return {
425
431
  ...plan,
426
- symbols: scope.definitions,
432
+ symbols: scope.definitions.filter((symbol) => !wrapped.has(symbol)),
427
433
  directBindings: verified.directBindings,
428
434
  }
429
435
  },
@@ -1012,8 +1012,9 @@ export function verifyGuestSymbolScopes(options: {
1012
1012
  providers: new Map<string, number>(),
1013
1013
  physicalModule: false,
1014
1014
  }
1015
- if (object === '<internal>' && kind === 'definition of') {
1016
- record.physicalModule = true
1015
+ // an internal reference is wasm-ld's own, such as the real half of a --wrap, with no object to scope
1016
+ if (object === '<internal>') {
1017
+ if (kind === 'definition of') record.physicalModule = true
1017
1018
  } else {
1018
1019
  const image = options.owners.get(object!)
1019
1020
  if (image === undefined)
@@ -1,7 +1,7 @@
1
1
  // the one place that selects and verifies the toolchain app Swift compiles with.
2
2
  // a binary .swiftmodule loads only in the compiler release that wrote it, so
3
3
  // every caller names the release from packages/sootsim-swift/toolchain.json
4
- // or the Swift distribution's lock (docs/swift-distribution.md).
4
+ // or the Swift distribution's lock (docs/peach/swift/distribution.md).
5
5
  //
6
6
  // node builtins only: packages/sootsim-swift/scripts/build.sh imports this
7
7
  // file straight from a checkout, with no install.
@@ -510,6 +510,7 @@ export const SWIFT_AUTOLINK_LINKER = '.peach-wasm-ld'
510
510
  export function writeSwiftAutolinkLinker(
511
511
  directory: string,
512
512
  toolchainBin: string,
513
+ omitLibraries: readonly string[] = [],
513
514
  ): string {
514
515
  const linker = path.join(directory, SWIFT_AUTOLINK_LINKER)
515
516
  const script = `#!/bin/sh
@@ -518,7 +519,7 @@ for arg in "$@"; do
518
519
  case $arg in
519
520
  @*)
520
521
  rsp=\${arg#@}
521
- awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
522
+ awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next }${omitLibraries.map((name) => ` $0 == "\\"-l${name}\\"" { next }`).join('')} { print }' "$rsp" > "$rsp.dedup"
522
523
  mv "$rsp.dedup" "$rsp"
523
524
  if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
524
525
  cp "$rsp" ${JSON.stringify(path.join(directory, '.peach-link.rsp'))}
@@ -100,6 +100,9 @@ const LEGACY_BRIDGE_DEV_SUPPORT = [
100
100
  // the pods whose sources a legacy RCTBridge needs when no renderer compiles
101
101
  const LEGACY_BRIDGE_PODS = new Set([
102
102
  'React-Core',
103
+ 'React-hermes',
104
+ 'React-jsi',
105
+ 'React-logger',
103
106
  'React-cxxreact',
104
107
  'React-jsinspector',
105
108
  'React-jsinspectortracing',
@@ -201,6 +201,7 @@ export async function compileTurboModule(options: {
201
201
  providers: options.providers,
202
202
  codegenDir: path.join(scratch, 'codegen'),
203
203
  installedPods: options.installedPods,
204
+ projectRoot: options.projectRoot,
204
205
  })
205
206
  const swiftTargets = collection.targets.filter((target) =>
206
207
  Object.keys(collection.files).some(
@@ -246,6 +246,7 @@ const REACT_NATIVE_HEADER_DIRS = [
246
246
  { from: 'Libraries/TypeSafety', to: 'RCTTypeSafety' },
247
247
  { from: 'Libraries/FBLazyVector/FBLazyVector', to: 'FBLazyVector' },
248
248
  { from: 'ReactApple/RCTSwiftUIWrapper', to: 'RCTSwiftUIWrapper' },
249
+ { from: 'ReactCommon/hermes/executor', to: 'reacthermes' },
249
250
  {
250
251
  from: 'ReactApple/Libraries/RCTFoundation/RCTDeprecation/Exported',
251
252
  to: 'RCTDeprecation',
@@ -1031,6 +1032,8 @@ export async function collectTurboSources(options: {
1031
1032
  providers: TurboProvider[]
1032
1033
  codegenDir: string
1033
1034
  installedPods?: ReadonlyMap<string, TurboInstalledPod>
1035
+ /** the prepared workspace whose ios/Pods holds installed binary pods' headers */
1036
+ projectRoot: string
1034
1037
  }): Promise<TurboSourceCollection> {
1035
1038
  if (options.providers.length === 0)
1036
1039
  throw new Error('TurboModule compilation needs at least one provider')
@@ -1403,6 +1406,17 @@ export async function collectTurboSources(options: {
1403
1406
  )
1404
1407
  return
1405
1408
  }
1409
+ if (
1410
+ hermesHeaders &&
1411
+ include.startsWith('hermes/') &&
1412
+ fs.existsSync(path.join(hermesHeaders, include))
1413
+ ) {
1414
+ alias(
1415
+ `${core}/include/${include}`,
1416
+ original(TURBO_CORE_TARGET, 'hermes-engine', hermesHeaders, include, false),
1417
+ )
1418
+ return
1419
+ }
1406
1420
  // a React pod header by its header_dir name; a quoted bare name reaches
1407
1421
  // React-Core's through the header map CocoaPods gives its own sources
1408
1422
  const nativeReactMaps = pod?.reactHeaderMaps ?? []
@@ -1577,6 +1591,7 @@ export async function collectTurboSources(options: {
1577
1591
  let objc = false
1578
1592
  let fabric = false
1579
1593
  let legacyBridge = false
1594
+ let hermesHeaders: string | null = null
1580
1595
  const objcClasses = new Set<string>()
1581
1596
  // module classes no macro registers: React Native finds them by name
1582
1597
  const unregisteredObjcClasses = new Set<string>()
@@ -2136,8 +2151,53 @@ export async function collectTurboSources(options: {
2136
2151
  }
2137
2152
  }
2138
2153
  if (fabric || legacyBridge) {
2139
- // React-Core's own compiler_flags select the Hermes executor factory
2140
- if (!fabric) result.targets[0]!.cxxDefines = [...defines, 'USE_HERMES=1']
2154
+ // React-Core's own compiler_flags select the Hermes executor factory,
2155
+ // which React-hermes builds against the installed hermes-engine headers.
2156
+ // hermes-engine's binary owns the crash managers' out-of-line
2157
+ // destructors and the runtime factory. a bridgeless app never starts
2158
+ // RCTCxxBridge, so no Hermes runtime is made; an app that starts the
2159
+ // legacy bridge stops at this error.
2160
+ if (!fabric) {
2161
+ result.targets[0]!.cxxDefines = [...defines, 'USE_HERMES=1']
2162
+ hermesHeaders = path.join(
2163
+ options.projectRoot,
2164
+ 'ios/Pods/hermes-engine/destroot/include',
2165
+ )
2166
+ if (!fs.existsSync(path.join(hermesHeaders, 'hermes/hermes.h')))
2167
+ throw new Error(
2168
+ `the legacy bridge needs the installed hermes-engine headers in ${hermesHeaders}`,
2169
+ )
2170
+ const runtimeUnit = `${core}/PeachHermesRuntime.cpp`
2171
+ add(
2172
+ runtimeUnit,
2173
+ [
2174
+ '#include <hermes/hermes.h>',
2175
+ '#include <stdexcept>',
2176
+ '',
2177
+ 'namespace hermes::vm {',
2178
+ 'CrashManager::~CrashManager() = default;',
2179
+ 'NopCrashManager::~NopCrashManager() = default;',
2180
+ '} // namespace hermes::vm',
2181
+ '',
2182
+ 'namespace facebook::hermes {',
2183
+ 'std::unique_ptr<HermesRuntime> makeHermesRuntime(const ::hermes::vm::RuntimeConfig &) {',
2184
+ ' throw std::logic_error("no native Hermes runtime in Peach: this app started the legacy bridge");',
2185
+ '}',
2186
+ '} // namespace facebook::hermes',
2187
+ '',
2188
+ ].join('\n'),
2189
+ )
2190
+ scanText(
2191
+ {
2192
+ key: runtimeUnit,
2193
+ targetName: TURBO_CORE_TARGET,
2194
+ label: 'peach',
2195
+ root: reactNative.root,
2196
+ relative: 'PeachHermesRuntime.cpp',
2197
+ },
2198
+ result.files[runtimeUnit]!,
2199
+ )
2200
+ }
2141
2201
  addPodSources(
2142
2202
  installedFabricSources(reactNative.root, { legacyBridge, bridgeOnly: !fabric }),
2143
2203
  )