peachsim 0.1.2247 → 0.1.2249

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 (111) hide show
  1. package/cli/bin.ts +5 -0
  2. package/cli/bridge-flow-runner.ts +28 -2
  3. package/cli/cloud-dispatch.ts +2 -0
  4. package/cli/commands/control.ts +2 -2
  5. package/cli/commands/coverage-swift.ts +3 -3
  6. package/cli/commands/inspect/settling.ts +35 -4
  7. package/cli/commands/shell-url.ts +6 -0
  8. package/cli/commands/skills.ts +6 -3
  9. package/cli/drivers/playwright.ts +2 -0
  10. package/dist-lib/agent-daemon-client.cjs +1 -29
  11. package/dist-lib/agent-events.cjs +1 -1
  12. package/dist-lib/attached-projects.cjs +1 -10
  13. package/dist-lib/auth/shared-session.cjs +1 -1
  14. package/dist-lib/backend-origin.cjs +1 -1
  15. package/dist-lib/beta.cjs +1 -1
  16. package/dist-lib/beta.mjs +1 -1
  17. package/dist-lib/bridge-constants.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.mjs +1 -1
  20. package/dist-lib/bridge-contract.cjs +1 -1
  21. package/dist-lib/bridge-contract.mjs +1 -1
  22. package/dist-lib/bundle-channel.cjs +4300 -4531
  23. package/dist-lib/capture-contract.cjs +1 -1
  24. package/dist-lib/capture-contract.mjs +1 -1
  25. package/dist-lib/cloud-contract.cjs +1 -1
  26. package/dist-lib/cloud-contract.mjs +1 -1
  27. package/dist-lib/cloud-test-args.cjs +1 -1
  28. package/dist-lib/cloud-test-args.mjs +1 -1
  29. package/dist-lib/cloud.cjs +1 -1
  30. package/dist-lib/cloud.mjs +1 -1
  31. package/dist-lib/config.cjs +1 -1
  32. package/dist-lib/config.mjs +1 -1
  33. package/dist-lib/detox/index.cjs +32 -315
  34. package/dist-lib/dev-bundle-resolution.cjs +1 -12
  35. package/dist-lib/expo-swift-bundle.cjs +3579 -3864
  36. package/dist-lib/expo-swift-metadata.cjs +1 -1
  37. package/dist-lib/expo-swift-metadata.mjs +1 -1
  38. package/dist-lib/home-paths.cjs +1 -1
  39. package/dist-lib/host/bridge-host.cjs +4376 -4682
  40. package/dist-lib/host/fetch-proxy-handler.cjs +97 -713
  41. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  42. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  43. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  44. package/dist-lib/host/websocket-proxy.cjs +1 -1
  45. package/dist-lib/index.cjs +669 -1116
  46. package/dist-lib/jump-to-source-babel.cjs +1 -1
  47. package/dist-lib/jump-to-source-native.cjs +1 -1
  48. package/dist-lib/kotlin-host.cjs +3 -24
  49. package/dist-lib/menu.cjs +1 -1
  50. package/dist-lib/menu.mjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  53. package/dist-lib/metro-production-bundle.cjs +1 -10
  54. package/dist-lib/metro-production-bundle.mjs +1 -12
  55. package/dist-lib/metro.cjs +546 -975
  56. package/dist-lib/native-app-identity-project.cjs +299 -592
  57. package/dist-lib/native-app-identity-project.mjs +11 -232
  58. package/dist-lib/native-app-identity.cjs +1 -1
  59. package/dist-lib/native-app-identity.mjs +1 -1
  60. package/dist-lib/native-firebase-metadata.cjs +1 -1
  61. package/dist-lib/native-firebase-metadata.mjs +1 -1
  62. package/dist-lib/pdfium-raster.cjs +1 -1
  63. package/dist-lib/pdfium-raster.mjs +1 -1
  64. package/dist-lib/plist.cjs +1 -1
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +1 -1
  67. package/dist-lib/public-brand.cjs +1 -1
  68. package/dist-lib/public-origins-lib-esm.json +28 -96
  69. package/dist-lib/public-origins-lib.json +172 -1058
  70. package/dist-lib/react-native-host-modules.cjs +1 -1
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/reap-browser.cjs +1 -1
  73. package/dist-lib/scripts/dev-server-scanner.cjs +1 -34
  74. package/dist-lib/sdk.cjs +31 -7
  75. package/dist-lib/sdk.mjs +31 -7
  76. package/dist-lib/skills.cjs +4960 -5345
  77. package/dist-lib/swift-compile.cjs +1185 -1107
  78. package/dist-lib/swift-compile.mjs +137 -54
  79. package/dist-lib/swift-package.cjs +1 -1
  80. package/dist-lib/swift-package.mjs +1 -1
  81. package/dist-lib/swift-submit.cjs +1 -1
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift-toolchain.cjs +1 -1
  84. package/dist-lib/swift.cjs +1 -1
  85. package/dist-lib/vite-swift.cjs +1568 -1672
  86. package/dist-lib/vite.cjs +173 -763
  87. package/dist-lib/worklet-executable.cjs +1 -1
  88. package/dist-lib/worklet-executable.mjs +1 -1
  89. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +3 -0
  90. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +4 -0
  91. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
  92. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +8 -0
  93. package/dist-types/packages/peach-engine/src/render-worker/webview-capture-protocol.d.ts +1 -0
  94. package/dist-types/packages/peach-engine/src/settings/duo-fold-bus.d.ts +10 -2
  95. package/dist-types/packages/peach-globals/src/globalsContract.d.ts +5 -0
  96. package/kotlin/sdk.tar.gz +0 -0
  97. package/package.json +1 -1
  98. package/runtime-companion.json +1 -1
  99. package/sdk/ios/wasm/include/math.h +1 -1
  100. package/sdk/ios/wasm/include/pthread.h +1 -1
  101. package/src/assetCatalogContract.ts +6 -0
  102. package/src/kotlin-module.ts +3 -3
  103. package/src/sfSymbolMetricsContract.ts +73 -37
  104. package/src/swift-compile.ts +99 -7
  105. package/src/swift-coverage/provenance.ts +4 -4
  106. package/src/swift-guest-image-ledger.ts +10 -5
  107. package/src/swift-guest-link.ts +20 -14
  108. package/src/swift-objc-sdk.ts +34 -21
  109. package/src/swift-objc-standin.ts +7 -7
  110. package/src/swift-standins.ts +11 -8
  111. package/src/swift-wasm-prune.ts +30 -0
