@qontinui/ui-bridge-wrapper 0.11.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 +129 -8
- package/dist/capture-specs-cli.cjs +171 -50
- package/dist/capture-specs-cli.cjs.map +1 -1
- package/dist/capture-specs-cli.d.ts.map +1 -1
- package/dist/index.cjs +88 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -4
- package/dist/index.js.map +1 -1
- package/dist/inject-cli.cjs +283 -115
- 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 +178 -54
- 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 +10 -2
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture-specs-cli.d.ts","sourceRoot":"","sources":["../src/capture-specs-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"capture-specs-cli.d.ts","sourceRoot":"","sources":["../src/capture-specs-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAeH,eAAO,MAAM,KAAK,wzCAwBjB,CAAC;AAWF,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAC3B,iFAAiF;IACjF,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf;AAED,6EAA6E;AAC7E,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAoBrE;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAK3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,UAAU,EAAE,EACrB,MAAM,EAAE,MAAM,GACb;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAYhD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CA6CxD;AAeD,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAKvD"}
|
package/dist/index.cjs
CHANGED
|
@@ -237,9 +237,60 @@ var HeadlessTransport = class extends BaseTransport {
|
|
|
237
237
|
userAgent: typeof raw["userAgent"] === "string" ? raw["userAgent"] : void 0,
|
|
238
238
|
forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0,
|
|
239
239
|
launchArgs: Array.isArray(raw["launchArgs"]) && raw["launchArgs"].every((a) => typeof a === "string") ? raw["launchArgs"] : void 0,
|
|
240
|
-
storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0
|
|
240
|
+
storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0,
|
|
241
|
+
...this.parseContextOptions(raw)
|
|
241
242
|
};
|
|
242
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* `recordHar`, `recordVideo`, `serviceWorkers` and `initRouter`. Unlike the display
|
|
246
|
+
* options above, a malformed value is REFUSED rather than dropped: dropping
|
|
247
|
+
* `recordHar` would leave a caller waiting for an archive that is never
|
|
248
|
+
* written, and dropping `initRouter` would let requests it meant to answer
|
|
249
|
+
* reach the network.
|
|
250
|
+
*/
|
|
251
|
+
parseContextOptions(raw) {
|
|
252
|
+
const out = {};
|
|
253
|
+
const invalid = (what) => new WrapperTransportError("INVALID_CONFIG", `Transport kind '${this.kind}': ${what}`);
|
|
254
|
+
const har = raw["recordHar"];
|
|
255
|
+
if (har !== void 0) {
|
|
256
|
+
if (typeof har !== "object" || har === null || typeof har.path !== "string" || har.path.length === 0) {
|
|
257
|
+
throw invalid("options.recordHar must be an object with a non-empty string `path`");
|
|
258
|
+
}
|
|
259
|
+
out.recordHar = har;
|
|
260
|
+
}
|
|
261
|
+
const video = raw["recordVideo"];
|
|
262
|
+
if (video !== void 0) {
|
|
263
|
+
if (typeof video !== "object" || video === null || typeof video.dir !== "string" || video.dir.length === 0) {
|
|
264
|
+
throw invalid("options.recordVideo must be an object with a non-empty string `dir`");
|
|
265
|
+
}
|
|
266
|
+
const size = video.size;
|
|
267
|
+
if (size !== void 0) {
|
|
268
|
+
const positiveInt = (n) => typeof n === "number" && Number.isInteger(n) && n > 0;
|
|
269
|
+
const s = size;
|
|
270
|
+
if (typeof size !== "object" || s === null || !positiveInt(s.width) || !positiveInt(s.height)) {
|
|
271
|
+
throw invalid(
|
|
272
|
+
"options.recordVideo.size must be { width, height } with positive integer sides"
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
out.recordVideo = video;
|
|
277
|
+
}
|
|
278
|
+
const sw = raw["serviceWorkers"];
|
|
279
|
+
if (sw !== void 0) {
|
|
280
|
+
if (sw !== "allow" && sw !== "block") {
|
|
281
|
+
throw invalid(`options.serviceWorkers must be 'allow' or 'block' (got ${String(sw)})`);
|
|
282
|
+
}
|
|
283
|
+
out.serviceWorkers = sw;
|
|
284
|
+
}
|
|
285
|
+
const router = raw["initRouter"];
|
|
286
|
+
if (router !== void 0) {
|
|
287
|
+
if (typeof router !== "function") {
|
|
288
|
+
throw invalid("options.initRouter must be a function (context) => void | Promise<void>");
|
|
289
|
+
}
|
|
290
|
+
out.initRouter = router;
|
|
291
|
+
}
|
|
292
|
+
return out;
|
|
293
|
+
}
|
|
243
294
|
async onReady() {
|
|
244
295
|
let launchHeadlessTab;
|
|
245
296
|
const headlessSpecifier = "@qontinui/ui-bridge-headless";
|
|
@@ -267,6 +318,13 @@ Underlying import error: ${cause}`
|
|
|
267
318
|
const initScripts = await this.buildInitScripts();
|
|
268
319
|
const relayAuth = this.relayAuth();
|
|
269
320
|
const pinnedTabId = this.pinnedTabId();
|
|
321
|
+
const { recordHar, recordVideo, serviceWorkers, initRouter: callerRouter } = this.options;
|
|
322
|
+
const contextOptionsRequested = recordHar !== void 0 || recordVideo !== void 0 || serviceWorkers === "block" || callerRouter !== void 0;
|
|
323
|
+
let routerCalled = false;
|
|
324
|
+
const initRouter = contextOptionsRequested || serviceWorkers !== void 0 ? async (context) => {
|
|
325
|
+
routerCalled = true;
|
|
326
|
+
if (callerRouter) await callerRouter(context);
|
|
327
|
+
} : void 0;
|
|
270
328
|
let tab;
|
|
271
329
|
try {
|
|
272
330
|
tab = await launchHeadlessTab({
|
|
@@ -285,7 +343,11 @@ Underlying import error: ${cause}`
|
|
|
285
343
|
storageStatePath: this.options.storageStatePath,
|
|
286
344
|
...relayAuth.authToken ? { authToken: relayAuth.authToken } : {},
|
|
287
345
|
...relayAuth.callerUserId ? { callerUserId: relayAuth.callerUserId } : {},
|
|
288
|
-
...pinnedTabId ? { pinnedTabId } : {}
|
|
346
|
+
...pinnedTabId ? { pinnedTabId } : {},
|
|
347
|
+
...recordHar !== void 0 ? { recordHar } : {},
|
|
348
|
+
...recordVideo !== void 0 ? { recordVideo } : {},
|
|
349
|
+
...serviceWorkers !== void 0 ? { serviceWorkers } : {},
|
|
350
|
+
...initRouter ? { initRouter } : {}
|
|
289
351
|
});
|
|
290
352
|
} catch (err) {
|
|
291
353
|
const cause = err instanceof Error ? err.message : String(err);
|
|
@@ -307,6 +369,24 @@ Underlying launch error: ${cause}`
|
|
|
307
369
|
tabId: tab.tabId,
|
|
308
370
|
close: tab.close
|
|
309
371
|
};
|
|
372
|
+
if (contextOptionsRequested && !routerCalled) {
|
|
373
|
+
await this.onClose().catch(() => {
|
|
374
|
+
});
|
|
375
|
+
throw new WrapperTransportError(
|
|
376
|
+
"CONTEXT_OPTIONS_NOT_APPLIED",
|
|
377
|
+
`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.`,
|
|
378
|
+
{
|
|
379
|
+
details: {
|
|
380
|
+
requested: {
|
|
381
|
+
recordHar: recordHar !== void 0,
|
|
382
|
+
recordVideo: recordVideo !== void 0,
|
|
383
|
+
serviceWorkers: serviceWorkers ?? null,
|
|
384
|
+
initRouter: callerRouter !== void 0
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
310
390
|
await this.verifyEmulation(tab.page);
|
|
311
391
|
await this.afterLaunch(tab.page);
|
|
312
392
|
}
|
|
@@ -564,7 +644,7 @@ var InjectedTransport = class extends HeadlessTransport {
|
|
|
564
644
|
}
|
|
565
645
|
/**
|
|
566
646
|
* Best-effort digest of the first {@link DIGEST_MAX_ELEMENTS} registered
|
|
567
|
-
* interactive elements, read through the in-page dispatcher's
|
|
647
|
+
* interactive and media elements, read through the in-page dispatcher's
|
|
568
648
|
* `getControlSnapshot` action (the snapshot's per-element projection is
|
|
569
649
|
* already redaction-safe — we never read raw DOM labels here). Returns
|
|
570
650
|
* `null` on ANY failure or timeout: this feeds error diagnostics only, and a
|
|
@@ -586,7 +666,10 @@ var InjectedTransport = class extends HeadlessTransport {
|
|
|
586
666
|
const elements = snapshot.elements;
|
|
587
667
|
if (!Array.isArray(elements)) return null;
|
|
588
668
|
const digest = [];
|
|
589
|
-
|
|
669
|
+
const counted = elements.filter(
|
|
670
|
+
(el) => el?.category !== "content"
|
|
671
|
+
);
|
|
672
|
+
for (const el of counted.slice(0, DIGEST_MAX_ELEMENTS)) {
|
|
590
673
|
if (!el || typeof el !== "object") continue;
|
|
591
674
|
const e = el;
|
|
592
675
|
if (typeof e.id !== "string") continue;
|
|
@@ -650,6 +733,7 @@ var InjectedTransport = class extends HeadlessTransport {
|
|
|
650
733
|
execute,
|
|
651
734
|
find: (criteria) => execute("find", criteria ?? {}),
|
|
652
735
|
act: (id, request) => execute("executeElementAction", { id, request }),
|
|
736
|
+
element: (id) => execute("getElement", { id }),
|
|
653
737
|
snapshot: (options) => execute("getControlSnapshot", options ?? {}),
|
|
654
738
|
assert: (spec) => execute("aiAssert", spec)
|
|
655
739
|
};
|