@mozilla/firefox-devtools-mcp 0.9.12 → 0.10.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.
- package/README.md +135 -38
- package/dist/index.js +11040 -22815
- package/dist/snapshot.injected.global.js +1 -1
- package/package.json +5 -4
- package/scripts/build-mcpb.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __SnapshotInjected=(()=>{var
|
|
1
|
+
"use strict";var __SnapshotInjected=(()=>{var x=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var oe=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of re(t))!ie.call(e,o)&&o!==n&&x(e,o,{get:()=>t[o],enumerable:!(r=ne(t,o))||r.enumerable});return e};var ae=e=>se(x({},"__esModule",{value:!0}),e);var Ee={};oe(Ee,{clearUidRegistry:()=>te,createSnapshot:()=>Q,resolveUid:()=>Z,uidToSelector:()=>ee});var C=["a","button","input","select","textarea","img","video","audio","iframe"],le=["nav","main","section","article","header","footer","form"],ue=["div","span","p","li","ul","ol"];function v(e){if(e?.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;for(;t&&t!==document.documentElement;){try{let n=window.getComputedStyle(t),r=parseFloat(n.opacity);if(n.display==="none"||n.visibility==="hidden"||r===0||isNaN(r))return!1}catch{return!1}t=t.parentElement}return!0}function ce(e){let t="";for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];r?.nodeType===Node.TEXT_NODE&&(t+=r.textContent||"")}return t.trim()}function de(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n){let r=n.tagName.toLowerCase();if(C.indexOf(r)!==-1||n.hasAttribute("role"))return!0}}return!1}function X(e){if(e?.nodeType!==Node.ELEMENT_NODE||!v(e))return!1;let t=e.tagName.toLowerCase();if(C.indexOf(t)!==-1||e.hasAttribute("role")||e.hasAttribute("aria-label")||/^h[1-6]$/.test(t)||le.indexOf(t)!==-1)return!0;if(ue.indexOf(t)!==-1){let n=ce(e);if(n.length>0&&n.length<500||e.id||e.className||de(e))return!0}return!1}function G(e){if(e.tabIndex>=0)return!0;let n=e.tagName.toLowerCase();return["a","button","input","select","textarea"].indexOf(n)!==-1}function $(e){let t=e.tagName.toLowerCase();if(C.indexOf(t)!==-1)return!0;let n=e.getAttribute("role");return!!(n&&["button","link","menuitem","tab"].indexOf(n)!==-1||e.hasAttribute("onclick"))}var fe=100;function H(e){if(e.hasAttribute("aria-label"))return e.getAttribute("aria-label")||void 0;let n=e.id;if(n){let o=document.querySelector(`label[for="${n}"]`);if(o?.textContent)return o.textContent.trim()}if(e.hasAttribute("placeholder"))return e.getAttribute("placeholder")||void 0;if(e.hasAttribute("title"))return e.getAttribute("title")||void 0;if(e.hasAttribute("alt"))return e.getAttribute("alt")||void 0;let r=e.tagName.toLowerCase();if(["button","a","h1","h2","h3","h4","h5","h6"].indexOf(r)!==-1)return R(e)}function R(e){let t="";for(let r=0;r<e.childNodes.length;r++){let o=e.childNodes[r];o?.nodeType===Node.TEXT_NODE&&(t+=o.textContent||"")}let n=t.trim();if(n)return n.substring(0,fe)}function F(e){let t={},n=!1,r=["disabled","hidden","selected","expanded"];for(let i of r){let s=e.getAttribute(`aria-${i}`);s!==null&&(t[i]=s==="true",n=!0)}let o=["checked","pressed"];for(let i of o){let s=e.getAttribute(`aria-${i}`);s!==null&&(s==="mixed"?t[i]="mixed":t[i]=s==="true",n=!0)}let l=["autocomplete","haspopup","invalid","label","labelledby","describedby","controls"];for(let i of l){let s=e.getAttribute(`aria-${i}`);s&&(t[i]=s,n=!0)}let u=e.getAttribute("aria-level");if(u){let i=parseInt(u,10);isNaN(i)||(t.level=i,n=!0)}return n?t:void 0}function P(e){let t={};try{let n=window.getComputedStyle(e),r=parseFloat(n.opacity);t.visible=n.display!=="none"&&n.visibility!=="hidden"&&r!==0&&!isNaN(r)}catch{t.visible=!1}return t.accessible=t.visible&&!e.getAttribute("aria-hidden"),t.focusable=G(e),t.interactive=$(e),t}var V="__uidRegistry";function A(){let e=window,t=e[V];return t||(t={uidToElement:new Map,elementToUid:new WeakMap},e[V]=t),t}function j(e){return A().elementToUid.get(e)}function q(e){let t=A();for(let[n,r]of e)t.uidToElement.set(n,new WeakRef(r)),t.elementToUid.set(r,n)}function _(e){let t=A(),n=t.uidToElement.get(e)?.deref();return n?.isConnected?n:(t.uidToElement.delete(e),null)}function Y(){let e=A();e.uidToElement.clear(),e.elementToUid=new WeakMap}var me=10,z=1e3;function B(e,t,n={}){let{includeAll:r=!1,includeIframes:o=!0}=n,l=0,u=t,i=!1,s=new Map;function c(a,h){if(h>me)return i=!0,{node:null,relevantChildren:[]};if(l>=z)return i=!0,{node:null,relevantChildren:[]};let S=h===0,b;r?b=S||v(a):b=S||X(a);let g=[],y=a.tagName.toLowerCase();if(y==="iframe"&&o&&b)try{let d=a,p=d.contentDocument||d.contentWindow?.document;if(p?.body){let f=c(p.body,h+1);f.node&&(f.node.isIframe=!0,f.node.frameSrc=d.src,g.push(f.node))}}catch{}else for(let d=0;d<a.children.length;d++){if(l>=z){i=!0;break}let p=a.children[d];if(!p)continue;let f=c(p,h+1);f.node?g.push(f.node):f.relevantChildren.length>0&&g.push(...f.relevantChildren)}if(!b)return{node:null,relevantChildren:g};let T=j(a);T===void 0&&(T=`e${u++}`,s.set(T,a)),l++;let N=a,w=a.id,k=a.getAttribute("role"),M=H(a),O=R(a),I=N.value,L=N.href,U=N.src,W=F(a),D=P(a),m={uid:T,tag:y,...w&&{id:w},...k&&{role:k},...M&&{name:M},...I&&{value:I},...L&&{href:L},...U&&{src:U},...O&&{text:O},...W&&{aria:W},...D&&{computed:D},children:g};if(y==="iframe"&&o)try{let d=a;(d.contentDocument||d.contentWindow?.document)?.body||(m.isIframe=!0,m.frameSrc=d.src,m.crossOrigin=!0)}catch{m.isIframe=!0,m.frameSrc=a.src,m.crossOrigin=!0}return{node:m,relevantChildren:[]}}return{tree:c(e,0).node,nodeCount:l,truncated:i,nextElementId:u,newUids:s}}var pe=["id","data-testid","data-test-id"];function K(e){let t=[],n=e;for(;n?.nodeType===Node.ELEMENT_NODE;){let r=n.nodeName.toLowerCase(),o=!1;for(let s of pe){let c=n.getAttribute(s);if(c){s==="id"?r+="#"+CSS.escape(c):r+=`[${s}="${J(c)}"]`,t.unshift(r),o=!0;break}}if(o)break;let l=n.getAttribute("aria-label"),u=n.getAttribute("role");if(l&&u){r+=`[role="${u}"][aria-label="${J(l)}"]`,t.unshift(r),n=n.parentElement;continue}let i=n.parentElement?.children;if(i&&i.length>1){let s=1;for(let c=0;c<i.length;c++){let E=i[c];if(E){if(E===n)break;E.nodeName===n.nodeName&&s++}}(s>1||i.length>1&&i[0]!==n)&&(r+=`:nth-of-type(${s})`)}if(t.unshift(ge(r)),n=n.parentElement,n?.nodeName.toLowerCase()==="body"){t.unshift("body");break}}return t.join(" > ")}function J(e){return e.replace(/"/g,'\\"').substring(0,64)}function ge(e){return e.length<=64?e:e.substring(0,64)}function Q(e,t){try{let n=document.body;if(t?.selector)try{let u=document.querySelector(t.selector);if(!u)return{tree:null,nodeCount:0,truncated:!1,nextElementId:e,selectorError:`Selector "${t.selector}" not found`};n=u}catch{return{tree:null,nodeCount:0,truncated:!1,nextElementId:e,selectorError:`Invalid selector syntax: "${t.selector}"`}}let r={includeIframes:t?.includeIframes??!0};t?.includeAll!==void 0&&(r.includeAll=t.includeAll);let{newUids:o,...l}=B(n,e,r);if(!l.tree)throw new Error("Failed to generate tree");return q(o),l}catch{return{tree:null,nodeCount:0,truncated:!1,nextElementId:e}}}function Z(e){return _(e)}function ee(e){let t=_(e);return t?K(t):null}function te(){Y()}if(typeof window<"u"){let e=window;e.__createSnapshot=Q,e.__resolveUid=Z,e.__uidToSelector=ee,e.__clearUidRegistry=te}return ae(Ee);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mozilla/firefox-devtools-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server for Firefox DevTools automation",
|
|
5
5
|
"author": "Mozilla",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
"start": "node dist/index.js",
|
|
21
21
|
"setup": "node scripts/setup-mcp-config.js",
|
|
22
22
|
"clean": "rm -rf dist",
|
|
23
|
-
"typecheck": "tsc
|
|
24
|
-
"
|
|
25
|
-
"lint
|
|
23
|
+
"typecheck": "tsc",
|
|
24
|
+
"typecheck:tests": "tsc -p tests/tsconfig.json",
|
|
25
|
+
"lint": "eslint src tests --ext .ts",
|
|
26
|
+
"lint:fix": "eslint src tests --ext .ts --fix",
|
|
26
27
|
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
27
28
|
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
28
29
|
"check": "npm run lint:fix && npm run typecheck",
|
package/scripts/build-mcpb.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { tmpdir } from 'node:os';
|
|
|
13
13
|
|
|
14
14
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
15
15
|
const pkg = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8'));
|
|
16
|
-
const manifest = JSON.parse(readFileSync(resolve(root, 'manifest.json'), 'utf8'));
|
|
16
|
+
const manifest = JSON.parse(readFileSync(resolve(root, 'manifest.mcpb.json'), 'utf8'));
|
|
17
17
|
|
|
18
18
|
console.log('Building server...');
|
|
19
19
|
execSync('npm run build', { cwd: root, stdio: 'inherit' });
|