sliccy 5.84.1 → 5.85.1
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/dist/ui/assets/{account-store-Dg-88ChJ.js → account-store-Bk0b9NNs.js} +1 -1
- package/dist/ui/assets/{account-store-CIBUpBw2.js → account-store-CsBhRflH.js} +1 -1
- package/dist/ui/assets/{adobe-DAu9m3li.js → adobe-BGZkhFf2.js} +1 -1
- package/dist/ui/assets/{adobe-CVUX352o.js → adobe-Cx_KcqS7.js} +1 -1
- package/dist/ui/assets/{apps-xHXbN2GJ.js → apps-Cu97llYd.js} +1 -1
- package/dist/ui/assets/{azure-openai-BRzd21eO.js → azure-openai-BAm3cDne.js} +1 -1
- package/dist/ui/assets/{azure-openai-Cj6dde55.js → azure-openai-GFt6bSin.js} +1 -1
- package/dist/ui/assets/{bedrock-camp-CVignIdH.js → bedrock-camp-CJY4i7di.js} +1 -1
- package/dist/ui/assets/{bedrock-camp-BO4bvAKs.js → bedrock-camp-DS0ilb3O.js} +1 -1
- package/dist/ui/assets/{cdp-BvZO3XX0.js → cdp-BEmpfM7z.js} +3 -3
- package/dist/ui/assets/{cerebras-DEHTb-Jp.js → cerebras-BdTrAltR.js} +1 -1
- package/dist/ui/assets/{cerebras-CSw0virw.js → cerebras-u2VrvWCg.js} +1 -1
- package/dist/ui/assets/{compat-aVSWLlYQ.js → compat-CkpNnFQS.js} +2 -2
- package/dist/ui/assets/completionchunk-CP7I4h3f.js +65 -0
- package/dist/ui/assets/completionchunk-JDMithrI.js +65 -0
- package/dist/ui/assets/{connect-surface-B3wGdqfR.js → connect-surface-B96uOALu.js} +1 -1
- package/dist/ui/assets/{context-compaction-_UkD06XB.js → context-compaction-C3e7rcEG.js} +1 -1
- package/dist/ui/assets/{fs-VwSXMsmq.js → fs-BQWc6Z05.js} +1 -1
- package/dist/ui/assets/{fs-g_oZbQ21.js → fs-kONhSqSK.js} +2 -2
- package/dist/ui/assets/{github-CyRcWzgO.js → github-BI5DkpcT.js} +1 -1
- package/dist/ui/assets/{github-copilot-CdLypAPy.js → github-copilot-Cta-8OE1.js} +1 -1
- package/dist/ui/assets/{github-copilot-BsgIQbuu.js → github-copilot-Ph5jEo5J.js} +1 -1
- package/dist/ui/assets/{github-DjZvupYV.js → github-hk9FJt_e.js} +2 -2
- package/dist/ui/assets/{kernel-worker-O-LVJQ2M.js → kernel-worker-DEYYnmZR.js} +437 -434
- package/dist/ui/assets/{legacy-api-aliases-IllWZ-uu.js → legacy-api-aliases-BWm3gxUe.js} +1 -1
- package/dist/ui/assets/{legacy-api-aliases-sqlB2uHc.js → legacy-api-aliases-YuuBU-he.js} +1 -1
- package/dist/ui/assets/{local-llm-Bo1kGMdi.js → local-llm-DtW9XFUO.js} +1 -1
- package/dist/ui/assets/{local-llm-C0t8US-G.js → local-llm-MwQVvzDf.js} +1 -1
- package/dist/ui/assets/{main-DiIgQpU7.js → main-DOvIDR_a.js} +3 -3
- package/dist/ui/assets/{main-cherry-CQ53lnqT.js → main-cherry-DCIO_2RP.js} +1 -1
- package/dist/ui/assets/{mistral-conversations-C57IiFrP.js → mistral-conversations-CIMZoDT4.js} +2 -2
- package/dist/ui/assets/{mistral-conversations-CzEm7KNl.js → mistral-conversations-CKK59QJS.js} +1 -1
- package/dist/ui/assets/{mount-D3ittikV.js → mount-28699D0M.js} +1 -1
- package/dist/ui/assets/{mount-OjhGugIM.js → mount-DABeOJmG.js} +2 -2
- package/dist/ui/assets/{mount-recovery-xwx3blgR.js → mount-recovery-DltEGR2O.js} +1 -1
- package/dist/ui/assets/{new-session-CM_drdQb.js → new-session-VQsGUTpx.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-CksCYB3j.js → oauth-bootstrap-E6pWsJ74.js} +2 -2
- package/dist/ui/assets/{openai-codex-CqUAR4bA.js → openai-codex-Bu3_z5H4.js} +1 -1
- package/dist/ui/assets/{openai-codex-BngX1JyO.js → openai-codex-E2ahulS6.js} +1 -1
- package/dist/ui/assets/{openrouter-BPw5Sadh.js → openrouter-Bcf97CqM.js} +1 -1
- package/dist/ui/assets/{openrouter-DuuXMYpn.js → openrouter-IR6bjwZs.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-BZGhluYu.js → openrouter-oauth-D2JDfVVh.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-D8PeRKGv.js → openrouter-oauth-r-JJqWWo.js} +1 -1
- package/dist/ui/assets/{otel-joHgpnL_.js → otel-BJT2f71U.js} +1 -1
- package/dist/ui/assets/{otel-C1NYdIbe.js → otel-DHVJhmnv.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-Bo8vrbSN.js → panel-rpc-handlers-BjQ7aZ4J.js} +2 -2
- package/dist/ui/assets/{provider-BGfZxYoy.js → provider-BIKweYVv.js} +1 -1
- package/dist/ui/assets/{provider-CE7DxoOs.js → provider-Ci-sMWNb.js} +2 -2
- package/dist/ui/assets/{provider-settings-DpKLVtWv.js → provider-settings-DMA4IYKn.js} +1 -1
- package/dist/ui/assets/{provider-settings-BlX2WDPs.js → provider-settings-onyoJBmZ.js} +1 -1
- package/dist/ui/assets/{provider-store-access-DMG7bO02.js → provider-store-access-CUma_NmZ.js} +2 -2
- package/dist/ui/assets/provider-store-access-D1zmsZC2.js +1 -0
- package/dist/ui/assets/{providers-Bf8LGL3R.js → providers-Bb9FFUf2.js} +1 -1
- package/dist/ui/assets/{providers-DtodZfUb.js → providers-DHt2mtgL.js} +2 -2
- package/dist/ui/assets/{quick-llm-CeEUNaq_.js → quick-llm-BNgArafa.js} +1 -1
- package/dist/ui/assets/{session-freezer-BWXlNuLZ.js → session-freezer-BxOqNgNy.js} +3 -3
- package/dist/ui/assets/{setup-standalone-prelude-B3IfFCKC.js → setup-standalone-prelude-BIyuLmhj.js} +2 -2
- package/dist/ui/assets/{setup-sudo-COdRfoNx.js → setup-sudo-kMkEApFT.js} +2 -2
- package/dist/ui/assets/{skills-C0KYnRNq.js → skills-Da4EzDso.js} +1 -1
- package/dist/ui/assets/{store-BkJEbwIV.js → store-F71gCibD.js} +1 -1
- package/dist/ui/assets/{sudo-C14xgLpR.js → sudo-BpkAFF9G.js} +1 -1
- package/dist/ui/assets/synthetic-cdp-transport-CtfKyiws.js +1 -0
- package/dist/ui/assets/{upgrade-detection-7iVU0rhN.js → upgrade-detection-CJ0TQg6r.js} +1 -1
- package/dist/ui/assets/{wc-extension-D51Vv0vp.js → wc-extension-OhzrnYpd.js} +2 -2
- package/dist/ui/assets/wc-floatbar-online-B6M0vf6K.js +5 -0
- package/dist/ui/assets/{wc-follower-c5fHMODp.js → wc-follower-DZUXv1tI.js} +3 -3
- package/dist/ui/assets/{wc-live-C9XjDjJF.js → wc-live-CvPOrtDy.js} +3 -3
- package/dist/ui/assets/{wc-nav-lsahpZ4D.js → wc-nav-v3ePVEaG.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-Cv35SFqQ.js → wc-onboarding-CKqWd2Kf.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-CVW34MdT.js → wc-placeholder-O8hlZSYg.js} +2 -2
- package/dist/ui/assets/{wc-settings-hY2enRpj.js → wc-settings-BYnJ8pmJ.js} +2 -2
- package/dist/ui/assets/{wc-shell-sWdEFmce.js → wc-shell-BS2MhiHQ.js} +2 -2
- package/dist/ui/assets/{wc-sprinkles-eo_EqzP6.js → wc-sprinkles-BGz-e1Ll.js} +2 -2
- package/dist/ui/assets/wc-tray-DlDL4ryR.js +2 -0
- package/dist/ui/assets/{xai-grok-QqXg9_fn.js → xai-grok-D6oOTqN5.js} +1 -1
- package/dist/ui/assets/{xai-grok-Cx13gJC8.js → xai-grok-DC9ObfPf.js} +1 -1
- package/dist/ui/index.html +9 -9
- package/dist/ui/packages/webapp/index.html +9 -9
- package/package.json +1 -1
- package/dist/ui/assets/completionchunk-BsT4qCtf.js +0 -40
- package/dist/ui/assets/completionchunk-D8ek1SQ-.js +0 -40
- package/dist/ui/assets/provider-store-access-D5wBiefF.js +0 -1
- package/dist/ui/assets/synthetic-cdp-transport-DLIt5SkY.js +0 -1
- package/dist/ui/assets/wc-floatbar-online-0Dg_sFmu.js +0 -5
- package/dist/ui/assets/wc-tray-CIccOKgS.js +0 -2
|
@@ -868,12 +868,12 @@ import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-DkN9hU8i.js
|
|
|
868
868
|
} catch(e) {
|
|
869
869
|
return { role: 'RootWebArea', name: '', description: 'Error: ' + (e.message || String(e)) };
|
|
870
870
|
}
|
|
871
|
-
})()`;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)}}function o(e){try{let t=atob(e.slice(0,48));return(t.charCodeAt(16)<<24|t.charCodeAt(17)<<16|t.charCodeAt(18)<<8|t.charCodeAt(19))>>>0}catch{return 0}}var s=`ws://localhost:5710/cdp`,c=e(`browser-api`);function l(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:s}var u=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;_lastConnectOptions=null;supersededHandler=null;supersededNotified=!1;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),c.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){c.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,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,kind:e.kind,capabilities:e.capabilities}));return[...e,...r]}async connect(e){this._lastConnectOptions=e?{...e}:{},await this.client.connect({url:e?.url??l(),timeout:e?.timeout,...e?.protocols===void 0?{}:{protocols:e.protocols}}),this.supersededNotified=!1}primeConnectOptions(e){this._lastConnectOptions=e?{...e}:{}}setCdpSupersededHandler(e){this.supersededHandler=e}notifySuperseded(){if(!this.supersededNotified){this.supersededNotified=!0;try{this.supersededHandler?.()}catch{}}}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.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.ensureLocalConnected(),((await this.localClient.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._frameContextCache.clear(),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);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),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 bringToFront(){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.bringToFront`,{},this.sessionId??void 0)}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let t={format:e?.format??`png`,captureBeyondViewport:!!(e?.clip||e?.fullPage)};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){c.warn(`fullPage: failed to evaluate scroll dimensions, falling back to viewport`,e)}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 n;try{n=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}catch(r){if(e?.foregroundFallback===!1)throw r;await this.client.send(`Page.bringToFront`,{},this.sessionId),n=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}let r=n.data;return e?.maxWidth&&(r=await this._applyMaxWidth(r,e.maxWidth,t)),r}finally{}}async _applyMaxWidth(e,t,n){let r=o(e);if(!r||r<=t)return e;let i=t/r,a=n.clip;if(a)a.scale=i;else{let e=1280,t=800;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({w:window.innerWidth,h:window.innerHeight})`,returnByValue:!0},this.sessionId),r=JSON.parse(n.result?.value??`{}`);e=r.w||1280,t=r.h||800}catch{}n.clip={x:0,y:0,width:e,height:t,scale:i}}n.captureBeyondViewport=!0;try{return(await this.client.send(`Page.captureScreenshot`,n,this.sessionId)).data}catch(t){return c.warn(`maxWidth re-capture failed, returning original`,t),e}}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,t=0){await this.ensureConnected(),this.ensureAttached();let n=await this.boundingBox(e);if(!n)throw Error(`Element not found: ${e}`);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,modifiers:t},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:`left`,clickCount:1,modifiers:t},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 insertText(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Input.insertText`,{text:e},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();let e=await this.evaluate(i,{awaitPromise:!1,returnByValue:!0});if(!e||typeof e!=`object`)return{role:`RootWebArea`,name:``};let t=p(e);try{let e=(await this.client.send(`Accessibility.getFullAXTree`,{},this.sessionId)).nodes;Array.isArray(e)&&f(t,d(e))}catch{}return t}async clickByBackendNodeId(e,t=0){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!n?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let r=(await this.client.send(`Runtime.callFunctionOn`,{objectId:n.objectId,functionDeclaration:`function() {
|
|
871
|
+
})()`;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)}}function o(e){try{let t=atob(e.slice(0,48));return(t.charCodeAt(16)<<24|t.charCodeAt(17)<<16|t.charCodeAt(18)<<8|t.charCodeAt(19))>>>0}catch{return 0}}var s=`ws://localhost:5710/cdp`,c=e(`browser-api`);function l(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:s}var u=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_mainWorldContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;_lastConnectOptions=null;supersededHandler=null;supersededNotified=!1;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),c.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){c.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};handleExecutionContextCreated=e=>{let t=e.sessionId;if(typeof t==`string`&&t!==this.sessionId)return;let n=e.context,r=n?.auxData?.frameId;n?.auxData?.isDefault===!0&&r&&typeof n.id==`number`&&this._mainWorldContextCache.set(r,n.id)};handleExecutionContextDestroyed=e=>{let t=e.sessionId;if(typeof t==`string`&&t!==this.sessionId)return;let n=e.executionContextId;if(typeof n==`number`)for(let[e,t]of this._mainWorldContextCache)t===n&&this._mainWorldContextCache.delete(e)};handleExecutionContextsCleared=e=>{let t=e.sessionId;typeof t==`string`&&t!==this.sessionId||this._mainWorldContextCache.clear()};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client),this.addExecutionContextListeners(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,kind:e.kind,capabilities:e.capabilities}));return[...e,...r]}async connect(e){this._lastConnectOptions=e?{...e}:{},await this.client.connect({url:e?.url??l(),timeout:e?.timeout,...e?.protocols===void 0?{}:{protocols:e.protocols}}),this.supersededNotified=!1}primeConnectOptions(e){this._lastConnectOptions=e?{...e}:{}}setCdpSupersededHandler(e){this.supersededHandler=e}notifySuperseded(){if(!this.supersededNotified){this.supersededNotified=!0;try{this.supersededHandler?.()}catch{}}}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.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.ensureLocalConnected(),((await this.localClient.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._frameContextCache.clear(),this._mainWorldContextCache.clear(),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);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),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 bringToFront(){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.bringToFront`,{},this.sessionId??void 0)}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let t={format:e?.format??`png`,captureBeyondViewport:!!(e?.clip||e?.fullPage)};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){c.warn(`fullPage: failed to evaluate scroll dimensions, falling back to viewport`,e)}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 n;try{n=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}catch(r){if(e?.foregroundFallback===!1)throw r;await this.client.send(`Page.bringToFront`,{},this.sessionId),n=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}let r=n.data;return e?.maxWidth&&(r=await this._applyMaxWidth(r,e.maxWidth,t)),r}finally{}}async _applyMaxWidth(e,t,n){let r=o(e);if(!r||r<=t)return e;let i=t/r,a=n.clip;if(a)a.scale=i;else{let e=1280,t=800;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({w:window.innerWidth,h:window.innerHeight})`,returnByValue:!0},this.sessionId),r=JSON.parse(n.result?.value??`{}`);e=r.w||1280,t=r.h||800}catch{}n.clip={x:0,y:0,width:e,height:t,scale:i}}n.captureBeyondViewport=!0;try{return(await this.client.send(`Page.captureScreenshot`,n,this.sessionId)).data}catch(t){return c.warn(`maxWidth re-capture failed, returning original`,t),e}}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,t=0){await this.ensureConnected(),this.ensureAttached();let n=await this.boundingBox(e);if(!n)throw Error(`Element not found: ${e}`);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,modifiers:t},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:`left`,clickCount:1,modifiers:t},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 insertText(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Input.insertText`,{text:e},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();let e=await this.evaluate(i,{awaitPromise:!1,returnByValue:!0});if(!e||typeof e!=`object`)return{role:`RootWebArea`,name:``};let t=p(e);try{let e=(await this.client.send(`Accessibility.getFullAXTree`,{},this.sessionId)).nodes;Array.isArray(e)&&f(t,d(e))}catch{}return t}async clickByBackendNodeId(e,t=0){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!n?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let r=(await this.client.send(`Runtime.callFunctionOn`,{objectId:n.objectId,functionDeclaration:`function() {
|
|
872
872
|
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
873
873
|
const r = this.getBoundingClientRect();
|
|
874
874
|
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
875
|
-
}`,returnByValue:!0},this.sessionId)).result?.value;if(!r||r.width===0||r.height===0){await this.client.send(`Runtime.callFunctionOn`,{objectId:n.objectId,functionDeclaration:`function() { this.click(); }`},this.sessionId);return}let i=r.x+r.width/2,a=r.y+r.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:i,y:a,button:`left`,clickCount:1,modifiers:t},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:i,y:a,button:`left`,clickCount:1,modifiers:t},this.sessionId)}async dblclickByBackendNodeId(e,t=`left`,n=0){await this.ensureConnected(),this.ensureAttached();let{x:r,y:i}=await this.resolveNodeCenter(e);await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:r,y:i,button:t,clickCount:1,modifiers:n},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:t,clickCount:1,modifiers:n},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:r,y:i,button:t,clickCount:2,modifiers:n},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:t,clickCount:2,modifiers:n},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 getFrameTree(){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let e=(await this.client.send(`Page.getFrameTree`,{},this.sessionId)).frameTree,t=[],n=e=>{if(t.push({frameId:e.frame.id,parentFrameId:e.frame.parentId,url:e.frame.url,name:e.frame.name??``,securityOrigin:e.frame.securityOrigin}),Array.isArray(e.childFrames))for(let t of e.childFrames)n(t)};return n(e),t}async evaluateInFrame(e,t,n){await this.ensureConnected(),this.ensureAttached();let r=e=>{let t=e instanceof Error?e.message:String(e);return t.includes(`Cannot find context with specified id`)||t.includes(`Execution context was destroyed`)},i=async()=>{let t=(await this.client.send(`Page.createIsolatedWorld`,{frameId:e,worldName:`__slicc_iframe`},this.sessionId)).executionContextId;return this._frameContextCache.set(e,t),t},a=this._frameContextCache.get(e);if(
|
|
875
|
+
}`,returnByValue:!0},this.sessionId)).result?.value;if(!r||r.width===0||r.height===0){await this.client.send(`Runtime.callFunctionOn`,{objectId:n.objectId,functionDeclaration:`function() { this.click(); }`},this.sessionId);return}let i=r.x+r.width/2,a=r.y+r.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:i,y:a,button:`left`,clickCount:1,modifiers:t},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:i,y:a,button:`left`,clickCount:1,modifiers:t},this.sessionId)}async dblclickByBackendNodeId(e,t=`left`,n=0){await this.ensureConnected(),this.ensureAttached();let{x:r,y:i}=await this.resolveNodeCenter(e);await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:r,y:i,button:t,clickCount:1,modifiers:n},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:t,clickCount:1,modifiers:n},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:r,y:i,button:t,clickCount:2,modifiers:n},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r,y:i,button:t,clickCount:2,modifiers:n},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 getFrameTree(){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let e=(await this.client.send(`Page.getFrameTree`,{},this.sessionId)).frameTree,t=[],n=e=>{if(t.push({frameId:e.frame.id,parentFrameId:e.frame.parentId,url:e.frame.url,name:e.frame.name??``,securityOrigin:e.frame.securityOrigin}),Array.isArray(e.childFrames))for(let t of e.childFrames)n(t)};return n(e),t}async evaluateInFrame(e,t,n){await this.ensureConnected(),this.ensureAttached();let r=e=>{let t=e instanceof Error?e.message:String(e);return t.includes(`Cannot find context with specified id`)||t.includes(`Execution context was destroyed`)},i=async()=>{let t=(await this.client.send(`Page.createIsolatedWorld`,{frameId:e,worldName:`__slicc_iframe`},this.sessionId)).executionContextId;return this._frameContextCache.set(e,t),t},a=async()=>{if(n?.world!==`main`)return this._frameContextCache.get(e)??i();await this.client.send(`Runtime.enable`,{},this.sessionId);let t=this._mainWorldContextCache.get(e);if(t===void 0&&(await this.client.send(`Runtime.disable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId),t=this._mainWorldContextCache.get(e)),t===void 0)throw Error(`Failed to find main world execution context for frame ${e}`);return t},o=()=>{n?.world===`main`?this._mainWorldContextCache.delete(e):this._frameContextCache.delete(e)},s;try{s=await a()}catch(t){let r=n?.world===`main`?`main world`:`isolated world`;throw Error(`Failed to resolve ${r} for frame ${e}: ${t instanceof Error?t.message:String(t)}`)}n?.world!==`main`&&await this.client.send(`Runtime.enable`,{},this.sessionId);let c={expression:t,contextId:s,awaitPromise:n?.awaitPromise??!0,returnByValue:n?.returnByValue??!0},l;try{l=await this.client.send(`Runtime.evaluate`,c,this.sessionId)}catch(e){if(r(e))o(),s=await a(),l=await this.client.send(`Runtime.evaluate`,{...c,contextId:s},this.sessionId);else throw e}let u=l.exceptionDetails;if(u){let t=u.exception?.description??u.text;if(r(Error(t))){o(),s=await a();let t=await this.client.send(`Runtime.evaluate`,{...c,contextId:s},this.sessionId),n=t.exceptionDetails;if(n){let t=n.exception?.description??n.text;throw Error(`Evaluation in frame ${e} failed: ${t}`)}return t.result.value}throw o(),Error(`Evaluation in frame ${e} failed: ${t}`)}return l.result.value}async getAccessibilityTreeForFrame(e){if(!e)return this.getAccessibilityTree();await this.ensureConnected(),this.ensureAttached();let t=await this.evaluateInFrame(e,i,{awaitPromise:!1,returnByValue:!0});return!t||typeof t!=`object`?{role:`RootWebArea`,name:``}:p(t)}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() {
|
|
876
876
|
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
877
877
|
const r = this.getBoundingClientRect();
|
|
878
878
|
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
879
|
-
}`,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 ensureLocalConnected(){if(this.localClient.superseded===!0){this.notifySuperseded();return}if(this.localClient.state===`disconnected`){let e=this._lastConnectOptions;await this.localClient.connect({url:e?.url??l(),...e?.timeout===void 0?{}:{timeout:e.timeout},...e?.protocols===void 0?{}:{protocols:e.protocols}})}}async ensureConnected(){if(this.client.superseded===!0){this.notifySuperseded();return}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(this._lastConnectOptions??void 0))}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}}};function d(e){let t=new Map;for(let n of e){let e=typeof n.backendDOMNodeId==`number`?n.backendDOMNodeId:null;if(e===null)continue;let r=n.role,i=n.name,a=typeof r?.value==`string`?r.value.toLowerCase():``,o=typeof i?.value==`string`?i.value:``;if(!a)continue;let s=`${a}|${o}`;t.has(s)||t.set(s,e)}return t}function f(e,t){let n=`${e.role.toLowerCase()}|${e.name}`,r=t.get(n);if(r!==void 0&&(e.backendNodeId=r),e.children)for(let n of e.children)f(n,t)}function p(e){let t={role:a(e.role,`unknown`),name:a(e.name)},n=a(e.value);n!==``&&(t.value=n);let r=a(e.description);return r!==``&&(t.description=r),Array.isArray(e.children)&&e.children.length>0&&(t.children=e.children.map(e=>p(e)).filter(e=>e.role!==`unknown`)),t}e(`har-recorder`);export{u as BrowserAPI};
|
|
879
|
+
}`,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 ensureLocalConnected(){if(this.localClient.superseded===!0){this.notifySuperseded();return}if(this.localClient.state===`disconnected`){let e=this._lastConnectOptions;await this.localClient.connect({url:e?.url??l(),...e?.timeout===void 0?{}:{timeout:e.timeout},...e?.protocols===void 0?{}:{protocols:e.protocols}})}}async ensureConnected(){if(this.client.superseded===!0){this.notifySuperseded();return}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(this._lastConnectOptions??void 0))}ensureAttached(){if(!this.sessionId)throw Error(`Not attached to a page. Call attachToPage(targetId) first.`)}addDialogListener(e){e.on(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}addExecutionContextListeners(e){e.on(`Runtime.executionContextCreated`,this.handleExecutionContextCreated),e.on(`Runtime.executionContextDestroyed`,this.handleExecutionContextDestroyed),e.on(`Runtime.executionContextsCleared`,this.handleExecutionContextsCleared)}removeDialogListener(e){e.off(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}removeExecutionContextListeners(e){e.off(`Runtime.executionContextCreated`,this.handleExecutionContextCreated),e.off(`Runtime.executionContextDestroyed`,this.handleExecutionContextDestroyed),e.off(`Runtime.executionContextsCleared`,this.handleExecutionContextsCleared)}setClient(e){this.client!==e&&(this.removeDialogListener(this.client),this.removeExecutionContextListeners(this.client),this.client=e,this.addDialogListener(this.client),this.addExecutionContextListeners(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}}};function d(e){let t=new Map;for(let n of e){let e=typeof n.backendDOMNodeId==`number`?n.backendDOMNodeId:null;if(e===null)continue;let r=n.role,i=n.name,a=typeof r?.value==`string`?r.value.toLowerCase():``,o=typeof i?.value==`string`?i.value:``;if(!a)continue;let s=`${a}|${o}`;t.has(s)||t.set(s,e)}return t}function f(e,t){let n=`${e.role.toLowerCase()}|${e.name}`,r=t.get(n);if(r!==void 0&&(e.backendNodeId=r),e.children)for(let n of e.children)f(n,t)}function p(e){let t={role:a(e.role,`unknown`),name:a(e.name)},n=a(e.value);n!==``&&(t.value=n);let r=a(e.description);return r!==``&&(t.description=r),Array.isArray(e.children)&&e.children.length>0&&(t.children=e.children.map(e=>p(e)).filter(e=>e.role!==`unknown`)),t}e(`har-recorder`);export{u as BrowserAPI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./account-store-
|
|
1
|
+
import{h as e}from"./account-store-Bk0b9NNs.js";import{n as t}from"./event-stream-qbAZIAKV.js";import{p as n}from"./bedrock-camp-DS0ilb3O.js";import{r,s as i}from"./legacy-api-aliases-YuuBU-he.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const _=(e,n,i={})=>{let a=t();return(async()=>{try{let t=r({...e,baseUrl:o,api:s},n,i);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},v=(e,n,r)=>{let a=t();return(async()=>{try{let t=i({...e,baseUrl:o,api:s},n,r);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},y={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function b(){n({api:c,stream:_,streamSimple:v})}export{y as config,b as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./account-store-
|
|
1
|
+
import{h as e}from"./account-store-CsBhRflH.js";import{n as t}from"./event-stream-qbAZIAKV.js";import{a as n}from"./compat-CkpNnFQS.js";import{r,s as i}from"./legacy-api-aliases-BWm3gxUe.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var _=(e,n,i={})=>{let a=t();return(async()=>{try{let t=r({...e,baseUrl:o,api:s},n,i);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},v=(e,n,r)=>{let a=t();return(async()=>{try{let t=i({...e,baseUrl:o,api:s},n,r);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},y={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function b(){n({api:c,stream:_,streamSimple:v})}export{y as config,b as register};
|