@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.
@@ -233,27 +233,48 @@ var HeadlessTransport = class extends BaseTransport {
233
233
  ({ launchHeadlessTab } = await import('@qontinui/ui-bridge-headless'));
234
234
  } catch (err) {
235
235
  const cause = err instanceof Error ? err.message : String(err);
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:
236
+ const code = err?.code;
237
+ if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
238
+ throw new WrapperTransportError(
239
+ "INVALID_CONFIG",
240
+ `Transport kind '${this.kind}' needs the optional '@qontinui/ui-bridge-headless' peer, which is not installed. Install it and the Chromium browser:
239
241
  npm i @qontinui/ui-bridge-headless && npx playwright install chromium
240
242
  (bare \`npx @qontinui/ui-bridge-wrapper \u2026\` does NOT install peers \u2014 pass each peer with \`-p\`, e.g.
241
243
  npx -y -p @qontinui/ui-bridge-wrapper -p @qontinui/ui-bridge -p @qontinui/ui-bridge-headless -p playwright ui-bridge-login-web \u2026)
242
244
  Underlying import error: ${cause}`
245
+ );
246
+ }
247
+ throw new WrapperTransportError(
248
+ "INVALID_CONFIG",
249
+ `'@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}`
243
250
  );
244
251
  }
245
252
  const initScripts = await this.buildInitScripts();
246
- const tab = await launchHeadlessTab({
247
- url: this.options.targetUrl,
248
- headless: this.headless,
249
- uiBridgeBase: this.options.uiBridgeBase,
250
- waitForUiBridgeMs: this.options.waitForUiBridgeMs,
251
- viewportWidth: this.options.viewportWidth,
252
- viewportHeight: this.options.viewportHeight,
253
- userAgent: this.options.userAgent,
254
- forwardConsole: this.options.forwardConsole,
255
- initScripts: initScripts.length > 0 ? initScripts : void 0
256
- });
253
+ let tab;
254
+ try {
255
+ tab = await launchHeadlessTab({
256
+ url: this.options.targetUrl,
257
+ headless: this.headless,
258
+ uiBridgeBase: this.options.uiBridgeBase,
259
+ waitForUiBridgeMs: this.options.waitForUiBridgeMs,
260
+ viewportWidth: this.options.viewportWidth,
261
+ viewportHeight: this.options.viewportHeight,
262
+ userAgent: this.options.userAgent,
263
+ forwardConsole: this.options.forwardConsole,
264
+ initScripts: initScripts.length > 0 ? initScripts : void 0
265
+ });
266
+ } catch (err) {
267
+ const cause = err instanceof Error ? err.message : String(err);
268
+ if (/Executable doesn't exist|browserType\.launch/i.test(cause)) {
269
+ throw new WrapperTransportError(
270
+ "INVALID_CONFIG",
271
+ `Playwright's Chromium browser is not installed (the '@qontinui/ui-bridge-headless' peer itself loaded fine). Run:
272
+ npx playwright install chromium
273
+ Underlying launch error: ${cause}`
274
+ );
275
+ }
276
+ throw err;
277
+ }
257
278
  this.tab = {
258
279
  browser: tab.browser,
259
280
  context: tab.context,
@@ -856,16 +877,16 @@ function parseArgs(argv) {
856
877
  args.tabId = consumeValue("--tab-id", argv[++i], mkError);
857
878
  break;
858
879
  case "--exec": {
859
- const raw = argv[++i];
860
- if (raw === void 0) {
880
+ const raw = consumeValue("--exec", argv[++i], mkError);
881
+ if (raw === null) {
861
882
  throw new InjectCliArgError(`--exec expects '<action> <json-payload>' (got <missing>)`);
862
883
  }
863
884
  args.execActions.push(parseExecValue(raw));
864
885
  break;
865
886
  }
866
887
  case "--registration-metadata": {
867
- const raw = argv[++i];
868
- if (raw === void 0) {
888
+ const raw = consumeValue("--registration-metadata", argv[++i], mkError);
889
+ if (raw === null) {
869
890
  throw new InjectCliArgError(
870
891
  `--registration-metadata expects JSON {"userId","sessionId"} (got <missing>)`
871
892
  );
@@ -887,8 +908,8 @@ function parseArgs(argv) {
887
908
  break;
888
909
  }
889
910
  case "--ready-timeout": {
890
- const raw = argv[++i];
891
- const n = raw === void 0 ? NaN : Number.parseInt(raw, 10);
911
+ const raw = consumeValue("--ready-timeout", argv[++i], mkError);
912
+ const n = raw === null ? NaN : Number.parseInt(raw, 10);
892
913
  if (!Number.isFinite(n) || n <= 0) {
893
914
  throw new InjectCliArgError(
894
915
  `--ready-timeout expects a positive integer (got ${raw ?? "<missing>"})`
@@ -901,8 +922,8 @@ function parseArgs(argv) {
901
922
  args.waitForSettle = false;
902
923
  break;
903
924
  case "--settle-quiet": {
904
- const raw = argv[++i];
905
- const n = raw === void 0 ? NaN : Number.parseInt(raw, 10);
925
+ const raw = consumeValue("--settle-quiet", argv[++i], mkError);
926
+ const n = raw === null ? NaN : Number.parseInt(raw, 10);
906
927
  if (!Number.isFinite(n) || n < 0) {
907
928
  throw new InjectCliArgError(
908
929
  `--settle-quiet expects a non-negative integer (got ${raw ?? "<missing>"})`
@@ -912,8 +933,8 @@ function parseArgs(argv) {
912
933
  break;
913
934
  }
914
935
  case "--settle-timeout": {
915
- const raw = argv[++i];
916
- const n = raw === void 0 ? NaN : Number.parseInt(raw, 10);
936
+ const raw = consumeValue("--settle-timeout", argv[++i], mkError);
937
+ const n = raw === null ? NaN : Number.parseInt(raw, 10);
917
938
  if (!Number.isFinite(n) || n <= 0) {
918
939
  throw new InjectCliArgError(
919
940
  `--settle-timeout expects a positive integer (got ${raw ?? "<missing>"})`
@@ -923,15 +944,15 @@ function parseArgs(argv) {
923
944
  break;
924
945
  }
925
946
  case "--expect-selector": {
926
- const raw = argv[++i];
927
- if (raw === void 0 || raw.length === 0) {
947
+ const raw = consumeValue("--expect-selector", argv[++i], mkError);
948
+ if (raw === null || raw.length === 0) {
928
949
  throw new InjectCliArgError(`--expect-selector expects a CSS selector (got <missing>)`);
929
950
  }
930
951
  args.expectSelector = raw;
931
952
  break;
932
953
  }
933
954
  case "--viewport": {
934
- const raw = argv[++i];
955
+ const raw = consumeValue("--viewport", argv[++i], mkError);
935
956
  const match = raw?.match(/^(\d+)x(\d+)$/);
936
957
  if (!match) {
937
958
  throw new InjectCliArgError(`--viewport expects WxH (got ${raw ?? "<missing>"})`);