peachsim 0.1.1921 → 0.1.1923

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 (86) hide show
  1. package/detox/index.ts +201 -24
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/attached-projects.cjs +1 -1
  5. package/dist-lib/auth/shared-session.cjs +1 -1
  6. package/dist-lib/backend-origin.cjs +1 -1
  7. package/dist-lib/beta.cjs +1 -1
  8. package/dist-lib/beta.mjs +1 -1
  9. package/dist-lib/bridge-constants.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.mjs +1 -1
  12. package/dist-lib/bridge-contract.cjs +1 -1
  13. package/dist-lib/bridge-contract.mjs +1 -1
  14. package/dist-lib/bundle-channel.cjs +1 -1
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cloud-contract.cjs +1 -1
  18. package/dist-lib/cloud-contract.mjs +1 -1
  19. package/dist-lib/cloud-test-args.cjs +1 -1
  20. package/dist-lib/cloud-test-args.mjs +1 -1
  21. package/dist-lib/cloud.cjs +1 -1
  22. package/dist-lib/cloud.mjs +1 -1
  23. package/dist-lib/config.cjs +1 -1
  24. package/dist-lib/config.mjs +1 -1
  25. package/dist-lib/detox/index.cjs +115 -10
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/expo-swift-bundle.cjs +1 -1
  28. package/dist-lib/expo-swift-metadata.cjs +1 -1
  29. package/dist-lib/expo-swift-metadata.mjs +1 -1
  30. package/dist-lib/home-paths.cjs +1 -1
  31. package/dist-lib/host/bridge-host.cjs +1 -1
  32. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  33. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  34. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  35. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  36. package/dist-lib/host/websocket-proxy.cjs +1 -1
  37. package/dist-lib/index.cjs +1 -1
  38. package/dist-lib/jump-to-source-babel.cjs +1 -1
  39. package/dist-lib/jump-to-source-native.cjs +1 -1
  40. package/dist-lib/kotlin-host.cjs +1 -1
  41. package/dist-lib/menu.cjs +1 -1
  42. package/dist-lib/menu.mjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  45. package/dist-lib/metro-production-bundle.cjs +1 -1
  46. package/dist-lib/metro-production-bundle.mjs +1 -1
  47. package/dist-lib/metro.cjs +1 -1
  48. package/dist-lib/native-app-identity-project.cjs +1 -1
  49. package/dist-lib/native-app-identity-project.mjs +1 -1
  50. package/dist-lib/native-app-identity.cjs +1 -1
  51. package/dist-lib/native-app-identity.mjs +1 -1
  52. package/dist-lib/native-firebase-metadata.cjs +1 -1
  53. package/dist-lib/native-firebase-metadata.mjs +1 -1
  54. package/dist-lib/pdfium-raster.cjs +1 -1
  55. package/dist-lib/pdfium-raster.mjs +1 -1
  56. package/dist-lib/plist.cjs +1 -1
  57. package/dist-lib/plist.mjs +1 -1
  58. package/dist-lib/profiles.cjs +1 -1
  59. package/dist-lib/public-brand.cjs +1 -1
  60. package/dist-lib/public-origins-lib-esm.json +24 -24
  61. package/dist-lib/public-origins-lib.json +53 -53
  62. package/dist-lib/react-native-host-modules.cjs +1 -1
  63. package/dist-lib/react-native-host-modules.mjs +1 -1
  64. package/dist-lib/reap-browser.cjs +1 -1
  65. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  66. package/dist-lib/sdk.cjs +1 -1
  67. package/dist-lib/sdk.mjs +1 -1
  68. package/dist-lib/skills.cjs +1 -1
  69. package/dist-lib/swift-compile.cjs +1 -1
  70. package/dist-lib/swift-compile.mjs +1 -1
  71. package/dist-lib/swift-package.cjs +1 -1
  72. package/dist-lib/swift-package.mjs +1 -1
  73. package/dist-lib/swift-submit.cjs +1 -1
  74. package/dist-lib/swift-submit.mjs +1 -1
  75. package/dist-lib/swift-toolchain.cjs +1 -1
  76. package/dist-lib/swift.cjs +1 -1
  77. package/dist-lib/vite-swift.cjs +1 -1
  78. package/dist-lib/vite.cjs +1 -1
  79. package/dist-lib/worklet-executable.cjs +1 -1
  80. package/dist-lib/worklet-executable.mjs +1 -1
  81. package/dist-types/packages/peach-engine/src/engine/layout-sab.d.ts +2 -1
  82. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  83. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +4 -0
  84. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -0
  85. package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +1 -0
  86. package/package.json +1 -1
