@glittering0717/ai-browser 2.5.7 → 2.5.10

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.
@@ -71,4 +71,34 @@ function liveness(view) {
71
71
  } catch (_) { return 'unknown'; }
72
72
  }
73
73
 
74
- module.exports = { isAlive, liveness };
74
+ /**
75
+ * webContents 还活着,但它的主框架已经没了 —— 渲染进程崩溃后的第二种形态。
76
+ *
77
+ * 为什么单独一个函数:`isAlive` 只回答"对象还在不在",而执行脚本要的是
78
+ * "这一帧能不能收消息"。渲染进程崩溃(render-process-gone: crashed/killed)之后
79
+ * `webContents.isDestroyed()` 仍是 false、`mainFrame` 仍在,但 `detached === true`,
80
+ * 此时 executeJavaScript 必然失败:
81
+ * Error sending from webFrameMain: Render frame was disposed before
82
+ * WebFrameMain could be accessed
83
+ *
84
+ * 2026-11-28 现场:stderr.log 里这条错误累积了 3482 条 —— 两个定时器
85
+ * (refreshTabBar 2s / pushNavState 1.5s)一直往一个死框架里撞,而
86
+ * `ensureTabBarAlive` 因为 isAlive 为真,从来没有重建过标签栏。
87
+ *
88
+ * @param {object} view 可能是 BrowserView 的东西
89
+ * @returns {boolean} 主框架是否还能接收脚本
90
+ */
91
+ function frameAlive(view) {
92
+ try {
93
+ const wc = view && view.webContents;
94
+ if (!wc || typeof wc.isDestroyed !== 'function' || wc.isDestroyed()) return false;
95
+ const mf = wc.mainFrame;
96
+ if (!mf) return false;
97
+ // detached 是 WebFrameMain 的只读属性;老版本没有就按"还活着"处理。
98
+ return mf.detached !== true;
99
+ } catch (_) {
100
+ return false;
101
+ }
102
+ }
103
+
104
+ module.exports = { isAlive, liveness, frameAlive };
@@ -81,7 +81,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
81
81
  // noIdChain 自己和整条祖先链都没有 id → **真缺口**
82
82
  // 真缺口 = ambiguous + noIdChain。
83
83
  const COUNT_JS = `(function(){
84
- // a[href] 换成 a:无 href 的锚点(onclick 驱动)也是可点目标。超星泛雅的章节
84
+ // a[href] 换成 a:无 href 的锚点(onclick 驱动)也是可点目标。某教学平台的章节
85
85
  // 条目就是 <a onclick>,href 为 null —— 只认 a[href] 会把它们从**分母**里删掉,
86
86
  // 于是覆盖率虚高。帧读取器(shared/frame_read_source.js)早先踩过同一个坑。
87
87
  var INTER = 'a,button,input,select,textarea,summary,details,[role=button],[role=link],[role=checkbox],[role=radio],[role=tab],[role=menuitem],[contenteditable=true]';
@@ -92,7 +92,7 @@ const COUNT_JS = `(function(){
92
92
  // 只算**可见的、最内层的**可交互元素:
93
93
  // - 不可见的(隐藏 input、0×0 的埋点控件)不是人能看到的目标;
94
94
  // - 最内层的(不再包含别的可交互元素)才是真正的动作目标,外面那层是包装。
95
- // 不这么筛,"这一行里到底有几个可点的东西"永远数不清 —— 实测超星章节行
95
+ // 不这么筛,"这一行里到底有几个可点的东西"永远数不清 —— 实测某教学平台章节行
96
96
  // 里同时有 2 个隐藏 input + 行容器 div[role=link] + 标题 a,共 4 个命中,
97
97
  // 于是"唯一可交互后代"这个前提永远不成立,6 个章节被永久误报成真缺口。
98
98
  var live = [];
@@ -125,7 +125,7 @@ const COUNT_JS = `(function(){
125
125
  // 只看交集/内层面积会把"大卡片里放个小链接"误判成壳子(点卡片 ≠ 点那个链接)。
126
126
  if (inter / (b.width * b.height) >= 0.9 && inter / (r.width * r.height) >= 0.9) return true;
127
127
  // 判据二(文本):外层的文字**就是**这一个链接的文字(可能多个角标)。
128
- // 2026-10-19 实测(超星泛雅章节行):外层是整行
128
+ // 2026-10-19 实测(某教学平台章节行):外层是整行
129
129
  // <div class="chapter_item" role="link">1.1 标题 <b>1</b></div>
130
130
  // 内层是 <a>1.1 标题</a>,宽 996 / 行宽 1100 —— 几何上差 5% 不过线,于是
131
131
  // 6 个章节被报成"真缺口"。但点内层 a 会冒泡到整行,实测
@@ -223,7 +223,7 @@ const COUNT_JS = `(function(){
223
223
  const raw2 = JSON.parse(String(r.value));
224
224
 
225
225
  // ---- 跨进程帧:分母必须包含它们,否则这个数字会骗人 ----
226
- // 2026-10-19 实测(超星泛雅学习页):本工具报「可点目标 4,可用率 100%、
226
+ // 2026-10-19 实测(某教学平台学习页):本工具报「可点目标 4,可用率 100%、
227
227
  // 真缺口 0」,而**整门课程的章节列表一个都没进树** —— 因为那 6 个条目住在
228
228
  // 跨进程 iframe 里,而 COUNT_JS 只在顶层 document 里数。
229
229
  // 100% 覆盖了 4 个按钮,同时 100% 看不见正文。