@qontinui/ui-bridge-wrapper 0.12.0 → 0.14.0
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 +119 -8
- package/dist/capture-specs-cli.cjs +166 -48
- package/dist/capture-specs-cli.cjs.map +1 -1
- package/dist/capture-specs-cli.d.ts.map +1 -1
- package/dist/index.cjs +83 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +83 -2
- package/dist/index.js.map +1 -1
- package/dist/inject-cli.cjs +278 -113
- package/dist/inject-cli.cjs.map +1 -1
- package/dist/inject-cli.d.ts +1 -1
- package/dist/inject-cli.d.ts.map +1 -1
- package/dist/login-web-cli.cjs +173 -52
- package/dist/login-web-cli.cjs.map +1 -1
- package/dist/login-web-cli.d.ts.map +1 -1
- package/dist/network-throttle.d.ts +5 -0
- package/dist/network-throttle.d.ts.map +1 -1
- package/dist/timeline-capture.d.ts +75 -9
- package/dist/timeline-capture.d.ts.map +1 -1
- package/dist/transports/headless.d.ts +46 -1
- package/dist/transports/headless.d.ts.map +1 -1
- package/dist/transports/injected.d.ts +8 -0
- package/dist/transports/injected.d.ts.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -6
- package/dist/cli-args.d.ts +0 -13
- package/dist/cli-args.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -60,11 +60,11 @@ so **they run from any directory once installed** — there is no "must run from
|
|
|
60
60
|
the ui-bridge repo root" coupling. Run via `npx @qontinui/ui-bridge-wrapper`
|
|
61
61
|
or a global/dev install:
|
|
62
62
|
|
|
63
|
-
| Bin
|
|
64
|
-
|
|
|
65
|
-
| `ui-bridge-inject`
|
|
66
|
-
| `ui-bridge-login-web`
|
|
67
|
-
| `ui-bridge-capture-specs` | Log in (same flow) then `goto` + snapshot a set of authed pages, writing one `<slug>.snapshot.json` per page.
|
|
63
|
+
| Bin | What it does |
|
|
64
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
65
|
+
| `ui-bridge-inject` | Drive the injected transport against a UI-Bridge-free page (exec one-shot actions, register as a relay tab, or capture frame-and-snapshot pairs — one, or a viewport × DPR × colour-scheme matrix). |
|
|
66
|
+
| `ui-bridge-login-web` | Automated web login via the injected transport — drives the full Cognito OAuth redirect chain in one headless tab. Optionally asserts on-page text (`--expect-text`) and screenshots the authed landing (`--screenshot`/`--scroll-to`). Prints one JSON result line; exit 0 = login confirmed AND all expected text present. |
|
|
67
|
+
| `ui-bridge-capture-specs` | Log in (same flow) then `goto` + snapshot a set of authed pages, writing one `<slug>.snapshot.json` per page. |
|
|
68
68
|
|
|
69
69
|
Each bin supports `--help`.
|
|
70
70
|
|
|
@@ -129,6 +129,63 @@ ui-bridge-login-web \
|
|
|
129
129
|
ui-bridge-capture-specs --out ./spec-capture
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
### Reading and acting on one element (`ui-bridge-inject` exec mode)
|
|
133
|
+
|
|
134
|
+
Exec mode (`--exec` / `--exec-stdin`) reads and acts on single elements through
|
|
135
|
+
the injected runtime's in-page dispatcher, the same one the relay drives, with
|
|
136
|
+
no relay call:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# read one element, click it, read its state again
|
|
140
|
+
ui-bridge-inject --url http://127.0.0.1:3000/ \
|
|
141
|
+
--exec 'getElement {"id":"open"}' \
|
|
142
|
+
--exec 'executeElementAction {"id":"open","request":{"action":"click"}}' \
|
|
143
|
+
--exec 'getElementState {"id":"open"}'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- `getElement {"id":"<id>"}` answers one element as a snapshot carries it:
|
|
147
|
+
identity (`id`, `type`, `tagName`, `label`, `role`, `accessibleName`),
|
|
148
|
+
`state`, box (`bbox`, `visible`) and `actions`, the same object as the
|
|
149
|
+
matching `getControlSnapshot` element, redaction included.
|
|
150
|
+
`{"elementId":"<id>"}` is accepted too; given both, they must name the same
|
|
151
|
+
element. Nothing settles first, so run `waitForSelector` before it for a
|
|
152
|
+
settled read. Beside the id it tolerates, and ignores, `settleTimeout` and
|
|
153
|
+
`skipSettle` (it does not settle), `targetTabId`, and the WebSocket
|
|
154
|
+
protocol's `includeState` (the state is always included); any other key is
|
|
155
|
+
refused with `INVALID_REQUEST`. An unknown id, or one whose DOM node is gone,
|
|
156
|
+
is a returned `ELEMENT_NOT_FOUND` (an `error` line and exit 1), never a
|
|
157
|
+
`null` result.
|
|
158
|
+
- `getElementState {"id":"<id>"}` answers the state alone. It reads `id` only,
|
|
159
|
+
and an unknown id is a thrown error (`HANDLER_ERROR`).
|
|
160
|
+
- `executeElementAction {"id":"<id>","request":{"action":"click"}}` acts on one
|
|
161
|
+
element. `request` holds the verb and the fields it reads (`value`, `text`,
|
|
162
|
+
`clear`, `params`, `fromSnapshotId`, …). Two other spellings are accepted:
|
|
163
|
+
`elementId` in place of `id`, and a flat payload such as
|
|
164
|
+
`{"id":"<id>","action":"type","text":"hi"}`, which, minus `id` / `elementId`,
|
|
165
|
+
_is_ the request. No key _beside_ a `request` object is silently dropped: a
|
|
166
|
+
top-level `action` or request field there must equal the same field inside
|
|
167
|
+
`request` (an agreeing duplicate is accepted); one that is only at the top
|
|
168
|
+
level, or at both levels with different values, is refused, and so are an
|
|
169
|
+
`id` and an `elementId` that name different elements. The dispatcher keys
|
|
170
|
+
stay allowed at the top level. The request fields themselves (the keys
|
|
171
|
+
inside `request`, or every key of a flat payload but the id) reach the
|
|
172
|
+
action as sent, so a misspelt one there (`txt` for `text`) is not caught.
|
|
173
|
+
Every refused shape is a returned `INVALID_REQUEST` (an `error` line and
|
|
174
|
+
exit 1, never a thrown `TypeError`) whose message names the canonical shape
|
|
175
|
+
`{"id":"<elementId>","request":{"action":"<action>", …}}` and both accepted
|
|
176
|
+
spellings, and names keys and the kinds of values, never a value, with one
|
|
177
|
+
exception: an `"id"` and an `"elementId"` that disagree are both named (they
|
|
178
|
+
are the element ids the caller sent, and naming both is what makes the
|
|
179
|
+
conflict diagnosable); `error.details` adds `expectedPayload` and
|
|
180
|
+
`receivedKeys`. A well-formed payload with an unknown verb is refused with
|
|
181
|
+
`UNSUPPORTED_ACTION`, naming the accepted verbs.
|
|
182
|
+
|
|
183
|
+
These need `@qontinui/ui-bridge` 0.47.0 or later, the first injected runtime
|
|
184
|
+
that serves `getElement` and the payload grammar. Against an older one,
|
|
185
|
+
`getElement` fails with `Unknown command action: getElement`, a flat
|
|
186
|
+
`executeElementAction` throws a `TypeError`, and an `elementId` one answers
|
|
187
|
+
`Element undefined not found`.
|
|
188
|
+
|
|
132
189
|
### Frames, device pixel ratio and the capture matrix (`ui-bridge-inject`)
|
|
133
190
|
|
|
134
191
|
`--screenshot <path>` captures a PNG frame **in lockstep** with every
|
|
@@ -179,6 +236,39 @@ directory must be empty or not exist yet: a non-empty one is refused before any
|
|
|
179
236
|
browser launches, and is never cleared. `--viewport` sides are at most 8192 CSS
|
|
180
237
|
pixels.
|
|
181
238
|
|
|
239
|
+
### HAR and video recording, service workers and routes (`createTransport` headless/injected)
|
|
240
|
+
|
|
241
|
+
The `headless`, `headed` and `injected` transports pass four options to
|
|
242
|
+
`@qontinui/ui-bridge-headless`'s browser context: `recordHar` (Playwright's
|
|
243
|
+
`recordHar` shape, unchanged), `recordVideo` (`{ dir, size?, … }`; the
|
|
244
|
+
launcher records at the viewport size when `size` is unset),
|
|
245
|
+
`serviceWorkers: 'allow' | 'block'`, and `initRouter(context)`, which runs
|
|
246
|
+
before the first page exists so a `context.route('**/*', …)` it installs
|
|
247
|
+
catches the first document request. The HAR and the video are complete once
|
|
248
|
+
`transport.close()` resolves. A launch that fails inside the launcher writes no
|
|
249
|
+
HAR, but a `ready()` that fails after the launch (an emulation refusal, an
|
|
250
|
+
injected-runtime wait) can still leave a complete archive, so a missing file is
|
|
251
|
+
not how to tell that `ready()` failed. A malformed value fails construction
|
|
252
|
+
with `INVALID_CONFIG`, and a headless peer older than 0.8.0 (ui-bridge#381)
|
|
253
|
+
ignores all four, so the transport then fails `ready()` with
|
|
254
|
+
`CONTEXT_OPTIONS_NOT_APPLIED` and closes the browser it opened.
|
|
255
|
+
`serviceWorkers: 'allow'` alone is exempt, since it is Playwright's default.
|
|
256
|
+
They have no CLI flags: `initRouter` is a function.
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
const transport = createTransport({
|
|
260
|
+
kind: 'injected',
|
|
261
|
+
options: {
|
|
262
|
+
targetUrl: 'https://example.com/',
|
|
263
|
+
recordHar: { path: './capture.zip', content: 'attach', mode: 'minimal' },
|
|
264
|
+
serviceWorkers: 'block',
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
await transport.ready();
|
|
268
|
+
// …
|
|
269
|
+
await transport.close(); // the HAR is written
|
|
270
|
+
```
|
|
271
|
+
|
|
182
272
|
### Candidates in situ: the media override, a slow network and a timeline
|
|
183
273
|
|
|
184
274
|
The injected runtime serves the SDK's `mediaOverride` dev control, so a
|
|
@@ -194,6 +284,11 @@ ui-bridge-inject --url http://127.0.0.1:3000/ --throttle slow-3g --no-cache \
|
|
|
194
284
|
`mediaOverride` answers only after the browser decoded the candidate and its
|
|
195
285
|
`currentSrc` names it (inside a `<picture>` every `<source srcset>` is replaced
|
|
196
286
|
too); one it cannot confirm is rolled back and fails the step.
|
|
287
|
+
On Chromium 158 a candidate URL the document already decoded is served with no
|
|
288
|
+
request, even under `--no-cache` (Chromium 147 refetched it); only a new URL or
|
|
289
|
+
a reload reaches the network. A candidate a timeline (or `captureTimeline`'s
|
|
290
|
+
`during`) should observe ARRIVING therefore needs a URL that document has not
|
|
291
|
+
decoded, such as a per-candidate query string (`cand.png?2`).
|
|
197
292
|
A `loading="lazy"` slot is loaded eagerly while overridden, so an offscreen one
|
|
198
293
|
still decodes. `mediaOverrideRestore` puts every attribute back and verifies
|
|
199
294
|
what the browser then RENDERS (the slot's `currentSrc` back on an original URL,
|
|
@@ -203,12 +298,28 @@ rewrote a value meanwhile) or `verified: false` is an unknown one.
|
|
|
203
298
|
`mediaOverrideList` returning `active: []` proves nothing is still overridden.
|
|
204
299
|
`--throttle <slow-3g|fast-3g|latency=<ms>,down=<kbps>,up=<kbps>>` applies CDP
|
|
205
300
|
network emulation once the page is ready (it persists across a reload) and
|
|
206
|
-
`--no-cache` disables the HTTP cache
|
|
207
|
-
|
|
301
|
+
`--no-cache` disables the HTTP cache (not the document's in-memory image cache:
|
|
302
|
+
on Chromium 158 a URL the page already decoded is answered at once, throttle or
|
|
303
|
+
not, so give a repeated `mediaOverride` candidate its own URL, e.g.
|
|
304
|
+
`cand.png?2`); what Chromium accepted is stamped as `network` on timeline
|
|
305
|
+
results, matrix cells and the relay info line.
|
|
208
306
|
`captureTimeline` screenshots the page `frames` times, `intervalMs` apart, each
|
|
209
307
|
frame stamped with its offset; `"reload":true` starts the clock at a fresh
|
|
210
308
|
navigation commit (the loading-to-loaded timeline) and waits for the runtime to
|
|
211
|
-
settle again.
|
|
309
|
+
settle again. Frame 1 of a reload is the first frame the page produced after
|
|
310
|
+
the commit. Right after it the new document can have no compositor frame yet,
|
|
311
|
+
and Chromium refuses the screenshot (`Unable to capture screenshot`), so frame 1
|
|
312
|
+
retries that refusal every 16 ms until `readyTimeoutMs` (default 30000) after
|
|
313
|
+
the commit. A frame's `offsetMs` is when the screenshot that produced it was
|
|
314
|
+
requested, so a frame 1 that had to wait reads tens of milliseconds, not 0, and
|
|
315
|
+
a frame that took more than one attempt carries `attempts`. Under `--throttle`
|
|
316
|
+
that first frame can still be the previous document's held frame; `offsetMs`
|
|
317
|
+
dates it either way. Every other frame retries the same refusal only while the
|
|
318
|
+
retry falls due before the next frame's due time (`"intervalMs":0` is one
|
|
319
|
+
attempt), so retries never take a later frame's slot; an attempt still under
|
|
320
|
+
way when the next frame falls due delays it by what is left of that attempt, as
|
|
321
|
+
any slow screenshot does. No other error is retried; a frame still refused at
|
|
322
|
+
its deadline carries `error` and fails the step. `"during":{"action":"mediaOverride","payload":{...}}` runs the
|
|
212
323
|
override concurrently with the frames, so the timeline shows the candidate
|
|
213
324
|
arriving (under `--throttle`, its slow-network load) while the override still
|
|
214
325
|
confirms decode before it answers. In `--capture-matrix` a relative `dir` lands
|
|
@@ -5,52 +5,19 @@ var fs = require('fs');
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var module$1 = require('module');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
|
-
var ui_bridge_cli_args_star = require('@qontinui/ui-bridge-cli-args');
|
|
9
8
|
|
|
10
9
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
11
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
11
|
|
|
13
|
-
function _interopNamespace(e) {
|
|
14
|
-
if (e && e.__esModule) return e;
|
|
15
|
-
var n = Object.create(null);
|
|
16
|
-
if (e) {
|
|
17
|
-
Object.keys(e).forEach(function (k) {
|
|
18
|
-
if (k !== 'default') {
|
|
19
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () { return e[k]; }
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
n.default = e;
|
|
28
|
-
return Object.freeze(n);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
12
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
32
13
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
33
|
-
var ui_bridge_cli_args_star__namespace = /*#__PURE__*/_interopNamespace(ui_bridge_cli_args_star);
|
|
34
14
|
|
|
35
|
-
var __defProp = Object.defineProperty;
|
|
36
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
37
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
38
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
39
15
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
40
16
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
41
17
|
}) : x)(function(x) {
|
|
42
18
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
43
19
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
44
20
|
});
|
|
45
|
-
var __copyProps = (to, from, except, desc) => {
|
|
46
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
47
|
-
for (let key of __getOwnPropNames(from))
|
|
48
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
49
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
50
|
-
}
|
|
51
|
-
return to;
|
|
52
|
-
};
|
|
53
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
|
|
54
21
|
|
|
55
22
|
// src/types.ts
|
|
56
23
|
var WrapperTransportError = class extends Error {
|
|
@@ -284,9 +251,60 @@ var HeadlessTransport = class extends BaseTransport {
|
|
|
284
251
|
userAgent: typeof raw["userAgent"] === "string" ? raw["userAgent"] : void 0,
|
|
285
252
|
forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0,
|
|
286
253
|
launchArgs: Array.isArray(raw["launchArgs"]) && raw["launchArgs"].every((a) => typeof a === "string") ? raw["launchArgs"] : void 0,
|
|
287
|
-
storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0
|
|
254
|
+
storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0,
|
|
255
|
+
...this.parseContextOptions(raw)
|
|
288
256
|
};
|
|
289
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* `recordHar`, `recordVideo`, `serviceWorkers` and `initRouter`. Unlike the display
|
|
260
|
+
* options above, a malformed value is REFUSED rather than dropped: dropping
|
|
261
|
+
* `recordHar` would leave a caller waiting for an archive that is never
|
|
262
|
+
* written, and dropping `initRouter` would let requests it meant to answer
|
|
263
|
+
* reach the network.
|
|
264
|
+
*/
|
|
265
|
+
parseContextOptions(raw) {
|
|
266
|
+
const out = {};
|
|
267
|
+
const invalid = (what) => new WrapperTransportError("INVALID_CONFIG", `Transport kind '${this.kind}': ${what}`);
|
|
268
|
+
const har = raw["recordHar"];
|
|
269
|
+
if (har !== void 0) {
|
|
270
|
+
if (typeof har !== "object" || har === null || typeof har.path !== "string" || har.path.length === 0) {
|
|
271
|
+
throw invalid("options.recordHar must be an object with a non-empty string `path`");
|
|
272
|
+
}
|
|
273
|
+
out.recordHar = har;
|
|
274
|
+
}
|
|
275
|
+
const video = raw["recordVideo"];
|
|
276
|
+
if (video !== void 0) {
|
|
277
|
+
if (typeof video !== "object" || video === null || typeof video.dir !== "string" || video.dir.length === 0) {
|
|
278
|
+
throw invalid("options.recordVideo must be an object with a non-empty string `dir`");
|
|
279
|
+
}
|
|
280
|
+
const size = video.size;
|
|
281
|
+
if (size !== void 0) {
|
|
282
|
+
const positiveInt = (n) => typeof n === "number" && Number.isInteger(n) && n > 0;
|
|
283
|
+
const s = size;
|
|
284
|
+
if (typeof size !== "object" || s === null || !positiveInt(s.width) || !positiveInt(s.height)) {
|
|
285
|
+
throw invalid(
|
|
286
|
+
"options.recordVideo.size must be { width, height } with positive integer sides"
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
out.recordVideo = video;
|
|
291
|
+
}
|
|
292
|
+
const sw = raw["serviceWorkers"];
|
|
293
|
+
if (sw !== void 0) {
|
|
294
|
+
if (sw !== "allow" && sw !== "block") {
|
|
295
|
+
throw invalid(`options.serviceWorkers must be 'allow' or 'block' (got ${String(sw)})`);
|
|
296
|
+
}
|
|
297
|
+
out.serviceWorkers = sw;
|
|
298
|
+
}
|
|
299
|
+
const router = raw["initRouter"];
|
|
300
|
+
if (router !== void 0) {
|
|
301
|
+
if (typeof router !== "function") {
|
|
302
|
+
throw invalid("options.initRouter must be a function (context) => void | Promise<void>");
|
|
303
|
+
}
|
|
304
|
+
out.initRouter = router;
|
|
305
|
+
}
|
|
306
|
+
return out;
|
|
307
|
+
}
|
|
290
308
|
async onReady() {
|
|
291
309
|
let launchHeadlessTab;
|
|
292
310
|
const headlessSpecifier = "@qontinui/ui-bridge-headless";
|
|
@@ -314,6 +332,13 @@ Underlying import error: ${cause}`
|
|
|
314
332
|
const initScripts = await this.buildInitScripts();
|
|
315
333
|
const relayAuth = this.relayAuth();
|
|
316
334
|
const pinnedTabId = this.pinnedTabId();
|
|
335
|
+
const { recordHar, recordVideo, serviceWorkers, initRouter: callerRouter } = this.options;
|
|
336
|
+
const contextOptionsRequested = recordHar !== void 0 || recordVideo !== void 0 || serviceWorkers === "block" || callerRouter !== void 0;
|
|
337
|
+
let routerCalled = false;
|
|
338
|
+
const initRouter = contextOptionsRequested || serviceWorkers !== void 0 ? async (context) => {
|
|
339
|
+
routerCalled = true;
|
|
340
|
+
if (callerRouter) await callerRouter(context);
|
|
341
|
+
} : void 0;
|
|
317
342
|
let tab;
|
|
318
343
|
try {
|
|
319
344
|
tab = await launchHeadlessTab({
|
|
@@ -332,7 +357,11 @@ Underlying import error: ${cause}`
|
|
|
332
357
|
storageStatePath: this.options.storageStatePath,
|
|
333
358
|
...relayAuth.authToken ? { authToken: relayAuth.authToken } : {},
|
|
334
359
|
...relayAuth.callerUserId ? { callerUserId: relayAuth.callerUserId } : {},
|
|
335
|
-
...pinnedTabId ? { pinnedTabId } : {}
|
|
360
|
+
...pinnedTabId ? { pinnedTabId } : {},
|
|
361
|
+
...recordHar !== void 0 ? { recordHar } : {},
|
|
362
|
+
...recordVideo !== void 0 ? { recordVideo } : {},
|
|
363
|
+
...serviceWorkers !== void 0 ? { serviceWorkers } : {},
|
|
364
|
+
...initRouter ? { initRouter } : {}
|
|
336
365
|
});
|
|
337
366
|
} catch (err) {
|
|
338
367
|
const cause = err instanceof Error ? err.message : String(err);
|
|
@@ -354,6 +383,24 @@ Underlying launch error: ${cause}`
|
|
|
354
383
|
tabId: tab.tabId,
|
|
355
384
|
close: tab.close
|
|
356
385
|
};
|
|
386
|
+
if (contextOptionsRequested && !routerCalled) {
|
|
387
|
+
await this.onClose().catch(() => {
|
|
388
|
+
});
|
|
389
|
+
throw new WrapperTransportError(
|
|
390
|
+
"CONTEXT_OPTIONS_NOT_APPLIED",
|
|
391
|
+
`The installed '@qontinui/ui-bridge-headless' peer launched the tab without calling initRouter, so it predates the recordHar / recordVideo / serviceWorkers / initRouter passthrough (0.8.0, ui-bridge#381) and ignored them: no HAR or video would be written and no route installed. Upgrade it to 0.8.0 or later.`,
|
|
392
|
+
{
|
|
393
|
+
details: {
|
|
394
|
+
requested: {
|
|
395
|
+
recordHar: recordHar !== void 0,
|
|
396
|
+
recordVideo: recordVideo !== void 0,
|
|
397
|
+
serviceWorkers: serviceWorkers ?? null,
|
|
398
|
+
initRouter: callerRouter !== void 0
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
}
|
|
357
404
|
await this.verifyEmulation(tab.page);
|
|
358
405
|
await this.afterLaunch(tab.page);
|
|
359
406
|
}
|
|
@@ -700,6 +747,7 @@ var InjectedTransport = class extends HeadlessTransport {
|
|
|
700
747
|
execute,
|
|
701
748
|
find: (criteria) => execute("find", criteria ?? {}),
|
|
702
749
|
act: (id, request) => execute("executeElementAction", { id, request }),
|
|
750
|
+
element: (id) => execute("getElement", { id }),
|
|
703
751
|
snapshot: (options) => execute("getControlSnapshot", options ?? {}),
|
|
704
752
|
assert: (spec) => execute("aiAssert", spec)
|
|
705
753
|
};
|
|
@@ -920,9 +968,80 @@ function createTransport(config) {
|
|
|
920
968
|
}
|
|
921
969
|
}
|
|
922
970
|
|
|
923
|
-
//
|
|
924
|
-
var
|
|
925
|
-
|
|
971
|
+
// ../ui-bridge-cli-args/dist/index.js
|
|
972
|
+
var COMMON_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--quiet"]);
|
|
973
|
+
function isFlagShaped(value) {
|
|
974
|
+
return value.startsWith("--");
|
|
975
|
+
}
|
|
976
|
+
function consumeValue(flag, raw, error) {
|
|
977
|
+
if (raw === void 0) return null;
|
|
978
|
+
if (isFlagShaped(raw)) {
|
|
979
|
+
throw error(
|
|
980
|
+
`${flag} expects a value but got the flag '${raw}' \u2014 did you omit ${flag}'s argument?`
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
return raw;
|
|
984
|
+
}
|
|
985
|
+
function parsePositiveInt(flag, raw, error) {
|
|
986
|
+
const n = raw !== null && /^\d+$/.test(raw) ? Number(raw) : NaN;
|
|
987
|
+
if (!Number.isSafeInteger(n) || n <= 0) {
|
|
988
|
+
throw error(`${flag} expects a positive integer (got ${raw ?? "<missing>"})`);
|
|
989
|
+
}
|
|
990
|
+
return n;
|
|
991
|
+
}
|
|
992
|
+
var ArgReader = class {
|
|
993
|
+
argv;
|
|
994
|
+
error;
|
|
995
|
+
valueFlags;
|
|
996
|
+
/**
|
|
997
|
+
* @param argv Already sliced past `node script`.
|
|
998
|
+
* @param known All flags the bin recognizes (union the bin's set with {@link COMMON_FLAGS}).
|
|
999
|
+
* @param error Factory producing the bin's domain error type.
|
|
1000
|
+
* @param valueFlags The flags that take a value. The token after one is that
|
|
1001
|
+
* flag's value, never a flag of its own, so `--success -h`
|
|
1002
|
+
* does not also ask for help. Without it, {@link has} cannot
|
|
1003
|
+
* tell a value from a flag.
|
|
1004
|
+
*/
|
|
1005
|
+
constructor(argv, known, error, valueFlags = /* @__PURE__ */ new Set()) {
|
|
1006
|
+
this.argv = argv;
|
|
1007
|
+
this.error = error;
|
|
1008
|
+
this.valueFlags = valueFlags;
|
|
1009
|
+
for (const arg of argv) {
|
|
1010
|
+
if (isFlagShaped(arg) && !known.has(arg)) {
|
|
1011
|
+
throw error(`Unknown flag: ${arg}`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
/** True if `name` appears as a bare boolean flag, not as a value-flag's value. */
|
|
1016
|
+
has(name) {
|
|
1017
|
+
for (let i = 0; i < this.argv.length; i++) {
|
|
1018
|
+
if (this.valueFlags.has(this.argv[i])) {
|
|
1019
|
+
i++;
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
if (this.argv[i] === name) return true;
|
|
1023
|
+
}
|
|
1024
|
+
return false;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Value following the value-flag `name`, or `null` when the flag is absent OR
|
|
1028
|
+
* has no following token (the caller defaults it). Throws when the following
|
|
1029
|
+
* token is flag-shaped — the swallow this kit exists to kill. Delegates to
|
|
1030
|
+
* {@link consumeValue} so the guard (and its message) live in exactly one
|
|
1031
|
+
* place for both the indexOf-style and switch-style parsers.
|
|
1032
|
+
*/
|
|
1033
|
+
value(name) {
|
|
1034
|
+
const i = this.argv.indexOf(name);
|
|
1035
|
+
if (i < 0 || i + 1 >= this.argv.length) return null;
|
|
1036
|
+
return consumeValue(name, this.argv[i + 1], this.error);
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
function makeLogger(prefix, quiet) {
|
|
1040
|
+
if (quiet) return () => {
|
|
1041
|
+
};
|
|
1042
|
+
return (m) => process.stderr.write(`${prefix} ${m}
|
|
1043
|
+
`) ;
|
|
1044
|
+
}
|
|
926
1045
|
|
|
927
1046
|
// src/login-drive.ts
|
|
928
1047
|
var isCognito = (u) => /auth\.qontinui\.io|amazoncognito\.com|\/oauth2\//i.test(u);
|
|
@@ -1142,17 +1261,14 @@ function computeLoginUrl(targets, origin) {
|
|
|
1142
1261
|
}
|
|
1143
1262
|
function parseArgs(argv) {
|
|
1144
1263
|
const mkError = (m) => new CaptureCliArgError(m);
|
|
1145
|
-
const reader = new
|
|
1264
|
+
const reader = new ArgReader(argv, KNOWN_FLAGS, mkError, VALUE_FLAGS);
|
|
1146
1265
|
const valueOf = (name) => reader.value(name);
|
|
1147
1266
|
const has = (name) => reader.has(name);
|
|
1148
1267
|
const help = has("--help") || has("-h");
|
|
1149
1268
|
const origin = valueOf("--origin") ?? DEFAULT_ORIGIN;
|
|
1150
1269
|
const device = valueOf("--device") ?? DEFAULT_DEVICE;
|
|
1151
1270
|
const timeoutRaw = valueOf("--timeout");
|
|
1152
|
-
const timeoutMs = timeoutRaw === null ? 7e4 :
|
|
1153
|
-
if (!help && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
|
|
1154
|
-
throw new CaptureCliArgError(`--timeout expects a positive integer (got ${timeoutRaw})`);
|
|
1155
|
-
}
|
|
1271
|
+
const timeoutMs = timeoutRaw === null || help ? 7e4 : parsePositiveInt("--timeout", timeoutRaw, mkError);
|
|
1156
1272
|
const pagesSpec = valueOf("--pages");
|
|
1157
1273
|
let pages = null;
|
|
1158
1274
|
if (pagesSpec !== null) {
|
|
@@ -1177,16 +1293,16 @@ function parseArgs(argv) {
|
|
|
1177
1293
|
validateArgs(args);
|
|
1178
1294
|
return args;
|
|
1179
1295
|
}
|
|
1180
|
-
var
|
|
1296
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
1181
1297
|
"--email",
|
|
1182
1298
|
"--password",
|
|
1183
1299
|
"--out",
|
|
1184
1300
|
"--origin",
|
|
1185
1301
|
"--pages",
|
|
1186
1302
|
"--device",
|
|
1187
|
-
"--timeout"
|
|
1188
|
-
...cli_args_exports.COMMON_FLAGS
|
|
1303
|
+
"--timeout"
|
|
1189
1304
|
]);
|
|
1305
|
+
var KNOWN_FLAGS = /* @__PURE__ */ new Set([...VALUE_FLAGS, ...COMMON_FLAGS]);
|
|
1190
1306
|
function validateArgs(args) {
|
|
1191
1307
|
if (args.help) return;
|
|
1192
1308
|
if (!args.email || !args.password) {
|
|
@@ -1211,7 +1327,7 @@ ${USAGE}`);
|
|
|
1211
1327
|
process.exit(0);
|
|
1212
1328
|
}
|
|
1213
1329
|
const { email, password, out, origin, device, timeoutMs } = args;
|
|
1214
|
-
const log =
|
|
1330
|
+
const log = makeLogger("[capture]", args.quiet);
|
|
1215
1331
|
const targets = args.pages ?? defaultTargets(origin, device);
|
|
1216
1332
|
const { loginUrl } = computeLoginUrl(targets, origin);
|
|
1217
1333
|
const transport = createTransport({
|
|
@@ -1260,7 +1376,9 @@ ${USAGE}`);
|
|
|
1260
1376
|
totalRegistered: snap?.registration?.totalRegistered ?? null,
|
|
1261
1377
|
snapshot: snap
|
|
1262
1378
|
});
|
|
1263
|
-
log(
|
|
1379
|
+
log(
|
|
1380
|
+
` -> route=${snap?.route} registered=${snap?.registration?.totalRegistered} onLogin=${onLogin}`
|
|
1381
|
+
);
|
|
1264
1382
|
}
|
|
1265
1383
|
return out2;
|
|
1266
1384
|
});
|