peachsim 0.1.1716 → 0.1.1728

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 (234) hide show
  1. package/README.md +21 -3
  2. package/cli/app-bundle-resources.ts +2 -1
  3. package/cli/app-fonts.ts +4 -4
  4. package/cli/app-splash.ts +4 -4
  5. package/cli/app-stubs.ts +17 -0
  6. package/cli/command-registry.ts +1 -0
  7. package/cli/commands/control.ts +82 -822
  8. package/cli/commands/daemon.ts +8 -0
  9. package/cli/commands/detox.ts +3 -0
  10. package/cli/commands/doctor.ts +19 -2
  11. package/cli/commands/inspect/actions.ts +74 -14
  12. package/cli/commands/inspect/core.ts +5 -1
  13. package/cli/commands/inspect/settling.ts +5 -2
  14. package/cli/commands/inspect/wait-ready.ts +6 -0
  15. package/cli/commands/inspect.ts +48 -45
  16. package/cli/commands/kotlin.ts +12 -2
  17. package/cli/commands/package.ts +750 -0
  18. package/cli/commands/serve.ts +6 -0
  19. package/cli/commands/shell-url.ts +834 -0
  20. package/cli/commands/swift.ts +42 -102
  21. package/cli/commands/test.ts +20 -0
  22. package/cli/commands/upload.ts +1 -1
  23. package/cli/device-option.ts +1 -1
  24. package/cli/main.ts +13 -1
  25. package/cli/native-input.ts +199 -0
  26. package/cli/outbound-endpoints.ts +26 -1
  27. package/cli/packaged-app-launcher.ts +95 -0
  28. package/cli/scene-video.ts +13 -6
  29. package/detox/index.ts +187 -23
  30. package/dist-lib/agent-daemon-client.cjs +1 -1
  31. package/dist-lib/agent-events.cjs +1 -1
  32. package/dist-lib/attached-projects.cjs +1 -1
  33. package/dist-lib/auth/shared-session.cjs +1 -1
  34. package/dist-lib/backend-origin.cjs +1 -1
  35. package/dist-lib/beta.cjs +1 -1
  36. package/dist-lib/beta.mjs +1 -1
  37. package/dist-lib/bridge-constants.cjs +1 -1
  38. package/dist-lib/bridge-contract-input.cjs +1 -1
  39. package/dist-lib/bridge-contract-input.mjs +1 -1
  40. package/dist-lib/bridge-contract.cjs +1 -1
  41. package/dist-lib/bridge-contract.mjs +1 -1
  42. package/dist-lib/bundle-channel.cjs +38000 -31658
  43. package/dist-lib/capture-contract.cjs +1 -1
  44. package/dist-lib/capture-contract.mjs +1 -1
  45. package/dist-lib/cloud-contract.cjs +1 -1
  46. package/dist-lib/cloud-contract.mjs +1 -1
  47. package/dist-lib/cloud-test-args.cjs +1 -1
  48. package/dist-lib/cloud-test-args.mjs +1 -1
  49. package/dist-lib/cloud.cjs +1 -1
  50. package/dist-lib/cloud.mjs +1 -1
  51. package/dist-lib/config.cjs +1 -1
  52. package/dist-lib/config.mjs +1 -1
  53. package/dist-lib/detox/index.cjs +184 -60
  54. package/dist-lib/dev-bundle-resolution.cjs +14 -13
  55. package/dist-lib/expo-swift-bundle.cjs +18199 -11834
  56. package/dist-lib/expo-swift-metadata.cjs +4 -1
  57. package/dist-lib/expo-swift-metadata.mjs +3 -1
  58. package/dist-lib/home-paths.cjs +21 -2
  59. package/dist-lib/host/bridge-host.cjs +26509 -23850
  60. package/dist-lib/host/fetch-proxy-handler.cjs +221 -222
  61. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  62. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  63. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  64. package/dist-lib/host/websocket-proxy.cjs +1 -1
  65. package/dist-lib/index.cjs +876 -389
  66. package/dist-lib/jump-to-source-babel.cjs +1 -1
  67. package/dist-lib/jump-to-source-native.cjs +1 -1
  68. package/dist-lib/kotlin-host.cjs +127 -16
  69. package/dist-lib/menu.cjs +7 -1
  70. package/dist-lib/menu.mjs +7 -1
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +1 -1
  75. package/dist-lib/metro.cjs +883 -404
  76. package/dist-lib/native-app-identity-project.cjs +694 -280
  77. package/dist-lib/native-app-identity-project.mjs +490 -83
  78. package/dist-lib/native-app-identity.cjs +13 -2
  79. package/dist-lib/native-app-identity.mjs +13 -2
  80. package/dist-lib/native-firebase-metadata.cjs +1 -1
  81. package/dist-lib/native-firebase-metadata.mjs +1 -1
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +1 -1
  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 +28 -23
  87. package/dist-lib/public-origins-lib.json +392 -224
  88. package/dist-lib/react-native-host-modules.cjs +32 -2
  89. package/dist-lib/react-native-host-modules.mjs +32 -2
  90. package/dist-lib/reap-browser.cjs +12 -4
  91. package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
  92. package/dist-lib/sdk.cjs +17 -7
  93. package/dist-lib/sdk.mjs +16 -7
  94. package/dist-lib/skills.cjs +61838 -47851
  95. package/dist-lib/swift-compile.cjs +583 -360
  96. package/dist-lib/swift-compile.mjs +496 -275
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +1 -1
  99. package/dist-lib/swift-submit.cjs +2 -2
  100. package/dist-lib/swift-submit.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +105 -17
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vite-swift.cjs +4453 -2231
  104. package/dist-lib/vite.cjs +230 -228
  105. package/dist-lib/worklet-executable.cjs +1 -1
  106. package/dist-lib/worklet-executable.mjs +1 -1
  107. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
  108. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
  109. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +7 -5
  110. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +3 -1
  111. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -11
  112. package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
  113. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
  114. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  115. package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
  116. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +4 -0
  117. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +23 -1
  119. package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
  120. package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
  121. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  122. package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
  123. package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
  124. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
  125. package/package.json +1 -1
  126. package/runtime-companion.json +1 -1
  127. package/scripts/dev-server-scanner.ts +12 -25
  128. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
  129. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
  130. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
  131. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
  132. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
  133. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
  134. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
  135. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
  136. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
  137. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
  138. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -0
  139. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
  140. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
  141. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +75 -9
  142. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
  143. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
  144. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
  145. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
  146. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
  147. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
  148. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
  149. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
  150. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
  151. package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
  152. package/sdk/ios/usr/include/module.modulemap +1 -0
  153. package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
  154. package/sdk/ios/usr/include/os.modulemap +5 -0
  155. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  156. package/sdk/ios/usr/include/sys/ioccom.h +99 -0
  157. package/sdk/ios/usr/include/sys/syslog.h +236 -0
  158. package/sdk/ios/usr/include/syslog.h +24 -0
  159. package/sdk/ios/wasm/include/fcntl.h +4 -2
  160. package/sdk/ios/wasm/include/stdio.h +24 -0
  161. package/sdk/ios/wasm/include/stdlib.h +32 -7
  162. package/sdk/ios/wasm/include/sys/file.h +7 -0
  163. package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
  164. package/sdk/ios/wasm/include/sys/syscall.h +9 -0
  165. package/sdk/ios/wasm/include/sys/time.h +10 -0
  166. package/sdk/ios/wasm/include/unistd.h +12 -3
  167. package/sdk/native-hashes.json +1 -0
  168. package/skills/contrast/SKILL.md +2 -1
  169. package/skills/peach-test/SKILL.md +7 -3
  170. package/src/admitted-mac-build.ts +3 -0
  171. package/src/android-app-identity.ts +18 -0
  172. package/src/android-root-module.ts +9 -9
  173. package/src/appPackageContract.ts +81 -0
  174. package/src/bridge-contract.ts +50 -0
  175. package/src/bundle-channel.mjs +21 -4
  176. package/src/dev-bundle-resolution.ts +7 -27
  177. package/src/dom-source-reference.ts +15 -0
  178. package/src/expo-discovery-cache.ts +127 -23
  179. package/src/expo-manifest-body.ts +33 -0
  180. package/src/expo-native-workspace.ts +38 -13
  181. package/src/expo-swift-host.ts +264 -62
  182. package/src/expoSwiftContract.ts +3 -0
  183. package/src/generated/swift-c-predefines.json +1 -1
  184. package/src/home-paths.ts +35 -1
  185. package/src/host/app-package-handler.ts +47 -0
  186. package/src/host/bridge-host.ts +3 -0
  187. package/src/host/staged-host-files.ts +18 -0
  188. package/src/index.ts +3 -0
  189. package/src/kotlin-host.ts +21 -18
  190. package/src/kotlin-instance-source.ts +126 -0
  191. package/src/menu.ts +7 -0
  192. package/src/native-app-identity-project.ts +7 -2
  193. package/src/native-app-identity.ts +11 -0
  194. package/src/native-firebase-config.ts +24 -1
  195. package/src/nitro-adapter.lock.json +268 -268
  196. package/src/nitro-bundle.ts +8 -0
  197. package/src/nitro-compile.ts +35 -9
  198. package/src/nitro-dependencies.ts +21 -19
  199. package/src/nitro-source.ts +4 -0
  200. package/src/nitroContract.ts +7 -0
  201. package/src/react-native-bridge-modules.ts +68 -42
  202. package/src/react-native-host-modules.ts +31 -1
  203. package/src/reactNativeConfigurationContract.ts +14 -0
  204. package/src/reap-browser.ts +15 -3
  205. package/src/sdk.ts +5 -0
  206. package/src/settingsContract.ts +27 -1
  207. package/src/sim-client.ts +4 -1
  208. package/src/storageSnapshotContract.ts +3 -0
  209. package/src/swift-compile.ts +221 -41
  210. package/src/swift-coverage/provenance.ts +1 -0
  211. package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
  212. package/src/swift-coverage/xcode-assets.ts +89 -131
  213. package/src/swift-coverage/xcode.ts +1 -1
  214. package/src/swift-cxx-reachable.ts +2 -1
  215. package/src/swift-distribution.lock.json +14 -13
  216. package/src/swift-host.ts +95 -22
  217. package/src/swift-icu.ts +1 -1
  218. package/src/swift-link-roots.ts +118 -0
  219. package/src/swift-objc-compile.ts +144 -22
  220. package/src/swift-objc-import.ts +6 -0
  221. package/src/swift-objc-standin.ts +2 -14
  222. package/src/swift-package-manifest.ts +14 -6
  223. package/src/swift-packages.ts +75 -11
  224. package/src/swift-pdf-raster.ts +1 -0
  225. package/src/swift-root-lock.ts +17 -1
  226. package/src/swift-source-pods.ts +2 -10
  227. package/src/swift-standin-emit.ts +592 -57
  228. package/src/swift-standins.ts +430 -49
  229. package/src/swift-submit.ts +3 -1
  230. package/src/swift-toolchain.ts +140 -17
  231. package/src/turbo-codegen-intake.ts +91 -0
  232. package/src/vite-plugin-one.ts +13 -9
  233. package/src/vite-plugin.ts +28 -15
  234. package/src/xcode-project.ts +223 -22
