@qontinui/ui-bridge-wrapper 0.4.2 → 0.6.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 CHANGED
@@ -78,10 +78,10 @@ Each bin supports `--help`.
78
78
 
79
79
  ### Prerequisites for the browser-driving bins
80
80
 
81
- `ui-bridge-login-web` and `ui-bridge-capture-specs` launch Chromium via the
82
- injected transport, which dynamically imports `@qontinui/ui-bridge-headless`
83
- (it carries `playwright` as a real dependency). When installing the wrapper
84
- standalone you must therefore also:
81
+ `ui-bridge-inject`, `ui-bridge-login-web`, and `ui-bridge-capture-specs` all
82
+ launch Chromium via the injected transport, which dynamically imports
83
+ `@qontinui/ui-bridge-headless` (it carries `playwright` as a real dependency).
84
+ When installing the wrapper standalone you must therefore also:
85
85
 
86
86
  1. Install the optional `@qontinui/ui-bridge-headless` peer alongside it, and
87
87
  2. Run `npx playwright install chromium` once (or point `PLAYWRIGHT_BROWSERS_PATH`
@@ -230,13 +230,17 @@ var HeadlessTransport = class extends BaseTransport {
230
230
  uiBridgeBase: typeof raw["uiBridgeBase"] === "string" ? raw["uiBridgeBase"] : void 0,
231
231
  waitForUiBridgeMs: typeof raw["waitForUiBridgeMs"] === "number" ? raw["waitForUiBridgeMs"] : void 0,
232
232
  userAgent: typeof raw["userAgent"] === "string" ? raw["userAgent"] : void 0,
233
- forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0
233
+ forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0,
234
+ launchArgs: Array.isArray(raw["launchArgs"]) && raw["launchArgs"].every((a) => typeof a === "string") ? raw["launchArgs"] : void 0,
235
+ storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0
234
236
  };
235
237
  }
236
238
  async onReady() {
237
239
  let launchHeadlessTab;
240
+ const headlessSpecifier = "@qontinui/ui-bridge-headless";
238
241
  try {
239
- ({ launchHeadlessTab } = await import('@qontinui/ui-bridge-headless'));
242
+ const mod = await import(headlessSpecifier);
243
+ ({ launchHeadlessTab } = mod);
240
244
  } catch (err) {
241
245
  const cause = err instanceof Error ? err.message : String(err);
242
246
  const code = err?.code;
@@ -256,6 +260,7 @@ Underlying import error: ${cause}`
256
260
  );
257
261
  }
258
262
  const initScripts = await this.buildInitScripts();
263
+ const relayAuth = this.relayAuth();
259
264
  let tab;
260
265
  try {
261
266
  tab = await launchHeadlessTab({
@@ -267,7 +272,11 @@ Underlying import error: ${cause}`
267
272
  viewportHeight: this.options.viewportHeight,
268
273
  userAgent: this.options.userAgent,
269
274
  forwardConsole: this.options.forwardConsole,
270
- initScripts: initScripts.length > 0 ? initScripts : void 0
275
+ initScripts: initScripts.length > 0 ? initScripts : void 0,
276
+ launchArgs: this.options.launchArgs && this.options.launchArgs.length > 0 ? this.options.launchArgs : void 0,
277
+ storageStatePath: this.options.storageStatePath,
278
+ ...relayAuth.authToken ? { authToken: relayAuth.authToken } : {},
279
+ ...relayAuth.callerUserId ? { callerUserId: relayAuth.callerUserId } : {}
271
280
  });
272
281
  } catch (err) {
273
282
  const cause = err instanceof Error ? err.message : String(err);
@@ -299,6 +308,15 @@ Underlying launch error: ${cause}`
299
308
  async buildInitScripts() {
300
309
  return [];
301
310
  }
311
+ /**
312
+ * Subclass hook: credentials for the launcher's Node-side relay registration
313
+ * poll (`<uiBridgeBase>/tabs`). Default: none (anonymous poll — correct for an
314
+ * ungated relay). Injected mode overrides this with the `--auth-token` bearer
315
+ * and the `--registration-metadata` userId.
316
+ */
317
+ relayAuth() {
318
+ return {};
319
+ }
302
320
  /**
303
321
  * Subclass hook: run after launch + navigation, before `ready()` resolves.
304
322
  * Default: no-op. Injected mode overrides it to await the in-page runtime.
@@ -392,8 +410,8 @@ var InjectedTransport = class extends HeadlessTransport {
392
410
  cfg.registrationMetadata = this.injected.registrationMetadata;
393
411
  if (this.injected.appId) cfg.appId = this.injected.appId;
394
412
  if (this.injected.appName) cfg.appName = this.injected.appName;
395
- if (this.injected.tabId) cfg.tabId = this.injected.tabId;
396
413
  }
414
+ if (this.injected.tabId) cfg.tabId = this.injected.tabId;
397
415
  if (this.injected.settleQuietMs !== void 0)
398
416
  cfg.settleQuietMs = this.injected.settleQuietMs;
399
417
  if (this.injected.settleTimeoutMs !== void 0)
@@ -402,6 +420,18 @@ var InjectedTransport = class extends HeadlessTransport {
402
420
  cfg.expectSelector = this.injected.expectSelector;
403
421
  return Object.keys(cfg).length > 0 ? cfg : null;
404
422
  }
423
+ /**
424
+ * The relay credentials the Node-side registration poll needs. Same bearer the
425
+ * page-side client gets via `__uiBridgeInjectedConfig.authToken`; without it
426
+ * the poll against a gated relay 401s and the CLI reports `tabId: null` on a
427
+ * launch that actually registered.
428
+ */
429
+ relayAuth() {
430
+ return {
431
+ ...this.injected.authToken ? { authToken: this.injected.authToken } : {},
432
+ ...this.injected.registrationMetadata?.userId ? { callerUserId: this.injected.registrationMetadata.userId } : {}
433
+ };
434
+ }
405
435
  async buildInitScripts() {
406
436
  const scripts = [];
407
437
  const cfg = this.injectedConfig();