@lightcone-ai/daemon 0.9.61 → 0.9.62

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.9.61",
3
+ "version": "0.9.62",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -23,13 +23,29 @@ export const PLATFORM_CONFIGS = {
23
23
  qrTabSelector: ['.qrcode-box', '[class*="qrcode"]', '[class*="scan-login"]', '[class*="qr-login"]'],
24
24
  qrFallbackScript: `
25
25
  const loginBox = document.querySelector('.login-box-container') || document.body;
26
- const candidates = [...loginBox.querySelectorAll('img, canvas, svg, [role="img"]')];
27
- const el = candidates.find(e => {
26
+ const boxRect = loginBox.getBoundingClientRect();
27
+ const visible = (e) => {
28
28
  const r = e.getBoundingClientRect();
29
29
  const cs = getComputedStyle(e);
30
- return r.width >= 40 && r.width <= 100 && r.height >= 40 && r.height <= 100 && cs.cursor === 'pointer';
31
- });
32
- if (el) { el.click(); return 'corner-qr-icon'; }
30
+ return r.width >= 35 && r.width <= 110
31
+ && r.height >= 35 && r.height <= 110
32
+ && r.left >= boxRect.left
33
+ && r.top >= boxRect.top
34
+ && r.right <= boxRect.right + 4
35
+ && r.bottom <= boxRect.bottom + 4
36
+ && cs.display !== 'none'
37
+ && cs.visibility !== 'hidden';
38
+ };
39
+ const elements = [...loginBox.querySelectorAll('img, canvas, svg, [role="img"], div, span, button')].filter(visible);
40
+ const corner = elements
41
+ .map(e => ({ e, r: e.getBoundingClientRect() }))
42
+ .filter(({ r }) => r.top <= boxRect.top + 120 && r.right >= boxRect.right - 140)
43
+ .sort((a, b) => (b.r.right + boxRect.top - b.r.top) - (a.r.right + boxRect.top - a.r.top))[0]?.e;
44
+ if (corner) {
45
+ const target = corner.closest('button, [role="button"], a, div') || corner;
46
+ target.click();
47
+ return 'corner-qr-icon';
48
+ }
33
49
  return null;
34
50
  `,
35
51
  getSessionValue: (cookies) =>
@@ -212,7 +228,7 @@ export class BrowserLoginSession {
212
228
  if (this._config.qrTabSelector) {
213
229
  try {
214
230
  const selectors = this._config.qrTabSelector;
215
- await this.send('Runtime.evaluate', {
231
+ const qrResult = await this.send('Runtime.evaluate', {
216
232
  expression: `(function() {
217
233
  const sels = ${JSON.stringify(selectors)};
218
234
  for (const s of sels) {
@@ -228,8 +244,11 @@ export class BrowserLoginSession {
228
244
  })()`,
229
245
  returnByValue: true,
230
246
  });
247
+ console.log(`[BrowserLogin][${this._platform}] QR switch result: ${qrResult.result?.value ?? 'not-found'}`);
231
248
  await sleep(1000);
232
- } catch {}
249
+ } catch (err) {
250
+ console.error(`[BrowserLogin][${this._platform}] QR switch failed: ${err.message}`);
251
+ }
233
252
  }
234
253
 
235
254
  // Record baseline session cookie value.