@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 +8 -0
- package/dist/capture-specs-cli.cjs +48 -24
- package/dist/capture-specs-cli.cjs.map +1 -1
- package/dist/cli-args.d.ts +11 -1
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/index.cjs +35 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -14
- package/dist/index.js.map +1 -1
- package/dist/inject-cli.cjs +48 -27
- package/dist/inject-cli.cjs.map +1 -1
- package/dist/inject-cli.d.ts.map +1 -1
- package/dist/login-drive.d.ts.map +1 -1
- package/dist/login-web-cli.cjs +60 -26
- package/dist/login-web-cli.cjs.map +1 -1
- package/dist/login-web-cli.d.ts.map +1 -1
- package/dist/react/index.cjs +4 -4
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +4 -4
- package/dist/react/index.js.map +1 -1
- package/dist/transports/headless.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/inject-cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-cli.d.ts","sourceRoot":"","sources":["../src/inject-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,eAAO,MAAM,KAAK,4zGAsDjB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oBAAoB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;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IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,OACuB,CAAC;AAE9D,6DAA6D;AAC7D,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,KAAG,MAMlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,SAAS,MAAM,KAAG,OAC9B,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM,KAAG,OACU,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxE;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAc,EAAE,EAAE,iBAAiB,GAChE,OAAO,CAAC,gBAAgB,CAAC,CAoI3B"}
|
package/dist/login-web-cli.cjs
CHANGED
|
@@ -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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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,
|
|
@@ -704,6 +725,21 @@ var COMMON_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--quiet"]);
|
|
|
704
725
|
function isFlagShaped(value) {
|
|
705
726
|
return value.startsWith("--");
|
|
706
727
|
}
|
|
728
|
+
function consumeValue(flag, raw, error) {
|
|
729
|
+
if (raw === void 0) return null;
|
|
730
|
+
if (isFlagShaped(raw)) {
|
|
731
|
+
throw error(`${flag} expects a value but got the flag '${raw}' \u2014 did you omit ${flag}'s argument?`);
|
|
732
|
+
}
|
|
733
|
+
return raw;
|
|
734
|
+
}
|
|
735
|
+
function rejectEmptyValue(flag, value, error) {
|
|
736
|
+
if (value !== null && value.trim() === "") {
|
|
737
|
+
throw error(
|
|
738
|
+
`${flag} was given an empty value \u2014 omit the flag to use its default, or pass a non-empty value`
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
return value;
|
|
742
|
+
}
|
|
707
743
|
var ArgReader = class {
|
|
708
744
|
argv;
|
|
709
745
|
error;
|
|
@@ -728,18 +764,14 @@ var ArgReader = class {
|
|
|
728
764
|
/**
|
|
729
765
|
* Value following the value-flag `name`, or `null` when the flag is absent OR
|
|
730
766
|
* has no following token (the caller defaults it). Throws when the following
|
|
731
|
-
* token is flag-shaped — the swallow this kit exists to kill.
|
|
767
|
+
* token is flag-shaped — the swallow this kit exists to kill. Delegates to
|
|
768
|
+
* {@link consumeValue} so the guard (and its message) live in exactly one
|
|
769
|
+
* place for both the indexOf-style and switch-style parsers.
|
|
732
770
|
*/
|
|
733
771
|
value(name) {
|
|
734
772
|
const i = this.argv.indexOf(name);
|
|
735
773
|
if (i < 0 || i + 1 >= this.argv.length) return null;
|
|
736
|
-
|
|
737
|
-
if (isFlagShaped(raw)) {
|
|
738
|
-
throw this.error(
|
|
739
|
-
`${name} expects a value but got the flag '${raw}' \u2014 did you omit ${name}'s argument?`
|
|
740
|
-
);
|
|
741
|
-
}
|
|
742
|
-
return raw;
|
|
774
|
+
return consumeValue(name, this.argv[i + 1], this.error);
|
|
743
775
|
}
|
|
744
776
|
};
|
|
745
777
|
function makeLogger(prefix, quiet) {
|
|
@@ -857,7 +889,7 @@ async function loginDrive(page, { email, password, timeoutMs, log = () => {
|
|
|
857
889
|
} catch {
|
|
858
890
|
const errorText2 = await scrapeErrorCard(page);
|
|
859
891
|
const finalUrl2 = page.url();
|
|
860
|
-
log(`
|
|
892
|
+
log(`stalled ${finalUrl2}`);
|
|
861
893
|
return { ok: false, finalUrl: finalUrl2, landingPath: pathOf(finalUrl2), errorText: errorText2 };
|
|
862
894
|
}
|
|
863
895
|
}
|
|
@@ -869,9 +901,9 @@ async function loginDrive(page, { email, password, timeoutMs, log = () => {
|
|
|
869
901
|
).catch(() => {
|
|
870
902
|
});
|
|
871
903
|
const finalUrl = page.url();
|
|
872
|
-
log(`final ${finalUrl}`);
|
|
873
904
|
const landingPath = await page.evaluate(() => location.pathname).catch(() => pathOf(finalUrl));
|
|
874
905
|
const ok = !isAppLoginPath(finalUrl) && !isCognito(finalUrl) && !/\/auth\/callback/.test(pathOf(finalUrl));
|
|
906
|
+
log(ok ? `authed ${finalUrl}` : `stalled ${finalUrl}`);
|
|
875
907
|
const errorText = ok ? null : await scrapeErrorCard(page);
|
|
876
908
|
return { ok, finalUrl, landingPath, errorText };
|
|
877
909
|
}
|
|
@@ -942,10 +974,12 @@ function parseArgs(argv) {
|
|
|
942
974
|
throw new LoginCliArgError(`--timeout expects a positive integer (got ${timeoutRaw})`);
|
|
943
975
|
}
|
|
944
976
|
const args = {
|
|
945
|
-
url: valueOf("--url") ?? "https://qontinui.io/login",
|
|
977
|
+
url: rejectEmptyValue("--url", valueOf("--url"), mkError) ?? "https://qontinui.io/login",
|
|
946
978
|
email: valueOf("--email") ?? process.env.UIB_LOGIN_EMAIL ?? "",
|
|
947
979
|
password: valueOf("--password") ?? process.env.UIB_LOGIN_PASSWORD ?? "",
|
|
948
|
-
success
|
|
980
|
+
// An EMPTY --success would make `landingPath.includes('')` true on any
|
|
981
|
+
// landing — ok:true while parked on the login page. Reject it.
|
|
982
|
+
success: rejectEmptyValue("--success", valueOf("--success"), mkError) ?? "/dashboard",
|
|
949
983
|
timeoutMs,
|
|
950
984
|
headed: has("--headed"),
|
|
951
985
|
postClick: valueOf("--post-login-click"),
|