Repository navigation
Expand file tree
/
Copy pathios-snapshot.ts
More file actions
246 lines (218 loc) · 7.64 KB
/
Copy pathios-snapshot.ts
File metadata and controls
246 lines (218 loc) · 7.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
import type {
PresentedSurface,
RawSnapshotNode,
Rect,
SnapshotNode,
SnapshotKeyboardBandFact,
} from '@agent-device/kernel/snapshot';
export type IosSnapshotProducer =
| 'apple-runner'
| 'simulator-ax-bridge'
| 'appium-source'
| 'limrun-ios-tree';
export type IosAcquisitionProducer = Exclude<IosSnapshotProducer, 'apple-runner'>;
export type IosProviderAcquisitionProducer = Extract<
IosAcquisitionProducer,
'appium-source' | 'limrun-ios-tree'
>;
export type IosAcquisitionIntent = 'full' | 'surface-observation';
export type IosSnapshotProjection = 'regular' | 'raw';
export type IosSnapshotEvidenceAvailability = 'available' | 'unavailable';
export type IosSnapshotGeneration = string;
export type IosSnapshotLineage = Readonly<{
targetId?: string;
generation?: IosSnapshotGeneration;
}>;
export type IosSnapshotPresentationKey = Readonly<{
projection: IosSnapshotProjection;
interactiveOnly: boolean;
depth: number | null;
scope: string | null;
customActions: boolean;
}>;
export type IosSnapshotRequest = Readonly<{
projection: IosSnapshotProjection;
interactiveOnly: boolean;
depth: number | null;
scope: string | null;
customActions: boolean;
acquisitionIntent: IosAcquisitionIntent;
}>;
export type IosSnapshotRequestInput = Readonly<{
projection?: IosSnapshotProjection;
raw?: boolean;
interactiveOnly?: boolean;
depth?: number | null;
scope?: string | null;
customActions?: boolean;
acquisitionIntent?: IosAcquisitionIntent;
}>;
export type CaptureHint = Readonly<{
projection: IosSnapshotProjection;
rawTraversalDepth: number | null;
regularPresentedDepth: number | null;
interactiveOnly: boolean;
customActions: boolean;
acquisitionIntent: IosAcquisitionIntent;
}>;
export type IosSnapshotDepthSupport =
| Readonly<{ kind: 'complete'; maxDepth?: number }>
| Readonly<{ kind: 'incomplete' }>;
export type IosSnapshotAcquisitionDepthCapability = Readonly<{
rawTraversal: IosSnapshotDepthSupport;
regularPresented: IosSnapshotDepthSupport;
}>;
export type IosSnapshotFact =
| 'acquisition-depth'
| 'scope'
| 'interactive-query'
| 'viewport'
| 'hittability'
| 'generation'
| 'truncation';
/**
* What a *provider* acquisition leaves unproven, declared so capture-kit can derive the residue
* for a producer that hands over a bare tree and nothing else.
*
* The producer axis is `IosProviderAcquisitionProducer` — Appium page source and the Limrun
* element tree — and deliberately not every {@link IosSnapshotProducer}. `apple-runner` and
* `simulator-ax-bridge` build their own residue at the source, so a capability declared for
* them here would be a claim nothing consults: exactly the shape that let the table say the
* Simulator bridge had hittability evidence while the bridge adapter published none and emitted
* `unavailable-fact: hittability` on every capture (#2199). The bridge now derives geometric
* `hittable` at the source and drops that residue when its inputs are established, so a table row
* for it would still have no reader. Narrowing the producer makes that claim unrepresentable
* rather than merely wrong.
*
* Truncation is not a field here: it is the one fact the runner and the bridge also need
* answered, so it has a single owner over all four producers instead
* (`iosSnapshotTruncationEvidence`).
*/
export type IosProviderAcquisitionCapabilities = Readonly<{
producer: IosProviderAcquisitionProducer;
acquisitionDepth: IosSnapshotAcquisitionDepthCapability;
hittabilityEvidence: IosSnapshotEvidenceAvailability;
}>;
export type IosViewportEvidence =
| Readonly<{ kind: 'reported'; rect: Rect }>
| Readonly<{ kind: 'derived'; rect: Rect }>
| Readonly<{
kind: 'missing';
reason: 'not-provided' | 'not-supported' | 'invalid';
}>;
export type IosHittabilityEvidence =
| Readonly<{ kind: 'available' }>
| Readonly<{
kind: 'unavailable';
reason: 'not-provided' | 'not-supported' | 'partial';
}>;
export type IosProviderPrunedField = 'nodes' | 'depth' | 'scope' | 'interactive-only';
export type IosAcquisitionResidue =
| Readonly<{
kind: 'provider-pruned';
fields: readonly IosProviderPrunedField[];
}>
| Readonly<{
kind: 'missing-viewport';
reason: 'not-provided' | 'not-supported' | 'invalid';
}>
| Readonly<{
kind: 'truncated';
}>
| Readonly<{
kind: 'stale-generation';
expected?: IosSnapshotGeneration;
observed?: IosSnapshotGeneration;
}>
| Readonly<{
kind: 'unknown-generation';
captureId: string;
}>
| Readonly<{
kind: 'unavailable-fact';
fact: IosSnapshotFact;
}>
| Readonly<{
kind: 'fallback-source';
producer: IosSnapshotProducer;
}>;
type IosSnapshotAcquisitionForIntent<Intent extends IosAcquisitionIntent> = Readonly<{
producer: IosAcquisitionProducer;
intent: Intent;
hint: CaptureHint & Readonly<{ acquisitionIntent: Intent }>;
nodes: readonly RawSnapshotNode[];
truncated?: boolean;
viewport: IosViewportEvidence;
keyboard?: SnapshotKeyboardBandFact;
lineage: IosSnapshotLineage;
residue: readonly IosAcquisitionResidue[];
}>;
export type IosSnapshotAcquisition =
| IosSnapshotAcquisitionForIntent<'full'>
| IosSnapshotAcquisitionForIntent<'surface-observation'>;
export type IosSnapshotAcquisitionFacts = Omit<IosSnapshotAcquisition, 'hint'>;
export type IosRunnerPayloadFacts = Readonly<{
nodes: readonly RawSnapshotNode[];
truncated: boolean;
effectiveDepth?: number;
}>;
export type IosRunnerQualityPayloadFacts = IosRunnerPayloadFacts &
Readonly<{
scope: null;
}>;
export type IosRunnerPresentation = Readonly<{
producer: 'apple-runner';
intent: IosAcquisitionIntent;
payload: IosRunnerPayloadFacts;
qualityPayload?: IosRunnerQualityPayloadFacts;
}>;
export type IosSnapshotValidationFacts = Readonly<{
presentationKey: IosSnapshotPresentationKey;
viewport: IosViewportEvidence;
hittability: IosHittabilityEvidence;
lineage: IosSnapshotLineage;
residue: readonly IosAcquisitionResidue[];
}>;
export type IosSnapshotInput =
| Readonly<{
stage: 'acquired';
acquisition: IosSnapshotAcquisition;
}>
| Readonly<{
stage: 'presented';
presentation: IosRunnerPresentation;
validation: IosSnapshotValidationFacts;
}>;
export type IosSnapshotPublishedPayload = Readonly<{
nodes: readonly SnapshotNode[];
truncated?: boolean;
}>;
export type IosSnapshotComparisonIdentity = Readonly<{
producer: IosSnapshotProducer;
intent: IosAcquisitionIntent;
lineage: IosSnapshotLineage;
presentationKey: IosSnapshotPresentationKey;
residue: readonly IosAcquisitionResidue[];
}>;
export type IosSnapshotPublication = Readonly<{
payload: IosSnapshotPublishedPayload;
presentationKey: IosSnapshotPresentationKey;
comparisonIdentity: IosSnapshotComparisonIdentity;
residue: readonly IosAcquisitionResidue[];
/**
* The box the regular projection validated this tree against (#3182), handed over by the engine
* that measured against it. A raw projection validates no box and carries none.
*/
validatedViewport?: Rect;
/**
* Whether this capture read a modal presentation over the app (#3565), classified on the acquired
* tree so every projection of one screen — interactive, full, depth-cut, scoped — answers the same
* value. Only an acquisition the engine itself classified carries it: a runner-declared capture
* arrives already presented, and the runner's own reading of its pre-presentation acquisition
* travels on the payload beside it.
*/
presentedSurface?: PresentedSurface;
}>;
export type IosSnapshotEngine = Readonly<{
publish(input: IosSnapshotInput, request: IosSnapshotRequest): IosSnapshotPublication;
}>;