@qontinui/ui-bridge-wrapper 0.4.0 → 0.4.2

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.
@@ -20,7 +20,7 @@
20
20
  * ui-bridge-capture-specs --out D:/qontinui-root/spec-capture
21
21
  * (creds via env UIB_LOGIN_EMAIL/PASSWORD or --email/--password)
22
22
  */
23
- export declare const USAGE = "ui-bridge-capture-specs \u2014 log in and snapshot authed pages via the injected transport\n\nRequired (one of):\n --email <e> / --password <p> Credentials. Falls back to env\n UIB_LOGIN_EMAIL / UIB_LOGIN_PASSWORD.\n\nOptions:\n --out <dir> Output dir for <slug>.snapshot.json files\n (default D:/qontinui-root/spec-capture).\n --origin <url> App origin (default https://qontinui.io).\n --pages \"slug=path,slug=path\" Pages to capture (paths joined to --origin;\n absolute http(s) URLs used verbatim). Default =\n the two admin coord pages.\n --device <id> device_id query for the default trees page.\n --timeout <ms> Per-hop wait budget (default 70000).\n --help, -h Print this help and exit.\n\nPrerequisites (packaged bin): the optional @qontinui/ui-bridge-headless peer must\nbe installed AND Chromium available (run `npx playwright install chromium` once,\nor set PLAYWRIGHT_BROWSERS_PATH).\n\nExits non-zero if any capture bounced to login or errored.\n";
23
+ export declare const USAGE = "ui-bridge-capture-specs \u2014 log in and snapshot authed pages via the injected transport\n\nRequired (one of):\n --email <e> / --password <p> Credentials. Falls back to env\n UIB_LOGIN_EMAIL / UIB_LOGIN_PASSWORD.\n\nOptions:\n --out <dir> Output dir for <slug>.snapshot.json files\n (default D:/qontinui-root/spec-capture).\n --origin <url> App origin (default https://qontinui.io).\n --pages \"slug=path,slug=path\" Pages to capture (paths joined to --origin;\n absolute http(s) URLs used verbatim). Default =\n the two admin coord pages.\n --device <id> device_id query for the default trees page.\n --timeout <ms> Per-hop wait budget (default 70000).\n --quiet Suppress human-readable stderr logs (the per-page\n JSON lines still print).\n --help, -h Print this help and exit.\n\nPrerequisites (packaged bin): the optional @qontinui/ui-bridge-headless peer must\nbe installed AND Chromium available (run `npx playwright install chromium` once,\nor set PLAYWRIGHT_BROWSERS_PATH).\n\nExits non-zero if any capture bounced to login or errored.\n";
24
24
  /** A page to capture: a display slug + the absolute URL to navigate to. */
