fix(dsh): restore native file tools and official loading UI
Core regression / Python core and release configuration (push) Successful in 20s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s

This commit is contained in:
阿白叔 committed 2026-11-04 19:05:21 +08:00
1 parent 1340f6c233
commit 705c15eb93
19 files changed
+398 -42

No files matched your search

+15 -5
View File
@@ -1,12 +1,14 @@
/** Tiny CDP driver for the real Qt Chromium page; no browser mocks. */
import {writeFile} from 'node:fs/promises';
export async function connect(port=9226) {
export async function connect(port=9226,{loading=false}={}) {
let target;
const deadline=Date.now()+45000;
const deadline=Date.now()+60000;
while(Date.now()<deadline){
const targets=await fetch(`http://127.0.0.1:${port}/json`,{signal:AbortSignal.timeout(3000)}).then(r=>r.json());
target=targets.find(x=>x.type==='page'&&x.url?.startsWith('http://127.0.0.1:'));
let targets;
try{targets=await fetch(`http://127.0.0.1:${port}/json`,{signal:AbortSignal.timeout(10000)}).then(r=>r.json());}
catch{await new Promise(resolve=>setTimeout(resolve,100));continue;}
target=targets.find(x=>x.type==='page'&&(loading?x.url?.startsWith('file:'):x.url?.startsWith('http://127.0.0.1:')));
if(target)break;
await new Promise(resolve=>setTimeout(resolve,100));
}
@@ -60,11 +62,19 @@ export async function connect(port=9226) {
}
if(process.argv[1]?.endsWith('dsh_cdp.mjs')) {
const client=await connect(Number(process.argv[2] || 9226));
const loading=process.argv[2]==='--capture-loading';
const client=await connect(Number(process.argv[loading?3:2] || 9226),{loading});
try {
if(loading){
const actual=await client.evaluate(`({official:!!document.querySelector('[data-dsh-boot-spinner]'),text:document.body.innerText})`);
if(!actual.official||!actual.text.includes('HARNESS'))throw Error('Official loading page was not rendered');
await client.screenshot(process.argv[4]);
console.log(JSON.stringify({officialLoading:true}));
}else{
console.log(JSON.stringify(await client.evaluate(`({title:document.title,text:document.body.innerText,
buttons:[...document.querySelectorAll('button')].map(x=>({text:x.innerText,label:x.getAttribute('aria-label'),title:x.title})),
svg:document.querySelectorAll('svg').length,animations:document.getAnimations().length,
animatedSvg:document.querySelectorAll('animate,animateTransform,animateMotion').length,canvas:document.querySelectorAll('canvas').length})`)));
}
}finally{client.close();}
}