@@ -11,34 +11,47 @@ import path from 'node:path'
11
11
  import { readIosSdkTree } from './swift-objc-sdk-tree'
12
12
  import { peachsimPackageRoot } from './swift-toolchain'
13
13
 
14
- declare const __PEACH_BUNDLED_IOS_SDK__: Readonly<Record<string, string>>
14
+ declare const __PEACH_BUNDLED_IOS_SDK__: string
15
15
 
16
16
  export const IOS_SDK_TARGET = 'arm64-apple-ios16.0-simulator'
17
17
 
18
18
  const OVERLAY_PATH =
19
19
  /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/
20
20
 
21
- // the tree is read from the package's sdk directory, which sits beside src and
22
- // every dist directory; the standalone executable embeds it at build time.
23
- const tree =
24
- typeof __PEACH_BUNDLED_IOS_SDK__ === 'undefined'
25
- ? readIosSdkTree(path.join(peachsimPackageRoot(), 'sdk', 'ios'))
26
- : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => (a < b ? -1 : 1))
27
-
28
- /** the clang headers and module maps, by path under the sdk root. */
29
- export const IOS_SDK_HEADERS: Record<string, string> = {}
21
+ export interface IosSdk {
22
+ /** the clang headers and module maps, by path under the sdk root. */
23
+ headers: Record<string, string>
24
+ /** the swift overlays of the clang modules above, by module name. */
25
+ overlays: Record<string, string>
26
+ }
30
27
 
31
- /** the swift overlays of the clang modules above, by module name. */
32
- export const IOS_SDK_OVERLAYS: Record<string, string> = {}
28
+ let sdk: IosSdk | undefined
33
29
 