25
25
  export interface PageTarget {
26
26
  slug: string;
@@ -36,6 +36,8 @@ export interface CaptureCliArgs {
36
36
  timeoutMs: number;
37
37
  /** Explicit page set from --pages, or null to use the default coord pages. */
38
38
  pages: PageTarget[] | null;
39
+ /** Suppress human-readable stderr logs (the per-page JSON lines still print). */
40
+ quiet: boolean;
39
41
  help: boolean;
40
42
  }
41
43
  /** Error raised by `parseArgs`/validation (no `process.exit` — testable). */
@@ -50,22 +52,6 @@ export declare class CaptureCliArgError extends Error {
50
52
  export declare function parsePages(spec: string, origin: string): PageTarget[];
51
53
  /** The default coord page set (used when --pages is absent). */
52
54
  export declare function defaultTargets(origin: string, device: string): PageTarget[];
53
- /**
54
- * Cognito is identified by HOST (custom domain / raw Cognito domain) or the
55
- * /oauth2/ endpoints — never by a bare `/login?` path match: the app's own
56
- * login URL now legitimately carries a query (`/login?next=…`), and a path
57
- * match would misclassify it as Cognito, silently disabling the
58
- * bounced-back-to-login detection below.
59
- */
60
- export declare const isCognito: (u: string) => boolean;
61
- /** Extract a URL's pathname; '' for an unparseable value. */
62
- export declare const pathOf: (u: string) => string;
63
- /**
64
- * Strict URL checks compare PATHNAMES, never the whole URL — a query param
65
- * echoing a path (state=…%2Fco-pilot) must not fake a match. Same fix as
66
- * login-web (#81). True when the URL is the app's OWN /login page.
67
- */
68
- export declare const isLoginPath: (u: string) => boolean;
69
55
  /**
70
56
  * Deep-link the login through the first same-origin target (`?next=`) so the
71
57
  * post-login landing is the target itself. Cross-origin first targets (absolute
@@ -1 +1 @@
1
- {"version":3,"file":"capture-specs-cli.d.ts","sourceRoot":"","sources":["../src/capture-specs-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH,eAAO,MAAM,KAAK,uqCAsBjB,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AAM,EAAE,GAAG,cAAc,CA8CxD;AAaD,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAKvD"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Shared CLI argument primitives for the package bins (`ui-bridge-login-web`,
3
+ * `ui-bridge-capture-specs`, `ui-bridge-inject`). Each bin used to re-implement
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.
10
+ *
11
+ * The bins keep their own typed `parseArgs` (the arg SHAPE differs per bin); this
12
+ * module only owns the low-level reading + the cross-bin invariants (flag-shaped
13
+ * value rejection, unknown-flag rejection, the shared `--quiet`/`--help` flags,
14
+ * and a `--quiet`-aware stderr logger).
15
+ */
16
+ /**
17
+ * Construct a bin's own domain error from a message. Passing the factory keeps
18
+ * thrown errors the bin's specific type (`LoginCliArgError` / `CaptureCliArgError`
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;
75
+ //# sourceMappingURL=cli-args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAAwC,CAAC;AAWtF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,eAAe,GACrB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,KAAK,EAAE,eAAe,GACrB,MAAM,GAAG,IAAI,CAOf;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IAExC;;;;OAIG;gBACS,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,eAAe;IAUvF,qDAAqD;IACrD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAKnC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAKpF"}
package/dist/index.cjs CHANGED
@@ -226,19 +226,53 @@ var HeadlessTransport = class extends BaseTransport {
226
226
  };
227
227
  }
228
228
  async onReady() {
229
- const { launchHeadlessTab } = await import('@qontinui/ui-bridge-headless');
229
+ let launchHeadlessTab;
230
+ try {
231
+ ({ launchHeadlessTab } = await import('@qontinui/ui-bridge-headless'));
232
+ } catch (err) {
233
+ const cause = err instanceof Error ? err.message : String(err);
234
+ const code = err?.code;
235
+ if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
236
+ throw new WrapperTransportError(
237
+ "INVALID_CONFIG",
238
+ `Transport kind '${this.kind}' needs the optional '@qontinui/ui-bridge-headless' peer, which is not installed. Install it and the Chromium browser:
239
+ npm i @qontinui/ui-bridge-headless && npx playwright install chromium
240
+ (bare \`npx @qontinui/ui-bridge-wrapper \u2026\` does NOT install peers \u2014 pass each peer with \`-p\`, e.g.
241
+ npx -y -p @qontinui/ui-bridge-wrapper -p @qontinui/ui-bridge -p @qontinui/ui-bridge-headless -p playwright ui-bridge-login-web \u2026)
242
+ Underlying import error: ${cause}`
243
+ );
244
+ }
245
+ throw new WrapperTransportError(
246
+ "INVALID_CONFIG",
247
+ `'@qontinui/ui-bridge-headless' is installed but failed to load \u2014 this is a broken install (missing transitive dependency or version skew), not a missing peer. Try reinstalling it. Underlying error: ${cause}`
248
+ );
249
+ }
230
250
  const initScripts = await this.buildInitScripts();
231
- const tab = await launchHeadlessTab({
232
- url: this.options.targetUrl,
233
- headless: this.headless,
234
- uiBridgeBase: this.options.uiBridgeBase,
235
- waitForUiBridgeMs: this.options.waitForUiBridgeMs,
236
- viewportWidth: this.options.viewportWidth,
237
- viewportHeight: this.options.viewportHeight,
238
- userAgent: this.options.userAgent,
239
- forwardConsole: this.options.forwardConsole,
240
- initScripts: initScripts.length > 0 ? initScripts : void 0
241
- });
251
+ let tab;
252
+ try {
253
+ tab = await launchHeadlessTab({
254
+ url: this.options.targetUrl,
255
+ headless: this.headless,
256
+ uiBridgeBase: this.options.uiBridgeBase,
257
+ waitForUiBridgeMs: this.options.waitForUiBridgeMs,
258
+ viewportWidth: this.options.viewportWidth,
259
+ viewportHeight: this.options.viewportHeight,
260
+ userAgent: this.options.userAgent,
261
+ forwardConsole: this.options.forwardConsole,
262
+ initScripts: initScripts.length > 0 ? initScripts : void 0
263
+ });
264
+ } catch (err) {
265
+ const cause = err instanceof Error ? err.message : String(err);
266
+ if (/Executable doesn't exist|browserType\.launch/i.test(cause)) {
267
+ throw new WrapperTransportError(
268
+ "INVALID_CONFIG",
269
+ `Playwright's Chromium browser is not installed (the '@qontinui/ui-bridge-headless' peer itself loaded fine). Run:
270
+ npx playwright install chromium
271
+ Underlying launch error: ${cause}`
272
+ );
273
+ }
274
+ throw err;
275
+ }
242
276
  this.tab = {
243
277
  browser: tab.browser,
244
278
  context: tab.context,