@melaya/runner 1.0.64 → 1.0.65
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/connection.js +13 -0
- package/dist/lumaLogin.d.ts +3 -0
- package/dist/lumaLogin.js +21 -0
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -1149,6 +1149,19 @@ export async function connect(opts) {
|
|
|
1149
1149
|
});
|
|
1150
1150
|
}
|
|
1151
1151
|
});
|
|
1152
|
+
// Server relays this when the user cancels a stuck sign-in to retry.
|
|
1153
|
+
// Close the abandoned login window if one is still open; the in-flight
|
|
1154
|
+
// runLumaLoginFlow then resolves as `user_cancelled`. No-op when no
|
|
1155
|
+
// window is open. The server has already cleared its pending lock.
|
|
1156
|
+
socket.on("luma:cancel-login", async (_req) => {
|
|
1157
|
+
try {
|
|
1158
|
+
const { cancelActiveLumaLogin } = await import("./lumaLogin.js");
|
|
1159
|
+
const closed = await cancelActiveLumaLogin();
|
|
1160
|
+
if (closed)
|
|
1161
|
+
console.log(chalk.gray(" [luma] sign-in window closed at server's request (cancel & retry)."));
|
|
1162
|
+
}
|
|
1163
|
+
catch { /* best-effort */ }
|
|
1164
|
+
});
|
|
1152
1165
|
// ── Kill command ───────────────────────────────────────────────────
|
|
1153
1166
|
socket.on("runner:kill", (data) => {
|
|
1154
1167
|
const proc = activeProcesses.get(data.runId);
|
package/dist/lumaLogin.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ export type LumaLoginOutcome = LumaLoginResult | LumaLoginError;
|
|
|
39
39
|
interface ProgressEmitter {
|
|
40
40
|
(msg: string): void;
|
|
41
41
|
}
|
|
42
|
+
/** Close the in-flight Luma sign-in browser, if any. Returns true if a
|
|
43
|
+
* window was actually open. Best-effort — never throws. */
|
|
44
|
+
export declare function cancelActiveLumaLogin(): Promise<boolean>;
|
|
42
45
|
export declare function runLumaLoginFlow(progress: ProgressEmitter): Promise<LumaLoginOutcome>;
|
|
43
46
|
export declare function describeOutcome(outcome: LumaLoginOutcome): string;
|
|
44
47
|
export {};
|
package/dist/lumaLogin.js
CHANGED
|
@@ -85,6 +85,25 @@ function _pageLooksLoggedIn(url) {
|
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
// Handle to the browser of an in-flight sign-in, so the server's
|
|
89
|
+
// `luma:cancel-login` (relayed via connection.ts) can close a window the
|
|
90
|
+
// user abandoned. Only one login runs per runner at a time, so a single
|
|
91
|
+
// module-level handle is sufficient. Closing it makes the poll loop's
|
|
92
|
+
// `page.url()` throw → the flow returns `user_cancelled` cleanly.
|
|
93
|
+
let _activeLoginBrowser = null;
|
|
94
|
+
/** Close the in-flight Luma sign-in browser, if any. Returns true if a
|
|
95
|
+
* window was actually open. Best-effort — never throws. */
|
|
96
|
+
export async function cancelActiveLumaLogin() {
|
|
97
|
+
const b = _activeLoginBrowser;
|
|
98
|
+
if (!b)
|
|
99
|
+
return false;
|
|
100
|
+
_activeLoginBrowser = null;
|
|
101
|
+
try {
|
|
102
|
+
await b.close();
|
|
103
|
+
}
|
|
104
|
+
catch { /* already closed */ }
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
88
107
|
export async function runLumaLoginFlow(progress) {
|
|
89
108
|
let playwright;
|
|
90
109
|
try {
|
|
@@ -106,6 +125,7 @@ export async function runLumaLoginFlow(progress) {
|
|
|
106
125
|
headless: false,
|
|
107
126
|
args: ["--disable-blink-features=AutomationControlled"],
|
|
108
127
|
});
|
|
128
|
+
_activeLoginBrowser = browser;
|
|
109
129
|
const context = await browser.newContext({
|
|
110
130
|
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
|
111
131
|
"(KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36",
|
|
@@ -230,6 +250,7 @@ export async function runLumaLoginFlow(progress) {
|
|
|
230
250
|
}
|
|
231
251
|
catch { /* already closed */ }
|
|
232
252
|
}
|
|
253
|
+
_activeLoginBrowser = null;
|
|
233
254
|
}
|
|
234
255
|
}
|
|
235
256
|
export function describeOutcome(outcome) {
|