@qontinui/ui-bridge-wrapper 0.4.2 → 0.5.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 +4 -4
- package/dist/capture-specs-cli.cjs +9 -3
- package/dist/capture-specs-cli.cjs.map +1 -1
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/inject-cli.cjs +98 -3
- package/dist/inject-cli.cjs.map +1 -1
- package/dist/inject-cli.d.ts +29 -1
- package/dist/inject-cli.d.ts.map +1 -1
- package/dist/login-web-cli.cjs +125 -9
- package/dist/login-web-cli.cjs.map +1 -1
- package/dist/login-web-cli.d.ts +5 -1
- package/dist/login-web-cli.d.ts.map +1 -1
- package/dist/session-storage-capture.d.ts +78 -0
- package/dist/session-storage-capture.d.ts.map +1 -0
- package/dist/transports/headless.d.ts +16 -0
- package/dist/transports/headless.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/inject-cli.cjs
CHANGED
|
@@ -224,13 +224,17 @@ var HeadlessTransport = class extends BaseTransport {
|
|
|
224
224
|
uiBridgeBase: typeof raw["uiBridgeBase"] === "string" ? raw["uiBridgeBase"] : void 0,
|
|
225
225
|
waitForUiBridgeMs: typeof raw["waitForUiBridgeMs"] === "number" ? raw["waitForUiBridgeMs"] : void 0,
|
|
226
226
|
userAgent: typeof raw["userAgent"] === "string" ? raw["userAgent"] : void 0,
|
|
227
|
-
forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0
|
|
227
|
+
forwardConsole: typeof raw["forwardConsole"] === "boolean" ? raw["forwardConsole"] : void 0,
|
|
228
|
+
launchArgs: Array.isArray(raw["launchArgs"]) && raw["launchArgs"].every((a) => typeof a === "string") ? raw["launchArgs"] : void 0,
|
|
229
|
+
storageStatePath: typeof raw["storageStatePath"] === "string" ? raw["storageStatePath"] : void 0
|
|
228
230
|
};
|
|
229
231
|
}
|
|
230
232
|
async onReady() {
|
|
231
233
|
let launchHeadlessTab;
|
|
234
|
+
const headlessSpecifier = "@qontinui/ui-bridge-headless";
|
|
232
235
|
try {
|
|
233
|
-
|
|
236
|
+
const mod = await import(headlessSpecifier);
|
|
237
|
+
({ launchHeadlessTab } = mod);
|
|
234
238
|
} catch (err) {
|
|
235
239
|
const cause = err instanceof Error ? err.message : String(err);
|
|
236
240
|
const code = err?.code;
|
|
@@ -261,7 +265,9 @@ Underlying import error: ${cause}`
|
|
|
261
265
|
viewportHeight: this.options.viewportHeight,
|
|
262
266
|
userAgent: this.options.userAgent,
|
|
263
267
|
forwardConsole: this.options.forwardConsole,
|
|
264
|
-
initScripts: initScripts.length > 0 ? initScripts : void 0
|
|
268
|
+
initScripts: initScripts.length > 0 ? initScripts : void 0,
|
|
269
|
+
launchArgs: this.options.launchArgs && this.options.launchArgs.length > 0 ? this.options.launchArgs : void 0,
|
|
270
|
+
storageStatePath: this.options.storageStatePath
|
|
265
271
|
});
|
|
266
272
|
} catch (err) {
|
|
267
273
|
const cause = err instanceof Error ? err.message : String(err);
|
|
@@ -758,6 +764,12 @@ Exec (Variant A \u2014 one-shot; presence of any --exec/--exec-stdin selects thi
|
|
|
758
764
|
{"action":"...","payload":{...}}
|
|
759
765
|
|
|
760
766
|
Optional:
|
|
767
|
+
--storage-state <path> Seed the browser context from a Playwright storageState
|
|
768
|
+
JSON file (cookies + localStorage) produced by
|
|
769
|
+
'ui-bridge-login-web --storage-state-out <path>'. This
|
|
770
|
+
carries a saved authenticated session past a login wall,
|
|
771
|
+
so you can drive a login-walled page (e.g. an /admin
|
|
772
|
+
wizard) WITHOUT re-driving the hosted-UI login each run.
|
|
761
773
|
--headed Launch with a visible window (default: headless)
|
|
762
774
|
--ready-timeout <ms> Max wait for the injected runtime ready/settle gate (default 30000)
|
|
763
775
|
--no-settle Gate ready on the runtime being live only, NOT on the DOM
|
|
@@ -772,6 +784,13 @@ Optional:
|
|
|
772
784
|
before --settle-timeout, ready() fails with a BLOCKED error
|
|
773
785
|
instead of returning a control-less page.
|
|
774
786
|
--viewport <WxH> Viewport size, e.g. 1280x720
|
|
787
|
+
--launch-arg <arg> Extra Chromium command-line argument (repeatable),
|
|
788
|
+
passed through to chromium.launch({ args }).
|
|
789
|
+
NOTE: when --url is https and --relay resolves to a
|
|
790
|
+
loopback host, the LNA-disable flags
|
|
791
|
+
(--disable-features=LocalNetworkAccessChecks,...) are
|
|
792
|
+
auto-appended \u2014 Chromium otherwise blocks the
|
|
793
|
+
https-page \u2192 loopback-relay fetch (Local Network Access).
|
|
775
794
|
--quiet Suppress human-readable logs (JSON results still print)
|
|
776
795
|
--help, -h Print this help and exit
|
|
777
796
|
|
|
@@ -787,6 +806,12 @@ Examples:
|
|
|
787
806
|
# Variant A: find a control and act on it
|
|
788
807
|
ui-bridge-inject --url https://example.com/login \\
|
|
789
808
|
--exec 'find {"text":"Sign in"}'
|
|
809
|
+
|
|
810
|
+
# Reuse a saved login: drive a login-walled page with a captured auth artifact
|
|
811
|
+
ui-bridge-login-web --url "https://qontinui.io/login?next=%2Fadmin" \\
|
|
812
|
+
--success /admin --storage-state-out auth.json
|
|
813
|
+
ui-bridge-inject --url https://qontinui.io/admin \\
|
|
814
|
+
--storage-state auth.json --exec 'getControlSnapshot {}'
|
|
790
815
|
`;
|
|
791
816
|
var InjectCliArgError = class extends Error {
|
|
792
817
|
constructor(message) {
|
|
@@ -834,6 +859,8 @@ function parseArgs(argv) {
|
|
|
834
859
|
tabId: null,
|
|
835
860
|
viewportWidth: null,
|
|
836
861
|
viewportHeight: null,
|
|
862
|
+
storageState: null,
|
|
863
|
+
launchArgs: [],
|
|
837
864
|
execActions: [],
|
|
838
865
|
execStdin: false,
|
|
839
866
|
quiet: false,
|
|
@@ -876,6 +903,24 @@ function parseArgs(argv) {
|
|
|
876
903
|
case "--tab-id":
|
|
877
904
|
args.tabId = consumeValue("--tab-id", argv[++i], mkError);
|
|
878
905
|
break;
|
|
906
|
+
case "--storage-state": {
|
|
907
|
+
const raw = consumeValue("--storage-state", argv[++i], mkError);
|
|
908
|
+
if (raw === null || raw.length === 0) {
|
|
909
|
+
throw new InjectCliArgError(
|
|
910
|
+
`--storage-state expects a path to a storageState JSON file (got <missing>)`
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
args.storageState = raw;
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
case "--launch-arg": {
|
|
917
|
+
const raw = argv[++i];
|
|
918
|
+
if (raw === void 0 || raw.length === 0) {
|
|
919
|
+
throw new InjectCliArgError(`--launch-arg expects a Chromium argument (got <missing>)`);
|
|
920
|
+
}
|
|
921
|
+
args.launchArgs.push(raw);
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
879
924
|
case "--exec": {
|
|
880
925
|
const raw = consumeValue("--exec", argv[++i], mkError);
|
|
881
926
|
if (raw === null) {
|
|
@@ -988,9 +1033,48 @@ function validateArgs(args) {
|
|
|
988
1033
|
function selectMode(args) {
|
|
989
1034
|
return args.execActions.length > 0 || args.execStdin ? "exec" : "relay";
|
|
990
1035
|
}
|
|
1036
|
+
var LNA_DISABLE_FEATURES = [
|
|
1037
|
+
"LocalNetworkAccessChecks",
|
|
1038
|
+
"PrivateNetworkAccessSendPreflights",
|
|
1039
|
+
"PrivateNetworkAccessRespectPreflightResults"
|
|
1040
|
+
];
|
|
1041
|
+
function isLoopbackHost(hostname) {
|
|
1042
|
+
const h = hostname.toLowerCase();
|
|
1043
|
+
return h === "localhost" || h.endsWith(".localhost") || h.startsWith("127.") || h === "::1" || h === "[::1]";
|
|
1044
|
+
}
|
|
1045
|
+
function buildLaunchArgs(args) {
|
|
1046
|
+
const launchArgs = [...args.launchArgs];
|
|
1047
|
+
let lnaAutoAppended = false;
|
|
1048
|
+
let relayIsLoopback = false;
|
|
1049
|
+
if (args.relay) {
|
|
1050
|
+
try {
|
|
1051
|
+
relayIsLoopback = isLoopbackHost(new URL(args.relay).hostname);
|
|
1052
|
+
} catch {
|
|
1053
|
+
relayIsLoopback = false;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
if (/^https:\/\//i.test(args.url) && relayIsLoopback) {
|
|
1057
|
+
const prefix = "--disable-features=";
|
|
1058
|
+
const existingIdx = launchArgs.findIndex((a) => a.startsWith(prefix));
|
|
1059
|
+
if (existingIdx === -1) {
|
|
1060
|
+
launchArgs.push(`${prefix}${LNA_DISABLE_FEATURES.join(",")}`);
|
|
1061
|
+
lnaAutoAppended = true;
|
|
1062
|
+
} else {
|
|
1063
|
+
const existing = launchArgs[existingIdx].slice(prefix.length).split(",").filter(Boolean);
|
|
1064
|
+
const missing = LNA_DISABLE_FEATURES.filter((f) => !existing.includes(f));
|
|
1065
|
+
if (missing.length > 0) {
|
|
1066
|
+
launchArgs[existingIdx] = `${prefix}${[...existing, ...missing].join(",")}`;
|
|
1067
|
+
lnaAutoAppended = true;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return { launchArgs, lnaAutoAppended };
|
|
1072
|
+
}
|
|
991
1073
|
function buildTransportOptions(args) {
|
|
992
1074
|
const options = { targetUrl: args.url };
|
|
993
1075
|
if (args.relay) options.uiBridgeBase = args.relay;
|
|
1076
|
+
const { launchArgs } = buildLaunchArgs(args);
|
|
1077
|
+
if (launchArgs.length > 0) options.launchArgs = launchArgs;
|
|
994
1078
|
if (args.authToken) options.authToken = args.authToken;
|
|
995
1079
|
if (args.registrationMetadata) options.registrationMetadata = args.registrationMetadata;
|
|
996
1080
|
if (args.headed) options.headed = true;
|
|
@@ -1004,6 +1088,7 @@ function buildTransportOptions(args) {
|
|
|
1004
1088
|
if (args.tabId) options.tabId = args.tabId;
|
|
1005
1089
|
if (args.viewportWidth !== null) options.viewportWidth = args.viewportWidth;
|
|
1006
1090
|
if (args.viewportHeight !== null) options.viewportHeight = args.viewportHeight;
|
|
1091
|
+
if (args.storageState) options.storageStatePath = args.storageState;
|
|
1007
1092
|
return options;
|
|
1008
1093
|
}
|
|
1009
1094
|
function die(msg) {
|
|
@@ -1065,6 +1150,13 @@ ${USAGE}`);
|
|
|
1065
1150
|
process.exit(0);
|
|
1066
1151
|
}
|
|
1067
1152
|
const mode = selectMode(args);
|
|
1153
|
+
const { launchArgs, lnaAutoAppended } = buildLaunchArgs(args);
|
|
1154
|
+
if (lnaAutoAppended) {
|
|
1155
|
+
log(
|
|
1156
|
+
args.quiet,
|
|
1157
|
+
`[ui-bridge-inject] https page + loopback relay detected \u2014 auto-appending Chromium LNA-disable flags so the page can fetch the relay: --disable-features=${LNA_DISABLE_FEATURES.join(",")} (effective launch args: ${JSON.stringify(launchArgs)})`
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1068
1160
|
const transport = createTransport({ kind: "injected", options: buildTransportOptions(args) });
|
|
1069
1161
|
transport.register("__inject_cli_info", (_p, ctx) => {
|
|
1070
1162
|
const c = ctx;
|
|
@@ -1196,8 +1288,11 @@ if (isMain) {
|
|
|
1196
1288
|
}
|
|
1197
1289
|
|
|
1198
1290
|
exports.InjectCliArgError = InjectCliArgError;
|
|
1291
|
+
exports.LNA_DISABLE_FEATURES = LNA_DISABLE_FEATURES;
|
|
1199
1292
|
exports.USAGE = USAGE;
|
|
1293
|
+
exports.buildLaunchArgs = buildLaunchArgs;
|
|
1200
1294
|
exports.buildTransportOptions = buildTransportOptions;
|
|
1295
|
+
exports.isLoopbackHost = isLoopbackHost;
|
|
1201
1296
|
exports.parseArgs = parseArgs;
|
|
1202
1297
|
exports.selectMode = selectMode;
|
|
1203
1298
|
exports.validateArgs = validateArgs;
|