@burdenoff/ui-engine 2026.1127.2 → 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 (70) hide show
  1. package/README.md +74 -4
  2. package/dist/capture.js +3 -2
  3. package/dist/dom-runtime/actions.d.ts +65 -0
  4. package/dist/dom-runtime/iife.d.ts +1 -0
  5. package/dist/dom-runtime/index.d.ts +7 -0
  6. package/dist/dom-runtime/runtime.d.ts +79 -0
  7. package/dist/dom-runtime.d.ts +2 -0
  8. package/dist/dom-runtime.iife.js +1 -0
  9. package/dist/dom-runtime.js +30 -0
  10. package/dist/drivers/dom-driver.d.ts +44 -0
  11. package/dist/drivers/index.d.ts +7 -0
  12. package/dist/drivers/snapshot-driver.d.ts +59 -0
  13. package/dist/drivers.d.ts +2 -0
  14. package/dist/drivers.js +170 -0
  15. package/dist/{index-n5amgh31.js → index-2kgsgn1c.js} +1 -1
  16. package/dist/index-3f1j8386.js +334 -0
  17. package/dist/index-3jymbm5t.js +315 -0
  18. package/dist/index-5k26keah.js +815 -0
  19. package/dist/index-77pcz6n3.js +303 -0
  20. package/dist/index-895kscx3.js +741 -0
  21. package/dist/{index-phd8yhyg.js → index-bnvmt4wf.js} +7 -5
  22. package/dist/{index-c6pmt2rg.js → index-cs6acyjn.js} +6 -59
  23. package/dist/index-ct2xctrq.js +229 -0
  24. package/dist/index-h88y5qgv.js +400 -0
  25. package/dist/index-mgztm37r.js +57 -0
  26. package/dist/{index-tqffkt91.js → index-pm13mvvc.js} +26 -1009
  27. package/dist/index-vg8r40y7.js +220 -0
  28. package/dist/index-ycs2bz1a.js +589 -0
  29. package/dist/index-zzhysbkj.js +1731 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +130 -42
  32. package/dist/interpret/compile.d.ts +58 -0
  33. package/dist/interpret/driver.d.ts +171 -0
  34. package/dist/interpret/errors.d.ts +194 -0
  35. package/dist/interpret/events.d.ts +73 -0
  36. package/dist/interpret/expr.d.ts +35 -0
  37. package/dist/interpret/index.d.ts +13 -0
  38. package/dist/interpret/run.d.ts +77 -0
  39. package/dist/interpret.d.ts +2 -0
  40. package/dist/interpret.js +84 -0
  41. package/dist/recording.js +1 -1
  42. package/dist/replay.js +2 -2
  43. package/dist/script/adapters/browser-action-contract.d.ts +5 -2
  44. package/dist/script/limits.d.ts +2 -0
  45. package/dist/script.js +44 -38
  46. package/dist/target/aria.d.ts +31 -0
  47. package/dist/target/dom.d.ts +35 -0
  48. package/dist/target/index.d.ts +13 -0
  49. package/dist/target/markers.d.ts +18 -0
  50. package/dist/target/methods.d.ts +52 -0
  51. package/dist/target/resolve.d.ts +63 -0
  52. package/dist/target/snapshot.d.ts +57 -0
  53. package/dist/target/text.d.ts +23 -0
  54. package/dist/target/types.d.ts +88 -0
  55. package/dist/target.d.ts +2 -0
  56. package/dist/target.js +96 -0
  57. package/dist/testing/fake-web-driver.d.ts +28 -0
  58. package/dist/testing/fixtures/ambiguous.d.ts +7 -0
  59. package/dist/testing/fixtures/iframe.d.ts +6 -0
  60. package/dist/testing/fixtures/index.d.ts +26 -0
  61. package/dist/testing/fixtures/invoices-v2.d.ts +8 -0
  62. package/dist/testing/fixtures/invoices-v3.d.ts +7 -0
  63. package/dist/testing/fixtures/invoices.d.ts +6 -0
  64. package/dist/testing/fixtures/login.d.ts +6 -0
  65. package/dist/testing/fixtures/shadow.d.ts +7 -0
  66. package/dist/testing/index.d.ts +7 -0
  67. package/dist/testing/mount.d.ts +18 -0
  68. package/dist/testing.d.ts +2 -0
  69. package/dist/testing.js +379 -0
  70. package/package.json +29 -5
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
@@ -1,6 +1,4 @@
1
1
  import {
2
- REDACTED2,
3
- redactCredentials2,
4
2
  sha256Hex2,
5
3
  RECORDING_VERSION2,
6
4
  MAX_RECORDED_STEPS2,
@@ -13,11 +11,11 @@ import {
13
11
  RecordingError2,
14
12
  parseRecording2,
15
13
  isSavedStepAuthor2
16
- } from "./index-c6pmt2rg.js";
14
+ } from "./index-cs6acyjn.js";
17
15
  import {
18
16
  maskUrl2,
19
17
  captureRecording2
20
- } from "./index-phd8yhyg.js";
18
+ } from "./index-bnvmt4wf.js";
21
19
  import {
22
20
  MAX_SNAPSHOT_NODES2,
23
21
  readSnapshotNodes2,
@@ -31,7 +29,89 @@ import {
31
29
  finishFallback2,
32
30
  markFallbackAsked2,
33
31
  replayReasons2
34
- } from "./index-n5amgh31.js";
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";
35
115
  import {
36
116
  UI_EXPRESSION_OPS2,
37
117
  UI_ANCHOR_RELATIONS2,
@@ -71,18 +151,8 @@ import {
71
151
  MAX_NAME_LENGTH2,
72
152
  LEGACY_MAX_BROWSER_STEPS2,
73
153
  LEGACY_MAX_STEPS_BYTES2,
154
+ LEGACY_MAX_STEP_TIMEOUT_MS2,
74
155
  jsonByteLength2,
75
- uiScriptRegistry2,
76
- NAME_PATTERN2,
77
- STEP_ID_PATTERN2,
78
- ELEMENT_KEY_PATTERN2,
79
- uiExpressionSchema2,
80
- uiTargetMethodSchema2,
81
- uiTargetSchema2,
82
- uiTargetRefSchema2,
83
- uiStepSchema2,
84
- uiScriptSchema2,
85
- canonicalJson2,
86
156
  childBlocks2,
87
157
  walkSteps2,
88
158
  countSteps2,
@@ -90,42 +160,33 @@ import {
90
160
  stepTargets2,
91
161
  stepExpressions2,
92
162
  visitExpression2,
93
- RECORDING_ACTION_OF2,
94
- uiStepFingerprint2,
95
- withFingerprint2,
96
- UiScriptError2,
97
- UI_EXPRESSION_ARITY2,
98
- parseUiScript2,
99
- safeParseUiScript2,
100
- UI_SCRIPT_SCHEMA_HASH2,
101
- schemaHashOf2,
102
- UI_SCRIPT_SCHEMA_TITLE2,
103
- uiScriptJsonSchema2,
104
163
  CAPABILITY_IDS2,
105
164
  SCRIPT_CAPABILITY2,
106
165
  requiredCapabilities2,
107
- missingCapabilities2,
108
- UI_SCRIPT_STEP_KEY_PREFIX2,
109
- UI_SCRIPT_STEP_MESSAGES2,
110
- stepMessageKey2,
111
- describeTarget2,
112
- describeExpression2,
113
- describeStep2,
114
- BROWSER_STEP_ACTIONS2,
115
- fromBrowserActionSteps2,
116
- toBrowserActionSteps2,
117
- targetFromPlaywrightSelector2,
118
- fromRemoteBrowserSteps2,
119
- fromRecording2,
120
- toRecording2
121
- } from "./index-tqffkt91.js";
166
+ missingCapabilities2
167
+ } from "./index-3jymbm5t.js";
168
+ import {
169
+ REDACTED2,
170
+ redactCredentials2
171
+ } from "./index-mgztm37r.js";
122
172
  export {
123
173
  BROWSER_STEP_ACTIONS2 as BROWSER_STEP_ACTIONS,
124
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,
125
182
  ELEMENT_KEY_PATTERN2 as ELEMENT_KEY_PATTERN,
126
183
  LEGACY_MAX_BROWSER_STEPS2 as LEGACY_MAX_BROWSER_STEPS,
127
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,
128
187
  MAX_DELAY_MS2 as MAX_DELAY_MS,
188
+ MAX_EVENTS_LIMIT2 as MAX_EVENTS_LIMIT,
189
+ MAX_EVENT_MESSAGE2 as MAX_EVENT_MESSAGE,
129
190
  MAX_EXPRESSION_DEPTH2 as MAX_EXPRESSION_DEPTH,
130
191
  MAX_EXPRESSION_ITEMS2 as MAX_EXPRESSION_ITEMS,
131
192
  MAX_EXTRACT_FIELDS2 as MAX_EXTRACT_FIELDS,
@@ -139,6 +200,7 @@ export {
139
200
  MAX_LOOP_ITERATIONS2 as MAX_LOOP_ITERATIONS,
140
201
  MAX_NAME_LENGTH2 as MAX_NAME_LENGTH,
141
202
  MAX_OPERATOR_ARGS2 as MAX_OPERATOR_ARGS,
203
+ MAX_PAGE_TEXT2 as MAX_PAGE_TEXT,
142
204
  MAX_RECORDED_STEPS2 as MAX_RECORDED_STEPS,
143
205
  MAX_RETRY_ATTEMPTS2 as MAX_RETRY_ATTEMPTS,
144
206
  MAX_SCRIPT_BYTES2 as MAX_SCRIPT_BYTES,
@@ -150,10 +212,13 @@ export {
150
212
  MAX_SELECTOR_LENGTH2 as MAX_SELECTOR_LENGTH,
151
213
  MAX_SELECT_VALUES2 as MAX_SELECT_VALUES,
152
214
  MAX_SNAPSHOT_NODES2 as MAX_SNAPSHOT_NODES,
215
+ MAX_STEP_LOG_ENTRIES2 as MAX_STEP_LOG_ENTRIES,
153
216
  MAX_STEP_TIMEOUT_MS2 as MAX_STEP_TIMEOUT_MS,
154
217
  MAX_TARGET_METHODS2 as MAX_TARGET_METHODS,
155
218
  MAX_TEXT_LENGTH2 as MAX_TEXT_LENGTH,
156
219
  MAX_URL_LENGTH2 as MAX_URL_LENGTH,
220
+ MAX_VALUE_ITEMS2 as MAX_VALUE_ITEMS,
221
+ MAX_VALUE_TEXT2 as MAX_VALUE_TEXT,
157
222
  NAME_PATTERN2 as NAME_PATTERN,
158
223
  RECORDING_ACTION_OF2 as RECORDING_ACTION_OF,
159
224
  RECORDING_VERSION2 as RECORDING_VERSION,
@@ -165,9 +230,13 @@ export {
165
230
  STEP_ID_PATTERN2 as STEP_ID_PATTERN,
166
231
  UI_ANCHOR_RELATIONS2 as UI_ANCHOR_RELATIONS,
167
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,
168
236
  UI_EXPRESSION_ARITY2 as UI_EXPRESSION_ARITY,
169
237
  UI_EXPRESSION_OPS2 as UI_EXPRESSION_OPS,
170
238
  UI_FLOW_ACTIONS2 as UI_FLOW_ACTIONS,
239
+ UI_RUN_EVENT_KINDS2 as UI_RUN_EVENT_KINDS,
171
240
  UI_SCRIPT_SCHEMA_HASH2 as UI_SCRIPT_SCHEMA_HASH,
172
241
  UI_SCRIPT_SCHEMA_TITLE2 as UI_SCRIPT_SCHEMA_TITLE,
173
242
  UI_SCRIPT_STEP_KEY_PREFIX2 as UI_SCRIPT_STEP_KEY_PREFIX,
@@ -177,20 +246,30 @@ export {
177
246
  UI_TARGET_METHOD_KINDS2 as UI_TARGET_METHOD_KINDS,
178
247
  UI_VALUE_TYPES2 as UI_VALUE_TYPES,
179
248
  UI_WEB_ACTIONS2 as UI_WEB_ACTIONS,
249
+ UiDriverError2 as UiDriverError,
250
+ UiRunError2 as UiRunError,
180
251
  UiScriptError2 as UiScriptError,
181
252
  afterReplayCall2 as afterReplayCall,
253
+ applyPins2 as applyPins,
182
254
  canonicalJson2 as canonicalJson,
183
255
  captureRecording2 as captureRecording,
184
256
  childBlocks2 as childBlocks,
257
+ compileUiScript2 as compileUiScript,
185
258
  countSteps2 as countSteps,
259
+ createVirtualClock2 as createVirtualClock,
186
260
  describeExpression2 as describeExpression,
187
261
  describeStep2 as describeStep,
188
262
  describeTarget2 as describeTarget,
263
+ errorFamilyOf2 as errorFamilyOf,
264
+ evaluateExpression2 as evaluateExpression,
189
265
  finishFallback2 as finishFallback,
190
266
  fromBrowserActionSteps2 as fromBrowserActionSteps,
191
267
  fromRecording2 as fromRecording,
192
268
  fromRemoteBrowserSteps2 as fromRemoteBrowserSteps,
269
+ inlineCalls2 as inlineCalls,
270
+ isRetryableInScript2 as isRetryableInScript,
193
271
  isSavedStepAuthor2 as isSavedStepAuthor,
272
+ isUiErrorCode2 as isUiErrorCode,
194
273
  jsonByteLength2 as jsonByteLength,
195
274
  markFallbackAsked2 as markFallbackAsked,
196
275
  maskUrl2 as maskUrl,
@@ -198,8 +277,10 @@ export {
198
277
  parseRecording2 as parseRecording,
199
278
  parseUiScript2 as parseUiScript,
200
279
  planReplay2 as planReplay,
280
+ readPath2 as readPath,
201
281
  readReplayState2 as readReplayState,
202
282
  readSnapshotNodes2 as readSnapshotNodes,
283
+ realClock2 as realClock,
203
284
  recordedStepSchema2 as recordedStepSchema,
204
285
  recordedTargetSchema2 as recordedTargetSchema,
205
286
  recordingSchema2 as recordingSchema,
@@ -208,6 +289,7 @@ export {
208
289
  replayStateFrom2 as replayStateFrom,
209
290
  requiredCapabilities2 as requiredCapabilities,
210
291
  resolveTarget2 as resolveTarget,
292
+ runUiScript2 as runUiScript,
211
293
  safeParseUiScript2 as safeParseUiScript,
212
294
  schemaHashOf2 as schemaHashOf,
213
295
  sha256Hex2 as sha256Hex,
@@ -215,10 +297,15 @@ export {
215
297
  stepExpressions2 as stepExpressions,
216
298
  stepMessageKey2 as stepMessageKey,
217
299
  stepTargets2 as stepTargets,
300
+ stripBreakpoints2 as stripBreakpoints,
218
301
  targetFingerprint2 as targetFingerprint,
219
302
  targetFromPlaywrightSelector2 as targetFromPlaywrightSelector,
220
303
  toBrowserActionSteps2 as toBrowserActionSteps,
304
+ toNumber2 as toNumber,
221
305
  toRecording2 as toRecording,
306
+ toText2 as toText,
307
+ toUiValue2 as toUiValue,
308
+ truthy2 as truthy,
222
309
  uiExpressionSchema2 as uiExpressionSchema,
223
310
  uiScriptJsonSchema2 as uiScriptJsonSchema,
224
311
  uiScriptRegistry2 as uiScriptRegistry,
@@ -228,6 +315,7 @@ export {
228
315
  uiTargetMethodSchema2 as uiTargetMethodSchema,
229
316
  uiTargetRefSchema2 as uiTargetRefSchema,
230
317
  uiTargetSchema2 as uiTargetSchema,
318
+ valuesEqual2 as valuesEqual,
231
319
  visitExpression2 as visitExpression,
232
320
  walkSteps2 as walkSteps,
233
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
+ };