34
- for (const [file, text] of tree) {
35
- const module = OVERLAY_PATH.exec(file)?.[1]
36
- if (module === undefined) {
37
- IOS_SDK_HEADERS[file] = text
38
- continue
30
+ // the tree is read from the package's sdk directory, which sits beside src and
31
+ // every dist directory; the standalone executable embeds it at build time. it is
32
+ // 34 MB, so only a command that compiles against it reads it.
33
+ export function iosSdk(): IosSdk {
34
+ if (sdk) return sdk
35
+ const bundled: Record<string, string> | null =
36
+ typeof __PEACH_BUNDLED_IOS_SDK__ === 'undefined'
37
+ ? null
38
+ : JSON.parse(__PEACH_BUNDLED_IOS_SDK__)
39
+ const tree = bundled
40
+ ? Object.entries(bundled).sort(([a], [b]) => (a < b ? -1 : 1))
41
+ : readIosSdkTree(path.join(peachsimPackageRoot(), 'sdk', 'ios'))
42
+ const headers: Record<string, string> = {}
43
+ const overlays: Record<string, string> = {}
44
+ for (const [file, text] of tree) {
45
+ const module = OVERLAY_PATH.exec(file)?.[1]
46
+ if (module === undefined) {
47
+ headers[file] = text
48
+ continue
49
+ }
50
+ const header = `// swift-interface-format-version: 1.0\n// swift-module-flags: -target ${IOS_SDK_TARGET} -enable-objc-interop -enable-library-evolution -module-name ${module}\n`
51
+ if (!text.startsWith(header))
52
+ throw new Error(`sdk overlay ${file} has the wrong interface header`)
53
+ overlays[module] = text.slice(header.length)
39
54
  }
40
- const header = `// swift-interface-format-version: 1.0\n// swift-module-flags: -target ${IOS_SDK_TARGET} -enable-objc-interop -enable-library-evolution -module-name ${module}\n`
41
- if (!text.startsWith(header))
42
- throw new Error(`sdk overlay ${file} has the wrong interface header`)
43
- IOS_SDK_OVERLAYS[module] = text.slice(header.length)
55
+ sdk = { headers, overlays }
56
+ return sdk
44
57
  }
@@ -21,7 +21,7 @@ import path from 'node:path'
21
21
  import { isRecord } from './is-record'
22
22
  import { swiftInterfaceWithoutBodies } from './swift-interface-bodies'
23
23
  import { swiftObjCPlatformFlags } from './swift-objc-platform'
24
- import { IOS_SDK_HEADERS, IOS_SDK_OVERLAYS, IOS_SDK_TARGET } from './swift-objc-sdk'
24
+ import { IOS_SDK_TARGET, iosSdk } from './swift-objc-sdk'
25
25
  import { clangImportNames, moduleMapTokens } from './swift-package'
26
26
  import {
27
27
  objcProtocolsInSwiftSignatures,
@@ -246,14 +246,14 @@ export function stripExternalSourceMarks(text: string): string {
246
246
  }
247
247
 
248
248
  function iosSdkEntries(): (readonly [string, string])[] {
249
- const overlays = Object.entries(IOS_SDK_OVERLAYS).map(
249
+ const overlays = Object.entries(iosSdk().overlays).map(
250
250
  ([module, text]) =>
251
251
  [
252
252
  `usr/lib/swift/${module}.swiftmodule/arm64-apple-ios-simulator.swiftinterface`,
253
253
  `// swift-interface-format-version: 1.0\n// swift-module-flags: -target ${IOS_SDK_TARGET} -enable-objc-interop -enable-library-evolution -module-name ${module}\n${text}`,
254
254
  ] as const,
255
255
  )
256
- const headers = Object.entries(IOS_SDK_HEADERS).map(
256
+ const headers = Object.entries(iosSdk().headers).map(
257
257
  ([file, text]) => [file, stripExternalSourceMarks(text)] as const,
258
258
  )
259
259
  return [...headers, ...overlays].sort(([a], [b]) => (a < b ? -1 : 1))
@@ -430,7 +430,7 @@ let sdkDeclarations: Map<string, SdkDeclaration> | null = null
430
430
  function sdkDeclaration(name: string): SdkDeclaration | null {
431
431
  if (sdkDeclarations === null) {
432
432
  const umbrellas = new Map<string, string>()
433
- for (const [file, text] of Object.entries(IOS_SDK_HEADERS)) {
433
+ for (const [file, text] of Object.entries(iosSdk().headers)) {
434
434
  const modulemap = FRAMEWORK_MODULEMAP.exec(file)
435
435
  if (!modulemap) continue
436
436
  const header = /umbrella header "([^"]+)"/.exec(text)?.[1]
@@ -441,7 +441,7 @@ function sdkDeclaration(name: string): SdkDeclaration | null {
441
441
  if (!found.has(name))
442
442
  found.set(name, { module, header: umbrellas.get(module) ?? header })
443
443
  }
444
- for (const [file, text] of Object.entries(IOS_SDK_HEADERS)) {
444
+ for (const [file, text] of Object.entries(iosSdk().headers)) {
445
445
  const location = FRAMEWORK_HEADER.exec(file)
446
446
  if (!location) continue
447
447
  const [, module, header] = location
@@ -693,7 +693,7 @@ export function objcView(
693
693
  const umbrella = `${name}/${name}.h`
694
694
  if (
695
695
  Object.hasOwn(
696
- IOS_SDK_HEADERS,
696
+ iosSdk().headers,
697
697
  `System/Library/Frameworks/${name}.framework/Headers/${name}.h`,
698
698
  )
699
699
  ) {
@@ -729,7 +729,7 @@ export function objcView(
729
729
  // standard library names, since `Swift.Duration` also searches it.
730
730
  const stubModule = (name: string, swift: boolean): boolean => {
731
731
  const sdk = Object.hasOwn(
732
- IOS_SDK_HEADERS,
732
+ iosSdk().headers,
733
733
  `System/Library/Frameworks/${name}.framework/Headers/${name}.h`,
734
734
  )
735
735
  if (!sdk && !swift) return stub(`${name}/${name}.h`, true)
@@ -137,12 +137,14 @@ function failure(error: unknown): string {
137
137
  const output =
138
138
  error && typeof error === 'object' && 'stderr' in error
139
139
  ? `${String(error.stderr)}\n${'stdout' in error ? String(error.stdout) : ''}`
140
- : String(error)
140
+ : error instanceof Error
141
+ ? error.message
142
+ : String(error)
141
143
  const errors = output
142
144
  .split('\n')
143
- .filter((line) => /^\S.*?:\d+:\d+: error:/.test(line))
144
- .map((line) => line.replace(/^.*?:\d+:\d+: error:\s*/, '').trim())
145
- return [...new Set(errors)].slice(0, 3).join('; ') || output.trim().slice(0, 400)
145
+ .filter((line) => /^(\S.*?:\d+:\d+: )?error:/.test(line))
146
+ .map((line) => line.replace(/^(.*?:\d+:\d+: )?error:\s*/, '').trim())
147
+ return [...new Set(errors)].slice(0, 3).join('; ') || output.trim().slice(-600)
146
148
  }
147
149
 
148
150
  const key = (...parts: string[]) =>
@@ -867,6 +869,8 @@ function peachModuleDirs(
867
869
  target,
868
870
  '-Xswiftc',
869
871
  '-Osize',
872
+ '-Xswiftc',
873
+ '-gnone',
870
874
  ...plugins.libraries.flatMap((library) => [
871
875
  '-Xswiftc',
872
876
  '-load-plugin-library',
@@ -3036,10 +3040,9 @@ async function binaryStandins(
3036
3040
  : cStandin(surface, binary, toolchain, dir),
3037
3041
  )
3038
3042
  } catch (error) {
3039
- throw new Error(
3040
- `no stand-in for ${surface.module}: ${error instanceof Error && !('stderr' in error) ? error.message : failure(error)}`,
3041
- { cause: error },
3042
- )
3043
+ throw new Error(`no stand-in for ${surface.module}: ${failure(error)}`, {
3044
+ cause: error,
3045
+ })
3043
3046
  }
3044
3047
  }
3045
3048
  publish(result)
@@ -193,6 +193,8 @@ interface ParsedObject {
193
193
  typePrefixesInObj: Set<string>
194
194
  rootFuncs: number[]
195
195
  rootSegs: number[]
196
+ /** absolute file offsets of each data segment's payload. */
197
+ segPayloadRanges: [number, number][]
196
198
  }
197
199
 
198
200
  const parsedObjectCache = new Map<string, ParsedObject>()
@@ -787,6 +789,10 @@ function parseWasmObjectBytes(
787
789
  typePrefixesInObj,
788
790
  rootFuncs,
789
791
  rootSegs,
792
+ segPayloadRanges: sEnds.map((end, i) => [
793
+ dataStart + sPayloadStarts[i]!,
794
+ dataStart + end,
795
+ ]),
790
796
  }
791
797
  }
792
798
 
@@ -1744,9 +1750,33 @@ export function pruneSwiftWasmLink(
1744
1750
  '$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufc',
1745
1751
  ])
1746
1752
 
1753
+ // the runtime resolves a clang-imported class named in a mangled type name,
1754
+ // such as the argument of Outcome<AVTimedMetadataGroup>, by objc_getClass
1755
+ // alone: no relocation reaches the class, so a live name keeps its provider.
1756
+ const objectBytes = new Map<ParsedObject, Buffer>()
1757
+ const keepObjCClassesNamedInSegment = (obj: ParsedObject, segIdx: number) => {
1758
+ const range = obj.segPayloadRanges[segIdx]
1759
+ if (!range) return
1760
+ let bytes = objectBytes.get(obj)
1761
+ if (!bytes) objectBytes.set(obj, (bytes = fs.readFileSync(obj.file)))
1762
+ const text = bytes.toString('latin1', range[0], range[1])
1763
+ for (const match of text.matchAll(/So(\d+)/g)) {
1764
+ const start = match.index + 2 + match[1]!.length
1765
+ const length = Number(match[1])
1766
+ if (text[start + length] !== 'C') continue
1767
+ const symbol = `._OBJC_CLASS_${text.slice(start, start + length)}`
1768
+ for (const provider of lazyProviders.get(symbol) ?? []) {
1769
+ eagerDynamicObjects.add(provider)
1770
+ extractObject(provider)
1771
+ activateSymbolInObj(provider, provider.symNames.indexOf(symbol))
1772
+ }
1773
+ }
1774
+ }
1775
+
1747
1776
  while (workQueue.length > 0) {
1748
1777
  const item = workQueue.pop()!
1749
1778
  const obj = item.obj
1779
+ if (item.kind === 'seg') keepObjCClassesNamedInSegment(obj, item.idx)
1750
1780
  let relocs: number[]
1751
1781
  if (item.kind === 'func') {
1752
1782
  relocs = obj.funcRelocs[item.idx]!