@gjsify/devtools-cdp 0.22.0 → 0.23.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.
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{InspectorProtocolClient as e}from"./inspector-protocol-client.js";import{discoverInspectorTargets as t}from"./target-discovery.js";const n=[`Inspector`,`Runtime`,`DOM`,`Console`];function inspectorProtocolExtension(r){let{port:i}=r,a=r.host??`127.0.0.1`,o=r.autoEnableDomains??n,s=new Map,c=null,discover=()=>t(i,{host:a,fetchImpl:r.fetchImpl});async function resolveTarget(e){let t=e&&e.trim()?JSON.parse(e):null;if(t&&typeof t.wsUrl==`string`)return t;let n=await discover();if(t&&typeof t.targetId==`string`){let e=n.find(e=>e.targetId===t.targetId);if(e)return e}return n.find(e=>e.targetType===`web-page`)??n[0]}async function connect(t){let n=await resolveTarget(t);if(!n)return!1;let i=s.get(n.wsUrl);return i||(i=new e(n.wsUrl,{createWebSocket:r.createWebSocket}),s.set(n.wsUrl,i)),i.connected||(await i.connect(),await i.enableDomains(o)),c=n.wsUrl,!0}let currentClient=()=>c?s.get(c)??null:null;return{methodsXml:[`<method name="CdpDiscoverTargets"><arg type="s" direction="out" name="targets_json"/></method>`,`<method name="CdpConnect"><arg type="s" direction="in" name="target_json"/><arg type="b" direction="out" name="ok"/></method>`,`<method name="CdpSend"><arg type="s" direction="in" name="method"/><arg type="s" direction="in" name="params_json"/><arg type="s" direction="out" name="result_json"/></method>`,`<method name="CdpDrainEvents"><arg type="s" direction="out" name="events_json"/></method>`],handlers:{CdpDiscoverTargets:async()=>JSON.stringify(await discover(),null,2),CdpConnect:async e=>connect(e),CdpSend:async(e,t)=>{let n=currentClient();if(!n)throw Error(`CdpSend: not connected — call CdpConnect first`);let r=t&&t.trim()?JSON.parse(t):void 0,i=await n.send(e,r);return JSON.stringify(i??null,null,2)},CdpDrainEvents:()=>{let e=currentClient();return JSON.stringify(e?e.drainEvents():[],null,2)}},methodKinds:{CdpDiscoverTargets:`read-only`,CdpConnect:`read-only`,CdpSend:`mutating`,CdpDrainEvents:`read-only`},contributeStatus:()=>({inspector:{port:i,host:a,connected:currentClient()?.connected??!1,targetCount:s.size}})}}export{inspectorProtocolExtension};
1
+ import"./_virtual/_rolldown/runtime.js";import{InspectorProtocolClient as e}from"./inspector-protocol-client.js";import{discoverInspectorTargets as t}from"./target-discovery.js";const n=[`Inspector`,`Runtime`,`DOM`,`Console`];function inspectorProtocolExtension(r){let{port:i}=r,a=r.host??`127.0.0.1`,o=r.autoEnableDomains??n,s=new Map,c=null,discover=()=>t(i,{host:a,fetchImpl:r.fetchImpl});async function resolveTarget(e){let t=e&&e.trim()?JSON.parse(e):null;if(t&&typeof t.wsUrl==`string`)return t;let n=await discover();if(t&&typeof t.targetId==`string`){let e=n.find(e=>e.targetId===t.targetId);if(e)return e}return n.find(e=>e.targetType===`web-page`)??n[0]}async function connect(t){let n=await resolveTarget(t);if(!n)return!1;let i=s.get(n.wsUrl);return i||(i=new e(n.wsUrl,{createWebSocket:r.createWebSocket}),s.set(n.wsUrl,i)),i.connected||(await i.connect(),await i.enableDomains(o)),c=n.wsUrl,!0}let currentClient=()=>c?s.get(c)??null:null;return{methodsXml:[`<method name="CdpDiscoverTargets"><arg type="s" direction="out" name="targets_json"/></method>`,`<method name="CdpConnect"><arg type="s" direction="in" name="target_json"/><arg type="b" direction="out" name="ok"/></method>`,`<method name="CdpSend"><arg type="s" direction="in" name="method"/><arg type="s" direction="in" name="params_json"/><arg type="s" direction="out" name="result_json"/></method>`,`<method name="CdpDrainEvents"><arg type="s" direction="out" name="events_json"/></method>`],handlers:{CdpDiscoverTargets:async()=>JSON.stringify(await discover(),null,2),CdpConnect:async e=>connect(e),CdpSend:async(e,t)=>{let n=currentClient();if(!n)throw Error(`CdpSend: not connected — call CdpConnect first`);let r=t&&t.trim()?JSON.parse(t):void 0,i=await n.send(e,r);return JSON.stringify(i??null,null,2)},CdpDrainEvents:()=>{let e=currentClient();return JSON.stringify(e?e.drainEvents():[],null,2)}},methodKinds:{CdpDiscoverTargets:`read-only`,CdpConnect:`read-only`,CdpSend:`mutating`,CdpDrainEvents:`read-only`},contributeStatus:()=>{let e=currentClient();return{inspector:{port:i,host:a,connected:e?.connected??!1,targetCount:s.size}}}}}export{inspectorProtocolExtension};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/devtools-cdp",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "WebKit Remote Inspector Protocol (CDP-shaped) client for GJS — JSON-RPC over a per-target WebSocket + HTML target discovery, the basis for driving WebKitGTK devtools over MCP",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -34,13 +34,13 @@
34
34
  "mcp"
35
35
  ],
36
36
  "dependencies": {
37
- "@gjsify/devtools": "^0.22.0",
38
- "@gjsify/fetch": "^0.22.0",
39
- "@gjsify/websocket": "^0.22.0"
37
+ "@gjsify/devtools": "^0.23.0",
38
+ "@gjsify/fetch": "^0.23.0",
39
+ "@gjsify/websocket": "^0.23.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@gjsify/cli": "^0.22.0",
43
- "@gjsify/unit": "^0.22.0",
42
+ "@gjsify/cli": "^0.23.0",
43
+ "@gjsify/unit": "^0.23.0",
44
44
  "@types/node": "^25.9.2",
45
45
  "typescript": "^6.0.3"
46
46
  },