@@ -30,12 +30,19 @@ export async function renderSceneToVideo(options: {
30
30
  if (!installed.ok) throw new Error(installed.message)
31
31
  const require = createRequire(import.meta.url)
32
32
  const { chromium }: typeof import('playwright-core') = require(resolved.modulePath)
33
- const browser = await launchReapedChrome((opts) => chromium.launch(opts), {
34
- headless: true,
35
- ...(installed.libraryPath
36
- ? { env: { ...process.env, LD_LIBRARY_PATH: installed.libraryPath } }
37
- : {}),
38
- })
33
+ // the headless shell provisioned above has no GPU; off a Mac it renders the
34
+ // scene in software, as the sim host that recorded it does.
35
+ const browser = await launchReapedChrome(
36
+ (opts) => chromium.launch(opts),
37
+ {
38
+ headless: true,
39
+ ...(installed.libraryPath
40
+ ? { env: { ...process.env, LD_LIBRARY_PATH: installed.libraryPath } }
41
+ : {}),
42
+ },
43
+ undefined,
44
+ { software: process.platform !== 'darwin' },
45
+ )
39
46
  try {
40
47
  const source = new URL(options.shellUrl)
41
48
  const url = new URL(source.pathname, source.origin)
package/detox/index.ts CHANGED
@@ -701,7 +701,12 @@ async function queryMatcherInPage({
701
701
  let hadNumericLayout = false
702
702
  let disappearedMidWait = false
703
703
  while (Date.now() - startedAt < maxWaitMs) {
704
- const observation = await window.__sootsimTest!.observeTapTarget(indexedMatcher)
704
+ // detox taps the element's own activation point and lets window
705
+ // hit-testing pick the receiver, so the settle wait tracks that point
706
+ // even when no finger can reach the element itself.
707
+ const observation = await window.__sootsimTest!.observeTapTarget(indexedMatcher, {
708
+ includeUnreachable: true,
709
+ })
705
710
  const node = observation
706
711
  if (!node) {
707
712
  if (hadNumericLayout) disappearedMidWait = true
@@ -825,7 +830,12 @@ async function dispatchTapAtSootsimPoint(page: Page, point: TapPoint, token?: st
825
830
  if ('nodeId' in point) {
826
831
  // resolve after the viewport read, in the browser task that dispatches
827
832
  // the pointer. a host round trip here can outlive a startup relayout.
828
- const resolved = await window.__sootsimTest!.resolveTapTarget(point.nodeId)
833
+ // detox creates the touch at the element's activation point even when
834
+ // the element itself cannot receive a pointer hit; window hit-testing
835
+ // picks the receiver.
836
+ const resolved = await window.__sootsimTest!.resolveTapTarget(point.nodeId, {
837
+ includeUnreachable: true,
838
+ })
829
839
  if (!resolved) throw new Error(`element disappeared before tap: ${point.nodeId}`)
830
840
  const node = resolved.match
831
841
  if (point.offset) {
@@ -1609,7 +1619,8 @@ function createSootSimElement(matcher: Matcher): SootSimElement {
1609
1619
  // label is visually projected around the wheel and can overlap a later
1610
1620
  // label near the cylinder edge.
1611
1621
  const tapTarget = await page.evaluate(
1612
- async (nodeId) => window.__sootsimTest?.resolveTapTarget(nodeId),
1622
+ async (nodeId) =>
1623
+ window.__sootsimTest?.resolveTapTarget(nodeId, { includeUnreachable: true }),
1613
1624
  target.nodeId,
1614
1625
  )
1615
1626
  if (!tapTarget) {
@@ -1889,6 +1900,48 @@ async function postRemotePushToSimulator(
1889
1900
  // searched at that resolution; a 60Hz step lands up to 16ms deep into the curve
1890
1901
  const ONSET_STEP_MS = 1000 / 240
1891
1902
 
1903
+ // the native onset frame sits an arbitrary phase into the animation, because
1904
+ // it is whichever display tick first showed change and the recording stamps it
1905
+ // on its own irregular grid. a stage is therefore sampled at the animation
1906
+ // progress its native frame showed, found within this window around the nominal
1907
+ // time, and the offset it lands on carries to the stages after it
1908
+ const PHASE_SEARCH_MS = 1000 / 30
1909
+
1910
+ // the changed-pixel inputs of the first timed stage of the stored native leg:
1911
+ // its pre-trigger and stage frames. the leg lives at
1912
+ // <proof dir>/<target>/<case>/<checkpoint> and the prefix is `<case>-<checkpoint>`
1913
+ function storedNativeProgressFrames(namePrefix: string, label: string) {
1914
+ const nativeTarget = `${DETOX_PLATFORM}${(process.env.APPEARANCE_REPORTED || process.env.APPEARANCE) === 'dark' ? '-dark' : ''}`
1915
+ const targetDir = path.resolve(
1916
+ process.cwd(),
1917
+ process.env.CONFORMANCE_PROOF_DIR || 'artifacts/conformance-proof/latest',
1918
+ nativeTarget,
1919
+ )
1920
+ if (!fs.existsSync(targetDir)) return null
1921
+ for (const caseName of fs.readdirSync(targetDir)) {
1922
+ if (!namePrefix.startsWith(`${caseName}-`)) continue
1923
+ const checkpointDir = path.join(
1924
+ targetDir,
1925
+ caseName,
1926
+ namePrefix.slice(caseName.length + 1),
1927
+ )
1928
+ if (!fs.existsSync(path.join(checkpointDir, `${label}.png`))) return null
1929
+ return {
1930
+ baselinePng: fs
1931
+ .readFileSync(path.join(checkpointDir, 'pre-trigger.png'))
1932
+ .toString('base64'),
1933
+ png: fs.readFileSync(path.join(checkpointDir, `${label}.png`)).toString('base64'),
1934
+ }
1935
+ }
1936
+ return null
1937
+ }
1938
+
1939
+ const isProgressStage = (stage: {
1940
+ offsetMs: number
1941
+ nativeActualMs?: number
1942
+ anchor?: object
1943
+ }) => stage.offsetMs > 0 && stage.nativeActualMs === undefined && !stage.anchor
1944
+
1892
1945
  export const device = {
1893
1946
  _currentUrl: '',
1894
1947
  _platform: DETOX_PLATFORM as 'ios' | 'android',
@@ -2155,7 +2208,11 @@ export const device = {
2155
2208
 
2156
2209
  async reloadReactNative() {
2157
2210
  const page = getPage()
2158
- await page.reload({ waitUntil: 'load', timeout: 30000 })
2211
+ // native detox reloads the js bundle inside the running app process: the
2212
+ // old react tree and runtime retire and a new one mounts. the shell page
2213
+ // stays loaded and the tenant worker is replaced in place. the bridge
2214
+ // resolves once the new tenant's display is ready.
2215
+ await page.evaluate(() => window.SootSim!.bridges.hotRemount!.reloadExternalApp())
2159
2216
  await waitForSootsimTree(page, 30000)
2160
2217
  await waitForSootsimSurfaceMetrics(page, 30000)
2161
2218
  await waitForSootsimShellReady(page, 30000)
@@ -2690,6 +2747,9 @@ export const device = {
2690
2747
  // the time after the onset at which the paired native leg sampled this
2691
2748
  // stage; the stage is sampled at that time instead of the nominal offset
2692
2749
  nativeActualMs?: number
2750
+ // the stored native frames whose changed-pixel progress this stage is
2751
+ // sampled at, set on the first timed stage only
2752
+ nativeProgress?: { baselinePng: string; png: string }
2693
2753
  anchor?: { id: string; notBeforeMs: number; onsetThresholdPercent?: number }
2694
2754
  }>,
2695
2755
  options: {
@@ -3283,32 +3343,114 @@ export const device = {
3283
3343
  }
3284
3344
 
3285
3345
  const snapshots: Snapshot[] = []
3346
+ // whole 60Hz frames, then one partial step to land on the target
3347
+ const stepToTime = async (targetMs: number) => {
3348
+ let receipt = currentReceipt
3349
+ if (targetMs < receipt.virtualTimestampMs - 0.01) {
3350
+ throw new Error(
3351
+ `sample time ${targetMs}ms precedes the frames already stepped`,
3352
+ )
3353
+ }
3354
+ while (receipt.virtualTimestampMs + 1000 / 60 <= targetMs + 0.01) {
3355
+ receipt = await controller.stepFrame()
3356
+ }
3357
+ if (targetMs - receipt.virtualTimestampMs > 0.01) {
3358
+ receipt = await controller.stepFrame(targetMs - receipt.virtualTimestampMs)
3359
+ }
3360
+ currentReceipt = receipt
3361
+ return receipt
3362
+ }
3363
+ const sampleAt = async (
3364
+ stage: { label: string; offsetMs: number },
3365
+ anchorReceipt: SootSimLockstepFrameReceipt,
3366
+ anchorId: string,
3367
+ targetMs: number,
3368
+ ) => {
3369
+ const receipt = await stepToTime(targetMs)
3370
+ snapshots.push({
3371
+ actualMs: receipt.virtualTimestampMs - anchorReceipt.virtualTimestampMs,
3372
+ anchorId,
3373
+ bitmap: await captureBitmap(),
3374
+ frameIndex: receipt.frameIndex,
3375
+ label: stage.label,
3376
+ offsetMs: stage.offsetMs,
3377
+ virtualTimestampMs: receipt.virtualTimestampMs,
3378
+ })
3379
+ }
3380
+ const nativeProgressPercent = async (progress: {
3381
+ baselinePng: string
3382
+ png: string
3383
+ }) => {
3384
+ const decode = async (png: string) =>
3385
+ createImageBitmap(
3386
+ await (await fetch(`data:image/png;base64,${png}`)).blob(),
3387
+ )
3388
+ const nativeBaseline = await decode(progress.baselinePng)
3389
+ const nativeStage = await decode(progress.png)
3390
+ const bounds = boundsFor(nativeStage)
3391
+ return measureChange({
3392
+ baseline: regionPixels(nativeBaseline),
3393
+ candidate: regionPixels(nativeStage),
3394
+ definition: input.motionChangeDefinition,
3395
+ height: bounds.height,
3396
+ label: 'native stage progress',
3397
+ width: bounds.width,
3398
+ }).changePercent
3399
+ }
3400
+ // the offset from the nominal time at which the first timed stage
3401
+ // reached the progress its native frame showed
3402
+ let phaseMs = 0
3286
3403
  for (const stage of input.stages) {
3287
3404
  if (state.cancelled) throw new Error('peach motion capture was cancelled')
3288
3405
  const { anchorId, receipt: anchorReceipt } = await resolveAnchor(stage)
3289
3406
  if (typeof stage.nativeActualMs === 'number') {
3290
- // sample the moment the native leg sampled: whole 60Hz frames,
3291
- // then one partial step to land on it
3292
- const targetMs = anchorReceipt.virtualTimestampMs + stage.nativeActualMs
3407
+ // sample the moment the native leg sampled
3408
+ await sampleAt(
3409
+ stage,
3410
+ anchorReceipt,
3411
+ anchorId,
3412
+ anchorReceipt.virtualTimestampMs + stage.nativeActualMs,
3413
+ )
3414
+ continue
3415
+ }
3416
+ const touchOffsetMs = await stageOffsetMs(stage.offsetMs, anchorId)
3417
+ if (stage.nativeProgress) {
3418
+ const targetPercent = await nativeProgressPercent(stage.nativeProgress)
3419
+ const nominalMs = anchorReceipt.virtualTimestampMs + touchOffsetMs
3293
3420
  let receipt = currentReceipt
3294
- if (targetMs < receipt.virtualTimestampMs - 0.01) {
3295
- throw new Error(
3296
- `peach stage ${stage.label} native time ${stage.nativeActualMs}ms precedes the frames already stepped`,
3297
- )
3298
- }
3299
- while (receipt.virtualTimestampMs + 1000 / 60 <= targetMs + 0.01) {
3421
+ while (
3422
+ receipt.virtualTimestampMs + 1000 / 60 <=
3423
+ nominalMs - input.phaseSearchMs
3424
+ ) {
3300
3425
  receipt = await controller.stepFrame()
3301
3426
  }
3302
- if (targetMs - receipt.virtualTimestampMs > 0.01) {
3303
- receipt = await controller.stepFrame(
3304
- targetMs - receipt.virtualTimestampMs,
3305
- )
3427
+ let progressBitmap: ImageBitmap | null = null
3428
+ while (!progressBitmap) {
3429
+ if (receipt.virtualTimestampMs > nominalMs + input.phaseSearchMs) {
3430
+ throw new Error(
3431
+ `peach stage ${stage.label} never reached the native progress ${targetPercent}% within ${input.phaseSearchMs}ms of ${touchOffsetMs}ms`,
3432
+ )
3433
+ }
3434
+ receipt = await controller.stepFrame(1)
3435
+ const candidateBitmap = await captureBitmap()
3436
+ const bounds = boundsFor(candidateBitmap)
3437
+ const progress = measureChange({
3438
+ baseline,
3439
+ candidate: regionPixels(candidateBitmap),
3440
+ definition: input.motionChangeDefinition,
3441
+ height: bounds.height,
3442
+ label: 'peach stage progress',
3443
+ width: bounds.width,
3444
+ }).changePercent
3445
+ if (progress >= targetPercent) progressBitmap = candidateBitmap
3446
+ else candidateBitmap.close()
3306
3447
  }
3307
3448
  currentReceipt = receipt
3449
+ phaseMs = receipt.virtualTimestampMs - nominalMs
3308
3450
  snapshots.push({
3309
3451
  actualMs: receipt.virtualTimestampMs - anchorReceipt.virtualTimestampMs,
3310
3452
  anchorId,
3311
- bitmap: await captureBitmap(),
3453
+ bitmap: progressBitmap,
3312
3454
  frameIndex: receipt.frameIndex,
3313
3455
  label: stage.label,
3314
3456
  offsetMs: stage.offsetMs,
@@ -3316,7 +3458,17 @@ export const device = {
3316
3458
  })
3317
3459
  continue
3318
3460
  }
3319
- const touchOffsetMs = await stageOffsetMs(stage.offsetMs, anchorId)
3461
+ if (phaseMs !== 0) {
3462
+ await sampleAt(
3463
+ stage,
3464
+ anchorReceipt,
3465
+ anchorId,
3466
+ anchorReceipt.virtualTimestampMs +
3467
+ touchOffsetMs +
3468
+ (anchorId === 'transition' ? phaseMs : 0),
3469
+ )
3470
+ continue
3471
+ }
3320
3472
  const stageFrameIndex =
3321
3473
  anchorReceipt.frameIndex + controller.framesForOffset(touchOffsetMs)
3322
3474
  const kept = keptFrames.get(stageFrameIndex)
@@ -3353,8 +3505,9 @@ export const device = {
3353
3505
  // and leave it down. the settle then runs from that release.
3354
3506
  let releasedOffsetMs = 0
3355
3507
  while (input.hold && !releaseReceipt()) {
3356
- const receipt = await controller.stepFrame()
3357
- releasedOffsetMs = receipt.virtualTimestampMs - driveStart.virtualTimestampMs
3508
+ currentReceipt = await controller.stepFrame()
3509
+ releasedOffsetMs =
3510
+ currentReceipt.virtualTimestampMs - driveStart.virtualTimestampMs
3358
3511
  }
3359
3512
  await heldInput
3360
3513
  if (input.settleMs > 0) {
@@ -3366,7 +3519,9 @@ export const device = {
3366
3519
  ),
3367
3520
  releasedOffsetMs,
3368
3521
  )
3369
- await controller.stepToOffset(driveStart, maximumPrimaryMs + input.settleMs)
3522
+ await stepToTime(
3523
+ driveStart.virtualTimestampMs + maximumPrimaryMs + input.settleMs,
3524
+ )
3370
3525
  }
3371
3526
  while (!state.triggerCompleted) {
3372
3527
  if (state.cancelled) throw new Error('peach motion capture was cancelled')
@@ -3415,6 +3570,7 @@ export const device = {
3415
3570
  workletFrameTimestampsSeconds: options.workletFrameTimestampsSeconds,
3416
3571
  detectionTimeoutMs: options.detectionTimeoutMs ?? 3000,
3417
3572
  onsetStepMs: ONSET_STEP_MS,
3573
+ phaseSearchMs: PHASE_SEARCH_MS,
3418
3574
  frame: options.frame ?? null,
3419
3575
  anchorAtTouch: options.anchorAtTouch ?? null,
3420
3576
  witnessedDrag: options.witnessedDrag === true,
@@ -3423,7 +3579,15 @@ export const device = {
3423
3579
  platform: device.getPlatform(),
3424
3580
  rootFrame: options.rootFrame ?? null,
3425
3581
  settleMs,
3426
- stages,
3582
+ stages: stages.map((stage, index) =>
3583
+ index === stages.findIndex(isProgressStage)
3584
+ ? {
3585
+ ...stage,
3586
+ nativeProgress:
3587
+ storedNativeProgressFrames(namePrefix, stage.label) ?? undefined,
3588
+ }
3589
+ : stage,
3590
+ ),
3427
3591
  token,
3428
3592
  },
3429
3593
  )
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
package/dist-lib/beta.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
package/dist-lib/beta.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/beta.ts
4
4
  var IS_BETA = true;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var SIM_LONG_PRESS_MAX_MS = 5e3;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var REFUSED_PERFORM_STEP_TYPES = [