package/detox/index.ts CHANGED
@@ -1963,6 +1963,10 @@ const ONSET_STEP_MS = 1000 / 240
1963
1963
  // when another platform has no recorded stage times, search for the progress
1964
1964
  // of its first stored native stage within this window around the nominal time
1965
1965
  const PHASE_SEARCH_MS = 1000 / 30
1966
+ // a card crosses about seven device pixels per millisecond, so a finer step fits its text
1967
+ const PHASE_STEP_MS = 0.25
1968
+ // a recording's bar sits within about a display frame of its fitted card
1969
+ const BAR_LAG_SEARCH_MS = 24
1966
1970
 
1967
1971
  // the stored native leg lives at
1968
1972
  // <proof dir>/<target>/<case>/<checkpoint> and the prefix is `<case>-<checkpoint>`
@@ -2855,6 +2859,12 @@ export const device = {
2855
2859
  // the stored native frames whose changed-pixel progress this stage is
2856
2860
  // sampled at, set on the first timed stage only
2857
2861
  nativeProgress?: { baselinePng: string; png: string }
2862
+ // the stored native frame of the first moving timed stage: the Peach
2863
+ // sample nearest it sets the phase every later stage keeps
2864
+ nativePhaseFramePng?: string
2865
+ // the stored native frame of a stage after the phase stage: the first one
2866
+ // the bar-item clock lag changes fixes the lag that reproduces this recording
2867
+ nativeBarFramePng?: string
2858
2868
  anchor?: { id: string; notBeforeMs: number; onsetThresholdPercent?: number }
2859
2869
  }>,
