@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/dist/index.js CHANGED
@@ -219,13 +219,17 @@ var HeadlessTransport = class extends BaseTransport {
219
219
  uiBridgeBase: typeof raw["uiBridgeBase"] === "string" ? raw["uiBridgeBase"] : void 0,
220
220
  waitForUiBridgeMs: typeof raw["waitForUiBridgeMs"] === "number" ? raw["waitForUiBridgeMs"] : void 0,
221
221
  userAgent: typeof raw["userAgent"] === "string" ? raw["userAgent"] : void 0,
222
- forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0
222
+ forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0,
223
+ launchArgs: Array.isArray(raw["launchArgs"]) && raw["launchArgs"].every((a) => typeof a === "string") ? raw["launchArgs"] : void 0,
224
+ storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0
223
225
  };
224
226
  }
225
227
  async onReady() {
226
228
  let launchHeadlessTab;
229
+ const headlessSpecifier = "@qontinui/ui-bridge-headless";
227
230
  try {
228
- ({ launchHeadlessTab } = await import('@qontinui/ui-bridge-headless'));
231
+ const mod = await import(headlessSpecifier);
232
+ ({ launchHeadlessTab } = mod);
229
233
  } catch (err) {
230
234
  const cause = err instanceof Error ? err.message : String(err);
231
235
  const code = err?.code;
@@ -245,6 +249,7 @@ Underlying import error: ${cause}`
245
249
  );
246
250
  }
247
251
  const initScripts = await this.buildInitScripts();
252
+ const relayAuth = this.relayAuth();
248
253
  let tab;
249
254
  try {
250
255
  tab = await launchHeadlessTab({
@@ -256,7 +261,11 @@ Underlying import error: ${cause}`
256
261
  viewportHeight: this.options.viewportHeight,
257
262
  userAgent: this.options.userAgent,
258
263
  forwardConsole: this.options.forwardConsole,
259
- initScripts: initScripts.length > 0 ? initScripts : void 0
264
+ initScripts: initScripts.length > 0 ? initScripts : void 0,
265
+ launchArgs: this.options.launchArgs && this.options.launchArgs.length > 0 ? this.options.launchArgs : void 0,
266
+ storageStatePath: this.options.storageStatePath,
267
+ ...relayAuth.authToken ? { authToken: relayAuth.authToken } : {},
268
+ ...relayAuth.callerUserId ? { callerUserId: relayAuth.callerUserId } : {}
260
269
  });
261
270
  } catch (err) {
262
271
  const cause = err instanceof Error ? err.message : String(err);
@@ -288,6 +297,15 @@ Underlying launch error: ${cause}`
288
297
  async buildInitScripts() {
289
298
  return [];
290
299
  }
300
+ /**
301
+ * Subclass hook: credentials for the launcher's Node-side relay registration
302
+ * poll (`<uiBridgeBase>/tabs`). Default: none (anonymous poll — correct for an
303
+ * ungated relay). Injected mode overrides this with the `--auth-token` bearer
304
+ * and the `--registration-metadata` userId.
305
+ */
306
+ relayAuth() {
307
+ return {};
308
+ }
291
309
  /**
292
310
  * Subclass hook: run after launch + navigation, before `ready()` resolves.
293
311
  * Default: no-op. Injected mode overrides it to await the in-page runtime.
@@ -381,8 +399,8 @@ var InjectedTransport = class extends HeadlessTransport {
381
399
  cfg.registrationMetadata = this.injected.registrationMetadata;
382
400
  if (this.injected.appId) cfg.appId = this.injected.appId;
383
401
  if (this.injected.appName) cfg.appName = this.injected.appName;
384
- if (this.injected.tabId) cfg.tabId = this.injected.tabId;
385
402
  }
403
+ if (this.injected.tabId) cfg.tabId = this.injected.tabId;
386
404
  if (this.injected.settleQuietMs !== void 0)
387
405
  cfg.settleQuietMs = this.injected.settleQuietMs;
388
406
  if (this.injected.settleTimeoutMs !== void 0)
@@ -391,6 +409,18 @@ var InjectedTransport = class extends HeadlessTransport {
391
409
  cfg.expectSelector = this.injected.expectSelector;
392
410
  return Object.keys(cfg).length > 0 ? cfg : null;
393
411
  }
412
+ /**
413
+ * The relay credentials the Node-side registration poll needs. Same bearer the
414
+ * page-side client gets via `__uiBridgeInjectedConfig.authToken`; without it
415
+ * the poll against a gated relay 401s and the CLI reports `tabId: null` on a
416
+ * launch that actually registered.
417
+ */
418
+ relayAuth() {
419
+ return {
420
+ ...this.injected.authToken ? { authToken: this.injected.authToken } : {},
421
+ ...this.injected.registrationMetadata?.userId ? { callerUserId: this.injected.registrationMetadata.userId } : {}
422
+ };
423
+ }
394
424
  async buildInitScripts() {
395
425
  const scripts = [];
396
426
  const cfg = this.injectedConfig();