sliccy 1.31.2 → 1.32.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 +2 -0
- package/dist/ui/assets/cdp-DNK51gjc.js +868 -0
- package/dist/ui/assets/{es-CV6wGk2C.js → es-DA17BdIU.js} +1 -1
- package/dist/ui/assets/{index-B3tZqynj.js → index-BDahNPoV.js} +6 -6
- package/dist/ui/assets/lick-manager-B_RADgkU.js +1 -0
- package/dist/ui/assets/shell-BKFvM9qv.js +1 -0
- package/dist/ui/assets/sprinkle-renderer-Bm_K0JjZ.js +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/ui/packages/webapp/index.html +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/cdp-bn5Tu_JK.js +0 -10
- package/dist/ui/assets/lick-manager-C-hwHk06.js +0 -1
- package/dist/ui/assets/shell-CJK5usKQ.js +0 -1
- package/dist/ui/assets/sprinkle-renderer-xyE0MKmx.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./index-BDahNPoV.js";export{e as getLickManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./index-BDahNPoV.js";export{e as WasmShell};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./index-BDahNPoV.js";export{e as collectThemeCSS};
|
package/dist/ui/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-BDahNPoV.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-zsgVPwQN.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ca-nBW7U.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/fs-f8JZDPIF.js">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/tray-follower-status-M8dOhnzY.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/provider-settings-9fKSxjtX.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/browser-DHa7-69Q.js">
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/cdp-
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/cdp-DNK51gjc.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/db-CogIG09c.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="/assets/magick-wasm-BR29mZjN.js">
|
|
22
22
|
<link rel="modulepreload" crossorigin href="/assets/skills-CTi4XTwR.js">
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-BDahNPoV.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-zsgVPwQN.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ca-nBW7U.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/fs-f8JZDPIF.js">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/tray-follower-status-M8dOhnzY.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/provider-settings-9fKSxjtX.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/browser-DHa7-69Q.js">
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/cdp-
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/cdp-DNK51gjc.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/db-CogIG09c.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="/assets/magick-wasm-BR29mZjN.js">
|
|
22
22
|
<link rel="modulepreload" crossorigin href="/assets/skills-CTi4XTwR.js">
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-BR29mZjN.js","assets/chunk-zsgVPwQN.js","assets/preload-helper-ca-nBW7U.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./chunk-zsgVPwQN.js";import{t}from"./logger-B-No_qN_.js";import{t as n}from"./preload-helper-ca-nBW7U.js";var r=t(`cdp`),i=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,r.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(r.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),r.info(`Disconnected`)}async send(e,t,n,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),n&&(o.sessionId=n),r.debug(`Send`,{method:e,id:a,sessionId:n}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;r.debug(`Response`,{id:e.id,hasError:!!e.error});let n=this.pending.get(e.id);n&&(this.pending.delete(e.id),e.error?(r.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),n.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):n.resolve(e.result??{}));return}if(`method`in t){let e=t;r.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(){r.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function a(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var o=`ws://localhost:5710/cdp`,s=t(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new i,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),(await this.client.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),((await this.client.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);return this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r},this.sessionId=(await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0})).sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}return this.sessionId=(await this.client.send(`Target.attachToTarget`,{targetId:e,flatten:!0})).sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let t={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(t.quality=e.quality),e?.clip||e?.fullPage){let n=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),t=JSON.parse(e.result?.value??`{}`);n=t.w??0,r=t.h??0}catch{}e?.clip?t.clip={...e.clip,scale:e.clip.scale??1}:t.clip={x:0,y:0,width:n||1280,height:r||800,scale:1}}let r=(await this.client.send(`Page.captureScreenshot`,t,this.sessionId)).data;if(e?.maxWidth)try{let{getMagick:t}=await n(async()=>{let{getMagick:e}=await import(`./magick-wasm-BR29mZjN.js`).then(e=>e.n);return{getMagick:e}},__vite__mapDeps([0,1,2])),i=await t(),a=atob(r),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await i.ImageMagick.read(o,async t=>{let n=Math.min(e.maxWidth,s),i=Math.max(t.width,t.height);if(t.width>n||i>s){let e=Math.min(n/t.width,s/i);t.resize(Math.round(t.width*e),Math.round(t.height*e)),c=!0}c&&t.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);r=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return r}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Accessibility.enable`,{},this.sessionId);let e=(await this.client.send(`Accessibility.getFullAXTree`,{},this.sessionId)).nodes;if(!e||e.length===0)return{role:`RootWebArea`,name:``};let t=new Map,n;for(let r of e){let e=a(r.value?.value),i=a(r.description?.value),o={role:a(r.role?.value,`unknown`),name:a(r.name?.value)};e!==``&&(o.value=e),i!==``&&(o.description=i),r.backendDOMNodeId&&(o.backendNodeId=r.backendDOMNodeId),r.childIds&&(o.childIds=r.childIds),t.set(r.nodeId,o),r.parentId||(n=r.nodeId)}function r(e){let n=t.get(e);if(!n)return{role:`unknown`,name:``};let i={role:n.role,name:n.name};return n.value&&(i.value=n.value),n.description&&(i.description=n.description),n.backendNodeId&&(i.backendNodeId=n.backendNodeId),n.childIds&&n.childIds.length>0&&(i.children=n.childIds.map(e=>r(e)).filter(e=>e.role!==`unknown`)),i}return n?r(n):{role:`RootWebArea`,name:``}}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
|
|
3
|
-
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
4
|
-
const r = this.getBoundingClientRect();
|
|
5
|
-
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
6
|
-
}`,returnByValue:!0},this.sessionId)).result?.value;if(!n||n.width===0||n.height===0){await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() { this.click(); }`},this.sessionId);return}let r=n.x+n.width/2,i=n.y+n.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:r,y:i,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:`left`,clickCount:1},this.sessionId)}async dblclickByBackendNodeId(e,t=`left`){await this.ensureConnected(),this.ensureAttached();let{x:n,y:r}=await this.resolveNodeCenter(e);await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:t,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:t,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:t,clickCount:2},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:t,clickCount:2},this.sessionId)}async hoverByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached();let{x:t,y:n}=await this.resolveNodeCenter(e);await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseMoved`,x:t,y:n},this.sessionId)}async selectByBackendNodeId(e,t){await this.ensureConnected(),this.ensureAttached();let n=await this.resolveNodeObjectId(e);await this.client.send(`Runtime.callFunctionOn`,{objectId:n,functionDeclaration:`function(val) { this.value = val; this.dispatchEvent(new Event('change', { bubbles: true })); }`,arguments:[{value:t}],returnByValue:!0},this.sessionId)}async setCheckedByBackendNodeId(e,t){await this.ensureConnected(),this.ensureAttached();let n=await this.resolveNodeObjectId(e);return(await this.client.send(`Runtime.callFunctionOn`,{objectId:n,functionDeclaration:`function() { return this.checked; }`,returnByValue:!0},this.sessionId)).result?.value===t?`already`:(await this.clickByBackendNodeId(e),`toggled`)}async dragByBackendNodeIds(e,t){await this.ensureConnected(),this.ensureAttached();let n=await this.resolveNodeCenter(e),r=await this.resolveNodeCenter(t);await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n.x,y:n.y,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseMoved`,x:r.x,y:r.y},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r.x,y:r.y,button:`left`,clickCount:1},this.sessionId)}async sendCDP(e,t={}){return await this.ensureConnected(),this.ensureAttached(),await this.client.send(e,t,this.sessionId)}async resolveNodeObjectId(e){await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);return t.objectId}async resolveNodeCenter(e){let t=await this.resolveNodeObjectId(e),n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t,functionDeclaration:`function() {
|
|
7
|
-
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
8
|
-
const r = this.getBoundingClientRect();
|
|
9
|
-
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
10
|
-
}`,returnByValue:!0},this.sessionId)).result?.value;if(!n||n.width===0||n.height===0)throw Error(`Element with backend node ${e} has no dimensions`);return{x:n.x+n.width/2,y:n.y+n.height/2}}async ensureConnected(){this.client.state===`disconnected`&&(this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null,this.client.state===`disconnected`&&await this.connect())}ensureAttached(){if(!this.sessionId)throw Error(`Not attached to a page. Call attachToPage(targetId) first.`)}addDialogListener(e){e.on(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}removeDialogListener(e){e.off(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}setClient(e){this.client!==e&&(this.removeDialogListener(this.client),this.client=e,this.addDialogListener(this.client))}async boundingBox(e){await this.client.send(`DOM.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.getDocument`,{depth:0},this.sessionId)).root.nodeId,n;try{n=(await this.client.send(`DOM.querySelector`,{nodeId:t,selector:e},this.sessionId)).nodeId}catch{return null}if(!n)return null;let r=(await this.client.send(`DOM.getBoxModel`,{nodeId:n},this.sessionId)).model;if(!r)return null;let i=r.content;return{x:i[0],y:i[1],width:r.width,height:r.height}}};t(`cdp:debugger`);var u=class{_state=`disconnected`;nextCommandId=1;listeners=new Map;pendingCommands=new Map;messageHandler=null;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);this.messageHandler=e=>{try{if(!d(e))return;let t=e;t.source===`offscreen`&&t.payload.type===`panel-cdp-response`&&this.handleCdpResponse(t.payload),t.source===`service-worker`&&t.payload.type===`cdp-event`&&this.handleCdpEvent(t.payload)}catch(e){console.error(`[panel-cdp-proxy] Error in message handler:`,e)}},chrome.runtime.onMessage.addListener(this.messageHandler),this._state=`connected`}disconnect(){this.messageHandler&&=(chrome.runtime.onMessage.removeListener(this.messageHandler),null);for(let[,e]of this.pendingCommands)clearTimeout(e.timer),e.reject(Error(`Panel CDP proxy disconnected`));this.pendingCommands.clear(),this.listeners.clear(),this._state=`disconnected`}async send(e,t,n,r=3e4){if(this._state!==`connected`)throw Error(`PanelCdpProxy is not connected`);let i=this.nextCommandId++,a={type:`panel-cdp-command`,id:i,method:e,params:t,sessionId:n};return new Promise((t,n)=>{let o=!1,s=setTimeout(()=>{o||(o=!0,this.pendingCommands.delete(i),n(Error(`CDP command timed out after ${r}ms: ${e}`)))},r);this.pendingCommands.set(i,{resolve:t,reject:n,timer:s}),chrome.runtime.sendMessage({source:`panel`,payload:a}).catch(e=>{o||(o=!0,this.pendingCommands.delete(i),clearTimeout(s),n(Error(`Failed to send CDP command: ${e instanceof Error?e.message:String(e)}`)))})})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleCdpResponse(e){let t=this.pendingCommands.get(e.id);if(!t){console.warn(`[panel-cdp-proxy] Ignoring CDP response with unknown id ${e.id}`);return}this.pendingCommands.delete(e.id),clearTimeout(t.timer),e.error?t.reject(Error(e.error)):t.resolve(e.result??{})}handleCdpEvent(e){let t=this.listeners.get(e.method);if(t)for(let n of t)try{n(e.params??{})}catch(t){console.error(`[panel-cdp-proxy] Listener error for event "${e.method}":`,t)}}};function d(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}var f=t(`har-recorder`),p=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n){let r=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await this.client.send(`Network.enable`,{},t),await this.client.send(`Page.enable`,{},t);let i=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,a={id:r,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:i,snapshotCount:0};return this.recordings.set(r,a),this.setupEventListeners(a),await this.ensureDir(`/recordings/${r}`),f.debug(`Started recording`,{recordingId:r,targetId:e,currentUrl:i}),r}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{n.sessionId===t&&this.handleRequestWillBeSent(e,n)},i=n=>{n.sessionId===t&&this.handleResponseReceived(e,n)},a=n=>{n.sessionId===t&&this.handleLoadingFinished(e,n)},o=n=>{n.sessionId===t&&this.handleLoadingFailed(e,n)},s=r=>{if(r.sessionId!==t)return;let i=r.frame;if(!i?.parentId&&i?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=i.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{f.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,o),this.client.on(`Page.frameNavigated`,s),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,o),this.client.off(`Page.frameNavigated`,s)})}handleRequestWillBeSent(e,t){let n=t.requestId,r=t.request,i=t.timestamp;e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let n=t.requestId,r=t.response,i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let n=t.requestId,r=t.timestamp,i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let n=t.requestId;e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){if(typeof chrome<`u`&&chrome?.runtime?.id)try{let n=document.querySelector(`iframe[data-js-tool]`);n||(n=document.createElement(`iframe`),n.style.display=`none`,n.dataset.jsTool=`true`,n.src=chrome.runtime.getURL(`sandbox.html`),document.body.appendChild(n),await Promise.race([new Promise(e=>{n.addEventListener(`load`,()=>e(),{once:!0})}),new Promise((e,t)=>{setTimeout(()=>t(Error(`Sandbox iframe failed to load`)),5e3)})]));let r=`har-filter-${Date.now()}-${Math.random().toString(36).slice(2)}`;return await new Promise((i,a)=>{let o=setTimeout(()=>{window.removeEventListener(`message`,s),a(Error(`HAR filter sandbox timeout`))},1e4),s=e=>{e.data?.type===`har_filter_result`&&e.data.id===r&&(window.removeEventListener(`message`,s),clearTimeout(o),e.data.error?a(Error(e.data.error)):i(e.data.entries))};window.addEventListener(`message`,s),n.contentWindow.postMessage({type:`har_filter`,id:r,entries:e,filterCode:t},`*`)})}catch(t){return f.error(`HAR filter sandbox error, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}else try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){f.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return f.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return f.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return f.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),o=this.urlToSlug(r),s=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${o}.har`,c=`/recordings/${e.id}/${s}`,l={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(c,JSON.stringify(l,null,2)),f.debug(`Saved HAR snapshot`,{recordingId:e.id,path:c,entryCount:i.length}),c}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return f.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}},m=t(`tray-sync`),h=32*1024;function g(e,t,n,r){if(r||!n)return e.send({type:`cdp.response`,requestId:t,result:n,error:r});let i=JSON.stringify(n);if(i.length<=65536)return e.send({type:`cdp.response`,requestId:t,result:n});let a=Math.ceil(i.length/h),o=!0;for(let n=0;n<a;n++){let r=i.slice(n*h,(n+1)*h);if(!e.send({type:`cdp.response`,requestId:t,chunkData:r,chunkIndex:n,totalChunks:a})){o=!1,e.send({type:`cdp.response`,requestId:t,error:`Failed to send CDP response chunk ${n}/${a} (response was ${i.length} bytes)`});break}}return o}function _(e,t){if(t.chunkIndex===void 0||t.totalChunks===void 0)return{result:t.result,error:t.error};if(t.error)return e.delete(t.requestId),{error:t.error};let n=t.requestId,r=e.get(n);if(r||(r={chunks:Array(t.totalChunks),received:0,totalChunks:t.totalChunks},e.set(n,r)),r.chunks[t.chunkIndex]||(r.chunks[t.chunkIndex]=t.chunkData,r.received++),r.received>=r.totalChunks){e.delete(n);try{return{result:JSON.parse(r.chunks.join(``))}}catch(e){return{error:`Failed to reassemble CDP response: ${e instanceof Error?e.message:String(e)}`}}}return null}var v=32*1024;function y(e,t,n){let r=JSON.stringify({messages:t,scoopJid:n});if(r.length<=65536)return e.send({type:`snapshot`,messages:t,scoopJid:n});let i=Math.ceil(r.length/v),a=!0;for(let t=0;t<i;t++){let o=r.slice(t*v,(t+1)*v);if(!e.send({type:`snapshot_chunk`,chunkData:o,chunkIndex:t,totalChunks:i,scoopJid:n})){a=!1,m.error(`Failed to send snapshot chunk`,{chunkIndex:t,totalChunks:i,totalSize:r.length});break}}return m.debug(`Snapshot sent in chunks`,{totalChunks:i,totalSize:r.length}),a}function b(e,t){if(e||={chunks:Array(t.totalChunks),received:0,totalChunks:t.totalChunks},e.chunks[t.chunkIndex]||(e.chunks[t.chunkIndex]=t.chunkData,e.received++),e.received>=e.totalChunks)try{return{result:JSON.parse(e.chunks.join(``)),buffer:null}}catch(e){return m.error(`Failed to reassemble snapshot`,{error:e instanceof Error?e.message:String(e)}),{result:{messages:[],scoopJid:t.scoopJid},buffer:null}}return{result:null,buffer:e}}var x=class{listeners=[];closed=!1;constructor(e){this.channel=e,this.channel.addEventListener(`message`,e=>{if(!this.closed)try{let t=JSON.parse(e.data);for(let e of this.listeners)e(t)}catch(e){m.warn(`Failed to parse tray sync message`,{error:e instanceof Error?e.message:String(e)})}})}send(e){if(this.closed)return!1;try{return this.channel.send(JSON.stringify(e)),!0}catch(t){return m.error(`Failed to send tray sync message`,{type:e.type,error:t instanceof Error?t.message:String(t)}),!1}}onMessage(e){return this.listeners.push(e),()=>{let t=this.listeners.indexOf(e);t>=0&&this.listeners.splice(t,1)}}close(){this.closed=!0,this.listeners.length=0,this.channel.close()}get isOpen(){return!this.closed&&this.channel.readyState===`open`}};function S(e){return new x(e)}function C(e){return new x(e)}var w=class{pending=new Map;eventListeners=new Map;chunkBuffers=new Map;_state=`connected`;requestCounter=0;constructor(e,t=3e4){this.sender=e,this.timeoutMs=t}get state(){return this._state}async connect(){}disconnect(){this._state=`disconnected`;for(let[,{reject:e,timer:t}]of this.pending)clearTimeout(t),e(Error(`Transport disconnected`));this.pending.clear()}async send(e,t,n,r){if(this._state===`disconnected`)throw Error(`Transport disconnected`);let i=`remote-${++this.requestCounter}-${Date.now()}`,a=r??this.timeoutMs;return new Promise((r,o)=>{let s=setTimeout(()=>{this.pending.delete(i),o(Error(`Remote CDP request timed out after ${a}ms: ${e}`))},a);this.pending.set(i,{resolve:r,reject:o,timer:s}),this.sender.sendCDPRequest(i,e,t,n)})}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n)),n.add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}once(e,t){return new Promise((n,r)=>{let i=t??this.timeoutMs,a=setTimeout(()=>{this.off(e,o),r(Error(`Remote CDP event timed out: ${e}`))},i),o=t=>{clearTimeout(a),this.off(e,o),n(t)};this.on(e,o)})}handleResponse(e,t,n,r,i,a){let o=this.pending.get(e);if(!o)return;let s=_(this.chunkBuffers,{type:`cdp.response`,requestId:e,result:t,error:n,chunkData:r,chunkIndex:i,totalChunks:a});s&&(this.pending.delete(e),clearTimeout(o.timer),s.error?o.reject(Error(s.error)):o.resolve(s.result??{}))}handleEvent(e,t){let n=this.eventListeners.get(e);if(n)for(let e of n)e(t)}},T=e({BrowserAPI:()=>l,PanelCdpProxy:()=>u});export{_ as a,y as c,a as d,S as i,p as l,w as n,b as o,C as r,g as s,T as t,l as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./index-B3tZqynj.js";export{e as getLickManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./index-B3tZqynj.js";export{e as WasmShell};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./index-B3tZqynj.js";export{e as collectThemeCSS};
|