@qontinui/ui-bridge-wrapper 0.6.0 → 0.7.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/dist/capture-specs-cli.cjs +105 -56
- package/dist/capture-specs-cli.cjs.map +1 -1
- package/dist/cli-args.d.ts +10 -72
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/index.cjs +66 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -2
- package/dist/index.js.map +1 -1
- package/dist/inject-cli.cjs +117 -26
- package/dist/inject-cli.cjs.map +1 -1
- package/dist/login-web-cli.cjs +121 -68
- package/dist/login-web-cli.cjs.map +1 -1
- package/dist/session-storage-capture.d.ts +31 -4
- package/dist/session-storage-capture.d.ts.map +1 -1
- package/dist/transports/injected.d.ts +19 -0
- package/dist/transports/injected.d.ts.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -4
package/dist/cli-args.d.ts
CHANGED
|
@@ -1,75 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared CLI argument primitives for the
|
|
3
|
-
* `ui-bridge-capture-specs`, `ui-bridge-inject`).
|
|
4
|
-
* its own `valueOf`/`has`/unknown-flag kit, and those copies drifted — most
|
|
5
|
-
* importantly, every one of them silently SWALLOWED a flag-shaped value: a
|
|
6
|
-
* value-flag followed by another `--flag` (e.g. `--success --headed`) captured
|
|
7
|
-
* the flag as the value, so a *successful* login could report `ok:false` because
|
|
8
|
-
* its `--success` target was literally `"--headed"`. The kit below is the single
|
|
9
|
-
* home for argument reading and rejects that swallow uniformly.
|
|
2
|
+
* Shared CLI argument primitives for the wrapper bins (`ui-bridge-login-web`,
|
|
3
|
+
* `ui-bridge-capture-specs`, `ui-bridge-inject`).
|
|
10
4
|
*
|
|
11
|
-
* The
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* / `InjectCliArgError`) so each bin's `main()` `instanceof` catch still fires.
|
|
20
|
-
*/
|
|
21
|
-
export type ArgErrorFactory = (message: string) => Error;
|
|
22
|
-
/**
|
|
23
|
-
* Flags shared by every bin. A bin unions these into its own KNOWN set so the
|
|
24
|
-
* common surface (`--help`, `-h`, `--quiet`) is defined in exactly one place.
|
|
25
|
-
*/
|
|
26
|
-
export declare const COMMON_FLAGS: ReadonlySet<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Guard a single value consumed by a *switch-style* parser (`argv[++i]`) against
|
|
29
|
-
* the flag-shaped swallow. Returns the value, `null` when it's simply absent
|
|
30
|
-
* (end of argv — the caller applies its own required/default handling), and
|
|
31
|
-
* THROWS (via `error`) when the value is flag-shaped — that is never an intended
|
|
32
|
-
* value, it's an omitted argument.
|
|
33
|
-
*/
|
|
34
|
-
export declare function consumeValue(flag: string, raw: string | undefined, error: ArgErrorFactory): string | null;
|
|
35
|
-
/**
|
|
36
|
-
* Reject a present-but-empty value (`--success ''`). An empty value on a
|
|
37
|
-
* matching/target flag is never intended — e.g. an empty `--success` makes
|
|
38
|
-
* `landingPath.includes('')` true on ANY landing page, turning a stuck login
|
|
39
|
-
* into a false success (the exact exit-code-trust failure #83 exists to
|
|
40
|
-
* prevent). `null` (flag absent — caller defaults it) passes through.
|
|
41
|
-
*/
|
|
42
|
-
export declare function rejectEmptyValue(flag: string, value: string | null, error: ArgErrorFactory): string | null;
|
|
43
|
-
/**
|
|
44
|
-
* An `indexOf`-based reader for the browser bins' flat arg lists. Rejects unknown
|
|
45
|
-
* `--flags` up front (matching each bin's prior behavior) and rejects flag-shaped
|
|
46
|
-
* values for value-flags (the swallow fix).
|
|
47
|
-
*/
|
|
48
|
-
export declare class ArgReader {
|
|
49
|
-
private readonly argv;
|
|
50
|
-
private readonly error;
|
|
51
|
-
/**
|
|
52
|
-
* @param argv Already sliced past `node script`.
|
|
53
|
-
* @param known All flags the bin recognizes (union the bin's set with {@link COMMON_FLAGS}).
|
|
54
|
-
* @param error Factory producing the bin's domain error type.
|
|
55
|
-
*/
|
|
56
|
-
constructor(argv: readonly string[], known: ReadonlySet<string>, error: ArgErrorFactory);
|
|
57
|
-
/** True if `name` appears as a bare boolean flag. */
|
|
58
|
-
has(name: string): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Value following the value-flag `name`, or `null` when the flag is absent OR
|
|
61
|
-
* has no following token (the caller defaults it). Throws when the following
|
|
62
|
-
* token is flag-shaped — the swallow this kit exists to kill. Delegates to
|
|
63
|
-
* {@link consumeValue} so the guard (and its message) live in exactly one
|
|
64
|
-
* place for both the indexOf-style and switch-style parsers.
|
|
65
|
-
*/
|
|
66
|
-
value(name: string): string | null;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Build a `--quiet`-aware stderr logger. When `quiet` is true it drops every
|
|
70
|
-
* line; otherwise it writes `<prefix> <message>` (or just `<message>` when
|
|
71
|
-
* `prefix` is empty) to stderr. Shared so all three bins honor `--quiet`
|
|
72
|
-
* identically.
|
|
73
|
-
*/
|
|
74
|
-
export declare function makeLogger(prefix: string, quiet: boolean): (message: string) => void;
|
|
5
|
+
* The primitives themselves now live in the zero-dependency leaf package
|
|
6
|
+
* `@qontinui/ui-bridge-cli-args`, so the sibling `@qontinui/ui-bridge-headless`
|
|
7
|
+
* bin (`ui-bridge-tab`) can import the same swallow guard without a dependency
|
|
8
|
+
* cycle (the wrapper AND the engine both depend *down* onto headless, so neither
|
|
9
|
+
* could host code headless imports). This file stays as a stable re-export so the
|
|
10
|
+
* three bins' `import … from './cli-args.js'` keep working — no bin churn.
|
|
11
|
+
*/
|
|
12
|
+
export * from '@qontinui/ui-bridge-cli-args';
|
|
75
13
|
//# sourceMappingURL=cli-args.d.ts.map
|
package/dist/cli-args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,8BAA8B,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -9,6 +9,13 @@ var WrapperTransportError = class extends Error {
|
|
|
9
9
|
code;
|
|
10
10
|
retryable;
|
|
11
11
|
cause;
|
|
12
|
+
/**
|
|
13
|
+
* Optional structured diagnostic payload (error-code-specific shape) so
|
|
14
|
+
* programmatic callers can branch on data instead of parsing the message —
|
|
15
|
+
* e.g. `INJECTED_EXPECT_SELECTOR_UNMET` attaches
|
|
16
|
+
* `{ registeredElements, elementCount }`.
|
|
17
|
+
*/
|
|
18
|
+
details;
|
|
12
19
|
constructor(code, message, options = {}) {
|
|
13
20
|
super(message);
|
|
14
21
|
this.name = "WrapperTransportError";
|
|
@@ -17,6 +24,9 @@ var WrapperTransportError = class extends Error {
|
|
|
17
24
|
if (options.cause !== void 0) {
|
|
18
25
|
this.cause = options.cause;
|
|
19
26
|
}
|
|
27
|
+
if (options.details !== void 0) {
|
|
28
|
+
this.details = options.details;
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
31
|
};
|
|
22
32
|
|
|
@@ -347,6 +357,8 @@ var HeadedTransport = class extends HeadlessTransport {
|
|
|
347
357
|
};
|
|
348
358
|
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
349
359
|
var cachedBundle = null;
|
|
360
|
+
var DIGEST_MAX_ELEMENTS = 10;
|
|
361
|
+
var DIGEST_TIMEOUT_MS = 5e3;
|
|
350
362
|
function loadInjectedBundle() {
|
|
351
363
|
if (cachedBundle !== null) return cachedBundle;
|
|
352
364
|
let bundlePath;
|
|
@@ -473,14 +485,66 @@ var InjectedTransport = class extends HeadlessTransport {
|
|
|
473
485
|
}
|
|
474
486
|
if (state.settledByTimeout && !state.expectSatisfied) {
|
|
475
487
|
const sel = this.injected.expectSelector;
|
|
488
|
+
const baseMessage = sel ? `The injected runtime settled at its cap without the expected control (selector '${sel}') appearing \u2014 ${state.elementCount} element(s) were registered, but none matched. The control may mount slower than the settle cap (raise options.settleTimeoutMs), the selector may be wrong, or the inject failed. Treat as BLOCKED/UNVERIFIED, not a clean page.` : `The injected runtime settled at its cap with an empty registry (0 elements). The page never rendered interactive content within the settle cap, or the inject failed. Raise options.settleTimeoutMs for a slow page; otherwise treat as BLOCKED/UNVERIFIED.`;
|
|
489
|
+
const digest = await this.registeredElementDigest(page);
|
|
490
|
+
if (digest === null) {
|
|
491
|
+
throw new WrapperTransportError("INJECTED_EXPECT_SELECTOR_UNMET", baseMessage, {
|
|
492
|
+
retryable: true
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
const summary = digest.length > 0 ? ` Registered: ${digest.map((el) => el.role ? `${el.id} (${el.role})` : el.id).join(", ")}${state.elementCount > digest.length ? ", \u2026" : ""}` : "";
|
|
476
496
|
throw new WrapperTransportError(
|
|
477
497
|
"INJECTED_EXPECT_SELECTOR_UNMET",
|
|
478
|
-
|
|
479
|
-
{
|
|
498
|
+
`${baseMessage}${summary}`,
|
|
499
|
+
{
|
|
500
|
+
retryable: true,
|
|
501
|
+
details: { registeredElements: digest, elementCount: state.elementCount }
|
|
502
|
+
}
|
|
480
503
|
);
|
|
481
504
|
}
|
|
482
505
|
}
|
|
483
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Best-effort digest of the first {@link DIGEST_MAX_ELEMENTS} registered
|
|
509
|
+
* interactive elements, read through the in-page dispatcher's
|
|
510
|
+
* `getControlSnapshot` action (the snapshot's per-element projection is
|
|
511
|
+
* already redaction-safe — we never read raw DOM labels here). Returns
|
|
512
|
+
* `null` on ANY failure or timeout: this feeds error diagnostics only, and a
|
|
513
|
+
* broken page realm must never mask the error being reported.
|
|
514
|
+
*/
|
|
515
|
+
async registeredElementDigest(page) {
|
|
516
|
+
let timer;
|
|
517
|
+
try {
|
|
518
|
+
const snapshotPromise = page.evaluate(
|
|
519
|
+
() => window.__uiBridgeInjected.execute("getControlSnapshot", { skipSettle: true })
|
|
520
|
+
);
|
|
521
|
+
const snapshot = await Promise.race([
|
|
522
|
+
snapshotPromise,
|
|
523
|
+
new Promise((_, reject) => {
|
|
524
|
+
timer = setTimeout(() => reject(new Error("digest fetch timed out")), DIGEST_TIMEOUT_MS);
|
|
525
|
+
})
|
|
526
|
+
]);
|
|
527
|
+
if (!snapshot || typeof snapshot !== "object") return null;
|
|
528
|
+
const elements = snapshot.elements;
|
|
529
|
+
if (!Array.isArray(elements)) return null;
|
|
530
|
+
const digest = [];
|
|
531
|
+
for (const el of elements.slice(0, DIGEST_MAX_ELEMENTS)) {
|
|
532
|
+
if (!el || typeof el !== "object") continue;
|
|
533
|
+
const e = el;
|
|
534
|
+
if (typeof e.id !== "string") continue;
|
|
535
|
+
digest.push({
|
|
536
|
+
id: e.id,
|
|
537
|
+
...typeof e.role === "string" ? { role: e.role } : {},
|
|
538
|
+
...typeof e.label === "string" ? { label: e.label } : {}
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return digest;
|
|
542
|
+
} catch {
|
|
543
|
+
return null;
|
|
544
|
+
} finally {
|
|
545
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
484
548
|
async buildContext() {
|
|
485
549
|
if (!this.tab) {
|
|
486
550
|
throw new WrapperTransportError(
|