@burdenoff/ui-engine 2026.1127.3 → 2026.1127.4

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 (40) hide show
  1. package/README.md +45 -5
  2. package/dist/dom-runtime.iife.js +1 -1
  3. package/dist/dom-runtime.js +27 -532
  4. package/dist/drivers/dom-driver.d.ts +44 -0
  5. package/dist/drivers/index.d.ts +7 -0
  6. package/dist/drivers/snapshot-driver.d.ts +59 -0
  7. package/dist/drivers.d.ts +2 -0
  8. package/dist/drivers.js +170 -0
  9. package/dist/index-3f1j8386.js +334 -0
  10. package/dist/index-3jymbm5t.js +315 -0
  11. package/dist/{index-q1b0j9yr.js → index-5k26keah.js} +58 -592
  12. package/dist/index-77pcz6n3.js +303 -0
  13. package/dist/index-895kscx3.js +741 -0
  14. package/dist/index-ct2xctrq.js +229 -0
  15. package/dist/index-h88y5qgv.js +400 -0
  16. package/dist/{index-zwrxw3zp.js → index-pm13mvvc.js} +24 -1009
  17. package/dist/index-vg8r40y7.js +220 -0
  18. package/dist/index-ycs2bz1a.js +589 -0
  19. package/dist/index-zzhysbkj.js +1731 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +123 -37
  22. package/dist/interpret/compile.d.ts +58 -0
  23. package/dist/interpret/driver.d.ts +171 -0
  24. package/dist/interpret/errors.d.ts +194 -0
  25. package/dist/interpret/events.d.ts +73 -0
  26. package/dist/interpret/expr.d.ts +35 -0
  27. package/dist/interpret/index.d.ts +13 -0
  28. package/dist/interpret/run.d.ts +77 -0
  29. package/dist/interpret.d.ts +2 -0
  30. package/dist/interpret.js +84 -0
  31. package/dist/script/adapters/browser-action-contract.d.ts +5 -2
  32. package/dist/script/limits.d.ts +2 -0
  33. package/dist/script.js +44 -38
  34. package/dist/target/index.d.ts +1 -1
  35. package/dist/target/resolve.d.ts +18 -1
  36. package/dist/target.js +23 -19
  37. package/dist/testing/fake-web-driver.d.ts +28 -0
  38. package/dist/testing/index.d.ts +3 -2
  39. package/dist/testing.js +55 -0
  40. package/package.json +11 -3
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export { type CaptureResult, REDACTED, type RecorderElement, type RecorderEvent,
9
9
  export { MAX_SNAPSHOT_NODES, type ResolveOutcome, type SnapshotNode, readSnapshotNodes, resolveTarget, } from './resolve.js';
10
10
  export { type FallbackReason, type ReplayCallKind, type ReplayCallOutcome, type ReplayChatMessage, type ReplayFunctionCall, type ReplayOptions, type ReplayPlan, type ReplaySource, type ReplayState, afterReplayCall, finishFallback, markFallbackAsked, planReplay, readReplayState, replayReasons, replayStateFrom, } from './replay.js';
11
11
  export * from './script.js';
12
+ export * from './interpret.js';
package/dist/index.js CHANGED
@@ -30,6 +30,88 @@ import {
30
30
  markFallbackAsked2,
31
31
  replayReasons2
32
32
  } from "./index-2kgsgn1c.js";
33
+ import {
34
+ uiScriptRegistry2,
35
+ NAME_PATTERN2,
36
+ STEP_ID_PATTERN2,
37
+ ELEMENT_KEY_PATTERN2,
38
+ uiExpressionSchema2,
39
+ uiTargetMethodSchema2,
40
+ uiTargetSchema2,
41
+ uiTargetRefSchema2,
42
+ uiStepSchema2,
43
+ uiScriptSchema2,
44
+ canonicalJson2,
45
+ RECORDING_ACTION_OF2,
46
+ uiStepFingerprint2,
47
+ withFingerprint2,
48
+ UiScriptError2,
49
+ UI_EXPRESSION_ARITY2,
50
+ parseUiScript2,
51
+ safeParseUiScript2
52
+ } from "./index-895kscx3.js";
53
+ import {
54
+ UI_SCRIPT_SCHEMA_HASH2,
55
+ schemaHashOf2,
56
+ UI_SCRIPT_SCHEMA_TITLE2,
57
+ uiScriptJsonSchema2,
58
+ UI_SCRIPT_STEP_KEY_PREFIX2,
59
+ UI_SCRIPT_STEP_MESSAGES2,
60
+ stepMessageKey2,
61
+ describeTarget2,
62
+ describeExpression2,
63
+ describeStep2,
64
+ BROWSER_STEP_ACTIONS2,
65
+ fromBrowserActionSteps2,
66
+ toBrowserActionSteps2,
67
+ targetFromPlaywrightSelector2,
68
+ fromRemoteBrowserSteps2,
69
+ fromRecording2,
70
+ toRecording2
71
+ } from "./index-pm13mvvc.js";
72
+ import {
73
+ MAX_CALL_DEPTH2,
74
+ COMPILED_NAME_PREFIX2,
75
+ applyPins2,
76
+ stripBreakpoints2,
77
+ inlineCalls2,
78
+ compileUiScript2
79
+ } from "./index-h88y5qgv.js";
80
+ import {
81
+ MAX_VALUE_TEXT2,
82
+ MAX_VALUE_ITEMS2,
83
+ toUiValue2,
84
+ readPath2,
85
+ truthy2,
86
+ valuesEqual2,
87
+ toText2,
88
+ toNumber2,
89
+ evaluateExpression2,
90
+ UI_RUN_EVENT_KINDS2,
91
+ DEFAULT_MAX_EVENTS2,
92
+ MAX_STEP_LOG_ENTRIES2,
93
+ MAX_EVENT_MESSAGE2,
94
+ DEFAULT_FIRST_WAIT_MS2,
95
+ DEFAULT_WAIT_MS2,
96
+ DEFAULT_RETRY_DELAY_MS2,
97
+ DEFAULT_POLL_INTERVAL_MS2,
98
+ MAX_EVENTS_LIMIT2,
99
+ MAX_PAGE_TEXT2,
100
+ DEFAULT_LIST_ITEMS2,
101
+ runUiScript2
102
+ } from "./index-zzhysbkj.js";
103
+ import {
104
+ UI_ERROR_FAMILIES2,
105
+ UI_ERROR_CODES2,
106
+ UI_ERROR_CODE_LIST2,
107
+ isUiErrorCode2,
108
+ errorFamilyOf2,
109
+ isRetryableInScript2,
110
+ UiRunError2,
111
+ UiDriverError2,
112
+ realClock2,
113
+ createVirtualClock2
114
+ } from "./index-vg8r40y7.js";
33
115
  import {
34
116
  UI_EXPRESSION_OPS2,
35
117
  UI_ANCHOR_RELATIONS2,
@@ -69,18 +151,8 @@ import {
69
151
  MAX_NAME_LENGTH2,
70
152
  LEGACY_MAX_BROWSER_STEPS2,
71
153
  LEGACY_MAX_STEPS_BYTES2,
154
+ LEGACY_MAX_STEP_TIMEOUT_MS2,
72
155
  jsonByteLength2,
73
- uiScriptRegistry2,
74
- NAME_PATTERN2,
75
- STEP_ID_PATTERN2,
76
- ELEMENT_KEY_PATTERN2,
77
- uiExpressionSchema2,
78
- uiTargetMethodSchema2,
79
- uiTargetSchema2,
80
- uiTargetRefSchema2,
81
- uiStepSchema2,
82
- uiScriptSchema2,
83
- canonicalJson2,
84
156
  childBlocks2,
85
157
  walkSteps2,
86
158
  countSteps2,
@@ -88,35 +160,11 @@ import {
88
160
  stepTargets2,
89
161
  stepExpressions2,
90
162
  visitExpression2,
91
- RECORDING_ACTION_OF2,
92
- uiStepFingerprint2,
93
- withFingerprint2,
94
- UiScriptError2,
95
- UI_EXPRESSION_ARITY2,
96
- parseUiScript2,
97
- safeParseUiScript2,
98
- UI_SCRIPT_SCHEMA_HASH2,
99
- schemaHashOf2,
100
- UI_SCRIPT_SCHEMA_TITLE2,
101
- uiScriptJsonSchema2,
102
163
  CAPABILITY_IDS2,
103
164
  SCRIPT_CAPABILITY2,
104
165
  requiredCapabilities2,
105
- missingCapabilities2,
106
- UI_SCRIPT_STEP_KEY_PREFIX2,
107
- UI_SCRIPT_STEP_MESSAGES2,
108
- stepMessageKey2,
109
- describeTarget2,
110
- describeExpression2,
111
- describeStep2,
112
- BROWSER_STEP_ACTIONS2,
113
- fromBrowserActionSteps2,
114
- toBrowserActionSteps2,
115
- targetFromPlaywrightSelector2,
116
- fromRemoteBrowserSteps2,
117
- fromRecording2,
118
- toRecording2
119
- } from "./index-zwrxw3zp.js";
166
+ missingCapabilities2
167
+ } from "./index-3jymbm5t.js";
120
168
  import {
121
169
  REDACTED2,
122
170
  redactCredentials2
@@ -124,10 +172,21 @@ import {
124
172
  export {
125
173
  BROWSER_STEP_ACTIONS2 as BROWSER_STEP_ACTIONS,
126
174
  CAPABILITY_IDS2 as CAPABILITY_IDS,
175
+ COMPILED_NAME_PREFIX2 as COMPILED_NAME_PREFIX,
176
+ DEFAULT_FIRST_WAIT_MS2 as DEFAULT_FIRST_WAIT_MS,
177
+ DEFAULT_LIST_ITEMS2 as DEFAULT_LIST_ITEMS,
178
+ DEFAULT_MAX_EVENTS2 as DEFAULT_MAX_EVENTS,
179
+ DEFAULT_POLL_INTERVAL_MS2 as DEFAULT_POLL_INTERVAL_MS,
180
+ DEFAULT_RETRY_DELAY_MS2 as DEFAULT_RETRY_DELAY_MS,
181
+ DEFAULT_WAIT_MS2 as DEFAULT_WAIT_MS,
127
182
  ELEMENT_KEY_PATTERN2 as ELEMENT_KEY_PATTERN,
128
183
  LEGACY_MAX_BROWSER_STEPS2 as LEGACY_MAX_BROWSER_STEPS,
129
184
  LEGACY_MAX_STEPS_BYTES2 as LEGACY_MAX_STEPS_BYTES,
185
+ LEGACY_MAX_STEP_TIMEOUT_MS2 as LEGACY_MAX_STEP_TIMEOUT_MS,
186
+ MAX_CALL_DEPTH2 as MAX_CALL_DEPTH,
130
187
  MAX_DELAY_MS2 as MAX_DELAY_MS,
188
+ MAX_EVENTS_LIMIT2 as MAX_EVENTS_LIMIT,
189
+ MAX_EVENT_MESSAGE2 as MAX_EVENT_MESSAGE,
131
190
  MAX_EXPRESSION_DEPTH2 as MAX_EXPRESSION_DEPTH,
132
191
  MAX_EXPRESSION_ITEMS2 as MAX_EXPRESSION_ITEMS,
133
192
  MAX_EXTRACT_FIELDS2 as MAX_EXTRACT_FIELDS,
@@ -141,6 +200,7 @@ export {
141
200
  MAX_LOOP_ITERATIONS2 as MAX_LOOP_ITERATIONS,
142
201
  MAX_NAME_LENGTH2 as MAX_NAME_LENGTH,
143
202
  MAX_OPERATOR_ARGS2 as MAX_OPERATOR_ARGS,
203
+ MAX_PAGE_TEXT2 as MAX_PAGE_TEXT,
144
204
  MAX_RECORDED_STEPS2 as MAX_RECORDED_STEPS,
145
205
  MAX_RETRY_ATTEMPTS2 as MAX_RETRY_ATTEMPTS,
146
206
  MAX_SCRIPT_BYTES2 as MAX_SCRIPT_BYTES,
@@ -152,10 +212,13 @@ export {
152
212
  MAX_SELECTOR_LENGTH2 as MAX_SELECTOR_LENGTH,
153
213
  MAX_SELECT_VALUES2 as MAX_SELECT_VALUES,
154
214
  MAX_SNAPSHOT_NODES2 as MAX_SNAPSHOT_NODES,
215
+ MAX_STEP_LOG_ENTRIES2 as MAX_STEP_LOG_ENTRIES,
155
216
  MAX_STEP_TIMEOUT_MS2 as MAX_STEP_TIMEOUT_MS,
156
217
  MAX_TARGET_METHODS2 as MAX_TARGET_METHODS,
157
218
  MAX_TEXT_LENGTH2 as MAX_TEXT_LENGTH,
158
219
  MAX_URL_LENGTH2 as MAX_URL_LENGTH,
220
+ MAX_VALUE_ITEMS2 as MAX_VALUE_ITEMS,
221
+ MAX_VALUE_TEXT2 as MAX_VALUE_TEXT,
159
222
  NAME_PATTERN2 as NAME_PATTERN,
160
223
  RECORDING_ACTION_OF2 as RECORDING_ACTION_OF,
161
224
  RECORDING_VERSION2 as RECORDING_VERSION,
@@ -167,9 +230,13 @@ export {
167
230
  STEP_ID_PATTERN2 as STEP_ID_PATTERN,
168
231
  UI_ANCHOR_RELATIONS2 as UI_ANCHOR_RELATIONS,
169
232
  UI_DESKTOP_ACTIONS2 as UI_DESKTOP_ACTIONS,
233
+ UI_ERROR_CODES2 as UI_ERROR_CODES,
234
+ UI_ERROR_CODE_LIST2 as UI_ERROR_CODE_LIST,
235
+ UI_ERROR_FAMILIES2 as UI_ERROR_FAMILIES,
170
236
  UI_EXPRESSION_ARITY2 as UI_EXPRESSION_ARITY,
171
237
  UI_EXPRESSION_OPS2 as UI_EXPRESSION_OPS,
172
238
  UI_FLOW_ACTIONS2 as UI_FLOW_ACTIONS,
239
+ UI_RUN_EVENT_KINDS2 as UI_RUN_EVENT_KINDS,
173
240
  UI_SCRIPT_SCHEMA_HASH2 as UI_SCRIPT_SCHEMA_HASH,
174
241
  UI_SCRIPT_SCHEMA_TITLE2 as UI_SCRIPT_SCHEMA_TITLE,
175
242
  UI_SCRIPT_STEP_KEY_PREFIX2 as UI_SCRIPT_STEP_KEY_PREFIX,
@@ -179,20 +246,30 @@ export {
179
246
  UI_TARGET_METHOD_KINDS2 as UI_TARGET_METHOD_KINDS,
180
247
  UI_VALUE_TYPES2 as UI_VALUE_TYPES,
181
248
  UI_WEB_ACTIONS2 as UI_WEB_ACTIONS,
249
+ UiDriverError2 as UiDriverError,
250
+ UiRunError2 as UiRunError,
182
251
  UiScriptError2 as UiScriptError,
183
252
  afterReplayCall2 as afterReplayCall,
253
+ applyPins2 as applyPins,
184
254
  canonicalJson2 as canonicalJson,
185
255
  captureRecording2 as captureRecording,
186
256
  childBlocks2 as childBlocks,
257
+ compileUiScript2 as compileUiScript,
187
258
  countSteps2 as countSteps,
259
+ createVirtualClock2 as createVirtualClock,
188
260
  describeExpression2 as describeExpression,
189
261
  describeStep2 as describeStep,
190
262
  describeTarget2 as describeTarget,
263
+ errorFamilyOf2 as errorFamilyOf,
264
+ evaluateExpression2 as evaluateExpression,
191
265
  finishFallback2 as finishFallback,
192
266
  fromBrowserActionSteps2 as fromBrowserActionSteps,
193
267
  fromRecording2 as fromRecording,
194
268
  fromRemoteBrowserSteps2 as fromRemoteBrowserSteps,
269
+ inlineCalls2 as inlineCalls,
270
+ isRetryableInScript2 as isRetryableInScript,
195
271
  isSavedStepAuthor2 as isSavedStepAuthor,
272
+ isUiErrorCode2 as isUiErrorCode,
196
273
  jsonByteLength2 as jsonByteLength,
197
274
  markFallbackAsked2 as markFallbackAsked,
198
275
  maskUrl2 as maskUrl,
@@ -200,8 +277,10 @@ export {
200
277
  parseRecording2 as parseRecording,
201
278
  parseUiScript2 as parseUiScript,
202
279
  planReplay2 as planReplay,
280
+ readPath2 as readPath,
203
281
  readReplayState2 as readReplayState,
204
282
  readSnapshotNodes2 as readSnapshotNodes,
283
+ realClock2 as realClock,
205
284
  recordedStepSchema2 as recordedStepSchema,
206
285
  recordedTargetSchema2 as recordedTargetSchema,
207
286
  recordingSchema2 as recordingSchema,
@@ -210,6 +289,7 @@ export {
210
289
  replayStateFrom2 as replayStateFrom,
211
290
  requiredCapabilities2 as requiredCapabilities,
212
291
  resolveTarget2 as resolveTarget,
292
+ runUiScript2 as runUiScript,
213
293
  safeParseUiScript2 as safeParseUiScript,
214
294
  schemaHashOf2 as schemaHashOf,
215
295
  sha256Hex2 as sha256Hex,
@@ -217,10 +297,15 @@ export {
217
297
  stepExpressions2 as stepExpressions,
218
298
  stepMessageKey2 as stepMessageKey,
219
299
  stepTargets2 as stepTargets,
300
+ stripBreakpoints2 as stripBreakpoints,
220
301
  targetFingerprint2 as targetFingerprint,
221
302
  targetFromPlaywrightSelector2 as targetFromPlaywrightSelector,
222
303
  toBrowserActionSteps2 as toBrowserActionSteps,
304
+ toNumber2 as toNumber,
223
305
  toRecording2 as toRecording,
306
+ toText2 as toText,
307
+ toUiValue2 as toUiValue,
308
+ truthy2 as truthy,
224
309
  uiExpressionSchema2 as uiExpressionSchema,
225
310
  uiScriptJsonSchema2 as uiScriptJsonSchema,
226
311
  uiScriptRegistry2 as uiScriptRegistry,
@@ -230,6 +315,7 @@ export {
230
315
  uiTargetMethodSchema2 as uiTargetMethodSchema,
231
316
  uiTargetRefSchema2 as uiTargetRefSchema,
232
317
  uiTargetSchema2 as uiTargetSchema,
318
+ valuesEqual2 as valuesEqual,
233
319
  visitExpression2 as visitExpression,
234
320
  walkSteps2 as walkSteps,
235
321
  withFingerprint2 as withFingerprint
@@ -0,0 +1,58 @@
1
+ import type { UiScript, UiScriptInput, UiScriptOutput, UiStep } from '../script/types.js';
2
+ /** A pinned element as `workerResolveUiAssets` returns it (`UiResolvedElement`). */
3
+ export interface ResolvedUiElement {
4
+ key: string;
5
+ elementId: string;
6
+ version: number;
7
+ name?: string;
8
+ /** A UI target of the engine schema (validated here). */
9
+ target: unknown;
10
+ }
11
+ /** A pinned shared sequence version as `workerResolveUiAssets` returns it (`UiResolvedSequence`). */
12
+ export interface ResolvedUiSequence {
13
+ sequenceId: string;
14
+ version: number;
15
+ /** `UiScriptInput[]`. */
16
+ arguments: readonly UiScriptInput[];
17
+ /** `UiScriptOutput[]`. */
18
+ outputs: readonly UiScriptOutput[];
19
+ /** `UiStep[]`; element references use the sequence's own keys. */
20
+ steps: readonly UiStep[];
21
+ elements: readonly ResolvedUiElement[];
22
+ }
23
+ /** Deepest chain of shared sequences calling shared sequences. */
24
+ export declare const MAX_CALL_DEPTH = 4;
25
+ /** The prefix of names the compiler gives a shared sequence's variables, arguments and elements. */
26
+ export declare const COMPILED_NAME_PREFIX = "__c";
27
+ /** A call the compiler inlined: the retry scope that replaced it keeps the call's step id. */
28
+ export interface InlinedCall {
29
+ stepId: string;
30
+ sequenceId: string;
31
+ version: number;
32
+ }
33
+ /** Fill the target (and the name, when absent) of every element the script pins. */
34
+ export declare function applyPins(script: UiScript, resolved: readonly ResolvedUiElement[]): UiScript;
35
+ /** The script without breakpoints (production runs never pause). */
36
+ export declare function stripBreakpoints(script: UiScript): UiScript;
37
+ /** Inline every `call` step, nested calls included (at most `MAX_CALL_DEPTH` deep). */
38
+ export declare function inlineCalls(script: UiScript, sequences: readonly ResolvedUiSequence[]): {
39
+ script: UiScript;
40
+ calls: InlinedCall[];
41
+ };
42
+ export interface CompileUiScriptOptions {
43
+ /** The pinned elements (`workerResolveUiAssets` `elements`). */
44
+ elements?: readonly ResolvedUiElement[];
45
+ /** The pinned shared sequences (`workerResolveUiAssets` `sequences`). */
46
+ sequences?: readonly ResolvedUiSequence[];
47
+ /** `test` keeps breakpoints; `production` (the default) removes them. */
48
+ mode?: 'test' | 'production';
49
+ /** The desk's capability ids; when given, a script the desk cannot run fails with `UNSUPPORTED_ON_DESK`. */
50
+ capabilities?: readonly string[];
51
+ }
52
+ export interface CompiledUiScript {
53
+ script: UiScript;
54
+ requiredCapabilities: string[];
55
+ calls: InlinedCall[];
56
+ }
57
+ /** Compile a stored script (an object or its JSON text) into the resolved script a desk runs. */
58
+ export declare function compileUiScript(value: unknown, options?: CompileUiScriptOptions): CompiledUiScript;
@@ -0,0 +1,171 @@
1
+ /**
2
+ * The desk driver interface (plan P1-02): what a desk implements so the
3
+ * interpreter can run a UI script on it. The paired browser (the extension,
4
+ * P1-09) forwards each call to the DOM runtime in the tab; the remote-browser
5
+ * executor (P1-07) forwards it over CDP to the runtime in an isolated world;
6
+ * the engine ships a DOM driver, a snapshot driver (P1-05 replay) and a fake
7
+ * web driver for tests (`@burdenoff/ui-engine/drivers`, `/testing`).
8
+ *
9
+ * A driver makes one attempt per call. The interpreter owns waiting: it polls
10
+ * a call until it succeeds, fails for good, or the step's wait runs out, so
11
+ * every desk waits the same way. Results are plain JSON; a driver never puts
12
+ * typed text or a secret in a result's report fields.
13
+ *
14
+ * A driver reports a desk failure (a navigation timeout, a lost tab) by
15
+ * throwing `UiDriverError` with an engine code. Anything else it throws is
16
+ * reported as `DRIVER_ERROR`.
17
+ */
18
+ import type { DomAction, DomActionProblem } from '../dom-runtime/actions.js';
19
+ import type { DomResolution } from '../dom-runtime/runtime.js';
20
+ import type { UiStepAction, UiTarget } from '../script/types.js';
21
+ import type { WebElementState, WebTargetErrorCode } from '../target/types.js';
22
+ /** Where the interpreter is when it calls the driver. */
23
+ export interface UiStepContext {
24
+ /** The step path (`"2"`, `"2.then.0"`, `"cleanup.0"`). */
25
+ path: string;
26
+ stepId: string;
27
+ action: UiStepAction;
28
+ /** 1 for the first attempt of the step, then 2, 3 for its retries. */
29
+ attempt: number;
30
+ /** Aborted when the run is cancelled; a driver that can stop a call early listens to it. */
31
+ signal?: AbortSignal;
32
+ }
33
+ /** Time as the interpreter sees it. A snapshot or test driver passes a virtual clock so waits take no real time. */
34
+ export interface UiClock {
35
+ /** Milliseconds since the epoch. */
36
+ now(): number;
37
+ /** Resolves after `ms` milliseconds, or rejects when the signal aborts. */
38
+ sleep(ms: number, signal?: AbortSignal): Promise<void>;
39
+ }
40
+ /** What a read takes from an element. `auto` is the value of a form control, otherwise the visible text. */
41
+ export type UiReadKind = {
42
+ kind: 'auto';
43
+ } | {
44
+ kind: 'text';
45
+ } | {
46
+ kind: 'value';
47
+ } | {
48
+ kind: 'html';
49
+ } | {
50
+ kind: 'attribute';
51
+ name: string;
52
+ };
53
+ /** A value a read returns. */
54
+ export type UiReadValue = string | boolean | null;
55
+ /** A failure of one driver call on a target. */
56
+ export interface UiDriverFailure {
57
+ ok: false;
58
+ code: WebTargetErrorCode | DomActionProblem;
59
+ resolution?: DomResolution;
60
+ reason?: 'covered' | 'noPointerEvents' | 'offscreen';
61
+ }
62
+ /**
63
+ * The result of an action or a read. The DOM runtime's `DomActResult` has
64
+ * this shape, so a driver can return the runtime's answer unchanged. A
65
+ * successful result without a resolution means the desk did not resolve a
66
+ * target for the call (an action on the focused element, or a step a
67
+ * snapshot replay does not check).
68
+ */
69
+ export type UiDriverResult = {
70
+ ok: true;
71
+ value?: UiReadValue;
72
+ resolution?: DomResolution;
73
+ } | UiDriverFailure;
74
+ /** The result of reading every element a target matches. */
75
+ export type UiDriverListResult<T> = {
76
+ ok: true;
77
+ items: T[];
78
+ resolution?: DomResolution;
79
+ } | UiDriverFailure;
80
+ /** One field of a list row: its target is searched inside each item. */
81
+ export interface UiListField {
82
+ name: string;
83
+ target: UiTarget;
84
+ read: UiReadKind;
85
+ /** Read every match inside the item as a list. */
86
+ all: boolean;
87
+ }
88
+ /** A row of an extracted list: field name to value. */
89
+ export type UiListRow = Record<string, UiReadValue | UiReadValue[]>;
90
+ /** The targets of a `login` step; absent targets use the desk's defaults. */
91
+ export interface UiLoginTargets {
92
+ username?: UiTarget;
93
+ password?: UiTarget;
94
+ submit?: UiTarget;
95
+ success?: UiTarget;
96
+ }
97
+ export interface UiDriver {
98
+ /** The capability ids this desk supports (`CAPABILITY_IDS` of the script module). */
99
+ readonly capabilities: readonly string[];
100
+ /** Absent means real time. */
101
+ readonly clock?: UiClock;
102
+ /**
103
+ * True when the page never changes between calls (a stored snapshot): the
104
+ * interpreter then makes one attempt instead of polling.
105
+ */
106
+ readonly staticPage?: boolean;
107
+ /**
108
+ * True for a snapshot replay: only targets are checked, so the interpreter
109
+ * skips verification, paging, and waits that are not for a target to appear.
110
+ */
111
+ readonly replay?: boolean;
112
+ /** Resolve a target once, in the given state. */
113
+ resolve(target: UiTarget, options: {
114
+ state: WebElementState;
115
+ }, context: UiStepContext): Promise<DomResolution>;
116
+ /** Act on the one element a target resolves to, or on the focused element when `target` is null. */
117
+ act(target: UiTarget | null, action: DomAction, options: {
118
+ state?: WebElementState;
119
+ }, context: UiStepContext): Promise<UiDriverResult>;
120
+ /** Read from the one element a target resolves to (it must be visible). */
121
+ read(target: UiTarget, read: UiReadKind, context: UiStepContext): Promise<UiDriverResult>;
122
+ /** Read from every visible element the first matching method finds, in document order. */
123
+ readAll(target: UiTarget, read: UiReadKind, context: UiStepContext): Promise<UiDriverListResult<UiReadValue>>;
124
+ /** Read up to `maxItems` rows: every element `item` matches, with each field searched inside it. */
125
+ listItems(item: UiTarget, fields: readonly UiListField[], maxItems: number, context: UiStepContext): Promise<UiDriverListResult<UiListRow>>;
126
+ /** Press keys together (one key, or modifiers and a key) on a target, or on the focused element when null. */
127
+ pressKeys(target: UiTarget | null, keys: readonly string[], context: UiStepContext): Promise<UiDriverResult>;
128
+ navigate(url: string, options: {
129
+ waitUntil: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
130
+ timeoutMs: number;
131
+ }, context: UiStepContext): Promise<void>;
132
+ goBack(options: {
133
+ timeoutMs: number;
134
+ }, context: UiStepContext): Promise<void>;
135
+ reload(options: {
136
+ timeoutMs: number;
137
+ }, context: UiStepContext): Promise<void>;
138
+ closeTab(context: UiStepContext): Promise<void>;
139
+ currentUrl(context: UiStepContext): Promise<string>;
140
+ /** The page's visible text. */
141
+ pageText(context: UiStepContext): Promise<string>;
142
+ pageHtml(context: UiStepContext): Promise<string>;
143
+ scrollPage(options: {
144
+ dx?: number;
145
+ dy?: number;
146
+ to?: 'top' | 'bottom';
147
+ }, context: UiStepContext): Promise<void>;
148
+ /** Type a secret the desk redeems itself; the value never reaches the interpreter. */
149
+ typeSecret?(target: UiTarget, secret: {
150
+ secretRef: string;
151
+ expectedOrigin?: string;
152
+ }, context: UiStepContext): Promise<UiDriverResult>;
153
+ /** Sign in through the node's Browser Login connection (remote browsers). Throws `LOGIN_FAILED`. */
154
+ login?(targets: UiLoginTargets, options: {
155
+ timeoutMs: number;
156
+ }, context: UiStepContext): Promise<void>;
157
+ /** Take a screenshot; returns a reference the host can store (a Files id), or null. */
158
+ screenshot?(options: {
159
+ target?: UiTarget;
160
+ fullPage?: boolean;
161
+ }, context: UiStepContext): Promise<string | null>;
162
+ }
163
+ /** Real time. */
164
+ export declare const realClock: UiClock;
165
+ /**
166
+ * A clock that moves only when the interpreter sleeps: a sleep advances it at
167
+ * once. Snapshot replays and tests use it so a 10-second wait costs nothing.
168
+ */
169
+ export declare function createVirtualClock(start?: number): UiClock & {
170
+ advance(ms: number): void;
171
+ };