peachsim 0.1.2489 → 0.1.2491

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 (145) hide show
  1. package/cli/bridge-flow-runner.ts +190 -167
  2. package/cli/cloud-client.ts +7 -2
  3. package/cli/commands/control.ts +36 -26
  4. package/cli/commands/inspect/settling.ts +7 -2
  5. package/cli/commands/kotlin.ts +2 -0
  6. package/cli/commands/swift.ts +3 -0
  7. package/cli/native-input.ts +2 -0
  8. package/dist-lib/agent-daemon-client.cjs +1 -1
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +2 -2
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +5 -5
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +3 -3
  20. package/dist-lib/bundle-channel.cjs +3 -3
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +3 -3
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +3 -3
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +2 -2
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +7 -7
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/config.mjs +5 -5
  31. package/dist-lib/detox/index.cjs +8 -3
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/esm-chunks/{acorn-46P725QB.mjs → acorn-2J725R5I.mjs} +3 -3
  34. package/dist-lib/esm-chunks/{chunk-PWLDSFLP.mjs → chunk-2HK4H7ZI.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-NN6KHA6F.mjs → chunk-6VR25SPG.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-T53UQ6V7.mjs → chunk-6XNOBDYY.mjs} +3 -3
  37. package/dist-lib/esm-chunks/{chunk-K3NXHJBV.mjs → chunk-7VU3MCJG.mjs} +12 -12
  38. package/dist-lib/esm-chunks/{chunk-FXOLLJ7N.mjs → chunk-7WLZ4NHN.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-CB2MREW2.mjs → chunk-AQZG62OH.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-FNFDX5OA.mjs → chunk-EIM3TPVZ.mjs} +2 -2
  41. package/dist-lib/esm-chunks/{chunk-QR4AFBNL.mjs → chunk-EMQ3TSAN.mjs} +5 -5
  42. package/dist-lib/esm-chunks/{chunk-KFJJOPLU.mjs → chunk-EN5F4P2G.mjs} +5 -5
  43. package/dist-lib/esm-chunks/{chunk-G4KFSINI.mjs → chunk-EZBJ5J3I.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-MOGXM5NJ.mjs → chunk-FX5ONYBN.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-HO4COZOG.mjs → chunk-GNJLEHNW.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-ST7BG6HB.mjs → chunk-GQJ6AWTA.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-5F5TV3M5.mjs → chunk-GV6SJTHZ.mjs} +4 -4
  48. package/dist-lib/esm-chunks/{chunk-ZGCWGHEX.mjs → chunk-IUJGRRA5.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-E7Z6E4VM.mjs → chunk-KYB5R7DP.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-XYRP56S5.mjs → chunk-MAHSHPSW.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{chunk-2ZAKSUG3.mjs → chunk-NLX75NDQ.mjs} +1 -1
  52. package/dist-lib/esm-chunks/{chunk-75IXYYPA.mjs → chunk-NPNMSHHT.mjs} +1 -1
  53. package/dist-lib/esm-chunks/{chunk-FMR76G4M.mjs → chunk-PE74RKR2.mjs} +1 -1
  54. package/dist-lib/esm-chunks/{chunk-YH2VVDO2.mjs → chunk-Z2NSJMVJ.mjs} +1 -1
  55. package/dist-lib/esm-chunks/{metro-layout-parser-FPL6XENQ.mjs → metro-layout-parser-G37VWZEJ.mjs} +3 -3
  56. package/dist-lib/esm-chunks/{swift-package-prebuilt-FYUAWFYO.mjs → swift-package-prebuilt-SEN55VIB.mjs} +10 -10
  57. package/dist-lib/esm-chunks/{swift-sdk-app-module-RVHNFMEY.mjs → swift-sdk-app-module-UK4USPH3.mjs} +13 -13
  58. package/dist-lib/esm-chunks/{swift-sdk-image-JHQ6DP5G.mjs → swift-sdk-image-IBWK7WQH.mjs} +13 -13
  59. package/dist-lib/esm-chunks/{swift-sdk-image-producer-XQ5W4ONP.mjs → swift-sdk-image-producer-NLZJWZSK.mjs} +4 -4
  60. package/dist-lib/expo-swift-bundle.cjs +2 -2
  61. package/dist-lib/expo-swift-metadata.cjs +1 -1
  62. package/dist-lib/expo-swift-metadata.mjs +7 -7
  63. package/dist-lib/home-paths.cjs +1 -1
  64. package/dist-lib/host/bridge-host.cjs +31 -8
  65. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  66. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  67. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  68. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  69. package/dist-lib/host/websocket-proxy.cjs +1 -1
  70. package/dist-lib/index.cjs +11 -5
  71. package/dist-lib/kotlin-host.cjs +1 -1
  72. package/dist-lib/menu.cjs +1 -1
  73. package/dist-lib/menu.mjs +3 -3
  74. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  75. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  76. package/dist-lib/metro-production-bundle.cjs +1 -1
  77. package/dist-lib/metro-production-bundle.mjs +4 -4
  78. package/dist-lib/native-app-identity-project.cjs +1 -1
  79. package/dist-lib/native-app-identity-project.mjs +15 -15
  80. package/dist-lib/native-app-identity.cjs +1 -1
  81. package/dist-lib/native-app-identity.mjs +6 -6
  82. package/dist-lib/native-firebase-metadata.cjs +1 -1
  83. package/dist-lib/native-firebase-metadata.mjs +3 -3
  84. package/dist-lib/pdfium-raster.cjs +1 -1
  85. package/dist-lib/pdfium-raster.mjs +2 -2
  86. package/dist-lib/plist.cjs +1 -1
  87. package/dist-lib/plist.mjs +3 -3
  88. package/dist-lib/profiles.cjs +1 -1
  89. package/dist-lib/public-brand.cjs +1 -1
  90. package/dist-lib/public-origins-lib-esm.json +79 -79
  91. package/dist-lib/public-origins-lib.json +69 -69
  92. package/dist-lib/react-native-host-modules.cjs +1 -1
  93. package/dist-lib/react-native-host-modules.mjs +2 -2
  94. package/dist-lib/reap-browser.cjs +1 -1
  95. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  96. package/dist-lib/sdk.cjs +8 -3
  97. package/dist-lib/sdk.mjs +14 -9
  98. package/dist-lib/skills.cjs +223 -208
  99. package/dist-lib/swift-compile.cjs +1 -1
  100. package/dist-lib/swift-compile.mjs +10 -10
  101. package/dist-lib/swift-package.cjs +1 -1
  102. package/dist-lib/swift-package.mjs +3 -3
  103. package/dist-lib/swift-submit.cjs +1 -1
  104. package/dist-lib/swift-submit.mjs +5 -5
  105. package/dist-lib/swift-svg-raster.cjs +1 -1
  106. package/dist-lib/swift-svg-raster.mjs +2 -2
  107. package/dist-lib/swift-toolchain.cjs +1 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  110. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  111. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  112. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  113. package/dist-lib/vendor/acorn.cjs +1 -1
  114. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  115. package/dist-lib/vendor/ignore.cjs +1 -1
  116. package/dist-lib/vendor/magic-string.cjs +1 -1
  117. package/dist-lib/vendor/plist.cjs +1 -1
  118. package/dist-lib/vendor/smol-toml.cjs +1 -1
  119. package/dist-lib/vendor/stream-json.cjs +1 -1
  120. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  121. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  122. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  123. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  124. package/dist-lib/vendor/sucrase.cjs +1 -1
  125. package/dist-lib/vendor/terser.cjs +1 -1
  126. package/dist-lib/vendor/valibot.cjs +1 -1
  127. package/dist-lib/vendor/ws.cjs +1 -1
  128. package/dist-lib/vendor/zod.cjs +1 -1
  129. package/dist-lib/worklet-executable.cjs +1 -1
  130. package/dist-lib/worklet-executable.mjs +3 -3
  131. package/dist-types/packages/peach-engine/src/render-worker/auxPointerContract.d.ts +4 -0
  132. package/dist-types/packages/peach-engine/src/render-worker/host.d.ts +187 -0
  133. package/dist-types/packages/peach-engine/src/render-worker/live-frame-to-shell.d.ts +2 -0
  134. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +10 -10
  135. package/dist-types/packages/peach-engine/src/render-worker/render-host-ref.d.ts +14 -0
  136. package/dist-types/packages/peach-engine/src/render-worker/surface-ownerContract.d.ts +2 -0
  137. package/dist-types/packages/peach-globals/src/index.d.ts +2 -2
  138. package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
  139. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +13 -1
  140. package/package.json +1 -1
  141. package/src/bridge-contract.ts +2 -17
  142. package/src/connect.ts +1 -1
  143. package/src/swift-host.ts +11 -2
  144. package/src/swift-sdk-later-data.ts +21 -4
  145. package/src/swift-startup-split.ts +6 -1
@@ -37,7 +37,13 @@ import {
37
37
  import { MaestroJsContext, scriptConditionIsTruthy } from './maestro-js'
38
38
  import { redactForSharing } from './output-redaction'
39
39
  import { ensureCliRecordingEntitlement } from './recording-access'
40
- import type { PerformResult, PerformStep, ResetResult } from '../src/bridge-contract'
40
+ import type {
41
+ PerformResult,
42
+ PerformStep,
43
+ ResetResult,
44
+ SimNodeRecord,
45
+ SimSemanticQueryResult,
46
+ } from '../src/bridge-contract'
41
47
  import type { WsBridge } from './ws-bridge'
42
48
  import type {
43
49
  PeachAccessibilityNode,
@@ -1645,178 +1651,193 @@ export class SootSimBridgeFlowRunner {
1645
1651
  // (match scoped to a container). a nested selector resolves the same way,
1646
1652
  // and a relative filter holds when ANY match of its anchor satisfies it.
1647
1653
  private async findElementScoped(opts: FlowTargetSelector, preferHittable = false) {
1648
- const screen = await this.screenBounds()
1649
- const candidates = await this.evaluate<any[]>(`(async () => {
1650
- const test = globalThis.__sootsimTest
1651
- if (!test || !test.queryAll) return null
1652
- const selector = ${JSON.stringify(opts)}
1653
- const compile = ${maestroSelectorMatcher.toString()}
1654
- // relative filters need their anchors too; other id selectors only
1655
- // project matching nodes, retaining every duplicate for ordering below.
1656
- // patterns accepting an absent id also need unidentified nodes.
1657
- const idMatcher = selector.id == null ? null : compile(selector.id, 'id')
1658
- const needsAnchors = ['childOf', 'below', 'above', 'leftOf', 'rightOf']
1659
- .some((key) => selector[key] != null)
1660
- const query = idMatcher && !idMatcher(null) && !needsAnchors
1661
- ? { idPattern: { source: idMatcher.source, flags: idMatcher.flags, matchLastSegment: true } }
1662
- : {}
1663
- const all = ((await test.queryAll(query)) || []).filter(
1664
- (n) => n && n.absolutePosition && n.layout,
1654
+ const relativeKeys = ['below', 'above', 'leftOf', 'rightOf'] as const
1655
+ const needsAnchors =
1656
+ opts.childOf != null || relativeKeys.some((key) => opts[key] != null)
1657
+ const recordQuery: Promise<SimSemanticQueryResult> = this.bridge.send({
1658
+ type: 'query',
1659
+ simId: this.opts.simId,
1660
+ query: { kind: 'nodes', id: needsAnchors ? undefined : opts.id },
1661
+ })
1662
+ const [screen, result] = await Promise.all([this.screenBounds(), recordQuery])
1663
+ const all = result.records
1664
+ if (!Array.isArray(all)) throw new Error('engine returned no selector node records')
1665
+ // maestro reads ios frames as integer edges (AXElement.boundsString)
1666
+ const bounds = (n: SimNodeRecord) => {
1667
+ const left = Math.trunc(n.absolutePosition.x)
1668
+ const top = Math.trunc(n.absolutePosition.y)
1669
+ return {
1670
+ x: left,
1671
+ y: top,
1672
+ width: Math.trunc(n.absolutePosition.x + n.layout.width) - left,
1673
+ height: Math.trunc(n.absolutePosition.y + n.layout.height) - top,
1674
+ }
1675
+ }
1676
+ const painted = (n: SimNodeRecord) => (n.visibleFrame?.area ?? 0) > 0
1677
+ // one viewport contract, shared with isOffscreen in
1678
+ // commands/inspect/resolve-target.ts: a center on the edge still takes
1679
+ // a tap, so the edge counts as on screen here too.
1680
+ const centerOnScreen = (n: SimNodeRecord) => {
1681
+ const cx = n.absolutePosition.x + n.layout.width / 2
1682
+ const cy = n.absolutePosition.y + n.layout.height / 2
1683
+ return cx >= 0 && cx <= screen.width && cy >= 0 && cy <= screen.height
1684
+ }
1685
+ const byPosition = (a: SimNodeRecord, b: SimNodeRecord) =>
1686
+ a.absolutePosition.y - b.absolutePosition.y ||
1687
+ a.absolutePosition.x - b.absolutePosition.x
1688
+ const relative = {
1689
+ below: (n: SimNodeRecord, other: SimNodeRecord) => bounds(n).y > bounds(other).y,
1690
+ above: (n: SimNodeRecord, other: SimNodeRecord) => bounds(n).y < bounds(other).y,
1691
+ leftOf: (n: SimNodeRecord, other: SimNodeRecord) => bounds(n).x < bounds(other).x,
1692
+ rightOf: (n: SimNodeRecord, other: SimNodeRecord) => bounds(n).x > bounds(other).x,
1693
+ }
1694
+ const traitFilters = new Map<string, (node: SimNodeRecord) => boolean>([
1695
+ ['TEXT', (node) => node.text != null],
1696
+ [
1697
+ 'SQUARE',
1698
+ (node) => {
1699
+ const frame = bounds(node)
1700
+ return Math.abs(1 - frame.width / frame.height) < 0.03
1701
+ },
1702
+ ],
1703
+ ['LONG_TEXT', (node) => (node.text?.length ?? 0) > 200],
1704
+ ])
1705
+ const matchAll = (raw: FlowTargetSelector | string): SimNodeRecord[] => {
1706
+ const sel = typeof raw === 'string' ? { text: raw } : raw
1707
+ const matchesId = sel.id == null ? null : maestroSelectorMatcher(sel.id, 'id')
1708
+ const matchesText =
1709
+ sel.text == null ? null : maestroSelectorMatcher(sel.text, 'text')
1710
+ let candidates = all.filter(
1711
+ (n) =>
1712
+ (!matchesId || matchesId(n.testID)) &&
1713
+ (!matchesText ||
1714
+ matchesText(n.text) ||
1715
+ matchesText(n.accessibilityLabel) ||
1716
+ matchesText(n.placeholder)),
1665
1717
  )
1666
- // maestro reads ios frames as integer edges (AXElement.boundsString)
1667
- const bounds = (n) => {
1668
- const left = Math.trunc(n.absolutePosition.x)
1669
- const top = Math.trunc(n.absolutePosition.y)
1670
- return {
1671
- x: left,
1672
- y: top,
1673
- width: Math.trunc(n.absolutePosition.x + n.layout.width) - left,
1674
- height: Math.trunc(n.absolutePosition.y + n.layout.height) - top,
1675
- }
1718
+ if (sel.width != null || sel.height != null) {
1719
+ const tolerance = sel.tolerance ?? 0
1720
+ candidates = candidates.filter((n) => {
1721
+ const b = bounds(n)
1722
+ return (
1723
+ (sel.width == null || Math.abs(b.width - sel.width) <= tolerance) &&
1724
+ (sel.height == null || Math.abs(b.height - sel.height) <= tolerance)
1725
+ )
1726
+ })
1676
1727
  }
1677
- const painted = (n) => (n.visibleFrame?.area ?? 0) > 0
1678
- // one viewport contract, shared with isOffscreen in
1679
- // commands/inspect/resolve-target.ts: a center on the edge still takes
1680
- // a tap, so the edge counts as on screen here too.
1681
- const centerOnScreen = (n) => {
1682
- const cx = n.absolutePosition.x + n.layout.width / 2
1683
- const cy = n.absolutePosition.y + n.layout.height / 2
1684
- return cx >= 0 && cx <= ${screen.width} && cy >= 0 && cy <= ${screen.height}
1728
+ for (const trait of sel.traits ? String(sel.traits).split(' ') : []) {
1729
+ const filter = traitFilters.get(trait.replaceAll('-', '_').toUpperCase())
1730
+ if (!filter) throw new Error('unknown selector trait: ' + trait)
1731
+ candidates = candidates.filter(filter)
1685
1732
  }
1686
- const byPosition = (a, b) =>
1687
- a.absolutePosition.y - b.absolutePosition.y ||
1688
- a.absolutePosition.x - b.absolutePosition.x
1689
- const relative = {
1690
- below: (n, other) => bounds(n).y > bounds(other).y,
1691
- above: (n, other) => bounds(n).y < bounds(other).y,
1692
- leftOf: (n, other) => bounds(n).x < bounds(other).x,
1693
- rightOf: (n, other) => bounds(n).x > bounds(other).x,
1733
+ // ios reports isEnabled / isSelected from the accessibility traits
1734
+ // react native derives from accessibilityState
1735
+ if (sel.enabled != null) {
1736
+ candidates = candidates.filter(
1737
+ (n) => !n.accessibilityState?.disabled === sel.enabled,
1738
+ )
1694
1739
  }
1695
- const traitFilters = {
1696
- TEXT: (n) => n.text != null,
1697
- SQUARE: (n) => {
1698
- const b = bounds(n)
1699
- return Math.abs(1 - b.width / b.height) < 0.03
1700
- },
1701
- LONG_TEXT: (n) => (n.text?.length ?? 0) > 200,
1740
+ if (sel.selected != null) {
1741
+ candidates = candidates.filter(
1742
+ (n) => !!n.accessibilityState?.selected === sel.selected,
1743
+ )
1702
1744
  }
1703
- const matchAll = (raw) => {
1704
- const sel = typeof raw === 'string' ? { text: raw } : raw
1705
- const matchesId = sel.id == null ? null : compile(sel.id, 'id')
1706
- const matchesText = sel.text == null ? null : compile(sel.text, 'text')
1707
- let candidates = all.filter((n) =>
1708
- (!matchesId || matchesId(n.testID)) &&
1709
- (!matchesText || matchesText(n.text) || matchesText(n.accessibilityLabel) || matchesText(n.placeholder)),
1745
+ // maestro's ios checked: a switch whose value is "1". react native
1746
+ // gives the switch role that trait and reports "1" from
1747
+ // accessibilityState.checked; a checkbox role gets no trait, so ios
1748
+ // never reads it as checked.
1749
+ if (sel.checked != null) {
1750
+ candidates = candidates.filter(
1751
+ (n) =>
1752
+ (n.accessibilityRole === 'switch' &&
1753
+ n.accessibilityState?.checked === true) === sel.checked,
1754
+ )
1755
+ }
1756
+ for (const key of relativeKeys) {
1757
+ const anchor = sel[key]
1758
+ if (anchor == null) continue
1759
+ const anchors = pick(
1760
+ matchAll(anchor),
1761
+ typeof anchor === 'string' ? undefined : anchor.index,
1762
+ )
1763
+ candidates = candidates.filter((n) =>
1764
+ anchors.some((other) => relative[key](n, other)),
1710
1765
  )
1711
- if (sel.width != null || sel.height != null) {
1712
- const tolerance = sel.tolerance ?? 0
1713
- candidates = candidates.filter((n) => {
1714
- const b = bounds(n)
1715
- return (sel.width == null || Math.abs(b.width - sel.width) <= tolerance) &&
1716
- (sel.height == null || Math.abs(b.height - sel.height) <= tolerance)
1717
- })
1718
- }
1719
- for (const trait of sel.traits ? String(sel.traits).split(' ') : []) {
1720
- const filter = traitFilters[trait.replaceAll('-', '_').toUpperCase()]
1721
- if (!filter) throw new Error('unknown selector trait: ' + trait)
1722
- candidates = candidates.filter(filter)
1723
- }
1724
- // ios reports isEnabled / isSelected from the accessibility traits
1725
- // react native derives from accessibilityState
1726
- if (sel.enabled != null) {
1727
- candidates = candidates.filter((n) => !n.accessibilityState?.disabled === sel.enabled)
1728
- }
1729
- if (sel.selected != null) {
1730
- candidates = candidates.filter((n) => !!n.accessibilityState?.selected === sel.selected)
1731
- }
1732
- // maestro's ios checked: a switch whose value is "1". react native
1733
- // gives the switch role that trait and reports "1" from
1734
- // accessibilityState.checked; a checkbox role gets no trait, so ios
1735
- // never reads it as checked.
1736
- if (sel.checked != null) {
1737
- candidates = candidates.filter(
1738
- (n) =>
1739
- (n.accessibilityRole === 'switch' && n.accessibilityState?.checked === true) ===
1740
- sel.checked,
1741
- )
1742
- }
1743
- for (const key of Object.keys(relative)) {
1744
- if (sel[key] == null) continue
1745
- const anchors = pick(matchAll(sel[key]), sel[key].index)
1746
- candidates = candidates.filter((n) => anchors.some((other) => relative[key](n, other)))
1747
- }
1748
- // scope before visibility: childOf narrows the match set first, so a
1749
- // clipped sliver inside the container survives to resolve (and refuse
1750
- // honestly) instead of being discarded for a hittable duplicate the
1751
- // scope then removes.
1752
- if (sel.childOf) {
1753
- const containers = matchAll(sel.childOf)
1754
- const container = containers.find(painted) ?? containers[0]
1755
- if (!container) return []
1756
- const x0 = container.absolutePosition.x
1757
- const y0 = container.absolutePosition.y
1758
- const x1 = x0 + container.layout.width
1759
- const y1 = y0 + container.layout.height
1760
- candidates = candidates.filter((n) => {
1761
- const cx = n.absolutePosition.x + n.layout.width / 2
1762
- const cy = n.absolutePosition.y + n.layout.height / 2
1763
- return cx >= x0 && cx <= x1 && cy >= y0 && cy <= y1
1764
- })
1765
- }
1766
- // prefer painted matches, then on-screen ones (findByTestId's
1767
- // visible-first behavior); only fall back to off-screen ones when
1768
- // nothing is on-screen, so index: still resolves a target that needs
1769
- // scrolling into view. a screen still mounted under the one on top
1770
- // paints nothing, and maestro's hierarchy never holds it.
1771
- const onScreen = candidates.filter(centerOnScreen)
1772
- // without an explicit index, prefer a painted match whose center is
1773
- // on screen: a painted sliver with its center off screen cannot take
1774
- // a tap at its center, so a duplicate id resolves to the hittable
1775
- // match. an explicit index keeps the full painted order, and a
1776
- // clipped-only match still resolves so the tap reports honestly.
1777
- const paintedCandidates = candidates.filter(painted)
1778
- if (paintedCandidates.length > 0) {
1779
- if (sel.index == null) {
1780
- const hittable = paintedCandidates.filter(centerOnScreen)
1781
- candidates = hittable.length > 0 ? hittable : paintedCandidates
1782
- } else {
1783
- candidates = paintedCandidates
1784
- }
1785
- } else if (onScreen.length > 0) candidates = onScreen
1786
- // maestro's index: sorts matches by frame y, then x, and without an
1787
- // index takes the first in the ios hierarchy, which lays siblings out
1788
- // by position rather than subview order (RAN on ios 27: two views with
1789
- // one identifier, the first subview moved below by a transform, maestro
1790
- // takes the upper one). a list that renders rows in key order and
1791
- // places them by transform still resolves its top row.
1792
- candidates.sort(byPosition)
1793
- if (sel.index == null && sel.text && !sel.id) {
1794
- candidates.sort((a, b) => (a.text || '').length - (b.text || '').length)
1795
- }
1796
- return candidates
1797
1766
  }
1798
- // maestro Filters.index: a negative index counts from the end
1799
- const pick = (candidates, rawIndex) => {
1800
- if (rawIndex == null) return candidates
1801
- const index = Math.trunc(Number(rawIndex))
1802
- const resolved = index >= 0 ? index : candidates.length + index
1803
- return candidates[resolved] ? [candidates[resolved]] : []
1767
+ // scope before visibility: childOf narrows the match set first, so a
1768
+ // clipped sliver inside the container survives to resolve (and refuse
1769
+ // honestly) instead of being discarded for a hittable duplicate the
1770
+ // scope then removes.
1771
+ if (sel.childOf) {
1772
+ const containers = matchAll(sel.childOf)
1773
+ const container = containers.find(painted) ?? containers[0]
1774
+ if (!container) return []
1775
+ const x0 = container.absolutePosition.x
1776
+ const y0 = container.absolutePosition.y
1777
+ const x1 = x0 + container.layout.width
1778
+ const y1 = y0 + container.layout.height
1779
+ candidates = candidates.filter((n) => {
1780
+ const cx = n.absolutePosition.x + n.layout.width / 2
1781
+ const cy = n.absolutePosition.y + n.layout.height / 2
1782
+ return cx >= x0 && cx <= x1 && cy >= y0 && cy <= y1
1783
+ })
1804
1784
  }
1805
- const matches = pick(matchAll(selector), selector.index)
1806
- const nodes = ${JSON.stringify(preferHittable && opts.index == null)} ? matches : matches.slice(0, 1)
1807
- return nodes.map((node) => ({
1808
- nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
1809
- id: node.id || null,
1810
- testID: node.testID || null,
1811
- text: node.text || null,
1812
- absolutePosition: node.absolutePosition,
1813
- layout: node.layout,
1814
- // authoritative visibility, as in findElement above.
1815
- visibleFrame: node.visibleFrame || null,
1816
- isTextInput: !!node.isTextInput,
1817
- }))
1818
- })()`)
1819
- if (!candidates?.length) return null
1785
+ // prefer painted matches, then on-screen ones (findByTestId's
1786
+ // visible-first behavior); only fall back to off-screen ones when
1787
+ // nothing is on-screen, so index: still resolves a target that needs
1788
+ // scrolling into view. a screen still mounted under the one on top
1789
+ // paints nothing, and maestro's hierarchy never holds it.
1790
+ const onScreen = candidates.filter(centerOnScreen)
1791
+ // without an explicit index, prefer a painted match whose center is
1792
+ // on screen: a painted sliver with its center off screen cannot take
1793
+ // a tap at its center, so a duplicate id resolves to the hittable
1794
+ // match. an explicit index keeps the full painted order, and a
1795
+ // clipped-only match still resolves so the tap reports honestly.
1796
+ const paintedCandidates = candidates.filter(painted)
1797
+ if (paintedCandidates.length > 0) {
1798
+ if (sel.index == null) {
1799
+ const hittable = paintedCandidates.filter(centerOnScreen)
1800
+ candidates = hittable.length > 0 ? hittable : paintedCandidates
1801
+ } else {
1802
+ candidates = paintedCandidates
1803
+ }
1804
+ } else if (onScreen.length > 0) candidates = onScreen
1805
+ // maestro's index: sorts matches by frame y, then x, and without an
1806
+ // index takes the first in the ios hierarchy, which lays siblings out
1807
+ // by position rather than subview order (RAN on ios 27: two views with
1808
+ // one identifier, the first subview moved below by a transform, maestro
1809
+ // takes the upper one). a list that renders rows in key order and
1810
+ // places them by transform still resolves its top row.
1811
+ candidates.sort(byPosition)
1812
+ if (sel.index == null && sel.text && !sel.id) {
1813
+ candidates.sort((a, b) => (a.text || '').length - (b.text || '').length)
1814
+ }
1815
+ return candidates
1816
+ }
1817
+ // maestro Filters.index: a negative index counts from the end
1818
+ const pick = (
1819
+ candidates: SimNodeRecord[],
1820
+ rawIndex?: FlowTargetSelector['index'],
1821
+ ) => {
1822
+ if (rawIndex == null) return candidates
1823
+ const index = Math.trunc(Number(rawIndex))
1824
+ const resolved = index >= 0 ? index : candidates.length + index
1825
+ return candidates[resolved] ? [candidates[resolved]] : []
1826
+ }
1827
+ const matches = pick(matchAll(opts), opts.index)
1828
+ const nodes = preferHittable && opts.index == null ? matches : matches.slice(0, 1)
1829
+ const candidates = nodes.map((node) => ({
1830
+ nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
1831
+ id: node.id || null,
1832
+ testID: node.testID || null,
1833
+ text: node.text || null,
1834
+ absolutePosition: node.absolutePosition,
1835
+ layout: node.layout,
1836
+ // authoritative visibility, as in findElement above.
1837
+ visibleFrame: node.visibleFrame || null,
1838
+ isTextInput: !!node.isTextInput,
1839
+ }))
1840
+ if (!candidates.length) return null
1820
1841
  return preferHittable && opts.index == null
1821
1842
  ? this.preferHittableCandidate(candidates)
1822
1843
  : candidates[0]
@@ -2214,11 +2235,13 @@ export class SootSimBridgeFlowRunner {
2214
2235
  const element = await this.findElement(opts)
2215
2236
  if (!element) return false
2216
2237
  const frame = element.visibleFrame
2238
+ const area = frame?.area
2217
2239
  const usable =
2218
2240
  !!frame &&
2219
2241
  Number.isFinite(frame.width) &&
2220
2242
  Number.isFinite(frame.height) &&
2221
- Number.isFinite(frame.area)
2243
+ typeof area === 'number' &&
2244
+ Number.isFinite(area)
2222
2245
  if (!usable) {
2223
2246
  // absent or non-numeric geometry is unknown visibility, never "hidden".
2224
2247
  // returning false here would quietly hand assertNotVisible a pass it did
@@ -2228,7 +2251,7 @@ export class SootSimBridgeFlowRunner {
2228
2251
  `returned visibleFrame ${JSON.stringify(frame ?? null)}`,
2229
2252
  )
2230
2253
  }
2231
- return frame.width > 0 && frame.height > 0 && frame.area > 0
2254
+ return frame.width > 0 && frame.height > 0 && area > 0
2232
2255
  }
2233
2256
 
2234
2257
  async inputText(text: string) {
@@ -1535,8 +1535,11 @@ export async function deleteRemoteSim(options: {
1535
1535
  }
1536
1536
 
1537
1537
  export function resolveCloudSessionForParsed(
1538
- parsed: Pick<ParsedBridgeCliArgs, 'simId' | 'simIdSource'>,
1538
+ parsed: Pick<ParsedBridgeCliArgs, 'simId' | 'simIdSource'> &
1539
+ Partial<Pick<ParsedBridgeCliArgs, 'explicitPort'>>,
1539
1540
  ): CloudSession | null {
1541
+ // an explicit --port names a local bridge, which a saved remote session never serves
1542
+ if (parsed.explicitPort) return null
1540
1543
  const session = readCloudSession()
1541
1544
  if (!session) return null
1542
1545
  // a box holds one simulator and names it by the box, so --sim names a box
@@ -1756,7 +1759,9 @@ export class CloudBoxBridge implements WsBridge {
1756
1759
 
1757
1760
  export function createCloudBridgeForParsed(
1758
1761
  parsed: Pick<ParsedBridgeCliArgs, 'simId' | 'simIdSource'> &
1759
- Partial<Pick<ParsedBridgeCliArgs, 'explicitTimeout' | 'commandTimeoutMs'>>,
1762
+ Partial<
1763
+ Pick<ParsedBridgeCliArgs, 'explicitTimeout' | 'commandTimeoutMs' | 'explicitPort'>
1764
+ >,
1760
1765
  ): WsBridge | null {
1761
1766
  const session = resolveCloudSessionForParsed(parsed)
1762
1767
  if (!session) return null
@@ -1420,6 +1420,7 @@ type OpenCommandOptions = ControlCommandOptions & {
1420
1420
  launchPermissions?: SystemPermissionBootSeed['presets']
1421
1421
  // the seeded boot is the last launch the page will see
1422
1422
  launchIsFinal?: boolean
1423
+ launchArguments?: readonly string[]
1423
1424
  reuseUnchangedSim?: boolean
1424
1425
  resources?: OpenCommandResources
1425
1426
  signal?: AbortSignal
@@ -1470,21 +1471,6 @@ async function openSim(
1470
1471
  args: string[],
1471
1472
  opts: OpenCommandOptions,
1472
1473
  ): Promise<OpenedSimulator | undefined> {
1473
- // an ipa or apk we built opens as the plain bundle it carries
1474
- const binary = args.find((arg) => !arg.startsWith('-') && isAppBinaryPath(arg))
1475
- if (binary) {
1476
- try {
1477
- const { bundlePath, platform } = extractAppBinaryBundle(binary)
1478
- args = args.map((arg) => (arg === binary ? bundlePath : arg))
1479
- if (platform === 'android' && !args.includes('--device') && !args.includes('-d'))
1480
- args = [...args, '--device', 'pixel-8']
1481
- } catch (error) {
1482
- console.error(
1483
- ` peach open: ${error instanceof Error ? error.message : String(error)}`,
1484
- )
1485
- peachExit(1)
1486
- }
1487
- }
1488
1474
  const openArgOptions = {
1489
1475
  stripBooleanFlags: [
1490
1476
  '--new',
@@ -1538,11 +1524,24 @@ async function openSim(
1538
1524
  const booleanFlags = new Set(openArgOptions.stripBooleanFlags)
1539
1525
  const valueFlags = new Set(openArgOptions.stripValueFlags)
1540
1526
  const bridgeValueFlags = new Set(BRIDGE_VALUE_FLAGS)
1527
+ const launchArgs = [...(opts.launchArguments ?? [])]
1528
+ const launchArgIndices = new Set<number>()
1541
1529
  // validate tokens, not parsed positionals: option values may start with a
1542
1530
  // dash, and an explicit separator ends option validation.
1543
1531
  for (let i = 0; i < args.length; i++) {
1544
1532
  const arg = args[i]
1545
1533
  if (arg === '--') break
1534
+ if (arg === '--arg') {
1535
+ const value = args[i + 1]
1536
+ if (value === undefined) {
1537
+ console.error(' peach open: --arg expects a value')
1538
+ peachExit(1)
1539
+ }
1540
+ launchArgs.push(value)
1541
+ launchArgIndices.add(i)
1542
+ launchArgIndices.add(++i)
1543
+ continue
1544
+ }
1546
1545
  if (valueFlags.has(arg) || bridgeValueFlags.has(arg)) {
1547
1546
  i++
1548
1547
  continue
@@ -1564,6 +1563,22 @@ async function openSim(
1564
1563
  peachExit(1)
1565
1564
  }
1566
1565
  }
1566
+ if (launchArgIndices.size) args = args.filter((_, index) => !launchArgIndices.has(index))
1567
+ // an ipa or apk we built opens as the plain bundle it carries
1568
+ const binary = args.find((arg) => !arg.startsWith('-') && isAppBinaryPath(arg))
1569
+ if (binary) {
1570
+ try {
1571
+ const { bundlePath, platform } = extractAppBinaryBundle(binary)
1572
+ args = args.map((arg) => (arg === binary ? bundlePath : arg))
1573
+ if (platform === 'android' && !args.includes('--device') && !args.includes('-d'))
1574
+ args = [...args, '--device', 'pixel-8']
1575
+ } catch (error) {
1576
+ console.error(
1577
+ ` peach open: ${error instanceof Error ? error.message : String(error)}`,
1578
+ )
1579
+ peachExit(1)
1580
+ }
1581
+ }
1567
1582
  const parsed = parseBridgeCliArgs(args, {
1568
1583
  ...openArgOptions,
1569
1584
  port: opts.port,
@@ -1706,13 +1721,18 @@ async function openSim(
1706
1721
  nativeInput.kind === 'kotlin'
1707
1722
  ? await (
1708
1723
  await import('./kotlin')
1709
- ).runKotlin(nativeArgs, { port: opts.port, openArgs: previewArgs })
1724
+ ).runKotlin(nativeArgs, {
1725
+ port: opts.port,
1726
+ openArgs: previewArgs,
1727
+ launchArguments: launchArgs,
1728
+ })
1710
1729
  : await (
1711
1730
  await import('./swift')
1712
1731
  ).runSwift(nativeArgs, {
1713
1732
  port: opts.port,
1714
1733
  openArgs: previewArgs,
1715
1734
  startupEnvironment: envArgs,
1735
+ launchArguments: launchArgs,
1716
1736
  })
1717
1737
  if (code) peachExit(code)
1718
1738
  return
@@ -2067,16 +2087,6 @@ async function openSim(
2067
2087
  peachExit(1)
2068
2088
  }
2069
2089
 
2070
- // --arg <value> (repeatable) is one launch argument, the peach analogue of
2071
- // a `simctl launch` argument: stamped as repeated ?arg=, carried on
2072
- // AppLoadRequest, and handed to a Swift guest as ProcessInfo.arguments[1...]
2073
- // verbatim, each value its own element after the executable path.
2074
- const launchArgs = args.flatMap((arg, i) => (args[i - 1] === '--arg' ? [arg] : []))
2075
- if (args.at(-1) === '--arg') {
2076
- console.error(' peach open: --arg expects a value')
2077
- peachExit(1)
2078
- }
2079
-
2080
2090
  // --viewport <WxH> sizes the driver-launched page explicitly (film and
2081
2091
  // promo captures frame the 3d stage in landscape). takes precedence over
2082
2092
  // the device-derived window; without either, the driver keeps its own
@@ -187,7 +187,9 @@ function renderActivityIdleScript({
187
187
  }
188
188
  const blockers = []
189
189
  const stats = await Promise.race([
190
- Promise.resolve().then(() => host?.queryStats(false)).catch(() => null),
190
+ Promise.resolve()
191
+ .then(() => host?.queryReadinessStats ? host.queryReadinessStats() : host?.queryStats(false))
192
+ .catch(() => null),
191
193
  new Promise((resolve) => setTimeout(() => resolve(null), 500)),
192
194
  ])
193
195
  if (stats) {
@@ -349,7 +351,10 @@ export async function waitForSootsimIdle({
349
351
  const motionRead = strict || screenStill
350
352
  ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
351
353
  : null
352
- const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.(false)).catch(() => null)
354
+ const host = globalThis.__sootsimRenderHost
355
+ const statsRead = answer(() =>
356
+ host?.queryReadinessStats ? host.queryReadinessStats() : host?.queryStats?.(false)
357
+ ).catch(() => null)
353
358
  // image preparation ends in the tenant before the compositor decodes
354
359
  // and realizes its pixels. both owners must finish before settling.
355
360
  // the compositor rejects a stats request it is too busy to answer.
@@ -38,6 +38,7 @@ export async function runKotlin(
38
38
  driver?: string
39
39
  headless?: boolean
40
40
  openArgs?: string[]
41
+ launchArguments?: readonly string[]
41
42
  } = {},
42
43
  ): Promise<number> {
43
44
  const input = [...args]
@@ -277,6 +278,7 @@ export async function runKotlin(
277
278
  resources,
278
279
  signal: controller.signal,
279
280
  ownerPid: process.pid,
281
+ launchArguments: opts.launchArguments,
280
282
  },
281
283
  )
282
284
  code = await waitForGuestCompletion(resources, controller.signal, 'Kotlin app')
@@ -35,6 +35,7 @@ export async function runSwift(
35
35
  driver?: string
36
36
  headless?: boolean
37
37
  openArgs?: string[]
38
+ launchArguments?: readonly string[]
38
39
  startupEnvironment?: readonly string[]
39
40
  } = {},
40
41
  ): Promise<number> {
@@ -139,6 +140,7 @@ export async function runSwift(
139
140
  hosted: hosted ?? undefined,
140
141
  signal: controller.signal,
141
142
  startupEnvironment: opts.startupEnvironment,
143
+ startupArguments: opts.launchArguments,
142
144
  startupRuntimeUrl: baseUrl ? new URL(baseUrl) : undefined,
143
145
  })
144
146
  const { host, module, appInfo } = prepared
@@ -385,6 +387,7 @@ export async function runSwift(
385
387
  resources,
386
388
  signal: controller.signal,
387
389
  ownerPid: process.pid,
390
+ launchArguments: opts.launchArguments,
388
391
  },
389
392
  )
390
393
  code = await waitForGuestCompletion(resources, controller.signal, 'Swift preview')
@@ -60,6 +60,7 @@ export async function prepareSwiftInput(
60
60
  hosted?: SwiftHostedCompileOptions
61
61
  swiftModule?: SwiftModule
62
62
  startupEnvironment?: readonly string[]
63
+ startupArguments?: readonly string[]
63
64
  startupRuntimeUrl?: URL
64
65
  signal?: AbortSignal
65
66
  } = {},
@@ -138,6 +139,7 @@ export async function prepareSwiftInput(
138
139
  opts.startupEnvironment,
139
140
  opts.startupRuntimeUrl,
140
141
  { packageName: name, source: guestSource },
142
+ opts.startupArguments,
141
143
  )
142
144
  return { guestSource, metadata }
143
145
  },
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2489 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2491 | (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.2489 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2491 | (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.2489 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2491 | (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.2489 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2491 | (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;