@burdenoff/ui-engine 2026.1127.1 → 2026.1127.3
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.
- package/README.md +68 -3
- package/dist/capture.js +3 -2
- package/dist/dom-runtime/actions.d.ts +65 -0
- package/dist/dom-runtime/iife.d.ts +1 -0
- package/dist/dom-runtime/index.d.ts +7 -0
- package/dist/dom-runtime/runtime.d.ts +79 -0
- package/dist/dom-runtime.d.ts +2 -0
- package/dist/dom-runtime.iife.js +1 -0
- package/dist/dom-runtime.js +535 -0
- package/dist/{index-05zgh18g.js → index-2kgsgn1c.js} +1 -1
- package/dist/{index-phd8yhyg.js → index-bnvmt4wf.js} +7 -5
- package/dist/{index-c6pmt2rg.js → index-cs6acyjn.js} +6 -59
- package/dist/index-mgztm37r.js +57 -0
- package/dist/index-q1b0j9yr.js +1349 -0
- package/dist/index-zwrxw3zp.js +1988 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +180 -6
- package/dist/recording.js +1 -1
- package/dist/replay.js +2 -2
- package/dist/script/adapters/browser-action-contract.d.ts +22 -0
- package/dist/script/adapters/from-browser-action.d.ts +7 -0
- package/dist/script/adapters/from-remote-browser.d.ts +7 -0
- package/dist/script/adapters/recording.d.ts +25 -0
- package/dist/script/adapters/to-browser-action.d.ts +8 -0
- package/dist/script/canonical.d.ts +6 -0
- package/dist/script/capabilities.d.ts +29 -0
- package/dist/script/describe.d.ts +83 -0
- package/dist/script/fingerprint.d.ts +9 -0
- package/dist/script/hash.d.ts +3 -0
- package/dist/script/index.d.ts +22 -0
- package/dist/script/json-schema.d.ts +4 -0
- package/dist/script/limits.d.ts +61 -0
- package/dist/script/parse.d.ts +31 -0
- package/dist/script/schema.d.ts +87 -0
- package/dist/script/types.d.ts +489 -0
- package/dist/script/walk.d.ts +29 -0
- package/dist/script.d.ts +2 -0
- package/dist/script.js +175 -0
- package/dist/target/aria.d.ts +31 -0
- package/dist/target/dom.d.ts +35 -0
- package/dist/target/index.d.ts +13 -0
- package/dist/target/markers.d.ts +18 -0
- package/dist/target/methods.d.ts +52 -0
- package/dist/target/resolve.d.ts +46 -0
- package/dist/target/snapshot.d.ts +57 -0
- package/dist/target/text.d.ts +23 -0
- package/dist/target/types.d.ts +88 -0
- package/dist/target.d.ts +2 -0
- package/dist/target.js +92 -0
- package/dist/testing/fixtures/ambiguous.d.ts +7 -0
- package/dist/testing/fixtures/iframe.d.ts +6 -0
- package/dist/testing/fixtures/index.d.ts +26 -0
- package/dist/testing/fixtures/invoices-v2.d.ts +8 -0
- package/dist/testing/fixtures/invoices-v3.d.ts +7 -0
- package/dist/testing/fixtures/invoices.d.ts +6 -0
- package/dist/testing/fixtures/login.d.ts +6 -0
- package/dist/testing/fixtures/shadow.d.ts +7 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/mount.d.ts +18 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +324 -0
- package/package.json +28 -5
- package/schema/ui-script-v1.schema.json +8199 -0
|
@@ -0,0 +1,1988 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sha256Hex2,
|
|
3
|
+
targetFingerprint2,
|
|
4
|
+
RecordingError2,
|
|
5
|
+
parseRecording2
|
|
6
|
+
} from "./index-cs6acyjn.js";
|
|
7
|
+
import {
|
|
8
|
+
containsCredential,
|
|
9
|
+
containsCredentialInUrl
|
|
10
|
+
} from "./index-mgztm37r.js";
|
|
11
|
+
|
|
12
|
+
// src/script/types.ts
|
|
13
|
+
var UI_EXPRESSION_OPS2 = [
|
|
14
|
+
"eq",
|
|
15
|
+
"ne",
|
|
16
|
+
"lt",
|
|
17
|
+
"le",
|
|
18
|
+
"gt",
|
|
19
|
+
"ge",
|
|
20
|
+
"and",
|
|
21
|
+
"or",
|
|
22
|
+
"not",
|
|
23
|
+
"add",
|
|
24
|
+
"sub",
|
|
25
|
+
"mul",
|
|
26
|
+
"div",
|
|
27
|
+
"mod",
|
|
28
|
+
"neg",
|
|
29
|
+
"abs",
|
|
30
|
+
"round",
|
|
31
|
+
"min",
|
|
32
|
+
"max",
|
|
33
|
+
"concat",
|
|
34
|
+
"contains",
|
|
35
|
+
"startsWith",
|
|
36
|
+
"endsWith",
|
|
37
|
+
"lower",
|
|
38
|
+
"upper",
|
|
39
|
+
"trim",
|
|
40
|
+
"replace",
|
|
41
|
+
"split",
|
|
42
|
+
"join",
|
|
43
|
+
"length",
|
|
44
|
+
"toNumber",
|
|
45
|
+
"toText",
|
|
46
|
+
"toBoolean",
|
|
47
|
+
"isEmpty",
|
|
48
|
+
"coalesce",
|
|
49
|
+
"if",
|
|
50
|
+
"get",
|
|
51
|
+
"now",
|
|
52
|
+
"formatDate",
|
|
53
|
+
"addDays"
|
|
54
|
+
];
|
|
55
|
+
var UI_ANCHOR_RELATIONS2 = ["leftOf", "rightOf", "above", "below", "inside", "sameRow"];
|
|
56
|
+
var UI_TARGET_METHOD_KINDS2 = ["role", "css", "testId", "xpath", "fuzzy", "anchor", "text"];
|
|
57
|
+
var UI_WEB_ACTIONS2 = [
|
|
58
|
+
"navigate",
|
|
59
|
+
"goBack",
|
|
60
|
+
"reload",
|
|
61
|
+
"closeTab",
|
|
62
|
+
"click",
|
|
63
|
+
"doubleClick",
|
|
64
|
+
"hover",
|
|
65
|
+
"type",
|
|
66
|
+
"typeSecret",
|
|
67
|
+
"clear",
|
|
68
|
+
"select",
|
|
69
|
+
"check",
|
|
70
|
+
"pressKey",
|
|
71
|
+
"scroll",
|
|
72
|
+
"waitFor",
|
|
73
|
+
"extract",
|
|
74
|
+
"extractList",
|
|
75
|
+
"getText",
|
|
76
|
+
"getValue",
|
|
77
|
+
"getAttribute",
|
|
78
|
+
"elementExists",
|
|
79
|
+
"getPageText",
|
|
80
|
+
"getPageHtml",
|
|
81
|
+
"screenshot",
|
|
82
|
+
"login"
|
|
83
|
+
];
|
|
84
|
+
var UI_DESKTOP_ACTIONS2 = ["focusWindow"];
|
|
85
|
+
var UI_FLOW_ACTIONS2 = [
|
|
86
|
+
"if",
|
|
87
|
+
"forEach",
|
|
88
|
+
"while",
|
|
89
|
+
"retryScope",
|
|
90
|
+
"set",
|
|
91
|
+
"log",
|
|
92
|
+
"call"
|
|
93
|
+
];
|
|
94
|
+
var UI_STEP_ACTIONS2 = [...UI_WEB_ACTIONS2, ...UI_DESKTOP_ACTIONS2, ...UI_FLOW_ACTIONS2];
|
|
95
|
+
var UI_VALUE_TYPES2 = ["text", "number", "boolean", "list", "object", "any"];
|
|
96
|
+
// src/script/limits.ts
|
|
97
|
+
var UI_SCRIPT_VERSION2 = 1;
|
|
98
|
+
var MAX_SCRIPT_STEPS2 = 500;
|
|
99
|
+
var MAX_SCRIPT_BYTES2 = 1024 * 1024;
|
|
100
|
+
var MAX_FLOW_DEPTH2 = 8;
|
|
101
|
+
var MAX_EXPRESSION_DEPTH2 = 16;
|
|
102
|
+
var MAX_EXPRESSION_ITEMS2 = 1000;
|
|
103
|
+
var MAX_OPERATOR_ARGS2 = 16;
|
|
104
|
+
var MAX_SCRIPT_INPUTS2 = 100;
|
|
105
|
+
var MAX_SCRIPT_OUTPUTS2 = 100;
|
|
106
|
+
var MAX_SCRIPT_VARIABLES2 = 100;
|
|
107
|
+
var MAX_SCRIPT_ELEMENTS2 = 500;
|
|
108
|
+
var MAX_TARGET_METHODS2 = 8;
|
|
109
|
+
var MAX_FRAME_DEPTH2 = 8;
|
|
110
|
+
var MAX_EXTRACT_FIELDS2 = 50;
|
|
111
|
+
var MAX_LIST_ITEMS2 = 5000;
|
|
112
|
+
var MAX_LIST_PAGES2 = 50;
|
|
113
|
+
var MAX_LOOP_ITERATIONS2 = 1e4;
|
|
114
|
+
var MAX_RETRY_ATTEMPTS2 = 10;
|
|
115
|
+
var MAX_STEP_TIMEOUT_MS2 = 600000;
|
|
116
|
+
var MAX_DELAY_MS2 = 60000;
|
|
117
|
+
var MAX_KEYS2 = 8;
|
|
118
|
+
var MAX_SELECT_VALUES2 = 50;
|
|
119
|
+
var MAX_SELECTOR_LENGTH2 = 500;
|
|
120
|
+
var MAX_URL_LENGTH2 = 4096;
|
|
121
|
+
var MAX_LABEL_LENGTH2 = 512;
|
|
122
|
+
var MAX_TEXT_LENGTH2 = 1e4;
|
|
123
|
+
var MAX_INTENT_LENGTH2 = 500;
|
|
124
|
+
var MAX_NAME_LENGTH2 = 64;
|
|
125
|
+
var LEGACY_MAX_BROWSER_STEPS2 = 100;
|
|
126
|
+
var LEGACY_MAX_STEPS_BYTES2 = 256 * 1024;
|
|
127
|
+
function jsonByteLength2(value) {
|
|
128
|
+
return new TextEncoder().encode(JSON.stringify(value) ?? "").length;
|
|
129
|
+
}
|
|
130
|
+
// src/script/schema.ts
|
|
131
|
+
import { z } from "zod";
|
|
132
|
+
var uiScriptRegistry2 = z.registry();
|
|
133
|
+
var NAME_PATTERN2 = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
134
|
+
var STEP_ID_PATTERN2 = /^[A-Za-z0-9_-]{1,64}$/;
|
|
135
|
+
var ELEMENT_KEY_PATTERN2 = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
136
|
+
var STORAGE_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9:/._-]{0,511}$/;
|
|
137
|
+
var SECRET_REF_PATTERN = /^[A-Za-z0-9][A-Za-z0-9:/._#-]{0,254}$/;
|
|
138
|
+
var ATTRIBUTE_PATTERN = /^[A-Za-z_:][A-Za-z0-9_.:-]{0,63}$/;
|
|
139
|
+
var name = z.string().regex(NAME_PATTERN2);
|
|
140
|
+
var label = z.string().min(1).max(MAX_LABEL_LENGTH2);
|
|
141
|
+
var selector = z.string().min(1).max(MAX_SELECTOR_LENGTH2);
|
|
142
|
+
var ms = z.int().min(0).max(MAX_STEP_TIMEOUT_MS2);
|
|
143
|
+
var delay = z.int().min(0).max(MAX_DELAY_MS2);
|
|
144
|
+
var valueType = z.enum(UI_VALUE_TYPES2);
|
|
145
|
+
var valuePath = z.array(z.union([z.string().min(1).max(MAX_NAME_LENGTH2), z.int().min(0)])).min(1).max(MAX_EXPRESSION_DEPTH2);
|
|
146
|
+
var uiExpressionSchema2 = z.lazy(() => z.union([
|
|
147
|
+
z.string().max(MAX_TEXT_LENGTH2),
|
|
148
|
+
z.number(),
|
|
149
|
+
z.boolean(),
|
|
150
|
+
z.null(),
|
|
151
|
+
z.strictObject({ input: name, path: valuePath.optional() }),
|
|
152
|
+
z.strictObject({ var: name, path: valuePath.optional() }),
|
|
153
|
+
z.strictObject({ list: z.array(uiExpressionSchema2).max(MAX_EXPRESSION_ITEMS2) }),
|
|
154
|
+
z.strictObject({ object: z.record(name, uiExpressionSchema2) }),
|
|
155
|
+
z.strictObject({ op: z.enum(UI_EXPRESSION_OPS2), args: z.array(uiExpressionSchema2).max(MAX_OPERATOR_ARGS2) })
|
|
156
|
+
])).register(uiScriptRegistry2, { id: "UiExpression" });
|
|
157
|
+
var enabled = { enabled: z.boolean().optional() };
|
|
158
|
+
var anchorSchema = z.discriminatedUnion("kind", [
|
|
159
|
+
z.strictObject({ kind: z.literal("text"), text: label }),
|
|
160
|
+
z.strictObject({ kind: z.literal("role"), role: label, name: label })
|
|
161
|
+
]);
|
|
162
|
+
var uiTargetMethodSchema2 = z.discriminatedUnion("kind", [
|
|
163
|
+
z.strictObject({
|
|
164
|
+
kind: z.literal("role"),
|
|
165
|
+
role: label,
|
|
166
|
+
name: label,
|
|
167
|
+
nth: z.int().min(0).max(50).optional(),
|
|
168
|
+
app: label.optional(),
|
|
169
|
+
window: label.optional(),
|
|
170
|
+
...enabled
|
|
171
|
+
}),
|
|
172
|
+
z.strictObject({ kind: z.literal("css"), selector, ...enabled }),
|
|
173
|
+
z.strictObject({
|
|
174
|
+
kind: z.literal("testId"),
|
|
175
|
+
value: label,
|
|
176
|
+
attribute: z.string().regex(ATTRIBUTE_PATTERN).optional(),
|
|
177
|
+
...enabled
|
|
178
|
+
}),
|
|
179
|
+
z.strictObject({ kind: z.literal("xpath"), xpath: selector, ...enabled }),
|
|
180
|
+
z.strictObject({
|
|
181
|
+
kind: z.literal("fuzzy"),
|
|
182
|
+
role: label.optional(),
|
|
183
|
+
name: label,
|
|
184
|
+
threshold: z.number().min(0.5).max(1).optional(),
|
|
185
|
+
...enabled
|
|
186
|
+
}),
|
|
187
|
+
z.strictObject({
|
|
188
|
+
kind: z.literal("anchor"),
|
|
189
|
+
anchor: anchorSchema,
|
|
190
|
+
relation: z.enum(UI_ANCHOR_RELATIONS2),
|
|
191
|
+
role: label.optional(),
|
|
192
|
+
...enabled
|
|
193
|
+
}),
|
|
194
|
+
z.strictObject({
|
|
195
|
+
kind: z.literal("text"),
|
|
196
|
+
text: label,
|
|
197
|
+
exact: z.boolean().optional(),
|
|
198
|
+
nth: z.int().min(0).max(50).optional(),
|
|
199
|
+
...enabled
|
|
200
|
+
})
|
|
201
|
+
]).register(uiScriptRegistry2, { id: "UiTargetMethod" });
|
|
202
|
+
var uiTargetSchema2 = z.strictObject({
|
|
203
|
+
methods: z.array(uiTargetMethodSchema2).min(1).max(MAX_TARGET_METHODS2),
|
|
204
|
+
frame: z.array(selector).min(1).max(MAX_FRAME_DEPTH2).optional()
|
|
205
|
+
}).register(uiScriptRegistry2, { id: "UiTarget" });
|
|
206
|
+
var uiTargetRefSchema2 = z.union([uiTargetSchema2, z.strictObject({ element: z.string().regex(ELEMENT_KEY_PATTERN2) })]).register(uiScriptRegistry2, { id: "UiTargetRef" });
|
|
207
|
+
var verifyTimeout = { timeoutMs: ms.optional() };
|
|
208
|
+
var verifySchema = z.discriminatedUnion("kind", [
|
|
209
|
+
z.strictObject({ kind: z.literal("elementVisible"), target: uiTargetRefSchema2, ...verifyTimeout }),
|
|
210
|
+
z.strictObject({ kind: z.literal("elementGone"), target: uiTargetRefSchema2, ...verifyTimeout }),
|
|
211
|
+
z.strictObject({ kind: z.literal("urlContains"), value: uiExpressionSchema2, ...verifyTimeout }),
|
|
212
|
+
z.strictObject({ kind: z.literal("textPresent"), text: uiExpressionSchema2, ...verifyTimeout }),
|
|
213
|
+
z.strictObject({
|
|
214
|
+
kind: z.literal("valueEquals"),
|
|
215
|
+
target: uiTargetRefSchema2,
|
|
216
|
+
value: uiExpressionSchema2,
|
|
217
|
+
...verifyTimeout
|
|
218
|
+
})
|
|
219
|
+
]);
|
|
220
|
+
var base = {
|
|
221
|
+
id: z.string().regex(STEP_ID_PATTERN2),
|
|
222
|
+
intent: z.string().min(1).max(MAX_INTENT_LENGTH2).optional(),
|
|
223
|
+
note: z.string().min(1).max(MAX_INTENT_LENGTH2).optional(),
|
|
224
|
+
saveAs: name.optional(),
|
|
225
|
+
disabled: z.boolean().optional(),
|
|
226
|
+
breakpoint: z.boolean().optional(),
|
|
227
|
+
timeoutMs: ms.optional(),
|
|
228
|
+
retry: z.strictObject({ attempts: z.int().min(1).max(MAX_RETRY_ATTEMPTS2), delayMs: delay.optional() }).optional(),
|
|
229
|
+
onError: z.enum(["fail", "continue"]).optional(),
|
|
230
|
+
verify: verifySchema.optional(),
|
|
231
|
+
screenshot: z.enum(["never", "onFailure", "always"]).optional(),
|
|
232
|
+
inputMethod: z.enum(["auto", "direct", "hardware"]).optional(),
|
|
233
|
+
safeToRepeat: z.boolean().optional(),
|
|
234
|
+
screenshotRef: z.string().regex(STORAGE_KEY_PATTERN).optional(),
|
|
235
|
+
fingerprint: z.string().regex(/^[0-9a-f]{64}$/).optional()
|
|
236
|
+
};
|
|
237
|
+
var target = uiTargetRefSchema2;
|
|
238
|
+
var steps = () => z.array(uiStepSchema2).min(1).max(MAX_SCRIPT_STEPS2);
|
|
239
|
+
var fieldSchema = z.strictObject({
|
|
240
|
+
name,
|
|
241
|
+
target,
|
|
242
|
+
attribute: z.string().regex(ATTRIBUTE_PATTERN).optional(),
|
|
243
|
+
all: z.boolean().optional()
|
|
244
|
+
});
|
|
245
|
+
var fields = z.array(fieldSchema).min(1).max(MAX_EXTRACT_FIELDS2);
|
|
246
|
+
var condition = { condition: uiExpressionSchema2.optional(), elementExists: target.optional() };
|
|
247
|
+
var uiStepSchema2 = z.lazy(() => z.discriminatedUnion("action", [
|
|
248
|
+
z.strictObject({
|
|
249
|
+
...base,
|
|
250
|
+
action: z.literal("navigate"),
|
|
251
|
+
url: uiExpressionSchema2,
|
|
252
|
+
waitUntil: z.enum(["load", "domcontentloaded", "networkidle", "commit"]).optional()
|
|
253
|
+
}),
|
|
254
|
+
z.strictObject({ ...base, action: z.literal("goBack") }),
|
|
255
|
+
z.strictObject({ ...base, action: z.literal("reload") }),
|
|
256
|
+
z.strictObject({ ...base, action: z.literal("closeTab") }),
|
|
257
|
+
z.strictObject({ ...base, action: z.literal("click"), target, button: z.enum(["left", "right"]).optional() }),
|
|
258
|
+
z.strictObject({
|
|
259
|
+
...base,
|
|
260
|
+
action: z.literal("doubleClick"),
|
|
261
|
+
target,
|
|
262
|
+
button: z.enum(["left", "right"]).optional()
|
|
263
|
+
}),
|
|
264
|
+
z.strictObject({ ...base, action: z.literal("hover"), target }),
|
|
265
|
+
z.strictObject({
|
|
266
|
+
...base,
|
|
267
|
+
action: z.literal("type"),
|
|
268
|
+
target: target.optional(),
|
|
269
|
+
text: uiExpressionSchema2.optional(),
|
|
270
|
+
masked: z.boolean().optional(),
|
|
271
|
+
clear: z.boolean().optional(),
|
|
272
|
+
pressEnter: z.boolean().optional(),
|
|
273
|
+
delayMs: delay.optional()
|
|
274
|
+
}),
|
|
275
|
+
z.strictObject({
|
|
276
|
+
...base,
|
|
277
|
+
action: z.literal("typeSecret"),
|
|
278
|
+
target,
|
|
279
|
+
secretRef: z.string().regex(SECRET_REF_PATTERN),
|
|
280
|
+
expectedOrigin: z.url({ protocol: /^https?$/ }).max(MAX_URL_LENGTH2).optional()
|
|
281
|
+
}),
|
|
282
|
+
z.strictObject({ ...base, action: z.literal("clear"), target }),
|
|
283
|
+
z.strictObject({
|
|
284
|
+
...base,
|
|
285
|
+
action: z.literal("select"),
|
|
286
|
+
target,
|
|
287
|
+
values: z.array(uiExpressionSchema2).min(1).max(MAX_SELECT_VALUES2)
|
|
288
|
+
}),
|
|
289
|
+
z.strictObject({ ...base, action: z.literal("check"), target, checked: z.boolean().optional() }),
|
|
290
|
+
z.strictObject({
|
|
291
|
+
...base,
|
|
292
|
+
action: z.literal("pressKey"),
|
|
293
|
+
keys: z.array(z.string().min(1).max(32)).min(1).max(MAX_KEYS2),
|
|
294
|
+
target: target.optional()
|
|
295
|
+
}),
|
|
296
|
+
z.strictObject({
|
|
297
|
+
...base,
|
|
298
|
+
action: z.literal("scroll"),
|
|
299
|
+
target: target.optional(),
|
|
300
|
+
dx: z.int().min(-1e4).max(1e4).optional(),
|
|
301
|
+
dy: z.int().min(-1e4).max(1e4).optional(),
|
|
302
|
+
to: z.enum(["top", "bottom"]).optional()
|
|
303
|
+
}),
|
|
304
|
+
z.strictObject({
|
|
305
|
+
...base,
|
|
306
|
+
action: z.literal("waitFor"),
|
|
307
|
+
target: target.optional(),
|
|
308
|
+
text: uiExpressionSchema2.optional(),
|
|
309
|
+
urlContains: uiExpressionSchema2.optional(),
|
|
310
|
+
milliseconds: z.int().min(1).max(MAX_STEP_TIMEOUT_MS2).optional(),
|
|
311
|
+
state: z.enum(["visible", "hidden", "attached", "detached"]).optional()
|
|
312
|
+
}),
|
|
313
|
+
z.strictObject({ ...base, action: z.literal("extract"), fields }),
|
|
314
|
+
z.strictObject({
|
|
315
|
+
...base,
|
|
316
|
+
action: z.literal("extractList"),
|
|
317
|
+
item: target,
|
|
318
|
+
fields,
|
|
319
|
+
maxItems: z.int().min(1).max(MAX_LIST_ITEMS2).optional(),
|
|
320
|
+
next: target.optional(),
|
|
321
|
+
maxPages: z.int().min(1).max(MAX_LIST_PAGES2).optional()
|
|
322
|
+
}),
|
|
323
|
+
z.strictObject({ ...base, action: z.literal("getText"), target }),
|
|
324
|
+
z.strictObject({ ...base, action: z.literal("getValue"), target }),
|
|
325
|
+
z.strictObject({
|
|
326
|
+
...base,
|
|
327
|
+
action: z.literal("getAttribute"),
|
|
328
|
+
target,
|
|
329
|
+
attribute: z.string().regex(ATTRIBUTE_PATTERN)
|
|
330
|
+
}),
|
|
331
|
+
z.strictObject({ ...base, action: z.literal("elementExists"), target }),
|
|
332
|
+
z.strictObject({ ...base, action: z.literal("getPageText") }),
|
|
333
|
+
z.strictObject({ ...base, action: z.literal("getPageHtml") }),
|
|
334
|
+
z.strictObject({
|
|
335
|
+
...base,
|
|
336
|
+
action: z.literal("screenshot"),
|
|
337
|
+
target: target.optional(),
|
|
338
|
+
fullPage: z.boolean().optional()
|
|
339
|
+
}),
|
|
340
|
+
z.strictObject({
|
|
341
|
+
...base,
|
|
342
|
+
action: z.literal("login"),
|
|
343
|
+
username: target.optional(),
|
|
344
|
+
password: target.optional(),
|
|
345
|
+
submit: target.optional(),
|
|
346
|
+
success: target.optional()
|
|
347
|
+
}),
|
|
348
|
+
z.strictObject({ ...base, action: z.literal("focusWindow"), app: label, title: label.optional() }),
|
|
349
|
+
z.strictObject({ ...base, action: z.literal("if"), ...condition, then: steps(), else: steps().optional() }),
|
|
350
|
+
z.strictObject({
|
|
351
|
+
...base,
|
|
352
|
+
action: z.literal("forEach"),
|
|
353
|
+
in: uiExpressionSchema2.optional(),
|
|
354
|
+
elements: target.optional(),
|
|
355
|
+
as: name,
|
|
356
|
+
index: name.optional(),
|
|
357
|
+
max: z.int().min(1).max(MAX_LOOP_ITERATIONS2).optional(),
|
|
358
|
+
steps: steps()
|
|
359
|
+
}),
|
|
360
|
+
z.strictObject({
|
|
361
|
+
...base,
|
|
362
|
+
action: z.literal("while"),
|
|
363
|
+
...condition,
|
|
364
|
+
maxIterations: z.int().min(1).max(MAX_LOOP_ITERATIONS2),
|
|
365
|
+
steps: steps()
|
|
366
|
+
}),
|
|
367
|
+
z.strictObject({
|
|
368
|
+
...base,
|
|
369
|
+
action: z.literal("retryScope"),
|
|
370
|
+
attempts: z.int().min(1).max(MAX_RETRY_ATTEMPTS2),
|
|
371
|
+
delayMs: delay.optional(),
|
|
372
|
+
steps: steps()
|
|
373
|
+
}),
|
|
374
|
+
z.strictObject({ ...base, action: z.literal("set"), name, value: uiExpressionSchema2 }),
|
|
375
|
+
z.strictObject({
|
|
376
|
+
...base,
|
|
377
|
+
action: z.literal("log"),
|
|
378
|
+
level: z.enum(["debug", "info", "warn", "error"]).optional(),
|
|
379
|
+
message: uiExpressionSchema2
|
|
380
|
+
}),
|
|
381
|
+
z.strictObject({
|
|
382
|
+
...base,
|
|
383
|
+
action: z.literal("call"),
|
|
384
|
+
sequenceId: z.string().min(1).max(MAX_NAME_LENGTH2),
|
|
385
|
+
version: z.int().min(1),
|
|
386
|
+
args: z.record(name, uiExpressionSchema2).optional()
|
|
387
|
+
})
|
|
388
|
+
])).register(uiScriptRegistry2, { id: "UiStep" });
|
|
389
|
+
var description = z.string().min(1).max(MAX_INTENT_LENGTH2).optional();
|
|
390
|
+
var uiScriptSchema2 = z.strictObject({
|
|
391
|
+
scriptVersion: z.literal(UI_SCRIPT_VERSION2),
|
|
392
|
+
name: label.optional(),
|
|
393
|
+
application: z.strictObject({ name: label.optional(), urlPattern: z.string().min(1).max(MAX_URL_LENGTH2).optional() }).optional(),
|
|
394
|
+
settings: z.strictObject({
|
|
395
|
+
firstWaitMs: ms.optional(),
|
|
396
|
+
waitMs: ms.optional(),
|
|
397
|
+
screenshots: z.enum(["never", "onFailure", "everyStep"]).optional(),
|
|
398
|
+
inputMethod: z.enum(["auto", "direct", "hardware"]).optional()
|
|
399
|
+
}).optional(),
|
|
400
|
+
inputs: z.array(z.strictObject({
|
|
401
|
+
name,
|
|
402
|
+
type: valueType.optional(),
|
|
403
|
+
required: z.boolean().optional(),
|
|
404
|
+
default: uiExpressionSchema2.optional(),
|
|
405
|
+
description
|
|
406
|
+
})).max(MAX_SCRIPT_INPUTS2).optional(),
|
|
407
|
+
outputs: z.array(z.strictObject({ name, type: valueType.optional(), value: uiExpressionSchema2, description })).max(MAX_SCRIPT_OUTPUTS2).optional(),
|
|
408
|
+
variables: z.array(z.strictObject({ name, type: valueType.optional(), initial: uiExpressionSchema2.optional() })).max(MAX_SCRIPT_VARIABLES2).optional(),
|
|
409
|
+
elements: z.record(z.string().regex(ELEMENT_KEY_PATTERN2), z.strictObject({
|
|
410
|
+
elementId: z.string().min(1).max(MAX_NAME_LENGTH2),
|
|
411
|
+
version: z.int().min(1),
|
|
412
|
+
name: label.optional(),
|
|
413
|
+
target: uiTargetSchema2.optional()
|
|
414
|
+
})).optional(),
|
|
415
|
+
steps: steps(),
|
|
416
|
+
cleanup: steps().optional()
|
|
417
|
+
});
|
|
418
|
+
// src/script/canonical.ts
|
|
419
|
+
function canonicalJson2(value) {
|
|
420
|
+
return JSON.stringify(canonicalValue(value)) ?? "null";
|
|
421
|
+
}
|
|
422
|
+
function canonicalValue(value) {
|
|
423
|
+
if (Array.isArray(value))
|
|
424
|
+
return value.map(canonicalValue);
|
|
425
|
+
if (value !== null && typeof value === "object") {
|
|
426
|
+
const out = {};
|
|
427
|
+
for (const key of Object.keys(value).sort()) {
|
|
428
|
+
const item = Reflect.get(value, key);
|
|
429
|
+
if (item !== undefined)
|
|
430
|
+
out[key] = canonicalValue(item);
|
|
431
|
+
}
|
|
432
|
+
return out;
|
|
433
|
+
}
|
|
434
|
+
return value;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/script/walk.ts
|
|
438
|
+
function childBlocks2(step) {
|
|
439
|
+
switch (step.action) {
|
|
440
|
+
case "if":
|
|
441
|
+
return step.else ? [
|
|
442
|
+
["then", step.then],
|
|
443
|
+
["else", step.else]
|
|
444
|
+
] : [["then", step.then]];
|
|
445
|
+
case "forEach":
|
|
446
|
+
case "while":
|
|
447
|
+
case "retryScope":
|
|
448
|
+
return [["steps", step.steps]];
|
|
449
|
+
default:
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function* walkList(steps, prefix, depth) {
|
|
454
|
+
for (const [index, step] of steps.entries()) {
|
|
455
|
+
const path = prefix ? `${prefix}.${index}` : String(index);
|
|
456
|
+
yield { step, path, depth };
|
|
457
|
+
for (const [block, children] of childBlocks2(step)) {
|
|
458
|
+
yield* walkList(children, `${path}.${block}`, depth + 1);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function* walkSteps2(script) {
|
|
463
|
+
yield* walkList(script.steps, "", 0);
|
|
464
|
+
if (script.cleanup)
|
|
465
|
+
yield* walkList(script.cleanup, "cleanup", 0);
|
|
466
|
+
}
|
|
467
|
+
function countSteps2(script) {
|
|
468
|
+
return Array.from(walkSteps2(script)).length;
|
|
469
|
+
}
|
|
470
|
+
function stepAtPath2(script, path) {
|
|
471
|
+
for (const walked of walkSteps2(script))
|
|
472
|
+
if (walked.path === path)
|
|
473
|
+
return walked.step;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
function stepTargets2(step) {
|
|
477
|
+
const found = [];
|
|
478
|
+
const add = (field, ref) => {
|
|
479
|
+
if (ref)
|
|
480
|
+
found.push([field, ref]);
|
|
481
|
+
};
|
|
482
|
+
if ("target" in step)
|
|
483
|
+
add("target", step.target);
|
|
484
|
+
switch (step.action) {
|
|
485
|
+
case "extract":
|
|
486
|
+
step.fields.forEach((field, index) => add(`fields.${index}.target`, field.target));
|
|
487
|
+
break;
|
|
488
|
+
case "extractList":
|
|
489
|
+
add("item", step.item);
|
|
490
|
+
add("next", step.next);
|
|
491
|
+
step.fields.forEach((field, index) => add(`fields.${index}.target`, field.target));
|
|
492
|
+
break;
|
|
493
|
+
case "login":
|
|
494
|
+
add("username", step.username);
|
|
495
|
+
add("password", step.password);
|
|
496
|
+
add("submit", step.submit);
|
|
497
|
+
add("success", step.success);
|
|
498
|
+
break;
|
|
499
|
+
case "if":
|
|
500
|
+
case "while":
|
|
501
|
+
add("elementExists", step.elementExists);
|
|
502
|
+
break;
|
|
503
|
+
case "forEach":
|
|
504
|
+
add("elements", step.elements);
|
|
505
|
+
break;
|
|
506
|
+
default:
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
if (step.verify && "target" in step.verify)
|
|
510
|
+
add("verify.target", step.verify.target);
|
|
511
|
+
return found;
|
|
512
|
+
}
|
|
513
|
+
function stepExpressions2(step) {
|
|
514
|
+
const found = [];
|
|
515
|
+
const add = (field, value) => {
|
|
516
|
+
if (value !== undefined)
|
|
517
|
+
found.push([field, value]);
|
|
518
|
+
};
|
|
519
|
+
switch (step.action) {
|
|
520
|
+
case "navigate":
|
|
521
|
+
add("url", step.url);
|
|
522
|
+
break;
|
|
523
|
+
case "type":
|
|
524
|
+
add("text", step.text);
|
|
525
|
+
break;
|
|
526
|
+
case "select":
|
|
527
|
+
step.values.forEach((value, index) => add(`values.${index}`, value));
|
|
528
|
+
break;
|
|
529
|
+
case "waitFor":
|
|
530
|
+
add("text", step.text);
|
|
531
|
+
add("urlContains", step.urlContains);
|
|
532
|
+
break;
|
|
533
|
+
case "if":
|
|
534
|
+
case "while":
|
|
535
|
+
add("condition", step.condition);
|
|
536
|
+
break;
|
|
537
|
+
case "forEach":
|
|
538
|
+
add("in", step.in);
|
|
539
|
+
break;
|
|
540
|
+
case "set":
|
|
541
|
+
add("value", step.value);
|
|
542
|
+
break;
|
|
543
|
+
case "log":
|
|
544
|
+
add("message", step.message);
|
|
545
|
+
break;
|
|
546
|
+
case "call":
|
|
547
|
+
for (const [arg, value] of Object.entries(step.args ?? {}))
|
|
548
|
+
add(`args.${arg}`, value);
|
|
549
|
+
break;
|
|
550
|
+
default:
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
const verify = step.verify;
|
|
554
|
+
if (verify?.kind === "urlContains" || verify?.kind === "valueEquals")
|
|
555
|
+
add("verify.value", verify.value);
|
|
556
|
+
if (verify?.kind === "textPresent")
|
|
557
|
+
add("verify.text", verify.text);
|
|
558
|
+
return found;
|
|
559
|
+
}
|
|
560
|
+
function visitExpression2(expression, visit, depth = 1) {
|
|
561
|
+
visit(expression, depth);
|
|
562
|
+
if (expression === null || typeof expression !== "object")
|
|
563
|
+
return;
|
|
564
|
+
if ("list" in expression)
|
|
565
|
+
for (const item of expression.list)
|
|
566
|
+
visitExpression2(item, visit, depth + 1);
|
|
567
|
+
else if ("object" in expression)
|
|
568
|
+
for (const item of Object.values(expression.object))
|
|
569
|
+
visitExpression2(item, visit, depth + 1);
|
|
570
|
+
else if ("op" in expression)
|
|
571
|
+
for (const arg of expression.args)
|
|
572
|
+
visitExpression2(arg, visit, depth + 1);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// src/script/fingerprint.ts
|
|
576
|
+
var RECORDING_ACTION_OF2 = {
|
|
577
|
+
click: "click",
|
|
578
|
+
doubleClick: "click",
|
|
579
|
+
type: "type",
|
|
580
|
+
typeSecret: "secret_fill",
|
|
581
|
+
pressKey: "key",
|
|
582
|
+
scroll: "scroll",
|
|
583
|
+
navigate: "navigate",
|
|
584
|
+
focusWindow: "focus_window"
|
|
585
|
+
};
|
|
586
|
+
function soleRoleMethod(ref) {
|
|
587
|
+
if (!ref || "element" in ref || ref.frame || ref.methods.length !== 1)
|
|
588
|
+
return;
|
|
589
|
+
const [method] = ref.methods;
|
|
590
|
+
return method?.kind === "role" && method.enabled !== false ? method : undefined;
|
|
591
|
+
}
|
|
592
|
+
function stepTarget(step) {
|
|
593
|
+
return "target" in step ? step.target : undefined;
|
|
594
|
+
}
|
|
595
|
+
function uiStepFingerprint2(step) {
|
|
596
|
+
const target = stepTarget(step);
|
|
597
|
+
const recordingAction = RECORDING_ACTION_OF2[step.action];
|
|
598
|
+
const url = step.action === "navigate" ? step.url : undefined;
|
|
599
|
+
const app = step.action === "focusWindow" ? step.app : undefined;
|
|
600
|
+
const title = step.action === "focusWindow" ? step.title : undefined;
|
|
601
|
+
const role = soleRoleMethod(target);
|
|
602
|
+
const targets = stepTargets2(step);
|
|
603
|
+
const onlyOwnTarget = targets.every(([field]) => field === "target");
|
|
604
|
+
if (recordingAction && onlyOwnTarget && (target === undefined || role) && (url === undefined || typeof url === "string")) {
|
|
605
|
+
return targetFingerprint2({
|
|
606
|
+
action: recordingAction,
|
|
607
|
+
...role ? {
|
|
608
|
+
target: {
|
|
609
|
+
role: role.role,
|
|
610
|
+
name: role.name,
|
|
611
|
+
nth: role.nth ?? 0,
|
|
612
|
+
...role.app === undefined ? {} : { app: role.app },
|
|
613
|
+
...role.window === undefined ? {} : { window: role.window }
|
|
614
|
+
}
|
|
615
|
+
} : {},
|
|
616
|
+
...url === undefined ? {} : { url },
|
|
617
|
+
...app === undefined ? {} : { app },
|
|
618
|
+
...title === undefined ? {} : { title }
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
return sha256Hex2(canonicalJson2(["ui-script/1", step.action, targets, url ?? null, app ?? null, title ?? null]));
|
|
622
|
+
}
|
|
623
|
+
function withFingerprint2(step) {
|
|
624
|
+
return { ...step, fingerprint: uiStepFingerprint2(step) };
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/script/parse.ts
|
|
628
|
+
class UiScriptError2 extends Error {
|
|
629
|
+
code;
|
|
630
|
+
path;
|
|
631
|
+
constructor(code, message, path) {
|
|
632
|
+
super(message);
|
|
633
|
+
this.code = code;
|
|
634
|
+
this.path = path;
|
|
635
|
+
this.name = "UiScriptError";
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
var UI_EXPRESSION_ARITY2 = {
|
|
639
|
+
eq: [2, 2],
|
|
640
|
+
ne: [2, 2],
|
|
641
|
+
lt: [2, 2],
|
|
642
|
+
le: [2, 2],
|
|
643
|
+
gt: [2, 2],
|
|
644
|
+
ge: [2, 2],
|
|
645
|
+
and: [2, 16],
|
|
646
|
+
or: [2, 16],
|
|
647
|
+
not: [1, 1],
|
|
648
|
+
add: [2, 16],
|
|
649
|
+
sub: [2, 2],
|
|
650
|
+
mul: [2, 16],
|
|
651
|
+
div: [2, 2],
|
|
652
|
+
mod: [2, 2],
|
|
653
|
+
neg: [1, 1],
|
|
654
|
+
abs: [1, 1],
|
|
655
|
+
round: [1, 2],
|
|
656
|
+
min: [1, 16],
|
|
657
|
+
max: [1, 16],
|
|
658
|
+
concat: [1, 16],
|
|
659
|
+
contains: [2, 2],
|
|
660
|
+
startsWith: [2, 2],
|
|
661
|
+
endsWith: [2, 2],
|
|
662
|
+
lower: [1, 1],
|
|
663
|
+
upper: [1, 1],
|
|
664
|
+
trim: [1, 1],
|
|
665
|
+
replace: [3, 3],
|
|
666
|
+
split: [2, 2],
|
|
667
|
+
join: [1, 2],
|
|
668
|
+
length: [1, 1],
|
|
669
|
+
toNumber: [1, 1],
|
|
670
|
+
toText: [1, 1],
|
|
671
|
+
toBoolean: [1, 1],
|
|
672
|
+
isEmpty: [1, 1],
|
|
673
|
+
coalesce: [1, 16],
|
|
674
|
+
if: [3, 3],
|
|
675
|
+
get: [2, 2],
|
|
676
|
+
now: [0, 0],
|
|
677
|
+
formatDate: [1, 2],
|
|
678
|
+
addDays: [2, 2]
|
|
679
|
+
};
|
|
680
|
+
function parseUiScript2(value, options = {}) {
|
|
681
|
+
const raw = readJson(value);
|
|
682
|
+
const parsed = uiScriptSchema2.safeParse(raw);
|
|
683
|
+
if (!parsed.success) {
|
|
684
|
+
const issue = parsed.error.issues[0];
|
|
685
|
+
const where = issue?.path.map(String).join(".") ?? "";
|
|
686
|
+
throw new UiScriptError2("INVALID_SCRIPT", `The UI script is not valid at ${where || "the top"}: ${issue?.message ?? "unknown problem"}`, where || undefined);
|
|
687
|
+
}
|
|
688
|
+
checkScript(parsed.data, options);
|
|
689
|
+
return parsed.data;
|
|
690
|
+
}
|
|
691
|
+
function safeParseUiScript2(value, options = {}) {
|
|
692
|
+
try {
|
|
693
|
+
return { success: true, script: parseUiScript2(value, options) };
|
|
694
|
+
} catch (error) {
|
|
695
|
+
if (error instanceof UiScriptError2)
|
|
696
|
+
return { success: false, error };
|
|
697
|
+
throw error;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
function readJson(value) {
|
|
701
|
+
let raw = value;
|
|
702
|
+
if (typeof value === "string") {
|
|
703
|
+
if (new TextEncoder().encode(value).length > MAX_SCRIPT_BYTES2)
|
|
704
|
+
tooLarge();
|
|
705
|
+
try {
|
|
706
|
+
raw = JSON.parse(value);
|
|
707
|
+
} catch {
|
|
708
|
+
throw new UiScriptError2("INVALID_SCRIPT", "The UI script is not valid JSON");
|
|
709
|
+
}
|
|
710
|
+
} else if (jsonByteLength2(value) > MAX_SCRIPT_BYTES2) {
|
|
711
|
+
tooLarge();
|
|
712
|
+
}
|
|
713
|
+
if (jsonDepth(raw) > MAX_JSON_DEPTH) {
|
|
714
|
+
throw new UiScriptError2("INVALID_SCRIPT", `The UI script is nested deeper than ${MAX_JSON_DEPTH} levels`);
|
|
715
|
+
}
|
|
716
|
+
return raw;
|
|
717
|
+
}
|
|
718
|
+
var MAX_JSON_DEPTH = 256;
|
|
719
|
+
function jsonDepth(value) {
|
|
720
|
+
let deepest = 0;
|
|
721
|
+
const stack = [[value, 1]];
|
|
722
|
+
while (stack.length > 0) {
|
|
723
|
+
const [item, depth] = stack.pop() ?? [null, 0];
|
|
724
|
+
if (item === null || typeof item !== "object")
|
|
725
|
+
continue;
|
|
726
|
+
deepest = Math.max(deepest, depth);
|
|
727
|
+
if (deepest > MAX_JSON_DEPTH)
|
|
728
|
+
return deepest;
|
|
729
|
+
for (const child of Object.values(item))
|
|
730
|
+
stack.push([child, depth + 1]);
|
|
731
|
+
}
|
|
732
|
+
return deepest;
|
|
733
|
+
}
|
|
734
|
+
function tooLarge() {
|
|
735
|
+
throw new UiScriptError2("SCRIPT_TOO_LARGE", `The UI script is larger than ${MAX_SCRIPT_BYTES2} bytes`);
|
|
736
|
+
}
|
|
737
|
+
function checkScript(script, options) {
|
|
738
|
+
const elements = script.elements ?? {};
|
|
739
|
+
if (Object.keys(elements).length > MAX_SCRIPT_ELEMENTS2) {
|
|
740
|
+
throw new UiScriptError2("INVALID_SCRIPT", `A UI script pins at most ${MAX_SCRIPT_ELEMENTS2} elements`, "elements");
|
|
741
|
+
}
|
|
742
|
+
const inputs = uniqueNames(script.inputs, "inputs");
|
|
743
|
+
uniqueNames(script.outputs, "outputs");
|
|
744
|
+
uniqueNames(script.variables, "variables");
|
|
745
|
+
const checkExpression = (expression, where) => {
|
|
746
|
+
visitExpression2(expression, (node, depth) => {
|
|
747
|
+
if (depth > MAX_EXPRESSION_DEPTH2) {
|
|
748
|
+
throw new UiScriptError2("INVALID_SCRIPT", `An expression is nested deeper than ${MAX_EXPRESSION_DEPTH2}`, where);
|
|
749
|
+
}
|
|
750
|
+
if (typeof node === "string" && containsCredential(node)) {
|
|
751
|
+
throw new UiScriptError2("CREDENTIAL_IN_SCRIPT", "The UI script holds a credential in a value", where);
|
|
752
|
+
}
|
|
753
|
+
if (node === null || typeof node !== "object")
|
|
754
|
+
return;
|
|
755
|
+
if ("input" in node && !inputs.has(node.input)) {
|
|
756
|
+
throw new UiScriptError2("UNKNOWN_INPUT", `The input "${node.input}" is not declared`, where);
|
|
757
|
+
}
|
|
758
|
+
if ("op" in node) {
|
|
759
|
+
const [fewest, most] = UI_EXPRESSION_ARITY2[node.op];
|
|
760
|
+
if (node.args.length < fewest || node.args.length > most) {
|
|
761
|
+
throw new UiScriptError2("INVALID_SCRIPT", `The operator "${node.op}" takes ${fewest === most ? fewest : `${fewest} to ${most}`} arguments`, where);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
script.inputs?.forEach((input, index) => {
|
|
767
|
+
if (input.default !== undefined)
|
|
768
|
+
checkExpression(input.default, `inputs.${index}.default`);
|
|
769
|
+
});
|
|
770
|
+
script.outputs?.forEach((output, index) => checkExpression(output.value, `outputs.${index}.value`));
|
|
771
|
+
script.variables?.forEach((variable, index) => {
|
|
772
|
+
if (variable.initial !== undefined)
|
|
773
|
+
checkExpression(variable.initial, `variables.${index}.initial`);
|
|
774
|
+
});
|
|
775
|
+
checkScriptText(script);
|
|
776
|
+
if (options.resolved) {
|
|
777
|
+
for (const [key, element] of Object.entries(elements)) {
|
|
778
|
+
if (!element.target) {
|
|
779
|
+
throw new UiScriptError2("UNRESOLVED", `The element "${key}" has no target`, `elements.${key}`);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
const ids = new Set;
|
|
784
|
+
let count = 0;
|
|
785
|
+
for (const { step, path, depth } of walkSteps2(script)) {
|
|
786
|
+
count += 1;
|
|
787
|
+
if (count > MAX_SCRIPT_STEPS2) {
|
|
788
|
+
throw new UiScriptError2("TOO_MANY_STEPS", `A UI script has at most ${MAX_SCRIPT_STEPS2} steps`, path);
|
|
789
|
+
}
|
|
790
|
+
if (depth > MAX_FLOW_DEPTH2) {
|
|
791
|
+
throw new UiScriptError2("INVALID_SCRIPT", `Flow blocks nest at most ${MAX_FLOW_DEPTH2} deep`, path);
|
|
792
|
+
}
|
|
793
|
+
if (ids.has(step.id)) {
|
|
794
|
+
throw new UiScriptError2("DUPLICATE_STEP_ID", `Step id ${step.id} is used twice`, path);
|
|
795
|
+
}
|
|
796
|
+
ids.add(step.id);
|
|
797
|
+
if (options.resolved && step.action === "call") {
|
|
798
|
+
throw new UiScriptError2("UNRESOLVED", `Step ${step.id} calls a shared sequence that was not inlined`, path);
|
|
799
|
+
}
|
|
800
|
+
checkStepShape(step, path);
|
|
801
|
+
for (const [field, ref] of stepTargets2(step)) {
|
|
802
|
+
if ("element" in ref && !Object.hasOwn(elements, ref.element)) {
|
|
803
|
+
throw new UiScriptError2("UNKNOWN_ELEMENT", `Step ${step.id} uses the element "${ref.element}", which the script does not pin`, `${path}.${field}`);
|
|
804
|
+
}
|
|
805
|
+
if (!("element" in ref))
|
|
806
|
+
refuseCredentialText(targetText(ref), `${path}.${field}`);
|
|
807
|
+
}
|
|
808
|
+
for (const [field, expression] of stepExpressions2(step))
|
|
809
|
+
checkExpression(expression, `${path}.${field}`);
|
|
810
|
+
checkStepText(step, path);
|
|
811
|
+
if (step.fingerprint !== undefined && step.fingerprint !== uiStepFingerprint2(step)) {
|
|
812
|
+
throw new UiScriptError2("FINGERPRINT_MISMATCH", `Step ${step.id} was changed after it was recorded`, path);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
function uniqueNames(list, where) {
|
|
817
|
+
const names = new Set;
|
|
818
|
+
list?.forEach(({ name }, index) => {
|
|
819
|
+
if (names.has(name)) {
|
|
820
|
+
throw new UiScriptError2("INVALID_SCRIPT", `The name "${name}" is declared twice`, `${where}.${index}`);
|
|
821
|
+
}
|
|
822
|
+
names.add(name);
|
|
823
|
+
});
|
|
824
|
+
return names;
|
|
825
|
+
}
|
|
826
|
+
function exactlyOne(step, path, fields) {
|
|
827
|
+
const given = Object.entries(fields).filter(([, value]) => value !== undefined);
|
|
828
|
+
if (given.length !== 1) {
|
|
829
|
+
throw new UiScriptError2("INVALID_SCRIPT", `Step ${step.id} (${step.action}) needs exactly one of ${Object.keys(fields).join(", ")}`, path);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
function checkStepShape(step, path) {
|
|
833
|
+
const refuse = (message) => {
|
|
834
|
+
throw new UiScriptError2("INVALID_SCRIPT", `Step ${step.id} (${step.action}): ${message}`, path);
|
|
835
|
+
};
|
|
836
|
+
switch (step.action) {
|
|
837
|
+
case "navigate":
|
|
838
|
+
if (typeof step.url === "string" && !isHttpUrl(step.url))
|
|
839
|
+
refuse("the URL must be an absolute http(s) URL");
|
|
840
|
+
break;
|
|
841
|
+
case "waitFor":
|
|
842
|
+
exactlyOne(step, path, {
|
|
843
|
+
target: step.target,
|
|
844
|
+
text: step.text,
|
|
845
|
+
urlContains: step.urlContains,
|
|
846
|
+
milliseconds: step.milliseconds
|
|
847
|
+
});
|
|
848
|
+
if (step.state !== undefined && step.target === undefined)
|
|
849
|
+
refuse("state needs a target");
|
|
850
|
+
break;
|
|
851
|
+
case "if":
|
|
852
|
+
case "while":
|
|
853
|
+
exactlyOne(step, path, { condition: step.condition, elementExists: step.elementExists });
|
|
854
|
+
break;
|
|
855
|
+
case "forEach":
|
|
856
|
+
exactlyOne(step, path, { in: step.in, elements: step.elements });
|
|
857
|
+
if (step.index !== undefined && step.index === step.as)
|
|
858
|
+
refuse("the item and the index need different names");
|
|
859
|
+
break;
|
|
860
|
+
case "type":
|
|
861
|
+
if (step.masked === true && step.text !== undefined)
|
|
862
|
+
refuse("a masked step carries no text");
|
|
863
|
+
break;
|
|
864
|
+
case "scroll":
|
|
865
|
+
if (step.to !== undefined && (step.target !== undefined || step.dx !== undefined || step.dy !== undefined)) {
|
|
866
|
+
refuse("to scrolls the page and cannot be combined with a target or an offset");
|
|
867
|
+
}
|
|
868
|
+
break;
|
|
869
|
+
default:
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
function isHttpUrl(text) {
|
|
874
|
+
if (text.length > MAX_URL_LENGTH2)
|
|
875
|
+
return false;
|
|
876
|
+
try {
|
|
877
|
+
const url = new URL(text);
|
|
878
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
879
|
+
} catch {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
function targetText(target) {
|
|
884
|
+
const texts = [...target.frame ?? []];
|
|
885
|
+
for (const method of target.methods) {
|
|
886
|
+
switch (method.kind) {
|
|
887
|
+
case "role":
|
|
888
|
+
texts.push(method.role, method.name, method.app, method.window);
|
|
889
|
+
break;
|
|
890
|
+
case "css":
|
|
891
|
+
texts.push(method.selector);
|
|
892
|
+
break;
|
|
893
|
+
case "testId":
|
|
894
|
+
texts.push(method.value, method.attribute);
|
|
895
|
+
break;
|
|
896
|
+
case "xpath":
|
|
897
|
+
texts.push(method.xpath);
|
|
898
|
+
break;
|
|
899
|
+
case "fuzzy":
|
|
900
|
+
texts.push(method.role, method.name);
|
|
901
|
+
break;
|
|
902
|
+
case "anchor":
|
|
903
|
+
texts.push(method.role, method.anchor.kind === "text" ? method.anchor.text : method.anchor.name);
|
|
904
|
+
if (method.anchor.kind === "role")
|
|
905
|
+
texts.push(method.anchor.role);
|
|
906
|
+
break;
|
|
907
|
+
default:
|
|
908
|
+
texts.push(method.text);
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return texts.filter((text) => text !== undefined);
|
|
913
|
+
}
|
|
914
|
+
function refuseCredentialText(texts, where) {
|
|
915
|
+
if (texts.some((text) => containsCredential(text))) {
|
|
916
|
+
throw new UiScriptError2("CREDENTIAL_IN_SCRIPT", "The UI script holds a credential in a stored text", where);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
function checkScriptText(script) {
|
|
920
|
+
refuseCredentialText([script.name, script.application?.name, script.application?.urlPattern].filter((text) => text !== undefined), "name");
|
|
921
|
+
for (const [list, where] of [
|
|
922
|
+
[script.inputs, "inputs"],
|
|
923
|
+
[script.outputs, "outputs"]
|
|
924
|
+
]) {
|
|
925
|
+
list?.forEach((item, index) => {
|
|
926
|
+
if (item.description !== undefined)
|
|
927
|
+
refuseCredentialText([item.description], `${where}.${index}.description`);
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
for (const [key, element] of Object.entries(script.elements ?? {})) {
|
|
931
|
+
refuseCredentialText([element.name, ...element.target ? targetText(element.target) : []].filter((text) => text !== undefined), `elements.${key}`);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
function checkStepText(step, path) {
|
|
935
|
+
if (step.action === "focusWindow") {
|
|
936
|
+
refuseCredentialText(step.title === undefined ? [step.app] : [step.app, step.title], path);
|
|
937
|
+
}
|
|
938
|
+
for (const [field, text] of [
|
|
939
|
+
["intent", step.intent],
|
|
940
|
+
["note", step.note]
|
|
941
|
+
]) {
|
|
942
|
+
if (text !== undefined && containsCredential(text)) {
|
|
943
|
+
throw new UiScriptError2("CREDENTIAL_IN_SCRIPT", `Step ${step.id} holds a credential in its ${field}`, path);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
if (step.action === "navigate" && typeof step.url === "string") {
|
|
947
|
+
let userInfo = false;
|
|
948
|
+
try {
|
|
949
|
+
const url = new URL(step.url);
|
|
950
|
+
userInfo = Boolean(url.username || url.password);
|
|
951
|
+
} catch {
|
|
952
|
+
userInfo = false;
|
|
953
|
+
}
|
|
954
|
+
if (userInfo || containsCredentialInUrl(step.url)) {
|
|
955
|
+
throw new UiScriptError2("CREDENTIAL_IN_SCRIPT", `Step ${step.id} holds a credential in its URL`, `${path}.url`);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
// src/script/hash.ts
|
|
960
|
+
var UI_SCRIPT_SCHEMA_HASH2 = "e6860649ad1cba906fb704ce4b62b3ea4380203e6628c809571602f4d0947884";
|
|
961
|
+
function schemaHashOf2(jsonSchema) {
|
|
962
|
+
return sha256Hex2(canonicalJson2(jsonSchema));
|
|
963
|
+
}
|
|
964
|
+
// src/script/json-schema.ts
|
|
965
|
+
import { z as z2 } from "zod";
|
|
966
|
+
var UI_SCRIPT_SCHEMA_TITLE2 = "FluidGrids UI script v1";
|
|
967
|
+
function uiScriptJsonSchema2() {
|
|
968
|
+
const generated = z2.toJSONSchema(uiScriptSchema2, {
|
|
969
|
+
target: "draft-2020-12",
|
|
970
|
+
io: "input",
|
|
971
|
+
unrepresentable: "throw",
|
|
972
|
+
metadata: uiScriptRegistry2
|
|
973
|
+
});
|
|
974
|
+
const { $schema, ...rest } = generated;
|
|
975
|
+
return { $schema, title: UI_SCRIPT_SCHEMA_TITLE2, ...rest };
|
|
976
|
+
}
|
|
977
|
+
// src/script/capabilities.ts
|
|
978
|
+
var CAPABILITY_IDS2 = [
|
|
979
|
+
"script:1",
|
|
980
|
+
...UI_STEP_ACTIONS2.map((action) => `action:${action}`),
|
|
981
|
+
...UI_TARGET_METHOD_KINDS2.map((kind) => `target:${kind}`),
|
|
982
|
+
"target:frame",
|
|
983
|
+
"step:verify",
|
|
984
|
+
"step:retry",
|
|
985
|
+
"step:breakpoint",
|
|
986
|
+
"input:direct",
|
|
987
|
+
"input:hardware"
|
|
988
|
+
].sort();
|
|
989
|
+
var SCRIPT_CAPABILITY2 = "script:1";
|
|
990
|
+
function targetCapabilities(target, into) {
|
|
991
|
+
for (const method of target.methods)
|
|
992
|
+
if (method.enabled !== false)
|
|
993
|
+
into.add(`target:${method.kind}`);
|
|
994
|
+
if (target.frame)
|
|
995
|
+
into.add("target:frame");
|
|
996
|
+
}
|
|
997
|
+
function requiredCapabilities2(script) {
|
|
998
|
+
const required = new Set([SCRIPT_CAPABILITY2]);
|
|
999
|
+
const elements = script.elements ?? {};
|
|
1000
|
+
const inputMethods = [script.settings?.inputMethod];
|
|
1001
|
+
const skipped = [];
|
|
1002
|
+
for (const { step, path } of walkSteps2(script)) {
|
|
1003
|
+
if (step.disabled === true)
|
|
1004
|
+
skipped.push(`${path}.`);
|
|
1005
|
+
if (step.disabled === true || skipped.some((prefix) => path.startsWith(prefix)))
|
|
1006
|
+
continue;
|
|
1007
|
+
required.add(`action:${step.action}`);
|
|
1008
|
+
for (const [, ref] of stepTargets2(step)) {
|
|
1009
|
+
const target = "element" in ref ? elements[ref.element]?.target : ref;
|
|
1010
|
+
if (target)
|
|
1011
|
+
targetCapabilities(target, required);
|
|
1012
|
+
}
|
|
1013
|
+
if (step.verify)
|
|
1014
|
+
required.add("step:verify");
|
|
1015
|
+
if (step.retry)
|
|
1016
|
+
required.add("step:retry");
|
|
1017
|
+
if (step.breakpoint === true)
|
|
1018
|
+
required.add("step:breakpoint");
|
|
1019
|
+
inputMethods.push(step.inputMethod);
|
|
1020
|
+
}
|
|
1021
|
+
for (const method of inputMethods) {
|
|
1022
|
+
if (method === "direct" || method === "hardware")
|
|
1023
|
+
required.add(`input:${method}`);
|
|
1024
|
+
}
|
|
1025
|
+
return [...required].sort();
|
|
1026
|
+
}
|
|
1027
|
+
function missingCapabilities2(script, supported) {
|
|
1028
|
+
const have = new Set(supported);
|
|
1029
|
+
return requiredCapabilities2(script).filter((id) => !have.has(id));
|
|
1030
|
+
}
|
|
1031
|
+
// src/script/describe.ts
|
|
1032
|
+
var UI_SCRIPT_STEP_KEY_PREFIX2 = "fluidgrids.uiScript.step.";
|
|
1033
|
+
var UI_SCRIPT_STEP_MESSAGES2 = {
|
|
1034
|
+
navigate: "Go to {{url}}",
|
|
1035
|
+
goBack: "Go back",
|
|
1036
|
+
reload: "Reload the page",
|
|
1037
|
+
closeTab: "Close the tab",
|
|
1038
|
+
click: "Click {{target}}",
|
|
1039
|
+
rightClick: "Right-click {{target}}",
|
|
1040
|
+
doubleClick: "Double-click {{target}}",
|
|
1041
|
+
rightDoubleClick: "Right double-click {{target}}",
|
|
1042
|
+
hover: "Point at {{target}}",
|
|
1043
|
+
type: "Type {{value}} into {{target}}",
|
|
1044
|
+
typeFocused: "Type {{value}}",
|
|
1045
|
+
typeMasked: "Type a hidden value into {{target}}",
|
|
1046
|
+
typeMaskedFocused: "Type a hidden value",
|
|
1047
|
+
typeSecret: "Type a secret into {{target}}",
|
|
1048
|
+
clear: "Clear {{target}}",
|
|
1049
|
+
select: "Choose {{value}} in {{target}}",
|
|
1050
|
+
check: "Tick {{target}}",
|
|
1051
|
+
uncheck: "Untick {{target}}",
|
|
1052
|
+
pressKey: "Press {{keys}}",
|
|
1053
|
+
scrollTop: "Scroll to the top",
|
|
1054
|
+
scrollBottom: "Scroll to the bottom",
|
|
1055
|
+
scrollTo: "Scroll to {{target}}",
|
|
1056
|
+
scrollBy: "Scroll by {{dx}}, {{dy}}",
|
|
1057
|
+
scrollInside: "Scroll {{target}} by {{dx}}, {{dy}}",
|
|
1058
|
+
waitFor: "Wait for {{target}}",
|
|
1059
|
+
waitForGone: "Wait for {{target}} to go away",
|
|
1060
|
+
waitForText: "Wait for the text {{value}}",
|
|
1061
|
+
waitForUrl: "Wait for the address to contain {{value}}",
|
|
1062
|
+
waitForTime: "Wait {{milliseconds}} ms",
|
|
1063
|
+
extract: "Read {{fields}}",
|
|
1064
|
+
extractList: "Read each {{target}}",
|
|
1065
|
+
getText: "Read the text of {{target}}",
|
|
1066
|
+
getValue: "Read the value of {{target}}",
|
|
1067
|
+
getAttribute: "Read {{attribute}} of {{target}}",
|
|
1068
|
+
elementExists: "Check whether {{target}} is there",
|
|
1069
|
+
getPageText: "Read the page text",
|
|
1070
|
+
getPageHtml: "Read the page HTML",
|
|
1071
|
+
screenshot: "Take a screenshot",
|
|
1072
|
+
screenshotOf: "Take a screenshot of {{target}}",
|
|
1073
|
+
login: "Sign in",
|
|
1074
|
+
focusWindow: "Switch to {{app}}",
|
|
1075
|
+
if: "If {{condition}}",
|
|
1076
|
+
ifElement: "If {{target}} is there",
|
|
1077
|
+
forEach: "For each item in {{value}}",
|
|
1078
|
+
forEachElement: "For each {{target}}",
|
|
1079
|
+
while: "While {{condition}}, at most {{max}} times",
|
|
1080
|
+
whileElement: "While {{target}} is there, at most {{max}} times",
|
|
1081
|
+
retryScope: "Try up to {{attempts}} times",
|
|
1082
|
+
set: "Set {{name}} to {{value}}",
|
|
1083
|
+
log: "Log {{value}}",
|
|
1084
|
+
call: "Run the shared sequence {{sequence}}"
|
|
1085
|
+
};
|
|
1086
|
+
function stepMessageKey2(name) {
|
|
1087
|
+
return `${UI_SCRIPT_STEP_KEY_PREFIX2}${name}`;
|
|
1088
|
+
}
|
|
1089
|
+
var MAX_SHOWN = 60;
|
|
1090
|
+
function shorten(text) {
|
|
1091
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
1092
|
+
return flat.length > MAX_SHOWN ? `${flat.slice(0, MAX_SHOWN - 1)}…` : flat;
|
|
1093
|
+
}
|
|
1094
|
+
function quoted(text) {
|
|
1095
|
+
return `"${shorten(text)}"`;
|
|
1096
|
+
}
|
|
1097
|
+
function describeTarget2(ref, elements = {}) {
|
|
1098
|
+
if (!ref)
|
|
1099
|
+
return quoted("?");
|
|
1100
|
+
if ("element" in ref) {
|
|
1101
|
+
const element = elements[ref.element];
|
|
1102
|
+
if (element?.name)
|
|
1103
|
+
return quoted(element.name);
|
|
1104
|
+
if (!element?.target)
|
|
1105
|
+
return quoted(ref.element);
|
|
1106
|
+
return describeTarget2(element.target);
|
|
1107
|
+
}
|
|
1108
|
+
const method = ref.methods.find((item) => item.enabled !== false) ?? ref.methods[0];
|
|
1109
|
+
switch (method?.kind) {
|
|
1110
|
+
case "role":
|
|
1111
|
+
case "fuzzy":
|
|
1112
|
+
return quoted(method.name);
|
|
1113
|
+
case "text":
|
|
1114
|
+
return quoted(method.text);
|
|
1115
|
+
case "testId":
|
|
1116
|
+
return quoted(method.value);
|
|
1117
|
+
case "anchor":
|
|
1118
|
+
return quoted(method.anchor.kind === "text" ? method.anchor.text : method.anchor.name);
|
|
1119
|
+
case "css":
|
|
1120
|
+
return quoted(method.selector);
|
|
1121
|
+
case "xpath":
|
|
1122
|
+
return quoted(method.xpath);
|
|
1123
|
+
default:
|
|
1124
|
+
return quoted("?");
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
function describeExpression2(expression) {
|
|
1128
|
+
if (expression === undefined || expression === null)
|
|
1129
|
+
return "…";
|
|
1130
|
+
if (typeof expression === "string")
|
|
1131
|
+
return quoted(expression);
|
|
1132
|
+
if (typeof expression === "number" || typeof expression === "boolean")
|
|
1133
|
+
return String(expression);
|
|
1134
|
+
if ("input" in expression)
|
|
1135
|
+
return `[${expression.input}]`;
|
|
1136
|
+
if ("var" in expression)
|
|
1137
|
+
return `[${expression.var}]`;
|
|
1138
|
+
return "…";
|
|
1139
|
+
}
|
|
1140
|
+
function fill(name, vars) {
|
|
1141
|
+
const fallback = UI_SCRIPT_STEP_MESSAGES2[name].replace(/\{\{(\w+)\}\}/g, (_match, variable) => String(vars[variable] ?? ""));
|
|
1142
|
+
return { key: stepMessageKey2(name), vars, fallback };
|
|
1143
|
+
}
|
|
1144
|
+
function describeStep2(step, elements = {}) {
|
|
1145
|
+
const target = (ref) => describeTarget2(ref, elements);
|
|
1146
|
+
switch (step.action) {
|
|
1147
|
+
case "navigate":
|
|
1148
|
+
return fill("navigate", { url: describeExpression2(step.url) });
|
|
1149
|
+
case "click":
|
|
1150
|
+
return fill(step.button === "right" ? "rightClick" : "click", { target: target(step.target) });
|
|
1151
|
+
case "doubleClick":
|
|
1152
|
+
return fill(step.button === "right" ? "rightDoubleClick" : "doubleClick", { target: target(step.target) });
|
|
1153
|
+
case "hover":
|
|
1154
|
+
case "clear":
|
|
1155
|
+
case "typeSecret":
|
|
1156
|
+
case "getText":
|
|
1157
|
+
case "getValue":
|
|
1158
|
+
case "elementExists":
|
|
1159
|
+
return fill(step.action, { target: target(step.target) });
|
|
1160
|
+
case "type": {
|
|
1161
|
+
if (!step.target)
|
|
1162
|
+
return fill(step.masked ? "typeMaskedFocused" : "typeFocused", step.masked ? {} : { value: describeExpression2(step.text) });
|
|
1163
|
+
return fill(step.masked ? "typeMasked" : "type", {
|
|
1164
|
+
target: target(step.target),
|
|
1165
|
+
...step.masked ? {} : { value: describeExpression2(step.text) }
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
case "select":
|
|
1169
|
+
return fill("select", {
|
|
1170
|
+
value: step.values.map(describeExpression2).join(", "),
|
|
1171
|
+
target: target(step.target)
|
|
1172
|
+
});
|
|
1173
|
+
case "check":
|
|
1174
|
+
return fill(step.checked === false ? "uncheck" : "check", { target: target(step.target) });
|
|
1175
|
+
case "pressKey":
|
|
1176
|
+
return fill("pressKey", { keys: step.keys.join("+") });
|
|
1177
|
+
case "scroll":
|
|
1178
|
+
if (step.target && (step.dx !== undefined || step.dy !== undefined)) {
|
|
1179
|
+
return fill("scrollInside", { target: target(step.target), dx: step.dx ?? 0, dy: step.dy ?? 0 });
|
|
1180
|
+
}
|
|
1181
|
+
if (step.target)
|
|
1182
|
+
return fill("scrollTo", { target: target(step.target) });
|
|
1183
|
+
if (step.dx !== undefined || step.dy !== undefined)
|
|
1184
|
+
return fill("scrollBy", { dx: step.dx ?? 0, dy: step.dy ?? 0 });
|
|
1185
|
+
return fill(step.to === "top" ? "scrollTop" : "scrollBottom", {});
|
|
1186
|
+
case "waitFor":
|
|
1187
|
+
if (step.target) {
|
|
1188
|
+
const gone = step.state === "hidden" || step.state === "detached";
|
|
1189
|
+
return fill(gone ? "waitForGone" : "waitFor", { target: target(step.target) });
|
|
1190
|
+
}
|
|
1191
|
+
if (step.text !== undefined)
|
|
1192
|
+
return fill("waitForText", { value: describeExpression2(step.text) });
|
|
1193
|
+
if (step.urlContains !== undefined)
|
|
1194
|
+
return fill("waitForUrl", { value: describeExpression2(step.urlContains) });
|
|
1195
|
+
return fill("waitForTime", { milliseconds: step.milliseconds ?? 0 });
|
|
1196
|
+
case "extract":
|
|
1197
|
+
return fill("extract", { fields: step.fields.map((field) => field.name).join(", ") });
|
|
1198
|
+
case "extractList":
|
|
1199
|
+
return fill("extractList", { target: target(step.item) });
|
|
1200
|
+
case "getAttribute":
|
|
1201
|
+
return fill("getAttribute", { attribute: step.attribute, target: target(step.target) });
|
|
1202
|
+
case "screenshot":
|
|
1203
|
+
return step.target ? fill("screenshotOf", { target: target(step.target) }) : fill("screenshot", {});
|
|
1204
|
+
case "focusWindow":
|
|
1205
|
+
return fill("focusWindow", { app: quoted(step.title ?? step.app) });
|
|
1206
|
+
case "if":
|
|
1207
|
+
return step.elementExists ? fill("ifElement", { target: target(step.elementExists) }) : fill("if", { condition: describeExpression2(step.condition) });
|
|
1208
|
+
case "forEach":
|
|
1209
|
+
return step.elements ? fill("forEachElement", { target: target(step.elements) }) : fill("forEach", { value: describeExpression2(step.in) });
|
|
1210
|
+
case "while":
|
|
1211
|
+
return step.elementExists ? fill("whileElement", { target: target(step.elementExists), max: step.maxIterations }) : fill("while", { condition: describeExpression2(step.condition), max: step.maxIterations });
|
|
1212
|
+
case "retryScope":
|
|
1213
|
+
return fill("retryScope", { attempts: step.attempts });
|
|
1214
|
+
case "set":
|
|
1215
|
+
return fill("set", { name: `[${step.name}]`, value: describeExpression2(step.value) });
|
|
1216
|
+
case "log":
|
|
1217
|
+
return fill("log", { value: describeExpression2(step.message) });
|
|
1218
|
+
case "call":
|
|
1219
|
+
return fill("call", { sequence: quoted(step.sequenceId) });
|
|
1220
|
+
default:
|
|
1221
|
+
return fill(step.action, {});
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
// src/script/adapters/browser-action-contract.ts
|
|
1225
|
+
var BROWSER_STEP_ACTIONS2 = [
|
|
1226
|
+
"navigate",
|
|
1227
|
+
"waitFor",
|
|
1228
|
+
"click",
|
|
1229
|
+
"type",
|
|
1230
|
+
"select",
|
|
1231
|
+
"check",
|
|
1232
|
+
"pressKey",
|
|
1233
|
+
"scroll",
|
|
1234
|
+
"extract",
|
|
1235
|
+
"extractList",
|
|
1236
|
+
"getPageText",
|
|
1237
|
+
"getPageHtml",
|
|
1238
|
+
"screenshot",
|
|
1239
|
+
"closeTab"
|
|
1240
|
+
];
|
|
1241
|
+
// src/script/adapters/from-browser-action.ts
|
|
1242
|
+
var LEGACY_ACTIONS = new Set(BROWSER_STEP_ACTIONS2);
|
|
1243
|
+
function isRecord(value) {
|
|
1244
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1245
|
+
}
|
|
1246
|
+
function text(value) {
|
|
1247
|
+
return typeof value === "string" && value.trim() ? value : undefined;
|
|
1248
|
+
}
|
|
1249
|
+
function css(selector) {
|
|
1250
|
+
return { methods: [{ kind: "css", selector: selector.trim() }] };
|
|
1251
|
+
}
|
|
1252
|
+
function intIn(value, min, max) {
|
|
1253
|
+
const number = typeof value === "string" && value.trim() ? Number(value) : value;
|
|
1254
|
+
return typeof number === "number" && Number.isInteger(number) && number >= min && number <= max ? number : undefined;
|
|
1255
|
+
}
|
|
1256
|
+
function readStepList(value, what) {
|
|
1257
|
+
let list = value;
|
|
1258
|
+
if (typeof value === "string") {
|
|
1259
|
+
try {
|
|
1260
|
+
list = JSON.parse(value);
|
|
1261
|
+
} catch {
|
|
1262
|
+
throw new UiScriptError2("INVALID_SCRIPT", `The ${what} are not valid JSON`);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
if (!Array.isArray(list) || list.length === 0) {
|
|
1266
|
+
throw new UiScriptError2("INVALID_SCRIPT", `The ${what} must be a non-empty list of steps`);
|
|
1267
|
+
}
|
|
1268
|
+
return list;
|
|
1269
|
+
}
|
|
1270
|
+
function fromBrowserActionSteps2(steps, options = {}) {
|
|
1271
|
+
const list = readStepList(steps, "Run in Browser steps");
|
|
1272
|
+
const script = {
|
|
1273
|
+
scriptVersion: 1,
|
|
1274
|
+
...options.name ? { name: options.name } : {},
|
|
1275
|
+
steps: list.map((step, index) => convertStep(step, index))
|
|
1276
|
+
};
|
|
1277
|
+
return parseUiScript2(script);
|
|
1278
|
+
}
|
|
1279
|
+
function convertStep(raw, index) {
|
|
1280
|
+
const where = `Step ${index + 1}`;
|
|
1281
|
+
const refuse = (message) => {
|
|
1282
|
+
throw new UiScriptError2("INVALID_SCRIPT", `${where}: ${message}`, String(index));
|
|
1283
|
+
};
|
|
1284
|
+
if (!isRecord(raw) || typeof raw.action !== "string" || !LEGACY_ACTIONS.has(raw.action)) {
|
|
1285
|
+
return refuse("has no known Run in Browser action");
|
|
1286
|
+
}
|
|
1287
|
+
const name = text(raw.name);
|
|
1288
|
+
if (name !== undefined && !NAME_PATTERN2.test(name)) {
|
|
1289
|
+
refuse(`the result name "${name.slice(0, 64)}" must be letters, digits or _ and start with a letter or _`);
|
|
1290
|
+
}
|
|
1291
|
+
const timeoutMs = intIn(raw.timeoutMs, 0, MAX_STEP_TIMEOUT_MS2);
|
|
1292
|
+
const note = text(raw.note)?.slice(0, MAX_INTENT_LENGTH2);
|
|
1293
|
+
const base = {
|
|
1294
|
+
id: `s${index + 1}`,
|
|
1295
|
+
...name === undefined ? {} : { saveAs: name },
|
|
1296
|
+
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
1297
|
+
...note === undefined ? {} : { note }
|
|
1298
|
+
};
|
|
1299
|
+
const selector = text(raw.selector);
|
|
1300
|
+
const needSelector = () => selector ? css(selector) : refuse(`${String(raw.action)} needs a selector`);
|
|
1301
|
+
const value = typeof raw.value === "string" ? raw.value : undefined;
|
|
1302
|
+
switch (raw.action) {
|
|
1303
|
+
case "navigate":
|
|
1304
|
+
return { ...base, action: "navigate", url: text(raw.url) ?? refuse("navigate needs a url") };
|
|
1305
|
+
case "waitFor":
|
|
1306
|
+
case "click": {
|
|
1307
|
+
const label = text(raw.text);
|
|
1308
|
+
if (raw.action === "waitFor" && !selector && label !== undefined)
|
|
1309
|
+
return { ...base, action: "waitFor", text: label };
|
|
1310
|
+
const target = selector ? css(selector) : label ? { methods: [{ kind: "text", text: label }] } : refuse(`${raw.action} needs a selector or text`);
|
|
1311
|
+
return raw.action === "click" ? { ...base, action: "click", target } : { ...base, action: "waitFor", target };
|
|
1312
|
+
}
|
|
1313
|
+
case "type":
|
|
1314
|
+
return {
|
|
1315
|
+
...base,
|
|
1316
|
+
action: "type",
|
|
1317
|
+
target: needSelector(),
|
|
1318
|
+
text: value ?? refuse("type needs a text value"),
|
|
1319
|
+
...raw.clear === false ? { clear: false } : {}
|
|
1320
|
+
};
|
|
1321
|
+
case "select":
|
|
1322
|
+
return { ...base, action: "select", target: needSelector(), values: [value ?? refuse("select needs a value")] };
|
|
1323
|
+
case "check":
|
|
1324
|
+
return { ...base, action: "check", target: needSelector(), ...raw.checked === false ? { checked: false } : {} };
|
|
1325
|
+
case "pressKey":
|
|
1326
|
+
return { ...base, action: "pressKey", keys: [text(raw.key) ?? refuse("pressKey needs a key")] };
|
|
1327
|
+
case "scroll":
|
|
1328
|
+
return selector ? { ...base, action: "scroll", target: css(selector) } : { ...base, action: "scroll", to: raw.to === "top" ? "top" : "bottom" };
|
|
1329
|
+
case "extract":
|
|
1330
|
+
return { ...base, action: "extract", fields: convertFields(raw.fields, refuse) };
|
|
1331
|
+
case "extractList": {
|
|
1332
|
+
const item = text(raw.itemSelector) ?? refuse("extractList needs an itemSelector");
|
|
1333
|
+
const maxItems = intIn(raw.maxItems, 1, MAX_LIST_ITEMS2);
|
|
1334
|
+
const maxPages = intIn(raw.maxPages, 1, MAX_LIST_PAGES2);
|
|
1335
|
+
const next = text(raw.paginateSelector);
|
|
1336
|
+
return {
|
|
1337
|
+
...base,
|
|
1338
|
+
action: "extractList",
|
|
1339
|
+
item: css(item),
|
|
1340
|
+
fields: convertFields(raw.fields, refuse),
|
|
1341
|
+
...maxItems === undefined ? {} : { maxItems },
|
|
1342
|
+
...next === undefined ? {} : { next: css(next) },
|
|
1343
|
+
...maxPages === undefined ? {} : { maxPages }
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
case "getPageText":
|
|
1347
|
+
return { ...base, action: "getPageText" };
|
|
1348
|
+
case "getPageHtml":
|
|
1349
|
+
return { ...base, action: "getPageHtml" };
|
|
1350
|
+
case "screenshot":
|
|
1351
|
+
return { ...base, action: "screenshot" };
|
|
1352
|
+
default:
|
|
1353
|
+
return { ...base, action: "closeTab" };
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
function convertFields(value, refuse) {
|
|
1357
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
1358
|
+
return refuse("needs at least one field");
|
|
1359
|
+
return value.map((field, index) => {
|
|
1360
|
+
if (!isRecord(field))
|
|
1361
|
+
return refuse(`field ${index + 1} needs a name and a selector`);
|
|
1362
|
+
const name = text(field.name);
|
|
1363
|
+
const selector = text(field.selector);
|
|
1364
|
+
if (!name || !selector)
|
|
1365
|
+
return refuse(`field ${index + 1} needs a name and a selector`);
|
|
1366
|
+
if (!NAME_PATTERN2.test(name)) {
|
|
1367
|
+
return refuse(`field name "${name.slice(0, 64)}" must be letters, digits or _ and start with a letter or _`);
|
|
1368
|
+
}
|
|
1369
|
+
const attribute = text(field.attribute);
|
|
1370
|
+
return {
|
|
1371
|
+
name,
|
|
1372
|
+
target: css(selector),
|
|
1373
|
+
...attribute === undefined ? {} : { attribute },
|
|
1374
|
+
...field.multiple === true ? { all: true } : {}
|
|
1375
|
+
};
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
// src/script/adapters/to-browser-action.ts
|
|
1379
|
+
class NotLowerable extends Error {
|
|
1380
|
+
}
|
|
1381
|
+
function stop() {
|
|
1382
|
+
throw new NotLowerable;
|
|
1383
|
+
}
|
|
1384
|
+
function toBrowserActionSteps2(script, options = {}) {
|
|
1385
|
+
try {
|
|
1386
|
+
return lower(script, options);
|
|
1387
|
+
} catch (error) {
|
|
1388
|
+
if (error instanceof NotLowerable)
|
|
1389
|
+
return null;
|
|
1390
|
+
throw error;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function lower(script, options) {
|
|
1394
|
+
if (script.cleanup || script.outputs?.length || script.variables?.length)
|
|
1395
|
+
stop();
|
|
1396
|
+
const settings = script.settings;
|
|
1397
|
+
if (settings?.inputMethod && settings.inputMethod !== "auto")
|
|
1398
|
+
stop();
|
|
1399
|
+
if (settings?.firstWaitMs !== undefined || settings?.waitMs !== undefined)
|
|
1400
|
+
stop();
|
|
1401
|
+
if (settings?.screenshots === "everyStep")
|
|
1402
|
+
stop();
|
|
1403
|
+
if (script.steps.length > LEGACY_MAX_BROWSER_STEPS2)
|
|
1404
|
+
stop();
|
|
1405
|
+
const context = {
|
|
1406
|
+
elements: script.elements ?? {},
|
|
1407
|
+
inputs: options.inputs ?? {},
|
|
1408
|
+
defaults: Object.fromEntries((script.inputs ?? []).map((input) => [input.name, input.default]))
|
|
1409
|
+
};
|
|
1410
|
+
const steps = script.steps.map((step) => lowerStep(step, context));
|
|
1411
|
+
if (jsonByteLength2(steps) > LEGACY_MAX_STEPS_BYTES2)
|
|
1412
|
+
stop();
|
|
1413
|
+
return steps;
|
|
1414
|
+
}
|
|
1415
|
+
function lowerStep(step, context) {
|
|
1416
|
+
if (step.disabled || step.breakpoint || step.verify || step.retry || step.onError === "continue")
|
|
1417
|
+
stop();
|
|
1418
|
+
if (step.screenshot === "always" || step.inputMethod && step.inputMethod !== "auto")
|
|
1419
|
+
stop();
|
|
1420
|
+
const common = {
|
|
1421
|
+
...step.saveAs === undefined ? {} : { name: step.saveAs },
|
|
1422
|
+
...step.timeoutMs === undefined ? {} : { timeoutMs: step.timeoutMs },
|
|
1423
|
+
...step.note === undefined ? {} : { note: step.note }
|
|
1424
|
+
};
|
|
1425
|
+
const selector = (ref) => cssOf(resolve(ref, context)) ?? stop();
|
|
1426
|
+
const value = (expression) => literal(expression, context) ?? stop();
|
|
1427
|
+
switch (step.action) {
|
|
1428
|
+
case "navigate": {
|
|
1429
|
+
if (step.waitUntil && step.waitUntil !== "load")
|
|
1430
|
+
stop();
|
|
1431
|
+
const url = value(step.url);
|
|
1432
|
+
if (!/^https?:\/\//i.test(url))
|
|
1433
|
+
stop();
|
|
1434
|
+
return { action: "navigate", ...common, url };
|
|
1435
|
+
}
|
|
1436
|
+
case "click": {
|
|
1437
|
+
if (step.button === "right")
|
|
1438
|
+
stop();
|
|
1439
|
+
return { action: "click", ...common, ...selectorOrText(resolve(step.target, context)) };
|
|
1440
|
+
}
|
|
1441
|
+
case "waitFor": {
|
|
1442
|
+
if (step.urlContains !== undefined || step.milliseconds !== undefined)
|
|
1443
|
+
stop();
|
|
1444
|
+
if (step.state && step.state !== "visible")
|
|
1445
|
+
stop();
|
|
1446
|
+
if (step.target)
|
|
1447
|
+
return { action: "waitFor", ...common, ...selectorOrText(resolve(step.target, context)) };
|
|
1448
|
+
return { action: "waitFor", ...common, text: value(step.text) };
|
|
1449
|
+
}
|
|
1450
|
+
case "type": {
|
|
1451
|
+
if (step.masked || step.pressEnter || step.delayMs !== undefined)
|
|
1452
|
+
stop();
|
|
1453
|
+
return {
|
|
1454
|
+
action: "type",
|
|
1455
|
+
...common,
|
|
1456
|
+
selector: selector(step.target),
|
|
1457
|
+
value: value(step.text),
|
|
1458
|
+
...step.clear === false ? { clear: false } : {}
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
case "select": {
|
|
1462
|
+
if (step.values.length !== 1)
|
|
1463
|
+
stop();
|
|
1464
|
+
return { action: "select", ...common, selector: selector(step.target), value: value(step.values[0]) };
|
|
1465
|
+
}
|
|
1466
|
+
case "check":
|
|
1467
|
+
return { action: "check", ...common, selector: selector(step.target), checked: step.checked !== false };
|
|
1468
|
+
case "pressKey": {
|
|
1469
|
+
const [key] = step.keys;
|
|
1470
|
+
if (step.keys.length !== 1 || step.target || key === undefined)
|
|
1471
|
+
stop();
|
|
1472
|
+
return { action: "pressKey", ...common, key };
|
|
1473
|
+
}
|
|
1474
|
+
case "scroll": {
|
|
1475
|
+
if (step.dx !== undefined || step.dy !== undefined)
|
|
1476
|
+
stop();
|
|
1477
|
+
if (step.target)
|
|
1478
|
+
return { action: "scroll", ...common, selector: selector(step.target) };
|
|
1479
|
+
return { action: "scroll", ...common, ...step.to === "top" ? { to: "top" } : {} };
|
|
1480
|
+
}
|
|
1481
|
+
case "extract":
|
|
1482
|
+
return { action: "extract", ...common, fields: step.fields.map((field) => lowerField(field, context)) };
|
|
1483
|
+
case "extractList":
|
|
1484
|
+
return {
|
|
1485
|
+
action: "extractList",
|
|
1486
|
+
...common,
|
|
1487
|
+
itemSelector: selector(step.item),
|
|
1488
|
+
fields: step.fields.map((field) => lowerField(field, context)),
|
|
1489
|
+
...step.maxItems === undefined ? {} : { maxItems: step.maxItems },
|
|
1490
|
+
...step.next ? { paginateSelector: selector(step.next) } : {},
|
|
1491
|
+
...step.maxPages === undefined ? {} : { maxPages: step.maxPages }
|
|
1492
|
+
};
|
|
1493
|
+
case "screenshot":
|
|
1494
|
+
if (step.target || step.fullPage)
|
|
1495
|
+
stop();
|
|
1496
|
+
return { action: "screenshot", ...common };
|
|
1497
|
+
case "getPageText":
|
|
1498
|
+
case "getPageHtml":
|
|
1499
|
+
case "closeTab":
|
|
1500
|
+
return { action: step.action, ...common };
|
|
1501
|
+
default:
|
|
1502
|
+
return stop();
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function lowerField(field, context) {
|
|
1506
|
+
if (field.attribute === "text" || field.attribute === "html" || field.attribute === "value")
|
|
1507
|
+
stop();
|
|
1508
|
+
return {
|
|
1509
|
+
name: field.name,
|
|
1510
|
+
selector: cssOf(resolve(field.target, context)) ?? stop(),
|
|
1511
|
+
...field.attribute === undefined ? {} : { attribute: field.attribute },
|
|
1512
|
+
...field.all ? { multiple: true } : {}
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function resolve(ref, context) {
|
|
1516
|
+
if (!ref)
|
|
1517
|
+
return stop();
|
|
1518
|
+
if ("element" in ref)
|
|
1519
|
+
return context.elements[ref.element]?.target ?? stop();
|
|
1520
|
+
return ref;
|
|
1521
|
+
}
|
|
1522
|
+
function cssOf(target) {
|
|
1523
|
+
const [method] = target.methods;
|
|
1524
|
+
if (target.frame || target.methods.length !== 1 || method?.enabled === false)
|
|
1525
|
+
return;
|
|
1526
|
+
return method?.kind === "css" ? method.selector : undefined;
|
|
1527
|
+
}
|
|
1528
|
+
function selectorOrText(target) {
|
|
1529
|
+
const selector = cssOf(target);
|
|
1530
|
+
if (selector !== undefined)
|
|
1531
|
+
return { selector };
|
|
1532
|
+
const [method] = target.methods;
|
|
1533
|
+
if (target.frame || target.methods.length !== 1 || method?.kind !== "text" || method.enabled === false || method.exact === true || (method.nth ?? 0) !== 0) {
|
|
1534
|
+
return stop();
|
|
1535
|
+
}
|
|
1536
|
+
return { text: method.text };
|
|
1537
|
+
}
|
|
1538
|
+
function literal(expression, context) {
|
|
1539
|
+
if (typeof expression === "string")
|
|
1540
|
+
return expression;
|
|
1541
|
+
if (typeof expression === "number" || typeof expression === "boolean")
|
|
1542
|
+
return String(expression);
|
|
1543
|
+
if (expression !== null && typeof expression === "object" && "input" in expression && !expression.path) {
|
|
1544
|
+
const supplied = context.inputs[expression.input];
|
|
1545
|
+
if (typeof supplied === "string")
|
|
1546
|
+
return supplied;
|
|
1547
|
+
if (typeof supplied === "number" || typeof supplied === "boolean")
|
|
1548
|
+
return String(supplied);
|
|
1549
|
+
if (supplied === undefined)
|
|
1550
|
+
return literal(context.defaults[expression.input], { ...context, defaults: {} });
|
|
1551
|
+
}
|
|
1552
|
+
return null;
|
|
1553
|
+
}
|
|
1554
|
+
// src/script/adapters/from-remote-browser.ts
|
|
1555
|
+
var ACTIONS = new Set([
|
|
1556
|
+
"navigate",
|
|
1557
|
+
"click",
|
|
1558
|
+
"type",
|
|
1559
|
+
"select",
|
|
1560
|
+
"press",
|
|
1561
|
+
"waitFor",
|
|
1562
|
+
"extract",
|
|
1563
|
+
"screenshot",
|
|
1564
|
+
"login"
|
|
1565
|
+
]);
|
|
1566
|
+
var STEP_KEYS = {
|
|
1567
|
+
navigate: ["url", "waitUntil"],
|
|
1568
|
+
click: ["selector"],
|
|
1569
|
+
type: ["selector", "text", "clear", "pressEnter"],
|
|
1570
|
+
select: ["selector", "values"],
|
|
1571
|
+
press: ["key"],
|
|
1572
|
+
waitFor: ["selector", "state", "urlContains", "milliseconds"],
|
|
1573
|
+
extract: ["fields"],
|
|
1574
|
+
screenshot: ["fullPage", "selector"],
|
|
1575
|
+
login: ["usernameSelector", "passwordSelector", "submitSelector", "successSelector"]
|
|
1576
|
+
};
|
|
1577
|
+
var WAIT_UNTIL = ["load", "domcontentloaded", "networkidle", "commit"];
|
|
1578
|
+
var WAIT_STATES = ["visible", "hidden", "attached", "detached"];
|
|
1579
|
+
function isRecord2(value) {
|
|
1580
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1581
|
+
}
|
|
1582
|
+
function given(value) {
|
|
1583
|
+
return value !== undefined && value !== null && value !== "";
|
|
1584
|
+
}
|
|
1585
|
+
function oneOf(list, value) {
|
|
1586
|
+
return list.find((item) => item === value);
|
|
1587
|
+
}
|
|
1588
|
+
function targetFromPlaywrightSelector2(raw, refuse) {
|
|
1589
|
+
const selector = raw.trim();
|
|
1590
|
+
if (!selector)
|
|
1591
|
+
return refuse("the selector is empty");
|
|
1592
|
+
if (selector.includes(">>"))
|
|
1593
|
+
return refuse(`the selector "${selector.slice(0, 80)}" chains engines with >>`);
|
|
1594
|
+
const engine = /^([a-zA-Z][\w-]*)=(.*)$/s.exec(selector);
|
|
1595
|
+
if (selector.startsWith("//") || selector.startsWith("(//")) {
|
|
1596
|
+
return { methods: [{ kind: "xpath", xpath: selector }] };
|
|
1597
|
+
}
|
|
1598
|
+
if (!engine)
|
|
1599
|
+
return { methods: [{ kind: "css", selector }] };
|
|
1600
|
+
const [, name = "", body = ""] = engine;
|
|
1601
|
+
const value = body.trim();
|
|
1602
|
+
if (!value)
|
|
1603
|
+
return refuse(`the selector "${selector.slice(0, 80)}" is empty after ${name}=`);
|
|
1604
|
+
const quoted = /^"(.*)"$/s.exec(value) ?? /^'(.*)'$/s.exec(value);
|
|
1605
|
+
switch (name) {
|
|
1606
|
+
case "css":
|
|
1607
|
+
return { methods: [{ kind: "css", selector: value }] };
|
|
1608
|
+
case "xpath":
|
|
1609
|
+
return { methods: [{ kind: "xpath", xpath: value }] };
|
|
1610
|
+
case "text":
|
|
1611
|
+
return {
|
|
1612
|
+
methods: [quoted ? { kind: "text", text: quoted[1] ?? "", exact: true } : { kind: "text", text: value }]
|
|
1613
|
+
};
|
|
1614
|
+
case "id":
|
|
1615
|
+
return { methods: [{ kind: "css", selector: `[id=${JSON.stringify(quoted?.[1] ?? value)}]` }] };
|
|
1616
|
+
case "data-testid":
|
|
1617
|
+
return { methods: [{ kind: "testId", value: quoted?.[1] ?? value }] };
|
|
1618
|
+
default:
|
|
1619
|
+
return refuse(`the selector engine "${name}" has no UI script equivalent`);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
function fromRemoteBrowserSteps2(steps, options = {}) {
|
|
1623
|
+
const list = readStepList(steps, "Remote Browser steps");
|
|
1624
|
+
const script = {
|
|
1625
|
+
scriptVersion: 1,
|
|
1626
|
+
...options.name ? { name: options.name } : {},
|
|
1627
|
+
steps: list.map((step, index) => convertStep2(step, index))
|
|
1628
|
+
};
|
|
1629
|
+
return parseUiScript2(script);
|
|
1630
|
+
}
|
|
1631
|
+
function bool(value, name, refuse) {
|
|
1632
|
+
if (!given(value))
|
|
1633
|
+
return;
|
|
1634
|
+
if (typeof value === "boolean")
|
|
1635
|
+
return value;
|
|
1636
|
+
if (typeof value === "string" && /^(true|false)$/i.test(value.trim()))
|
|
1637
|
+
return value.trim().toLowerCase() === "true";
|
|
1638
|
+
return refuse(`'${name}' must be true or false`);
|
|
1639
|
+
}
|
|
1640
|
+
function convertStep2(raw, index) {
|
|
1641
|
+
const where = `Step ${index + 1}`;
|
|
1642
|
+
const refuse = (message) => {
|
|
1643
|
+
throw new UiScriptError2("INVALID_SCRIPT", `${where}: ${message}`, String(index));
|
|
1644
|
+
};
|
|
1645
|
+
if (!isRecord2(raw) || typeof raw.action !== "string" || !ACTIONS.has(raw.action)) {
|
|
1646
|
+
return refuse("has no known Remote Browser action");
|
|
1647
|
+
}
|
|
1648
|
+
const action = raw.action;
|
|
1649
|
+
const unknown = Object.keys(raw).filter((key) => key !== "action" && key !== "name" && !(STEP_KEYS[action] ?? []).includes(key));
|
|
1650
|
+
if (unknown.length > 0)
|
|
1651
|
+
refuse(`(${action}) has unknown keys: ${unknown.sort().join(", ")}`);
|
|
1652
|
+
const name = typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : undefined;
|
|
1653
|
+
if (name !== undefined && !NAME_PATTERN2.test(name))
|
|
1654
|
+
refuse(`the result name "${name.slice(0, 64)}" is not valid`);
|
|
1655
|
+
const base = { id: `s${index + 1}`, ...name === undefined ? {} : { saveAs: name } };
|
|
1656
|
+
const target = (key = "selector", required = true) => {
|
|
1657
|
+
const value = raw[key];
|
|
1658
|
+
if (!given(value))
|
|
1659
|
+
return required ? refuse(`'${key}' is required`) : undefined;
|
|
1660
|
+
if (typeof value !== "string")
|
|
1661
|
+
return refuse(`'${key}' must be text`);
|
|
1662
|
+
return targetFromPlaywrightSelector2(value, refuse);
|
|
1663
|
+
};
|
|
1664
|
+
const need = (key = "selector") => target(key, true) ?? refuse(`'${key}' is required`);
|
|
1665
|
+
switch (action) {
|
|
1666
|
+
case "navigate": {
|
|
1667
|
+
if (typeof raw.url !== "string" || !raw.url.trim())
|
|
1668
|
+
return refuse("'url' is required");
|
|
1669
|
+
const waitUntil = given(raw.waitUntil) ? oneOf(WAIT_UNTIL, raw.waitUntil) : undefined;
|
|
1670
|
+
if (given(raw.waitUntil) && !waitUntil)
|
|
1671
|
+
refuse(`'waitUntil' must be one of ${WAIT_UNTIL.join(", ")}`);
|
|
1672
|
+
return {
|
|
1673
|
+
...base,
|
|
1674
|
+
action: "navigate",
|
|
1675
|
+
url: raw.url,
|
|
1676
|
+
...waitUntil && waitUntil !== "load" ? { waitUntil } : {}
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
case "click":
|
|
1680
|
+
return { ...base, action: "click", target: need() };
|
|
1681
|
+
case "type": {
|
|
1682
|
+
const text = typeof raw.text === "number" ? String(raw.text) : raw.text;
|
|
1683
|
+
if (given(text) && typeof text !== "string")
|
|
1684
|
+
refuse("'text' must be text");
|
|
1685
|
+
const clear = bool(raw.clear, "clear", refuse);
|
|
1686
|
+
const pressEnter = bool(raw.pressEnter, "pressEnter", refuse);
|
|
1687
|
+
return {
|
|
1688
|
+
...base,
|
|
1689
|
+
action: "type",
|
|
1690
|
+
target: need(),
|
|
1691
|
+
text: typeof text === "string" ? text : "",
|
|
1692
|
+
...clear === false ? { clear: false } : {},
|
|
1693
|
+
...pressEnter === true ? { pressEnter: true } : {}
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
case "select":
|
|
1697
|
+
return { ...base, action: "select", target: need(), values: selectValues(raw.values, refuse) };
|
|
1698
|
+
case "press": {
|
|
1699
|
+
const key = typeof raw.key === "string" ? raw.key.trim() : "";
|
|
1700
|
+
if (!/^(?:(?:Control|Shift|Alt|Meta)\+){0,3}[A-Za-z0-9]{1,16}$/.test(key)) {
|
|
1701
|
+
refuse("'key' must be a key name such as Enter, Tab, Escape or Control+A");
|
|
1702
|
+
}
|
|
1703
|
+
return { ...base, action: "pressKey", keys: key.split("+") };
|
|
1704
|
+
}
|
|
1705
|
+
case "waitFor":
|
|
1706
|
+
return convertWait(raw, base, refuse, target);
|
|
1707
|
+
case "extract":
|
|
1708
|
+
return { ...base, action: "extract", fields: convertFields2(raw.fields, refuse) };
|
|
1709
|
+
case "screenshot": {
|
|
1710
|
+
const fullPage = bool(raw.fullPage, "fullPage", refuse);
|
|
1711
|
+
const shot = target("selector", false);
|
|
1712
|
+
return {
|
|
1713
|
+
...base,
|
|
1714
|
+
action: "screenshot",
|
|
1715
|
+
...shot ? { target: shot } : {},
|
|
1716
|
+
...fullPage === true ? { fullPage: true } : {}
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
default: {
|
|
1720
|
+
const username = target("usernameSelector", false);
|
|
1721
|
+
const password = target("passwordSelector", false);
|
|
1722
|
+
const submit = target("submitSelector", false);
|
|
1723
|
+
const success = target("successSelector", false);
|
|
1724
|
+
return {
|
|
1725
|
+
...base,
|
|
1726
|
+
action: "login",
|
|
1727
|
+
...username ? { username } : {},
|
|
1728
|
+
...password ? { password } : {},
|
|
1729
|
+
...submit ? { submit } : {},
|
|
1730
|
+
...success ? { success } : {}
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
function convertWait(raw, base, refuse, target) {
|
|
1736
|
+
const present = ["selector", "urlContains", "milliseconds"].filter((key) => given(raw[key]));
|
|
1737
|
+
if (present.length !== 1)
|
|
1738
|
+
return refuse("give exactly one of 'selector', 'urlContains' or 'milliseconds'");
|
|
1739
|
+
if (present[0] === "selector") {
|
|
1740
|
+
const state = given(raw.state) ? oneOf(WAIT_STATES, raw.state) : undefined;
|
|
1741
|
+
if (given(raw.state) && !state)
|
|
1742
|
+
refuse(`'state' must be one of ${WAIT_STATES.join(", ")}`);
|
|
1743
|
+
return {
|
|
1744
|
+
...base,
|
|
1745
|
+
action: "waitFor",
|
|
1746
|
+
target: target("selector", true) ?? refuse("'selector' is required"),
|
|
1747
|
+
...state && state !== "visible" ? { state } : {}
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
if (present[0] === "urlContains") {
|
|
1751
|
+
if (typeof raw.urlContains !== "string")
|
|
1752
|
+
return refuse("'urlContains' must be text");
|
|
1753
|
+
return { ...base, action: "waitFor", urlContains: raw.urlContains };
|
|
1754
|
+
}
|
|
1755
|
+
const milliseconds = typeof raw.milliseconds === "string" ? Number(raw.milliseconds.trim()) : raw.milliseconds;
|
|
1756
|
+
if (typeof milliseconds !== "number" || !Number.isInteger(milliseconds) || milliseconds < 1 || milliseconds > MAX_STEP_TIMEOUT_MS2) {
|
|
1757
|
+
return refuse(`'milliseconds' must be a whole number between 1 and ${MAX_STEP_TIMEOUT_MS2}`);
|
|
1758
|
+
}
|
|
1759
|
+
return { ...base, action: "waitFor", milliseconds };
|
|
1760
|
+
}
|
|
1761
|
+
function selectValues(value, refuse) {
|
|
1762
|
+
let list = value;
|
|
1763
|
+
if (typeof value === "string") {
|
|
1764
|
+
const text = value.trim();
|
|
1765
|
+
if (text.startsWith("[")) {
|
|
1766
|
+
try {
|
|
1767
|
+
list = JSON.parse(text);
|
|
1768
|
+
} catch {
|
|
1769
|
+
return refuse("'values' is not valid JSON");
|
|
1770
|
+
}
|
|
1771
|
+
} else {
|
|
1772
|
+
list = text.split(",").map((part) => part.trim()).filter(Boolean);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
if (!Array.isArray(list) || list.length === 0)
|
|
1776
|
+
return refuse("'values' is required");
|
|
1777
|
+
return list.map((item) => typeof item === "string" || typeof item === "number" ? String(item) : refuse("'values' must be a list of values"));
|
|
1778
|
+
}
|
|
1779
|
+
function convertFields2(value, refuse) {
|
|
1780
|
+
let fields = value;
|
|
1781
|
+
if (typeof value === "string") {
|
|
1782
|
+
try {
|
|
1783
|
+
fields = JSON.parse(value);
|
|
1784
|
+
} catch {
|
|
1785
|
+
return refuse("'fields' is not valid JSON");
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
if (!isRecord2(fields) || Object.keys(fields).length === 0) {
|
|
1789
|
+
return refuse("'fields' must be an object of {name: selector} or {name: {selector, attribute, all}}");
|
|
1790
|
+
}
|
|
1791
|
+
return Object.entries(fields).map(([name, spec]) => {
|
|
1792
|
+
if (!NAME_PATTERN2.test(name))
|
|
1793
|
+
return refuse(`field name '${name.slice(0, 64)}' is not valid`);
|
|
1794
|
+
if (typeof spec === "string")
|
|
1795
|
+
return { name, target: targetFromPlaywrightSelector2(spec, refuse), attribute: "text" };
|
|
1796
|
+
if (!isRecord2(spec) || typeof spec.selector !== "string") {
|
|
1797
|
+
return refuse(`'fields.${name}' must be a selector or an object with a selector`);
|
|
1798
|
+
}
|
|
1799
|
+
const extra = Object.keys(spec).filter((key) => !["selector", "attribute", "all"].includes(key));
|
|
1800
|
+
if (extra.length > 0)
|
|
1801
|
+
refuse(`'fields.${name}' has unknown keys: ${extra.sort().join(", ")}`);
|
|
1802
|
+
const attribute = typeof spec.attribute === "string" && spec.attribute ? spec.attribute : "text";
|
|
1803
|
+
const all = bool(spec.all, `fields.${name}.all`, refuse);
|
|
1804
|
+
return {
|
|
1805
|
+
name,
|
|
1806
|
+
target: targetFromPlaywrightSelector2(spec.selector, refuse),
|
|
1807
|
+
attribute,
|
|
1808
|
+
...all === true ? { all: true } : {}
|
|
1809
|
+
};
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
// src/script/adapters/recording.ts
|
|
1813
|
+
function roleTarget(target) {
|
|
1814
|
+
const method = {
|
|
1815
|
+
kind: "role",
|
|
1816
|
+
role: target.role,
|
|
1817
|
+
name: target.name,
|
|
1818
|
+
nth: target.nth,
|
|
1819
|
+
...target.app === undefined ? {} : { app: target.app },
|
|
1820
|
+
...target.window === undefined ? {} : { window: target.window }
|
|
1821
|
+
};
|
|
1822
|
+
return { methods: [method] };
|
|
1823
|
+
}
|
|
1824
|
+
function fromRecording2(value) {
|
|
1825
|
+
const recording = parseRecording2(value);
|
|
1826
|
+
return parseUiScript2({ scriptVersion: 1, steps: recording.steps.map(fromRecordedStep) });
|
|
1827
|
+
}
|
|
1828
|
+
function fromRecordedStep(step) {
|
|
1829
|
+
const base = {
|
|
1830
|
+
id: step.id,
|
|
1831
|
+
intent: step.intent,
|
|
1832
|
+
...step.screenshotRef === undefined ? {} : { screenshotRef: step.screenshotRef },
|
|
1833
|
+
fingerprint: step.fingerprint
|
|
1834
|
+
};
|
|
1835
|
+
switch (step.action) {
|
|
1836
|
+
case "click": {
|
|
1837
|
+
const button = step.button === "right" ? { button: "right" } : {};
|
|
1838
|
+
return step.count === 2 ? { ...base, action: "doubleClick", target: roleTarget(step.target), ...button } : { ...base, action: "click", target: roleTarget(step.target), ...button };
|
|
1839
|
+
}
|
|
1840
|
+
case "type":
|
|
1841
|
+
return {
|
|
1842
|
+
...base,
|
|
1843
|
+
action: "type",
|
|
1844
|
+
...step.target ? { target: roleTarget(step.target) } : {},
|
|
1845
|
+
...step.text === undefined ? {} : { text: step.text },
|
|
1846
|
+
masked: step.masked
|
|
1847
|
+
};
|
|
1848
|
+
case "secret_fill":
|
|
1849
|
+
return {
|
|
1850
|
+
...base,
|
|
1851
|
+
action: "typeSecret",
|
|
1852
|
+
target: roleTarget(step.target),
|
|
1853
|
+
secretRef: step.secretRef,
|
|
1854
|
+
expectedOrigin: step.expectedOrigin
|
|
1855
|
+
};
|
|
1856
|
+
case "key":
|
|
1857
|
+
return { ...base, action: "pressKey", keys: step.keys };
|
|
1858
|
+
case "scroll":
|
|
1859
|
+
return {
|
|
1860
|
+
...base,
|
|
1861
|
+
action: "scroll",
|
|
1862
|
+
...step.target ? { target: roleTarget(step.target) } : {},
|
|
1863
|
+
dx: step.dx,
|
|
1864
|
+
dy: step.dy
|
|
1865
|
+
};
|
|
1866
|
+
case "navigate":
|
|
1867
|
+
return { ...base, action: "navigate", url: step.url };
|
|
1868
|
+
default:
|
|
1869
|
+
return {
|
|
1870
|
+
...base,
|
|
1871
|
+
action: "focusWindow",
|
|
1872
|
+
app: step.app,
|
|
1873
|
+
...step.title === undefined ? {} : { title: step.title }
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
class NotRecordable extends Error {
|
|
1879
|
+
}
|
|
1880
|
+
function stop2() {
|
|
1881
|
+
throw new NotRecordable;
|
|
1882
|
+
}
|
|
1883
|
+
function toRecording2(script, fallbackIntent) {
|
|
1884
|
+
try {
|
|
1885
|
+
if (script.cleanup || script.outputs?.length || script.variables?.length || script.inputs?.length)
|
|
1886
|
+
stop2();
|
|
1887
|
+
if (script.settings && Object.values(script.settings).some((value) => value !== undefined))
|
|
1888
|
+
stop2();
|
|
1889
|
+
const recording = {
|
|
1890
|
+
version: 1,
|
|
1891
|
+
steps: script.steps.map((step) => toRecordedStep(step, fallbackIntent))
|
|
1892
|
+
};
|
|
1893
|
+
return parseRecording2(recording);
|
|
1894
|
+
} catch (error) {
|
|
1895
|
+
if (error instanceof NotRecordable || error instanceof RecordingError2)
|
|
1896
|
+
return null;
|
|
1897
|
+
throw error;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
function recordedTarget(ref) {
|
|
1901
|
+
const method = soleRoleMethod(ref) ?? stop2();
|
|
1902
|
+
return {
|
|
1903
|
+
...method.app === undefined ? {} : { app: method.app },
|
|
1904
|
+
...method.window === undefined ? {} : { window: method.window },
|
|
1905
|
+
role: method.role,
|
|
1906
|
+
name: method.name,
|
|
1907
|
+
nth: method.nth ?? 0
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
function toRecordedStep(step, fallbackIntent) {
|
|
1911
|
+
if (step.disabled || step.breakpoint || step.verify || step.retry || step.saveAs !== undefined)
|
|
1912
|
+
stop2();
|
|
1913
|
+
if (step.onError === "continue" || step.note !== undefined || step.timeoutMs !== undefined)
|
|
1914
|
+
stop2();
|
|
1915
|
+
if (step.screenshot || step.inputMethod || step.safeToRepeat)
|
|
1916
|
+
stop2();
|
|
1917
|
+
const intent = step.intent ?? fallbackIntent?.(step) ?? stop2();
|
|
1918
|
+
const base = {
|
|
1919
|
+
id: step.id,
|
|
1920
|
+
intent,
|
|
1921
|
+
...step.screenshotRef === undefined ? {} : { screenshotRef: step.screenshotRef }
|
|
1922
|
+
};
|
|
1923
|
+
const fingerprint = uiStepFingerprint2(step);
|
|
1924
|
+
switch (step.action) {
|
|
1925
|
+
case "click":
|
|
1926
|
+
case "doubleClick":
|
|
1927
|
+
return {
|
|
1928
|
+
...base,
|
|
1929
|
+
fingerprint,
|
|
1930
|
+
action: "click",
|
|
1931
|
+
target: recordedTarget(step.target),
|
|
1932
|
+
button: step.button ?? "left",
|
|
1933
|
+
count: step.action === "doubleClick" ? 2 : 1
|
|
1934
|
+
};
|
|
1935
|
+
case "type":
|
|
1936
|
+
if (step.clear === false || step.pressEnter || step.delayMs !== undefined)
|
|
1937
|
+
stop2();
|
|
1938
|
+
if (step.text !== undefined && typeof step.text !== "string")
|
|
1939
|
+
stop2();
|
|
1940
|
+
return {
|
|
1941
|
+
...base,
|
|
1942
|
+
fingerprint,
|
|
1943
|
+
action: "type",
|
|
1944
|
+
...step.target ? { target: recordedTarget(step.target) } : {},
|
|
1945
|
+
...step.text === undefined ? {} : { text: step.text },
|
|
1946
|
+
masked: step.masked === true
|
|
1947
|
+
};
|
|
1948
|
+
case "typeSecret":
|
|
1949
|
+
return {
|
|
1950
|
+
...base,
|
|
1951
|
+
fingerprint,
|
|
1952
|
+
action: "secret_fill",
|
|
1953
|
+
target: recordedTarget(step.target),
|
|
1954
|
+
secretRef: step.secretRef,
|
|
1955
|
+
expectedOrigin: step.expectedOrigin ?? stop2()
|
|
1956
|
+
};
|
|
1957
|
+
case "pressKey":
|
|
1958
|
+
if (step.target)
|
|
1959
|
+
stop2();
|
|
1960
|
+
return { ...base, fingerprint, action: "key", keys: step.keys };
|
|
1961
|
+
case "scroll":
|
|
1962
|
+
if (step.to || step.dx === undefined && step.dy === undefined)
|
|
1963
|
+
stop2();
|
|
1964
|
+
return {
|
|
1965
|
+
...base,
|
|
1966
|
+
fingerprint,
|
|
1967
|
+
action: "scroll",
|
|
1968
|
+
...step.target ? { target: recordedTarget(step.target) } : {},
|
|
1969
|
+
dx: step.dx ?? 0,
|
|
1970
|
+
dy: step.dy ?? 0
|
|
1971
|
+
};
|
|
1972
|
+
case "navigate":
|
|
1973
|
+
if (typeof step.url !== "string" || step.waitUntil && step.waitUntil !== "load")
|
|
1974
|
+
stop2();
|
|
1975
|
+
return { ...base, fingerprint, action: "navigate", url: step.url };
|
|
1976
|
+
case "focusWindow":
|
|
1977
|
+
return {
|
|
1978
|
+
...base,
|
|
1979
|
+
fingerprint,
|
|
1980
|
+
action: "focus_window",
|
|
1981
|
+
app: step.app,
|
|
1982
|
+
...step.title === undefined ? {} : { title: step.title }
|
|
1983
|
+
};
|
|
1984
|
+
default:
|
|
1985
|
+
return stop2();
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
export { UI_EXPRESSION_OPS2, UI_ANCHOR_RELATIONS2, UI_TARGET_METHOD_KINDS2, UI_WEB_ACTIONS2, UI_DESKTOP_ACTIONS2, UI_FLOW_ACTIONS2, UI_STEP_ACTIONS2, UI_VALUE_TYPES2, UI_SCRIPT_VERSION2, MAX_SCRIPT_STEPS2, MAX_SCRIPT_BYTES2, MAX_FLOW_DEPTH2, MAX_EXPRESSION_DEPTH2, MAX_EXPRESSION_ITEMS2, MAX_OPERATOR_ARGS2, MAX_SCRIPT_INPUTS2, MAX_SCRIPT_OUTPUTS2, MAX_SCRIPT_VARIABLES2, MAX_SCRIPT_ELEMENTS2, MAX_TARGET_METHODS2, MAX_FRAME_DEPTH2, MAX_EXTRACT_FIELDS2, MAX_LIST_ITEMS2, MAX_LIST_PAGES2, MAX_LOOP_ITERATIONS2, MAX_RETRY_ATTEMPTS2, MAX_STEP_TIMEOUT_MS2, MAX_DELAY_MS2, MAX_KEYS2, MAX_SELECT_VALUES2, MAX_SELECTOR_LENGTH2, MAX_URL_LENGTH2, MAX_LABEL_LENGTH2, MAX_TEXT_LENGTH2, MAX_INTENT_LENGTH2, MAX_NAME_LENGTH2, LEGACY_MAX_BROWSER_STEPS2, LEGACY_MAX_STEPS_BYTES2, jsonByteLength2, uiScriptRegistry2, NAME_PATTERN2, STEP_ID_PATTERN2, ELEMENT_KEY_PATTERN2, uiExpressionSchema2, uiTargetMethodSchema2, uiTargetSchema2, uiTargetRefSchema2, uiStepSchema2, uiScriptSchema2, canonicalJson2, childBlocks2, walkSteps2, countSteps2, stepAtPath2, stepTargets2, stepExpressions2, visitExpression2, RECORDING_ACTION_OF2, uiStepFingerprint2, withFingerprint2, UiScriptError2, UI_EXPRESSION_ARITY2, parseUiScript2, safeParseUiScript2, UI_SCRIPT_SCHEMA_HASH2, schemaHashOf2, UI_SCRIPT_SCHEMA_TITLE2, uiScriptJsonSchema2, CAPABILITY_IDS2, SCRIPT_CAPABILITY2, requiredCapabilities2, missingCapabilities2, UI_SCRIPT_STEP_KEY_PREFIX2, UI_SCRIPT_STEP_MESSAGES2, stepMessageKey2, describeTarget2, describeExpression2, describeStep2, BROWSER_STEP_ACTIONS2, fromBrowserActionSteps2, toBrowserActionSteps2, targetFromPlaywrightSelector2, fromRemoteBrowserSteps2, fromRecording2, toRecording2 };
|