@qontinui/ui-bridge-wrapper 0.4.1 → 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.
package/README.md CHANGED
@@ -68,6 +68,14 @@ or a global/dev install:
68
68
 
69
69
  Each bin supports `--help`.
70
70
 
71
+ > **Version floor:** the bins exist only at `@qontinui/ui-bridge-wrapper` **>= 0.4.0**
72
+ > (the `scripts/` predecessors were deleted in the same release). A pin or cached
73
+ > npx resolution below that yields `command not found: ui-bridge-login-web` —
74
+ > upgrade rather than hunting for the bin. Also note: since 0.4.1 an explicit but
75
+ > EMPTY `--pages` errors (exit 2) instead of silently capturing the default page
76
+ > set, and (0.4.2) an empty `--success`/`--url` value is rejected rather than
77
+ > matching every landing page.
78
+
71
79
  ### Prerequisites for the browser-driving bins
72
80
 
73
81
  `ui-bridge-login-web` and `ui-bridge-capture-specs` launch Chromium via the
@@ -239,27 +239,48 @@ var HeadlessTransport = class extends BaseTransport {
239
239
  ({ launchHeadlessTab } = await import('@qontinui/ui-bridge-headless'));
240
240
  } catch (err) {
241
241
  const cause = err instanceof Error ? err.message : String(err);
242
- throw new WrapperTransportError(
243
- "INVALID_CONFIG",
244
- `Transport kind '${this.kind}' needs the optional '@qontinui/ui-bridge-headless' peer, which is not installed. Install it and the Chromium browser:
242
+ const code = err?.code;
243
+ if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
244
+ throw new WrapperTransportError(
245
+ "INVALID_CONFIG",
246
+ `Transport kind '${this.kind}' needs the optional '@qontinui/ui-bridge-headless' peer, which is not installed. Install it and the Chromium browser:
245
247
  npm i @qontinui/ui-bridge-headless && npx playwright install chromium
246
248
  (bare \`npx @qontinui/ui-bridge-wrapper \u2026\` does NOT install peers \u2014 pass each peer with \`-p\`, e.g.
247
249
  npx -y -p @qontinui/ui-bridge-wrapper -p @qontinui/ui-bridge -p @qontinui/ui-bridge-headless -p playwright ui-bridge-login-web \u2026)
248
250
  Underlying import error: ${cause}`
251
+ );
252
+ }
253
+ throw new WrapperTransportError(
254
+ "INVALID_CONFIG",
255
+ `'@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}`
249
256
  );
250
257
  }
251
258
  const initScripts = await this.buildInitScripts();
252
- const tab = await launchHeadlessTab({
253
- url: this.options.targetUrl,
254
- headless: this.headless,
255
- uiBridgeBase: this.options.uiBridgeBase,
256
- waitForUiBridgeMs: this.options.waitForUiBridgeMs,
257
- viewportWidth: this.options.viewportWidth,
258
- viewportHeight: this.options.viewportHeight,
259
- userAgent: this.options.userAgent,
260
- forwardConsole: this.options.forwardConsole,
261
- initScripts: initScripts.length > 0 ? initScripts : void 0
262
- });
259
+ let tab;
260
+ try {
261
+ tab = await launchHeadlessTab({
262
+ url: this.options.targetUrl,
263
+ headless: this.headless,
264
+ uiBridgeBase: this.options.uiBridgeBase,
265
+ waitForUiBridgeMs: this.options.waitForUiBridgeMs,
266
+ viewportWidth: this.options.viewportWidth,
267
+ viewportHeight: this.options.viewportHeight,
268
+ userAgent: this.options.userAgent,
269
+ forwardConsole: this.options.forwardConsole,
270
+ initScripts: initScripts.length > 0 ? initScripts : void 0
271
+ });
272
+ } catch (err) {
273
+ const cause = err instanceof Error ? err.message : String(err);
274
+ if (/Executable doesn't exist|browserType\.launch/i.test(cause)) {
275
+ throw new WrapperTransportError(
276
+ "INVALID_CONFIG",
277
+ `Playwright's Chromium browser is not installed (the '@qontinui/ui-bridge-headless' peer itself loaded fine). Run:
278
+ npx playwright install chromium
279
+ Underlying launch error: ${cause}`
280
+ );
281
+ }
282
+ throw err;
283
+ }
263
284
  this.tab = {
264
285
  browser: tab.browser,
265
286
  context: tab.context,
@@ -710,6 +731,13 @@ var COMMON_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--quiet"]);
710
731
  function isFlagShaped(value) {
711
732
  return value.startsWith("--");
712
733
  }
734
+ function consumeValue(flag, raw, error) {
735
+ if (raw === void 0) return null;
736
+ if (isFlagShaped(raw)) {
737
+ throw error(`${flag} expects a value but got the flag '${raw}' \u2014 did you omit ${flag}'s argument?`);
738
+ }
739
+ return raw;
740
+ }
713
741
  var ArgReader = class {
714
742
  argv;
715
743
  error;
@@ -734,18 +762,14 @@ var ArgReader = class {
734
762
  /**
735
763
  * Value following the value-flag `name`, or `null` when the flag is absent OR
736
764
  * has no following token (the caller defaults it). Throws when the following
737
- * token is flag-shaped — the swallow this kit exists to kill.
765
+ * token is flag-shaped — the swallow this kit exists to kill. Delegates to
766
+ * {@link consumeValue} so the guard (and its message) live in exactly one
767
+ * place for both the indexOf-style and switch-style parsers.
738
768
  */
739
769
  value(name) {
740
770
  const i = this.argv.indexOf(name);
741
771
  if (i < 0 || i + 1 >= this.argv.length) return null;
742
- const raw = this.argv[i + 1];
743
- if (isFlagShaped(raw)) {
744
- throw this.error(
745
- `${name} expects a value but got the flag '${raw}' \u2014 did you omit ${name}'s argument?`
746
- );
747
- }
748
- return raw;
772
+ return consumeValue(name, this.argv[i + 1], this.error);
749
773
  }
750
774
  };
751
775
  function makeLogger(prefix, quiet) {
@@ -862,7 +886,7 @@ async function loginDrive(page, { email, password, timeoutMs, log = () => {
862
886
  } catch {
863
887
  const errorText2 = await scrapeErrorCard(page);
864
888
  const finalUrl2 = page.url();
865
- log(`final ${finalUrl2} (stalled)`);
889
+ log(`stalled ${finalUrl2}`);
866
890
  return { ok: false, finalUrl: finalUrl2, landingPath: pathOf(finalUrl2), errorText: errorText2 };
867
891
  }
868
892
  }
@@ -874,9 +898,9 @@ async function loginDrive(page, { email, password, timeoutMs, log = () => {
874
898
  ).catch(() => {
875
899
  });
876
900
  const finalUrl = page.url();
877
- log(`final ${finalUrl}`);
878
901
  const landingPath = await page.evaluate(() => location.pathname).catch(() => pathOf(finalUrl));
879
902
  const ok = !isAppLoginPath(finalUrl) && !isCognito(finalUrl) && !/\/auth\/callback/.test(pathOf(finalUrl));
903
+ log(ok ? `authed ${finalUrl}` : `stalled ${finalUrl}`);
880
904
  const errorText = ok ? null : await scrapeErrorCard(page);
881
905
  return { ok, finalUrl, landingPath, errorText };
882
906
  }