2860
2870
  options: {
@@ -3012,6 +3022,19 @@ export const device = {
3012
3022
  ? -1
3013
3023
  : pairedStages.findIndex(isProgressStage)
3014
3024
  const nativeBaselineLabel = nativeStages[0]?.label
3025
+ // only a drive anchored on its first visible change carries native's
3026
+ // display phase; a touch or witnessed anchor already shares its clock
3027
+ const phaseStageIndex =
3028
+ DETOX_PLATFORM === 'ios' &&
3029
+ !options.anchorAtTouch &&
3030
+ !options.producerWitness &&
3031
+ !options.hold &&
3032
+ !options.witnessedInput
3033
+ ? pairedStages.findIndex(
3034
+ (stage) =>
3035
+ stage.offsetMs > 0 && stage.nativeActualMs !== undefined && !stage.anchor,
3036
+ )
3037
+ : -1
3015
3038
  const capturePromise: Promise<{
3016
3039
  workletFirstDelivery: { first: number | null; initial: number } | null
3017
3040
  inputReceipts: LockstepInputReceipt[]
@@ -3711,14 +3734,32 @@ export const device = {
3711
3734
  ...(sampledRefresh ? { samplingTargetTimestampMs: targetMs } : {}),
3712
3735
  })
3713
3736
  }
3737
+ const decode = async (png: string) =>
3738
+ createImageBitmap(await (await fetch(`data:image/png;base64,${png}`)).blob())
3739
+ const screenPixels = (bitmap: ImageBitmap) => {
3740
+ const canvas = document.createElement('canvas')
3741
+ canvas.width = bitmap.width
3742
+ canvas.height = bitmap.height
3743
+ const context = canvas.getContext('2d', { willReadFrequently: true })
3744
+ if (!context) throw new Error('peach phase fit needs a 2d canvas')
3745
+ context.drawImage(bitmap, 0, 0)
3746
+ return context.getImageData(0, 0, bitmap.width, bitmap.height).data
3747
+ }
3748
+ // a summed channel distance, since a card sliding over a dimmed
3749
+ // screen of nearly its own colour stays under the change threshold
3750
+ const screenDistance = (a: Uint8ClampedArray, b: Uint8ClampedArray) => {
3751
+ let diff = 0
3752
+ for (let i = 0; i < a.length; i += 4)
3753
+ diff +=
3754
+ Math.abs(a[i] - b[i]) +
3755
+ Math.abs(a[i + 1] - b[i + 1]) +
3756
+ Math.abs(a[i + 2] - b[i + 2])
3757
+ return diff
3758
+ }
3714
3759
  const nativeProgressPercent = async (progress: {
3715
3760
  baselinePng: string
3716
3761
  png: string
3717
3762
  }) => {
3718
- const decode = async (png: string) =>
3719
- createImageBitmap(
3720
- await (await fetch(`data:image/png;base64,${png}`)).blob(),
3721
- )
3722
3763
  const nativeBaseline = await decode(progress.baselinePng)
3723
3764
  const nativeStage = await decode(progress.png)
3724
3765
  const bounds = boundsFor(nativeStage)
@@ -3734,6 +3775,8 @@ export const device = {
3734
3775
  // the offset from the nominal time at which the first timed stage
3735
3776
  // reached the progress its native frame showed
3736
3777
  let phaseMs = 0
3778
+ let barLagFitted = false
3779
+ let barLagMinMs = -input.barLagSearchMs
3737
3780
  for (const stage of input.stages) {
3738
3781
  if (state.cancelled) throw new Error('peach motion capture was cancelled')
3739
3782
  const { anchorId, receipt: anchorReceipt } = await resolveAnchor(stage)
@@ -3768,16 +3811,128 @@ export const device = {
3768
3811
  }
3769
3812
  // sample the moment the native leg sampled, as long after this
3770
3813
  // lane's last delivered touch as native was after its own
3771
- await sampleAt(
3772
- stage,
3773
- anchorReceipt,
3774
- anchorId,
3814
+ const nativeMs =
3775
3815
  anchorReceipt.virtualTimestampMs +
3776
- stage.nativeActualMs +
3777
- touchOffsetMs -
3778
- stage.offsetMs +
3779
- producerOffsetMs,
3816
+ stage.nativeActualMs +
3817
+ touchOffsetMs -
3818
+ stage.offsetMs +
3819
+ producerOffsetMs
3820
+ if (!stage.nativePhaseFramePng) {
3821
+ if (stage.nativeBarFramePng && !barLagFitted) {
3822
+ const barMs = nativeMs + (anchorId === 'transition' ? phaseMs : 0)
3823
+ await stepToTime(barMs, false, stage.label)
3824
+ const nativeBar = await decode(stage.nativeBarFramePng)
3825
+ const nativePixels = screenPixels(nativeBar)
3826
+ nativeBar.close()
3827
+ const lags: { diff: number; lagMs: number }[] = []
3828
+ for (
3829
+ let lagMs = barLagMinMs;
3830
+ lagMs <= input.barLagSearchMs;
3831
+ lagMs += 2
3832
+ ) {
3833
+ controller.setScreenBarClockLag(lagMs)
3834
+ await controller.flushFrame()
3835
+ const bitmap = await captureBitmap()
3836
+ lags.push({
3837
+ diff: screenDistance(screenPixels(bitmap), nativePixels),
3838
+ lagMs,
3839
+ })
3840
+ bitmap.close()
3841
+ }
3842
+ // lags that render the same here have not reached the bar yet, so
3843
+ // the lag stays open to every one of them until a later stage
3844
+ // tells them apart, and this snapshot is the same for all
3845
+ const bestDiff = Math.min(...lags.map((entry) => entry.diff))
3846
+ const ties = lags.filter((entry) => entry.diff === bestDiff)
3847
+ barLagMinMs = ties[0].lagMs
3848
+ barLagFitted =
3849
+ ties.length === 1 ||
3850
+ ties[ties.length - 1].lagMs < input.barLagSearchMs
3851
+ controller.setScreenBarClockLag(barLagMinMs)
3852
+ await controller.flushFrame()
3853
+ }
3854
+ await sampleAt(
3855
+ stage,
3856
+ anchorReceipt,
3857
+ anchorId,
3858
+ nativeMs + (anchorId === 'transition' ? phaseMs : 0),
3859
+ )
3860
+ continue
3861
+ }
3862
+ // native's motion began at a random point of its display frame, so
3863
+ // its onset frame sits up to a frame into the curve. the whole
3864
+ // screen nearest the native frame within the phase search window
3865
+ // gives the phase; the card's travel dominates it, so the bar's own
3866
+ // timing is still judged by every later stage.
3867
+ const nativeFrame = await decode(stage.nativePhaseFramePng)
3868
+ const nativePixels = screenPixels(nativeFrame)
3869
+ let receipt = await stepToTime(
3870
+ Math.max(
3871
+ currentReceipt.virtualTimestampMs,
3872
+ nativeMs - input.phaseSearchMs,
3873
+ ),
3874
+ false,
3875
+ stage.label,
3876
+ )
3877
+ let best: {
3878
+ bitmap: ImageBitmap
3879
+ diff: number
3880
+ receipt: typeof receipt
3881
+ } | null = null
3882
+ // the next stage samples its native gap after the best frame, so
3883
+ // the search stops there and every later stage stays ahead of it
3884
+ const stageNativeMs = stage.nativeActualMs
3885
+ const next = input.stages.find(
3886
+ (later) =>
3887
+ typeof later.nativeActualMs === 'number' &&
3888
+ later.nativeActualMs > stageNativeMs,
3780
3889
  )
3890
+ const gapMs =
3891
+ next?.nativeActualMs === undefined
3892
+ ? Number.POSITIVE_INFINITY
3893
+ : next.nativeActualMs - stageNativeMs
3894
+ for (;;) {
3895
+ const bitmap = await captureBitmap()
3896
+ if (
3897
+ bitmap.width !== nativeFrame.width ||
3898
+ bitmap.height !== nativeFrame.height
3899
+ )
3900
+ throw new Error(
3901
+ `peach phase fit compares ${bitmap.width}x${bitmap.height} with native ${nativeFrame.width}x${nativeFrame.height}`,
3902
+ )
3903
+ const diff = screenDistance(screenPixels(bitmap), nativePixels)
3904
+ // frames that tie carry no phase, as before the motion reaches
3905
+ // the screen, so the latest of them is the nearest in phase
3906
+ if (!best || diff <= best.diff) {
3907
+ best?.bitmap.close()
3908
+ best = { bitmap, diff, receipt }
3909
+ } else {
3910
+ bitmap.close()
3911
+ }
3912
+ const nextMs = receipt.virtualTimestampMs + input.phaseStepMs
3913
+ if (
3914
+ nextMs > nativeMs + input.phaseSearchMs ||
3915
+ nextMs > best.receipt.virtualTimestampMs + gapMs - 2
3916
+ )
3917
+ break
3918
+ receipt = await controller.stepFrame(input.phaseStepMs)
3919
+ currentReceipt = receipt
3920
+ }
3921
+ nativeFrame.close()
3922
+ if (!best)
3923
+ throw new Error(`peach phase fit for ${stage.label} sampled nothing`)
3924
+ phaseMs = best.receipt.virtualTimestampMs - nativeMs
3925
+ snapshots.push({
3926
+ actualMs:
3927
+ best.receipt.virtualTimestampMs - anchorReceipt.virtualTimestampMs,
3928
+ anchorId,
3929
+ bitmap: best.bitmap,
3930
+ frameIndex: best.receipt.frameIndex,
3931
+ label: stage.label,
3932
+ offsetMs: stage.offsetMs,
3933
+ virtualTimestampMs: best.receipt.virtualTimestampMs,
3934
+ samplingTargetTimestampMs: nativeMs,
3935
+ })
3781
3936
  continue
3782
3937
  }
3783
3938
  if (stage.nativeProgress) {
@@ -3957,6 +4112,8 @@ export const device = {
3957
4112
  onsetStepMs: ONSET_STEP_MS,
3958
4113
  onsetChangePercent,
3959
4114
  phaseSearchMs: PHASE_SEARCH_MS,
4115
+ phaseStepMs: PHASE_STEP_MS,
4116
+ barLagSearchMs: BAR_LAG_SEARCH_MS,
3960
4117
  frame: options.frame ?? null,
3961
4118
  anchorAtTouch: options.anchorAtTouch ?? null,
3962
4119
  producerWitness: options.producerWitness ?? null,
@@ -3967,24 +4124,44 @@ export const device = {
3967
4124
  rootFrame: options.rootFrame ?? null,
3968
4125
  settleMs,
3969
4126
  stages: pairedStages.map((stage, index) =>
3970
- index === progressStageIndex &&
4127
+ index === phaseStageIndex &&
3971
4128
  nativeCheckpoint &&
3972
- nativeBaselineLabel &&
3973
4129
  fs.existsSync(path.join(nativeCheckpoint, `${stage.label}.png`))
3974
4130
  ? {
3975
4131
  ...stage,
3976
- nativeProgress: {
3977
- baselinePng: fs
3978
- .readFileSync(
3979
- path.join(nativeCheckpoint, `${nativeBaselineLabel}.png`),
3980
- )
3981
- .toString('base64'),
3982
- png: fs
4132
+ nativePhaseFramePng: fs
4133
+ .readFileSync(path.join(nativeCheckpoint, `${stage.label}.png`))
4134
+ .toString('base64'),
4135
+ }
4136
+ : index > phaseStageIndex &&
4137
+ phaseStageIndex >= 0 &&
4138
+ stage.nativeActualMs !== undefined &&
4139
+ nativeCheckpoint &&
4140
+ fs.existsSync(path.join(nativeCheckpoint, `${stage.label}.png`))
4141
+ ? {
4142
+ ...stage,
4143
+ nativeBarFramePng: fs
3983
4144
  .readFileSync(path.join(nativeCheckpoint, `${stage.label}.png`))
3984
4145
  .toString('base64'),
3985
- },
3986
- }
3987
- : stage,
4146
+ }
4147
+ : index === progressStageIndex &&
4148
+ nativeCheckpoint &&
4149
+ nativeBaselineLabel &&
4150
+ fs.existsSync(path.join(nativeCheckpoint, `${stage.label}.png`))
4151
+ ? {
4152
+ ...stage,
4153
+ nativeProgress: {
4154
+ baselinePng: fs
4155
+ .readFileSync(
4156
+ path.join(nativeCheckpoint, `${nativeBaselineLabel}.png`),
4157
+ )
4158
+ .toString('base64'),
4159
+ png: fs
4160
+ .readFileSync(path.join(nativeCheckpoint, `${stage.label}.png`))
4161
+ .toString('base64'),
4162
+ },
4163
+ }
4164
+ : stage,
3988
4165
  ),
3989
4166
  token,
3990
4167
  },
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var REFUSED_PERFORM_STEP_TYPES = [
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/capture-contract.ts
4
4
  var RNX_SCREEN_CAPTURE_VERSION = 1;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/cloud-contract.ts
4
4
  var RNX_CLOUD_MAX_ARTIFACT_BYTES = 40761776;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/cloud-test-args.ts
4
4
  var CLOUD_TEST_ARGS_MAX_COUNT = 32;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // ../contrast-runtime-delivery/src/version.ts
4
4
  function isValidRuntimeVersion(value) {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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;
@@ -10069,6 +10069,8 @@ async function postRemotePushToSimulator(params, launch) {
10069
10069
  }
10070
10070
  var ONSET_STEP_MS = 1e3 / 240;
10071
10071
  var PHASE_SEARCH_MS = 1e3 / 30;
10072
+ var PHASE_STEP_MS = 0.25;
10073
+ var BAR_LAG_SEARCH_MS = 24;
10072
10074
  function storedNativeCheckpoint(namePrefix) {
10073
10075
  const nativeTarget = `${DETOX_PLATFORM}${(process.env.APPEARANCE_REPORTED || process.env.APPEARANCE) === "dark" ? "-dark" : ""}`;
10074
10076
  const targetDir = path6.resolve(
@@ -10766,6 +10768,9 @@ var device = {
10766
10768
  });
10767
10769
  const progressStageIndex = DETOX_PLATFORM === "ios" || pairedStages.some((stage) => stage.nativeActualMs !== void 0) ? -1 : pairedStages.findIndex(isProgressStage);
10768
10770
  const nativeBaselineLabel = nativeStages[0]?.label;
10771
+ const phaseStageIndex = DETOX_PLATFORM === "ios" && !options.anchorAtTouch && !options.producerWitness && !options.hold && !options.witnessedInput ? pairedStages.findIndex(
10772
+ (stage) => stage.offsetMs > 0 && stage.nativeActualMs !== void 0 && !stage.anchor
10773
+ ) : -1;
10769
10774
  const capturePromise = page.evaluate(
10770
10775
  async (input) => {
10771
10776
  const captureWindow = window;
@@ -11252,10 +11257,23 @@ var device = {
11252
11257
  ...sampledRefresh ? { samplingTargetTimestampMs: targetMs } : {}
11253
11258
  });
11254
11259
  };
11260
+ const decode = async (png) => createImageBitmap(await (await fetch(`data:image/png;base64,${png}`)).blob());
11261
+ const screenPixels = (bitmap) => {
11262
+ const canvas = document.createElement("canvas");
11263
+ canvas.width = bitmap.width;
11264
+ canvas.height = bitmap.height;
11265
+ const context = canvas.getContext("2d", { willReadFrequently: true });
11266
+ if (!context) throw new Error("peach phase fit needs a 2d canvas");
11267
+ context.drawImage(bitmap, 0, 0);
11268
+ return context.getImageData(0, 0, bitmap.width, bitmap.height).data;
11269
+ };
11270
+ const screenDistance = (a, b) => {
11271
+ let diff = 0;
11272
+ for (let i = 0; i < a.length; i += 4)
11273
+ diff += Math.abs(a[i] - b[i]) + Math.abs(a[i + 1] - b[i + 1]) + Math.abs(a[i + 2] - b[i + 2]);
11274
+ return diff;
11275
+ };
11255
11276
  const nativeProgressPercent = async (progress) => {
11256
- const decode = async (png) => createImageBitmap(
11257
- await (await fetch(`data:image/png;base64,${png}`)).blob()
11258
- );
11259
11277
  const nativeBaseline = await decode(progress.baselinePng);
11260
11278
  const nativeStage = await decode(progress.png);
11261
11279
  const bounds = boundsFor(nativeStage);
@@ -11269,6 +11287,8 @@ var device = {
11269
11287
  }).changePercent;
11270
11288
  };
11271
11289
  let phaseMs = 0;
11290
+ let barLagFitted = false;
11291
+ let barLagMinMs = -input.barLagSearchMs;
11272
11292
  for (const stage of input.stages) {
11273
11293
  if (state.cancelled) throw new Error("peach motion capture was cancelled");
11274
11294
  const { anchorId, receipt: anchorReceipt } = await resolveAnchor(stage);
@@ -11290,12 +11310,89 @@ var device = {
11290
11310
  });
11291
11311
  continue;
11292
11312
  }
11293
- await sampleAt(
11294
- stage,
11295
- anchorReceipt,
11296
- anchorId,
11297
- anchorReceipt.virtualTimestampMs + stage.nativeActualMs + touchOffsetMs - stage.offsetMs + producerOffsetMs
11313
+ const nativeMs = anchorReceipt.virtualTimestampMs + stage.nativeActualMs + touchOffsetMs - stage.offsetMs + producerOffsetMs;
11314
+ if (!stage.nativePhaseFramePng) {
11315
+ if (stage.nativeBarFramePng && !barLagFitted) {
11316
+ const barMs = nativeMs + (anchorId === "transition" ? phaseMs : 0);
11317
+ await stepToTime(barMs, false, stage.label);
11318
+ const nativeBar = await decode(stage.nativeBarFramePng);
11319
+ const nativePixels2 = screenPixels(nativeBar);
11320
+ nativeBar.close();
11321
+ const lags = [];
11322
+ for (let lagMs = barLagMinMs; lagMs <= input.barLagSearchMs; lagMs += 2) {
11323
+ controller.setScreenBarClockLag(lagMs);
11324
+ await controller.flushFrame();
11325
+ const bitmap = await captureBitmap();
11326
+ lags.push({
11327
+ diff: screenDistance(screenPixels(bitmap), nativePixels2),
11328
+ lagMs
11329
+ });
11330
+ bitmap.close();
11331
+ }
11332
+ const bestDiff = Math.min(...lags.map((entry) => entry.diff));
11333
+ const ties = lags.filter((entry) => entry.diff === bestDiff);
11334
+ barLagMinMs = ties[0].lagMs;
11335
+ barLagFitted = ties.length === 1 || ties[ties.length - 1].lagMs < input.barLagSearchMs;
11336
+ controller.setScreenBarClockLag(barLagMinMs);
11337
+ await controller.flushFrame();
11338
+ }
11339
+ await sampleAt(
11340
+ stage,
11341
+ anchorReceipt,
11342
+ anchorId,
11343
+ nativeMs + (anchorId === "transition" ? phaseMs : 0)
11344
+ );
11345
+ continue;
11346
+ }
11347
+ const nativeFrame = await decode(stage.nativePhaseFramePng);
11348
+ const nativePixels = screenPixels(nativeFrame);
11349
+ let receipt2 = await stepToTime(
11350
+ Math.max(
11351
+ currentReceipt.virtualTimestampMs,
11352
+ nativeMs - input.phaseSearchMs
11353
+ ),
11354
+ false,
11355
+ stage.label
11298
11356
  );
11357
+ let best = null;
11358
+ const stageNativeMs = stage.nativeActualMs;
11359
+ const next = input.stages.find(
11360
+ (later) => typeof later.nativeActualMs === "number" && later.nativeActualMs > stageNativeMs
11361
+ );
11362
+ const gapMs = next?.nativeActualMs === void 0 ? Number.POSITIVE_INFINITY : next.nativeActualMs - stageNativeMs;
11363
+ for (; ; ) {
11364
+ const bitmap = await captureBitmap();
11365
+ if (bitmap.width !== nativeFrame.width || bitmap.height !== nativeFrame.height)
11366
+ throw new Error(
11367
+ `peach phase fit compares ${bitmap.width}x${bitmap.height} with native ${nativeFrame.width}x${nativeFrame.height}`
11368
+ );
11369
+ const diff = screenDistance(screenPixels(bitmap), nativePixels);
11370
+ if (!best || diff <= best.diff) {
11371
+ best?.bitmap.close();
11372
+ best = { bitmap, diff, receipt: receipt2 };
11373
+ } else {
11374
+ bitmap.close();
11375
+ }
11376
+ const nextMs = receipt2.virtualTimestampMs + input.phaseStepMs;
11377
+ if (nextMs > nativeMs + input.phaseSearchMs || nextMs > best.receipt.virtualTimestampMs + gapMs - 2)
11378
+ break;
11379
+ receipt2 = await controller.stepFrame(input.phaseStepMs);
11380
+ currentReceipt = receipt2;
11381
+ }
11382
+ nativeFrame.close();
11383
+ if (!best)
11384
+ throw new Error(`peach phase fit for ${stage.label} sampled nothing`);
11385
+ phaseMs = best.receipt.virtualTimestampMs - nativeMs;
11386
+ snapshots.push({
11387
+ actualMs: best.receipt.virtualTimestampMs - anchorReceipt.virtualTimestampMs,
11388
+ anchorId,
11389
+ bitmap: best.bitmap,
11390
+ frameIndex: best.receipt.frameIndex,
11391
+ label: stage.label,
11392
+ offsetMs: stage.offsetMs,
11393
+ virtualTimestampMs: best.receipt.virtualTimestampMs,
11394
+ samplingTargetTimestampMs: nativeMs
11395
+ });
11299
11396
  continue;
11300
11397
  }
11301
11398
  if (stage.nativeProgress) {
@@ -11451,6 +11548,8 @@ var device = {
11451
11548
  onsetStepMs: ONSET_STEP_MS,
11452
11549
  onsetChangePercent,
11453
11550
  phaseSearchMs: PHASE_SEARCH_MS,
11551
+ phaseStepMs: PHASE_STEP_MS,
11552
+ barLagSearchMs: BAR_LAG_SEARCH_MS,
11454
11553
  frame: options.frame ?? null,
11455
11554
  anchorAtTouch: options.anchorAtTouch ?? null,
11456
11555
  producerWitness: options.producerWitness ?? null,
@@ -11461,7 +11560,13 @@ var device = {
11461
11560
  rootFrame: options.rootFrame ?? null,
11462
11561
  settleMs,
11463
11562
  stages: pairedStages.map(
11464
- (stage, index) => index === progressStageIndex && nativeCheckpoint && nativeBaselineLabel && fs4.existsSync(path6.join(nativeCheckpoint, `${stage.label}.png`)) ? {
11563
+ (stage, index) => index === phaseStageIndex && nativeCheckpoint && fs4.existsSync(path6.join(nativeCheckpoint, `${stage.label}.png`)) ? {
11564
+ ...stage,
11565
+ nativePhaseFramePng: fs4.readFileSync(path6.join(nativeCheckpoint, `${stage.label}.png`)).toString("base64")
11566
+ } : index > phaseStageIndex && phaseStageIndex >= 0 && stage.nativeActualMs !== void 0 && nativeCheckpoint && fs4.existsSync(path6.join(nativeCheckpoint, `${stage.label}.png`)) ? {
11567
+ ...stage,
11568
+ nativeBarFramePng: fs4.readFileSync(path6.join(nativeCheckpoint, `${stage.label}.png`)).toString("base64")
11569
+ } : index === progressStageIndex && nativeCheckpoint && nativeBaselineLabel && fs4.existsSync(path6.join(nativeCheckpoint, `${stage.label}.png`)) ? {
11465
11570
  ...stage,
11466
11571
  nativeProgress: {
11467
11572
  baselinePng: fs4.readFileSync(
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1921 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1923 | (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;