chrometools-mcp 3.5.3 → 3.5.4-beta.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.
Files changed (2) hide show
  1. package/index.js +24 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2362,7 +2362,7 @@ Start coding now.`;
2362
2362
  const pageUrl = page.url();
2363
2363
 
2364
2364
  // APOM Tree format (default) - v2 with tree structure and positioning
2365
- const apomResult = await page.evaluate((apomTreeConverterCode, selectorResolverCode, modelsCode, shouldRegister, includeAll, viewportOnly) => {
2365
+ const apomResult = await page.evaluate(async (apomTreeConverterCode, selectorResolverCode, modelsCode, shouldRegister, includeAll, viewportOnly) => {
2366
2366
  // Inject utilities if not already loaded
2367
2367
  if (typeof buildAPOMTree === 'undefined') {
2368
2368
  eval(apomTreeConverterCode);
@@ -2374,6 +2374,29 @@ Start coding now.`;
2374
2374
  eval(modelsCode);
2375
2375
  }
2376
2376
 
2377
+ // Wait for Angular stability before DOM traversal (like Protractor's whenStable).
2378
+ // Prevents reading intermediate DOM state during Angular change detection.
2379
+ // whenStable() resolves immediately if Angular is already stable (zero overhead).
2380
+ if (typeof window.getAllAngularTestabilities === 'function') {
2381
+ try {
2382
+ const testabilities = window.getAllAngularTestabilities();
2383
+ if (testabilities && testabilities.length > 0) {
2384
+ await Promise.race([
2385
+ new Promise(resolve => testabilities[0].whenStable(resolve)),
2386
+ new Promise(resolve => setTimeout(resolve, 3000))
2387
+ ]);
2388
+ }
2389
+ } catch (e) {
2390
+ // Angular testability API not available or errored — proceed without waiting
2391
+ }
2392
+ }
2393
+
2394
+ // Clear stale element registry before building new tree.
2395
+ // Old IDs from previous analyses may point to elements that no longer exist.
2396
+ if (typeof clearRegistry === 'function') {
2397
+ clearRegistry();
2398
+ }
2399
+
2377
2400
  // Build APOM tree
2378
2401
  // interactiveOnly = !includeAll (if includeAll is true, we want ALL elements)
2379
2402
  const apomData = buildAPOMTree(!includeAll, viewportOnly);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrometools-mcp",
3
- "version": "3.5.3",
3
+ "version": "3.5.4-beta.0",
4
4
  "description": "MCP (Model Context Protocol) server for Chrome automation using Puppeteer. Persistent browser sessions, UI framework detection (MUI, Ant Design, etc.), Page Object support, visual testing, Figma comparison. Works seamlessly in WSL, Linux, macOS, and Windows.",
5
5
  "type": "module",
6
6
  "main": "index.js",