@yuriai/web 0.2.38-beta.2 → 0.2.38-beta.3
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/assets/{AgentAvatar-DNVD6VCV.js → AgentAvatar-CAC4rKO_.js} +1 -1
- package/dist/assets/{AssistantContactStatus-C5zpVdGa.js → AssistantContactStatus-Co_TnYMc.js} +3 -3
- package/dist/assets/{AssistantUnreadBadge-7KpCtnd3.js → AssistantUnreadBadge-DqJFhaNg.js} +1 -1
- package/dist/assets/{AssistantView-BZU6TlwK.js → AssistantView-D6fdLgFj.js} +1 -1
- package/dist/assets/{DiagramView-CXgsVJ3A.js → DiagramView-tx4upWOs.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CK7jBcu4.js → FadeInOnReveal--aVey7kZ.js} +1 -1
- package/dist/assets/{GuiPluginSurface-Bk01hnV6.js → GuiPluginSurface-Bd3v_5A8.js} +1 -1
- package/dist/assets/{GuiPluginWindow-BgOCEgEb.js → GuiPluginWindow-fy3lT5ns.js} +1 -1
- package/dist/assets/{Icon-DsN23fuV.js → Icon-h0JiZMjp.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-MfVzv_y1.js → ImageLoadingPlaceholder-A2tjfBfo.js} +1 -1
- package/dist/assets/{LoadingImage-MAgXscGl.js → LoadingImage-C4DsIEui.js} +1 -1
- package/dist/assets/{MarkdownRenderer-DswMDaKf.js → MarkdownRenderer-BfAZBFzv.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-ecACjpZw.js → MarkdownRendererImpl-MYwBFYBA.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-Bqbq2VPn.js → MarkstreamRendererImpl-13XA9vlX.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CXcMdlRH.js → MobileDetailNavigation-UU1cGYp2.js} +1 -1
- package/dist/assets/{MobileResizableSheet-D_PnyzR0.js → MobileResizableSheet-nUZzBOmQ.js} +1 -1
- package/dist/assets/{MobileShareBridge-DfgyncNh.js → MobileShareBridge-IWtj1SYy.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-Bm8nYrzH.js → MobileTabPageHeader-Diplic-W.js} +1 -1
- package/dist/assets/{MultiRunWindow-CvCgKiyV.js → MultiRunWindow-CHdpFi_v.js} +1 -1
- package/dist/assets/{OnboardingScreen-BwJ3iMGY.js → OnboardingScreen-CeQxPD6C.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BLhv7Nq-.js → OverlayScrollbar-DMbq1jNO.js} +1 -1
- package/dist/assets/{SettingsView-DGduWj3I.js → SettingsView-CxHpCSsu.js} +2 -2
- package/dist/assets/{SettingsWindow-BM8abllV.js → SettingsWindow-DEEHLurG.js} +1 -1
- package/dist/assets/{SetupTourDialog-vmNGHNXl.js → SetupTourDialog-5w42fqYN.js} +1 -1
- package/dist/assets/{TerminalView-BZObkK0H.js → TerminalView-DAx8JZmn.js} +1 -1
- package/dist/assets/{ToolOutputDialog-D_CH2A0-.js → ToolOutputDialog-CoKt-9rk.js} +1 -1
- package/dist/assets/{VoiceSettings-Ru8tm8eq.js → VoiceSettings-BFCJ8d-d.js} +1 -1
- package/dist/assets/{YuriLogo-C5K_9jSK.js → YuriLogo-BFawEKZ2.js} +1 -1
- package/dist/assets/{appThemeRegistry-CcdIpK3S.js → appThemeRegistry-CbyMACnN.js} +1 -1
- package/dist/assets/{appearance--vFosLNi.js → appearance-DFsI3pnP.js} +1 -1
- package/dist/assets/{capgoAdapter-DceVw3SM.js → capgoAdapter-C1AUTwaK.js} +1 -1
- package/dist/assets/{checkbox-CJsiyoER.js → checkbox-DR7tyhFb.js} +1 -1
- package/dist/assets/{collapsible-B3zojUm2.js → collapsible-C8DgipZf.js} +1 -1
- package/dist/assets/{context-menu-DFRg1NJF.js → context-menu-BfLJgbjE.js} +1 -1
- package/dist/assets/{diagram-OTF8YAve.js → diagram-0lT2w7uS.js} +1 -1
- package/dist/assets/{dialog-CgtwKUKd.js → dialog-Kz0pw-SO.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CorehkTj.js → fileMentionTouchSelection-BhQqAWYa.js} +1 -1
- package/dist/assets/{gitApi-C6rhS4rG.js → gitApi-CWUhy6kY.js} +1 -1
- package/dist/assets/host-D_6AN-1g.js +1 -0
- package/dist/assets/{input-B7-PmgcW.js → input-Baq2dV0C.js} +1 -1
- package/dist/assets/{insertionBoundaries-B-ncem5c.js → insertionBoundaries-Bfzw2QQw.js} +1 -1
- package/dist/assets/{main-BMvwUUi4.js → main-CeqfStCn.js} +2 -2
- package/dist/assets/{main-Chq1F31E.js → main-c0X9U5aG.js} +4 -4
- package/dist/assets/{markdownHeightCache-DlRC53XG.js → markdownHeightCache-BEb1XAlf.js} +1 -1
- package/dist/assets/{mcpQueries-BRFr-Gfm.js → mcpQueries-DtBlC0VK.js} +1 -1
- package/dist/assets/{miniChat-C3vDY9WG.js → miniChat-TSOpbP39.js} +2 -2
- package/dist/assets/{mobile-B2KYTY1c.js → mobile-W2QaGheB.js} +2 -2
- package/dist/assets/{mobileBackNavigation-ByUDCJde.js → mobileBackNavigation-Dy-OW7DB.js} +1 -1
- package/dist/assets/{multirun-F1yOJb2_.js → multirun-O7LH-36l.js} +1 -1
- package/dist/assets/{native-config-C2j59qnN.js → native-config-CGAqvpqz.js} +1 -1
- package/dist/assets/{projectMeta-C08trpZE.js → projectMeta-B2LbasoM.js} +1 -1
- package/dist/assets/{pwa-C956NPB0.js → pwa-BHki-tGS.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-CWyeG_sJ.js → queue-abort-optimistic-DaJr8CmG.js} +1 -1
- package/dist/assets/{readiness-CUPPcONt.js → readiness-DqfcV8R2.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DNK4YFG8.js → renderElectronMiniChatApp-Dlt2LoM5.js} +2 -2
- package/dist/assets/{renderMobileApp-DagPx3n0.js → renderMobileApp-BqUbrWSg.js} +4 -4
- package/dist/assets/{runtimeConfig-D_McrwNd.js → runtimeConfig-k2t218IT.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-D-aHzKPN.js → runtimeEndpointReset-_8oYno9l.js} +3 -3
- package/dist/assets/{select-DoYUmvbX.js → select-DV9UcboH.js} +1 -1
- package/dist/assets/{sessionLookup-D2JIMvDo.js → sessionLookup-BBH2jvTL.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-B-W7ADKC.js → sortable-tabs-strip-M-5RVko_.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CJqxaC2Q.js → speechSettingsQueries-C4eOkV7q.js} +1 -1
- package/dist/assets/{src-CzDk_0Pp.css → src-Bc4Nf__6.css} +1 -1
- package/dist/assets/{textarea-BCTNmuPZ.js → textarea-DWw42WmZ.js} +1 -1
- package/dist/assets/{tooltip-D5Xeh6py.js → tooltip-CxneNjeR.js} +1 -1
- package/dist/assets/{types-DXSnGXVb.js → types-hxNDOWGs.js} +1 -1
- package/dist/assets/{useAppFontEffects-Blo2lGTo.js → useAppFontEffects-C9muit_c.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-YAxhtSDl.js → useDesktopWindowControlsLayout-3SlaV4G-.js} +1 -1
- package/dist/assets/{useDictation-Dp2Y3X49.js → useDictation-CgUBTlk5.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-Uc8I6wXt.js → useEffectiveDirectory-Dn3Z6Sbz.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-SCjA_7jP.js → useMobileNavigationStore-ywElU2fl.js} +4 -4
- package/dist/assets/{usePluginsStore-DfksbEZx.js → usePluginsStore-BD47b67P.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-BY1Ynoj1.js → useStreamingTextThrottle-BDPkHk3Z.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-DAxMD3fK.js → useWorkerHighlightedLines-D9HhL0-T.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +1 -1
- package/server/lib/gui-customization/DOCUMENTATION.md +2 -0
- package/server/lib/gui-customization/skill/SKILL.md +1 -1
- package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
- package/server/lib/gui-customization/skill/references/gui-api.md +1 -1
- package/server/lib/gui-customization/skill/references/icons.md +35 -8
- package/dist/assets/host-8TDDnZXo.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./runtime-switch-ibQIZnws.js";import{n}from"./runtime-fetch-9B8F_rKW.js";import{a as r,i,r as a}from"./vendor-zustand-vDaAPGfl.js";import{o,ot as s,s as c}from"./vendor-base-ui-CzHs0bHY.js";import{Mn as l}from"./bootstrap-BzeQds0D.js";import{w as u}from"./useUIStore-BsCfUWQw.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{s as f}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{_ as p,g as m,h}from"./fileQueries-BaEKb7SZ.js";import{Ea as g,Jn as _,Kn as v,Va as y,wa as b}from"./useMobileNavigationStore-SCjA_7jP.js";var x=d(),S=s();function ee(e){let t=(0,x.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=y(),d;t[0]!==n||t[1]!==l||t[2]!==r?(d=e=>{!l&&e!==n&&r(e)},t[0]=n,t[1]=l,t[2]=r,t[3]=d):d=t[3];let f;t[4]===s?f=t[5]:(f=_(`yuri-settings-switch`,s),t[4]=s,t[5]=f);let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[!1,!0],t[6]=p):p=t[6];let m;t[7]!==n||t[8]!==u?(m=p.map(e=>(0,S.jsxs)(c,{value:e,nativeButton:!0,render:(0,S.jsx)(v,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,S.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,S.jsx)(`span`,{className:`relative`,children:u(e?`settings.switch.on`:`settings.switch.off`)})]},String(e))),t[7]=n,t[8]=u,t[9]=m):m=t[9];let h;return t[10]!==a||t[11]!==n||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==m?(h=(0,S.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:w,onKeyDown:C,children:m}),t[10]=a,t[11]=n,t[12]=l,t[13]=d,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function C(e){return e.stopPropagation()}function w(e){return e.stopPropagation()}function T(e){let t=(0,x.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=_(`flex shrink-0 items-center justify-between gap-3 py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,S.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,S.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function E(e){let t=(0,x.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=_(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,S.jsx)(T,{className:`py-0`,actions:r,children:n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=_(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,S.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,S.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let v;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(v=(0,S.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=v):v=t[20],v}function D(e){let t=(0,x.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,S.jsx)(O,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,S.jsx)(E,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function O(e){let t=(0,x.c)(25),{label:n,children:r,description:i,footer:a,itemId:o,className:s,copyClassName:c,controlClassName:l}=e,u;t[0]===s?u=t[1]:(u=_(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=_(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,S.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=f);let p;t[6]===i?p=t[7]:(p=i?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=p);let m;t[8]!==d||t[9]!==f||t[10]!==p?(m=(0,S.jsxs)(`div`,{className:d,children:[f,p]}),t[8]=d,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===l?h=t[13]:(h=_(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,S.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let v;t[17]===a?v=t[18]:(v=a?(0,S.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=v);let y;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==v?(y=(0,S.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,v]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=v,t[24]=y):y=t[24],y}function te(e){let t=(0,x.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=ne,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=_(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,v=u||void 0,y,b;t[7]===f?(y=t[8],b=t[9]):(y=e=>{p(e.target)||f()},b=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=y,t[9]=b);let C;t[10]===i?C=t[11]:(C=(0,S.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=C);let w;t[12]===o?w=t[13]:(w=o?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=w);let T;t[14]!==w||t[15]!==C?(T=(0,S.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[C,w]}),t[14]=w,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,S.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,S.jsx)(ee,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=E):E=t[21];let D;return t[22]!==n||t[23]!==s||t[24]!==T||t[25]!==E||t[26]!==h||t[27]!==g||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,S.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":v,onClick:y,onKeyDown:b,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function ne(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var k=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},A=()=>{let e=l.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},re=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ie=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ae=e=>({source:re(e.source),state:ie(e.state)}),oe=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ae(e))};async function j(e,t){return oe((await A().list(k(e),t?{signal:t}:void 0))?.data)}async function se(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await A().update({...k(e),targets:[r]},n?{signal:n}:void 0)}function ce(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var le=1500,M=e=>e?.trim()||null,N=(t,n=e())=>p.plugins.list(t,n),P=(t,n,r=!1,i=e())=>p.plugins.registry(t,n,r,i),F=(t,n=e())=>p.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=b(),r=e())=>{let i=M(t);return{queryKey:N(i,r),queryFn:async({signal:e})=>{let t=await n(he(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},B=(t,r,i=!1,a=e(),o=!1)=>{let s=M(t),c=h(r);return{queryKey:o?[...P(s,c,i,a),`details`]:P(s,c,i,a),queryFn:async({signal:e})=>{let t={};for(let r of _e(c)){let a=ge(r,i,s),c=await n(o?`${a}&details=true`:a,{headers:U(s),signal:e});if(!c.ok)throw Error(`Failed to load plugin registry info`);let l=await c.json();for(let e of l.results??[])t[e.spec]=e}return t},staleTime:i?0:3e5,retry:2}},ue=(t=b(),n=e())=>{let r=M(t);return{queryKey:F(r,n),queryFn:async({signal:e})=>{let t=L(),i=await j(r,e);if(t!==I){let e=R(m,r,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},de=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=g(ve),a;t[2]===i?a=t[3]:(a=z(M(i)??M(l.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},fe=(e,t)=>{let n=(0,x.c)(6),r=t!==void 0&&t,i=g(ye),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(l.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),f(o)},V=()=>{let e=(0,x.c)(2),t=g(be),n;return e[0]===t?n=e[1]:(n=M(t)??M(l.getDirectory()),e[0]=t,e[1]=n),n},pe=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=V(),a;t[2]===i?a=t[3]:(a=ue(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},H=async(t,n,r)=>{let i=M(n);return e()===r?t.fetchQuery({...z(i,r),staleTime:0}):t.getQueryData(N(i,r))??{entries:[],files:[]}},me=async(t,n,r)=>{let i=M(n);if(e()!==r)return R(t,i,r);let a=L(),o=await j(i);return a!==I||e()!==r?R(t,i,r):(t.setQueryData(F(i,r),o),o)};function he(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ge(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function _e(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>le){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function U(e){return e?{"x-opencode-directory":e}:void 0}function ve(e){return e.getActiveProject?.()?.path??null}function ye(e){return e.getActiveProject?.()?.path??null}function be(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=g.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=l.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},xe=5e3,Se=`__default__`,G=new Map,K=new Map,Ce=1500,q=e=>e?.trim()||Se,we=e=>{G.delete(q(e))},J=r()(a(i((r,i)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:e=>r({selectedId:e}),setDraft:e=>r({draft:e}),loadPlugins:async n=>{let a=W(),o=e(),s=t(),c=()=>o===e()&&s===t()&&a===W(),l=q(a),u=Date.now(),d=G.get(l)??0,f=i().entries.length>0||i().files.length>0;if(!n?.force&&f&&u-d<xe)return!0;let p=K.get(l);if(!n?.force&&p)return p;let h=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(m,a,o):await m.fetchQuery(z(a,o));return c()?(r({entries:e.entries??[],files:e.files??[],isLoading:!1}),G.set(l,Date.now()),n?.force||i().loadRegistryInfo(),!0):!1}catch(e){return console.error(`[PluginsStore] Failed to load plugins:`,e),c()&&r({isLoading:!1}),!1}})();K.set(l,h);try{return await h}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Ee(e?.specs??i().entries.map(e=>e.spec));if(t.length===0){r({isLoadingRegistry:!1});return}r({isLoadingRegistry:!0});try{let a=W(),o={...i().registryInfo};for(let r of De(t)){let t=await n(Te(r,e?.force===!0,a),{headers:X(a)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let i=await $(t);for(let e of i.results??[])o[e.spec]=e}r({registryInfo:o,isLoadingRegistry:!1})}catch(e){console.error(`[PluginsStore] Failed to load plugin registry info:`,e),r({isLoadingRegistry:!1})}},updateToLatest:async e=>{let t=i().entries.find(t=>t.id===e);if(!t)return{ok:!1};let n=i().registryInfo[t.spec];return!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion?{ok:!1}:await i().updateEntry(e,{spec:`${n.name}@${n.latestVersion}`})},createEntry:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/entry`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(Oe(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(m.getQueryData(z(W(),e()).queryKey)?.entries??i().entries).find(e=>e.id===t),o=a?.spec,s=r.spec??o,c=await Q(async e=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(t)}`,e),{method:`PATCH`,headers:Z(e),body:JSON.stringify(Oe(r))}),a&&s?{...a,spec:s}:void 0);return c.ok&&s&&i().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async e=>{let t=i().entries.find(t=>t.id===e),a=await Q(async t=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));if(a.ok&&i().selectedId===e&&r({selectedId:null}),a.ok&&t){let e={...i().registryInfo};delete e[t.spec],r({registryInfo:e})}return a},readFile:async e=>{try{let t=W(),r=await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:X(t)});if(!r.ok)throw Error(`Failed to read plugin file`);return await $(r)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Q(async t=>await n(Y(`/api/config/plugins/file`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Q(async r=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,r),{method:`PUT`,headers:Z(r),body:JSON.stringify(t)})),deleteFile:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));return t.ok&&i().selectedId===e&&r({selectedId:null}),t},getById:e=>i().entries.find(t=>t.id===e)??i().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:u(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Te(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ee(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function De(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ce?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function X(e){return e?{"x-opencode-directory":e}:void 0}function Z(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Oe(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Q(n,r){let i=e(),a=t();try{let o=W(),s=await n(o),c=await $(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==e()||a!==t())return{ok:!0};we(o);let l=await H(m,o,i);if(o===W()&&i===e()&&a===t()){let e=r&&J.getState().selectedId===r.id?l.entries.find(e=>e.spec===r.spec&&e.scope===r.scope&&e.sourcePath===r.sourcePath):void 0;J.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),G.set(q(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function $(e){return await e.json()}export{V as a,de as c,D as d,E as f,ee as g,T as h,me as i,ce as l,te as m,B as n,fe as o,O as p,z as r,pe as s,J as t,se as u};
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-ibQIZnws.js";import{n}from"./runtime-fetch-9B8F_rKW.js";import{a as r,i,r as a}from"./vendor-zustand-vDaAPGfl.js";import{o,ot as s,s as c}from"./vendor-base-ui-CzHs0bHY.js";import{Mn as l}from"./bootstrap-BzeQds0D.js";import{w as u}from"./useUIStore-BsCfUWQw.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{s as f}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{_ as p,g as m,h}from"./fileQueries-BaEKb7SZ.js";import{Ea as g,Jn as _,Kn as v,Va as y,wa as b}from"./useMobileNavigationStore-ywElU2fl.js";var x=d(),S=s();function ee(e){let t=(0,x.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=y(),d;t[0]!==n||t[1]!==l||t[2]!==r?(d=e=>{!l&&e!==n&&r(e)},t[0]=n,t[1]=l,t[2]=r,t[3]=d):d=t[3];let f;t[4]===s?f=t[5]:(f=_(`yuri-settings-switch`,s),t[4]=s,t[5]=f);let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[!1,!0],t[6]=p):p=t[6];let m;t[7]!==n||t[8]!==u?(m=p.map(e=>(0,S.jsxs)(c,{value:e,nativeButton:!0,render:(0,S.jsx)(v,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,S.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,S.jsx)(`span`,{className:`relative`,children:u(e?`settings.switch.on`:`settings.switch.off`)})]},String(e))),t[7]=n,t[8]=u,t[9]=m):m=t[9];let h;return t[10]!==a||t[11]!==n||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==m?(h=(0,S.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:w,onKeyDown:C,children:m}),t[10]=a,t[11]=n,t[12]=l,t[13]=d,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function C(e){return e.stopPropagation()}function w(e){return e.stopPropagation()}function T(e){let t=(0,x.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=_(`flex shrink-0 items-center justify-between gap-3 py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,S.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,S.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function E(e){let t=(0,x.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=_(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,S.jsx)(T,{className:`py-0`,actions:r,children:n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=_(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,S.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,S.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let v;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(v=(0,S.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=v):v=t[20],v}function D(e){let t=(0,x.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,S.jsx)(O,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,S.jsx)(E,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function O(e){let t=(0,x.c)(25),{label:n,children:r,description:i,footer:a,itemId:o,className:s,copyClassName:c,controlClassName:l}=e,u;t[0]===s?u=t[1]:(u=_(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=_(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,S.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=f);let p;t[6]===i?p=t[7]:(p=i?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=p);let m;t[8]!==d||t[9]!==f||t[10]!==p?(m=(0,S.jsxs)(`div`,{className:d,children:[f,p]}),t[8]=d,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===l?h=t[13]:(h=_(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,S.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let v;t[17]===a?v=t[18]:(v=a?(0,S.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=v);let y;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==v?(y=(0,S.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,v]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=v,t[24]=y):y=t[24],y}function te(e){let t=(0,x.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=ne,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=_(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,v=u||void 0,y,b;t[7]===f?(y=t[8],b=t[9]):(y=e=>{p(e.target)||f()},b=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=y,t[9]=b);let C;t[10]===i?C=t[11]:(C=(0,S.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=C);let w;t[12]===o?w=t[13]:(w=o?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=w);let T;t[14]!==w||t[15]!==C?(T=(0,S.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[C,w]}),t[14]=w,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,S.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,S.jsx)(ee,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=E):E=t[21];let D;return t[22]!==n||t[23]!==s||t[24]!==T||t[25]!==E||t[26]!==h||t[27]!==g||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,S.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":v,onClick:y,onKeyDown:b,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function ne(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var k=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},A=()=>{let e=l.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},re=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ie=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ae=e=>({source:re(e.source),state:ie(e.state)}),oe=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ae(e))};async function j(e,t){return oe((await A().list(k(e),t?{signal:t}:void 0))?.data)}async function se(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await A().update({...k(e),targets:[r]},n?{signal:n}:void 0)}function ce(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var le=1500,M=e=>e?.trim()||null,N=(t,n=e())=>p.plugins.list(t,n),P=(t,n,r=!1,i=e())=>p.plugins.registry(t,n,r,i),F=(t,n=e())=>p.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=b(),r=e())=>{let i=M(t);return{queryKey:N(i,r),queryFn:async({signal:e})=>{let t=await n(he(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},B=(t,r,i=!1,a=e(),o=!1)=>{let s=M(t),c=h(r);return{queryKey:o?[...P(s,c,i,a),`details`]:P(s,c,i,a),queryFn:async({signal:e})=>{let t={};for(let r of _e(c)){let a=ge(r,i,s),c=await n(o?`${a}&details=true`:a,{headers:U(s),signal:e});if(!c.ok)throw Error(`Failed to load plugin registry info`);let l=await c.json();for(let e of l.results??[])t[e.spec]=e}return t},staleTime:i?0:3e5,retry:2}},ue=(t=b(),n=e())=>{let r=M(t);return{queryKey:F(r,n),queryFn:async({signal:e})=>{let t=L(),i=await j(r,e);if(t!==I){let e=R(m,r,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},de=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=g(ve),a;t[2]===i?a=t[3]:(a=z(M(i)??M(l.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},fe=(e,t)=>{let n=(0,x.c)(6),r=t!==void 0&&t,i=g(ye),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(l.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),f(o)},V=()=>{let e=(0,x.c)(2),t=g(be),n;return e[0]===t?n=e[1]:(n=M(t)??M(l.getDirectory()),e[0]=t,e[1]=n),n},pe=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=V(),a;t[2]===i?a=t[3]:(a=ue(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},H=async(t,n,r)=>{let i=M(n);return e()===r?t.fetchQuery({...z(i,r),staleTime:0}):t.getQueryData(N(i,r))??{entries:[],files:[]}},me=async(t,n,r)=>{let i=M(n);if(e()!==r)return R(t,i,r);let a=L(),o=await j(i);return a!==I||e()!==r?R(t,i,r):(t.setQueryData(F(i,r),o),o)};function he(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ge(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function _e(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>le){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function U(e){return e?{"x-opencode-directory":e}:void 0}function ve(e){return e.getActiveProject?.()?.path??null}function ye(e){return e.getActiveProject?.()?.path??null}function be(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=g.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=l.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},xe=5e3,Se=`__default__`,G=new Map,K=new Map,Ce=1500,q=e=>e?.trim()||Se,we=e=>{G.delete(q(e))},J=r()(a(i((r,i)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:e=>r({selectedId:e}),setDraft:e=>r({draft:e}),loadPlugins:async n=>{let a=W(),o=e(),s=t(),c=()=>o===e()&&s===t()&&a===W(),l=q(a),u=Date.now(),d=G.get(l)??0,f=i().entries.length>0||i().files.length>0;if(!n?.force&&f&&u-d<xe)return!0;let p=K.get(l);if(!n?.force&&p)return p;let h=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(m,a,o):await m.fetchQuery(z(a,o));return c()?(r({entries:e.entries??[],files:e.files??[],isLoading:!1}),G.set(l,Date.now()),n?.force||i().loadRegistryInfo(),!0):!1}catch(e){return console.error(`[PluginsStore] Failed to load plugins:`,e),c()&&r({isLoading:!1}),!1}})();K.set(l,h);try{return await h}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Ee(e?.specs??i().entries.map(e=>e.spec));if(t.length===0){r({isLoadingRegistry:!1});return}r({isLoadingRegistry:!0});try{let a=W(),o={...i().registryInfo};for(let r of De(t)){let t=await n(Te(r,e?.force===!0,a),{headers:X(a)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let i=await $(t);for(let e of i.results??[])o[e.spec]=e}r({registryInfo:o,isLoadingRegistry:!1})}catch(e){console.error(`[PluginsStore] Failed to load plugin registry info:`,e),r({isLoadingRegistry:!1})}},updateToLatest:async e=>{let t=i().entries.find(t=>t.id===e);if(!t)return{ok:!1};let n=i().registryInfo[t.spec];return!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion?{ok:!1}:await i().updateEntry(e,{spec:`${n.name}@${n.latestVersion}`})},createEntry:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/entry`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(Oe(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(m.getQueryData(z(W(),e()).queryKey)?.entries??i().entries).find(e=>e.id===t),o=a?.spec,s=r.spec??o,c=await Q(async e=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(t)}`,e),{method:`PATCH`,headers:Z(e),body:JSON.stringify(Oe(r))}),a&&s?{...a,spec:s}:void 0);return c.ok&&s&&i().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async e=>{let t=i().entries.find(t=>t.id===e),a=await Q(async t=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));if(a.ok&&i().selectedId===e&&r({selectedId:null}),a.ok&&t){let e={...i().registryInfo};delete e[t.spec],r({registryInfo:e})}return a},readFile:async e=>{try{let t=W(),r=await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:X(t)});if(!r.ok)throw Error(`Failed to read plugin file`);return await $(r)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Q(async t=>await n(Y(`/api/config/plugins/file`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Q(async r=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,r),{method:`PUT`,headers:Z(r),body:JSON.stringify(t)})),deleteFile:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));return t.ok&&i().selectedId===e&&r({selectedId:null}),t},getById:e=>i().entries.find(t=>t.id===e)??i().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:u(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Te(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ee(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function De(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ce?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function X(e){return e?{"x-opencode-directory":e}:void 0}function Z(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Oe(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Q(n,r){let i=e(),a=t();try{let o=W(),s=await n(o),c=await $(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==e()||a!==t())return{ok:!0};we(o);let l=await H(m,o,i);if(o===W()&&i===e()&&a===t()){let e=r&&J.getState().selectedId===r.id?l.entries.find(e=>e.spec===r.spec&&e.scope===r.scope&&e.sourcePath===r.sourcePath):void 0;J.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),G.set(q(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function $(e){return await e.json()}export{V as a,de as c,D as d,E as f,ee as g,T as h,me as i,ce as l,te as m,B as n,fe as o,O as p,z as r,pe as s,J as t,se as u};
|
package/dist/assets/{useStreamingTextThrottle-BY1Ynoj1.js → useStreamingTextThrottle-BDPkHk3Z.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{st as t}from"./vendor-base-ui-CzHs0bHY.js";import{t as n}from"./platform-Dids8J9D.js";import{r}from"./FadeInOnReveal
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{st as t}from"./vendor-base-ui-CzHs0bHY.js";import{t as n}from"./platform-Dids8J9D.js";import{r}from"./FadeInOnReveal--aVey7kZ.js";var i=e(t(),1),a=(e,t,n)=>{let r=t-e;return Math.max(0,n-r)},o=e=>{e.timer&&=(clearTimeout(e.timer),null)},s=({text:e,isStreaming:t,throttleMs:s=r(n()).textThrottleMs,identityKey:c})=>{let[l,u]=i.useState(e),d=i.useRef(e),f=i.useRef(l),p=i.useRef({timer:null,pendingText:e,lastEmitAt:0});return i.useEffect(()=>{d.current=e},[e]),i.useEffect(()=>{f.current=l},[l]),i.useEffect(()=>{let e=p.current;o(e),e.pendingText=d.current,e.lastEmitAt=0,u(d.current)},[c]),i.useEffect(()=>{let n=p.current;n.pendingText=e;let r=f.current,i=t&&r.length>e.length?r:e;if(!t){o(n),n.lastEmitAt=Date.now(),u(i);return}let c=Date.now(),l=a(n.lastEmitAt,c,s);if(l<=0){o(n),n.lastEmitAt=c,u(i);return}return o(n),n.timer=setTimeout(()=>{n.timer=null,n.lastEmitAt=Date.now(),u(e=>t&&e.length>n.pendingText.length?e:n.pendingText)},l),()=>{o(n)}},[t,e,s]),i.useEffect(()=>{let e=p.current;return()=>{o(e)}},[]),l};export{s as t};
|
package/dist/assets/{useWorkerHighlightedLines-DAxMD3fK.js → useWorkerHighlightedLines-D9HhL0-T.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{S as r}from"./useUIStore-BsCfUWQw.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{Jn as a,Kn as o,Va as s}from"./useMobileNavigationStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{S as r}from"./useUIStore-BsCfUWQw.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{Jn as a,Kn as o,Va as s}from"./useMobileNavigationStore-ywElU2fl.js";import{n as c}from"./useThemeSystem-CNzUUkFn.js";import{n as l}from"./Icon-h0JiZMjp.js";import{n as u}from"./MarkdownRenderer-BfAZBFzv.js";import{n as d,r as f}from"./toolHelpers-iEHVHQ9p.js";import{n as p}from"./markdownTheme-CHNl6tUv.js";import{n as m,t as h}from"./markdown-worker-oBGEB9Eg.js";var g=e(n(),1),_=i(),v=t(),y=e=>e===`in_progress`||e===`completed`||e===`cancelled`?e:`pending`,b=e=>e.status===`completed`||e.status===`cancelled`,x={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},S={in_progress:`text-foreground`,pending:`text-muted-foreground/60`,completed:`text-muted-foreground`,cancelled:`text-muted-foreground/60`},C={in_progress:`text-foreground`,pending:`text-muted-foreground`,completed:`text-muted-foreground/60 line-through decoration-1`,cancelled:`text-muted-foreground/60 line-through decoration-1`},w=1.2,T=24,E=`1 1`,D=e=>{let t=(0,_.c)(23),{status:n,className:r}=e,{t:i}=s(),o=x[n],c;t[0]!==i||t[1]!==o?(c=i(o),t[0]=i,t[1]=o,t[2]=c):c=t[2];let l=S[n],u;t[3]!==r||t[4]!==l?(u=a(`size-[1em] shrink-0 transition-colors duration-300`,l,r),t[3]=r,t[4]=l,t[5]=u):u=t[5];let d=n===`pending`?w:void 0,f=n===`pending`?T:void 0,p=n===`pending`?E:void 0,m;t[6]!==d||t[7]!==f||t[8]!==p?(m=(0,v.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:d,pathLength:f,strokeDasharray:p}),t[6]=d,t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===n?h=t[11]:(h=n===`in_progress`?(0,v.jsx)(`path`,{d:`M4.8 8h6.4M8.6 5.4 11.2 8l-2.6 2.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[10]=n,t[11]=h);let g;t[12]===n?g=t[13]:(g=n===`completed`?(0,v.jsx)(`path`,{d:`M5 8 7.5 11 11 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[12]=n,t[13]=g);let y;t[14]===n?y=t[15]:(y=n===`cancelled`?(0,v.jsx)(`path`,{d:`M3.5 12.5 12.5 3.5`,stroke:`currentColor`}):null,t[14]=n,t[15]=y);let b;return t[16]!==g||t[17]!==y||t[18]!==c||t[19]!==u||t[20]!==m||t[21]!==h?(b=(0,v.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,role:`img`,"aria-label":c,className:u,children:[m,h,g,y]}),t[16]=g,t[17]=y,t[18]=c,t[19]=u,t[20]=m,t[21]=h,t[22]=b):b=t[22],b},O=3.2,k=e=>{let t=Math.PI*2*e,n=8+O*Math.sin(t),r=8-O*Math.cos(t);return`M8 8 L8 4.8 A${O} ${O} 0 ${+(e>.5)} 1 ${n.toFixed(3)} ${r.toFixed(3)} Z`},A=e=>{let t=(0,_.c)(11),{done:n,total:r,spinning:i,className:o}=e,s=n===void 0?0:n,c=r===void 0?0:r,l=i!==void 0&&i,u=c>0?Math.min(1,s/c):0,d;t[0]===o?d=t[1]:(d=a(`size-[1.15em] shrink-0 text-foreground`,o),t[0]=o,t[1]=d);let f=l?`yuri-todo-spin`:void 0,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p={transformBox:`fill-box`,transformOrigin:`center`},t[2]=p):p=t[2];let m;t[3]===f?m=t[4]:(m=(0,v.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:w,pathLength:T,strokeDasharray:E,className:f,style:p}),t[3]=f,t[4]=m);let h;t[5]===u?h=t[6]:(h=u>0?(0,v.jsx)(`path`,{d:k(u),fill:`currentColor`,className:`transition-opacity duration-300`}):null,t[5]=u,t[6]=h);let g;return t[7]!==d||t[8]!==m||t[9]!==h?(g=(0,v.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:d,children:[m,h]}),t[7]=d,t[8]=m,t[9]=h,t[10]=g):g=t[10],g},j=({done:e,total:t,className:n,animate:r=!0})=>{let i=g.useRef(e),o=r&&i.current!==e;return g.useEffect(()=>{i.current=e},[e]),(0,v.jsxs)(`span`,{className:a(`shrink-0 tabular-nums`,n),children:[(0,v.jsx)(`span`,{className:a(o&&`yuri-todo-count-tick`),children:e},e),`/${t}`]})},ee=e=>{let t=(0,_.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=a(`flex size-[1.15em] shrink-0 items-center justify-center rounded-full bg-[var(--status-success)] text-[var(--status-success-foreground)]`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,v.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`size-[70%]`,children:(0,v.jsx)(`path`,{d:`M4.5 8.2 7 10.8 11.5 5.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),t[2]=i):i=t[2];let o;return t[3]===r?o=t[4]:(o=(0,v.jsx)(`span`,{"data-todo-complete":!0,className:r,children:i}),t[3]=r,t[4]=o),o},M=e=>{let t=(0,_.c)(27),{todos:n,isWorking:r,animate:i,className:o,rowClassName:c,listRef:l,id:u}=e,d=r!==void 0&&r,f=i!==void 0&&i,{t:p}=s(),m=n.findIndex(N),h;t[0]!==m||t[1]!==n?(h=m>=0?m:n.findIndex(P),t[0]=m,t[1]=n,t[2]=h):h=t[2];let g=h,b;t[3]===n?b=t[4]:(b=n.some(F),t[3]=n,t[4]=b);let S=b,w;t[5]===o?w=t[6]:(w=a(`m-0 flex min-w-0 list-none flex-col gap-[0.125em] p-0`,o),t[5]=o,t[6]=w);let T;if(t[7]!==g||t[8]!==f||t[9]!==S||t[10]!==d||t[11]!==c||t[12]!==p||t[13]!==n){let e;t[15]!==g||t[16]!==f||t[17]!==S||t[18]!==d||t[19]!==c||t[20]!==p?(e=(e,t)=>{let n=y(e.status),r=d&&!S&&t===g&&n===`pending`?`in_progress`:n;return(0,v.jsxs)(`li`,{"data-status":r,"aria-current":t===g?`step`:void 0,className:a(`grid min-w-0 shrink-0 grid-cols-[auto_minmax(0,1fr)] items-start py-[0.25em]`,c??`gap-[0.6em] px-[0.5em]`,f&&`yuri-todo-row-in`),children:[(0,v.jsx)(`span`,{className:a(`flex h-[1.32em] w-[1.15em] items-center justify-center`,f&&`yuri-todo-icon-pop`),title:p(x[r]),children:(0,v.jsx)(D,{status:r})},r),(0,v.jsx)(`span`,{dir:`auto`,title:e.content,className:a(`line-clamp-3 min-w-0 whitespace-normal text-[0.88em] break-words leading-[1.5] transition-colors duration-300`,C[r]),children:(0,v.jsx)(`span`,{className:a(r===`in_progress`&&`animate-text-shimmer`),children:e.content})})]},e.id??`${t}:${e.content}`)},t[15]=g,t[16]=f,t[17]=S,t[18]=d,t[19]=c,t[20]=p,t[21]=e):e=t[21],T=n.map(e),t[7]=g,t[8]=f,t[9]=S,t[10]=d,t[11]=c,t[12]=p,t[13]=n,t[14]=T}else T=t[14];let E;return t[22]!==u||t[23]!==l||t[24]!==w||t[25]!==T?(E=(0,v.jsx)(`ul`,{id:u,ref:l,className:w,children:T}),t[22]=u,t[23]=l,t[24]=w,t[25]=T,t[26]=E):E=t[26],E};function N(e){return e.status===`in_progress`}function P(e){return e.status===`pending`}function F(e){return e.status===`in_progress`}var I=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),L=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,R=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=L(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},z=e=>`<pre><code>${I(e)}</code></pre>`,B=e=>{let t=(0,_.c)(21),{code:n,language:r,className:i,style:o,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=g.useRef(null),m;t[0]===d?m=t[1]:(m=p(d),t[0]=d,t[1]=m);let y=m,b,x;t[2]!==n||t[3]!==s||t[4]!==u?(b=()=>{let e=f.current;e&&(e.innerHTML=z(n),R(e,u,s))},x=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=b,t[6]=x):(b=t[5],x=t[6]),g.useLayoutEffect(b,x);let S,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(S=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return h(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,R(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=S,t[12]=C):(S=t[11],C=t[12]),g.useEffect(S,C);let w;t[13]===i?w=t[14]:(w=a(`typography-code`,i),t[13]=i,t[14]=w);let T=y,E;t[15]!==o||t[16]!==T?(E={...T,...o},t[15]=o,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,v.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},V=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},H=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},U=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,W=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,G=(e,t)=>!e||typeof e!=`object`?String(e):f(e,t||``),K=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},q=e=>{if(!e||typeof e!=`object`)return;let t=K(e.patch)??K(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=K(e.patch)??K(e.diff);if(t)return t}},J=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},Y=(e,t,n)=>{let r=V(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&U(r)&&(r=W(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=q(n);if(e)return e}return r},X=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},Z=(e,t)=>{try{let n=e.trim().split(`
|
|
4
4
|
`).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,v.jsx)(`div`,{className:a(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,v.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,v.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,v.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Q={backgroundColor:`var(--status-info)`,opacity:.6},te=(e,t,n)=>{try{let i=e.trim().split(`
|
package/dist/index.html
CHANGED
|
@@ -571,7 +571,7 @@
|
|
|
571
571
|
opacity: 0.72;
|
|
572
572
|
}
|
|
573
573
|
</style>
|
|
574
|
-
<script type="module" crossorigin src="/assets/main-
|
|
574
|
+
<script type="module" crossorigin src="/assets/main-CeqfStCn.js"></script>
|
|
575
575
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
576
576
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-Bh3htXtG.js">
|
|
577
577
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-ibQIZnws.js">
|
|
@@ -600,11 +600,11 @@
|
|
|
600
600
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-BzeQds0D.js">
|
|
601
601
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BXf0a2VZ.js">
|
|
602
602
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-D4WGSMk-.js">
|
|
603
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
604
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
605
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
606
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
607
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
603
|
+
<link rel="modulepreload" crossorigin href="/assets/types-hxNDOWGs.js">
|
|
604
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-C1AUTwaK.js">
|
|
605
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-CGAqvpqz.js">
|
|
606
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-k2t218IT.js">
|
|
607
|
+
<link rel="stylesheet" crossorigin href="/assets/src-Bc4Nf__6.css">
|
|
608
608
|
</head>
|
|
609
609
|
<body class="h-full bg-background text-foreground">
|
|
610
610
|
<!-- Keep the startup layer outside #root. React replaces every child of
|
package/dist/mini-chat.html
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
.dark #initial-loading img { filter: invert(1); }
|
|
78
78
|
</style>
|
|
79
79
|
|
|
80
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
80
|
+
<script type="module" crossorigin src="/assets/miniChat-TSOpbP39.js"></script>
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-Bh3htXtG.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-ibQIZnws.js">
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-BzeQds0D.js">
|
|
107
107
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BXf0a2VZ.js">
|
|
108
108
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-D4WGSMk-.js">
|
|
109
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
110
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
111
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
112
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
113
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
109
|
+
<link rel="modulepreload" crossorigin href="/assets/types-hxNDOWGs.js">
|
|
110
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-C1AUTwaK.js">
|
|
111
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-CGAqvpqz.js">
|
|
112
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-k2t218IT.js">
|
|
113
|
+
<link rel="stylesheet" crossorigin href="/assets/src-Bc4Nf__6.css">
|
|
114
114
|
</head>
|
|
115
115
|
<body class="h-full bg-background text-foreground">
|
|
116
116
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
66
|
<style>.dark #mobile-startup-logo img { filter: invert(1); }</style>
|
|
67
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
67
|
+
<script type="module" crossorigin src="/assets/mobile-W2QaGheB.js"></script>
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-Bh3htXtG.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-ibQIZnws.js">
|
|
@@ -93,11 +93,11 @@
|
|
|
93
93
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-BzeQds0D.js">
|
|
94
94
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BXf0a2VZ.js">
|
|
95
95
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-D4WGSMk-.js">
|
|
96
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
97
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
98
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
99
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
100
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
96
|
+
<link rel="modulepreload" crossorigin href="/assets/types-hxNDOWGs.js">
|
|
97
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-C1AUTwaK.js">
|
|
98
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-CGAqvpqz.js">
|
|
99
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-k2t218IT.js">
|
|
100
|
+
<link rel="stylesheet" crossorigin href="/assets/src-Bc4Nf__6.css">
|
|
101
101
|
</head>
|
|
102
102
|
<body class="h-full bg-background text-foreground">
|
|
103
103
|
<div id="root" class="h-full">
|
package/package.json
CHANGED
|
@@ -23,6 +23,8 @@ unsupported; plugin markup, layout and behavior remain plugin-owned.
|
|
|
23
23
|
`references/icons.md` distinguishes the upstream generated `IconName` union from
|
|
24
24
|
Yuri's actual titlebar/sidebar renderer, lists their verified shared names and
|
|
25
25
|
aliases, and separates entry icons from Settings artwork, file icons and branding.
|
|
26
|
+
It documents Yuri's direct `TitlebarItem.icon` SVG/data-URI string extension,
|
|
27
|
+
static-SVG validation, image fallback, SDK typing and portability boundary.
|
|
26
28
|
It also documents same-document SVG symbol references, common sprite keys and the
|
|
27
29
|
current DOM/version boundary without exposing the React Icon component. Update its
|
|
28
30
|
shared-name list when the renderer or supported SDK catalog changes.
|
|
@@ -16,7 +16,7 @@ Use a standard OpenCode GUI plugin to change the running Yuri UI without modifyi
|
|
|
16
16
|
- Themes, CSS, logos, Dock icons: [appearance](references/appearance.md).
|
|
17
17
|
- Global main-content tabs and titlebar entries: [global pages](references/global-pages.md).
|
|
18
18
|
- Widgets under Changes in the conversation's status column: [work-status widgets](references/work-status.md).
|
|
19
|
-
- Entry/tab icons or icons inside plugin content: [icons](references/icons.md), including supported names, same-document SVG usage and artwork boundaries.
|
|
19
|
+
- Entry/tab icons or icons inside plugin content: [icons](references/icons.md), including direct SVG/data-URI icon strings, supported names, same-document SVG usage and artwork boundaries.
|
|
20
20
|
- Custom file suffixes, parsers, inline/mobile previews and file icons: [file previews](references/file-previews.md).
|
|
21
21
|
- Preview toolbar placement, PDF/PNG/HTML export and iframe snapshot boundaries: [preview actions and exports](references/preview-exports.md).
|
|
22
22
|
- Panels, commands, settings, files, RPC, lifecycle, runtime support: [GUI API](references/gui-api.md).
|
|
@@ -74,7 +74,7 @@ Those message names, header and navigation rules form Runmark's service protocol
|
|
|
74
74
|
|
|
75
75
|
## Entry icon versus content branding
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
Set `TitlebarItem.icon` directly to a built-in name, raw SVG or image data URI; [plugin entry icons](icons.md) documents Yuri's image-string extension, SDK typing, compatible names/aliases and fallback behavior. `yuri.page.icon` does not configure that entry. Top-level `package.json.icon` supplies artwork in Settings plugin details, not the global navigation entry. Application Logo/Dock branding uses `yuri.branding`; see [appearance](appearance.md).
|
|
78
78
|
|
|
79
79
|
## Verification
|
|
80
80
|
|
|
@@ -5,7 +5,7 @@ The supported contract is OpenCode GUI SDK **2.2.0**. Consult current official d
|
|
|
5
5
|
## Window APIs
|
|
6
6
|
|
|
7
7
|
- `Command`: command palette and plugin management execution; hidden commands can be called by `ctx.commands.run`. No GUI shortcut registration or slash autocomplete yet.
|
|
8
|
-
- `TitlebarItem`: global action/status, independent of a session; reactive label/title/icon/busy/pressed.
|
|
8
|
+
- `TitlebarItem`: global action/status, independent of a session; reactive label/title/icon/busy/pressed. Direct SVG/data-URI icon strings, built-in names and upstream/Yuri differences: [icons](icons.md).
|
|
9
9
|
- `Panel`: Solid `list/render`, reactive session/tab getters; file panels mount in existing file previews. An independent panel uses a dialog/mobile sheet, not upstream's full draggable workspace layout.
|
|
10
10
|
- `LinkHandler`: match, exists and open file/custom links. Use `ctx.links.open({ href, base, session })` for navigation. Preserve workspace-relative identity; never resolve against a different session's directory.
|
|
11
11
|
- `SettingsPage`: independent plugin settings pages; host `page/section` injection is unsupported.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Plugin icons
|
|
2
2
|
|
|
3
|
-
Use this reference when choosing an entry icon or rendering icons inside plugin-owned Solid/DOM content.
|
|
3
|
+
Use this reference when choosing an entry icon or rendering icons inside plugin-owned Solid/DOM content. Entry icons accept built-in names or self-contained image strings in Yuri. Package artwork, file icons and application branding are separate contracts. Use [plugin styles](plugin-styles.md) for the surrounding text and colors.
|
|
4
4
|
|
|
5
5
|
## Upstream contract
|
|
6
6
|
|
|
7
|
-
OpenCode's `TitlebarItem.icon` is an optional `IconName`, imported as a **type** from `@opencode/plugin/gui`.
|
|
7
|
+
OpenCode's `TitlebarItem.icon` is an optional `IconName`, imported as a **type** from `@opencode/plugin/gui`. Upstream defines it as a catalog name such as `globe`; Yuri additionally accepts image strings as documented below. The type is erased at runtime; it is not an exported array or an icon renderer.
|
|
8
8
|
|
|
9
9
|
Upstream generates the SDK union from the application's icon catalog:
|
|
10
10
|
|
|
@@ -15,6 +15,33 @@ Upstream generates the SDK union from the application's icon catalog:
|
|
|
15
15
|
|
|
16
16
|
Use the installed SDK's declaration for its exact version. The links above follow upstream development; a name accepted by a newer SDK is not proof that Yuri renders it.
|
|
17
17
|
|
|
18
|
+
## Custom entry images in Yuri
|
|
19
|
+
|
|
20
|
+
Pass the artwork directly as the existing `TitlebarItem.icon` string. No resource registration, extra field, file path or dependency is needed:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const { Plugin, TitlebarItem } = require('@opencode/plugin/gui')
|
|
24
|
+
|
|
25
|
+
const icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#6b83d6" d="M3 3h18v18H3z"/></svg>'
|
|
26
|
+
|
|
27
|
+
module.exports = Plugin.define({
|
|
28
|
+
setup(ctx) {
|
|
29
|
+
ctx.add(TitlebarItem, {
|
|
30
|
+
id: 'website', label: 'Studio', icon,
|
|
31
|
+
run: () => ctx.system.openExternal('https://example.com'),
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The same field also accepts an SVG data URI (`data:image/svg+xml,` with percent-encoded SVG, or `data:image/svg+xml;base64,...`) or a base64 image data URI for PNG, JPEG, GIF, WebP, AVIF or ICO. Include the `data:image/...;base64,` prefix; bare base64 is not an image declaration. HTTPS URLs and local file paths are not loaded.
|
|
38
|
+
|
|
39
|
+
Yuri validates raw SVG and SVG data URIs with the existing static-SVG rules: a complete `<svg xmlns="http://www.w3.org/2000/svg">` root, at most 16 KiB UTF-8; static geometry, groups, defs, gradients, clip paths, masks, local `#id` references and title/description. Scripts, event attributes, inline `style`, external references, foreign content, DTDs and processing instructions are rejected. All icon strings are bounded to 2 MiB characters. Invalid artwork affects only its icon, not the entry or other plugin contributions.
|
|
40
|
+
|
|
41
|
+
SVG is normalized to a data URI; all custom images render through `<img>`, never injected markup. Images retain their own colors; `currentColor` and host CSS variables do not inherit into the image document. Use explicit artwork colors, or a built-in name for host-colored line icons. The host fits images into the existing 16px sidebar / 14px compact icon slot.
|
|
42
|
+
|
|
43
|
+
This is a **Yuri extension**, not portable upstream `IconName` behavior. Direct CJS needs no type workaround. In TypeScript, use a narrow assertion on this field only, e.g. `icon: svg as TitlebarContribution['icon']` with `import type { TitlebarItem as TitlebarContribution } from '@opencode/plugin/gui'`. Keep the rest of the contribution checked by the SDK. For plugins targeting both hosts, use a shared catalog name instead.
|
|
44
|
+
|
|
18
45
|
## Names supported by both hosts
|
|
19
46
|
|
|
20
47
|
For a plugin targeting OpenCode and Yuri, choose from this verified intersection of the upstream SDK catalog and Yuri's current **TitlebarItem** renderer (including aliases):
|
|
@@ -54,11 +81,11 @@ module.exports = Plugin.define({
|
|
|
54
81
|
})
|
|
55
82
|
```
|
|
56
83
|
|
|
57
|
-
For typed reactive contributions, annotate the return type as in the [global-page example](global-pages.md); otherwise TypeScript can widen `icon` to `string`.
|
|
84
|
+
For typed reactive contributions using catalog names, annotate the return type as in the [global-page example](global-pages.md); otherwise TypeScript can widen `icon` to `string`.
|
|
58
85
|
|
|
59
86
|
## Yuri resolution and fallback
|
|
60
87
|
|
|
61
|
-
Yuri resolves `TitlebarItem.icon` through these aliases first, then an exact key in its own sprite:
|
|
88
|
+
For built-in names, Yuri resolves `TitlebarItem.icon` through these aliases first, then an exact key in its own sprite:
|
|
62
89
|
|
|
63
90
|
| SDK name | Yuri sprite key |
|
|
64
91
|
| --- | --- |
|
|
@@ -70,7 +97,7 @@ Yuri resolves `TitlebarItem.icon` through these aliases first, then an exact key
|
|
|
70
97
|
|
|
71
98
|
Yuri's sprite contains additional names, but those are not automatically valid upstream `IconName` values. Use the shared names above for portable SDK contributions rather than casting a Yuri-only name into the SDK type. For an unlisted name, check the installed SDK and target Yuri version before relying on it.
|
|
72
99
|
|
|
73
|
-
- Missing or
|
|
100
|
+
- Missing/unknown name, rejected image or image load failure: Yuri keeps the entry label. Sidebar placement reserves an empty icon slot; titlebar placement renders text instead of an icon. It does not substitute package artwork or the upstream default download arrow. A changed image string can render again after failure.
|
|
74
101
|
- `busy: true`: a loading spinner replaces the icon and disables an actionable entry.
|
|
75
102
|
- Valid icon: titlebar placement shows the icon with a hover label; sidebar placement shows icon and text. Host styles control size and color.
|
|
76
103
|
- Registering `yuri.page.icon` alone does not create or configure its navigation entry. Register `TitlebarItem` and set its `icon` separately, as in [global pages](global-pages.md).
|
|
@@ -121,14 +148,14 @@ These symbol IDs are current DOM implementation hooks, not an SDK icon-renderer
|
|
|
121
148
|
|
|
122
149
|
| Surface | Contract |
|
|
123
150
|
| --- | --- |
|
|
124
|
-
| Global plugin page/tab navigation entry | `TitlebarItem.icon`: supported catalog name |
|
|
151
|
+
| Global plugin page/tab navigation entry | `TitlebarItem.icon`: supported catalog name, raw SVG or image data URI |
|
|
125
152
|
| Plugin artwork in Settings plugin details | Top-level `package.json.icon`: validated image/data resource; not used by the global entry renderer |
|
|
126
153
|
| Custom file extension icon | `yuri.file-icon`: SVG resource; see [file previews](file-previews.md) |
|
|
127
154
|
| Application Logo / running macOS Dock icon | `yuri.branding`; see [appearance](appearance.md) |
|
|
128
155
|
| Artwork inside plugin-owned page content | Render it in the page's own Solid/DOM content |
|
|
129
156
|
|
|
130
|
-
|
|
157
|
+
Set entry artwork directly on `TitlebarItem.icon`; `package.json.icon` does not configure it. Remote image URLs and local paths are unsupported for this field.
|
|
131
158
|
|
|
132
159
|
## Verification
|
|
133
160
|
|
|
134
|
-
Check the actual entry in each target placement: selected artwork, visible/hover label, `busy` spinner, missing-name fallback, and withdrawal when the plugin is disabled. SDK typechecking alone does not prove Yuri runtime support.
|
|
161
|
+
Check the actual entry in each target placement: selected artwork, visible/hover label, `busy` spinner, missing-name/rejected-image/load-failure fallback, reactive image replacement, and withdrawal when the plugin is disabled. SDK typechecking alone does not prove Yuri runtime support.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./path-utils-HRmerlyU.js";import{C as t,D as n,I as r,L as i,M as a,O as o,P as s,S as c,T as l,_ as u,a as d,b as f,c as p,j as m,n as h,o as g,r as _,s as v,t as y,v as b,w as x,y as S}from"./vendor-opencode-client-cQ47ywrT.js";import{i as ee}from"./vendor-tanstack-query-core-Y_YoRHtC.js";import{n as te,r as ne}from"./fileQueries-BaEKb7SZ.js";import{a as re,n as ie}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as ae,n as oe}from"./platform-Dids8J9D.js";import{Dt as se,ht as ce,mt as le,y as ue}from"./vendor-effect-X1Hqc7ba.js";import{t as C}from"./native-errors-06if6eu-.js";import{a as de,i as w,n as T,o as E,r as fe}from"./appearance--vFosLNi.js";import{i as pe,o as me}from"./fileReferenceParser-BayaidRM.js";import{n as he,t as ge}from"./vendor-solid-js-D98iXT7C.js";import{a as _e,c as ve,d as ye,f as be,g as D,h as O,i as k,l as A,m as j,n as M,o as N,p as P,r as xe,s as Se,t as Ce,u as we}from"./vendor-opencode-plugin-BmdTE4Te.js";var F={"@opencode/plugin/gui":N,"@opencode/plugin/gui/main":N,"@opencode/plugin/gui/file":_e,"@opencode/plugin/gui/review":k,"@opencode/plugin/gui/browser":xe,"@opencode/plugin/rpc":Ce,"@opencode/schema/rpc":M,"@opencode/client":_,"@opencode/client/effect":h,"@opencode/client/solid":y,effect:ue,"solid-js":s,"solid-js/web":he,"solid-js/store":v},I=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function Te(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function Ee(e,t){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let n={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(F,e))return F[e];if(e===`electron`||e.startsWith(`node:`)||I.has(e))return Te();throw Error(`Unsupported GUI shared module: ${e}`)},n,n.exports);let r=n.exports,i=r&&typeof r==`object`&&`default`in r?r.default:r;if(!i||typeof i!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if((!(`setup`in i)||typeof i.setup!=`function`)&&!(t&&`main`in i&&typeof i.main==`function`))throw new C(`GUI_PLUGIN_UNSUPPORTED`,`This host requires a window setup; main-only plugins are unsupported`);if(`os`in i&&i.os!==void 0){if(!t)throw new C(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new C(`GUI_PLUGIN_UNSUPPORTED`,`GUI plugin is unavailable on this OS`)}if(`main`in i&&i.main!==void 0&&typeof i.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in i&&i.stores!==void 0){if(!i.stores||typeof i.stores!=`object`||Array.isArray(i.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(i.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!se(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in i&&i.i18n!==void 0){if(!i.i18n||typeof i.i18n!=`object`||Array.isArray(i.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(i.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return i}function L(e){let t=e;if(/^file:/i.test(t)){let e=new URL(t);t=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(t)&&(t=t.slice(1))}let n=ae(t)??``;return n===`.`?``:n}var R=e=>/^(?:\/|[a-z]:\/)/i.test(e),z=()=>{throw Error(`Unsupported GUI file API: tree`)},B=class extends Error{},V=e=>new TextEncoder().encode(e).byteLength,De=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,n,r){this.files=e,this.query=t,this.transport=n,this.root=r,this.root=L(r),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:R,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let n=o();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(o(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&L(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let r=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,n,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return r.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:z,state:z,sync:z,expand:z,collapse:z}}}resolve(e){let t=L(e);if(!R(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return R(t)?t:L(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ne(this.files,this.input(e),this.transport),gcTime:3e4}}track(e,t){let r=this.resolve(e),i=n();if(!i||this.ended)return r;let o=`${t}:${r}`,s=this.subscriptions.get(o);s||(s={revision:l(0),listeners:new Set},this.subscriptions.set(o,s));let c=s;return c.listeners.has(i)||(c.listeners.add(i),a(i,()=>m(()=>{c.listeners.delete(i),!c.listeners.size&&this.subscriptions.get(o)===c&&this.subscriptions.delete(o)}))),c.revision[0](),r}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),u(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=o();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let n=this.resolve(e),r=this.apiLeases.get(t);if(r?.has(n))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let i=this.watch(n);r||(r=new Map,this.apiLeases.set(t,r)),r.set(n,i),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),m(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),u(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=te(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new B(`File does not exist`);let t=e.content;if(V(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(V(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof B?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new ee(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()},this.states.get(t)?.loaded&&this.sync(t,!0).catch(()=>{})}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},H=256,U=2097152,W=e=>structuredClone(p(e)),Oe=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,t){let n=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},r=e=>{if(t.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},i=new Map;return{store:(e,a)=>{r(a.from);let o=n(e,a.scope),s=i.get(o);if(s)return s;if(i.size>=H)throw Error(`GUI plugin store limit exceeded`);let c=le(a.schema),u=ce(a.schema),d=c(u(W(a.initial)));if(JSON.stringify(u(d)).length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(o);if(p!==null&&p.length<=U)try{f=c(JSON.parse(p))}catch{f=d}let[m,h]=l(f),g=e=>{r();let t=JSON.stringify(u(W(e)));if(t.length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let n=c(JSON.parse(t));this.backend.setItem(o,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=W(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>W(d)),y=this.resets.get(o)??new Set;return y.add(v),this.resets.set(o,y),t.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(o),i.clear()},{once:!0}),i.set(o,_),_},memory:(e,t)=>{r();let i=n(e),a=this.memory.get(i);if(a)return[a[0],e=>{r(),a[1](e)}];if(this.memory.size>=H)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=d(W(t.initial)),c=[o,e=>{r();let t=W(p(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(g(t))}];return this.memory.set(i,[o,e=>{let t=W(p(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(g(t))}]),c},remove:(e,t)=>{r(t?.from);let i=n(e,t?.scope);this.backend.removeItem(i);for(let e of this.resets.get(i)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}},G=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,ke=class{api;probe;clients=new Map;ended=!1;constructor(e){this.api=e}use(e,t){let n=this.clients.get(t),r=n?.get(e);if(r)return r.live;let[i,a]=l(this.api&&!t.aborted&&!this.ended?{status:`pending`}:{status:`inactive`,reason:`disabled`}),o=()=>{a({status:`inactive`,reason:`disabled`}),t.removeEventListener(`abort`,o),this.clients.delete(t)},s={live:D(i),stop:o};if(this.ended||t.aborted||(n||(n=new Map,this.clients.set(t,n)),n.set(e,s),t.addEventListener(`abort`,o,{once:!0}),!this.api))return s.live;let c=this.api;return this.probe??=Promise.resolve().then(()=>c.capabilities()),this.probe.then(n=>{if(this.ended||t.aborted)return;let r=e===`yuri.exportPDF`?`exportPDF`:`exportLongImage`;if(n.version!==1||!n[r]){a({status:`inactive`,reason:`disabled`});return}let o=async(e,n={})=>{if(this.ended||t.aborted||i().status!==`active`)return{status:`cancelled`};let o=AbortSignal.any([t,...n.signal?[n.signal]:[]]);try{return await c[r](e,{...n,signal:o})}catch(e){throw e&&typeof e==`object`&&`code`in e&&e.code===`EXPORT_UNSUPPORTED`&&a({status:`inactive`,reason:`failed`}),e}},s=Object.freeze(e===`yuri.exportPDF`?{version:1,limits:n.limits,exportPDF:o}:{version:1,limits:n.limits,exportLongImage:o});a({status:`active`,generation:1,value:s})}).catch(()=>{!this.ended&&!t.aborted&&a({status:`inactive`,reason:`failed`})}),s.live}dispose(){this.ended=!0;for(let e of this.clients.values())for(let t of e.values())t.stop();this.clients.clear()}};function Ae(e,t){let n=new Map,r=Object.freeze({dismiss(){}});return e.addEventListener(`abort`,()=>{for(let e of[...n.values()])e.handle.dismiss()},{once:!0}),Object.freeze({show(i){if(e.aborted)return r;if(!t)throw new C(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new C(`GUI_PLUGIN_INVALID_INPUT`,`Expected toast options`);let{title:a,description:o,variant:s=`default`,duration:c=5e3,persistent:l=!1,icon:u,actions:d}=i;if(typeof a!=`string`||o!==void 0&&typeof o!=`string`||![`default`,`success`,`error`,`loading`].includes(s)||typeof l!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0)throw new C(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new C(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast icon/actions are unsupported`);if(e.aborted)return r;let f=JSON.stringify([a,o??null,s,c,l]),p=n.get(f),m=()=>{let e=n.get(f);!e||e.id!==h||(clearTimeout(e.timer),n.delete(f))},h=(s==="default"?t:t[s])(a,{id:p?.id,description:o,duration:l?1/0:c,onDismiss:m,onAutoClose:m}),g=p?.handle??Object.freeze({dismiss(){m(),t.dismiss(h)}});clearTimeout(p?.timer);let _=s===`loading`&&!l?setTimeout(()=>g.dismiss(),c):void 0;return n.set(f,{id:h,handle:g,timer:_}),g}})}var je=re(`YuriMedia`);async function Me(e){let t=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,n=new Blob([e.content],{type:t});if(oe()){if(!ie.isPluginAvailable(`YuriMedia`))throw new C(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(n.size>33554432)throw new C(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let r=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result!=`string`){t(Error(`Failed to encode file`));return}e(r.result.slice(r.result.indexOf(`,`)+1))},r.onerror=()=>t(r.error??Error(`Failed to encode file`)),r.readAsDataURL(n)});return!(await je.saveFile({dataBase64:r,mimeType:t,filename:e.name})).cancelled}let r=URL.createObjectURL(n),i=document.createElement(`a`);try{return i.href=r,i.download=e.name,document.body.append(i),i.click(),!0}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}}var K=f();function Ne(e){return{version:1,register(t){let n=i(K);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let r=new AbortController,a=AbortSignal.any([e,n.signal,r.signal]),o,s=()=>{a.removeEventListener(`abort`,s),r.abort(),o?.remove()};m(s),a.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:a,async snapshot(e={}){let r=AbortSignal.any([a,...e.signal?[e.signal]:[]]);if(r.throwIfAborted(),!n.content.contains(t.element)||n.target.contains(t.element))throw Error(`Preview capture region is no longer in its owning panel`);let i=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return i}}),a.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}function q(e,t){return JSON.stringify([e,t])}function Pe(e){if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||!(`title`in e)||typeof e.title!=`string`||!(`render`in e)||typeof e.render!=`function`)throw Error(`Invalid yuri.page contribution`);return e}var Fe=`yuri.work-status`;function J(e,t){return e===t||!!(e&&t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>e[n]===t[n]))}var Y=e=>e&&Object.freeze({...e});function Ie(e,t,n){let r=new AbortController,[i,a]=l(!0),[o,s]=l(Y(e.project),{equals:J}),[c,d]=l(Y(e.worktree),{equals:J}),[f,p]=l(Object.freeze({...e.git}),{equals:J}),[m,h]=l(e.placement);return{props:Object.freeze({session:t,directory:e.directory,runtimeId:n,signal:r.signal,get active(){return i()},get project(){return o()},get worktree(){return c()},get git(){return f()},get placement(){return m()}}),matches:t=>t.sessionId===e.sessionId&&t.directory===e.directory,update(e){r.signal.aborted||u(()=>{s(Y(e.project)),d(Y(e.worktree)),p(Object.freeze({...e.git})),h(e.placement)})},dispose(){r.signal.aborted||(a(!1),r.abort())}}}var Le=class{plugins=new Map;order=new Map;snapshot=Object.freeze([]);generation=0;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.size&&e.every((e,t)=>this.order.get(e)===t)||(this.order=new Map(e.map((e,t)=>[e,t])),this.publish())}replace(e,t,n){let r=this.plugins.get(e)??[],i=new Set,a=n.map(n=>{if(!n||typeof n!=`object`||!(`id`in n)||typeof n.id!=`string`||!n.id.trim()||n.id.length>128||i.has(n.id)||!(`render`in n)||typeof n.render!=`function`||`order`in n&&n.order!==void 0&&(typeof n.order!=`number`||!Number.isFinite(n.order)))throw Error(`Invalid or duplicate yuri.work-status contribution`);i.add(n.id);let a=JSON.stringify([e,n.id]),o=`order`in n&&typeof n.order==`number`?n.order:0,s=n.render,c=r.find(e=>e.key===a),l=c&&c.revision===t&&c.render===s?c.generation:++this.generation;return c&&c.revision===t&&c.render===s&&c.order===o?c:Object.freeze({key:a,pluginId:e,revision:t,generation:l,order:o,render:s})});a.length?this.plugins.set(e,a):this.plugins.delete(e),this.publish()}contains(e){return this.plugins.get(e.pluginId)?.some(t=>t.key===e.key&&t.generation===e.generation)??!1}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=[...this.plugins.values()].flat().sort((e,t)=>e.order-t.order||(this.order.get(e.pluginId)??2**53-1)-(this.order.get(t.pluginId)??2**53-1));if(!(e.length===this.snapshot.length&&e.every((e,t)=>e===this.snapshot[t]))){this.snapshot=Object.freeze(e);for(let e of this.listeners)r(e)}}},X=e=>{throw new C(`GUI_PLUGIN_UNSUPPORTED`,`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function Re(e,t){if(!e.fields||!t.fields)return!1;let n=Reflect.ownKeys(e.fields);return n.length===Reflect.ownKeys(t.fields).length&&n.every(n=>{let r=e.fields[n],i=t.fields[n];return i!==void 0&&`value`in r&&`value`in i&&Object.is(r.value,i.value)&&r.enumerable===i.enumerable&&r.configurable===i.configurable&&r.writable===i.writable})}function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var ze=class{options;fileIcons=new E;appearanceCatalog=new w;workStatus=new Le;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=l(0);views=l(0);session=l();currentPage=l();appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),titlebarItems:Object.freeze([]),panels:Object.freeze([]),pages:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});#e;viewExports;constructor(e){this.options=e,this.viewExports=new ke(e.viewExport),this.appearance=l({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new Oe(e.storage,e.transport);let t=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.#e=Z(`screen`,{get file(){return t()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(e=!1){let t=this.snapshot;this.changes[1](e=>e+1),e&&t===this.snapshot&&this.publish()}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new De(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=e?this.sessionReference(e):void 0,r=this.snapshot;this.session[1](n),r===this.snapshot&&this.publish()}sessionReference(e){let t=Z(`session.server`,{id:this.options.transport,name:this.options.transport,client:this.options.client});return Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:`${this.options.transport}\n${e.id}`,tab:e.id,server:t,pending:!1,visit:{},location:{directory:e.directory}}))}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}setPage(e){this.ended||this.currentPage[1](e)}install(e,n,i){let s=this.instances.get(e);if(this.ended||s?.status===`active`&&s.revision===n.revision&&s.native?.active!==!1){i?.dispose();return}s&&(this.instances.delete(e),this.release(s));let c={id:e,native:i,revision:n.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:l(0),appearanceChanges:l(0),workStatusChanges:l(0),commands:[],titlebarItems:[],panels:[],pages:[],settings:[],menus:[]};this.instances.set(e,c);try{if(e===`yuri`||e.startsWith(`yuri.`))throw Error(`The yuri namespace is reserved to the host`);let s=Ee(n.code,i?.activation.os);x(e=>{c.dispose=e,c.root=o(),b(()=>S(O.Provider,{value:c.context=this.context(c,s,n.options),get children(){c.owner=o();let e=r(()=>s.setup?.(c.context));if(typeof e==`function`)c.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{c.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(c,e)),c.controller.signal.aborted||a(c.owner,()=>t(()=>{if(c.iconChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===de).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(c.id,e),c.iconError!==void 0&&r(()=>{c.iconError=void 0,this.publish()})}catch(e){r(()=>{this.fileIcons.remove(c.id),c.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),c.controller.signal.aborted||a(c.owner,()=>t(()=>{if(c.appearanceChanges[0](),!c.controller.signal.aborted)try{let e=e=>[...c.contributions].filter(t=>t.registry===e).map(e=>e.read()).filter(e=>e!==void 0);this.appearanceCatalog.replace(c.id,e(fe),e(T),c.native?.activation.capabilities?.dockIcon===!0)}catch(e){r(()=>this.fail(c,e))}})),c.controller.signal.aborted||a(c.owner,()=>t(()=>{if(c.workStatusChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===Fe).map(e=>e.read()).filter(e=>e!==void 0);this.workStatus.replace(c.id,c.revision,e)}catch(e){r(()=>this.fail(c,e))}})),c.controller.signal.aborted||a(c.owner,()=>t(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(c)}catch(e){r(()=>this.fail(c,e))}r(()=>this.publish())}))})}catch(e){this.fail(c,e)}this.changed(!0)}release(e){e.controller.abort(),e.native?.dispose();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.titlebarItems=[],e.panels=[],e.pages=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id),this.appearanceCatalog.remove(e.id),this.workStatus.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),t instanceof C&&(e.errorCode=t.code),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(!0)}}dispose(){this.ended||(this.ended=!0,u(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.viewExports.dispose(),this.files?.dispose(),this.fileIcons.dispose(),this.appearanceCatalog.dispose(),this.workStatus.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}async setDockIcon(e,t){let n=this.instances.get(e),r=n?.native;if(!r?.active||!r.activation.capabilities?.dockIcon)return X(`Dock icon`);try{await r.setDockIcon(t)}catch(e){throw t!==null&&n&&this.fail(n,e),e}}own(e,t){let n=!0,r=()=>{n&&(n=!1,e.cleanups.delete(r),t())};return e.controller.signal.aborted||i(P)?.ended?(r(),r):(e.cleanups.add(r),o()&&m(r),r)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(e,n,a){let s=this.storage.forPlugin(e.id,e.controller.signal),l=Object.fromEntries(Object.entries(n.stores??{}).map(([e,t])=>[e,t.scope===`global`?s.store(e,{...t,scope:`global`}):n=>s.store(e,{...t,scope:{session:n}})])),u=(e,t)=>{let r=this.appearance[0]().locale;return(n.i18n?.[r]?.[e]??n.i18n?.[r.split(`-`)[0]]?.[e]??n.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t?.[n]??e))},d=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(t,n,r)=>{e.controller.signal.aborted||this.openPanel(t,n,r)},close:(t,n)=>{e.controller.signal.aborted||this.closeFor(t,n)},toggle:(e,t)=>d.state(e,t)===`visible`?d.close(e,t):d.open(e,t),hide:(t,n)=>{if(e.controller.signal.aborted)return;let r=this.layout(n);r.active===t&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:t=>(this.changes[0](),this.layout(t).open.filter(t=>t.startsWith(`${e.id}:`)).map(t=>t.slice(e.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:t=>{if(e.controller.signal.aborted)return;let n=this.layout(t);n.shown=!n.shown,this.changed()},menu:()=>this.list(A).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(t,n,r)=>{if(e.controller.signal.aborted)return;let i=this.layout(t).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}}),f=Ne(e.controller.signal),p=D(()=>e.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),h={open:t=>e.controller.signal.aborted||this.appearance[0]().narrow||!e.pages.some(e=>e.id===t)?!1:this.options.openPage?.(q(e.id,t))??!1,current:()=>{let t=this.currentPage[0]();return e.pages.find(n=>q(e.id,n.id)===t)?.id}},g=D(()=>e.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:h});return Z(`ctx`,{id:e.id,options:a,signal:e.controller.signal,client:this.options.client,storage:s,stores:l,toast:Ae(e.controller.signal,this.options.toast),app:{name:`yuri`,version:e.native?.activation.app.version??``,channel:e.native?.activation.app.packaged?`prod`:`local`,platform:e.native?`desktop`:`web`,packaged:e.native?.activation.app.packaged??!1},desktop:e.native?Z(`desktop`,{os:e.native.activation.os}):void 0,t:u,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return u(r,{...n,count:t})===r?u(`${e}.other`,{...n,count:t}):u(r,{...n,count:t})},add:(n,a)=>{if(e.controller.signal.aborted||i(P)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(n.id)&&X(`registry.${n.id}`),e.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let s=()=>{},l,u=x(r=>{s=r,l=o();let i=()=>typeof a==`function`?a():a,u;if(n.id===`yuri.file-icon`){let e=c(()=>{try{return{ok:!0,value:i()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=c(i);if(n.id===`style`){let n=document.createElement(`style`);n.dataset.yuriPluginStyle=e.id,document.head.append(n),m(()=>n.remove()),t(()=>{let e=u();n.textContent=e===void 0?``:String(e)})}return{registry:n.id,read:u}},o()??e.owner);e.contributions.add(u);let d=()=>{n.id===`yuri.file-icon`&&e.iconChanges[1](e=>e+1)},f=()=>{(n.id===`yuri.theme`||n.id===`yuri.branding`)&&e.appearanceChanges[1](e=>e+1)},p=()=>{n.id===`yuri.work-status`&&e.workStatusChanges[1](e=>e+1)};return r(d),r(f),r(p),r(()=>this.changed()),this.own(e,()=>{$(l,t=>{e.error??=String(t)}),s(),e.contributions.delete(u),r(d),r(f),r(p),r(()=>this.changed())})},list:e=>this.list(e),provide:(t,n)=>{if(e.controller.signal.aborted||i(P)?.ended)return()=>{};if(G(t.id)||t.id===`yuri.previewActions`||t.id===`yuri.pages`)throw Error(`Preview/export/page contracts are provided only by the Yuri host`);if(t.kind!==`contract`||!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`Contract must belong to the providing plugin`);let r=this.contract(t.id);if(r.provider)throw Error(`Contract already provided: ${t.id}`);return r.provider=e,r.live[1]({status:`active`,value:n,generation:++r.generation}),this.own(e,()=>{r.provider===e&&(r.provider=void 0,r.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))})},use:t=>t.id===`yuri.pages`?t.kind===`contract`?g:X(`pages token must be a Contract`):t.id===`yuri.previewActions`?t.kind===`contract`?p:X(`preview actions token must be a Contract`):G(t.id)?t.kind===`contract`?this.viewExports.use(t.id,e.controller.signal):X(`export token must be a Contract`):t.kind===`ipc`&&e.native?e.native.token(t).live:this.contract(t.id,t.kind===`ipc`).live[0],main:t=>{if(!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw new C(`GUI_PLUGIN_FORBIDDEN`,`IPC must belong to the plugin`);return e.native?e.native.token(t).value:new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>{throw new C(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new C(`GUI_PLUGIN_UNSUPPORTED`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.#e:void 0},layout:d,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:Me},commands:{run:t=>e.controller.signal.aborted||!this.command(t)?!1:(this.runCommand(t),!0)},links:{open:t=>!e.controller.signal.aborted&&this.navigateLink(e,t),exists:t=>r(()=>{if(e.controller.signal.aborted)return!1;let n=this.linkHandler(t);try{return Promise.resolve(n?.value.exists?.(t)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,t=!1){let n=this.contracts.get(e);if(!n){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let t=l({status:`inactive`,reason:`disabled`});n={live:[D(t[0]),t[1]],generation:0},this.contracts.set(e,n)}return t&&n.provider&&X(`IPC contract collision`),n}derive(e){if(e.status!==`active`)return;let t=[],n=[],i=[],a=[],o=[],s=[],c=this.session[0]();for(let r of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`,`yuri.work-status`].includes(r.registry))continue;let l=r.read();if(l!==void 0){if(r.registry===`yuri.page`){let e=Pe(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(r.registry===Se.id){let n=l;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,pluginId:e.id,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(r.registry===be.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:t.icon,busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(r.registry===we.id&&c){let t=l,r=`${e.id}:`,i=this.layout(c).open.filter(e=>e.startsWith(r)).map(e=>e.slice(r.length));for(let r of t.list({session:c,screen:this.#e,open:i}))n.push({plugin:e,panel:t,tab:r})}else if(r.registry===ye.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,i.push(e)}else if(r.registry===A.id){let e=l;e.menu===`session.panel`?(e.title,a.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of n)e.tab.title;e.commands=t,e.titlebarItems=o,e.panels=n,e.pages=s,e.settings=i,e.menus=a,r(()=>this.views[1](e=>e+1))}publish(){let e=r(this.session[0]),t=e?this.layouts.get(e.key):void 0,n=[...this.instances.values()],i=n.filter(e=>e.status===`active`),a=i.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(n.map(({id:e,revision:t,status:n,error:r,errorCode:i,iconError:a})=>({id:e,revision:t,status:n,error:r??a,...i?{errorCode:i}:{}}))),commands:Q(i.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(i.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(i.flatMap(e=>e.pages.map(t=>({key:q(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(i.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(i.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&a.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(e,t){if(!e.controller.signal.aborted)try{let n=a(e.owner??null,t);if(n instanceof Promise)return n.catch(t=>this.fail(e,t))}catch(t){this.fail(e,t)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}runTitlebarItem(e){for(let t of this.instances.values()){let n=t.titlebarItems.find(t=>t.key===e);if(n?.run&&!n.busy)return this.invoke(t,n.run)}}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ve.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(t,n){if(this.ended)return!1;let r=me(n.href);if(!r||!pe(r.path))return this.openLink(n);let i=this.session[0]();if(!i||n.session&&(n.session.key!==i.key||n.session.server.id!==i.server.id))return!1;if(!this.options.focusFile)return this.openLink(n);let a=e(n.base??i.directory,r.path),o=r.line===void 0?``:`:${r.line}${r.column===void 0?``:`:${r.column}`}`;return this.invoke(t,()=>this.options.focusFile(a+o,i.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=L(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:L(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&this.changed(!0);let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(!0)}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&this.changed(!0);let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.#e}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(!0),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(!0))}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e,t=!1){let n=this.panel(e)?.tab,r=()=>(this.views[0](),this.panel(e)?.tab??n??X(`panel no longer listed`)),i=t?c(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Re}):void 0,a=i?()=>i().tab:r,o=()=>this.session[0]()??X(`panel without session`);return{get tab(){return a()},get session(){return o()},screen:this.#e}}mountPanel(e,n,i){let a=this.panel(e);if(!a)return()=>{};let o=new AbortController,s=()=>{let s=c(()=>{this.session[0](),this.changes[0](),this.views[0]();let t=this.panel(e)?.tab.file;return t&&this.files&&this.panelVisible(e)?{model:this.files,file:t}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});t(()=>{let e=s();e&&(m(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let l=()=>r(()=>a.panel.render(this.props(e,!0)));return S(K.Provider,{value:i?{plugin:a.plugin.controller.signal,signal:o.signal,content:n,target:i}:void 0,get children(){return l()}})},l=this.mount(a.plugin,n,()=>S(j.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(e)),present:()=>(this.changes[0](),this.panelVisible(e)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?a.plugin.context.layout.stored(e):[]}},get children(){return s()}})),u=()=>{this.panelMounts.delete(u),o.abort(),l()};return this.panelMounts.add(u),this.own(a.plugin,u)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mountPage(e,t){if(this.appearance[0]().narrow)return()=>{};for(let n of this.instances.values()){let r=n.pages.find(t=>q(n.id,t.id)===e);if(r)return this.mount(n,t,()=>r.render())}return()=>{}}mountWorkStatus(e,t,n){let r=this.instances.get(e.pluginId);if(!r||!this.workStatus.contains(e)||this.ended)return{update(){},dispose(){}};let i=Ie(n,n.sessionId&&n.directory?this.sessionReference({id:n.sessionId,directory:n.directory}):void 0,this.options.transport),a=()=>{},o=()=>{},s=this.own(r,()=>{i.dispose(),o(),a()});return o=this.workStatus.subscribe(()=>{this.workStatus.contains(e)||s()}),a=this.mount(r,t,()=>e.render(i.props)),i.props.signal.aborted&&(o(),a()),{update:e=>{if(!i.matches(e)){s();return}i.update(e)},dispose:s}}mount(e,t,n){if(e.controller.signal.aborted)return()=>{};let i=()=>{},a,s=t=>{queueMicrotask(()=>this.fail(e,t))};try{i=ge(()=>S(O.Provider,{value:e.context,get children(){return a=o(),b(()=>r(n),s)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(a,t=>{e.error??=String(t)}),i(),t.replaceChildren()})}};export{ze as GuiPluginHost};
|